Skip to contentSkip to conversation

I2C controller support for KEBA PLCs

PATCH In review Gerhard Engleder 2 participants 5 messages Aug 9, 2024 – Sep 13, 2024 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

v5 cover I2C controller support for KEBA PLCs

KEBA PLCs use a PCIe FPGA to implement several functions in a common way. This is a first step to include basic support for this FPGA.

Under drivers/misc the cp500 PCI driver is added. This drivers creates auxiliary devices for every function inside the FPGA. As a first step it only creates auxiliary devices for the I2C controllers.

The I2C controller driver is added under drivers/i2c/busses like all the other I2C controller drivers.

This patches enable access to the EEPROMs and to the hardware monitoring chip of KEBA PLCs.

v5:
- simplify (ret != 0) (Andi Shyti)
- change KI2C_RECOVERY_CLK_CNT to (9 * 2) (Andi Shyti)
- change KI2C_RECOVERY_NDELAY to KI2C_RECOVERY_UDELAY (Andi Shyti)
- rework reset while loop to for loop (Andi Shyti)
- use dev_err() for errors (Andi Shyti)
- don't define int i within for loop (Andi Shyti)
- use else if within read loop (Andi Shyti)
- remove unnecessary parenthesis of (ret < 0) ? ... (Andi Shyti)
- reduce ki2c->client_size in case of failed device registration (Andi Shyti)
- don't use ',' after delimiters (Andi Shyti)
- remove platform_data from comment

v4:
- first patch removed because it is already merged and part of 6.11-rc1

v3:
- first patch is already merged to char-misc-next by Greg KH
- add AUXILIARY_BUS Kconfig dependency
- don't declare int i within for loop (Andi Shyti)
- enable I2C controller as late as possible (Andi Shyti)
- use devm_i2c_add_adapter (Andi Shyti)
- add KI2C_CONTROL_DISABLE (Andi Shyti)

v2:
- use aux bus (Greg KH)
- add Documentation/ABI/ entry for version and keep_cfg sysfs files (Greg KH)
- use sysfs_emit (Greg KH)
- add some information about I2C controller in commit message (Andi Shyti)
- remove old copyright line (Andi Shyti)
- sort header alphabetically (Andi Shyti)
- rework register defines as suggested (Andi Shyti)
- fix block comment style multiple times (Andi Shyti)
- add comment that IN_USE bit is a semaphore (Andi Shyti)
- add comment that IN_USE bit polling sleeps (Andi Shyti)
- addr as first argument of ki2c_wait_for_bit() (Andi Shyti)
- avoid compact style for register flag check (Andi Shyti)
- move bus reset dev_err's to reset implementation (Andi Shyti)
- use dev_err_probe() (Andi Shyti)
- fix 'ki2c_devtype defined but not used' (kernel test robot)
- fix 'WARNING comparing pointer to 0', twice (kernel test robot)
- fix 'Using plain integer as NULL pointer' (kernel test robot)
- fix 'symbol cp035_devices was not declared. Should it be static?', 3 times (kernel test robot)

Gerhard Engleder (1):
i2c: keba: Add KEBA I2C controller support

 drivers/i2c/busses/Kconfig    |  11 +
 drivers/i2c/busses/Makefile   |   1 +
 drivers/i2c/busses/i2c-keba.c | 598 ++++++++++++++++++++++++++++++++++
 3 files changed, 610 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-keba.c
Signature · 1 line
2.39.2
#1 lore raw

PATCH v5 1/1 i2c: keba: Add KEBA I2C controller support

From: Gerhard Engleder <[email protected]>

The KEBA I2C controller is found in the system FPGA of KEBA PLC devices. It is used to connect EEPROMs and hardware monitoring chips. The

It is a simple I2C controller with a fixed bus speed of 100 kbit/s. The whole message transmission is executed by the driver. The driver triggers all steps over control, status and data register. There are no FIFOs or interrupts.

---
 drivers/i2c/busses/Kconfig    |  11 +
 drivers/i2c/busses/Makefile   |   1 +
 drivers/i2c/busses/i2c-keba.c | 598 ++++++++++++++++++++++++++++++++++
 3 files changed, 610 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-keba.c
drivers/i2c/busses/Kconfig +11 -0
index a22f9125322a..3d2215acc9b4 100644
@@ -772,6 +772,17 @@ config I2C_JZ4780
 
 	 If you don't know what to do here, say N.
 
+config I2C_KEBA
+	tristate "KEBA I2C controller support"
+	depends on HAS_IOMEM
+	select AUXILIARY_BUS
+	help
+	  This driver supports the I2C controller found in KEBA system FPGA
+	  devices.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called i2c-keba.
+
 config I2C_KEMPLD
 	tristate "Kontron COM I2C Controller"
 	depends on MFD_KEMPLD
drivers/i2c/busses/Makefile +1 -0
index 78d0561339e5..ecc07c50f2a0 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_I2C_IMX)		+= i2c-imx.o
 obj-$(CONFIG_I2C_IMX_LPI2C)	+= i2c-imx-lpi2c.o
 obj-$(CONFIG_I2C_IOP3XX)	+= i2c-iop3xx.o
 obj-$(CONFIG_I2C_JZ4780)	+= i2c-jz4780.o
+obj-$(CONFIG_I2C_KEBA)		+= i2c-keba.o
 obj-$(CONFIG_I2C_KEMPLD)	+= i2c-kempld.o
 obj-$(CONFIG_I2C_LPC2K)		+= i2c-lpc2k.o
 obj-$(CONFIG_I2C_LS2X)		+= i2c-ls2x.o
drivers/i2c/busses/i2c-keba.c new file +598 -0

598 lines not on this page · raw message

Signature · 1 line
2.39.2
#2 lore raw
In reply to Gerhard Engleder
Quoted 57 lines · Gerhard Engleder

KEBA PLCs use a PCIe FPGA to implement several functions in a common way. This is a first step to include basic support for this FPGA.

Under drivers/misc the cp500 PCI driver is added. This drivers creates auxiliary devices for every function inside the FPGA. As a first step it only creates auxiliary devices for the I2C controllers.

The I2C controller driver is added under drivers/i2c/busses like all the other I2C controller drivers.

This patches enable access to the EEPROMs and to the hardware monitoring chip of KEBA PLCs.

v5:
- simplify (ret != 0) (Andi Shyti)
- change KI2C_RECOVERY_CLK_CNT to (9 * 2) (Andi Shyti)
- change KI2C_RECOVERY_NDELAY to KI2C_RECOVERY_UDELAY (Andi Shyti)
- rework reset while loop to for loop (Andi Shyti)
- use dev_err() for errors (Andi Shyti)
- don't define int i within for loop (Andi Shyti)
- use else if within read loop (Andi Shyti)
- remove unnecessary parenthesis of (ret < 0) ? ... (Andi Shyti)
- reduce ki2c->client_size in case of failed device registration (Andi Shyti)
- don't use ',' after delimiters (Andi Shyti)
- remove platform_data from comment

v4:
- first patch removed because it is already merged and part of 6.11-rc1

v3:
- first patch is already merged to char-misc-next by Greg KH
- add AUXILIARY_BUS Kconfig dependency
- don't declare int i within for loop (Andi Shyti)
- enable I2C controller as late as possible (Andi Shyti)
- use devm_i2c_add_adapter (Andi Shyti)
- add KI2C_CONTROL_DISABLE (Andi Shyti)

v2:
- use aux bus (Greg KH)
- add Documentation/ABI/ entry for version and keep_cfg sysfs files (Greg KH)
- use sysfs_emit (Greg KH)
- add some information about I2C controller in commit message (Andi Shyti)
- remove old copyright line (Andi Shyti)
- sort header alphabetically (Andi Shyti)
- rework register defines as suggested (Andi Shyti)
- fix block comment style multiple times (Andi Shyti)
- add comment that IN_USE bit is a semaphore (Andi Shyti)
- add comment that IN_USE bit polling sleeps (Andi Shyti)
- addr as first argument of ki2c_wait_for_bit() (Andi Shyti)
- avoid compact style for register flag check (Andi Shyti)
- move bus reset dev_err's to reset implementation (Andi Shyti)
- use dev_err_probe() (Andi Shyti)
- fix 'ki2c_devtype defined but not used' (kernel test robot)
- fix 'WARNING comparing pointer to 0', twice (kernel test robot)
- fix 'Using plain integer as NULL pointer' (kernel test robot)
- fix 'symbol cp035_devices was not declared. Should it be static?', 3 times (kernel test robot)

Quoted 9 lines

Gerhard Engleder (1):
i2c: keba: Add KEBA I2C controller support

  drivers/i2c/busses/Kconfig    |  11 +
  drivers/i2c/busses/Makefile   |   1 +
  drivers/i2c/busses/i2c-keba.c | 598 ++++++++++++++++++++++++++++++++++
  3 files changed, 610 insertions(+)

create mode 100644 drivers/i2c/busses/i2c-keba.c

Hello Andi,

are there any reasons why this patch does not make any progress? Did I miss something? Or is it hanging just because of holiday season?

Thanks,
Gerhard

maintainer
#3 lore raw

Hi Gerhard,

Quoted 1 line · Gerhard Engleder

On 09.08.24 07:23, Gerhard Engleder wrote:

...

Quoted 10 lines
Quoted 9 lines

Gerhard Engleder (1):
i2c: keba: Add KEBA I2C controller support

  drivers/i2c/busses/Kconfig    |  11 +
  drivers/i2c/busses/Makefile   |   1 +
  drivers/i2c/busses/i2c-keba.c | 598 ++++++++++++++++++++++++++++++++++
  3 files changed, 610 insertions(+)

create mode 100644 drivers/i2c/busses/i2c-keba.c

Quoted 4 lines

Hello Andi,

are there any reasons why this patch does not make any progress? Did I miss something? Or is it hanging just because of holiday season?

Sorry for having taken so long, now it's merged to i2c/i2c-host.

I took the liberty of changing only 'slave' to 'target' in one comment to align with the new inclusive I2C naming convention.

Thanks,
Andi

#4 lore raw
Quoted 19 lines · Andi Shyti

Hi Gerhard,

Quoted 1 line · Gerhard Engleder

On 09.08.24 07:23, Gerhard Engleder wrote:

...

Quoted 12 lines
Quoted 9 lines

Gerhard Engleder (1):
i2c: keba: Add KEBA I2C controller support

   drivers/i2c/busses/Kconfig    |  11 +
   drivers/i2c/busses/Makefile   |   1 +
   drivers/i2c/busses/i2c-keba.c | 598 ++++++++++++++++++++++++++++++++++
   3 files changed, 610 insertions(+)

create mode 100644 drivers/i2c/busses/i2c-keba.c

Hello Andi,

Quoted 7 lines
Quoted 2 lines

are there any reasons why this patch does not make any progress? Did I miss something? Or is it hanging just because of holiday season?

Sorry for having taken so long, now it's merged to i2c/i2c-host.

I took the liberty of changing only 'slave' to 'target' in one comment to align with the new inclusive I2C naming convention.

Thank you!