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