summaryrefslogtreecommitdiff
path: root/arch/arm/mach-u300/i2c.c
blob: 96800aa1316d980d9e41f94c11360918aedb9ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/*
 * arch/arm/mach-u300/i2c.c
 *
 * Copyright (C) 2009-2012 ST-Ericsson AB
 * License terms: GNU General Public License (GPL) version 2
 *
 * Register board i2c devices
 * Author: Linus Walleij <linus.walleij@stericsson.com>
 */
#include <linux/kernel.h>
#include <linux/i2c.h>
#include <linux/mfd/ab3100.h>
#include <linux/regulator/machine.h>
#include <linux/amba/bus.h>
#include <mach/irqs.h>

/*
 * Initial settings of ab3100 registers.
 * Common for below LDO regulator settings are that
 * bit 7-5 controls voltage. Bit 4 turns regulator ON(1) or OFF(0).
 * Bit 3-2 controls sleep enable and bit 1-0 controls sleep mode.
 */

/* LDO_A 0x16: 2.75V, ON, SLEEP_A, SLEEP OFF GND */
#define LDO_A_SETTING		0x16
/* LDO_C 0x10: 2.65V, ON, SLEEP_A or B, SLEEP full power */
#define LDO_C_SETTING		0x10
/* LDO_D 0x10: 2.65V, ON, sleep mode not used */
#define LDO_D_SETTING		0x10
/* LDO_E 0x10: 1.8V, ON, SLEEP_A or B, SLEEP full power */
#define LDO_E_SETTING		0x10
/* LDO_E SLEEP 0x00: 1.8V, not used, SLEEP_A or B, not used */
#define LDO_E_SLEEP_SETTING	0x00
/* LDO_F 0xD0: 2.5V, ON, SLEEP_A or B, SLEEP full power */
#define LDO_F_SETTING		0xD0
/* LDO_G 0x00: 2.85V, OFF, SLEEP_A or B, SLEEP full power */
#define LDO_G_SETTING		0x00
/* LDO_H 0x18: 2.75V, ON, SLEEP_B, SLEEP full power */
#define LDO_H_SETTING		0x18
/* LDO_K 0x00: 2.75V, OFF, SLEEP_A or B, SLEEP full power */
#define LDO_K_SETTING		0x00
/* LDO_EXT 0x00: Voltage not set, OFF, not used, not used */
#define LDO_EXT_SETTING		0x00
/* BUCK 0x7D: 1.2V, ON, SLEEP_A and B, SLEEP low power */
#define BUCK_SETTING	0x7D
/* BUCK SLEEP 0xAC: 1.05V, Not used, SLEEP_A and B, Not used */
#define BUCK_SLEEP_SETTING	0xAC

#ifdef CONFIG_AB3100_CORE
static struct regulator_consumer_supply supply_ldo_c[] = {
	{
		.dev_name = "ab3100-codec",
		.supply = "vaudio", /* Powers the codec */
	},
};

/*
 * This one needs to be a supply so we can turn it off
 * in order to shut down the system.
 */
static struct regulator_consumer_supply supply_ldo_d[] = {
	{
		.supply = "vana15", /* Powers the SoC (CPU etc) */
	},
};

static struct regulator_consumer_supply supply_ldo_g[] = {
	{
		.dev_name = "mmci",
		.supply = "vmmc", /* Powers MMC/SD card */
	},
};

static struct regulator_consumer_supply supply_ldo_h[] = {
	{
		.dev_name = "xgam_pdi",
		.supply = "vdisp", /* Powers camera, display etc */
	},
};

static struct regulator_consumer_supply supply_ldo_k[] = {
	{
		.dev_name = "irda",
		.supply = "vir", /* Power IrDA */
	},
};

/*
 * This is a placeholder for whoever wish to use the
 * external power.
 */
static struct regulator_consumer_supply supply_ldo_ext[] = {
	{
		.supply = "vext", /* External power */
	},
};

/* Preset (hardware defined) voltages for these regulators */
#define LDO_A_VOLTAGE 2750000
#define LDO_C_VOLTAGE 2650000
#define LDO_D_VOLTAGE 2650000

static struct ab3100_platform_data ab3100_plf_data = {
	.reg_constraints = {
		/* LDO A routing and constraints */
		{
			.constraints = {
				.name = "vrad",
				.min_uV = LDO_A_VOLTAGE,
				.max_uV = LDO_A_VOLTAGE,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.always_on = 1,
				.boot_on = 1,
			},
		},
		/* LDO C routing and constraints */
		{
			.constraints = {
				.min_uV = LDO_C_VOLTAGE,
				.max_uV = LDO_C_VOLTAGE,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
			},
			.num_consumer_supplies = ARRAY_SIZE(supply_ldo_c),
			.consumer_supplies = supply_ldo_c,
		},
		/* LDO D routing and constraints */
		{
			.constraints = {
				.min_uV = LDO_D_VOLTAGE,
				.max_uV = LDO_D_VOLTAGE,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.valid_ops_mask = REGULATOR_CHANGE_STATUS,
				/*
				 * Actually this is boot_on but we need
				 * to reference count it externally to
				 * be able to shut down the system.
				 */
			},
			.num_consumer_supplies = ARRAY_SIZE(supply_ldo_d),
			.consumer_supplies = supply_ldo_d,
		},
		/* LDO E routing and constraints */
		{
			.constraints = {
				.name = "vio",
				.min_uV = 1800000,
				.max_uV = 1800000,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.always_on = 1,
				.boot_on = 1,
			},
		},
		/* LDO F routing and constraints */
		{
			.constraints = {
				.name = "vana25",
				.min_uV = 2500000,
				.max_uV = 2500000,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.always_on = 1,
				.boot_on = 1,
			},
		},
		/* LDO G routing and constraints */
		{
			.constraints = {
				.min_uV = 1500000,
				.max_uV = 2850000,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.valid_ops_mask =
				REGULATOR_CHANGE_VOLTAGE |
				REGULATOR_CHANGE_STATUS,
			},
			.num_consumer_supplies = ARRAY_SIZE(supply_ldo_g),
			.consumer_supplies = supply_ldo_g,
		},
		/* LDO H routing and constraints */
		{
			.constraints = {
				.min_uV = 1200000,
				.max_uV = 2750000,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.valid_ops_mask =
				REGULATOR_CHANGE_VOLTAGE |
				REGULATOR_CHANGE_STATUS,
			},
			.num_consumer_supplies = ARRAY_SIZE(supply_ldo_h),
			.consumer_supplies = supply_ldo_h,
		},
		/* LDO K routing and constraints */
		{
			.constraints = {
				.min_uV = 1800000,
				.max_uV = 2750000,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.valid_ops_mask =
				REGULATOR_CHANGE_VOLTAGE |
				REGULATOR_CHANGE_STATUS,
			},
			.num_consumer_supplies = ARRAY_SIZE(supply_ldo_k),
			.consumer_supplies = supply_ldo_k,
		},
		/* External regulator interface. No fixed voltage specified.
		 * If we knew the voltage of the external regulator and it
		 * was connected on the board, we could add the (fixed)
		 * voltage for it here.
		 */
		{
			.constraints = {
				.min_uV = 0,
				.max_uV = 0,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.valid_ops_mask =
				REGULATOR_CHANGE_STATUS,
			},
			.num_consumer_supplies = ARRAY_SIZE(supply_ldo_ext),
			.consumer_supplies = supply_ldo_ext,
		},
		/* Buck converter routing and constraints */
		{
			.constraints = {
				.name = "vcore",
				.min_uV = 1200000,
				.max_uV = 1800000,
				.valid_modes_mask = REGULATOR_MODE_NORMAL,
				.valid_ops_mask =
				REGULATOR_CHANGE_VOLTAGE,
				.always_on = 1,
				.boot_on = 1,
			},
		},
	},
	.reg_initvals = {
		LDO_A_SETTING,
		LDO_C_SETTING,
		LDO_E_SETTING,
		LDO_E_SLEEP_SETTING,
		LDO_F_SETTING,
		LDO_G_SETTING,
		LDO_H_SETTING,
		LDO_K_SETTING,
		LDO_EXT_SETTING,
		BUCK_SETTING,
		BUCK_SLEEP_SETTING,
		LDO_D_SETTING,
	},
};
#endif

static struct i2c_board_info __initdata bus0_i2c_board_info[] = {
#ifdef CONFIG_AB3100_CORE
	{
		.type = "ab3100",
		.addr = 0x48,
		.irq = IRQ_U300_IRQ0_EXT,
		.platform_data = &ab3100_plf_data,
	},
#else
	{ },
#endif
};

static struct i2c_board_info __initdata bus1_i2c_board_info[] = {
	{
		.type = "fwcam",
		.addr = 0x10,
	},
	{
		.type = "fwcam",
		.addr = 0x5d,
	},
};

void __init u300_i2c_register_board_devices(void)
{
	i2c_register_board_info(0, bus0_i2c_board_info,
				ARRAY_SIZE(bus0_i2c_board_info));
	/*
	 * This makes the core shut down all unused regulators
	 * after all the initcalls have completed.
	 */
	regulator_has_full_constraints();
	i2c_register_board_info(1, bus1_i2c_board_info,
				ARRAY_SIZE(bus1_i2c_board_info));
}