diff options
author | Tony Lindgren <tony@atomide.com> | 2012-10-29 19:17:59 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2012-10-31 18:37:13 -0400 |
commit | c34f7c696211e3d45ff94a34824b65aa52576bc6 (patch) | |
tree | 81327c2b471e51e47171ed11e57c99eda552a0ef | |
parent | bb77209432873214a796a70a4539e4ebdf3feb54 (diff) |
ARM: OMAP: Make plat-omap/i2c.c port checks local
The common code should not have any omap1 or omap2+
specific code, and should not need to call the cpu_is_omap
macros.
The only remaining user for cpu_is_omap macros is
omap_i2c_nr_ports(). Let's make those checks in
the omap specific implementation of omap_i2c_add_bus()
instead in order to remove cpu_is_omap usage from
the common code.
Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r-- | arch/arm/mach-omap1/i2c.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/i2c.c | 16 | ||||
-rw-r--r-- | arch/arm/plat-omap/i2c.c | 26 |
3 files changed, 22 insertions, 23 deletions
diff --git a/arch/arm/mach-omap1/i2c.c b/arch/arm/mach-omap1/i2c.c index 32bcbb8d6c73..54097a29f432 100644 --- a/arch/arm/mach-omap1/i2c.c +++ b/arch/arm/mach-omap1/i2c.c | |||
@@ -54,6 +54,9 @@ int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *pdata, | |||
54 | struct platform_device *pdev; | 54 | struct platform_device *pdev; |
55 | struct resource *res; | 55 | struct resource *res; |
56 | 56 | ||
57 | if (bus_id > 1) | ||
58 | return -EINVAL; | ||
59 | |||
57 | omap1_i2c_mux_pins(bus_id); | 60 | omap1_i2c_mux_pins(bus_id); |
58 | 61 | ||
59 | pdev = &omap_i2c_devices[bus_id - 1]; | 62 | pdev = &omap_i2c_devices[bus_id - 1]; |
diff --git a/arch/arm/mach-omap2/i2c.c b/arch/arm/mach-omap2/i2c.c index ad55b943108f..4e63097e3cd8 100644 --- a/arch/arm/mach-omap2/i2c.c +++ b/arch/arm/mach-omap2/i2c.c | |||
@@ -109,6 +109,19 @@ int omap_i2c_reset(struct omap_hwmod *oh) | |||
109 | return 0; | 109 | return 0; |
110 | } | 110 | } |
111 | 111 | ||
112 | static int __init omap_i2c_nr_ports(void) | ||
113 | { | ||
114 | int ports = 0; | ||
115 | |||
116 | if (cpu_is_omap24xx()) | ||
117 | ports = 2; | ||
118 | else if (cpu_is_omap34xx()) | ||
119 | ports = 3; | ||
120 | else if (cpu_is_omap44xx()) | ||
121 | ports = 4; | ||
122 | return ports; | ||
123 | } | ||
124 | |||
112 | static const char name[] = "omap_i2c"; | 125 | static const char name[] = "omap_i2c"; |
113 | 126 | ||
114 | int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata, | 127 | int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata, |
@@ -121,6 +134,9 @@ int __init omap_i2c_add_bus(struct omap_i2c_bus_platform_data *i2c_pdata, | |||
121 | struct omap_i2c_bus_platform_data *pdata; | 134 | struct omap_i2c_bus_platform_data *pdata; |
122 | struct omap_i2c_dev_attr *dev_attr; | 135 | struct omap_i2c_dev_attr *dev_attr; |
123 | 136 | ||
137 | if (bus_id > omap_i2c_nr_ports()) | ||
138 | return -EINVAL; | ||
139 | |||
124 | omap2_i2c_mux_pins(bus_id); | 140 | omap2_i2c_mux_pins(bus_id); |
125 | 141 | ||
126 | l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id); | 142 | l = snprintf(oh_name, MAX_OMAP_I2C_HWMOD_NAME_LEN, "i2c%d", bus_id); |
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c index be6deb7c12ec..d094273b9df5 100644 --- a/arch/arm/plat-omap/i2c.c +++ b/arch/arm/plat-omap/i2c.c | |||
@@ -33,9 +33,6 @@ | |||
33 | 33 | ||
34 | #include <mach/irqs.h> | 34 | #include <mach/irqs.h> |
35 | 35 | ||
36 | #include "../mach-omap1/soc.h" | ||
37 | #include "../mach-omap2/soc.h" | ||
38 | |||
39 | #include "i2c.h" | 36 | #include "i2c.h" |
40 | 37 | ||
41 | #define OMAP_I2C_MAX_CONTROLLERS 4 | 38 | #define OMAP_I2C_MAX_CONTROLLERS 4 |
@@ -43,22 +40,6 @@ static struct omap_i2c_bus_platform_data i2c_pdata[OMAP_I2C_MAX_CONTROLLERS]; | |||
43 | 40 | ||
44 | #define OMAP_I2C_CMDLINE_SETUP (BIT(31)) | 41 | #define OMAP_I2C_CMDLINE_SETUP (BIT(31)) |
45 | 42 | ||
46 | static int __init omap_i2c_nr_ports(void) | ||
47 | { | ||
48 | int ports = 0; | ||
49 | |||
50 | if (cpu_class_is_omap1()) | ||
51 | ports = 1; | ||
52 | else if (cpu_is_omap24xx()) | ||
53 | ports = 2; | ||
54 | else if (cpu_is_omap34xx()) | ||
55 | ports = 3; | ||
56 | else if (cpu_is_omap44xx()) | ||
57 | ports = 4; | ||
58 | |||
59 | return ports; | ||
60 | } | ||
61 | |||
62 | /** | 43 | /** |
63 | * omap_i2c_bus_setup - Process command line options for the I2C bus speed | 44 | * omap_i2c_bus_setup - Process command line options for the I2C bus speed |
64 | * @str: String of options | 45 | * @str: String of options |
@@ -72,12 +53,11 @@ static int __init omap_i2c_nr_ports(void) | |||
72 | */ | 53 | */ |
73 | static int __init omap_i2c_bus_setup(char *str) | 54 | static int __init omap_i2c_bus_setup(char *str) |
74 | { | 55 | { |
75 | int ports; | ||
76 | int ints[3]; | 56 | int ints[3]; |
77 | 57 | ||
78 | ports = omap_i2c_nr_ports(); | ||
79 | get_options(str, 3, ints); | 58 | get_options(str, 3, ints); |
80 | if (ints[0] < 2 || ints[1] < 1 || ints[1] > ports) | 59 | if (ints[0] < 2 || ints[1] < 1 || |
60 | ints[1] > OMAP_I2C_MAX_CONTROLLERS) | ||
81 | return 0; | 61 | return 0; |
82 | i2c_pdata[ints[1] - 1].clkrate = ints[2]; | 62 | i2c_pdata[ints[1] - 1].clkrate = ints[2]; |
83 | i2c_pdata[ints[1] - 1].clkrate |= OMAP_I2C_CMDLINE_SETUP; | 63 | i2c_pdata[ints[1] - 1].clkrate |= OMAP_I2C_CMDLINE_SETUP; |
@@ -122,7 +102,7 @@ int __init omap_register_i2c_bus(int bus_id, u32 clkrate, | |||
122 | { | 102 | { |
123 | int err; | 103 | int err; |
124 | 104 | ||
125 | BUG_ON(bus_id < 1 || bus_id > omap_i2c_nr_ports()); | 105 | BUG_ON(bus_id < 1 || bus_id > OMAP_I2C_MAX_CONTROLLERS); |
126 | 106 | ||
127 | if (info) { | 107 | if (info) { |
128 | err = i2c_register_board_info(bus_id, info, len); | 108 | err = i2c_register_board_info(bus_id, info, len); |