Commit 351c8a09 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'i2c/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c updates from Wolfram Sang:

 - new driver for ICY, an Amiga Zorro card :)

 - axxia driver gained slave mode support, NXP driver gained ACPI

 - the slave EEPROM backend gained 16 bit address support

 - and lots of regular driver updates and reworks

* 'i2c/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (52 commits)
  i2c: tegra: Move suspend handling to NOIRQ phase
  i2c: imx: ACPI support for NXP i2c controller
  i2c: uniphier(-f): remove all dev_dbg()
  i2c: uniphier(-f): use devm_platform_ioremap_resource()
  i2c: slave-eeprom: Add comment about address handling
  i2c: exynos5: Remove IRQF_ONESHOT
  i2c: stm32f7: Make structure stm32f7_i2c_algo constant
  i2c: cht-wc: drop check because i2c_unregister_device() is NULL safe
  i2c-eeprom_slave: Add support for more eeprom models
  i2c: fsi: Add of_put_node() before break
  i2c: synquacer: Make synquacer_i2c_ops constant
  i2c: hix5hd2: Remove IRQF_ONESHOT
  i2c: i801: Use iTCO version 6 in Cannon Lake PCH and beyond
  watchdog: iTCO: Add support for Cannon Lake PCH iTCO
  i2c: iproc: Make bcm_iproc_i2c_quirks constant
  i2c: iproc: Add full name of devicetree node to adapter name
  i2c: piix4: Add ACPI support
  i2c: piix4: Fix probing of reserved ports on AMD Family 16h Model 30h
  i2c: ocores: use request_any_context_irq() to register IRQ handler
  i2c: designware: Fix optional reset error handling
  ...
parents 3cf7487c 8ebf15e9
Broadcom BCM2835 I2C controller Broadcom BCM2835 I2C controller
Required properties: Required properties:
- compatible : Should be "brcm,bcm2835-i2c". - compatible : Should be one of:
"brcm,bcm2711-i2c"
"brcm,bcm2835-i2c"
- reg: Should contain register location and length. - reg: Should contain register location and length.
- interrupts: Should contain interrupt. - interrupts: Should contain interrupt.
- clocks : The clock feeding the I2C controller. - clocks : The clock feeding the I2C controller.
......
...@@ -7865,6 +7865,12 @@ S: Maintained ...@@ -7865,6 +7865,12 @@ S: Maintained
F: drivers/mfd/lpc_ich.c F: drivers/mfd/lpc_ich.c
F: drivers/gpio/gpio-ich.c F: drivers/gpio/gpio-ich.c
ICY I2C DRIVER
M: Max Staudt <max@enpas.org>
L: linux-i2c@vger.kernel.org
S: Maintained
F: drivers/i2c/busses/i2c-icy.c
IDE SUBSYSTEM IDE SUBSYSTEM
M: "David S. Miller" <davem@davemloft.net> M: "David S. Miller" <davem@davemloft.net>
L: linux-ide@vger.kernel.org L: linux-ide@vger.kernel.org
...@@ -13791,7 +13797,7 @@ F: drivers/clk/renesas/ ...@@ -13791,7 +13797,7 @@ F: drivers/clk/renesas/
RENESAS EMEV2 I2C DRIVER RENESAS EMEV2 I2C DRIVER
M: Wolfram Sang <wsa+renesas@sang-engineering.com> M: Wolfram Sang <wsa+renesas@sang-engineering.com>
S: Supported S: Supported
F: Documentation/devicetree/bindings/i2c/i2c-emev2.txt F: Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt
F: drivers/i2c/busses/i2c-emev2.c F: drivers/i2c/busses/i2c-emev2.c
RENESAS ETHERNET DRIVERS RENESAS ETHERNET DRIVERS
...@@ -13813,15 +13819,15 @@ F: drivers/iio/adc/rcar-gyroadc.c ...@@ -13813,15 +13819,15 @@ F: drivers/iio/adc/rcar-gyroadc.c
RENESAS R-CAR I2C DRIVERS RENESAS R-CAR I2C DRIVERS
M: Wolfram Sang <wsa+renesas@sang-engineering.com> M: Wolfram Sang <wsa+renesas@sang-engineering.com>
S: Supported S: Supported
F: Documentation/devicetree/bindings/i2c/i2c-rcar.txt F: Documentation/devicetree/bindings/i2c/renesas,i2c.txt
F: Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt F: Documentation/devicetree/bindings/i2c/renesas,iic.txt
F: drivers/i2c/busses/i2c-rcar.c F: drivers/i2c/busses/i2c-rcar.c
F: drivers/i2c/busses/i2c-sh_mobile.c F: drivers/i2c/busses/i2c-sh_mobile.c
RENESAS RIIC DRIVER RENESAS RIIC DRIVER
M: Chris Brandt <chris.brandt@renesas.com> M: Chris Brandt <chris.brandt@renesas.com>
S: Supported S: Supported
F: Documentation/devicetree/bindings/i2c/i2c-riic.txt F: Documentation/devicetree/bindings/i2c/renesas,riic.txt
F: drivers/i2c/busses/i2c-riic.c F: drivers/i2c/busses/i2c-riic.c
RENESAS USB PHY DRIVER RENESAS USB PHY DRIVER
......
...@@ -160,11 +160,17 @@ static const struct apd_device_desc hip08_i2c_desc = { ...@@ -160,11 +160,17 @@ static const struct apd_device_desc hip08_i2c_desc = {
.setup = acpi_apd_setup, .setup = acpi_apd_setup,
.fixed_clk_rate = 250000000, .fixed_clk_rate = 250000000,
}; };
static const struct apd_device_desc thunderx2_i2c_desc = { static const struct apd_device_desc thunderx2_i2c_desc = {
.setup = acpi_apd_setup, .setup = acpi_apd_setup,
.fixed_clk_rate = 125000000, .fixed_clk_rate = 125000000,
}; };
static const struct apd_device_desc nxp_i2c_desc = {
.setup = acpi_apd_setup,
.fixed_clk_rate = 350000000,
};
static const struct apd_device_desc hip08_spi_desc = { static const struct apd_device_desc hip08_spi_desc = {
.setup = acpi_apd_setup, .setup = acpi_apd_setup,
.fixed_clk_rate = 250000000, .fixed_clk_rate = 250000000,
...@@ -238,6 +244,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = { ...@@ -238,6 +244,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = {
{ "HISI02A1", APD_ADDR(hip07_i2c_desc) }, { "HISI02A1", APD_ADDR(hip07_i2c_desc) },
{ "HISI02A2", APD_ADDR(hip08_i2c_desc) }, { "HISI02A2", APD_ADDR(hip08_i2c_desc) },
{ "HISI0173", APD_ADDR(hip08_spi_desc) }, { "HISI0173", APD_ADDR(hip08_spi_desc) },
{ "NXP0001", APD_ADDR(nxp_i2c_desc) },
#endif #endif
{ } { }
}; };
......
...@@ -978,10 +978,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv) ...@@ -978,10 +978,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv)
{ {
int ret; int ret;
adv->i2c_cec = i2c_new_secondary_device(adv->i2c_main, "cec", adv->i2c_cec = i2c_new_ancillary_device(adv->i2c_main, "cec",
ADV7511_CEC_I2C_ADDR_DEFAULT); ADV7511_CEC_I2C_ADDR_DEFAULT);
if (!adv->i2c_cec) if (IS_ERR(adv->i2c_cec))
return -EINVAL; return PTR_ERR(adv->i2c_cec);
i2c_set_clientdata(adv->i2c_cec, adv); i2c_set_clientdata(adv->i2c_cec, adv);
adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec, adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec,
...@@ -1162,20 +1162,20 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) ...@@ -1162,20 +1162,20 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
adv7511_packet_disable(adv7511, 0xffff); adv7511_packet_disable(adv7511, 0xffff);
adv7511->i2c_edid = i2c_new_secondary_device(i2c, "edid", adv7511->i2c_edid = i2c_new_ancillary_device(i2c, "edid",
ADV7511_EDID_I2C_ADDR_DEFAULT); ADV7511_EDID_I2C_ADDR_DEFAULT);
if (!adv7511->i2c_edid) { if (IS_ERR(adv7511->i2c_edid)) {
ret = -EINVAL; ret = PTR_ERR(adv7511->i2c_edid);
goto uninit_regulators; goto uninit_regulators;
} }
regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR,
adv7511->i2c_edid->addr << 1); adv7511->i2c_edid->addr << 1);
adv7511->i2c_packet = i2c_new_secondary_device(i2c, "packet", adv7511->i2c_packet = i2c_new_ancillary_device(i2c, "packet",
ADV7511_PACKET_I2C_ADDR_DEFAULT); ADV7511_PACKET_I2C_ADDR_DEFAULT);
if (!adv7511->i2c_packet) { if (IS_ERR(adv7511->i2c_packet)) {
ret = -EINVAL; ret = PTR_ERR(adv7511->i2c_packet);
goto err_i2c_unregister_edid; goto err_i2c_unregister_edid;
} }
......
...@@ -429,6 +429,7 @@ config I2C_AXXIA ...@@ -429,6 +429,7 @@ config I2C_AXXIA
tristate "Axxia I2C controller" tristate "Axxia I2C controller"
depends on ARCH_AXXIA || COMPILE_TEST depends on ARCH_AXXIA || COMPILE_TEST
default ARCH_AXXIA default ARCH_AXXIA
select I2C_SLAVE
help help
Say yes if you want to support the I2C bus on Axxia platforms. Say yes if you want to support the I2C bus on Axxia platforms.
...@@ -977,7 +978,7 @@ config I2C_SIRF ...@@ -977,7 +978,7 @@ config I2C_SIRF
will be called i2c-sirf. will be called i2c-sirf.
config I2C_SPRD config I2C_SPRD
bool "Spreadtrum I2C interface" tristate "Spreadtrum I2C interface"
depends on I2C=y && ARCH_SPRD depends on I2C=y && ARCH_SPRD
help help
If you say yes to this option, support will be included for the If you say yes to this option, support will be included for the
...@@ -1309,6 +1310,20 @@ config I2C_ELEKTOR ...@@ -1309,6 +1310,20 @@ config I2C_ELEKTOR
This support is also available as a module. If so, the module This support is also available as a module. If so, the module
will be called i2c-elektor. will be called i2c-elektor.
config I2C_ICY
tristate "ICY Zorro card"
depends on ZORRO
select I2C_ALGOPCF
help
This supports the PCF8584 Zorro bus I2C adapter, known as ICY.
Say Y if you own such an adapter.
This support is also available as a module. If so, the module
will be called i2c-icy.
If you have a 2019 edition board with an LTC2990 sensor at address
0x4c, loading the module 'ltc2990' is sufficient to enable it.
config I2C_MLXCPLD config I2C_MLXCPLD
tristate "Mellanox I2C driver" tristate "Mellanox I2C driver"
depends on X86_64 depends on X86_64
......
...@@ -140,6 +140,7 @@ obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o ...@@ -140,6 +140,7 @@ obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o
obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o
obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o
obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
obj-$(CONFIG_I2C_ICY) += i2c-icy.o
obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o
obj-$(CONFIG_I2C_OPAL) += i2c-opal.o obj-$(CONFIG_I2C_OPAL) += i2c-opal.o
obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
......
...@@ -77,6 +77,40 @@ ...@@ -77,6 +77,40 @@
MST_STATUS_IP) MST_STATUS_IP)
#define MST_TX_BYTES_XFRD 0x50 #define MST_TX_BYTES_XFRD 0x50
#define MST_RX_BYTES_XFRD 0x54 #define MST_RX_BYTES_XFRD 0x54
#define SLV_ADDR_DEC_CTL 0x58
#define SLV_ADDR_DEC_GCE BIT(0) /* ACK to General Call Address from own master (loopback) */
#define SLV_ADDR_DEC_OGCE BIT(1) /* ACK to General Call Address from external masters */
#define SLV_ADDR_DEC_SA1E BIT(2) /* ACK to addr_1 enabled */
#define SLV_ADDR_DEC_SA1M BIT(3) /* 10-bit addressing for addr_1 enabled */
#define SLV_ADDR_DEC_SA2E BIT(4) /* ACK to addr_2 enabled */
#define SLV_ADDR_DEC_SA2M BIT(5) /* 10-bit addressing for addr_2 enabled */
#define SLV_ADDR_1 0x5c
#define SLV_ADDR_2 0x60
#define SLV_RX_CTL 0x64
#define SLV_RX_ACSA1 BIT(0) /* Generate ACK for writes to addr_1 */
#define SLV_RX_ACSA2 BIT(1) /* Generate ACK for writes to addr_2 */
#define SLV_RX_ACGCA BIT(2) /* ACK data phase transfers to General Call Address */
#define SLV_DATA 0x68
#define SLV_RX_FIFO 0x6c
#define SLV_FIFO_DV1 BIT(0) /* Data Valid for addr_1 */
#define SLV_FIFO_DV2 BIT(1) /* Data Valid for addr_2 */
#define SLV_FIFO_AS BIT(2) /* (N)ACK Sent */
#define SLV_FIFO_TNAK BIT(3) /* Timeout NACK */
#define SLV_FIFO_STRC BIT(4) /* First byte after start condition received */
#define SLV_FIFO_RSC BIT(5) /* Repeated Start Condition */
#define SLV_FIFO_STPC BIT(6) /* Stop Condition */
#define SLV_FIFO_DV (SLV_FIFO_DV1 | SLV_FIFO_DV2)
#define SLV_INT_ENABLE 0x70
#define SLV_INT_STATUS 0x74
#define SLV_STATUS_RFH BIT(0) /* FIFO service */
#define SLV_STATUS_WTC BIT(1) /* Write transfer complete */
#define SLV_STATUS_SRS1 BIT(2) /* Slave read from addr 1 */
#define SLV_STATUS_SRRS1 BIT(3) /* Repeated start from addr 1 */
#define SLV_STATUS_SRND1 BIT(4) /* Read request not following start condition */
#define SLV_STATUS_SRC1 BIT(5) /* Read canceled */
#define SLV_STATUS_SRAT1 BIT(6) /* Slave Read timed out */
#define SLV_STATUS_SRDRE1 BIT(7) /* Data written after timed out */
#define SLV_READ_DUMMY 0x78
#define SCL_HIGH_PERIOD 0x80 #define SCL_HIGH_PERIOD 0x80
#define SCL_LOW_PERIOD 0x84 #define SCL_LOW_PERIOD 0x84
#define SPIKE_FLTR_LEN 0x88 #define SPIKE_FLTR_LEN 0x88
...@@ -111,6 +145,8 @@ struct axxia_i2c_dev { ...@@ -111,6 +145,8 @@ struct axxia_i2c_dev {
struct clk *i2c_clk; struct clk *i2c_clk;
u32 bus_clk_rate; u32 bus_clk_rate;
bool last; bool last;
struct i2c_client *slave;
int irq;
}; };
static void i2c_int_disable(struct axxia_i2c_dev *idev, u32 mask) static void i2c_int_disable(struct axxia_i2c_dev *idev, u32 mask)
...@@ -276,13 +312,65 @@ static int axxia_i2c_fill_tx_fifo(struct axxia_i2c_dev *idev) ...@@ -276,13 +312,65 @@ static int axxia_i2c_fill_tx_fifo(struct axxia_i2c_dev *idev)
return ret; return ret;
} }
static void axxia_i2c_slv_fifo_event(struct axxia_i2c_dev *idev)
{
u32 fifo_status = readl(idev->base + SLV_RX_FIFO);
u8 val;
dev_dbg(idev->dev, "slave irq fifo_status=0x%x\n", fifo_status);
if (fifo_status & SLV_FIFO_DV1) {
if (fifo_status & SLV_FIFO_STRC)
i2c_slave_event(idev->slave,
I2C_SLAVE_WRITE_REQUESTED, &val);
val = readl(idev->base + SLV_DATA);
i2c_slave_event(idev->slave, I2C_SLAVE_WRITE_RECEIVED, &val);
}
if (fifo_status & SLV_FIFO_STPC) {
readl(idev->base + SLV_DATA); /* dummy read */
i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val);
}
if (fifo_status & SLV_FIFO_RSC)
readl(idev->base + SLV_DATA); /* dummy read */
}
static irqreturn_t axxia_i2c_slv_isr(struct axxia_i2c_dev *idev)
{
u32 status = readl(idev->base + SLV_INT_STATUS);
u8 val;
dev_dbg(idev->dev, "slave irq status=0x%x\n", status);
if (status & SLV_STATUS_RFH)
axxia_i2c_slv_fifo_event(idev);
if (status & SLV_STATUS_SRS1) {
i2c_slave_event(idev->slave, I2C_SLAVE_READ_REQUESTED, &val);
writel(val, idev->base + SLV_DATA);
}
if (status & SLV_STATUS_SRND1) {
i2c_slave_event(idev->slave, I2C_SLAVE_READ_PROCESSED, &val);
writel(val, idev->base + SLV_DATA);
}
if (status & SLV_STATUS_SRC1)
i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val);
writel(INT_SLV, idev->base + INTERRUPT_STATUS);
return IRQ_HANDLED;
}
static irqreturn_t axxia_i2c_isr(int irq, void *_dev) static irqreturn_t axxia_i2c_isr(int irq, void *_dev)
{ {
struct axxia_i2c_dev *idev = _dev; struct axxia_i2c_dev *idev = _dev;
irqreturn_t ret = IRQ_NONE;
u32 status; u32 status;
if (!(readl(idev->base + INTERRUPT_STATUS) & INT_MST)) status = readl(idev->base + INTERRUPT_STATUS);
return IRQ_NONE;
if (status & INT_SLV)
ret = axxia_i2c_slv_isr(idev);
if (!(status & INT_MST))
return ret;
/* Read interrupt status bits */ /* Read interrupt status bits */
status = readl(idev->base + MST_INT_STATUS); status = readl(idev->base + MST_INT_STATUS);
...@@ -583,9 +671,58 @@ static u32 axxia_i2c_func(struct i2c_adapter *adap) ...@@ -583,9 +671,58 @@ static u32 axxia_i2c_func(struct i2c_adapter *adap)
return caps; return caps;
} }
static int axxia_i2c_reg_slave(struct i2c_client *slave)
{
struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter);
u32 slv_int_mask = SLV_STATUS_RFH;
u32 dec_ctl;
if (idev->slave)
return -EBUSY;
idev->slave = slave;
/* Enable slave mode as well */
writel(GLOBAL_MST_EN | GLOBAL_SLV_EN, idev->base + GLOBAL_CONTROL);
writel(INT_MST | INT_SLV, idev->base + INTERRUPT_ENABLE);
/* Set slave address */
dec_ctl = SLV_ADDR_DEC_SA1E;
if (slave->flags & I2C_CLIENT_TEN)
dec_ctl |= SLV_ADDR_DEC_SA1M;
writel(SLV_RX_ACSA1, idev->base + SLV_RX_CTL);
writel(dec_ctl, idev->base + SLV_ADDR_DEC_CTL);
writel(slave->addr, idev->base + SLV_ADDR_1);
/* Enable interrupts */
slv_int_mask |= SLV_STATUS_SRS1 | SLV_STATUS_SRRS1 | SLV_STATUS_SRND1;
slv_int_mask |= SLV_STATUS_SRC1;
writel(slv_int_mask, idev->base + SLV_INT_ENABLE);
return 0;
}
static int axxia_i2c_unreg_slave(struct i2c_client *slave)
{
struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter);
/* Disable slave mode */
writel(GLOBAL_MST_EN, idev->base + GLOBAL_CONTROL);
writel(INT_MST, idev->base + INTERRUPT_ENABLE);
synchronize_irq(idev->irq);
idev->slave = NULL;
return 0;
}
static const struct i2c_algorithm axxia_i2c_algo = { static const struct i2c_algorithm axxia_i2c_algo = {
.master_xfer = axxia_i2c_xfer, .master_xfer = axxia_i2c_xfer,
.functionality = axxia_i2c_func, .functionality = axxia_i2c_func,
.reg_slave = axxia_i2c_reg_slave,
.unreg_slave = axxia_i2c_unreg_slave,
}; };
static const struct i2c_adapter_quirks axxia_i2c_quirks = { static const struct i2c_adapter_quirks axxia_i2c_quirks = {
...@@ -599,7 +736,6 @@ static int axxia_i2c_probe(struct platform_device *pdev) ...@@ -599,7 +736,6 @@ static int axxia_i2c_probe(struct platform_device *pdev)
struct axxia_i2c_dev *idev = NULL; struct axxia_i2c_dev *idev = NULL;
struct resource *res; struct resource *res;
void __iomem *base; void __iomem *base;
int irq;
int ret = 0; int ret = 0;
idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL); idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL);
...@@ -611,10 +747,10 @@ static int axxia_i2c_probe(struct platform_device *pdev) ...@@ -611,10 +747,10 @@ static int axxia_i2c_probe(struct platform_device *pdev)
if (IS_ERR(base)) if (IS_ERR(base))
return PTR_ERR(base); return PTR_ERR(base);
irq = platform_get_irq(pdev, 0); idev->irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (idev->irq < 0) {
dev_err(&pdev->dev, "missing interrupt resource\n"); dev_err(&pdev->dev, "missing interrupt resource\n");
return irq; return idev->irq;
} }
idev->i2c_clk = devm_clk_get(&pdev->dev, "i2c"); idev->i2c_clk = devm_clk_get(&pdev->dev, "i2c");
...@@ -643,10 +779,10 @@ static int axxia_i2c_probe(struct platform_device *pdev) ...@@ -643,10 +779,10 @@ static int axxia_i2c_probe(struct platform_device *pdev)
goto error_disable_clk; goto error_disable_clk;
} }
ret = devm_request_irq(&pdev->dev, irq, axxia_i2c_isr, 0, ret = devm_request_irq(&pdev->dev, idev->irq, axxia_i2c_isr, 0,
pdev->name, idev); pdev->name, idev);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to claim IRQ%d\n", irq); dev_err(&pdev->dev, "failed to claim IRQ%d\n", idev->irq);
goto error_disable_clk; goto error_disable_clk;
} }
......
...@@ -808,7 +808,7 @@ static struct i2c_algorithm bcm_iproc_algo = { ...@@ -808,7 +808,7 @@ static struct i2c_algorithm bcm_iproc_algo = {
.unreg_slave = bcm_iproc_i2c_unreg_slave, .unreg_slave = bcm_iproc_i2c_unreg_slave,
}; };
static struct i2c_adapter_quirks bcm_iproc_i2c_quirks = { static const struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
.max_read_len = M_RX_MAX_READ_LEN, .max_read_len = M_RX_MAX_READ_LEN,
}; };
...@@ -922,7 +922,9 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev) ...@@ -922,7 +922,9 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev)
adap = &iproc_i2c->adapter; adap = &iproc_i2c->adapter;
i2c_set_adapdata(adap, iproc_i2c); i2c_set_adapdata(adap, iproc_i2c);
strlcpy(adap->name, "Broadcom iProc I2C adapter", sizeof(adap->name)); snprintf(adap->name, sizeof(adap->name),
"Broadcom iProc (%s)",
of_node_full_name(iproc_i2c->device->of_node));
adap->algo = &bcm_iproc_algo; adap->algo = &bcm_iproc_algo;
adap->quirks = &bcm_iproc_i2c_quirks; adap->quirks = &bcm_iproc_i2c_quirks;
adap->dev.parent = &pdev->dev; adap->dev.parent = &pdev->dev;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -389,7 +390,7 @@ static const struct i2c_algorithm bcm2835_i2c_algo = { ...@@ -389,7 +390,7 @@ static const struct i2c_algorithm bcm2835_i2c_algo = {
}; };
/* /*
* This HW was reported to have problems with clock stretching: * The BCM2835 was reported to have problems with clock stretching:
* http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html * http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html
* https://www.raspberrypi.org/forums/viewtopic.php?p=146272 * https://www.raspberrypi.org/forums/viewtopic.php?p=146272
*/ */
...@@ -471,11 +472,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) ...@@ -471,11 +472,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
i2c_set_adapdata(adap, i2c_dev); i2c_set_adapdata(adap, i2c_dev);
adap->owner = THIS_MODULE; adap->owner = THIS_MODULE;
adap->class = I2C_CLASS_DEPRECATED; adap->class = I2C_CLASS_DEPRECATED;
strlcpy(adap->name, "bcm2835 I2C adapter", sizeof(adap->name)); snprintf(adap->name, sizeof(adap->name), "bcm2835 (%s)",
of_node_full_name(pdev->dev.of_node));
adap->algo = &bcm2835_i2c_algo; adap->algo = &bcm2835_i2c_algo;
adap->dev.parent = &pdev->dev; adap->dev.parent = &pdev->dev;
adap->dev.of_node = pdev->dev.of_node; adap->dev.of_node = pdev->dev.of_node;
adap->quirks = &bcm2835_i2c_quirks; adap->quirks = of_device_get_match_data(&pdev->dev);
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0); bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);
...@@ -501,7 +503,8 @@ static int bcm2835_i2c_remove(struct platform_device *pdev) ...@@ -501,7 +503,8 @@ static int bcm2835_i2c_remove(struct platform_device *pdev)
} }
static const struct of_device_id bcm2835_i2c_of_match[] = { static const struct of_device_id bcm2835_i2c_of_match[] = {
{ .compatible = "brcm,bcm2835-i2c" }, { .compatible = "brcm,bcm2711-i2c" },
{ .compatible = "brcm,bcm2835-i2c", .data = &bcm2835_i2c_quirks },
{}, {},
}; };
MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match); MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match);
......
...@@ -178,6 +178,51 @@ static const struct i2c_algorithm cht_wc_i2c_adap_algo = { ...@@ -178,6 +178,51 @@ static const struct i2c_algorithm cht_wc_i2c_adap_algo = {
.smbus_xfer = cht_wc_i2c_adap_smbus_xfer, .smbus_xfer = cht_wc_i2c_adap_smbus_xfer,
}; };
/*
* We are an i2c-adapter which itself is part of an i2c-client. This means that
* transfers done through us take adapter->bus_lock twice, once for our parent
* i2c-adapter and once to take our own bus_lock. Lockdep does not like this
* nested locking, to make lockdep happy in the case of busses with muxes, the
* i2c-core's i2c_adapter_lock_bus function calls:
* rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter));
*
* But i2c_adapter_depth only works when the direct parent of the adapter is
* another adapter, as it is only meant for muxes. In our case there is an
* i2c-client and MFD instantiated platform_device in the parent->child chain
* between the 2 devices.
*
* So we override the default i2c_lock_operations and pass a hardcoded
* depth of 1 to rt_mutex_lock_nested, to make lockdep happy.
*
* Note that if there were to be a mux attached to our adapter, this would
* break things again since the i2c-mux code expects the root-adapter to have
* a locking depth of 0. But we always have only 1 client directly attached
* in the form of the Charger IC paired with the CHT Whiskey Cove PMIC.
*/
static void cht_wc_i2c_adap_lock_bus(struct i2c_adapter *adapter,
unsigned int flags)
{
rt_mutex_lock_nested(&adapter->bus_lock, 1);
}
static int cht_wc_i2c_adap_trylock_bus(struct i2c_adapter *adapter,
unsigned int flags)
{
return rt_mutex_trylock(&adapter->bus_lock);
}
static void cht_wc_i2c_adap_unlock_bus(struct i2c_adapter *adapter,
unsigned int flags)
{
rt_mutex_unlock(&adapter->bus_lock);
}
static const struct i2c_lock_operations cht_wc_i2c_adap_lock_ops = {
.lock_bus = cht_wc_i2c_adap_lock_bus,
.trylock_bus = cht_wc_i2c_adap_trylock_bus,
.unlock_bus = cht_wc_i2c_adap_unlock_bus,
};
/**** irqchip for the client connected to the extchgr i2c adapter ****/ /**** irqchip for the client connected to the extchgr i2c adapter ****/
static void cht_wc_i2c_irq_lock(struct irq_data *data) static void cht_wc_i2c_irq_lock(struct irq_data *data)
{ {
...@@ -286,6 +331,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) ...@@ -286,6 +331,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
adap->adapter.owner = THIS_MODULE; adap->adapter.owner = THIS_MODULE;
adap->adapter.class = I2C_CLASS_HWMON; adap->adapter.class = I2C_CLASS_HWMON;
adap->adapter.algo = &cht_wc_i2c_adap_algo; adap->adapter.algo = &cht_wc_i2c_adap_algo;
adap->adapter.lock_ops = &cht_wc_i2c_adap_lock_ops;
strlcpy(adap->adapter.name, "PMIC I2C Adapter", strlcpy(adap->adapter.name, "PMIC I2C Adapter",
sizeof(adap->adapter.name)); sizeof(adap->adapter.name));
adap->adapter.dev.parent = &pdev->dev; adap->adapter.dev.parent = &pdev->dev;
...@@ -363,8 +409,7 @@ static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev) ...@@ -363,8 +409,7 @@ static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)
{ {
struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev); struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev);
if (adap->client) i2c_unregister_device(adap->client);
i2c_unregister_device(adap->client);
i2c_del_adapter(&adap->adapter); i2c_del_adapter(&adap->adapter);
irq_domain_remove(adap->irq_domain); irq_domain_remove(adap->irq_domain);
......
...@@ -655,15 +655,11 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev) ...@@ -655,15 +655,11 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev)
struct i2c_bus_recovery_info *rinfo = &dev->rinfo; struct i2c_bus_recovery_info *rinfo = &dev->rinfo;
struct i2c_adapter *adap = &dev->adapter; struct i2c_adapter *adap = &dev->adapter;
struct gpio_desc *gpio;