diff options
author | Andy Green <andy@warmcat.com> | 2011-05-30 10:43:09 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-10-29 04:37:08 -0400 |
commit | 3be0053ee1a8bfb68de82716ae784f75e1610d60 (patch) | |
tree | 37ced3431cc2c24d2b6f6819f83e03bed2a0d91e /drivers/i2c/busses/i2c-omap.c | |
parent | 8e286f5a2156f71dd304ce9ad1cd6b07231aaae6 (diff) |
I2C: OMAP2+: Convert omap I2C driver to use feature implementation flags from platform data
This patch eliminates all cpu_...() tests from the OMAP I2C driver.
Instead, it uses the functionality flags in the platform data to make
the decisions about product variations the driver needs to handle.
Cc: patches@linaro.org
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andy Green <andy.green@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'drivers/i2c/busses/i2c-omap.c')
-rw-r--r-- | drivers/i2c/busses/i2c-omap.c | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 0254da47952b..3aaf7f127514 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c | |||
@@ -277,7 +277,7 @@ static void omap_i2c_unidle(struct omap_i2c_dev *dev) | |||
277 | 277 | ||
278 | pm_runtime_get_sync(&pdev->dev); | 278 | pm_runtime_get_sync(&pdev->dev); |
279 | 279 | ||
280 | if (cpu_is_omap34xx()) { | 280 | if (pdata->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) { |
281 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | 281 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); |
282 | omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate); | 282 | omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate); |
283 | omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate); | 283 | omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate); |
@@ -335,6 +335,11 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
335 | unsigned long timeout; | 335 | unsigned long timeout; |
336 | unsigned long internal_clk = 0; | 336 | unsigned long internal_clk = 0; |
337 | struct clk *fclk; | 337 | struct clk *fclk; |
338 | struct platform_device *pdev; | ||
339 | struct omap_i2c_bus_platform_data *pdata; | ||
340 | |||
341 | pdev = to_platform_device(dev->dev); | ||
342 | pdata = pdev->dev.platform_data; | ||
338 | 343 | ||
339 | if (dev->rev >= OMAP_I2C_OMAP1_REV_2) { | 344 | if (dev->rev >= OMAP_I2C_OMAP1_REV_2) { |
340 | /* Disable I2C controller before soft reset */ | 345 | /* Disable I2C controller before soft reset */ |
@@ -386,7 +391,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
386 | } | 391 | } |
387 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); | 392 | omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); |
388 | 393 | ||
389 | if (cpu_class_is_omap1()) { | 394 | if (pdata->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) { |
390 | /* | 395 | /* |
391 | * The I2C functional clock is the armxor_ck, so there's | 396 | * The I2C functional clock is the armxor_ck, so there's |
392 | * no need to get "armxor_ck" separately. Now, if OMAP2420 | 397 | * no need to get "armxor_ck" separately. Now, if OMAP2420 |
@@ -410,7 +415,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
410 | psc = fclk_rate / 12000000; | 415 | psc = fclk_rate / 12000000; |
411 | } | 416 | } |
412 | 417 | ||
413 | if (!(cpu_class_is_omap1() || cpu_is_omap2420())) { | 418 | if (!(pdata->flags & OMAP_I2C_FLAG_SIMPLE_CLOCK)) { |
414 | 419 | ||
415 | /* | 420 | /* |
416 | * HSI2C controller internal clk rate should be 19.2 Mhz for | 421 | * HSI2C controller internal clk rate should be 19.2 Mhz for |
@@ -418,7 +423,8 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
418 | * to get longer filter period for better noise suppression. | 423 | * to get longer filter period for better noise suppression. |
419 | * The filter is iclk (fclk for HS) period. | 424 | * The filter is iclk (fclk for HS) period. |
420 | */ | 425 | */ |
421 | if (dev->speed > 400 || cpu_is_omap2430()) | 426 | if (dev->speed > 400 || |
427 | pdata->flags & OMAP_I2C_FLAG_FORCE_19200_INT_CLK) | ||
422 | internal_clk = 19200; | 428 | internal_clk = 19200; |
423 | else if (dev->speed > 100) | 429 | else if (dev->speed > 100) |
424 | internal_clk = 9600; | 430 | internal_clk = 9600; |
@@ -487,7 +493,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
487 | 493 | ||
488 | dev->errata = 0; | 494 | dev->errata = 0; |
489 | 495 | ||
490 | if (cpu_is_omap2430() || cpu_is_omap34xx()) | 496 | if (pdata->flags & OMAP_I2C_FLAG_APPLY_ERRATA_I207) |
491 | dev->errata |= I2C_OMAP_ERRATA_I207; | 497 | dev->errata |= I2C_OMAP_ERRATA_I207; |
492 | 498 | ||
493 | /* Enable interrupts */ | 499 | /* Enable interrupts */ |
@@ -496,7 +502,7 @@ static int omap_i2c_init(struct omap_i2c_dev *dev) | |||
496 | OMAP_I2C_IE_AL) | ((dev->fifo_size) ? | 502 | OMAP_I2C_IE_AL) | ((dev->fifo_size) ? |
497 | (OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0); | 503 | (OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0); |
498 | omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate); | 504 | omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate); |
499 | if (cpu_is_omap34xx()) { | 505 | if (pdata->flags & OMAP_I2C_FLAG_RESET_REGS_POSTIDLE) { |
500 | dev->pscstate = psc; | 506 | dev->pscstate = psc; |
501 | dev->scllstate = scll; | 507 | dev->scllstate = scll; |
502 | dev->sclhstate = sclh; | 508 | dev->sclhstate = sclh; |
@@ -816,6 +822,11 @@ omap_i2c_isr(int this_irq, void *dev_id) | |||
816 | u16 bits; | 822 | u16 bits; |
817 | u16 stat, w; | 823 | u16 stat, w; |
818 | int err, count = 0; | 824 | int err, count = 0; |
825 | struct platform_device *pdev; | ||
826 | struct omap_i2c_bus_platform_data *pdata; | ||
827 | |||
828 | pdev = to_platform_device(dev->dev); | ||
829 | pdata = pdev->dev.platform_data; | ||
819 | 830 | ||
820 | if (dev->idle) | 831 | if (dev->idle) |
821 | return IRQ_NONE; | 832 | return IRQ_NONE; |
@@ -884,8 +895,8 @@ complete: | |||
884 | * Data reg in 2430, omap3 and | 895 | * Data reg in 2430, omap3 and |
885 | * omap4 is 8 bit wide | 896 | * omap4 is 8 bit wide |
886 | */ | 897 | */ |
887 | if (cpu_class_is_omap1() || | 898 | if (pdata->flags & |
888 | cpu_is_omap2420()) { | 899 | OMAP_I2C_FLAG_16BIT_DATA_REG) { |
889 | if (dev->buf_len) { | 900 | if (dev->buf_len) { |
890 | *dev->buf++ = w >> 8; | 901 | *dev->buf++ = w >> 8; |
891 | dev->buf_len--; | 902 | dev->buf_len--; |
@@ -927,8 +938,8 @@ complete: | |||
927 | * Data reg in 2430, omap3 and | 938 | * Data reg in 2430, omap3 and |
928 | * omap4 is 8 bit wide | 939 | * omap4 is 8 bit wide |
929 | */ | 940 | */ |
930 | if (cpu_class_is_omap1() || | 941 | if (pdata->flags & |
931 | cpu_is_omap2420()) { | 942 | OMAP_I2C_FLAG_16BIT_DATA_REG) { |
932 | if (dev->buf_len) { | 943 | if (dev->buf_len) { |
933 | w |= *dev->buf++ << 8; | 944 | w |= *dev->buf++ << 8; |
934 | dev->buf_len--; | 945 | dev->buf_len--; |
@@ -1030,12 +1041,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1030 | 1041 | ||
1031 | platform_set_drvdata(pdev, dev); | 1042 | platform_set_drvdata(pdev, dev); |
1032 | 1043 | ||
1033 | if (cpu_is_omap7xx()) | 1044 | dev->reg_shift = (pdata->flags >> OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3; |
1034 | dev->reg_shift = 1; | ||
1035 | else if (cpu_is_omap44xx()) | ||
1036 | dev->reg_shift = 0; | ||
1037 | else | ||
1038 | dev->reg_shift = 2; | ||
1039 | 1045 | ||
1040 | if (pdata->rev == OMAP_I2C_IP_VERSION_2) | 1046 | if (pdata->rev == OMAP_I2C_IP_VERSION_2) |
1041 | dev->regs = (u8 *)reg_map_ip_v2; | 1047 | dev->regs = (u8 *)reg_map_ip_v2; |
@@ -1050,7 +1056,7 @@ omap_i2c_probe(struct platform_device *pdev) | |||
1050 | if (dev->rev <= OMAP_I2C_REV_ON_3430) | 1056 | if (dev->rev <= OMAP_I2C_REV_ON_3430) |
1051 | dev->errata |= I2C_OMAP3_1P153; | 1057 | dev->errata |= I2C_OMAP3_1P153; |
1052 | 1058 | ||
1053 | if (!(cpu_class_is_omap1() || cpu_is_omap2420())) { | 1059 | if (!(pdata->flags & OMAP_I2C_FLAG_NO_FIFO)) { |
1054 | u16 s; | 1060 | u16 s; |
1055 | 1061 | ||
1056 | /* Set up the fifo size - Get total size */ | 1062 | /* Set up the fifo size - Get total size */ |