2 * I2C initialization for PNX4008.
4 * Author: Vitaly Wool <vitalywool@gmail.com>
6 * 2005-2006 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
12 #include <linux/clk.h>
13 #include <linux/i2c.h>
14 #include <linux/i2c-pnx.h>
15 #include <linux/platform_device.h>
16 #include <linux/err.h>
17 #include <mach/platform.h>
18 #include <mach/irqs.h>
21 static int set_clock_run(struct platform_device
*pdev
)
27 snprintf(name
, 10, "i2c%d_ck", pdev
->id
);
28 clk
= clk_get(&pdev
->dev
, name
);
38 static int set_clock_stop(struct platform_device
*pdev
)
44 snprintf(name
, 10, "i2c%d_ck", pdev
->id
);
45 clk
= clk_get(&pdev
->dev
, name
);
55 static int i2c_pnx_suspend(struct platform_device
*pdev
, pm_message_t state
)
59 retval
= set_clock_run(pdev
);
64 static int i2c_pnx_resume(struct platform_device
*pdev
)
68 retval
= set_clock_run(pdev
);
73 static u32
calculate_input_freq(struct platform_device
*pdev
)
79 static struct i2c_pnx_algo_data pnx_algo_data0
= {
80 .base
= PNX4008_I2C1_BASE
,
84 static struct i2c_pnx_algo_data pnx_algo_data1
= {
85 .base
= PNX4008_I2C2_BASE
,
89 static struct i2c_pnx_algo_data pnx_algo_data2
= {
90 .base
= (PNX4008_USB_CONFIG_BASE
+ 0x300),
94 static struct i2c_adapter pnx_adapter0
= {
95 .name
= I2C_CHIP_NAME
"0",
96 .algo_data
= &pnx_algo_data0
,
98 static struct i2c_adapter pnx_adapter1
= {
99 .name
= I2C_CHIP_NAME
"1",
100 .algo_data
= &pnx_algo_data1
,
103 static struct i2c_adapter pnx_adapter2
= {
105 .algo_data
= &pnx_algo_data2
,
108 static 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
,
117 static 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
,
126 static 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
,
135 static struct platform_device i2c0_device
= {
139 .platform_data
= &i2c0_data
,
143 static struct platform_device i2c1_device
= {
147 .platform_data
= &i2c1_data
,
151 static struct platform_device i2c2_device
= {
155 .platform_data
= &i2c2_data
,
159 static struct platform_device
*devices
[] __initdata
= {
165 void __init
pnx4008_register_i2c_devices(void)
167 platform_add_devices(devices
, ARRAY_SIZE(devices
));