gpio: dwapb_gpio: Add reset ctrl to driver
PATCH 1/1 gpio: dwapb_gpio: Add reset ctrl to driver
Add code to reset all reset signals as in gpio DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.
If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.
--- drivers/gpio/dwapb_gpio.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpio/dwapb_gpio.c +17 -0
@@ -15,6 +15,7 @@#include <dm/lists.h> #include <dm/root.h> #include <errno.h> +#include <reset.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -114,6 +115,20 @@ static int gpio_dwapb_probe(struct udevice *dev)return 0 ; } +static void gpio_dwapb_reset (struct udevice *dev) +{ +struct reset_ctl_bulk reset_bulk; +int ret; + + ret =reset_get_bulk (dev, &reset_bulk); +if (ret) { +dev_warn (dev,"Can't get reset: %d\n" , ret); +return ; + } + +reset_deassert_bulk (&reset_bulk); +} +static int gpio_dwapb_bind (struct udevice *dev) {struct gpio_dwapb_platdata *plat =dev_get_platdata (dev);
@@ -126,6 +141,8 @@ static int gpio_dwapb_bind(struct udevice *dev)if (plat)return 0 ; +gpio_dwapb_reset (dev); + base =dev_read_addr (dev);if (base ==FDT_ADDR_T_NONE ) {debug ("Can't get the GPIO register base address\n" );
Signature · 1 line
2.2.2
PATCH 1/1 gpio: dwapb_gpio: Add reset ctrl to driver
Quoted 46 lines · Ley Foon Tan
Add code to reset all reset signals as in gpio DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.
If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.
Signed-off-by Ley Foon Tan <[email protected]>--- drivers/gpio/dwapb_gpio.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/gpio/dwapb_gpio.c +15
-0@@ -15,6 +15,7 @@#include <dm/lists.h> #include <dm/root.h> #include <errno.h> +#include <reset.h> DECLARE_GLOBAL_DATA_PTR ;@@ -114,6 +115,20 @@ static int gpio_dwapb_probe(struct udevice *dev)return 0 ; } +static void gpio_dwapb_reset (struct udevice *dev) +{ +struct reset_ctl_bulk reset_bulk; +int ret; + + ret =reset_get_bulk (dev, &reset_bulk); +if (ret) { +dev_warn (dev,"Can't get reset: %d\n" , ret); +return ; + } + +reset_deassert_bulk (&reset_bulk); +} +static int gpio_dwapb_bind (struct udevice *dev) {struct gpio_dwapb_platdata *plat =dev_get_platdata (dev);
drivers/gpio/dwapb_gpio.c static int gpio_dwapb_bind(struct udevice *dev) · line 144
Quoted 4 lines
drivers/gpio/dwapb_gpio.c +1
-0@@ -126,6 +141,8 @@ static int gpio_dwapb_bind(struct udevice *dev)if (plat)return 0 ; +gpio_dwapb_reset (dev);
This should be done in probe, not bind. Also, it should be undone in .remove.
Quoted 4 lines
drivers/gpio/dwapb_gpio.c +0
-0base =dev_read_addr (dev);if (base ==FDT_ADDR_T_NONE ) {debug ("Can't get the GPIO register base address\n" );
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 gpio: dwapb_gpio: Change to use dev_read_addr()
In reply to Ley Foon TanThis changes the driver to use dev_read_addr() which is safe both for flat trees and live trees.
--- drivers/gpio/dwapb_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/dwapb_gpio.c +1 -1
@@ -111,7 +111,7 @@ static int gpio_dwapb_bind(struct udevice *dev)if (plat)return 0 ; - base =fdtdec_get_addr (blob,dev_of_offset (dev),"reg" ); + base =dev_read_addr (dev);if (base ==FDT_ADDR_T_NONE ) {debug ("Can't get the GPIO register base address\n" );return -ENXIO ;
Signature · 1 line
2.2.2
PATCH 1/1 gpio: dwapb_gpio: Change to use dev_read_addr()
Quoted 4 lines · Ley Foon Tan
This changes the driver to use
dev_read_addr()which is safe both for flat trees and live trees.Signed-off-by Ley Foon Tan <[email protected]>
Quoted 18 lines
--- drivers/gpio/dwapb_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpio/dwapb_gpio.c +1
-1@@ -111,7 +111,7 @@ static int gpio_dwapb_bind(struct udevice *dev)if (plat)return 0 ; - base =fdtdec_get_addr (blob,dev_of_offset (dev),"reg" ); + base =dev_read_addr (dev);if (base ==FDT_ADDR_T_NONE ) {debug ("Can't get the GPIO register base address\n" );return -ENXIO ;
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 gpio: dwapb_gpio: Change to use dev_read_addr()
Quoted 21 lines · Marek Vasut
Quoted 4 lines · Ley Foon Tan
This changes the driver to use
dev_read_addr()which is safe both for flat trees and live trees.Signed-off-by Ley Foon Tan <[email protected]>Acked-by Marek Vasut <[email protected]>Quoted 12 lines
--- drivers/gpio/dwapb_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpio/dwapb_gpio.c +0
-0@@ -111,7 +111,7 @@ static int gpio_dwapb_bind(struct udevice *dev)if (plat)return 0 ;
Quoted 9 lines
drivers/gpio/dwapb_gpio.c static int gpio_dwapb_bind(struct udevice *dev) · line 117
Quoted 6 lines
drivers/gpio/dwapb_gpio.c +1
-1- base =fdtdec_get_addr (blob,dev_of_offset (dev),"reg" ); + base =dev_read_addr (dev);if (base ==FDT_ADDR_T_NONE ) {debug ("Can't get the GPIO register base address\n" );return -ENXIO ;--
Hi Marek
Do you merge this patch too?
Regards
Ley Foon
Marek Vasut
AppliedPATCH 1/1 gpio: dwapb_gpio: Change to use dev_read_addr()
In reply to Ley Foon TanQuoted 14 lines · Ley Foon Tan
This changes the driver to use
dev_read_addr()which is safe both for flat trees and live trees.Signed-off-by Ley Foon Tan <[email protected]>--- drivers/gpio/dwapb_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpio/dwapb_gpio.c +0
-0
drivers/gpio/dwapb_gpio.c static int gpio_dwapb_bind(struct udevice *dev) · line 117
Quoted 8 lines
drivers/gpio/dwapb_gpio.c +1
-1@@ -111,7 +111,7 @@ static int gpio_dwapb_bind(struct udevice *dev)if (plat)return 0 ; - base =fdtdec_get_addr (blob,dev_of_offset (dev),"reg" ); + base =dev_read_addr (dev);if (base ==FDT_ADDR_T_NONE ) {debug ("Can't get the GPIO register base address\n" );return -ENXIO ;
Applied, thanks.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 gpio: dwapb_gpio: Enable get_function support
In reply to Ley Foon TanEnabled get_function support for dwapb where the function will return the state of GPIO port.
--- drivers/gpio/dwapb_gpio.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpio/dwapb_gpio.c +15 -0
@@ -78,11 +78,26 @@ static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val)return 0 ; } +static int dwapb_gpio_get_function (struct udevice *dev,unsigned offset) +{ +struct gpio_dwapb_platdata *plat =dev_get_platdata (dev); +int gpio; + + gpio =readl (plat->base +GPIO_SWPORT_DDR (plat->bank)); + gpio = (gpio >> offset) &1 ; + +if (gpio) +return GPIOF_OUTPUT ; +else +return GPIOF_INPUT ; +} +static const struct dm_gpio_ops gpio_dwapb_ops = { .direction_input = dwapb_gpio_direction_input, .direction_output = dwapb_gpio_direction_output, .get_value = dwapb_gpio_get_value, .set_value = dwapb_gpio_set_value, + .get_function = dwapb_gpio_get_function, };static int gpio_dwapb_probe (struct udevice *dev)
Signature · 1 line
2.2.2
PATCH 1/1 gpio: dwapb_gpio: Enable get_function support
Quoted 16 lines · Ley Foon Tan
Enabled
get_functionsupport for dwapb where the function will return the state of GPIO port.Signed-off-by Chin Liang See <[email protected]>Signed-off-by Ley Foon Tan <[email protected]>--- drivers/gpio/dwapb_gpio.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/gpio/dwapb_gpio.c +0
-0@@ -78,11 +78,26 @@ static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val)return 0 ; }
drivers/gpio/dwapb_gpio.c static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val) · line 89
Quoted 10 lines
drivers/gpio/dwapb_gpio.c +9
-0+static int dwapb_gpio_get_function (struct udevice *dev,unsigned offset) +{ +struct gpio_dwapb_platdata *plat =dev_get_platdata (dev); +int gpio; + + gpio =readl (plat->base +GPIO_SWPORT_DDR (plat->bank)); + gpio = (gpio >> offset) &1 ; + +if (gpio)
if (gpio & BIT(offset)) ?
Quoted 15 lines
drivers/gpio/dwapb_gpio.c +6
-0+return GPIOF_OUTPUT ; + else + return GPIOF_INPUT; +} +static const struct dm_gpio_ops gpio_dwapb_ops = { .direction_input = dwapb_gpio_direction_input, .direction_output = dwapb_gpio_direction_output, .get_value = dwapb_gpio_get_value, .set_value = dwapb_gpio_set_value, + .get_function = dwapb_gpio_get_function, };static int gpio_dwapb_probe (struct udevice *dev)
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 gpio: dwapb_gpio: Enable get_function support
Quoted 18 lines · Marek Vasut
Quoted 17 lines · Ley Foon Tan
Enabled
get_functionsupport for dwapb where the function will return the state of GPIO port.Signed-off-by Chin Liang See <[email protected]>Signed-off-by Ley Foon Tan <[email protected]>--- drivers/gpio/dwapb_gpio.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/gpio/dwapb_gpio.c +0
-0@@ -78,11 +78,26 @@ static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val)return 0 ; }
Quoted 11 lines
drivers/gpio/dwapb_gpio.c static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val) · line 89
Quoted 9 lines
drivers/gpio/dwapb_gpio.c +9
-0+static int dwapb_gpio_get_function (struct udevice *dev,unsigned offset) +{ +struct gpio_dwapb_platdata *plat =dev_get_platdata (dev); +int gpio; + + gpio =readl (plat->base +GPIO_SWPORT_DDR (plat->bank)); + gpio = (gpio >> offset) &1 ; + +if (gpio)if (gpio & BIT(offset)) ?
Will change this.
Quoted 14 lines
Quoted 14 lines
drivers/gpio/dwapb_gpio.c +6
-0+return GPIOF_OUTPUT ; + else + return GPIOF_INPUT; +} +static const struct dm_gpio_ops gpio_dwapb_ops = { .direction_input = dwapb_gpio_direction_input, .direction_output = dwapb_gpio_direction_output, .get_value = dwapb_gpio_get_value, .set_value = dwapb_gpio_set_value, + .get_function = dwapb_gpio_get_function, };
Quoted 4 lines
drivers/gpio/dwapb_gpio.c static int dwapb_gpio_set_value(struct udevice *dev, unsigned pin, int val) · line 103
Quoted 2 lines
drivers/gpio/dwapb_gpio.c +0
-0static int gpio_dwapb_probe (struct udevice *dev)
Regards
Ley Foon