aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-mpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-mpc.c')
-rw-r--r--drivers/i2c/busses/i2c-mpc.c99
1 files changed, 46 insertions, 53 deletions
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index f627001108b8..2f74d9b6c0b9 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -66,7 +66,7 @@ struct mpc_i2c_divider {
66 u16 fdr; /* including dfsrr */ 66 u16 fdr; /* including dfsrr */
67}; 67};
68 68
69struct mpc_i2c_match_data { 69struct mpc_i2c_data {
70 void (*setclock)(struct device_node *node, 70 void (*setclock)(struct device_node *node,
71 struct mpc_i2c *i2c, 71 struct mpc_i2c *i2c,
72 u32 clock, u32 prescaler); 72 u32 clock, u32 prescaler);
@@ -165,7 +165,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
165} 165}
166 166
167#ifdef CONFIG_PPC_MPC52xx 167#ifdef CONFIG_PPC_MPC52xx
168static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { 168static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] __devinitconst = {
169 {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23}, 169 {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23},
170 {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02}, 170 {28, 0x24}, {30, 0x01}, {32, 0x25}, {34, 0x02},
171 {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28}, 171 {36, 0x26}, {40, 0x27}, {44, 0x04}, {48, 0x28},
@@ -186,7 +186,8 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = {
186 {10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f} 186 {10240, 0x9d}, {12288, 0x9e}, {15360, 0x9f}
187}; 187};
188 188
189int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler) 189static int __devinit mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock,
190 int prescaler)
190{ 191{
191 const struct mpc_i2c_divider *div = NULL; 192 const struct mpc_i2c_divider *div = NULL;
192 unsigned int pvr = mfspr(SPRN_PVR); 193 unsigned int pvr = mfspr(SPRN_PVR);
@@ -215,9 +216,9 @@ int mpc_i2c_get_fdr_52xx(struct device_node *node, u32 clock, int prescaler)
215 return div ? (int)div->fdr : -EINVAL; 216 return div ? (int)div->fdr : -EINVAL;
216} 217}
217 218
218static void mpc_i2c_setclock_52xx(struct device_node *node, 219static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
219 struct mpc_i2c *i2c, 220 struct mpc_i2c *i2c,
220 u32 clock, u32 prescaler) 221 u32 clock, u32 prescaler)
221{ 222{
222 int ret, fdr; 223 int ret, fdr;
223 224
@@ -230,15 +231,15 @@ static void mpc_i2c_setclock_52xx(struct device_node *node,
230 dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr); 231 dev_info(i2c->dev, "clock %d Hz (fdr=%d)\n", clock, fdr);
231} 232}
232#else /* !CONFIG_PPC_MPC52xx */ 233#else /* !CONFIG_PPC_MPC52xx */
233static void mpc_i2c_setclock_52xx(struct device_node *node, 234static void __devinit mpc_i2c_setclock_52xx(struct device_node *node,
234 struct mpc_i2c *i2c, 235 struct mpc_i2c *i2c,
235 u32 clock, u32 prescaler) 236 u32 clock, u32 prescaler)
236{ 237{
237} 238}
238#endif /* CONFIG_PPC_MPC52xx*/ 239#endif /* CONFIG_PPC_MPC52xx*/
239 240
240#ifdef CONFIG_FSL_SOC 241#ifdef CONFIG_FSL_SOC
241static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = { 242static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] __devinitconst = {
242 {160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123}, 243 {160, 0x0120}, {192, 0x0121}, {224, 0x0122}, {256, 0x0123},
243 {288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102}, 244 {288, 0x0100}, {320, 0x0101}, {352, 0x0601}, {384, 0x0102},
244 {416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127}, 245 {416, 0x0602}, {448, 0x0126}, {480, 0x0103}, {512, 0x0127},
@@ -258,7 +259,7 @@ static const struct mpc_i2c_divider mpc_i2c_dividers_8xxx[] = {
258 {49152, 0x011e}, {61440, 0x011f} 259 {49152, 0x011e}, {61440, 0x011f}
259}; 260};
260 261
261u32 mpc_i2c_get_sec_cfg_8xxx(void) 262static u32 __devinit mpc_i2c_get_sec_cfg_8xxx(void)
262{ 263{
263 struct device_node *node = NULL; 264 struct device_node *node = NULL;
264 u32 __iomem *reg; 265 u32 __iomem *reg;
@@ -287,7 +288,8 @@ u32 mpc_i2c_get_sec_cfg_8xxx(void)
287 return val; 288 return val;
288} 289}
289 290
290int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler) 291static int __devinit mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock,
292 u32 prescaler)
291{ 293{
292 const struct mpc_i2c_divider *div = NULL; 294 const struct mpc_i2c_divider *div = NULL;
293 u32 divider; 295 u32 divider;
@@ -320,9 +322,9 @@ int mpc_i2c_get_fdr_8xxx(struct device_node *node, u32 clock, u32 prescaler)
320 return div ? (int)div->fdr : -EINVAL; 322 return div ? (int)div->fdr : -EINVAL;
321} 323}
322 324
323static void mpc_i2c_setclock_8xxx(struct device_node *node, 325static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
324 struct mpc_i2c *i2c, 326 struct mpc_i2c *i2c,
325 u32 clock, u32 prescaler) 327 u32 clock, u32 prescaler)
326{ 328{
327 int ret, fdr; 329 int ret, fdr;
328 330
@@ -338,9 +340,9 @@ static void mpc_i2c_setclock_8xxx(struct device_node *node,
338} 340}
339 341
340#else /* !CONFIG_FSL_SOC */ 342#else /* !CONFIG_FSL_SOC */
341static void mpc_i2c_setclock_8xxx(struct device_node *node, 343static void __devinit mpc_i2c_setclock_8xxx(struct device_node *node,
342 struct mpc_i2c *i2c, 344 struct mpc_i2c *i2c,
343 u32 clock, u32 prescaler) 345 u32 clock, u32 prescaler)
344{ 346{
345} 347}
346#endif /* CONFIG_FSL_SOC */ 348#endif /* CONFIG_FSL_SOC */
@@ -529,8 +531,8 @@ static int __devinit fsl_i2c_probe(struct of_device *op,
529 clock = *prop; 531 clock = *prop;
530 532
531 if (match->data) { 533 if (match->data) {
532 struct mpc_i2c_match_data *data = 534 struct mpc_i2c_data *data =
533 (struct mpc_i2c_match_data *)match->data; 535 (struct mpc_i2c_data *)match->data;
534 data->setclock(op->node, i2c, clock, data->prescaler); 536 data->setclock(op->node, i2c, clock, data->prescaler);
535 } else { 537 } else {
536 /* Backwards compatibility */ 538 /* Backwards compatibility */
@@ -582,44 +584,35 @@ static int __devexit fsl_i2c_remove(struct of_device *op)
582 return 0; 584 return 0;
583}; 585};
584 586
587static struct mpc_i2c_data mpc_i2c_data_52xx __devinitdata = {
588 .setclock = mpc_i2c_setclock_52xx,
589};
590
591static struct mpc_i2c_data mpc_i2c_data_8313 __devinitdata = {
592 .setclock = mpc_i2c_setclock_8xxx,
593};
594
595static struct mpc_i2c_data mpc_i2c_data_8543 __devinitdata = {
596 .setclock = mpc_i2c_setclock_8xxx,
597 .prescaler = 2,
598};
599
600static struct mpc_i2c_data mpc_i2c_data_8544 __devinitdata = {
601 .setclock = mpc_i2c_setclock_8xxx,
602 .prescaler = 3,
603};
604
585static const struct of_device_id mpc_i2c_of_match[] = { 605static const struct of_device_id mpc_i2c_of_match[] = {
586 {.compatible = "mpc5200-i2c", 606 {.compatible = "mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
587 .data = &(struct mpc_i2c_match_data) { 607 {.compatible = "fsl,mpc5200b-i2c", .data = &mpc_i2c_data_52xx, },
588 .setclock = mpc_i2c_setclock_52xx, 608 {.compatible = "fsl,mpc5200-i2c", .data = &mpc_i2c_data_52xx, },
589 }, 609 {.compatible = "fsl,mpc8313-i2c", .data = &mpc_i2c_data_8313, },
590 }, 610 {.compatible = "fsl,mpc8543-i2c", .data = &mpc_i2c_data_8543, },
591 {.compatible = "fsl,mpc5200b-i2c", 611 {.compatible = "fsl,mpc8544-i2c", .data = &mpc_i2c_data_8544, },
592 .data = &(struct mpc_i2c_match_data) {
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 */ 612 /* Backward compatibility */
618 },
619 {.compatible = "fsl-i2c", }, 613 {.compatible = "fsl-i2c", },
620 {}, 614 {},
621}; 615};
622
623MODULE_DEVICE_TABLE(of, mpc_i2c_of_match); 616MODULE_DEVICE_TABLE(of, mpc_i2c_of_match);
624 617
625 618