Skip to contentSkip to conversation

Add OpenCores I2C controller driver

PATCH Superseded Pragnesh Patel 3 participants 7 messages Oct 22, 2020 – Nov 14, 2020 2 messages not in the archive

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 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 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     | 636 +++++++++++++++++++++++++++++++++++
 5 files changed, 647 insertions(+)
 create mode 100644 drivers/i2c/ocores_i2c.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 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 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 | 636 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 644 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 bd248cbf52..37dc8ada6d 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 +636 -0

636 lines not on this page · raw message

Signature · 1 line
2.17.1

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

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

Quoted 22 lines

From: Pragnesh Patel [mailto:pragnesh.patel at sifive.com]
Sent: Thursday, October 22, 2020 2:55 PM
To: u-boot at lists.denx.de
Cc: atish.patra at wdc.com; palmerdabbelt at google.com; bmeng.cn at gmail.com; paul.walmsley at sifive.com; anup.patel at wdc.com; sagar.kadam at sifive.com; Rick Jian-Zhi Chen(???); peter at korsgaard.com; Pragnesh Patel; Heiko Schocher
Subject: [PATCH v2 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 v2:
- Remove TYPE_SIFIVE_REV0 flag
- Update the Opencores I2C Controller Link

Quoted 6 lines
 drivers/i2c/Kconfig      |   7 +
 drivers/i2c/Makefile     |   1 +
 drivers/i2c/ocores_i2c.c | 636 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 644 insertions(+)
 create mode 100644 drivers/i2c/ocores_i2c.c
#4 lore raw

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

Hi Pragnesh

Quoted 22 lines
Quoted 22 lines

From: Pragnesh Patel [mailto:pragnesh.patel at sifive.com]
Sent: Thursday, October 22, 2020 2:55 PM
To: u-boot at lists.denx.de
Cc: atish.patra at wdc.com; palmerdabbelt at google.com; bmeng.cn at gmail.com; paul.walmsley at sifive.com; anup.patel at wdc.com; sagar.kadam at sifive.com; Rick Jian-Zhi Chen(???); peter at korsgaard.com; Pragnesh Patel; Heiko Schocher
Subject: [PATCH v2 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 v2:
- Remove TYPE_SIFIVE_REV0 flag
- Update the Opencores I2C Controller Link

Quoted 8 lines
Quoted 6 lines
 drivers/i2c/Kconfig      |   7 +
 drivers/i2c/Makefile     |   1 +
 drivers/i2c/ocores_i2c.c | 636 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 644 insertions(+)
 create mode 100644 drivers/i2c/ocores_i2c.c

Please check the CI failure item:
https://travis-ci.org/github/rickchen36/u-boot-riscv/jobs/743114190

+drivers/i2c/ocores_i2c.c: In function 'ocores_i2c_probe':
1291+drivers/i2c/ocores_i2c.c:523:4: error: implicit declaration of function 'dev_err' [-Werror=implicit-function-declaration]

1292+  523 |    dev_err(dev,
1293+      |    ^~~~~~~
1294+drivers/i2c/ocores_i2c.c:528:4: error: implicit declaration of
function 'dev_warn' [-Werror=implicit-function-declaration]
1295+  528 |    dev_warn(dev,
1296+      |    ^~~~~~~~

1297+cc1: all warnings being treated as errors

Thanks,
Rick

#5 lore raw

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

Hi Rick,

Quoted 66 lines

-----Original Message-----
From: Rick Chen <[email protected]>
Sent: 13 November 2020 12:47
To: Pragnesh Patel <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; Atish Patra <[email protected]>; palmerdabbelt at google.com; Bin Meng <[email protected]>; Paul Walmsley ( Sifive) <[email protected]>; Anup Patel <[email protected]>; Sagar Kadam <[email protected]>; rick <[email protected]>; Alan Kao <[email protected]>; Leo Liang <[email protected]>
Subject: Re: [PATCH v2 1/2] i2c: ocores: add i2c driver for OpenCores I2C controller

[External Email] Do not click links or attachments unless you recognize the sender and know the content is safe

Hi Pragnesh

Quoted 34 lines
Quoted 26 lines

From: Pragnesh Patel [mailto:pragnesh.patel at sifive.com]
Sent: Thursday, October 22, 2020 2:55 PM
To: u-boot at lists.denx.de
Cc: atish.patra at wdc.com; palmerdabbelt at google.com; bmeng.cn at gmail.com; paul.walmsley at sifive.com; anup.patel at wdc.com; sagar.kadam at sifive.com; Rick Jian-Zhi Chen(???);
peter at korsgaard.com; Pragnesh Patel; Heiko Schocher
Subject: [PATCH v2 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 v2:
- Remove TYPE_SIFIVE_REV0 flag
- Update the Opencores I2C Controller Link

Quoted 7 lines
 drivers/i2c/Kconfig      |   7 +
 drivers/i2c/Makefile     |   1 +
 drivers/i2c/ocores_i2c.c | 636
+++++++++++++++++++++++++++++++++++++++
 3 files changed, 644 insertions(+)
 create mode 100644 drivers/i2c/ocores_i2c.c
Quoted 1 line

Please check the CI failure item:
https://travis-ci.org/github/rickchen36/u-boot-riscv/jobs/743114190

+drivers/i2c/ocores_i2c.c: In function 'ocores_i2c_probe':
1291+drivers/i2c/ocores_i2c.c:523:4: error: implicit declaration of function 'dev_err' [-Werror=implicit-function-declaration]

1292+  523 |    dev_err(dev,
1293+      |    ^~~~~~~
1294+drivers/i2c/ocores_i2c.c:528:4: error: implicit declaration of
function 'dev_warn' [-Werror=implicit-function-declaration]
1295+  528 |    dev_warn(dev,
1296+      |    ^~~~~~~~
Quoted 4 lines

1297+cc1: all warnings being treated as errors

Thanks,
Rick

Will rebase and send it again.

#6 lore raw

PATCH v2 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

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

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

Quoted 8 lines

From: Pragnesh Patel [mailto:pragnesh.patel at sifive.com]
Sent: Thursday, October 22, 2020 2:55 PM
To: u-boot at lists.denx.de
Cc: atish.patra at wdc.com; palmerdabbelt at google.com; bmeng.cn at gmail.com; paul.walmsley at sifive.com; anup.patel at wdc.com; sagar.kadam at sifive.com; Rick Jian-Zhi Chen(???); peter at korsgaard.com; Pragnesh Patel; Palmer Dabbelt; Bin Meng; Jagan Teki; Sean Anderson
Subject: [PATCH v2 2/2] riscv: sifive/fu540: kconfig: Enable support for Opencores I2C controller

Enable support for SiFive FU540 Opencores I2C master controller.

Quoted 9 lines

---

(no changes since v1)

 arch/riscv/cpu/fu540/Kconfig | 2 ++
 board/sifive/fu540/Kconfig   | 1 +
 2 files changed, 3 insertions(+)