[PATCH 1/2] mmc: core: support platform interrupt as card detect interrupt

Heiner Kallweit hkallweit1 at gmail.com
Mon Feb 13 23:45:30 PST 2023


On 13.02.2023 23:46, Ulf Hansson wrote:
> On Mon, 30 Jan 2023 at 00:10, Heiner Kallweit <hkallweit1 at gmail.com> wrote:
>>
>> On certain platforms like Amlogic Meson gpiod_to_irq() isn't supported
>> due to the design of gpio / interrupt controller. Therefore provide an
>> option to specify the cd interrupt e.g. by device tree. The host
>> controller can store the interrupt in cd_irq for use by
>> mmc_gpiod_request_cd_irq().
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1 at gmail.com>
>> ---
>>  drivers/mmc/core/slot-gpio.c | 2 +-
>>  include/linux/mmc/host.h     | 1 +
>>  2 files changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
>> index dd2a4b6ab..69c22a997 100644
>> --- a/drivers/mmc/core/slot-gpio.c
>> +++ b/drivers/mmc/core/slot-gpio.c
>> @@ -99,7 +99,7 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host)
>>          * IRQ number is already used by another unit and cannot be shared.
>>          */
>>         if (!(host->caps & MMC_CAP_NEEDS_POLL))
>> -               irq = gpiod_to_irq(ctx->cd_gpio);
>> +               irq = host->cd_irq > 0 ? host->cd_irq : gpiod_to_irq(ctx->cd_gpio);
>>
>>         if (irq >= 0) {
>>                 if (!ctx->cd_gpio_isr)
>> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
>> index 8fdd3cf97..e998e919e 100644
>> --- a/include/linux/mmc/host.h
>> +++ b/include/linux/mmc/host.h
>> @@ -470,6 +470,7 @@ struct mmc_host {
>>
>>         struct delayed_work     detect;
>>         int                     detect_change;  /* card detect flag */
>> +       int                     cd_irq;         /* for use by mmc_gpiod_request_cd_irq */
> 
> Rather than putting this in the struct mmc_host, I would prefer to
> keep it more internal to the mmc core/slot code.
> 
> That said, what do you think of moving this into the struct mmc_gpio
> instead? Of course, that also means that we need to add new slot gpio
> helper that users can call to set the corresponding value for the
> cd_irq.
> 
> Would that be okay to you?
> 
Yes, that's the better approach.

>>         struct mmc_slot         slot;
>>
>>         const struct mmc_bus_ops *bus_ops;      /* current bus driver */
> 
> Kind regards
> Uffe




More information about the linux-arm-kernel mailing list