Add a virtual PMIC in order to supply the regulators that pn544 needed. Change-Id: I28ea959d760c8f264ce968df77b087d554140181 Signed-off-by: Neil Zhang <zhangwm@xxxxxxxxxxx> --- drivers/regulator/Kconfig | 5 ++ drivers/regulator/Makefile | 1 + drivers/regulator/vpmic.c | 135 +++++++++++++++++++++++++++++++++++++++ include/linux/regulator/vpmic.h | 25 +++++++ 4 files changed, 166 insertions(+), 0 deletions(-) create mode 100644 drivers/regulator/vpmic.c create mode 100644 include/linux/regulator/vpmic.h diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index a4bf594..fed4440 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -263,6 +263,11 @@ config REGULATOR_88PM8607 help This driver supports 88PM8607 voltage regulator chips. +config REGULATOR_VPMIC + bool "Marvell VPMIC Power regulators" + help + This driver supports VPMIC voltage regulator, only for NFC test usage. + config REGULATOR_88PM800 bool "Marvell 88PM800 Power regulators" depends on MFD_88PM80X=y diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index c4f4458..f7df62d 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -39,6 +39,7 @@ obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o +obj-$(CONFIG_REGULATOR_VPMIC) += vpmic.o obj-$(CONFIG_REGULATOR_88PM800) += 88pm800.o obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o diff --git a/drivers/regulator/vpmic.c b/drivers/regulator/vpmic.c new file mode 100644 index 0000000..288841b --- /dev/null +++ b/drivers/regulator/vpmic.c @@ -0,0 +1,135 @@ +/* + * Virtual Regulators driver for PN544 + * + * Copyright (C) 2010 Marvell International Ltd. + * Neil Zhang <zhangwm@xxxxxxxxxxx> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/err.h> +#include <linux/platform_device.h> +#include <linux/regulator/driver.h> +#include <linux/regulator/machine.h> + +#include <linux/regulator/vpmic.h> + + +struct vpmic_regulator_info { + struct regulator_desc desc; + struct regulator_dev *regulator; +}; + + +static int vpmic_enable(struct regulator_dev *rdev) +{ + struct vpmic_regulator_info *info = rdev_get_drvdata(rdev); + dev_dbg(&rdev->dev, "vpmic_enable: %s\n", info->desc.name); + + return 0; +} + +static int vpmic_disable(struct regulator_dev *rdev) +{ + struct vpmic_regulator_info *info = rdev_get_drvdata(rdev); + dev_dbg(&rdev->dev, "vpmic_disable: %s\n", info->desc.name); + + return 0; +} + + +static struct regulator_ops vpmic_regulator_ops = { + .enable = vpmic_enable, + .disable = vpmic_disable, +}; + + +#define VPMIC_DVC(vreg) \ +{ \ + .desc = { \ + .name = #vreg, \ + .ops = &vpmic_regulator_ops, \ + .type = REGULATOR_VOLTAGE, \ + .id = VPMIC_ID_##vreg, \ + .owner = THIS_MODULE, \ + }, \ +} + + +static struct vpmic_regulator_info vpmic_info[] = { + VPMIC_DVC(Vdd_IO), + VPMIC_DVC(VBat), + VPMIC_DVC(VSim), +}; + + +static int __devinit vpmic_regulator_probe(struct platform_device *pdev) +{ + struct vpmic_regulator_info *info = NULL; + struct regulator_init_data *pdata = NULL; + int i = 0; + + pdata = pdev->dev.platform_data; + if (pdata == NULL) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(vpmic_info); i++) { + info = &vpmic_info[i]; + if (!strcmp(info->desc.name, pdata->constraints.name)) + break; + } + + if (i >= ARRAY_SIZE(vpmic_info)) { + dev_err(&pdev->dev, "Failed to find regulator %s\n", + pdata->constraints.name); + return -EINVAL; + } + + info->regulator = regulator_register(&info->desc, &pdev->dev, + pdata, info); + if (IS_ERR(info->regulator)) { + dev_err(&pdev->dev, "failed to register regulator %s\n", + info->desc.name); + return PTR_ERR(info->regulator); + } + + platform_set_drvdata(pdev, info); + + return 0; +} + +static int __devexit vpmic_regulator_remove(struct platform_device *pdev) +{ + struct vpmic_regulator_info *info = platform_get_drvdata(pdev); + + platform_set_drvdata(pdev, NULL); + regulator_unregister(info->regulator); + return 0; +} + +static struct platform_driver vpmic_regulator_driver = { + .driver = { + .name = "vpmic-regulator", + .owner = THIS_MODULE, + }, + .probe = vpmic_regulator_probe, + .remove = __devexit_p(vpmic_regulator_remove), +}; + +static int __init vpmic_regulator_init(void) +{ + return platform_driver_register(&vpmic_regulator_driver); +} +subsys_initcall(vpmic_regulator_init); + +static void __exit vpmic_regulator_exit(void) +{ + platform_driver_unregister(&vpmic_regulator_driver); +} +module_exit(vpmic_regulator_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Regulator Driver for Marvell Virtual PMIC"); diff --git a/include/linux/regulator/vpmic.h b/include/linux/regulator/vpmic.h new file mode 100644 index 0000000..0e8e5bf --- /dev/null +++ b/include/linux/regulator/vpmic.h @@ -0,0 +1,25 @@ +/* + * Marvell vpmic Interface + * + * Copyright (C) 2010 Marvell International Ltd. + * Neil Zhang <zhangwm@xxxxxxxxxxx> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + + +#ifndef __VPMIC_H +#define __VPMIC_H + + +enum { + VPMIC_ID_Vdd_IO = 0, + VPMIC_ID_VBat, + VPMIC_ID_VSim, + VPMIC_ID_RG_MAX, +}; + + +#endif -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html