Skip to contentSkip to conversation

drivers: Add FPGA register map uclass

PATCH New Mario Six 2 participants 5 messages Mar 28, 2018 – Apr 11, 2018 Char and misc drivers

lore
Share & tools
lore

Mario Six

author
#0 lore raw

PATCH 1/3 drivers: Add FPGA register map uclass

The FPGA (as a device) and the register map supplied by a FPGA are two different entities. There are U-Boot drivers for the former, but not for the later.

Add a uclass that makes it possible to read from and write to FPGA memory maps. The interface provided emulates the PCI interface, with one function for reading/writing plus a size parameter.

---
 drivers/Kconfig                  |   2 +
 drivers/Makefile                 |   1 +
 drivers/fpgamap/Kconfig          |   9 +++
 drivers/fpgamap/Makefile         |   8 +++
 drivers/fpgamap/fpgamap-uclass.c |  53 ++++++++++++++++
 include/dm/uclass-id.h           |   1 +
 include/fpgamap.h                | 131 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 205 insertions(+)
 create mode 100644 drivers/fpgamap/Kconfig
 create mode 100644 drivers/fpgamap/Makefile
 create mode 100644 drivers/fpgamap/fpgamap-uclass.c
 create mode 100644 include/fpgamap.h
drivers/Kconfig +2 -0
index c2e813f5ad..29dac7b50e 100644
@@ -32,6 +32,8 @@ source "drivers/firmware/Kconfig"
 
 source "drivers/fpga/Kconfig"
 
+source "drivers/fpgamap/Kconfig"
+
 source "drivers/gpio/Kconfig"
 
 source "drivers/i2c/Kconfig"
drivers/Makefile +1 -0
index 6846d181aa..32f0527001 100644
@@ -74,6 +74,7 @@ obj-$(CONFIG_CPU) += cpu/
 obj-y += crypto/
 obj-y += firmware/
 obj-$(CONFIG_FPGA) += fpga/
+obj-$(CONFIG_FPGAMAP) += fpgamap/
 obj-y += misc/
 obj-$(CONFIG_MMC) += mmc/
 obj-$(CONFIG_NVME) += nvme/
drivers/fpgamap/Kconfig new file +9 -0
new file mode 100644
index 0000000000..b57d31e3f7
@@ -0,0 +1,9 @@
+menuconfig FPGAMAP
+	bool "FPGA register map drivers"
+	help
+	  Support drivers to operate on memory-mapped register maps of FPGAs.
+	  Drivers are necessarily very device-dependant.
+
+	  Generic read/write operations with varying widths (8, 16, and 32 for
+	  now), as well as read/write access to named registers (defined via
+	  device tree entries) are supported
drivers/fpgamap/Makefile new file +8 -0
new file mode 100644
index 0000000000..c32efba771
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2017
+# Mario Six,  Guntermann & Drunck GmbH, mario.six at gdsys.cc
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-$(CONFIG_FPGAMAP) += fpgamap-uclass.o
drivers/fpgamap/fpgamap-uclass.c new file +53 -0

53 lines not on this page · raw message

include/dm/uclass-id.h +1 -0
index 07fabc3ce6..8c47ae9d00 100644
@@ -36,6 +36,7 @@ enum uclass_id {
 	UCLASS_DMA,		/* Direct Memory Access */
 	UCLASS_EFI,		/* EFI managed devices */
 	UCLASS_ETH,		/* Ethernet device */
+	UCLASS_FPGAMAP,		/* FPGA register maps */
 	UCLASS_GPIO,		/* Bank of general-purpose I/O pins */
 	UCLASS_FIRMWARE,	/* Firmware */
 	UCLASS_I2C,		/* I2C bus */
include/fpgamap.h new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
2.16.1
author
#1 lore raw

PATCH 2/3 fpgamap/misc: Add ihs_fpga and gdsys_soc drivers

This patch adds drivers for IHS FPGAs and their associated busses.

---
 drivers/fpgamap/Kconfig       |  11 +
 drivers/fpgamap/Makefile      |   1 +
 drivers/fpgamap/ihs_fpgamap.c | 811 ++++++++++++++++++++++++++++++++++++++++++
 drivers/misc/Kconfig          |  10 +
 drivers/misc/Makefile         |   2 +
 drivers/misc/gdsys_soc.c      |  67 ++++
 drivers/misc/gdsys_soc.h      |  24 ++
 7 files changed, 926 insertions(+)
 create mode 100644 drivers/fpgamap/ihs_fpgamap.c
 create mode 100644 drivers/misc/gdsys_soc.c
 create mode 100644 drivers/misc/gdsys_soc.h
drivers/fpgamap/Kconfig +11 -0
index b57d31e3f7..d32043ebfd 100644
@@ -7,3 +7,14 @@ menuconfig FPGAMAP
 	  Generic read/write operations with varying widths (8, 16, and 32 for
 	  now), as well as read/write access to named registers (defined via
 	  device tree entries) are supported
+
+if FPGAMAP
+
+config IHS_FPGAMAP
+	bool "Enable IHS FPGA register map driver"
+	depends on DM
+	help
+	  Support for IHS FPGA register map on a gdsys IHS FPGA used on gdsys
+	  boards.
+
+endif
drivers/fpgamap/Makefile +1 -0
index c32efba771..80153b34a0 100644
@@ -6,3 +6,4 @@
 #
 
 obj-$(CONFIG_FPGAMAP) += fpgamap-uclass.o
+obj-$(CONFIG_IHS_FPGAMAP) += ihs_fpgamap.o
drivers/fpgamap/ihs_fpgamap.c new file +811 -0

811 lines not on this page · raw message

drivers/misc/Kconfig +10 -0
index d774569cbc..b2e0cf2f83 100644
@@ -263,5 +263,15 @@ config SYS_I2C_EEPROM_ADDR_OVERFLOW
 
 endif
 
+config GDSYS_IOEP
+	bool "Enable gdsys IOEP driver"
+	depends on MISC
+	help
+	  Support gdsys FPGA's IO endpoint driver.
 
+config GDSYS_SOC
+	bool "Enable gdsys SOC driver"
+	depends on MISC
+	help
+	  Support for IHS SOC.
 endmenu
drivers/misc/Makefile +2 -0
index e8d598cd47..2e1c1021d2 100644
@@ -54,3 +54,5 @@ obj-$(CONFIG_QFW) += qfw.o
 obj-$(CONFIG_ROCKCHIP_EFUSE) += rockchip-efuse.o
 obj-$(CONFIG_STM32_RCC) += stm32_rcc.o
 obj-$(CONFIG_SYS_DPAA_QBMAN) += fsl_portals.o
+obj-$(CONFIG_GDSYS_IOEP) += gdsys_ioep.o
+obj-$(CONFIG_GDSYS_SOC) += gdsys_soc.o
drivers/misc/gdsys_soc.c new file +67 -0

67 lines not on this page · raw message

drivers/misc/gdsys_soc.h new file +24 -0
new file mode 100644
index 0000000000..0f88149fd6
@@ -0,0 +1,24 @@
+/*
+ * (C) Copyright 2017
+ * Mario Six,  Guntermann & Drunck GmbH, mario.six at gdsys.cc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _GDSYS_SOC_H_
+#define _GDSYS_SOC_H_
+
+/**
+ * gdsys_soc_get_fpga() - Retrieve pointer to parent bus' FPGA device
+ *
+ * To access their register maps, devices on gdsys soc buses usually have
+ * facilitate the accessor function of the IHS FPGA their parent bus is
+ * attached to. To access the FPGA device from within the bus' children, this
+ * function returns a pointer to it.
+ *
+ * @child:	The child device on the FPGA bus needing access to the FPGA.
+ * @fpga:	Pointer to the retrieved FPGA device.
+ * @return 0 on success, -ve on failure
+ */
+int gdsys_soc_get_fpga(struct udevice *child, struct udevice **fpga);
+#endif /* _GDSYS_SOC_H_ */

--
2.16.1

author
#2 lore raw

PATCH 3/3 cmd: Add fpgamap command

In reply to Mario Six

Add a command to debug the IHS FPGA's bus.

---
 cmd/Kconfig   |   5 +
 cmd/Makefile  |   2 +
 cmd/fpgamap.c | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 313 insertions(+)
 create mode 100644 cmd/fpgamap.c
cmd/Kconfig +5 -0
index 136836d146..b669b9d6ac 100644
@@ -976,6 +976,11 @@ config CMD_USB_MASS_STORAGE
 	help
 	  USB mass storage support
 
+config CMD_FPGAMAP
+	bool "fpgamap"
+	help
+	  Enable the command "fpgamap" to access register maps of FPGAs.
+
 endmenu
 
 
cmd/Makefile +2 -0
index 9a358e4801..6fcb89e118 100644
@@ -144,6 +144,8 @@ obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-$(CONFIG_CMD_GPT) += gpt.o
 obj-$(CONFIG_CMD_ETHSW) += ethsw.o
 
+obj-$(CONFIG_CMD_FPGAMAP) += fpgamap.o
+
 # Power
 obj-$(CONFIG_CMD_PMIC) += pmic.o
 obj-$(CONFIG_CMD_REGULATOR) += regulator.o
cmd/fpgamap.c new file +306 -0

306 lines not on this page · raw message

--
2.16.1

#3 lore raw

PATCH 1/3 drivers: Add FPGA register map uclass

In reply to Mario Six

Hi Mario,

Quoted 9 lines · Mario Six

The FPGA (as a device) and the register map supplied by a FPGA are two different entities. There are U-Boot drivers for the former, but not for the later.

Add a uclass that makes it possible to read from and write to FPGA memory maps. The interface provided emulates the PCI interface, with one function for reading/writing plus a size parameter.

Quoted 14 lines
---
 drivers/Kconfig                  |   2 +
 drivers/Makefile                 |   1 +
 drivers/fpgamap/Kconfig          |   9 +++
 drivers/fpgamap/Makefile         |   8 +++
 drivers/fpgamap/fpgamap-uclass.c |  53 ++++++++++++++++
 include/dm/uclass-id.h           |   1 +
 include/fpgamap.h                | 131 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 205 insertions(+)
 create mode 100644 drivers/fpgamap/Kconfig
 create mode 100644 drivers/fpgamap/Makefile
 create mode 100644 drivers/fpgamap/fpgamap-uclass.c
 create mode 100644 include/fpgamap.h

Could we use regmap for this? That uclass really could use being enhanced to do the things you do here.

Regards,
Simon

author
#4 lore raw

PATCH 1/3 drivers: Add FPGA register map uclass

Hi Simon,

Quoted 27 lines · Simon Glass

Hi Mario,

Quoted 9 lines · Mario Six

The FPGA (as a device) and the register map supplied by a FPGA are two different entities. There are U-Boot drivers for the former, but not for the later.

Add a uclass that makes it possible to read from and write to FPGA memory maps. The interface provided emulates the PCI interface, with one function for reading/writing plus a size parameter.

Quoted 14 lines
---
 drivers/Kconfig                  |   2 +
 drivers/Makefile                 |   1 +
 drivers/fpgamap/Kconfig          |   9 +++
 drivers/fpgamap/Makefile         |   8 +++
 drivers/fpgamap/fpgamap-uclass.c |  53 ++++++++++++++++
 include/dm/uclass-id.h           |   1 +
 include/fpgamap.h                | 131 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 205 insertions(+)
 create mode 100644 drivers/fpgamap/Kconfig
 create mode 100644 drivers/fpgamap/Makefile
 create mode 100644 drivers/fpgamap/fpgamap-uclass.c
 create mode 100644 include/fpgamap.h
Quoted 3 lines

Could we use regmap for this? That uclass really could use being enhanced to do the things you do here.

OK, that should work, I'll move the functionality over to regmap then.

Quoted 3 lines

Regards,
Simon

Best regards,

Mario