diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-09 09:07:00 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-09 09:07:00 -0700 |
commit | 2ec98f567888501df0140c858af5f5ea10216a6f (patch) | |
tree | 656e0a3d0bba600bf79ab98c85bfec24ddcb2115 /include | |
parent | 96407298ff6ef59c4554833d47d29c775d1e7652 (diff) | |
parent | 9b3b623804a67d2274ee372c1587926ab0275833 (diff) |
Merge tag 'gpio-v5.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij:
"This is the big slew of GPIO changes for the v5.3 kernel cycle. This
is mostly incremental work this time.
Three important things:
- The FMC subsystem is deleted through my tree. This happens through
GPIO as its demise was discussed in relation to a patch decoupling
its GPIO implementation from the standard way of handling GPIO. As
it turns out, that is not the only subsystem it reimplements and
the authors think it is better do scratch it and start over using
the proper kernel subsystems than try to polish the rust shiny. See
the commit (ACKed by the maintainers) for details.
- Arnd made a small devres patch that was ACKed by Greg and goes into
the device core.
- SPDX header change colissions may happen, because at times I've
seen that quite a lot changed during the -rc:s in regards to SPDX.
(It is good stuff, tglx has me convinced, and it is worth the
occasional pain.)
Apart from this is is nothing controversial or problematic.
Summary:
Core:
- When a gpio_chip request GPIOs from itself, it can now fully
control the line characteristics, both machine and consumer flags.
This makes a lot of sense, but took some time before I figured out
that this is how it has to work.
- Several smallish documentation fixes.
New drivers:
- The PCA953x driver now supports the TI TCA9539.
- The DaVinci driver now supports the K3 AM654 SoCs.
Driver improvements:
- Major overhaul and hardening of the OMAP driver by Russell King.
- Starting to move some drivers to the new API passing irq_chip along
with the gpio_chip when adding the gpio_chip instead of adding it
separately.
Unrelated:
- Delete the FMC subsystem"
* tag 'gpio-v5.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (87 commits)
Revert "gpio: tegra: Clean-up debugfs initialisation"
gpiolib: Use spinlock_t instead of struct spinlock
gpio: stp-xway: allow compile-testing
gpio: stp-xway: get rid of the #include <lantiq_soc.h> dependency
gpio: stp-xway: improve module clock error handling
gpio: stp-xway: simplify error handling in xway_stp_probe()
gpiolib: Clarify use of non-sleeping functions
gpiolib: Fix references to gpiod_[gs]et_*value_cansleep() variants
gpiolib: Document new gpio_chip.init_valid_mask field
Documentation: gpio: Fix reference to gpiod_get_array()
gpio: pl061: drop duplicate printing of device name
gpio: altera: Pass irqchip when adding gpiochip
gpio: siox: Use devm_ managed gpiochip
gpio: siox: Add struct device *dev helper variable
gpio: siox: Pass irqchip when adding gpiochip
drivers: gpio: amd-fch: make resource struct const
devres: allow const resource arguments
gpio: ath79: Pass irqchip when adding gpiochip
gpio: tegra: Clean-up debugfs initialisation
gpio: siox: Switch to IRQ_TYPE_NONE
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/fmc-sdb.h | 39 | ||||
-rw-r--r-- | include/linux/fmc.h | 269 | ||||
-rw-r--r-- | include/linux/gpio/driver.h | 29 | ||||
-rw-r--r-- | include/linux/gpio/gpio-reg.h | 2 | ||||
-rw-r--r-- | include/linux/gpio/machine.h | 4 | ||||
-rw-r--r-- | include/linux/platform_data/gpio-omap.h | 2 | ||||
-rw-r--r-- | include/linux/siox.h | 10 |
7 files changed, 27 insertions, 328 deletions
diff --git a/include/linux/fmc-sdb.h b/include/linux/fmc-sdb.h deleted file mode 100644 index bec899f0867c..000000000000 --- a/include/linux/fmc-sdb.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * This file is separate from sdb.h, because I want that one to remain - * unchanged (as far as possible) from the official sdb distribution - * - * This file and associated functionality are a playground for me to - * understand stuff which will later be implemented in more generic places. - */ -#include <linux/sdb.h> - -/* This is the union of all currently defined types */ -union sdb_record { - struct sdb_interconnect ic; - struct sdb_device dev; - struct sdb_bridge bridge; - struct sdb_integration integr; - struct sdb_empty empty; - struct sdb_synthesis synthesis; - struct sdb_repo_url repo_url; -}; - -struct fmc_device; - -/* Every sdb table is turned into this structure */ -struct sdb_array { - int len; - int level; - unsigned long baseaddr; - struct fmc_device *fmc; /* the device that hosts it */ - struct sdb_array *parent; /* NULL at root */ - union sdb_record *record; /* copies of the struct */ - struct sdb_array **subtree; /* only valid for bridge items */ -}; - -extern int fmc_scan_sdb_tree(struct fmc_device *fmc, unsigned long address); -extern void fmc_show_sdb_tree(const struct fmc_device *fmc); -extern signed long fmc_find_sdb_device(struct sdb_array *tree, uint64_t vendor, - uint32_t device, unsigned long *sz); -extern int fmc_free_sdb_tree(struct fmc_device *fmc); diff --git a/include/linux/fmc.h b/include/linux/fmc.h deleted file mode 100644 index b355f3806f3f..000000000000 --- a/include/linux/fmc.h +++ /dev/null @@ -1,269 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2012 CERN (www.cern.ch) - * Author: Alessandro Rubini <rubini@gnudd.com> - * - * This work is part of the White Rabbit project, a research effort led - * by CERN, the European Institute for Nuclear Research. - */ -#ifndef __LINUX_FMC_H__ -#define __LINUX_FMC_H__ -#include <linux/types.h> -#include <linux/moduleparam.h> -#include <linux/device.h> -#include <linux/list.h> -#include <linux/interrupt.h> -#include <linux/io.h> - -struct fmc_device; -struct fmc_driver; - -/* - * This bus abstraction is developed separately from drivers, so we need - * to check the version of the data structures we receive. - */ - -#define FMC_MAJOR 3 -#define FMC_MINOR 0 -#define FMC_VERSION ((FMC_MAJOR << 16) | FMC_MINOR) -#define __FMC_MAJOR(x) ((x) >> 16) -#define __FMC_MINOR(x) ((x) & 0xffff) - -/* - * The device identification, as defined by the IPMI FRU (Field Replaceable - * Unit) includes four different strings to describe the device. Here we - * only match the "Board Manufacturer" and the "Board Product Name", - * ignoring the "Board Serial Number" and "Board Part Number". All 4 are - * expected to be strings, so they are treated as zero-terminated C strings. - * Unspecified string (NULL) means "any", so if both are unspecified this - * is a catch-all driver. So null entries are allowed and we use array - * and length. This is unlike pci and usb that use null-terminated arrays - */ -struct fmc_fru_id { - char *manufacturer; - char *product_name; -}; - -/* - * If the FPGA is already programmed (think Etherbone or the second - * SVEC slot), we can match on SDB devices in the memory image. This - * match uses an array of devices that must all be present, and the - * match is based on vendor and device only. Further checks are expected - * to happen in the probe function. Zero means "any" and catch-all is allowed. - */ -struct fmc_sdb_one_id { - uint64_t vendor; - uint32_t device; -}; -struct fmc_sdb_id { - struct fmc_sdb_one_id *cores; - int cores_nr; -}; - -struct fmc_device_id { - struct fmc_fru_id *fru_id; - int fru_id_nr; - struct fmc_sdb_id *sdb_id; - int sdb_id_nr; -}; - -/* This sizes the module_param_array used by generic module parameters */ -#define FMC_MAX_CARDS 32 - -/* The driver is a pretty simple thing */ -struct fmc_driver { - unsigned long version; - struct device_driver driver; - int (*probe)(struct fmc_device *); - int (*remove)(struct fmc_device *); - const struct fmc_device_id id_table; - /* What follows is for generic module parameters */ - int busid_n; - int busid_val[FMC_MAX_CARDS]; - int gw_n; - char *gw_val[FMC_MAX_CARDS]; -}; -#define to_fmc_driver(x) container_of((x), struct fmc_driver, driver) - -/* These are the generic parameters, that drivers may instantiate */ -#define FMC_PARAM_BUSID(_d) \ - module_param_array_named(busid, _d.busid_val, int, &_d.busid_n, 0444) -#define FMC_PARAM_GATEWARE(_d) \ - module_param_array_named(gateware, _d.gw_val, charp, &_d.gw_n, 0444) - -/* - * Drivers may need to configure gpio pins in the carrier. To read input - * (a very uncommon operation, and definitely not in the hot paths), just - * configure one gpio only and get 0 or 1 as retval of the config method - */ -struct fmc_gpio { - char *carrier_name; /* name or NULL for virtual pins */ - int gpio; - int _gpio; /* internal use by the carrier */ - int mode; /* GPIOF_DIR_OUT etc, from <linux/gpio.h> */ - int irqmode; /* IRQF_TRIGGER_LOW and so on */ -}; - -/* The numbering of gpio pins allows access to raw pins or virtual roles */ -#define FMC_GPIO_RAW(x) (x) /* 4096 of them */ -#define __FMC_GPIO_IS_RAW(x) ((x) < 0x1000) -#define FMC_GPIO_IRQ(x) ((x) + 0x1000) /* 256 of them */ -#define FMC_GPIO_LED(x) ((x) + 0x1100) /* 256 of them */ -#define FMC_GPIO_KEY(x) ((x) + 0x1200) /* 256 of them */ -#define FMC_GPIO_TP(x) ((x) + 0x1300) /* 256 of them */ -#define FMC_GPIO_USER(x) ((x) + 0x1400) /* 256 of them */ -/* We may add SCL and SDA, or other roles if the need arises */ - -/* GPIOF_DIR_IN etc are missing before 3.0. copy from <linux/gpio.h> */ -#ifndef GPIOF_DIR_IN -# define GPIOF_DIR_OUT (0 << 0) -# define GPIOF_DIR_IN (1 << 0) -# define GPIOF_INIT_LOW (0 << 1) -# define GPIOF_INIT_HIGH (1 << 1) -#endif - -/* - * The operations are offered by each carrier and should make driver - * design completely independent of the carrier. Named GPIO pins may be - * the exception. - */ -struct fmc_operations { - uint32_t (*read32)(struct fmc_device *fmc, int offset); - void (*write32)(struct fmc_device *fmc, uint32_t value, int offset); - int (*validate)(struct fmc_device *fmc, struct fmc_driver *drv); - int (*reprogram_raw)(struct fmc_device *f, struct fmc_driver *d, - void *gw, unsigned long len); - int (*reprogram)(struct fmc_device *f, struct fmc_driver *d, char *gw); - int (*irq_request)(struct fmc_device *fmc, irq_handler_t h, - char *name, int flags); - void (*irq_ack)(struct fmc_device *fmc); - int (*irq_free)(struct fmc_device *fmc); - int (*gpio_config)(struct fmc_device *fmc, struct fmc_gpio *gpio, - int ngpio); - int (*read_ee)(struct fmc_device *fmc, int pos, void *d, int l); - int (*write_ee)(struct fmc_device *fmc, int pos, const void *d, int l); -}; - -/* Prefer this helper rather than calling of fmc->reprogram directly */ -int fmc_reprogram_raw(struct fmc_device *fmc, struct fmc_driver *d, - void *gw, unsigned long len, int sdb_entry); -extern int fmc_reprogram(struct fmc_device *f, struct fmc_driver *d, char *gw, - int sdb_entry); - -/* - * The device reports all information needed to access hw. - * - * If we have eeprom_len and not contents, the core reads it. - * Then, parsing of identifiers is done by the core which fills fmc_fru_id.. - * Similarly a device that must be matched based on SDB cores must - * fill the entry point and the core will scan the bus (FIXME: sdb match) - */ -struct fmc_device { - unsigned long version; - unsigned long flags; - struct module *owner; /* char device must pin it */ - struct fmc_fru_id id; /* for EEPROM-based match */ - struct fmc_operations *op; /* carrier-provided */ - int irq; /* according to host bus. 0 == none */ - int eeprom_len; /* Usually 8kB, may be less */ - int eeprom_addr; /* 0x50, 0x52 etc */ - uint8_t *eeprom; /* Full contents or leading part */ - char *carrier_name; /* "SPEC" or similar, for special use */ - void *carrier_data; /* "struct spec *" or equivalent */ - __iomem void *fpga_base; /* May be NULL (Etherbone) */ - __iomem void *slot_base; /* Set by the driver */ - struct fmc_device **devarray; /* Allocated by the bus */ - int slot_id; /* Index in the slot array */ - int nr_slots; /* Number of slots in this carrier */ - unsigned long memlen; /* Used for the char device */ - struct device dev; /* For Linux use */ - struct device *hwdev; /* The underlying hardware device */ - unsigned long sdbfs_entry; - struct sdb_array *sdb; - uint32_t device_id; /* Filled by the device */ - char *mezzanine_name; /* Defaults to ``fmc'' */ - void *mezzanine_data; - - struct dentry *dbg_dir; - struct dentry *dbg_sdb_dump; -}; -#define to_fmc_device(x) container_of((x), struct fmc_device, dev) - -#define FMC_DEVICE_HAS_GOLDEN 1 -#define FMC_DEVICE_HAS_CUSTOM 2 -#define FMC_DEVICE_NO_MEZZANINE 4 -#define FMC_DEVICE_MATCH_SDB 8 /* fmc-core must scan sdb in fpga */ - -/* - * If fpga_base can be used, the carrier offers no readl/writel methods, and - * this expands to a single, fast, I/O access. - */ -static inline uint32_t fmc_readl(struct fmc_device *fmc, int offset) -{ - if (unlikely(fmc->op->read32)) - return fmc->op->read32(fmc, offset); - return readl(fmc->fpga_base + offset); -} -static inline void fmc_writel(struct fmc_device *fmc, uint32_t val, int off) -{ - if (unlikely(fmc->op->write32)) - fmc->op->write32(fmc, val, off); - else - writel(val, fmc->fpga_base + off); -} - -/* pci-like naming */ -static inline void *fmc_get_drvdata(const struct fmc_device *fmc) -{ - return dev_get_drvdata(&fmc->dev); -} - -static inline void fmc_set_drvdata(struct fmc_device *fmc, void *data) -{ - dev_set_drvdata(&fmc->dev, data); -} - -struct fmc_gateware { - void *bitstream; - unsigned long len; -}; - -/* The 5 access points */ -extern int fmc_driver_register(struct fmc_driver *drv); -extern void fmc_driver_unregister(struct fmc_driver *drv); -extern int fmc_device_register(struct fmc_device *tdev); -extern int fmc_device_register_gw(struct fmc_device *tdev, - struct fmc_gateware *gw); -extern void fmc_device_unregister(struct fmc_device *tdev); - -/* Three more for device sets, all driven by the same FPGA */ -extern int fmc_device_register_n(struct fmc_device **devs, int n); -extern int fmc_device_register_n_gw(struct fmc_device **devs, int n, - struct fmc_gateware *gw); -extern void fmc_device_unregister_n(struct fmc_device **devs, int n); - -/* Internal cross-calls between files; not exported to other modules */ -extern int fmc_match(struct device *dev, struct device_driver *drv); -extern int fmc_fill_id_info(struct fmc_device *fmc); -extern void fmc_free_id_info(struct fmc_device *fmc); -extern void fmc_dump_eeprom(const struct fmc_device *fmc); - -/* helpers for FMC operations */ -extern int fmc_irq_request(struct fmc_device *fmc, irq_handler_t h, - char *name, int flags); -extern void fmc_irq_free(struct fmc_device *fmc); -extern void fmc_irq_ack(struct fmc_device *fmc); -extern int fmc_validate(struct fmc_device *fmc, struct fmc_driver *drv); -extern int fmc_gpio_config(struct fmc_device *fmc, struct fmc_gpio *gpio, - int ngpio); -extern int fmc_read_ee(struct fmc_device *fmc, int pos, void *d, int l); -extern int fmc_write_ee(struct fmc_device *fmc, int pos, const void *d, int l); - -/* helpers for FMC operations */ -extern int fmc_irq_request(struct fmc_device *fmc, irq_handler_t h, - char *name, int flags); -extern void fmc_irq_free(struct fmc_device *fmc); -extern void fmc_irq_ack(struct fmc_device *fmc); -extern int fmc_validate(struct fmc_device *fmc, struct fmc_driver *drv); - -#endif /* __LINUX_FMC_H__ */ diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index a1d273c96016..8d58386aadd5 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -18,6 +18,7 @@ struct seq_file; struct gpio_device; struct module; enum gpiod_flags; +enum gpio_lookup_flags; #ifdef CONFIG_GPIOLIB @@ -102,13 +103,6 @@ struct gpio_irq_chip { unsigned int num_parents; /** - * @parent_irq: - * - * For use by gpiochip_set_cascaded_irqchip() - */ - unsigned int parent_irq; - - /** * @parents: * * A list of interrupt parents of a GPIO chip. This is owned by the @@ -167,7 +161,7 @@ struct gpio_irq_chip { */ void (*irq_disable)(struct irq_data *data); }; -#endif +#endif /* CONFIG_GPIOLIB_IRQCHIP */ /** * struct gpio_chip - abstract a GPIO controller @@ -200,6 +194,8 @@ struct gpio_irq_chip { * @dbg_show: optional routine to show contents in debugfs; default code * will be used when this is omitted, but custom code can show extra * state (such as pullup/pulldown configuration). + * @init_valid_mask: optional routine to initialize @valid_mask, to be used if + * not all GPIOs are valid. * @base: identifies the first GPIO number handled by this chip; * or, if negative during registration, requests dynamic ID allocation. * DEPRECATION: providing anything non-negative and nailing the base @@ -307,7 +303,7 @@ struct gpio_chip { spinlock_t bgpio_lock; unsigned long bgpio_data; unsigned long bgpio_dir; -#endif +#endif /* CONFIG_GPIO_GENERIC */ #ifdef CONFIG_GPIOLIB_IRQCHIP /* @@ -322,7 +318,7 @@ struct gpio_chip { * used to handle IRQs for most practical cases. */ struct gpio_irq_chip irq; -#endif +#endif /* CONFIG_GPIOLIB_IRQCHIP */ /** * @need_valid_mask: @@ -369,7 +365,7 @@ struct gpio_chip { */ int (*of_xlate)(struct gpio_chip *gc, const struct of_phandle_args *gpiospec, u32 *flags); -#endif +#endif /* CONFIG_OF_GPIO */ }; extern const char *gpiochip_is_requested(struct gpio_chip *chip, @@ -412,7 +408,7 @@ extern int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, }) #else #define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL, NULL) -#endif +#endif /* CONFIG_LOCKDEP */ static inline int gpiochip_add(struct gpio_chip *chip) { @@ -467,7 +463,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev, #define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */ #define BGPIOF_NO_OUTPUT BIT(5) /* only input */ -#endif +#endif /* CONFIG_GPIO_GENERIC */ #ifdef CONFIG_GPIOLIB_IRQCHIP @@ -537,7 +533,7 @@ static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, handler, type, true, &lock_key, &request_key); } -#else +#else /* ! CONFIG_LOCKDEP */ static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip, struct irq_chip *irqchip, unsigned int first_irq, @@ -588,7 +584,7 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip, unsigned int gpio_offset, const char *pin_group); void gpiochip_remove_pin_ranges(struct gpio_chip *chip); -#else +#else /* ! CONFIG_PINCTRL */ static inline int gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, @@ -614,7 +610,8 @@ gpiochip_remove_pin_ranges(struct gpio_chip *chip) struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, const char *label, - enum gpiod_flags flags); + enum gpio_lookup_flags lflags, + enum gpiod_flags dflags); void gpiochip_free_own_desc(struct gpio_desc *desc); void devprop_gpiochip_set_names(struct gpio_chip *chip, diff --git a/include/linux/gpio/gpio-reg.h b/include/linux/gpio/gpio-reg.h index 5c6efd394cb0..39b888c40b39 100644 --- a/include/linux/gpio/gpio-reg.h +++ b/include/linux/gpio/gpio-reg.h @@ -11,4 +11,4 @@ struct gpio_chip *gpio_reg_init(struct device *dev, void __iomem *reg, int gpio_reg_resume(struct gpio_chip *gc); -#endif +#endif /* GPIO_REG_H */ diff --git a/include/linux/gpio/machine.h b/include/linux/gpio/machine.h index 35f299d1f6a7..1ebe5be05d5f 100644 --- a/include/linux/gpio/machine.h +++ b/include/linux/gpio/machine.h @@ -97,7 +97,7 @@ void gpiod_add_lookup_table(struct gpiod_lookup_table *table); void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n); void gpiod_remove_lookup_table(struct gpiod_lookup_table *table); void gpiod_add_hogs(struct gpiod_hog *hogs); -#else +#else /* ! CONFIG_GPIOLIB */ static inline void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {} static inline @@ -105,6 +105,6 @@ void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {} static inline void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {} static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {} -#endif +#endif /* CONFIG_GPIOLIB */ #endif /* __LINUX_GPIO_MACHINE_H */ diff --git a/include/linux/platform_data/gpio-omap.h b/include/linux/platform_data/gpio-omap.h index 17edc43201d2..8b30b14b47d3 100644 --- a/include/linux/platform_data/gpio-omap.h +++ b/include/linux/platform_data/gpio-omap.h @@ -186,7 +186,7 @@ struct omap_gpio_platform_data { bool is_mpuio; /* whether the bank is of type MPUIO */ u32 non_wakeup_gpios; - struct omap_gpio_reg_offs *regs; + const struct omap_gpio_reg_offs *regs; /* Return context loss count due to PM states changing */ int (*get_context_loss_count)(struct device *dev); diff --git a/include/linux/siox.h b/include/linux/siox.h index a860cb8c1f9d..da7225bf1877 100644 --- a/include/linux/siox.h +++ b/include/linux/siox.h @@ -72,3 +72,13 @@ static inline void siox_driver_unregister(struct siox_driver *sdriver) { return driver_unregister(&sdriver->driver); } + +/* + * module_siox_driver() - Helper macro for drivers that don't do + * anything special in module init/exit. This eliminates a lot of + * boilerplate. Each module may only use this macro once, and + * calling it replaces module_init() and module_exit() + */ +#define module_siox_driver(__siox_driver) \ + module_driver(__siox_driver, siox_driver_register, \ + siox_driver_unregister) |