mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-19 18:24:14 +08:00
510965dd4a
cycle: - A new GPIO hogging mechanism has been added. This can be used on boards that want to drive some GPIO line high, low, or set it as input on boot and then never touch it again. For some embedded systems this is bliss and simplifies things to a great extent. - Some API cleanup and closure: gpiod_get_array() and gpiod_put_array() has been added to get and put GPIOs in bulk as was possible with the non-descriptor API. - Encapsulate cross-calls to the pin control subsystem in <linux/gpio/driver.h>. Now this should be the only header any GPIO driver needs to include or something is wrong. Cleanups restricting drivers to this include are welcomed if tested. - Sort the GPIO Kconfig and split it into submenus, as it was becoming and unstructured, illogical and unnavigatable mess. I hope this is easier to follow. Menus that require a certain subsystem like I2C can now be hidden nicely for example, still working on others. - New drivers: - New driver for the Altera Soft GPIO. - The F7188x driver now handles the F71869 and F71869A variants. - The MIPS Loongson driver has been moved to drivers/gpio for consolidation and cleanup. - Cleanups: - The MAX732x is converted to use the GPIOLIB_IRQCHIP infrastructure. - The PCF857x is converted to use the GPIOLIB_IRQCHIP infrastructure. - Radical cleanup of the OMAP driver. - Misc: - Enable the DWAPB GPIO for all architectures. This is a "hard IP" block from Synopsys which has started to turn up in so diverse architectures as X86 Quark, ARC and a slew of ARM systems. So even though it's not an expander, it's generic enough to be available for all. - We add a mock GPIO on Crystalcove PMIC after a long discussion with Daniel Vetter et al, tracing back to the shootout at the kernel summit where DRM drivers and sub-componentization was discussed. In this case a mock GPIO is assumed to be the best compromise gaining some reuse of infrastructure without making DRM drivers overly complex at the same time. Let's see. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJVMNYHAAoJEEEQszewGV1zSmwP/2oCk4CB4fexrqM+irUJrDnT 3D/8tuaq7EghMnwPXCfHa8R8eWF6XEDvHPcJNVgXiWbtCGRMpdsiobFunzwLQv5A CbcuAOzWmzA0ePbfa0+xpLpWM/RJP9u1an/RboIzeeS7oQ1Yj/VjF8uS8Se+Pe3r nPKvTpoU5lGpIUTEEYjiJhL8pBmp8k75a6NGM4U8VwXI9BsdhDkpRGsfG3NK8hs2 vSvWDB19NCW6iOd3gN4KA4f0Zz57WONMS7jY2WaipqYRlr37o4i2CA0ME1xoXEfg 3JT1lmg7esNCvnjQOaGTaM6nf66j7/nleNtnMmAAJcJeMNoh9yS6397TGaYFThsn C1WmAoaonor3RAujrL3oRenxfq2+Vl63OvsClDiWz7LL9YYJ/G2nS3MggFHpZUhu /CHXSt08j0Kewfc5SkvFCTnrPG7aWy/YDou6PfuXIvkFp5h1FXDkHTXvOD33turD ohEPlg/9i2uCnVQfN+GV4h69WSyEiOpxG5W7ryE+nIo6XzWIctHLIH2V6aE7YrwG FBg7hC1QV1cI776HFOuM4rPwG1N80IQeC3vr5z/jEtZVPXrIaGvupxFC+O1DAx4W rzBD8lX45B96WmIW2odg11KXXyPO1srW4ZFWghm95HTfvnQc3O6LmV9riv1k7DYA gR+aRYNiLO01UmoTPYbK =QFbC -----END PGP SIGNATURE----- Merge tag 'gpio-v4.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v4.1 development cycle: - A new GPIO hogging mechanism has been added. This can be used on boards that want to drive some GPIO line high, low, or set it as input on boot and then never touch it again. For some embedded systems this is bliss and simplifies things to a great extent. - Some API cleanup and closure: gpiod_get_array() and gpiod_put_array() has been added to get and put GPIOs in bulk as was possible with the non-descriptor API. - Encapsulate cross-calls to the pin control subsystem in <linux/gpio/driver.h>. Now this should be the only header any GPIO driver needs to include or something is wrong. Cleanups restricting drivers to this include are welcomed if tested. - Sort the GPIO Kconfig and split it into submenus, as it was becoming and unstructured, illogical and unnavigatable mess. I hope this is easier to follow. Menus that require a certain subsystem like I2C can now be hidden nicely for example, still working on others. - New drivers: - New driver for the Altera Soft GPIO. - The F7188x driver now handles the F71869 and F71869A variants. - The MIPS Loongson driver has been moved to drivers/gpio for consolidation and cleanup. - Cleanups: - The MAX732x is converted to use the GPIOLIB_IRQCHIP infrastructure. - The PCF857x is converted to use the GPIOLIB_IRQCHIP infrastructure. - Radical cleanup of the OMAP driver. - Misc: - Enable the DWAPB GPIO for all architectures. This is a "hard IP" block from Synopsys which has started to turn up in so diverse architectures as X86 Quark, ARC and a slew of ARM systems. So even though it's not an expander, it's generic enough to be available for all. - We add a mock GPIO on Crystalcove PMIC after a long discussion with Daniel Vetter et al, tracing back to the shootout at the kernel summit where DRM drivers and sub-componentization was discussed. In this case a mock GPIO is assumed to be the best compromise gaining some reuse of infrastructure without making DRM drivers overly complex at the same time. Let's see" * tag 'gpio-v4.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (62 commits) Revert "gpio: sch: use uapi/linux/pci_ids.h directly" gpio: dwapb: remove dependencies gpio: dwapb: enable for ARC gpio: removing kfree remove functionality gpio: mvebu: Fix mask/unmask managment per irq chip type gpio: split GPIO drivers in submenus gpio: move MFD GPIO drivers under their own comment gpio: move BCM Kona Kconfig option gpio: arrange SPI Kconfig symbols alphabetically gpio: arrange PCI GPIO controllers alphabetically gpio: arrange I2C Kconfig symbols alphabetically gpio: arrange Kconfig symbols alphabetically gpio: ich: Implement get_direction function gpio: use (!foo) instead of (foo == NULL) gpio: arizona: drop owner assignment from platform_drivers gpio: max7300: remove 'ret' variable gpio: use devm_kzalloc gpio: sch: use uapi/linux/pci_ids.h directly gpio: x-gene: fix devm_ioremap_resource() check gpio: loongson: Add Loongson-3A/3B GPIO driver support ...
171 lines
5.2 KiB
C
171 lines
5.2 KiB
C
/*
|
|
* Internal GPIO functions.
|
|
*
|
|
* Copyright (C) 2013, Intel Corporation
|
|
* Author: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#ifndef GPIOLIB_H
|
|
#define GPIOLIB_H
|
|
|
|
#include <linux/err.h>
|
|
#include <linux/device.h>
|
|
|
|
enum of_gpio_flags;
|
|
|
|
struct acpi_device;
|
|
|
|
/**
|
|
* struct acpi_gpio_info - ACPI GPIO specific information
|
|
* @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
|
|
* @active_low: in case of @gpioint, the pin is active low
|
|
*/
|
|
struct acpi_gpio_info {
|
|
bool gpioint;
|
|
bool active_low;
|
|
};
|
|
|
|
/* gpio suffixes used for ACPI and device tree lookup */
|
|
static const char * const gpio_suffixes[] = { "gpios", "gpio" };
|
|
|
|
#ifdef CONFIG_ACPI
|
|
void acpi_gpiochip_add(struct gpio_chip *chip);
|
|
void acpi_gpiochip_remove(struct gpio_chip *chip);
|
|
|
|
void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
|
|
void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
|
|
|
|
struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
|
|
const char *propname, int index,
|
|
struct acpi_gpio_info *info);
|
|
|
|
int acpi_gpio_count(struct device *dev, const char *con_id);
|
|
#else
|
|
static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
|
|
static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
|
|
|
|
static inline void
|
|
acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
|
|
|
|
static inline void
|
|
acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
|
|
|
|
static inline struct gpio_desc *
|
|
acpi_get_gpiod_by_index(struct acpi_device *adev, const char *propname,
|
|
int index, struct acpi_gpio_info *info)
|
|
{
|
|
return ERR_PTR(-ENOSYS);
|
|
}
|
|
|
|
static inline int acpi_gpio_count(struct device *dev, const char *con_id)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
#endif
|
|
|
|
struct gpio_desc *of_get_named_gpiod_flags(struct device_node *np,
|
|
const char *list_name, int index, enum of_gpio_flags *flags);
|
|
|
|
struct gpio_desc *gpiochip_get_desc(struct gpio_chip *chip, u16 hwnum);
|
|
|
|
extern struct spinlock gpio_lock;
|
|
extern struct list_head gpio_chips;
|
|
|
|
struct gpio_desc {
|
|
struct gpio_chip *chip;
|
|
unsigned long flags;
|
|
/* flag symbols are bit numbers */
|
|
#define FLAG_REQUESTED 0
|
|
#define FLAG_IS_OUT 1
|
|
#define FLAG_EXPORT 2 /* protected by sysfs_lock */
|
|
#define FLAG_SYSFS 3 /* exported via /sys/class/gpio/control */
|
|
#define FLAG_TRIG_FALL 4 /* trigger on falling edge */
|
|
#define FLAG_TRIG_RISE 5 /* trigger on rising edge */
|
|
#define FLAG_ACTIVE_LOW 6 /* value has active low */
|
|
#define FLAG_OPEN_DRAIN 7 /* Gpio is open drain type */
|
|
#define FLAG_OPEN_SOURCE 8 /* Gpio is open source type */
|
|
#define FLAG_USED_AS_IRQ 9 /* GPIO is connected to an IRQ */
|
|
#define FLAG_SYSFS_DIR 10 /* show sysfs direction attribute */
|
|
#define FLAG_IS_HOGGED 11 /* GPIO is hogged */
|
|
|
|
#define ID_SHIFT 16 /* add new flags before this one */
|
|
|
|
#define GPIO_FLAGS_MASK ((1 << ID_SHIFT) - 1)
|
|
#define GPIO_TRIGGER_MASK (BIT(FLAG_TRIG_FALL) | BIT(FLAG_TRIG_RISE))
|
|
|
|
const char *label;
|
|
};
|
|
|
|
int gpiod_request(struct gpio_desc *desc, const char *label);
|
|
void gpiod_free(struct gpio_desc *desc);
|
|
int gpiod_hog(struct gpio_desc *desc, const char *name,
|
|
unsigned long lflags, enum gpiod_flags dflags);
|
|
|
|
/*
|
|
* Return the GPIO number of the passed descriptor relative to its chip
|
|
*/
|
|
static int __maybe_unused gpio_chip_hwgpio(const struct gpio_desc *desc)
|
|
{
|
|
return desc - &desc->chip->desc[0];
|
|
}
|
|
|
|
/* With descriptor prefix */
|
|
|
|
#define gpiod_emerg(desc, fmt, ...) \
|
|
pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\
|
|
##__VA_ARGS__)
|
|
#define gpiod_crit(desc, fmt, ...) \
|
|
pr_crit("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \
|
|
##__VA_ARGS__)
|
|
#define gpiod_err(desc, fmt, ...) \
|
|
pr_err("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \
|
|
##__VA_ARGS__)
|
|
#define gpiod_warn(desc, fmt, ...) \
|
|
pr_warn("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \
|
|
##__VA_ARGS__)
|
|
#define gpiod_info(desc, fmt, ...) \
|
|
pr_info("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \
|
|
##__VA_ARGS__)
|
|
#define gpiod_dbg(desc, fmt, ...) \
|
|
pr_debug("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\
|
|
##__VA_ARGS__)
|
|
|
|
/* With chip prefix */
|
|
|
|
#define chip_emerg(chip, fmt, ...) \
|
|
pr_emerg("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
|
|
#define chip_crit(chip, fmt, ...) \
|
|
pr_crit("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
|
|
#define chip_err(chip, fmt, ...) \
|
|
pr_err("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
|
|
#define chip_warn(chip, fmt, ...) \
|
|
pr_warn("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
|
|
#define chip_info(chip, fmt, ...) \
|
|
pr_info("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
|
|
#define chip_dbg(chip, fmt, ...) \
|
|
pr_debug("GPIO chip %s: " fmt, chip->label, ##__VA_ARGS__)
|
|
|
|
#ifdef CONFIG_GPIO_SYSFS
|
|
|
|
int gpiochip_export(struct gpio_chip *chip);
|
|
void gpiochip_unexport(struct gpio_chip *chip);
|
|
|
|
#else
|
|
|
|
static inline int gpiochip_export(struct gpio_chip *chip)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void gpiochip_unexport(struct gpio_chip *chip)
|
|
{
|
|
}
|
|
|
|
#endif /* CONFIG_GPIO_SYSFS */
|
|
|
|
#endif /* GPIOLIB_H */
|