diff options
Diffstat (limited to 'arch/arm/mach-omap1/i2c.c')
-rw-r--r-- | arch/arm/mach-omap1/i2c.c | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/arch/arm/mach-omap1/i2c.c b/arch/arm/mach-omap1/i2c.c index a0551a6d7451..faca808cb3d9 100644 --- a/arch/arm/mach-omap1/i2c.c +++ b/arch/arm/mach-omap1/i2c.c | |||
@@ -19,11 +19,25 @@ | |||
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <plat/i2c.h> | 22 | #include <linux/i2c-omap.h> |
23 | #include <mach/mux.h> | 23 | #include <mach/mux.h> |
24 | #include <plat/cpu.h> | 24 | #include "soc.h" |
25 | |||
26 | #include <plat/i2c.h> | ||
27 | |||
28 | #define OMAP_I2C_SIZE 0x3f | ||
29 | #define OMAP1_I2C_BASE 0xfffb3800 | ||
30 | #define OMAP1_INT_I2C (32 + 4) | ||
31 | |||
32 | static const char name[] = "omap_i2c"; | ||
25 | 33 | ||
26 | void __init omap1_i2c_mux_pins(int bus_id) | 34 | static struct resource i2c_resources[2] = { |
35 | }; | ||
36 | |||
37 | static struct platform_device omap_i2c_devices[1] = { | ||
38 | }; | ||
39 | |||
40 | static void __init omap1_i2c_mux_pins(int bus_id) | ||
27 | { | 41 | { |
28 | if (cpu_is_omap7xx()) { | 42 | if (cpu_is_omap7xx()) { |
29 | omap_cfg_reg(I2C_7XX_SDA); | 43 | omap_cfg_reg(I2C_7XX_SDA); |
@@ -33,3 +47,47 @@ void __init omap1_i2c_mux_pins(int bus_id) | |||
33 | omap_cfg_reg(I2C_SCL); | 47 | omap_cfg_reg(I2C_SCL); |
34 | } | 48 | } |
35 | } | 49 | } |
50 | |||
51 | int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *pdata, | ||
52 | int bus_id) | ||
53 | { | ||
54 | struct platform_device *pdev; | ||
55 | struct resource *res; | ||
56 | |||
57 | if (bus_id > 1) | ||
58 | return -EINVAL; | ||
59 | |||
60 | omap1_i2c_mux_pins(bus_id); | ||
61 | |||
62 | pdev = &omap_i2c_devices[bus_id - 1]; | ||
63 | pdev->id = bus_id; | ||
64 | pdev->name = name; | ||
65 | pdev->num_resources = ARRAY_SIZE(i2c_resources); | ||
66 | res = i2c_resources; | ||
67 | res[0].start = OMAP1_I2C_BASE; | ||
68 | res[0].end = res[0].start + OMAP_I2C_SIZE; | ||
69 | res[0].flags = IORESOURCE_MEM; | ||
70 | res[1].start = OMAP1_INT_I2C; | ||
71 | res[1].flags = IORESOURCE_IRQ; | ||
72 | pdev->resource = res; | ||
73 | |||
74 | /* all OMAP1 have IP version 1 register set */ | ||
75 | pdata->rev = OMAP_I2C_IP_VERSION_1; | ||
76 | |||
77 | /* all OMAP1 I2C are implemented like this */ | ||
78 | pdata->flags = OMAP_I2C_FLAG_NO_FIFO | | ||
79 | OMAP_I2C_FLAG_SIMPLE_CLOCK | | ||
80 | OMAP_I2C_FLAG_16BIT_DATA_REG | | ||
81 | OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK; | ||
82 | |||
83 | /* how the cpu bus is wired up differs for 7xx only */ | ||
84 | |||
85 | if (cpu_is_omap7xx()) | ||
86 | pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_1; | ||
87 | else | ||
88 | pdata->flags |= OMAP_I2C_FLAG_BUS_SHIFT_2; | ||
89 | |||
90 | pdev->dev.platform_data = pdata; | ||
91 | |||
92 | return platform_device_register(pdev); | ||
93 | } | ||