Re: [U-Boot] [U-BOOT PATCH v1 0/2] add gpio support for HiFive Unleashed A00 board.

2019-09-25 Thread Sagar Kadam
Hi Bin,

On Thu, Sep 26, 2019 at 7:26 AM Bin Meng  wrote:
>
> Hi Sagar,
>
> On Thu, Sep 26, 2019 at 1:54 AM Sagar Kadam  wrote:
> >
> > Hi Bin,
> >
> > On Wed, Sep 18, 2019 at 1:23 PM Bin Meng  wrote:
> > >
> > > Hi Sagar,
> > >
> > > On Tue, Sep 10, 2019 at 11:44 PM Sagar Shrikant Kadam
> > >  wrote:
> > > >
> > > > U-Boot currently is missing GPIO support for FU540-C000 SoC which is
> > > > mounted on HiFive Unleashed A00 board. This patch is intended to add DM
> > > > based GPIO controller driver in order to access GPIO pins within the SoC
> > > > using GPIO command in U-Boot. More details on the GPIO controller within
> > > > the SoC can be found at[1]
> > > >
> > > > The driver is based above master branch of u-boot-riscv.git and 
> > > > provides a
> > > > method to configure Input/Output mode of the GPIO pin along with an 
> > > > option
> > > > to set or clear state of the GPIO pin. The patch is available in
> > > > dev/sagark/gpio_v3 branch here[2].
> > > >
> > > > GPIO device node added to the mainline bound device tree for HiFive
> > > > Unleashed is available in dev/sagark/mlv5.3-rc5 branch of repo here[3].
> > > >
> > > > This implementation is ported from linux driver submitted for review
> > > > at [4].
> > > >
> > > > More details of GPIO pin routing on J1 header is available in schematic
> > > > document[5]
> > > >
> > > > [1] https://static.dev.sifive.com/FU540-C000-v1.0.pdf
> > > > [2] https://github.com/sagsifive/u-boot
> > > > [3] https://github.com/sagsifive/riscv-linux-hifive/
> > > > [4] https://lkml.org/lkml/2018/10/9/1103
> > > > [5] 
> > > > https://static.dev.sifive.com/dev-kits/hifive-unleashed/hifive-unleashed-a00-schematics.pdf
> > > >
> > > > Driver Testing:
> > > > #Set GPIO1 high.
> > > > =>gpio set 1
> > > >   Can be confirmed by probing pin No #24 on J1 Header or memory dump of
> > > >   gpio register space viz: #md 0x1006
> > > >
> > > > #Set GPIO1 low
> > > > =>gpio clear 0
> > > >
> > > > #Toggle GPIO1
> > > > =>gpio toggle 1 #Toggle value of GPIO1
> > > > =>gpio toggle 1 #Toggle value of GPIO1
> > > >
> > > > #Configure pin as input
> > > > =>gpio input 3  #Configure gpio line 3 as input.
> > > >
> > > > #Error check
> > > > =>gpio set 16   #Not a valid GPIO number for FU540-C000
> > > >   GPIO: '16' not found
> > > >   Command 'gpio' failed: Error -22
> > > >
> > >
> > > I tested this:
> > >
> > > => gpio status -a
> > > Bank gpio@1006:
> > > gpio@10060: unknown
> > > gpio@10061: unknown
> > > gpio@10062: unknown
> > > gpio@10063: unknown
> > > gpio@10064: unknown
> > > gpio@10065: unknown
> > > gpio@10066: unknown
> > > gpio@10067: unknown
> > > gpio@10068: unknown
> > > gpio@10069: unknown
> > > gpio@100610: unknown
> > > gpio@100611: unknown
> > > gpio@100612: unknown
> > > gpio@100613: unknown
> > > gpio@100614: unknown
> > > gpio@100615: unknown
> > >
> > > The status is "unknown" for all gpio pins, which is wrong. It should
> > > be either input or output.
> >
> > Thank you for your suggestions.
> > The get_function operation is missing for this driver and so the
> > status is unknown.
> > I will implement it and send a revised version. Thanks for catching this.
> > Please correct me if I am wrong, what I do see is that the gpio command
> > uses the bank name appended before the GPIO number. So the bank_name
> > as assigned in the driver probe function gets prefixed to the pin number and
> > so it shows:
> > gpio@10060
> > gpio@10061
> > and so on.
> > I see that few driver's updates the uc_priv->bank_name in probe function
> > with '_' as the separator between bank_name and pin number and so
> > #gpio status -a will show it as :
> >
> > Bank :
> > _0: input : 1 []
> > _1: input : 1 []
> >  and so on
> >
> > eg: In the current case here it will show as
> > Bank gpio@1006_:
> > gpio@1006_0
> > gpio@1006_1 and so on.
> >
> > Please let me know if this implementation is ok.
> > >
> > > Also the gpio pin name is weird. I think we should use "0, 1, 2 ..."
> > >
> > The current implementation of the gpio_get_status function includes
> > the base_name
> > to the pin description. Truncating it here can help to get pin numbers
> > as just numbers
> > "0,1,2". I will also include this if needed?
> >
>
> I think _0 is fine. Thanks!
>
Thanks, I will roll out the next patch with necessary changes.

BR,
Sagar
> Regards,
> Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-BOOT PATCH v1 0/2] add gpio support for HiFive Unleashed A00 board.

2019-09-25 Thread Bin Meng
Hi Sagar,

On Thu, Sep 26, 2019 at 1:54 AM Sagar Kadam  wrote:
>
> Hi Bin,
>
> On Wed, Sep 18, 2019 at 1:23 PM Bin Meng  wrote:
> >
> > Hi Sagar,
> >
> > On Tue, Sep 10, 2019 at 11:44 PM Sagar Shrikant Kadam
> >  wrote:
> > >
> > > U-Boot currently is missing GPIO support for FU540-C000 SoC which is
> > > mounted on HiFive Unleashed A00 board. This patch is intended to add DM
> > > based GPIO controller driver in order to access GPIO pins within the SoC
> > > using GPIO command in U-Boot. More details on the GPIO controller within
> > > the SoC can be found at[1]
> > >
> > > The driver is based above master branch of u-boot-riscv.git and provides a
> > > method to configure Input/Output mode of the GPIO pin along with an option
> > > to set or clear state of the GPIO pin. The patch is available in
> > > dev/sagark/gpio_v3 branch here[2].
> > >
> > > GPIO device node added to the mainline bound device tree for HiFive
> > > Unleashed is available in dev/sagark/mlv5.3-rc5 branch of repo here[3].
> > >
> > > This implementation is ported from linux driver submitted for review
> > > at [4].
> > >
> > > More details of GPIO pin routing on J1 header is available in schematic
> > > document[5]
> > >
> > > [1] https://static.dev.sifive.com/FU540-C000-v1.0.pdf
> > > [2] https://github.com/sagsifive/u-boot
> > > [3] https://github.com/sagsifive/riscv-linux-hifive/
> > > [4] https://lkml.org/lkml/2018/10/9/1103
> > > [5] 
> > > https://static.dev.sifive.com/dev-kits/hifive-unleashed/hifive-unleashed-a00-schematics.pdf
> > >
> > > Driver Testing:
> > > #Set GPIO1 high.
> > > =>gpio set 1
> > >   Can be confirmed by probing pin No #24 on J1 Header or memory dump of
> > >   gpio register space viz: #md 0x1006
> > >
> > > #Set GPIO1 low
> > > =>gpio clear 0
> > >
> > > #Toggle GPIO1
> > > =>gpio toggle 1 #Toggle value of GPIO1
> > > =>gpio toggle 1 #Toggle value of GPIO1
> > >
> > > #Configure pin as input
> > > =>gpio input 3  #Configure gpio line 3 as input.
> > >
> > > #Error check
> > > =>gpio set 16   #Not a valid GPIO number for FU540-C000
> > >   GPIO: '16' not found
> > >   Command 'gpio' failed: Error -22
> > >
> >
> > I tested this:
> >
> > => gpio status -a
> > Bank gpio@1006:
> > gpio@10060: unknown
> > gpio@10061: unknown
> > gpio@10062: unknown
> > gpio@10063: unknown
> > gpio@10064: unknown
> > gpio@10065: unknown
> > gpio@10066: unknown
> > gpio@10067: unknown
> > gpio@10068: unknown
> > gpio@10069: unknown
> > gpio@100610: unknown
> > gpio@100611: unknown
> > gpio@100612: unknown
> > gpio@100613: unknown
> > gpio@100614: unknown
> > gpio@100615: unknown
> >
> > The status is "unknown" for all gpio pins, which is wrong. It should
> > be either input or output.
>
> Thank you for your suggestions.
> The get_function operation is missing for this driver and so the
> status is unknown.
> I will implement it and send a revised version. Thanks for catching this.
> Please correct me if I am wrong, what I do see is that the gpio command
> uses the bank name appended before the GPIO number. So the bank_name
> as assigned in the driver probe function gets prefixed to the pin number and
> so it shows:
> gpio@10060
> gpio@10061
> and so on.
> I see that few driver's updates the uc_priv->bank_name in probe function
> with '_' as the separator between bank_name and pin number and so
> #gpio status -a will show it as :
>
> Bank :
> _0: input : 1 []
> _1: input : 1 []
>  and so on
>
> eg: In the current case here it will show as
> Bank gpio@1006_:
> gpio@1006_0
> gpio@1006_1 and so on.
>
> Please let me know if this implementation is ok.
> >
> > Also the gpio pin name is weird. I think we should use "0, 1, 2 ..."
> >
> The current implementation of the gpio_get_status function includes
> the base_name
> to the pin description. Truncating it here can help to get pin numbers
> as just numbers
> "0,1,2". I will also include this if needed?
>

I think _0 is fine. Thanks!

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-BOOT PATCH v1 0/2] add gpio support for HiFive Unleashed A00 board.

2019-09-25 Thread Sagar Kadam
Hi Bin,

On Wed, Sep 18, 2019 at 1:23 PM Bin Meng  wrote:
>
> Hi Sagar,
>
> On Tue, Sep 10, 2019 at 11:44 PM Sagar Shrikant Kadam
>  wrote:
> >
> > U-Boot currently is missing GPIO support for FU540-C000 SoC which is
> > mounted on HiFive Unleashed A00 board. This patch is intended to add DM
> > based GPIO controller driver in order to access GPIO pins within the SoC
> > using GPIO command in U-Boot. More details on the GPIO controller within
> > the SoC can be found at[1]
> >
> > The driver is based above master branch of u-boot-riscv.git and provides a
> > method to configure Input/Output mode of the GPIO pin along with an option
> > to set or clear state of the GPIO pin. The patch is available in
> > dev/sagark/gpio_v3 branch here[2].
> >
> > GPIO device node added to the mainline bound device tree for HiFive
> > Unleashed is available in dev/sagark/mlv5.3-rc5 branch of repo here[3].
> >
> > This implementation is ported from linux driver submitted for review
> > at [4].
> >
> > More details of GPIO pin routing on J1 header is available in schematic
> > document[5]
> >
> > [1] https://static.dev.sifive.com/FU540-C000-v1.0.pdf
> > [2] https://github.com/sagsifive/u-boot
> > [3] https://github.com/sagsifive/riscv-linux-hifive/
> > [4] https://lkml.org/lkml/2018/10/9/1103
> > [5] 
> > https://static.dev.sifive.com/dev-kits/hifive-unleashed/hifive-unleashed-a00-schematics.pdf
> >
> > Driver Testing:
> > #Set GPIO1 high.
> > =>gpio set 1
> >   Can be confirmed by probing pin No #24 on J1 Header or memory dump of
> >   gpio register space viz: #md 0x1006
> >
> > #Set GPIO1 low
> > =>gpio clear 0
> >
> > #Toggle GPIO1
> > =>gpio toggle 1 #Toggle value of GPIO1
> > =>gpio toggle 1 #Toggle value of GPIO1
> >
> > #Configure pin as input
> > =>gpio input 3  #Configure gpio line 3 as input.
> >
> > #Error check
> > =>gpio set 16   #Not a valid GPIO number for FU540-C000
> >   GPIO: '16' not found
> >   Command 'gpio' failed: Error -22
> >
>
> I tested this:
>
> => gpio status -a
> Bank gpio@1006:
> gpio@10060: unknown
> gpio@10061: unknown
> gpio@10062: unknown
> gpio@10063: unknown
> gpio@10064: unknown
> gpio@10065: unknown
> gpio@10066: unknown
> gpio@10067: unknown
> gpio@10068: unknown
> gpio@10069: unknown
> gpio@100610: unknown
> gpio@100611: unknown
> gpio@100612: unknown
> gpio@100613: unknown
> gpio@100614: unknown
> gpio@100615: unknown
>
> The status is "unknown" for all gpio pins, which is wrong. It should
> be either input or output.

Thank you for your suggestions.
The get_function operation is missing for this driver and so the
status is unknown.
I will implement it and send a revised version. Thanks for catching this.
Please correct me if I am wrong, what I do see is that the gpio command
uses the bank name appended before the GPIO number. So the bank_name
as assigned in the driver probe function gets prefixed to the pin number and
so it shows:
gpio@10060
gpio@10061
and so on.
I see that few driver's updates the uc_priv->bank_name in probe function
with '_' as the separator between bank_name and pin number and so
#gpio status -a will show it as :

Bank :
_0: input : 1 []
_1: input : 1 []
 and so on

eg: In the current case here it will show as
Bank gpio@1006_:
gpio@1006_0
gpio@1006_1 and so on.

Please let me know if this implementation is ok.
>
> Also the gpio pin name is weird. I think we should use "0, 1, 2 ..."
>
The current implementation of the gpio_get_status function includes
the base_name
to the pin description. Truncating it here can help to get pin numbers
as just numbers
"0,1,2". I will also include this if needed?

Thanks & BR,
Sagar Kadam

> Regards,
> Bin
>
> Regards,
> Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-BOOT PATCH v1 0/2] add gpio support for HiFive Unleashed A00 board.

2019-09-18 Thread Bin Meng
Hi Sagar,

On Tue, Sep 10, 2019 at 11:44 PM Sagar Shrikant Kadam
 wrote:
>
> U-Boot currently is missing GPIO support for FU540-C000 SoC which is
> mounted on HiFive Unleashed A00 board. This patch is intended to add DM
> based GPIO controller driver in order to access GPIO pins within the SoC
> using GPIO command in U-Boot. More details on the GPIO controller within
> the SoC can be found at[1]
>
> The driver is based above master branch of u-boot-riscv.git and provides a
> method to configure Input/Output mode of the GPIO pin along with an option
> to set or clear state of the GPIO pin. The patch is available in
> dev/sagark/gpio_v3 branch here[2].
>
> GPIO device node added to the mainline bound device tree for HiFive
> Unleashed is available in dev/sagark/mlv5.3-rc5 branch of repo here[3].
>
> This implementation is ported from linux driver submitted for review
> at [4].
>
> More details of GPIO pin routing on J1 header is available in schematic
> document[5]
>
> [1] https://static.dev.sifive.com/FU540-C000-v1.0.pdf
> [2] https://github.com/sagsifive/u-boot
> [3] https://github.com/sagsifive/riscv-linux-hifive/
> [4] https://lkml.org/lkml/2018/10/9/1103
> [5] 
> https://static.dev.sifive.com/dev-kits/hifive-unleashed/hifive-unleashed-a00-schematics.pdf
>
> Driver Testing:
> #Set GPIO1 high.
> =>gpio set 1
>   Can be confirmed by probing pin No #24 on J1 Header or memory dump of
>   gpio register space viz: #md 0x1006
>
> #Set GPIO1 low
> =>gpio clear 0
>
> #Toggle GPIO1
> =>gpio toggle 1 #Toggle value of GPIO1
> =>gpio toggle 1 #Toggle value of GPIO1
>
> #Configure pin as input
> =>gpio input 3  #Configure gpio line 3 as input.
>
> #Error check
> =>gpio set 16   #Not a valid GPIO number for FU540-C000
>   GPIO: '16' not found
>   Command 'gpio' failed: Error -22
>

I tested this:

=> gpio status -a
Bank gpio@1006:
gpio@10060: unknown
gpio@10061: unknown
gpio@10062: unknown
gpio@10063: unknown
gpio@10064: unknown
gpio@10065: unknown
gpio@10066: unknown
gpio@10067: unknown
gpio@10068: unknown
gpio@10069: unknown
gpio@100610: unknown
gpio@100611: unknown
gpio@100612: unknown
gpio@100613: unknown
gpio@100614: unknown
gpio@100615: unknown

The status is "unknown" for all gpio pins, which is wrong. It should
be either input or output.

Also the gpio pin name is weird. I think we should use "0, 1, 2 ..."

Regards,
Bin

Regards,
Bin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [U-BOOT PATCH v1 0/2] add gpio support for HiFive Unleashed A00 board.

2019-09-10 Thread Sagar Shrikant Kadam
U-Boot currently is missing GPIO support for FU540-C000 SoC which is
mounted on HiFive Unleashed A00 board. This patch is intended to add DM
based GPIO controller driver in order to access GPIO pins within the SoC
using GPIO command in U-Boot. More details on the GPIO controller within
the SoC can be found at[1]

The driver is based above master branch of u-boot-riscv.git and provides a
method to configure Input/Output mode of the GPIO pin along with an option
to set or clear state of the GPIO pin. The patch is available in
dev/sagark/gpio_v3 branch here[2].

GPIO device node added to the mainline bound device tree for HiFive
Unleashed is available in dev/sagark/mlv5.3-rc5 branch of repo here[3].

This implementation is ported from linux driver submitted for review
at [4]. 

More details of GPIO pin routing on J1 header is available in schematic
document[5]

[1] https://static.dev.sifive.com/FU540-C000-v1.0.pdf
[2] https://github.com/sagsifive/u-boot
[3] https://github.com/sagsifive/riscv-linux-hifive/
[4] https://lkml.org/lkml/2018/10/9/1103
[5] 
https://static.dev.sifive.com/dev-kits/hifive-unleashed/hifive-unleashed-a00-schematics.pdf

Driver Testing:
#Set GPIO1 high. 
=>gpio set 1
  Can be confirmed by probing pin No #24 on J1 Header or memory dump of 
  gpio register space viz: #md 0x1006 

#Set GPIO1 low
=>gpio clear 0

#Toggle GPIO1 
=>gpio toggle 1 #Toggle value of GPIO1  
=>gpio toggle 1 #Toggle value of GPIO1

#Configure pin as input
=>gpio input 3  #Configure gpio line 3 as input.

#Error check
=>gpio set 16   #Not a valid GPIO number for FU540-C000
  GPIO: '16' not found
  Command 'gpio' failed: Error -22

Patch history:
v1:
-Set gpio_count either from the device tree or with a MACRO if ngpio's property
 is not mentioned in device node.
-Check if gpio number passed from the command line is within the valid range.

Incorporated review comment from Bin Meng 
-Renamed driver from fu540-gpio to sifive-gpio
-Include a proper header file
-Use dev->name as bank_name.

v0: Base version


Sagar Shrikant Kadam (2):
  gpio: fu540: add support for DM based gpio driver for FU540-SoC
  configs: fu540: enable gpio driver

 arch/riscv/include/asm/arch-generic/gpio.h |  35 +++
 arch/riscv/include/asm/gpio.h  |   6 ++
 board/sifive/fu540/Kconfig |   3 +
 drivers/gpio/Kconfig   |   8 ++
 drivers/gpio/Makefile  |   1 +
 drivers/gpio/sifive-gpio.c | 143 +
 6 files changed, 196 insertions(+)
 create mode 100644 arch/riscv/include/asm/arch-generic/gpio.h
 create mode 100644 arch/riscv/include/asm/gpio.h
 create mode 100644 drivers/gpio/sifive-gpio.c

-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot