linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: linux-omap@vger.kernel.org
Subject: [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c
Date: Thu, 28 Jul 2011 14:48:58 +0300	[thread overview]
Message-ID: <1311853739-18984-4-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1311853739-18984-1-git-send-email-t-kristo@ti.com>

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
 


  parent reply	other threads:[~2011-07-28 11:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Tero Kristo [this message]
2011-08-05 21:52   ` [PATCHv4 3/4] omap: smps: add smps regulator init to voltage.c 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311853739-18984-4-git-send-email-t-kristo@ti.com \
    --to=t-kristo@ti.com \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).