Skip to content

Commit fc2bb8d

Browse files
committed
Merge branch 'i2c-embedded/for-3.4' of git://git.pengutronix.de/git/wsa/linux
Pull i2c embedded updates from Wolfram Sang: "Nothing special from i2c-embedded for this merge window. Two new drivers, minor feature additions, bugfixes, cleanups. All patches have been in linux-next for some time, too." * 'i2c-embedded/for-3.4' of git://git.pengutronix.de/git/wsa/linux: i2c-eg20t: Remove write-only variables i2c-eg20t: Rework pch_i2c_wait_for_bus_idle to reduce wait time i2c-s3c2410: Add stub runtime power management i2c-s3c2410: Convert to devm_kzalloc() i2c: add CSR SiRFprimaII on-chip I2C controllers driver i2c: tegra: Remove unnecessary write to INT_STATUS i2c: imx: fix imx driver to work though signal is pending i2c: designware: dw_i2c_init_driver as subsys initcall misc: at24: describe platform_data with kernel_doc i2c: Move I2C_EG20T option to the right place. i2c: Support for Netlogic XLR/XLS I2C controller. i2c: mpc: Add support for SMBUS_READ_BLOCK_DATA i2c: versatile: Add Device Tree support
2 parents 475c77e + bbceeee commit fc2bb8d

13 files changed

Lines changed: 912 additions & 66 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
I2C for SiRFprimaII platforms
2+
3+
Required properties :
4+
- compatible : Must be "sirf,prima2-i2c"
5+
- reg: physical base address of the controller and length of memory mapped
6+
region.
7+
- interrupts: interrupt number to the cpu.
8+
9+
Optional properties:
10+
- clock-frequency : Constains desired I2C/HS-I2C bus clock frequency in Hz.
11+
The absence of the propoerty indicates the default frequency 100 kHz.
12+
13+
Examples :
14+
15+
i2c0: i2c@b00e0000 {
16+
compatible = "sirf,prima2-i2c";
17+
reg = <0xb00e0000 0x10000>;
18+
interrupts = <24>;
19+
};

‎drivers/i2c/busses/Kconfig‎

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,21 @@ config I2C_DESIGNWARE_PCI
369369
This driver can also be built as a module. If so, the module
370370
will be called i2c-designware-pci.
371371

372+
config I2C_EG20T
373+
tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) I2C"
374+
depends on PCI
375+
help
376+
This driver is for PCH(Platform controller Hub) I2C of EG20T which
377+
is an IOH(Input/Output Hub) for x86 embedded processor.
378+
This driver can access PCH I2C bus device.
379+
380+
This driver also can be used for LAPIS Semiconductor IOH(Input/
381+
Output Hub), ML7213, ML7223 and ML7831.
382+
ML7213 IOH is for IVI(In-Vehicle Infotainment) use, ML7223 IOH is
383+
for MP(Media Phone) use and ML7831 IOH is for general purpose use.
384+
ML7213/ML7223/ML7831 is companion chip for Intel Atom E6xx series.
385+
ML7213/ML7223/ML7831 is completely compatible for Intel EG20T PCH.
386+
372387
config I2C_GPIO
373388
tristate "GPIO-based bitbanging I2C"
374389
depends on GENERIC_GPIO
@@ -630,6 +645,16 @@ config I2C_SIMTEC
630645
This driver can also be built as a module. If so, the module
631646
will be called i2c-simtec.
632647

648+
config I2C_SIRF
649+
tristate "CSR SiRFprimaII I2C interface"
650+
depends on ARCH_PRIMA2
651+
help
652+
If you say yes to this option, support will be included for the
653+
CSR SiRFprimaII I2C interface.
654+
655+
This driver can also be built as a module. If so, the module
656+
will be called i2c-sirf.
657+
633658
config I2C_STU300
634659
tristate "ST Microelectronics DDC I2C interface"
635660
depends on MACH_U300
@@ -681,20 +706,15 @@ config I2C_XILINX
681706
This driver can also be built as a module. If so, the module
682707
will be called xilinx_i2c.
683708

684-
config I2C_EG20T
685-
tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) I2C"
686-
depends on PCI
709+
config I2C_XLR
710+
tristate "XLR I2C support"
711+
depends on CPU_XLR
687712
help
688-
This driver is for PCH(Platform controller Hub) I2C of EG20T which
689-
is an IOH(Input/Output Hub) for x86 embedded processor.
690-
This driver can access PCH I2C bus device.
713+
This driver enables support for the on-chip I2C interface of
714+
the Netlogic XLR/XLS MIPS processors.
691715

692-
This driver also can be used for LAPIS Semiconductor IOH(Input/
693-
Output Hub), ML7213, ML7223 and ML7831.
694-
ML7213 IOH is for IVI(In-Vehicle Infotainment) use, ML7223 IOH is
695-
for MP(Media Phone) use and ML7831 IOH is for general purpose use.
696-
ML7213/ML7223/ML7831 is companion chip for Intel Atom E6xx series.
697-
ML7213/ML7223/ML7831 is completely compatible for Intel EG20T PCH.
716+
This driver can also be built as a module. If so, the module
717+
will be called i2c-xlr.
698718

699719
comment "External I2C/SMBus adapter drivers"
700720

‎drivers/i2c/busses/Makefile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM) += i2c-designware-platform.o
3737
i2c-designware-platform-objs := i2c-designware-platdrv.o i2c-designware-core.o
3838
obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o
3939
i2c-designware-pci-objs := i2c-designware-pcidrv.o i2c-designware-core.o
40+
obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
4041
obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
4142
obj-$(CONFIG_I2C_HIGHLANDER) += i2c-highlander.o
4243
obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o
@@ -63,12 +64,13 @@ obj-$(CONFIG_I2C_S6000) += i2c-s6000.o
6364
obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o
6465
obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o
6566
obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o
67+
obj-$(CONFIG_I2C_SIRF) += i2c-sirf.o
6668
obj-$(CONFIG_I2C_STU300) += i2c-stu300.o
6769
obj-$(CONFIG_I2C_TEGRA) += i2c-tegra.o
6870
obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o
6971
obj-$(CONFIG_I2C_OCTEON) += i2c-octeon.o
7072
obj-$(CONFIG_I2C_XILINX) += i2c-xiic.o
71-
obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
73+
obj-$(CONFIG_I2C_XLR) += i2c-xlr.o
7274

7375
# External I2C/SMBus adapter drivers
7476
obj-$(CONFIG_I2C_DIOLAN_U2C) += i2c-diolan-u2c.o

‎drivers/i2c/busses/i2c-designware-platdrv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int __init dw_i2c_init_driver(void)
214214
{
215215
return platform_driver_probe(&dw_i2c_driver, dw_i2c_probe);
216216
}
217-
module_init(dw_i2c_init_driver);
217+
subsys_initcall(dw_i2c_init_driver);
218218

219219
static void __exit dw_i2c_exit_driver(void)
220220
{

‎drivers/i2c/busses/i2c-eg20t.c‎

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -271,30 +271,36 @@ static inline bool ktime_lt(const ktime_t cmp1, const ktime_t cmp2)
271271
/**
272272
* pch_i2c_wait_for_bus_idle() - check the status of bus.
273273
* @adap: Pointer to struct i2c_algo_pch_data.
274-
* @timeout: waiting time counter (us).
274+
* @timeout: waiting time counter (ms).
275275
*/
276276
static s32 pch_i2c_wait_for_bus_idle(struct i2c_algo_pch_data *adap,
277277
s32 timeout)
278278
{
279279
void __iomem *p = adap->pch_base_address;
280-
ktime_t ns_val;
280+
int schedule = 0;
281+
unsigned long end = jiffies + msecs_to_jiffies(timeout);
282+
283+
while (ioread32(p + PCH_I2CSR) & I2CMBB_BIT) {
284+
if (time_after(jiffies, end)) {
285+
pch_dbg(adap, "I2CSR = %x\n", ioread32(p + PCH_I2CSR));
286+
pch_err(adap, "%s: Timeout Error.return%d\n",
287+
__func__, -ETIME);
288+
pch_i2c_init(adap);
281289

282-
if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0)
283-
return 0;
290+
return -ETIME;
291+
}
284292

285-
/* MAX timeout value is timeout*1000*1000nsec */
286-
ns_val = ktime_add_ns(ktime_get(), timeout*1000*1000);
287-
do {
288-
msleep(20);
289-
if ((ioread32(p + PCH_I2CSR) & I2CMBB_BIT) == 0)
290-
return 0;
291-
} while (ktime_lt(ktime_get(), ns_val));
293+
if (!schedule)
294+
/* Retry after some usecs */
295+
udelay(5);
296+
else
297+
/* Wait a bit more without consuming CPU */
298+
usleep_range(20, 1000);
292299

293-
pch_dbg(adap, "I2CSR = %x\n", ioread32(p + PCH_I2CSR));
294-
pch_err(adap, "%s: Timeout Error.return%d\n", __func__, -ETIME);
295-
pch_i2c_init(adap);
300+
schedule = 1;
301+
}
296302

297-
return -ETIME;
303+
return 0;
298304
}
299305

300306
/**
@@ -778,8 +784,6 @@ static s32 pch_i2c_xfer(struct i2c_adapter *i2c_adap,
778784
struct i2c_msg *pmsg;
779785
u32 i = 0;
780786
u32 status;
781-
u32 msglen;
782-
u32 subaddrlen;
783787
s32 ret;
784788

785789
struct i2c_algo_pch_data *adap = i2c_adap->algo_data;
@@ -804,12 +808,6 @@ static s32 pch_i2c_xfer(struct i2c_adapter *i2c_adap,
804808
status = pmsg->flags;
805809
pch_dbg(adap,
806810
"After invoking I2C_MODE_SEL :flag= 0x%x\n", status);
807-
/* calculate sub address length and message length */
808-
/* these are applicable only for buffer mode */
809-
subaddrlen = pmsg->buf[0];
810-
/* calculate actual message length excluding
811-
* the sub address fields */
812-
msglen = (pmsg->len) - (subaddrlen + 1);
813811

814812
if ((status & (I2C_M_RD)) != false) {
815813
ret = pch_i2c_readbytes(i2c_adap, pmsg, (i + 1 == num),

‎drivers/i2c/busses/i2c-imx.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy)
149149
break;
150150
if (!for_busy && !(temp & I2SR_IBB))
151151
break;
152-
if (signal_pending(current)) {
153-
dev_dbg(&i2c_imx->adapter.dev,
154-
"<%s> I2C Interrupted\n", __func__);
155-
return -EINTR;
156-
}
157152
if (time_after(jiffies, orig_jiffies + msecs_to_jiffies(500))) {
158153
dev_dbg(&i2c_imx->adapter.dev,
159154
"<%s> I2C bus is busy\n", __func__);

‎drivers/i2c/busses/i2c-mpc.c‎

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static int mpc_write(struct mpc_i2c *i2c, int target,
454454
}
455455

456456
static int mpc_read(struct mpc_i2c *i2c, int target,
457-
u8 *data, int length, int restart)
457+
u8 *data, int length, int restart, bool recv_len)
458458
{
459459
unsigned timeout = i2c->adap.timeout;
460460
int i, result;
@@ -470,7 +470,7 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
470470
return result;
471471

472472
if (length) {
473-
if (length == 1)
473+
if (length == 1 && !recv_len)
474474
writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_TXAK);
475475
else
476476
writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA);
@@ -479,17 +479,46 @@ static int mpc_read(struct mpc_i2c *i2c, int target,
479479
}
480480

481481
for (i = 0; i < length; i++) {
482+
u8 byte;
483+
482484
result = i2c_wait(i2c, timeout, 0);
483485
if (result < 0)
484486
return result;
485487

486-
/* Generate txack on next to last byte */
487-
if (i == length - 2)
488-
writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_TXAK);
489-
/* Do not generate stop on last byte */
490-
if (i == length - 1)
491-
writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX);
492-
data[i] = readb(i2c->base + MPC_I2C_DR);
488+
/*
489+
* For block reads, we have to know the total length (1st byte)
490+
* before we can determine if we are done.
491+
*/
492+
if (i || !recv_len) {
493+
/* Generate txack on next to last byte */
494+
if (i == length - 2)
495+
writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA
496+
| CCR_TXAK);
497+
/* Do not generate stop on last byte */
498+
if (i == length - 1)
499+
writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA
500+
| CCR_MTX);
501+
}
502+
503+
byte = readb(i2c->base + MPC_I2C_DR);
504+
505+
/*
506+
* Adjust length if first received byte is length.
507+
* The length is 1 length byte plus actually data length
508+
*/
509+
if (i == 0 && recv_len) {
510+
if (byte == 0 || byte > I2C_SMBUS_BLOCK_MAX)
511+
return -EPROTO;
512+
length += byte;
513+
/*
514+
* For block reads, generate txack here if data length
515+
* is 1 byte (total length is 2 bytes).
516+
*/
517+
if (length == 2)
518+
writeccr(i2c, CCR_MIEN | CCR_MEN | CCR_MSTA
519+
| CCR_TXAK);
520+
}
521+
data[i] = byte;
493522
}
494523

495524
return length;
@@ -532,20 +561,26 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
532561
"Doing %s %d bytes to 0x%02x - %d of %d messages\n",
533562
pmsg->flags & I2C_M_RD ? "read" : "write",
534563
pmsg->len, pmsg->addr, i + 1, num);
535-
if (pmsg->flags & I2C_M_RD)
536-
ret =
537-
mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
538-
else
564+
if (pmsg->flags & I2C_M_RD) {
565+
bool recv_len = pmsg->flags & I2C_M_RECV_LEN;
566+
567+
ret = mpc_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, i,
568+
recv_len);
569+
if (recv_len && ret > 0)
570+
pmsg->len = ret;
571+
} else {
539572
ret =
540573
mpc_write(i2c, pmsg->addr, pmsg->buf, pmsg->len, i);
574+
}
541575
}
542576
mpc_i2c_stop(i2c);
543577
return (ret < 0) ? ret : num;
544578
}
545579

546580
static u32 mpc_functionality(struct i2c_adapter *adap)
547581
{
548-
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
582+
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL
583+
| I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL;
549584
}
550585

551586
static const struct i2c_algorithm mpc_algo = {

‎drivers/i2c/busses/i2c-s3c2410.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/errno.h>
3232
#include <linux/err.h>
3333
#include <linux/platform_device.h>
34+
#include <linux/pm_runtime.h>
3435
#include <linux/clk.h>
3536
#include <linux/cpufreq.h>
3637
#include <linux/slab.h>
@@ -564,6 +565,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
564565
int retry;
565566
int ret;
566567

568+
pm_runtime_get_sync(&adap->dev);
567569
clk_enable(i2c->clk);
568570

569571
for (retry = 0; retry < adap->retries; retry++) {
@@ -572,6 +574,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
572574

573575
if (ret != -EAGAIN) {
574576
clk_disable(i2c->clk);
577+
pm_runtime_put_sync(&adap->dev);
575578
return ret;
576579
}
577580

@@ -581,6 +584,7 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
581584
}
582585

583586
clk_disable(i2c->clk);
587+
pm_runtime_put_sync(&adap->dev);
584588
return -EREMOTEIO;
585589
}
586590

@@ -890,7 +894,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
890894
}
891895
}
892896

893-
i2c = kzalloc(sizeof(struct s3c24xx_i2c), GFP_KERNEL);
897+
i2c = devm_kzalloc(&pdev->dev, sizeof(struct s3c24xx_i2c), GFP_KERNEL);
894898
if (!i2c) {
895899
dev_err(&pdev->dev, "no memory for state\n");
896900
return -ENOMEM;
@@ -1013,6 +1017,9 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
10131017
of_i2c_register_devices(&i2c->adap);
10141018
platform_set_drvdata(pdev, i2c);
10151019

1020+
pm_runtime_enable(&pdev->dev);
1021+
pm_runtime_enable(&i2c->adap.dev);
1022+
10161023
dev_info(&pdev->dev, "%s: S3C I2C adapter\n", dev_name(&i2c->adap.dev));
10171024
clk_disable(i2c->clk);
10181025
return 0;
@@ -1035,7 +1042,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
10351042
clk_put(i2c->clk);
10361043

10371044
err_noclk:
1038-
kfree(i2c);
10391045
return ret;
10401046
}
10411047

@@ -1048,6 +1054,9 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
10481054
{
10491055
struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
10501056

1057+
pm_runtime_disable(&i2c->adap.dev);
1058+
pm_runtime_disable(&pdev->dev);
1059+
10511060
s3c24xx_i2c_deregister_cpufreq(i2c);
10521061

10531062
i2c_del_adapter(&i2c->adap);
@@ -1061,7 +1070,6 @@ static int s3c24xx_i2c_remove(struct platform_device *pdev)
10611070
release_resource(i2c->ioarea);
10621071
s3c24xx_i2c_dt_gpio_free(i2c);
10631072
kfree(i2c->ioarea);
1064-
kfree(i2c);
10651073

10661074
return 0;
10671075
}

0 commit comments

Comments
 (0)