26 #include <linux/kernel.h>
28 #include <linux/i2c.h>
30 #include <linux/slab.h>
34 #include <mach/irqs.h>
39 #define OMAP_I2C_SIZE 0x3f
40 #define OMAP1_I2C_BASE 0xfffb3800
41 #define OMAP1_INT_I2C (32 + 4)
43 static const char name[] =
"omap_i2c";
45 #define I2C_RESOURCE_BUILDER(base, irq) \
48 .end = (base) + OMAP_I2C_SIZE, \
49 .flags = IORESOURCE_MEM, \
53 .flags = IORESOURCE_IRQ, \
56 static struct resource i2c_resources[][2] = {
60 #define I2C_DEV_BUILDER(bus_id, res, data) \
64 .num_resources = ARRAY_SIZE(res), \
67 .platform_data = (data), \
71 #define MAX_OMAP_I2C_HWMOD_NAME_LEN 16
72 #define OMAP_I2C_MAX_CONTROLLERS 4
78 #define OMAP_I2C_CMDLINE_SETUP (BIT(31))
80 static int __init omap_i2c_nr_ports(
void)
96 static inline int omap1_i2c_add_bus(
int bus_id)
104 pdev = &omap_i2c_devices[bus_id - 1];
131 #ifdef CONFIG_ARCH_OMAP2PLUS
137 static void omap_pm_set_max_mpu_wakeup_lat_compat(
struct device *
dev,
long t)
142 static inline int omap2_i2c_add_bus(
int bus_id)
155 "String buffer overflow in I2C%d device setup\n", bus_id);
158 pr_err(
"Could not look up %s\n", oh_name);
185 WARN(IS_ERR(pdev),
"Could not build omap_device for %s\n",
name);
187 return PTR_RET(pdev);
190 static inline int omap2_i2c_add_bus(
int bus_id)
196 static int __init omap_i2c_add_bus(
int bus_id)
199 return omap1_i2c_add_bus(bus_id);
201 return omap2_i2c_add_bus(bus_id);
215 static int __init omap_i2c_bus_setup(
char *
str)
220 ports = omap_i2c_nr_ports();
222 if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports)
224 i2c_pdata[ints[1] - 1].clkrate = ints[2];
229 __setup(
"i2c_bus=", omap_i2c_bus_setup);
235 static int __init omap_register_i2c_bus_cmdline(
void)
241 i2c_pdata[
i].clkrate &= ~OMAP_I2C_CMDLINE_SETUP;
242 err = omap_i2c_add_bus(i + 1);
267 BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports());
278 i2c_pdata[bus_id - 1].clkrate &= ~OMAP_I2C_CMDLINE_SETUP;
280 return omap_i2c_add_bus(bus_id);