Skip to content

Commit 63a7cd6

Browse files
jwrdegoedestorulf
authored andcommitted
mmc: core: Add mmc_gpiod_set_cd_config() function
Some mmc host drivers may need to fixup a card-detection GPIO's config to e.g. enable the GPIO controllers builtin pull-up resistor on devices where the firmware description of the GPIO is broken (e.g. GpioInt with PullNone instead of PullUp in ACPI DSDT). Since this is the exception rather then the rule adding a config parameter to mmc_gpiod_request_cd() seems undesirable, so instead add a new mmc_gpiod_set_cd_config() function. This is simply a wrapper to call gpiod_set_config() on the card-detect GPIO acquired through mmc_gpiod_request_cd(). Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent f16d1b8 commit 63a7cd6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

drivers/mmc/core/slot-gpio.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,26 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id,
221221
}
222222
EXPORT_SYMBOL(mmc_gpiod_request_cd);
223223

224+
/**
225+
* mmc_gpiod_set_cd_config - set config for card-detection GPIO
226+
* @host: mmc host
227+
* @config: Generic pinconf config (from pinconf_to_config_packed())
228+
*
229+
* This can be used by mmc host drivers to fixup a card-detection GPIO's config
230+
* (e.g. set PIN_CONFIG_BIAS_PULL_UP) after acquiring the GPIO descriptor
231+
* through mmc_gpiod_request_cd().
232+
*
233+
* Returns:
234+
* 0 on success, or a negative errno value on error.
235+
*/
236+
int mmc_gpiod_set_cd_config(struct mmc_host *host, unsigned long config)
237+
{
238+
struct mmc_gpio *ctx = host->slot.handler_priv;
239+
240+
return gpiod_set_config(ctx->cd_gpio, config);
241+
}
242+
EXPORT_SYMBOL(mmc_gpiod_set_cd_config);
243+
224244
bool mmc_can_gpio_cd(struct mmc_host *host)
225245
{
226246
struct mmc_gpio *ctx = host->slot.handler_priv;

include/linux/mmc/slot-gpio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id,
2121
unsigned int debounce);
2222
int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id,
2323
unsigned int idx, unsigned int debounce);
24+
int mmc_gpiod_set_cd_config(struct mmc_host *host, unsigned long config);
2425
void mmc_gpio_set_cd_isr(struct mmc_host *host,
2526
irqreturn_t (*isr)(int irq, void *dev_id));
2627
int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on);

0 commit comments

Comments
 (0)