aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/cavium-octeon
diff options
context:
space:
mode:
authorDavid Daney <ddaney@caviumnetworks.com>2010-01-07 16:23:41 -0500
committerRalf Baechle <ralf@linux-mips.org>2010-02-27 06:53:04 -0500
commitf41c3c1b3ed53440b37445712f8e1048a39d7001 (patch)
treec737d70385a32aea9de6a2d1e3b9a088c4bbe63f /arch/mips/cavium-octeon
parentd38760ccdf879a8648be53488227bf7fe597792d (diff)
MIPS: Octeon: Add I2C platform device.
Signed-off-by: David Daney <ddaney@caviumnetworks.com> To: linux-mips@linux-mips.org To: linux-i2c@vger.kernel.org To: ben-linux@fluff.org To: khali@linux-fr.org Cc: Rade Bozic <rade.bozic.ext@nsn.com> Patchwork: http://patchwork.linux-mips.org/patch/847/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/cavium-octeon')
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index cfdb4c2ac5c3..784c1c874018 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -159,6 +159,78 @@ out:
159} 159}
160device_initcall(octeon_rng_device_init); 160device_initcall(octeon_rng_device_init);
161 161
162
163#define OCTEON_I2C_IO_BASE 0x1180000001000ull
164#define OCTEON_I2C_IO_UNIT_OFFSET 0x200
165
166static struct octeon_i2c_data octeon_i2c_data[2];
167
168static int __init octeon_i2c_device_init(void)
169{
170 struct platform_device *pd;
171 int ret = 0;
172 int port, num_ports;
173
174 struct resource i2c_resources[] = {
175 {
176 .flags = IORESOURCE_MEM,
177 }, {
178 .flags = IORESOURCE_IRQ,
179 }
180 };
181
182 if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
183 num_ports = 2;
184 else
185 num_ports = 1;
186
187 for (port = 0; port < num_ports; port++) {
188 octeon_i2c_data[port].sys_freq = octeon_get_clock_rate();
189 /*FIXME: should be examined. At the moment is set for 100Khz */
190 octeon_i2c_data[port].i2c_freq = 100000;
191
192 pd = platform_device_alloc("i2c-octeon", port);
193 if (!pd) {
194 ret = -ENOMEM;
195 goto out;
196 }
197
198 pd->dev.platform_data = octeon_i2c_data + port;
199
200 i2c_resources[0].start =
201 OCTEON_I2C_IO_BASE + (port * OCTEON_I2C_IO_UNIT_OFFSET);
202 i2c_resources[0].end = i2c_resources[0].start + 0x1f;
203 switch (port) {
204 case 0:
205 i2c_resources[1].start = OCTEON_IRQ_TWSI;
206 i2c_resources[1].end = OCTEON_IRQ_TWSI;
207 break;
208 case 1:
209 i2c_resources[1].start = OCTEON_IRQ_TWSI2;
210 i2c_resources[1].end = OCTEON_IRQ_TWSI2;
211 break;
212 default:
213 BUG();
214 }
215
216 ret = platform_device_add_resources(pd,
217 i2c_resources,
218 ARRAY_SIZE(i2c_resources));
219 if (ret)
220 goto fail;
221
222 ret = platform_device_add(pd);
223 if (ret)
224 goto fail;
225 }
226 return ret;
227fail:
228 platform_device_put(pd);
229out:
230 return ret;
231}
232device_initcall(octeon_i2c_device_init);
233
162/* Octeon SMI/MDIO interface. */ 234/* Octeon SMI/MDIO interface. */
163static int __init octeon_mdiobus_device_init(void) 235static int __init octeon_mdiobus_device_init(void)
164{ 236{