From e0c61c04791a3500060023b0dfc35d06b0508028 Mon Sep 17 00:00:00 2001 From: Jarkko Nikula Date: Thu, 24 Oct 2019 13:57:25 +0300 Subject: i2c: i801: Add support for Intel Jasper Lake Add support for SMBus controller on Intel Jasper Lake PCH-N. Signed-off-by: Jarkko Nikula Reviewed-by: Jean Delvare Signed-off-by: Wolfram Sang --- drivers/i2c/busses/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/i2c/busses/Kconfig') diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 146ce40d8e0a..89cb8d7c4853 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -145,6 +145,7 @@ config I2C_I801 Comet Lake (PCH) Elkhart Lake (PCH) Tiger Lake (PCH) + Jasper Lake (PCH) This driver can also be built as a module. If so, the module will be called i2c-i801. -- cgit v1.2.3 From 4d51b4cea21831422614366de4e929701846d801 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 1 Oct 2019 10:59:59 -0500 Subject: i2c: pxa: migrate to new i2c_slave APIs The i2c subsystem was enhanced circa 2015 to support operating as an i2c-slave device. Prior to that, the i2c-pxa driver supported an i2c-slave but had its own APIs. There are no existing in-kernel drivers or platforms that utilize the i2c-pxa APIs. Migrate the i2c-pxa driver to the general i2c-slave APIs so that existing drivers, such as the i2c-slave-eeprom, can be used. This has been tested with a Marvell EspressoBin, using i2c-pxa and i2c-slave-eeprom, acting as a slave, and a RaspeberryPi 3, using the at24 driver, acting as a master. Signed-off-by: Patrick Williams Signed-off-by: Wolfram Sang --- drivers/i2c/busses/Kconfig | 1 + drivers/i2c/busses/i2c-pxa.c | 74 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 14 deletions(-) (limited to 'drivers/i2c/busses/Kconfig') diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 89cb8d7c4853..45ca099e7315 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -875,6 +875,7 @@ config I2C_PXA_PCI config I2C_PXA_SLAVE bool "Intel PXA2XX I2C Slave comms support" depends on I2C_PXA && !X86_32 + select I2C_SLAVE help Support I2C slave mode communications on the PXA I2C bus. This is necessary for systems where the PXA may be a target on the diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 2c3c3d6935c0..c811646e809f 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -180,7 +180,7 @@ struct pxa_i2c { struct i2c_adapter adap; struct clk *clk; #ifdef CONFIG_I2C_PXA_SLAVE - struct i2c_slave_client *slave; + struct i2c_client *slave; #endif unsigned int irqlogidx; @@ -544,22 +544,23 @@ static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr) if (isr & ISR_BED) { /* what should we do here? */ } else { - int ret = 0; + u8 byte = 0; if (i2c->slave != NULL) - ret = i2c->slave->read(i2c->slave->data); + i2c_slave_event(i2c->slave, I2C_SLAVE_READ_PROCESSED, + &byte); - writel(ret, _IDBR(i2c)); + writel(byte, _IDBR(i2c)); writel(readl(_ICR(i2c)) | ICR_TB, _ICR(i2c)); /* allow next byte */ } } static void i2c_pxa_slave_rxfull(struct pxa_i2c *i2c, u32 isr) { - unsigned int byte = readl(_IDBR(i2c)); + u8 byte = readl(_IDBR(i2c)); if (i2c->slave != NULL) - i2c->slave->write(i2c->slave->data, byte); + i2c_slave_event(i2c->slave, I2C_SLAVE_WRITE_RECEIVED, &byte); writel(readl(_ICR(i2c)) | ICR_TB, _ICR(i2c)); } @@ -572,9 +573,18 @@ static void i2c_pxa_slave_start(struct pxa_i2c *i2c, u32 isr) dev_dbg(&i2c->adap.dev, "SAD, mode is slave-%cx\n", (isr & ISR_RWM) ? 'r' : 't'); - if (i2c->slave != NULL) - i2c->slave->event(i2c->slave->data, - (isr & ISR_RWM) ? I2C_SLAVE_EVENT_START_READ : I2C_SLAVE_EVENT_START_WRITE); + if (i2c->slave != NULL) { + if (isr & ISR_RWM) { + u8 byte = 0; + + i2c_slave_event(i2c->slave, I2C_SLAVE_READ_REQUESTED, + &byte); + writel(byte, _IDBR(i2c)); + } else { + i2c_slave_event(i2c->slave, I2C_SLAVE_WRITE_REQUESTED, + NULL); + } + } /* * slave could interrupt in the middle of us generating a @@ -607,7 +617,7 @@ static void i2c_pxa_slave_stop(struct pxa_i2c *i2c) dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop)\n"); if (i2c->slave != NULL) - i2c->slave->event(i2c->slave->data, I2C_SLAVE_EVENT_STOP); + i2c_slave_event(i2c->slave, I2C_SLAVE_STOP, NULL); if (i2c_debug > 2) dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop) acked\n"); @@ -619,6 +629,38 @@ static void i2c_pxa_slave_stop(struct pxa_i2c *i2c) if (i2c->msg) i2c_pxa_master_complete(i2c, I2C_RETRY); } + +static int i2c_pxa_slave_reg(struct i2c_client *slave) +{ + struct pxa_i2c *i2c = slave->adapter->algo_data; + + if (i2c->slave) + return -EBUSY; + + if (!i2c->reg_isar) + return -EAFNOSUPPORT; + + i2c->slave = slave; + i2c->slave_addr = slave->addr; + + writel(i2c->slave_addr, _ISAR(i2c)); + + return 0; +} + +static int i2c_pxa_slave_unreg(struct i2c_client *slave) +{ + struct pxa_i2c *i2c = slave->adapter->algo_data; + + WARN_ON(!i2c->slave); + + i2c->slave_addr = I2C_PXA_SLAVE_ADDR; + writel(i2c->slave_addr, _ISAR(i2c)); + + i2c->slave = NULL; + + return 0; +} #else static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr) { @@ -1141,11 +1183,19 @@ static u32 i2c_pxa_functionality(struct i2c_adapter *adap) static const struct i2c_algorithm i2c_pxa_algorithm = { .master_xfer = i2c_pxa_xfer, .functionality = i2c_pxa_functionality, +#ifdef CONFIG_I2C_PXA_SLAVE + .reg_slave = i2c_pxa_slave_reg, + .unreg_slave = i2c_pxa_slave_unreg, +#endif }; static const struct i2c_algorithm i2c_pxa_pio_algorithm = { .master_xfer = i2c_pxa_pio_xfer, .functionality = i2c_pxa_functionality, +#ifdef CONFIG_I2C_PXA_SLAVE + .reg_slave = i2c_pxa_slave_reg, + .unreg_slave = i2c_pxa_slave_unreg, +#endif }; static const struct of_device_id i2c_pxa_dt_ids[] = { @@ -1270,10 +1320,6 @@ static int i2c_pxa_probe(struct platform_device *dev) i2c->highmode_enter = false; if (plat) { -#ifdef CONFIG_I2C_PXA_SLAVE - i2c->slave_addr = plat->slave_addr; - i2c->slave = plat->slave; -#endif i2c->adap.class = plat->class; } -- cgit v1.2.3 From 790591f41ede7b6fcfea8753dfb4030752dbfbec Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 20 Nov 2019 17:19:32 +0200 Subject: i2c: i801: Correct Intel Jasper Lake SOC naming There is no suffix applied to Intel Jasper Lake SOC. Remove it from the comments and definitions. Besides that, it's a SOC, thus replace PCH with SOC where it appropriate. Fixes: e0c61c04791a ("i2c: i801: Add support for Intel Jasper Lake") Cc: Jarkko Nikula Signed-off-by: Andy Shevchenko Reviewed-by: Jarkko Nikula Reviewed-by: Jean Delvare Signed-off-by: Wolfram Sang --- Documentation/i2c/busses/i2c-i801.rst | 2 +- drivers/i2c/busses/Kconfig | 2 +- drivers/i2c/busses/i2c-i801.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/i2c/busses/Kconfig') diff --git a/Documentation/i2c/busses/i2c-i801.rst b/Documentation/i2c/busses/i2c-i801.rst index aa4a0e26e9b9..b83da0e94184 100644 --- a/Documentation/i2c/busses/i2c-i801.rst +++ b/Documentation/i2c/busses/i2c-i801.rst @@ -42,7 +42,7 @@ Supported adapters: * Intel Comet Lake (PCH) * Intel Elkhart Lake (PCH) * Intel Tiger Lake (PCH) - * Intel Jasper Lake (PCH) + * Intel Jasper Lake (SOC) Datasheets: Publicly available at the Intel website diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 45ca099e7315..71e5ee263dce 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -145,7 +145,7 @@ config I2C_I801 Comet Lake (PCH) Elkhart Lake (PCH) Tiger Lake (PCH) - Jasper Lake (PCH) + Jasper Lake (SOC) This driver can also be built as a module. If so, the module will be called i2c-i801. diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index df02040d36d5..f5e69fe56532 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -67,7 +67,7 @@ * Comet Lake-H (PCH) 0x06a3 32 hard yes yes yes * Elkhart Lake (PCH) 0x4b23 32 hard yes yes yes * Tiger Lake-LP (PCH) 0xa0a3 32 hard yes yes yes - * Jasper Lake-N (PCH) 0x4da3 32 hard yes yes yes + * Jasper Lake (SOC) 0x4da3 32 hard yes yes yes * * Features supported by this driver: * Software PEC no @@ -226,7 +226,7 @@ #define PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS 0x34a3 #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 #define PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS 0x4b23 -#define PCI_DEVICE_ID_INTEL_JASPER_LAKE_N_SMBUS 0x4da3 +#define PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS 0x4da3 #define PCI_DEVICE_ID_INTEL_BROXTON_SMBUS 0x5ad4 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22 #define PCI_DEVICE_ID_INTEL_WILDCATPOINT_SMBUS 0x8ca2 @@ -1076,7 +1076,7 @@ static const struct pci_device_id i801_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TIGERLAKE_LP_SMBUS) }, - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_JASPER_LAKE_N_SMBUS) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS) }, { 0, } }; @@ -1759,7 +1759,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) case PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS: case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS: case PCI_DEVICE_ID_INTEL_TIGERLAKE_LP_SMBUS: - case PCI_DEVICE_ID_INTEL_JASPER_LAKE_N_SMBUS: + case PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS: priv->features |= FEATURE_BLOCK_PROC; priv->features |= FEATURE_I2C_BLOCK_READ; priv->features |= FEATURE_IRQ; -- cgit v1.2.3 From 1b00ff61597e7b5758372ded5134f673dddc1831 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Thu, 21 Nov 2019 04:19:23 +0100 Subject: i2c: Fix Kconfig indentation Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like: $ sed -e 's/^ /\t/' -i */Kconfig Signed-off-by: Krzysztof Kozlowski Acked-by: Peter Rosin Signed-off-by: Wolfram Sang --- drivers/i2c/busses/Kconfig | 22 +++++++++++----------- drivers/i2c/muxes/Kconfig | 18 +++++++++--------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'drivers/i2c/busses/Kconfig') diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 71e5ee263dce..6a0aa76859f3 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -293,7 +293,7 @@ config I2C_VIA select I2C_ALGOBIT help If you say yes to this option, support will be included for the VIA - 82C586B I2C interface + 82C586B I2C interface This driver can also be built as a module. If so, the module will be called i2c-via. @@ -678,11 +678,11 @@ config I2C_IMX_LPI2C tristate "IMX Low Power I2C interface" depends on ARCH_MXC || COMPILE_TEST help - Say Y here if you want to use the Low Power IIC bus controller - on the Freescale i.MX processors. + Say Y here if you want to use the Low Power IIC bus controller + on the Freescale i.MX processors. - This driver can also be built as a module. If so, the module - will be called i2c-imx-lpi2c. + This driver can also be built as a module. If so, the module + will be called i2c-imx-lpi2c. config I2C_IOP3XX tristate "Intel IOPx3xx and IXP4xx on-chip I2C interface" @@ -1184,9 +1184,9 @@ config I2C_DIOLAN_U2C will be called i2c-diolan-u2c. config I2C_DLN2 - tristate "Diolan DLN-2 USB I2C adapter" - depends on MFD_DLN2 - help + tristate "Diolan DLN-2 USB I2C adapter" + depends on MFD_DLN2 + help If you say yes to this option, support will be included for Diolan DLN2, a USB to I2C interface. @@ -1285,9 +1285,9 @@ config I2C_VIPERBOARD help Say yes here to access the I2C part of the Nano River Technologies Viperboard as I2C master. - See viperboard API specification and Nano - River Tech's viperboard.h for detailed meaning - of the module parameters. + See viperboard API specification and Nano + River Tech's viperboard.h for detailed meaning + of the module parameters. comment "Other I2C/SMBus bus drivers" diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig index c6040aa839ac..1708b1a82da2 100644 --- a/drivers/i2c/muxes/Kconfig +++ b/drivers/i2c/muxes/Kconfig @@ -109,14 +109,14 @@ config I2C_DEMUX_PINCTRL want to change the I2C master at run-time depending on features. config I2C_MUX_MLXCPLD - tristate "Mellanox CPLD based I2C multiplexer" - help - If you say yes to this option, support will be included for a - CPLD based I2C multiplexer. This driver provides access to - I2C busses connected through a MUX, which is controlled - by a CPLD register. - - This driver can also be built as a module. If so, the module - will be called i2c-mux-mlxcpld. + tristate "Mellanox CPLD based I2C multiplexer" + help + If you say yes to this option, support will be included for a + CPLD based I2C multiplexer. This driver provides access to + I2C busses connected through a MUX, which is controlled + by a CPLD register. + + This driver can also be built as a module. If so, the module + will be called i2c-mux-mlxcpld. endmenu -- cgit v1.2.3