9 #include <linux/kernel.h>
10 #include <linux/module.h>
14 #include <linux/errno.h>
15 #include <linux/i2c.h>
16 #include <linux/slab.h>
18 #define PIC32_I2CxCON 0x0000
19 #define PIC32_I2CxCONCLR 0x0004
20 #define PIC32_I2CxCONSET 0x0008
21 #define PIC32_I2CxCONINV 0x000C
22 #define I2CCON_ON (1<<15)
23 #define I2CCON_FRZ (1<<14)
24 #define I2CCON_SIDL (1<<13)
25 #define I2CCON_SCLREL (1<<12)
26 #define I2CCON_STRICT (1<<11)
27 #define I2CCON_A10M (1<<10)
28 #define I2CCON_DISSLW (1<<9)
29 #define I2CCON_SMEN (1<<8)
30 #define I2CCON_GCEN (1<<7)
31 #define I2CCON_STREN (1<<6)
32 #define I2CCON_ACKDT (1<<5)
33 #define I2CCON_ACKEN (1<<4)
34 #define I2CCON_RCEN (1<<3)
35 #define I2CCON_PEN (1<<2)
36 #define I2CCON_RSEN (1<<1)
37 #define I2CCON_SEN (1<<0)
39 #define PIC32_I2CxSTAT 0x0010
40 #define PIC32_I2CxSTATCLR 0x0014
41 #define PIC32_I2CxSTATSET 0x0018
42 #define PIC32_I2CxSTATINV 0x001C
43 #define I2CSTAT_ACKSTAT (1<<15)
44 #define I2CSTAT_TRSTAT (1<<14)
45 #define I2CSTAT_BCL (1<<10)
46 #define I2CSTAT_GCSTAT (1<<9)
47 #define I2CSTAT_ADD10 (1<<8)
48 #define I2CSTAT_IWCOL (1<<7)
49 #define I2CSTAT_I2COV (1<<6)
50 #define I2CSTAT_DA (1<<5)
51 #define I2CSTAT_P (1<<4)
52 #define I2CSTAT_S (1<<3)
53 #define I2CSTAT_RW (1<<2)
54 #define I2CSTAT_RBF (1<<1)
55 #define I2CSTAT_TBF (1<<0)
57 #define PIC32_I2CxADD 0x0020
58 #define PIC32_I2CxADDCLR 0x0024
59 #define PIC32_I2CxADDSET 0x0028
60 #define PIC32_I2CxADDINV 0x002C
61 #define PIC32_I2CxMSK 0x0030
62 #define PIC32_I2CxMSKCLR 0x0034
63 #define PIC32_I2CxMSKSET 0x0038
64 #define PIC32_I2CxMSKINV 0x003C
65 #define PIC32_I2CxBRG 0x0040
66 #define PIC32_I2CxBRGCLR 0x0044
67 #define PIC32_I2CxBRGSET 0x0048
68 #define PIC32_I2CxBRGINV 0x004C
69 #define PIC32_I2CxTRN 0x0050
70 #define PIC32_I2CxTRNCLR 0x0054
71 #define PIC32_I2CxTRNSET 0x0058
72 #define PIC32_I2CxTRNINV 0x005C
73 #define PIC32_I2CxRCV 0x0060
172 if (MasterWriteI2C(adap, addr))
191 data = MasterReadI2C(adap);
216 if (MasterWriteI2C(adap, data))
238 for (i = 0; i < num; i++) {
247 for (ii = 0; ii < p->
len; ii++) {
248 if (b < &buf[__BUFSIZE-4]) {
256 pr_debug(
"xfer%d: DevAddr: %04x Op:%s Data:%s\n", i, p->
addr,
261 for (i = 0; !err && i < num; i++) {
287 .master_xfer = platform_xfer,
288 .functionality = platform_func,
329 priv->
base = bus_request_region(r->
start, resource_size(r),
344 priv->
adap.algo = &platform_algo;
346 priv->
adap.dev.parent = &pdev->
dev;
349 i2c_platform_setup(priv);
353 platform_set_drvdata(pdev, priv);
357 i2c_platform_disable(priv);
371 platform_set_drvdata(pdev,
NULL);
373 i2c_platform_disable(priv);
384 dev_dbg(&pdev->
dev,
"i2c_platform_disable\n");
385 i2c_platform_disable(priv);
396 i2c_platform_setup(priv);
401 #define i2c_platform_suspend NULL
402 #define i2c_platform_resume NULL
410 .probe = i2c_platform_probe,
417 i2c_platform_init(
void)
424 i2c_platform_exit(
void)