// SPDX-License-Identifier: GPL-2.0-only /* * Generic GPIO card-detect helper * * Copyright (C) 2011, Guennadi Liakhovetski <[email protected]> */ #include <linux/err.h> #include <linux/gpio/consumer.h> #include <linux/interrupt.h> #include <linux/jiffies.h> #include <linux/mmc/host.h> #include <linux/mmc/slot-gpio.h> #include <linux/module.h> #include <linux/slab.h> #include "slot-gpio.h" struct mmc_gpio { … }; static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) { … } int mmc_gpio_alloc(struct mmc_host *host) { … } void mmc_gpio_set_cd_irq(struct mmc_host *host, int irq) { … } EXPORT_SYMBOL(…); int mmc_gpio_get_ro(struct mmc_host *host) { … } EXPORT_SYMBOL(…); int mmc_gpio_get_cd(struct mmc_host *host) { … } EXPORT_SYMBOL(…); void mmc_gpiod_request_cd_irq(struct mmc_host *host) { … } EXPORT_SYMBOL(…); int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on) { … } EXPORT_SYMBOL(…); /* Register an alternate interrupt service routine for * the card-detect GPIO. */ void mmc_gpio_set_cd_isr(struct mmc_host *host, irq_handler_t isr) { … } EXPORT_SYMBOL(…); /** * mmc_gpiod_request_cd - request a gpio descriptor for card-detection * @host: mmc host * @con_id: function within the GPIO consumer * @idx: index of the GPIO to obtain in the consumer * @override_active_level: ignore %GPIO_ACTIVE_LOW flag * @debounce: debounce time in microseconds * * Note that this must be called prior to mmc_add_host() * otherwise the caller must also call mmc_gpiod_request_cd_irq(). * * Returns zero on success, else an error. */ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, unsigned int idx, bool override_active_level, unsigned int debounce) { … } EXPORT_SYMBOL(…); /** * mmc_gpiod_set_cd_config - set config for card-detection GPIO * @host: mmc host * @config: Generic pinconf config (from pinconf_to_config_packed()) * * This can be used by mmc host drivers to fixup a card-detection GPIO's config * (e.g. set PIN_CONFIG_BIAS_PULL_UP) after acquiring the GPIO descriptor * through mmc_gpiod_request_cd(). * * Returns: * 0 on success, or a negative errno value on error. */ int mmc_gpiod_set_cd_config(struct mmc_host *host, unsigned long config) { … } EXPORT_SYMBOL(…); bool mmc_can_gpio_cd(struct mmc_host *host) { … } EXPORT_SYMBOL(…); /** * mmc_gpiod_request_ro - request a gpio descriptor for write protection * @host: mmc host * @con_id: function within the GPIO consumer * @idx: index of the GPIO to obtain in the consumer * @debounce: debounce time in microseconds * * Returns zero on success, else an error. */ int mmc_gpiod_request_ro(struct mmc_host *host, const char *con_id, unsigned int idx, unsigned int debounce) { … } EXPORT_SYMBOL(…); bool mmc_can_gpio_ro(struct mmc_host *host) { … } EXPORT_SYMBOL(…);