-
Notifications
You must be signed in to change notification settings - Fork 19.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23d466f
commit 927e1b6
Showing
3 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ Signed-off-by: John Crispin <[email protected]> | |
|
||
#include "gpiolib.h" | ||
#include "gpiolib-of.h" | ||
@@ -1187,3 +1189,72 @@ void of_gpiochip_remove(struct gpio_chip | ||
@@ -1187,3 +1189,73 @@ void of_gpiochip_remove(struct gpio_chip | ||
{ | ||
of_node_put(dev_of_node(&chip->gpiodev->dev)); | ||
} | ||
|
@@ -44,17 +44,19 @@ Signed-off-by: John Crispin <[email protected]> | |
+ of_property_read_string(cnp, "gpio-export,name", &name); | ||
+ | ||
+ if (!name) | ||
+ // max_gpio = of_gpio_count(cnp); | ||
+ max_gpio = of_gpio_named_count(cnp, "gpios"); | ||
+ | ||
+ for (i = 0; i < max_gpio; i++) { | ||
+ struct gpio_desc *desc; | ||
+ unsigned flags = 0; | ||
+ enum of_gpio_flags of_flags; | ||
+ | ||
+ gpio = of_get_named_gpio(cnp, i, &of_flags); | ||
+ if (!gpio_is_valid(gpio)) | ||
+ return gpio; | ||
+ desc = of_get_named_gpiod_flags(cnp, "gpios", i, &of_flags); | ||
+ if (IS_ERR(desc)) | ||
+ return PTR_ERR(desc); | ||
+ gpio = desc_to_gpio(desc); | ||
+ | ||
+ if (of_flags == OF_GPIO_ACTIVE_LOW) | ||
+ if (of_flags & OF_GPIO_ACTIVE_LOW) | ||
+ flags |= GPIOF_ACTIVE_LOW; | ||
+ | ||
+ if (!of_property_read_u32(cnp, "gpio-export,output", &val)) | ||
|
@@ -66,7 +68,7 @@ Signed-off-by: John Crispin <[email protected]> | |
+ continue; | ||
+ | ||
+ dmc = of_property_read_bool(cnp, "gpio-export,direction_may_change"); | ||
+ gpio_export_with_name(gpio, dmc, name); | ||
+ gpio_export_with_name(gpio_to_desc(gpio), dmc, name); | ||
+ nb++; | ||
+ } | ||
+ } | ||
|
@@ -79,7 +81,6 @@ Signed-off-by: John Crispin <[email protected]> | |
+static struct platform_driver gpio_export_driver = { | ||
+ .driver = { | ||
+ .name = "gpio-export", | ||
+ .owner = THIS_MODULE, | ||
+ .of_match_table = of_match_ptr(gpio_export_ids), | ||
+ }, | ||
+ .probe = of_gpio_export_probe, | ||
|
@@ -88,22 +89,24 @@ Signed-off-by: John Crispin <[email protected]> | |
+module_platform_driver(gpio_export_driver); | ||
+ | ||
+#endif | ||
\ No newline at end of file | ||
--- a/include/linux/gpio/consumer.h | ||
+++ b/include/linux/gpio/consumer.h | ||
@@ -628,6 +628,7 @@ static inline int devm_acpi_dev_add_driv | ||
@@ -628,7 +628,10 @@ static inline int devm_acpi_dev_add_driv | ||
|
||
#if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS) | ||
|
||
+int _gpiod_export(struct gpio_desc *desc, bool direction_may_change, const char *name); | ||
+int __gpiod_export(struct gpio_desc *desc, bool direction_may_change, const char *name); | ||
int gpiod_export(struct gpio_desc *desc, bool direction_may_change); | ||
+int gpio_export_with_name(struct gpio_desc *desc, bool direction_may_change, | ||
+ const char *name); | ||
int gpiod_export_link(struct device *dev, const char *name, | ||
struct gpio_desc *desc); | ||
@@ -637,6 +638,13 @@ void gpiod_unexport(struct gpio_desc *de | ||
void gpiod_unexport(struct gpio_desc *desc); | ||
@@ -637,11 +640,25 @@ void gpiod_unexport(struct gpio_desc *de | ||
|
||
#include <asm/errno.h> | ||
|
||
+static inline int _gpiod_export(struct gpio_desc *desc, | ||
+static inline int __gpiod_export(struct gpio_desc *desc, | ||
+ bool direction_may_change, | ||
+ const char *name) | ||
+{ | ||
|
@@ -113,6 +116,18 @@ Signed-off-by: John Crispin <[email protected]> | |
static inline int gpiod_export(struct gpio_desc *desc, | ||
bool direction_may_change) | ||
{ | ||
return -ENOSYS; | ||
} | ||
+ | ||
+static inline int gpio_export_with_name(struct gpio_desc *desc, | ||
+ bool direction_may_change, | ||
+ const char *name) | ||
+{ | ||
+ return -ENOSYS; | ||
+} | ||
|
||
static inline int gpiod_export_link(struct device *dev, const char *name, | ||
struct gpio_desc *desc) | ||
--- a/drivers/gpio/gpiolib-sysfs.c | ||
+++ b/drivers/gpio/gpiolib-sysfs.c | ||
@@ -571,7 +571,7 @@ static struct class gpio_class = { | ||
|
@@ -133,7 +148,7 @@ Signed-off-by: John Crispin <[email protected]> | |
|
||
dev = device_create_with_groups(&gpio_class, &gdev->dev, | ||
MKDEV(0, 0), data, gpio_groups, | ||
@@ -650,6 +652,12 @@ err_unlock: | ||
@@ -650,8 +652,21 @@ err_unlock: | ||
gpiod_dbg(desc, "%s: status %d\n", __func__, status); | ||
return status; | ||
} | ||
|
@@ -145,4 +160,13 @@ Signed-off-by: John Crispin <[email protected]> | |
+} | ||
EXPORT_SYMBOL_GPL(gpiod_export); | ||
|
||
+int gpio_export_with_name(struct gpio_desc *desc, bool direction_may_change, | ||
+ const char *name) | ||
+{ | ||
+ return __gpiod_export(desc, direction_may_change, name); | ||
+} | ||
+EXPORT_SYMBOL_GPL(gpio_export_with_name); | ||
+ | ||
static int match_export(struct device *dev, const void *desc) | ||
{ | ||
struct gpiod_data *data = dev_get_drvdata(dev); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
{ | ||
if (!nor->params->set_4byte_addr_mode) | ||
nor->params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode_en4b_ex4b; | ||
+ nor->flags |= SNOR_F_HAS_LOCK; | ||
+ nor->flags |= SNOR_F_HAS_LOCK; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ Signed-off-by: Nick Hainke <[email protected]> | |
{ | ||
if (!nor->params->set_4byte_addr_mode) | ||
nor->params->set_4byte_addr_mode = spi_nor_set_4byte_addr_mode_en4b_ex4b; | ||
+ nor->flags &= ~SNOR_F_HAS_16BIT_SR; | ||
nor->flags |= SNOR_F_HAS_LOCK; | ||
+ nor->flags &= ~SNOR_F_HAS_16BIT_SR; | ||
nor->flags |= SNOR_F_HAS_LOCK; | ||
|
||
return 0; |