Release 4.7 drivers/gpio/gpiolib.h
/*
* 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/gpio/driver.h>
#include <linux/err.h>
#include <linux/device.h>
#include <linux/module.h>
#include <linux/cdev.h>
enum of_gpio_flags;
enum gpiod_flags;
struct acpi_device;
/**
* struct gpio_device - internal state container for GPIO devices
* @id: numerical ID number for the GPIO chip
* @dev: the GPIO device struct
* @chrdev: character device for the GPIO device
* @mockdev: class device used by the deprecated sysfs interface (may be
* NULL)
* @owner: helps prevent removal of modules exporting active GPIOs
* @chip: pointer to the corresponding gpiochip, holding static
* data for this device
* @descs: array of ngpio descriptors.
* @ngpio: the number of GPIO lines on this GPIO device, equal to the size
* of the @descs array.
* @base: GPIO base in the DEPRECATED global Linux GPIO numberspace, assigned
* at device creation time.
* @label: a descriptive name for the GPIO device, such as the part number
* or name of the IP component in a System on Chip.
* @data: per-instance data assigned by the driver
* @list: links gpio_device:s together for traversal
*
* This state container holds most of the runtime variable data
* for a GPIO device and can hold references and live on after the
* GPIO chip has been removed, if it is still being used from
* userspace.
*/
struct gpio_device {
int id;
struct device dev;
struct cdev chrdev;
struct device *mockdev;
struct module *owner;
struct gpio_chip *chip;
struct gpio_desc *descs;
int base;
u16 ngpio;
char *label;
void *data;
struct list_head list;
#ifdef CONFIG_PINCTRL
/*
* If CONFIG_PINCTRL is enabled, then gpio controllers can optionally
* describe the actual pin range which they serve in an SoC. This
* information would be used by pinctrl subsystem to configure
* corresponding pins for gpio usage.
*/
struct list_head pin_ranges;
#endif
};
/**
* 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;
int polarity;
int triggering;
};
/* 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);
struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
const char *propname, int index,
struct acpi_gpio_info *info);
int acpi_gpio_count(struct device *dev, const char *con_id);
bool acpi_can_fallback_to_crs(struct acpi_device *adev, const char *con_id);
#else
static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mika westerberg | mika westerberg | 11 | 100.00% | 1 | 100.00% |
| Total | 11 | 100.00% | 1 | 100.00% |
static inline void acpi_gpiochip_remove(struct gpio_chip *chip) { }
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mika westerberg | mika westerberg | 11 | 100.00% | 1 | 100.00% |
| Total | 11 | 100.00% | 1 | 100.00% |
static inline void
acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mika westerberg | mika westerberg | 11 | 100.00% | 2 | 100.00% |
| Total | 11 | 100.00% | 2 | 100.00% |
static inline void
acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mika westerberg | mika westerberg | 11 | 100.00% | 1 | 100.00% |
| Total | 11 | 100.00% | 1 | 100.00% |
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);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
mika westerberg | mika westerberg | 34 | 100.00% | 3 | 100.00% |
| Total | 34 | 100.00% | 3 | 100.00% |
static inline struct gpio_desc *
acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname,
int index, struct acpi_gpio_info *info)
{
return ERR_PTR(-ENXIO);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
rafael j. wysocki | rafael j. wysocki | 34 | 100.00% | 1 | 100.00% |
| Total | 34 | 100.00% | 1 | 100.00% |
static inline int acpi_gpio_count(struct device *dev, const char *con_id)
{
return -ENODEV;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
rojhalat ibrahim | rojhalat ibrahim | 20 | 95.24% | 1 | 50.00% |
dmitry torokhov | dmitry torokhov | 1 | 4.76% | 1 | 50.00% |
| Total | 21 | 100.00% | 2 | 100.00% |
static inline bool acpi_can_fallback_to_crs(struct acpi_device *adev,
const char *con_id)
{
return false;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
dmitry torokhov | dmitry torokhov | 19 | 95.00% | 1 | 50.00% |
rojhalat ibrahim | rojhalat ibrahim | 1 | 5.00% | 1 | 50.00% |
| Total | 20 | 100.00% | 2 | 100.00% |
#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);
void gpiod_set_array_value_complex(bool raw, bool can_sleep,
unsigned int array_size,
struct gpio_desc **desc_array,
int *value_array);
extern struct spinlock gpio_lock;
extern struct list_head gpio_devices;
struct gpio_desc {
struct gpio_device *gdev;
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_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_IS_HOGGED 11 /* GPIO is hogged */
/* Connection label */
const char *label;
/* Name of the GPIO */
const char *name;
};
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->gdev->descs[0];
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
alexandre courbot | alexandre courbot | 23 | 88.46% | 1 | 33.33% |
linus walleij | linus walleij | 3 | 11.54% | 2 | 66.67% |
| Total | 26 | 100.00% | 3 | 100.00% |
/* 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, ...) \
dev_emerg(&chip->gpiodev->dev, "(%s): " fmt, chip->label, ##__VA_ARGS__)
#define chip_crit(chip, fmt, ...) \
dev_crit(&chip->gpiodev->dev, "(%s): " fmt, chip->label, ##__VA_ARGS__)
#define chip_err(chip, fmt, ...) \
dev_err(&chip->gpiodev->dev, "(%s): " fmt, chip->label, ##__VA_ARGS__)
#define chip_warn(chip, fmt, ...) \
dev_warn(&chip->gpiodev->dev, "(%s): " fmt, chip->label, ##__VA_ARGS__)
#define chip_info(chip, fmt, ...) \
dev_info(&chip->gpiodev->dev, "(%s): " fmt, chip->label, ##__VA_ARGS__)
#define chip_dbg(chip, fmt, ...) \
dev_dbg(&chip->gpiodev->dev, "(%s): " fmt, chip->label, ##__VA_ARGS__)
#ifdef CONFIG_GPIO_SYSFS
int gpiochip_sysfs_register(struct gpio_device *gdev);
void gpiochip_sysfs_unregister(struct gpio_device *gdev);
#else
static inline int gpiochip_sysfs_register(struct gpio_device *gdev)
{
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
alexandre courbot | alexandre courbot | 12 | 80.00% | 1 | 33.33% |
linus walleij | linus walleij | 2 | 13.33% | 1 | 33.33% |
johan hovold | johan hovold | 1 | 6.67% | 1 | 33.33% |
| Total | 15 | 100.00% | 3 | 100.00% |
static inline void gpiochip_sysfs_unregister(struct gpio_device *gdev)
{
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
alexandre courbot | alexandre courbot | 8 | 72.73% | 1 | 33.33% |
linus walleij | linus walleij | 2 | 18.18% | 1 | 33.33% |
johan hovold | johan hovold | 1 | 9.09% | 1 | 33.33% |
| Total | 11 | 100.00% | 3 | 100.00% |
#endif /* CONFIG_GPIO_SYSFS */
#endif /* GPIOLIB_H */
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
alexandre courbot | alexandre courbot | 333 | 40.96% | 3 | 11.11% |
mika westerberg | mika westerberg | 171 | 21.03% | 4 | 14.81% |
linus walleij | linus walleij | 121 | 14.88% | 11 | 40.74% |
rafael j. wysocki | rafael j. wysocki | 61 | 7.50% | 2 | 7.41% |
rojhalat ibrahim | rojhalat ibrahim | 50 | 6.15% | 2 | 7.41% |
dmitry torokhov | dmitry torokhov | 34 | 4.18% | 1 | 3.70% |
benoit parrot | benoit parrot | 27 | 3.32% | 1 | 3.70% |
markus pargmann | markus pargmann | 7 | 0.86% | 1 | 3.70% |
christophe ricard | christophe ricard | 5 | 0.62% | 1 | 3.70% |
johan hovold | johan hovold | 4 | 0.49% | 1 | 3.70% |
| Total | 813 | 100.00% | 27 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.