* [U-Boot] [PATCH] gpio: dwapb_gpio: Add reset ctrl to driver
2018-08-15 18:05 [U-Boot] [PATCH] gpio: dwapb_gpio: Add reset ctrl to driver Ley Foon Tan
@ 2018-08-15 10:11 ` Marek Vasut
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr() Ley Foon Tan
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Enable get_function support Ley Foon Tan
2 siblings, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2018-08-15 10:11 UTC (permalink / raw)
To: u-boot
On 08/15/2018 08:05 PM, Ley Foon Tan wrote:
> 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 <ley.foon.tan@intel.com>
> ---
> drivers/gpio/dwapb_gpio.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> index 3b5c181..e2b6e69 100644
> --- a/drivers/gpio/dwapb_gpio.c
> +++ b/drivers/gpio/dwapb_gpio.c
> @@ -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);
This should be done in probe, not bind. Also, it should be undone in
.remove.
> base = dev_read_addr(dev);
> if (base == FDT_ADDR_T_NONE) {
> debug("Can't get the GPIO register base address\n");
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr()
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr() Ley Foon Tan
@ 2018-08-15 10:11 ` Marek Vasut
2018-09-04 8:14 ` Ley Foon Tan
2018-09-04 8:31 ` Marek Vasut
1 sibling, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2018-08-15 10:11 UTC (permalink / raw)
To: u-boot
On 08/15/2018 08:05 PM, Ley Foon Tan wrote:
> 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 <ley.foon.tan@intel.com>
Acked-by: Marek Vasut <marex@denx.de>
> ---
> drivers/gpio/dwapb_gpio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> index a118f58..680b11a 100644
> --- a/drivers/gpio/dwapb_gpio.c
> +++ b/drivers/gpio/dwapb_gpio.c
> @@ -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;
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] gpio: dwapb_gpio: Enable get_function support
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Enable get_function support Ley Foon Tan
@ 2018-08-15 10:12 ` Marek Vasut
2018-08-15 10:30 ` Ley Foon Tan
0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2018-08-15 10:12 UTC (permalink / raw)
To: u-boot
On 08/15/2018 08:05 PM, Ley Foon Tan wrote:
> Enabled get_function support for dwapb where the function will
> return the state of GPIO port.
>
> Signed-off-by: Chin Liang See <chin.liang.see@intel.com>
> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
> drivers/gpio/dwapb_gpio.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> index 680b11a..3b5c181 100644
> --- a/drivers/gpio/dwapb_gpio.c
> +++ b/drivers/gpio/dwapb_gpio.c
> @@ -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)
if (gpio & BIT(offset)) ?
> + 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)
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] gpio: dwapb_gpio: Enable get_function support
2018-08-15 10:12 ` Marek Vasut
@ 2018-08-15 10:30 ` Ley Foon Tan
0 siblings, 0 replies; 9+ messages in thread
From: Ley Foon Tan @ 2018-08-15 10:30 UTC (permalink / raw)
To: u-boot
On Wed, Aug 15, 2018 at 6:12 PM, Marek Vasut <marex@denx.de> wrote:
> On 08/15/2018 08:05 PM, Ley Foon Tan wrote:
>> Enabled get_function support for dwapb where the function will
>> return the state of GPIO port.
>>
>> Signed-off-by: Chin Liang See <chin.liang.see@intel.com>
>> Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
>> ---
>> drivers/gpio/dwapb_gpio.c | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
>> index 680b11a..3b5c181 100644
>> --- a/drivers/gpio/dwapb_gpio.c
>> +++ b/drivers/gpio/dwapb_gpio.c
>> @@ -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)
>
> if (gpio & BIT(offset)) ?
Will change this.
>
>> + 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)
>>
>
>
Regards
Ley Foon
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] gpio: dwapb_gpio: Add reset ctrl to driver
@ 2018-08-15 18:05 Ley Foon Tan
2018-08-15 10:11 ` Marek Vasut
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Ley Foon Tan @ 2018-08-15 18:05 UTC (permalink / raw)
To: u-boot
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 <ley.foon.tan@intel.com>
---
drivers/gpio/dwapb_gpio.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 3b5c181..e2b6e69 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -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");
--
2.2.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr()
2018-08-15 18:05 [U-Boot] [PATCH] gpio: dwapb_gpio: Add reset ctrl to driver Ley Foon Tan
2018-08-15 10:11 ` Marek Vasut
@ 2018-08-15 18:05 ` Ley Foon Tan
2018-08-15 10:11 ` Marek Vasut
2018-09-04 8:31 ` Marek Vasut
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Enable get_function support Ley Foon Tan
2 siblings, 2 replies; 9+ messages in thread
From: Ley Foon Tan @ 2018-08-15 18:05 UTC (permalink / raw)
To: u-boot
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 <ley.foon.tan@intel.com>
---
drivers/gpio/dwapb_gpio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index a118f58..680b11a 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -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;
--
2.2.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] gpio: dwapb_gpio: Enable get_function support
2018-08-15 18:05 [U-Boot] [PATCH] gpio: dwapb_gpio: Add reset ctrl to driver Ley Foon Tan
2018-08-15 10:11 ` Marek Vasut
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr() Ley Foon Tan
@ 2018-08-15 18:05 ` Ley Foon Tan
2018-08-15 10:12 ` Marek Vasut
2 siblings, 1 reply; 9+ messages in thread
From: Ley Foon Tan @ 2018-08-15 18:05 UTC (permalink / raw)
To: u-boot
Enabled get_function support for dwapb where the function will
return the state of GPIO port.
Signed-off-by: Chin Liang See <chin.liang.see@intel.com>
Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
---
drivers/gpio/dwapb_gpio.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
index 680b11a..3b5c181 100644
--- a/drivers/gpio/dwapb_gpio.c
+++ b/drivers/gpio/dwapb_gpio.c
@@ -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)
--
2.2.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr()
2018-08-15 10:11 ` Marek Vasut
@ 2018-09-04 8:14 ` Ley Foon Tan
0 siblings, 0 replies; 9+ messages in thread
From: Ley Foon Tan @ 2018-09-04 8:14 UTC (permalink / raw)
To: u-boot
On Wed, Aug 15, 2018 at 6:14 PM Marek Vasut <marex@denx.de> wrote:
>
> On 08/15/2018 08:05 PM, Ley Foon Tan wrote:
> > 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 <ley.foon.tan@intel.com>
>
> Acked-by: Marek Vasut <marex@denx.de>
>
> > ---
> > drivers/gpio/dwapb_gpio.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> > index a118f58..680b11a 100644
> > --- a/drivers/gpio/dwapb_gpio.c
> > +++ b/drivers/gpio/dwapb_gpio.c
> > @@ -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;
> >
>
>
> --
Hi Marek
Do you merge this patch too?
Regards
Ley Foon
^ permalink raw reply [flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr()
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr() Ley Foon Tan
2018-08-15 10:11 ` Marek Vasut
@ 2018-09-04 8:31 ` Marek Vasut
1 sibling, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2018-09-04 8:31 UTC (permalink / raw)
To: u-boot
On 08/15/2018 08:05 PM, Ley Foon Tan wrote:
> 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 <ley.foon.tan@intel.com>
> ---
> drivers/gpio/dwapb_gpio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/dwapb_gpio.c b/drivers/gpio/dwapb_gpio.c
> index a118f58..680b11a 100644
> --- a/drivers/gpio/dwapb_gpio.c
> +++ b/drivers/gpio/dwapb_gpio.c
> @@ -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.
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2018-09-04 8:31 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-15 18:05 [U-Boot] [PATCH] gpio: dwapb_gpio: Add reset ctrl to driver Ley Foon Tan
2018-08-15 10:11 ` Marek Vasut
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Change to use dev_read_addr() Ley Foon Tan
2018-08-15 10:11 ` Marek Vasut
2018-09-04 8:14 ` Ley Foon Tan
2018-09-04 8:31 ` Marek Vasut
2018-08-15 18:05 ` [U-Boot] [PATCH] gpio: dwapb_gpio: Enable get_function support Ley Foon Tan
2018-08-15 10:12 ` Marek Vasut
2018-08-15 10:30 ` Ley Foon Tan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.