public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv3 0/6] OMAP SMPS regulator driver
@ 2011-07-18 17:35 Tero Kristo
  2011-07-18 17:35 ` [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory Tero Kristo
                   ` (6 more replies)
  0 siblings, 7 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-18 17:35 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, tony, toddpoynor, broonie, lrg

Hello,

Main changes compared to v2:

- cleanup should now work better
- register all available regulators always, if no initdata => readonly
- added board init support functionality to twl-common
- constraints not touched by the driver anymore

Tested on omap3 beagle.

-Tero


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


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

* [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory
  2011-07-18 17:35 [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
@ 2011-07-18 17:35 ` Tero Kristo
  2011-07-18 18:16   ` Felipe Balbi
  2011-07-18 23:45   ` Kevin Hilman
  2011-07-18 17:35 ` [PATCHv3 2/6] omap: voltage: change code to use new location of voltage.h and vp.h Tero Kristo
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-18 17:35 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, tony, toddpoynor, broonie, lrg

This is needed so that these include files can be accessed from drivers.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/voltage.h             |  180 -----------------------------
 arch/arm/mach-omap2/vp.h                  |  128 --------------------
 arch/arm/plat-omap/include/plat/voltage.h |  179 ++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/vp.h      |  128 ++++++++++++++++++++
 4 files changed, 307 insertions(+), 308 deletions(-)
 delete mode 100644 arch/arm/mach-omap2/voltage.h
 delete mode 100644 arch/arm/mach-omap2/vp.h
 create mode 100644 arch/arm/plat-omap/include/plat/voltage.h
 create mode 100644 arch/arm/plat-omap/include/plat/vp.h

diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h
deleted file mode 100644
index 38a0145..0000000
--- a/arch/arm/mach-omap2/voltage.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * OMAP Voltage Management Routines
- *
- * Author: Thara Gopinath	<thara@ti.com>
- *
- * Copyright (C) 2009 Texas Instruments, Inc.
- * Thara Gopinath <thara@ti.com>
- *
- * 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_MACH_OMAP2_VOLTAGE_H
-#define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
-
-#include <linux/err.h>
-
-#include "vc.h"
-#include "vp.h"
-
-struct powerdomain;
-
-/* XXX document */
-#define VOLTSCALE_VPFORCEUPDATE		1
-#define VOLTSCALE_VCBYPASS		2
-
-/*
- * OMAP3 GENERIC setup times. Revisit to see if these needs to be
- * passed from board or PMIC file
- */
-#define OMAP3_CLKSETUP		0xff
-#define OMAP3_VOLTOFFSET	0xff
-#define OMAP3_VOLTSETUP2	0xff
-
-/**
- * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
- * data
- * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
- * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
- * @voltsetup_shift: SETUP_TIME* field shift in the PRM_VOLTSETUP* register
- *
- * XXX What about VOLTOFFSET/VOLTCTRL?
- * XXX It is not necessary to have both a _mask and a _shift for the same
- *     bitfield - remove one!
- */
-struct omap_vfsm_instance {
-	u32 voltsetup_mask;
-	u8 voltsetup_reg;
-	u8 voltsetup_shift;
-};
-
-/**
- * struct voltagedomain - omap voltage domain global structure.
- * @name: Name of the voltage domain which can be used as a unique identifier.
- * @scalable: Whether or not this voltage domain is scalable
- * @node: list_head linking all voltage domains
- * @pwrdm_node: list_head linking all powerdomains in this voltagedomain
- * @vdd: to be removed
- * @pwrdms: powerdomains in this voltagedomain
- * @scale: function used to scale the voltage of the voltagedomain
- * @curr_volt: current nominal voltage for this voltage domain
- */
-struct voltagedomain {
-	char *name;
-	bool scalable;
-	struct list_head node;
-	struct list_head pwrdm_list;
-	struct omap_vc_channel *vc;
-	const struct omap_vfsm_instance *vfsm;
-	struct omap_vp_instance *vp;
-	struct omap_voltdm_pmic *pmic;
-
-	/* VC/VP register access functions: SoC specific */
-	u32 (*read) (u8 offset);
-	void (*write) (u32 val, u8 offset);
-	u32 (*rmw)(u32 mask, u32 bits, u8 offset);
-
-	union {
-		const char *name;
-		u32 rate;
-	} sys_clk;
-
-	int (*scale) (struct voltagedomain *voltdm,
-		      unsigned long target_volt);
-	u32 curr_volt;
-	struct omap_volt_data *volt_data;
-};
-
-/**
- * struct omap_volt_data - Omap voltage specific data.
- * @voltage_nominal:	The possible voltage value in uV
- * @sr_efuse_offs:	The offset of the efuse register(from system
- *			control module base address) from where to read
- *			the n-target value for the smartreflex module.
- * @sr_errminlimit:	Error min limit value for smartreflex. This value
- *			differs at differnet opp and thus is linked
- *			with voltage.
- * @vp_errorgain:	Error gain value for the voltage processor. This
- *			field also differs according to the voltage/opp.
- */
-struct omap_volt_data {
-	u32	volt_nominal;
-	u32	sr_efuse_offs;
-	u8	sr_errminlimit;
-	u8	vp_errgain;
-};
-
-/**
- * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
- * @slew_rate:	PMIC slew rate (in uv/us)
- * @step_size:	PMIC voltage step size (in uv)
- * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
- * @i2c_mcode: master code value for I2C high-speed preamble transmission
- * @vsel_to_uv:	PMIC API to convert vsel value to actual voltage in uV.
- * @uv_to_vsel:	PMIC API to convert voltage in uV to vsel value.
- */
-struct omap_voltdm_pmic {
-	int slew_rate;
-	int step_size;
-	u32 on_volt;
-	u32 onlp_volt;
-	u32 ret_volt;
-	u32 off_volt;
-	u16 volt_setup_time;
-	u16 i2c_slave_addr;
-	u16 volt_reg_addr;
-	u16 cmd_reg_addr;
-	u8 vp_erroroffset;
-	u8 vp_vstepmin;
-	u8 vp_vstepmax;
-	u8 vp_vddmin;
-	u8 vp_vddmax;
-	u8 vp_timeout_us;
-	bool i2c_high_speed;
-	u8 i2c_mcode;
-	unsigned long (*vsel_to_uv) (const u8 vsel);
-	u8 (*uv_to_vsel) (unsigned long uV);
-};
-
-void omap_voltage_get_volttable(struct voltagedomain *voltdm,
-		struct omap_volt_data **volt_data);
-struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
-		unsigned long volt);
-unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
-#ifdef CONFIG_PM
-int omap_voltage_register_pmic(struct voltagedomain *voltdm,
-			       struct omap_voltdm_pmic *pmic);
-void omap_change_voltscale_method(struct voltagedomain *voltdm,
-		int voltscale_method);
-int omap_voltage_late_init(void);
-#else
-static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm,
-					     struct omap_voltdm_pmic *pmic)
-{
-	return -EINVAL;
-}
-static inline  void omap_change_voltscale_method(struct voltagedomain *voltdm,
-		int voltscale_method) {}
-static inline int omap_voltage_late_init(void)
-{
-	return -EINVAL;
-}
-#endif
-
-extern void omap2xxx_voltagedomains_init(void);
-extern void omap3xxx_voltagedomains_init(void);
-extern void omap44xx_voltagedomains_init(void);
-
-struct voltagedomain *voltdm_lookup(const char *name);
-void voltdm_init(struct voltagedomain **voltdm_list);
-int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
-int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
-		    void *user);
-int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
-			  int (*fn)(struct voltagedomain *voltdm,
-				    struct powerdomain *pwrdm));
-int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
-void voltdm_reset(struct voltagedomain *voltdm);
-#endif
diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h
deleted file mode 100644
index f78752b..0000000
--- a/arch/arm/mach-omap2/vp.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * OMAP3/4 Voltage Processor (VP) structure and macro definitions
- *
- * Copyright (C) 2007, 2010 Texas Instruments, Inc.
- * Rajendra Nayak <rnayak@ti.com>
- * Lesly A M <x0080970@ti.com>
- * Thara Gopinath <thara@ti.com>
- *
- * Copyright (C) 2008, 2011 Nokia Corporation
- * Kalle Jokiniemi
- * Paul Walmsley
- *
- * 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_MACH_OMAP2_VP_H
-#define __ARCH_ARM_MACH_OMAP2_VP_H
-
-#include <linux/kernel.h>
-
-struct voltagedomain;
-
-/*
- * Voltage Processor (VP) identifiers
- */
-#define OMAP3_VP_VDD_MPU_ID 0
-#define OMAP3_VP_VDD_CORE_ID 1
-#define OMAP4_VP_VDD_CORE_ID 0
-#define OMAP4_VP_VDD_IVA_ID 1
-#define OMAP4_VP_VDD_MPU_ID 2
-
-/* XXX document */
-#define VP_IDLE_TIMEOUT		200
-#define VP_TRANXDONE_TIMEOUT	300
-
-/**
- * struct omap_vp_ops - per-VP operations
- * @check_txdone: check for VP transaction done
- * @clear_txdone: clear VP transaction done status
- */
-struct omap_vp_ops {
-	u32 (*check_txdone)(u8 vp_id);
-	void (*clear_txdone)(u8 vp_id);
-};
-
-/**
- * struct omap_vp_common - register data common to all VDDs
- * @vpconfig_erroroffset_mask: ERROROFFSET bitmask in the PRM_VP*_CONFIG reg
- * @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg
- * @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg
- * @vpconfig_timeouten: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
- * @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg
- * @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg
- * @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg
- * @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg
- * @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg
- * @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg
- * @vstepmin_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg
- * @vstepmin_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg
- * @vstepmax_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg
- * @vstepmax_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg
- * @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
- * @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
- * @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
- * @vpvoltage_mask: VPVOLTAGE field mask in PRM_VP*_VOLTAGE reg
- */
-struct omap_vp_common {
-	u32 vpconfig_erroroffset_mask;
-	u32 vpconfig_errorgain_mask;
-	u32 vpconfig_initvoltage_mask;
-	u8 vpconfig_timeouten;
-	u8 vpconfig_initvdd;
-	u8 vpconfig_forceupdate;
-	u8 vpconfig_vpenable;
-	u8 vstepmin_stepmin_shift;
-	u8 vstepmin_smpswaittimemin_shift;
-	u8 vstepmax_stepmax_shift;
-	u8 vstepmax_smpswaittimemax_shift;
-	u8 vlimitto_vddmin_shift;
-	u8 vlimitto_vddmax_shift;
-	u8 vlimitto_timeout_shift;
-	u8 vpvoltage_mask;
-
-	const struct omap_vp_ops *ops;
-};
-
-/**
- * struct omap_vp_instance - VP register offsets (per-VDD)
- * @common: pointer to struct omap_vp_common * for this SoC
- * @vpconfig: PRM_VP*_CONFIG reg offset from PRM start
- * @vstepmin: PRM_VP*_VSTEPMIN reg offset from PRM start
- * @vlimitto: PRM_VP*_VLIMITTO reg offset from PRM start
- * @vstatus: PRM_VP*_VSTATUS reg offset from PRM start
- * @voltage: PRM_VP*_VOLTAGE reg offset from PRM start
- * @enabled: flag to keep track of whether vp is enabled or not
- *
- * XXX vp_common is probably not needed since it is per-SoC
- */
-struct omap_vp_instance {
-	const struct omap_vp_common *common;
-	u8 vpconfig;
-	u8 vstepmin;
-	u8 vstepmax;
-	u8 vlimitto;
-	u8 vstatus;
-	u8 voltage;
-	u8 id;
-	bool enabled;
-};
-
-extern struct omap_vp_instance omap3_vp_mpu;
-extern struct omap_vp_instance omap3_vp_core;
-
-extern struct omap_vp_instance omap4_vp_mpu;
-extern struct omap_vp_instance omap4_vp_iva;
-extern struct omap_vp_instance omap4_vp_core;
-
-void omap_vp_init(struct voltagedomain *voltdm);
-void omap_vp_enable(struct voltagedomain *voltdm);
-void omap_vp_disable(struct voltagedomain *voltdm);
-unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
-int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
-			      unsigned long target_volt);
-int omap_vp_update_errorgain(struct voltagedomain *voltdm,
-			     unsigned long target_volt);
-
-#endif
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..23568fd
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/voltage.h
@@ -0,0 +1,179 @@
+/*
+ * OMAP Voltage Management Routines
+ *
+ * Author: Thara Gopinath	<thara@ti.com>
+ *
+ * Copyright (C) 2009 Texas Instruments, Inc.
+ * Thara Gopinath <thara@ti.com>
+ *
+ * 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
+
+#include <linux/err.h>
+
+#include <plat/vp.h>
+
+struct powerdomain;
+
+/* XXX document */
+#define VOLTSCALE_VPFORCEUPDATE		1
+#define VOLTSCALE_VCBYPASS		2
+
+/*
+ * OMAP3 GENERIC setup times. Revisit to see if these needs to be
+ * passed from board or PMIC file
+ */
+#define OMAP3_CLKSETUP		0xff
+#define OMAP3_VOLTOFFSET	0xff
+#define OMAP3_VOLTSETUP2	0xff
+
+/**
+ * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
+ * data
+ * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
+ * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
+ * @voltsetup_shift: SETUP_TIME* field shift in the PRM_VOLTSETUP* register
+ *
+ * XXX What about VOLTOFFSET/VOLTCTRL?
+ * XXX It is not necessary to have both a _mask and a _shift for the same
+ *     bitfield - remove one!
+ */
+struct omap_vfsm_instance {
+	u32 voltsetup_mask;
+	u8 voltsetup_reg;
+	u8 voltsetup_shift;
+};
+
+/**
+ * struct voltagedomain - omap voltage domain global structure.
+ * @name: Name of the voltage domain which can be used as a unique identifier.
+ * @scalable: Whether or not this voltage domain is scalable
+ * @node: list_head linking all voltage domains
+ * @pwrdm_node: list_head linking all powerdomains in this voltagedomain
+ * @vdd: to be removed
+ * @pwrdms: powerdomains in this voltagedomain
+ * @scale: function used to scale the voltage of the voltagedomain
+ * @curr_volt: current nominal voltage for this voltage domain
+ */
+struct voltagedomain {
+	char *name;
+	bool scalable;
+	struct list_head node;
+	struct list_head pwrdm_list;
+	struct omap_vc_channel *vc;
+	const struct omap_vfsm_instance *vfsm;
+	struct omap_vp_instance *vp;
+	struct omap_voltdm_pmic *pmic;
+
+	/* VC/VP register access functions: SoC specific */
+	u32 (*read) (u8 offset);
+	void (*write) (u32 val, u8 offset);
+	u32 (*rmw)(u32 mask, u32 bits, u8 offset);
+
+	union {
+		const char *name;
+		u32 rate;
+	} sys_clk;
+
+	int (*scale) (struct voltagedomain *voltdm,
+		      unsigned long target_volt);
+	u32 curr_volt;
+	struct omap_volt_data *volt_data;
+};
+
+/**
+ * struct omap_volt_data - Omap voltage specific data.
+ * @voltage_nominal:	The possible voltage value in uV
+ * @sr_efuse_offs:	The offset of the efuse register(from system
+ *			control module base address) from where to read
+ *			the n-target value for the smartreflex module.
+ * @sr_errminlimit:	Error min limit value for smartreflex. This value
+ *			differs at differnet opp and thus is linked
+ *			with voltage.
+ * @vp_errorgain:	Error gain value for the voltage processor. This
+ *			field also differs according to the voltage/opp.
+ */
+struct omap_volt_data {
+	u32	volt_nominal;
+	u32	sr_efuse_offs;
+	u8	sr_errminlimit;
+	u8	vp_errgain;
+};
+
+/**
+ * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
+ * @slew_rate:	PMIC slew rate (in uv/us)
+ * @step_size:	PMIC voltage step size (in uv)
+ * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
+ * @i2c_mcode: master code value for I2C high-speed preamble transmission
+ * @vsel_to_uv:	PMIC API to convert vsel value to actual voltage in uV.
+ * @uv_to_vsel:	PMIC API to convert voltage in uV to vsel value.
+ */
+struct omap_voltdm_pmic {
+	int slew_rate;
+	int step_size;
+	u32 on_volt;
+	u32 onlp_volt;
+	u32 ret_volt;
+	u32 off_volt;
+	u16 volt_setup_time;
+	u16 i2c_slave_addr;
+	u16 volt_reg_addr;
+	u16 cmd_reg_addr;
+	u8 vp_erroroffset;
+	u8 vp_vstepmin;
+	u8 vp_vstepmax;
+	u8 vp_vddmin;
+	u8 vp_vddmax;
+	u8 vp_timeout_us;
+	bool i2c_high_speed;
+	u8 i2c_mcode;
+	unsigned long (*vsel_to_uv) (const u8 vsel);
+	u8 (*uv_to_vsel) (unsigned long uV);
+};
+
+void omap_voltage_get_volttable(struct voltagedomain *voltdm,
+		struct omap_volt_data **volt_data);
+struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
+		unsigned long volt);
+unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
+#ifdef CONFIG_PM
+int omap_voltage_register_pmic(struct voltagedomain *voltdm,
+			       struct omap_voltdm_pmic *pmic);
+void omap_change_voltscale_method(struct voltagedomain *voltdm,
+		int voltscale_method);
+int omap_voltage_late_init(void);
+#else
+static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm,
+					     struct omap_voltdm_pmic *pmic)
+{
+	return -EINVAL;
+}
+static inline  void omap_change_voltscale_method(struct voltagedomain *voltdm,
+		int voltscale_method) {}
+static inline int omap_voltage_late_init(void)
+{
+	return -EINVAL;
+}
+#endif
+
+extern void omap2xxx_voltagedomains_init(void);
+extern void omap3xxx_voltagedomains_init(void);
+extern void omap44xx_voltagedomains_init(void);
+
+struct voltagedomain *voltdm_lookup(const char *name);
+void voltdm_init(struct voltagedomain **voltdm_list);
+int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
+int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
+		    void *user);
+int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
+			  int (*fn)(struct voltagedomain *voltdm,
+				    struct powerdomain *pwrdm));
+int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
+void voltdm_reset(struct voltagedomain *voltdm);
+#endif
diff --git a/arch/arm/plat-omap/include/plat/vp.h b/arch/arm/plat-omap/include/plat/vp.h
new file mode 100644
index 0000000..530fed5
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/vp.h
@@ -0,0 +1,128 @@
+/*
+ * OMAP3/4 Voltage Processor (VP) structure and macro definitions
+ *
+ * Copyright (C) 2007, 2010 Texas Instruments, Inc.
+ * Rajendra Nayak <rnayak@ti.com>
+ * Lesly A M <x0080970@ti.com>
+ * Thara Gopinath <thara@ti.com>
+ *
+ * Copyright (C) 2008, 2011 Nokia Corporation
+ * Kalle Jokiniemi
+ * Paul Walmsley
+ *
+ * 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_VP_H
+#define __ARCH_ARM_OMAP_VP_H
+
+#include <linux/kernel.h>
+
+struct voltagedomain;
+
+/*
+ * Voltage Processor (VP) identifiers
+ */
+#define OMAP3_VP_VDD_MPU_ID 0
+#define OMAP3_VP_VDD_CORE_ID 1
+#define OMAP4_VP_VDD_CORE_ID 0
+#define OMAP4_VP_VDD_IVA_ID 1
+#define OMAP4_VP_VDD_MPU_ID 2
+
+/* XXX document */
+#define VP_IDLE_TIMEOUT		200
+#define VP_TRANXDONE_TIMEOUT	300
+
+/**
+ * struct omap_vp_ops - per-VP operations
+ * @check_txdone: check for VP transaction done
+ * @clear_txdone: clear VP transaction done status
+ */
+struct omap_vp_ops {
+	u32 (*check_txdone)(u8 vp_id);
+	void (*clear_txdone)(u8 vp_id);
+};
+
+/**
+ * struct omap_vp_common - register data common to all VDDs
+ * @vpconfig_erroroffset_mask: ERROROFFSET bitmask in the PRM_VP*_CONFIG reg
+ * @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg
+ * @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg
+ * @vpconfig_timeouten: TIMEOUT bitmask in the PRM_VP*_CONFIG reg
+ * @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg
+ * @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg
+ * @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg
+ * @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg
+ * @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg
+ * @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg
+ * @vstepmin_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg
+ * @vstepmin_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg
+ * @vstepmax_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg
+ * @vstepmax_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg
+ * @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg
+ * @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg
+ * @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg
+ * @vpvoltage_mask: VPVOLTAGE field mask in PRM_VP*_VOLTAGE reg
+ */
+struct omap_vp_common {
+	u32 vpconfig_erroroffset_mask;
+	u32 vpconfig_errorgain_mask;
+	u32 vpconfig_initvoltage_mask;
+	u8 vpconfig_timeouten;
+	u8 vpconfig_initvdd;
+	u8 vpconfig_forceupdate;
+	u8 vpconfig_vpenable;
+	u8 vstepmin_stepmin_shift;
+	u8 vstepmin_smpswaittimemin_shift;
+	u8 vstepmax_stepmax_shift;
+	u8 vstepmax_smpswaittimemax_shift;
+	u8 vlimitto_vddmin_shift;
+	u8 vlimitto_vddmax_shift;
+	u8 vlimitto_timeout_shift;
+	u8 vpvoltage_mask;
+
+	const struct omap_vp_ops *ops;
+};
+
+/**
+ * struct omap_vp_instance - VP register offsets (per-VDD)
+ * @common: pointer to struct omap_vp_common * for this SoC
+ * @vpconfig: PRM_VP*_CONFIG reg offset from PRM start
+ * @vstepmin: PRM_VP*_VSTEPMIN reg offset from PRM start
+ * @vlimitto: PRM_VP*_VLIMITTO reg offset from PRM start
+ * @vstatus: PRM_VP*_VSTATUS reg offset from PRM start
+ * @voltage: PRM_VP*_VOLTAGE reg offset from PRM start
+ * @enabled: flag to keep track of whether vp is enabled or not
+ *
+ * XXX vp_common is probably not needed since it is per-SoC
+ */
+struct omap_vp_instance {
+	const struct omap_vp_common *common;
+	u8 vpconfig;
+	u8 vstepmin;
+	u8 vstepmax;
+	u8 vlimitto;
+	u8 vstatus;
+	u8 voltage;
+	u8 id;
+	bool enabled;
+};
+
+extern struct omap_vp_instance omap3_vp_mpu;
+extern struct omap_vp_instance omap3_vp_core;
+
+extern struct omap_vp_instance omap4_vp_mpu;
+extern struct omap_vp_instance omap4_vp_iva;
+extern struct omap_vp_instance omap4_vp_core;
+
+void omap_vp_init(struct voltagedomain *voltdm);
+void omap_vp_enable(struct voltagedomain *voltdm);
+void omap_vp_disable(struct voltagedomain *voltdm);
+unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
+int omap_vp_forceupdate_scale(struct voltagedomain *voltdm,
+			      unsigned long target_volt);
+int omap_vp_update_errorgain(struct voltagedomain *voltdm,
+			     unsigned long target_volt);
+
+#endif
-- 
1.7.4.1


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


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

* [PATCHv3 2/6] omap: voltage: change code to use new location of voltage.h and vp.h
  2011-07-18 17:35 [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
  2011-07-18 17:35 ` [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory Tero Kristo
@ 2011-07-18 17:35 ` Tero Kristo
  2011-07-18 18:16   ` Felipe Balbi
  2011-07-18 17:35 ` [PATCHv3 3/6] regulator: omap smps regulator driver Tero Kristo
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Tero Kristo @ 2011-07-18 17:35 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, tony, toddpoynor, broonie, lrg

These are now under plat-omap/include/plat.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/io.c                      |    2 +-
 arch/arm/mach-omap2/omap_opp_data.h           |    3 +--
 arch/arm/mach-omap2/omap_twl.c                |    2 +-
 arch/arm/mach-omap2/pm.c                      |    2 +-
 arch/arm/mach-omap2/powerdomain.h             |    3 +--
 arch/arm/mach-omap2/prm2xxx_3xxx.c            |    3 +--
 arch/arm/mach-omap2/prm44xx.c                 |    2 +-
 arch/arm/mach-omap2/smartreflex.h             |    2 +-
 arch/arm/mach-omap2/sr_device.c               |    2 +-
 arch/arm/mach-omap2/vc.c                      |    2 +-
 arch/arm/mach-omap2/vc3xxx_data.c             |    2 +-
 arch/arm/mach-omap2/vc44xx_data.c             |    2 +-
 arch/arm/mach-omap2/voltage.c                 |    3 +--
 arch/arm/mach-omap2/voltagedomains2xxx_data.c |    2 +-
 arch/arm/mach-omap2/voltagedomains3xxx_data.c |    3 +--
 arch/arm/mach-omap2/voltagedomains44xx_data.c |    3 +--
 arch/arm/mach-omap2/vp.c                      |    4 ++--
 arch/arm/mach-omap2/vp3xxx_data.c             |    3 +--
 arch/arm/mach-omap2/vp44xx_data.c             |    4 +---
 19 files changed, 20 insertions(+), 29 deletions(-)

diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 4c8a5de..b151fca 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -31,6 +31,7 @@
 #include <plat/sram.h>
 #include <plat/sdrc.h>
 #include <plat/serial.h>
+#include <plat/voltage.h>
 
 #include "clock2xxx.h"
 #include "clock3xxx.h"
@@ -38,7 +39,6 @@
 #include "io.h"
 
 #include <plat/omap-pm.h>
-#include "voltage.h"
 #include "powerdomain.h"
 
 #include "clockdomain.h"
diff --git a/arch/arm/mach-omap2/omap_opp_data.h b/arch/arm/mach-omap2/omap_opp_data.h
index c784c12..4d93209 100644
--- a/arch/arm/mach-omap2/omap_opp_data.h
+++ b/arch/arm/mach-omap2/omap_opp_data.h
@@ -20,8 +20,7 @@
 #define __ARCH_ARM_MACH_OMAP2_OMAP_OPP_DATA_H
 
 #include <plat/omap_hwmod.h>
-
-#include "voltage.h"
+#include <plat/voltage.h>
 
 /*
  * *BIG FAT WARNING*:
diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index f515a1a..b9720a0 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -18,7 +18,7 @@
 #include <linux/kernel.h>
 #include <linux/i2c/twl.h>
 
-#include "voltage.h"
+#include <plat/voltage.h>
 
 #include "pm.h"
 
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 659e400..699d347 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -18,8 +18,8 @@
 #include <plat/omap-pm.h>
 #include <plat/omap_device.h>
 #include <plat/common.h>
+#include <plat/voltage.h>
 
-#include "voltage.h"
 #include "powerdomain.h"
 #include "clockdomain.h"
 #include "pm.h"
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h
index 2c685a5..2ae9236 100644
--- a/arch/arm/mach-omap2/powerdomain.h
+++ b/arch/arm/mach-omap2/powerdomain.h
@@ -23,8 +23,7 @@
 #include <linux/atomic.h>
 
 #include <plat/cpu.h>
-
-#include "voltage.h"
+#include <plat/voltage.h>
 
 /* Powerdomain basic power states */
 #define PWRDM_POWER_OFF		0x0
diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c b/arch/arm/mach-omap2/prm2xxx_3xxx.c
index 3b83763..e096c76 100644
--- a/arch/arm/mach-omap2/prm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c
@@ -19,8 +19,7 @@
 #include <plat/common.h>
 #include <plat/cpu.h>
 #include <plat/prcm.h>
-
-#include "vp.h"
+#include <plat/vp.h>
 
 #include "prm2xxx_3xxx.h"
 #include "cm2xxx_3xxx.h"
diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c
index 495a31a..5979803 100644
--- a/arch/arm/mach-omap2/prm44xx.c
+++ b/arch/arm/mach-omap2/prm44xx.c
@@ -20,8 +20,8 @@
 #include <plat/common.h>
 #include <plat/cpu.h>
 #include <plat/prcm.h>
+#include <plat/vp.h>
 
-#include "vp.h"
 #include "prm44xx.h"
 #include "prm-regbits-44xx.h"
 #include "prcm44xx.h"
diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h
index 5f35b9e..fe9b242 100644
--- a/arch/arm/mach-omap2/smartreflex.h
+++ b/arch/arm/mach-omap2/smartreflex.h
@@ -22,7 +22,7 @@
 
 #include <linux/platform_device.h>
 
-#include "voltage.h"
+#include <plat/voltage.h>
 
 /*
  * Different Smartreflex IPs version. The v1 is the 65nm version used in
diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index 2782d3f..bc08751 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -23,9 +23,9 @@
 #include <linux/io.h>
 
 #include <plat/omap_device.h>
+#include <plat/voltage.h>
 
 #include "smartreflex.h"
-#include "voltage.h"
 #include "control.h"
 #include "pm.h"
 
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index aa9f0bc..2c8bc24 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -3,8 +3,8 @@
 #include <linux/init.h>
 
 #include <plat/cpu.h>
+#include <plat/voltage.h>
 
-#include "voltage.h"
 #include "vc.h"
 #include "prm-regbits-34xx.h"
 #include "prm-regbits-44xx.h"
diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c
index 95d7701..b691dad 100644
--- a/arch/arm/mach-omap2/vc3xxx_data.c
+++ b/arch/arm/mach-omap2/vc3xxx_data.c
@@ -19,9 +19,9 @@
 #include <linux/init.h>
 
 #include <plat/common.h>
+#include <plat/voltage.h>
 
 #include "prm-regbits-34xx.h"
-#include "voltage.h"
 
 #include "vc.h"
 
diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c
index 0a4fc37..1eeab16 100644
--- a/arch/arm/mach-omap2/vc44xx_data.c
+++ b/arch/arm/mach-omap2/vc44xx_data.c
@@ -19,10 +19,10 @@
 #include <linux/init.h>
 
 #include <plat/common.h>
+#include <plat/voltage.h>
 
 #include "prm44xx.h"
 #include "prm-regbits-44xx.h"
-#include "voltage.h"
 
 #include "vc.h"
 
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c
index b20985a..11c4a6c 100644
--- a/arch/arm/mach-omap2/voltage.c
+++ b/arch/arm/mach-omap2/voltage.c
@@ -27,6 +27,7 @@
 #include <linux/clk.h>
 
 #include <plat/common.h>
+#include <plat/voltage.h>
 
 #include "prm-regbits-34xx.h"
 #include "prm-regbits-44xx.h"
@@ -35,11 +36,9 @@
 #include "prminst44xx.h"
 #include "control.h"
 
-#include "voltage.h"
 #include "powerdomain.h"
 
 #include "vc.h"
-#include "vp.h"
 
 static LIST_HEAD(voltdm_list);
 
diff --git a/arch/arm/mach-omap2/voltagedomains2xxx_data.c b/arch/arm/mach-omap2/voltagedomains2xxx_data.c
index 69ff261..e5ae258 100644
--- a/arch/arm/mach-omap2/voltagedomains2xxx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains2xxx_data.c
@@ -10,7 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 
-#include "voltage.h"
+#include <plat/voltage.h>
 
 static struct voltagedomain omap2_voltdm_core = {
 	.name = "core",
diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
index b0d0ae1..175e856 100644
--- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c
@@ -20,12 +20,11 @@
 
 #include <plat/common.h>
 #include <plat/cpu.h>
+#include <plat/voltage.h>
 
 #include "prm-regbits-34xx.h"
 #include "omap_opp_data.h"
-#include "voltage.h"
 #include "vc.h"
-#include "vp.h"
 
 /*
  * VDD data
diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c
index c4584e9..9d1f6d3 100644
--- a/arch/arm/mach-omap2/voltagedomains44xx_data.c
+++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c
@@ -22,15 +22,14 @@
 #include <linux/init.h>
 
 #include <plat/common.h>
+#include <plat/voltage.h>
 
 #include "prm-regbits-44xx.h"
 #include "prm44xx.h"
 #include "prcm44xx.h"
 #include "prminst44xx.h"
-#include "voltage.h"
 #include "omap_opp_data.h"
 #include "vc.h"
-#include "vp.h"
 
 static const struct omap_vfsm_instance omap4_vdd_mpu_vfsm = {
 	.voltsetup_reg = OMAP4_PRM_VOLTSETUP_MPU_RET_SLEEP_OFFSET,
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 3807620..b01c571 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -2,9 +2,9 @@
 #include <linux/init.h>
 
 #include <plat/common.h>
+#include <plat/voltage.h>
 
-#include "voltage.h"
-#include "vp.h"
+#include "vc.h"
 #include "prm-regbits-34xx.h"
 #include "prm-regbits-44xx.h"
 #include "prm44xx.h"
diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c
index 260c554..9bac34e 100644
--- a/arch/arm/mach-omap2/vp3xxx_data.c
+++ b/arch/arm/mach-omap2/vp3xxx_data.c
@@ -20,11 +20,10 @@
 #include <linux/init.h>
 
 #include <plat/common.h>
+#include <plat/voltage.h>
 
 #include "prm-regbits-34xx.h"
-#include "voltage.h"
 
-#include "vp.h"
 #include "prm2xxx_3xxx.h"
 
 static const struct omap_vp_ops omap3_vp_ops = {
diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c
index b4e7704..6bd1d90 100644
--- a/arch/arm/mach-omap2/vp44xx_data.c
+++ b/arch/arm/mach-omap2/vp44xx_data.c
@@ -20,12 +20,10 @@
 #include <linux/init.h>
 
 #include <plat/common.h>
+#include <plat/voltage.h>
 
 #include "prm44xx.h"
 #include "prm-regbits-44xx.h"
-#include "voltage.h"
-
-#include "vp.h"
 
 static const struct omap_vp_ops omap4_vp_ops = {
 	.check_txdone = omap4_prm_vp_check_txdone,
-- 
1.7.4.1


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


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

* [PATCHv3 3/6] regulator: omap smps regulator driver
  2011-07-18 17:35 [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
  2011-07-18 17:35 ` [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory Tero Kristo
  2011-07-18 17:35 ` [PATCHv3 2/6] omap: voltage: change code to use new location of voltage.h and vp.h Tero Kristo
@ 2011-07-18 17:35 ` Tero Kristo
  2011-07-18 18:22   ` Felipe Balbi
                     ` (2 more replies)
  2011-07-18 17:35 ` [PATCHv3 4/6] omap3: pmic: add API to get common SMPS regulators Tero Kristo
                   ` (3 subsequent siblings)
  6 siblings, 3 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-18 17:35 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, tony, toddpoynor, broonie, lrg

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>
---
 drivers/regulator/Kconfig               |    9 ++
 drivers/regulator/Makefile              |    1 +
 drivers/regulator/omap-smps-regulator.c |  180 +++++++++++++++++++++++++++++++
 include/linux/regulator/omap-smps.h     |   20 ++++
 4 files changed, 210 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..bb18ff2 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -303,5 +303,14 @@ 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 && TWL4030_CORE
+	help
+	  This driver supports the OMAP3 / OMAP4 SMPS regulators for VDD1,
+	  VDD2 and VDD3. These regulators reside inside the TWL4030 /
+	  TWL6030 chip but 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..8b56e4f
--- /dev/null
+++ b/drivers/regulator/omap-smps-regulator.c
@@ -0,0 +1,179 @@
+/*
+ * omap-vp-regulator.c -- support SMPS regulators for OMAP chips
+ *
+ * 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 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 omap_vp_get_curr_volt(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] 22+ messages in thread

* [PATCHv3 4/6] omap3: pmic: add API to get common SMPS regulators
  2011-07-18 17:35 [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
                   ` (2 preceding siblings ...)
  2011-07-18 17:35 ` [PATCHv3 3/6] regulator: omap smps regulator driver Tero Kristo
@ 2011-07-18 17:35 ` Tero Kristo
  2011-07-18 18:23   ` Felipe Balbi
  2011-07-18 17:35 ` [PATCHv3 5/6] omap3: beagleboard: add " Tero Kristo
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 22+ messages in thread
From: Tero Kristo @ 2011-07-18 17:35 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, tony, toddpoynor, broonie, lrg

omap3_pmic_get_smps_config can now be used to get regulator configuration
for MPU and CORE SMPS regulators. This should be expanded later to add IVA
SMPS regulator for OMAP4.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 arch/arm/mach-omap2/twl-common.c |   62 ++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/twl-common.h |   14 ++++++++
 2 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index 2543342..dc36053 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -23,8 +23,10 @@
 #include <linux/i2c.h>
 #include <linux/i2c/twl.h>
 #include <linux/gpio.h>
+#include <linux/slab.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/fixed.h>
+#include <linux/regulator/omap-smps.h>
 
 #include <plat/i2c.h>
 #include <plat/usb.h>
@@ -302,3 +304,63 @@ void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
 	if (regulators_flags & TWL_COMMON_REGULATOR_VPLL2 && !pmic_data->vpll2)
 		pmic_data->vpll2 = &omap3_vpll2_idata;
 }
+
+static struct regulator_consumer_supply omap_smps_mpu_iva_supply[] = {
+	REGULATOR_SUPPLY("vcc", "mpu_iva"),
+};
+
+static struct regulator_consumer_supply omap_smps_core_supply[] = {
+	REGULATOR_SUPPLY("vcc", "core"),
+};
+
+static struct regulator_init_data omap_smps_mpu_iva = {
+	.constraints = {
+		.min_uV			= 600000,
+		.max_uV			= 1450000,
+		.valid_modes_mask	= REGULATOR_MODE_NORMAL,
+		.valid_ops_mask		= REGULATOR_CHANGE_VOLTAGE,
+	},
+	.num_consumer_supplies	= ARRAY_SIZE(omap_smps_mpu_iva_supply),
+	.consumer_supplies	= omap_smps_mpu_iva_supply,
+};
+
+static struct regulator_init_data omap_smps_core = {
+	.constraints = {
+		.min_uV			= 600000,
+		.max_uV			= 1450000,
+		.valid_modes_mask	= REGULATOR_MODE_NORMAL,
+		.valid_ops_mask		= REGULATOR_CHANGE_VOLTAGE,
+	},
+	.num_consumer_supplies	= ARRAY_SIZE(omap_smps_core_supply),
+	.consumer_supplies	= omap_smps_core_supply,
+};
+
+void omap_pmic_get_smps_config(struct platform_device *smps_dev,
+				u32 smps_flags)
+{
+	struct omap_smps_platform_data *info;
+	struct regulator_init_data **reg_list;
+	int num_reg = 0;
+
+	reg_list = kmalloc(sizeof(void *) * hweight32(smps_flags), GFP_KERNEL);
+	info = kzalloc(sizeof(struct omap_smps_platform_data), GFP_KERNEL);
+
+	if (!reg_list || !info)
+		return;
+
+	if (smps_flags & SMPS_COMMON_REGULATOR_MPU_IVA) {
+		reg_list[num_reg] = &omap_smps_mpu_iva;
+		num_reg++;
+	}
+	if (smps_flags & SMPS_COMMON_REGULATOR_CORE) {
+		reg_list[num_reg] = &omap_smps_core;
+		num_reg++;
+	}
+
+	info->regulators = reg_list;
+	info->num_regulators = num_reg;
+
+	smps_dev->name = "omap-smps";
+	smps_dev->id = -1;
+	smps_dev->dev.platform_data = info;
+}
diff --git a/arch/arm/mach-omap2/twl-common.h b/arch/arm/mach-omap2/twl-common.h
index 5e83a5b..fde8467 100644
--- a/arch/arm/mach-omap2/twl-common.h
+++ b/arch/arm/mach-omap2/twl-common.h
@@ -25,6 +25,11 @@
 #define TWL_COMMON_REGULATOR_VPLL1	(1 << 4)
 #define TWL_COMMON_REGULATOR_VPLL2	(1 << 5)
 
+/* TWLxxxx SMPS regulators */
+#define SMPS_COMMON_REGULATOR_MPU	(1 << 0)
+#define SMPS_COMMON_REGULATOR_CORE	(1 << 1)
+#define SMPS_COMMON_REGULATOR_IVA	(1 << 2)
+#define SMPS_COMMON_REGULATOR_MPU_IVA	(1 << 3)
 
 struct twl4030_platform_data;
 
@@ -56,4 +61,13 @@ void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
 void omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
 			   u32 pdata_flags, u32 regulators_flags);
 
+void omap_pmic_get_smps_config(struct platform_device *smps_dev,
+				u32 smps_flags);
+
+static inline void omap3_pmic_get_smps_config(struct platform_device *smps_dev)
+{
+	omap_pmic_get_smps_config(smps_dev, SMPS_COMMON_REGULATOR_MPU_IVA |
+		SMPS_COMMON_REGULATOR_CORE);
+}
+
 #endif /* __OMAP_PMIC_COMMON__ */
-- 
1.7.4.1


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


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

* [PATCHv3 5/6] omap3: beagleboard: add SMPS regulators
  2011-07-18 17:35 [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
                   ` (3 preceding siblings ...)
  2011-07-18 17:35 ` [PATCHv3 4/6] omap3: pmic: add API to get common SMPS regulators Tero Kristo
@ 2011-07-18 17:35 ` Tero Kristo
  2011-07-18 17:35 ` [PATCHv3 6/6] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
  2011-07-18 17:55 ` [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
  6 siblings, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-18 17:35 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, tony, toddpoynor, broonie, lrg

This is using the common API defined in twl-common.

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

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 32f5f89..d493b0b 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -444,6 +444,8 @@ static struct platform_device keys_gpio = {
 	},
 };
 
+static struct platform_device beagle_smps;
+
 static void __init omap3_beagle_init_early(void)
 {
 	omap2_init_common_infrastructure();
@@ -459,6 +461,7 @@ static void __init omap3_beagle_init_irq(void)
 static struct platform_device *omap3_beagle_devices[] __initdata = {
 	&leds_gpio,
 	&keys_gpio,
+	&beagle_smps,
 };
 
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
@@ -533,6 +536,7 @@ static void __init omap3_beagle_init(void)
 
 	gpio_buttons[0].gpio = beagle_config.usr_button_gpio;
 
+	omap3_pmic_get_smps_config(&beagle_smps);
 	platform_add_devices(omap3_beagle_devices,
 			ARRAY_SIZE(omap3_beagle_devices));
 	omap_display_init(&beagle_dss_data);
-- 
1.7.4.1


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


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

* [PATCHv3 6/6] TEMP: OMAP3: beagle rev-c4: enable OPP6
  2011-07-18 17:35 [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
                   ` (4 preceding siblings ...)
  2011-07-18 17:35 ` [PATCHv3 5/6] omap3: beagleboard: add " Tero Kristo
@ 2011-07-18 17:35 ` Tero Kristo
  2011-07-18 17:55 ` [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
  6 siblings, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-18 17:35 UTC (permalink / raw)
  To: linux-omap; +Cc: khilman, tony, toddpoynor, broonie, lrg

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

This is a temporary patch for supporting this set only, do not integrate.

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 d493b0b..4d7fd3f 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -492,6 +492,38 @@ static void __init beagle_opp_init(void)
 		return;
 	}
 
+	/* Custom OPP enabled for C4 */
+	if (omap3_beagle_version == 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 all xM versions */
 	if (cpu_is_omap3630()) {
 		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] 22+ messages in thread

* Re: [PATCHv3 0/6] OMAP SMPS regulator driver
  2011-07-18 17:35 [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
                   ` (5 preceding siblings ...)
  2011-07-18 17:35 ` [PATCHv3 6/6] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
@ 2011-07-18 17:55 ` Tero Kristo
  6 siblings, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-18 17:55 UTC (permalink / raw)
  To: linux-omap; +Cc: Hilman, Kevin, tony, toddpoynor, broonie, Girdwood, Liam

On Mon, 2011-07-18 at 19:35 +0200, Kristo, Tero wrote:
> Hello,
> 
> Main changes compared to v2:
> 
> - cleanup should now work better
> - register all available regulators always, if no initdata => readonly
> - added board init support functionality to twl-common
> - constraints not touched by the driver anymore
> 

forgot to mention, this set was also rebased on top of
linux-omap/pm/wip/voltdm branch.

> Tested on omap3 beagle.
> 
> -Tero
> 
> 
> Texas Instruments Oy, Tekniikantie 12, 02150 Espoo. Y-tunnus: 0115040-6. Kotipaikka: Helsinki
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



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


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

* Re: [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory
  2011-07-18 17:35 ` [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory Tero Kristo
@ 2011-07-18 18:16   ` Felipe Balbi
  2011-07-19  7:49     ` Tero Kristo
  2011-07-18 23:45   ` Kevin Hilman
  1 sibling, 1 reply; 22+ messages in thread
From: Felipe Balbi @ 2011-07-18 18:16 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, tony, toddpoynor, broonie, lrg

[-- Attachment #1: Type: text/plain, Size: 917 bytes --]

Hi,

On Mon, Jul 18, 2011 at 08:35:17PM +0300, Tero Kristo wrote:
> This is needed so that these include files can be accessed from drivers.
>
> Signed-off-by: Tero Kristo <t-kristo@ti.com>
> ---
>  arch/arm/mach-omap2/voltage.h             |  180 -----------------------------
>  arch/arm/mach-omap2/vp.h                  |  128 --------------------
>  arch/arm/plat-omap/include/plat/voltage.h |  179 ++++++++++++++++++++++++++++
>  arch/arm/plat-omap/include/plat/vp.h      |  128 ++++++++++++++++++++
>  4 files changed, 307 insertions(+), 308 deletions(-)
>  delete mode 100644 arch/arm/mach-omap2/voltage.h
>  delete mode 100644 arch/arm/mach-omap2/vp.h
>  create mode 100644 arch/arm/plat-omap/include/plat/voltage.h
>  create mode 100644 arch/arm/plat-omap/include/plat/vp.h

just one small tip, if you use git format-patch -M, it would detect that
this was just a rename ;-)

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* Re: [PATCHv3 2/6] omap: voltage: change code to use new location of voltage.h and vp.h
  2011-07-18 17:35 ` [PATCHv3 2/6] omap: voltage: change code to use new location of voltage.h and vp.h Tero Kristo
@ 2011-07-18 18:16   ` Felipe Balbi
  2011-07-19  7:47     ` Tero Kristo
  0 siblings, 1 reply; 22+ messages in thread
From: Felipe Balbi @ 2011-07-18 18:16 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, tony, toddpoynor, broonie, lrg

[-- Attachment #1: Type: text/plain, Size: 278 bytes --]

Hi,

On Mon, Jul 18, 2011 at 08:35:18PM +0300, Tero Kristo wrote:
> These are now under plat-omap/include/plat.
> 
> Signed-off-by: Tero Kristo <t-kristo@ti.com>

this has to be folded into previous patch, otherwise we will have a
broken bisection point.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* Re: [PATCHv3 3/6] regulator: omap smps regulator driver
  2011-07-18 17:35 ` [PATCHv3 3/6] regulator: omap smps regulator driver Tero Kristo
@ 2011-07-18 18:22   ` Felipe Balbi
  2011-07-18 23:40     ` Kevin Hilman
  2011-07-19  7:58     ` Tero Kristo
  2011-07-19 10:28   ` Graeme Gregory
  2011-07-19 15:38   ` Mark Brown
  2 siblings, 2 replies; 22+ messages in thread
From: Felipe Balbi @ 2011-07-18 18:22 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, tony, toddpoynor, broonie, lrg

[-- Attachment #1: Type: text/plain, Size: 1897 bytes --]

Hi,

On Mon, Jul 18, 2011 at 08:35:19PM +0300, Tero Kristo wrote:
> diff --git a/drivers/regulator/omap-smps-regulator.c b/drivers/regulator/omap-smps-regulator.c
> new file mode 100644
> index 0000000..8b56e4f
> --- /dev/null
> +++ b/drivers/regulator/omap-smps-regulator.c
> @@ -0,0 +1,179 @@
> +/*
> + * omap-vp-regulator.c -- support SMPS regulators for OMAP chips

name is wrong here.

> + *
> + * 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 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 omap_vp_get_curr_volt(info->voltdm);
> +}
> +
> +static struct regulator_ops omap_smps_ops = {

should this be const ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* Re: [PATCHv3 4/6] omap3: pmic: add API to get common SMPS regulators
  2011-07-18 17:35 ` [PATCHv3 4/6] omap3: pmic: add API to get common SMPS regulators Tero Kristo
@ 2011-07-18 18:23   ` Felipe Balbi
  2011-07-19  8:07     ` Tero Kristo
  0 siblings, 1 reply; 22+ messages in thread
From: Felipe Balbi @ 2011-07-18 18:23 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, tony, toddpoynor, broonie, lrg

[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]

Hi,

On Mon, Jul 18, 2011 at 08:35:20PM +0300, Tero Kristo wrote:
> diff --git a/arch/arm/mach-omap2/twl-common.h b/arch/arm/mach-omap2/twl-common.h
> index 5e83a5b..fde8467 100644
> --- a/arch/arm/mach-omap2/twl-common.h
> +++ b/arch/arm/mach-omap2/twl-common.h
> @@ -25,6 +25,11 @@
>  #define TWL_COMMON_REGULATOR_VPLL1	(1 << 4)
>  #define TWL_COMMON_REGULATOR_VPLL2	(1 << 5)
>  
> +/* TWLxxxx SMPS regulators */
> +#define SMPS_COMMON_REGULATOR_MPU	(1 << 0)
> +#define SMPS_COMMON_REGULATOR_CORE	(1 << 1)
> +#define SMPS_COMMON_REGULATOR_IVA	(1 << 2)
> +#define SMPS_COMMON_REGULATOR_MPU_IVA	(1 << 3)
>  
>  struct twl4030_platform_data;
>  
> @@ -56,4 +61,13 @@ void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
>  void omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
>  			   u32 pdata_flags, u32 regulators_flags);
>  
> +void omap_pmic_get_smps_config(struct platform_device *smps_dev,
> +				u32 smps_flags);
> +
> +static inline void omap3_pmic_get_smps_config(struct platform_device *smps_dev)
> +{
> +	omap_pmic_get_smps_config(smps_dev, SMPS_COMMON_REGULATOR_MPU_IVA |
> +		SMPS_COMMON_REGULATOR_CORE);
> +}

if these are specific to OMAP SoC, why do they come on twl-common.h
header ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

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

* Re: [PATCHv3 3/6] regulator: omap smps regulator driver
  2011-07-18 18:22   ` Felipe Balbi
@ 2011-07-18 23:40     ` Kevin Hilman
  2011-07-19  7:53       ` Tero Kristo
  2011-07-19  7:58     ` Tero Kristo
  1 sibling, 1 reply; 22+ messages in thread
From: Kevin Hilman @ 2011-07-18 23:40 UTC (permalink / raw)
  To: balbi; +Cc: Tero Kristo, linux-omap, tony, toddpoynor, broonie, lrg

Felipe Balbi <balbi@ti.com> writes:

> On Mon, Jul 18, 2011 at 08:35:19PM +0300, Tero Kristo wrote:
>> diff --git a/drivers/regulator/omap-smps-regulator.c b/drivers/regulator/omap-smps-regulator.c
>> new file mode 100644
>> index 0000000..8b56e4f
>> --- /dev/null
>> +++ b/drivers/regulator/omap-smps-regulator.c
>> @@ -0,0 +1,179 @@
>> +/*
>> + * omap-vp-regulator.c -- support SMPS regulators for OMAP chips
>
> name is wrong here.

In fact, just leave filenames out of file headers all together to avoid
this kind of problem.

Kevin

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

* Re: [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory
  2011-07-18 17:35 ` [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory Tero Kristo
  2011-07-18 18:16   ` Felipe Balbi
@ 2011-07-18 23:45   ` Kevin Hilman
  1 sibling, 0 replies; 22+ messages in thread
From: Kevin Hilman @ 2011-07-18 23:45 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, tony, toddpoynor, broonie, lrg

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

> This is needed so that these include files can be accessed from drivers.

I think you can get by with a <plat/voltage.h> with simply an opaque
struct voltagedomain, and the definitions of the functions needed by the
regulator driver (currently only voltdm_scale, omap_vp_get_curr_volt).
Then mach-omap2/voltage.h could just include <plat/voltage.h> and all
the truly internal stuff can stay internal.

Also note that in the latest pm-wip/voltdm branch (just pushed)
omap_vp_get_curr_volt() no longer exists.  Just use
voltdm_get_voltage().

Kevin

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

* Re: [PATCHv3 2/6] omap: voltage: change code to use new location of voltage.h and vp.h
  2011-07-18 18:16   ` Felipe Balbi
@ 2011-07-19  7:47     ` Tero Kristo
  0 siblings, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-19  7:47 UTC (permalink / raw)
  To: Balbi, Felipe
  Cc: linux-omap, Hilman, Kevin, tony, toddpoynor, broonie,
	Girdwood, Liam

On Mon, 2011-07-18 at 20:16 +0200, Balbi, Felipe wrote:
> Hi,
> 
> On Mon, Jul 18, 2011 at 08:35:18PM +0300, Tero Kristo wrote:
> > These are now under plat-omap/include/plat.
> > 
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> 
> this has to be folded into previous patch, otherwise we will have a
> broken bisection point.
> 

Good to know for future, I will just drop this patch (and patch 1 also)
though as Kevin suggested and create a simple stub that provides only
the API needed.

-Tero


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


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

* Re: [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory
  2011-07-18 18:16   ` Felipe Balbi
@ 2011-07-19  7:49     ` Tero Kristo
  0 siblings, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-19  7:49 UTC (permalink / raw)
  To: Balbi, Felipe
  Cc: linux-omap, Hilman, Kevin, tony, toddpoynor, broonie,
	Girdwood, Liam

On Mon, 2011-07-18 at 20:16 +0200, Balbi, Felipe wrote:
> Hi,
> 
> On Mon, Jul 18, 2011 at 08:35:17PM +0300, Tero Kristo wrote:
> > This is needed so that these include files can be accessed from drivers.
> >
> > Signed-off-by: Tero Kristo <t-kristo@ti.com>
> > ---
> >  arch/arm/mach-omap2/voltage.h             |  180 -----------------------------
> >  arch/arm/mach-omap2/vp.h                  |  128 --------------------
> >  arch/arm/plat-omap/include/plat/voltage.h |  179 ++++++++++++++++++++++++++++
> >  arch/arm/plat-omap/include/plat/vp.h      |  128 ++++++++++++++++++++
> >  4 files changed, 307 insertions(+), 308 deletions(-)
> >  delete mode 100644 arch/arm/mach-omap2/voltage.h
> >  delete mode 100644 arch/arm/mach-omap2/vp.h
> >  create mode 100644 arch/arm/plat-omap/include/plat/voltage.h
> >  create mode 100644 arch/arm/plat-omap/include/plat/vp.h
> 
> just one small tip, if you use git format-patch -M, it would detect that
> this was just a rename ;-)
> 

Hmm did not notice this... git-format actually detected that this was a
rename in previous version of the set, even without the -M option. Will
try to remember that in the future.


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


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

* Re: [PATCHv3 3/6] regulator: omap smps regulator driver
  2011-07-18 23:40     ` Kevin Hilman
@ 2011-07-19  7:53       ` Tero Kristo
  0 siblings, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-19  7:53 UTC (permalink / raw)
  To: Hilman, Kevin
  Cc: Balbi, Felipe, linux-omap, tony, toddpoynor, broonie,
	Girdwood, Liam

On Tue, 2011-07-19 at 01:40 +0200, Hilman, Kevin wrote:
> Felipe Balbi <balbi@ti.com> writes:
> 
> > On Mon, Jul 18, 2011 at 08:35:19PM +0300, Tero Kristo wrote:
> >> diff --git a/drivers/regulator/omap-smps-regulator.c b/drivers/regulator/omap-smps-regulator.c
> >> new file mode 100644
> >> index 0000000..8b56e4f
> >> --- /dev/null
> >> +++ b/drivers/regulator/omap-smps-regulator.c
> >> @@ -0,0 +1,179 @@
> >> +/*
> >> + * omap-vp-regulator.c -- support SMPS regulators for OMAP chips
> >
> > name is wrong here.
> 
> In fact, just leave filenames out of file headers all together to avoid
> this kind of problem.

Yea, can drop that out.



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


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

* Re: [PATCHv3 3/6] regulator: omap smps regulator driver
  2011-07-18 18:22   ` Felipe Balbi
  2011-07-18 23:40     ` Kevin Hilman
@ 2011-07-19  7:58     ` Tero Kristo
  1 sibling, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-19  7:58 UTC (permalink / raw)
  To: Balbi, Felipe
  Cc: linux-omap, Hilman, Kevin, tony, toddpoynor, broonie,
	Girdwood, Liam

On Mon, 2011-07-18 at 20:22 +0200, Balbi, Felipe wrote:
> Hi,
> 
> On Mon, Jul 18, 2011 at 08:35:19PM +0300, Tero Kristo wrote:
> > diff --git a/drivers/regulator/omap-smps-regulator.c b/drivers/regulator/omap-smps-regulator.c
> > new file mode 100644
> > index 0000000..8b56e4f
> > --- /dev/null
> > +++ b/drivers/regulator/omap-smps-regulator.c
> > @@ -0,0 +1,179 @@
> > +/*
> > + * omap-vp-regulator.c -- support SMPS regulators for OMAP chips
> 
> name is wrong here.
> 
> > + *
> > + * 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 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 omap_vp_get_curr_volt(info->voltdm);
> > +}
> > +
> > +static struct regulator_ops omap_smps_ops = {
> 
> should this be const ?
> 

I think it can be yea, I'll change that for next version.



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


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

* Re: [PATCHv3 4/6] omap3: pmic: add API to get common SMPS regulators
  2011-07-18 18:23   ` Felipe Balbi
@ 2011-07-19  8:07     ` Tero Kristo
  0 siblings, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-19  8:07 UTC (permalink / raw)
  To: Balbi, Felipe
  Cc: linux-omap, Hilman, Kevin, tony, toddpoynor, broonie,
	Girdwood, Liam

On Mon, 2011-07-18 at 20:23 +0200, Balbi, Felipe wrote:
> Hi,
> 
> On Mon, Jul 18, 2011 at 08:35:20PM +0300, Tero Kristo wrote:
> > diff --git a/arch/arm/mach-omap2/twl-common.h b/arch/arm/mach-omap2/twl-common.h
> > index 5e83a5b..fde8467 100644
> > --- a/arch/arm/mach-omap2/twl-common.h
> > +++ b/arch/arm/mach-omap2/twl-common.h
> > @@ -25,6 +25,11 @@
> >  #define TWL_COMMON_REGULATOR_VPLL1	(1 << 4)
> >  #define TWL_COMMON_REGULATOR_VPLL2	(1 << 5)
> >  
> > +/* TWLxxxx SMPS regulators */
> > +#define SMPS_COMMON_REGULATOR_MPU	(1 << 0)
> > +#define SMPS_COMMON_REGULATOR_CORE	(1 << 1)
> > +#define SMPS_COMMON_REGULATOR_IVA	(1 << 2)
> > +#define SMPS_COMMON_REGULATOR_MPU_IVA	(1 << 3)
> >  
> >  struct twl4030_platform_data;
> >  
> > @@ -56,4 +61,13 @@ void omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
> >  void omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
> >  			   u32 pdata_flags, u32 regulators_flags);
> >  
> > +void omap_pmic_get_smps_config(struct platform_device *smps_dev,
> > +				u32 smps_flags);
> > +
> > +static inline void omap3_pmic_get_smps_config(struct platform_device *smps_dev)
> > +{
> > +	omap_pmic_get_smps_config(smps_dev, SMPS_COMMON_REGULATOR_MPU_IVA |
> > +		SMPS_COMMON_REGULATOR_CORE);
> > +}
> 
> if these are specific to OMAP SoC, why do they come on twl-common.h
> header ?
> 

I was wondering about this myself too and was almost certain that
someone will ask about it. I decided to follow the easy path for this
version though for comments. Anyway, which would be the best option for
this:
1) just add them into twl-common
2) rename twl-common to something else and add these
3) add a completely new file + header for the smps regulator support


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


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

* Re: [PATCHv3 3/6] regulator: omap smps regulator driver
  2011-07-18 17:35 ` [PATCHv3 3/6] regulator: omap smps regulator driver Tero Kristo
  2011-07-18 18:22   ` Felipe Balbi
@ 2011-07-19 10:28   ` Graeme Gregory
  2011-07-19 15:38   ` Mark Brown
  2 siblings, 0 replies; 22+ messages in thread
From: Graeme Gregory @ 2011-07-19 10:28 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, tony, toddpoynor, broonie, lrg

On 07/18/2011 06:35 PM, 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>
> 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>
> ---
>  drivers/regulator/Kconfig               |    9 ++
>  drivers/regulator/Makefile              |    1 +
>  drivers/regulator/omap-smps-regulator.c |  180 +++++++++++++++++++++++++++++++
>  include/linux/regulator/omap-smps.h     |   20 ++++
>  4 files changed, 210 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..bb18ff2 100644
> --- a/drivers/regulator/Kconfig
> +++ b/drivers/regulator/Kconfig
> @@ -303,5 +303,14 @@ 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 && TWL4030_CORE
> +	help
> +	  This driver supports the OMAP3 / OMAP4 SMPS regulators for VDD1,
> +	  VDD2 and VDD3. These regulators reside inside the TWL4030 /
> +	  TWL6030 chip but 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..8b56e4f
> --- /dev/null
> +++ b/drivers/regulator/omap-smps-regulator.c
> @@ -0,0 +1,179 @@
> +/*
> + * omap-vp-regulator.c -- support SMPS regulators for OMAP chips
> + *
> + * 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 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 omap_vp_get_curr_volt(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__ */
This does not conflict with my driver for the same functionality on non
omap CPUs which is still waiting for me to clean up and upstream. So

Acked-by: Graeme Gregory <gg@slimlogic.co.uk>

Graeme


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

* Re: [PATCHv3 3/6] regulator: omap smps regulator driver
  2011-07-18 17:35 ` [PATCHv3 3/6] regulator: omap smps regulator driver Tero Kristo
  2011-07-18 18:22   ` Felipe Balbi
  2011-07-19 10:28   ` Graeme Gregory
@ 2011-07-19 15:38   ` Mark Brown
  2011-07-19 15:52     ` Tero Kristo
  2 siblings, 1 reply; 22+ messages in thread
From: Mark Brown @ 2011-07-19 15:38 UTC (permalink / raw)
  To: Tero Kristo; +Cc: linux-omap, khilman, tony, toddpoynor, lrg

On Mon, Jul 18, 2011 at 08:35:19PM +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.


> +config REGULATOR_OMAP_SMPS
> +	tristate "TI OMAP SMPS Power Regulators"
> +	depends on (ARCH_OMAP3 || ARCH_OMAP4) && PM && TWL4030_CORE

Why does this depend on TWL4030_CORE or PM?

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

* Re: [PATCHv3 3/6] regulator: omap smps regulator driver
  2011-07-19 15:38   ` Mark Brown
@ 2011-07-19 15:52     ` Tero Kristo
  0 siblings, 0 replies; 22+ messages in thread
From: Tero Kristo @ 2011-07-19 15:52 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-omap, Hilman, Kevin, tony, toddpoynor, Girdwood, Liam

On Tue, 2011-07-19 at 17:38 +0200, Mark Brown wrote:
> On Mon, Jul 18, 2011 at 08:35:19PM +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.
> 
> 
> > +config REGULATOR_OMAP_SMPS
> > +	tristate "TI OMAP SMPS Power Regulators"
> > +	depends on (ARCH_OMAP3 || ARCH_OMAP4) && PM && TWL4030_CORE
> 
> Why does this depend on TWL4030_CORE or PM?

Oh forgot that one, TWL_CORE can be removed, PM must be there because
the depending libraries are only built when PM is enabled.



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


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

end of thread, other threads:[~2011-07-19 15:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-18 17:35 [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo
2011-07-18 17:35 ` [PATCHv3 1/6] OMAP: move voltage.h and vp.h under platform include directory Tero Kristo
2011-07-18 18:16   ` Felipe Balbi
2011-07-19  7:49     ` Tero Kristo
2011-07-18 23:45   ` Kevin Hilman
2011-07-18 17:35 ` [PATCHv3 2/6] omap: voltage: change code to use new location of voltage.h and vp.h Tero Kristo
2011-07-18 18:16   ` Felipe Balbi
2011-07-19  7:47     ` Tero Kristo
2011-07-18 17:35 ` [PATCHv3 3/6] regulator: omap smps regulator driver Tero Kristo
2011-07-18 18:22   ` Felipe Balbi
2011-07-18 23:40     ` Kevin Hilman
2011-07-19  7:53       ` Tero Kristo
2011-07-19  7:58     ` Tero Kristo
2011-07-19 10:28   ` Graeme Gregory
2011-07-19 15:38   ` Mark Brown
2011-07-19 15:52     ` Tero Kristo
2011-07-18 17:35 ` [PATCHv3 4/6] omap3: pmic: add API to get common SMPS regulators Tero Kristo
2011-07-18 18:23   ` Felipe Balbi
2011-07-19  8:07     ` Tero Kristo
2011-07-18 17:35 ` [PATCHv3 5/6] omap3: beagleboard: add " Tero Kristo
2011-07-18 17:35 ` [PATCHv3 6/6] TEMP: OMAP3: beagle rev-c4: enable OPP6 Tero Kristo
2011-07-18 17:55 ` [PATCHv3 0/6] OMAP SMPS regulator driver Tero Kristo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox