Skip to contentSkip to conversation

Add OpenCores I2C controller driver

PATCH New Pragnesh Patel 2 participants 4 messages Nov 14, 2020 – Nov 28, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover Add OpenCores I2C controller driver

This driver has been tested on HiFive Unleashed with a PMOD based RTCC sensor connected to I2C pins J1 header of the board.

This series is available here [1] for testing
[1] https://github.com/pragnesh26992/u-boot/tree/i2c

Changes in v3:
- Rebase to master and add missing #include <dm/device_compat.h>

Changes in v2:
- Remove TYPE_SIFIVE_REV0 flag
- Update the Opencores I2C Controller Link

U-Boot Logs for reference:

Hit any key to stop autoboot: 0
=> i2c dev 0
Setting bus to 0
=> i2c probe
Valid chip addresses: 57 6F
=> i2c md 0x57 0x0 1
0000: a5 .
=> i2c mw 0x57 0x0 0x5a 1
=> i2c md 0x57 0x0 1
0000: 5a Z
=> i2c md 0x57 0x2 1
0002: 99 .
=> i2c mw 0x57 0x2 0xa9 1
=> i2c md 0x57 0x2 1
0002: a9 .
=> i2c md 0x6f 0x20 1
0020: 5a Z
=> i2c md 0x6f 0x5f 1
005f: a5 .
=> i2c mw 0x6f 0x20 0xa9 1
=> i2c mw 0x6f 0x5f 0xa9 1
=> i2c md 0x6f 0x20 1
0020: a9 .
=> i2c md 0x6f 0x5f 1
005f: a9 .
=>

Pragnesh Patel (2):
i2c: ocores: add i2c driver for OpenCores I2C controller
riscv: sifive/fu540: kconfig: Enable support for Opencores I2C
controller

 arch/riscv/cpu/fu540/Kconfig |   2 +
 board/sifive/fu540/Kconfig   |   1 +
 drivers/i2c/Kconfig          |   7 +
 drivers/i2c/Makefile         |   1 +
 drivers/i2c/ocores_i2c.c     | 637 +++++++++++++++++++++++++++++++++++
 5 files changed, 648 insertions(+)
 create mode 100644 drivers/i2c/ocores_i2c.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/2 i2c: ocores: add i2c driver for OpenCores I2C controller

Add support for the OpenCores I2C controller IP core (See http://www.opencores.org/projects.cgi/web/i2c/overview).

This driver implementation is inspired from the Linux OpenCores I2C driver available.

Thanks to Peter Korsgaard <[email protected]> for writing Linux OpenCores I2C driver.

---

Changes in v3:
- Rebase to master and add missing #include <dm/device_compat.h>

Changes in v2:
- Remove TYPE_SIFIVE_REV0 flag
- Update the Opencores I2C Controller Link

 drivers/i2c/Kconfig      |   7 +
 drivers/i2c/Makefile     |   1 +
 drivers/i2c/ocores_i2c.c | 637 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 645 insertions(+)
 create mode 100644 drivers/i2c/ocores_i2c.c
drivers/i2c/Kconfig +7 -0
index 8ae54e1e93..37958083af 100644
@@ -342,6 +342,13 @@ config SYS_I2C_NEXELL
 	  have several I2C ports and all are provided, controlled by the
 	  device tree.
 
+config SYS_I2C_OCORES
+	bool "ocores I2C driver"
+	depends on DM_I2C
+	help
+	  Add support for ocores I2C controller. For details see
+	  https://opencores.org/projects/i2c
+
 config SYS_I2C_OMAP24XX
 	bool "TI OMAP2+ I2C driver"
 	depends on ARCH_OMAP2PLUS || ARCH_K3
drivers/i2c/Makefile +1 -0
index b37198036c..1aac5c481e 100644
@@ -32,6 +32,7 @@ obj-$(CONFIG_SYS_I2C_MESON) += meson_i2c.o
 obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o
 obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o
 obj-$(CONFIG_SYS_I2C_NEXELL) += nx_i2c.o
+obj-$(CONFIG_SYS_I2C_OCORES) += ocores_i2c.o
 obj-$(CONFIG_SYS_I2C_OCTEON) += octeon_i2c.o
 obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o
 obj-$(CONFIG_SYS_I2C_RCAR_I2C) += rcar_i2c.o
drivers/i2c/ocores_i2c.c new file +637 -0

637 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 2/2 riscv: sifive/fu540: kconfig: Enable support for Opencores I2C controller

In reply to Pragnesh Patel

Enable support for SiFive FU540 Opencores I2C master controller.

---

(no changes since v1)

 arch/riscv/cpu/fu540/Kconfig | 2 ++
 board/sifive/fu540/Kconfig   | 1 +
 2 files changed, 3 insertions(+)
arch/riscv/cpu/fu540/Kconfig +2 -0
index ac3f183342..61bd5c426e 100644
@@ -35,6 +35,8 @@ config SIFIVE_FU540
 	imply SIFIVE_OTP
 	imply DM_PWM
 	imply PWM_SIFIVE
+	imply DM_I2C
+	imply SYS_I2C_OCORES
 
 if ENV_IS_IN_SPI_FLASH
 
board/sifive/fu540/Kconfig +1 -0
index e70d1e53f9..64fdbd44b4 100644
@@ -47,5 +47,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply SPI_FLASH_ISSI
 	imply SYSRESET
 	imply SYSRESET_GPIO
+	imply CMD_I2C
 
 endif
Signature · 1 line
2.17.1
#3 lore raw

v3 cover Add OpenCores I2C controller driver

In reply to Pragnesh Patel

Hello Pragnesh,

Am 14.11.20 um 10:12 schrieb Pragnesh Patel:

Quoted 49 lines

This driver has been tested on HiFive Unleashed with a PMOD based RTCC sensor connected to I2C pins J1 header of the board.

This series is available here [1] for testing
[1] https://github.com/pragnesh26992/u-boot/tree/i2c

Changes in v3:
- Rebase to master and add missing #include <dm/device_compat.h>

Changes in v2:
- Remove TYPE_SIFIVE_REV0 flag
- Update the Opencores I2C Controller Link

U-Boot Logs for reference:

Hit any key to stop autoboot: 0
=> i2c dev 0
Setting bus to 0
=> i2c probe
Valid chip addresses: 57 6F
=> i2c md 0x57 0x0 1
0000: a5 .
=> i2c mw 0x57 0x0 0x5a 1
=> i2c md 0x57 0x0 1
0000: 5a Z
=> i2c md 0x57 0x2 1
0002: 99 .
=> i2c mw 0x57 0x2 0xa9 1
=> i2c md 0x57 0x2 1
0002: a9 .
=> i2c md 0x6f 0x20 1
0020: 5a Z
=> i2c md 0x6f 0x5f 1
005f: a5 .
=> i2c mw 0x6f 0x20 0xa9 1
=> i2c mw 0x6f 0x5f 0xa9 1
=> i2c md 0x6f 0x20 1
0020: a9 .
=> i2c md 0x6f 0x5f 1
005f: a9 .
=>

Pragnesh Patel (2):
i2c: ocores: add i2c driver for OpenCores I2C controller
riscv: sifive/fu540: kconfig: Enable support for Opencores I2C
controller

Quoted 7 lines
 arch/riscv/cpu/fu540/Kconfig |   2 +
 board/sifive/fu540/Kconfig   |   1 +
 drivers/i2c/Kconfig          |   7 +
 drivers/i2c/Makefile         |   1 +
 drivers/i2c/ocores_i2c.c     | 637 +++++++++++++++++++++++++++++++++++
 5 files changed, 648 insertions(+)
 create mode 100644 drivers/i2c/ocores_i2c.c

Series applied to u-boot-i2c

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de