aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-u300/regulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-u300/regulator.c')
-rw-r--r--arch/arm/mach-u300/regulator.c67
1 files changed, 56 insertions, 11 deletions
diff --git a/arch/arm/mach-u300/regulator.c b/arch/arm/mach-u300/regulator.c
index 9c53f01c62eb..bf40cd478fe9 100644
--- a/arch/arm/mach-u300/regulator.c
+++ b/arch/arm/mach-u300/regulator.c
@@ -10,11 +10,18 @@
10#include <linux/device.h> 10#include <linux/device.h>
11#include <linux/signal.h> 11#include <linux/signal.h>
12#include <linux/err.h> 12#include <linux/err.h>
13#include <linux/of.h>
14#include <linux/module.h>
15#include <linux/platform_device.h>
16#include <linux/regulator/machine.h>
13#include <linux/regulator/consumer.h> 17#include <linux/regulator/consumer.h>
14/* Those are just for writing in syscon */ 18#include <linux/mfd/syscon.h>
15#include <linux/io.h> 19#include <linux/regmap.h>
16#include <mach/hardware.h> 20
17#include <mach/syscon.h> 21/* Power Management Control 16bit (R/W) */
22#define U300_SYSCON_PMCR (0x50)
23#define U300_SYSCON_PMCR_DCON_ENABLE (0x0002)
24#define U300_SYSCON_PMCR_PWR_MGNT_ENABLE (0x0001)
18 25
19/* 26/*
20 * Regulators that power the board and chip and which are 27 * Regulators that power the board and chip and which are
@@ -47,13 +54,28 @@ void u300_pm_poweroff(void)
47/* 54/*
48 * Hog the regulators needed to power up the board. 55 * Hog the regulators needed to power up the board.
49 */ 56 */
50static int __init u300_init_boardpower(void) 57static int __init __u300_init_boardpower(struct platform_device *pdev)
51{ 58{
59 struct device_node *np = pdev->dev.of_node;
60 struct device_node *syscon_np;
61 struct regmap *regmap;
52 int err; 62 int err;
53 u32 val;
54 63
55 pr_info("U300: setting up board power\n"); 64 pr_info("U300: setting up board power\n");
56 main_power_15 = regulator_get(NULL, "vana15"); 65
66 syscon_np = of_parse_phandle(np, "syscon", 0);
67 if (!syscon_np) {
68 pr_crit("U300: no syscon node\n");
69 return -ENODEV;
70 }
71 regmap = syscon_node_to_regmap(syscon_np);
72 if (!regmap) {
73 pr_crit("U300: could not locate syscon regmap\n");
74 return -ENODEV;
75 }
76
77 main_power_15 = regulator_get(&pdev->dev, "vana15");
78
57 if (IS_ERR(main_power_15)) { 79 if (IS_ERR(main_power_15)) {
58 pr_err("could not get vana15"); 80 pr_err("could not get vana15");
59 return PTR_ERR(main_power_15); 81 return PTR_ERR(main_power_15);
@@ -72,9 +94,8 @@ static int __init u300_init_boardpower(void)
72 * the rest of the U300 power management is implemented. 94 * the rest of the U300 power management is implemented.
73 */ 95 */
74 pr_info("U300: disable system controller pull-up\n"); 96 pr_info("U300: disable system controller pull-up\n");
75 val = readw(U300_SYSCON_VBASE + U300_SYSCON_PMCR); 97 regmap_update_bits(regmap, U300_SYSCON_PMCR,
76 val &= ~U300_SYSCON_PMCR_DCON_ENABLE; 98 U300_SYSCON_PMCR_DCON_ENABLE, 0);
77 writew(val, U300_SYSCON_VBASE + U300_SYSCON_PMCR);
78 99
79 /* Register globally exported PM poweroff hook */ 100 /* Register globally exported PM poweroff hook */
80 pm_power_off = u300_pm_poweroff; 101 pm_power_off = u300_pm_poweroff;
@@ -82,7 +103,31 @@ static int __init u300_init_boardpower(void)
82 return 0; 103 return 0;
83} 104}
84 105
106static int __init s365_board_probe(struct platform_device *pdev)
107{
108 return __u300_init_boardpower(pdev);
109}
110
111static const struct of_device_id s365_board_match[] = {
112 { .compatible = "stericsson,s365" },
113 {},
114};
115
116static struct platform_driver s365_board_driver = {
117 .driver = {
118 .name = "s365-board",
119 .owner = THIS_MODULE,
120 .of_match_table = s365_board_match,
121 },
122};
123
85/* 124/*
86 * So at module init time we hog the regulator! 125 * So at module init time we hog the regulator!
87 */ 126 */
88module_init(u300_init_boardpower); 127static int __init u300_init_boardpower(void)
128{
129 return platform_driver_probe(&s365_board_driver,
130 s365_board_probe);
131}
132
133device_initcall(u300_init_boardpower);