diff options
author | Mark Brown <broonie@linaro.org> | 2013-10-24 06:11:40 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-10-24 06:11:40 -0400 |
commit | aa11a358f88b371dee64a556eb7acc9ea05b0102 (patch) | |
tree | 439035bd5fd20b04b3a2ac0200afd3f0319d42d2 | |
parent | 67471b6a242b182dd44afbd3848fcfe4065c6445 (diff) | |
parent | 18dca93eb7faa8d90fbc54bfb08560caebbf92cd (diff) |
Merge remote-tracking branch 'regulator/topic/stw481x' into regulator-next
-rw-r--r-- | drivers/regulator/Kconfig | 8 | ||||
-rw-r--r-- | drivers/regulator/Makefile | 1 | ||||
-rw-r--r-- | drivers/regulator/stw481x-vmmc.c | 111 |
3 files changed, 120 insertions, 0 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 75c04b8b3ec2..ce785f481281 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -427,6 +427,14 @@ config REGULATOR_TI_ABB | |||
427 | on TI SoCs may be unstable without enabling this as it provides | 427 | on TI SoCs may be unstable without enabling this as it provides |
428 | device specific optimized bias to allow/optimize functionality. | 428 | device specific optimized bias to allow/optimize functionality. |
429 | 429 | ||
430 | config REGULATOR_STW481X_VMMC | ||
431 | bool "ST Microelectronics STW481X VMMC regulator" | ||
432 | depends on MFD_STW481X | ||
433 | default y if MFD_STW481X | ||
434 | help | ||
435 | This driver supports the internal VMMC regulator in the STw481x | ||
436 | PMIC chips. | ||
437 | |||
430 | config REGULATOR_TPS51632 | 438 | config REGULATOR_TPS51632 |
431 | tristate "TI TPS51632 Power Regulator" | 439 | tristate "TI TPS51632 Power Regulator" |
432 | depends on I2C | 440 | depends on I2C |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 828c6054960f..01c597ea1744 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
@@ -57,6 +57,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o | |||
57 | obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o | 57 | obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o |
58 | obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o | 58 | obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o |
59 | obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o | 59 | obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o |
60 | obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o | ||
60 | obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o | 61 | obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o |
61 | obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o | 62 | obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o |
62 | obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o | 63 | obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o |
diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c new file mode 100644 index 000000000000..f78857bd6a15 --- /dev/null +++ b/drivers/regulator/stw481x-vmmc.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * Regulator driver for STw4810/STw4811 VMMC regulator. | ||
3 | * | ||
4 | * Copyright (C) 2013 ST-Ericsson SA | ||
5 | * Written on behalf of Linaro for ST-Ericsson | ||
6 | * | ||
7 | * Author: Linus Walleij <linus.walleij@linaro.org> | ||
8 | * | ||
9 | * License terms: GNU General Public License (GPL) version 2 | ||
10 | */ | ||
11 | |||
12 | #include <linux/err.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/mfd/stw481x.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/regulator/driver.h> | ||
18 | #include <linux/regulator/of_regulator.h> | ||
19 | |||
20 | static const unsigned int stw481x_vmmc_voltages[] = { | ||
21 | 1800000, | ||
22 | 1800000, | ||
23 | 2850000, | ||
24 | 3000000, | ||
25 | 1850000, | ||
26 | 2600000, | ||
27 | 2700000, | ||
28 | 3300000, | ||
29 | }; | ||
30 | |||
31 | static struct regulator_ops stw481x_vmmc_ops = { | ||
32 | .list_voltage = regulator_list_voltage_table, | ||
33 | .enable = regulator_enable_regmap, | ||
34 | .disable = regulator_disable_regmap, | ||
35 | .is_enabled = regulator_is_enabled_regmap, | ||
36 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
37 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
38 | }; | ||
39 | |||
40 | static struct regulator_desc vmmc_regulator = { | ||
41 | .name = "VMMC", | ||
42 | .id = 0, | ||
43 | .ops = &stw481x_vmmc_ops, | ||
44 | .type = REGULATOR_VOLTAGE, | ||
45 | .owner = THIS_MODULE, | ||
46 | .n_voltages = ARRAY_SIZE(stw481x_vmmc_voltages), | ||
47 | .volt_table = stw481x_vmmc_voltages, | ||
48 | .enable_time = 200, /* FIXME: look this up */ | ||
49 | .enable_reg = STW_CONF1, | ||
50 | .enable_mask = STW_CONF1_PDN_VMMC, | ||
51 | .vsel_reg = STW_CONF1, | ||
52 | .vsel_mask = STW_CONF1_VMMC_MASK, | ||
53 | }; | ||
54 | |||
55 | static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) | ||
56 | { | ||
57 | struct stw481x *stw481x = dev_get_platdata(&pdev->dev); | ||
58 | struct regulator_config config = { }; | ||
59 | int ret; | ||
60 | |||
61 | /* First disable the external VMMC if it's active */ | ||
62 | ret = regmap_update_bits(stw481x->map, STW_CONF2, | ||
63 | STW_CONF2_VMMC_EXT, 0); | ||
64 | if (ret) { | ||
65 | dev_err(&pdev->dev, "could not disable external VMMC\n"); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | /* Register VMMC regulator */ | ||
70 | config.dev = &pdev->dev; | ||
71 | config.driver_data = stw481x; | ||
72 | config.regmap = stw481x->map; | ||
73 | config.of_node = pdev->dev.of_node; | ||
74 | config.init_data = of_get_regulator_init_data(&pdev->dev, | ||
75 | pdev->dev.of_node); | ||
76 | |||
77 | stw481x->vmmc_regulator = regulator_register(&vmmc_regulator, &config); | ||
78 | if (IS_ERR(stw481x->vmmc_regulator)) { | ||
79 | dev_err(&pdev->dev, | ||
80 | "error initializing STw481x VMMC regulator\n"); | ||
81 | return PTR_ERR(stw481x->vmmc_regulator); | ||
82 | } | ||
83 | |||
84 | dev_info(&pdev->dev, "initialized STw481x VMMC regulator\n"); | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | static int stw481x_vmmc_regulator_remove(struct platform_device *pdev) | ||
89 | { | ||
90 | struct stw481x *stw481x = dev_get_platdata(&pdev->dev); | ||
91 | |||
92 | regulator_unregister(stw481x->vmmc_regulator); | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static const struct of_device_id stw481x_vmmc_match[] = { | ||
97 | { .compatible = "st,stw481x-vmmc", }, | ||
98 | {}, | ||
99 | }; | ||
100 | |||
101 | static struct platform_driver stw481x_vmmc_regulator_driver = { | ||
102 | .driver = { | ||
103 | .name = "stw481x-vmmc-regulator", | ||
104 | .owner = THIS_MODULE, | ||
105 | .of_match_table = stw481x_vmmc_match, | ||
106 | }, | ||
107 | .probe = stw481x_vmmc_regulator_probe, | ||
108 | .remove = stw481x_vmmc_regulator_remove, | ||
109 | }; | ||
110 | |||
111 | module_platform_driver(stw481x_vmmc_regulator_driver); | ||