aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pnx4008/i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pnx4008/i2c.c')
-rw-r--r--arch/arm/mach-pnx4008/i2c.c108
1 files changed, 6 insertions, 102 deletions
diff --git a/arch/arm/mach-pnx4008/i2c.c b/arch/arm/mach-pnx4008/i2c.c
index f3fea29c00d3..8103f9644e2d 100644
--- a/arch/arm/mach-pnx4008/i2c.c
+++ b/arch/arm/mach-pnx4008/i2c.c
@@ -18,120 +18,24 @@
18#include <mach/irqs.h> 18#include <mach/irqs.h>
19#include <mach/i2c.h> 19#include <mach/i2c.h>
20 20
21static int set_clock_run(struct platform_device *pdev) 21static struct i2c_pnx_data i2c0_data = {
22{ 22 .name = I2C_CHIP_NAME "0",
23 struct clk *clk;
24 char name[10];
25 int retval = 0;
26
27 snprintf(name, 10, "i2c%d_ck", pdev->id);
28 clk = clk_get(&pdev->dev, name);
29 if (!IS_ERR(clk)) {
30 clk_set_rate(clk, 1);
31 clk_put(clk);
32 } else
33 retval = -ENOENT;
34
35 return retval;
36}
37
38static int set_clock_stop(struct platform_device *pdev)
39{
40 struct clk *clk;
41 char name[10];
42 int retval = 0;
43
44 snprintf(name, 10, "i2c%d_ck", pdev->id);
45 clk = clk_get(&pdev->dev, name);
46 if (!IS_ERR(clk)) {
47 clk_set_rate(clk, 0);
48 clk_put(clk);
49 } else
50 retval = -ENOENT;
51
52 return retval;
53}
54
55static int i2c_pnx_suspend(struct platform_device *pdev, pm_message_t state)
56{
57 int retval = 0;
58#ifdef CONFIG_PM
59 retval = set_clock_run(pdev);
60#endif
61 return retval;
62}
63
64static int i2c_pnx_resume(struct platform_device *pdev)
65{
66 int retval = 0;
67#ifdef CONFIG_PM
68 retval = set_clock_run(pdev);
69#endif
70 return retval;
71}
72
73static u32 calculate_input_freq(struct platform_device *pdev)
74{
75 return HCLK_MHZ;
76}
77
78
79static struct i2c_pnx_algo_data pnx_algo_data0 = {
80 .base = PNX4008_I2C1_BASE, 23 .base = PNX4008_I2C1_BASE,
81 .irq = I2C_1_INT, 24 .irq = I2C_1_INT,
82}; 25};
83 26
84static struct i2c_pnx_algo_data pnx_algo_data1 = { 27static struct i2c_pnx_data i2c1_data = {
28 .name = I2C_CHIP_NAME "1",
85 .base = PNX4008_I2C2_BASE, 29 .base = PNX4008_I2C2_BASE,
86 .irq = I2C_2_INT, 30 .irq = I2C_2_INT,
87}; 31};
88 32
89static struct i2c_pnx_algo_data pnx_algo_data2 = { 33static struct i2c_pnx_data i2c2_data = {
34 .name = "USB-I2C",
90 .base = (PNX4008_USB_CONFIG_BASE + 0x300), 35 .base = (PNX4008_USB_CONFIG_BASE + 0x300),
91 .irq = USB_I2C_INT, 36 .irq = USB_I2C_INT,
92}; 37};
93 38
94static struct i2c_adapter pnx_adapter0 = {
95 .name = I2C_CHIP_NAME "0",
96 .algo_data = &pnx_algo_data0,
97};
98static struct i2c_adapter pnx_adapter1 = {
99 .name = I2C_CHIP_NAME "1",
100 .algo_data = &pnx_algo_data1,
101};
102
103static struct i2c_adapter pnx_adapter2 = {
104 .name = "USB-I2C",
105 .algo_data = &pnx_algo_data2,
106};
107
108static struct i2c_pnx_data i2c0_data = {
109 .suspend = i2c_pnx_suspend,
110 .resume = i2c_pnx_resume,
111 .calculate_input_freq = calculate_input_freq,
112 .set_clock_run = set_clock_run,
113 .set_clock_stop = set_clock_stop,
114 .adapter = &pnx_adapter0,
115};
116
117static struct i2c_pnx_data i2c1_data = {
118 .suspend = i2c_pnx_suspend,
119 .resume = i2c_pnx_resume,
120 .calculate_input_freq = calculate_input_freq,
121 .set_clock_run = set_clock_run,
122 .set_clock_stop = set_clock_stop,
123 .adapter = &pnx_adapter1,
124};
125
126static struct i2c_pnx_data i2c2_data = {
127 .suspend = i2c_pnx_suspend,
128 .resume = i2c_pnx_resume,
129 .calculate_input_freq = calculate_input_freq,
130 .set_clock_run = set_clock_run,
131 .set_clock_stop = set_clock_stop,
132 .adapter = &pnx_adapter2,
133};
134
135static struct platform_device i2c0_device = { 39static struct platform_device i2c0_device = {
136 .name = "pnx-i2c", 40 .name = "pnx-i2c",
137 .id = 0, 41 .id = 0,