aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/cavium-octeon/octeon-platform.c72
-rw-r--r--arch/mips/include/asm/octeon/octeon.h5
2 files changed, 77 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{
diff --git a/arch/mips/include/asm/octeon/octeon.h b/arch/mips/include/asm/octeon/octeon.h
index 4d0a8c61fc3e..ca6214b5ccb9 100644
--- a/arch/mips/include/asm/octeon/octeon.h
+++ b/arch/mips/include/asm/octeon/octeon.h
@@ -213,6 +213,11 @@ struct octeon_cf_data {
213 int dma_engine; /* -1 for no DMA */ 213 int dma_engine; /* -1 for no DMA */
214}; 214};
215 215
216struct octeon_i2c_data {
217 unsigned int sys_freq;
218 unsigned int i2c_freq;
219};
220
216extern void octeon_write_lcd(const char *s); 221extern void octeon_write_lcd(const char *s);
217extern void octeon_check_cpu_bist(void); 222extern void octeon_check_cpu_bist(void);
218extern int octeon_get_boot_debug_flag(void); 223extern int octeon_get_boot_debug_flag(void);