OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 20... | Line 20... | |||
20 | +#include <linux/init.h> |
20 | +#include <linux/init.h> |
|
21 | +#include <linux/platform_device.h> |
21 | +#include <linux/platform_device.h> |
|
Line 22... | Line 22... | |||
22 | |
22 | |
|
Line 23... | Line 23... | |||
23 | #include "gpiolib.h" |
23 | #include "gpiolib.h" |
|
24 | |
24 | |
|
25 | @@ -507,3 +509,72 @@ void of_gpiochip_remove(struct gpio_chip |
25 | @@ -506,3 +508,73 @@ void of_gpiochip_remove(struct gpio_chip |
|
26 | gpiochip_remove_pin_ranges(chip); |
26 | gpiochip_remove_pin_ranges(chip); |
|
27 | of_node_put(chip->of_node); |
27 | of_node_put(chip->of_node); |
|
28 | } |
28 | } |
|
Line 32... | Line 32... | |||
32 | +static struct of_device_id gpio_export_ids[] = { |
32 | +static struct of_device_id gpio_export_ids[] = { |
|
33 | + { .compatible = "gpio-export" }, |
33 | + { .compatible = "gpio-export" }, |
|
34 | + { /* sentinel */ } |
34 | + { /* sentinel */ } |
|
35 | +}; |
35 | +}; |
|
36 | + |
36 | + |
|
37 | +static int of_gpio_export_probe(struct platform_device *pdev) |
37 | +static int __init of_gpio_export_probe(struct platform_device *pdev) |
|
38 | +{ |
38 | +{ |
|
39 | + struct device_node *np = pdev->dev.of_node; |
39 | + struct device_node *np = pdev->dev.of_node; |
|
40 | + struct device_node *cnp; |
40 | + struct device_node *cnp; |
|
41 | + u32 val; |
41 | + u32 val; |
|
42 | + int nb = 0; |
42 | + int nb = 0; |
|
Line 56... | Line 56... | |||
56 | + for (i = 0; i < max_gpio; i++) { |
56 | + for (i = 0; i < max_gpio; i++) { |
|
57 | + unsigned flags = 0; |
57 | + unsigned flags = 0; |
|
58 | + enum of_gpio_flags of_flags; |
58 | + enum of_gpio_flags of_flags; |
|
59 | + |
59 | + |
|
60 | + gpio = of_get_gpio_flags(cnp, i, &of_flags); |
60 | + gpio = of_get_gpio_flags(cnp, i, &of_flags); |
|
61 | + if (!gpio_is_valid(gpio)) |
- | ||
62 | + return gpio; |
- | ||
63 | + |
61 | + |
|
64 | + if (of_flags == OF_GPIO_ACTIVE_LOW) |
62 | + if (of_flags == OF_GPIO_ACTIVE_LOW) |
|
65 | + flags |= GPIOF_ACTIVE_LOW; |
63 | + flags |= GPIOF_ACTIVE_LOW; |
|
66 | + |
64 | + |
|
67 | + if (!of_property_read_u32(cnp, "gpio-export,output", &val)) |
65 | + if (!of_property_read_u32(cnp, "gpio-export,output", &val)) |
|
Line 87... | Line 85... | |||
87 | + .driver = { |
85 | + .driver = { |
|
88 | + .name = "gpio-export", |
86 | + .name = "gpio-export", |
|
89 | + .owner = THIS_MODULE, |
87 | + .owner = THIS_MODULE, |
|
90 | + .of_match_table = of_match_ptr(gpio_export_ids), |
88 | + .of_match_table = of_match_ptr(gpio_export_ids), |
|
91 | + }, |
89 | + }, |
|
92 | + .probe = of_gpio_export_probe, |
- | ||
93 | +}; |
90 | +}; |
|
94 | + |
91 | + |
|
- | 92 | +static int __init of_gpio_export_init(void) |
||
- | 93 | +{ |
||
- | 94 | + return platform_driver_probe(&gpio_export_driver, of_gpio_export_probe); |
||
- | 95 | +} |
||
95 | +module_platform_driver(gpio_export_driver); |
96 | +device_initcall(of_gpio_export_init); |
|
96 | + |
97 | + |
|
97 | +#endif |
98 | +#endif |
|
98 | --- a/include/asm-generic/gpio.h |
99 | --- a/include/asm-generic/gpio.h |
|
99 | +++ b/include/asm-generic/gpio.h |
100 | +++ b/include/asm-generic/gpio.h |
|
100 | @@ -127,6 +127,12 @@ static inline int gpio_export(unsigned g |
101 | @@ -127,6 +127,12 @@ static inline int gpio_export(unsigned g |