summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorNancy Chen <Nancy.Chen@freescale.com>2011-10-27 16:52:37 -0500
committerJason Liu <r64343@freescale.com>2012-01-09 21:03:20 +0800
commit2fc112ccacaa975845659cd1633bf7eef425e60c (patch)
tree945f65522a038bcdaa32db7daaf8308e0503aa05 /drivers/regulator
parent0d41e1935defa9bf31bc70a0412229f2fa8e9c95 (diff)
ENGR00160797-2 Add Anatop regulator driver
Add Anatop regulator driver. Signed-off-by: Nancy Chen <Nancy.Chen@freescale.com>
Diffstat (limited to 'drivers/regulator')
-rwxr-xr-xdrivers/regulator/Kconfig8
-rwxr-xr-xdrivers/regulator/Makefile1
-rw-r--r--drivers/regulator/anatop-regulator.c235
3 files changed, 244 insertions, 0 deletions
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index af5ab1ea98b8..db301f4758b3 100755
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -290,6 +290,14 @@ config REGULATOR_DB8500_PRCMU
config REGULATOR_TPS6586X
tristate "TI TPS6586X Power regulators"
+
+config REGULATOR_ANATOP
+ tristate "ANATOP LDO regulators"
+ depends on REGULATOR
+ depends on ARCH_MX6
+ default y
+ help
+ Say y here to support ANATOP LDOs regulators.
depends on MFD_TPS6586X
help
This driver supports TPS6586X voltage regulator chips.
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 6de507e1cf0c..ed0c60604da0 100755
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o
obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
+obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
obj-$(CONFIG_REGULATOR_MAX17135) += max17135-regulator.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
new file mode 100644
index 000000000000..8eb76587c8fa
--- /dev/null
+++ b/drivers/regulator/anatop-regulator.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/slab.h>
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/anatop-regulator.h>
+
+static int anatop_set_voltage(struct regulator_dev *reg, int MiniV, int uv)
+{
+ struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+ if (anatop_reg->rdata->set_voltage)
+ return anatop_reg->rdata->set_voltage(anatop_reg, uv);
+ else
+ return -ENOTSUPP;
+}
+
+static int anatop_get_voltage(struct regulator_dev *reg)
+{
+ struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+ if (anatop_reg->rdata->get_voltage)
+ return anatop_reg->rdata->get_voltage(anatop_reg);
+ else
+ return -ENOTSUPP;
+}
+
+static int anatop_enable(struct regulator_dev *reg)
+{
+ struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+ return anatop_reg->rdata->enable(anatop_reg);
+}
+
+static int anatop_disable(struct regulator_dev *reg)
+{
+ struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+ return anatop_reg->rdata->disable(anatop_reg);
+}
+
+static int anatop_is_enabled(struct regulator_dev *reg)
+{
+ struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
+
+ return anatop_reg->rdata->is_enabled(anatop_reg);
+}
+
+static struct regulator_ops anatop_rops = {
+ .set_voltage = anatop_set_voltage,
+ .get_voltage = anatop_get_voltage,
+ .enable = anatop_enable,
+ .disable = anatop_disable,
+ .is_enabled = anatop_is_enabled,
+};
+
+static struct regulator_desc anatop_reg_desc[] = {
+ {
+ .name = "vddpu",
+ .id = ANATOP_VDDPU,
+ .ops = &anatop_rops,
+ .irq = 0,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE
+ },
+ {
+ .name = "vddcore",
+ .id = ANATOP_VDDCORE,
+ .ops = &anatop_rops,
+ .irq = 0,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE
+ },
+ {
+ .name = "vddsoc",
+ .id = ANATOP_VDDSOC,
+ .ops = &anatop_rops,
+ .irq = 0,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE
+ },
+ {
+ .name = "vdd2p5",
+ .id = ANATOP_VDD2P5,
+ .ops = &anatop_rops,
+ .irq = 0,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE
+ },
+ {
+ .name = "vdd1p1",
+ .id = ANATOP_VDD1P1,
+ .ops = &anatop_rops,
+ .irq = 0,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE
+ },
+ {
+ .name = "vdd3p0",
+ .id = ANATOP_VDD3P0,
+ .ops = &anatop_rops,
+ .irq = 0,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE
+ },
+};
+
+int anatop_regulator_probe(struct platform_device *pdev)
+{
+ struct regulator_desc *rdesc;
+ struct regulator_dev *rdev;
+ struct anatop_regulator *sreg;
+ struct regulator_init_data *initdata;
+
+ sreg = platform_get_drvdata(pdev);
+ initdata = pdev->dev.platform_data;
+ sreg->cur_current = 0;
+ sreg->next_current = 0;
+ sreg->cur_voltage = 0;
+
+ init_waitqueue_head(&sreg->wait_q);
+ spin_lock_init(&sreg->lock);
+
+ if (pdev->id > ANATOP_SUPPLY_NUM) {
+ rdesc = kzalloc(sizeof(struct regulator_desc), GFP_KERNEL);
+ memcpy(rdesc, &anatop_reg_desc[ANATOP_SUPPLY_NUM],
+ sizeof(struct regulator_desc));
+ rdesc->name = kstrdup(sreg->rdata->name, GFP_KERNEL);
+ } else
+ rdesc = &anatop_reg_desc[pdev->id];
+
+ pr_debug("probing regulator %s %s %d\n",
+ sreg->rdata->name,
+ rdesc->name,
+ pdev->id);
+
+ /* register regulator */
+ rdev = regulator_register(rdesc, &pdev->dev,
+ initdata, sreg);
+
+ if (IS_ERR(rdev)) {
+ dev_err(&pdev->dev, "failed to register %s\n",
+ rdesc->name);
+ return PTR_ERR(rdev);
+ }
+
+ return 0;
+}
+
+
+int anatop_regulator_remove(struct platform_device *pdev)
+{
+ struct regulator_dev *rdev = platform_get_drvdata(pdev);
+
+ regulator_unregister(rdev);
+
+ return 0;
+
+}
+
+int anatop_register_regulator(
+ struct anatop_regulator *reg_data, int reg,
+ struct regulator_init_data *initdata)
+{
+ struct platform_device *pdev;
+ int ret;
+
+ pdev = platform_device_alloc("anatop_reg", reg);
+ if (!pdev)
+ return -ENOMEM;
+
+ pdev->dev.platform_data = initdata;
+
+ platform_set_drvdata(pdev, reg_data);
+ ret = platform_device_add(pdev);
+
+ if (ret != 0) {
+ pr_debug("Failed to register regulator %d: %d\n",
+ reg, ret);
+ platform_device_del(pdev);
+ }
+ pr_debug("register regulator %s, %d: %d\n",
+ reg_data->rdata->name, reg, ret);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(anatop_register_regulator);
+
+struct platform_driver anatop_reg = {
+ .driver = {
+ .name = "anatop_reg",
+ },
+ .probe = anatop_regulator_probe,
+ .remove = anatop_regulator_remove,
+};
+
+int anatop_regulator_init(void)
+{
+ return platform_driver_register(&anatop_reg);
+}
+
+void anatop_regulator_exit(void)
+{
+ platform_driver_unregister(&anatop_reg);
+}
+
+postcore_initcall(anatop_regulator_init);
+module_exit(anatop_regulator_exit);
+
+MODULE_AUTHOR("Freescale Semiconductor, Inc.");
+MODULE_DESCRIPTION("ANATOP Regulator driver");
+MODULE_LICENSE("GPL");
+