Skip to content

Commit 351c8a0

Browse files
committed
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 ...
2 parents 3cf7487 + 8ebf15e commit 351c8a0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+795
-267
lines changed

Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
Broadcom BCM2835 I2C controller
22

33
Required properties:
4-
- compatible : Should be "brcm,bcm2835-i2c".
4+
- compatible : Should be one of:
5+
"brcm,bcm2711-i2c"
6+
"brcm,bcm2835-i2c"
57
- reg: Should contain register location and length.
68
- interrupts: Should contain interrupt.
79
- clocks : The clock feeding the I2C controller.

MAINTAINERS

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7865,6 +7865,12 @@ S: Maintained
78657865
F: drivers/mfd/lpc_ich.c
78667866
F: drivers/gpio/gpio-ich.c
78677867

7868+
ICY I2C DRIVER
7869+
M: Max Staudt <[email protected]>
7870+
7871+
S: Maintained
7872+
F: drivers/i2c/busses/i2c-icy.c
7873+
78687874
IDE SUBSYSTEM
78697875
M: "David S. Miller" <[email protected]>
78707876
@@ -13791,7 +13797,7 @@ F: drivers/clk/renesas/
1379113797
RENESAS EMEV2 I2C DRIVER
1379213798
M: Wolfram Sang <[email protected]>
1379313799
S: Supported
13794-
F: Documentation/devicetree/bindings/i2c/i2c-emev2.txt
13800+
F: Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt
1379513801
F: drivers/i2c/busses/i2c-emev2.c
1379613802

1379713803
RENESAS ETHERNET DRIVERS
@@ -13813,15 +13819,15 @@ F: drivers/iio/adc/rcar-gyroadc.c
1381313819
RENESAS R-CAR I2C DRIVERS
1381413820
M: Wolfram Sang <[email protected]>
1381513821
S: Supported
13816-
F: Documentation/devicetree/bindings/i2c/i2c-rcar.txt
13817-
F: Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt
13822+
F: Documentation/devicetree/bindings/i2c/renesas,i2c.txt
13823+
F: Documentation/devicetree/bindings/i2c/renesas,iic.txt
1381813824
F: drivers/i2c/busses/i2c-rcar.c
1381913825
F: drivers/i2c/busses/i2c-sh_mobile.c
1382013826

1382113827
RENESAS RIIC DRIVER
1382213828
M: Chris Brandt <[email protected]>
1382313829
S: Supported
13824-
F: Documentation/devicetree/bindings/i2c/i2c-riic.txt
13830+
F: Documentation/devicetree/bindings/i2c/renesas,riic.txt
1382513831
F: drivers/i2c/busses/i2c-riic.c
1382613832

1382713833
RENESAS USB PHY DRIVER

drivers/acpi/acpi_apd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,17 @@ static const struct apd_device_desc hip08_i2c_desc = {
160160
.setup = acpi_apd_setup,
161161
.fixed_clk_rate = 250000000,
162162
};
163+
163164
static const struct apd_device_desc thunderx2_i2c_desc = {
164165
.setup = acpi_apd_setup,
165166
.fixed_clk_rate = 125000000,
166167
};
167168

169+
static const struct apd_device_desc nxp_i2c_desc = {
170+
.setup = acpi_apd_setup,
171+
.fixed_clk_rate = 350000000,
172+
};
173+
168174
static const struct apd_device_desc hip08_spi_desc = {
169175
.setup = acpi_apd_setup,
170176
.fixed_clk_rate = 250000000,
@@ -238,6 +244,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = {
238244
{ "HISI02A1", APD_ADDR(hip07_i2c_desc) },
239245
{ "HISI02A2", APD_ADDR(hip08_i2c_desc) },
240246
{ "HISI0173", APD_ADDR(hip08_spi_desc) },
247+
{ "NXP0001", APD_ADDR(nxp_i2c_desc) },
241248
#endif
242249
{ }
243250
};

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -978,10 +978,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv)
978978
{
979979
int ret;
980980

981-
adv->i2c_cec = i2c_new_secondary_device(adv->i2c_main, "cec",
981+
adv->i2c_cec = i2c_new_ancillary_device(adv->i2c_main, "cec",
982982
ADV7511_CEC_I2C_ADDR_DEFAULT);
983-
if (!adv->i2c_cec)
984-
return -EINVAL;
983+
if (IS_ERR(adv->i2c_cec))
984+
return PTR_ERR(adv->i2c_cec);
985985
i2c_set_clientdata(adv->i2c_cec, adv);
986986

987987
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)
11621162

11631163
adv7511_packet_disable(adv7511, 0xffff);
11641164

1165-
adv7511->i2c_edid = i2c_new_secondary_device(i2c, "edid",
1165+
adv7511->i2c_edid = i2c_new_ancillary_device(i2c, "edid",
11661166
ADV7511_EDID_I2C_ADDR_DEFAULT);
1167-
if (!adv7511->i2c_edid) {
1168-
ret = -EINVAL;
1167+
if (IS_ERR(adv7511->i2c_edid)) {
1168+
ret = PTR_ERR(adv7511->i2c_edid);
11691169
goto uninit_regulators;
11701170
}
11711171

11721172
regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR,
11731173
adv7511->i2c_edid->addr << 1);
11741174

1175-
adv7511->i2c_packet = i2c_new_secondary_device(i2c, "packet",
1175+
adv7511->i2c_packet = i2c_new_ancillary_device(i2c, "packet",
11761176
ADV7511_PACKET_I2C_ADDR_DEFAULT);
1177-
if (!adv7511->i2c_packet) {
1178-
ret = -EINVAL;
1177+
if (IS_ERR(adv7511->i2c_packet)) {
1178+
ret = PTR_ERR(adv7511->i2c_packet);
11791179
goto err_i2c_unregister_edid;
11801180
}
11811181

drivers/i2c/busses/Kconfig

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ config I2C_AXXIA
429429
tristate "Axxia I2C controller"
430430
depends on ARCH_AXXIA || COMPILE_TEST
431431
default ARCH_AXXIA
432+
select I2C_SLAVE
432433
help
433434
Say yes if you want to support the I2C bus on Axxia platforms.
434435

@@ -977,7 +978,7 @@ config I2C_SIRF
977978
will be called i2c-sirf.
978979

979980
config I2C_SPRD
980-
bool "Spreadtrum I2C interface"
981+
tristate "Spreadtrum I2C interface"
981982
depends on I2C=y && ARCH_SPRD
982983
help
983984
If you say yes to this option, support will be included for the
@@ -1309,6 +1310,20 @@ config I2C_ELEKTOR
13091310
This support is also available as a module. If so, the module
13101311
will be called i2c-elektor.
13111312

1313+
config I2C_ICY
1314+
tristate "ICY Zorro card"
1315+
depends on ZORRO
1316+
select I2C_ALGOPCF
1317+
help
1318+
This supports the PCF8584 Zorro bus I2C adapter, known as ICY.
1319+
Say Y if you own such an adapter.
1320+
1321+
This support is also available as a module. If so, the module
1322+
will be called i2c-icy.
1323+
1324+
If you have a 2019 edition board with an LTC2990 sensor at address
1325+
0x4c, loading the module 'ltc2990' is sufficient to enable it.
1326+
13121327
config I2C_MLXCPLD
13131328
tristate "Mellanox I2C driver"
13141329
depends on X86_64

drivers/i2c/busses/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o
140140
obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o
141141
obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o
142142
obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
143+
obj-$(CONFIG_I2C_ICY) += i2c-icy.o
143144
obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o
144145
obj-$(CONFIG_I2C_OPAL) += i2c-opal.o
145146
obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o

drivers/i2c/busses/i2c-axxia.c

Lines changed: 144 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,40 @@
7777
MST_STATUS_IP)
7878
#define MST_TX_BYTES_XFRD 0x50
7979
#define MST_RX_BYTES_XFRD 0x54
80+
#define SLV_ADDR_DEC_CTL 0x58
81+
#define SLV_ADDR_DEC_GCE BIT(0) /* ACK to General Call Address from own master (loopback) */
82+
#define SLV_ADDR_DEC_OGCE BIT(1) /* ACK to General Call Address from external masters */
83+
#define SLV_ADDR_DEC_SA1E BIT(2) /* ACK to addr_1 enabled */
84+
#define SLV_ADDR_DEC_SA1M BIT(3) /* 10-bit addressing for addr_1 enabled */
85+
#define SLV_ADDR_DEC_SA2E BIT(4) /* ACK to addr_2 enabled */
86+
#define SLV_ADDR_DEC_SA2M BIT(5) /* 10-bit addressing for addr_2 enabled */
87+
#define SLV_ADDR_1 0x5c
88+
#define SLV_ADDR_2 0x60
89+
#define SLV_RX_CTL 0x64
90+
#define SLV_RX_ACSA1 BIT(0) /* Generate ACK for writes to addr_1 */
91+
#define SLV_RX_ACSA2 BIT(1) /* Generate ACK for writes to addr_2 */
92+
#define SLV_RX_ACGCA BIT(2) /* ACK data phase transfers to General Call Address */
93+
#define SLV_DATA 0x68
94+
#define SLV_RX_FIFO 0x6c
95+
#define SLV_FIFO_DV1 BIT(0) /* Data Valid for addr_1 */
96+
#define SLV_FIFO_DV2 BIT(1) /* Data Valid for addr_2 */
97+
#define SLV_FIFO_AS BIT(2) /* (N)ACK Sent */
98+
#define SLV_FIFO_TNAK BIT(3) /* Timeout NACK */
99+
#define SLV_FIFO_STRC BIT(4) /* First byte after start condition received */
100+
#define SLV_FIFO_RSC BIT(5) /* Repeated Start Condition */
101+
#define SLV_FIFO_STPC BIT(6) /* Stop Condition */
102+
#define SLV_FIFO_DV (SLV_FIFO_DV1 | SLV_FIFO_DV2)
103+
#define SLV_INT_ENABLE 0x70
104+
#define SLV_INT_STATUS 0x74
105+
#define SLV_STATUS_RFH BIT(0) /* FIFO service */
106+
#define SLV_STATUS_WTC BIT(1) /* Write transfer complete */
107+
#define SLV_STATUS_SRS1 BIT(2) /* Slave read from addr 1 */
108+
#define SLV_STATUS_SRRS1 BIT(3) /* Repeated start from addr 1 */
109+
#define SLV_STATUS_SRND1 BIT(4) /* Read request not following start condition */
110+
#define SLV_STATUS_SRC1 BIT(5) /* Read canceled */
111+
#define SLV_STATUS_SRAT1 BIT(6) /* Slave Read timed out */
112+
#define SLV_STATUS_SRDRE1 BIT(7) /* Data written after timed out */
113+
#define SLV_READ_DUMMY 0x78
80114
#define SCL_HIGH_PERIOD 0x80
81115
#define SCL_LOW_PERIOD 0x84
82116
#define SPIKE_FLTR_LEN 0x88
@@ -111,6 +145,8 @@ struct axxia_i2c_dev {
111145
struct clk *i2c_clk;
112146
u32 bus_clk_rate;
113147
bool last;
148+
struct i2c_client *slave;
149+
int irq;
114150
};
115151

116152
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)
276312
return ret;
277313
}
278314

315+
static void axxia_i2c_slv_fifo_event(struct axxia_i2c_dev *idev)
316+
{
317+
u32 fifo_status = readl(idev->base + SLV_RX_FIFO);
318+
u8 val;
319+
320+
dev_dbg(idev->dev, "slave irq fifo_status=0x%x\n", fifo_status);
321+
322+
if (fifo_status & SLV_FIFO_DV1) {
323+
if (fifo_status & SLV_FIFO_STRC)
324+
i2c_slave_event(idev->slave,
325+
I2C_SLAVE_WRITE_REQUESTED, &val);
326+
327+
val = readl(idev->base + SLV_DATA);
328+
i2c_slave_event(idev->slave, I2C_SLAVE_WRITE_RECEIVED, &val);
329+
}
330+
if (fifo_status & SLV_FIFO_STPC) {
331+
readl(idev->base + SLV_DATA); /* dummy read */
332+
i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val);
333+
}
334+
if (fifo_status & SLV_FIFO_RSC)
335+
readl(idev->base + SLV_DATA); /* dummy read */
336+
}
337+
338+
static irqreturn_t axxia_i2c_slv_isr(struct axxia_i2c_dev *idev)
339+
{
340+
u32 status = readl(idev->base + SLV_INT_STATUS);
341+
u8 val;
342+
343+
dev_dbg(idev->dev, "slave irq status=0x%x\n", status);
344+
345+
if (status & SLV_STATUS_RFH)
346+
axxia_i2c_slv_fifo_event(idev);
347+
if (status & SLV_STATUS_SRS1) {
348+
i2c_slave_event(idev->slave, I2C_SLAVE_READ_REQUESTED, &val);
349+
writel(val, idev->base + SLV_DATA);
350+
}
351+
if (status & SLV_STATUS_SRND1) {
352+
i2c_slave_event(idev->slave, I2C_SLAVE_READ_PROCESSED, &val);
353+
writel(val, idev->base + SLV_DATA);
354+
}
355+
if (status & SLV_STATUS_SRC1)
356+
i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val);
357+
358+
writel(INT_SLV, idev->base + INTERRUPT_STATUS);
359+
return IRQ_HANDLED;
360+
}
361+
279362
static irqreturn_t axxia_i2c_isr(int irq, void *_dev)
280363
{
281364
struct axxia_i2c_dev *idev = _dev;
365+
irqreturn_t ret = IRQ_NONE;
282366
u32 status;
283367

284-
if (!(readl(idev->base + INTERRUPT_STATUS) & INT_MST))
285-
return IRQ_NONE;
368+
status = readl(idev->base + INTERRUPT_STATUS);
369+
370+
if (status & INT_SLV)
371+
ret = axxia_i2c_slv_isr(idev);
372+
if (!(status & INT_MST))
373+
return ret;
286374

287375
/* Read interrupt status bits */
288376
status = readl(idev->base + MST_INT_STATUS);
@@ -583,9 +671,58 @@ static u32 axxia_i2c_func(struct i2c_adapter *adap)
583671
return caps;
584672
}
585673

674+
static int axxia_i2c_reg_slave(struct i2c_client *slave)
675+
{
676+
struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter);
677+
u32 slv_int_mask = SLV_STATUS_RFH;
678+
u32 dec_ctl;
679+
680+
if (idev->slave)
681+
return -EBUSY;
682+
683+
idev->slave = slave;
684+
685+
/* Enable slave mode as well */
686+
writel(GLOBAL_MST_EN | GLOBAL_SLV_EN, idev->base + GLOBAL_CONTROL);
687+
writel(INT_MST | INT_SLV, idev->base + INTERRUPT_ENABLE);
688+
689+
/* Set slave address */
690+
dec_ctl = SLV_ADDR_DEC_SA1E;
691+
if (slave->flags & I2C_CLIENT_TEN)
692+
dec_ctl |= SLV_ADDR_DEC_SA1M;
693+
694+
writel(SLV_RX_ACSA1, idev->base + SLV_RX_CTL);
695+
writel(dec_ctl, idev->base + SLV_ADDR_DEC_CTL);
696+
writel(slave->addr, idev->base + SLV_ADDR_1);
697+
698+
/* Enable interrupts */
699+
slv_int_mask |= SLV_STATUS_SRS1 | SLV_STATUS_SRRS1 | SLV_STATUS_SRND1;
700+
slv_int_mask |= SLV_STATUS_SRC1;
701+
writel(slv_int_mask, idev->base + SLV_INT_ENABLE);
702+
703+
return 0;
704+
}
705+
706+
static int axxia_i2c_unreg_slave(struct i2c_client *slave)
707+
{
708+
struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter);
709+
710+
/* Disable slave mode */
711+
writel(GLOBAL_MST_EN, idev->base + GLOBAL_CONTROL);
712+
writel(INT_MST, idev->base + INTERRUPT_ENABLE);
713+
714+
synchronize_irq(idev->irq);
715+
716+
idev->slave = NULL;
717+
718+
return 0;
719+
}
720+
586721
static const struct i2c_algorithm axxia_i2c_algo = {
587722
.master_xfer = axxia_i2c_xfer,
588723
.functionality = axxia_i2c_func,
724+
.reg_slave = axxia_i2c_reg_slave,
725+
.unreg_slave = axxia_i2c_unreg_slave,
589726
};
590727

591728
static const struct i2c_adapter_quirks axxia_i2c_quirks = {
@@ -599,7 +736,6 @@ static int axxia_i2c_probe(struct platform_device *pdev)
599736
struct axxia_i2c_dev *idev = NULL;
600737
struct resource *res;
601738
void __iomem *base;
602-
int irq;
603739
int ret = 0;
604740

605741
idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL);
@@ -611,10 +747,10 @@ static int axxia_i2c_probe(struct platform_device *pdev)
611747
if (IS_ERR(base))
612748
return PTR_ERR(base);
613749

614-
irq = platform_get_irq(pdev, 0);
615-
if (irq < 0) {
750+
idev->irq = platform_get_irq(pdev, 0);
751+
if (idev->irq < 0) {
616752
dev_err(&pdev->dev, "missing interrupt resource\n");
617-
return irq;
753+
return idev->irq;
618754
}
619755

620756
idev->i2c_clk = devm_clk_get(&pdev->dev, "i2c");
@@ -643,10 +779,10 @@ static int axxia_i2c_probe(struct platform_device *pdev)
643779
goto error_disable_clk;
644780
}
645781

646-
ret = devm_request_irq(&pdev->dev, irq, axxia_i2c_isr, 0,
782+
ret = devm_request_irq(&pdev->dev, idev->irq, axxia_i2c_isr, 0,
647783
pdev->name, idev);
648784
if (ret) {
649-
dev_err(&pdev->dev, "failed to claim IRQ%d\n", irq);
785+
dev_err(&pdev->dev, "failed to claim IRQ%d\n", idev->irq);
650786
goto error_disable_clk;
651787
}
652788

drivers/i2c/busses/i2c-bcm-iproc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ static struct i2c_algorithm bcm_iproc_algo = {
808808
.unreg_slave = bcm_iproc_i2c_unreg_slave,
809809
};
810810

811-
static struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
811+
static const struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
812812
.max_read_len = M_RX_MAX_READ_LEN,
813813
};
814814

@@ -922,7 +922,9 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev)
922922

923923
adap = &iproc_i2c->adapter;
924924
i2c_set_adapdata(adap, iproc_i2c);
925-
strlcpy(adap->name, "Broadcom iProc I2C adapter", sizeof(adap->name));
925+
snprintf(adap->name, sizeof(adap->name),
926+
"Broadcom iProc (%s)",
927+
of_node_full_name(iproc_i2c->device->of_node));
926928
adap->algo = &bcm_iproc_algo;
927929
adap->quirks = &bcm_iproc_i2c_quirks;
928930
adap->dev.parent = &pdev->dev;

0 commit comments

Comments
 (0)