Skip to contentSkip to conversation

i2c: add support for microchip fpga i2c controllers

PATCH In review Conor Dooley 2 participants 6 messages Jul 6, 2022 – Jul 7, 2022

Subsystems (3)
lore
Share & tools
lore

Conor Dooley

author maintainer
#0 lore raw

PATCH v7 1/2 i2c: add support for microchip fpga i2c controllers

Add Microchip CoreI2C i2c controller support. This driver supports the "hard" i2c controller on the Microchip PolarFire SoC & the basic feature set for "soft" i2c controller implemtations in the FPGA fabric.

---
Changes from v6:
- dropped the unused spinlock
- switched the timeout to HZ
- renamed to i2c-microchip-corei2c
- fixed a useless < 0 check on a u16
- removed unused iopoll.h

Changes from v5:
- add zero to the invalid irq check

Changes from v4:
- reset the controller on xfer timeout
- sort the headers alphabetically

Changes from v3:
- update members in struct doc comment
- move mchp_corei2c_transfer in its caller
- change msg_len to a u16
- remove unused variable msg_read
- use adapater.timeout for completion
- dont use last_byte goto
- remove block on zero length messages
(the hardware can do them, was a carryover from the baremetal driver)
- probe:
- drop unneeded initialisation
- use ret not val
- explain shared irq
- disallow 0 bus_clock_rate
- include base in device name
- dropped the duplicate "microchip" in the registered print (its in driver.name)

Changes from v2:
- Fixed whitespace in defines that I removed accidentally

Changes from v1:
- Use byte write and read functions
- Return IRQ_NONE and don't warn if not this drivers interrupt
- Add a clk_disable_unprepare to avoid leaking a clock in the probe

---
 drivers/i2c/busses/Kconfig                 |  11 +
 drivers/i2c/busses/Makefile                |   1 +
 drivers/i2c/busses/i2c-microchip-corei2c.c | 480 +++++++++++++++++++++
 3 files changed, 492 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-microchip-corei2c.c
drivers/i2c/busses/Kconfig +11 -0
index b1d7069dd377..ccd6537cfd18 100644
@@ -781,6 +781,17 @@ config I2C_MESON
 	  If you say yes to this option, support will be included for the
 	  I2C interface on the Amlogic Meson family of SoCs.
 
+config I2C_MICROCHIP_CORE
+	tristate "Microchip FPGA I2C controller"
+	depends on SOC_MICROCHIP_POLARFIRE || COMPILE_TEST
+	depends on OF
+	help
+	  If you say yes to this option, support will be included for the
+	  I2C interface on Microchip FPGAs.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called i2c-microchip-core.
+
 config I2C_MPC
 	tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx"
 	depends on PPC
drivers/i2c/busses/Makefile +1 -0
index b0a10e5d9ee9..29d729b6a5b7 100644
@@ -78,6 +78,7 @@ obj-$(CONFIG_I2C_JZ4780)	+= i2c-jz4780.o
 obj-$(CONFIG_I2C_KEMPLD)	+= i2c-kempld.o
 obj-$(CONFIG_I2C_LPC2K)		+= i2c-lpc2k.o
 obj-$(CONFIG_I2C_MESON)		+= i2c-meson.o
+obj-$(CONFIG_I2C_MICROCHIP_CORE)	+= i2c-microchip-corei2c.o
 obj-$(CONFIG_I2C_MPC)		+= i2c-mpc.o
 obj-$(CONFIG_I2C_MT65XX)	+= i2c-mt65xx.o
 obj-$(CONFIG_I2C_MT7621)	+= i2c-mt7621.o
drivers/i2c/busses/i2c-microchip-corei2c.c new file +480 -0

480 lines not on this page · raw message

base-commit: 088b9c375534d905a4d337c78db3b3bfbb52c4a0

Signature · 1 line
2.36.1
author maintainer
#1 lore raw

PATCH v7 2/2 MAINTAINERS: add the polarfire soc's i2c driver

Add the newly added i2c controller driver to the existing entry for PolarFire SoC.

---
Changes since v6:
I rebased this on next-20220706 & it went through without a conflict. I'll bump it after mw1.

New in v6.
FYI: I have several maintainers updates in flight - usb, pwm, spi of which some will be in 5.20 & clk/hwrng/pci that are likely to go into 5.19-rcN.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index d64d79eb36a2..3286b727c90b 100644
@@ -17428,6 +17428,7 @@ M:	Conor Dooley <[email protected]>
 L:	[email protected]
 S:	Supported
 F:	arch/riscv/boot/dts/microchip/
+F:	drivers/i2c/busses/i2c-microchip-core.c
 F:	drivers/mailbox/mailbox-mpfs.c
 F:	drivers/rtc/rtc-mpfs.c
 F:	drivers/soc/microchip/
Signature · 1 line
2.36.1
#2 lore raw
In reply to Conor Dooley
Quoted 7 lines · Conor Dooley

Add Microchip CoreI2C i2c controller support. This driver supports the "hard" i2c controller on the Microchip PolarFire SoC & the basic feature set for "soft" i2c controller implemtations in the FPGA fabric.

Driver looks good, but what about the bindings? I shall not merge the driver without these.

author maintainer
#3 lore raw
Quoted 7 lines · Wolfram Sang

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 4 lines · Conor Dooley

Add Microchip CoreI2C i2c controller support. This driver supports the "hard" i2c controller on the Microchip PolarFire SoC & the basic feature set for "soft" i2c controller implemtations in the FPGA fabric.

Quoted 7 lines
Quoted 3 lines

Driver looks good, but what about the bindings? I shall not merge the driver without these.

Already upstream :) Documentation/devicetree/bindings/i2c/microchip,corei2c.yaml

#4 lore raw
Quoted 3 lines

Already upstream :) Documentation/devicetree/bindings/i2c/microchip,corei2c.yaml

Oops, I only checked commits in master..next :D Thanks for the heads up!

author maintainer
#5 lore raw
Quoted 6 lines · Wolfram Sang

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 2 lines

Already upstream :) Documentation/devicetree/bindings/i2c/microchip,corei2c.yaml

Oops, I only checked commits in master..next :D Thanks for the heads up!

No worries. Thanks for the time taken to review.
Conor.