diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-11-20 07:46:07 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-02-12 12:32:39 -0500 |
commit | 6fff3da998ac3cc9ed8a84bf4f19911bd63c8c32 (patch) | |
tree | 97c80144615bbc9ff8c4baee20feb1cf2af20fef | |
parent | ebdbbf2003ae2342147c87c2a6c6ed8984b9cede (diff) |
ARM: PNX4008: get i2c clock rate from clk API
Acked-by: Vitaly Wool <vitalywool@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/mach-pnx4008/clock.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-pnx4008/i2c.c | 9 | ||||
-rw-r--r-- | drivers/i2c/busses/i2c-pnx.c | 15 | ||||
-rw-r--r-- | include/linux/i2c-pnx.h | 1 |
4 files changed, 10 insertions, 24 deletions
diff --git a/arch/arm/mach-pnx4008/clock.c b/arch/arm/mach-pnx4008/clock.c index 692625cd2001..9d1975fa4d9f 100644 --- a/arch/arm/mach-pnx4008/clock.c +++ b/arch/arm/mach-pnx4008/clock.c | |||
@@ -638,9 +638,10 @@ static struct clk flash_ck = { | |||
638 | static struct clk i2c0_ck = { | 638 | static struct clk i2c0_ck = { |
639 | .name = "i2c0_ck", | 639 | .name = "i2c0_ck", |
640 | .parent = &per_ck, | 640 | .parent = &per_ck, |
641 | .flags = NEEDS_INITIALIZATION, | 641 | .flags = NEEDS_INITIALIZATION | FIXED_RATE, |
642 | .enable_shift = 0, | 642 | .enable_shift = 0, |
643 | .enable_reg = I2CCLKCTRL_REG, | 643 | .enable_reg = I2CCLKCTRL_REG, |
644 | .rate = 13000000, | ||
644 | .enable = clk_reg_enable, | 645 | .enable = clk_reg_enable, |
645 | .disable = clk_reg_disable, | 646 | .disable = clk_reg_disable, |
646 | }; | 647 | }; |
@@ -648,9 +649,10 @@ static struct clk i2c0_ck = { | |||
648 | static struct clk i2c1_ck = { | 649 | static struct clk i2c1_ck = { |
649 | .name = "i2c1_ck", | 650 | .name = "i2c1_ck", |
650 | .parent = &per_ck, | 651 | .parent = &per_ck, |
651 | .flags = NEEDS_INITIALIZATION, | 652 | .flags = NEEDS_INITIALIZATION | FIXED_RATE, |
652 | .enable_shift = 1, | 653 | .enable_shift = 1, |
653 | .enable_reg = I2CCLKCTRL_REG, | 654 | .enable_reg = I2CCLKCTRL_REG, |
655 | .rate = 13000000, | ||
654 | .enable = clk_reg_enable, | 656 | .enable = clk_reg_enable, |
655 | .disable = clk_reg_disable, | 657 | .disable = clk_reg_disable, |
656 | }; | 658 | }; |
@@ -658,9 +660,10 @@ static struct clk i2c1_ck = { | |||
658 | static struct clk i2c2_ck = { | 660 | static struct clk i2c2_ck = { |
659 | .name = "i2c2_ck", | 661 | .name = "i2c2_ck", |
660 | .parent = &per_ck, | 662 | .parent = &per_ck, |
661 | .flags = NEEDS_INITIALIZATION, | 663 | .flags = NEEDS_INITIALIZATION | FIXED_RATE, |
662 | .enable_shift = 2, | 664 | .enable_shift = 2, |
663 | .enable_reg = USB_OTG_CLKCTRL_REG, | 665 | .enable_reg = USB_OTG_CLKCTRL_REG, |
666 | .rate = 13000000, | ||
664 | .enable = clk_reg_enable, | 667 | .enable = clk_reg_enable, |
665 | .disable = clk_reg_disable, | 668 | .disable = clk_reg_disable, |
666 | }; | 669 | }; |
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c index 14b4906bec2f..23ec335a4bc0 100644 --- a/arch/arm/mach-pnx4008/i2c.c +++ b/arch/arm/mach-pnx4008/i2c.c | |||
@@ -18,12 +18,6 @@ | |||
18 | #include <mach/irqs.h> | 18 | #include <mach/irqs.h> |
19 | #include <mach/i2c.h> | 19 | #include <mach/i2c.h> |
20 | 20 | ||
21 | static u32 calculate_input_freq(struct platform_device *pdev) | ||
22 | { | ||
23 | return HCLK_MHZ; | ||
24 | } | ||
25 | |||
26 | |||
27 | static struct i2c_pnx_algo_data pnx_algo_data0 = { | 21 | static struct i2c_pnx_algo_data pnx_algo_data0 = { |
28 | .base = PNX4008_I2C1_BASE, | 22 | .base = PNX4008_I2C1_BASE, |
29 | .irq = I2C_1_INT, | 23 | .irq = I2C_1_INT, |
@@ -54,17 +48,14 @@ static struct i2c_adapter pnx_adapter2 = { | |||
54 | }; | 48 | }; |
55 | 49 | ||
56 | static struct i2c_pnx_data i2c0_data = { | 50 | static struct i2c_pnx_data i2c0_data = { |
57 | .calculate_input_freq = calculate_input_freq, | ||
58 | .adapter = &pnx_adapter0, | 51 | .adapter = &pnx_adapter0, |
59 | }; | 52 | }; |
60 | 53 | ||
61 | static struct i2c_pnx_data i2c1_data = { | 54 | static struct i2c_pnx_data i2c1_data = { |
62 | .calculate_input_freq = calculate_input_freq, | ||
63 | .adapter = &pnx_adapter1, | 55 | .adapter = &pnx_adapter1, |
64 | }; | 56 | }; |
65 | 57 | ||
66 | static struct i2c_pnx_data i2c2_data = { | 58 | static struct i2c_pnx_data i2c2_data = { |
67 | .calculate_input_freq = calculate_input_freq, | ||
68 | .adapter = &pnx_adapter2, | 59 | .adapter = &pnx_adapter2, |
69 | }; | 60 | }; |
70 | 61 | ||
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c index 29f91774c4df..bfcd079e885c 100644 --- a/drivers/i2c/busses/i2c-pnx.c +++ b/drivers/i2c/busses/i2c-pnx.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #define I2C_PNX_TIMEOUT 10 /* msec */ | 31 | #define I2C_PNX_TIMEOUT 10 /* msec */ |
32 | #define I2C_PNX_SPEED_KHZ 100 | 32 | #define I2C_PNX_SPEED_KHZ 100 |
33 | #define I2C_PNX_REGION_SIZE 0x100 | 33 | #define I2C_PNX_REGION_SIZE 0x100 |
34 | #define PNX_DEFAULT_FREQ 13 /* MHz */ | ||
35 | 34 | ||
36 | static inline int wait_timeout(long timeout, struct i2c_pnx_algo_data *data) | 35 | static inline int wait_timeout(long timeout, struct i2c_pnx_algo_data *data) |
37 | { | 36 | { |
@@ -578,7 +577,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
578 | unsigned long tmp; | 577 | unsigned long tmp; |
579 | int ret = 0; | 578 | int ret = 0; |
580 | struct i2c_pnx_algo_data *alg_data; | 579 | struct i2c_pnx_algo_data *alg_data; |
581 | int freq_mhz; | 580 | unsigned long freq; |
582 | struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data; | 581 | struct i2c_pnx_data *i2c_pnx = pdev->dev.platform_data; |
583 | 582 | ||
584 | if (!i2c_pnx || !i2c_pnx->adapter) { | 583 | if (!i2c_pnx || !i2c_pnx->adapter) { |
@@ -599,14 +598,6 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
599 | goto out_drvdata; | 598 | goto out_drvdata; |
600 | } | 599 | } |
601 | 600 | ||
602 | if (i2c_pnx->calculate_input_freq) | ||
603 | freq_mhz = i2c_pnx->calculate_input_freq(pdev); | ||
604 | else { | ||
605 | freq_mhz = PNX_DEFAULT_FREQ; | ||
606 | dev_info(&pdev->dev, "Setting bus frequency to default value: " | ||
607 | "%d MHz\n", freq_mhz); | ||
608 | } | ||
609 | |||
610 | init_timer(&alg_data->mif.timer); | 601 | init_timer(&alg_data->mif.timer); |
611 | alg_data->mif.timer.function = i2c_pnx_timeout; | 602 | alg_data->mif.timer.function = i2c_pnx_timeout; |
612 | alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; | 603 | alg_data->mif.timer.data = (unsigned long)i2c_pnx->adapter; |
@@ -632,6 +623,8 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
632 | if (ret) | 623 | if (ret) |
633 | goto out_unmap; | 624 | goto out_unmap; |
634 | 625 | ||
626 | freq = clk_get_rate(alg_data->clk); | ||
627 | |||
635 | /* | 628 | /* |
636 | * Clock Divisor High This value is the number of system clocks | 629 | * Clock Divisor High This value is the number of system clocks |
637 | * the serial clock (SCL) will be high. | 630 | * the serial clock (SCL) will be high. |
@@ -643,7 +636,7 @@ static int __devinit i2c_pnx_probe(struct platform_device *pdev) | |||
643 | * the deglitching filter length. | 636 | * the deglitching filter length. |
644 | */ | 637 | */ |
645 | 638 | ||
646 | tmp = ((freq_mhz * 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; | 639 | tmp = ((freq / 1000) / I2C_PNX_SPEED_KHZ) / 2 - 2; |
647 | iowrite32(tmp, I2C_REG_CKH(alg_data)); | 640 | iowrite32(tmp, I2C_REG_CKH(alg_data)); |
648 | iowrite32(tmp, I2C_REG_CKL(alg_data)); | 641 | iowrite32(tmp, I2C_REG_CKL(alg_data)); |
649 | 642 | ||
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h index 688e29262a43..9035711cb3b1 100644 --- a/include/linux/i2c-pnx.h +++ b/include/linux/i2c-pnx.h | |||
@@ -34,7 +34,6 @@ struct i2c_pnx_algo_data { | |||
34 | }; | 34 | }; |
35 | 35 | ||
36 | struct i2c_pnx_data { | 36 | struct i2c_pnx_data { |
37 | u32 (*calculate_input_freq) (struct platform_device *pdev); | ||
38 | struct i2c_adapter *adapter; | 37 | struct i2c_adapter *adapter; |
39 | }; | 38 | }; |
40 | 39 | ||