aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-u300/regulator.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-08 11:12:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-08 11:12:43 -0500
commit79c9601c2e0dbbe69895d302de4d19f3a31fbd30 (patch)
tree78d4be2df851b2b4106adcfd736622a90cecf9e9 /arch/arm/mach-u300/regulator.c
parent41440ffe21f29bdb985cab76b2d0b06d83e63b19 (diff)
parent3d14b5beba35250c548d3851a2b84fce742d8311 (diff)
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm: (272 commits) Fix soc_common PCMCIA configuration ARM: 5827/1: SA1100: h3100/h3600: emit messages on failed gpio_request ARM: 5826/1: SA1100: h3100/h3600: always build htc-egpio driver ARM: 5825/1: SA1100: h3600: update defconfig ARM: 5824/1: SA1100: reuse h3600 PCMCIA driver on h3100 ARM: 5823/1: SA1100: h3100/h3600: add support for gpio-keys ARM: 5822/1: SA1100: h3100/h3600: clean up #includes ARM: 5821/1: SA1100: h3100/h3600: revise copyright boilerplates ARM: 5820/1: SA1100: h3100/h3600: split h3600.c ARM: 5819/1: SA1100: h3100/h3600: merge h3600.h and h3600_gpio.h into h3xxx.h ARM: 5818/1: SA1100: h3100/h3600: drop old GPIO definitions ARM: 5817/1: SA1100: h3100/h3600: configure all unused gpios as inputs ARM: 5816/1: SA1100: h3600: remove IRQ_GPIO_* definitions ARM: 5815/1: SA1100: h3100/h3600: remove now unused assign_h3600_egpio handlers ARM: 5814/1: SA1100: h3100/h3600: convert all users of assign_h3600_egpio to gpiolib ARM: 5813/1: SA1100: h3100/h3600: add htc-egpio driver ARM: 5812/1: SA1100: h3100/h3600: separate machine-specific LCD helpers ARM: 5811/2: pcmcia: convert sa1100_h3600 driver to gpiolib ARM: 5799/1: SA1100: h3600: stop setting direction for LCD pins ARM: 5798/1: SA1100: h3600: remove unused cruft from h3600.h ...
Diffstat (limited to 'arch/arm/mach-u300/regulator.c')
-rw-r--r--arch/arm/mach-u300/regulator.c88
1 files changed, 88 insertions, 0 deletions
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);