aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-u300
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-u300')
-rw-r--r--arch/arm/mach-u300/Makefile1
-rw-r--r--arch/arm/mach-u300/i2c.c249
-rw-r--r--arch/arm/mach-u300/mmc.c64
-rw-r--r--arch/arm/mach-u300/regulator.c88
4 files changed, 342 insertions, 60 deletions
diff --git a/arch/arm/mach-u300/Makefile b/arch/arm/mach-u300/Makefile
index 885b5c027c1e..fab46fe9a71f 100644
--- a/arch/arm/mach-u300/Makefile
+++ b/arch/arm/mach-u300/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_MMC) += mmc.o
12obj-$(CONFIG_SPI_PL022) += spi.o 12obj-$(CONFIG_SPI_PL022) += spi.o
13obj-$(CONFIG_MACH_U300_SPIDUMMY) += dummyspichip.o 13obj-$(CONFIG_MACH_U300_SPIDUMMY) += dummyspichip.o
14obj-$(CONFIG_I2C_STU300) += i2c.o 14obj-$(CONFIG_I2C_STU300) += i2c.o
15obj-$(CONFIG_REGULATOR_AB3100) += regulator.o
diff --git a/arch/arm/mach-u300/i2c.c b/arch/arm/mach-u300/i2c.c
index 10be1f888b27..c73ed06b6065 100644
--- a/arch/arm/mach-u300/i2c.c
+++ b/arch/arm/mach-u300/i2c.c
@@ -9,13 +9,257 @@
9 */ 9 */
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/i2c.h> 11#include <linux/i2c.h>
12#include <linux/mfd/ab3100.h>
13#include <linux/regulator/machine.h>
14#include <linux/amba/bus.h>
12#include <mach/irqs.h> 15#include <mach/irqs.h>
13 16
17/*
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 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
134 /*
135 * Actually this is boot_on but we need
136 * to reference count it externally to
137 * be able to shut down the system.
138 */
139 },
140 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_d),
141 .consumer_supplies = supply_ldo_d,
142 },
143 /* LDO E routing and constraints */
144 {
145 .constraints = {
146 .name = "vio",
147 .min_uV = 1800000,
148 .max_uV = 1800000,
149 .valid_modes_mask = REGULATOR_MODE_NORMAL,
150 .valid_ops_mask =
151 REGULATOR_CHANGE_VOLTAGE |
152 REGULATOR_CHANGE_STATUS,
153 .always_on = 1,
154 .boot_on = 1,
155 },
156 },
157 /* LDO F routing and constraints */
158 {
159 .constraints = {
160 .name = "vana25",
161 .min_uV = 2500000,
162 .max_uV = 2500000,
163 .valid_modes_mask = REGULATOR_MODE_NORMAL,
164 .valid_ops_mask =
165 REGULATOR_CHANGE_VOLTAGE |
166 REGULATOR_CHANGE_STATUS,
167 .always_on = 1,
168 .boot_on = 1,
169 },
170 },
171 /* LDO G routing and constraints */
172 {
173 .constraints = {
174 .min_uV = 1500000,
175 .max_uV = 2850000,
176 .valid_modes_mask = REGULATOR_MODE_NORMAL,
177 .valid_ops_mask =
178 REGULATOR_CHANGE_VOLTAGE |
179 REGULATOR_CHANGE_STATUS,
180 },
181 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_g),
182 .consumer_supplies = supply_ldo_g,
183 },
184 /* LDO H routing and constraints */
185 {
186 .constraints = {
187 .min_uV = 1200000,
188 .max_uV = 2750000,
189 .valid_modes_mask = REGULATOR_MODE_NORMAL,
190 .valid_ops_mask =
191 REGULATOR_CHANGE_VOLTAGE |
192 REGULATOR_CHANGE_STATUS,
193 },
194 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_h),
195 .consumer_supplies = supply_ldo_h,
196 },
197 /* LDO K routing and constraints */
198 {
199 .constraints = {
200 .min_uV = 1800000,
201 .max_uV = 2750000,
202 .valid_modes_mask = REGULATOR_MODE_NORMAL,
203 .valid_ops_mask =
204 REGULATOR_CHANGE_VOLTAGE |
205 REGULATOR_CHANGE_STATUS,
206 },
207 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_k),
208 .consumer_supplies = supply_ldo_k,
209 },
210 /* External regulator interface. No fixed voltage specified.
211 * If we knew the voltage of the external regulator and it
212 * was connected on the board, we could add the (fixed)
213 * voltage for it here.
214 */
215 {
216 .constraints = {
217 .min_uV = 0,
218 .max_uV = 0,
219 .valid_modes_mask = REGULATOR_MODE_NORMAL,
220 .valid_ops_mask =
221 REGULATOR_CHANGE_STATUS,
222 },
223 .num_consumer_supplies = ARRAY_SIZE(supply_ldo_ext),
224 .consumer_supplies = supply_ldo_ext,
225 },
226 /* Buck converter routing and constraints */
227 {
228 .constraints = {
229 .name = "vcore",
230 .min_uV = 1200000,
231 .max_uV = 1800000,
232 .valid_modes_mask = REGULATOR_MODE_NORMAL,
233 .valid_ops_mask =
234 REGULATOR_CHANGE_VOLTAGE |
235 REGULATOR_CHANGE_STATUS,
236 .always_on = 1,
237 .boot_on = 1,
238 },
239 },
240 },
241 .reg_initvals = {
242 LDO_A_SETTING,
243 LDO_C_SETTING,
244 LDO_E_SETTING,
245 LDO_E_SLEEP_SETTING,
246 LDO_F_SETTING,
247 LDO_G_SETTING,
248 LDO_H_SETTING,
249 LDO_K_SETTING,
250 LDO_EXT_SETTING,
251 BUCK_SETTING,
252 BUCK_SLEEP_SETTING,
253 LDO_D_SETTING,
254 },
255};
256
14static struct i2c_board_info __initdata bus0_i2c_board_info[] = { 257static struct i2c_board_info __initdata bus0_i2c_board_info[] = {
15 { 258 {
16 .type = "ab3100", 259 .type = "ab3100",
17 .addr = 0x48, 260 .addr = 0x48,
18 .irq = IRQ_U300_IRQ0_EXT, 261 .irq = IRQ_U300_IRQ0_EXT,
262 .platform_data = &ab3100_plf_data,
19 }, 263 },
20}; 264};
21 265
@@ -38,6 +282,11 @@ void __init u300_i2c_register_board_devices(void)
38{ 282{
39 i2c_register_board_info(0, bus0_i2c_board_info, 283 i2c_register_board_info(0, bus0_i2c_board_info,
40 ARRAY_SIZE(bus0_i2c_board_info)); 284 ARRAY_SIZE(bus0_i2c_board_info));
285 /*
286 * This makes the core shut down all unused regulators
287 * after all the initcalls have completed.
288 */
289 regulator_has_full_constraints();
41 i2c_register_board_info(1, bus1_i2c_board_info, 290 i2c_register_board_info(1, bus1_i2c_board_info,
42 ARRAY_SIZE(bus1_i2c_board_info)); 291 ARRAY_SIZE(bus1_i2c_board_info));
43} 292}
diff --git a/arch/arm/mach-u300/mmc.c b/arch/arm/mach-u300/mmc.c
index 7b6b016786bb..109f5a6e71c7 100644
--- a/arch/arm/mach-u300/mmc.c
+++ b/arch/arm/mach-u300/mmc.c
@@ -40,64 +40,6 @@ static unsigned int mmc_status(struct device *dev)
40 return mmci_card->mmc_inserted; 40 return mmci_card->mmc_inserted;
41} 41}
42 42
43/*
44 * Here follows a large chunk of code which will only be enabled if you
45 * have both the AB3100 chip mounted and the MMC subsystem activated.
46 */
47
48static u32 mmc_translate_vdd(struct device *dev, unsigned int voltage)
49{
50 int v;
51
52 /*
53 * MMC Spec:
54 * bit 7: 1.70 - 1.95V
55 * bit 8 - 14: 2.0 - 2.6V
56 * bit 15 - 23: 2.7 - 3.6V
57 *
58 * ab3100 voltages:
59 * 000 - 2.85V
60 * 001 - 2.75V
61 * 010 - 1.8V
62 * 011 - 1.5V
63 */
64 switch (voltage) {
65 case 8:
66 v = 3;
67 break;
68 case 9:
69 case 10:
70 case 11:
71 case 12:
72 case 13:
73 case 14:
74 case 15:
75 v = 1;
76 break;
77 case 16:
78 v = 1;
79 break;
80 case 17:
81 case 18:
82 case 19:
83 case 20:
84 case 21:
85 case 22:
86 case 23:
87 case 24:
88 v = 0;
89 break;
90 default:
91 v = 0;
92 break;
93 }
94
95 /* PL180 voltage register bits */
96 return v << 2;
97}
98
99
100
101static int mmci_callback(void *data) 43static int mmci_callback(void *data)
102{ 44{
103 struct mmci_card_event *mmci_card = data; 45 struct mmci_card_event *mmci_card = data;
@@ -154,9 +96,11 @@ int __devinit mmc_init(struct amba_device *adev)
154 if (!mmci_card) 96 if (!mmci_card)
155 return -ENOMEM; 97 return -ENOMEM;
156 98
99 /*
100 * Do not set ocr_mask or voltage translation function,
101 * we have a regulator we can control instead.
102 */
157 /* Nominally 2.85V on our platform */ 103 /* Nominally 2.85V on our platform */
158 mmci_card->mmc0_plat_data.ocr_mask = MMC_VDD_28_29;
159 mmci_card->mmc0_plat_data.translate_vdd = mmc_translate_vdd;
160 mmci_card->mmc0_plat_data.status = mmc_status; 104 mmci_card->mmc0_plat_data.status = mmc_status;
161 mmci_card->mmc0_plat_data.gpio_wp = -1; 105 mmci_card->mmc0_plat_data.gpio_wp = -1;
162 mmci_card->mmc0_plat_data.gpio_cd = -1; 106 mmci_card->mmc0_plat_data.gpio_cd = -1;
diff --git a/arch/arm/mach-u300/regulator.c b/arch/arm/mach-u300/regulator.c
new file mode 100644
index 000000000000..9c53f01c62eb
--- /dev/null
+++ b/arch/arm/mach-u300/regulator.c
@@ -0,0 +1,88 @@
1/*
2 * arch/arm/mach-u300/regulator.c
3 *
4 * Copyright (C) 2009 ST-Ericsson AB
5 * License terms: GNU General Public License (GPL) version 2
6 * Handle board-bound regulators and board power not related
7 * to any devices.
8 * Author: Linus Walleij <linus.walleij@stericsson.com>
9 */
10#include <linux/device.h>
11#include <linux/signal.h>
12#include <linux/err.h>
13#include <linux/regulator/consumer.h>
14/* Those are just for writing in syscon */
15#include <linux/io.h>
16#include <mach/hardware.h>
17#include <mach/syscon.h>
18
19/*
20 * Regulators that power the board and chip and which are
21 * not copuled to specific drivers are hogged in these
22 * instances.
23 */
24static struct regulator *main_power_15;
25
26/*
27 * This function is used from pm.h to shut down the system by
28 * resetting all regulators in turn and then disable regulator
29 * LDO D (main power).
30 */
31void u300_pm_poweroff(void)
32{
33 sigset_t old, all;
34
35 sigfillset(&all);
36 if (!sigprocmask(SIG_BLOCK, &all, &old)) {
37 /* Disable LDO D to shut down the system */
38 if (main_power_15)
39 regulator_disable(main_power_15);
40 else
41 pr_err("regulator not available to shut down system\n");
42 (void) sigprocmask(SIG_SETMASK, &old, NULL);
43 }
44 return;
45}
46
47/*
48 * Hog the regulators needed to power up the board.
49 */
50static int __init u300_init_boardpower(void)
51{
52 int err;
53 u32 val;
54
55 pr_info("U300: setting up board power\n");
56 main_power_15 = regulator_get(NULL, "vana15");
57 if (IS_ERR(main_power_15)) {
58 pr_err("could not get vana15");
59 return PTR_ERR(main_power_15);
60 }
61 err = regulator_enable(main_power_15);
62 if (err) {
63 pr_err("could not enable vana15\n");
64 return err;
65 }
66
67 /*
68 * On U300 a special system controller register pulls up the DC
69 * until the vana15 (LDO D) regulator comes up. At this point, all
70 * regulators are set and we do not need power control via
71 * DC ON anymore. This function will likely be moved whenever
72 * the rest of the U300 power management is implemented.
73 */
74 pr_info("U300: disable system controller pull-up\n");
75 val = readw(U300_SYSCON_VBASE + U300_SYSCON_PMCR);
76 val &= ~U300_SYSCON_PMCR_DCON_ENABLE;
77 writew(val, U300_SYSCON_VBASE + U300_SYSCON_PMCR);
78
79 /* Register globally exported PM poweroff hook */
80 pm_power_off = u300_pm_poweroff;
81
82 return 0;
83}
84
85/*
86 * So at module init time we hog the regulator!
87 */
88module_init(u300_init_boardpower);