diff options
75 files changed, 831 insertions, 4206 deletions
diff --git a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt index 553b92a7e87b..bc6b4b62df83 100644 --- a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt +++ b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt | |||
@@ -5,6 +5,7 @@ Required Properties: | |||
5 | "ti,keystone-gpio": for Keystone 2 66AK2H/K, 66AK2L, | 5 | "ti,keystone-gpio": for Keystone 2 66AK2H/K, 66AK2L, |
6 | 66AK2E SoCs | 6 | 66AK2E SoCs |
7 | "ti,k2g-gpio", "ti,keystone-gpio": for 66AK2G | 7 | "ti,k2g-gpio", "ti,keystone-gpio": for 66AK2G |
8 | "ti,am654-gpio", "ti,keystone-gpio": for TI K3 AM654 | ||
8 | 9 | ||
9 | - reg: Physical base address of the controller and the size of memory mapped | 10 | - reg: Physical base address of the controller and the size of memory mapped |
10 | registers. | 11 | registers. |
@@ -145,3 +146,20 @@ gpio0: gpio@260bf00 { | |||
145 | ti,ngpio = <32>; | 146 | ti,ngpio = <32>; |
146 | ti,davinci-gpio-unbanked = <32>; | 147 | ti,davinci-gpio-unbanked = <32>; |
147 | }; | 148 | }; |
149 | |||
150 | Example for K3 AM654: | ||
151 | |||
152 | wkup_gpio0: wkup_gpio0@42110000 { | ||
153 | compatible = "ti,am654-gpio", "ti,keystone-gpio"; | ||
154 | reg = <0x42110000 0x100>; | ||
155 | gpio-controller; | ||
156 | #gpio-cells = <2>; | ||
157 | interrupt-parent = <&intr_wkup_gpio>; | ||
158 | interrupts = <59 128>, <59 129>, <59 130>, <59 131>; | ||
159 | interrupt-controller; | ||
160 | #interrupt-cells = <2>; | ||
161 | ti,ngpio = <56>; | ||
162 | ti,davinci-gpio-unbanked = <0>; | ||
163 | clocks = <&k3_clks 59 0>; | ||
164 | clock-names = "gpio"; | ||
165 | }; | ||
diff --git a/Documentation/devicetree/bindings/gpio/pl061-gpio.txt b/Documentation/devicetree/bindings/gpio/pl061-gpio.txt deleted file mode 100644 index 89058d375b7c..000000000000 --- a/Documentation/devicetree/bindings/gpio/pl061-gpio.txt +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | ARM PL061 GPIO controller | ||
2 | |||
3 | Required properties: | ||
4 | - compatible : "arm,pl061", "arm,primecell" | ||
5 | - #gpio-cells : Should be two. The first cell is the pin number and the | ||
6 | second cell is used to specify optional parameters: | ||
7 | - bit 0 specifies polarity (0 for normal, 1 for inverted) | ||
8 | - gpio-controller : Marks the device node as a GPIO controller. | ||
9 | - interrupts : Interrupt mapping for GPIO IRQ. | ||
10 | - gpio-ranges : Interaction with the PINCTRL subsystem. | ||
diff --git a/Documentation/devicetree/bindings/gpio/pl061-gpio.yaml b/Documentation/devicetree/bindings/gpio/pl061-gpio.yaml new file mode 100644 index 000000000000..313b17229247 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/pl061-gpio.yaml | |||
@@ -0,0 +1,69 @@ | |||
1 | # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) | ||
2 | %YAML 1.2 | ||
3 | --- | ||
4 | $id: http://devicetree.org/schemas/gpio/pl061-gpio.yaml# | ||
5 | $schema: http://devicetree.org/meta-schemas/core.yaml# | ||
6 | |||
7 | title: ARM PL061 GPIO controller | ||
8 | |||
9 | maintainers: | ||
10 | - Linus Walleij <linus.walleij@linaro.org> | ||
11 | - Rob Herring <robh@kernel.org> | ||
12 | |||
13 | # We need a select here so we don't match all nodes with 'arm,primecell' | ||
14 | select: | ||
15 | properties: | ||
16 | compatible: | ||
17 | contains: | ||
18 | const: arm,pl061 | ||
19 | required: | ||
20 | - compatible | ||
21 | |||
22 | properties: | ||
23 | $nodename: | ||
24 | pattern: "^gpio@[0-9a-f]+$" | ||
25 | |||
26 | compatible: | ||
27 | items: | ||
28 | - const: arm,pl061 | ||
29 | - const: arm,primecell | ||
30 | |||
31 | reg: | ||
32 | maxItems: 1 | ||
33 | |||
34 | interrupts: | ||
35 | oneOf: | ||
36 | - maxItems: 1 | ||
37 | - maxItems: 8 | ||
38 | |||
39 | interrupt-controller: true | ||
40 | |||
41 | "#interrupt-cells": | ||
42 | const: 2 | ||
43 | |||
44 | clocks: | ||
45 | maxItems: 1 | ||
46 | |||
47 | clock-names: true | ||
48 | |||
49 | "#gpio-cells": | ||
50 | const: 2 | ||
51 | |||
52 | gpio-controller: true | ||
53 | |||
54 | gpio-ranges: | ||
55 | maxItems: 8 | ||
56 | |||
57 | required: | ||
58 | - compatible | ||
59 | - reg | ||
60 | - interrupts | ||
61 | - interrupt-controller | ||
62 | - "#interrupt-cells" | ||
63 | - clocks | ||
64 | - "#gpio-cells" | ||
65 | - gpio-controller | ||
66 | |||
67 | additionalProperties: false | ||
68 | |||
69 | ... | ||
diff --git a/Documentation/driver-api/gpio/consumer.rst b/Documentation/driver-api/gpio/consumer.rst index 5e4d8aa68913..9559aa3cbcef 100644 --- a/Documentation/driver-api/gpio/consumer.rst +++ b/Documentation/driver-api/gpio/consumer.rst | |||
@@ -283,8 +283,6 @@ To summarize:: | |||
283 | gpiod_set_value(desc, 1); default (active high) high | 283 | gpiod_set_value(desc, 1); default (active high) high |
284 | gpiod_set_value(desc, 0); active low high | 284 | gpiod_set_value(desc, 0); active low high |
285 | gpiod_set_value(desc, 1); active low low | 285 | gpiod_set_value(desc, 1); active low low |
286 | gpiod_set_value(desc, 0); default (active high) low | ||
287 | gpiod_set_value(desc, 1); default (active high) high | ||
288 | gpiod_set_value(desc, 0); open drain low | 286 | gpiod_set_value(desc, 0); open drain low |
289 | gpiod_set_value(desc, 1); open drain high impedance | 287 | gpiod_set_value(desc, 1); open drain high impedance |
290 | gpiod_set_value(desc, 0); open source high impedance | 288 | gpiod_set_value(desc, 0); open source high impedance |
@@ -366,7 +364,7 @@ accessed sequentially. | |||
366 | The functions take three arguments: | 364 | The functions take three arguments: |
367 | * array_size - the number of array elements | 365 | * array_size - the number of array elements |
368 | * desc_array - an array of GPIO descriptors | 366 | * desc_array - an array of GPIO descriptors |
369 | * array_info - optional information obtained from gpiod_array_get() | 367 | * array_info - optional information obtained from gpiod_get_array() |
370 | * value_bitmap - a bitmap to store the GPIOs' values (get) or | 368 | * value_bitmap - a bitmap to store the GPIOs' values (get) or |
371 | a bitmap of values to assign to the GPIOs (set) | 369 | a bitmap of values to assign to the GPIOs (set) |
372 | 370 | ||
diff --git a/Documentation/driver-api/gpio/driver.rst b/Documentation/driver-api/gpio/driver.rst index 1ce7fcd0f989..4af9aae724f0 100644 --- a/Documentation/driver-api/gpio/driver.rst +++ b/Documentation/driver-api/gpio/driver.rst | |||
@@ -235,7 +235,7 @@ means that a pull up or pull-down resistor is available on the output of the | |||
235 | GPIO line, and this resistor is software controlled. | 235 | GPIO line, and this resistor is software controlled. |
236 | 236 | ||
237 | In discrete designs, a pull-up or pull-down resistor is simply soldered on | 237 | In discrete designs, a pull-up or pull-down resistor is simply soldered on |
238 | the circuit board. This is not something we deal or model in software. The | 238 | the circuit board. This is not something we deal with or model in software. The |
239 | most you will think about these lines is that they will very likely be | 239 | most you will think about these lines is that they will very likely be |
240 | configured as open drain or open source (see the section above). | 240 | configured as open drain or open source (see the section above). |
241 | 241 | ||
@@ -292,18 +292,18 @@ We can divide GPIO irqchips in two broad categories: | |||
292 | 292 | ||
293 | - HIERARCHICAL INTERRUPT CHIPS: this means that each GPIO line has a dedicated | 293 | - HIERARCHICAL INTERRUPT CHIPS: this means that each GPIO line has a dedicated |
294 | irq line to a parent interrupt controller one level up. There is no need | 294 | irq line to a parent interrupt controller one level up. There is no need |
295 | to inquire the GPIO hardware to figure out which line has figured, but it | 295 | to inquire the GPIO hardware to figure out which line has fired, but it |
296 | may still be necessary to acknowledge the interrupt and set up the | 296 | may still be necessary to acknowledge the interrupt and set up configuration |
297 | configuration such as edge sensitivity. | 297 | such as edge sensitivity. |
298 | 298 | ||
299 | Realtime considerations: a realtime compliant GPIO driver should not use | 299 | Realtime considerations: a realtime compliant GPIO driver should not use |
300 | spinlock_t or any sleepable APIs (like PM runtime) as part of its irqchip | 300 | spinlock_t or any sleepable APIs (like PM runtime) as part of its irqchip |
301 | implementation. | 301 | implementation. |
302 | 302 | ||
303 | - spinlock_t should be replaced with raw_spinlock_t [1]. | 303 | - spinlock_t should be replaced with raw_spinlock_t.[1] |
304 | - If sleepable APIs have to be used, these can be done from the .irq_bus_lock() | 304 | - If sleepable APIs have to be used, these can be done from the .irq_bus_lock() |
305 | and .irq_bus_unlock() callbacks, as these are the only slowpath callbacks | 305 | and .irq_bus_unlock() callbacks, as these are the only slowpath callbacks |
306 | on an irqchip. Create the callbacks if needed [2]. | 306 | on an irqchip. Create the callbacks if needed.[2] |
307 | 307 | ||
308 | 308 | ||
309 | Cascaded GPIO irqchips | 309 | Cascaded GPIO irqchips |
@@ -361,7 +361,7 @@ Cascaded GPIO irqchips usually fall in one of three categories: | |||
361 | 361 | ||
362 | Realtime considerations: this kind of handlers will be forced threaded on -RT, | 362 | Realtime considerations: this kind of handlers will be forced threaded on -RT, |
363 | and as result the IRQ core will complain that generic_handle_irq() is called | 363 | and as result the IRQ core will complain that generic_handle_irq() is called |
364 | with IRQ enabled and the same work around as for "CHAINED GPIO irqchips" can | 364 | with IRQ enabled and the same work-around as for "CHAINED GPIO irqchips" can |
365 | be applied. | 365 | be applied. |
366 | 366 | ||
367 | - NESTED THREADED GPIO IRQCHIPS: these are off-chip GPIO expanders and any | 367 | - NESTED THREADED GPIO IRQCHIPS: these are off-chip GPIO expanders and any |
@@ -418,7 +418,7 @@ symbol: | |||
418 | 418 | ||
419 | If there is a need to exclude certain GPIO lines from the IRQ domain handled by | 419 | If there is a need to exclude certain GPIO lines from the IRQ domain handled by |
420 | these helpers, we can set .irq.need_valid_mask of the gpiochip before | 420 | these helpers, we can set .irq.need_valid_mask of the gpiochip before |
421 | [devm_]gpiochip_add_data() is called. This allocates an .irq.valid_mask with as | 421 | ``[devm_]gpiochip_add_data()`` is called. This allocates an .irq.valid_mask with as |
422 | many bits set as there are GPIO lines in the chip, each bit representing line | 422 | many bits set as there are GPIO lines in the chip, each bit representing line |
423 | 0..n-1. Drivers can exclude GPIO lines by clearing bits from this mask. The mask | 423 | 0..n-1. Drivers can exclude GPIO lines by clearing bits from this mask. The mask |
424 | must be filled in before gpiochip_irqchip_add() or gpiochip_irqchip_add_nested() | 424 | must be filled in before gpiochip_irqchip_add() or gpiochip_irqchip_add_nested() |
diff --git a/Documentation/fmc/API.txt b/Documentation/fmc/API.txt deleted file mode 100644 index 06b06b92c794..000000000000 --- a/Documentation/fmc/API.txt +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | Functions Exported by fmc.ko | ||
2 | **************************** | ||
3 | |||
4 | The FMC core exports the usual 4 functions that are needed for a bus to | ||
5 | work, and a few more: | ||
6 | |||
7 | int fmc_driver_register(struct fmc_driver *drv); | ||
8 | void fmc_driver_unregister(struct fmc_driver *drv); | ||
9 | int fmc_device_register(struct fmc_device *fmc); | ||
10 | void fmc_device_unregister(struct fmc_device *fmc); | ||
11 | |||
12 | int fmc_device_register_n(struct fmc_device **fmc, int n); | ||
13 | void fmc_device_unregister_n(struct fmc_device **fmc, int n); | ||
14 | |||
15 | uint32_t fmc_readl(struct fmc_device *fmc, int offset); | ||
16 | void fmc_writel(struct fmc_device *fmc, uint32_t val, int off); | ||
17 | void *fmc_get_drvdata(struct fmc_device *fmc); | ||
18 | void fmc_set_drvdata(struct fmc_device *fmc, void *data); | ||
19 | |||
20 | int fmc_reprogram(struct fmc_device *f, struct fmc_driver *d, char *gw, | ||
21 | int sdb_entry); | ||
22 | |||
23 | The data structure that describe a device is detailed in *note FMC | ||
24 | Device::, the one that describes a driver is detailed in *note FMC | ||
25 | Driver::. Please note that structures of type fmc_device must be | ||
26 | allocated by the caller, but must not be released after unregistering. | ||
27 | The fmc-bus itself takes care of releasing the structure when their use | ||
28 | count reaches zero - actually, the device model does that in lieu of us. | ||
29 | |||
30 | The functions to register and unregister n devices are meant to be used | ||
31 | by carriers that host more than one mezzanine. The devices must all be | ||
32 | registered at the same time because if the FPGA is reprogrammed, all | ||
33 | devices in the array are affected. Usually, the driver matching the | ||
34 | first device will reprogram the FPGA, so other devices must know they | ||
35 | are already driven by a reprogrammed FPGA. | ||
36 | |||
37 | If a carrier hosts slots that are driven by different FPGA devices, it | ||
38 | should register as a group only mezzanines that are driven by the same | ||
39 | FPGA, for the reason outlined above. | ||
40 | |||
41 | Finally, the fmc_reprogram function calls the reprogram method (see | ||
42 | *note The API Offered by Carriers:: and also scans the memory area for | ||
43 | an SDB tree. You can pass -1 as sdb_entry to disable such scan. | ||
44 | Otherwise, the function fails if no tree is found at the specified | ||
45 | entry point. The function is meant to factorize common code, and by | ||
46 | the time you read this it is already used by the spec-sw and fine-delay | ||
47 | modules. | ||
diff --git a/Documentation/fmc/FMC-and-SDB.txt b/Documentation/fmc/FMC-and-SDB.txt deleted file mode 100644 index fa14e0b24521..000000000000 --- a/Documentation/fmc/FMC-and-SDB.txt +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | |||
2 | FMC (FPGA Mezzanine Card) is the standard we use for our I/O devices, | ||
3 | in the context of White Rabbit and related hardware. | ||
4 | |||
5 | In our I/O environments we need to write drivers for each mezzanine | ||
6 | card, and such drivers must work regardless of the carrier being used. | ||
7 | To achieve this, we abstract the FMC interface. | ||
8 | |||
9 | We have a carrier for PCI-E called SPEC and one for VME called SVEC, | ||
10 | but more are planned. Also, we support stand-alone devices (usually | ||
11 | plugged on a SPEC card), controlled through Etherbone, developed by GSI. | ||
12 | |||
13 | Code and documentation for the FMC bus was born as part of the spec-sw | ||
14 | project, but now it lives in its own project. Other projects, i.e. | ||
15 | software support for the various carriers, should include this as a | ||
16 | submodule. | ||
17 | |||
18 | The most up to date version of code and documentation is always | ||
19 | available from the repository you can clone from: | ||
20 | |||
21 | git://ohwr.org/fmc-projects/fmc-bus.git (read-only) | ||
22 | git@ohwr.org:fmc-projects/fmc-bus.git (read-write for developers) | ||
23 | |||
24 | Selected versions of the documentation, as well as complete tar | ||
25 | archives for selected revisions are placed to the Files section of the | ||
26 | project: `http://www.ohwr.org/projects/fmc-bus/files' | ||
27 | |||
28 | |||
29 | What is FMC | ||
30 | *********** | ||
31 | |||
32 | FMC, as said, stands for "FPGA Mezzanine Card". It is a standard | ||
33 | developed by the VME consortium called VITA (VMEbus International Trade | ||
34 | Association and ratified by ANSI, the American National Standard | ||
35 | Institute. The official documentation is called "ANSI-VITA 57.1". | ||
36 | |||
37 | The FMC card is an almost square PCB, around 70x75 millimeters, that is | ||
38 | called mezzanine in this document. It usually lives plugged into | ||
39 | another PCB for power supply and control; such bigger circuit board is | ||
40 | called carrier from now on, and a single carrier may host more than one | ||
41 | mezzanine. | ||
42 | |||
43 | In the typical application the mezzanine is mostly analog while the | ||
44 | carrier is mostly digital, and hosts an FPGA that must be configured to | ||
45 | match the specific mezzanine and the desired application. Thus, you may | ||
46 | need to load different FPGA images to drive different instances of the | ||
47 | same mezzanine. | ||
48 | |||
49 | FMC, as such, is not a bus in the usual meaning of the term, because | ||
50 | most carriers have only one connector, and carriers with several | ||
51 | connectors have completely separate electrical connections to them. | ||
52 | This package, however, implements a bus as a software abstraction. | ||
53 | |||
54 | |||
55 | What is SDB | ||
56 | *********** | ||
57 | |||
58 | SDB (Self Describing Bus) is a set of data structures that we use for | ||
59 | enumerating the internal structure of an FPGA image. We also use it as | ||
60 | a filesystem inside the FMC EEPROM. | ||
61 | |||
62 | SDB is not mandatory for use of this FMC kernel bus, but if you have SDB | ||
63 | this package can make good use of it. SDB itself is developed in the | ||
64 | fpga-config-space OHWR project. The link to the repository is | ||
65 | `git://ohwr.org/hdl-core-lib/fpga-config-space.git' and what is used in | ||
66 | this project lives in the sdbfs subdirectory in there. | ||
67 | |||
68 | SDB support for FMC is described in *note FMC Identification:: and | ||
69 | *note SDB Support:: | ||
70 | |||
71 | |||
72 | SDB Support | ||
73 | *********** | ||
74 | |||
75 | The fmc.ko bus driver exports a few functions to help drivers taking | ||
76 | advantage of the SDB information that may be present in your own FPGA | ||
77 | memory image. | ||
78 | |||
79 | The module exports the following functions, in the special header | ||
80 | <linux/fmc-sdb.h>. The linux/ prefix in the name is there because we | ||
81 | plan to submit it upstream in the future, and don't want to force | ||
82 | changes on our drivers if that happens. | ||
83 | |||
84 | int fmc_scan_sdb_tree(struct fmc_device *fmc, unsigned long address); | ||
85 | void fmc_show_sdb_tree(struct fmc_device *fmc); | ||
86 | signed long fmc_find_sdb_device(struct sdb_array *tree, uint64_t vendor, | ||
87 | uint32_t device, unsigned long *sz); | ||
88 | int fmc_free_sdb_tree(struct fmc_device *fmc); | ||
diff --git a/Documentation/fmc/carrier.txt b/Documentation/fmc/carrier.txt deleted file mode 100644 index 5e4f1dd3e98b..000000000000 --- a/Documentation/fmc/carrier.txt +++ /dev/null | |||
@@ -1,311 +0,0 @@ | |||
1 | FMC Device | ||
2 | ********** | ||
3 | |||
4 | Within the Linux bus framework, the FMC device is created and | ||
5 | registered by the carrier driver. For example, the PCI driver for the | ||
6 | SPEC card fills a data structure for each SPEC that it drives, and | ||
7 | registers an associated FMC device for each card. The SVEC driver can | ||
8 | do exactly the same for the VME carrier (actually, it should do it | ||
9 | twice, because the SVEC carries two FMC mezzanines). Similarly, an | ||
10 | Etherbone driver will be able to register its own FMC devices, offering | ||
11 | communication primitives through frame exchange. | ||
12 | |||
13 | The contents of the EEPROM within the FMC are used for identification | ||
14 | purposes, i.e. for matching the device with its own driver. For this | ||
15 | reason the device structure includes a complete copy of the EEPROM | ||
16 | (actually, the carrier driver may choose whether or not to return it - | ||
17 | for example we most likely won't have the whole EEPROM available for | ||
18 | Etherbone devices. | ||
19 | |||
20 | The following listing shows the current structure defining a device. | ||
21 | Please note that all the machinery is in place but some details may | ||
22 | still change in the future. For this reason, there is a version field | ||
23 | at the beginning of the structure. As usual, the minor number will | ||
24 | change for compatible changes (like a new flag) and the major number | ||
25 | will increase when an incompatible change happens (for example, a | ||
26 | change in layout of some fmc data structures). Device writers should | ||
27 | just set it to the value FMC_VERSION, and be ready to get back -EINVAL | ||
28 | at registration time. | ||
29 | |||
30 | struct fmc_device { | ||
31 | unsigned long version; | ||
32 | unsigned long flags; | ||
33 | struct module *owner; /* char device must pin it */ | ||
34 | struct fmc_fru_id id; /* for EEPROM-based match */ | ||
35 | struct fmc_operations *op; /* carrier-provided */ | ||
36 | int irq; /* according to host bus. 0 == none */ | ||
37 | int eeprom_len; /* Usually 8kB, may be less */ | ||
38 | int eeprom_addr; /* 0x50, 0x52 etc */ | ||
39 | uint8_t *eeprom; /* Full contents or leading part */ | ||
40 | char *carrier_name; /* "SPEC" or similar, for special use */ | ||
41 | void *carrier_data; /* "struct spec *" or equivalent */ | ||
42 | __iomem void *fpga_base; /* May be NULL (Etherbone) */ | ||
43 | __iomem void *slot_base; /* Set by the driver */ | ||
44 | struct fmc_device **devarray; /* Allocated by the bus */ | ||
45 | int slot_id; /* Index in the slot array */ | ||
46 | int nr_slots; /* Number of slots in this carrier */ | ||
47 | unsigned long memlen; /* Used for the char device */ | ||
48 | struct device dev; /* For Linux use */ | ||
49 | struct device *hwdev; /* The underlying hardware device */ | ||
50 | unsigned long sdbfs_entry; | ||
51 | struct sdb_array *sdb; | ||
52 | uint32_t device_id; /* Filled by the device */ | ||
53 | char *mezzanine_name; /* Defaults to ``fmc'' */ | ||
54 | void *mezzanine_data; | ||
55 | }; | ||
56 | |||
57 | The meaning of most fields is summarized in the code comment above. | ||
58 | |||
59 | The following fields must be filled by the carrier driver before | ||
60 | registration: | ||
61 | |||
62 | * version: must be set to FMC_VERSION. | ||
63 | |||
64 | * owner: set to MODULE_OWNER. | ||
65 | |||
66 | * op: the operations to act on the device. | ||
67 | |||
68 | * irq: number for the mezzanine; may be zero. | ||
69 | |||
70 | * eeprom_len: length of the following array. | ||
71 | |||
72 | * eeprom_addr: 0x50 for first mezzanine and so on. | ||
73 | |||
74 | * eeprom: the full content of the I2C EEPROM. | ||
75 | |||
76 | * carrier_name. | ||
77 | |||
78 | * carrier_data: a unique pointer for the carrier. | ||
79 | |||
80 | * fpga_base: the I/O memory address (may be NULL). | ||
81 | |||
82 | * slot_id: the index of this slot (starting from zero). | ||
83 | |||
84 | * memlen: if fpga_base is valid, the length of I/O memory. | ||
85 | |||
86 | * hwdev: to be used in some dev_err() calls. | ||
87 | |||
88 | * device_id: a slot-specific unique integer number. | ||
89 | |||
90 | |||
91 | Please note that the carrier should read its own EEPROM memory before | ||
92 | registering the device, as well as fill all other fields listed above. | ||
93 | |||
94 | The following fields should not be assigned, because they are filled | ||
95 | later by either the bus or the device driver: | ||
96 | |||
97 | * flags. | ||
98 | |||
99 | * fru_id: filled by the bus, parsing the eeprom. | ||
100 | |||
101 | * slot_base: filled and used by the driver, if useful to it. | ||
102 | |||
103 | * devarray: an array og all mezzanines driven by a singe FPGA. | ||
104 | |||
105 | * nr_slots: set by the core at registration time. | ||
106 | |||
107 | * dev: used by Linux. | ||
108 | |||
109 | * sdb: FPGA contents, scanned according to driver's directions. | ||
110 | |||
111 | * sdbfs_entry: SDB entry point in EEPROM: autodetected. | ||
112 | |||
113 | * mezzanine_data: available for the driver. | ||
114 | |||
115 | * mezzanine_name: filled by fmc-bus during identification. | ||
116 | |||
117 | |||
118 | Note: mezzanine_data may be redundant, because Linux offers the drvdata | ||
119 | approach, so the field may be removed in later versions of this bus | ||
120 | implementation. | ||
121 | |||
122 | As I write this, she SPEC carrier is already completely functional in | ||
123 | the fmc-bus environment, and is a good reference to look at. | ||
124 | |||
125 | |||
126 | The API Offered by Carriers | ||
127 | =========================== | ||
128 | |||
129 | The carrier provides a number of methods by means of the | ||
130 | `fmc_operations' structure, which currently is defined like this | ||
131 | (again, it is a moving target, please refer to the header rather than | ||
132 | this document): | ||
133 | |||
134 | struct fmc_operations { | ||
135 | uint32_t (*readl)(struct fmc_device *fmc, int offset); | ||
136 | void (*writel)(struct fmc_device *fmc, uint32_t value, int offset); | ||
137 | int (*reprogram)(struct fmc_device *f, struct fmc_driver *d, char *gw); | ||
138 | int (*validate)(struct fmc_device *fmc, struct fmc_driver *drv); | ||
139 | int (*irq_request)(struct fmc_device *fmc, irq_handler_t h, | ||
140 | char *name, int flags); | ||
141 | void (*irq_ack)(struct fmc_device *fmc); | ||
142 | int (*irq_free)(struct fmc_device *fmc); | ||
143 | int (*gpio_config)(struct fmc_device *fmc, struct fmc_gpio *gpio, | ||
144 | int ngpio); | ||
145 | int (*read_ee)(struct fmc_device *fmc, int pos, void *d, int l); | ||
146 | int (*write_ee)(struct fmc_device *fmc, int pos, const void *d, int l); | ||
147 | }; | ||
148 | |||
149 | The individual methods perform the following tasks: | ||
150 | |||
151 | `readl' | ||
152 | `writel' | ||
153 | These functions access FPGA registers by whatever means the | ||
154 | carrier offers. They are not expected to fail, and most of the time | ||
155 | they will just make a memory access to the host bus. If the | ||
156 | carrier provides a fpga_base pointer, the driver may use direct | ||
157 | access through that pointer. For this reason the header offers the | ||
158 | inline functions fmc_readl and fmc_writel that access fpga_base if | ||
159 | the respective method is NULL. A driver that wants to be portable | ||
160 | and efficient should use fmc_readl and fmc_writel. For Etherbone, | ||
161 | or other non-local carriers, error-management is still to be | ||
162 | defined. | ||
163 | |||
164 | `validate' | ||
165 | Module parameters are used to manage different applications for | ||
166 | two or more boards of the same kind. Validation is based on the | ||
167 | busid module parameter, if provided, and returns the matching | ||
168 | index in the associated array. See *note Module Parameters:: in in | ||
169 | doubt. If no match is found, `-ENOENT' is returned; if the user | ||
170 | didn't pass `busid=', all devices will pass validation. The value | ||
171 | returned by the validate method can be used as index into other | ||
172 | parameters (for example, some drivers use the `lm32=' parameter in | ||
173 | this way). Such "generic parameters" are documented in *note | ||
174 | Module Parameters::, below. The validate method is used by | ||
175 | `fmc-trivial.ko', described in *note fmc-trivial::. | ||
176 | |||
177 | `reprogram' | ||
178 | The carrier enumerates FMC devices by loading a standard (or | ||
179 | golden) FPGA binary that allows EEPROM access. Each driver, then, | ||
180 | will need to reprogram the FPGA by calling this function. If the | ||
181 | name argument is NULL, the carrier should reprogram the golden | ||
182 | binary. If the gateware name has been overridden through module | ||
183 | parameters (in a carrier-specific way) the file loaded will match | ||
184 | the parameters. Per-device gateware names can be specified using | ||
185 | the `gateware=' parameter, see *note Module Parameters::. Note: | ||
186 | Clients should call rhe new helper, fmc_reprogram, which both | ||
187 | calls this method and parse the SDB tree of the FPGA. | ||
188 | |||
189 | `irq_request' | ||
190 | `irq_ack' | ||
191 | `irq_free' | ||
192 | Interrupt management is carrier-specific, so it is abstracted as | ||
193 | operations. The interrupt number is listed in the device | ||
194 | structure, and for the mezzanine driver the number is only | ||
195 | informative. The handler will receive the fmc pointer as dev_id; | ||
196 | the flags argument is passed to the Linux request_irq function, | ||
197 | but fmc-specific flags may be added in the future. You'll most | ||
198 | likely want to pass the `IRQF_SHARED' flag. | ||
199 | |||
200 | `gpio_config' | ||
201 | The method allows to configure a GPIO pin in the carrier, and read | ||
202 | its current value if it is configured as input. See *note The GPIO | ||
203 | Abstraction:: for details. | ||
204 | |||
205 | `read_ee' | ||
206 | `write_ee' | ||
207 | Read or write the EEPROM. The functions are expected to be only | ||
208 | called before reprogramming and the carrier should refuse them | ||
209 | with `ENODEV' after reprogramming. The offset is expected to be | ||
210 | within 8kB (the current size), but addresses up to 1MB are | ||
211 | reserved to fit bigger I2C devices in the future. Carriers may | ||
212 | offer access to other internal flash memories using these same | ||
213 | methods: for example the SPEC driver may define that its carrier | ||
214 | I2C memory is seen at offset 1M and the internal SPI flash is seen | ||
215 | at offset 16M. This multiplexing of several flash memories in the | ||
216 | same address space is carrier-specific and should only be used | ||
217 | by a driver that has verified the `carrier_name' field. | ||
218 | |||
219 | |||
220 | |||
221 | The GPIO Abstraction | ||
222 | ==================== | ||
223 | |||
224 | Support for GPIO pins in the fmc-bus environment is not very | ||
225 | straightforward and deserves special discussion. | ||
226 | |||
227 | While the general idea of a carrier-independent driver seems to fly, | ||
228 | configuration of specific signals within the carrier needs at least | ||
229 | some knowledge of the carrier itself. For this reason, the specific | ||
230 | driver can request to configure carrier-specific GPIO pins, numbered | ||
231 | from 0 to at most 4095. Configuration is performed by passing a | ||
232 | pointer to an array of struct fmc_gpio items, as well as the length of | ||
233 | the array. This is the data structure: | ||
234 | |||
235 | struct fmc_gpio { | ||
236 | char *carrier_name; | ||
237 | int gpio; | ||
238 | int _gpio; /* internal use by the carrier */ | ||
239 | int mode; /* GPIOF_DIR_OUT etc, from <linux/gpio.h> */ | ||
240 | int irqmode; /* IRQF_TRIGGER_LOW and so on */ | ||
241 | }; | ||
242 | |||
243 | By specifying a carrier_name for each pin, the driver may access | ||
244 | different pins in different carriers. The gpio_config method is | ||
245 | expected to return the number of pins successfully configured, ignoring | ||
246 | requests for other carriers. However, if no pin is configured (because | ||
247 | no structure at all refers to the current carrier_name), the operation | ||
248 | returns an error so the caller will know that it is running under a | ||
249 | yet-unsupported carrier. | ||
250 | |||
251 | So, for example, a driver that has been developed and tested on both | ||
252 | the SPEC and the SVEC may request configuration of two different GPIO | ||
253 | pins, and expect one such configuration to succeed - if none succeeds | ||
254 | it most likely means that the current carrier is a still-unknown one. | ||
255 | |||
256 | If, however, your GPIO pin has a specific known role, you can pass a | ||
257 | special number in the gpio field, using one of the following macros: | ||
258 | |||
259 | #define FMC_GPIO_RAW(x) (x) /* 4096 of them */ | ||
260 | #define FMC_GPIO_IRQ(x) ((x) + 0x1000) /* 256 of them */ | ||
261 | #define FMC_GPIO_LED(x) ((x) + 0x1100) /* 256 of them */ | ||
262 | #define FMC_GPIO_KEY(x) ((x) + 0x1200) /* 256 of them */ | ||
263 | #define FMC_GPIO_TP(x) ((x) + 0x1300) /* 256 of them */ | ||
264 | #define FMC_GPIO_USER(x) ((x) + 0x1400) /* 256 of them */ | ||
265 | |||
266 | Use of virtual GPIO numbers (anything but FMC_GPIO_RAW) is allowed | ||
267 | provided the carrier_name field in the data structure is left | ||
268 | unspecified (NULL). Each carrier is responsible for providing a mapping | ||
269 | between virtual and physical GPIO numbers. The carrier may then use the | ||
270 | _gpio field to cache the result of this mapping. | ||
271 | |||
272 | All carriers must map their I/O lines to the sets above starting from | ||
273 | zero. The SPEC, for example, maps interrupt pins 0 and 1, and test | ||
274 | points 0 through 3 (even if the test points on the PCB are called | ||
275 | 5,6,7,8). | ||
276 | |||
277 | If, for example, a driver requires a free LED and a test point (for a | ||
278 | scope probe to be plugged at some point during development) it may ask | ||
279 | for FMC_GPIO_LED(0) and FMC_GPIO_TP(0). Each carrier will provide | ||
280 | suitable GPIO pins. Clearly, the person running the drivers will know | ||
281 | the order used by the specific carrier driver in assigning leds and | ||
282 | testpoints, so to make a carrier-dependent use of the diagnostic tools. | ||
283 | |||
284 | In theory, some form of autodetection should be possible: a driver like | ||
285 | the wr-nic (which uses IRQ(1) on the SPEC card) should configure | ||
286 | IRQ(0), make a test with software-generated interrupts and configure | ||
287 | IRQ(1) if the test fails. This probing step should be used because even | ||
288 | if the wr-nic gateware is known to use IRQ1 on the SPEC, the driver | ||
289 | should be carrier-independent and thus use IRQ(0) as a first bet - | ||
290 | actually, the knowledge that IRQ0 may fail is carrier-dependent | ||
291 | information, but using it doesn't make the driver unsuitable for other | ||
292 | carriers. | ||
293 | |||
294 | The return value of gpio_config is defined as follows: | ||
295 | |||
296 | * If no pin in the array can be used by the carrier, `-ENODEV'. | ||
297 | |||
298 | * If at least one virtual GPIO number cannot be mapped, `-ENOENT'. | ||
299 | |||
300 | * On success, 0 or positive. The value returned is the number of | ||
301 | high input bits (if no input is configured, the value for success | ||
302 | is 0). | ||
303 | |||
304 | While I admit the procedure is not completely straightforward, it | ||
305 | allows configuration, input and output with a single carrier operation. | ||
306 | Given the typical use case of FMC devices, GPIO operations are not | ||
307 | expected to ever by in hot paths, and GPIO access so fare has only been | ||
308 | used to configure the interrupt pin, mode and polarity. Especially | ||
309 | reading inputs is not expected to be common. If your device has GPIO | ||
310 | capabilities in the hot path, you should consider using the kernel's | ||
311 | GPIO mechanisms. | ||
diff --git a/Documentation/fmc/fmc-chardev.txt b/Documentation/fmc/fmc-chardev.txt deleted file mode 100644 index d9ccb278e597..000000000000 --- a/Documentation/fmc/fmc-chardev.txt +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | fmc-chardev | ||
2 | =========== | ||
3 | |||
4 | This is a simple generic driver, that allows user access by means of a | ||
5 | character device (actually, one for each mezzanine it takes hold of). | ||
6 | |||
7 | The char device is created as a misc device. Its name in /dev (as | ||
8 | created by udev) is the same name as the underlying FMC device. Thus, | ||
9 | the name can be a silly fmc-0000 look-alike if the device has no | ||
10 | identifiers nor bus_id, a more specific fmc-0400 if the device has a | ||
11 | bus-specific address but no associated name, or something like | ||
12 | fdelay-0400 if the FMC core can rely on both a mezzanine name and a bus | ||
13 | address. | ||
14 | |||
15 | Currently the driver only supports read and write: you can lseek to the | ||
16 | desired address and read or write a register. | ||
17 | |||
18 | The driver assumes all registers are 32-bit in size, and only accepts a | ||
19 | single read or write per system call. However, as a result of Unix read | ||
20 | and write semantics, users can simply fread or fwrite bigger areas in | ||
21 | order to dump or store bigger memory areas. | ||
22 | |||
23 | There is currently no support for mmap, user-space interrupt management | ||
24 | and DMA buffers. They may be added in later versions, if the need | ||
25 | arises. | ||
26 | |||
27 | The example below shows raw access to a SPEC card programmed with its | ||
28 | golden FPGA file, that features an SDB structure at offset 256 - i.e. | ||
29 | 64 words. The mezzanine's EEPROM in this case is not programmed, so the | ||
30 | default name is fmc-<bus><devfn>, and there are two cards in the system: | ||
31 | |||
32 | spusa.root# insmod fmc-chardev.ko | ||
33 | [ 1073.339332] spec 0000:02:00.0: Driver has no ID: matches all | ||
34 | [ 1073.345051] spec 0000:02:00.0: Created misc device "fmc-0200" | ||
35 | [ 1073.350821] spec 0000:04:00.0: Driver has no ID: matches all | ||
36 | [ 1073.356525] spec 0000:04:00.0: Created misc device "fmc-0400" | ||
37 | spusa.root# ls -l /dev/fmc* | ||
38 | crw------- 1 root root 10, 58 Nov 20 19:23 /dev/fmc-0200 | ||
39 | crw------- 1 root root 10, 57 Nov 20 19:23 /dev/fmc-0400 | ||
40 | spusa.root# dd bs=4 skip=64 count=1 if=/dev/fmc-0200 2> /dev/null | od -t x1z | ||
41 | 0000000 2d 42 44 53 >-BDS< | ||
42 | 0000004 | ||
43 | |||
44 | The simple program tools/fmc-mem in this package can access an FMC char | ||
45 | device and read or write a word or a whole area. Actually, the program | ||
46 | is not specific to FMC at all, it just uses lseek, read and write. | ||
47 | |||
48 | Its first argument is the device name, the second the offset, the third | ||
49 | (if any) the value to write and the optional last argument that must | ||
50 | begin with "+" is the number of bytes to read or write. In case of | ||
51 | repeated reading data is written to stdout; repeated writes read from | ||
52 | stdin and the value argument is ignored. | ||
53 | |||
54 | The following examples show reading the SDB magic number and the first | ||
55 | SDB record from a SPEC device programmed with its golden image: | ||
56 | |||
57 | spusa.root# ./fmc-mem /dev/fmc-0200 100 | ||
58 | 5344422d | ||
59 | spusa.root# ./fmc-mem /dev/fmc-0200 100 +40 | od -Ax -t x1z | ||
60 | 000000 2d 42 44 53 00 01 02 00 00 00 00 00 00 00 00 00 >-BDS............< | ||
61 | 000010 00 00 00 00 ff 01 00 00 00 00 00 00 51 06 00 00 >............Q...< | ||
62 | 000020 c9 42 a5 e6 02 00 00 00 11 05 12 20 2d 34 42 57 >.B......... -4BW< | ||
63 | 000030 73 6f 72 43 72 61 62 73 49 53 47 2d 00 20 20 20 >sorCrabsISG-. < | ||
64 | 000040 | ||
diff --git a/Documentation/fmc/fmc-fakedev.txt b/Documentation/fmc/fmc-fakedev.txt deleted file mode 100644 index e85b74a4ae30..000000000000 --- a/Documentation/fmc/fmc-fakedev.txt +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | fmc-fakedev | ||
2 | =========== | ||
3 | |||
4 | This package includes a software-only device, called fmc-fakedev, which | ||
5 | is able to register up to 4 mezzanines (by default it registers one). | ||
6 | Unlike the SPEC driver, which creates an FMC device for each PCI cards | ||
7 | it manages, this module creates a single instance of its set of | ||
8 | mezzanines. | ||
9 | |||
10 | It is meant as the simplest possible example of how a driver should be | ||
11 | written, and it includes a fake EEPROM image (built using the tools | ||
12 | described in *note FMC Identification::),, which by default is | ||
13 | replicated for each fake mezzanine. | ||
14 | |||
15 | You can also use this device to verify the match algorithms, by asking | ||
16 | it to test your own EEPROM image. You can provide the image by means of | ||
17 | the eeprom= module parameter: the new EEPROM image is loaded, as usual, | ||
18 | by means of the firmware loader. This example shows the defaults and a | ||
19 | custom EEPROM image: | ||
20 | |||
21 | spusa.root# insmod fmc-fakedev.ko | ||
22 | [ 99.971247] fake-fmc-carrier: mezzanine 0 | ||
23 | [ 99.975393] Manufacturer: fake-vendor | ||
24 | [ 99.979624] Product name: fake-design-for-testing | ||
25 | spusa.root# rmmod fmc-fakedev | ||
26 | spusa.root# insmod fmc-fakedev.ko eeprom=fdelay-eeprom.bin | ||
27 | [ 121.447464] fake-fmc-carrier: Mezzanine 0: eeprom "fdelay-eeprom.bin" | ||
28 | [ 121.462725] fake-fmc-carrier: mezzanine 0 | ||
29 | [ 121.466858] Manufacturer: CERN | ||
30 | [ 121.470477] Product name: FmcDelay1ns4cha | ||
31 | spusa.root# rmmod fmc-fakedev | ||
32 | |||
33 | After loading the device, you can use the write_ee method do modify its | ||
34 | own internal fake EEPROM: whenever the image is overwritten starting at | ||
35 | offset 0, the module will unregister and register again the FMC device. | ||
36 | This is shown in fmc-write-eeprom.txt | ||
diff --git a/Documentation/fmc/fmc-trivial.txt b/Documentation/fmc/fmc-trivial.txt deleted file mode 100644 index d1910bc67159..000000000000 --- a/Documentation/fmc/fmc-trivial.txt +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | fmc-trivial | ||
2 | =========== | ||
3 | |||
4 | The simple module fmc-trivial is just a simple client that registers an | ||
5 | interrupt handler. I used it to verify the basic mechanism of the FMC | ||
6 | bus and how interrupts worked. | ||
7 | |||
8 | The module implements the generic FMC parameters, so it can program a | ||
9 | different gateware file in each card. The whole list of parameters it | ||
10 | accepts are: | ||
11 | |||
12 | `busid=' | ||
13 | `gateware=' | ||
14 | Generic parameters. See mezzanine.txt | ||
15 | |||
16 | |||
17 | This driver is worth reading, in my opinion. | ||
diff --git a/Documentation/fmc/fmc-write-eeprom.txt b/Documentation/fmc/fmc-write-eeprom.txt deleted file mode 100644 index e0a9712156aa..000000000000 --- a/Documentation/fmc/fmc-write-eeprom.txt +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | fmc-write-eeprom | ||
2 | ================ | ||
3 | |||
4 | This module is designed to load a binary file from /lib/firmware and to | ||
5 | write it to the internal EEPROM of the mezzanine card. This driver uses | ||
6 | the `busid' generic parameter. | ||
7 | |||
8 | Overwriting the EEPROM is not something you should do daily, and it is | ||
9 | expected to only happen during manufacturing. For this reason, the | ||
10 | module makes it unlikely for the random user to change a working EEPROM. | ||
11 | |||
12 | However, since the EEPROM may include application-specific information | ||
13 | other than the identification, later versions of this packages added | ||
14 | write-support through sysfs. See *note Accessing the EEPROM::. | ||
15 | |||
16 | To avoid damaging the EEPROM content, the module takes the following | ||
17 | measures: | ||
18 | |||
19 | * It accepts a `file=' argument (within /lib/firmware) and if no | ||
20 | such argument is received, it doesn't write anything to EEPROM | ||
21 | (i.e. there is no default file name). | ||
22 | |||
23 | * If the file name ends with `.bin' it is written verbatim starting | ||
24 | at offset 0. | ||
25 | |||
26 | * If the file name ends with `.tlv' it is interpreted as | ||
27 | type-length-value (i.e., it allows writev(2)-like operation). | ||
28 | |||
29 | * If the file name doesn't match any of the patterns above, it is | ||
30 | ignored and no write is performed. | ||
31 | |||
32 | * Only cards listed with `busid=' are written to. If no busid is | ||
33 | specified, no programming is done (and the probe function of the | ||
34 | driver will fail). | ||
35 | |||
36 | |||
37 | Each TLV tuple is formatted in this way: the header is 5 bytes, | ||
38 | followed by data. The first byte is `w' for write, the next two bytes | ||
39 | represent the address, in little-endian byte order, and the next two | ||
40 | represent the data length, in little-endian order. The length does not | ||
41 | include the header (it is the actual number of bytes to be written). | ||
42 | |||
43 | This is a real example: that writes 5 bytes at position 0x110: | ||
44 | |||
45 | spusa.root# od -t x1 -Ax /lib/firmware/try.tlv | ||
46 | 000000 77 10 01 05 00 30 31 32 33 34 | ||
47 | 00000a | ||
48 | spusa.root# insmod /tmp/fmc-write-eeprom.ko busid=0x0200 file=try.tlv | ||
49 | [19983.391498] spec 0000:03:00.0: write 5 bytes at 0x0110 | ||
50 | [19983.414615] spec 0000:03:00.0: write_eeprom: success | ||
51 | |||
52 | Please note that you'll most likely want to use SDBFS to build your | ||
53 | EEPROM image, at least if your mezzanines are being used in the White | ||
54 | Rabbit environment. For this reason the TLV format is not expected to | ||
55 | be used much and is not expected to be developed further. | ||
56 | |||
57 | If you want to try reflashing fake EEPROM devices, you can use the | ||
58 | fmc-fakedev.ko module (see *note fmc-fakedev::). Whenever you change | ||
59 | the image starting at offset 0, it will deregister and register again | ||
60 | after two seconds. Please note, however, that if fmc-write-eeprom is | ||
61 | still loaded, the system will associate it to the new device, which | ||
62 | will be reprogrammed and thus will be unloaded after two seconds. The | ||
63 | following example removes the module after it reflashed fakedev the | ||
64 | first time. | ||
65 | |||
66 | spusa.root# insmod fmc-fakedev.ko | ||
67 | [ 72.984733] fake-fmc: Manufacturer: fake-vendor | ||
68 | [ 72.989434] fake-fmc: Product name: fake-design-for-testing | ||
69 | spusa.root# insmod fmc-write-eeprom.ko busid=0 file=fdelay-eeprom.bin; \ | ||
70 | rmmod fmc-write-eeprom | ||
71 | [ 130.874098] fake-fmc: Matching a generic driver (no ID) | ||
72 | [ 130.887845] fake-fmc: programming 6155 bytes | ||
73 | [ 130.894567] fake-fmc: write_eeprom: success | ||
74 | [ 132.895794] fake-fmc: Manufacturer: CERN | ||
75 | [ 132.899872] fake-fmc: Product name: FmcDelay1ns4cha | ||
76 | |||
77 | |||
78 | Accessing the EEPROM | ||
79 | ===================== | ||
80 | |||
81 | The bus creates a sysfs binary file called eeprom for each mezzanine it | ||
82 | knows about: | ||
83 | |||
84 | spusa.root# cd /sys/bus/fmc/devices; ls -l */eeprom | ||
85 | -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcAdc100m14b4cha-0800/eeprom | ||
86 | -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcDelay1ns4cha-0200/eeprom | ||
87 | -r--r--r-- 1 root root 8192 Feb 21 12:30 FmcDio5cha-0400/eeprom | ||
88 | |||
89 | Everybody can read the files and the superuser can also modify it, but | ||
90 | the operation may on the carrier driver, if the carrier is unable to | ||
91 | access the I2C bus. For example, the spec driver can access the bus | ||
92 | only with its golden gateware: after a mezzanine driver reprogrammed | ||
93 | the FPGA with a custom circuit, the carrier is unable to access the | ||
94 | EEPROM and returns ENOTSUPP. | ||
95 | |||
96 | An alternative way to write the EEPROM is the mezzanine driver | ||
97 | fmc-write-eeprom (See *note fmc-write-eeprom::), but the procedure is | ||
98 | more complex. | ||
diff --git a/Documentation/fmc/identifiers.txt b/Documentation/fmc/identifiers.txt deleted file mode 100644 index 3bb577ff0d52..000000000000 --- a/Documentation/fmc/identifiers.txt +++ /dev/null | |||
@@ -1,168 +0,0 @@ | |||
1 | FMC Identification | ||
2 | ****************** | ||
3 | |||
4 | The FMC standard requires every compliant mezzanine to carry | ||
5 | identification information in an I2C EEPROM. The information must be | ||
6 | laid out according to the "IPMI Platform Management FRU Information", | ||
7 | where IPMI is a lie I'd better not expand, and FRU means "Field | ||
8 | Replaceable Unit". | ||
9 | |||
10 | The FRU information is an intricate unreadable binary blob that must | ||
11 | live at offset 0 of the EEPROM, and typically extends for a few hundred | ||
12 | bytes. The standard allows the application to use all the remaining | ||
13 | storage area of the EEPROM as it wants. | ||
14 | |||
15 | This chapter explains how to create your own EEPROM image and how to | ||
16 | write it in your mezzanine, as well as how devices and drivers are | ||
17 | paired at run time. EEPROM programming uses tools that are part of this | ||
18 | package and SDB (part of the fpga-config-space package). | ||
19 | |||
20 | The first sections are only interesting for manufacturers who need to | ||
21 | write the EEPROM. If you are just a software developer writing an FMC | ||
22 | device or driver, you may jump straight to *note SDB Support::. | ||
23 | |||
24 | |||
25 | Building the FRU Structure | ||
26 | ========================== | ||
27 | |||
28 | If you want to know the internals of the FRU structure and despair, you | ||
29 | can retrieve the document from | ||
30 | `http://download.intel.com/design/servers/ipmi/FRU1011.pdf' . The | ||
31 | standard is awful and difficult without reason, so we only support the | ||
32 | minimum mandatory subset - we create a simple structure and parse it | ||
33 | back at run time, but we are not able to either generate or parse more | ||
34 | arcane features like non-english languages and 6-bit text. If you need | ||
35 | more items of the FRU standard for your boards, please submit patches. | ||
36 | |||
37 | This package includes the Python script that Matthieu Cattin wrote to | ||
38 | generate the FRU binary blob, based on an helper libipmi by Manohar | ||
39 | Vanga and Matthieu himself. I changed the test script to receive | ||
40 | parameters from the command line or from the environment (the command | ||
41 | line takes precedence) | ||
42 | |||
43 | To make a long story short, in order to build a standard-compliant | ||
44 | binary file to be burned in your EEPROM, you need the following items: | ||
45 | |||
46 | Environment Opt Official Name Default | ||
47 | --------------------------------------------------------------------- | ||
48 | FRU_VENDOR -v "Board Manufacturer" fmc-example | ||
49 | FRU_NAME -n "Board Product Name" mezzanine | ||
50 | FRU_SERIAL -s `Board Serial Number" 0001 | ||
51 | FRU_PART -p "Board Part Number" sample-part | ||
52 | FRU_OUTPUT -o not applicable /dev/stdout | ||
53 | |||
54 | The "Official Name" above is what you find in the FRU official | ||
55 | documentation, chapter 11, page 7 ("Board Info Area Format"). The | ||
56 | output option is used to save the generated binary to a specific file | ||
57 | name instead of stdout. | ||
58 | |||
59 | You can pass the items to the FRU generator either in the environment | ||
60 | or on the command line. This package has currently no support for | ||
61 | specifying power consumption or such stuff, but I plan to add it as | ||
62 | soon as I find some time for that. | ||
63 | |||
64 | FIXME: consumption etc for FRU are here or in PTS? | ||
65 | |||
66 | The following example creates a binary image for a specific board: | ||
67 | |||
68 | ./tools/fru-generator -v CERN -n FmcAdc100m14b4cha \ | ||
69 | -s HCCFFIA___-CR000003 -p EDA-02063-V5-0 > eeprom.bin | ||
70 | |||
71 | The following example shows a script that builds several binary EEPROM | ||
72 | images for a series of boards, changing the serial number for each of | ||
73 | them. The script uses a mix of environment variables and command line | ||
74 | options, and uses the same string patterns shown above. | ||
75 | |||
76 | #!/bin/sh | ||
77 | |||
78 | export FRU_VENDOR="CERN" | ||
79 | export FRU_NAME="FmcAdc100m14b4cha" | ||
80 | export FRU_PART="EDA-02063-V5-0" | ||
81 | |||
82 | serial="HCCFFIA___-CR" | ||
83 | |||
84 | for number in $(seq 1 50); do | ||
85 | # build number-string "ns" | ||
86 | ns="$(printf %06d $number)" | ||
87 | ./fru-generator -s "${serial}${ns}" > eeprom-${ns}.bin | ||
88 | done | ||
89 | |||
90 | |||
91 | Using SDB-FS in the EEPROM | ||
92 | ========================== | ||
93 | |||
94 | If you want to use SDB as a filesystem in the EEPROM device within the | ||
95 | mezzanine, you should create one such filesystem using gensdbfs, from | ||
96 | the fpga-config-space package on OHWR. | ||
97 | |||
98 | By using an SBD filesystem you can cluster several files in a single | ||
99 | EEPROM, so both the host system and a soft-core running in the FPGA (if | ||
100 | any) can access extra production-time information. | ||
101 | |||
102 | We chose to use SDB as a storage filesystem because the format is very | ||
103 | simple, and both the host system and the soft-core will likely already | ||
104 | include support code for such format. The SDB library offered by the | ||
105 | fpga-config-space is less than 1kB under LM32, so it proves quite up to | ||
106 | the task. | ||
107 | |||
108 | The SDB entry point (which acts as a directory listing) cannot live at | ||
109 | offset zero in the flash device, because the FRU information must live | ||
110 | there. To avoid wasting precious storage space while still allowing | ||
111 | for more-than-minimal FRU structures, the fmc.ko will look for the SDB | ||
112 | record at address 256, 512 and 1024. | ||
113 | |||
114 | In order to generate the complete EEPROM image you'll need a | ||
115 | configuration file for gensdbfs: you tell the program where to place | ||
116 | the sdb entry point, and you must force the FRU data file to be placed | ||
117 | at the beginning of the storage device. If needed, you can also place | ||
118 | other files at a special offset (we sometimes do it for backward | ||
119 | compatibility with drivers we wrote before implementing SDB for flash | ||
120 | memory). | ||
121 | |||
122 | The directory tools/sdbfs of this package includes a well-commented | ||
123 | example that you may want to use as a starting point (the comments are | ||
124 | in the file called -SDB-CONFIG-). Reading documentation for gensdbfs | ||
125 | is a suggested first step anyways. | ||
126 | |||
127 | This package (generic FMC bus support) only accesses two files in the | ||
128 | EEPROM: the FRU information, at offset zero, with a suggested filename | ||
129 | of IPMI-FRU and the short name for the mezzanine, in a file called | ||
130 | name. The IPMI-FRU name is not mandatory, but a strongly suggested | ||
131 | choice; the name filename is mandatory, because this is the preferred | ||
132 | short name used by the FMC core. For example, a name of "fdelay" may | ||
133 | supplement a Product Name like "FmcDelay1ns4cha" - exactly as | ||
134 | demonstrated in `tools/sdbfs'. | ||
135 | |||
136 | Note: SDB access to flash memory is not yet supported, so the short | ||
137 | name currently in use is just the "Product Name" FRU string. | ||
138 | |||
139 | The example in tools/sdbfs includes an extra file, that is needed by | ||
140 | the fine-delay driver, and must live at a known address of 0x1800. By | ||
141 | running gensdbfs on that directory you can output your binary EEPROM | ||
142 | image (here below spusa$ is the shell prompt): | ||
143 | |||
144 | spusa$ ../fru-generator -v CERN -n FmcDelay1ns4cha -s proto-0 \ | ||
145 | -p EDA-02267-V3 > IPMI-FRU | ||
146 | spusa$ ls -l | ||
147 | total 16 | ||
148 | -rw-rw-r-- 1 rubini staff 975 Nov 19 18:08 --SDB-CONFIG-- | ||
149 | -rw-rw-r-- 1 rubini staff 216 Nov 19 18:13 IPMI-FRU | ||
150 | -rw-rw-r-- 1 rubini staff 11 Nov 19 18:04 fd-calib | ||
151 | -rw-rw-r-- 1 rubini staff 7 Nov 19 18:04 name | ||
152 | spusa$ sudo gensdbfs . /lib/firmware/fdelay-eeprom.bin | ||
153 | spusa$ sdb-read -l -e 0x100 /lib/firmware/fdelay-eeprom.bin | ||
154 | /home/rubini/wip/sdbfs/userspace/sdb-read: listing format is to be defined | ||
155 | 46696c6544617461:2e202020 00000100-000018ff . | ||
156 | 46696c6544617461:6e616d65 00000200-00000206 name | ||
157 | 46696c6544617461:66642d63 00001800-000018ff fd-calib | ||
158 | 46696c6544617461:49504d49 00000000-000000d7 IPMI-FRU | ||
159 | spusa$ ../fru-dump /lib/firmware/fdelay-eeprom.bin | ||
160 | /lib/firmware/fdelay-eeprom.bin: manufacturer: CERN | ||
161 | /lib/firmware/fdelay-eeprom.bin: product-name: FmcDelay1ns4cha | ||
162 | /lib/firmware/fdelay-eeprom.bin: serial-number: proto-0 | ||
163 | /lib/firmware/fdelay-eeprom.bin: part-number: EDA-02267-V3 | ||
164 | |||
165 | As expected, the output file is both a proper sdbfs object and an IPMI | ||
166 | FRU information blob. The fd-calib file lives at offset 0x1800 and is | ||
167 | over-allocated to 256 bytes, according to the configuration file for | ||
168 | gensdbfs. | ||
diff --git a/Documentation/fmc/mezzanine.txt b/Documentation/fmc/mezzanine.txt deleted file mode 100644 index 87910dbfc91e..000000000000 --- a/Documentation/fmc/mezzanine.txt +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | FMC Driver | ||
2 | ********** | ||
3 | |||
4 | An FMC driver is concerned with the specific mezzanine and associated | ||
5 | gateware. As such, it is expected to be independent of the carrier | ||
6 | being used: it will perform I/O accesses only by means of | ||
7 | carrier-provided functions. | ||
8 | |||
9 | The matching between device and driver is based on the content of the | ||
10 | EEPROM (as mandated by the FMC standard) or by the actual cores | ||
11 | configured in the FPGA; the latter technique is used when the FPGA is | ||
12 | already programmed when the device is registered to the bus core. | ||
13 | |||
14 | In some special cases it is possible for a driver to directly access | ||
15 | FPGA registers, by means of the `fpga_base' field of the device | ||
16 | structure. This may be needed for high-bandwidth peripherals like fast | ||
17 | ADC cards. If the device module registered a remote device (for example | ||
18 | by means of Etherbone), the `fpga_base' pointer will be NULL. | ||
19 | Therefore, drivers must be ready to deal with NULL base pointers, and | ||
20 | fail gracefully. Most driver, however, are not expected to access the | ||
21 | pointer directly but run fmc_readl and fmc_writel instead, which will | ||
22 | work in any case. | ||
23 | |||
24 | In even more special cases, the driver may access carrier-specific | ||
25 | functionality: the `carrier_name' string allows the driver to check | ||
26 | which is the current carrier and make use of the `carrier_data' | ||
27 | pointer. We chose to use carrier names rather than numeric identifiers | ||
28 | for greater flexibility, but also to avoid a central registry within | ||
29 | the `fmc.h' file - we hope other users will exploit our framework with | ||
30 | their own carriers. An example use of carrier names is in GPIO setup | ||
31 | (see *note The GPIO Abstraction::), although the name match is not | ||
32 | expected to be performed by the driver. If you depend on specific | ||
33 | carriers, please check the carrier name and fail gracefully if your | ||
34 | driver finds it is running in a yet-unknown-to-it environment. | ||
35 | |||
36 | |||
37 | ID Table | ||
38 | ======== | ||
39 | |||
40 | Like most other Linux drivers, and FMC driver must list all the devices | ||
41 | which it is able to drive. This is usually done by means of a device | ||
42 | table, but in FMC we can match hardware based either on the contents of | ||
43 | their EEPROM or on the actual FPGA cores that can be enumerated. | ||
44 | Therefore, we have two tables of identifiers. | ||
45 | |||
46 | Matching of FRU information depends on two names, the manufacturer (or | ||
47 | vendor) and the device (see *note FMC Identification::); for | ||
48 | flexibility during production (i.e. before writing to the EEPROM) the | ||
49 | bus supports a catch-all driver that specifies NULL strings. For this | ||
50 | reason, the table is specified as pointer-and-length, not a a | ||
51 | null-terminated array - the entry with NULL names can be a valid entry. | ||
52 | |||
53 | Matching on FPGA cores depends on two numeric fields: the 64-bit vendor | ||
54 | number and the 32-bit device number. Support for matching based on | ||
55 | class is not yet implemented. Each device is expected to be uniquely | ||
56 | identified by an array of cores (it matches if all of the cores are | ||
57 | instantiated), and for consistency the list is passed as | ||
58 | pointer-and-length. Several similar devices can be driven by the same | ||
59 | driver, and thus the driver specifies and array of such arrays. | ||
60 | |||
61 | The complete set of involved data structures is thus the following: | ||
62 | |||
63 | struct fmc_fru_id { char *manufacturer; char *product_name; }; | ||
64 | struct fmc_sdb_one_id { uint64_t vendor; uint32_t device; }; | ||
65 | struct fmc_sdb_id { struct fmc_sdb_one_id *cores; int cores_nr; }; | ||
66 | |||
67 | struct fmc_device_id { | ||
68 | struct fmc_fru_id *fru_id; int fru_id_nr; | ||
69 | struct fmc_sdb_id *sdb_id; int sdb_id_nr; | ||
70 | }; | ||
71 | |||
72 | A better reference, with full explanation, is the <linux/fmc.h> header. | ||
73 | |||
74 | |||
75 | Module Parameters | ||
76 | ================= | ||
77 | |||
78 | Most of the FMC drivers need the same set of kernel parameters. This | ||
79 | package includes support to implement common parameters by means of | ||
80 | fields in the `fmc_driver' structure and simple macro definitions. | ||
81 | |||
82 | The parameters are carrier-specific, in that they rely on the busid | ||
83 | concept, that varies among carriers. For the SPEC, the identifier is a | ||
84 | PCI bus and devfn number, 16 bits wide in total; drivers for other | ||
85 | carriers will most likely offer something similar but not identical, | ||
86 | and some code duplication is unavoidable. | ||
87 | |||
88 | This is the list of parameters that are common to several modules to | ||
89 | see how they are actually used, please look at spec-trivial.c. | ||
90 | |||
91 | `busid=' | ||
92 | This is an array of integers, listing carrier-specific | ||
93 | identification numbers. For PIC, for example, `0x0400' represents | ||
94 | bus 4, slot 0. If any such ID is specified, the driver will only | ||
95 | accept to drive cards that appear in the list (even if the FMC ID | ||
96 | matches). This is accomplished by the validate carrier method. | ||
97 | |||
98 | `gateware=' | ||
99 | The argument is an array of strings. If no busid= is specified, | ||
100 | the first string of gateware= is used for all cards; otherwise the | ||
101 | identifiers and gateware names are paired one by one, in the order | ||
102 | specified. | ||
103 | |||
104 | `show_sdb=' | ||
105 | For modules supporting it, this parameter asks to show the SDB | ||
106 | internal structure by means of kernel messages. It is disabled by | ||
107 | default because those lines tend to hide more important messages, | ||
108 | if you look at the system console while loading the drivers. | ||
109 | Note: the parameter is being obsoleted, because fmc.ko itself now | ||
110 | supports dump_sdb= that applies to every client driver. | ||
111 | |||
112 | |||
113 | For example, if you are using the trivial driver to load two different | ||
114 | gateware files to two different cards, you can use the following | ||
115 | parameters to load different binaries to the cards, after looking up | ||
116 | the PCI identifiers. This has been tested with a SPEC carrier. | ||
117 | |||
118 | insmod fmc-trivial.ko \ | ||
119 | busid=0x0200,0x0400 \ | ||
120 | gateware=fmc/fine-delay.bin,fmc/simple-dio.bin | ||
121 | |||
122 | Please note that not all sub-modules support all of those parameters. | ||
123 | You can use modinfo to check what is supported by each module. | ||
diff --git a/Documentation/fmc/parameters.txt b/Documentation/fmc/parameters.txt deleted file mode 100644 index 59edf088e3a4..000000000000 --- a/Documentation/fmc/parameters.txt +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | Module Parameters in fmc.ko | ||
2 | *************************** | ||
3 | |||
4 | The core driver receives two module parameters, meant to help debugging | ||
5 | client modules. Both parameters can be modified by writing to | ||
6 | /sys/module/fmc/parameters/, because they are used when client drivers | ||
7 | are devices are registered, not when fmc.ko is loaded. | ||
8 | |||
9 | `dump_eeprom=' | ||
10 | If not zero, the parameter asks the bus controller to dump the | ||
11 | EEPROM of any device that is registered, using printk. | ||
12 | |||
13 | `dump_sdb=' | ||
14 | If not zero, the parameter prints the SDB tree of every FPGA it is | ||
15 | loaded by fmc_reprogram(). If greater than one, it asks to dump | ||
16 | the binary content of SDB records. This currently only dumps the | ||
17 | top-level SDB array, though. | ||
18 | |||
19 | |||
20 | EEPROM dumping avoids repeating lines, since most of the contents is | ||
21 | usually empty and all bits are one or zero. This is an example of the | ||
22 | output: | ||
23 | |||
24 | [ 6625.850480] spec 0000:02:00.0: FPGA programming successful | ||
25 | [ 6626.139949] spec 0000:02:00.0: Manufacturer: CERN | ||
26 | [ 6626.144666] spec 0000:02:00.0: Product name: FmcDelay1ns4cha | ||
27 | [ 6626.150370] FMC: mezzanine 0: 0000:02:00.0 on SPEC | ||
28 | [ 6626.155179] FMC: dumping eeprom 0x2000 (8192) bytes | ||
29 | [ 6626.160087] 0000: 01 00 00 01 00 0b 00 f3 01 0a 00 a5 85 87 c4 43 | ||
30 | [ 6626.167069] 0010: 45 52 4e cf 46 6d 63 44 65 6c 61 79 31 6e 73 34 | ||
31 | [ 6626.174019] 0020: 63 68 61 c7 70 72 6f 74 6f 2d 30 cc 45 44 41 2d | ||
32 | [ 6626.180975] 0030: 30 32 32 36 37 2d 56 33 da 32 30 31 32 2d 31 31 | ||
33 | [...] | ||
34 | [ 6626.371366] 0200: 66 64 65 6c 61 79 0a 00 00 00 00 00 00 00 00 00 | ||
35 | [ 6626.378359] 0210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ||
36 | [ 6626.385361] [...] | ||
37 | [ 6626.387308] 1800: 70 6c 61 63 65 68 6f 6c 64 65 72 ff ff ff ff ff | ||
38 | [ 6626.394259] 1810: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff | ||
39 | [ 6626.401250] [...] | ||
40 | |||
41 | The dump of SDB looks like the following; the example shows the simple | ||
42 | golden gateware for the SPEC card, removing the leading timestamps to | ||
43 | fit the page: | ||
44 | |||
45 | spec 0000:02:00.0: SDB: 00000651:e6a542c9 WB4-Crossbar-GSI | ||
46 | spec 0000:02:00.0: SDB: 0000ce42:ff07fc47 WR-Periph-Syscon (00000000-000000ff) | ||
47 | FMC: mezzanine 0: 0000:02:00.0 on SPEC | ||
48 | FMC: poor dump of sdb first level: | ||
49 | 0000: 53 44 42 2d 00 02 01 00 00 00 00 00 00 00 00 00 | ||
50 | 0010: 00 00 00 00 00 00 01 ff 00 00 00 00 00 00 06 51 | ||
51 | 0020: e6 a5 42 c9 00 00 00 02 20 12 05 11 57 42 34 2d | ||
52 | 0030: 43 72 6f 73 73 62 61 72 2d 47 53 49 20 20 20 00 | ||
53 | 0040: 00 00 01 01 00 00 00 07 00 00 00 00 00 00 00 00 | ||
54 | 0050: 00 00 00 00 00 00 00 ff 00 00 00 00 00 00 ce 42 | ||
55 | 0060: ff 07 fc 47 00 00 00 01 20 12 03 05 57 52 2d 50 | ||
56 | 0070: 65 72 69 70 68 2d 53 79 73 63 6f 6e 20 20 20 01 | ||
diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c index 0af2bf6f9933..43899fa56674 100644 --- a/arch/arm/mach-omap1/ams-delta-fiq.c +++ b/arch/arm/mach-omap1/ams-delta-fiq.c | |||
@@ -11,6 +11,7 @@ | |||
11 | * in the MontaVista 2.4 kernel (and the Amstrad changes therein) | 11 | * in the MontaVista 2.4 kernel (and the Amstrad changes therein) |
12 | */ | 12 | */ |
13 | #include <linux/gpio/consumer.h> | 13 | #include <linux/gpio/consumer.h> |
14 | #include <linux/gpio/machine.h> | ||
14 | #include <linux/gpio/driver.h> | 15 | #include <linux/gpio/driver.h> |
15 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
16 | #include <linux/irq.h> | 17 | #include <linux/irq.h> |
@@ -99,7 +100,8 @@ void __init ams_delta_init_fiq(struct gpio_chip *chip, | |||
99 | } | 100 | } |
100 | 101 | ||
101 | for (i = 0; i < ARRAY_SIZE(irq_data); i++) { | 102 | for (i = 0; i < ARRAY_SIZE(irq_data); i++) { |
102 | gpiod = gpiochip_request_own_desc(chip, i, pin_name[i], 0); | 103 | gpiod = gpiochip_request_own_desc(chip, i, pin_name[i], |
104 | GPIO_ACTIVE_HIGH, GPIOD_IN); | ||
103 | if (IS_ERR(gpiod)) { | 105 | if (IS_ERR(gpiod)) { |
104 | pr_err("%s: failed to get GPIO pin %d (%ld)\n", | 106 | pr_err("%s: failed to get GPIO pin %d (%ld)\n", |
105 | __func__, i, PTR_ERR(gpiod)); | 107 | __func__, i, PTR_ERR(gpiod)); |
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 36498ea1b2f3..e47a6fbcfd6e 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | #include <linux/gpio/driver.h> | 11 | #include <linux/gpio/driver.h> |
12 | #include <linux/gpio/machine.h> | 12 | #include <linux/gpio/machine.h> |
13 | #include <linux/gpio/consumer.h> | ||
13 | #include <linux/gpio.h> | 14 | #include <linux/gpio.h> |
14 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
15 | #include <linux/init.h> | 16 | #include <linux/init.h> |
@@ -606,12 +607,12 @@ static void __init modem_assign_irq(struct gpio_chip *chip) | |||
606 | struct gpio_desc *gpiod; | 607 | struct gpio_desc *gpiod; |
607 | 608 | ||
608 | gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ, | 609 | gpiod = gpiochip_request_own_desc(chip, AMS_DELTA_GPIO_PIN_MODEM_IRQ, |
609 | "modem_irq", 0); | 610 | "modem_irq", GPIO_ACTIVE_HIGH, |
611 | GPIOD_IN); | ||
610 | if (IS_ERR(gpiod)) { | 612 | if (IS_ERR(gpiod)) { |
611 | pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__, | 613 | pr_err("%s: modem IRQ GPIO request failed (%ld)\n", __func__, |
612 | PTR_ERR(gpiod)); | 614 | PTR_ERR(gpiod)); |
613 | } else { | 615 | } else { |
614 | gpiod_direction_input(gpiod); | ||
615 | ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod); | 616 | ams_delta_modem_ports[0].irq = gpiod_to_irq(gpiod); |
616 | } | 617 | } |
617 | } | 618 | } |
diff --git a/drivers/Kconfig b/drivers/Kconfig index e8231663f201..61cf4ea2c229 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig | |||
@@ -188,8 +188,6 @@ source "drivers/ipack/Kconfig" | |||
188 | 188 | ||
189 | source "drivers/reset/Kconfig" | 189 | source "drivers/reset/Kconfig" |
190 | 190 | ||
191 | source "drivers/fmc/Kconfig" | ||
192 | |||
193 | source "drivers/phy/Kconfig" | 191 | source "drivers/phy/Kconfig" |
194 | 192 | ||
195 | source "drivers/powercap/Kconfig" | 193 | source "drivers/powercap/Kconfig" |
diff --git a/drivers/Makefile b/drivers/Makefile index 28b030d7988d..6d37564e783c 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -168,7 +168,6 @@ obj-$(CONFIG_IIO) += iio/ | |||
168 | obj-$(CONFIG_VME_BUS) += vme/ | 168 | obj-$(CONFIG_VME_BUS) += vme/ |
169 | obj-$(CONFIG_IPACK_BUS) += ipack/ | 169 | obj-$(CONFIG_IPACK_BUS) += ipack/ |
170 | obj-$(CONFIG_NTB) += ntb/ | 170 | obj-$(CONFIG_NTB) += ntb/ |
171 | obj-$(CONFIG_FMC) += fmc/ | ||
172 | obj-$(CONFIG_POWERCAP) += powercap/ | 171 | obj-$(CONFIG_POWERCAP) += powercap/ |
173 | obj-$(CONFIG_MCB) += mcb/ | 172 | obj-$(CONFIG_MCB) += mcb/ |
174 | obj-$(CONFIG_PERF_EVENTS) += perf/ | 173 | obj-$(CONFIG_PERF_EVENTS) += perf/ |
diff --git a/drivers/fmc/Kconfig b/drivers/fmc/Kconfig deleted file mode 100644 index ae3d7f634932..000000000000 --- a/drivers/fmc/Kconfig +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0-only | ||
2 | # | ||
3 | # FMC (ANSI-VITA 57.1) bus support | ||
4 | # | ||
5 | |||
6 | menuconfig FMC | ||
7 | tristate "FMC support" | ||
8 | help | ||
9 | |||
10 | FMC (FPGA Mezzanine Carrier) is a mechanical and electrical | ||
11 | standard for mezzanine cards that plug into a carrier board. | ||
12 | This kernel subsystem supports the matching between carrier | ||
13 | and mezzanine based on identifiers stored in the internal I2C | ||
14 | EEPROM, as well as having carrier-independent drivers. | ||
15 | |||
16 | The framework was born outside of the kernel and at this time | ||
17 | the off-tree code base is more complete. Code and documentation | ||
18 | is at git://ohwr.org/fmc-projects/fmc-bus.git . | ||
19 | |||
20 | if FMC | ||
21 | |||
22 | config FMC_FAKEDEV | ||
23 | tristate "FMC fake device (software testing)" | ||
24 | help | ||
25 | This is a fake carrier, bringing a default EEPROM content | ||
26 | that can be rewritten at run time and usef for matching | ||
27 | mezzanines. | ||
28 | |||
29 | config FMC_TRIVIAL | ||
30 | tristate "FMC trivial mezzanine driver (software testing)" | ||
31 | help | ||
32 | This is a fake mezzanine driver, to show how FMC works and test it. | ||
33 | The driver also handles interrupts (we used it with a real carrier | ||
34 | before the mezzanines were produced) | ||
35 | |||
36 | config FMC_WRITE_EEPROM | ||
37 | tristate "FMC mezzanine driver to write I2C EEPROM" | ||
38 | help | ||
39 | This driver matches every mezzanine device and can write the | ||
40 | internal EEPROM of the PCB, using the firmware loader to get | ||
41 | its binary and the function carrier->reprogram to actually do it. | ||
42 | It is useful when the mezzanines are produced. | ||
43 | |||
44 | config FMC_CHARDEV | ||
45 | tristate "FMC mezzanine driver that registers a char device" | ||
46 | help | ||
47 | This driver matches every mezzanine device and allows user | ||
48 | space to read and write registers using a char device. It | ||
49 | can be used to write user-space drivers, or just get | ||
50 | acquainted with a mezzanine before writing its specific driver. | ||
51 | |||
52 | endif # FMC | ||
diff --git a/drivers/fmc/Makefile b/drivers/fmc/Makefile deleted file mode 100644 index e3da6192cf39..000000000000 --- a/drivers/fmc/Makefile +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | # SPDX-License-Identifier: GPL-2.0 | ||
2 | |||
3 | obj-$(CONFIG_FMC) += fmc.o | ||
4 | |||
5 | fmc-y = fmc-core.o | ||
6 | fmc-y += fmc-match.o | ||
7 | fmc-y += fmc-sdb.o | ||
8 | fmc-y += fru-parse.o | ||
9 | fmc-y += fmc-dump.o | ||
10 | fmc-y += fmc-debug.o | ||
11 | |||
12 | obj-$(CONFIG_FMC_FAKEDEV) += fmc-fakedev.o | ||
13 | obj-$(CONFIG_FMC_TRIVIAL) += fmc-trivial.o | ||
14 | obj-$(CONFIG_FMC_WRITE_EEPROM) += fmc-write-eeprom.o | ||
15 | obj-$(CONFIG_FMC_CHARDEV) += fmc-chardev.o | ||
diff --git a/drivers/fmc/fmc-chardev.c b/drivers/fmc/fmc-chardev.c deleted file mode 100644 index 7d2091b5e978..000000000000 --- a/drivers/fmc/fmc-chardev.c +++ /dev/null | |||
@@ -1,199 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
4 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
5 | * | ||
6 | * This work is part of the White Rabbit project, a research effort led | ||
7 | * by CERN, the European Institute for Nuclear Research. | ||
8 | */ | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/list.h> | ||
12 | #include <linux/slab.h> | ||
13 | #include <linux/fs.h> | ||
14 | #include <linux/miscdevice.h> | ||
15 | #include <linux/spinlock.h> | ||
16 | #include <linux/fmc.h> | ||
17 | #include <linux/uaccess.h> | ||
18 | |||
19 | static LIST_HEAD(fc_devices); | ||
20 | static DEFINE_SPINLOCK(fc_lock); | ||
21 | |||
22 | struct fc_instance { | ||
23 | struct list_head list; | ||
24 | struct fmc_device *fmc; | ||
25 | struct miscdevice misc; | ||
26 | }; | ||
27 | |||
28 | /* at open time, we must identify our device */ | ||
29 | static int fc_open(struct inode *ino, struct file *f) | ||
30 | { | ||
31 | struct fmc_device *fmc; | ||
32 | struct fc_instance *fc; | ||
33 | int minor = iminor(ino); | ||
34 | |||
35 | list_for_each_entry(fc, &fc_devices, list) | ||
36 | if (fc->misc.minor == minor) | ||
37 | break; | ||
38 | if (fc->misc.minor != minor) | ||
39 | return -ENODEV; | ||
40 | fmc = fc->fmc; | ||
41 | if (try_module_get(fmc->owner) == 0) | ||
42 | return -ENODEV; | ||
43 | |||
44 | f->private_data = fmc; | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static int fc_release(struct inode *ino, struct file *f) | ||
49 | { | ||
50 | struct fmc_device *fmc = f->private_data; | ||
51 | module_put(fmc->owner); | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | /* read and write are simple after the default llseek has been used */ | ||
56 | static ssize_t fc_read(struct file *f, char __user *buf, size_t count, | ||
57 | loff_t *offp) | ||
58 | { | ||
59 | struct fmc_device *fmc = f->private_data; | ||
60 | unsigned long addr; | ||
61 | uint32_t val; | ||
62 | |||
63 | if (count < sizeof(val)) | ||
64 | return -EINVAL; | ||
65 | count = sizeof(val); | ||
66 | |||
67 | addr = *offp; | ||
68 | if (addr > fmc->memlen) | ||
69 | return -ESPIPE; /* Illegal seek */ | ||
70 | val = fmc_readl(fmc, addr); | ||
71 | if (copy_to_user(buf, &val, count)) | ||
72 | return -EFAULT; | ||
73 | *offp += count; | ||
74 | return count; | ||
75 | } | ||
76 | |||
77 | static ssize_t fc_write(struct file *f, const char __user *buf, size_t count, | ||
78 | loff_t *offp) | ||
79 | { | ||
80 | struct fmc_device *fmc = f->private_data; | ||
81 | unsigned long addr; | ||
82 | uint32_t val; | ||
83 | |||
84 | if (count < sizeof(val)) | ||
85 | return -EINVAL; | ||
86 | count = sizeof(val); | ||
87 | |||
88 | addr = *offp; | ||
89 | if (addr > fmc->memlen) | ||
90 | return -ESPIPE; /* Illegal seek */ | ||
91 | if (copy_from_user(&val, buf, count)) | ||
92 | return -EFAULT; | ||
93 | fmc_writel(fmc, val, addr); | ||
94 | *offp += count; | ||
95 | return count; | ||
96 | } | ||
97 | |||
98 | static const struct file_operations fc_fops = { | ||
99 | .owner = THIS_MODULE, | ||
100 | .open = fc_open, | ||
101 | .release = fc_release, | ||
102 | .llseek = generic_file_llseek, | ||
103 | .read = fc_read, | ||
104 | .write = fc_write, | ||
105 | }; | ||
106 | |||
107 | |||
108 | /* Device part .. */ | ||
109 | static int fc_probe(struct fmc_device *fmc); | ||
110 | static int fc_remove(struct fmc_device *fmc); | ||
111 | |||
112 | static struct fmc_driver fc_drv = { | ||
113 | .version = FMC_VERSION, | ||
114 | .driver.name = KBUILD_MODNAME, | ||
115 | .probe = fc_probe, | ||
116 | .remove = fc_remove, | ||
117 | /* no table: we want to match everything */ | ||
118 | }; | ||
119 | |||
120 | /* We accept the generic busid parameter */ | ||
121 | FMC_PARAM_BUSID(fc_drv); | ||
122 | |||
123 | /* probe and remove must allocate and release a misc device */ | ||
124 | static int fc_probe(struct fmc_device *fmc) | ||
125 | { | ||
126 | int ret; | ||
127 | int index = 0; | ||
128 | |||
129 | struct fc_instance *fc; | ||
130 | |||
131 | index = fmc_validate(fmc, &fc_drv); | ||
132 | if (index < 0) | ||
133 | return -EINVAL; /* not our device: invalid */ | ||
134 | |||
135 | /* Create a char device: we want to create it anew */ | ||
136 | fc = kzalloc(sizeof(*fc), GFP_KERNEL); | ||
137 | if (!fc) | ||
138 | return -ENOMEM; | ||
139 | fc->fmc = fmc; | ||
140 | fc->misc.minor = MISC_DYNAMIC_MINOR; | ||
141 | fc->misc.fops = &fc_fops; | ||
142 | fc->misc.name = kstrdup(dev_name(&fmc->dev), GFP_KERNEL); | ||
143 | |||
144 | ret = misc_register(&fc->misc); | ||
145 | if (ret < 0) | ||
146 | goto out; | ||
147 | spin_lock(&fc_lock); | ||
148 | list_add(&fc->list, &fc_devices); | ||
149 | spin_unlock(&fc_lock); | ||
150 | dev_info(&fc->fmc->dev, "Created misc device \"%s\"\n", | ||
151 | fc->misc.name); | ||
152 | return 0; | ||
153 | |||
154 | out: | ||
155 | kfree(fc->misc.name); | ||
156 | kfree(fc); | ||
157 | return ret; | ||
158 | } | ||
159 | |||
160 | static int fc_remove(struct fmc_device *fmc) | ||
161 | { | ||
162 | struct fc_instance *fc; | ||
163 | |||
164 | list_for_each_entry(fc, &fc_devices, list) | ||
165 | if (fc->fmc == fmc) | ||
166 | break; | ||
167 | if (fc->fmc != fmc) { | ||
168 | dev_err(&fmc->dev, "remove called but not found\n"); | ||
169 | return -ENODEV; | ||
170 | } | ||
171 | |||
172 | spin_lock(&fc_lock); | ||
173 | list_del(&fc->list); | ||
174 | spin_unlock(&fc_lock); | ||
175 | misc_deregister(&fc->misc); | ||
176 | kfree(fc->misc.name); | ||
177 | kfree(fc); | ||
178 | |||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | |||
183 | static int fc_init(void) | ||
184 | { | ||
185 | int ret; | ||
186 | |||
187 | ret = fmc_driver_register(&fc_drv); | ||
188 | return ret; | ||
189 | } | ||
190 | |||
191 | static void fc_exit(void) | ||
192 | { | ||
193 | fmc_driver_unregister(&fc_drv); | ||
194 | } | ||
195 | |||
196 | module_init(fc_init); | ||
197 | module_exit(fc_exit); | ||
198 | |||
199 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/fmc/fmc-core.c b/drivers/fmc/fmc-core.c deleted file mode 100644 index 573f5471f680..000000000000 --- a/drivers/fmc/fmc-core.c +++ /dev/null | |||
@@ -1,388 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
4 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
5 | * | ||
6 | * This work is part of the White Rabbit project, a research effort led | ||
7 | * by CERN, the European Institute for Nuclear Research. | ||
8 | */ | ||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/slab.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/device.h> | ||
14 | #include <linux/fmc.h> | ||
15 | #include <linux/fmc-sdb.h> | ||
16 | |||
17 | #include "fmc-private.h" | ||
18 | |||
19 | static int fmc_check_version(unsigned long version, const char *name) | ||
20 | { | ||
21 | if (__FMC_MAJOR(version) != FMC_MAJOR) { | ||
22 | pr_err("%s: \"%s\" has wrong major (has %li, expected %i)\n", | ||
23 | __func__, name, __FMC_MAJOR(version), FMC_MAJOR); | ||
24 | return -EINVAL; | ||
25 | } | ||
26 | |||
27 | if (__FMC_MINOR(version) != FMC_MINOR) | ||
28 | pr_info("%s: \"%s\" has wrong minor (has %li, expected %i)\n", | ||
29 | __func__, name, __FMC_MINOR(version), FMC_MINOR); | ||
30 | return 0; | ||
31 | } | ||
32 | |||
33 | static int fmc_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
34 | { | ||
35 | /* struct fmc_device *fdev = to_fmc_device(dev); */ | ||
36 | |||
37 | /* FIXME: The MODALIAS */ | ||
38 | add_uevent_var(env, "MODALIAS=%s", "fmc"); | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | static int fmc_probe(struct device *dev) | ||
43 | { | ||
44 | struct fmc_driver *fdrv = to_fmc_driver(dev->driver); | ||
45 | struct fmc_device *fdev = to_fmc_device(dev); | ||
46 | |||
47 | return fdrv->probe(fdev); | ||
48 | } | ||
49 | |||
50 | static int fmc_remove(struct device *dev) | ||
51 | { | ||
52 | struct fmc_driver *fdrv = to_fmc_driver(dev->driver); | ||
53 | struct fmc_device *fdev = to_fmc_device(dev); | ||
54 | |||
55 | return fdrv->remove(fdev); | ||
56 | } | ||
57 | |||
58 | static void fmc_shutdown(struct device *dev) | ||
59 | { | ||
60 | /* not implemented but mandatory */ | ||
61 | } | ||
62 | |||
63 | static struct bus_type fmc_bus_type = { | ||
64 | .name = "fmc", | ||
65 | .match = fmc_match, | ||
66 | .uevent = fmc_uevent, | ||
67 | .probe = fmc_probe, | ||
68 | .remove = fmc_remove, | ||
69 | .shutdown = fmc_shutdown, | ||
70 | }; | ||
71 | |||
72 | static void fmc_release(struct device *dev) | ||
73 | { | ||
74 | struct fmc_device *fmc = container_of(dev, struct fmc_device, dev); | ||
75 | |||
76 | kfree(fmc); | ||
77 | } | ||
78 | |||
79 | /* | ||
80 | * The eeprom is exported in sysfs, through a binary attribute | ||
81 | */ | ||
82 | |||
83 | static ssize_t fmc_read_eeprom(struct file *file, struct kobject *kobj, | ||
84 | struct bin_attribute *bin_attr, | ||
85 | char *buf, loff_t off, size_t count) | ||
86 | { | ||
87 | struct device *dev; | ||
88 | struct fmc_device *fmc; | ||
89 | int eelen; | ||
90 | |||
91 | dev = container_of(kobj, struct device, kobj); | ||
92 | fmc = container_of(dev, struct fmc_device, dev); | ||
93 | eelen = fmc->eeprom_len; | ||
94 | if (off > eelen) | ||
95 | return -ESPIPE; | ||
96 | if (off == eelen) | ||
97 | return 0; /* EOF */ | ||
98 | if (off + count > eelen) | ||
99 | count = eelen - off; | ||
100 | memcpy(buf, fmc->eeprom + off, count); | ||
101 | return count; | ||
102 | } | ||
103 | |||
104 | static ssize_t fmc_write_eeprom(struct file *file, struct kobject *kobj, | ||
105 | struct bin_attribute *bin_attr, | ||
106 | char *buf, loff_t off, size_t count) | ||
107 | { | ||
108 | struct device *dev; | ||
109 | struct fmc_device *fmc; | ||
110 | |||
111 | dev = container_of(kobj, struct device, kobj); | ||
112 | fmc = container_of(dev, struct fmc_device, dev); | ||
113 | return fmc->op->write_ee(fmc, off, buf, count); | ||
114 | } | ||
115 | |||
116 | static struct bin_attribute fmc_eeprom_attr = { | ||
117 | .attr = { .name = "eeprom", .mode = S_IRUGO | S_IWUSR, }, | ||
118 | .size = 8192, /* more or less standard */ | ||
119 | .read = fmc_read_eeprom, | ||
120 | .write = fmc_write_eeprom, | ||
121 | }; | ||
122 | |||
123 | int fmc_irq_request(struct fmc_device *fmc, irq_handler_t h, | ||
124 | char *name, int flags) | ||
125 | { | ||
126 | if (fmc->op->irq_request) | ||
127 | return fmc->op->irq_request(fmc, h, name, flags); | ||
128 | return -EPERM; | ||
129 | } | ||
130 | EXPORT_SYMBOL(fmc_irq_request); | ||
131 | |||
132 | void fmc_irq_free(struct fmc_device *fmc) | ||
133 | { | ||
134 | if (fmc->op->irq_free) | ||
135 | fmc->op->irq_free(fmc); | ||
136 | } | ||
137 | EXPORT_SYMBOL(fmc_irq_free); | ||
138 | |||
139 | void fmc_irq_ack(struct fmc_device *fmc) | ||
140 | { | ||
141 | if (likely(fmc->op->irq_ack)) | ||
142 | fmc->op->irq_ack(fmc); | ||
143 | } | ||
144 | EXPORT_SYMBOL(fmc_irq_ack); | ||
145 | |||
146 | int fmc_validate(struct fmc_device *fmc, struct fmc_driver *drv) | ||
147 | { | ||
148 | if (fmc->op->validate) | ||
149 | return fmc->op->validate(fmc, drv); | ||
150 | return -EPERM; | ||
151 | } | ||
152 | EXPORT_SYMBOL(fmc_validate); | ||
153 | |||
154 | int fmc_gpio_config(struct fmc_device *fmc, struct fmc_gpio *gpio, int ngpio) | ||
155 | { | ||
156 | if (fmc->op->gpio_config) | ||
157 | return fmc->op->gpio_config(fmc, gpio, ngpio); | ||
158 | return -EPERM; | ||
159 | } | ||
160 | EXPORT_SYMBOL(fmc_gpio_config); | ||
161 | |||
162 | int fmc_read_ee(struct fmc_device *fmc, int pos, void *d, int l) | ||
163 | { | ||
164 | if (fmc->op->read_ee) | ||
165 | return fmc->op->read_ee(fmc, pos, d, l); | ||
166 | return -EPERM; | ||
167 | } | ||
168 | EXPORT_SYMBOL(fmc_read_ee); | ||
169 | |||
170 | int fmc_write_ee(struct fmc_device *fmc, int pos, const void *d, int l) | ||
171 | { | ||
172 | if (fmc->op->write_ee) | ||
173 | return fmc->op->write_ee(fmc, pos, d, l); | ||
174 | return -EPERM; | ||
175 | } | ||
176 | EXPORT_SYMBOL(fmc_write_ee); | ||
177 | |||
178 | /* | ||
179 | * Functions for client modules follow | ||
180 | */ | ||
181 | |||
182 | int fmc_driver_register(struct fmc_driver *drv) | ||
183 | { | ||
184 | if (fmc_check_version(drv->version, drv->driver.name)) | ||
185 | return -EINVAL; | ||
186 | drv->driver.bus = &fmc_bus_type; | ||
187 | return driver_register(&drv->driver); | ||
188 | } | ||
189 | EXPORT_SYMBOL(fmc_driver_register); | ||
190 | |||
191 | void fmc_driver_unregister(struct fmc_driver *drv) | ||
192 | { | ||
193 | driver_unregister(&drv->driver); | ||
194 | } | ||
195 | EXPORT_SYMBOL(fmc_driver_unregister); | ||
196 | |||
197 | /* | ||
198 | * When a device set is registered, all eeproms must be read | ||
199 | * and all FRUs must be parsed | ||
200 | */ | ||
201 | int fmc_device_register_n_gw(struct fmc_device **devs, int n, | ||
202 | struct fmc_gateware *gw) | ||
203 | { | ||
204 | struct fmc_device *fmc, **devarray; | ||
205 | uint32_t device_id; | ||
206 | int i, ret = 0; | ||
207 | |||
208 | if (n < 1) | ||
209 | return 0; | ||
210 | |||
211 | /* Check the version of the first data structure (function prints) */ | ||
212 | if (fmc_check_version(devs[0]->version, devs[0]->carrier_name)) | ||
213 | return -EINVAL; | ||
214 | |||
215 | devarray = kmemdup(devs, n * sizeof(*devs), GFP_KERNEL); | ||
216 | if (!devarray) | ||
217 | return -ENOMEM; | ||
218 | |||
219 | /* Make all other checks before continuing, for all devices */ | ||
220 | for (i = 0; i < n; i++) { | ||
221 | fmc = devarray[i]; | ||
222 | if (!fmc->hwdev) { | ||
223 | pr_err("%s: device nr. %i has no hwdev pointer\n", | ||
224 | __func__, i); | ||
225 | ret = -EINVAL; | ||
226 | break; | ||
227 | } | ||
228 | if (fmc->flags & FMC_DEVICE_NO_MEZZANINE) { | ||
229 | dev_info(fmc->hwdev, "absent mezzanine in slot %d\n", | ||
230 | fmc->slot_id); | ||
231 | continue; | ||
232 | } | ||
233 | if (!fmc->eeprom) { | ||
234 | dev_err(fmc->hwdev, "no eeprom provided for slot %i\n", | ||
235 | fmc->slot_id); | ||
236 | ret = -EINVAL; | ||
237 | } | ||
238 | if (!fmc->eeprom_addr) { | ||
239 | dev_err(fmc->hwdev, "no eeprom_addr for slot %i\n", | ||
240 | fmc->slot_id); | ||
241 | ret = -EINVAL; | ||
242 | } | ||
243 | if (!fmc->carrier_name || !fmc->carrier_data || | ||
244 | !fmc->device_id) { | ||
245 | dev_err(fmc->hwdev, | ||
246 | "device nr %i: carrier name, " | ||
247 | "data or dev_id not set\n", i); | ||
248 | ret = -EINVAL; | ||
249 | } | ||
250 | if (ret) | ||
251 | break; | ||
252 | |||
253 | } | ||
254 | if (ret) { | ||
255 | kfree(devarray); | ||
256 | return ret; | ||
257 | } | ||
258 | |||
259 | /* Validation is ok. Now init and register the devices */ | ||
260 | for (i = 0; i < n; i++) { | ||
261 | fmc = devarray[i]; | ||
262 | |||
263 | fmc->nr_slots = n; /* each slot must know how many are there */ | ||
264 | fmc->devarray = devarray; | ||
265 | |||
266 | device_initialize(&fmc->dev); | ||
267 | fmc->dev.release = fmc_release; | ||
268 | fmc->dev.parent = fmc->hwdev; | ||
269 | |||
270 | /* Fill the identification stuff (may fail) */ | ||
271 | fmc_fill_id_info(fmc); | ||
272 | |||
273 | fmc->dev.bus = &fmc_bus_type; | ||
274 | |||
275 | /* Name from mezzanine info or carrier info. Or 0,1,2.. */ | ||
276 | device_id = fmc->device_id; | ||
277 | if (!fmc->mezzanine_name) | ||
278 | dev_set_name(&fmc->dev, "fmc-%04x", device_id); | ||
279 | else | ||
280 | dev_set_name(&fmc->dev, "%s-%04x", fmc->mezzanine_name, | ||
281 | device_id); | ||
282 | |||
283 | if (gw) { | ||
284 | /* | ||
285 | * The carrier already know the bitstream to load | ||
286 | * for this set of FMC mezzanines. | ||
287 | */ | ||
288 | ret = fmc->op->reprogram_raw(fmc, NULL, | ||
289 | gw->bitstream, gw->len); | ||
290 | if (ret) { | ||
291 | dev_warn(fmc->hwdev, | ||
292 | "Invalid gateware for FMC mezzanine\n"); | ||
293 | goto out; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | ret = device_add(&fmc->dev); | ||
298 | if (ret < 0) { | ||
299 | dev_err(fmc->hwdev, "Slot %i: Failed in registering " | ||
300 | "\"%s\"\n", fmc->slot_id, fmc->dev.kobj.name); | ||
301 | goto out; | ||
302 | } | ||
303 | ret = sysfs_create_bin_file(&fmc->dev.kobj, &fmc_eeprom_attr); | ||
304 | if (ret < 0) { | ||
305 | dev_err(&fmc->dev, "Failed in registering eeprom\n"); | ||
306 | goto out1; | ||
307 | } | ||
308 | /* This device went well, give information to the user */ | ||
309 | fmc_dump_eeprom(fmc); | ||
310 | fmc_debug_init(fmc); | ||
311 | } | ||
312 | return 0; | ||
313 | |||
314 | out1: | ||
315 | device_del(&fmc->dev); | ||
316 | out: | ||
317 | kfree(devarray); | ||
318 | for (i--; i >= 0; i--) { | ||
319 | fmc_debug_exit(devs[i]); | ||
320 | sysfs_remove_bin_file(&devs[i]->dev.kobj, &fmc_eeprom_attr); | ||
321 | device_del(&devs[i]->dev); | ||
322 | fmc_free_id_info(devs[i]); | ||
323 | put_device(&devs[i]->dev); | ||
324 | } | ||
325 | return ret; | ||
326 | |||
327 | } | ||
328 | EXPORT_SYMBOL(fmc_device_register_n_gw); | ||
329 | |||
330 | int fmc_device_register_n(struct fmc_device **devs, int n) | ||
331 | { | ||
332 | return fmc_device_register_n_gw(devs, n, NULL); | ||
333 | } | ||
334 | EXPORT_SYMBOL(fmc_device_register_n); | ||
335 | |||
336 | int fmc_device_register_gw(struct fmc_device *fmc, struct fmc_gateware *gw) | ||
337 | { | ||
338 | return fmc_device_register_n_gw(&fmc, 1, gw); | ||
339 | } | ||
340 | EXPORT_SYMBOL(fmc_device_register_gw); | ||
341 | |||
342 | int fmc_device_register(struct fmc_device *fmc) | ||
343 | { | ||
344 | return fmc_device_register_n(&fmc, 1); | ||
345 | } | ||
346 | EXPORT_SYMBOL(fmc_device_register); | ||
347 | |||
348 | void fmc_device_unregister_n(struct fmc_device **devs, int n) | ||
349 | { | ||
350 | int i; | ||
351 | |||
352 | if (n < 1) | ||
353 | return; | ||
354 | |||
355 | /* Free devarray first, not used by the later loop */ | ||
356 | kfree(devs[0]->devarray); | ||
357 | |||
358 | for (i = 0; i < n; i++) { | ||
359 | fmc_debug_exit(devs[i]); | ||
360 | sysfs_remove_bin_file(&devs[i]->dev.kobj, &fmc_eeprom_attr); | ||
361 | device_del(&devs[i]->dev); | ||
362 | fmc_free_id_info(devs[i]); | ||
363 | put_device(&devs[i]->dev); | ||
364 | } | ||
365 | } | ||
366 | EXPORT_SYMBOL(fmc_device_unregister_n); | ||
367 | |||
368 | void fmc_device_unregister(struct fmc_device *fmc) | ||
369 | { | ||
370 | fmc_device_unregister_n(&fmc, 1); | ||
371 | } | ||
372 | EXPORT_SYMBOL(fmc_device_unregister); | ||
373 | |||
374 | /* Init and exit are trivial */ | ||
375 | static int fmc_init(void) | ||
376 | { | ||
377 | return bus_register(&fmc_bus_type); | ||
378 | } | ||
379 | |||
380 | static void fmc_exit(void) | ||
381 | { | ||
382 | bus_unregister(&fmc_bus_type); | ||
383 | } | ||
384 | |||
385 | module_init(fmc_init); | ||
386 | module_exit(fmc_exit); | ||
387 | |||
388 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/fmc/fmc-debug.c b/drivers/fmc/fmc-debug.c deleted file mode 100644 index 1734c7cf0e76..000000000000 --- a/drivers/fmc/fmc-debug.c +++ /dev/null | |||
@@ -1,172 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2015 CERN (www.cern.ch) | ||
4 | * Author: Federico Vaga <federico.vaga@cern.ch> | ||
5 | */ | ||
6 | |||
7 | #include <linux/module.h> | ||
8 | #include <linux/device.h> | ||
9 | #include <linux/init.h> | ||
10 | #include <linux/fs.h> | ||
11 | #include <linux/debugfs.h> | ||
12 | #include <linux/seq_file.h> | ||
13 | #include <asm/byteorder.h> | ||
14 | |||
15 | #include <linux/fmc.h> | ||
16 | #include <linux/sdb.h> | ||
17 | #include <linux/fmc-sdb.h> | ||
18 | |||
19 | #define FMC_DBG_SDB_DUMP "dump_sdb" | ||
20 | |||
21 | static char *__strip_trailing_space(char *buf, char *str, int len) | ||
22 | { | ||
23 | int i = len - 1; | ||
24 | |||
25 | memcpy(buf, str, len); | ||
26 | buf[len] = '\0'; | ||
27 | while (i >= 0 && buf[i] == ' ') | ||
28 | buf[i--] = '\0'; | ||
29 | return buf; | ||
30 | } | ||
31 | |||
32 | #define __sdb_string(buf, field) ({ \ | ||
33 | BUILD_BUG_ON(sizeof(buf) < sizeof(field)); \ | ||
34 | __strip_trailing_space(buf, (void *)(field), sizeof(field)); \ | ||
35 | }) | ||
36 | |||
37 | /** | ||
38 | * We do not check seq_printf() errors because we want to see things in any case | ||
39 | */ | ||
40 | static void fmc_sdb_dump_recursive(struct fmc_device *fmc, struct seq_file *s, | ||
41 | const struct sdb_array *arr) | ||
42 | { | ||
43 | unsigned long base = arr->baseaddr; | ||
44 | int i, j, n = arr->len, level = arr->level; | ||
45 | char tmp[64]; | ||
46 | |||
47 | for (i = 0; i < n; i++) { | ||
48 | union sdb_record *r; | ||
49 | struct sdb_product *p; | ||
50 | struct sdb_component *c; | ||
51 | |||
52 | r = &arr->record[i]; | ||
53 | c = &r->dev.sdb_component; | ||
54 | p = &c->product; | ||
55 | |||
56 | for (j = 0; j < level; j++) | ||
57 | seq_printf(s, " "); | ||
58 | switch (r->empty.record_type) { | ||
59 | case sdb_type_interconnect: | ||
60 | seq_printf(s, "%08llx:%08x %.19s\n", | ||
61 | __be64_to_cpu(p->vendor_id), | ||
62 | __be32_to_cpu(p->device_id), | ||
63 | p->name); | ||
64 | break; | ||
65 | case sdb_type_device: | ||
66 | seq_printf(s, "%08llx:%08x %.19s (%08llx-%08llx)\n", | ||
67 | __be64_to_cpu(p->vendor_id), | ||
68 | __be32_to_cpu(p->device_id), | ||
69 | p->name, | ||
70 | __be64_to_cpu(c->addr_first) + base, | ||
71 | __be64_to_cpu(c->addr_last) + base); | ||
72 | break; | ||
73 | case sdb_type_bridge: | ||
74 | seq_printf(s, "%08llx:%08x %.19s (bridge: %08llx)\n", | ||
75 | __be64_to_cpu(p->vendor_id), | ||
76 | __be32_to_cpu(p->device_id), | ||
77 | p->name, | ||
78 | __be64_to_cpu(c->addr_first) + base); | ||
79 | if (IS_ERR(arr->subtree[i])) { | ||
80 | seq_printf(s, "SDB: (bridge error %li)\n", | ||
81 | PTR_ERR(arr->subtree[i])); | ||
82 | break; | ||
83 | } | ||
84 | fmc_sdb_dump_recursive(fmc, s, arr->subtree[i]); | ||
85 | break; | ||
86 | case sdb_type_integration: | ||
87 | seq_printf(s, "integration\n"); | ||
88 | break; | ||
89 | case sdb_type_repo_url: | ||
90 | seq_printf(s, "Synthesis repository: %s\n", | ||
91 | __sdb_string(tmp, r->repo_url.repo_url)); | ||
92 | break; | ||
93 | case sdb_type_synthesis: | ||
94 | seq_printf(s, "Bitstream '%s' ", | ||
95 | __sdb_string(tmp, r->synthesis.syn_name)); | ||
96 | seq_printf(s, "synthesized %08x by %s ", | ||
97 | __be32_to_cpu(r->synthesis.date), | ||
98 | __sdb_string(tmp, r->synthesis.user_name)); | ||
99 | seq_printf(s, "(%s version %x), ", | ||
100 | __sdb_string(tmp, r->synthesis.tool_name), | ||
101 | __be32_to_cpu(r->synthesis.tool_version)); | ||
102 | seq_printf(s, "commit %pm\n", | ||
103 | r->synthesis.commit_id); | ||
104 | break; | ||
105 | case sdb_type_empty: | ||
106 | seq_printf(s, "empty\n"); | ||
107 | break; | ||
108 | default: | ||
109 | seq_printf(s, "UNKNOWN TYPE 0x%02x\n", | ||
110 | r->empty.record_type); | ||
111 | break; | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | |||
116 | static int fmc_sdb_dump(struct seq_file *s, void *offset) | ||
117 | { | ||
118 | struct fmc_device *fmc = s->private; | ||
119 | |||
120 | if (!fmc->sdb) { | ||
121 | seq_printf(s, "no SDB information\n"); | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | seq_printf(s, "FMC: %s (%s), slot %i, device %s\n", dev_name(fmc->hwdev), | ||
126 | fmc->carrier_name, fmc->slot_id, dev_name(&fmc->dev)); | ||
127 | /* Dump SDB information */ | ||
128 | fmc_sdb_dump_recursive(fmc, s, fmc->sdb); | ||
129 | |||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | |||
134 | static int fmc_sdb_dump_open(struct inode *inode, struct file *file) | ||
135 | { | ||
136 | struct fmc_device *fmc = inode->i_private; | ||
137 | |||
138 | return single_open(file, fmc_sdb_dump, fmc); | ||
139 | } | ||
140 | |||
141 | |||
142 | const struct file_operations fmc_dbgfs_sdb_dump = { | ||
143 | .owner = THIS_MODULE, | ||
144 | .open = fmc_sdb_dump_open, | ||
145 | .read = seq_read, | ||
146 | .llseek = seq_lseek, | ||
147 | .release = single_release, | ||
148 | }; | ||
149 | |||
150 | int fmc_debug_init(struct fmc_device *fmc) | ||
151 | { | ||
152 | fmc->dbg_dir = debugfs_create_dir(dev_name(&fmc->dev), NULL); | ||
153 | if (IS_ERR_OR_NULL(fmc->dbg_dir)) { | ||
154 | pr_err("FMC: Cannot create debugfs\n"); | ||
155 | return PTR_ERR(fmc->dbg_dir); | ||
156 | } | ||
157 | |||
158 | fmc->dbg_sdb_dump = debugfs_create_file(FMC_DBG_SDB_DUMP, 0444, | ||
159 | fmc->dbg_dir, fmc, | ||
160 | &fmc_dbgfs_sdb_dump); | ||
161 | if (IS_ERR_OR_NULL(fmc->dbg_sdb_dump)) | ||
162 | pr_err("FMC: Cannot create debugfs file %s\n", | ||
163 | FMC_DBG_SDB_DUMP); | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | void fmc_debug_exit(struct fmc_device *fmc) | ||
169 | { | ||
170 | if (fmc->dbg_dir) | ||
171 | debugfs_remove_recursive(fmc->dbg_dir); | ||
172 | } | ||
diff --git a/drivers/fmc/fmc-dump.c b/drivers/fmc/fmc-dump.c deleted file mode 100644 index 6c81dbde1d16..000000000000 --- a/drivers/fmc/fmc-dump.c +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2013 CERN (www.cern.ch) | ||
4 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
5 | * | ||
6 | * This work is part of the White Rabbit project, a research effort led | ||
7 | * by CERN, the European Institute for Nuclear Research. | ||
8 | */ | ||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/moduleparam.h> | ||
11 | #include <linux/device.h> | ||
12 | #include <linux/fmc.h> | ||
13 | #include <linux/fmc-sdb.h> | ||
14 | |||
15 | static int fmc_must_dump_eeprom; | ||
16 | module_param_named(dump_eeprom, fmc_must_dump_eeprom, int, 0644); | ||
17 | |||
18 | #define LINELEN 16 | ||
19 | |||
20 | /* Dumping 8k takes oh so much: avoid duplicate lines */ | ||
21 | static const uint8_t *dump_line(int addr, const uint8_t *line, | ||
22 | const uint8_t *prev) | ||
23 | { | ||
24 | int i; | ||
25 | |||
26 | if (!prev || memcmp(line, prev, LINELEN)) { | ||
27 | pr_info("%04x: ", addr); | ||
28 | for (i = 0; i < LINELEN; ) { | ||
29 | printk(KERN_CONT "%02x", line[i]); | ||
30 | i++; | ||
31 | printk(i & 3 ? " " : i & (LINELEN - 1) ? " " : "\n"); | ||
32 | } | ||
33 | return line; | ||
34 | } | ||
35 | /* repeated line */ | ||
36 | if (line == prev + LINELEN) | ||
37 | pr_info("[...]\n"); | ||
38 | return prev; | ||
39 | } | ||
40 | |||
41 | void fmc_dump_eeprom(const struct fmc_device *fmc) | ||
42 | { | ||
43 | const uint8_t *line, *prev; | ||
44 | int i; | ||
45 | |||
46 | if (!fmc_must_dump_eeprom) | ||
47 | return; | ||
48 | |||
49 | pr_info("FMC: %s (%s), slot %i, device %s\n", dev_name(fmc->hwdev), | ||
50 | fmc->carrier_name, fmc->slot_id, dev_name(&fmc->dev)); | ||
51 | pr_info("FMC: dumping eeprom 0x%x (%i) bytes\n", fmc->eeprom_len, | ||
52 | fmc->eeprom_len); | ||
53 | |||
54 | line = fmc->eeprom; | ||
55 | prev = NULL; | ||
56 | for (i = 0; i < fmc->eeprom_len; i += LINELEN, line += LINELEN) | ||
57 | prev = dump_line(i, line, prev); | ||
58 | } | ||
diff --git a/drivers/fmc/fmc-fakedev.c b/drivers/fmc/fmc-fakedev.c deleted file mode 100644 index 941d0930969a..000000000000 --- a/drivers/fmc/fmc-fakedev.c +++ /dev/null | |||
@@ -1,355 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
3 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and/or distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * The software is provided "as is"; the copyright holders disclaim | ||
10 | * all warranties and liabilities, to the extent permitted by | ||
11 | * applicable law. | ||
12 | */ | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/string.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/firmware.h> | ||
19 | #include <linux/workqueue.h> | ||
20 | #include <linux/err.h> | ||
21 | #include <linux/fmc.h> | ||
22 | |||
23 | #define FF_EEPROM_SIZE 8192 /* The standard eeprom size */ | ||
24 | #define FF_MAX_MEZZANINES 4 /* Fakes a multi-mezzanine carrier */ | ||
25 | |||
26 | /* The user can pass up to 4 names of eeprom images to load */ | ||
27 | static char *ff_eeprom[FF_MAX_MEZZANINES]; | ||
28 | static int ff_nr_eeprom; | ||
29 | module_param_array_named(eeprom, ff_eeprom, charp, &ff_nr_eeprom, 0444); | ||
30 | |||
31 | /* The user can ask for a multi-mezzanine carrier, with the default eeprom */ | ||
32 | static int ff_nr_dev = 1; | ||
33 | module_param_named(ndev, ff_nr_dev, int, 0444); | ||
34 | |||
35 | |||
36 | /* Lazily, don't support the "standard" module parameters */ | ||
37 | |||
38 | /* | ||
39 | * Eeprom built from these commands: | ||
40 | |||
41 | ../fru-generator -v fake-vendor -n fake-design-for-testing \ | ||
42 | -s 01234 -p none > IPMI-FRU | ||
43 | |||
44 | gensdbfs . ../fake-eeprom.bin | ||
45 | */ | ||
46 | static char ff_eeimg[FF_MAX_MEZZANINES][FF_EEPROM_SIZE] = { | ||
47 | { | ||
48 | 0x01, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x00, 0xf2, 0x01, 0x0b, 0x00, 0xb2, | ||
49 | 0x86, 0x87, 0xcb, 0x66, 0x61, 0x6b, 0x65, 0x2d, 0x76, 0x65, 0x6e, 0x64, | ||
50 | 0x6f, 0x72, 0xd7, 0x66, 0x61, 0x6b, 0x65, 0x2d, 0x64, 0x65, 0x73, 0x69, | ||
51 | 0x67, 0x6e, 0x2d, 0x66, 0x6f, 0x72, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x69, | ||
52 | 0x6e, 0x67, 0xc5, 0x30, 0x31, 0x32, 0x33, 0x34, 0xc4, 0x6e, 0x6f, 0x6e, | ||
53 | 0x65, 0xda, 0x32, 0x30, 0x31, 0x32, 0x2d, 0x31, 0x31, 0x2d, 0x31, 0x39, | ||
54 | 0x20, 0x32, 0x32, 0x3a, 0x34, 0x32, 0x3a, 0x33, 0x30, 0x2e, 0x30, 0x37, | ||
55 | 0x34, 0x30, 0x35, 0x35, 0xc1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, | ||
56 | 0x02, 0x02, 0x0d, 0xf7, 0xf8, 0x02, 0xb0, 0x04, 0x74, 0x04, 0xec, 0x04, | ||
57 | 0x00, 0x00, 0x00, 0x00, 0xe8, 0x03, 0x02, 0x02, 0x0d, 0x5c, 0x93, 0x01, | ||
58 | 0x4a, 0x01, 0x39, 0x01, 0x5a, 0x01, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x0b, | ||
59 | 0x02, 0x02, 0x0d, 0x63, 0x8c, 0x00, 0xfa, 0x00, 0xed, 0x00, 0x06, 0x01, | ||
60 | 0x00, 0x00, 0x00, 0x00, 0xa0, 0x0f, 0x01, 0x02, 0x0d, 0xfb, 0xf5, 0x05, | ||
61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
62 | 0x01, 0x02, 0x0d, 0xfc, 0xf4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x0d, 0xfd, 0xf3, 0x03, | ||
64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
65 | 0xfa, 0x82, 0x0b, 0xea, 0x8f, 0xa2, 0x12, 0x00, 0x00, 0x1e, 0x44, 0x00, | ||
66 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
69 | 0x00, 0x00, 0x00, 0x00, 0x53, 0x44, 0x42, 0x2d, 0x00, 0x03, 0x01, 0x01, | ||
70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
71 | 0x00, 0x00, 0x01, 0xc4, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, | ||
72 | 0x2e, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, | ||
73 | 0x2e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
74 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
75 | 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, | ||
76 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc4, 0x46, 0x69, 0x6c, 0x65, | ||
77 | 0x44, 0x61, 0x74, 0x61, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x01, | ||
78 | 0x00, 0x00, 0x00, 0x00, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x20, 0x20, 0x20, | ||
79 | 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x01, | ||
80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, | ||
81 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdf, | ||
82 | 0x46, 0x69, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, 0x49, 0x50, 0x4d, 0x49, | ||
83 | 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x49, 0x50, 0x4d, 0x49, | ||
84 | 0x2d, 0x46, 0x52, 0x55, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | ||
85 | 0x20, 0x20, 0x20, 0x01, 0x66, 0x61, 0x6b, 0x65, 0x0a, | ||
86 | }, | ||
87 | }; | ||
88 | |||
89 | struct ff_dev { | ||
90 | struct fmc_device *fmc[FF_MAX_MEZZANINES]; | ||
91 | struct device dev; | ||
92 | }; | ||
93 | |||
94 | static struct ff_dev *ff_current_dev; /* We have 1 carrier, 1 slot */ | ||
95 | |||
96 | static int ff_reprogram(struct fmc_device *fmc, struct fmc_driver *drv, | ||
97 | char *gw) | ||
98 | { | ||
99 | const struct firmware *fw; | ||
100 | int ret; | ||
101 | |||
102 | if (!gw) { | ||
103 | /* program golden: success */ | ||
104 | fmc->flags &= ~FMC_DEVICE_HAS_CUSTOM; | ||
105 | fmc->flags |= FMC_DEVICE_HAS_GOLDEN; | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | dev_info(&fmc->dev, "reprogramming with %s\n", gw); | ||
110 | ret = request_firmware(&fw, gw, &fmc->dev); | ||
111 | if (ret < 0) { | ||
112 | dev_warn(&fmc->dev, "request firmware \"%s\": error %i\n", | ||
113 | gw, ret); | ||
114 | goto out; | ||
115 | } | ||
116 | fmc->flags &= ~FMC_DEVICE_HAS_GOLDEN; | ||
117 | fmc->flags |= FMC_DEVICE_HAS_CUSTOM; | ||
118 | |||
119 | out: | ||
120 | release_firmware(fw); | ||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | static int ff_irq_request(struct fmc_device *fmc, irq_handler_t handler, | ||
125 | char *name, int flags) | ||
126 | { | ||
127 | return -EOPNOTSUPP; | ||
128 | } | ||
129 | |||
130 | /* FIXME: should also have some fake FMC GPIO mapping */ | ||
131 | |||
132 | |||
133 | /* | ||
134 | * This work function is called when we changed the eeprom. It removes the | ||
135 | * current fmc device and registers a new one, with different identifiers. | ||
136 | */ | ||
137 | static struct ff_dev *ff_dev_create(void); /* defined later */ | ||
138 | |||
139 | static void ff_work_fn(struct work_struct *work) | ||
140 | { | ||
141 | struct ff_dev *ff = ff_current_dev; | ||
142 | int ret; | ||
143 | |||
144 | fmc_device_unregister_n(ff->fmc, ff_nr_dev); | ||
145 | device_unregister(&ff->dev); | ||
146 | ff_current_dev = NULL; | ||
147 | |||
148 | ff = ff_dev_create(); | ||
149 | if (IS_ERR(ff)) { | ||
150 | pr_warning("%s: can't re-create FMC devices\n", __func__); | ||
151 | return; | ||
152 | } | ||
153 | ret = fmc_device_register_n(ff->fmc, ff_nr_dev); | ||
154 | if (ret < 0) { | ||
155 | dev_warn(&ff->dev, "can't re-register FMC devices\n"); | ||
156 | device_unregister(&ff->dev); | ||
157 | return; | ||
158 | } | ||
159 | |||
160 | ff_current_dev = ff; | ||
161 | } | ||
162 | |||
163 | static DECLARE_DELAYED_WORK(ff_work, ff_work_fn); | ||
164 | |||
165 | |||
166 | /* low-level i2c */ | ||
167 | static int ff_eeprom_read(struct fmc_device *fmc, uint32_t offset, | ||
168 | void *buf, size_t size) | ||
169 | { | ||
170 | if (offset > FF_EEPROM_SIZE) | ||
171 | return -EINVAL; | ||
172 | if (offset + size > FF_EEPROM_SIZE) | ||
173 | size = FF_EEPROM_SIZE - offset; | ||
174 | memcpy(buf, fmc->eeprom + offset, size); | ||
175 | return size; | ||
176 | } | ||
177 | |||
178 | static int ff_eeprom_write(struct fmc_device *fmc, uint32_t offset, | ||
179 | const void *buf, size_t size) | ||
180 | { | ||
181 | if (offset > FF_EEPROM_SIZE) | ||
182 | return -EINVAL; | ||
183 | if (offset + size > FF_EEPROM_SIZE) | ||
184 | size = FF_EEPROM_SIZE - offset; | ||
185 | dev_info(&fmc->dev, "write_eeprom: offset %i, size %zi\n", | ||
186 | (int)offset, size); | ||
187 | memcpy(fmc->eeprom + offset, buf, size); | ||
188 | schedule_delayed_work(&ff_work, HZ * 2); /* remove, replug, in 2s */ | ||
189 | return size; | ||
190 | } | ||
191 | |||
192 | /* i2c operations for fmc */ | ||
193 | static int ff_read_ee(struct fmc_device *fmc, int pos, void *data, int len) | ||
194 | { | ||
195 | if (!(fmc->flags & FMC_DEVICE_HAS_GOLDEN)) | ||
196 | return -EOPNOTSUPP; | ||
197 | return ff_eeprom_read(fmc, pos, data, len); | ||
198 | } | ||
199 | |||
200 | static int ff_write_ee(struct fmc_device *fmc, int pos, | ||
201 | const void *data, int len) | ||
202 | { | ||
203 | if (!(fmc->flags & FMC_DEVICE_HAS_GOLDEN)) | ||
204 | return -EOPNOTSUPP; | ||
205 | return ff_eeprom_write(fmc, pos, data, len); | ||
206 | } | ||
207 | |||
208 | /* readl and writel do not do anything. Don't waste RAM with "base" */ | ||
209 | static uint32_t ff_readl(struct fmc_device *fmc, int offset) | ||
210 | { | ||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | static void ff_writel(struct fmc_device *fmc, uint32_t value, int offset) | ||
215 | { | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | /* validate is useful so fmc-write-eeprom will not reprogram every 2 seconds */ | ||
220 | static int ff_validate(struct fmc_device *fmc, struct fmc_driver *drv) | ||
221 | { | ||
222 | int i; | ||
223 | |||
224 | if (!drv->busid_n) | ||
225 | return 0; /* everyhing is valid */ | ||
226 | for (i = 0; i < drv->busid_n; i++) | ||
227 | if (drv->busid_val[i] == fmc->device_id) | ||
228 | return i; | ||
229 | return -ENOENT; | ||
230 | } | ||
231 | |||
232 | |||
233 | |||
234 | static struct fmc_operations ff_fmc_operations = { | ||
235 | .read32 = ff_readl, | ||
236 | .write32 = ff_writel, | ||
237 | .reprogram = ff_reprogram, | ||
238 | .irq_request = ff_irq_request, | ||
239 | .read_ee = ff_read_ee, | ||
240 | .write_ee = ff_write_ee, | ||
241 | .validate = ff_validate, | ||
242 | }; | ||
243 | |||
244 | /* This device is kmalloced: release it */ | ||
245 | static void ff_dev_release(struct device *dev) | ||
246 | { | ||
247 | struct ff_dev *ff = container_of(dev, struct ff_dev, dev); | ||
248 | kfree(ff); | ||
249 | } | ||
250 | |||
251 | static struct fmc_device ff_template_fmc = { | ||
252 | .version = FMC_VERSION, | ||
253 | .owner = THIS_MODULE, | ||
254 | .carrier_name = "fake-fmc-carrier", | ||
255 | .device_id = 0xf001, /* fool */ | ||
256 | .eeprom_len = sizeof(ff_eeimg[0]), | ||
257 | .memlen = 0x1000, /* 4k, to show something */ | ||
258 | .op = &ff_fmc_operations, | ||
259 | .hwdev = NULL, /* filled at creation time */ | ||
260 | .flags = FMC_DEVICE_HAS_GOLDEN, | ||
261 | }; | ||
262 | |||
263 | static struct ff_dev *ff_dev_create(void) | ||
264 | { | ||
265 | struct ff_dev *ff; | ||
266 | struct fmc_device *fmc; | ||
267 | int i, ret; | ||
268 | |||
269 | ff = kzalloc(sizeof(*ff), GFP_KERNEL); | ||
270 | if (!ff) | ||
271 | return ERR_PTR(-ENOMEM); | ||
272 | dev_set_name(&ff->dev, "fake-fmc-carrier"); | ||
273 | ff->dev.release = ff_dev_release; | ||
274 | |||
275 | ret = device_register(&ff->dev); | ||
276 | if (ret < 0) { | ||
277 | put_device(&ff->dev); | ||
278 | return ERR_PTR(ret); | ||
279 | } | ||
280 | |||
281 | /* Create fmc structures that refer to this new "hw" device */ | ||
282 | for (i = 0; i < ff_nr_dev; i++) { | ||
283 | fmc = kmemdup(&ff_template_fmc, sizeof(ff_template_fmc), | ||
284 | GFP_KERNEL); | ||
285 | fmc->hwdev = &ff->dev; | ||
286 | fmc->carrier_data = ff; | ||
287 | fmc->nr_slots = ff_nr_dev; | ||
288 | /* the following fields are different for each slot */ | ||
289 | fmc->eeprom = ff_eeimg[i]; | ||
290 | fmc->eeprom_addr = 0x50 + 2 * i; | ||
291 | fmc->slot_id = i; | ||
292 | ff->fmc[i] = fmc; | ||
293 | /* increment the identifier, each must be different */ | ||
294 | ff_template_fmc.device_id++; | ||
295 | } | ||
296 | return ff; | ||
297 | } | ||
298 | |||
299 | /* init and exit */ | ||
300 | static int ff_init(void) | ||
301 | { | ||
302 | struct ff_dev *ff; | ||
303 | const struct firmware *fw; | ||
304 | int i, len, ret = 0; | ||
305 | |||
306 | /* Replicate the default eeprom for the max number of mezzanines */ | ||
307 | for (i = 1; i < FF_MAX_MEZZANINES; i++) | ||
308 | memcpy(ff_eeimg[i], ff_eeimg[0], sizeof(ff_eeimg[0])); | ||
309 | |||
310 | if (ff_nr_eeprom > ff_nr_dev) | ||
311 | ff_nr_dev = ff_nr_eeprom; | ||
312 | |||
313 | ff = ff_dev_create(); | ||
314 | if (IS_ERR(ff)) | ||
315 | return PTR_ERR(ff); | ||
316 | |||
317 | /* If the user passed "eeprom=" as a parameter, fetch them */ | ||
318 | for (i = 0; i < ff_nr_eeprom; i++) { | ||
319 | if (!strlen(ff_eeprom[i])) | ||
320 | continue; | ||
321 | ret = request_firmware(&fw, ff_eeprom[i], &ff->dev); | ||
322 | if (ret < 0) { | ||
323 | dev_err(&ff->dev, "Mezzanine %i: can't load \"%s\" " | ||
324 | "(error %i)\n", i, ff_eeprom[i], -ret); | ||
325 | } else { | ||
326 | len = min_t(size_t, fw->size, (size_t)FF_EEPROM_SIZE); | ||
327 | memcpy(ff_eeimg[i], fw->data, len); | ||
328 | release_firmware(fw); | ||
329 | dev_info(&ff->dev, "Mezzanine %i: eeprom \"%s\"\n", i, | ||
330 | ff_eeprom[i]); | ||
331 | } | ||
332 | } | ||
333 | |||
334 | ret = fmc_device_register_n(ff->fmc, ff_nr_dev); | ||
335 | if (ret) { | ||
336 | device_unregister(&ff->dev); | ||
337 | return ret; | ||
338 | } | ||
339 | ff_current_dev = ff; | ||
340 | return ret; | ||
341 | } | ||
342 | |||
343 | static void ff_exit(void) | ||
344 | { | ||
345 | if (ff_current_dev) { | ||
346 | fmc_device_unregister_n(ff_current_dev->fmc, ff_nr_dev); | ||
347 | device_unregister(&ff_current_dev->dev); | ||
348 | } | ||
349 | cancel_delayed_work_sync(&ff_work); | ||
350 | } | ||
351 | |||
352 | module_init(ff_init); | ||
353 | module_exit(ff_exit); | ||
354 | |||
355 | MODULE_LICENSE("Dual BSD/GPL"); | ||
diff --git a/drivers/fmc/fmc-match.c b/drivers/fmc/fmc-match.c deleted file mode 100644 index 995bd6041a67..000000000000 --- a/drivers/fmc/fmc-match.c +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
4 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
5 | * | ||
6 | * This work is part of the White Rabbit project, a research effort led | ||
7 | * by CERN, the European Institute for Nuclear Research. | ||
8 | */ | ||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/slab.h> | ||
11 | #include <linux/fmc.h> | ||
12 | #include <linux/ipmi-fru.h> | ||
13 | |||
14 | /* The fru parser is both user and kernel capable: it needs alloc */ | ||
15 | void *fru_alloc(size_t size) | ||
16 | { | ||
17 | return kzalloc(size, GFP_KERNEL); | ||
18 | } | ||
19 | |||
20 | /* The actual match function */ | ||
21 | int fmc_match(struct device *dev, struct device_driver *drv) | ||
22 | { | ||
23 | struct fmc_driver *fdrv = to_fmc_driver(drv); | ||
24 | struct fmc_device *fdev = to_fmc_device(dev); | ||
25 | struct fmc_fru_id *fid; | ||
26 | int i, matched = 0; | ||
27 | |||
28 | /* This currently only matches the EEPROM (FRU id) */ | ||
29 | fid = fdrv->id_table.fru_id; | ||
30 | if (!fid) { | ||
31 | dev_warn(&fdev->dev, "Driver has no ID: matches all\n"); | ||
32 | matched = 1; | ||
33 | } else { | ||
34 | if (!fdev->id.manufacturer || !fdev->id.product_name) | ||
35 | return 0; /* the device has no FRU information */ | ||
36 | for (i = 0; i < fdrv->id_table.fru_id_nr; i++, fid++) { | ||
37 | if (fid->manufacturer && | ||
38 | strcmp(fid->manufacturer, fdev->id.manufacturer)) | ||
39 | continue; | ||
40 | if (fid->product_name && | ||
41 | strcmp(fid->product_name, fdev->id.product_name)) | ||
42 | continue; | ||
43 | matched = 1; | ||
44 | break; | ||
45 | } | ||
46 | } | ||
47 | |||
48 | /* FIXME: match SDB contents */ | ||
49 | return matched; | ||
50 | } | ||
51 | |||
52 | /* This function creates ID info for a newly registered device */ | ||
53 | int fmc_fill_id_info(struct fmc_device *fmc) | ||
54 | { | ||
55 | struct fru_common_header *h; | ||
56 | struct fru_board_info_area *bia; | ||
57 | int ret, allocated = 0; | ||
58 | |||
59 | /* If we know the eeprom length, try to read it off the device */ | ||
60 | if (fmc->eeprom_len && !fmc->eeprom) { | ||
61 | fmc->eeprom = kzalloc(fmc->eeprom_len, GFP_KERNEL); | ||
62 | if (!fmc->eeprom) | ||
63 | return -ENOMEM; | ||
64 | allocated = 1; | ||
65 | ret = fmc_read_ee(fmc, 0, fmc->eeprom, fmc->eeprom_len); | ||
66 | if (ret < 0) | ||
67 | goto out; | ||
68 | } | ||
69 | |||
70 | /* If no eeprom, continue with other matches */ | ||
71 | if (!fmc->eeprom) | ||
72 | return 0; | ||
73 | |||
74 | dev_info(fmc->hwdev, "mezzanine %i\n", fmc->slot_id); /* header */ | ||
75 | |||
76 | /* So we have the eeprom: parse the FRU part (if any) */ | ||
77 | h = (void *)fmc->eeprom; | ||
78 | if (h->format != 1) { | ||
79 | pr_info(" EEPROM has no FRU information\n"); | ||
80 | goto out; | ||
81 | } | ||
82 | if (!fru_header_cksum_ok(h)) { | ||
83 | pr_info(" FRU: wrong header checksum\n"); | ||
84 | goto out; | ||
85 | } | ||
86 | bia = fru_get_board_area(h); | ||
87 | if (!fru_bia_cksum_ok(bia)) { | ||
88 | pr_info(" FRU: wrong board area checksum\n"); | ||
89 | goto out; | ||
90 | } | ||
91 | fmc->id.manufacturer = fru_get_board_manufacturer(h); | ||
92 | fmc->id.product_name = fru_get_product_name(h); | ||
93 | pr_info(" Manufacturer: %s\n", fmc->id.manufacturer); | ||
94 | pr_info(" Product name: %s\n", fmc->id.product_name); | ||
95 | |||
96 | /* Create the short name (FIXME: look in sdb as well) */ | ||
97 | fmc->mezzanine_name = kstrdup(fmc->id.product_name, GFP_KERNEL); | ||
98 | |||
99 | out: | ||
100 | if (allocated) { | ||
101 | kfree(fmc->eeprom); | ||
102 | fmc->eeprom = NULL; | ||
103 | } | ||
104 | return 0; /* no error: let other identification work */ | ||
105 | } | ||
106 | |||
107 | /* Some ID data is allocated using fru_alloc() above, so release it */ | ||
108 | void fmc_free_id_info(struct fmc_device *fmc) | ||
109 | { | ||
110 | kfree(fmc->mezzanine_name); | ||
111 | kfree(fmc->id.manufacturer); | ||
112 | kfree(fmc->id.product_name); | ||
113 | } | ||
diff --git a/drivers/fmc/fmc-private.h b/drivers/fmc/fmc-private.h deleted file mode 100644 index 93cb8030f764..000000000000 --- a/drivers/fmc/fmc-private.h +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
2 | /* | ||
3 | * Copyright (C) 2015 CERN (www.cern.ch) | ||
4 | * Author: Federico Vaga <federico.vaga@cern.ch> | ||
5 | */ | ||
6 | |||
7 | extern int fmc_debug_init(struct fmc_device *fmc); | ||
8 | extern void fmc_debug_exit(struct fmc_device *fmc); | ||
diff --git a/drivers/fmc/fmc-sdb.c b/drivers/fmc/fmc-sdb.c deleted file mode 100644 index 14758db1a5fb..000000000000 --- a/drivers/fmc/fmc-sdb.c +++ /dev/null | |||
@@ -1,219 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
4 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
5 | * | ||
6 | * This work is part of the White Rabbit project, a research effort led | ||
7 | * by CERN, the European Institute for Nuclear Research. | ||
8 | */ | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/slab.h> | ||
11 | #include <linux/fmc.h> | ||
12 | #include <linux/sdb.h> | ||
13 | #include <linux/err.h> | ||
14 | #include <linux/fmc-sdb.h> | ||
15 | #include <asm/byteorder.h> | ||
16 | |||
17 | static uint32_t __sdb_rd(struct fmc_device *fmc, unsigned long address, | ||
18 | int convert) | ||
19 | { | ||
20 | uint32_t res = fmc_readl(fmc, address); | ||
21 | if (convert) | ||
22 | return __be32_to_cpu(res); | ||
23 | return res; | ||
24 | } | ||
25 | |||
26 | static struct sdb_array *__fmc_scan_sdb_tree(struct fmc_device *fmc, | ||
27 | unsigned long sdb_addr, | ||
28 | unsigned long reg_base, int level) | ||
29 | { | ||
30 | uint32_t onew; | ||
31 | int i, j, n, convert = 0; | ||
32 | struct sdb_array *arr, *sub; | ||
33 | |||
34 | onew = fmc_readl(fmc, sdb_addr); | ||
35 | if (onew == SDB_MAGIC) { | ||
36 | /* Uh! If we are little-endian, we must convert */ | ||
37 | if (SDB_MAGIC != __be32_to_cpu(SDB_MAGIC)) | ||
38 | convert = 1; | ||
39 | } else if (onew == __be32_to_cpu(SDB_MAGIC)) { | ||
40 | /* ok, don't convert */ | ||
41 | } else { | ||
42 | return ERR_PTR(-ENOENT); | ||
43 | } | ||
44 | /* So, the magic was there: get the count from offset 4*/ | ||
45 | onew = __sdb_rd(fmc, sdb_addr + 4, convert); | ||
46 | n = __be16_to_cpu(*(uint16_t *)&onew); | ||
47 | arr = kzalloc(sizeof(*arr), GFP_KERNEL); | ||
48 | if (!arr) | ||
49 | return ERR_PTR(-ENOMEM); | ||
50 | arr->record = kcalloc(n, sizeof(arr->record[0]), GFP_KERNEL); | ||
51 | arr->subtree = kcalloc(n, sizeof(arr->subtree[0]), GFP_KERNEL); | ||
52 | if (!arr->record || !arr->subtree) { | ||
53 | kfree(arr->record); | ||
54 | kfree(arr->subtree); | ||
55 | kfree(arr); | ||
56 | return ERR_PTR(-ENOMEM); | ||
57 | } | ||
58 | |||
59 | arr->len = n; | ||
60 | arr->level = level; | ||
61 | arr->fmc = fmc; | ||
62 | for (i = 0; i < n; i++) { | ||
63 | union sdb_record *r; | ||
64 | |||
65 | for (j = 0; j < sizeof(arr->record[0]); j += 4) { | ||
66 | *(uint32_t *)((void *)(arr->record + i) + j) = | ||
67 | __sdb_rd(fmc, sdb_addr + (i * 64) + j, convert); | ||
68 | } | ||
69 | r = &arr->record[i]; | ||
70 | arr->subtree[i] = ERR_PTR(-ENODEV); | ||
71 | if (r->empty.record_type == sdb_type_bridge) { | ||
72 | struct sdb_component *c = &r->bridge.sdb_component; | ||
73 | uint64_t subaddr = __be64_to_cpu(r->bridge.sdb_child); | ||
74 | uint64_t newbase = __be64_to_cpu(c->addr_first); | ||
75 | |||
76 | subaddr += reg_base; | ||
77 | newbase += reg_base; | ||
78 | sub = __fmc_scan_sdb_tree(fmc, subaddr, newbase, | ||
79 | level + 1); | ||
80 | arr->subtree[i] = sub; /* may be error */ | ||
81 | if (IS_ERR(sub)) | ||
82 | continue; | ||
83 | sub->parent = arr; | ||
84 | sub->baseaddr = newbase; | ||
85 | } | ||
86 | } | ||
87 | return arr; | ||
88 | } | ||
89 | |||
90 | int fmc_scan_sdb_tree(struct fmc_device *fmc, unsigned long address) | ||
91 | { | ||
92 | struct sdb_array *ret; | ||
93 | if (fmc->sdb) | ||
94 | return -EBUSY; | ||
95 | ret = __fmc_scan_sdb_tree(fmc, address, 0 /* regs */, 0); | ||
96 | if (IS_ERR(ret)) | ||
97 | return PTR_ERR(ret); | ||
98 | fmc->sdb = ret; | ||
99 | return 0; | ||
100 | } | ||
101 | EXPORT_SYMBOL(fmc_scan_sdb_tree); | ||
102 | |||
103 | static void __fmc_sdb_free(struct sdb_array *arr) | ||
104 | { | ||
105 | int i, n; | ||
106 | |||
107 | if (!arr) | ||
108 | return; | ||
109 | n = arr->len; | ||
110 | for (i = 0; i < n; i++) { | ||
111 | if (IS_ERR(arr->subtree[i])) | ||
112 | continue; | ||
113 | __fmc_sdb_free(arr->subtree[i]); | ||
114 | } | ||
115 | kfree(arr->record); | ||
116 | kfree(arr->subtree); | ||
117 | kfree(arr); | ||
118 | } | ||
119 | |||
120 | int fmc_free_sdb_tree(struct fmc_device *fmc) | ||
121 | { | ||
122 | __fmc_sdb_free(fmc->sdb); | ||
123 | fmc->sdb = NULL; | ||
124 | return 0; | ||
125 | } | ||
126 | EXPORT_SYMBOL(fmc_free_sdb_tree); | ||
127 | |||
128 | /* This helper calls reprogram and inizialized sdb as well */ | ||
129 | int fmc_reprogram_raw(struct fmc_device *fmc, struct fmc_driver *d, | ||
130 | void *gw, unsigned long len, int sdb_entry) | ||
131 | { | ||
132 | int ret; | ||
133 | |||
134 | ret = fmc->op->reprogram_raw(fmc, d, gw, len); | ||
135 | if (ret < 0) | ||
136 | return ret; | ||
137 | if (sdb_entry < 0) | ||
138 | return ret; | ||
139 | |||
140 | /* We are required to find SDB at a given offset */ | ||
141 | ret = fmc_scan_sdb_tree(fmc, sdb_entry); | ||
142 | if (ret < 0) { | ||
143 | dev_err(&fmc->dev, "Can't find SDB at address 0x%x\n", | ||
144 | sdb_entry); | ||
145 | return -ENODEV; | ||
146 | } | ||
147 | |||
148 | return 0; | ||
149 | } | ||
150 | EXPORT_SYMBOL(fmc_reprogram_raw); | ||
151 | |||
152 | /* This helper calls reprogram and inizialized sdb as well */ | ||
153 | int fmc_reprogram(struct fmc_device *fmc, struct fmc_driver *d, char *gw, | ||
154 | int sdb_entry) | ||
155 | { | ||
156 | int ret; | ||
157 | |||
158 | ret = fmc->op->reprogram(fmc, d, gw); | ||
159 | if (ret < 0) | ||
160 | return ret; | ||
161 | if (sdb_entry < 0) | ||
162 | return ret; | ||
163 | |||
164 | /* We are required to find SDB at a given offset */ | ||
165 | ret = fmc_scan_sdb_tree(fmc, sdb_entry); | ||
166 | if (ret < 0) { | ||
167 | dev_err(&fmc->dev, "Can't find SDB at address 0x%x\n", | ||
168 | sdb_entry); | ||
169 | return -ENODEV; | ||
170 | } | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | EXPORT_SYMBOL(fmc_reprogram); | ||
175 | |||
176 | void fmc_show_sdb_tree(const struct fmc_device *fmc) | ||
177 | { | ||
178 | pr_err("%s: not supported anymore, use debugfs to dump SDB\n", | ||
179 | __func__); | ||
180 | } | ||
181 | EXPORT_SYMBOL(fmc_show_sdb_tree); | ||
182 | |||
183 | signed long fmc_find_sdb_device(struct sdb_array *tree, | ||
184 | uint64_t vid, uint32_t did, unsigned long *sz) | ||
185 | { | ||
186 | signed long res = -ENODEV; | ||
187 | union sdb_record *r; | ||
188 | struct sdb_product *p; | ||
189 | struct sdb_component *c; | ||
190 | int i, n = tree->len; | ||
191 | uint64_t last, first; | ||
192 | |||
193 | /* FIXME: what if the first interconnect is not at zero? */ | ||
194 | for (i = 0; i < n; i++) { | ||
195 | r = &tree->record[i]; | ||
196 | c = &r->dev.sdb_component; | ||
197 | p = &c->product; | ||
198 | |||
199 | if (!IS_ERR(tree->subtree[i])) | ||
200 | res = fmc_find_sdb_device(tree->subtree[i], | ||
201 | vid, did, sz); | ||
202 | if (res >= 0) | ||
203 | return res + tree->baseaddr; | ||
204 | if (r->empty.record_type != sdb_type_device) | ||
205 | continue; | ||
206 | if (__be64_to_cpu(p->vendor_id) != vid) | ||
207 | continue; | ||
208 | if (__be32_to_cpu(p->device_id) != did) | ||
209 | continue; | ||
210 | /* found */ | ||
211 | last = __be64_to_cpu(c->addr_last); | ||
212 | first = __be64_to_cpu(c->addr_first); | ||
213 | if (sz) | ||
214 | *sz = (typeof(*sz))(last + 1 - first); | ||
215 | return first + tree->baseaddr; | ||
216 | } | ||
217 | return res; | ||
218 | } | ||
219 | EXPORT_SYMBOL(fmc_find_sdb_device); | ||
diff --git a/drivers/fmc/fmc-trivial.c b/drivers/fmc/fmc-trivial.c deleted file mode 100644 index 8defdee3e3a3..000000000000 --- a/drivers/fmc/fmc-trivial.c +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
3 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and/or distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * The software is provided "as is"; the copyright holders disclaim | ||
10 | * all warranties and liabilities, to the extent permitted by | ||
11 | * applicable law. | ||
12 | */ | ||
13 | |||
14 | /* A trivial fmc driver that can load a gateware file and reports interrupts */ | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/fmc.h> | ||
20 | |||
21 | static struct fmc_driver t_drv; /* initialized later */ | ||
22 | |||
23 | static irqreturn_t t_handler(int irq, void *dev_id) | ||
24 | { | ||
25 | struct fmc_device *fmc = dev_id; | ||
26 | |||
27 | fmc_irq_ack(fmc); | ||
28 | dev_info(&fmc->dev, "received irq %i\n", irq); | ||
29 | return IRQ_HANDLED; | ||
30 | } | ||
31 | |||
32 | static struct fmc_gpio t_gpio[] = { | ||
33 | { | ||
34 | .gpio = FMC_GPIO_IRQ(0), | ||
35 | .mode = GPIOF_DIR_IN, | ||
36 | .irqmode = IRQF_TRIGGER_RISING, | ||
37 | }, { | ||
38 | .gpio = FMC_GPIO_IRQ(1), | ||
39 | .mode = GPIOF_DIR_IN, | ||
40 | .irqmode = IRQF_TRIGGER_RISING, | ||
41 | } | ||
42 | }; | ||
43 | |||
44 | static int t_probe(struct fmc_device *fmc) | ||
45 | { | ||
46 | int ret; | ||
47 | int index = 0; | ||
48 | |||
49 | index = fmc_validate(fmc, &t_drv); | ||
50 | if (index < 0) | ||
51 | return -EINVAL; /* not our device: invalid */ | ||
52 | |||
53 | ret = fmc_irq_request(fmc, t_handler, "fmc-trivial", IRQF_SHARED); | ||
54 | if (ret < 0) | ||
55 | return ret; | ||
56 | /* ignore error code of call below, we really don't care */ | ||
57 | fmc_gpio_config(fmc, t_gpio, ARRAY_SIZE(t_gpio)); | ||
58 | |||
59 | ret = fmc_reprogram(fmc, &t_drv, "", 0); | ||
60 | if (ret == -EPERM) /* programming not supported */ | ||
61 | ret = 0; | ||
62 | if (ret < 0) | ||
63 | fmc_irq_free(fmc); | ||
64 | |||
65 | /* FIXME: reprogram LM32 too */ | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | static int t_remove(struct fmc_device *fmc) | ||
70 | { | ||
71 | fmc_irq_free(fmc); | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static struct fmc_driver t_drv = { | ||
76 | .version = FMC_VERSION, | ||
77 | .driver.name = KBUILD_MODNAME, | ||
78 | .probe = t_probe, | ||
79 | .remove = t_remove, | ||
80 | /* no table, as the current match just matches everything */ | ||
81 | }; | ||
82 | |||
83 | /* We accept the generic parameters */ | ||
84 | FMC_PARAM_BUSID(t_drv); | ||
85 | FMC_PARAM_GATEWARE(t_drv); | ||
86 | |||
87 | static int t_init(void) | ||
88 | { | ||
89 | int ret; | ||
90 | |||
91 | ret = fmc_driver_register(&t_drv); | ||
92 | return ret; | ||
93 | } | ||
94 | |||
95 | static void t_exit(void) | ||
96 | { | ||
97 | fmc_driver_unregister(&t_drv); | ||
98 | } | ||
99 | |||
100 | module_init(t_init); | ||
101 | module_exit(t_exit); | ||
102 | |||
103 | MODULE_LICENSE("Dual BSD/GPL"); | ||
diff --git a/drivers/fmc/fmc-write-eeprom.c b/drivers/fmc/fmc-write-eeprom.c deleted file mode 100644 index 1c7826e3f526..000000000000 --- a/drivers/fmc/fmc-write-eeprom.c +++ /dev/null | |||
@@ -1,175 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
4 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
5 | * | ||
6 | * This work is part of the White Rabbit project, a research effort led | ||
7 | * by CERN, the European Institute for Nuclear Research. | ||
8 | */ | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/string.h> | ||
11 | #include <linux/firmware.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/fmc.h> | ||
14 | #include <asm/unaligned.h> | ||
15 | |||
16 | /* | ||
17 | * This module uses the firmware loader to program the whole or part | ||
18 | * of the FMC eeprom. The meat is in the _run functions. However, no | ||
19 | * default file name is provided, to avoid accidental mishaps. Also, | ||
20 | * you must pass the busid argument | ||
21 | */ | ||
22 | static struct fmc_driver fwe_drv; | ||
23 | |||
24 | FMC_PARAM_BUSID(fwe_drv); | ||
25 | |||
26 | /* The "file=" is like the generic "gateware=" used elsewhere */ | ||
27 | static char *fwe_file[FMC_MAX_CARDS]; | ||
28 | static int fwe_file_n; | ||
29 | module_param_array_named(file, fwe_file, charp, &fwe_file_n, 0444); | ||
30 | |||
31 | static int fwe_run_tlv(struct fmc_device *fmc, const struct firmware *fw, | ||
32 | int write) | ||
33 | { | ||
34 | const uint8_t *p = fw->data; | ||
35 | int len = fw->size; | ||
36 | uint16_t thislen, thisaddr; | ||
37 | int err; | ||
38 | |||
39 | /* format is: 'w' addr16 len16 data... */ | ||
40 | while (len > 5) { | ||
41 | thisaddr = get_unaligned_le16(p+1); | ||
42 | thislen = get_unaligned_le16(p+3); | ||
43 | if (p[0] != 'w' || thislen + 5 > len) { | ||
44 | dev_err(&fmc->dev, "invalid tlv at offset %ti\n", | ||
45 | p - fw->data); | ||
46 | return -EINVAL; | ||
47 | } | ||
48 | err = 0; | ||
49 | if (write) { | ||
50 | dev_info(&fmc->dev, "write %i bytes at 0x%04x\n", | ||
51 | thislen, thisaddr); | ||
52 | err = fmc_write_ee(fmc, thisaddr, p + 5, thislen); | ||
53 | } | ||
54 | if (err < 0) { | ||
55 | dev_err(&fmc->dev, "write failure @0x%04x\n", | ||
56 | thisaddr); | ||
57 | return err; | ||
58 | } | ||
59 | p += 5 + thislen; | ||
60 | len -= 5 + thislen; | ||
61 | } | ||
62 | if (write) | ||
63 | dev_info(&fmc->dev, "write_eeprom: success\n"); | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | static int fwe_run_bin(struct fmc_device *fmc, const struct firmware *fw) | ||
68 | { | ||
69 | int ret; | ||
70 | |||
71 | dev_info(&fmc->dev, "programming %zi bytes\n", fw->size); | ||
72 | ret = fmc_write_ee(fmc, 0, (void *)fw->data, fw->size); | ||
73 | if (ret < 0) { | ||
74 | dev_info(&fmc->dev, "write_eeprom: error %i\n", ret); | ||
75 | return ret; | ||
76 | } | ||
77 | dev_info(&fmc->dev, "write_eeprom: success\n"); | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static int fwe_run(struct fmc_device *fmc, const struct firmware *fw, char *s) | ||
82 | { | ||
83 | char *last4 = s + strlen(s) - 4; | ||
84 | int err; | ||
85 | |||
86 | if (!strcmp(last4, ".bin")) | ||
87 | return fwe_run_bin(fmc, fw); | ||
88 | if (!strcmp(last4, ".tlv")) { | ||
89 | err = fwe_run_tlv(fmc, fw, 0); | ||
90 | if (!err) | ||
91 | err = fwe_run_tlv(fmc, fw, 1); | ||
92 | return err; | ||
93 | } | ||
94 | dev_err(&fmc->dev, "invalid file name \"%s\"\n", s); | ||
95 | return -EINVAL; | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * Programming is done at probe time. Morever, only those listed with | ||
100 | * busid= are programmed. | ||
101 | * card is probed for, only one is programmed. Unfortunately, it's | ||
102 | * difficult to know in advance when probing the first card if others | ||
103 | * are there. | ||
104 | */ | ||
105 | static int fwe_probe(struct fmc_device *fmc) | ||
106 | { | ||
107 | int err, index = 0; | ||
108 | const struct firmware *fw; | ||
109 | struct device *dev = &fmc->dev; | ||
110 | char *s; | ||
111 | |||
112 | if (!fwe_drv.busid_n) { | ||
113 | dev_err(dev, "%s: no busid passed, refusing all cards\n", | ||
114 | KBUILD_MODNAME); | ||
115 | return -ENODEV; | ||
116 | } | ||
117 | |||
118 | index = fmc_validate(fmc, &fwe_drv); | ||
119 | if (index < 0) { | ||
120 | pr_err("%s: refusing device \"%s\"\n", KBUILD_MODNAME, | ||
121 | dev_name(dev)); | ||
122 | return -ENODEV; | ||
123 | } | ||
124 | if (index >= fwe_file_n) { | ||
125 | pr_err("%s: no filename for device index %i\n", | ||
126 | KBUILD_MODNAME, index); | ||
127 | return -ENODEV; | ||
128 | } | ||
129 | s = fwe_file[index]; | ||
130 | if (!s) { | ||
131 | pr_err("%s: no filename for \"%s\" not programming\n", | ||
132 | KBUILD_MODNAME, dev_name(dev)); | ||
133 | return -ENOENT; | ||
134 | } | ||
135 | err = request_firmware(&fw, s, dev); | ||
136 | if (err < 0) { | ||
137 | dev_err(&fmc->dev, "request firmware \"%s\": error %i\n", | ||
138 | s, err); | ||
139 | return err; | ||
140 | } | ||
141 | fwe_run(fmc, fw, s); | ||
142 | release_firmware(fw); | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static int fwe_remove(struct fmc_device *fmc) | ||
147 | { | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static struct fmc_driver fwe_drv = { | ||
152 | .version = FMC_VERSION, | ||
153 | .driver.name = KBUILD_MODNAME, | ||
154 | .probe = fwe_probe, | ||
155 | .remove = fwe_remove, | ||
156 | /* no table, as the current match just matches everything */ | ||
157 | }; | ||
158 | |||
159 | static int fwe_init(void) | ||
160 | { | ||
161 | int ret; | ||
162 | |||
163 | ret = fmc_driver_register(&fwe_drv); | ||
164 | return ret; | ||
165 | } | ||
166 | |||
167 | static void fwe_exit(void) | ||
168 | { | ||
169 | fmc_driver_unregister(&fwe_drv); | ||
170 | } | ||
171 | |||
172 | module_init(fwe_init); | ||
173 | module_exit(fwe_exit); | ||
174 | |||
175 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/fmc/fru-parse.c b/drivers/fmc/fru-parse.c deleted file mode 100644 index f551b81f4fd9..000000000000 --- a/drivers/fmc/fru-parse.c +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
2 | /* | ||
3 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
4 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
5 | * | ||
6 | * This work is part of the White Rabbit project, a research effort led | ||
7 | * by CERN, the European Institute for Nuclear Research. | ||
8 | */ | ||
9 | #include <linux/ipmi-fru.h> | ||
10 | |||
11 | /* Some internal helpers */ | ||
12 | static struct fru_type_length * | ||
13 | __fru_get_board_tl(struct fru_common_header *header, int nr) | ||
14 | { | ||
15 | struct fru_board_info_area *bia; | ||
16 | struct fru_type_length *tl; | ||
17 | |||
18 | bia = fru_get_board_area(header); | ||
19 | tl = bia->tl; | ||
20 | while (nr > 0 && !fru_is_eof(tl)) { | ||
21 | tl = fru_next_tl(tl); | ||
22 | nr--; | ||
23 | } | ||
24 | if (fru_is_eof(tl)) | ||
25 | return NULL; | ||
26 | return tl; | ||
27 | } | ||
28 | |||
29 | static char *__fru_alloc_get_tl(struct fru_common_header *header, int nr) | ||
30 | { | ||
31 | struct fru_type_length *tl; | ||
32 | char *res; | ||
33 | |||
34 | tl = __fru_get_board_tl(header, nr); | ||
35 | if (!tl) | ||
36 | return NULL; | ||
37 | |||
38 | res = fru_alloc(fru_strlen(tl) + 1); | ||
39 | if (!res) | ||
40 | return NULL; | ||
41 | return fru_strcpy(res, tl); | ||
42 | } | ||
43 | |||
44 | /* Public checksum verifiers */ | ||
45 | int fru_header_cksum_ok(struct fru_common_header *header) | ||
46 | { | ||
47 | uint8_t *ptr = (void *)header; | ||
48 | int i, sum; | ||
49 | |||
50 | for (i = sum = 0; i < sizeof(*header); i++) | ||
51 | sum += ptr[i]; | ||
52 | return (sum & 0xff) == 0; | ||
53 | } | ||
54 | int fru_bia_cksum_ok(struct fru_board_info_area *bia) | ||
55 | { | ||
56 | uint8_t *ptr = (void *)bia; | ||
57 | int i, sum; | ||
58 | |||
59 | for (i = sum = 0; i < 8 * bia->area_len; i++) | ||
60 | sum += ptr[i]; | ||
61 | return (sum & 0xff) == 0; | ||
62 | } | ||
63 | |||
64 | /* Get various stuff, trivial */ | ||
65 | char *fru_get_board_manufacturer(struct fru_common_header *header) | ||
66 | { | ||
67 | return __fru_alloc_get_tl(header, 0); | ||
68 | } | ||
69 | char *fru_get_product_name(struct fru_common_header *header) | ||
70 | { | ||
71 | return __fru_alloc_get_tl(header, 1); | ||
72 | } | ||
73 | char *fru_get_serial_number(struct fru_common_header *header) | ||
74 | { | ||
75 | return __fru_alloc_get_tl(header, 2); | ||
76 | } | ||
77 | char *fru_get_part_number(struct fru_common_header *header) | ||
78 | { | ||
79 | return __fru_alloc_get_tl(header, 3); | ||
80 | } | ||
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index acd40eb51c46..e4fee216d5a4 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig | |||
@@ -62,16 +62,12 @@ config GPIO_SYSFS | |||
62 | bool "/sys/class/gpio/... (sysfs interface)" | 62 | bool "/sys/class/gpio/... (sysfs interface)" |
63 | depends on SYSFS | 63 | depends on SYSFS |
64 | help | 64 | help |
65 | Say Y here to add a sysfs interface for GPIOs. | 65 | Say Y here to add the legacy sysfs interface for GPIOs. |
66 | 66 | ||
67 | This is mostly useful to work around omissions in a system's | 67 | This ABI is deprecated. If you want to use GPIO from userspace, |
68 | kernel support. Those are common in custom and semicustom | 68 | use the character device /dev/gpiochipN with the appropriate |
69 | hardware assembled using standard kernels with a minimum of | 69 | ioctl() operations instead. The character device is always |
70 | custom patches. In those cases, userspace code may import | 70 | available. |
71 | a given GPIO from the kernel, if no kernel driver requested it. | ||
72 | |||
73 | Kernel drivers may also request that a particular GPIO be | ||
74 | exported to userspace; this can be useful when debugging. | ||
75 | 71 | ||
76 | config GPIO_GENERIC | 72 | config GPIO_GENERIC |
77 | depends on HAS_IOMEM # Only for IOMEM drivers | 73 | depends on HAS_IOMEM # Only for IOMEM drivers |
@@ -178,7 +174,7 @@ config GPIO_CLPS711X | |||
178 | config GPIO_DAVINCI | 174 | config GPIO_DAVINCI |
179 | bool "TI Davinci/Keystone GPIO support" | 175 | bool "TI Davinci/Keystone GPIO support" |
180 | default y if ARCH_DAVINCI | 176 | default y if ARCH_DAVINCI |
181 | depends on ARM && (ARCH_DAVINCI || ARCH_KEYSTONE) | 177 | depends on (ARM || ARM64) && (ARCH_DAVINCI || ARCH_KEYSTONE || ARCH_K3) |
182 | help | 178 | help |
183 | Say yes here to enable GPIO support for TI Davinci/Keystone SoCs. | 179 | Say yes here to enable GPIO support for TI Davinci/Keystone SoCs. |
184 | 180 | ||
@@ -493,7 +489,8 @@ config GPIO_STA2X11 | |||
493 | 489 | ||
494 | config GPIO_STP_XWAY | 490 | config GPIO_STP_XWAY |
495 | bool "XWAY STP GPIOs" | 491 | bool "XWAY STP GPIOs" |
496 | depends on SOC_XWAY | 492 | depends on SOC_XWAY || COMPILE_TEST |
493 | depends on OF_GPIO | ||
497 | help | 494 | help |
498 | This enables support for the Serial To Parallel (STP) unit found on | 495 | This enables support for the Serial To Parallel (STP) unit found on |
499 | XWAY SoC. The STP allows the SoC to drive a shift registers cascade, | 496 | XWAY SoC. The STP allows the SoC to drive a shift registers cascade, |
@@ -602,7 +599,6 @@ config GPIO_XGENE_SB | |||
602 | 599 | ||
603 | config GPIO_XILINX | 600 | config GPIO_XILINX |
604 | tristate "Xilinx GPIO support" | 601 | tristate "Xilinx GPIO support" |
605 | depends on OF_GPIO | ||
606 | help | 602 | help |
607 | Say yes here to support the Xilinx FPGA GPIO device | 603 | Say yes here to support the Xilinx FPGA GPIO device |
608 | 604 | ||
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 6700eee860b7..9e400e34e300 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile | |||
@@ -17,154 +17,154 @@ obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o | |||
17 | # directly supported by gpio-generic | 17 | # directly supported by gpio-generic |
18 | gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o | 18 | gpio-generic-$(CONFIG_GPIO_GENERIC) += gpio-mmio.o |
19 | 19 | ||
20 | obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o | 20 | obj-$(CONFIG_GPIO_104_DIO_48E) += gpio-104-dio-48e.o |
21 | obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o | 21 | obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o |
22 | obj-$(CONFIG_GPIO_104_IDI_48) += gpio-104-idi-48.o | 22 | obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o |
23 | obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o | 23 | obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o |
24 | obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o | 24 | obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o |
25 | obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o | 25 | obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o |
26 | obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o | 26 | obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o |
27 | obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o | 27 | obj-$(CONFIG_GPIO_ADP5588) += gpio-adp5588.o |
28 | obj-$(CONFIG_GPIO_ALTERA) += gpio-altera.o | 28 | obj-$(CONFIG_GPIO_ALTERA_A10SR) += gpio-altera-a10sr.o |
29 | obj-$(CONFIG_GPIO_ALTERA_A10SR) += gpio-altera-a10sr.o | 29 | obj-$(CONFIG_GPIO_ALTERA) += gpio-altera.o |
30 | obj-$(CONFIG_GPIO_AMD_FCH) += gpio-amd-fch.o | 30 | obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o |
31 | obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o | 31 | obj-$(CONFIG_GPIO_AMD_FCH) += gpio-amd-fch.o |
32 | obj-$(CONFIG_GPIO_AMDPT) += gpio-amdpt.o | 32 | obj-$(CONFIG_GPIO_AMDPT) += gpio-amdpt.o |
33 | obj-$(CONFIG_GPIO_ARIZONA) += gpio-arizona.o | 33 | obj-$(CONFIG_GPIO_ARIZONA) += gpio-arizona.o |
34 | obj-$(CONFIG_GPIO_ATH79) += gpio-ath79.o | 34 | obj-$(CONFIG_GPIO_ASPEED) += gpio-aspeed.o |
35 | obj-$(CONFIG_GPIO_ASPEED) += gpio-aspeed.o | 35 | obj-$(CONFIG_GPIO_ATH79) += gpio-ath79.o |
36 | obj-$(CONFIG_GPIO_RASPBERRYPI_EXP) += gpio-raspberrypi-exp.o | 36 | obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o |
37 | obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o | 37 | obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o |
38 | obj-$(CONFIG_GPIO_BD9571MWV) += gpio-bd9571mwv.o | 38 | obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o |
39 | obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o | 39 | obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o |
40 | obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o | 40 | obj-$(CONFIG_GPIO_CADENCE) += gpio-cadence.o |
41 | obj-$(CONFIG_GPIO_CADENCE) += gpio-cadence.o | 41 | obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o |
42 | obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o | 42 | obj-$(CONFIG_GPIO_SNPS_CREG) += gpio-creg-snps.o |
43 | obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o | 43 | obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o |
44 | obj-$(CONFIG_GPIO_CRYSTAL_COVE) += gpio-crystalcove.o | 44 | obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o |
45 | obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o | 45 | obj-$(CONFIG_GPIO_DA9052) += gpio-da9052.o |
46 | obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o | 46 | obj-$(CONFIG_GPIO_DA9055) += gpio-da9055.o |
47 | obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o | 47 | obj-$(CONFIG_GPIO_DAVINCI) += gpio-davinci.o |
48 | obj-$(CONFIG_GPIO_DLN2) += gpio-dln2.o | 48 | obj-$(CONFIG_GPIO_DLN2) += gpio-dln2.o |
49 | obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o | 49 | obj-$(CONFIG_GPIO_DWAPB) += gpio-dwapb.o |
50 | obj-$(CONFIG_GPIO_EIC_SPRD) += gpio-eic-sprd.o | 50 | obj-$(CONFIG_GPIO_EIC_SPRD) += gpio-eic-sprd.o |
51 | obj-$(CONFIG_GPIO_EM) += gpio-em.o | 51 | obj-$(CONFIG_GPIO_EM) += gpio-em.o |
52 | obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o | 52 | obj-$(CONFIG_GPIO_EP93XX) += gpio-ep93xx.o |
53 | obj-$(CONFIG_GPIO_EXAR) += gpio-exar.o | 53 | obj-$(CONFIG_GPIO_EXAR) += gpio-exar.o |
54 | obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o | 54 | obj-$(CONFIG_GPIO_F7188X) += gpio-f7188x.o |
55 | obj-$(CONFIG_GPIO_FTGPIO010) += gpio-ftgpio010.o | 55 | obj-$(CONFIG_GPIO_FTGPIO010) += gpio-ftgpio010.o |
56 | obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o | 56 | obj-$(CONFIG_GPIO_GE_FPGA) += gpio-ge.o |
57 | obj-$(CONFIG_GPIO_GPIO_MM) += gpio-gpio-mm.o | 57 | obj-$(CONFIG_GPIO_GPIO_MM) += gpio-gpio-mm.o |
58 | obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o | 58 | obj-$(CONFIG_GPIO_GRGPIO) += gpio-grgpio.o |
59 | obj-$(CONFIG_GPIO_GW_PLD) += gpio-gw-pld.o | 59 | obj-$(CONFIG_GPIO_GW_PLD) += gpio-gw-pld.o |
60 | obj-$(CONFIG_GPIO_HLWD) += gpio-hlwd.o | 60 | obj-$(CONFIG_GPIO_HLWD) += gpio-hlwd.o |
61 | obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o | 61 | obj-$(CONFIG_HTC_EGPIO) += gpio-htc-egpio.o |
62 | obj-$(CONFIG_GPIO_ICH) += gpio-ich.o | 62 | obj-$(CONFIG_GPIO_ICH) += gpio-ich.o |
63 | obj-$(CONFIG_GPIO_IOP) += gpio-iop.o | 63 | obj-$(CONFIG_GPIO_INTEL_MID) += gpio-intel-mid.o |
64 | obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o | 64 | obj-$(CONFIG_GPIO_IOP) += gpio-iop.o |
65 | obj-$(CONFIG_GPIO_IT87) += gpio-it87.o | 65 | obj-$(CONFIG_GPIO_IT87) += gpio-it87.o |
66 | obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o | 66 | obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o |
67 | obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o | 67 | obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o |
68 | obj-$(CONFIG_ARCH_KS8695) += gpio-ks8695.o | 68 | obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o |
69 | obj-$(CONFIG_GPIO_INTEL_MID) += gpio-intel-mid.o | 69 | obj-$(CONFIG_ARCH_KS8695) += gpio-ks8695.o |
70 | obj-$(CONFIG_GPIO_LOONGSON) += gpio-loongson.o | 70 | obj-$(CONFIG_GPIO_LOONGSON1) += gpio-loongson1.o |
71 | obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o | 71 | obj-$(CONFIG_GPIO_LOONGSON) += gpio-loongson.o |
72 | obj-$(CONFIG_GPIO_LPC18XX) += gpio-lpc18xx.o | 72 | obj-$(CONFIG_GPIO_LP3943) += gpio-lp3943.o |
73 | obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o | 73 | obj-$(CONFIG_GPIO_LP873X) += gpio-lp873x.o |
74 | obj-$(CONFIG_GPIO_LP873X) += gpio-lp873x.o | 74 | obj-$(CONFIG_GPIO_LP87565) += gpio-lp87565.o |
75 | obj-$(CONFIG_GPIO_LP87565) += gpio-lp87565.o | 75 | obj-$(CONFIG_GPIO_LPC18XX) += gpio-lpc18xx.o |
76 | obj-$(CONFIG_GPIO_LYNXPOINT) += gpio-lynxpoint.o | 76 | obj-$(CONFIG_ARCH_LPC32XX) += gpio-lpc32xx.o |
77 | obj-$(CONFIG_GPIO_MADERA) += gpio-madera.o | 77 | obj-$(CONFIG_GPIO_LYNXPOINT) += gpio-lynxpoint.o |
78 | obj-$(CONFIG_GPIO_MAX3191X) += gpio-max3191x.o | 78 | obj-$(CONFIG_GPIO_MADERA) += gpio-madera.o |
79 | obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o | 79 | obj-$(CONFIG_GPIO_MAX3191X) += gpio-max3191x.o |
80 | obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o | 80 | obj-$(CONFIG_GPIO_MAX7300) += gpio-max7300.o |
81 | obj-$(CONFIG_GPIO_MAX7301) += gpio-max7301.o | 81 | obj-$(CONFIG_GPIO_MAX7301) += gpio-max7301.o |
82 | obj-$(CONFIG_GPIO_MAX732X) += gpio-max732x.o | 82 | obj-$(CONFIG_GPIO_MAX730X) += gpio-max730x.o |
83 | obj-$(CONFIG_GPIO_MAX77620) += gpio-max77620.o | 83 | obj-$(CONFIG_GPIO_MAX732X) += gpio-max732x.o |
84 | obj-$(CONFIG_GPIO_MAX77650) += gpio-max77650.o | 84 | obj-$(CONFIG_GPIO_MAX77620) += gpio-max77620.o |
85 | obj-$(CONFIG_GPIO_MB86S7X) += gpio-mb86s7x.o | 85 | obj-$(CONFIG_GPIO_MAX77650) += gpio-max77650.o |
86 | obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o | 86 | obj-$(CONFIG_GPIO_MB86S7X) += gpio-mb86s7x.o |
87 | obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o | 87 | obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o |
88 | obj-$(CONFIG_GPIO_MC33880) += gpio-mc33880.o | 88 | obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o |
89 | obj-$(CONFIG_GPIO_MC9S08DZ60) += gpio-mc9s08dz60.o | 89 | obj-$(CONFIG_GPIO_MENZ127) += gpio-menz127.o |
90 | obj-$(CONFIG_GPIO_MLXBF) += gpio-mlxbf.o | 90 | obj-$(CONFIG_GPIO_MERRIFIELD) += gpio-merrifield.o |
91 | obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o | 91 | obj-$(CONFIG_GPIO_ML_IOH) += gpio-ml-ioh.o |
92 | obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o | 92 | obj-$(CONFIG_GPIO_MLXBF) += gpio-mlxbf.o |
93 | obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o | 93 | obj-$(CONFIG_GPIO_MM_LANTIQ) += gpio-mm-lantiq.o |
94 | obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o | 94 | obj-$(CONFIG_GPIO_MOCKUP) += gpio-mockup.o |
95 | obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o | 95 | obj-$(CONFIG_GPIO_MPC5200) += gpio-mpc5200.o |
96 | obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o | 96 | obj-$(CONFIG_GPIO_MPC8XXX) += gpio-mpc8xxx.o |
97 | obj-$(CONFIG_GPIO_MSIC) += gpio-msic.o | ||
97 | obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o | 98 | obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o |
98 | obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o | 99 | obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o |
99 | obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o | 100 | obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o |
100 | obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o | 101 | obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o |
101 | obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o | 102 | obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o |
102 | obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o | 103 | obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o |
103 | obj-$(CONFIG_GPIO_PCA953X) += gpio-pca953x.o | 104 | obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o |
104 | obj-$(CONFIG_GPIO_PCF857X) += gpio-pcf857x.o | 105 | obj-$(CONFIG_GPIO_PCA953X) += gpio-pca953x.o |
105 | obj-$(CONFIG_GPIO_PCH) += gpio-pch.o | 106 | obj-$(CONFIG_GPIO_PCF857X) += gpio-pcf857x.o |
106 | obj-$(CONFIG_GPIO_PCI_IDIO_16) += gpio-pci-idio-16.o | 107 | obj-$(CONFIG_GPIO_PCH) += gpio-pch.o |
107 | obj-$(CONFIG_GPIO_PCIE_IDIO_24) += gpio-pcie-idio-24.o | 108 | obj-$(CONFIG_GPIO_PCIE_IDIO_24) += gpio-pcie-idio-24.o |
108 | obj-$(CONFIG_GPIO_PISOSR) += gpio-pisosr.o | 109 | obj-$(CONFIG_GPIO_PCI_IDIO_16) += gpio-pci-idio-16.o |
109 | obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o | 110 | obj-$(CONFIG_GPIO_PISOSR) += gpio-pisosr.o |
111 | obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o | ||
110 | obj-$(CONFIG_GPIO_PMIC_EIC_SPRD) += gpio-pmic-eic-sprd.o | 112 | obj-$(CONFIG_GPIO_PMIC_EIC_SPRD) += gpio-pmic-eic-sprd.o |
111 | obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o | 113 | obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o |
112 | obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o | 114 | obj-$(CONFIG_GPIO_RASPBERRYPI_EXP) += gpio-raspberrypi-exp.o |
113 | obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o | 115 | obj-$(CONFIG_GPIO_RC5T583) += gpio-rc5t583.o |
114 | obj-$(CONFIG_GPIO_RCAR) += gpio-rcar.o | 116 | obj-$(CONFIG_GPIO_RCAR) += gpio-rcar.o |
115 | obj-$(CONFIG_GPIO_REG) += gpio-reg.o | 117 | obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o |
116 | obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o | 118 | obj-$(CONFIG_GPIO_REG) += gpio-reg.o |
119 | obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o | ||
117 | obj-$(CONFIG_GPIO_SAMA5D2_PIOBU) += gpio-sama5d2-piobu.o | 120 | obj-$(CONFIG_GPIO_SAMA5D2_PIOBU) += gpio-sama5d2-piobu.o |
118 | obj-$(CONFIG_GPIO_SCH) += gpio-sch.o | 121 | obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o |
119 | obj-$(CONFIG_GPIO_SCH311X) += gpio-sch311x.o | 122 | obj-$(CONFIG_GPIO_SCH) += gpio-sch.o |
120 | obj-$(CONFIG_GPIO_SNPS_CREG) += gpio-creg-snps.o | 123 | obj-$(CONFIG_GPIO_SIOX) += gpio-siox.o |
121 | obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o | 124 | obj-$(CONFIG_GPIO_SODAVILLE) += gpio-sodaville.o |
122 | obj-$(CONFIG_GPIO_SPEAR_SPICS) += gpio-spear-spics.o | 125 | obj-$(CONFIG_GPIO_SPEAR_SPICS) += gpio-spear-spics.o |
123 | obj-$(CONFIG_GPIO_SPRD) += gpio-sprd.o | 126 | obj-$(CONFIG_GPIO_SPRD) += gpio-sprd.o |
124 | obj-$(CONFIG_GPIO_STA2X11) += gpio-sta2x11.o | 127 | obj-$(CONFIG_GPIO_STA2X11) += gpio-sta2x11.o |
125 | obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o | 128 | obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o |
126 | obj-$(CONFIG_GPIO_STP_XWAY) += gpio-stp-xway.o | 129 | obj-$(CONFIG_GPIO_STP_XWAY) += gpio-stp-xway.o |
127 | obj-$(CONFIG_GPIO_SYSCON) += gpio-syscon.o | 130 | obj-$(CONFIG_GPIO_SYSCON) += gpio-syscon.o |
128 | obj-$(CONFIG_GPIO_TB10X) += gpio-tb10x.o | 131 | obj-$(CONFIG_GPIO_TB10X) += gpio-tb10x.o |
129 | obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o | 132 | obj-$(CONFIG_GPIO_TC3589X) += gpio-tc3589x.o |
130 | obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o | 133 | obj-$(CONFIG_GPIO_TEGRA186) += gpio-tegra186.o |
131 | obj-$(CONFIG_GPIO_TEGRA186) += gpio-tegra186.o | 134 | obj-$(CONFIG_GPIO_TEGRA) += gpio-tegra.o |
132 | obj-$(CONFIG_GPIO_THUNDERX) += gpio-thunderx.o | 135 | obj-$(CONFIG_GPIO_THUNDERX) += gpio-thunderx.o |
133 | obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o | 136 | obj-$(CONFIG_GPIO_TIMBERDALE) += gpio-timberdale.o |
134 | obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o | 137 | obj-$(CONFIG_GPIO_TPIC2810) += gpio-tpic2810.o |
135 | obj-$(CONFIG_GPIO_SIOX) += gpio-siox.o | 138 | obj-$(CONFIG_GPIO_TPS65086) += gpio-tps65086.o |
136 | obj-$(CONFIG_GPIO_TPIC2810) += gpio-tpic2810.o | 139 | obj-$(CONFIG_GPIO_TPS65218) += gpio-tps65218.o |
137 | obj-$(CONFIG_GPIO_TPS65086) += gpio-tps65086.o | 140 | obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o |
138 | obj-$(CONFIG_GPIO_TPS65218) += gpio-tps65218.o | 141 | obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o |
139 | obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o | 142 | obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o |
140 | obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o | 143 | obj-$(CONFIG_GPIO_TPS68470) += gpio-tps68470.o |
141 | obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o | 144 | obj-$(CONFIG_GPIO_TQMX86) += gpio-tqmx86.o |
142 | obj-$(CONFIG_GPIO_TPS68470) += gpio-tps68470.o | 145 | obj-$(CONFIG_GPIO_TS4800) += gpio-ts4800.o |
143 | obj-$(CONFIG_GPIO_TQMX86) += gpio-tqmx86.o | 146 | obj-$(CONFIG_GPIO_TS4900) += gpio-ts4900.o |
144 | obj-$(CONFIG_GPIO_TS4800) += gpio-ts4800.o | 147 | obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o |
145 | obj-$(CONFIG_GPIO_TS4900) += gpio-ts4900.o | 148 | obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o |
146 | obj-$(CONFIG_GPIO_TS5500) += gpio-ts5500.o | 149 | obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o |
147 | obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o | 150 | obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o |
148 | obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o | 151 | obj-$(CONFIG_GPIO_UNIPHIER) += gpio-uniphier.o |
149 | obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o | 152 | obj-$(CONFIG_GPIO_VF610) += gpio-vf610.o |
150 | obj-$(CONFIG_GPIO_UNIPHIER) += gpio-uniphier.o | 153 | obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o |
151 | obj-$(CONFIG_GPIO_VF610) += gpio-vf610.o | 154 | obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o |
152 | obj-$(CONFIG_GPIO_VIPERBOARD) += gpio-viperboard.o | 155 | obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o |
153 | obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o | 156 | obj-$(CONFIG_GPIO_WHISKEY_COVE) += gpio-wcove.o |
154 | obj-$(CONFIG_GPIO_VX855) += gpio-vx855.o | 157 | obj-$(CONFIG_GPIO_WINBOND) += gpio-winbond.o |
155 | obj-$(CONFIG_GPIO_WHISKEY_COVE) += gpio-wcove.o | 158 | obj-$(CONFIG_GPIO_WM831X) += gpio-wm831x.o |
156 | obj-$(CONFIG_GPIO_WINBOND) += gpio-winbond.o | 159 | obj-$(CONFIG_GPIO_WM8350) += gpio-wm8350.o |
157 | obj-$(CONFIG_GPIO_WM831X) += gpio-wm831x.o | 160 | obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o |
158 | obj-$(CONFIG_GPIO_WM8350) += gpio-wm8350.o | 161 | obj-$(CONFIG_GPIO_WS16C48) += gpio-ws16c48.o |
159 | obj-$(CONFIG_GPIO_WM8994) += gpio-wm8994.o | 162 | obj-$(CONFIG_GPIO_XGENE) += gpio-xgene.o |
160 | obj-$(CONFIG_GPIO_WS16C48) += gpio-ws16c48.o | 163 | obj-$(CONFIG_GPIO_XGENE_SB) += gpio-xgene-sb.o |
161 | obj-$(CONFIG_GPIO_XGENE) += gpio-xgene.o | 164 | obj-$(CONFIG_GPIO_XILINX) += gpio-xilinx.o |
162 | obj-$(CONFIG_GPIO_XGENE_SB) += gpio-xgene-sb.o | 165 | obj-$(CONFIG_GPIO_XLP) += gpio-xlp.o |
163 | obj-$(CONFIG_GPIO_XILINX) += gpio-xilinx.o | 166 | obj-$(CONFIG_GPIO_XRA1403) += gpio-xra1403.o |
164 | obj-$(CONFIG_GPIO_XLP) += gpio-xlp.o | 167 | obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o |
165 | obj-$(CONFIG_GPIO_XRA1403) += gpio-xra1403.o | 168 | obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o |
166 | obj-$(CONFIG_GPIO_XTENSA) += gpio-xtensa.o | 169 | obj-$(CONFIG_GPIO_ZX) += gpio-zx.o |
167 | obj-$(CONFIG_GPIO_ZEVIO) += gpio-zevio.o | 170 | obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o |
168 | obj-$(CONFIG_GPIO_ZYNQ) += gpio-zynq.o | ||
169 | obj-$(CONFIG_GPIO_ZX) += gpio-zx.o | ||
170 | obj-$(CONFIG_GPIO_LOONGSON1) += gpio-loongson1.o | ||
diff --git a/drivers/gpio/TODO b/drivers/gpio/TODO index 19d27c904916..9c048f10c9ad 100644 --- a/drivers/gpio/TODO +++ b/drivers/gpio/TODO | |||
@@ -90,6 +90,46 @@ GPIOLIB irqchip | |||
90 | The GPIOLIB irqchip is a helper irqchip for "simple cases" that should | 90 | The GPIOLIB irqchip is a helper irqchip for "simple cases" that should |
91 | try to cover any generic kind of irqchip cascaded from a GPIO. | 91 | try to cover any generic kind of irqchip cascaded from a GPIO. |
92 | 92 | ||
93 | - Convert all the GPIOLIB_IRQCHIP users to pass an irqchip template, | ||
94 | parent and flags before calling [devm_]gpiochip_add[_data](). | ||
95 | Currently we set up the irqchip after setting up the gpiochip | ||
96 | using gpiochip_irqchip_add() and gpiochip_set_[chained|nested]_irqchip(). | ||
97 | This is too complex, so convert all users over to just set up | ||
98 | the irqchip before registering the gpio_chip, typical example: | ||
99 | |||
100 | /* Typical state container with dynamic irqchip */ | ||
101 | struct my_gpio { | ||
102 | struct gpio_chip gc; | ||
103 | struct irq_chip irq; | ||
104 | }; | ||
105 | |||
106 | int irq; /* from platform etc */ | ||
107 | struct my_gpio *g; | ||
108 | struct gpio_irq_chip *girq | ||
109 | |||
110 | /* Set up the irqchip dynamically */ | ||
111 | g->irq.name = "my_gpio_irq"; | ||
112 | g->irq.irq_ack = my_gpio_ack_irq; | ||
113 | g->irq.irq_mask = my_gpio_mask_irq; | ||
114 | g->irq.irq_unmask = my_gpio_unmask_irq; | ||
115 | g->irq.irq_set_type = my_gpio_set_irq_type; | ||
116 | |||
117 | /* Get a pointer to the gpio_irq_chip */ | ||
118 | girq = &g->gc.irq; | ||
119 | girq->chip = &g->irq; | ||
120 | girq->parent_handler = ftgpio_gpio_irq_handler; | ||
121 | girq->num_parents = 1; | ||
122 | girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), | ||
123 | GFP_KERNEL); | ||
124 | if (!girq->parents) | ||
125 | return -ENOMEM; | ||
126 | girq->default_type = IRQ_TYPE_NONE; | ||
127 | girq->handler = handle_bad_irq; | ||
128 | girq->parents[0] = irq; | ||
129 | |||
130 | When this is done, we will delete the old APIs for instatiating | ||
131 | GPIOLIB_IRQCHIP and simplify the code. | ||
132 | |||
93 | - Look over and identify any remaining easily converted drivers and | 133 | - Look over and identify any remaining easily converted drivers and |
94 | dry-code conversions to gpiolib irqchip for maintainers to test | 134 | dry-code conversions to gpiolib irqchip for maintainers to test |
95 | 135 | ||
diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index e088b908c2c1..9f2e6b04c361 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c | |||
@@ -30,6 +30,7 @@ struct altera_gpio_chip { | |||
30 | raw_spinlock_t gpio_lock; | 30 | raw_spinlock_t gpio_lock; |
31 | int interrupt_trigger; | 31 | int interrupt_trigger; |
32 | int mapped_irq; | 32 | int mapped_irq; |
33 | struct irq_chip irq_chip; | ||
33 | }; | 34 | }; |
34 | 35 | ||
35 | static void altera_gpio_irq_unmask(struct irq_data *d) | 36 | static void altera_gpio_irq_unmask(struct irq_data *d) |
@@ -101,15 +102,6 @@ static unsigned int altera_gpio_irq_startup(struct irq_data *d) | |||
101 | return 0; | 102 | return 0; |
102 | } | 103 | } |
103 | 104 | ||
104 | static struct irq_chip altera_irq_chip = { | ||
105 | .name = "altera-gpio", | ||
106 | .irq_mask = altera_gpio_irq_mask, | ||
107 | .irq_unmask = altera_gpio_irq_unmask, | ||
108 | .irq_set_type = altera_gpio_irq_set_type, | ||
109 | .irq_startup = altera_gpio_irq_startup, | ||
110 | .irq_shutdown = altera_gpio_irq_mask, | ||
111 | }; | ||
112 | |||
113 | static int altera_gpio_get(struct gpio_chip *gc, unsigned offset) | 105 | static int altera_gpio_get(struct gpio_chip *gc, unsigned offset) |
114 | { | 106 | { |
115 | struct of_mm_gpio_chip *mm_gc; | 107 | struct of_mm_gpio_chip *mm_gc; |
@@ -246,6 +238,7 @@ static int altera_gpio_probe(struct platform_device *pdev) | |||
246 | struct device_node *node = pdev->dev.of_node; | 238 | struct device_node *node = pdev->dev.of_node; |
247 | int reg, ret; | 239 | int reg, ret; |
248 | struct altera_gpio_chip *altera_gc; | 240 | struct altera_gpio_chip *altera_gc; |
241 | struct gpio_irq_chip *girq; | ||
249 | 242 | ||
250 | altera_gc = devm_kzalloc(&pdev->dev, sizeof(*altera_gc), GFP_KERNEL); | 243 | altera_gc = devm_kzalloc(&pdev->dev, sizeof(*altera_gc), GFP_KERNEL); |
251 | if (!altera_gc) | 244 | if (!altera_gc) |
@@ -273,50 +266,50 @@ static int altera_gpio_probe(struct platform_device *pdev) | |||
273 | altera_gc->mmchip.gc.owner = THIS_MODULE; | 266 | altera_gc->mmchip.gc.owner = THIS_MODULE; |
274 | altera_gc->mmchip.gc.parent = &pdev->dev; | 267 | altera_gc->mmchip.gc.parent = &pdev->dev; |
275 | 268 | ||
276 | ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc); | ||
277 | if (ret) { | ||
278 | dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); | ||
279 | return ret; | ||
280 | } | ||
281 | |||
282 | platform_set_drvdata(pdev, altera_gc); | ||
283 | |||
284 | altera_gc->mapped_irq = platform_get_irq(pdev, 0); | 269 | altera_gc->mapped_irq = platform_get_irq(pdev, 0); |
285 | 270 | ||
286 | if (altera_gc->mapped_irq < 0) | 271 | if (altera_gc->mapped_irq < 0) |
287 | goto skip_irq; | 272 | goto skip_irq; |
288 | 273 | ||
289 | if (of_property_read_u32(node, "altr,interrupt-type", ®)) { | 274 | if (of_property_read_u32(node, "altr,interrupt-type", ®)) { |
290 | ret = -EINVAL; | ||
291 | dev_err(&pdev->dev, | 275 | dev_err(&pdev->dev, |
292 | "altr,interrupt-type value not set in device tree\n"); | 276 | "altr,interrupt-type value not set in device tree\n"); |
293 | goto teardown; | 277 | return -EINVAL; |
294 | } | 278 | } |
295 | altera_gc->interrupt_trigger = reg; | 279 | altera_gc->interrupt_trigger = reg; |
296 | 280 | ||
297 | ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc, &altera_irq_chip, 0, | 281 | altera_gc->irq_chip.name = "altera-gpio"; |
298 | handle_bad_irq, IRQ_TYPE_NONE); | 282 | altera_gc->irq_chip.irq_mask = altera_gpio_irq_mask; |
283 | altera_gc->irq_chip.irq_unmask = altera_gpio_irq_unmask; | ||
284 | altera_gc->irq_chip.irq_set_type = altera_gpio_irq_set_type; | ||
285 | altera_gc->irq_chip.irq_startup = altera_gpio_irq_startup; | ||
286 | altera_gc->irq_chip.irq_shutdown = altera_gpio_irq_mask; | ||
287 | |||
288 | girq = &altera_gc->mmchip.gc.irq; | ||
289 | girq->chip = &altera_gc->irq_chip; | ||
290 | if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH) | ||
291 | girq->parent_handler = altera_gpio_irq_leveL_high_handler; | ||
292 | else | ||
293 | girq->parent_handler = altera_gpio_irq_edge_handler; | ||
294 | girq->num_parents = 1; | ||
295 | girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents), | ||
296 | GFP_KERNEL); | ||
297 | if (!girq->parents) | ||
298 | return -ENOMEM; | ||
299 | girq->default_type = IRQ_TYPE_NONE; | ||
300 | girq->handler = handle_bad_irq; | ||
301 | girq->parents[0] = altera_gc->mapped_irq; | ||
299 | 302 | ||
303 | skip_irq: | ||
304 | ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc); | ||
300 | if (ret) { | 305 | if (ret) { |
301 | dev_err(&pdev->dev, "could not add irqchip\n"); | 306 | dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); |
302 | goto teardown; | 307 | return ret; |
303 | } | 308 | } |
304 | 309 | ||
305 | gpiochip_set_chained_irqchip(&altera_gc->mmchip.gc, | 310 | platform_set_drvdata(pdev, altera_gc); |
306 | &altera_irq_chip, | ||
307 | altera_gc->mapped_irq, | ||
308 | altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ? | ||
309 | altera_gpio_irq_leveL_high_handler : | ||
310 | altera_gpio_irq_edge_handler); | ||
311 | 311 | ||
312 | skip_irq: | ||
313 | return 0; | 312 | return 0; |
314 | teardown: | ||
315 | of_mm_gpiochip_remove(&altera_gc->mmchip); | ||
316 | pr_err("%pOF: registration failed with status %d\n", | ||
317 | node, ret); | ||
318 | |||
319 | return ret; | ||
320 | } | 313 | } |
321 | 314 | ||
322 | static int altera_gpio_remove(struct platform_device *pdev) | 315 | static int altera_gpio_remove(struct platform_device *pdev) |
diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c index 38c3f4a3d4aa..181df1581df5 100644 --- a/drivers/gpio/gpio-amd-fch.c +++ b/drivers/gpio/gpio-amd-fch.c | |||
@@ -25,14 +25,13 @@ | |||
25 | #define AMD_FCH_GPIO_FLAG_WRITE BIT(22) | 25 | #define AMD_FCH_GPIO_FLAG_WRITE BIT(22) |
26 | #define AMD_FCH_GPIO_FLAG_READ BIT(16) | 26 | #define AMD_FCH_GPIO_FLAG_READ BIT(16) |
27 | 27 | ||
28 | static struct resource amd_fch_gpio_iores = | 28 | static const struct resource amd_fch_gpio_iores = |
29 | DEFINE_RES_MEM_NAMED( | 29 | DEFINE_RES_MEM_NAMED( |
30 | AMD_FCH_MMIO_BASE + AMD_FCH_GPIO_BANK0_BASE, | 30 | AMD_FCH_MMIO_BASE + AMD_FCH_GPIO_BANK0_BASE, |
31 | AMD_FCH_GPIO_SIZE, | 31 | AMD_FCH_GPIO_SIZE, |
32 | "amd-fch-gpio-iomem"); | 32 | "amd-fch-gpio-iomem"); |
33 | 33 | ||
34 | struct amd_fch_gpio_priv { | 34 | struct amd_fch_gpio_priv { |
35 | struct platform_device *pdev; | ||
36 | struct gpio_chip gc; | 35 | struct gpio_chip gc; |
37 | void __iomem *base; | 36 | void __iomem *base; |
38 | struct amd_fch_gpio_pdata *pdata; | 37 | struct amd_fch_gpio_pdata *pdata; |
@@ -153,7 +152,6 @@ static int amd_fch_gpio_probe(struct platform_device *pdev) | |||
153 | return -ENOMEM; | 152 | return -ENOMEM; |
154 | 153 | ||
155 | priv->pdata = pdata; | 154 | priv->pdata = pdata; |
156 | priv->pdev = pdev; | ||
157 | 155 | ||
158 | priv->gc.owner = THIS_MODULE; | 156 | priv->gc.owner = THIS_MODULE; |
159 | priv->gc.parent = &pdev->dev; | 157 | priv->gc.parent = &pdev->dev; |
diff --git a/drivers/gpio/gpio-amdpt.c b/drivers/gpio/gpio-amdpt.c index ad255ba7ece9..44398992ae15 100644 --- a/drivers/gpio/gpio-amdpt.c +++ b/drivers/gpio/gpio-amdpt.c | |||
@@ -88,7 +88,7 @@ static int pt_gpio_probe(struct platform_device *pdev) | |||
88 | 88 | ||
89 | pt_gpio->reg_base = devm_platform_ioremap_resource(pdev, 0); | 89 | pt_gpio->reg_base = devm_platform_ioremap_resource(pdev, 0); |
90 | if (IS_ERR(pt_gpio->reg_base)) { | 90 | if (IS_ERR(pt_gpio->reg_base)) { |
91 | dev_err(&pdev->dev, "Failed to map MMIO resource for PT GPIO.\n"); | 91 | dev_err(dev, "Failed to map MMIO resource for PT GPIO.\n"); |
92 | return PTR_ERR(pt_gpio->reg_base); | 92 | return PTR_ERR(pt_gpio->reg_base); |
93 | } | 93 | } |
94 | 94 | ||
@@ -98,7 +98,7 @@ static int pt_gpio_probe(struct platform_device *pdev) | |||
98 | pt_gpio->reg_base + PT_DIRECTION_REG, NULL, | 98 | pt_gpio->reg_base + PT_DIRECTION_REG, NULL, |
99 | BGPIOF_READ_OUTPUT_REG_SET); | 99 | BGPIOF_READ_OUTPUT_REG_SET); |
100 | if (ret) { | 100 | if (ret) { |
101 | dev_err(&pdev->dev, "bgpio_init failed\n"); | 101 | dev_err(dev, "bgpio_init failed\n"); |
102 | return ret; | 102 | return ret; |
103 | } | 103 | } |
104 | 104 | ||
@@ -107,11 +107,11 @@ static int pt_gpio_probe(struct platform_device *pdev) | |||
107 | pt_gpio->gc.free = pt_gpio_free; | 107 | pt_gpio->gc.free = pt_gpio_free; |
108 | pt_gpio->gc.ngpio = PT_TOTAL_GPIO; | 108 | pt_gpio->gc.ngpio = PT_TOTAL_GPIO; |
109 | #if defined(CONFIG_OF_GPIO) | 109 | #if defined(CONFIG_OF_GPIO) |
110 | pt_gpio->gc.of_node = pdev->dev.of_node; | 110 | pt_gpio->gc.of_node = dev->of_node; |
111 | #endif | 111 | #endif |
112 | ret = gpiochip_add_data(&pt_gpio->gc, pt_gpio); | 112 | ret = gpiochip_add_data(&pt_gpio->gc, pt_gpio); |
113 | if (ret) { | 113 | if (ret) { |
114 | dev_err(&pdev->dev, "Failed to register GPIO lib\n"); | 114 | dev_err(dev, "Failed to register GPIO lib\n"); |
115 | return ret; | 115 | return ret; |
116 | } | 116 | } |
117 | 117 | ||
@@ -121,7 +121,7 @@ static int pt_gpio_probe(struct platform_device *pdev) | |||
121 | writel(0, pt_gpio->reg_base + PT_SYNC_REG); | 121 | writel(0, pt_gpio->reg_base + PT_SYNC_REG); |
122 | writel(0, pt_gpio->reg_base + PT_CLOCKRATE_REG); | 122 | writel(0, pt_gpio->reg_base + PT_CLOCKRATE_REG); |
123 | 123 | ||
124 | dev_dbg(&pdev->dev, "PT GPIO driver loaded\n"); | 124 | dev_dbg(dev, "PT GPIO driver loaded\n"); |
125 | return ret; | 125 | return ret; |
126 | } | 126 | } |
127 | 127 | ||
diff --git a/drivers/gpio/gpio-ath79.c b/drivers/gpio/gpio-ath79.c index 6c6dcda1100c..f1a5ea9b3de2 100644 --- a/drivers/gpio/gpio-ath79.c +++ b/drivers/gpio/gpio-ath79.c | |||
@@ -222,14 +222,16 @@ MODULE_DEVICE_TABLE(of, ath79_gpio_of_match); | |||
222 | static int ath79_gpio_probe(struct platform_device *pdev) | 222 | static int ath79_gpio_probe(struct platform_device *pdev) |
223 | { | 223 | { |
224 | struct ath79_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); | 224 | struct ath79_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); |
225 | struct device_node *np = pdev->dev.of_node; | 225 | struct device *dev = &pdev->dev; |
226 | struct device_node *np = dev->of_node; | ||
226 | struct ath79_gpio_ctrl *ctrl; | 227 | struct ath79_gpio_ctrl *ctrl; |
228 | struct gpio_irq_chip *girq; | ||
227 | struct resource *res; | 229 | struct resource *res; |
228 | u32 ath79_gpio_count; | 230 | u32 ath79_gpio_count; |
229 | bool oe_inverted; | 231 | bool oe_inverted; |
230 | int err; | 232 | int err; |
231 | 233 | ||
232 | ctrl = devm_kzalloc(&pdev->dev, sizeof(*ctrl), GFP_KERNEL); | 234 | ctrl = devm_kzalloc(dev, sizeof(*ctrl), GFP_KERNEL); |
233 | if (!ctrl) | 235 | if (!ctrl) |
234 | return -ENOMEM; | 236 | return -ENOMEM; |
235 | platform_set_drvdata(pdev, ctrl); | 237 | platform_set_drvdata(pdev, ctrl); |
@@ -237,7 +239,7 @@ static int ath79_gpio_probe(struct platform_device *pdev) | |||
237 | if (np) { | 239 | if (np) { |
238 | err = of_property_read_u32(np, "ngpios", &ath79_gpio_count); | 240 | err = of_property_read_u32(np, "ngpios", &ath79_gpio_count); |
239 | if (err) { | 241 | if (err) { |
240 | dev_err(&pdev->dev, "ngpios property is not valid\n"); | 242 | dev_err(dev, "ngpios property is not valid\n"); |
241 | return err; | 243 | return err; |
242 | } | 244 | } |
243 | oe_inverted = of_device_is_compatible(np, "qca,ar9340-gpio"); | 245 | oe_inverted = of_device_is_compatible(np, "qca,ar9340-gpio"); |
@@ -245,25 +247,24 @@ static int ath79_gpio_probe(struct platform_device *pdev) | |||
245 | ath79_gpio_count = pdata->ngpios; | 247 | ath79_gpio_count = pdata->ngpios; |
246 | oe_inverted = pdata->oe_inverted; | 248 | oe_inverted = pdata->oe_inverted; |
247 | } else { | 249 | } else { |
248 | dev_err(&pdev->dev, "No DT node or platform data found\n"); | 250 | dev_err(dev, "No DT node or platform data found\n"); |
249 | return -EINVAL; | 251 | return -EINVAL; |
250 | } | 252 | } |
251 | 253 | ||
252 | if (ath79_gpio_count >= 32) { | 254 | if (ath79_gpio_count >= 32) { |
253 | dev_err(&pdev->dev, "ngpios must be less than 32\n"); | 255 | dev_err(dev, "ngpios must be less than 32\n"); |
254 | return -EINVAL; | 256 | return -EINVAL; |
255 | } | 257 | } |
256 | 258 | ||
257 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 259 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
258 | if (!res) | 260 | if (!res) |
259 | return -EINVAL; | 261 | return -EINVAL; |
260 | ctrl->base = devm_ioremap_nocache( | 262 | ctrl->base = devm_ioremap_nocache(dev, res->start, resource_size(res)); |
261 | &pdev->dev, res->start, resource_size(res)); | ||
262 | if (!ctrl->base) | 263 | if (!ctrl->base) |
263 | return -ENOMEM; | 264 | return -ENOMEM; |
264 | 265 | ||
265 | raw_spin_lock_init(&ctrl->lock); | 266 | raw_spin_lock_init(&ctrl->lock); |
266 | err = bgpio_init(&ctrl->gc, &pdev->dev, 4, | 267 | err = bgpio_init(&ctrl->gc, dev, 4, |
267 | ctrl->base + AR71XX_GPIO_REG_IN, | 268 | ctrl->base + AR71XX_GPIO_REG_IN, |
268 | ctrl->base + AR71XX_GPIO_REG_SET, | 269 | ctrl->base + AR71XX_GPIO_REG_SET, |
269 | ctrl->base + AR71XX_GPIO_REG_CLEAR, | 270 | ctrl->base + AR71XX_GPIO_REG_CLEAR, |
@@ -271,45 +272,33 @@ static int ath79_gpio_probe(struct platform_device *pdev) | |||
271 | oe_inverted ? ctrl->base + AR71XX_GPIO_REG_OE : NULL, | 272 | oe_inverted ? ctrl->base + AR71XX_GPIO_REG_OE : NULL, |
272 | 0); | 273 | 0); |
273 | if (err) { | 274 | if (err) { |
274 | dev_err(&pdev->dev, "bgpio_init failed\n"); | 275 | dev_err(dev, "bgpio_init failed\n"); |
275 | return err; | 276 | return err; |
276 | } | 277 | } |
277 | /* Use base 0 to stay compatible with legacy platforms */ | 278 | /* Use base 0 to stay compatible with legacy platforms */ |
278 | ctrl->gc.base = 0; | 279 | ctrl->gc.base = 0; |
279 | 280 | ||
280 | err = gpiochip_add_data(&ctrl->gc, ctrl); | 281 | /* Optional interrupt setup */ |
281 | if (err) { | 282 | if (!np || of_property_read_bool(np, "interrupt-controller")) { |
282 | dev_err(&pdev->dev, | 283 | girq = &ctrl->gc.irq; |
283 | "cannot add AR71xx GPIO chip, error=%d", err); | 284 | girq->chip = &ath79_gpio_irqchip; |
284 | return err; | 285 | girq->parent_handler = ath79_gpio_irq_handler; |
286 | girq->num_parents = 1; | ||
287 | girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), | ||
288 | GFP_KERNEL); | ||
289 | if (!girq->parents) | ||
290 | return -ENOMEM; | ||
291 | girq->parents[0] = platform_get_irq(pdev, 0); | ||
292 | girq->default_type = IRQ_TYPE_NONE; | ||
293 | girq->handler = handle_simple_irq; | ||
285 | } | 294 | } |
286 | 295 | ||
287 | if (np && !of_property_read_bool(np, "interrupt-controller")) | 296 | err = devm_gpiochip_add_data(dev, &ctrl->gc, ctrl); |
288 | return 0; | ||
289 | |||
290 | err = gpiochip_irqchip_add(&ctrl->gc, &ath79_gpio_irqchip, 0, | ||
291 | handle_simple_irq, IRQ_TYPE_NONE); | ||
292 | if (err) { | 297 | if (err) { |
293 | dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n"); | 298 | dev_err(dev, |
294 | goto gpiochip_remove; | 299 | "cannot add AR71xx GPIO chip, error=%d", err); |
300 | return err; | ||
295 | } | 301 | } |
296 | |||
297 | gpiochip_set_chained_irqchip(&ctrl->gc, &ath79_gpio_irqchip, | ||
298 | platform_get_irq(pdev, 0), | ||
299 | ath79_gpio_irq_handler); | ||
300 | |||
301 | return 0; | ||
302 | |||
303 | gpiochip_remove: | ||
304 | gpiochip_remove(&ctrl->gc); | ||
305 | return err; | ||
306 | } | ||
307 | |||
308 | static int ath79_gpio_remove(struct platform_device *pdev) | ||
309 | { | ||
310 | struct ath79_gpio_ctrl *ctrl = platform_get_drvdata(pdev); | ||
311 | |||
312 | gpiochip_remove(&ctrl->gc); | ||
313 | return 0; | 302 | return 0; |
314 | } | 303 | } |
315 | 304 | ||
@@ -319,7 +308,6 @@ static struct platform_driver ath79_gpio_driver = { | |||
319 | .of_match_table = ath79_gpio_of_match, | 308 | .of_match_table = ath79_gpio_of_match, |
320 | }, | 309 | }, |
321 | .probe = ath79_gpio_probe, | 310 | .probe = ath79_gpio_probe, |
322 | .remove = ath79_gpio_remove, | ||
323 | }; | 311 | }; |
324 | 312 | ||
325 | module_platform_driver(ath79_gpio_driver); | 313 | module_platform_driver(ath79_gpio_driver); |
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 3bbf5804bd11..fc494a84a29d 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c | |||
@@ -297,7 +297,7 @@ static int davinci_gpio_probe(struct platform_device *pdev) | |||
297 | static void gpio_irq_disable(struct irq_data *d) | 297 | static void gpio_irq_disable(struct irq_data *d) |
298 | { | 298 | { |
299 | struct davinci_gpio_regs __iomem *g = irq2regs(d); | 299 | struct davinci_gpio_regs __iomem *g = irq2regs(d); |
300 | u32 mask = (u32) irq_data_get_irq_handler_data(d); | 300 | uintptr_t mask = (uintptr_t)irq_data_get_irq_handler_data(d); |
301 | 301 | ||
302 | writel_relaxed(mask, &g->clr_falling); | 302 | writel_relaxed(mask, &g->clr_falling); |
303 | writel_relaxed(mask, &g->clr_rising); | 303 | writel_relaxed(mask, &g->clr_rising); |
@@ -306,7 +306,7 @@ static void gpio_irq_disable(struct irq_data *d) | |||
306 | static void gpio_irq_enable(struct irq_data *d) | 306 | static void gpio_irq_enable(struct irq_data *d) |
307 | { | 307 | { |
308 | struct davinci_gpio_regs __iomem *g = irq2regs(d); | 308 | struct davinci_gpio_regs __iomem *g = irq2regs(d); |
309 | u32 mask = (u32) irq_data_get_irq_handler_data(d); | 309 | uintptr_t mask = (uintptr_t)irq_data_get_irq_handler_data(d); |
310 | unsigned status = irqd_get_trigger_type(d); | 310 | unsigned status = irqd_get_trigger_type(d); |
311 | 311 | ||
312 | status &= IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING; | 312 | status &= IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING; |
@@ -447,7 +447,7 @@ davinci_gpio_irq_map(struct irq_domain *d, unsigned int irq, | |||
447 | "davinci_gpio"); | 447 | "davinci_gpio"); |
448 | irq_set_irq_type(irq, IRQ_TYPE_NONE); | 448 | irq_set_irq_type(irq, IRQ_TYPE_NONE); |
449 | irq_set_chip_data(irq, (__force void *)g); | 449 | irq_set_chip_data(irq, (__force void *)g); |
450 | irq_set_handler_data(irq, (void *)__gpio_mask(hw)); | 450 | irq_set_handler_data(irq, (void *)(uintptr_t)__gpio_mask(hw)); |
451 | 451 | ||
452 | return 0; | 452 | return 0; |
453 | } | 453 | } |
@@ -632,6 +632,7 @@ done: | |||
632 | 632 | ||
633 | static const struct of_device_id davinci_gpio_ids[] = { | 633 | static const struct of_device_id davinci_gpio_ids[] = { |
634 | { .compatible = "ti,keystone-gpio", keystone_gpio_get_irq_chip}, | 634 | { .compatible = "ti,keystone-gpio", keystone_gpio_get_irq_chip}, |
635 | { .compatible = "ti,am654-gpio", keystone_gpio_get_irq_chip}, | ||
635 | { .compatible = "ti,dm6441-gpio", davinci_gpio_get_irq_chip}, | 636 | { .compatible = "ti,dm6441-gpio", davinci_gpio_get_irq_chip}, |
636 | { /* sentinel */ }, | 637 | { /* sentinel */ }, |
637 | }; | 638 | }; |
diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c index 77092268ee95..7b9ac4a12c20 100644 --- a/drivers/gpio/gpio-eic-sprd.c +++ b/drivers/gpio/gpio-eic-sprd.c | |||
@@ -568,7 +568,6 @@ static int sprd_eic_probe(struct platform_device *pdev) | |||
568 | const struct sprd_eic_variant_data *pdata; | 568 | const struct sprd_eic_variant_data *pdata; |
569 | struct gpio_irq_chip *irq; | 569 | struct gpio_irq_chip *irq; |
570 | struct sprd_eic *sprd_eic; | 570 | struct sprd_eic *sprd_eic; |
571 | struct resource *res; | ||
572 | int ret, i; | 571 | int ret, i; |
573 | 572 | ||
574 | pdata = of_device_get_match_data(&pdev->dev); | 573 | pdata = of_device_get_match_data(&pdev->dev); |
@@ -597,13 +596,9 @@ static int sprd_eic_probe(struct platform_device *pdev) | |||
597 | * have one bank EIC, thus base[1] and base[2] can be | 596 | * have one bank EIC, thus base[1] and base[2] can be |
598 | * optional. | 597 | * optional. |
599 | */ | 598 | */ |
600 | res = platform_get_resource(pdev, IORESOURCE_MEM, i); | 599 | sprd_eic->base[i] = devm_platform_ioremap_resource(pdev, i); |
601 | if (!res) | ||
602 | continue; | ||
603 | |||
604 | sprd_eic->base[i] = devm_ioremap_resource(&pdev->dev, res); | ||
605 | if (IS_ERR(sprd_eic->base[i])) | 600 | if (IS_ERR(sprd_eic->base[i])) |
606 | return PTR_ERR(sprd_eic->base[i]); | 601 | continue; |
607 | } | 602 | } |
608 | 603 | ||
609 | sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type]; | 604 | sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type]; |
diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index 84a7375cee0a..b6af705a4e5f 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c | |||
@@ -270,10 +270,8 @@ static int em_gio_probe(struct platform_device *pdev) | |||
270 | int ret; | 270 | int ret; |
271 | 271 | ||
272 | p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); | 272 | p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); |
273 | if (!p) { | 273 | if (!p) |
274 | ret = -ENOMEM; | 274 | return -ENOMEM; |
275 | goto err0; | ||
276 | } | ||
277 | 275 | ||
278 | p->pdev = pdev; | 276 | p->pdev = pdev; |
279 | platform_set_drvdata(pdev, p); | 277 | platform_set_drvdata(pdev, p); |
@@ -286,30 +284,22 @@ static int em_gio_probe(struct platform_device *pdev) | |||
286 | 284 | ||
287 | if (!io[0] || !io[1] || !irq[0] || !irq[1]) { | 285 | if (!io[0] || !io[1] || !irq[0] || !irq[1]) { |
288 | dev_err(&pdev->dev, "missing IRQ or IOMEM\n"); | 286 | dev_err(&pdev->dev, "missing IRQ or IOMEM\n"); |
289 | ret = -EINVAL; | 287 | return -EINVAL; |
290 | goto err0; | ||
291 | } | 288 | } |
292 | 289 | ||
293 | p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start, | 290 | p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start, |
294 | resource_size(io[0])); | 291 | resource_size(io[0])); |
295 | if (!p->base0) { | 292 | if (!p->base0) |
296 | dev_err(&pdev->dev, "failed to remap low I/O memory\n"); | 293 | return -ENOMEM; |
297 | ret = -ENXIO; | ||
298 | goto err0; | ||
299 | } | ||
300 | 294 | ||
301 | p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start, | 295 | p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start, |
302 | resource_size(io[1])); | 296 | resource_size(io[1])); |
303 | if (!p->base1) { | 297 | if (!p->base1) |
304 | dev_err(&pdev->dev, "failed to remap high I/O memory\n"); | 298 | return -ENOMEM; |
305 | ret = -ENXIO; | ||
306 | goto err0; | ||
307 | } | ||
308 | 299 | ||
309 | if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) { | 300 | if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) { |
310 | dev_err(&pdev->dev, "Missing ngpios OF property\n"); | 301 | dev_err(&pdev->dev, "Missing ngpios OF property\n"); |
311 | ret = -EINVAL; | 302 | return -EINVAL; |
312 | goto err0; | ||
313 | } | 303 | } |
314 | 304 | ||
315 | gpio_chip = &p->gpio_chip; | 305 | gpio_chip = &p->gpio_chip; |
@@ -339,9 +329,8 @@ static int em_gio_probe(struct platform_device *pdev) | |||
339 | p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, ngpios, 0, | 329 | p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, ngpios, 0, |
340 | &em_gio_irq_domain_ops, p); | 330 | &em_gio_irq_domain_ops, p); |
341 | if (!p->irq_domain) { | 331 | if (!p->irq_domain) { |
342 | ret = -ENXIO; | ||
343 | dev_err(&pdev->dev, "cannot initialize irq domain\n"); | 332 | dev_err(&pdev->dev, "cannot initialize irq domain\n"); |
344 | goto err0; | 333 | return -ENXIO; |
345 | } | 334 | } |
346 | 335 | ||
347 | if (devm_request_irq(&pdev->dev, irq[0]->start, | 336 | if (devm_request_irq(&pdev->dev, irq[0]->start, |
@@ -358,7 +347,7 @@ static int em_gio_probe(struct platform_device *pdev) | |||
358 | goto err1; | 347 | goto err1; |
359 | } | 348 | } |
360 | 349 | ||
361 | ret = gpiochip_add_data(gpio_chip, p); | 350 | ret = devm_gpiochip_add_data(&pdev->dev, gpio_chip, p); |
362 | if (ret) { | 351 | if (ret) { |
363 | dev_err(&pdev->dev, "failed to add GPIO controller\n"); | 352 | dev_err(&pdev->dev, "failed to add GPIO controller\n"); |
364 | goto err1; | 353 | goto err1; |
@@ -368,7 +357,6 @@ static int em_gio_probe(struct platform_device *pdev) | |||
368 | 357 | ||
369 | err1: | 358 | err1: |
370 | irq_domain_remove(p->irq_domain); | 359 | irq_domain_remove(p->irq_domain); |
371 | err0: | ||
372 | return ret; | 360 | return ret; |
373 | } | 361 | } |
374 | 362 | ||
@@ -376,8 +364,6 @@ static int em_gio_remove(struct platform_device *pdev) | |||
376 | { | 364 | { |
377 | struct em_gio_priv *p = platform_get_drvdata(pdev); | 365 | struct em_gio_priv *p = platform_get_drvdata(pdev); |
378 | 366 | ||
379 | gpiochip_remove(&p->gpio_chip); | ||
380 | |||
381 | irq_domain_remove(p->irq_domain); | 367 | irq_domain_remove(p->irq_domain); |
382 | return 0; | 368 | return 0; |
383 | } | 369 | } |
diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c index 71728d6e0bca..a90870a60c15 100644 --- a/drivers/gpio/gpio-ep93xx.c +++ b/drivers/gpio/gpio-ep93xx.c | |||
@@ -393,16 +393,13 @@ static int ep93xx_gpio_add_bank(struct gpio_chip *gc, struct device *dev, | |||
393 | static int ep93xx_gpio_probe(struct platform_device *pdev) | 393 | static int ep93xx_gpio_probe(struct platform_device *pdev) |
394 | { | 394 | { |
395 | struct ep93xx_gpio *epg; | 395 | struct ep93xx_gpio *epg; |
396 | struct resource *res; | ||
397 | int i; | 396 | int i; |
398 | struct device *dev = &pdev->dev; | ||
399 | 397 | ||
400 | epg = devm_kzalloc(dev, sizeof(*epg), GFP_KERNEL); | 398 | epg = devm_kzalloc(&pdev->dev, sizeof(*epg), GFP_KERNEL); |
401 | if (!epg) | 399 | if (!epg) |
402 | return -ENOMEM; | 400 | return -ENOMEM; |
403 | 401 | ||
404 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 402 | epg->base = devm_platform_ioremap_resource(pdev, 0); |
405 | epg->base = devm_ioremap_resource(dev, res); | ||
406 | if (IS_ERR(epg->base)) | 403 | if (IS_ERR(epg->base)) |
407 | return PTR_ERR(epg->base); | 404 | return PTR_ERR(epg->base); |
408 | 405 | ||
diff --git a/drivers/gpio/gpio-ftgpio010.c b/drivers/gpio/gpio-ftgpio010.c index 8ff8ce2970d9..250e71f3e688 100644 --- a/drivers/gpio/gpio-ftgpio010.c +++ b/drivers/gpio/gpio-ftgpio010.c | |||
@@ -226,6 +226,7 @@ static int ftgpio_gpio_probe(struct platform_device *pdev) | |||
226 | { | 226 | { |
227 | struct device *dev = &pdev->dev; | 227 | struct device *dev = &pdev->dev; |
228 | struct ftgpio_gpio *g; | 228 | struct ftgpio_gpio *g; |
229 | struct gpio_irq_chip *girq; | ||
229 | int irq; | 230 | int irq; |
230 | int ret; | 231 | int ret; |
231 | 232 | ||
@@ -277,6 +278,24 @@ static int ftgpio_gpio_probe(struct platform_device *pdev) | |||
277 | if (!IS_ERR(g->clk)) | 278 | if (!IS_ERR(g->clk)) |
278 | g->gc.set_config = ftgpio_gpio_set_config; | 279 | g->gc.set_config = ftgpio_gpio_set_config; |
279 | 280 | ||
281 | g->irq.name = "FTGPIO010"; | ||
282 | g->irq.irq_ack = ftgpio_gpio_ack_irq; | ||
283 | g->irq.irq_mask = ftgpio_gpio_mask_irq; | ||
284 | g->irq.irq_unmask = ftgpio_gpio_unmask_irq; | ||
285 | g->irq.irq_set_type = ftgpio_gpio_set_irq_type; | ||
286 | |||
287 | girq = &g->gc.irq; | ||
288 | girq->chip = &g->irq; | ||
289 | girq->parent_handler = ftgpio_gpio_irq_handler; | ||
290 | girq->num_parents = 1; | ||
291 | girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), | ||
292 | GFP_KERNEL); | ||
293 | if (!girq->parents) | ||
294 | return -ENOMEM; | ||
295 | girq->default_type = IRQ_TYPE_NONE; | ||
296 | girq->handler = handle_bad_irq; | ||
297 | girq->parents[0] = irq; | ||
298 | |||
280 | ret = devm_gpiochip_add_data(dev, &g->gc, g); | 299 | ret = devm_gpiochip_add_data(dev, &g->gc, g); |
281 | if (ret) | 300 | if (ret) |
282 | goto dis_clk; | 301 | goto dis_clk; |
@@ -289,22 +308,6 @@ static int ftgpio_gpio_probe(struct platform_device *pdev) | |||
289 | /* Clear any use of debounce */ | 308 | /* Clear any use of debounce */ |
290 | writel(0x0, g->base + GPIO_DEBOUNCE_EN); | 309 | writel(0x0, g->base + GPIO_DEBOUNCE_EN); |
291 | 310 | ||
292 | g->irq.name = "FTGPIO010"; | ||
293 | g->irq.irq_ack = ftgpio_gpio_ack_irq; | ||
294 | g->irq.irq_mask = ftgpio_gpio_mask_irq; | ||
295 | g->irq.irq_unmask = ftgpio_gpio_unmask_irq; | ||
296 | g->irq.irq_set_type = ftgpio_gpio_set_irq_type; | ||
297 | |||
298 | ret = gpiochip_irqchip_add(&g->gc, &g->irq, | ||
299 | 0, handle_bad_irq, | ||
300 | IRQ_TYPE_NONE); | ||
301 | if (ret) { | ||
302 | dev_info(dev, "could not add irqchip\n"); | ||
303 | goto dis_clk; | ||
304 | } | ||
305 | gpiochip_set_chained_irqchip(&g->gc, &g->irq, | ||
306 | irq, ftgpio_gpio_irq_handler); | ||
307 | |||
308 | platform_set_drvdata(pdev, g); | 311 | platform_set_drvdata(pdev, g); |
309 | dev_info(dev, "FTGPIO010 @%p registered\n", g->base); | 312 | dev_info(dev, "FTGPIO010 @%p registered\n", g->base); |
310 | 313 | ||
diff --git a/drivers/gpio/gpio-grgpio.c b/drivers/gpio/gpio-grgpio.c index 7df48e76baea..0937b605e134 100644 --- a/drivers/gpio/gpio-grgpio.c +++ b/drivers/gpio/gpio-grgpio.c | |||
@@ -329,7 +329,6 @@ static int grgpio_probe(struct platform_device *ofdev) | |||
329 | void __iomem *regs; | 329 | void __iomem *regs; |
330 | struct gpio_chip *gc; | 330 | struct gpio_chip *gc; |
331 | struct grgpio_priv *priv; | 331 | struct grgpio_priv *priv; |
332 | struct resource *res; | ||
333 | int err; | 332 | int err; |
334 | u32 prop; | 333 | u32 prop; |
335 | s32 *irqmap; | 334 | s32 *irqmap; |
@@ -340,8 +339,7 @@ static int grgpio_probe(struct platform_device *ofdev) | |||
340 | if (!priv) | 339 | if (!priv) |
341 | return -ENOMEM; | 340 | return -ENOMEM; |
342 | 341 | ||
343 | res = platform_get_resource(ofdev, IORESOURCE_MEM, 0); | 342 | regs = devm_platform_ioremap_resource(ofdev, 0); |
344 | regs = devm_ioremap_resource(&ofdev->dev, res); | ||
345 | if (IS_ERR(regs)) | 343 | if (IS_ERR(regs)) |
346 | return PTR_ERR(regs); | 344 | return PTR_ERR(regs); |
347 | 345 | ||
diff --git a/drivers/gpio/gpio-ixp4xx.c b/drivers/gpio/gpio-ixp4xx.c index 4b1cf7ea858d..670c2a85a35b 100644 --- a/drivers/gpio/gpio-ixp4xx.c +++ b/drivers/gpio/gpio-ixp4xx.c | |||
@@ -205,20 +205,20 @@ static int ixp4xx_gpio_irq_domain_translate(struct irq_domain *domain, | |||
205 | unsigned long *hwirq, | 205 | unsigned long *hwirq, |
206 | unsigned int *type) | 206 | unsigned int *type) |
207 | { | 207 | { |
208 | int ret; | ||
208 | 209 | ||
209 | /* We support standard DT translation */ | 210 | /* We support standard DT translation */ |
210 | if (is_of_node(fwspec->fwnode) && fwspec->param_count == 2) { | 211 | if (is_of_node(fwspec->fwnode) && fwspec->param_count == 2) { |
211 | *hwirq = fwspec->param[0]; | 212 | return irq_domain_translate_twocell(domain, fwspec, |
212 | *type = fwspec->param[1]; | 213 | hwirq, type); |
213 | return 0; | ||
214 | } | 214 | } |
215 | 215 | ||
216 | /* This goes away when we transition to DT */ | 216 | /* This goes away when we transition to DT */ |
217 | if (is_fwnode_irqchip(fwspec->fwnode)) { | 217 | if (is_fwnode_irqchip(fwspec->fwnode)) { |
218 | if (fwspec->param_count != 2) | 218 | ret = irq_domain_translate_twocell(domain, fwspec, |
219 | return -EINVAL; | 219 | hwirq, type); |
220 | *hwirq = fwspec->param[0]; | 220 | if (ret) |
221 | *type = fwspec->param[1]; | 221 | return ret; |
222 | WARN_ON(*type == IRQ_TYPE_NONE); | 222 | WARN_ON(*type == IRQ_TYPE_NONE); |
223 | return 0; | 223 | return 0; |
224 | } | 224 | } |
diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c index 6b5b5a8b9173..cdf50e4ea165 100644 --- a/drivers/gpio/gpio-janz-ttl.c +++ b/drivers/gpio/gpio-janz-ttl.c | |||
@@ -140,18 +140,17 @@ static void ttl_setup_device(struct ttl_module *mod) | |||
140 | static int ttl_probe(struct platform_device *pdev) | 140 | static int ttl_probe(struct platform_device *pdev) |
141 | { | 141 | { |
142 | struct janz_platform_data *pdata; | 142 | struct janz_platform_data *pdata; |
143 | struct device *dev = &pdev->dev; | ||
144 | struct ttl_module *mod; | 143 | struct ttl_module *mod; |
145 | struct gpio_chip *gpio; | 144 | struct gpio_chip *gpio; |
146 | int ret; | 145 | int ret; |
147 | 146 | ||
148 | pdata = dev_get_platdata(&pdev->dev); | 147 | pdata = dev_get_platdata(&pdev->dev); |
149 | if (!pdata) { | 148 | if (!pdata) { |
150 | dev_err(dev, "no platform data\n"); | 149 | dev_err(&pdev->dev, "no platform data\n"); |
151 | return -ENXIO; | 150 | return -ENXIO; |
152 | } | 151 | } |
153 | 152 | ||
154 | mod = devm_kzalloc(dev, sizeof(*mod), GFP_KERNEL); | 153 | mod = devm_kzalloc(&pdev->dev, sizeof(*mod), GFP_KERNEL); |
155 | if (!mod) | 154 | if (!mod) |
156 | return -ENOMEM; | 155 | return -ENOMEM; |
157 | 156 | ||
@@ -177,9 +176,9 @@ static int ttl_probe(struct platform_device *pdev) | |||
177 | gpio->base = -1; | 176 | gpio->base = -1; |
178 | gpio->ngpio = 20; | 177 | gpio->ngpio = 20; |
179 | 178 | ||
180 | ret = devm_gpiochip_add_data(dev, gpio, NULL); | 179 | ret = devm_gpiochip_add_data(&pdev->dev, gpio, NULL); |
181 | if (ret) { | 180 | if (ret) { |
182 | dev_err(dev, "unable to add GPIO chip\n"); | 181 | dev_err(&pdev->dev, "unable to add GPIO chip\n"); |
183 | return ret; | 182 | return ret; |
184 | } | 183 | } |
185 | 184 | ||
diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c index c9dad0543672..4dbc837d1215 100644 --- a/drivers/gpio/gpio-madera.c +++ b/drivers/gpio/gpio-madera.c | |||
@@ -1,12 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | /* | 2 | /* |
3 | * GPIO support for Cirrus Logic Madera codecs | 3 | * GPIO support for Cirrus Logic Madera codecs |
4 | * | 4 | * |
5 | * Copyright (C) 2015-2018 Cirrus Logic | 5 | * Copyright (C) 2015-2018 Cirrus Logic |
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by the | ||
9 | * Free Software Foundation; version 2. | ||
10 | */ | 6 | */ |
11 | 7 | ||
12 | #include <linux/gpio/driver.h> | 8 | #include <linux/gpio/driver.h> |
diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index 5e4102e7b1f9..5fb0bcf31142 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c | |||
@@ -649,12 +649,12 @@ static int max732x_probe(struct i2c_client *client, | |||
649 | case 0x60: | 649 | case 0x60: |
650 | chip->client_group_a = client; | 650 | chip->client_group_a = client; |
651 | if (nr_port > 8) { | 651 | if (nr_port > 8) { |
652 | c = i2c_new_dummy(client->adapter, addr_b); | 652 | c = devm_i2c_new_dummy_device(&client->dev, |
653 | if (!c) { | 653 | client->adapter, addr_b); |
654 | if (IS_ERR(c)) { | ||
654 | dev_err(&client->dev, | 655 | dev_err(&client->dev, |
655 | "Failed to allocate I2C device\n"); | 656 | "Failed to allocate I2C device\n"); |
656 | ret = -ENODEV; | 657 | return PTR_ERR(c); |
657 | goto out_failed; | ||
658 | } | 658 | } |
659 | chip->client_group_b = chip->client_dummy = c; | 659 | chip->client_group_b = chip->client_dummy = c; |
660 | } | 660 | } |
@@ -662,12 +662,12 @@ static int max732x_probe(struct i2c_client *client, | |||
662 | case 0x50: | 662 | case 0x50: |
663 | chip->client_group_b = client; | 663 | chip->client_group_b = client; |
664 | if (nr_port > 8) { | 664 | if (nr_port > 8) { |
665 | c = i2c_new_dummy(client->adapter, addr_a); | 665 | c = devm_i2c_new_dummy_device(&client->dev, |
666 | if (!c) { | 666 | client->adapter, addr_a); |
667 | if (IS_ERR(c)) { | ||
667 | dev_err(&client->dev, | 668 | dev_err(&client->dev, |
668 | "Failed to allocate I2C device\n"); | 669 | "Failed to allocate I2C device\n"); |
669 | ret = -ENODEV; | 670 | return PTR_ERR(c); |
670 | goto out_failed; | ||
671 | } | 671 | } |
672 | chip->client_group_a = chip->client_dummy = c; | 672 | chip->client_group_a = chip->client_dummy = c; |
673 | } | 673 | } |
@@ -675,37 +675,33 @@ static int max732x_probe(struct i2c_client *client, | |||
675 | default: | 675 | default: |
676 | dev_err(&client->dev, "invalid I2C address specified %02x\n", | 676 | dev_err(&client->dev, "invalid I2C address specified %02x\n", |
677 | client->addr); | 677 | client->addr); |
678 | ret = -EINVAL; | 678 | return -EINVAL; |
679 | goto out_failed; | ||
680 | } | 679 | } |
681 | 680 | ||
682 | if (nr_port > 8 && !chip->client_dummy) { | 681 | if (nr_port > 8 && !chip->client_dummy) { |
683 | dev_err(&client->dev, | 682 | dev_err(&client->dev, |
684 | "Failed to allocate second group I2C device\n"); | 683 | "Failed to allocate second group I2C device\n"); |
685 | ret = -ENODEV; | 684 | return -ENODEV; |
686 | goto out_failed; | ||
687 | } | 685 | } |
688 | 686 | ||
689 | mutex_init(&chip->lock); | 687 | mutex_init(&chip->lock); |
690 | 688 | ||
691 | ret = max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]); | 689 | ret = max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]); |
692 | if (ret) | 690 | if (ret) |
693 | goto out_failed; | 691 | return ret; |
694 | if (nr_port > 8) { | 692 | if (nr_port > 8) { |
695 | ret = max732x_readb(chip, is_group_a(chip, 8), &chip->reg_out[1]); | 693 | ret = max732x_readb(chip, is_group_a(chip, 8), &chip->reg_out[1]); |
696 | if (ret) | 694 | if (ret) |
697 | goto out_failed; | 695 | return ret; |
698 | } | 696 | } |
699 | 697 | ||
700 | ret = gpiochip_add_data(&chip->gpio_chip, chip); | 698 | ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip); |
701 | if (ret) | 699 | if (ret) |
702 | goto out_failed; | 700 | return ret; |
703 | 701 | ||
704 | ret = max732x_irq_setup(chip, id); | 702 | ret = max732x_irq_setup(chip, id); |
705 | if (ret) { | 703 | if (ret) |
706 | gpiochip_remove(&chip->gpio_chip); | 704 | return ret; |
707 | goto out_failed; | ||
708 | } | ||
709 | 705 | ||
710 | if (pdata && pdata->setup) { | 706 | if (pdata && pdata->setup) { |
711 | ret = pdata->setup(client, chip->gpio_chip.base, | 707 | ret = pdata->setup(client, chip->gpio_chip.base, |
@@ -716,10 +712,6 @@ static int max732x_probe(struct i2c_client *client, | |||
716 | 712 | ||
717 | i2c_set_clientdata(client, chip); | 713 | i2c_set_clientdata(client, chip); |
718 | return 0; | 714 | return 0; |
719 | |||
720 | out_failed: | ||
721 | i2c_unregister_device(chip->client_dummy); | ||
722 | return ret; | ||
723 | } | 715 | } |
724 | 716 | ||
725 | static int max732x_remove(struct i2c_client *client) | 717 | static int max732x_remove(struct i2c_client *client) |
@@ -739,11 +731,6 @@ static int max732x_remove(struct i2c_client *client) | |||
739 | } | 731 | } |
740 | } | 732 | } |
741 | 733 | ||
742 | gpiochip_remove(&chip->gpio_chip); | ||
743 | |||
744 | /* unregister any dummy i2c_client */ | ||
745 | i2c_unregister_device(chip->client_dummy); | ||
746 | |||
747 | return 0; | 734 | return 0; |
748 | } | 735 | } |
749 | 736 | ||
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index b6a4efce7c92..f1a9c0544e3f 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c | |||
@@ -315,7 +315,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev, | |||
315 | struct gpio_mockup_chip *chip) | 315 | struct gpio_mockup_chip *chip) |
316 | { | 316 | { |
317 | struct gpio_mockup_dbgfs_private *priv; | 317 | struct gpio_mockup_dbgfs_private *priv; |
318 | struct dentry *evfile; | ||
319 | struct gpio_chip *gc; | 318 | struct gpio_chip *gc; |
320 | const char *devname; | 319 | const char *devname; |
321 | char *name; | 320 | char *name; |
@@ -325,32 +324,25 @@ static void gpio_mockup_debugfs_setup(struct device *dev, | |||
325 | devname = dev_name(&gc->gpiodev->dev); | 324 | devname = dev_name(&gc->gpiodev->dev); |
326 | 325 | ||
327 | chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir); | 326 | chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir); |
328 | if (IS_ERR_OR_NULL(chip->dbg_dir)) | ||
329 | goto err; | ||
330 | 327 | ||
331 | for (i = 0; i < gc->ngpio; i++) { | 328 | for (i = 0; i < gc->ngpio; i++) { |
332 | name = devm_kasprintf(dev, GFP_KERNEL, "%d", i); | 329 | name = devm_kasprintf(dev, GFP_KERNEL, "%d", i); |
333 | if (!name) | 330 | if (!name) |
334 | goto err; | 331 | return; |
335 | 332 | ||
336 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | 333 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
337 | if (!priv) | 334 | if (!priv) |
338 | goto err; | 335 | return; |
339 | 336 | ||
340 | priv->chip = chip; | 337 | priv->chip = chip; |
341 | priv->offset = i; | 338 | priv->offset = i; |
342 | priv->desc = &gc->gpiodev->descs[i]; | 339 | priv->desc = &gc->gpiodev->descs[i]; |
343 | 340 | ||
344 | evfile = debugfs_create_file(name, 0200, chip->dbg_dir, priv, | 341 | debugfs_create_file(name, 0200, chip->dbg_dir, priv, |
345 | &gpio_mockup_debugfs_ops); | 342 | &gpio_mockup_debugfs_ops); |
346 | if (IS_ERR_OR_NULL(evfile)) | ||
347 | goto err; | ||
348 | } | 343 | } |
349 | 344 | ||
350 | return; | 345 | return; |
351 | |||
352 | err: | ||
353 | dev_err(dev, "error creating debugfs files\n"); | ||
354 | } | 346 | } |
355 | 347 | ||
356 | static int gpio_mockup_name_lines(struct device *dev, | 348 | static int gpio_mockup_name_lines(struct device *dev, |
@@ -447,8 +439,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) | |||
447 | if (rv) | 439 | if (rv) |
448 | return rv; | 440 | return rv; |
449 | 441 | ||
450 | if (!IS_ERR_OR_NULL(gpio_mockup_dbg_dir)) | 442 | gpio_mockup_debugfs_setup(dev, chip); |
451 | gpio_mockup_debugfs_setup(dev, chip); | ||
452 | 443 | ||
453 | return 0; | 444 | return 0; |
454 | } | 445 | } |
@@ -501,8 +492,6 @@ static int __init gpio_mockup_init(void) | |||
501 | } | 492 | } |
502 | 493 | ||
503 | gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup", NULL); | 494 | gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup", NULL); |
504 | if (IS_ERR_OR_NULL(gpio_mockup_dbg_dir)) | ||
505 | gpio_mockup_err("error creating debugfs directory\n"); | ||
506 | 495 | ||
507 | err = platform_driver_register(&gpio_mockup_driver); | 496 | err = platform_driver_register(&gpio_mockup_driver); |
508 | if (err) { | 497 | if (err) { |
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c index 059094ac44cb..869d47f89599 100644 --- a/drivers/gpio/gpio-mvebu.c +++ b/drivers/gpio/gpio-mvebu.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/err.h> | 38 | #include <linux/err.h> |
39 | #include <linux/gpio/driver.h> | 39 | #include <linux/gpio/driver.h> |
40 | #include <linux/gpio/consumer.h> | 40 | #include <linux/gpio/consumer.h> |
41 | #include <linux/gpio/machine.h> | ||
41 | #include <linux/init.h> | 42 | #include <linux/init.h> |
42 | #include <linux/io.h> | 43 | #include <linux/io.h> |
43 | #include <linux/irq.h> | 44 | #include <linux/irq.h> |
@@ -618,18 +619,14 @@ static int mvebu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) | |||
618 | ret = -EBUSY; | 619 | ret = -EBUSY; |
619 | } else { | 620 | } else { |
620 | desc = gpiochip_request_own_desc(&mvchip->chip, | 621 | desc = gpiochip_request_own_desc(&mvchip->chip, |
621 | pwm->hwpwm, "mvebu-pwm", 0); | 622 | pwm->hwpwm, "mvebu-pwm", |
623 | GPIO_ACTIVE_HIGH, | ||
624 | GPIOD_OUT_LOW); | ||
622 | if (IS_ERR(desc)) { | 625 | if (IS_ERR(desc)) { |
623 | ret = PTR_ERR(desc); | 626 | ret = PTR_ERR(desc); |
624 | goto out; | 627 | goto out; |
625 | } | 628 | } |
626 | 629 | ||
627 | ret = gpiod_direction_output(desc, 0); | ||
628 | if (ret) { | ||
629 | gpiochip_free_own_desc(desc); | ||
630 | goto out; | ||
631 | } | ||
632 | |||
633 | mvpwm->gpiod = desc; | 630 | mvpwm->gpiod = desc; |
634 | } | 631 | } |
635 | out: | 632 | out: |
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 9276ef616430..d0f27084a942 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -44,8 +44,9 @@ struct gpio_regs { | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | struct gpio_bank { | 46 | struct gpio_bank { |
47 | struct list_head node; | ||
48 | void __iomem *base; | 47 | void __iomem *base; |
48 | const struct omap_gpio_reg_offs *regs; | ||
49 | |||
49 | int irq; | 50 | int irq; |
50 | u32 non_wakeup_gpios; | 51 | u32 non_wakeup_gpios; |
51 | u32 enabled_non_wakeup_gpios; | 52 | u32 enabled_non_wakeup_gpios; |
@@ -72,11 +73,7 @@ struct gpio_bank { | |||
72 | int context_loss_count; | 73 | int context_loss_count; |
73 | 74 | ||
74 | void (*set_dataout)(struct gpio_bank *bank, unsigned gpio, int enable); | 75 | void (*set_dataout)(struct gpio_bank *bank, unsigned gpio, int enable); |
75 | void (*set_dataout_multiple)(struct gpio_bank *bank, | ||
76 | unsigned long *mask, unsigned long *bits); | ||
77 | int (*get_context_loss_count)(struct device *dev); | 76 | int (*get_context_loss_count)(struct device *dev); |
78 | |||
79 | struct omap_gpio_reg_offs *regs; | ||
80 | }; | 77 | }; |
81 | 78 | ||
82 | #define GPIO_MOD_CTRL_BIT BIT(0) | 79 | #define GPIO_MOD_CTRL_BIT BIT(0) |
@@ -92,20 +89,25 @@ static inline struct gpio_bank *omap_irq_data_get_bank(struct irq_data *d) | |||
92 | return gpiochip_get_data(chip); | 89 | return gpiochip_get_data(chip); |
93 | } | 90 | } |
94 | 91 | ||
95 | static void omap_set_gpio_direction(struct gpio_bank *bank, int gpio, | 92 | static inline u32 omap_gpio_rmw(void __iomem *reg, u32 mask, bool set) |
96 | int is_input) | ||
97 | { | 93 | { |
98 | void __iomem *reg = bank->base; | 94 | u32 val = readl_relaxed(reg); |
99 | u32 l; | ||
100 | 95 | ||
101 | reg += bank->regs->direction; | 96 | if (set) |
102 | l = readl_relaxed(reg); | 97 | val |= mask; |
103 | if (is_input) | ||
104 | l |= BIT(gpio); | ||
105 | else | 98 | else |
106 | l &= ~(BIT(gpio)); | 99 | val &= ~mask; |
107 | writel_relaxed(l, reg); | 100 | |
108 | bank->context.oe = l; | 101 | writel_relaxed(val, reg); |
102 | |||
103 | return val; | ||
104 | } | ||
105 | |||
106 | static void omap_set_gpio_direction(struct gpio_bank *bank, int gpio, | ||
107 | int is_input) | ||
108 | { | ||
109 | bank->context.oe = omap_gpio_rmw(bank->base + bank->regs->direction, | ||
110 | BIT(gpio), is_input); | ||
109 | } | 111 | } |
110 | 112 | ||
111 | 113 | ||
@@ -131,88 +133,8 @@ static void omap_set_gpio_dataout_reg(struct gpio_bank *bank, unsigned offset, | |||
131 | static void omap_set_gpio_dataout_mask(struct gpio_bank *bank, unsigned offset, | 133 | static void omap_set_gpio_dataout_mask(struct gpio_bank *bank, unsigned offset, |
132 | int enable) | 134 | int enable) |
133 | { | 135 | { |
134 | void __iomem *reg = bank->base + bank->regs->dataout; | 136 | bank->context.dataout = omap_gpio_rmw(bank->base + bank->regs->dataout, |
135 | u32 gpio_bit = BIT(offset); | 137 | BIT(offset), enable); |
136 | u32 l; | ||
137 | |||
138 | l = readl_relaxed(reg); | ||
139 | if (enable) | ||
140 | l |= gpio_bit; | ||
141 | else | ||
142 | l &= ~gpio_bit; | ||
143 | writel_relaxed(l, reg); | ||
144 | bank->context.dataout = l; | ||
145 | } | ||
146 | |||
147 | static int omap_get_gpio_datain(struct gpio_bank *bank, int offset) | ||
148 | { | ||
149 | void __iomem *reg = bank->base + bank->regs->datain; | ||
150 | |||
151 | return (readl_relaxed(reg) & (BIT(offset))) != 0; | ||
152 | } | ||
153 | |||
154 | static int omap_get_gpio_dataout(struct gpio_bank *bank, int offset) | ||
155 | { | ||
156 | void __iomem *reg = bank->base + bank->regs->dataout; | ||
157 | |||
158 | return (readl_relaxed(reg) & (BIT(offset))) != 0; | ||
159 | } | ||
160 | |||
161 | /* set multiple data out values using dedicate set/clear register */ | ||
162 | static void omap_set_gpio_dataout_reg_multiple(struct gpio_bank *bank, | ||
163 | unsigned long *mask, | ||
164 | unsigned long *bits) | ||
165 | { | ||
166 | void __iomem *reg = bank->base; | ||
167 | u32 l; | ||
168 | |||
169 | l = *bits & *mask; | ||
170 | writel_relaxed(l, reg + bank->regs->set_dataout); | ||
171 | bank->context.dataout |= l; | ||
172 | |||
173 | l = ~*bits & *mask; | ||
174 | writel_relaxed(l, reg + bank->regs->clr_dataout); | ||
175 | bank->context.dataout &= ~l; | ||
176 | } | ||
177 | |||
178 | /* set multiple data out values using mask register */ | ||
179 | static void omap_set_gpio_dataout_mask_multiple(struct gpio_bank *bank, | ||
180 | unsigned long *mask, | ||
181 | unsigned long *bits) | ||
182 | { | ||
183 | void __iomem *reg = bank->base + bank->regs->dataout; | ||
184 | u32 l = (readl_relaxed(reg) & ~*mask) | (*bits & *mask); | ||
185 | |||
186 | writel_relaxed(l, reg); | ||
187 | bank->context.dataout = l; | ||
188 | } | ||
189 | |||
190 | static unsigned long omap_get_gpio_datain_multiple(struct gpio_bank *bank, | ||
191 | unsigned long *mask) | ||
192 | { | ||
193 | void __iomem *reg = bank->base + bank->regs->datain; | ||
194 | |||
195 | return readl_relaxed(reg) & *mask; | ||
196 | } | ||
197 | |||
198 | static unsigned long omap_get_gpio_dataout_multiple(struct gpio_bank *bank, | ||
199 | unsigned long *mask) | ||
200 | { | ||
201 | void __iomem *reg = bank->base + bank->regs->dataout; | ||
202 | |||
203 | return readl_relaxed(reg) & *mask; | ||
204 | } | ||
205 | |||
206 | static inline void omap_gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set) | ||
207 | { | ||
208 | int l = readl_relaxed(base + reg); | ||
209 | |||
210 | if (set) | ||
211 | l |= mask; | ||
212 | else | ||
213 | l &= ~mask; | ||
214 | |||
215 | writel_relaxed(l, base + reg); | ||
216 | } | 138 | } |
217 | 139 | ||
218 | static inline void omap_gpio_dbck_enable(struct gpio_bank *bank) | 140 | static inline void omap_gpio_dbck_enable(struct gpio_bank *bank) |
@@ -256,7 +178,6 @@ static inline void omap_gpio_dbck_disable(struct gpio_bank *bank) | |||
256 | static int omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset, | 178 | static int omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset, |
257 | unsigned debounce) | 179 | unsigned debounce) |
258 | { | 180 | { |
259 | void __iomem *reg; | ||
260 | u32 val; | 181 | u32 val; |
261 | u32 l; | 182 | u32 l; |
262 | bool enable = !!debounce; | 183 | bool enable = !!debounce; |
@@ -273,19 +194,11 @@ static int omap2_set_gpio_debounce(struct gpio_bank *bank, unsigned offset, | |||
273 | l = BIT(offset); | 194 | l = BIT(offset); |
274 | 195 | ||
275 | clk_enable(bank->dbck); | 196 | clk_enable(bank->dbck); |
276 | reg = bank->base + bank->regs->debounce; | 197 | writel_relaxed(debounce, bank->base + bank->regs->debounce); |
277 | writel_relaxed(debounce, reg); | ||
278 | 198 | ||
279 | reg = bank->base + bank->regs->debounce_en; | 199 | val = omap_gpio_rmw(bank->base + bank->regs->debounce_en, l, enable); |
280 | val = readl_relaxed(reg); | ||
281 | |||
282 | if (enable) | ||
283 | val |= l; | ||
284 | else | ||
285 | val &= ~l; | ||
286 | bank->dbck_enable_mask = val; | 200 | bank->dbck_enable_mask = val; |
287 | 201 | ||
288 | writel_relaxed(val, reg); | ||
289 | clk_disable(bank->dbck); | 202 | clk_disable(bank->dbck); |
290 | /* | 203 | /* |
291 | * Enable debounce clock per module. | 204 | * Enable debounce clock per module. |
@@ -360,9 +273,9 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, | |||
360 | void __iomem *base = bank->base; | 273 | void __iomem *base = bank->base; |
361 | u32 gpio_bit = BIT(gpio); | 274 | u32 gpio_bit = BIT(gpio); |
362 | 275 | ||
363 | omap_gpio_rmw(base, bank->regs->leveldetect0, gpio_bit, | 276 | omap_gpio_rmw(base + bank->regs->leveldetect0, gpio_bit, |
364 | trigger & IRQ_TYPE_LEVEL_LOW); | 277 | trigger & IRQ_TYPE_LEVEL_LOW); |
365 | omap_gpio_rmw(base, bank->regs->leveldetect1, gpio_bit, | 278 | omap_gpio_rmw(base + bank->regs->leveldetect1, gpio_bit, |
366 | trigger & IRQ_TYPE_LEVEL_HIGH); | 279 | trigger & IRQ_TYPE_LEVEL_HIGH); |
367 | 280 | ||
368 | /* | 281 | /* |
@@ -370,9 +283,9 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, | |||
370 | * to be woken from idle state. Set the appropriate edge detection | 283 | * to be woken from idle state. Set the appropriate edge detection |
371 | * in addition to the level detection. | 284 | * in addition to the level detection. |
372 | */ | 285 | */ |
373 | omap_gpio_rmw(base, bank->regs->risingdetect, gpio_bit, | 286 | omap_gpio_rmw(base + bank->regs->risingdetect, gpio_bit, |
374 | trigger & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)); | 287 | trigger & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)); |
375 | omap_gpio_rmw(base, bank->regs->fallingdetect, gpio_bit, | 288 | omap_gpio_rmw(base + bank->regs->fallingdetect, gpio_bit, |
376 | trigger & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW)); | 289 | trigger & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW)); |
377 | 290 | ||
378 | bank->context.leveldetect0 = | 291 | bank->context.leveldetect0 = |
@@ -384,11 +297,8 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, | |||
384 | bank->context.fallingdetect = | 297 | bank->context.fallingdetect = |
385 | readl_relaxed(bank->base + bank->regs->fallingdetect); | 298 | readl_relaxed(bank->base + bank->regs->fallingdetect); |
386 | 299 | ||
387 | if (likely(!(bank->non_wakeup_gpios & gpio_bit))) { | 300 | bank->level_mask = bank->context.leveldetect0 | |
388 | omap_gpio_rmw(base, bank->regs->wkup_en, gpio_bit, trigger != 0); | 301 | bank->context.leveldetect1; |
389 | bank->context.wake_en = | ||
390 | readl_relaxed(bank->base + bank->regs->wkup_en); | ||
391 | } | ||
392 | 302 | ||
393 | /* This part needs to be executed always for OMAP{34xx, 44xx} */ | 303 | /* This part needs to be executed always for OMAP{34xx, 44xx} */ |
394 | if (!bank->regs->irqctrl && !omap_gpio_is_off_wakeup_capable(bank, gpio)) { | 304 | if (!bank->regs->irqctrl && !omap_gpio_is_off_wakeup_capable(bank, gpio)) { |
@@ -403,44 +313,25 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, | |||
403 | else | 313 | else |
404 | bank->enabled_non_wakeup_gpios &= ~gpio_bit; | 314 | bank->enabled_non_wakeup_gpios &= ~gpio_bit; |
405 | } | 315 | } |
406 | |||
407 | bank->level_mask = | ||
408 | readl_relaxed(bank->base + bank->regs->leveldetect0) | | ||
409 | readl_relaxed(bank->base + bank->regs->leveldetect1); | ||
410 | } | 316 | } |
411 | 317 | ||
412 | #ifdef CONFIG_ARCH_OMAP1 | ||
413 | /* | 318 | /* |
414 | * This only applies to chips that can't do both rising and falling edge | 319 | * This only applies to chips that can't do both rising and falling edge |
415 | * detection at once. For all other chips, this function is a noop. | 320 | * detection at once. For all other chips, this function is a noop. |
416 | */ | 321 | */ |
417 | static void omap_toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) | 322 | static void omap_toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) |
418 | { | 323 | { |
419 | void __iomem *reg = bank->base; | 324 | if (IS_ENABLED(CONFIG_ARCH_OMAP1) && bank->regs->irqctrl) { |
420 | u32 l = 0; | 325 | void __iomem *reg = bank->base + bank->regs->irqctrl; |
421 | |||
422 | if (!bank->regs->irqctrl) | ||
423 | return; | ||
424 | 326 | ||
425 | reg += bank->regs->irqctrl; | 327 | writel_relaxed(readl_relaxed(reg) ^ BIT(gpio), reg); |
426 | 328 | } | |
427 | l = readl_relaxed(reg); | ||
428 | if ((l >> gpio) & 1) | ||
429 | l &= ~(BIT(gpio)); | ||
430 | else | ||
431 | l |= BIT(gpio); | ||
432 | |||
433 | writel_relaxed(l, reg); | ||
434 | } | 329 | } |
435 | #else | ||
436 | static void omap_toggle_gpio_edge_triggering(struct gpio_bank *bank, int gpio) {} | ||
437 | #endif | ||
438 | 330 | ||
439 | static int omap_set_gpio_triggering(struct gpio_bank *bank, int gpio, | 331 | static int omap_set_gpio_triggering(struct gpio_bank *bank, int gpio, |
440 | unsigned trigger) | 332 | unsigned trigger) |
441 | { | 333 | { |
442 | void __iomem *reg = bank->base; | 334 | void __iomem *reg = bank->base; |
443 | void __iomem *base = bank->base; | ||
444 | u32 l = 0; | 335 | u32 l = 0; |
445 | 336 | ||
446 | if (bank->regs->leveldetect0 && bank->regs->wkup_en) { | 337 | if (bank->regs->leveldetect0 && bank->regs->wkup_en) { |
@@ -472,11 +363,6 @@ static int omap_set_gpio_triggering(struct gpio_bank *bank, int gpio, | |||
472 | l |= 2 << (gpio << 1); | 363 | l |= 2 << (gpio << 1); |
473 | if (trigger & IRQ_TYPE_EDGE_FALLING) | 364 | if (trigger & IRQ_TYPE_EDGE_FALLING) |
474 | l |= BIT(gpio << 1); | 365 | l |= BIT(gpio << 1); |
475 | |||
476 | /* Enable wake-up during idle for dynamic tick */ | ||
477 | omap_gpio_rmw(base, bank->regs->wkup_en, BIT(gpio), trigger); | ||
478 | bank->context.wake_en = | ||
479 | readl_relaxed(bank->base + bank->regs->wkup_en); | ||
480 | writel_relaxed(l, reg); | 366 | writel_relaxed(l, reg); |
481 | } | 367 | } |
482 | return 0; | 368 | return 0; |
@@ -505,17 +391,6 @@ static void omap_enable_gpio_module(struct gpio_bank *bank, unsigned offset) | |||
505 | 391 | ||
506 | static void omap_disable_gpio_module(struct gpio_bank *bank, unsigned offset) | 392 | static void omap_disable_gpio_module(struct gpio_bank *bank, unsigned offset) |
507 | { | 393 | { |
508 | void __iomem *base = bank->base; | ||
509 | |||
510 | if (bank->regs->wkup_en && | ||
511 | !LINE_USED(bank->mod_usage, offset) && | ||
512 | !LINE_USED(bank->irq_usage, offset)) { | ||
513 | /* Disable wake-up during idle for dynamic tick */ | ||
514 | omap_gpio_rmw(base, bank->regs->wkup_en, BIT(offset), 0); | ||
515 | bank->context.wake_en = | ||
516 | readl_relaxed(bank->base + bank->regs->wkup_en); | ||
517 | } | ||
518 | |||
519 | if (bank->regs->ctrl && !BANK_USED(bank)) { | 394 | if (bank->regs->ctrl && !BANK_USED(bank)) { |
520 | void __iomem *reg = bank->base + bank->regs->ctrl; | 395 | void __iomem *reg = bank->base + bank->regs->ctrl; |
521 | u32 ctrl; | 396 | u32 ctrl; |
@@ -626,57 +501,39 @@ static u32 omap_get_gpio_irqbank_mask(struct gpio_bank *bank) | |||
626 | return l; | 501 | return l; |
627 | } | 502 | } |
628 | 503 | ||
629 | static void omap_enable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask) | 504 | static inline void omap_set_gpio_irqenable(struct gpio_bank *bank, |
505 | unsigned offset, int enable) | ||
630 | { | 506 | { |
631 | void __iomem *reg = bank->base; | 507 | void __iomem *reg = bank->base; |
632 | u32 l; | 508 | u32 gpio_mask = BIT(offset); |
633 | 509 | ||
634 | if (bank->regs->set_irqenable) { | 510 | if (bank->regs->set_irqenable && bank->regs->clr_irqenable) { |
635 | reg += bank->regs->set_irqenable; | 511 | if (enable) { |
636 | l = gpio_mask; | 512 | reg += bank->regs->set_irqenable; |
637 | bank->context.irqenable1 |= gpio_mask; | 513 | bank->context.irqenable1 |= gpio_mask; |
514 | } else { | ||
515 | reg += bank->regs->clr_irqenable; | ||
516 | bank->context.irqenable1 &= ~gpio_mask; | ||
517 | } | ||
518 | writel_relaxed(gpio_mask, reg); | ||
638 | } else { | 519 | } else { |
639 | reg += bank->regs->irqenable; | 520 | bank->context.irqenable1 = |
640 | l = readl_relaxed(reg); | 521 | omap_gpio_rmw(reg + bank->regs->irqenable, gpio_mask, |
641 | if (bank->regs->irqenable_inv) | 522 | enable ^ bank->regs->irqenable_inv); |
642 | l &= ~gpio_mask; | ||
643 | else | ||
644 | l |= gpio_mask; | ||
645 | bank->context.irqenable1 = l; | ||
646 | } | 523 | } |
647 | 524 | ||
648 | writel_relaxed(l, reg); | 525 | /* |
649 | } | 526 | * Program GPIO wakeup along with IRQ enable to satisfy OMAP4430 TRM |
650 | 527 | * note requiring correlation between the IRQ enable registers and | |
651 | static void omap_disable_gpio_irqbank(struct gpio_bank *bank, int gpio_mask) | 528 | * the wakeup registers. In any case, we want wakeup from idle |
652 | { | 529 | * enabled for the GPIOs which support this feature. |
653 | void __iomem *reg = bank->base; | 530 | */ |
654 | u32 l; | 531 | if (bank->regs->wkup_en && |
655 | 532 | (bank->regs->edgectrl1 || !(bank->non_wakeup_gpios & gpio_mask))) { | |
656 | if (bank->regs->clr_irqenable) { | 533 | bank->context.wake_en = |
657 | reg += bank->regs->clr_irqenable; | 534 | omap_gpio_rmw(bank->base + bank->regs->wkup_en, |
658 | l = gpio_mask; | 535 | gpio_mask, enable); |
659 | bank->context.irqenable1 &= ~gpio_mask; | ||
660 | } else { | ||
661 | reg += bank->regs->irqenable; | ||
662 | l = readl_relaxed(reg); | ||
663 | if (bank->regs->irqenable_inv) | ||
664 | l |= gpio_mask; | ||
665 | else | ||
666 | l &= ~gpio_mask; | ||
667 | bank->context.irqenable1 = l; | ||
668 | } | 536 | } |
669 | |||
670 | writel_relaxed(l, reg); | ||
671 | } | ||
672 | |||
673 | static inline void omap_set_gpio_irqenable(struct gpio_bank *bank, | ||
674 | unsigned offset, int enable) | ||
675 | { | ||
676 | if (enable) | ||
677 | omap_enable_gpio_irqbank(bank, BIT(offset)); | ||
678 | else | ||
679 | omap_disable_gpio_irqbank(bank, BIT(offset)); | ||
680 | } | 537 | } |
681 | 538 | ||
682 | /* Use disable_irq_wake() and enable_irq_wake() functions from drivers */ | 539 | /* Use disable_irq_wake() and enable_irq_wake() functions from drivers */ |
@@ -687,38 +544,6 @@ static int omap_gpio_wake_enable(struct irq_data *d, unsigned int enable) | |||
687 | return irq_set_irq_wake(bank->irq, enable); | 544 | return irq_set_irq_wake(bank->irq, enable); |
688 | } | 545 | } |
689 | 546 | ||
690 | static int omap_gpio_request(struct gpio_chip *chip, unsigned offset) | ||
691 | { | ||
692 | struct gpio_bank *bank = gpiochip_get_data(chip); | ||
693 | unsigned long flags; | ||
694 | |||
695 | pm_runtime_get_sync(chip->parent); | ||
696 | |||
697 | raw_spin_lock_irqsave(&bank->lock, flags); | ||
698 | omap_enable_gpio_module(bank, offset); | ||
699 | bank->mod_usage |= BIT(offset); | ||
700 | raw_spin_unlock_irqrestore(&bank->lock, flags); | ||
701 | |||
702 | return 0; | ||
703 | } | ||
704 | |||
705 | static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
706 | { | ||
707 | struct gpio_bank *bank = gpiochip_get_data(chip); | ||
708 | unsigned long flags; | ||
709 | |||
710 | raw_spin_lock_irqsave(&bank->lock, flags); | ||
711 | bank->mod_usage &= ~(BIT(offset)); | ||
712 | if (!LINE_USED(bank->irq_usage, offset)) { | ||
713 | omap_set_gpio_direction(bank, offset, 1); | ||
714 | omap_clear_gpio_debounce(bank, offset); | ||
715 | } | ||
716 | omap_disable_gpio_module(bank, offset); | ||
717 | raw_spin_unlock_irqrestore(&bank->lock, flags); | ||
718 | |||
719 | pm_runtime_put(chip->parent); | ||
720 | } | ||
721 | |||
722 | /* | 547 | /* |
723 | * We need to unmask the GPIO bank interrupt as soon as possible to | 548 | * We need to unmask the GPIO bank interrupt as soon as possible to |
724 | * avoid missing GPIO interrupts for other lines in the bank. | 549 | * avoid missing GPIO interrupts for other lines in the bank. |
@@ -731,7 +556,7 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) | |||
731 | static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank) | 556 | static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank) |
732 | { | 557 | { |
733 | void __iomem *isr_reg = NULL; | 558 | void __iomem *isr_reg = NULL; |
734 | u32 enabled, isr, level_mask; | 559 | u32 enabled, isr, edge; |
735 | unsigned int bit; | 560 | unsigned int bit; |
736 | struct gpio_bank *bank = gpiobank; | 561 | struct gpio_bank *bank = gpiobank; |
737 | unsigned long wa_lock_flags; | 562 | unsigned long wa_lock_flags; |
@@ -751,16 +576,14 @@ static irqreturn_t omap_gpio_irq_handler(int irq, void *gpiobank) | |||
751 | enabled = omap_get_gpio_irqbank_mask(bank); | 576 | enabled = omap_get_gpio_irqbank_mask(bank); |
752 | isr = readl_relaxed(isr_reg) & enabled; | 577 | isr = readl_relaxed(isr_reg) & enabled; |
753 | 578 | ||
754 | if (bank->level_mask) | 579 | /* |
755 | level_mask = bank->level_mask & enabled; | 580 | * Clear edge sensitive interrupts before calling handler(s) |
756 | else | 581 | * so subsequent edge transitions are not missed while the |
757 | level_mask = 0; | 582 | * handlers are running. |
758 | 583 | */ | |
759 | /* clear edge sensitive interrupts before handler(s) are | 584 | edge = isr & ~bank->level_mask; |
760 | called so that we don't miss any interrupt occurred while | 585 | if (edge) |
761 | executing them */ | 586 | omap_clear_gpio_irqbank(bank, edge); |
762 | if (isr & ~level_mask) | ||
763 | omap_clear_gpio_irqbank(bank, isr & ~level_mask); | ||
764 | 587 | ||
765 | raw_spin_unlock_irqrestore(&bank->lock, lock_flags); | 588 | raw_spin_unlock_irqrestore(&bank->lock, lock_flags); |
766 | 589 | ||
@@ -807,8 +630,6 @@ static unsigned int omap_gpio_irq_startup(struct irq_data *d) | |||
807 | 630 | ||
808 | if (!LINE_USED(bank->mod_usage, offset)) | 631 | if (!LINE_USED(bank->mod_usage, offset)) |
809 | omap_set_gpio_direction(bank, offset, 1); | 632 | omap_set_gpio_direction(bank, offset, 1); |
810 | else if (!omap_gpio_is_input(bank, offset)) | ||
811 | goto err; | ||
812 | omap_enable_gpio_module(bank, offset); | 633 | omap_enable_gpio_module(bank, offset); |
813 | bank->irq_usage |= BIT(offset); | 634 | bank->irq_usage |= BIT(offset); |
814 | 635 | ||
@@ -816,9 +637,6 @@ static unsigned int omap_gpio_irq_startup(struct irq_data *d) | |||
816 | omap_gpio_unmask_irq(d); | 637 | omap_gpio_unmask_irq(d); |
817 | 638 | ||
818 | return 0; | 639 | return 0; |
819 | err: | ||
820 | raw_spin_unlock_irqrestore(&bank->lock, flags); | ||
821 | return -EINVAL; | ||
822 | } | 640 | } |
823 | 641 | ||
824 | static void omap_gpio_irq_shutdown(struct irq_data *d) | 642 | static void omap_gpio_irq_shutdown(struct irq_data *d) |
@@ -829,9 +647,9 @@ static void omap_gpio_irq_shutdown(struct irq_data *d) | |||
829 | 647 | ||
830 | raw_spin_lock_irqsave(&bank->lock, flags); | 648 | raw_spin_lock_irqsave(&bank->lock, flags); |
831 | bank->irq_usage &= ~(BIT(offset)); | 649 | bank->irq_usage &= ~(BIT(offset)); |
832 | omap_set_gpio_irqenable(bank, offset, 0); | ||
833 | omap_clear_gpio_irqstatus(bank, offset); | ||
834 | omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); | 650 | omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); |
651 | omap_clear_gpio_irqstatus(bank, offset); | ||
652 | omap_set_gpio_irqenable(bank, offset, 0); | ||
835 | if (!LINE_USED(bank->mod_usage, offset)) | 653 | if (!LINE_USED(bank->mod_usage, offset)) |
836 | omap_clear_gpio_debounce(bank, offset); | 654 | omap_clear_gpio_debounce(bank, offset); |
837 | omap_disable_gpio_module(bank, offset); | 655 | omap_disable_gpio_module(bank, offset); |
@@ -852,14 +670,6 @@ static void gpio_irq_bus_sync_unlock(struct irq_data *data) | |||
852 | pm_runtime_put(bank->chip.parent); | 670 | pm_runtime_put(bank->chip.parent); |
853 | } | 671 | } |
854 | 672 | ||
855 | static void omap_gpio_ack_irq(struct irq_data *d) | ||
856 | { | ||
857 | struct gpio_bank *bank = omap_irq_data_get_bank(d); | ||
858 | unsigned offset = d->hwirq; | ||
859 | |||
860 | omap_clear_gpio_irqstatus(bank, offset); | ||
861 | } | ||
862 | |||
863 | static void omap_gpio_mask_irq(struct irq_data *d) | 673 | static void omap_gpio_mask_irq(struct irq_data *d) |
864 | { | 674 | { |
865 | struct gpio_bank *bank = omap_irq_data_get_bank(d); | 675 | struct gpio_bank *bank = omap_irq_data_get_bank(d); |
@@ -867,8 +677,8 @@ static void omap_gpio_mask_irq(struct irq_data *d) | |||
867 | unsigned long flags; | 677 | unsigned long flags; |
868 | 678 | ||
869 | raw_spin_lock_irqsave(&bank->lock, flags); | 679 | raw_spin_lock_irqsave(&bank->lock, flags); |
870 | omap_set_gpio_irqenable(bank, offset, 0); | ||
871 | omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); | 680 | omap_set_gpio_triggering(bank, offset, IRQ_TYPE_NONE); |
681 | omap_set_gpio_irqenable(bank, offset, 0); | ||
872 | raw_spin_unlock_irqrestore(&bank->lock, flags); | 682 | raw_spin_unlock_irqrestore(&bank->lock, flags); |
873 | } | 683 | } |
874 | 684 | ||
@@ -880,9 +690,6 @@ static void omap_gpio_unmask_irq(struct irq_data *d) | |||
880 | unsigned long flags; | 690 | unsigned long flags; |
881 | 691 | ||
882 | raw_spin_lock_irqsave(&bank->lock, flags); | 692 | raw_spin_lock_irqsave(&bank->lock, flags); |
883 | if (trigger) | ||
884 | omap_set_gpio_triggering(bank, offset, trigger); | ||
885 | |||
886 | omap_set_gpio_irqenable(bank, offset, 1); | 693 | omap_set_gpio_irqenable(bank, offset, 1); |
887 | 694 | ||
888 | /* | 695 | /* |
@@ -890,9 +697,13 @@ static void omap_gpio_unmask_irq(struct irq_data *d) | |||
890 | * is cleared, thus after the handler has run. OMAP4 needs this done | 697 | * is cleared, thus after the handler has run. OMAP4 needs this done |
891 | * after enabing the interrupt to clear the wakeup status. | 698 | * after enabing the interrupt to clear the wakeup status. |
892 | */ | 699 | */ |
893 | if (bank->level_mask & BIT(offset)) | 700 | if (bank->regs->leveldetect0 && bank->regs->wkup_en && |
701 | trigger & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) | ||
894 | omap_clear_gpio_irqstatus(bank, offset); | 702 | omap_clear_gpio_irqstatus(bank, offset); |
895 | 703 | ||
704 | if (trigger) | ||
705 | omap_set_gpio_triggering(bank, offset, trigger); | ||
706 | |||
896 | raw_spin_unlock_irqrestore(&bank->lock, flags); | 707 | raw_spin_unlock_irqrestore(&bank->lock, flags); |
897 | } | 708 | } |
898 | 709 | ||
@@ -958,19 +769,44 @@ static inline void omap_mpuio_init(struct gpio_bank *bank) | |||
958 | 769 | ||
959 | /*---------------------------------------------------------------------*/ | 770 | /*---------------------------------------------------------------------*/ |
960 | 771 | ||
961 | static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | 772 | static int omap_gpio_request(struct gpio_chip *chip, unsigned offset) |
962 | { | 773 | { |
963 | struct gpio_bank *bank; | 774 | struct gpio_bank *bank = gpiochip_get_data(chip); |
775 | unsigned long flags; | ||
776 | |||
777 | pm_runtime_get_sync(chip->parent); | ||
778 | |||
779 | raw_spin_lock_irqsave(&bank->lock, flags); | ||
780 | omap_enable_gpio_module(bank, offset); | ||
781 | bank->mod_usage |= BIT(offset); | ||
782 | raw_spin_unlock_irqrestore(&bank->lock, flags); | ||
783 | |||
784 | return 0; | ||
785 | } | ||
786 | |||
787 | static void omap_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
788 | { | ||
789 | struct gpio_bank *bank = gpiochip_get_data(chip); | ||
964 | unsigned long flags; | 790 | unsigned long flags; |
965 | void __iomem *reg; | ||
966 | int dir; | ||
967 | 791 | ||
968 | bank = gpiochip_get_data(chip); | ||
969 | reg = bank->base + bank->regs->direction; | ||
970 | raw_spin_lock_irqsave(&bank->lock, flags); | 792 | raw_spin_lock_irqsave(&bank->lock, flags); |
971 | dir = !!(readl_relaxed(reg) & BIT(offset)); | 793 | bank->mod_usage &= ~(BIT(offset)); |
794 | if (!LINE_USED(bank->irq_usage, offset)) { | ||
795 | omap_set_gpio_direction(bank, offset, 1); | ||
796 | omap_clear_gpio_debounce(bank, offset); | ||
797 | } | ||
798 | omap_disable_gpio_module(bank, offset); | ||
972 | raw_spin_unlock_irqrestore(&bank->lock, flags); | 799 | raw_spin_unlock_irqrestore(&bank->lock, flags); |
973 | return dir; | 800 | |
801 | pm_runtime_put(chip->parent); | ||
802 | } | ||
803 | |||
804 | static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset) | ||
805 | { | ||
806 | struct gpio_bank *bank = gpiochip_get_data(chip); | ||
807 | |||
808 | return !!(readl_relaxed(bank->base + bank->regs->direction) & | ||
809 | BIT(offset)); | ||
974 | } | 810 | } |
975 | 811 | ||
976 | static int omap_gpio_input(struct gpio_chip *chip, unsigned offset) | 812 | static int omap_gpio_input(struct gpio_chip *chip, unsigned offset) |
@@ -987,14 +823,15 @@ static int omap_gpio_input(struct gpio_chip *chip, unsigned offset) | |||
987 | 823 | ||
988 | static int omap_gpio_get(struct gpio_chip *chip, unsigned offset) | 824 | static int omap_gpio_get(struct gpio_chip *chip, unsigned offset) |
989 | { | 825 | { |
990 | struct gpio_bank *bank; | 826 | struct gpio_bank *bank = gpiochip_get_data(chip); |
991 | 827 | void __iomem *reg; | |
992 | bank = gpiochip_get_data(chip); | ||
993 | 828 | ||
994 | if (omap_gpio_is_input(bank, offset)) | 829 | if (omap_gpio_is_input(bank, offset)) |
995 | return omap_get_gpio_datain(bank, offset); | 830 | reg = bank->base + bank->regs->datain; |
996 | else | 831 | else |
997 | return omap_get_gpio_dataout(bank, offset); | 832 | reg = bank->base + bank->regs->dataout; |
833 | |||
834 | return (readl_relaxed(reg) & BIT(offset)) != 0; | ||
998 | } | 835 | } |
999 | 836 | ||
1000 | static int omap_gpio_output(struct gpio_chip *chip, unsigned offset, int value) | 837 | static int omap_gpio_output(struct gpio_chip *chip, unsigned offset, int value) |
@@ -1014,18 +851,20 @@ static int omap_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, | |||
1014 | unsigned long *bits) | 851 | unsigned long *bits) |
1015 | { | 852 | { |
1016 | struct gpio_bank *bank = gpiochip_get_data(chip); | 853 | struct gpio_bank *bank = gpiochip_get_data(chip); |
1017 | void __iomem *reg = bank->base + bank->regs->direction; | 854 | void __iomem *base = bank->base; |
1018 | unsigned long in = readl_relaxed(reg), l; | 855 | u32 direction, m, val = 0; |
1019 | 856 | ||
1020 | *bits = 0; | 857 | direction = readl_relaxed(base + bank->regs->direction); |
1021 | 858 | ||
1022 | l = in & *mask; | 859 | m = direction & *mask; |
1023 | if (l) | 860 | if (m) |
1024 | *bits |= omap_get_gpio_datain_multiple(bank, &l); | 861 | val |= readl_relaxed(base + bank->regs->datain) & m; |
1025 | 862 | ||
1026 | l = ~in & *mask; | 863 | m = ~direction & *mask; |
1027 | if (l) | 864 | if (m) |
1028 | *bits |= omap_get_gpio_dataout_multiple(bank, &l); | 865 | val |= readl_relaxed(base + bank->regs->dataout) & m; |
866 | |||
867 | *bits = val; | ||
1029 | 868 | ||
1030 | return 0; | 869 | return 0; |
1031 | } | 870 | } |
@@ -1078,10 +917,14 @@ static void omap_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask, | |||
1078 | unsigned long *bits) | 917 | unsigned long *bits) |
1079 | { | 918 | { |
1080 | struct gpio_bank *bank = gpiochip_get_data(chip); | 919 | struct gpio_bank *bank = gpiochip_get_data(chip); |
920 | void __iomem *reg = bank->base + bank->regs->dataout; | ||
1081 | unsigned long flags; | 921 | unsigned long flags; |
922 | u32 l; | ||
1082 | 923 | ||
1083 | raw_spin_lock_irqsave(&bank->lock, flags); | 924 | raw_spin_lock_irqsave(&bank->lock, flags); |
1084 | bank->set_dataout_multiple(bank, mask, bits); | 925 | l = (readl_relaxed(reg) & ~*mask) | (*bits & *mask); |
926 | writel_relaxed(l, reg); | ||
927 | bank->context.dataout = l; | ||
1085 | raw_spin_unlock_irqrestore(&bank->lock, flags); | 928 | raw_spin_unlock_irqrestore(&bank->lock, flags); |
1086 | } | 929 | } |
1087 | 930 | ||
@@ -1115,9 +958,9 @@ static void omap_gpio_mod_init(struct gpio_bank *bank) | |||
1115 | return; | 958 | return; |
1116 | } | 959 | } |
1117 | 960 | ||
1118 | omap_gpio_rmw(base, bank->regs->irqenable, l, | 961 | omap_gpio_rmw(base + bank->regs->irqenable, l, |
1119 | bank->regs->irqenable_inv); | 962 | bank->regs->irqenable_inv); |
1120 | omap_gpio_rmw(base, bank->regs->irqstatus, l, | 963 | omap_gpio_rmw(base + bank->regs->irqstatus, l, |
1121 | !bank->regs->irqenable_inv); | 964 | !bank->regs->irqenable_inv); |
1122 | if (bank->regs->debounce_en) | 965 | if (bank->regs->debounce_en) |
1123 | writel_relaxed(0, base + bank->regs->debounce_en); | 966 | writel_relaxed(0, base + bank->regs->debounce_en); |
@@ -1180,11 +1023,8 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1180 | #endif | 1023 | #endif |
1181 | 1024 | ||
1182 | /* MPUIO is a bit different, reading IRQ status clears it */ | 1025 | /* MPUIO is a bit different, reading IRQ status clears it */ |
1183 | if (bank->is_mpuio) { | 1026 | if (bank->is_mpuio && !bank->regs->wkup_en) |
1184 | irqc->irq_ack = dummy_irq_chip.irq_ack; | 1027 | irqc->irq_set_wake = NULL; |
1185 | if (!bank->regs->wkup_en) | ||
1186 | irqc->irq_set_wake = NULL; | ||
1187 | } | ||
1188 | 1028 | ||
1189 | irq = &bank->chip.irq; | 1029 | irq = &bank->chip.irq; |
1190 | irq->chip = irqc; | 1030 | irq->chip = irqc; |
@@ -1215,7 +1055,7 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1215 | 1055 | ||
1216 | static void omap_gpio_init_context(struct gpio_bank *p) | 1056 | static void omap_gpio_init_context(struct gpio_bank *p) |
1217 | { | 1057 | { |
1218 | struct omap_gpio_reg_offs *regs = p->regs; | 1058 | const struct omap_gpio_reg_offs *regs = p->regs; |
1219 | void __iomem *base = p->base; | 1059 | void __iomem *base = p->base; |
1220 | 1060 | ||
1221 | p->context.ctrl = readl_relaxed(base + regs->ctrl); | 1061 | p->context.ctrl = readl_relaxed(base + regs->ctrl); |
@@ -1227,60 +1067,56 @@ static void omap_gpio_init_context(struct gpio_bank *p) | |||
1227 | p->context.fallingdetect = readl_relaxed(base + regs->fallingdetect); | 1067 | p->context.fallingdetect = readl_relaxed(base + regs->fallingdetect); |
1228 | p->context.irqenable1 = readl_relaxed(base + regs->irqenable); | 1068 | p->context.irqenable1 = readl_relaxed(base + regs->irqenable); |
1229 | p->context.irqenable2 = readl_relaxed(base + regs->irqenable2); | 1069 | p->context.irqenable2 = readl_relaxed(base + regs->irqenable2); |
1230 | 1070 | p->context.dataout = readl_relaxed(base + regs->dataout); | |
1231 | if (regs->set_dataout && p->regs->clr_dataout) | ||
1232 | p->context.dataout = readl_relaxed(base + regs->set_dataout); | ||
1233 | else | ||
1234 | p->context.dataout = readl_relaxed(base + regs->dataout); | ||
1235 | 1071 | ||
1236 | p->context_valid = true; | 1072 | p->context_valid = true; |
1237 | } | 1073 | } |
1238 | 1074 | ||
1239 | static void omap_gpio_restore_context(struct gpio_bank *bank) | 1075 | static void omap_gpio_restore_context(struct gpio_bank *bank) |
1240 | { | 1076 | { |
1241 | writel_relaxed(bank->context.wake_en, | 1077 | const struct omap_gpio_reg_offs *regs = bank->regs; |
1242 | bank->base + bank->regs->wkup_en); | 1078 | void __iomem *base = bank->base; |
1243 | writel_relaxed(bank->context.ctrl, bank->base + bank->regs->ctrl); | 1079 | |
1244 | writel_relaxed(bank->context.leveldetect0, | 1080 | writel_relaxed(bank->context.wake_en, base + regs->wkup_en); |
1245 | bank->base + bank->regs->leveldetect0); | 1081 | writel_relaxed(bank->context.ctrl, base + regs->ctrl); |
1246 | writel_relaxed(bank->context.leveldetect1, | 1082 | writel_relaxed(bank->context.leveldetect0, base + regs->leveldetect0); |
1247 | bank->base + bank->regs->leveldetect1); | 1083 | writel_relaxed(bank->context.leveldetect1, base + regs->leveldetect1); |
1248 | writel_relaxed(bank->context.risingdetect, | 1084 | writel_relaxed(bank->context.risingdetect, base + regs->risingdetect); |
1249 | bank->base + bank->regs->risingdetect); | 1085 | writel_relaxed(bank->context.fallingdetect, base + regs->fallingdetect); |
1250 | writel_relaxed(bank->context.fallingdetect, | 1086 | writel_relaxed(bank->context.dataout, base + regs->dataout); |
1251 | bank->base + bank->regs->fallingdetect); | 1087 | writel_relaxed(bank->context.oe, base + regs->direction); |
1252 | if (bank->regs->set_dataout && bank->regs->clr_dataout) | ||
1253 | writel_relaxed(bank->context.dataout, | ||
1254 | bank->base + bank->regs->set_dataout); | ||
1255 | else | ||
1256 | writel_relaxed(bank->context.dataout, | ||
1257 | bank->base + bank->regs->dataout); | ||
1258 | writel_relaxed(bank->context.oe, bank->base + bank->regs->direction); | ||
1259 | 1088 | ||
1260 | if (bank->dbck_enable_mask) { | 1089 | if (bank->dbck_enable_mask) { |
1261 | writel_relaxed(bank->context.debounce, bank->base + | 1090 | writel_relaxed(bank->context.debounce, base + regs->debounce); |
1262 | bank->regs->debounce); | ||
1263 | writel_relaxed(bank->context.debounce_en, | 1091 | writel_relaxed(bank->context.debounce_en, |
1264 | bank->base + bank->regs->debounce_en); | 1092 | base + regs->debounce_en); |
1265 | } | 1093 | } |
1266 | 1094 | ||
1267 | writel_relaxed(bank->context.irqenable1, | 1095 | writel_relaxed(bank->context.irqenable1, base + regs->irqenable); |
1268 | bank->base + bank->regs->irqenable); | 1096 | writel_relaxed(bank->context.irqenable2, base + regs->irqenable2); |
1269 | writel_relaxed(bank->context.irqenable2, | ||
1270 | bank->base + bank->regs->irqenable2); | ||
1271 | } | 1097 | } |
1272 | 1098 | ||
1273 | static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) | 1099 | static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) |
1274 | { | 1100 | { |
1275 | struct device *dev = bank->chip.parent; | 1101 | struct device *dev = bank->chip.parent; |
1276 | void __iomem *base = bank->base; | 1102 | void __iomem *base = bank->base; |
1277 | u32 nowake; | 1103 | u32 mask, nowake; |
1278 | 1104 | ||
1279 | bank->saved_datain = readl_relaxed(base + bank->regs->datain); | 1105 | bank->saved_datain = readl_relaxed(base + bank->regs->datain); |
1280 | 1106 | ||
1281 | if (!bank->enabled_non_wakeup_gpios) | 1107 | if (!bank->enabled_non_wakeup_gpios) |
1282 | goto update_gpio_context_count; | 1108 | goto update_gpio_context_count; |
1283 | 1109 | ||
1110 | /* Check for pending EDGE_FALLING, ignore EDGE_BOTH */ | ||
1111 | mask = bank->enabled_non_wakeup_gpios & bank->context.fallingdetect; | ||
1112 | mask &= ~bank->context.risingdetect; | ||
1113 | bank->saved_datain |= mask; | ||
1114 | |||
1115 | /* Check for pending EDGE_RISING, ignore EDGE_BOTH */ | ||
1116 | mask = bank->enabled_non_wakeup_gpios & bank->context.risingdetect; | ||
1117 | mask &= ~bank->context.fallingdetect; | ||
1118 | bank->saved_datain &= ~mask; | ||
1119 | |||
1284 | if (!may_lose_context) | 1120 | if (!may_lose_context) |
1285 | goto update_gpio_context_count; | 1121 | goto update_gpio_context_count; |
1286 | 1122 | ||
@@ -1291,8 +1127,8 @@ static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) | |||
1291 | */ | 1127 | */ |
1292 | if (!bank->loses_context && bank->enabled_non_wakeup_gpios) { | 1128 | if (!bank->loses_context && bank->enabled_non_wakeup_gpios) { |
1293 | nowake = bank->enabled_non_wakeup_gpios; | 1129 | nowake = bank->enabled_non_wakeup_gpios; |
1294 | omap_gpio_rmw(base, bank->regs->fallingdetect, nowake, ~nowake); | 1130 | omap_gpio_rmw(base + bank->regs->fallingdetect, nowake, ~nowake); |
1295 | omap_gpio_rmw(base, bank->regs->risingdetect, nowake, ~nowake); | 1131 | omap_gpio_rmw(base + bank->regs->risingdetect, nowake, ~nowake); |
1296 | } | 1132 | } |
1297 | 1133 | ||
1298 | update_gpio_context_count: | 1134 | update_gpio_context_count: |
@@ -1421,7 +1257,7 @@ static int gpio_omap_cpu_notifier(struct notifier_block *nb, | |||
1421 | return NOTIFY_OK; | 1257 | return NOTIFY_OK; |
1422 | } | 1258 | } |
1423 | 1259 | ||
1424 | static struct omap_gpio_reg_offs omap2_gpio_regs = { | 1260 | static const struct omap_gpio_reg_offs omap2_gpio_regs = { |
1425 | .revision = OMAP24XX_GPIO_REVISION, | 1261 | .revision = OMAP24XX_GPIO_REVISION, |
1426 | .direction = OMAP24XX_GPIO_OE, | 1262 | .direction = OMAP24XX_GPIO_OE, |
1427 | .datain = OMAP24XX_GPIO_DATAIN, | 1263 | .datain = OMAP24XX_GPIO_DATAIN, |
@@ -1444,7 +1280,7 @@ static struct omap_gpio_reg_offs omap2_gpio_regs = { | |||
1444 | .fallingdetect = OMAP24XX_GPIO_FALLINGDETECT, | 1280 | .fallingdetect = OMAP24XX_GPIO_FALLINGDETECT, |
1445 | }; | 1281 | }; |
1446 | 1282 | ||
1447 | static struct omap_gpio_reg_offs omap4_gpio_regs = { | 1283 | static const struct omap_gpio_reg_offs omap4_gpio_regs = { |
1448 | .revision = OMAP4_GPIO_REVISION, | 1284 | .revision = OMAP4_GPIO_REVISION, |
1449 | .direction = OMAP4_GPIO_OE, | 1285 | .direction = OMAP4_GPIO_OE, |
1450 | .datain = OMAP4_GPIO_DATAIN, | 1286 | .datain = OMAP4_GPIO_DATAIN, |
@@ -1453,6 +1289,8 @@ static struct omap_gpio_reg_offs omap4_gpio_regs = { | |||
1453 | .clr_dataout = OMAP4_GPIO_CLEARDATAOUT, | 1289 | .clr_dataout = OMAP4_GPIO_CLEARDATAOUT, |
1454 | .irqstatus = OMAP4_GPIO_IRQSTATUS0, | 1290 | .irqstatus = OMAP4_GPIO_IRQSTATUS0, |
1455 | .irqstatus2 = OMAP4_GPIO_IRQSTATUS1, | 1291 | .irqstatus2 = OMAP4_GPIO_IRQSTATUS1, |
1292 | .irqstatus_raw0 = OMAP4_GPIO_IRQSTATUSRAW0, | ||
1293 | .irqstatus_raw1 = OMAP4_GPIO_IRQSTATUSRAW1, | ||
1456 | .irqenable = OMAP4_GPIO_IRQSTATUSSET0, | 1294 | .irqenable = OMAP4_GPIO_IRQSTATUSSET0, |
1457 | .irqenable2 = OMAP4_GPIO_IRQSTATUSSET1, | 1295 | .irqenable2 = OMAP4_GPIO_IRQSTATUSSET1, |
1458 | .set_irqenable = OMAP4_GPIO_IRQSTATUSSET0, | 1296 | .set_irqenable = OMAP4_GPIO_IRQSTATUSSET0, |
@@ -1528,7 +1366,7 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1528 | 1366 | ||
1529 | irqc->irq_startup = omap_gpio_irq_startup, | 1367 | irqc->irq_startup = omap_gpio_irq_startup, |
1530 | irqc->irq_shutdown = omap_gpio_irq_shutdown, | 1368 | irqc->irq_shutdown = omap_gpio_irq_shutdown, |
1531 | irqc->irq_ack = omap_gpio_ack_irq, | 1369 | irqc->irq_ack = dummy_irq_chip.irq_ack, |
1532 | irqc->irq_mask = omap_gpio_mask_irq, | 1370 | irqc->irq_mask = omap_gpio_mask_irq, |
1533 | irqc->irq_unmask = omap_gpio_unmask_irq, | 1371 | irqc->irq_unmask = omap_gpio_unmask_irq, |
1534 | irqc->irq_set_type = omap_gpio_irq_type, | 1372 | irqc->irq_set_type = omap_gpio_irq_type, |
@@ -1572,14 +1410,10 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1572 | pdata->get_context_loss_count; | 1410 | pdata->get_context_loss_count; |
1573 | } | 1411 | } |
1574 | 1412 | ||
1575 | if (bank->regs->set_dataout && bank->regs->clr_dataout) { | 1413 | if (bank->regs->set_dataout && bank->regs->clr_dataout) |
1576 | bank->set_dataout = omap_set_gpio_dataout_reg; | 1414 | bank->set_dataout = omap_set_gpio_dataout_reg; |
1577 | bank->set_dataout_multiple = omap_set_gpio_dataout_reg_multiple; | 1415 | else |
1578 | } else { | ||
1579 | bank->set_dataout = omap_set_gpio_dataout_mask; | 1416 | bank->set_dataout = omap_set_gpio_dataout_mask; |
1580 | bank->set_dataout_multiple = | ||
1581 | omap_set_gpio_dataout_mask_multiple; | ||
1582 | } | ||
1583 | 1417 | ||
1584 | raw_spin_lock_init(&bank->lock); | 1418 | raw_spin_lock_init(&bank->lock); |
1585 | raw_spin_lock_init(&bank->wa_lock); | 1419 | raw_spin_lock_init(&bank->wa_lock); |
@@ -1635,7 +1469,6 @@ static int omap_gpio_remove(struct platform_device *pdev) | |||
1635 | struct gpio_bank *bank = platform_get_drvdata(pdev); | 1469 | struct gpio_bank *bank = platform_get_drvdata(pdev); |
1636 | 1470 | ||
1637 | cpu_pm_unregister_notifier(&bank->nb); | 1471 | cpu_pm_unregister_notifier(&bank->nb); |
1638 | list_del(&bank->node); | ||
1639 | gpiochip_remove(&bank->chip); | 1472 | gpiochip_remove(&bank->chip); |
1640 | pm_runtime_disable(&pdev->dev); | 1473 | pm_runtime_disable(&pdev->dev); |
1641 | if (bank->dbck_flag) | 1474 | if (bank->dbck_flag) |
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index cfe827cefad8..378b206d2dc9 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c | |||
@@ -1178,6 +1178,7 @@ static const struct of_device_id pca953x_dt_ids[] = { | |||
1178 | { .compatible = "ti,tca6408", .data = OF_953X( 8, PCA_INT), }, | 1178 | { .compatible = "ti,tca6408", .data = OF_953X( 8, PCA_INT), }, |
1179 | { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), }, | 1179 | { .compatible = "ti,tca6416", .data = OF_953X(16, PCA_INT), }, |
1180 | { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), }, | 1180 | { .compatible = "ti,tca6424", .data = OF_953X(24, PCA_INT), }, |
1181 | { .compatible = "ti,tca9539", .data = OF_953X(16, PCA_INT), }, | ||
1181 | 1182 | ||
1182 | { .compatible = "onnn,cat9554", .data = OF_953X( 8, PCA_INT), }, | 1183 | { .compatible = "onnn,cat9554", .data = OF_953X( 8, PCA_INT), }, |
1183 | { .compatible = "onnn,pca9654", .data = OF_953X( 8, PCA_INT), }, | 1184 | { .compatible = "onnn,pca9654", .data = OF_953X( 8, PCA_INT), }, |
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 9aad32206e84..722ce5cf861e 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -283,6 +283,7 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
283 | { | 283 | { |
284 | struct device *dev = &adev->dev; | 284 | struct device *dev = &adev->dev; |
285 | struct pl061 *pl061; | 285 | struct pl061 *pl061; |
286 | struct gpio_irq_chip *girq; | ||
286 | int ret, irq; | 287 | int ret, irq; |
287 | 288 | ||
288 | pl061 = devm_kzalloc(dev, sizeof(*pl061), GFP_KERNEL); | 289 | pl061 = devm_kzalloc(dev, sizeof(*pl061), GFP_KERNEL); |
@@ -310,10 +311,6 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
310 | pl061->gc.parent = dev; | 311 | pl061->gc.parent = dev; |
311 | pl061->gc.owner = THIS_MODULE; | 312 | pl061->gc.owner = THIS_MODULE; |
312 | 313 | ||
313 | ret = gpiochip_add_data(&pl061->gc, pl061); | ||
314 | if (ret) | ||
315 | return ret; | ||
316 | |||
317 | /* | 314 | /* |
318 | * irq_chip support | 315 | * irq_chip support |
319 | */ | 316 | */ |
@@ -332,19 +329,24 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
332 | } | 329 | } |
333 | pl061->parent_irq = irq; | 330 | pl061->parent_irq = irq; |
334 | 331 | ||
335 | ret = gpiochip_irqchip_add(&pl061->gc, &pl061->irq_chip, | 332 | girq = &pl061->gc.irq; |
336 | 0, handle_bad_irq, | 333 | girq->chip = &pl061->irq_chip; |
337 | IRQ_TYPE_NONE); | 334 | girq->parent_handler = pl061_irq_handler; |
338 | if (ret) { | 335 | girq->num_parents = 1; |
339 | dev_info(&adev->dev, "could not add irqchip\n"); | 336 | girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), |
337 | GFP_KERNEL); | ||
338 | if (!girq->parents) | ||
339 | return -ENOMEM; | ||
340 | girq->parents[0] = irq; | ||
341 | girq->default_type = IRQ_TYPE_NONE; | ||
342 | girq->handler = handle_bad_irq; | ||
343 | |||
344 | ret = devm_gpiochip_add_data(dev, &pl061->gc, pl061); | ||
345 | if (ret) | ||
340 | return ret; | 346 | return ret; |
341 | } | ||
342 | gpiochip_set_chained_irqchip(&pl061->gc, &pl061->irq_chip, | ||
343 | irq, pl061_irq_handler); | ||
344 | 347 | ||
345 | amba_set_drvdata(adev, pl061); | 348 | amba_set_drvdata(adev, pl061); |
346 | dev_info(&adev->dev, "PL061 GPIO chip @%pa registered\n", | 349 | dev_info(dev, "PL061 GPIO chip registered\n"); |
347 | &adev->res.start); | ||
348 | 350 | ||
349 | return 0; | 351 | return 0; |
350 | } | 352 | } |
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 70e95fc4779f..187984d26f47 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
@@ -489,7 +489,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) | |||
489 | irq_chip->irq_unmask = gpio_rcar_irq_enable; | 489 | irq_chip->irq_unmask = gpio_rcar_irq_enable; |
490 | irq_chip->irq_set_type = gpio_rcar_irq_set_type; | 490 | irq_chip->irq_set_type = gpio_rcar_irq_set_type; |
491 | irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; | 491 | irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; |
492 | irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; | 492 | irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; |
493 | 493 | ||
494 | ret = gpiochip_add_data(gpio_chip, p); | 494 | ret = gpiochip_add_data(gpio_chip, p); |
495 | if (ret) { | 495 | if (ret) { |
diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c index 571b2a81c6de..006a7e6a75f2 100644 --- a/drivers/gpio/gpio-siox.c +++ b/drivers/gpio/gpio-siox.c | |||
@@ -211,20 +211,22 @@ static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset) | |||
211 | static int gpio_siox_probe(struct siox_device *sdevice) | 211 | static int gpio_siox_probe(struct siox_device *sdevice) |
212 | { | 212 | { |
213 | struct gpio_siox_ddata *ddata; | 213 | struct gpio_siox_ddata *ddata; |
214 | struct gpio_irq_chip *girq; | ||
215 | struct device *dev = &sdevice->dev; | ||
214 | int ret; | 216 | int ret; |
215 | 217 | ||
216 | ddata = devm_kzalloc(&sdevice->dev, sizeof(*ddata), GFP_KERNEL); | 218 | ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); |
217 | if (!ddata) | 219 | if (!ddata) |
218 | return -ENOMEM; | 220 | return -ENOMEM; |
219 | 221 | ||
220 | dev_set_drvdata(&sdevice->dev, ddata); | 222 | dev_set_drvdata(dev, ddata); |
221 | 223 | ||
222 | mutex_init(&ddata->lock); | 224 | mutex_init(&ddata->lock); |
223 | spin_lock_init(&ddata->irqlock); | 225 | spin_lock_init(&ddata->irqlock); |
224 | 226 | ||
225 | ddata->gchip.base = -1; | 227 | ddata->gchip.base = -1; |
226 | ddata->gchip.can_sleep = 1; | 228 | ddata->gchip.can_sleep = 1; |
227 | ddata->gchip.parent = &sdevice->dev; | 229 | ddata->gchip.parent = dev; |
228 | ddata->gchip.owner = THIS_MODULE; | 230 | ddata->gchip.owner = THIS_MODULE; |
229 | ddata->gchip.get = gpio_siox_get; | 231 | ddata->gchip.get = gpio_siox_get; |
230 | ddata->gchip.set = gpio_siox_set; | 232 | ddata->gchip.set = gpio_siox_set; |
@@ -239,54 +241,27 @@ static int gpio_siox_probe(struct siox_device *sdevice) | |||
239 | ddata->ichip.irq_unmask = gpio_siox_irq_unmask; | 241 | ddata->ichip.irq_unmask = gpio_siox_irq_unmask; |
240 | ddata->ichip.irq_set_type = gpio_siox_irq_set_type; | 242 | ddata->ichip.irq_set_type = gpio_siox_irq_set_type; |
241 | 243 | ||
242 | ret = gpiochip_add(&ddata->gchip); | 244 | girq = &ddata->gchip.irq; |
243 | if (ret) { | 245 | girq->chip = &ddata->ichip; |
244 | dev_err(&sdevice->dev, | 246 | girq->default_type = IRQ_TYPE_NONE; |
245 | "Failed to register gpio chip (%d)\n", ret); | 247 | girq->handler = handle_level_irq; |
246 | goto err_gpiochip; | ||
247 | } | ||
248 | 248 | ||
249 | ret = gpiochip_irqchip_add(&ddata->gchip, &ddata->ichip, | 249 | ret = devm_gpiochip_add_data(dev, &ddata->gchip, NULL); |
250 | 0, handle_level_irq, IRQ_TYPE_EDGE_RISING); | 250 | if (ret) |
251 | if (ret) { | 251 | dev_err(dev, "Failed to register gpio chip (%d)\n", ret); |
252 | dev_err(&sdevice->dev, | ||
253 | "Failed to register irq chip (%d)\n", ret); | ||
254 | err_gpiochip: | ||
255 | gpiochip_remove(&ddata->gchip); | ||
256 | } | ||
257 | 252 | ||
258 | return ret; | 253 | return ret; |
259 | } | 254 | } |
260 | 255 | ||
261 | static int gpio_siox_remove(struct siox_device *sdevice) | ||
262 | { | ||
263 | struct gpio_siox_ddata *ddata = dev_get_drvdata(&sdevice->dev); | ||
264 | |||
265 | gpiochip_remove(&ddata->gchip); | ||
266 | return 0; | ||
267 | } | ||
268 | |||
269 | static struct siox_driver gpio_siox_driver = { | 256 | static struct siox_driver gpio_siox_driver = { |
270 | .probe = gpio_siox_probe, | 257 | .probe = gpio_siox_probe, |
271 | .remove = gpio_siox_remove, | ||
272 | .set_data = gpio_siox_set_data, | 258 | .set_data = gpio_siox_set_data, |
273 | .get_data = gpio_siox_get_data, | 259 | .get_data = gpio_siox_get_data, |
274 | .driver = { | 260 | .driver = { |
275 | .name = "gpio-siox", | 261 | .name = "gpio-siox", |
276 | }, | 262 | }, |
277 | }; | 263 | }; |
278 | 264 | module_siox_driver(gpio_siox_driver); | |
279 | static int __init gpio_siox_init(void) | ||
280 | { | ||
281 | return siox_driver_register(&gpio_siox_driver); | ||
282 | } | ||
283 | module_init(gpio_siox_init); | ||
284 | |||
285 | static void __exit gpio_siox_exit(void) | ||
286 | { | ||
287 | siox_driver_unregister(&gpio_siox_driver); | ||
288 | } | ||
289 | module_exit(gpio_siox_exit); | ||
290 | 265 | ||
291 | MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>"); | 266 | MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>"); |
292 | MODULE_DESCRIPTION("SIOX gpio driver"); | 267 | MODULE_DESCRIPTION("SIOX gpio driver"); |
diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c index 24c478392394..9e23a5ae8108 100644 --- a/drivers/gpio/gpio-stp-xway.c +++ b/drivers/gpio/gpio-stp-xway.c | |||
@@ -15,8 +15,6 @@ | |||
15 | #include <linux/clk.h> | 15 | #include <linux/clk.h> |
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | 17 | ||
18 | #include <lantiq_soc.h> | ||
19 | |||
20 | /* | 18 | /* |
21 | * The Serial To Parallel (STP) is found on MIPS based Lantiq socs. It is a | 19 | * The Serial To Parallel (STP) is found on MIPS based Lantiq socs. It is a |
22 | * peripheral controller used to drive external shift register cascades. At most | 20 | * peripheral controller used to drive external shift register cascades. At most |
@@ -71,8 +69,7 @@ | |||
71 | #define xway_stp_r32(m, reg) __raw_readl(m + reg) | 69 | #define xway_stp_r32(m, reg) __raw_readl(m + reg) |
72 | #define xway_stp_w32(m, val, reg) __raw_writel(val, m + reg) | 70 | #define xway_stp_w32(m, val, reg) __raw_writel(val, m + reg) |
73 | #define xway_stp_w32_mask(m, clear, set, reg) \ | 71 | #define xway_stp_w32_mask(m, clear, set, reg) \ |
74 | ltq_w32((ltq_r32(m + reg) & ~(clear)) | (set), \ | 72 | xway_stp_w32(m, (xway_stp_r32(m, reg) & ~(clear)) | (set), reg) |
75 | m + reg) | ||
76 | 73 | ||
77 | struct xway_stp { | 74 | struct xway_stp { |
78 | struct gpio_chip gc; | 75 | struct gpio_chip gc; |
@@ -156,9 +153,9 @@ static int xway_stp_request(struct gpio_chip *gc, unsigned gpio) | |||
156 | 153 | ||
157 | /** | 154 | /** |
158 | * xway_stp_hw_init() - Configure the STP unit and enable the clock gate | 155 | * xway_stp_hw_init() - Configure the STP unit and enable the clock gate |
159 | * @virt: pointer to the remapped register range | 156 | * @chip: Pointer to the xway_stp chip structure |
160 | */ | 157 | */ |
161 | static int xway_stp_hw_init(struct xway_stp *chip) | 158 | static void xway_stp_hw_init(struct xway_stp *chip) |
162 | { | 159 | { |
163 | /* sane defaults */ | 160 | /* sane defaults */ |
164 | xway_stp_w32(chip->virt, 0, XWAY_STP_AR); | 161 | xway_stp_w32(chip->virt, 0, XWAY_STP_AR); |
@@ -201,8 +198,6 @@ static int xway_stp_hw_init(struct xway_stp *chip) | |||
201 | if (chip->reserved) | 198 | if (chip->reserved) |
202 | xway_stp_w32_mask(chip->virt, XWAY_STP_UPD_MASK, | 199 | xway_stp_w32_mask(chip->virt, XWAY_STP_UPD_MASK, |
203 | XWAY_STP_UPD_FPI, XWAY_STP_CON1); | 200 | XWAY_STP_UPD_FPI, XWAY_STP_CON1); |
204 | |||
205 | return 0; | ||
206 | } | 201 | } |
207 | 202 | ||
208 | static int xway_stp_probe(struct platform_device *pdev) | 203 | static int xway_stp_probe(struct platform_device *pdev) |
@@ -258,21 +253,27 @@ static int xway_stp_probe(struct platform_device *pdev) | |||
258 | if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL)) | 253 | if (!of_find_property(pdev->dev.of_node, "lantiq,rising", NULL)) |
259 | chip->edge = XWAY_STP_FALLING; | 254 | chip->edge = XWAY_STP_FALLING; |
260 | 255 | ||
261 | clk = clk_get(&pdev->dev, NULL); | 256 | clk = devm_clk_get(&pdev->dev, NULL); |
262 | if (IS_ERR(clk)) { | 257 | if (IS_ERR(clk)) { |
263 | dev_err(&pdev->dev, "Failed to get clock\n"); | 258 | dev_err(&pdev->dev, "Failed to get clock\n"); |
264 | return PTR_ERR(clk); | 259 | return PTR_ERR(clk); |
265 | } | 260 | } |
266 | clk_enable(clk); | ||
267 | 261 | ||
268 | ret = xway_stp_hw_init(chip); | 262 | ret = clk_prepare_enable(clk); |
269 | if (!ret) | 263 | if (ret) |
270 | ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip); | 264 | return ret; |
271 | 265 | ||
272 | if (!ret) | 266 | xway_stp_hw_init(chip); |
273 | dev_info(&pdev->dev, "Init done\n"); | ||
274 | 267 | ||
275 | return ret; | 268 | ret = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip); |
269 | if (ret) { | ||
270 | clk_disable_unprepare(clk); | ||
271 | return ret; | ||
272 | } | ||
273 | |||
274 | dev_info(&pdev->dev, "Init done\n"); | ||
275 | |||
276 | return 0; | ||
276 | } | 277 | } |
277 | 278 | ||
278 | static const struct of_device_id xway_stp_match[] = { | 279 | static const struct of_device_id xway_stp_match[] = { |
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index f57bfc07ae22..0f59161a4701 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c | |||
@@ -541,8 +541,8 @@ DEFINE_SHOW_ATTRIBUTE(tegra_dbg_gpio); | |||
541 | 541 | ||
542 | static void tegra_gpio_debuginit(struct tegra_gpio_info *tgi) | 542 | static void tegra_gpio_debuginit(struct tegra_gpio_info *tgi) |
543 | { | 543 | { |
544 | (void) debugfs_create_file("tegra_gpio", 0444, | 544 | debugfs_create_file("tegra_gpio", 0444, NULL, tgi, |
545 | NULL, tgi, &tegra_dbg_gpio_fops); | 545 | &tegra_dbg_gpio_fops); |
546 | } | 546 | } |
547 | 547 | ||
548 | #else | 548 | #else |
diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index 30aef41e3b7e..7ba668db171b 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c | |||
@@ -265,7 +265,8 @@ static int vf610_gpio_probe(struct platform_device *pdev) | |||
265 | return port->irq; | 265 | return port->irq; |
266 | 266 | ||
267 | port->clk_port = devm_clk_get(dev, "port"); | 267 | port->clk_port = devm_clk_get(dev, "port"); |
268 | if (!IS_ERR(port->clk_port)) { | 268 | ret = PTR_ERR_OR_ZERO(port->clk_port); |
269 | if (!ret) { | ||
269 | ret = clk_prepare_enable(port->clk_port); | 270 | ret = clk_prepare_enable(port->clk_port); |
270 | if (ret) | 271 | if (ret) |
271 | return ret; | 272 | return ret; |
@@ -273,16 +274,17 @@ static int vf610_gpio_probe(struct platform_device *pdev) | |||
273 | port->clk_port); | 274 | port->clk_port); |
274 | if (ret) | 275 | if (ret) |
275 | return ret; | 276 | return ret; |
276 | } else if (port->clk_port == ERR_PTR(-EPROBE_DEFER)) { | 277 | } else if (ret == -EPROBE_DEFER) { |
277 | /* | 278 | /* |
278 | * Percolate deferrals, for anything else, | 279 | * Percolate deferrals, for anything else, |
279 | * just live without the clocking. | 280 | * just live without the clocking. |
280 | */ | 281 | */ |
281 | return PTR_ERR(port->clk_port); | 282 | return ret; |
282 | } | 283 | } |
283 | 284 | ||
284 | port->clk_gpio = devm_clk_get(dev, "gpio"); | 285 | port->clk_gpio = devm_clk_get(dev, "gpio"); |
285 | if (!IS_ERR(port->clk_gpio)) { | 286 | ret = PTR_ERR_OR_ZERO(port->clk_gpio); |
287 | if (!ret) { | ||
286 | ret = clk_prepare_enable(port->clk_gpio); | 288 | ret = clk_prepare_enable(port->clk_gpio); |
287 | if (ret) | 289 | if (ret) |
288 | return ret; | 290 | return ret; |
@@ -290,8 +292,8 @@ static int vf610_gpio_probe(struct platform_device *pdev) | |||
290 | port->clk_gpio); | 292 | port->clk_gpio); |
291 | if (ret) | 293 | if (ret) |
292 | return ret; | 294 | return ret; |
293 | } else if (port->clk_gpio == ERR_PTR(-EPROBE_DEFER)) { | 295 | } else if (ret == -EPROBE_DEFER) { |
294 | return PTR_ERR(port->clk_gpio); | 296 | return ret; |
295 | } | 297 | } |
296 | 298 | ||
297 | gc = &port->gc; | 299 | gc = &port->gc; |
diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c index b13a49c89cc1..98cd715ccc33 100644 --- a/drivers/gpio/gpio-vr41xx.c +++ b/drivers/gpio/gpio-vr41xx.c | |||
@@ -467,10 +467,9 @@ static struct gpio_chip vr41xx_gpio_chip = { | |||
467 | 467 | ||
468 | static int giu_probe(struct platform_device *pdev) | 468 | static int giu_probe(struct platform_device *pdev) |
469 | { | 469 | { |
470 | struct resource *res; | ||
471 | unsigned int trigger, i, pin; | 470 | unsigned int trigger, i, pin; |
472 | struct irq_chip *chip; | 471 | struct irq_chip *chip; |
473 | int irq, ret; | 472 | int irq; |
474 | 473 | ||
475 | switch (pdev->id) { | 474 | switch (pdev->id) { |
476 | case GPIO_50PINS_PULLUPDOWN: | 475 | case GPIO_50PINS_PULLUPDOWN: |
@@ -489,21 +488,14 @@ static int giu_probe(struct platform_device *pdev) | |||
489 | return -ENODEV; | 488 | return -ENODEV; |
490 | } | 489 | } |
491 | 490 | ||
492 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 491 | giu_base = devm_platform_ioremap_resource(pdev, 0); |
493 | if (!res) | 492 | if (IS_ERR(giu_base)) |
494 | return -EBUSY; | 493 | return PTR_ERR(giu_base); |
495 | |||
496 | giu_base = ioremap(res->start, resource_size(res)); | ||
497 | if (!giu_base) | ||
498 | return -ENOMEM; | ||
499 | 494 | ||
500 | vr41xx_gpio_chip.parent = &pdev->dev; | 495 | vr41xx_gpio_chip.parent = &pdev->dev; |
501 | 496 | ||
502 | ret = gpiochip_add_data(&vr41xx_gpio_chip, NULL); | 497 | if (gpiochip_add_data(&vr41xx_gpio_chip, NULL)) |
503 | if (!ret) { | ||
504 | iounmap(giu_base); | ||
505 | return -ENODEV; | 498 | return -ENODEV; |
506 | } | ||
507 | 499 | ||
508 | giu_write(GIUINTENL, 0); | 500 | giu_write(GIUINTENL, 0); |
509 | giu_write(GIUINTENH, 0); | 501 | giu_write(GIUINTENH, 0); |
@@ -534,7 +526,6 @@ static int giu_probe(struct platform_device *pdev) | |||
534 | static int giu_remove(struct platform_device *pdev) | 526 | static int giu_remove(struct platform_device *pdev) |
535 | { | 527 | { |
536 | if (giu_base) { | 528 | if (giu_base) { |
537 | iounmap(giu_base); | ||
538 | giu_base = NULL; | 529 | giu_base = NULL; |
539 | } | 530 | } |
540 | 531 | ||
diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 32944eb886c1..a9748b5198e6 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/of_device.h> | 12 | #include <linux/of_device.h> |
13 | #include <linux/of_platform.h> | 13 | #include <linux/of_platform.h> |
14 | #include <linux/of_gpio.h> | ||
15 | #include <linux/io.h> | 14 | #include <linux/io.h> |
16 | #include <linux/gpio/driver.h> | 15 | #include <linux/gpio/driver.h> |
17 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
@@ -33,14 +32,16 @@ | |||
33 | 32 | ||
34 | /** | 33 | /** |
35 | * struct xgpio_instance - Stores information about GPIO device | 34 | * struct xgpio_instance - Stores information about GPIO device |
36 | * @mmchip: OF GPIO chip for memory mapped banks | 35 | * @gc: GPIO chip |
36 | * @regs: register block | ||
37 | * @gpio_width: GPIO width for every channel | 37 | * @gpio_width: GPIO width for every channel |
38 | * @gpio_state: GPIO state shadow register | 38 | * @gpio_state: GPIO state shadow register |
39 | * @gpio_dir: GPIO direction shadow register | 39 | * @gpio_dir: GPIO direction shadow register |
40 | * @gpio_lock: Lock used for synchronization | 40 | * @gpio_lock: Lock used for synchronization |
41 | */ | 41 | */ |
42 | struct xgpio_instance { | 42 | struct xgpio_instance { |
43 | struct of_mm_gpio_chip mmchip; | 43 | struct gpio_chip gc; |
44 | void __iomem *regs; | ||
44 | unsigned int gpio_width[2]; | 45 | unsigned int gpio_width[2]; |
45 | u32 gpio_state[2]; | 46 | u32 gpio_state[2]; |
46 | u32 gpio_dir[2]; | 47 | u32 gpio_dir[2]; |
@@ -84,11 +85,10 @@ static inline int xgpio_offset(struct xgpio_instance *chip, int gpio) | |||
84 | */ | 85 | */ |
85 | static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) | 86 | static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) |
86 | { | 87 | { |
87 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
88 | struct xgpio_instance *chip = gpiochip_get_data(gc); | 88 | struct xgpio_instance *chip = gpiochip_get_data(gc); |
89 | u32 val; | 89 | u32 val; |
90 | 90 | ||
91 | val = xgpio_readreg(mm_gc->regs + XGPIO_DATA_OFFSET + | 91 | val = xgpio_readreg(chip->regs + XGPIO_DATA_OFFSET + |
92 | xgpio_regoffset(chip, gpio)); | 92 | xgpio_regoffset(chip, gpio)); |
93 | 93 | ||
94 | return !!(val & BIT(xgpio_offset(chip, gpio))); | 94 | return !!(val & BIT(xgpio_offset(chip, gpio))); |
@@ -106,7 +106,6 @@ static int xgpio_get(struct gpio_chip *gc, unsigned int gpio) | |||
106 | static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | 106 | static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) |
107 | { | 107 | { |
108 | unsigned long flags; | 108 | unsigned long flags; |
109 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
110 | struct xgpio_instance *chip = gpiochip_get_data(gc); | 109 | struct xgpio_instance *chip = gpiochip_get_data(gc); |
111 | int index = xgpio_index(chip, gpio); | 110 | int index = xgpio_index(chip, gpio); |
112 | int offset = xgpio_offset(chip, gpio); | 111 | int offset = xgpio_offset(chip, gpio); |
@@ -119,7 +118,7 @@ static void xgpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | |||
119 | else | 118 | else |
120 | chip->gpio_state[index] &= ~BIT(offset); | 119 | chip->gpio_state[index] &= ~BIT(offset); |
121 | 120 | ||
122 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET + | 121 | xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + |
123 | xgpio_regoffset(chip, gpio), chip->gpio_state[index]); | 122 | xgpio_regoffset(chip, gpio), chip->gpio_state[index]); |
124 | 123 | ||
125 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); | 124 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); |
@@ -138,7 +137,6 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, | |||
138 | unsigned long *bits) | 137 | unsigned long *bits) |
139 | { | 138 | { |
140 | unsigned long flags; | 139 | unsigned long flags; |
141 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
142 | struct xgpio_instance *chip = gpiochip_get_data(gc); | 140 | struct xgpio_instance *chip = gpiochip_get_data(gc); |
143 | int index = xgpio_index(chip, 0); | 141 | int index = xgpio_index(chip, 0); |
144 | int offset, i; | 142 | int offset, i; |
@@ -150,7 +148,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, | |||
150 | if (*mask == 0) | 148 | if (*mask == 0) |
151 | break; | 149 | break; |
152 | if (index != xgpio_index(chip, i)) { | 150 | if (index != xgpio_index(chip, i)) { |
153 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET + | 151 | xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + |
154 | xgpio_regoffset(chip, i), | 152 | xgpio_regoffset(chip, i), |
155 | chip->gpio_state[index]); | 153 | chip->gpio_state[index]); |
156 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); | 154 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); |
@@ -166,7 +164,7 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, | |||
166 | } | 164 | } |
167 | } | 165 | } |
168 | 166 | ||
169 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET + | 167 | xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + |
170 | xgpio_regoffset(chip, i), chip->gpio_state[index]); | 168 | xgpio_regoffset(chip, i), chip->gpio_state[index]); |
171 | 169 | ||
172 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); | 170 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); |
@@ -184,7 +182,6 @@ static void xgpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, | |||
184 | static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) | 182 | static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) |
185 | { | 183 | { |
186 | unsigned long flags; | 184 | unsigned long flags; |
187 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
188 | struct xgpio_instance *chip = gpiochip_get_data(gc); | 185 | struct xgpio_instance *chip = gpiochip_get_data(gc); |
189 | int index = xgpio_index(chip, gpio); | 186 | int index = xgpio_index(chip, gpio); |
190 | int offset = xgpio_offset(chip, gpio); | 187 | int offset = xgpio_offset(chip, gpio); |
@@ -193,7 +190,7 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) | |||
193 | 190 | ||
194 | /* Set the GPIO bit in shadow register and set direction as input */ | 191 | /* Set the GPIO bit in shadow register and set direction as input */ |
195 | chip->gpio_dir[index] |= BIT(offset); | 192 | chip->gpio_dir[index] |= BIT(offset); |
196 | xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET + | 193 | xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + |
197 | xgpio_regoffset(chip, gpio), chip->gpio_dir[index]); | 194 | xgpio_regoffset(chip, gpio), chip->gpio_dir[index]); |
198 | 195 | ||
199 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); | 196 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); |
@@ -216,7 +213,6 @@ static int xgpio_dir_in(struct gpio_chip *gc, unsigned int gpio) | |||
216 | static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | 213 | static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) |
217 | { | 214 | { |
218 | unsigned long flags; | 215 | unsigned long flags; |
219 | struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); | ||
220 | struct xgpio_instance *chip = gpiochip_get_data(gc); | 216 | struct xgpio_instance *chip = gpiochip_get_data(gc); |
221 | int index = xgpio_index(chip, gpio); | 217 | int index = xgpio_index(chip, gpio); |
222 | int offset = xgpio_offset(chip, gpio); | 218 | int offset = xgpio_offset(chip, gpio); |
@@ -228,12 +224,12 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | |||
228 | chip->gpio_state[index] |= BIT(offset); | 224 | chip->gpio_state[index] |= BIT(offset); |
229 | else | 225 | else |
230 | chip->gpio_state[index] &= ~BIT(offset); | 226 | chip->gpio_state[index] &= ~BIT(offset); |
231 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET + | 227 | xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + |
232 | xgpio_regoffset(chip, gpio), chip->gpio_state[index]); | 228 | xgpio_regoffset(chip, gpio), chip->gpio_state[index]); |
233 | 229 | ||
234 | /* Clear the GPIO bit in shadow register and set direction as output */ | 230 | /* Clear the GPIO bit in shadow register and set direction as output */ |
235 | chip->gpio_dir[index] &= ~BIT(offset); | 231 | chip->gpio_dir[index] &= ~BIT(offset); |
236 | xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET + | 232 | xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + |
237 | xgpio_regoffset(chip, gpio), chip->gpio_dir[index]); | 233 | xgpio_regoffset(chip, gpio), chip->gpio_dir[index]); |
238 | 234 | ||
239 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); | 235 | spin_unlock_irqrestore(&chip->gpio_lock[index], flags); |
@@ -243,43 +239,23 @@ static int xgpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) | |||
243 | 239 | ||
244 | /** | 240 | /** |
245 | * xgpio_save_regs - Set initial values of GPIO pins | 241 | * xgpio_save_regs - Set initial values of GPIO pins |
246 | * @mm_gc: Pointer to memory mapped GPIO chip structure | 242 | * @chip: Pointer to GPIO instance |
247 | */ | 243 | */ |
248 | static void xgpio_save_regs(struct of_mm_gpio_chip *mm_gc) | 244 | static void xgpio_save_regs(struct xgpio_instance *chip) |
249 | { | 245 | { |
250 | struct xgpio_instance *chip = | 246 | xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]); |
251 | container_of(mm_gc, struct xgpio_instance, mmchip); | 247 | xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]); |
252 | |||
253 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET, chip->gpio_state[0]); | ||
254 | xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET, chip->gpio_dir[0]); | ||
255 | 248 | ||
256 | if (!chip->gpio_width[1]) | 249 | if (!chip->gpio_width[1]) |
257 | return; | 250 | return; |
258 | 251 | ||
259 | xgpio_writereg(mm_gc->regs + XGPIO_DATA_OFFSET + XGPIO_CHANNEL_OFFSET, | 252 | xgpio_writereg(chip->regs + XGPIO_DATA_OFFSET + XGPIO_CHANNEL_OFFSET, |
260 | chip->gpio_state[1]); | 253 | chip->gpio_state[1]); |
261 | xgpio_writereg(mm_gc->regs + XGPIO_TRI_OFFSET + XGPIO_CHANNEL_OFFSET, | 254 | xgpio_writereg(chip->regs + XGPIO_TRI_OFFSET + XGPIO_CHANNEL_OFFSET, |
262 | chip->gpio_dir[1]); | 255 | chip->gpio_dir[1]); |
263 | } | 256 | } |
264 | 257 | ||
265 | /** | 258 | /** |
266 | * xgpio_remove - Remove method for the GPIO device. | ||
267 | * @pdev: pointer to the platform device | ||
268 | * | ||
269 | * This function remove gpiochips and frees all the allocated resources. | ||
270 | * | ||
271 | * Return: 0 always | ||
272 | */ | ||
273 | static int xgpio_remove(struct platform_device *pdev) | ||
274 | { | ||
275 | struct xgpio_instance *chip = platform_get_drvdata(pdev); | ||
276 | |||
277 | of_mm_gpiochip_remove(&chip->mmchip); | ||
278 | |||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | /** | ||
283 | * xgpio_of_probe - Probe method for the GPIO device. | 259 | * xgpio_of_probe - Probe method for the GPIO device. |
284 | * @pdev: pointer to the platform device | 260 | * @pdev: pointer to the platform device |
285 | * | 261 | * |
@@ -340,21 +316,28 @@ static int xgpio_probe(struct platform_device *pdev) | |||
340 | spin_lock_init(&chip->gpio_lock[1]); | 316 | spin_lock_init(&chip->gpio_lock[1]); |
341 | } | 317 | } |
342 | 318 | ||
343 | chip->mmchip.gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; | 319 | chip->gc.base = -1; |
344 | chip->mmchip.gc.parent = &pdev->dev; | 320 | chip->gc.ngpio = chip->gpio_width[0] + chip->gpio_width[1]; |
345 | chip->mmchip.gc.direction_input = xgpio_dir_in; | 321 | chip->gc.parent = &pdev->dev; |
346 | chip->mmchip.gc.direction_output = xgpio_dir_out; | 322 | chip->gc.direction_input = xgpio_dir_in; |
347 | chip->mmchip.gc.get = xgpio_get; | 323 | chip->gc.direction_output = xgpio_dir_out; |
348 | chip->mmchip.gc.set = xgpio_set; | 324 | chip->gc.get = xgpio_get; |
349 | chip->mmchip.gc.set_multiple = xgpio_set_multiple; | 325 | chip->gc.set = xgpio_set; |
326 | chip->gc.set_multiple = xgpio_set_multiple; | ||
327 | |||
328 | chip->gc.label = dev_name(&pdev->dev); | ||
329 | |||
330 | chip->regs = devm_platform_ioremap_resource(pdev, 0); | ||
331 | if (IS_ERR(chip->regs)) { | ||
332 | dev_err(&pdev->dev, "failed to ioremap memory resource\n"); | ||
333 | return PTR_ERR(chip->regs); | ||
334 | } | ||
350 | 335 | ||
351 | chip->mmchip.save_regs = xgpio_save_regs; | 336 | xgpio_save_regs(chip); |
352 | 337 | ||
353 | /* Call the OF gpio helper to setup and register the GPIO device */ | 338 | status = devm_gpiochip_add_data(&pdev->dev, &chip->gc, chip); |
354 | status = of_mm_gpiochip_add_data(np, &chip->mmchip, chip); | ||
355 | if (status) { | 339 | if (status) { |
356 | pr_err("%pOF: error in probe function with status %d\n", | 340 | dev_err(&pdev->dev, "failed to add GPIO chip\n"); |
357 | np, status); | ||
358 | return status; | 341 | return status; |
359 | } | 342 | } |
360 | 343 | ||
@@ -370,7 +353,6 @@ MODULE_DEVICE_TABLE(of, xgpio_of_match); | |||
370 | 353 | ||
371 | static struct platform_driver xgpio_plat_driver = { | 354 | static struct platform_driver xgpio_plat_driver = { |
372 | .probe = xgpio_probe, | 355 | .probe = xgpio_probe, |
373 | .remove = xgpio_remove, | ||
374 | .driver = { | 356 | .driver = { |
375 | .name = "gpio-xilinx", | 357 | .name = "gpio-xilinx", |
376 | .of_match_table = xgpio_of_match, | 358 | .of_match_table = xgpio_of_match, |
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index c9fc9e232aaf..39f2f9035c11 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -217,14 +217,13 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares, | |||
217 | if (!handler) | 217 | if (!handler) |
218 | return AE_OK; | 218 | return AE_OK; |
219 | 219 | ||
220 | desc = gpiochip_request_own_desc(chip, pin, "ACPI:Event", 0); | 220 | desc = gpiochip_request_own_desc(chip, pin, "ACPI:Event", |
221 | GPIO_ACTIVE_HIGH, GPIOD_IN); | ||
221 | if (IS_ERR(desc)) { | 222 | if (IS_ERR(desc)) { |
222 | dev_err(chip->parent, "Failed to request GPIO\n"); | 223 | dev_err(chip->parent, "Failed to request GPIO\n"); |
223 | return AE_ERROR; | 224 | return AE_ERROR; |
224 | } | 225 | } |
225 | 226 | ||
226 | gpiod_direction_input(desc); | ||
227 | |||
228 | ret = gpiochip_lock_as_irq(chip, pin); | 227 | ret = gpiochip_lock_as_irq(chip, pin); |
229 | if (ret) { | 228 | if (ret) { |
230 | dev_err(chip->parent, "Failed to lock GPIO as interrupt\n"); | 229 | dev_err(chip->parent, "Failed to lock GPIO as interrupt\n"); |
@@ -951,6 +950,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, | |||
951 | const char *label = "ACPI:OpRegion"; | 950 | const char *label = "ACPI:OpRegion"; |
952 | 951 | ||
953 | desc = gpiochip_request_own_desc(chip, pin, label, | 952 | desc = gpiochip_request_own_desc(chip, pin, label, |
953 | GPIO_ACTIVE_HIGH, | ||
954 | flags); | 954 | flags); |
955 | if (IS_ERR(desc)) { | 955 | if (IS_ERR(desc)) { |
956 | status = AE_ERROR; | 956 | status = AE_ERROR; |
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 9c9b965d7d6d..f974075ff00e 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
@@ -165,6 +165,12 @@ static void of_gpio_flags_quirks(struct device_node *np, | |||
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | |||
169 | /* Legacy handling of stmmac's active-low PHY reset line */ | ||
170 | if (IS_ENABLED(CONFIG_STMMAC_ETH) && | ||
171 | !strcmp(propname, "snps,reset-gpio") && | ||
172 | of_property_read_bool(np, "snps,reset-active-low")) | ||
173 | *flags |= OF_GPIO_ACTIVE_LOW; | ||
168 | } | 174 | } |
169 | 175 | ||
170 | /** | 176 | /** |
@@ -262,6 +268,37 @@ static struct gpio_desc *of_find_spi_gpio(struct device *dev, const char *con_id | |||
262 | } | 268 | } |
263 | 269 | ||
264 | /* | 270 | /* |
271 | * The old Freescale bindings use simply "gpios" as name for the chip select | ||
272 | * lines rather than "cs-gpios" like all other SPI hardware. Account for this | ||
273 | * with a special quirk. | ||
274 | */ | ||
275 | static struct gpio_desc *of_find_spi_cs_gpio(struct device *dev, | ||
276 | const char *con_id, | ||
277 | unsigned int idx, | ||
278 | unsigned long *flags) | ||
279 | { | ||
280 | struct device_node *np = dev->of_node; | ||
281 | |||
282 | if (!IS_ENABLED(CONFIG_SPI_MASTER)) | ||
283 | return ERR_PTR(-ENOENT); | ||
284 | |||
285 | /* Allow this specifically for Freescale devices */ | ||
286 | if (!of_device_is_compatible(np, "fsl,spi") && | ||
287 | !of_device_is_compatible(np, "aeroflexgaisler,spictrl")) | ||
288 | return ERR_PTR(-ENOENT); | ||
289 | /* Allow only if asking for "cs-gpios" */ | ||
290 | if (!con_id || strcmp(con_id, "cs")) | ||
291 | return ERR_PTR(-ENOENT); | ||
292 | |||
293 | /* | ||
294 | * While all other SPI controllers use "cs-gpios" the Freescale | ||
295 | * uses just "gpios" so translate to that when "cs-gpios" is | ||
296 | * requested. | ||
297 | */ | ||
298 | return of_find_gpio(dev, NULL, idx, flags); | ||
299 | } | ||
300 | |||
301 | /* | ||
265 | * Some regulator bindings happened before we managed to establish that GPIO | 302 | * Some regulator bindings happened before we managed to establish that GPIO |
266 | * properties should be named "foo-gpios" so we have this special kludge for | 303 | * properties should be named "foo-gpios" so we have this special kludge for |
267 | * them. | 304 | * them. |
@@ -332,6 +369,12 @@ struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | |||
332 | /* Special handling for SPI GPIOs if used */ | 369 | /* Special handling for SPI GPIOs if used */ |
333 | if (IS_ERR(desc)) | 370 | if (IS_ERR(desc)) |
334 | desc = of_find_spi_gpio(dev, con_id, &of_flags); | 371 | desc = of_find_spi_gpio(dev, con_id, &of_flags); |
372 | if (IS_ERR(desc)) { | ||
373 | /* This quirk looks up flags and all */ | ||
374 | desc = of_find_spi_cs_gpio(dev, con_id, idx, flags); | ||
375 | if (!IS_ERR(desc)) | ||
376 | return desc; | ||
377 | } | ||
335 | 378 | ||
336 | /* Special handling for regulator GPIOs if used */ | 379 | /* Special handling for regulator GPIOs if used */ |
337 | if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) | 380 | if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e013d417a936..47a67c4deed4 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1644,39 +1644,47 @@ EXPORT_SYMBOL_GPL(gpiochip_irqchip_irq_valid); | |||
1644 | 1644 | ||
1645 | /** | 1645 | /** |
1646 | * gpiochip_set_cascaded_irqchip() - connects a cascaded irqchip to a gpiochip | 1646 | * gpiochip_set_cascaded_irqchip() - connects a cascaded irqchip to a gpiochip |
1647 | * @gpiochip: the gpiochip to set the irqchip chain to | 1647 | * @gc: the gpiochip to set the irqchip chain to |
1648 | * @parent_irq: the irq number corresponding to the parent IRQ for this | 1648 | * @parent_irq: the irq number corresponding to the parent IRQ for this |
1649 | * chained irqchip | 1649 | * chained irqchip |
1650 | * @parent_handler: the parent interrupt handler for the accumulated IRQ | 1650 | * @parent_handler: the parent interrupt handler for the accumulated IRQ |
1651 | * coming out of the gpiochip. If the interrupt is nested rather than | 1651 | * coming out of the gpiochip. If the interrupt is nested rather than |
1652 | * cascaded, pass NULL in this handler argument | 1652 | * cascaded, pass NULL in this handler argument |
1653 | */ | 1653 | */ |
1654 | static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gpiochip, | 1654 | static void gpiochip_set_cascaded_irqchip(struct gpio_chip *gc, |
1655 | unsigned int parent_irq, | 1655 | unsigned int parent_irq, |
1656 | irq_flow_handler_t parent_handler) | 1656 | irq_flow_handler_t parent_handler) |
1657 | { | 1657 | { |
1658 | if (!gpiochip->irq.domain) { | 1658 | struct gpio_irq_chip *girq = &gc->irq; |
1659 | chip_err(gpiochip, "called %s before setting up irqchip\n", | 1659 | struct device *dev = &gc->gpiodev->dev; |
1660 | |||
1661 | if (!girq->domain) { | ||
1662 | chip_err(gc, "called %s before setting up irqchip\n", | ||
1660 | __func__); | 1663 | __func__); |
1661 | return; | 1664 | return; |
1662 | } | 1665 | } |
1663 | 1666 | ||
1664 | if (parent_handler) { | 1667 | if (parent_handler) { |
1665 | if (gpiochip->can_sleep) { | 1668 | if (gc->can_sleep) { |
1666 | chip_err(gpiochip, | 1669 | chip_err(gc, |
1667 | "you cannot have chained interrupts on a chip that may sleep\n"); | 1670 | "you cannot have chained interrupts on a chip that may sleep\n"); |
1668 | return; | 1671 | return; |
1669 | } | 1672 | } |
1673 | girq->parents = devm_kcalloc(dev, 1, | ||
1674 | sizeof(*girq->parents), | ||
1675 | GFP_KERNEL); | ||
1676 | if (!girq->parents) { | ||
1677 | chip_err(gc, "out of memory allocating parent IRQ\n"); | ||
1678 | return; | ||
1679 | } | ||
1680 | girq->parents[0] = parent_irq; | ||
1681 | girq->num_parents = 1; | ||
1670 | /* | 1682 | /* |
1671 | * The parent irqchip is already using the chip_data for this | 1683 | * The parent irqchip is already using the chip_data for this |
1672 | * irqchip, so our callbacks simply use the handler_data. | 1684 | * irqchip, so our callbacks simply use the handler_data. |
1673 | */ | 1685 | */ |
1674 | irq_set_chained_handler_and_data(parent_irq, parent_handler, | 1686 | irq_set_chained_handler_and_data(parent_irq, parent_handler, |
1675 | gpiochip); | 1687 | gc); |
1676 | |||
1677 | gpiochip->irq.parent_irq = parent_irq; | ||
1678 | gpiochip->irq.parents = &gpiochip->irq.parent_irq; | ||
1679 | gpiochip->irq.num_parents = 1; | ||
1680 | } | 1688 | } |
1681 | } | 1689 | } |
1682 | 1690 | ||
@@ -2503,7 +2511,11 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested); | |||
2503 | * @chip: GPIO chip | 2511 | * @chip: GPIO chip |
2504 | * @hwnum: hardware number of the GPIO for which to request the descriptor | 2512 | * @hwnum: hardware number of the GPIO for which to request the descriptor |
2505 | * @label: label for the GPIO | 2513 | * @label: label for the GPIO |
2506 | * @flags: flags for this GPIO or 0 if default | 2514 | * @lflags: lookup flags for this GPIO or 0 if default, this can be used to |
2515 | * specify things like line inversion semantics with the machine flags | ||
2516 | * such as GPIO_OUT_LOW | ||
2517 | * @dflags: descriptor request flags for this GPIO or 0 if default, this | ||
2518 | * can be used to specify consumer semantics such as open drain | ||
2507 | * | 2519 | * |
2508 | * Function allows GPIO chip drivers to request and use their own GPIO | 2520 | * Function allows GPIO chip drivers to request and use their own GPIO |
2509 | * descriptors via gpiolib API. Difference to gpiod_request() is that this | 2521 | * descriptors via gpiolib API. Difference to gpiod_request() is that this |
@@ -2517,9 +2529,9 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested); | |||
2517 | */ | 2529 | */ |
2518 | struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, | 2530 | struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, |
2519 | const char *label, | 2531 | const char *label, |
2520 | enum gpiod_flags flags) | 2532 | enum gpio_lookup_flags lflags, |
2533 | enum gpiod_flags dflags) | ||
2521 | { | 2534 | { |
2522 | unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT; | ||
2523 | struct gpio_desc *desc = gpiochip_get_desc(chip, hwnum); | 2535 | struct gpio_desc *desc = gpiochip_get_desc(chip, hwnum); |
2524 | int err; | 2536 | int err; |
2525 | 2537 | ||
@@ -2532,7 +2544,7 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, | |||
2532 | if (err < 0) | 2544 | if (err < 0) |
2533 | return ERR_PTR(err); | 2545 | return ERR_PTR(err); |
2534 | 2546 | ||
2535 | err = gpiod_configure_flags(desc, label, lflags, flags); | 2547 | err = gpiod_configure_flags(desc, label, lflags, dflags); |
2536 | if (err) { | 2548 | if (err) { |
2537 | chip_err(chip, "setup of own GPIO %s failed\n", label); | 2549 | chip_err(chip, "setup of own GPIO %s failed\n", label); |
2538 | gpiod_free_commit(desc); | 2550 | gpiod_free_commit(desc); |
@@ -3019,13 +3031,13 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep, | |||
3019 | * Return the GPIO's raw value, i.e. the value of the physical line disregarding | 3031 | * Return the GPIO's raw value, i.e. the value of the physical line disregarding |
3020 | * its ACTIVE_LOW status, or negative errno on failure. | 3032 | * its ACTIVE_LOW status, or negative errno on failure. |
3021 | * | 3033 | * |
3022 | * This function should be called from contexts where we cannot sleep, and will | 3034 | * This function can be called from contexts where we cannot sleep, and will |
3023 | * complain if the GPIO chip functions potentially sleep. | 3035 | * complain if the GPIO chip functions potentially sleep. |
3024 | */ | 3036 | */ |
3025 | int gpiod_get_raw_value(const struct gpio_desc *desc) | 3037 | int gpiod_get_raw_value(const struct gpio_desc *desc) |
3026 | { | 3038 | { |
3027 | VALIDATE_DESC(desc); | 3039 | VALIDATE_DESC(desc); |
3028 | /* Should be using gpio_get_value_cansleep() */ | 3040 | /* Should be using gpiod_get_raw_value_cansleep() */ |
3029 | WARN_ON(desc->gdev->chip->can_sleep); | 3041 | WARN_ON(desc->gdev->chip->can_sleep); |
3030 | return gpiod_get_raw_value_commit(desc); | 3042 | return gpiod_get_raw_value_commit(desc); |
3031 | } | 3043 | } |
@@ -3038,7 +3050,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_raw_value); | |||
3038 | * Return the GPIO's logical value, i.e. taking the ACTIVE_LOW status into | 3050 | * Return the GPIO's logical value, i.e. taking the ACTIVE_LOW status into |
3039 | * account, or negative errno on failure. | 3051 | * account, or negative errno on failure. |
3040 | * | 3052 | * |
3041 | * This function should be called from contexts where we cannot sleep, and will | 3053 | * This function can be called from contexts where we cannot sleep, and will |
3042 | * complain if the GPIO chip functions potentially sleep. | 3054 | * complain if the GPIO chip functions potentially sleep. |
3043 | */ | 3055 | */ |
3044 | int gpiod_get_value(const struct gpio_desc *desc) | 3056 | int gpiod_get_value(const struct gpio_desc *desc) |
@@ -3046,7 +3058,7 @@ int gpiod_get_value(const struct gpio_desc *desc) | |||
3046 | int value; | 3058 | int value; |
3047 | 3059 | ||
3048 | VALIDATE_DESC(desc); | 3060 | VALIDATE_DESC(desc); |
3049 | /* Should be using gpio_get_value_cansleep() */ | 3061 | /* Should be using gpiod_get_value_cansleep() */ |
3050 | WARN_ON(desc->gdev->chip->can_sleep); | 3062 | WARN_ON(desc->gdev->chip->can_sleep); |
3051 | 3063 | ||
3052 | value = gpiod_get_raw_value_commit(desc); | 3064 | value = gpiod_get_raw_value_commit(desc); |
@@ -3071,7 +3083,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_value); | |||
3071 | * without regard for their ACTIVE_LOW status. Return 0 in case of success, | 3083 | * without regard for their ACTIVE_LOW status. Return 0 in case of success, |
3072 | * else an error code. | 3084 | * else an error code. |
3073 | * | 3085 | * |
3074 | * This function should be called from contexts where we cannot sleep, | 3086 | * This function can be called from contexts where we cannot sleep, |
3075 | * and it will complain if the GPIO chip functions potentially sleep. | 3087 | * and it will complain if the GPIO chip functions potentially sleep. |
3076 | */ | 3088 | */ |
3077 | int gpiod_get_raw_array_value(unsigned int array_size, | 3089 | int gpiod_get_raw_array_value(unsigned int array_size, |
@@ -3097,7 +3109,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_raw_array_value); | |||
3097 | * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | 3109 | * Read the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status |
3098 | * into account. Return 0 in case of success, else an error code. | 3110 | * into account. Return 0 in case of success, else an error code. |
3099 | * | 3111 | * |
3100 | * This function should be called from contexts where we cannot sleep, | 3112 | * This function can be called from contexts where we cannot sleep, |
3101 | * and it will complain if the GPIO chip functions potentially sleep. | 3113 | * and it will complain if the GPIO chip functions potentially sleep. |
3102 | */ | 3114 | */ |
3103 | int gpiod_get_array_value(unsigned int array_size, | 3115 | int gpiod_get_array_value(unsigned int array_size, |
@@ -3311,13 +3323,13 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, | |||
3311 | * Set the raw value of the GPIO, i.e. the value of its physical line without | 3323 | * Set the raw value of the GPIO, i.e. the value of its physical line without |
3312 | * regard for its ACTIVE_LOW status. | 3324 | * regard for its ACTIVE_LOW status. |
3313 | * | 3325 | * |
3314 | * This function should be called from contexts where we cannot sleep, and will | 3326 | * This function can be called from contexts where we cannot sleep, and will |
3315 | * complain if the GPIO chip functions potentially sleep. | 3327 | * complain if the GPIO chip functions potentially sleep. |
3316 | */ | 3328 | */ |
3317 | void gpiod_set_raw_value(struct gpio_desc *desc, int value) | 3329 | void gpiod_set_raw_value(struct gpio_desc *desc, int value) |
3318 | { | 3330 | { |
3319 | VALIDATE_DESC_VOID(desc); | 3331 | VALIDATE_DESC_VOID(desc); |
3320 | /* Should be using gpiod_set_value_cansleep() */ | 3332 | /* Should be using gpiod_set_raw_value_cansleep() */ |
3321 | WARN_ON(desc->gdev->chip->can_sleep); | 3333 | WARN_ON(desc->gdev->chip->can_sleep); |
3322 | gpiod_set_raw_value_commit(desc, value); | 3334 | gpiod_set_raw_value_commit(desc, value); |
3323 | } | 3335 | } |
@@ -3352,12 +3364,13 @@ static void gpiod_set_value_nocheck(struct gpio_desc *desc, int value) | |||
3352 | * Set the logical value of the GPIO, i.e. taking its ACTIVE_LOW, | 3364 | * Set the logical value of the GPIO, i.e. taking its ACTIVE_LOW, |
3353 | * OPEN_DRAIN and OPEN_SOURCE flags into account. | 3365 | * OPEN_DRAIN and OPEN_SOURCE flags into account. |
3354 | * | 3366 | * |
3355 | * This function should be called from contexts where we cannot sleep, and will | 3367 | * This function can be called from contexts where we cannot sleep, and will |
3356 | * complain if the GPIO chip functions potentially sleep. | 3368 | * complain if the GPIO chip functions potentially sleep. |
3357 | */ | 3369 | */ |
3358 | void gpiod_set_value(struct gpio_desc *desc, int value) | 3370 | void gpiod_set_value(struct gpio_desc *desc, int value) |
3359 | { | 3371 | { |
3360 | VALIDATE_DESC_VOID(desc); | 3372 | VALIDATE_DESC_VOID(desc); |
3373 | /* Should be using gpiod_set_value_cansleep() */ | ||
3361 | WARN_ON(desc->gdev->chip->can_sleep); | 3374 | WARN_ON(desc->gdev->chip->can_sleep); |
3362 | gpiod_set_value_nocheck(desc, value); | 3375 | gpiod_set_value_nocheck(desc, value); |
3363 | } | 3376 | } |
@@ -3373,7 +3386,7 @@ EXPORT_SYMBOL_GPL(gpiod_set_value); | |||
3373 | * Set the raw values of the GPIOs, i.e. the values of the physical lines | 3386 | * Set the raw values of the GPIOs, i.e. the values of the physical lines |
3374 | * without regard for their ACTIVE_LOW status. | 3387 | * without regard for their ACTIVE_LOW status. |
3375 | * | 3388 | * |
3376 | * This function should be called from contexts where we cannot sleep, and will | 3389 | * This function can be called from contexts where we cannot sleep, and will |
3377 | * complain if the GPIO chip functions potentially sleep. | 3390 | * complain if the GPIO chip functions potentially sleep. |
3378 | */ | 3391 | */ |
3379 | int gpiod_set_raw_array_value(unsigned int array_size, | 3392 | int gpiod_set_raw_array_value(unsigned int array_size, |
@@ -3398,7 +3411,7 @@ EXPORT_SYMBOL_GPL(gpiod_set_raw_array_value); | |||
3398 | * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status | 3411 | * Set the logical values of the GPIOs, i.e. taking their ACTIVE_LOW status |
3399 | * into account. | 3412 | * into account. |
3400 | * | 3413 | * |
3401 | * This function should be called from contexts where we cannot sleep, and will | 3414 | * This function can be called from contexts where we cannot sleep, and will |
3402 | * complain if the GPIO chip functions potentially sleep. | 3415 | * complain if the GPIO chip functions potentially sleep. |
3403 | */ | 3416 | */ |
3404 | int gpiod_set_array_value(unsigned int array_size, | 3417 | int gpiod_set_array_value(unsigned int array_size, |
@@ -4420,15 +4433,8 @@ int gpiod_hog(struct gpio_desc *desc, const char *name, | |||
4420 | chip = gpiod_to_chip(desc); | 4433 | chip = gpiod_to_chip(desc); |
4421 | hwnum = gpio_chip_hwgpio(desc); | 4434 | hwnum = gpio_chip_hwgpio(desc); |
4422 | 4435 | ||
4423 | /* | 4436 | local_desc = gpiochip_request_own_desc(chip, hwnum, name, |
4424 | * FIXME: not very elegant that we call gpiod_configure_flags() | 4437 | lflags, dflags); |
4425 | * twice here (once inside gpiochip_request_own_desc() and | ||
4426 | * again here), but the gpiochip_request_own_desc() is external | ||
4427 | * and cannot really pass the lflags so this is the lesser evil | ||
4428 | * at the moment. Pass zero as dflags on this first call so we | ||
4429 | * don't screw anything up. | ||
4430 | */ | ||
4431 | local_desc = gpiochip_request_own_desc(chip, hwnum, name, 0); | ||
4432 | if (IS_ERR(local_desc)) { | 4438 | if (IS_ERR(local_desc)) { |
4433 | status = PTR_ERR(local_desc); | 4439 | status = PTR_ERR(local_desc); |
4434 | pr_err("requesting hog GPIO %s (chip %s, offset %d) failed, %d\n", | 4440 | pr_err("requesting hog GPIO %s (chip %s, offset %d) failed, %d\n", |
@@ -4436,14 +4442,6 @@ int gpiod_hog(struct gpio_desc *desc, const char *name, | |||
4436 | return status; | 4442 | return status; |
4437 | } | 4443 | } |
4438 | 4444 | ||
4439 | status = gpiod_configure_flags(desc, name, lflags, dflags); | ||
4440 | if (status < 0) { | ||
4441 | pr_err("setup of hog GPIO %s (chip %s, offset %d) failed, %d\n", | ||
4442 | name, chip->label, hwnum, status); | ||
4443 | gpiochip_free_own_desc(desc); | ||
4444 | return status; | ||
4445 | } | ||
4446 | |||
4447 | /* Mark GPIO as hogged so it can be identified and removed later */ | 4445 | /* Mark GPIO as hogged so it can be identified and removed later */ |
4448 | set_bit(FLAG_IS_HOGGED, &desc->flags); | 4446 | set_bit(FLAG_IS_HOGGED, &desc->flags); |
4449 | 4447 | ||
@@ -4805,8 +4803,8 @@ static const struct file_operations gpiolib_operations = { | |||
4805 | static int __init gpiolib_debugfs_init(void) | 4803 | static int __init gpiolib_debugfs_init(void) |
4806 | { | 4804 | { |
4807 | /* /sys/kernel/debug/gpio */ | 4805 | /* /sys/kernel/debug/gpio */ |
4808 | (void) debugfs_create_file("gpio", S_IFREG | S_IRUGO, | 4806 | debugfs_create_file("gpio", S_IFREG | S_IRUGO, NULL, NULL, |
4809 | NULL, NULL, &gpiolib_operations); | 4807 | &gpiolib_operations); |
4810 | return 0; | 4808 | return 0; |
4811 | } | 4809 | } |
4812 | subsys_initcall(gpiolib_debugfs_init); | 4810 | subsys_initcall(gpiolib_debugfs_init); |
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 7a65dad43932..7c52c2442173 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h | |||
@@ -210,7 +210,7 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, | |||
210 | struct gpio_array *array_info, | 210 | struct gpio_array *array_info, |
211 | unsigned long *value_bitmap); | 211 | unsigned long *value_bitmap); |
212 | 212 | ||
213 | extern struct spinlock gpio_lock; | 213 | extern spinlock_t gpio_lock; |
214 | extern struct list_head gpio_devices; | 214 | extern struct list_head gpio_devices; |
215 | 215 | ||
216 | struct gpio_desc { | 216 | struct gpio_desc { |
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 8bbe3d0cbe5d..2310c96ccf4a 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c | |||
@@ -16,7 +16,8 @@ | |||
16 | * https://www.silabs.com/documents/public/application-notes/an495-cp2112-interface-specification.pdf | 16 | * https://www.silabs.com/documents/public/application-notes/an495-cp2112-interface-specification.pdf |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/gpio.h> | 19 | #include <linux/gpio/consumer.h> |
20 | #include <linux/gpio/machine.h> | ||
20 | #include <linux/gpio/driver.h> | 21 | #include <linux/gpio/driver.h> |
21 | #include <linux/hid.h> | 22 | #include <linux/hid.h> |
22 | #include <linux/hidraw.h> | 23 | #include <linux/hidraw.h> |
@@ -1195,7 +1196,9 @@ static int __maybe_unused cp2112_allocate_irq(struct cp2112_device *dev, | |||
1195 | return -EINVAL; | 1196 | return -EINVAL; |
1196 | 1197 | ||
1197 | dev->desc[pin] = gpiochip_request_own_desc(&dev->gc, pin, | 1198 | dev->desc[pin] = gpiochip_request_own_desc(&dev->gc, pin, |
1198 | "HID/I2C:Event", 0); | 1199 | "HID/I2C:Event", |
1200 | GPIO_ACTIVE_HIGH, | ||
1201 | GPIOD_IN); | ||
1199 | if (IS_ERR(dev->desc[pin])) { | 1202 | if (IS_ERR(dev->desc[pin])) { |
1200 | dev_err(dev->gc.parent, "Failed to request GPIO\n"); | 1203 | dev_err(dev->gc.parent, "Failed to request GPIO\n"); |
1201 | return PTR_ERR(dev->desc[pin]); | 1204 | return PTR_ERR(dev->desc[pin]); |
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c index 139782fefd02..eff26c1b1394 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
20 | #include <linux/gpio/driver.h> | 20 | #include <linux/gpio/driver.h> |
21 | #include <linux/gpio/consumer.h> /* GPIO descriptor enum */ | 21 | #include <linux/gpio/consumer.h> /* GPIO descriptor enum */ |
22 | #include <linux/gpio/machine.h> | ||
22 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
23 | #include <linux/irqdomain.h> | 24 | #include <linux/irqdomain.h> |
24 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
@@ -2169,7 +2170,8 @@ static int gpmc_probe_generic_child(struct platform_device *pdev, | |||
2169 | 2170 | ||
2170 | waitpin_desc = gpiochip_request_own_desc(&gpmc->gpio_chip, | 2171 | waitpin_desc = gpiochip_request_own_desc(&gpmc->gpio_chip, |
2171 | wait_pin, "WAITPIN", | 2172 | wait_pin, "WAITPIN", |
2172 | 0); | 2173 | GPIO_ACTIVE_HIGH, |
2174 | GPIOD_IN); | ||
2173 | if (IS_ERR(waitpin_desc)) { | 2175 | if (IS_ERR(waitpin_desc)) { |
2174 | dev_err(&pdev->dev, "invalid wait-pin: %d\n", wait_pin); | 2176 | dev_err(&pdev->dev, "invalid wait-pin: %d\n", wait_pin); |
2175 | ret = PTR_ERR(waitpin_desc); | 2177 | ret = PTR_ERR(waitpin_desc); |
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 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | /* | ||
3 | * This file is separate from sdb.h, because I want that one to remain | ||
4 | * unchanged (as far as possible) from the official sdb distribution | ||
5 | * | ||
6 | * This file and associated functionality are a playground for me to | ||
7 | * understand stuff which will later be implemented in more generic places. | ||
8 | */ | ||
9 | #include <linux/sdb.h> | ||
10 | |||
11 | /* This is the union of all currently defined types */ | ||
12 | union sdb_record { | ||
13 | struct sdb_interconnect ic; | ||
14 | struct sdb_device dev; | ||
15 | struct sdb_bridge bridge; | ||
16 | struct sdb_integration integr; | ||
17 | struct sdb_empty empty; | ||
18 | struct sdb_synthesis synthesis; | ||
19 | struct sdb_repo_url repo_url; | ||
20 | }; | ||
21 | |||
22 | struct fmc_device; | ||
23 | |||
24 | /* Every sdb table is turned into this structure */ | ||
25 | struct sdb_array { | ||
26 | int len; | ||
27 | int level; | ||
28 | unsigned long baseaddr; | ||
29 | struct fmc_device *fmc; /* the device that hosts it */ | ||
30 | struct sdb_array *parent; /* NULL at root */ | ||
31 | union sdb_record *record; /* copies of the struct */ | ||
32 | struct sdb_array **subtree; /* only valid for bridge items */ | ||
33 | }; | ||
34 | |||
35 | extern int fmc_scan_sdb_tree(struct fmc_device *fmc, unsigned long address); | ||
36 | extern void fmc_show_sdb_tree(const struct fmc_device *fmc); | ||
37 | extern signed long fmc_find_sdb_device(struct sdb_array *tree, uint64_t vendor, | ||
38 | uint32_t device, unsigned long *sz); | ||
39 | 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 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
2 | /* | ||
3 | * Copyright (C) 2012 CERN (www.cern.ch) | ||
4 | * Author: Alessandro Rubini <rubini@gnudd.com> | ||
5 | * | ||
6 | * This work is part of the White Rabbit project, a research effort led | ||
7 | * by CERN, the European Institute for Nuclear Research. | ||
8 | */ | ||
9 | #ifndef __LINUX_FMC_H__ | ||
10 | #define __LINUX_FMC_H__ | ||
11 | #include <linux/types.h> | ||
12 | #include <linux/moduleparam.h> | ||
13 | #include <linux/device.h> | ||
14 | #include <linux/list.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | #include <linux/io.h> | ||
17 | |||
18 | struct fmc_device; | ||
19 | struct fmc_driver; | ||
20 | |||
21 | /* | ||
22 | * This bus abstraction is developed separately from drivers, so we need | ||
23 | * to check the version of the data structures we receive. | ||
24 | */ | ||
25 | |||
26 | #define FMC_MAJOR 3 | ||
27 | #define FMC_MINOR 0 | ||
28 | #define FMC_VERSION ((FMC_MAJOR << 16) | FMC_MINOR) | ||
29 | #define __FMC_MAJOR(x) ((x) >> 16) | ||
30 | #define __FMC_MINOR(x) ((x) & 0xffff) | ||
31 | |||
32 | /* | ||
33 | * The device identification, as defined by the IPMI FRU (Field Replaceable | ||
34 | * Unit) includes four different strings to describe the device. Here we | ||
35 | * only match the "Board Manufacturer" and the "Board Product Name", | ||
36 | * ignoring the "Board Serial Number" and "Board Part Number". All 4 are | ||
37 | * expected to be strings, so they are treated as zero-terminated C strings. | ||
38 | * Unspecified string (NULL) means "any", so if both are unspecified this | ||
39 | * is a catch-all driver. So null entries are allowed and we use array | ||
40 | * and length. This is unlike pci and usb that use null-terminated arrays | ||
41 | */ | ||
42 | struct fmc_fru_id { | ||
43 | char *manufacturer; | ||
44 | char *product_name; | ||
45 | }; | ||
46 | |||
47 | /* | ||
48 | * If the FPGA is already programmed (think Etherbone or the second | ||
49 | * SVEC slot), we can match on SDB devices in the memory image. This | ||
50 | * match uses an array of devices that must all be present, and the | ||
51 | * match is based on vendor and device only. Further checks are expected | ||
52 | * to happen in the probe function. Zero means "any" and catch-all is allowed. | ||
53 | */ | ||
54 | struct fmc_sdb_one_id { | ||
55 | uint64_t vendor; | ||
56 | uint32_t device; | ||
57 | }; | ||
58 | struct fmc_sdb_id { | ||
59 | struct fmc_sdb_one_id *cores; | ||
60 | int cores_nr; | ||
61 | }; | ||
62 | |||
63 | struct fmc_device_id { | ||
64 | struct fmc_fru_id *fru_id; | ||
65 | int fru_id_nr; | ||
66 | struct fmc_sdb_id *sdb_id; | ||
67 | int sdb_id_nr; | ||
68 | }; | ||
69 | |||
70 | /* This sizes the module_param_array used by generic module parameters */ | ||
71 | #define FMC_MAX_CARDS 32 | ||
72 | |||
73 | /* The driver is a pretty simple thing */ | ||
74 | struct fmc_driver { | ||
75 | unsigned long version; | ||
76 | struct device_driver driver; | ||
77 | int (*probe)(struct fmc_device *); | ||
78 | int (*remove)(struct fmc_device *); | ||
79 | const struct fmc_device_id id_table; | ||
80 | /* What follows is for generic module parameters */ | ||
81 | int busid_n; | ||
82 | int busid_val[FMC_MAX_CARDS]; | ||
83 | int gw_n; | ||
84 | char *gw_val[FMC_MAX_CARDS]; | ||
85 | }; | ||
86 | #define to_fmc_driver(x) container_of((x), struct fmc_driver, driver) | ||
87 | |||
88 | /* These are the generic parameters, that drivers may instantiate */ | ||
89 | #define FMC_PARAM_BUSID(_d) \ | ||
90 | module_param_array_named(busid, _d.busid_val, int, &_d.busid_n, 0444) | ||
91 | #define FMC_PARAM_GATEWARE(_d) \ | ||
92 | module_param_array_named(gateware, _d.gw_val, charp, &_d.gw_n, 0444) | ||
93 | |||
94 | /* | ||
95 | * Drivers may need to configure gpio pins in the carrier. To read input | ||
96 | * (a very uncommon operation, and definitely not in the hot paths), just | ||
97 | * configure one gpio only and get 0 or 1 as retval of the config method | ||
98 | */ | ||
99 | struct fmc_gpio { | ||
100 | char *carrier_name; /* name or NULL for virtual pins */ | ||
101 | int gpio; | ||
102 | int _gpio; /* internal use by the carrier */ | ||
103 | int mode; /* GPIOF_DIR_OUT etc, from <linux/gpio.h> */ | ||
104 | int irqmode; /* IRQF_TRIGGER_LOW and so on */ | ||
105 | }; | ||
106 | |||
107 | /* The numbering of gpio pins allows access to raw pins or virtual roles */ | ||
108 | #define FMC_GPIO_RAW(x) (x) /* 4096 of them */ | ||
109 | #define __FMC_GPIO_IS_RAW(x) ((x) < 0x1000) | ||
110 | #define FMC_GPIO_IRQ(x) ((x) + 0x1000) /* 256 of them */ | ||
111 | #define FMC_GPIO_LED(x) ((x) + 0x1100) /* 256 of them */ | ||
112 | #define FMC_GPIO_KEY(x) ((x) + 0x1200) /* 256 of them */ | ||
113 | #define FMC_GPIO_TP(x) ((x) + 0x1300) /* 256 of them */ | ||
114 | #define FMC_GPIO_USER(x) ((x) + 0x1400) /* 256 of them */ | ||
115 | /* We may add SCL and SDA, or other roles if the need arises */ | ||
116 | |||
117 | /* GPIOF_DIR_IN etc are missing before 3.0. copy from <linux/gpio.h> */ | ||
118 | #ifndef GPIOF_DIR_IN | ||
119 | # define GPIOF_DIR_OUT (0 << 0) | ||
120 | # define GPIOF_DIR_IN (1 << 0) | ||
121 | # define GPIOF_INIT_LOW (0 << 1) | ||
122 | # define GPIOF_INIT_HIGH (1 << 1) | ||
123 | #endif | ||
124 | |||
125 | /* | ||
126 | * The operations are offered by each carrier and should make driver | ||
127 | * design completely independent of the carrier. Named GPIO pins may be | ||
128 | * the exception. | ||
129 | */ | ||
130 | struct fmc_operations { | ||
131 | uint32_t (*read32)(struct fmc_device *fmc, int offset); | ||
132 | void (*write32)(struct fmc_device *fmc, uint32_t value, int offset); | ||
133 | int (*validate)(struct fmc_device *fmc, struct fmc_driver *drv); | ||
134 | int (*reprogram_raw)(struct fmc_device *f, struct fmc_driver *d, | ||
135 | void *gw, unsigned long len); | ||
136 | int (*reprogram)(struct fmc_device *f, struct fmc_driver *d, char *gw); | ||
137 | int (*irq_request)(struct fmc_device *fmc, irq_handler_t h, | ||
138 | char *name, int flags); | ||
139 | void (*irq_ack)(struct fmc_device *fmc); | ||
140 | int (*irq_free)(struct fmc_device *fmc); | ||
141 | int (*gpio_config)(struct fmc_device *fmc, struct fmc_gpio *gpio, | ||
142 | int ngpio); | ||
143 | int (*read_ee)(struct fmc_device *fmc, int pos, void *d, int l); | ||
144 | int (*write_ee)(struct fmc_device *fmc, int pos, const void *d, int l); | ||
145 | }; | ||
146 | |||
147 | /* Prefer this helper rather than calling of fmc->reprogram directly */ | ||
148 | int fmc_reprogram_raw(struct fmc_device *fmc, struct fmc_driver *d, | ||
149 | void *gw, unsigned long len, int sdb_entry); | ||
150 | extern int fmc_reprogram(struct fmc_device *f, struct fmc_driver *d, char *gw, | ||
151 | int sdb_entry); | ||
152 | |||
153 | /* | ||
154 | * The device reports all information needed to access hw. | ||
155 | * | ||
156 | * If we have eeprom_len and not contents, the core reads it. | ||
157 | * Then, parsing of identifiers is done by the core which fills fmc_fru_id.. | ||
158 | * Similarly a device that must be matched based on SDB cores must | ||
159 | * fill the entry point and the core will scan the bus (FIXME: sdb match) | ||
160 | */ | ||
161 | struct fmc_device { | ||
162 | unsigned long version; | ||
163 | unsigned long flags; | ||
164 | struct module *owner; /* char device must pin it */ | ||
165 | struct fmc_fru_id id; /* for EEPROM-based match */ | ||
166 | struct fmc_operations *op; /* carrier-provided */ | ||
167 | int irq; /* according to host bus. 0 == none */ | ||
168 | int eeprom_len; /* Usually 8kB, may be less */ | ||
169 | int eeprom_addr; /* 0x50, 0x52 etc */ | ||
170 | uint8_t *eeprom; /* Full contents or leading part */ | ||
171 | char *carrier_name; /* "SPEC" or similar, for special use */ | ||
172 | void *carrier_data; /* "struct spec *" or equivalent */ | ||
173 | __iomem void *fpga_base; /* May be NULL (Etherbone) */ | ||
174 | __iomem void *slot_base; /* Set by the driver */ | ||
175 | struct fmc_device **devarray; /* Allocated by the bus */ | ||
176 | int slot_id; /* Index in the slot array */ | ||
177 | int nr_slots; /* Number of slots in this carrier */ | ||
178 | unsigned long memlen; /* Used for the char device */ | ||
179 | struct device dev; /* For Linux use */ | ||
180 | struct device *hwdev; /* The underlying hardware device */ | ||
181 | unsigned long sdbfs_entry; | ||
182 | struct sdb_array *sdb; | ||
183 | uint32_t device_id; /* Filled by the device */ | ||
184 | char *mezzanine_name; /* Defaults to ``fmc'' */ | ||
185 | void *mezzanine_data; | ||
186 | |||
187 | struct dentry *dbg_dir; | ||
188 | struct dentry *dbg_sdb_dump; | ||
189 | }; | ||
190 | #define to_fmc_device(x) container_of((x), struct fmc_device, dev) | ||
191 | |||
192 | #define FMC_DEVICE_HAS_GOLDEN 1 | ||
193 | #define FMC_DEVICE_HAS_CUSTOM 2 | ||
194 | #define FMC_DEVICE_NO_MEZZANINE 4 | ||
195 | #define FMC_DEVICE_MATCH_SDB 8 /* fmc-core must scan sdb in fpga */ | ||
196 | |||
197 | /* | ||
198 | * If fpga_base can be used, the carrier offers no readl/writel methods, and | ||
199 | * this expands to a single, fast, I/O access. | ||
200 | */ | ||
201 | static inline uint32_t fmc_readl(struct fmc_device *fmc, int offset) | ||
202 | { | ||
203 | if (unlikely(fmc->op->read32)) | ||
204 | return fmc->op->read32(fmc, offset); | ||
205 | return readl(fmc->fpga_base + offset); | ||
206 | } | ||
207 | static inline void fmc_writel(struct fmc_device *fmc, uint32_t val, int off) | ||
208 | { | ||
209 | if (unlikely(fmc->op->write32)) | ||
210 | fmc->op->write32(fmc, val, off); | ||
211 | else | ||
212 | writel(val, fmc->fpga_base + off); | ||
213 | } | ||
214 | |||
215 | /* pci-like naming */ | ||
216 | static inline void *fmc_get_drvdata(const struct fmc_device *fmc) | ||
217 | { | ||
218 | return dev_get_drvdata(&fmc->dev); | ||
219 | } | ||
220 | |||
221 | static inline void fmc_set_drvdata(struct fmc_device *fmc, void *data) | ||
222 | { | ||
223 | dev_set_drvdata(&fmc->dev, data); | ||
224 | } | ||
225 | |||
226 | struct fmc_gateware { | ||
227 | void *bitstream; | ||
228 | unsigned long len; | ||
229 | }; | ||
230 | |||
231 | /* The 5 access points */ | ||
232 | extern int fmc_driver_register(struct fmc_driver *drv); | ||
233 | extern void fmc_driver_unregister(struct fmc_driver *drv); | ||
234 | extern int fmc_device_register(struct fmc_device *tdev); | ||
235 | extern int fmc_device_register_gw(struct fmc_device *tdev, | ||
236 | struct fmc_gateware *gw); | ||
237 | extern void fmc_device_unregister(struct fmc_device *tdev); | ||
238 | |||
239 | /* Three more for device sets, all driven by the same FPGA */ | ||
240 | extern int fmc_device_register_n(struct fmc_device **devs, int n); | ||
241 | extern int fmc_device_register_n_gw(struct fmc_device **devs, int n, | ||
242 | struct fmc_gateware *gw); | ||
243 | extern void fmc_device_unregister_n(struct fmc_device **devs, int n); | ||
244 | |||
245 | /* Internal cross-calls between files; not exported to other modules */ | ||
246 | extern int fmc_match(struct device *dev, struct device_driver *drv); | ||
247 | extern int fmc_fill_id_info(struct fmc_device *fmc); | ||
248 | extern void fmc_free_id_info(struct fmc_device *fmc); | ||
249 | extern void fmc_dump_eeprom(const struct fmc_device *fmc); | ||
250 | |||
251 | /* helpers for FMC operations */ | ||
252 | extern int fmc_irq_request(struct fmc_device *fmc, irq_handler_t h, | ||
253 | char *name, int flags); | ||
254 | extern void fmc_irq_free(struct fmc_device *fmc); | ||
255 | extern void fmc_irq_ack(struct fmc_device *fmc); | ||
256 | extern int fmc_validate(struct fmc_device *fmc, struct fmc_driver *drv); | ||
257 | extern int fmc_gpio_config(struct fmc_device *fmc, struct fmc_gpio *gpio, | ||
258 | int ngpio); | ||
259 | extern int fmc_read_ee(struct fmc_device *fmc, int pos, void *d, int l); | ||
260 | extern int fmc_write_ee(struct fmc_device *fmc, int pos, const void *d, int l); | ||
261 | |||
262 | /* helpers for FMC operations */ | ||
263 | extern int fmc_irq_request(struct fmc_device *fmc, irq_handler_t h, | ||
264 | char *name, int flags); | ||
265 | extern void fmc_irq_free(struct fmc_device *fmc); | ||
266 | extern void fmc_irq_ack(struct fmc_device *fmc); | ||
267 | extern int fmc_validate(struct fmc_device *fmc, struct fmc_driver *drv); | ||
268 | |||
269 | #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; | |||
18 | struct gpio_device; | 18 | struct gpio_device; |
19 | struct module; | 19 | struct module; |
20 | enum gpiod_flags; | 20 | enum gpiod_flags; |
21 | enum gpio_lookup_flags; | ||
21 | 22 | ||
22 | #ifdef CONFIG_GPIOLIB | 23 | #ifdef CONFIG_GPIOLIB |
23 | 24 | ||
@@ -102,13 +103,6 @@ struct gpio_irq_chip { | |||
102 | unsigned int num_parents; | 103 | unsigned int num_parents; |
103 | 104 | ||
104 | /** | 105 | /** |
105 | * @parent_irq: | ||
106 | * | ||
107 | * For use by gpiochip_set_cascaded_irqchip() | ||
108 | */ | ||
109 | unsigned int parent_irq; | ||
110 | |||
111 | /** | ||
112 | * @parents: | 106 | * @parents: |
113 | * | 107 | * |
114 | * A list of interrupt parents of a GPIO chip. This is owned by the | 108 | * A list of interrupt parents of a GPIO chip. This is owned by the |
@@ -167,7 +161,7 @@ struct gpio_irq_chip { | |||
167 | */ | 161 | */ |
168 | void (*irq_disable)(struct irq_data *data); | 162 | void (*irq_disable)(struct irq_data *data); |
169 | }; | 163 | }; |
170 | #endif | 164 | #endif /* CONFIG_GPIOLIB_IRQCHIP */ |
171 | 165 | ||
172 | /** | 166 | /** |
173 | * struct gpio_chip - abstract a GPIO controller | 167 | * struct gpio_chip - abstract a GPIO controller |
@@ -200,6 +194,8 @@ struct gpio_irq_chip { | |||
200 | * @dbg_show: optional routine to show contents in debugfs; default code | 194 | * @dbg_show: optional routine to show contents in debugfs; default code |
201 | * will be used when this is omitted, but custom code can show extra | 195 | * will be used when this is omitted, but custom code can show extra |
202 | * state (such as pullup/pulldown configuration). | 196 | * state (such as pullup/pulldown configuration). |
197 | * @init_valid_mask: optional routine to initialize @valid_mask, to be used if | ||
198 | * not all GPIOs are valid. | ||
203 | * @base: identifies the first GPIO number handled by this chip; | 199 | * @base: identifies the first GPIO number handled by this chip; |
204 | * or, if negative during registration, requests dynamic ID allocation. | 200 | * or, if negative during registration, requests dynamic ID allocation. |
205 | * DEPRECATION: providing anything non-negative and nailing the base | 201 | * DEPRECATION: providing anything non-negative and nailing the base |
@@ -307,7 +303,7 @@ struct gpio_chip { | |||
307 | spinlock_t bgpio_lock; | 303 | spinlock_t bgpio_lock; |
308 | unsigned long bgpio_data; | 304 | unsigned long bgpio_data; |
309 | unsigned long bgpio_dir; | 305 | unsigned long bgpio_dir; |
310 | #endif | 306 | #endif /* CONFIG_GPIO_GENERIC */ |
311 | 307 | ||
312 | #ifdef CONFIG_GPIOLIB_IRQCHIP | 308 | #ifdef CONFIG_GPIOLIB_IRQCHIP |
313 | /* | 309 | /* |
@@ -322,7 +318,7 @@ struct gpio_chip { | |||
322 | * used to handle IRQs for most practical cases. | 318 | * used to handle IRQs for most practical cases. |
323 | */ | 319 | */ |
324 | struct gpio_irq_chip irq; | 320 | struct gpio_irq_chip irq; |
325 | #endif | 321 | #endif /* CONFIG_GPIOLIB_IRQCHIP */ |
326 | 322 | ||
327 | /** | 323 | /** |
328 | * @need_valid_mask: | 324 | * @need_valid_mask: |
@@ -369,7 +365,7 @@ struct gpio_chip { | |||
369 | */ | 365 | */ |
370 | int (*of_xlate)(struct gpio_chip *gc, | 366 | int (*of_xlate)(struct gpio_chip *gc, |
371 | const struct of_phandle_args *gpiospec, u32 *flags); | 367 | const struct of_phandle_args *gpiospec, u32 *flags); |
372 | #endif | 368 | #endif /* CONFIG_OF_GPIO */ |
373 | }; | 369 | }; |
374 | 370 | ||
375 | extern const char *gpiochip_is_requested(struct gpio_chip *chip, | 371 | 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, | |||
412 | }) | 408 | }) |
413 | #else | 409 | #else |
414 | #define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL, NULL) | 410 | #define gpiochip_add_data(chip, data) gpiochip_add_data_with_key(chip, data, NULL, NULL) |
415 | #endif | 411 | #endif /* CONFIG_LOCKDEP */ |
416 | 412 | ||
417 | static inline int gpiochip_add(struct gpio_chip *chip) | 413 | static inline int gpiochip_add(struct gpio_chip *chip) |
418 | { | 414 | { |
@@ -467,7 +463,7 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev, | |||
467 | #define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */ | 463 | #define BGPIOF_READ_OUTPUT_REG_SET BIT(4) /* reg_set stores output value */ |
468 | #define BGPIOF_NO_OUTPUT BIT(5) /* only input */ | 464 | #define BGPIOF_NO_OUTPUT BIT(5) /* only input */ |
469 | 465 | ||
470 | #endif | 466 | #endif /* CONFIG_GPIO_GENERIC */ |
471 | 467 | ||
472 | #ifdef CONFIG_GPIOLIB_IRQCHIP | 468 | #ifdef CONFIG_GPIOLIB_IRQCHIP |
473 | 469 | ||
@@ -537,7 +533,7 @@ static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, | |||
537 | handler, type, true, | 533 | handler, type, true, |
538 | &lock_key, &request_key); | 534 | &lock_key, &request_key); |
539 | } | 535 | } |
540 | #else | 536 | #else /* ! CONFIG_LOCKDEP */ |
541 | static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip, | 537 | static inline int gpiochip_irqchip_add(struct gpio_chip *gpiochip, |
542 | struct irq_chip *irqchip, | 538 | struct irq_chip *irqchip, |
543 | unsigned int first_irq, | 539 | unsigned int first_irq, |
@@ -588,7 +584,7 @@ int gpiochip_add_pingroup_range(struct gpio_chip *chip, | |||
588 | unsigned int gpio_offset, const char *pin_group); | 584 | unsigned int gpio_offset, const char *pin_group); |
589 | void gpiochip_remove_pin_ranges(struct gpio_chip *chip); | 585 | void gpiochip_remove_pin_ranges(struct gpio_chip *chip); |
590 | 586 | ||
591 | #else | 587 | #else /* ! CONFIG_PINCTRL */ |
592 | 588 | ||
593 | static inline int | 589 | static inline int |
594 | gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, | 590 | gpiochip_add_pin_range(struct gpio_chip *chip, const char *pinctl_name, |
@@ -614,7 +610,8 @@ gpiochip_remove_pin_ranges(struct gpio_chip *chip) | |||
614 | 610 | ||
615 | struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, | 611 | struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *chip, u16 hwnum, |
616 | const char *label, | 612 | const char *label, |
617 | enum gpiod_flags flags); | 613 | enum gpio_lookup_flags lflags, |
614 | enum gpiod_flags dflags); | ||
618 | void gpiochip_free_own_desc(struct gpio_desc *desc); | 615 | void gpiochip_free_own_desc(struct gpio_desc *desc); |
619 | 616 | ||
620 | void devprop_gpiochip_set_names(struct gpio_chip *chip, | 617 | 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, | |||
11 | 11 | ||
12 | int gpio_reg_resume(struct gpio_chip *gc); | 12 | int gpio_reg_resume(struct gpio_chip *gc); |
13 | 13 | ||
14 | #endif | 14 | #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); | |||
97 | void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n); | 97 | void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n); |
98 | void gpiod_remove_lookup_table(struct gpiod_lookup_table *table); | 98 | void gpiod_remove_lookup_table(struct gpiod_lookup_table *table); |
99 | void gpiod_add_hogs(struct gpiod_hog *hogs); | 99 | void gpiod_add_hogs(struct gpiod_hog *hogs); |
100 | #else | 100 | #else /* ! CONFIG_GPIOLIB */ |
101 | static inline | 101 | static inline |
102 | void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {} | 102 | void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {} |
103 | static inline | 103 | static inline |
@@ -105,6 +105,6 @@ void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {} | |||
105 | static inline | 105 | static inline |
106 | void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {} | 106 | void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {} |
107 | static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {} | 107 | static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {} |
108 | #endif | 108 | #endif /* CONFIG_GPIOLIB */ |
109 | 109 | ||
110 | #endif /* __LINUX_GPIO_MACHINE_H */ | 110 | #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 { | |||
186 | bool is_mpuio; /* whether the bank is of type MPUIO */ | 186 | bool is_mpuio; /* whether the bank is of type MPUIO */ |
187 | u32 non_wakeup_gpios; | 187 | u32 non_wakeup_gpios; |
188 | 188 | ||
189 | struct omap_gpio_reg_offs *regs; | 189 | const struct omap_gpio_reg_offs *regs; |
190 | 190 | ||
191 | /* Return context loss count due to PM states changing */ | 191 | /* Return context loss count due to PM states changing */ |
192 | int (*get_context_loss_count)(struct device *dev); | 192 | 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) | |||
72 | { | 72 | { |
73 | return driver_unregister(&sdriver->driver); | 73 | return driver_unregister(&sdriver->driver); |
74 | } | 74 | } |
75 | |||
76 | /* | ||
77 | * module_siox_driver() - Helper macro for drivers that don't do | ||
78 | * anything special in module init/exit. This eliminates a lot of | ||
79 | * boilerplate. Each module may only use this macro once, and | ||
80 | * calling it replaces module_init() and module_exit() | ||
81 | */ | ||
82 | #define module_siox_driver(__siox_driver) \ | ||
83 | module_driver(__siox_driver, siox_driver_register, \ | ||
84 | siox_driver_unregister) | ||
diff --git a/tools/gpio/.gitignore b/tools/gpio/.gitignore index 9e9dd4b681b2..a94c0e83b209 100644 --- a/tools/gpio/.gitignore +++ b/tools/gpio/.gitignore | |||
@@ -1,4 +1,4 @@ | |||
1 | gpio-event-mon | 1 | gpio-event-mon |
2 | gpio-hammer | 2 | gpio-hammer |
3 | lsgpio | 3 | lsgpio |
4 | 4 | include/linux/gpio.h | |