microblaze/PCI: factor out pcibios_setup()
[linux-2.6.git] / arch / arm / mach-u300 / i2c.c
blobcb04bd6ab3e7f07248f57372015cec729e030798
1 /*
2 * arch/arm/mach-u300/i2c.c
4 * Copyright (C) 2009 ST-Ericsson AB
5 * License terms: GNU General Public License (GPL) version 2
7 * Register board i2c devices
8 * Author: Linus Walleij <linus.walleij@stericsson.com>
9 */
10 #include <linux/kernel.h>
11 #include <linux/i2c.h>
12 #include <linux/mfd/abx500.h>
13 #include <linux/regulator/machine.h>
14 #include <linux/amba/bus.h>
15 #include <mach/irqs.h>
18 * Initial settings of ab3100 registers.
19 * Common for below LDO regulator settings are that
20 * bit 7-5 controls voltage. Bit 4 turns regulator ON(1) or OFF(0).
21 * Bit 3-2 controls sleep enable and bit 1-0 controls sleep mode.
24 /* LDO_A 0x16: 2.75V, ON, SLEEP_A, SLEEP OFF GND */
25 #define LDO_A_SETTING 0x16
26 /* LDO_C 0x10: 2.65V, ON, SLEEP_A or B, SLEEP full power */
27 #define LDO_C_SETTING 0x10
28 /* LDO_D 0x10: 2.65V, ON, sleep mode not used */
29 #define LDO_D_SETTING 0x10
30 /* LDO_E 0x10: 1.8V, ON, SLEEP_A or B, SLEEP full power */
31 #define LDO_E_SETTING 0x10
32 /* LDO_E SLEEP 0x00: 1.8V, not used, SLEEP_A or B, not used */
33 #define LDO_E_SLEEP_SETTING 0x00
34 /* LDO_F 0xD0: 2.5V, ON, SLEEP_A or B, SLEEP full power */
35 #define LDO_F_SETTING 0xD0
36 /* LDO_G 0x00: 2.85V, OFF, SLEEP_A or B, SLEEP full power */
37 #define LDO_G_SETTING 0x00
38 /* LDO_H 0x18: 2.75V, ON, SLEEP_B, SLEEP full power */
39 #define LDO_H_SETTING 0x18
40 /* LDO_K 0x00: 2.75V, OFF, SLEEP_A or B, SLEEP full power */
41 #define LDO_K_SETTING 0x00
42 /* LDO_EXT 0x00: Voltage not set, OFF, not used, not used */
43 #define LDO_EXT_SETTING 0x00
44 /* BUCK 0x7D: 1.2V, ON, SLEEP_A and B, SLEEP low power */
45 #define BUCK_SETTING 0x7D
46 /* BUCK SLEEP 0xAC: 1.05V, Not used, SLEEP_A and B, Not used */
47 #define BUCK_SLEEP_SETTING 0xAC
49 #ifdef CONFIG_AB3100_CORE
50 static struct regulator_consumer_supply supply_ldo_c[] = {
52 .dev_name = "ab3100-codec",
53 .supply = "vaudio", /* Powers the codec */
58 * This one needs to be a supply so we can turn it off
59 * in order to shut down the system.
61 static struct regulator_consumer_supply supply_ldo_d[] = {
63 .supply = "vana15", /* Powers the SoC (CPU etc) */
67 static struct regulator_consumer_supply supply_ldo_g[] = {
69 .dev_name = "mmci",
70 .supply = "vmmc", /* Powers MMC/SD card */
74 static struct regulator_consumer_supply supply_ldo_h[] = {
76 .dev_name = "xgam_pdi",
77 .supply = "vdisp", /* Powers camera, display etc */
81 static struct regulator_consumer_supply supply_ldo_k[] = {
83 .dev_name = "irda",
84 .supply = "vir", /* Power IrDA */
89 * This is a placeholder for whoever wish to use the
90 * external power.
92 static struct regulator_consumer_supply supply_ldo_ext[] = {
94 .supply = "vext", /* External power */
98 /* Preset (hardware defined) voltages for these regulators */
99 #define LDO_A_VOLTAGE 2750000
100 #define LDO_C_VOLTAGE 2650000
101 #define LDO_D_VOLTAGE 2650000
103 static struct ab3100_platform_data ab3100_plf_data = {
104 .reg_constraints = {
105 /* LDO A routing and constraints */
107 .constraints = {
108 .name = "vrad",
109 .min_uV = LDO_A_VOLTAGE,
110 .max_uV = LDO_A_VOLTAGE,
111 .valid_modes_mask = REGULATOR_MODE_NORMAL,
112 .always_on = 1,
113 .boot_on = 1,
116 /* LDO C routing and constraints */
118 .constraints = {
119 .min_uV = LDO_C_VOLTAGE,
120 .max_uV = LDO_C_VOLTAGE,
121 .valid_modes_mask = REGULATOR_MODE_NORMAL,
123 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_c),
124 .consumer_supplies = supply_ldo_c,
126 /* LDO D routing and constraints */
128 .constraints = {
129 .min_uV = LDO_D_VOLTAGE,
130 .max_uV = LDO_D_VOLTAGE,
131 .valid_modes_mask = REGULATOR_MODE_NORMAL,
132 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
134 * Actually this is boot_on but we need
135 * to reference count it externally to
136 * be able to shut down the system.
139 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_d),
140 .consumer_supplies = supply_ldo_d,
142 /* LDO E routing and constraints */
144 .constraints = {
145 .name = "vio",
146 .min_uV = 1800000,
147 .max_uV = 1800000,
148 .valid_modes_mask = REGULATOR_MODE_NORMAL,
149 .always_on = 1,
150 .boot_on = 1,
153 /* LDO F routing and constraints */
155 .constraints = {
156 .name = "vana25",
157 .min_uV = 2500000,
158 .max_uV = 2500000,
159 .valid_modes_mask = REGULATOR_MODE_NORMAL,
160 .always_on = 1,
161 .boot_on = 1,
164 /* LDO G routing and constraints */
166 .constraints = {
167 .min_uV = 1500000,
168 .max_uV = 2850000,
169 .valid_modes_mask = REGULATOR_MODE_NORMAL,
170 .valid_ops_mask =
171 REGULATOR_CHANGE_VOLTAGE |
172 REGULATOR_CHANGE_STATUS,
174 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_g),
175 .consumer_supplies = supply_ldo_g,
177 /* LDO H routing and constraints */
179 .constraints = {
180 .min_uV = 1200000,
181 .max_uV = 2750000,
182 .valid_modes_mask = REGULATOR_MODE_NORMAL,
183 .valid_ops_mask =
184 REGULATOR_CHANGE_VOLTAGE |
185 REGULATOR_CHANGE_STATUS,
187 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_h),
188 .consumer_supplies = supply_ldo_h,
190 /* LDO K routing and constraints */
192 .constraints = {
193 .min_uV = 1800000,
194 .max_uV = 2750000,
195 .valid_modes_mask = REGULATOR_MODE_NORMAL,
196 .valid_ops_mask =
197 REGULATOR_CHANGE_VOLTAGE |
198 REGULATOR_CHANGE_STATUS,
200 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_k),
201 .consumer_supplies = supply_ldo_k,
203 /* External regulator interface. No fixed voltage specified.
204 * If we knew the voltage of the external regulator and it
205 * was connected on the board, we could add the (fixed)
206 * voltage for it here.
209 .constraints = {
210 .min_uV = 0,
211 .max_uV = 0,
212 .valid_modes_mask = REGULATOR_MODE_NORMAL,
213 .valid_ops_mask =
214 REGULATOR_CHANGE_STATUS,
216 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_ext),
217 .consumer_supplies = supply_ldo_ext,
219 /* Buck converter routing and constraints */
221 .constraints = {
222 .name = "vcore",
223 .min_uV = 1200000,
224 .max_uV = 1800000,
225 .valid_modes_mask = REGULATOR_MODE_NORMAL,
226 .valid_ops_mask =
227 REGULATOR_CHANGE_VOLTAGE,
228 .always_on = 1,
229 .boot_on = 1,
233 .reg_initvals = {
234 LDO_A_SETTING,
235 LDO_C_SETTING,
236 LDO_E_SETTING,
237 LDO_E_SLEEP_SETTING,
238 LDO_F_SETTING,
239 LDO_G_SETTING,
240 LDO_H_SETTING,
241 LDO_K_SETTING,
242 LDO_EXT_SETTING,
243 BUCK_SETTING,
244 BUCK_SLEEP_SETTING,
245 LDO_D_SETTING,
248 #endif
250 static struct i2c_board_info __initdata bus0_i2c_board_info[] = {
251 #ifdef CONFIG_AB3100_CORE
253 .type = "ab3100",
254 .addr = 0x48,
255 .irq = IRQ_U300_IRQ0_EXT,
256 .platform_data = &ab3100_plf_data,
258 #else
259 { },
260 #endif
263 static struct i2c_board_info __initdata bus1_i2c_board_info[] = {
264 #ifdef CONFIG_MACH_U300_BS335
266 .type = "fwcam",
267 .addr = 0x10,
270 .type = "fwcam",
271 .addr = 0x5d,
273 #else
274 { },
275 #endif
278 void __init u300_i2c_register_board_devices(void)
280 i2c_register_board_info(0, bus0_i2c_board_info,
281 ARRAY_SIZE(bus0_i2c_board_info));
283 * This makes the core shut down all unused regulators
284 * after all the initcalls have completed.
286 regulator_has_full_constraints();
287 i2c_register_board_info(1, bus1_i2c_board_info,
288 ARRAY_SIZE(bus1_i2c_board_info));