blob: 7bc2503f64429719721f604c113e9e7804e0a522 [file] [log] [blame]
Linus Walleij6be2a0c2009-08-13 21:42:01 +01001/*
2 * arch/arm/mach-u300/i2c.c
3 *
4 * Copyright (C) 2009 ST-Ericsson AB
5 * License terms: GNU General Public License (GPL) version 2
6 *
7 * Register board i2c devices
8 * Author: Linus Walleij <linus.walleij@stericsson.com>
9 */
10#include <linux/kernel.h>
11#include <linux/i2c.h>
Linus Walleij3d812772009-09-23 15:45:02 +010012#include <linux/mfd/ab3100.h>
13#include <linux/regulator/machine.h>
14#include <linux/amba/bus.h>
Linus Walleij6be2a0c2009-08-13 21:42:01 +010015#include <mach/irqs.h>
16
Linus Walleij3d812772009-09-23 15:45:02 +010017/*
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.
22 */
23
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
48
49static struct regulator_consumer_supply supply_ldo_c[] = {
50 {
51 .dev_name = "ab3100-codec",
52 .supply = "vaudio", /* Powers the codec */
53 },
54};
55
56/*
57 * This one needs to be a supply so we can turn it off
58 * in order to shut down the system.
59 */
60static struct regulator_consumer_supply supply_ldo_d[] = {
61 {
62 .dev = NULL,
63 .supply = "vana15", /* Powers the SoC (CPU etc) */
64 },
65};
66
67static struct regulator_consumer_supply supply_ldo_g[] = {
68 {
69 .dev_name = "mmci",
70 .supply = "vmmc", /* Powers MMC/SD card */
71 },
72};
73
74static struct regulator_consumer_supply supply_ldo_h[] = {
75 {
76 .dev_name = "xgam_pdi",
77 .supply = "vdisp", /* Powers camera, display etc */
78 },
79};
80
81static struct regulator_consumer_supply supply_ldo_k[] = {
82 {
83 .dev_name = "irda",
84 .supply = "vir", /* Power IrDA */
85 },
86};
87
88/*
89 * This is a placeholder for whoever wish to use the
90 * external power.
91 */
92static struct regulator_consumer_supply supply_ldo_ext[] = {
93 {
94 .dev = NULL,
95 .supply = "vext", /* External power */
96 },
97};
98
99/* Preset (hardware defined) voltages for these regulators */
100#define LDO_A_VOLTAGE 2750000
101#define LDO_C_VOLTAGE 2650000
102#define LDO_D_VOLTAGE 2650000
103
104static struct ab3100_platform_data ab3100_plf_data = {
105 .reg_constraints = {
106 /* LDO A routing and constraints */
107 {
108 .constraints = {
109 .name = "vrad",
110 .min_uV = LDO_A_VOLTAGE,
111 .max_uV = LDO_A_VOLTAGE,
112 .valid_modes_mask = REGULATOR_MODE_NORMAL,
113 .always_on = 1,
114 .boot_on = 1,
115 },
116 },
117 /* LDO C routing and constraints */
118 {
119 .constraints = {
120 .min_uV = LDO_C_VOLTAGE,
121 .max_uV = LDO_C_VOLTAGE,
122 .valid_modes_mask = REGULATOR_MODE_NORMAL,
123 },
124 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_c),
125 .consumer_supplies = supply_ldo_c,
126 },
127 /* LDO D routing and constraints */
128 {
129 .constraints = {
130 .min_uV = LDO_D_VOLTAGE,
131 .max_uV = LDO_D_VOLTAGE,
132 .valid_modes_mask = REGULATOR_MODE_NORMAL,
133 /*
134 * Actually this is boot_on but we need
135 * to reference count it externally to
136 * be able to shut down the system.
137 */
138 },
139 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_d),
140 .consumer_supplies = supply_ldo_d,
141 },
142 /* LDO E routing and constraints */
143 {
144 .constraints = {
145 .name = "vio",
146 .min_uV = 1800000,
147 .max_uV = 1800000,
148 .valid_modes_mask = REGULATOR_MODE_NORMAL,
149 .valid_ops_mask =
150 REGULATOR_CHANGE_VOLTAGE |
151 REGULATOR_CHANGE_STATUS,
152 .always_on = 1,
153 .boot_on = 1,
154 },
155 },
156 /* LDO F routing and constraints */
157 {
158 .constraints = {
159 .name = "vana25",
160 .min_uV = 2500000,
161 .max_uV = 2500000,
162 .valid_modes_mask = REGULATOR_MODE_NORMAL,
163 .valid_ops_mask =
164 REGULATOR_CHANGE_VOLTAGE |
165 REGULATOR_CHANGE_STATUS,
166 .always_on = 1,
167 .boot_on = 1,
168 },
169 },
170 /* LDO G routing and constraints */
171 {
172 .constraints = {
173 .min_uV = 1500000,
174 .max_uV = 2850000,
175 .valid_modes_mask = REGULATOR_MODE_NORMAL,
176 .valid_ops_mask =
177 REGULATOR_CHANGE_VOLTAGE |
178 REGULATOR_CHANGE_STATUS,
179 },
180 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_g),
181 .consumer_supplies = supply_ldo_g,
182 },
183 /* LDO H routing and constraints */
184 {
185 .constraints = {
186 .min_uV = 1200000,
187 .max_uV = 2750000,
188 .valid_modes_mask = REGULATOR_MODE_NORMAL,
189 .valid_ops_mask =
190 REGULATOR_CHANGE_VOLTAGE |
191 REGULATOR_CHANGE_STATUS,
192 },
193 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_h),
194 .consumer_supplies = supply_ldo_h,
195 },
196 /* LDO K routing and constraints */
197 {
198 .constraints = {
199 .min_uV = 1800000,
200 .max_uV = 2750000,
201 .valid_modes_mask = REGULATOR_MODE_NORMAL,
202 .valid_ops_mask =
203 REGULATOR_CHANGE_VOLTAGE |
204 REGULATOR_CHANGE_STATUS,
205 },
206 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_k),
207 .consumer_supplies = supply_ldo_k,
208 },
209 /* External regulator interface. No fixed voltage specified.
210 * If we knew the voltage of the external regulator and it
211 * was connected on the board, we could add the (fixed)
212 * voltage for it here.
213 */
214 {
215 .constraints = {
216 .min_uV = 0,
217 .max_uV = 0,
218 .valid_modes_mask = REGULATOR_MODE_NORMAL,
219 .valid_ops_mask =
220 REGULATOR_CHANGE_STATUS,
221 },
222 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_ext),
223 .consumer_supplies = supply_ldo_ext,
224 },
225 /* Buck converter routing and constraints */
226 {
227 .constraints = {
228 .name = "vcore",
229 .min_uV = 1200000,
230 .max_uV = 1800000,
231 .valid_modes_mask = REGULATOR_MODE_NORMAL,
232 .valid_ops_mask =
233 REGULATOR_CHANGE_VOLTAGE |
234 REGULATOR_CHANGE_STATUS,
235 .always_on = 1,
236 .boot_on = 1,
237 },
238 },
239 },
240 .reg_initvals = {
241 LDO_A_SETTING,
242 LDO_C_SETTING,
243 LDO_E_SETTING,
244 LDO_E_SLEEP_SETTING,
245 LDO_F_SETTING,
246 LDO_G_SETTING,
247 LDO_H_SETTING,
248 LDO_K_SETTING,
249 LDO_EXT_SETTING,
250 BUCK_SETTING,
251 BUCK_SLEEP_SETTING,
252 LDO_D_SETTING,
253 },
254};
255
Linus Walleij6be2a0c2009-08-13 21:42:01 +0100256static struct i2c_board_info __initdata bus0_i2c_board_info[] = {
257 {
258 .type = "ab3100",
259 .addr = 0x48,
260 .irq = IRQ_U300_IRQ0_EXT,
Linus Walleij3d812772009-09-23 15:45:02 +0100261 .platform_data = &ab3100_plf_data,
Linus Walleij6be2a0c2009-08-13 21:42:01 +0100262 },
263};
264
265static struct i2c_board_info __initdata bus1_i2c_board_info[] = {
266#ifdef CONFIG_MACH_U300_BS335
267 {
268 .type = "fwcam",
269 .addr = 0x10,
270 },
271 {
272 .type = "fwcam",
273 .addr = 0x5d,
274 },
275#else
276 { },
277#endif
278};
279
280void __init u300_i2c_register_board_devices(void)
281{
282 i2c_register_board_info(0, bus0_i2c_board_info,
283 ARRAY_SIZE(bus0_i2c_board_info));
Linus Walleij3d812772009-09-23 15:45:02 +0100284 /*
285 * This makes the core shut down all unused regulators
286 * after all the initcalls have completed.
287 */
288 regulator_has_full_constraints();
Linus Walleij6be2a0c2009-08-13 21:42:01 +0100289 i2c_register_board_info(1, bus1_i2c_board_info,
290 ARRAY_SIZE(bus1_i2c_board_info));
291}