All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv4 0/4] OMAP SMPS regulator driver
@ 2011-07-28 11:48 Tero Kristo
  2011-07-28 11:48 ` [PATCHv4 1/4] omap: voltage: add a stub header file Tero Kristo
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Tero Kristo @ 2011-07-28 11:48 UTC (permalink / raw)
  To: linux-omap

Hello,

This version has following changes:

- does not move voltage.h under plat-omap anymore, instead
  creates a stub voltage.h under plat-omap with minimal support required
- platform device registration is now done from voltage.c, no need
  for board file changes anymore
- Kconfig option does not depend upon TWL core anymore

-Tero


Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCHv4 1/4] omap: voltage: add a stub header file
  2011-07-28 11:48 [PATCHv4 0/4] OMAP SMPS regulator driver Tero Kristo
@ 2011-07-28 11:48 ` Tero Kristo
  2011-08-05 19:35   ` Kevin Hilman
  2011-07-28 11:48 ` [PATCHv4 2/4] regulator: omap smps regulator driver Tero Kristo
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 19+ messages in thread
From: Tero Kristo @ 2011-07-28 11:48 UTC (permalink / raw)
  To: linux-omap

Needed as some of the voltage layer functionality is accessed from the
SMPS regulator driver.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/plat-omap/include/plat/voltage.h |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/voltage.h

diff --git a/arch/arm/plat-omap/include/plat/voltage.h b/arch/arm/plat-omap/include/plat/voltage.h
new file mode 100644
index 0000000..0a6a482
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/voltage.h
@@ -0,0 +1,20 @@
+/*
+ * OMAP Voltage Management Routines
+ *
+ * Copyright (C) 2011, Texas Instruments, Inc.
+ *
+ * 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 __ARCH_ARM_OMAP_VOLTAGE_H
+#define __ARCH_ARM_OMAP_VOLTAGE_H
+
+struct voltagedomain;
+
+struct voltagedomain *voltdm_lookup(const char *name);
+int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
+unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
+
+#endif
-- 
1.7.4.1


Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCHv4 2/4] regulator: omap smps regulator driver
  2011-07-28 11:48 [PATCHv4 0/4] OMAP SMPS regulator driver Tero Kristo
  2011-07-28 11:48 ` [PATCHv4 1/4] omap: voltage: add a stub header file Tero Kristo
@ 2011-07-28 11:48 ` Tero Kristo
  2011-07-29  9:48   ` Mark Brown
  2011-08-05 23:48   ` Kevin Hilman
  2011-07-28 11:48 ` [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c Tero Kristo
  2011-07-28 11:48 ` [PATCHv4 4/4] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
  3 siblings, 2 replies; 19+ messages in thread
From: Tero Kristo @ 2011-07-28 11:48 UTC (permalink / raw)
  To: linux-omap
  Cc: Kevin Hilman, Tony Lindgren, Todd Poynor, Mark Brown,
	Liam Girdwood, Graeme Gregory

OMAP SMPS regulator driver provides access to OMAP voltage processor
controlled regulators. These include VDD_MPU and VDD_CORE for OMAP3 and
additionally VDD_IVA for OMAP4. SMPS regulators use the OMAP voltage
layer for the actual voltage regulation operations.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Todd Poynor <toddpoynor@google.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Liam Girdwood <lrg@ti.com>
Cc: Graeme Gregory <gg@slimlogic.co.uk>
---
 drivers/regulator/Kconfig               |    8 ++
 drivers/regulator/Makefile              |    1 +
 drivers/regulator/omap-smps-regulator.c |  182 +++++++++++++++++++++++++++++++
 include/linux/regulator/omap-smps.h     |   20 ++++
 4 files changed, 211 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/omap-smps-regulator.c
 create mode 100644 include/linux/regulator/omap-smps.h

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index d7ed20f..2ba8ed2 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -303,5 +303,13 @@ config REGULATOR_TPS65910
 	help
 	  This driver supports TPS65910 voltage regulator chips.
 
+config REGULATOR_OMAP_SMPS
+	tristate "TI OMAP SMPS Power Regulators"
+	depends on (ARCH_OMAP3 || ARCH_OMAP4) && PM
+	help
+	  This driver supports the OMAP3 / OMAP4 SMPS regulators for VDD1,
+	  VDD2 and VDD3. These regulators are accessed using the voltage
+	  processor interface of OMAP.
+
 endif
 
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 3932d2e..191e3d5 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -43,5 +43,6 @@ obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
 obj-$(CONFIG_REGULATOR_AB8500)	+= ab8500.o
 obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
 obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
+obj-$(CONFIG_REGULATOR_OMAP_SMPS) += omap-smps-regulator.o
 
 ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
diff --git a/drivers/regulator/omap-smps-regulator.c b/drivers/regulator/omap-smps-regulator.c
new file mode 100644
index 0000000..e4a0262
--- /dev/null
+++ b/drivers/regulator/omap-smps-regulator.c
@@ -0,0 +1,181 @@
+/*
+ * OMAP SMPS regulator driver
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ *
+ * Author: Tero Kristo <t-kristo@ti.com>
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/ctype.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/omap-smps.h>
+#include <plat/voltage.h>
+
+#define DRIVER_NAME		"omap-smps"
+
+struct omap_smps_reg_info {
+	const char		*vdd_name;
+	struct regulator_dev	*rdev;
+	struct voltagedomain	*voltdm;
+	struct regulator_desc	desc;
+};
+
+static int omap_smps_set_voltage(struct regulator_dev *rdev, int min_uV,
+				    int max_uV, unsigned *selector)
+{
+	struct omap_smps_reg_info	*info = rdev_get_drvdata(rdev);
+	return voltdm_scale(info->voltdm, min_uV);
+}
+
+static int omap_smps_get_voltage(struct regulator_dev *rdev)
+{
+	struct omap_smps_reg_info	*info = rdev_get_drvdata(rdev);
+	return voltdm_get_voltage(info->voltdm);
+}
+
+static struct regulator_ops omap_smps_ops = {
+	.set_voltage	= omap_smps_set_voltage,
+	.get_voltage	= omap_smps_get_voltage,
+};
+
+#define SMPS_REG(name) { \
+	.vdd_name = #name, \
+	.desc = { \
+		.ops = &omap_smps_ops, \
+		.type = REGULATOR_VOLTAGE, \
+		.owner = THIS_MODULE, \
+		}, \
+	}
+
+static struct omap_smps_reg_info omap_smps_regs[] = {
+	SMPS_REG(mpu),
+	SMPS_REG(mpu_iva),
+	SMPS_REG(iva),
+	SMPS_REG(core),
+};
+
+static void omap_smps_reg_cleanup(void)
+{
+	int				i;
+	struct omap_smps_reg_info	*info;
+
+	for (i = 0; i < ARRAY_SIZE(omap_smps_regs); i++) {
+		info = &omap_smps_regs[i];
+		if (info->rdev) {
+			regulator_unregister(info->rdev);
+			info->rdev = NULL;
+		}
+
+		kfree(info->desc.name);
+		info->desc.name = NULL;
+	}
+}
+
+static struct regulator_init_data dummy_initdata __initdata;
+
+static int __devinit omap_smps_reg_probe(struct platform_device *pdev)
+{
+	int				i, j, ret;
+	struct omap_smps_reg_info	*info;
+	struct omap_smps_platform_data	*pdata;
+	struct regulator_dev		*rdev;
+	struct regulator_init_data	*initdata;
+	struct voltagedomain		*voltdm;
+	char				*name;
+
+	pdata = pdev->dev.platform_data;
+
+	for (i = 0; i < ARRAY_SIZE(omap_smps_regs); i++) {
+		initdata = &dummy_initdata;
+		info = &omap_smps_regs[i];
+
+		for (j = 0; j < pdata->num_regulators; j++)
+			if (!strcmp(info->vdd_name,
+				    pdata->regulators[j]->consumer_supplies[0].
+				    dev_name)) {
+				initdata = pdata->regulators[j];
+				break;
+			}
+
+		voltdm = voltdm_lookup(info->vdd_name);
+
+		if (!voltdm)
+			continue;
+
+		info->voltdm = voltdm;
+
+		name = kmalloc(strlen(info->vdd_name) + 5, GFP_KERNEL);
+
+		if (!name) {
+			ret = -ENOMEM;
+			goto err;
+		}
+
+		sprintf(name, "VDD_%s", info->vdd_name);
+
+		for (j = 0; j < strlen(name); j++)
+			name[j] = toupper(name[j]);
+
+		info->desc.name = name;
+
+		rdev = regulator_register(&info->desc, &pdev->dev, initdata,
+			info);
+
+		if (IS_ERR(rdev)) {
+			dev_err(&pdev->dev, "can't register %s, %ld\n",
+				info->desc.name, PTR_ERR(rdev));
+			ret = PTR_ERR(rdev);
+			goto err;
+		}
+
+		info->rdev = rdev;
+	}
+
+	return 0;
+err:
+	omap_smps_reg_cleanup();
+	return ret;
+}
+
+static int omap_smps_reg_remove(struct platform_device *pdev)
+{
+	omap_smps_reg_cleanup();
+	return 0;
+}
+
+static struct platform_driver omap_smps_reg_driver = {
+	.probe		= omap_smps_reg_probe,
+	.remove		= __devexit_p(omap_smps_reg_remove),
+	.driver.name	= DRIVER_NAME,
+	.driver.owner	= THIS_MODULE,
+};
+
+static int __init omap_smps_reg_init(void)
+{
+	return platform_driver_register(&omap_smps_reg_driver);
+}
+subsys_initcall(omap_smps_reg_init);
+
+static void __exit omap_smps_reg_exit(void)
+{
+	platform_driver_unregister(&omap_smps_reg_driver);
+}
+module_exit(omap_smps_reg_exit);
+
+MODULE_ALIAS("platform:"DRIVER_NAME);
+MODULE_AUTHOR("Tero Kristo <t-kristo@ti.com>");
+MODULE_DESCRIPTION("OMAP SMPS regulator driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/regulator/omap-smps.h b/include/linux/regulator/omap-smps.h
new file mode 100644
index 0000000..1d5f940
--- /dev/null
+++ b/include/linux/regulator/omap-smps.h
@@ -0,0 +1,20 @@
+/*
+ * omap-smps.h - header for OMAP SMPS regulator support
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ *
+ *
+ * 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 __OMAP_SMPS_H__
+#define __OMAP_SMPS_H__
+
+struct omap_smps_platform_data {
+	struct regulator_init_data	**regulators;
+	int				num_regulators;
+};
+
+#endif /* End of __OMAP_SMPS_H__ */
-- 
1.7.4.1


Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c
  2011-07-28 11:48 [PATCHv4 0/4] OMAP SMPS regulator driver Tero Kristo
  2011-07-28 11:48 ` [PATCHv4 1/4] omap: voltage: add a stub header file Tero Kristo
  2011-07-28 11:48 ` [PATCHv4 2/4] regulator: omap smps regulator driver Tero Kristo
@ 2011-07-28 11:48 ` Tero Kristo
  2011-08-05 21:52   ` Kevin Hilman
                     ` (2 more replies)
  2011-07-28 11:48 ` [PATCHv4 4/4] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
  3 siblings, 3 replies; 19+ messages in thread
From: Tero Kristo @ 2011-07-28 11:48 UTC (permalink / raw)
  To: linux-omap

All voltagedomains that have support for vc and vp are now automatically
registered with SMPS regulator driver. Voltage.c builds a platform device
structure for this purpose during late init.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/voltage.c |   68 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index cebc8b1..790f7ab 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -25,6 +25,9 @@
 #include <linux/debugfs.h>
 #include <linux/slab.h>
 #include <linux/clk.h>
+#include <linux/platform_device.h>
+#include <linux/regulator/machine.h>
+#include <linux/regulator/omap-smps.h>
 
 #include <plat/common.h>
 
@@ -238,6 +241,39 @@ void omap_change_voltscale_method(struct voltagedomain *voltdm,
 	}
 }
 
+static void smps_add_regulator(struct platform_device *smps_dev,
+			       struct voltagedomain *voltdm)
+{
+	struct omap_smps_platform_data *info;
+	struct regulator_init_data *init_data;
+	struct regulator_consumer_supply *supply;
+
+	if (!smps_dev || !voltdm)
+		return;
+
+	info = smps_dev->dev.platform_data;
+
+	init_data = kzalloc(sizeof(struct regulator_init_data), GFP_KERNEL);
+	supply = kzalloc(sizeof(struct regulator_consumer_supply), GFP_KERNEL);
+
+	if (!init_data || !supply) {
+		kfree(init_data);
+		kfree(supply);
+		return;
+	}
+	supply->supply = "vcc";
+	supply->dev_name = voltdm->name;
+	init_data->constraints.min_uV = 600000;
+	init_data->constraints.max_uV = 1450000;
+	init_data->constraints.valid_modes_mask = REGULATOR_MODE_NORMAL;
+	init_data->constraints.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE;
+	init_data->num_consumer_supplies = 1;
+	init_data->consumer_supplies = supply;
+
+	info->regulators[info->num_regulators++] = init_data;
+}
+
+
 /**
  * omap_voltage_late_init() - Init the various voltage parameters
  *
@@ -248,6 +284,10 @@ void omap_change_voltscale_method(struct voltagedomain *voltdm,
 int __init omap_voltage_late_init(void)
 {
 	struct voltagedomain *voltdm;
+	struct platform_device *smps_dev[1];
+	struct omap_smps_platform_data *smps_pdata;
+	struct regulator_init_data **reg_list;
+	int num_smps = 0;
 
 	if (list_empty(&voltdm_list)) {
 		pr_err("%s: Voltage driver support not added\n",
@@ -279,8 +319,36 @@ int __init omap_voltage_late_init(void)
 			voltdm->scale = omap_vp_forceupdate_scale;
 			omap_vp_init(voltdm);
 		}
+
+		if (voltdm->vc && voltdm->vp)
+			num_smps++;
 	}
 
+	if (num_smps) {
+		smps_dev[0] = kzalloc(sizeof(struct platform_device),
+			GFP_KERNEL);
+		smps_pdata = kzalloc(sizeof(struct omap_smps_platform_data),
+			GFP_KERNEL);
+		reg_list = kzalloc(sizeof(void *) * num_smps, GFP_KERNEL);
+
+		if (!smps_dev[0] || !smps_pdata || !reg_list) {
+			kfree(smps_dev[0]);
+			kfree(smps_pdata);
+			kfree(reg_list);
+			return -ENOMEM;
+		}
+
+		smps_pdata->regulators = reg_list;
+		smps_dev[0]->name = "omap-smps";
+		smps_dev[0]->id = -1;
+		smps_dev[0]->dev.platform_data = smps_pdata;
+
+		list_for_each_entry(voltdm, &voltdm_list, node)
+			if (voltdm->vp && voltdm->vc)
+				smps_add_regulator(smps_dev[0], voltdm);
+
+		platform_add_devices(smps_dev, 1);
+	}
 	return 0;
 }
 
-- 
1.7.4.1


Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCHv4 4/4] TEMP: OMAP3: beagle rev-c4: enable OPP6
  2011-07-28 11:48 [PATCHv4 0/4] OMAP SMPS regulator driver Tero Kristo
                   ` (2 preceding siblings ...)
  2011-07-28 11:48 ` [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c Tero Kristo
@ 2011-07-28 11:48 ` Tero Kristo
  2011-08-05 19:41   ` Kevin Hilman
  3 siblings, 1 reply; 19+ messages in thread
From: Tero Kristo @ 2011-07-28 11:48 UTC (permalink / raw)
  To: linux-omap

Beagleboard rev-c4 has a speed sorted OMAP3530 chip which can run at 720MHz.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/board-omap3beagle.c |   32 +++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/opp3xxx_data.c      |    4 +++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 34f8411..ba84c0e 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -468,6 +468,38 @@ static void __init beagle_opp_init(void)
 		return;
 	}
 
+	/* Custom OPP enabled for C4 */
+	if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C4) {
+		struct omap_hwmod *mh = omap_hwmod_lookup("mpu");
+		struct omap_hwmod *dh = omap_hwmod_lookup("iva");
+		struct device *dev;
+
+		if (!mh || !dh) {
+			pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n",
+				__func__, mh, dh);
+		}
+		/* Enable MPU 720MHz opp */
+		dev = &mh->od->pdev.dev;
+		r = opp_enable(dev, 720000000);
+
+		/* Enable IVA 520MHz opp */
+		dev = &dh->od->pdev.dev;
+		r |= opp_enable(dev, 520000000);
+
+		if (r) {
+			pr_err("%s: failed to enable higher opp %d\n",
+				__func__, r);
+			/*
+			 * Cleanup - disable the higher freqs - we dont care
+			 * about the results
+			 */
+			dev = &mh->od->pdev.dev;
+			opp_disable(dev, 720000000);
+			dev = &dh->od->pdev.dev;
+			opp_disable(dev, 520000000);
+		}
+	}
+
 	/* Custom OPP enabled for XM */
 	if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
 		struct omap_hwmod *mh = omap_hwmod_lookup("mpu");
diff --git a/arch/arm/mach-omap2/opp3xxx_data.c b/arch/arm/mach-omap2/opp3xxx_data.c
index d95f3f9..a0f5fe1 100644
--- a/arch/arm/mach-omap2/opp3xxx_data.c
+++ b/arch/arm/mach-omap2/opp3xxx_data.c
@@ -98,6 +98,8 @@ static struct omap_opp_def __initdata omap34xx_opp_def_list[] = {
 	OPP_INITIALIZER("mpu", true, 550000000, OMAP3430_VDD_MPU_OPP4_UV),
 	/* MPU OPP5 */
 	OPP_INITIALIZER("mpu", true, 600000000, OMAP3430_VDD_MPU_OPP5_UV),
+	/* MPU OPP6 : omap3530 high speed grade only */
+	OPP_INITIALIZER("mpu", false, 720000000, OMAP3430_VDD_MPU_OPP5_UV),
 
 	/*
 	 * L3 OPP1 - 41.5 MHz is disabled because: The voltage for that OPP is
@@ -123,6 +125,8 @@ static struct omap_opp_def __initdata omap34xx_opp_def_list[] = {
 	OPP_INITIALIZER("iva", true, 400000000, OMAP3430_VDD_MPU_OPP4_UV),
 	/* DSP OPP5 */
 	OPP_INITIALIZER("iva", true, 430000000, OMAP3430_VDD_MPU_OPP5_UV),
+	/* DSP OPP6 : omap3530 high speed grade only */
+	OPP_INITIALIZER("iva", false, 520000000, OMAP3430_VDD_MPU_OPP5_UV),
 };
 
 static struct omap_opp_def __initdata omap36xx_opp_def_list[] = {
-- 
1.7.4.1


Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
 


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 2/4] regulator: omap smps regulator driver
  2011-07-28 11:48 ` [PATCHv4 2/4] regulator: omap smps regulator driver Tero Kristo
@ 2011-07-29  9:48   ` Mark Brown
  2011-08-05 19:33     ` Kevin Hilman
  2011-08-05 23:48   ` Kevin Hilman
  1 sibling, 1 reply; 19+ messages in thread
From: Mark Brown @ 2011-07-29  9:48 UTC (permalink / raw)
  To: Tero Kristo
  Cc: linux-omap, Kevin Hilman, Tony Lindgren, Todd Poynor,
	Liam Girdwood, Graeme Gregory

On Thu, Jul 28, 2011 at 02:48:57PM +0300, Tero Kristo wrote:
> OMAP SMPS regulator driver provides access to OMAP voltage processor
> controlled regulators. These include VDD_MPU and VDD_CORE for OMAP3 and
> additionally VDD_IVA for OMAP4. SMPS regulators use the OMAP voltage
> layer for the actual voltage regulation operations.
> 
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 2/4] regulator: omap smps regulator driver
  2011-07-29  9:48   ` Mark Brown
@ 2011-08-05 19:33     ` Kevin Hilman
  2011-08-08  8:28       ` Liam Girdwood
  0 siblings, 1 reply; 19+ messages in thread
From: Kevin Hilman @ 2011-08-05 19:33 UTC (permalink / raw)
  To: Mark Brown
  Cc: Tero Kristo, linux-omap, Tony Lindgren, Todd Poynor,
	Liam Girdwood, Graeme Gregory

Mark Brown <broonie@opensource.wolfsonmicro.com> writes:

> On Thu, Jul 28, 2011 at 02:48:57PM +0300, Tero Kristo wrote:
>> OMAP SMPS regulator driver provides access to OMAP voltage processor
>> controlled regulators. These include VDD_MPU and VDD_CORE for OMAP3 and
>> additionally VDD_IVA for OMAP4. SMPS regulators use the OMAP voltage
>> layer for the actual voltage regulation operations.
>> 
>> Signed-off-by: Tero Kristo <t-kristo@ti.com>
>
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Do you prefer we merge this via OMAP trees (along with the
infrastructure) or would you like to merge it.

At this point, it's probably best to merge it along with the voltage
infrastructure, which still might change slightly at the API level.

Kevin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 1/4] omap: voltage: add a stub header file
  2011-07-28 11:48 ` [PATCHv4 1/4] omap: voltage: add a stub header file Tero Kristo
@ 2011-08-05 19:35   ` Kevin Hilman
  0 siblings, 0 replies; 19+ messages in thread
From: Kevin Hilman @ 2011-08-05 19:35 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

Tero Kristo <t-kristo@ti.com> writes:

> Needed as some of the voltage layer functionality is accessed from the
> SMPS regulator driver.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

Looks good, I'll add this to my pm-wip/voltdm branch.

Kevin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 4/4] TEMP: OMAP3: beagle rev-c4: enable OPP6
  2011-07-28 11:48 ` [PATCHv4 4/4] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
@ 2011-08-05 19:41   ` Kevin Hilman
  0 siblings, 0 replies; 19+ messages in thread
From: Kevin Hilman @ 2011-08-05 19:41 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

Tero Kristo <t-kristo@ti.com> writes:

> Beagleboard rev-c4 has a speed sorted OMAP3530 chip which can run at 720MHz.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

FYI... this needs an update similar to the patch I just posted for
v3.1-rc so it's not directly using omap_device:

  https://patchwork.kernel.org/patch/1036202/

Kevin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c
  2011-07-28 11:48 ` [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c Tero Kristo
@ 2011-08-05 21:52   ` Kevin Hilman
  2011-08-29  8:21     ` Tero Kristo
  2011-08-05 21:54   ` Kevin Hilman
  2011-08-05 23:37   ` Kevin Hilman
  2 siblings, 1 reply; 19+ messages in thread
From: Kevin Hilman @ 2011-08-05 21:52 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

Tero Kristo <t-kristo@ti.com> writes:

> All voltagedomains that have support for vc and vp are now automatically
> registered with SMPS regulator driver. Voltage.c builds a platform device
> structure for this purpose during late init.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
>  arch/arm/mach-omap2/voltage.c |   68 +++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 68 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
> index cebc8b1..790f7ab 100644
> --- a/arch/arm/mach-omap2/voltage.c
> +++ b/arch/arm/mach-omap2/voltage.c
> @@ -25,6 +25,9 @@
>  #include <linux/debugfs.h>
>  #include <linux/slab.h>
>  #include <linux/clk.h>
> +#include <linux/platform_device.h>
> +#include <linux/regulator/machine.h>
> +#include <linux/regulator/omap-smps.h>
>  
>  #include <plat/common.h>
>  
> @@ -238,6 +241,39 @@ void omap_change_voltscale_method(struct voltagedomain *voltdm,
>  	}
>  }
>  
> +static void smps_add_regulator(struct platform_device *smps_dev,

Minor: maybe smps_add_regulator_info() is a better name, since it
doesn't actually add a regulator.

> +			       struct voltagedomain *voltdm)
> +{
> +	struct omap_smps_platform_data *info;
> +	struct regulator_init_data *init_data;
> +	struct regulator_consumer_supply *supply;
> +
> +	if (!smps_dev || !voltdm)
> +		return;
> +
> +	info = smps_dev->dev.platform_data;
> +
> +	init_data = kzalloc(sizeof(struct regulator_init_data), GFP_KERNEL);
> +	supply = kzalloc(sizeof(struct regulator_consumer_supply), GFP_KERNEL);
> +
> +	if (!init_data || !supply) {
> +		kfree(init_data);
> +		kfree(supply);
> +		return;
> +	}
> +	supply->supply = "vcc";
> +	supply->dev_name = voltdm->name;
> +	init_data->constraints.min_uV = 600000;
> +	init_data->constraints.max_uV = 1450000;
> +	init_data->constraints.valid_modes_mask = REGULATOR_MODE_NORMAL;
> +	init_data->constraints.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE;
> +	init_data->num_consumer_supplies = 1;
> +	init_data->consumer_supplies = supply;
> +
> +	info->regulators[info->num_regulators++] = init_data;
> +}
> +
> +
>  /**
>   * omap_voltage_late_init() - Init the various voltage parameters
>   *
> @@ -248,6 +284,10 @@ void omap_change_voltscale_method(struct voltagedomain *voltdm,
>  int __init omap_voltage_late_init(void)
>  {
>  	struct voltagedomain *voltdm;
> +	struct platform_device *smps_dev[1];

why the array? a simple pointer should suffice:

        struct platform_device *pdev; 

> +	struct omap_smps_platform_data *smps_pdata;
> +	struct regulator_init_data **reg_list;
> +	int num_smps = 0;
>  
>  	if (list_empty(&voltdm_list)) {
>  		pr_err("%s: Voltage driver support not added\n",
> @@ -279,8 +319,36 @@ int __init omap_voltage_late_init(void)
>  			voltdm->scale = omap_vp_forceupdate_scale;
>  			omap_vp_init(voltdm);
>  		}
> +
> +		if (voltdm->vc && voltdm->vp)
> +			num_smps++;
>  	}
>  
> +	if (num_smps) {
> +		smps_dev[0] = kzalloc(sizeof(struct platform_device),
> +			GFP_KERNEL);

platform_device_alloc() should be used here, which takes the name and id.

> +		smps_pdata = kzalloc(sizeof(struct omap_smps_platform_data),
> +			GFP_KERNEL);
> +		reg_list = kzalloc(sizeof(void *) * num_smps, GFP_KERNEL);

Should this (void *) be (struct regulator_init_data *)?

> +		if (!smps_dev[0] || !smps_pdata || !reg_list) {
> +			kfree(smps_dev[0]);

And the "free" for platform_device_alloc() is platform_device_put()

> +			kfree(smps_pdata);
> +			kfree(reg_list);
> +			return -ENOMEM;
> +		}
> +
> +		smps_pdata->regulators = reg_list;
> +		smps_dev[0]->name = "omap-smps";
> +		smps_dev[0]->id = -1;
> +		smps_dev[0]->dev.platform_data = smps_pdata;

platform_device_add_data() should be used here.

> +		list_for_each_entry(voltdm, &voltdm_list, node)
> +			if (voltdm->vp && voltdm->vc)
> +				smps_add_regulator(smps_dev[0], voltdm);
> +
> +		platform_add_devices(smps_dev, 1);

and finally, platform_device_add() here.

> +	}
>  	return 0;
>  }

Kevin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c
  2011-07-28 11:48 ` [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c Tero Kristo
  2011-08-05 21:52   ` Kevin Hilman
@ 2011-08-05 21:54   ` Kevin Hilman
  2011-08-29  8:06     ` Tero Kristo
  2011-08-05 23:37   ` Kevin Hilman
  2 siblings, 1 reply; 19+ messages in thread
From: Kevin Hilman @ 2011-08-05 21:54 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

Tero Kristo <t-kristo@ti.com> writes:

> All voltagedomains that have support for vc and vp are now automatically
> registered with SMPS regulator driver. Voltage.c builds a platform device
> structure for this purpose during late init.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

[...]

> +static void smps_add_regulator(struct platform_device *smps_dev,
> +			       struct voltagedomain *voltdm)
> +{
> +	struct omap_smps_platform_data *info;
> +	struct regulator_init_data *init_data;
> +	struct regulator_consumer_supply *supply;
> +
> +	if (!smps_dev || !voltdm)
> +		return;
> +
> +	info = smps_dev->dev.platform_data;
> +
> +	init_data = kzalloc(sizeof(struct regulator_init_data), GFP_KERNEL);
> +	supply = kzalloc(sizeof(struct regulator_consumer_supply), GFP_KERNEL);
> +
> +	if (!init_data || !supply) {
> +		kfree(init_data);
> +		kfree(supply);
> +		return;
> +	}
> +	supply->supply = "vcc";
> +	supply->dev_name = voltdm->name;
> +	init_data->constraints.min_uV = 600000;
> +	init_data->constraints.max_uV = 1450000;

These values should come from the OMAP/PMIC limitations, not from hard
coded values.

Kevin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c
  2011-07-28 11:48 ` [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c Tero Kristo
  2011-08-05 21:52   ` Kevin Hilman
  2011-08-05 21:54   ` Kevin Hilman
@ 2011-08-05 23:37   ` Kevin Hilman
  2011-08-29  7:56     ` Tero Kristo
  2 siblings, 1 reply; 19+ messages in thread
From: Kevin Hilman @ 2011-08-05 23:37 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap

Tero Kristo <t-kristo@ti.com> writes:

> All voltagedomains that have support for vc and vp are now automatically
> registered with SMPS regulator driver. Voltage.c builds a platform device
> structure for this purpose during late init.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

With the creation of this "dummy" platform device, I'm a bit confused
about how is the mapping from device to regulator meant to work here.

e.g., for MPU DVFS, if I want to also scale voltage in the CPUfreq
driver, I would do something like

        dev = omap2_get_mpuss_device()

and then want to somehow get the regulator associated with the MPU
device so I can do a regulator_set_voltage().  What would I use for the
id argument of regulator_get()?

What's missing (at least in my mind) is the mapping of devices to
regulators.

Specifically, this part doesn't seem right:

> +	supply->supply = "vcc";
> +	supply->dev_name = voltdm->name;

becase voltdm->name is not a device name.

Kevin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 2/4] regulator: omap smps regulator driver
  2011-07-28 11:48 ` [PATCHv4 2/4] regulator: omap smps regulator driver Tero Kristo
  2011-07-29  9:48   ` Mark Brown
@ 2011-08-05 23:48   ` Kevin Hilman
  1 sibling, 0 replies; 19+ messages in thread
From: Kevin Hilman @ 2011-08-05 23:48 UTC (permalink / raw)
  To: Tero Kristo
  Cc: linux-omap, Tony Lindgren, Todd Poynor, Mark Brown,
	Liam Girdwood, Graeme Gregory

Tero Kristo <t-kristo@ti.com> writes:

> OMAP SMPS regulator driver provides access to OMAP voltage processor
> controlled regulators. These include VDD_MPU and VDD_CORE for OMAP3 and
> additionally VDD_IVA for OMAP4. SMPS regulators use the OMAP voltage
> layer for the actual voltage regulation operations.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

FYI, this adds a section mismatch warning:

WARNING: vmlinux.o(.devinit.text+0x1984): Section mismatch in reference from the function omap_smps_reg_probe() to the (unknown reference) .init.data:(unknown)
The function __devinit omap_smps_reg_probe() references
a (unknown reference) __initdata (unknown).
If (unknown) is only used by omap_smps_reg_probe then
annotate (unknown) with a matching annotation.


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 2/4] regulator: omap smps regulator driver
  2011-08-05 19:33     ` Kevin Hilman
@ 2011-08-08  8:28       ` Liam Girdwood
  2011-08-22 22:39         ` Kevin Hilman
  0 siblings, 1 reply; 19+ messages in thread
From: Liam Girdwood @ 2011-08-08  8:28 UTC (permalink / raw)
  To: Hilman, Kevin
  Cc: Mark Brown, Kristo, Tero, linux-omap, Tony Lindgren, Todd Poynor,
	Graeme Gregory

On 05/08/11 20:33, Hilman, Kevin wrote:
> Mark Brown <broonie@opensource.wolfsonmicro.com> writes:
> 
>> On Thu, Jul 28, 2011 at 02:48:57PM +0300, Tero Kristo wrote:
>>> OMAP SMPS regulator driver provides access to OMAP voltage processor
>>> controlled regulators. These include VDD_MPU and VDD_CORE for OMAP3 and
>>> additionally VDD_IVA for OMAP4. SMPS regulators use the OMAP voltage
>>> layer for the actual voltage regulation operations.
>>>
>>> Signed-off-by: Tero Kristo <t-kristo@ti.com>
>>
>> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> 
> Do you prefer we merge this via OMAP trees (along with the
> infrastructure) or would you like to merge it.
> 
> At this point, it's probably best to merge it along with the voltage
> infrastructure, which still might change slightly at the API level.
> 

Ok, lets merge with the voltage infrastructure.

Thanks

Liam

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 2/4] regulator: omap smps regulator driver
  2011-08-08  8:28       ` Liam Girdwood
@ 2011-08-22 22:39         ` Kevin Hilman
  2011-08-23  7:28           ` Liam Girdwood
  0 siblings, 1 reply; 19+ messages in thread
From: Kevin Hilman @ 2011-08-22 22:39 UTC (permalink / raw)
  To: Liam Girdwood
  Cc: Mark Brown, Kristo, Tero, linux-omap, Tony Lindgren, Todd Poynor,
	Graeme Gregory

Liam Girdwood <lrg@ti.com> writes:

> On 05/08/11 20:33, Hilman, Kevin wrote:
>> Mark Brown <broonie@opensource.wolfsonmicro.com> writes:
>> 
>>> On Thu, Jul 28, 2011 at 02:48:57PM +0300, Tero Kristo wrote:
>>>> OMAP SMPS regulator driver provides access to OMAP voltage processor
>>>> controlled regulators. These include VDD_MPU and VDD_CORE for OMAP3 and
>>>> additionally VDD_IVA for OMAP4. SMPS regulators use the OMAP voltage
>>>> layer for the actual voltage regulation operations.
>>>>
>>>> Signed-off-by: Tero Kristo <t-kristo@ti.com>
>>>
>>> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
>> 
>> Do you prefer we merge this via OMAP trees (along with the
>> infrastructure) or would you like to merge it.
>> 
>> At this point, it's probably best to merge it along with the voltage
>> infrastructure, which still might change slightly at the API level.
>> 
>
> Ok, lets merge with the voltage infrastructure.
>

OK, shall I take this is an Ack from you then?

Kevin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 2/4] regulator: omap smps regulator driver
  2011-08-22 22:39         ` Kevin Hilman
@ 2011-08-23  7:28           ` Liam Girdwood
  0 siblings, 0 replies; 19+ messages in thread
From: Liam Girdwood @ 2011-08-23  7:28 UTC (permalink / raw)
  To: Hilman, Kevin
  Cc: Mark Brown, Kristo, Tero, linux-omap, Tony Lindgren, Todd Poynor,
	Graeme Gregory

On 22/08/11 23:39, Hilman, Kevin wrote:
> Liam Girdwood <lrg@ti.com> writes:
> 
>> On 05/08/11 20:33, Hilman, Kevin wrote:
>>> Mark Brown <broonie@opensource.wolfsonmicro.com> writes:
>>>
>>>> On Thu, Jul 28, 2011 at 02:48:57PM +0300, Tero Kristo wrote:
>>>>> OMAP SMPS regulator driver provides access to OMAP voltage processor
>>>>> controlled regulators. These include VDD_MPU and VDD_CORE for OMAP3 and
>>>>> additionally VDD_IVA for OMAP4. SMPS regulators use the OMAP voltage
>>>>> layer for the actual voltage regulation operations.
>>>>>
>>>>> Signed-off-by: Tero Kristo <t-kristo@ti.com>
>>>>
>>>> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
>>>
>>> Do you prefer we merge this via OMAP trees (along with the
>>> infrastructure) or would you like to merge it.
>>>
>>> At this point, it's probably best to merge it along with the voltage
>>> infrastructure, which still might change slightly at the API level.
>>>
>>
>> Ok, lets merge with the voltage infrastructure.
>>
> 
> OK, shall I take this is an Ack from you then?
> 
> Kevin

Sorry, yes.

Acked-by: Liam Girdwood <lrg@ti.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c
  2011-08-05 23:37   ` Kevin Hilman
@ 2011-08-29  7:56     ` Tero Kristo
  0 siblings, 0 replies; 19+ messages in thread
From: Tero Kristo @ 2011-08-29  7:56 UTC (permalink / raw)
  To: Hilman, Kevin; +Cc: linux-omap

Hi Kevin,

Sorry for bit late reply, I've been on holiday during last 3 weeks.

On Sat, 2011-08-06 at 01:37 +0200, Hilman, Kevin wrote:
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > All voltagedomains that have support for vc and vp are now automatically
> > registered with SMPS regulator driver. Voltage.c builds a platform device
> > structure for this purpose during late init.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> 
> With the creation of this "dummy" platform device, I'm a bit confused
> about how is the mapping from device to regulator meant to work here.
> 
> e.g., for MPU DVFS, if I want to also scale voltage in the CPUfreq
> driver, I would do something like
> 
>         dev = omap2_get_mpuss_device()
> 
> and then want to somehow get the regulator associated with the MPU
> device so I can do a regulator_set_voltage().  What would I use for the
> id argument of regulator_get()?

Hmm right, I haven't been thinking about this part in too much detail.
However, the regulator names are built in following way:

- take voltdm name (e.g. mpu_iva)
- add "VDD_" in the beginning
- capitalize whole thing (results in VDD_MPU_IVA)

> What's missing (at least in my mind) is the mapping of devices to
> regulators.

True, should I think of something for this?

> 
> Specifically, this part doesn't seem right:
> 
> > +	supply->supply = "vcc";
> > +	supply->dev_name = voltdm->name;
> 
> becase voltdm->name is not a device name.
> 
> Kevin



Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c
  2011-08-05 21:54   ` Kevin Hilman
@ 2011-08-29  8:06     ` Tero Kristo
  0 siblings, 0 replies; 19+ messages in thread
From: Tero Kristo @ 2011-08-29  8:06 UTC (permalink / raw)
  To: Hilman, Kevin; +Cc: linux-omap

On Fri, 2011-08-05 at 23:54 +0200, Hilman, Kevin wrote:
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > All voltagedomains that have support for vc and vp are now automatically
> > registered with SMPS regulator driver. Voltage.c builds a platform device
> > structure for this purpose during late init.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> 
> [...]
> 
> > +static void smps_add_regulator(struct platform_device *smps_dev,
> > +			       struct voltagedomain *voltdm)
> > +{
> > +	struct omap_smps_platform_data *info;
> > +	struct regulator_init_data *init_data;
> > +	struct regulator_consumer_supply *supply;
> > +
> > +	if (!smps_dev || !voltdm)
> > +		return;
> > +
> > +	info = smps_dev->dev.platform_data;
> > +
> > +	init_data = kzalloc(sizeof(struct regulator_init_data), GFP_KERNEL);
> > +	supply = kzalloc(sizeof(struct regulator_consumer_supply), GFP_KERNEL);
> > +
> > +	if (!init_data || !supply) {
> > +		kfree(init_data);
> > +		kfree(supply);
> > +		return;
> > +	}
> > +	supply->supply = "vcc";
> > +	supply->dev_name = voltdm->name;
> > +	init_data->constraints.min_uV = 600000;
> > +	init_data->constraints.max_uV = 1450000;
> 
> These values should come from the OMAP/PMIC limitations, not from hard
> coded values.

True. Should this wait until the work is finished with the PMIC
parameter work or should I try to figure out a way to do this already
now?

> 
> Kevin



Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c
  2011-08-05 21:52   ` Kevin Hilman
@ 2011-08-29  8:21     ` Tero Kristo
  0 siblings, 0 replies; 19+ messages in thread
From: Tero Kristo @ 2011-08-29  8:21 UTC (permalink / raw)
  To: Hilman, Kevin; +Cc: linux-omap

On Fri, 2011-08-05 at 23:52 +0200, Hilman, Kevin wrote:
> Tero Kristo <t-kristo@ti.com> writes:
> 
> > All voltagedomains that have support for vc and vp are now automatically
> > registered with SMPS regulator driver. Voltage.c builds a platform device
> > structure for this purpose during late init.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> > ---
> >  arch/arm/mach-omap2/voltage.c |   68 +++++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 68 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
> > index cebc8b1..790f7ab 100644
> > --- a/arch/arm/mach-omap2/voltage.c
> > +++ b/arch/arm/mach-omap2/voltage.c
> > @@ -25,6 +25,9 @@
> >  #include <linux/debugfs.h>
> >  #include <linux/slab.h>
> >  #include <linux/clk.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/regulator/machine.h>
> > +#include <linux/regulator/omap-smps.h>
> >  
> >  #include <plat/common.h>
> >  
> > @@ -238,6 +241,39 @@ void omap_change_voltscale_method(struct voltagedomain *voltdm,
> >  	}
> >  }
> >  
> > +static void smps_add_regulator(struct platform_device *smps_dev,
> 
> Minor: maybe smps_add_regulator_info() is a better name, since it
> doesn't actually add a regulator.

I can change this.

> 
> > +			       struct voltagedomain *voltdm)
> > +{
> > +	struct omap_smps_platform_data *info;
> > +	struct regulator_init_data *init_data;
> > +	struct regulator_consumer_supply *supply;
> > +
> > +	if (!smps_dev || !voltdm)
> > +		return;
> > +
> > +	info = smps_dev->dev.platform_data;
> > +
> > +	init_data = kzalloc(sizeof(struct regulator_init_data), GFP_KERNEL);
> > +	supply = kzalloc(sizeof(struct regulator_consumer_supply), GFP_KERNEL);
> > +
> > +	if (!init_data || !supply) {
> > +		kfree(init_data);
> > +		kfree(supply);
> > +		return;
> > +	}
> > +	supply->supply = "vcc";
> > +	supply->dev_name = voltdm->name;
> > +	init_data->constraints.min_uV = 600000;
> > +	init_data->constraints.max_uV = 1450000;
> > +	init_data->constraints.valid_modes_mask = REGULATOR_MODE_NORMAL;
> > +	init_data->constraints.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE;
> > +	init_data->num_consumer_supplies = 1;
> > +	init_data->consumer_supplies = supply;
> > +
> > +	info->regulators[info->num_regulators++] = init_data;
> > +}
> > +
> > +
> >  /**
> >   * omap_voltage_late_init() - Init the various voltage parameters
> >   *
> > @@ -248,6 +284,10 @@ void omap_change_voltscale_method(struct voltagedomain *voltdm,
> >  int __init omap_voltage_late_init(void)
> >  {
> >  	struct voltagedomain *voltdm;
> > +	struct platform_device *smps_dev[1];
> 
> why the array? a simple pointer should suffice:

I can try to change this. platform_add_devices needs an array of
platform_devices, thats the reason I made it like this initially.

> 
>         struct platform_device *pdev; 
> 
> > +	struct omap_smps_platform_data *smps_pdata;
> > +	struct regulator_init_data **reg_list;
> > +	int num_smps = 0;
> >  
> >  	if (list_empty(&voltdm_list)) {
> >  		pr_err("%s: Voltage driver support not added\n",
> > @@ -279,8 +319,36 @@ int __init omap_voltage_late_init(void)
> >  			voltdm->scale = omap_vp_forceupdate_scale;
> >  			omap_vp_init(voltdm);
> >  		}
> > +
> > +		if (voltdm->vc && voltdm->vp)
> > +			num_smps++;
> >  	}
> >  
> > +	if (num_smps) {
> > +		smps_dev[0] = kzalloc(sizeof(struct platform_device),
> > +			GFP_KERNEL);
> 
> platform_device_alloc() should be used here, which takes the name and id.

Okay.

> 
> > +		smps_pdata = kzalloc(sizeof(struct omap_smps_platform_data),
> > +			GFP_KERNEL);
> > +		reg_list = kzalloc(sizeof(void *) * num_smps, GFP_KERNEL);
> 
> Should this (void *) be (struct regulator_init_data *)?

No, we are allocating an array of pointers here, which gets filled later
by smps_add_regulator().

> 
> > +		if (!smps_dev[0] || !smps_pdata || !reg_list) {
> > +			kfree(smps_dev[0]);
> 
> And the "free" for platform_device_alloc() is platform_device_put()

Okay also.

> 
> > +			kfree(smps_pdata);
> > +			kfree(reg_list);
> > +			return -ENOMEM;
> > +		}
> > +
> > +		smps_pdata->regulators = reg_list;
> > +		smps_dev[0]->name = "omap-smps";
> > +		smps_dev[0]->id = -1;
> > +		smps_dev[0]->dev.platform_data = smps_pdata;
> 
> platform_device_add_data() should be used here.

Okay.

> 
> > +		list_for_each_entry(voltdm, &voltdm_list, node)
> > +			if (voltdm->vp && voltdm->vc)
> > +				smps_add_regulator(smps_dev[0], voltdm);
> > +
> > +		platform_add_devices(smps_dev, 1);
> 
> and finally, platform_device_add() here.

Okay, this way I can drop the array part from smps_dev.

> 
> > +	}
> >  	return 0;
> >  }
> 
> Kevin



Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
 


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-08-29  8:22 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 11:48 [PATCHv4 0/4] OMAP SMPS regulator driver Tero Kristo
2011-07-28 11:48 ` [PATCHv4 1/4] omap: voltage: add a stub header file Tero Kristo
2011-08-05 19:35   ` Kevin Hilman
2011-07-28 11:48 ` [PATCHv4 2/4] regulator: omap smps regulator driver Tero Kristo
2011-07-29  9:48   ` Mark Brown
2011-08-05 19:33     ` Kevin Hilman
2011-08-08  8:28       ` Liam Girdwood
2011-08-22 22:39         ` Kevin Hilman
2011-08-23  7:28           ` Liam Girdwood
2011-08-05 23:48   ` Kevin Hilman
2011-07-28 11:48 ` [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c Tero Kristo
2011-08-05 21:52   ` Kevin Hilman
2011-08-29  8:21     ` Tero Kristo
2011-08-05 21:54   ` Kevin Hilman
2011-08-29  8:06     ` Tero Kristo
2011-08-05 23:37   ` Kevin Hilman
2011-08-29  7:56     ` Tero Kristo
2011-07-28 11:48 ` [PATCHv4 4/4] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
2011-08-05 19:41   ` Kevin Hilman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.