diff options
| -rw-r--r-- | Documentation/powerpc/dts-bindings/fsl/i2c.txt | 30 | ||||
| -rw-r--r-- | drivers/i2c/busses/Kconfig | 7 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-mpc.c | 194 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-omap.c | 44 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-pnx.c | 11 |
5 files changed, 171 insertions, 115 deletions
diff --git a/Documentation/powerpc/dts-bindings/fsl/i2c.txt b/Documentation/powerpc/dts-bindings/fsl/i2c.txt index b6d2e21474f9..50da20310585 100644 --- a/Documentation/powerpc/dts-bindings/fsl/i2c.txt +++ b/Documentation/powerpc/dts-bindings/fsl/i2c.txt | |||
| @@ -2,15 +2,14 @@ | |||
| 2 | 2 | ||
| 3 | Required properties : | 3 | Required properties : |
| 4 | 4 | ||
| 5 | - device_type : Should be "i2c" | ||
| 6 | - reg : Offset and length of the register set for the device | 5 | - reg : Offset and length of the register set for the device |
| 6 | - compatible : should be "fsl,CHIP-i2c" where CHIP is the name of a | ||
| 7 | compatible processor, e.g. mpc8313, mpc8543, mpc8544, mpc5121, | ||
| 8 | mpc5200 or mpc5200b. For the mpc5121, an additional node | ||
| 9 | "fsl,mpc5121-i2c-ctrl" is required as shown in the example below. | ||
| 7 | 10 | ||
| 8 | Recommended properties : | 11 | Recommended properties : |
| 9 | 12 | ||
| 10 | - compatible : compatibility list with 2 entries, the first should | ||
| 11 | be "fsl,CHIP-i2c" where CHIP is the name of a compatible processor, | ||
| 12 | e.g. mpc8313, mpc8543, mpc8544, mpc5200 or mpc5200b. The second one | ||
| 13 | should be "fsl-i2c". | ||
| 14 | - interrupts : <a b> where a is the interrupt number and b is a | 13 | - interrupts : <a b> where a is the interrupt number and b is a |
| 15 | field that represents an encoding of the sense and level | 14 | field that represents an encoding of the sense and level |
| 16 | information for the interrupt. This should be encoded based on | 15 | information for the interrupt. This should be encoded based on |
| @@ -24,25 +23,40 @@ Recommended properties : | |||
| 24 | 23 | ||
| 25 | Examples : | 24 | Examples : |
| 26 | 25 | ||
| 26 | /* MPC5121 based board */ | ||
| 27 | i2c@1740 { | ||
| 28 | #address-cells = <1>; | ||
| 29 | #size-cells = <0>; | ||
| 30 | compatible = "fsl,mpc5121-i2c", "fsl-i2c"; | ||
| 31 | reg = <0x1740 0x20>; | ||
| 32 | interrupts = <11 0x8>; | ||
| 33 | interrupt-parent = <&ipic>; | ||
| 34 | clock-frequency = <100000>; | ||
| 35 | }; | ||
| 36 | |||
| 37 | i2ccontrol@1760 { | ||
| 38 | compatible = "fsl,mpc5121-i2c-ctrl"; | ||
| 39 | reg = <0x1760 0x8>; | ||
| 40 | }; | ||
| 41 | |||
| 42 | /* MPC5200B based board */ | ||
| 27 | i2c@3d00 { | 43 | i2c@3d00 { |
| 28 | #address-cells = <1>; | 44 | #address-cells = <1>; |
| 29 | #size-cells = <0>; | 45 | #size-cells = <0>; |
| 30 | compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c"; | 46 | compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c"; |
| 31 | cell-index = <0>; | ||
| 32 | reg = <0x3d00 0x40>; | 47 | reg = <0x3d00 0x40>; |
| 33 | interrupts = <2 15 0>; | 48 | interrupts = <2 15 0>; |
| 34 | interrupt-parent = <&mpc5200_pic>; | 49 | interrupt-parent = <&mpc5200_pic>; |
| 35 | fsl,preserve-clocking; | 50 | fsl,preserve-clocking; |
| 36 | }; | 51 | }; |
| 37 | 52 | ||
| 53 | /* MPC8544 base board */ | ||
| 38 | i2c@3100 { | 54 | i2c@3100 { |
| 39 | #address-cells = <1>; | 55 | #address-cells = <1>; |
| 40 | #size-cells = <0>; | 56 | #size-cells = <0>; |
| 41 | cell-index = <1>; | ||
| 42 | compatible = "fsl,mpc8544-i2c", "fsl-i2c"; | 57 | compatible = "fsl,mpc8544-i2c", "fsl-i2c"; |
| 43 | reg = <0x3100 0x100>; | 58 | reg = <0x3100 0x100>; |
| 44 | interrupts = <43 2>; | 59 | interrupts = <43 2>; |
| 45 | interrupt-parent = <&mpic>; | 60 | interrupt-parent = <&mpic>; |
| 46 | clock-frequency = <400000>; | 61 | clock-frequency = <400000>; |
| 47 | }; | 62 | }; |
| 48 | |||
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index de04cd850353..02afe89de165 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig | |||
| @@ -419,13 +419,12 @@ config I2C_IXP2000 | |||
| 419 | instead. | 419 | instead. |
| 420 | 420 | ||
| 421 | config I2C_MPC | 421 | config I2C_MPC |
| 422 | tristate "MPC107/824x/85xx/52xx/86xx" | 422 | tristate "MPC107/824x/85xx/512x/52xx/83xx/86xx" |
| 423 | depends on PPC32 | 423 | depends on PPC32 |
| 424 | help | 424 | help |
| 425 | If you say yes to this option, support will be included for the | 425 | If you say yes to this option, support will be included for the |
| 426 | built-in I2C interface on the MPC107/Tsi107/MPC8240/MPC8245 and | 426 | built-in I2C interface on the MPC107, Tsi107, MPC512x, MPC52xx, |
| 427 | MPC85xx/MPC8641 family processors. The driver may also work on 52xx | 427 | MPC8240, MPC8245, MPC83xx, MPC85xx and MPC8641 family processors. |
| 428 | family processors, though interrupts are known not to work. | ||
| 429 | 428 | ||
| 430 | This driver can also be built as a module. If so, the module | 429 | This driver can also be built as a module. If so, the module |
| 431 | will be called i2c-mpc. | 430 | will be called i2c-mpc. |
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index f627001108b8..78a15af32942 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c | |||
| @@ -31,6 +31,9 @@ | |||
| 31 | 31 | ||
| 32 | #define DRV_NAME "mpc-i2c" | 32 | #define DRV_NAME "mpc-i2c" |
| 33 | 33 | ||
| 34 | #define MPC_I2C_CLOCK_LEGACY 0 | ||
| 35 | #define MPC_I2C_CLOCK_PRESERVE (~0U) | ||
| 36 | |||
| 34 | #define MPC_I2C_FDR 0x04 | 37 | #define MPC_I2C_FDR 0x04 |
| 35 | #define MPC_I2C_CR 0x08 | 38 | #define MPC_I2C_CR 0x08 |
| 36 | #define MPC_I2C_SR 0x0c | 39 | #define MPC_I2C_SR 0x0c |
| @@ -66,10 +69,9 @@ struct mpc_i2c_divider { | |||
| 66 | u16 fdr; /* including dfsrr */ | 69 | u16 fdr; /* including dfsrr */ |
| 67 | }; | 70 | }; |
| 68 | 71 | ||
| 69 | struct mpc_i2c_match_data { | 72 | struct mpc_i2c_data { |
| 70 | void (*setclock)(struct device_node *node, | 73 | void (*setup)(struct device_node *node, struct mpc_i2c *i2c, |
| 71 | struct mpc_i2c *i2c, | 74 | u32 clock, u32 prescaler); |
| 72 | u32 clock, u32 prescaler); | ||
| 73 | u32 prescaler; | 75 | u32 prescaler; |
| 74 | }; | 76 | }; |
| 75 | 77 | ||
| @@ -164,8 +166,8 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) | |||
| 164 | return 0; | 166 | return 0; |
| 165 | } | 167 | } |
| 166 | 168 | ||
| 167 | #ifdef CONFIG_PPC_MPC52xx | 169 | #if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x) |
| 168 | static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { | 170 | static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] __devinitconst = { |
| 169 | {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23}, | 171 | {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23}, |
| 170 | {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02}, | 172 | {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02}, |
| 171 | {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28}, | 173 | {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28}, |
| @@ -186,14 +188,15 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { | |||
| 186 | {10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f} | 188 | {10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f} |
| 187 | }; | 189 | }; |
| 188 | 190 | ||
| 189 | int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler) | 191 | static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, |
| 192 | int prescaler) | ||
| 190 | { | 193 | { |
| 191 | const struct mpc_i2c_divider *div = NULL; | 194 | const struct mpc_i2c_divider *div = NULL; |
| 192 | unsigned int pvr = mfspr(SPRN_PVR); | 195 | unsigned int pvr = mfspr(SPRN_PVR); |
| 193 | u32 divider; | 196 | u32 divider; |
| 194 | int i; | 197 | int i; |
| 195 | 198 | ||
| 196 | if (!clock) | 199 | if (clock == MPC_I2C_CLOCK_LEGACY) |
| 197 | return -EINVAL; | 200 | return -EINVAL; |
| 198 | 201 | ||
| 199 | /* Determine divider value */ | 202 | /* Determine divider value */ |
| @@ -215,12 +218,18 @@ int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler) | |||
| 215 | return div ? (int)div->fdr : -EINVAL; | 218 | return div ? (int)div->fdr : -EINVAL; |
| 216 | } | 219 | } |
| 217 | 220 | ||
| 218 | static void mpc_i2c_setclock_52xx(struct device_node *node, | 221 | static void __devinit mpc_i2c_setup_52xx(struct device_node *node, |
| 219 | struct mpc_i2c *i2c, | 222 | struct mpc_i2c *i2c, |
| 220 | u32 clock, u32 prescaler) | 223 | u32 clock, u32 prescaler) |
| 221 | { | 224 | { |
| 222 | int ret, fdr; | 225 | int ret, fdr; |
| 223 | 226 | ||
| 227 | if (clock == MPC_I2C_CLOCK_PRESERVE) { | ||
| 228 | dev_dbg(i2c->dev, "using fdr %d\n", | ||
| 229 | readb(i2c->base + MPC_I2C_FDR)); | ||
| 230 | return; | ||
| 231 | } | ||
| 232 | |||
| 224 | ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler); | 233 | ret = mpc_i2c_get_fdr_52xx(node, clock, prescaler); |
| 225 | fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */ | 234 | fdr = (ret >= 0) ? ret : 0x3f; /* backward compatibility */ |
| 226 | 235 | ||
| @@ -229,16 +238,52 @@ static void mpc_i2c_setclock_52xx(struct device_node *node, | |||
| 229 | if (ret >= 0) | 238 | if (ret >= 0) |
| 230 | dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr); | 239 | dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr); |
| 231 | } | 240 | } |
| 232 | #else /* !CONFIG_PPC_MPC52xx */ | 241 | #else /* !(CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x) */ |
| 233 | static void mpc_i2c_setclock_52xx(struct device_node *node, | 242 | static void __devinit mpc_i2c_setup_52xx(struct device_node *node, |
| 234 | struct mpc_i2c *i2c, | 243 | struct mpc_i2c *i2c, |
| 235 | u32 clock, u32 prescaler) | 244 | u32 clock, u32 prescaler) |
| 245 | { | ||
| 246 | } | ||
| 247 | #endif /* CONFIG_PPC_MPC52xx || CONFIG_PPC_MPC512x */ | ||
| 248 | |||
| 249 | #ifdef CONFIG_PPC_MPC512x | ||
| 250 | static void __devinit mpc_i2c_setup_512x(struct device_node *node, | ||
| 251 | struct mpc_i2c *i2c, | ||
| 252 | u32 clock, u32 prescaler) | ||
| 253 | { | ||
| 254 | struct device_node *node_ctrl; | ||
| 255 | void __iomem *ctrl; | ||
| 256 | const u32 *pval; | ||
| 257 | u32 idx; | ||
| 258 | |||
| 259 | /* Enable I2C interrupts for mpc5121 */ | ||
| 260 | node_ctrl = of_find_compatible_node(NULL, NULL, | ||
| 261 | "fsl,mpc5121-i2c-ctrl"); | ||
| 262 | if (node_ctrl) { | ||
| 263 | ctrl = of_iomap(node_ctrl, 0); | ||
| 264 | if (ctrl) { | ||
| 265 | /* Interrupt enable bits for i2c-0/1/2: bit 24/26/28 */ | ||
| 266 | pval = of_get_property(node, "reg", NULL); | ||
| 267 | idx = (*pval & 0xff) / 0x20; | ||
| 268 | setbits32(ctrl, 1 << (24 + idx * 2)); | ||
| 269 | iounmap(ctrl); | ||
| 270 | } | ||
| 271 | of_node_put(node_ctrl); | ||
| 272 | } | ||
| 273 | |||
| 274 | /* The clock setup for the 52xx works also fine for the 512x */ | ||
| 275 | mpc_i2c_setup_52xx(node, i2c, clock, prescaler); | ||
| 276 | } | ||
| 277 | #else /* CONFIG_PPC_MPC512x */ | ||
| 278 | static void __devinit mpc_i2c_setup_512x(struct device_node *node, | ||
| 279 | struct mpc_i2c *i2c, | ||
| 280 | u32 clock, u32 prescaler) | ||
| 236 | { | 281 | { |
| 237 | } | 282 | } |
| 238 | #endif /* CONFIG_PPC_MPC52xx*/ | 283 | #endif /* CONFIG_PPC_MPC512x */ |
| 239 | 284 | ||
| 240 | #ifdef CONFIG_FSL_SOC | 285 | #ifdef CONFIG_FSL_SOC |
| 241 | static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = { | 286 | static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] __devinitconst = { |
| 242 | {160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123}, | 287 | {160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123}, |
| 243 | {288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102}, | 288 | {288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102}, |
| 244 | {416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127}, | 289 | {416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127}, |
| @@ -258,7 +303,7 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = { | |||
| 258 | {49152, 0x011e}, {61440, 0x011f} | 303 | {49152, 0x011e}, {61440, 0x011f} |
| 259 | }; | 304 | }; |
| 260 | 305 | ||
| 261 | u32 mpc_i2c_get_sec_cfg_8xxx(void) | 306 | static u32 __devinit mpc_i2c_get_sec_cfg_8xxx(void) |
| 262 | { | 307 | { |
| 263 | struct device_node *node = NULL; | 308 | struct device_node *node = NULL; |
| 264 | u32 __iomem *reg; | 309 | u32 __iomem *reg; |
| @@ -287,13 +332,14 @@ u32 mpc_i2c_get_sec_cfg_8xxx(void) | |||
| 287 | return val; | 332 | return val; |
| 288 | } | 333 | } |
| 289 | 334 | ||
| 290 | int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler) | 335 | static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, |
| 336 | u32 prescaler) | ||
| 291 | { | 337 | { |
| 292 | const struct mpc_i2c_divider *div = NULL; | 338 | const struct mpc_i2c_divider *div = NULL; |
| 293 | u32 divider; | 339 | u32 divider; |
| 294 | int i; | 340 | int i; |
| 295 | 341 | ||
| 296 | if (!clock) | 342 | if (clock == MPC_I2C_CLOCK_LEGACY) |
| 297 | return -EINVAL; | 343 | return -EINVAL; |
| 298 | 344 | ||
| 299 | /* Determine proper divider value */ | 345 | /* Determine proper divider value */ |
| @@ -320,12 +366,19 @@ int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler) | |||
| 320 | return div ? (int)div->fdr : -EINVAL; | 366 | return div ? (int)div->fdr : -EINVAL; |
| 321 | } | 367 | } |
| 322 | 368 | ||
| 323 | static void mpc_i2c_setclock_8xxx(struct device_node *node, | 369 | static void __devinit mpc_i2c_setup_8xxx(struct device_node *node, |
| 324 | struct mpc_i2c *i2c, | 370 | struct mpc_i2c *i2c, |
| 325 | u32 clock, u32 prescaler) | 371 | u32 clock, u32 prescaler) |
| 326 | { | 372 | { |
| 327 | int ret, fdr; | 373 | int ret, fdr; |
| 328 | 374 | ||
| 375 | if (clock == MPC_I2C_CLOCK_PRESERVE) { | ||
| 376 | dev_dbg(i2c->dev, "using dfsrr %d, fdr %d\n", | ||
| 377 | readb(i2c->base + MPC_I2C_DFSRR), | ||
| 378 | readb(i2c->base + MPC_I2C_FDR)); | ||
| 379 | return; | ||
| 380 | } | ||
| 381 | |||
| 329 | ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler); | 382 | ret = mpc_i2c_get_fdr_8xxx(node, clock, prescaler); |
| 330 | fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */ | 383 | fdr = (ret >= 0) ? ret : 0x1031; /* backward compatibility */ |
| 331 | 384 | ||
| @@ -338,9 +391,9 @@ static void mpc_i2c_setclock_8xxx(struct device_node *node, | |||
| 338 | } | 391 | } |
| 339 | 392 | ||
| 340 | #else /* !CONFIG_FSL_SOC */ | 393 | #else /* !CONFIG_FSL_SOC */ |
| 341 | static void mpc_i2c_setclock_8xxx(struct device_node *node, | 394 | static void __devinit mpc_i2c_setup_8xxx(struct device_node *node, |
| 342 | struct mpc_i2c *i2c, | 395 | struct mpc_i2c *i2c, |
| 343 | u32 clock, u32 prescaler) | 396 | u32 clock, u32 prescaler) |
| 344 | { | 397 | { |
| 345 | } | 398 | } |
| 346 | #endif /* CONFIG_FSL_SOC */ | 399 | #endif /* CONFIG_FSL_SOC */ |
| @@ -494,7 +547,7 @@ static int __devinit fsl_i2c_probe(struct of_device *op, | |||
| 494 | { | 547 | { |
| 495 | struct mpc_i2c *i2c; | 548 | struct mpc_i2c *i2c; |
| 496 | const u32 *prop; | 549 | const u32 *prop; |
| 497 | u32 clock = 0; | 550 | u32 clock = MPC_I2C_CLOCK_LEGACY; |
| 498 | int result = 0; | 551 | int result = 0; |
| 499 | int plen; | 552 | int plen; |
| 500 | 553 | ||
| @@ -523,21 +576,21 @@ static int __devinit fsl_i2c_probe(struct of_device *op, | |||
| 523 | } | 576 | } |
| 524 | } | 577 | } |
| 525 | 578 | ||
| 526 | if (!of_get_property(op->node, "fsl,preserve-clocking", NULL)) { | 579 | if (of_get_property(op->node, "fsl,preserve-clocking", NULL)) { |
| 580 | clock = MPC_I2C_CLOCK_PRESERVE; | ||
| 581 | } else { | ||
| 527 | prop = of_get_property(op->node, "clock-frequency", &plen); | 582 | prop = of_get_property(op->node, "clock-frequency", &plen); |
| 528 | if (prop && plen == sizeof(u32)) | 583 | if (prop && plen == sizeof(u32)) |
| 529 | clock = *prop; | 584 | clock = *prop; |
| 585 | } | ||
| 530 | 586 | ||
| 531 | if (match->data) { | 587 | if (match->data) { |
| 532 | struct mpc_i2c_match_data *data = | 588 | struct mpc_i2c_data *data = match->data; |
| 533 | (struct mpc_i2c_match_data *)match->data; | 589 | data->setup(op->node, i2c, clock, data->prescaler); |
| 534 | data->setclock(op->node, i2c, clock, data->prescaler); | 590 | } else { |
| 535 | } else { | 591 | /* Backwards compatibility */ |
| 536 | /* Backwards compatibility */ | 592 | if (of_get_property(op->node, "dfsrr", NULL)) |
| 537 | if (of_get_property(op->node, "dfsrr", NULL)) | 593 | mpc_i2c_setup_8xxx(op->node, i2c, clock, 0); |
| 538 | mpc_i2c_setclock_8xxx(op->node, i2c, | ||
| 539 | clock, 0); | ||
| 540 | } | ||
| 541 | } | 594 | } |
| 542 | 595 | ||
| 543 | dev_set_drvdata(&op->dev, i2c); | 596 | dev_set_drvdata(&op->dev, i2c); |
| @@ -582,47 +635,42 @@ static int __devexit fsl_i2c_remove(struct of_device *op) | |||
| 582 | return 0; | 635 | return 0; |
| 583 | }; | 636 | }; |
| 584 | 637 | ||
| 638 | static struct mpc_i2c_data mpc_i2c_data_512x __devinitdata = { | ||
| 639 | .setup = mpc_i2c_setup_512x, | ||
| 640 | }; | ||
| 641 | |||
| 642 | static struct mpc_i2c_data mpc_i2c_data_52xx __devinitdata = { | ||
| 643 | .setup = mpc_i2c_setup_52xx, | ||
| 644 | }; | ||
| 645 | |||
| 646 | static struct mpc_i2c_data mpc_i2c_data_8313 __devinitdata = { | ||
| 647 | .setup = mpc_i2c_setup_8xxx, | ||
| 648 | }; | ||
| 649 | |||
| 650 | static struct mpc_i2c_data mpc_i2c_data_8543 __devinitdata = { | ||
| 651 | .setup = mpc_i2c_setup_8xxx, | ||
| 652 | .prescaler = 2, | ||
| 653 | }; | ||
| 654 | |||
| 655 | static struct mpc_i2c_data mpc_i2c_data_8544 __devinitdata = { | ||
| 656 | .setup = mpc_i2c_setup_8xxx, | ||
| 657 | .prescaler = 3, | ||
| 658 | }; | ||
| 659 | |||
| 585 | static const struct of_device_id mpc_i2c_of_match[] = { | 660 | static const struct of_device_id mpc_i2c_of_match[] = { |
| 586 | {.compatible = "mpc5200-i2c", | 661 | {.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, }, |
| 587 | .data = &(struct mpc_i2c_match_data) { | 662 | {.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, }, |
| 588 | .setclock = mpc_i2c_setclock_52xx, | 663 | {.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, }, |
| 589 | }, | 664 | {.compatible = "fsl,mpc5121-i2c", .data = &mpc_i2c_data_512x, }, |
| 590 | }, | 665 | {.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, }, |
| 591 | {.compatible = "fsl,mpc5200b-i2c", | 666 | {.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, }, |
| 592 | .data = &(struct mpc_i2c_match_data) { | 667 | {.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, }, |
| 593 | .setclock = mpc_i2c_setclock_52xx, | ||
| 594 | }, | ||
| 595 | }, | ||
| 596 | {.compatible = "fsl,mpc5200-i2c", | ||
| 597 | .data = &(struct mpc_i2c_match_data) { | ||
| 598 | .setclock = mpc_i2c_setclock_52xx, | ||
| 599 | }, | ||
| 600 | }, | ||
| 601 | {.compatible = "fsl,mpc8313-i2c", | ||
| 602 | .data = &(struct mpc_i2c_match_data) { | ||
| 603 | .setclock = mpc_i2c_setclock_8xxx, | ||
| 604 | }, | ||
| 605 | }, | ||
| 606 | {.compatible = "fsl,mpc8543-i2c", | ||
| 607 | .data = &(struct mpc_i2c_match_data) { | ||
| 608 | .setclock = mpc_i2c_setclock_8xxx, | ||
| 609 | .prescaler = 2, | ||
| 610 | }, | ||
| 611 | }, | ||
| 612 | {.compatible = "fsl,mpc8544-i2c", | ||
| 613 | .data = &(struct mpc_i2c_match_data) { | ||
| 614 | .setclock = mpc_i2c_setclock_8xxx, | ||
| 615 | .prescaler = 3, | ||
| 616 | }, | ||
| 617 | /* Backward compatibility */ | 668 | /* Backward compatibility */ |
| 618 | }, | ||
| 619 | {.compatible = "fsl-i2c", }, | 669 | {.compatible = "fsl-i2c", }, |
| 620 | {}, | 670 | {}, |
| 621 | }; | 671 | }; |
| 622 | |||
| 623 | MODULE_DEVICE_TABLE(of, mpc_i2c_of_match); | 672 | MODULE_DEVICE_TABLE(of, mpc_i2c_of_match); |
| 624 | 673 | ||
| 625 | |||
| 626 | /* Structure for a device driver */ | 674 | /* Structure for a device driver */ |
| 627 | static struct of_platform_driver mpc_i2c_driver = { | 675 | static struct of_platform_driver mpc_i2c_driver = { |
| 628 | .match_table = mpc_i2c_of_match, | 676 | .match_table = mpc_i2c_of_match, |
| @@ -655,5 +703,5 @@ module_exit(fsl_i2c_exit); | |||
| 655 | 703 | ||
| 656 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); | 704 | MODULE_AUTHOR("Adrian Cox <adrian@humboldt.co.uk>"); |
| 657 | MODULE_DESCRIPTION("I2C-Bus adapter for MPC107 bridge and " | 705 | MODULE_DESCRIPTION("I2C-Bus adapter for MPC107 bridge and " |
| 658 | "MPC824x/85xx/52xx processors"); | 706 | "MPC824x/83xx/85xx/86xx/512x/52xx processors"); |
| 659 | MODULE_LICENSE("GPL"); | 707 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 0037e31076ba..913abd7c172f 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
| @@ -49,24 +49,24 @@ | |||
| 49 | #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) | 49 | #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) |
| 50 | 50 | ||
| 51 | #define OMAP_I2C_REV_REG 0x00 | 51 | #define OMAP_I2C_REV_REG 0x00 |
| 52 | #define OMAP_I2C_IE_REG 0x04 | 52 | #define OMAP_I2C_IE_REG 0x01 |
| 53 | #define OMAP_I2C_STAT_REG 0x08 | 53 | #define OMAP_I2C_STAT_REG 0x02 |
| 54 | #define OMAP_I2C_IV_REG 0x0c | 54 | #define OMAP_I2C_IV_REG 0x03 |
| 55 | /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ | 55 | /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ |
| 56 | #define OMAP_I2C_WE_REG 0x0c | 56 | #define OMAP_I2C_WE_REG 0x03 |
| 57 | #define OMAP_I2C_SYSS_REG 0x10 | 57 | #define OMAP_I2C_SYSS_REG 0x04 |
| 58 | #define OMAP_I2C_BUF_REG 0x14 | 58 | #define OMAP_I2C_BUF_REG 0x05 |
| 59 | #define OMAP_I2C_CNT_REG 0x18 | 59 | #define OMAP_I2C_CNT_REG 0x06 |
| 60 | #define OMAP_I2C_DATA_REG 0x1c | 60 | #define OMAP_I2C_DATA_REG 0x07 |
| 61 | #define OMAP_I2C_SYSC_REG 0x20 | 61 | #define OMAP_I2C_SYSC_REG 0x08 |
| 62 | #define OMAP_I2C_CON_REG 0x24 | 62 | #define OMAP_I2C_CON_REG 0x09 |
| 63 | #define OMAP_I2C_OA_REG 0x28 | 63 | #define OMAP_I2C_OA_REG 0x0a |
| 64 | #define OMAP_I2C_SA_REG 0x2c | 64 | #define OMAP_I2C_SA_REG 0x0b |
| 65 | #define OMAP_I2C_PSC_REG 0x30 | 65 | #define OMAP_I2C_PSC_REG 0x0c |
| 66 | #define OMAP_I2C_SCLL_REG 0x34 | 66 | #define OMAP_I2C_SCLL_REG 0x0d |
| 67 | #define OMAP_I2C_SCLH_REG 0x38 | 67 | #define OMAP_I2C_SCLH_REG 0x0e |
| 68 | #define OMAP_I2C_SYSTEST_REG 0x3c | 68 | #define OMAP_I2C_SYSTEST_REG 0x0f |
| 69 | #define OMAP_I2C_BUFSTAT_REG 0x40 | 69 | #define OMAP_I2C_BUFSTAT_REG 0x10 |
| 70 | 70 | ||
| 71 | /* I2C Interrupt Enable Register (OMAP_I2C_IE): */ | 71 | /* I2C Interrupt Enable Register (OMAP_I2C_IE): */ |
| 72 | #define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */ | 72 | #define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */ |
| @@ -161,6 +161,7 @@ struct omap_i2c_dev { | |||
| 161 | struct device *dev; | 161 | struct device *dev; |
| 162 | void __iomem *base; /* virtual */ | 162 | void __iomem *base; /* virtual */ |
| 163 | int irq; | 163 | int irq; |
| 164 | int reg_shift; /* bit shift for I2C register addresses */ | ||
| 164 | struct clk *iclk; /* Interface clock */ | 165 | struct clk *iclk; /* Interface clock */ |
| 165 | struct clk *fclk; /* Functional clock */ | 166 | struct clk *fclk; /* Functional clock */ |
| 166 | struct completion cmd_complete; | 167 | struct completion cmd_complete; |
| @@ -189,12 +190,12 @@ struct omap_i2c_dev { | |||
| 189 | static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, | 190 | static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, |
| 190 | int reg, u16 val) | 191 | int reg, u16 val) |
| 191 | { | 192 | { |
| 192 | __raw_writew(val, i2c_dev->base + reg); | 193 | __raw_writew(val, i2c_dev->base + (reg << i2c_dev->reg_shift)); |
| 193 | } | 194 | } |
| 194 | 195 | ||
| 195 | static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) | 196 | static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) |
| 196 | { | 197 | { |
| 197 | return __raw_readw(i2c_dev->base + reg); | 198 | return __raw_readw(i2c_dev->base + (reg << i2c_dev->reg_shift)); |
| 198 | } | 199 | } |
| 199 | 200 | ||
| 200 | static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) | 201 | static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) |
| @@ -924,6 +925,11 @@ omap_i2c_probe(struct platform_device *pdev) | |||
| 924 | dev->b_hw = 1; /* Enable hardware fixes */ | 925 | dev->b_hw = 1; /* Enable hardware fixes */ |
| 925 | } | 926 | } |
| 926 | 927 | ||
| 928 | if (cpu_is_omap7xx()) | ||
| 929 | dev->reg_shift = 1; | ||
| 930 | else | ||
| 931 | dev->reg_shift = 2; | ||
| 932 | |||
| 927 | /* reset ASAP, clearing any IRQs */ | 933 | /* reset ASAP, clearing any IRQs */ |
| 928 | omap_i2c_init(dev); | 934 | omap_i2c_init(dev); |
| 929 | 935 | ||
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index 2b0bd0b042d6..9532dee6b580 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
| @@ -172,12 +172,6 @@ static int i2c_pnx_master_xmit(struct i2c_pnx_algo_data *alg_data) | |||
| 172 | /* We still have something to talk about... */ | 172 | /* We still have something to talk about... */ |
| 173 | val = *alg_data->mif.buf++; | 173 | val = *alg_data->mif.buf++; |
| 174 | 174 | ||
| 175 | if (alg_data->mif.len == 1) { | ||
| 176 | val |= stop_bit; | ||
| 177 | if (!alg_data->last) | ||
| 178 | val |= start_bit; | ||
| 179 | } | ||
| 180 | |||
| 181 | alg_data->mif.len--; | 175 | alg_data->mif.len--; |
| 182 | iowrite32(val, I2C_REG_TX(alg_data)); | 176 | iowrite32(val, I2C_REG_TX(alg_data)); |
| 183 | 177 | ||
| @@ -251,11 +245,6 @@ static int i2c_pnx_master_rcv(struct i2c_pnx_algo_data *alg_data) | |||
| 251 | __func__); | 245 | __func__); |
| 252 | 246 | ||
| 253 | if (alg_data->mif.len == 1) { | 247 | if (alg_data->mif.len == 1) { |
| 254 | /* Last byte, do not acknowledge next rcv. */ | ||
| 255 | val |= stop_bit; | ||
| 256 | if (!alg_data->last) | ||
| 257 | val |= start_bit; | ||
| 258 | |||
| 259 | /* | 248 | /* |
| 260 | * Enable interrupt RFDAIE (data in Rx fifo), | 249 | * Enable interrupt RFDAIE (data in Rx fifo), |
| 261 | * and disable DRMIE (need data for Tx) | 250 | * and disable DRMIE (need data for Tx) |
