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 <asm/arch/platform.h>
18 #include <asm/arch/i2c.h>
20 static int set_clock_run(struct platform_device *pdev)
26 snprintf(name, 10, "i2c%d_ck", pdev->id);
27 clk = clk_get(&pdev->dev, name);
37 static int set_clock_stop(struct platform_device *pdev)
43 snprintf(name, 10, "i2c%d_ck", pdev->id);
44 clk = clk_get(&pdev->dev, name);
54 static int i2c_pnx_suspend(struct platform_device *pdev, pm_message_t state)
58 retval = set_clock_run(pdev);
63 static int i2c_pnx_resume(struct platform_device *pdev)
67 retval = set_clock_run(pdev);
72 static u32 calculate_input_freq(struct platform_device *pdev)
78 static struct i2c_pnx_algo_data pnx_algo_data0 = {
79 .base = PNX4008_I2C1_BASE,
83 static struct i2c_pnx_algo_data pnx_algo_data1 = {
84 .base = PNX4008_I2C2_BASE,
88 static struct i2c_pnx_algo_data pnx_algo_data2 = {
89 .base = (PNX4008_USB_CONFIG_BASE + 0x300),
93 static struct i2c_adapter pnx_adapter0 = {
94 .name = I2C_CHIP_NAME "0",
95 .algo_data = &pnx_algo_data0,
97 static struct i2c_adapter pnx_adapter1 = {
98 .name = I2C_CHIP_NAME "1",
99 .algo_data = &pnx_algo_data1,
102 static struct i2c_adapter pnx_adapter2 = {
104 .algo_data = &pnx_algo_data2,
107 static struct i2c_pnx_data i2c0_data = {
108 .suspend = i2c_pnx_suspend,
109 .resume = i2c_pnx_resume,
110 .calculate_input_freq = calculate_input_freq,
111 .set_clock_run = set_clock_run,
112 .set_clock_stop = set_clock_stop,
113 .adapter = &pnx_adapter0,
116 static struct i2c_pnx_data i2c1_data = {
117 .suspend = i2c_pnx_suspend,
118 .resume = i2c_pnx_resume,
119 .calculate_input_freq = calculate_input_freq,
120 .set_clock_run = set_clock_run,
121 .set_clock_stop = set_clock_stop,
122 .adapter = &pnx_adapter1,
125 static struct i2c_pnx_data i2c2_data = {
126 .suspend = i2c_pnx_suspend,
127 .resume = i2c_pnx_resume,
128 .calculate_input_freq = calculate_input_freq,
129 .set_clock_run = set_clock_run,
130 .set_clock_stop = set_clock_stop,
131 .adapter = &pnx_adapter2,
134 static struct platform_device i2c0_device = {
138 .platform_data = &i2c0_data,
142 static struct platform_device i2c1_device = {
146 .platform_data = &i2c1_data,
150 static struct platform_device i2c2_device = {
154 .platform_data = &i2c2_data,
158 static struct platform_device *devices[] __initdata = {
164 void __init pnx4008_register_i2c_devices(void)
166 platform_add_devices(devices, ARRAY_SIZE(devices));