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

Sagar Shrikant Kadam sagar.kadam at sifive.com
Tue Oct 1 17:00:45 UTC 2019


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_v4 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:
# Show status of all gpio's
# Pin description will shown pins as unused/output/input.
=> gpio status -a	
Bank gpio at 10060000_:
gpio at 10060000_0: unused: 0 [ ]
gpio at 10060000_1: unused: 0 [ ]
...............................
...............................
...............................
gpio at 10060000_15: unused: 0 [ ]

#Show status of pin 0
=> gpio status gpio at 10060000_0	
Bank gpio at 10060000_:
gpio at 10060000_0: unused: 0 [ ]

#Set GPIO1 high. 
=>gpio set 1
=> gpio status gpio at 10060000_1
Bank gpio at 10060000_:
gpio at 10060000_1: output: 1 [ ]

#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
#16 is not a valid GPIO number for FU540-C000 so return error.
=>gpio set 16
  GPIO: '16' not found
  Command 'gpio' failed: Error -22

Patch history:
v2:
-Added get_function handler which is used by "gpio status" command.
-Incorporated review comments on v1 patch series.
-Updated driver testing information.

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: sifive: 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                       |   7 ++
 drivers/gpio/Makefile                      |   1 +
 drivers/gpio/sifive-gpio.c                 | 177 +++++++++++++++++++++++++++++
 6 files changed, 229 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



More information about the U-Boot mailing list