Skip to contentSkip to conversation

OMAP3: Adding Smartreflex and Voltage driver support

PATCH Superseded Thara Gopinath 4 participants 31 messages Oct 27, 2010 – Dec 9, 2010 3 messages not in the archive

Subsystems (6)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover OMAP3: Adding Smartreflex and Voltage driver support

This patch series introduces smartreflex and voltage driver support for OMAP3430 and OMAP3630. SmartReflex modules do adaptive voltage control for real-time voltage adjustments.

Originally all the functionalities introduced in this patch were present in arch/arm/mach-omap2/smartreflex.c file in Kevin's pm tree. This patch series does a major rewrite of this file and introduces a separate voltage driver. Major contributors to the original driver are

Eduardo Valentin (1):
OMAP3: PM: SmartReflex: Fix scheduled while atomic problem

Kalle Jokiniemi (1):
OMAP3: PM: SmartReflex driver integration

Kevin Hilman (2):
temp: SR: IO_ADDRESS conversion
OMAP: SR: OPP interfaces removed from OMAP PM layer

Nishanth Menon (1):
omap3: pm: sr: replace get_opp with freq_to_opp

Paul Walmsley (2):
OMAP SR: use opp_find_opp_by_opp_id()
OMAP SR: use OPP API for OPP ID, remove direct access

Phil Carmody (2):
OMAP3: PM: Don't do unnecessary searches in omap_sr_vdd*_autocomp_store
OMAP3: PM: Early exit on invalid parameters

Rajendra Nayak (9):
OMAP3: SR: Fix init voltage on OPP change
OMAP3: SR: Update VDD1/2 voltages at boot
OMAP3: SR: Use sysclk for SR CLKLENGTH calc
OMAP3: SR: Reset voltage level on SR disable
OMAP3: SR: Replace printk's with pr_* calls
OMAP3: SR: Remove redundant defines
OMAP3: SR: Fix SR driver to check for omap-pm return values
OMAP3: PM: Put optimal SMPS stabilization delay
OMAP3: SR: Wait for VP idle before a VP disable

Roger Quadros (4):
OMAP3: PM: Fix Smartreflex when used with PM_NOOP layer
OMAP3: PM: Make Smartreflex driver independent of SRF
OMAP3: PM: Do not Enable SmartReflex if OPP tables not defined
OMAP3: PM: Smartreflex: Fix VDD2 OPP determining logic

Romit Dasgupta (1):
omap: pm: SR: use enum for OPP types

Teerth Reddy (1):
OMAP3: SR: Replace SR_PASS/FAIL,SR_TRUE/FALSE

Tero Kristo (1):
Smartreflex: Avoid unnecessary spam

This patch series is based against lo-master with the following additional patches applied.

	https://patchwork.kernel.org/patch/266911/
	https://patchwork.kernel.org/patch/266921/
	https://patchwork.kernel.org/patch/266931/
	https://patchwork.kernel.org/patch/183712/
	https://patchwork.kernel.org/patch/285872/

The entire series with the dependencies are available at
http://dev.omapzoom.org/?p=thara/omap-dvfs.git;a=summary
head: thara-pm-sr

This patch series has been tested on OMAP3430 SDP with omap2plus_defconfig with the following menuconfig options enabled.
System type -> TI OMAP Implementations -> Smartreflex Support System type -> TI OMAP Implementations ->
Class 3 mode of Smartreflex Implementation

Thara Gopinath (9):
OMAP3: PM: Adding voltage driver support for OMAP3
OMAP3: PM: Adding smartreflex driver support.
OMAP3: PM: Adding smartreflex device file.
OMAP3: PM: Adding smartreflex hwmod data
OMAP3: PM: Adding smartreflex class3 driver
OMAP3: PM: Adding T2 enabling of smartreflex support
OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers
OMAP3: PM: Program correct init voltages for VDD1 and VDD2
OMAP3: PM: Register TWL4030 pmic info with the voltage driver.

 arch/arm/mach-omap2/Makefile                  |    5 +-
 arch/arm/mach-omap2/control.h                 |   27 +
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c    |  249 +++++
 arch/arm/mach-omap2/pm.c                      |   68 ++
 arch/arm/mach-omap2/smartreflex-class3.c      |   59 ++
 arch/arm/mach-omap2/smartreflex.c             | 1005 ++++++++++++++++++
 arch/arm/mach-omap2/sr_device.c               |  177 ++++
 arch/arm/mach-omap2/voltage.c                 | 1369 +++++++++++++++++++++++++
 arch/arm/plat-omap/Kconfig                    |   45 +
 arch/arm/plat-omap/include/plat/smartreflex.h |  271 +++++
 arch/arm/plat-omap/include/plat/voltage.h     |  142 +++
 arch/arm/plat-omap/opp_twl_tps.c              |   17 +
 drivers/mfd/twl-core.c                        |    7 +-
 drivers/mfd/twl4030-power.c                   |   29 +
 include/linux/i2c/twl.h                       |    1 +
 15 files changed, 3468 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-omap2/smartreflex-class3.c
 create mode 100644 arch/arm/mach-omap2/smartreflex.c
 create mode 100644 arch/arm/mach-omap2/sr_device.c
 create mode 100644 arch/arm/mach-omap2/voltage.c
 create mode 100644 arch/arm/plat-omap/include/plat/smartreflex.h
 create mode 100644 arch/arm/plat-omap/include/plat/voltage.h
#1 lore raw

PATCH v4 1/9 OMAP3: PM: Adding voltage driver support for OMAP3

This patch adds voltage driver support for OMAP3. The driver allows configuring the voltage controller and voltage processors during init and exports APIs to enable/disable voltage processors, scale voltage and reset voltage. The driver also maintains the global voltage table on a per VDD basis which contains the various voltages supported by the VDD along with per voltage dependent data like smartreflex n-target value, errminlimit and voltage processor errorgain. The driver allows scaling of VDD voltages either through "vc bypass method" or through "vp forceupdate method" the choice being configurable through the board file.

This patch contains code originally in linux omap pm branch smartreflex driver. Major contributors to this driver are Lesly A M, Rajendra Nayak, Kalle Jokiniemi, Paul Walmsley, Nishant Menon, Kevin Hilman.

---
 arch/arm/mach-omap2/Makefile              |    3 +-
 arch/arm/mach-omap2/voltage.c             | 1158 +++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/voltage.h |  141 ++++
 3 files changed, 1301 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/voltage.c
 create mode 100644 arch/arm/plat-omap/include/plat/voltage.h
arch/arm/mach-omap2/Makefile +2 -1
index 0b6d9af..bfdabcc 100644
@@ -51,7 +51,8 @@ obj-$(CONFIG_ARCH_OMAP2)		+= sdrc2xxx.o
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)		+= sleep24xx.o pm_bus.o
-obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o cpuidle34xx.o pm_bus.o
+obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o voltage.o \
+					   cpuidle34xx.o pm_bus.o
 obj-$(CONFIG_ARCH_OMAP4)		+= pm44xx.o pm_bus.o
 obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
 
arch/arm/mach-omap2/voltage.c new file +1158 -0

1,158 lines not on this page · raw message

arch/arm/plat-omap/include/plat/voltage.h new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

[resend with thinned out response, since original reply was determined
to be spam by vger.kernel.org. wondering that tells me about my review style... ]

Quoted 12 lines · Thara Gopinath

This patch adds voltage driver support for OMAP3. The driver allows configuring the voltage controller and voltage processors during init and exports APIs to enable/disable voltage processors, scale voltage and reset voltage. The driver also maintains the global voltage table on a per VDD basis which contains the various voltages supported by the VDD along with per voltage dependent data like smartreflex n-target value, errminlimit and voltage processor errorgain. The driver allows scaling of VDD voltages either through "vc bypass method" or through "vp forceupdate method" the choice being configurable through the board file.

Quoted 6 lines

This patch contains code originally in linux omap pm branch smartreflex driver. Major contributors to this driver are Lesly A M, Rajendra Nayak, Kalle Jokiniemi, Paul Walmsley, Nishant Menon, Kevin Hilman.

All comments below are cut-and-paste from v3 review, and were not addressed in this update.

[...]

Quoted 32 lines
arch/arm/mach-omap2/voltage.c new file +29 -0
@@ -0,0 +1,1158 @@
+/*
+ * OMAP3/OMAP4 Voltage Management Routines
+ *
+ * Author: Thara Gopinath	<[email protected]>
+ *
+ * Copyright (C) 2007 Texas Instruments, Inc.
+ * Rajendra Nayak <[email protected]>
+ * Lesly A M <[email protected]>
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Kalle Jokiniemi
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ * Thara Gopinath <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+
+#include <plat/common.h>
+#include <plat/voltage.h>

arch/arm/mach-omap2/voltage.c line 39

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+
+#include "prm-regbits-34xx.h"
+
+#define VP_IDLE_TIMEOUT		200
+#define VP_TRANXDONE_TIMEOUT	300
+#define VOLTAGE_DIR_SIZE	16
+
+static struct dentry *voltage_dir;
+/* PRM voltage module */
+static u32 volt_mod;

There's no need for this to be a global, this should be a member of vdd_info (or the voltage domain.) That means the read/write functions will have to take an additional argument (vdd or voltdm) but that's cleaner to me.

[...]

arch/arm/mach-omap2/voltage.c line 274

Quoted 8 lines
arch/arm/mach-omap2/voltage.c new file +8 -0
+/* OMAP3 specific voltage init functions */
+/*
+ * Intializes the voltage controller registers with the PMIC and board
+ * specific parameters and voltage setup times for OMAP3. If the board
+ * file does not populate the voltage controller parameters through
+ * omap3_pm_init_vc, default values specified in vc_config is used.
+ */
+static void __init omap3_init_voltagecontroller(void)

I'd like to see consistent naming. Elsewhere in the code, things are named with either a vdd, vc or vp prefix. Let's keep that here and call this omap3_vc_init(), and for VP below, s/init_voltagecontroller/vp_init/

[...]

Quoted 7 lines
arch/arm/mach-omap2/voltage.c new file +7 -0
+	/*
+	 * Sys clk rate is require to calculate vp timeout value and
+	 * smpswaittimemin and smpswaittimemax.
+	 */
+	sys_ck = clk_get(NULL, "sys_ck");
+	if (IS_ERR(sys_ck)) {
+		pr_warning("%s: Could not get the sys clk to calculate"

arch/arm/mach-omap2/voltage.c line 382

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+			"various vdd_%s params\n", __func__, vdd->voltdm.name);
+		return;
+	}
+	sys_clk_speed = clk_get_rate(sys_ck);
+	clk_put(sys_ck);
+	/* Divide to avoid overflow */
+	sys_clk_speed /= 1000;
+
+	/* Nominal/Reset voltage of the VDD */
+	vdd->nominal_volt = vdd->curr_volt = 1200000;

This should be a #define someplace, something like OMAP3_VDDx_RESET_VOL or similar. Ideally with a TRM/doc reference to where it comes from.

I'm a little confused. Is this a hardware reset value? or a software reset value which is part of this layer.

It's a little confusing, since if this is a hardware reset voltage why does init_voltageprocessor() have to write it to the VP during init?

Even better, rather than hard code this, it would be even better if it just picked one of the nominal voltages from the volt_data table.

[...]

Quoted 17 lines
arch/arm/mach-omap2/voltage.c new file +17 -0
+/* vc_bypass_scale_voltage - VC bypass method of voltage scaling */
+static int vc_bypass_scale_voltage(struct omap_vdd_info *vdd,
+		unsigned long target_volt)
+{
+	struct omap_volt_data *volt_data;
+	u32 vc_bypass_value, vc_cmdval, vc_valid, vc_bypass_val_reg_offs;
+	u32 vp_errgain_val, vc_cmd_on_mask;
+	u32 loop_cnt = 0, retries_cnt = 0;
+	u32 smps_steps = 0, smps_delay = 0;
+	u8 vc_data_shift, vc_slaveaddr_shift, vc_regaddr_shift;
+	u8 vc_cmd_on_shift;
+	u8 target_vsel, current_vsel, sr_i2c_slave_addr;
+
+	if (cpu_is_omap34xx()) {
+		vc_cmd_on_shift = OMAP3430_VC_CMD_ON_SHIFT;
+		vc_cmd_on_mask = OMAP3430_VC_CMD_ON_MASK;
+		vc_data_shift = OMAP3430_DATA_SHIFT;

arch/arm/mach-omap2/voltage.c line 499

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+		vc_slaveaddr_shift = OMAP3430_SLAVEADDR_SHIFT;
+		vc_regaddr_shift = OMAP3430_REGADDR_SHIFT;
+		vc_valid = OMAP3430_VALID_MASK;
+		vc_bypass_val_reg_offs = OMAP3_PRM_VC_BYPASS_VAL_OFFSET;
+		sr_i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR;
+	} else {
+		pr_warning("%s: Voltage scaling not yet enabled for"
+			"this chip\n", __func__);
+		return -EINVAL;
+	}

cpu_is_* checks are only acceptable at init time. This one happens during every scale. These VC settings should be set at init time only.

Same issue with forceupdate_scale.

[...]

Quoted 46 lines
arch/arm/mach-omap2/voltage.c new file +46 -0
+/* VP force update method of voltage scaling */
+static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd,
+		unsigned long target_volt)
+{
+	struct omap_volt_data *volt_data;
+	u32 vc_cmd_on_mask, vc_cmdval, vpconfig;
+	u32 smps_steps = 0, smps_delay = 0;
+	int timeout = 0;
+	u8 target_vsel, current_vsel;
+	u8 vc_cmd_on_shift;
+	u8 prm_irqst_reg_offs, ocp_mod;
+
+	if (cpu_is_omap34xx()) {
+		vc_cmd_on_shift = OMAP3430_VC_CMD_ON_SHIFT;
+		vc_cmd_on_mask = OMAP3430_VC_CMD_ON_MASK;
+		prm_irqst_reg_offs = OMAP3_PRM_IRQSTATUS_MPU_OFFSET;
+		ocp_mod = OCP_MOD;
+	} else {
+		pr_warning("%s: Voltage scaling not yet enabled for"
+			"this chip\n", __func__);
+		return -EINVAL;
+	}
+
+	/* Get volt_data corresponding to the target_volt */
+	volt_data = omap_voltage_get_voltdata(&vdd->voltdm, target_volt);
+	if (IS_ERR(volt_data)) {
+		/*
+		 * If a match is not found but the target voltage is
+		 * is the nominal vdd voltage allow scaling
+		 */
+		if (target_volt != vdd->nominal_volt) {
+			pr_warning("%s: Unable to get voltage table for vdd_%s"
+				"during voltage scaling. Some really Wrong!",
+				__func__, vdd->voltdm.name);
+			return -ENODATA;
+		}
+		volt_data = NULL;
+	}
+
+	if (!volt_pmic_info.uv_to_vsel) {
+		pr_warning("%s: PMIC function to convert voltage in uV to"
+			"vsel not registered. Hence unable to scale voltage"
+			"for vdd_%s\n", __func__, vdd->voltdm.name);
+		return -ENODATA;
+	}
+

arch/arm/mach-omap2/voltage.c line 639

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+	target_vsel = volt_pmic_info.uv_to_vsel(target_volt);
+	current_vsel = voltage_read_reg(vdd->vp_offs.voltage);
+	smps_steps = abs(target_vsel - current_vsel);
+
+	/* Setting the ON voltage to the new target voltage */
+	vc_cmdval = voltage_read_reg(vdd->cmdval_reg);
+	vc_cmdval &= ~vc_cmd_on_mask;
+	vc_cmdval |= (target_vsel << vc_cmd_on_shift);
+	voltage_write_reg(vdd->cmdval_reg, vc_cmdval);
+

Up 'til here, this looks almost exactly like the vc_bypass version. Maybe they can be combined into a common pre-scale function?

arch/arm/mach-omap2/voltage.c line 643

Quoted 4 lines
arch/arm/mach-omap2/voltage.c new file +4 -0
+	/* Getting  vp errorgain based on the voltage */
+	if (volt_data)
+		vdd->vp_reg.vpconfig_errorgain =
+					volt_data->vp_errgain;

This also looks similar to the vc_bypass version.

After the full-series is applied, the comments are identical, but the
code is different. I suspect they should be the same though. Possibly
a good reason to have a common pre-scale function.

Quoted 77 lines
arch/arm/mach-omap2/voltage.c new file +77 -0
+
+	/*
+	 * Clear all pending TransactionDone interrupt/status. Typical latency
+	 * is <3us
+	 */
+	while (timeout++ < VP_TRANXDONE_TIMEOUT) {
+		prm_write_mod_reg(vdd->vp_reg.tranxdone_status,
+				ocp_mod, prm_irqst_reg_offs);
+		if (!(prm_read_mod_reg(ocp_mod, prm_irqst_reg_offs) &
+				vdd->vp_reg.tranxdone_status))
+				break;
+		udelay(1);
+	}
+	if (timeout >= VP_TRANXDONE_TIMEOUT) {
+		pr_warning("%s: vdd_%s TRANXDONE timeout exceeded."
+			"Voltage change aborted", __func__, vdd->voltdm.name);
+		return -ETIMEDOUT;
+	}
+
+	/* Configure for VP-Force Update */
+	vpconfig = voltage_read_reg(vdd->vp_offs.vpconfig);
+	vpconfig &= ~(vdd->vp_reg.vpconfig_initvdd |
+			vdd->vp_reg.vpconfig_forceupdate |
+			vdd->vp_reg.vpconfig_initvoltage_mask |
+			vdd->vp_reg.vpconfig_errorgain_mask);
+	vpconfig |= ((target_vsel <<
+			vdd->vp_reg.vpconfig_initvoltage_shift) |
+			(vdd->vp_reg.vpconfig_errorgain <<
+			 vdd->vp_reg.vpconfig_errorgain_shift));
+	voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+	/* Trigger initVDD value copy to voltage processor */
+	vpconfig |= vdd->vp_reg.vpconfig_initvdd;
+	voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+	/* Force update of voltage */
+	vpconfig |= vdd->vp_reg.vpconfig_forceupdate;
+	voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+	/*
+	 * Wait for TransactionDone. Typical latency is <200us.
+	 * Depends on SMPSWAITTIMEMIN/MAX and voltage change
+	 */
+	timeout = 0;
+	omap_test_timeout((prm_read_mod_reg(ocp_mod, prm_irqst_reg_offs) &
+			vdd->vp_reg.tranxdone_status),
+			VP_TRANXDONE_TIMEOUT, timeout);
+	if (timeout >= VP_TRANXDONE_TIMEOUT)
+		pr_err("%s: vdd_%s TRANXDONE timeout exceeded."
+			"TRANXDONE never got set after the voltage update\n",
+			__func__, vdd->voltdm.name);
+
+	/*
+	 * Wait for voltage to settle with SW wait-loop.
+	 * SMPS slew rate / step size. 2us added as buffer.
+	 */
+	smps_delay = ((smps_steps * volt_pmic_info.step_size) /
+			volt_pmic_info.slew_rate) + 2;
+	udelay(smps_delay);
+
+	/*
+	 * Disable TransactionDone interrupt , clear all status, clear
+	 * control registers
+	 */
+	timeout = 0;
+	while (timeout++ < VP_TRANXDONE_TIMEOUT) {
+		prm_write_mod_reg(vdd->vp_reg.tranxdone_status,
+				ocp_mod, prm_irqst_reg_offs);
+		if (!(prm_read_mod_reg(ocp_mod, prm_irqst_reg_offs) &
+				vdd->vp_reg.tranxdone_status))
+				break;
+		udelay(1);
+	}
+	if (timeout >= VP_TRANXDONE_TIMEOUT)
+		pr_warning("%s: vdd_%s TRANXDONE timeout exceeded while trying"
+			"to clear the TRANXDONE status\n",
+			__func__, vdd->voltdm.name);

arch/arm/mach-omap2/voltage.c line 730

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+
+	vpconfig = voltage_read_reg(vdd->vp_offs.vpconfig);
+	/* Clear initVDD copy trigger bit */
+	vpconfig &= ~vdd->vp_reg.vpconfig_initvdd;;
+	voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+	/* Clear force bit */
+	vpconfig &= ~vdd->vp_reg.vpconfig_forceupdate;
+	voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+	vdd->curr_volt = target_volt;

The smps_delay part and updating ->curr_volt is common to the two scale methods too. Maybe can be combined into a post-scale common function.

Quoted 3 lines
arch/arm/mach-omap2/voltage.c new file +3 -0
+
+	return 0;
+}

[...]

Quoted 6 lines
arch/arm/mach-omap2/voltage.c new file +6 -0
+void omap_vp_enable(struct voltagedomain *voltdm)
+{
+	struct omap_vdd_info *vdd;
+	u32 vpconfig;
+
+	if (!voltdm || IS_ERR(voltdm)) {

arch/arm/mach-omap2/voltage.c line 808

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+		pr_warning("%s: VDD specified does not exist!\n", __func__);
+		return;
+	}
+
+	vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
+
+	/* If VP is already enabled, do nothing. Return */
+	if (voltage_read_reg(vdd->vp_offs.vpconfig) &
+				vdd->vp_reg.vpconfig_vpenable)
+		return;

Minor: is a register access here required? Why not just keep an 'vp_enabled' flag as part of the vdd struct?

Quoted 30 lines
arch/arm/mach-omap2/voltage.c new file +30 -0
+	/*
+	 * This latching is required only if VC bypass method is used for
+	 * voltage scaling during dvfs.
+	 */
+	if (!voltscale_vpforceupdate)
+		vp_latch_vsel(vdd);
+
+	/* Enable VP */
+	vpconfig = voltage_read_reg(vdd->vp_offs.vpconfig);
+	voltage_write_reg(vdd->vp_offs.vpconfig,
+				vpconfig | vdd->vp_reg.vpconfig_vpenable);
+}
+
+/**
+ * omap_vp_disable() - API to disable a particular VP
+ * @voltdm:	pointer to the VDD whose VP is to be disabled.
+ *
+ * This API disables a particular voltage processor. Needed by the smartreflex
+ * class drivers.
+ */
+void omap_vp_disable(struct voltagedomain *voltdm)
+{
+	struct omap_vdd_info *vdd;
+	u32 vpconfig;
+	int timeout;
+
+	if (!voltdm || IS_ERR(voltdm)) {
+		pr_warning("%s: VDD specified does not exist!\n", __func__);
+		return;
+	}

arch/arm/mach-omap2/voltage.c line 848

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+
+	vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
+
+	/* If VP is already disabled, do nothing. Return */
+	if (!(voltage_read_reg(vdd->vp_offs.vpconfig) &
+				vdd->vp_reg.vpconfig_vpenable)) {
+		pr_warning("%s: Trying to disable VP for vdd_%s when"
+			"it is already disabled\n", __func__, voltdm->name);
+		return;
+	}

Same here... is a register read really needed if we can just check vdd->vp_enabled?

Quoted 33 lines
arch/arm/mach-omap2/voltage.c new file +33 -0
+
+	/* Disable VP */
+	vpconfig = voltage_read_reg(vdd->vp_offs.vpconfig);
+	vpconfig &= ~vdd->vp_reg.vpconfig_vpenable;
+	voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+	/*
+	 * Wait for VP idle Typical latency is <2us. Maximum latency is ~100us
+	 */
+	omap_test_timeout((voltage_read_reg(vdd->vp_offs.vstatus)),
+				VP_IDLE_TIMEOUT, timeout);
+
+	if (timeout >= VP_IDLE_TIMEOUT)
+		pr_warning("%s: vdd_%s idle timedout\n",
+			__func__, voltdm->name);
+	return;
+}
+
+/**
+ * omap_voltage_scale_vdd() - API to scale voltage of a particular
+ *				voltage domain.
+ * @voltdm:	pointer to the VDD which is to be scaled.
+ * @target_volt:	The target voltage of the voltage domain
+ *
+ * This API should be called by the kernel to do the voltage scaling
+ * for a particular voltage domain during dvfs or any other situation.
+ */
+int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
+		unsigned long target_volt)
+{
+	struct omap_vdd_info *vdd;
+
+	if (!voltdm || IS_ERR(voltdm)) {

arch/arm/mach-omap2/voltage.c line 891

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+		pr_warning("%s: VDD specified does not exist!\n", __func__);
+		return -EINVAL;
+	}
+
+	vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
+
+	if (voltscale_vpforceupdate)
+		return vp_forceupdate_scale_voltage(vdd, target_volt);
+	else
+		return vc_bypass_scale_voltage(vdd, target_volt);

Rather than the 'if' here, let's have a 'scale' function pointer associated with the VDD which gets updated if the method changes.

Not sure if would ever be useful, but that would also allow the scale method to be different across VDDs instead of having it global.

[...]

Quoted 4 lines
arch/arm/mach-omap2/voltage.c new file +4 -0
+void omap_change_voltscale_method(int voltscale_method)
+{
+	switch (voltscale_method) {
+	case VOLTSCALE_VPFORCEUPDATE:

arch/arm/mach-omap2/voltage.c line 945

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+		voltscale_vpforceupdate = true;
+		return;
+	case VOLTSCALE_VCBYPASS:
+		voltscale_vpforceupdate = false;
+		return;
+	default:
+		pr_warning("%s: Trying to change the method of voltage scaling"
+			"to an unsupported one!\n", __func__);
+	}
+}

And this API should be changed to take a 'vdd' and just change the 'scale' function pointer.

[...]

Kevin

#3 lore raw

RE: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

Quoted 34 lines
Quoted 34 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, November 11, 2010 12:30 AM
To: Gopinath, Thara
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

[resend with thinned out response, since original reply was determined to be spam by vger.kernel.org. wondering that tells me about my review style... ]

Quoted 17 lines · Thara Gopinath

This patch adds voltage driver support for OMAP3. The driver allows configuring the voltage controller and voltage processors during init and exports APIs to enable/disable voltage processors, scale voltage and reset voltage. The driver also maintains the global voltage table on a per VDD basis which contains the various voltages supported by the VDD along with per voltage dependent data like smartreflex n-target value, errminlimit and voltage processor errorgain. The driver allows scaling of VDD voltages either through "vc bypass method" or through "vp forceupdate method" the choice being configurable through the board file.

This patch contains code originally in linux omap pm branch smartreflex driver. Major contributors to this driver are Lesly A M, Rajendra Nayak, Kalle Jokiniemi, Paul Walmsley, Nishant Menon, Kevin Hilman.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

All comments below are cut-and-paste from v3 review, and were not addressed in this update.

Hello Kevin,

Thanks for the review. I thought I had fixed most of the v3 comments except the ones about the n-target values. Sorry if I had missed some.

Quoted 42 lines
Quoted 42 lines

[...]

Quoted 39 lines
arch/arm/mach-omap2/voltage.c new file +36 -0
@@ -0,0 +1,1158 @@
+/*
+ * OMAP3/OMAP4 Voltage Management Routines
+ *
+ * Author: Thara Gopinath  <[email protected]>
+ *
+ * Copyright (C) 2007 Texas Instruments, Inc.
+ * Rajendra Nayak <[email protected]>
+ * Lesly A M <[email protected]>
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Kalle Jokiniemi
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ * Thara Gopinath <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+
+#include <plat/common.h>
+#include <plat/voltage.h>
+
+#include "prm-regbits-34xx.h"
+
+#define VP_IDLE_TIMEOUT            200
+#define VP_TRANXDONE_TIMEOUT       300
+#define VOLTAGE_DIR_SIZE   16
+
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-omap2/voltage.c line 39

Quoted 3 lines
arch/arm/mach-omap2/voltage.c new file +3 -0
+static struct dentry *voltage_dir;
+/* PRM voltage module */
+static u32 volt_mod;

There's no need for this to be a global, this should be a member of vdd_info (or the voltage domain.) That means the read/write functions will have to take an additional argument (vdd or voltdm) but that's cleaner to me.

Ok.

Quoted 15 lines
Quoted 15 lines

[...]

arch/arm/mach-omap2/voltage.c line 274

Quoted 8 lines
arch/arm/mach-omap2/voltage.c new file +8 -0
+/* OMAP3 specific voltage init functions */
+/*
+ * Intializes the voltage controller registers with the PMIC and board
+ * specific parameters and voltage setup times for OMAP3. If the board
+ * file does not populate the voltage controller parameters through
+ * omap3_pm_init_vc, default values specified in vc_config is used.
+ */
+static void __init omap3_init_voltagecontroller(void)

I'd like to see consistent naming. Elsewhere in the code, things are named with either a vdd, vc or vp prefix. Let's keep that here and call this omap3_vc_init(), and for VP below, s/init_voltagecontroller/vp_init/

Will rename

Quoted 24 lines
Quoted 24 lines

[...]

Quoted 7 lines
arch/arm/mach-omap2/voltage.c new file +7 -0
+   /*
+    * Sys clk rate is require to calculate vp timeout value and
+    * smpswaittimemin and smpswaittimemax.
+    */
+   sys_ck = clk_get(NULL, "sys_ck");
+   if (IS_ERR(sys_ck)) {
+           pr_warning("%s: Could not get the sys clk to calculate"

arch/arm/mach-omap2/voltage.c line 382

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+                   "various vdd_%s params\n", __func__, vdd->voltdm.name);
+           return;
+   }
+   sys_clk_speed = clk_get_rate(sys_ck);
+   clk_put(sys_ck);
+   /* Divide to avoid overflow */
+   sys_clk_speed /= 1000;
+
+   /* Nominal/Reset voltage of the VDD */
+   vdd->nominal_volt = vdd->curr_volt = 1200000;

This should be a #define someplace, something like OMAP3_VDDx_RESET_VOL or similar. Ideally with a TRM/doc reference to where it comes from.

Quoted 8 lines
Quoted 8 lines

I'm a little confused. Is this a hardware reset value? or a software reset value which is part of this layer.

It's a little confusing, since if this is a hardware reset voltage why does init_voltageprocessor() have to write it to the VP during init?

Even better, rather than hard code this, it would be even better if it just picked one of the nominal voltages from the volt_data table.

Yes this is the default voltage at which the hardware will boot up.
I had to add this since some errata workarounds requires the vdd to be put to
this level even though this level might not correspond to any opp. The voltage scaling APIs get the error gain from a table corresponding to voltage and might not find an entry for this voltage and hence will fail. I do a check in the scaling APIs if not errorgain is found, is the voltage equal to nominal voltage and if yes I go ahead with the voltage scaling. Maybe I will remove this variable and allow the scaling APIs to scale voltage even if the table does not contain the entry.

Quoted 34 lines
Quoted 34 lines

[...]

Quoted 17 lines
arch/arm/mach-omap2/voltage.c new file +17 -0
+/* vc_bypass_scale_voltage - VC bypass method of voltage scaling */
+static int vc_bypass_scale_voltage(struct omap_vdd_info *vdd,
+           unsigned long target_volt)
+{
+   struct omap_volt_data *volt_data;
+   u32 vc_bypass_value, vc_cmdval, vc_valid, vc_bypass_val_reg_offs;
+   u32 vp_errgain_val, vc_cmd_on_mask;
+   u32 loop_cnt = 0, retries_cnt = 0;
+   u32 smps_steps = 0, smps_delay = 0;
+   u8 vc_data_shift, vc_slaveaddr_shift, vc_regaddr_shift;
+   u8 vc_cmd_on_shift;
+   u8 target_vsel, current_vsel, sr_i2c_slave_addr;
+
+   if (cpu_is_omap34xx()) {
+           vc_cmd_on_shift = OMAP3430_VC_CMD_ON_SHIFT;
+           vc_cmd_on_mask = OMAP3430_VC_CMD_ON_MASK;
+           vc_data_shift = OMAP3430_DATA_SHIFT;

arch/arm/mach-omap2/voltage.c line 499

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+           vc_slaveaddr_shift = OMAP3430_SLAVEADDR_SHIFT;
+           vc_regaddr_shift = OMAP3430_REGADDR_SHIFT;
+           vc_valid = OMAP3430_VALID_MASK;
+           vc_bypass_val_reg_offs = OMAP3_PRM_VC_BYPASS_VAL_OFFSET;
+           sr_i2c_slave_addr = OMAP3_SRI2C_SLAVE_ADDR;
+   } else {
+           pr_warning("%s: Voltage scaling not yet enabled for"
+                   "this chip\n", __func__);
+           return -EINVAL;
+   }

cpu_is_* checks are only acceptable at init time. This one happens during every scale. These VC settings should be set at init time only.

Quoted 1 line
Quoted 1 line

Same issue with forceupdate_scale.

These masks are needed only in vc bypass voltage scaling API. I was thinking that for using in just one API I need not maintain these variables in the generic vdd structure. But yes this will add a cpu_is_* check in this API. Is it preferred to have these variables defined in the common vdd structures and populated during init even if used only in one API?

Quoted 68 lines
Quoted 68 lines

[...]

Quoted 46 lines
arch/arm/mach-omap2/voltage.c new file +46 -0
+/* VP force update method of voltage scaling */
+static int vp_forceupdate_scale_voltage(struct omap_vdd_info *vdd,
+           unsigned long target_volt)
+{
+   struct omap_volt_data *volt_data;
+   u32 vc_cmd_on_mask, vc_cmdval, vpconfig;
+   u32 smps_steps = 0, smps_delay = 0;
+   int timeout = 0;
+   u8 target_vsel, current_vsel;
+   u8 vc_cmd_on_shift;
+   u8 prm_irqst_reg_offs, ocp_mod;
+
+   if (cpu_is_omap34xx()) {
+           vc_cmd_on_shift = OMAP3430_VC_CMD_ON_SHIFT;
+           vc_cmd_on_mask = OMAP3430_VC_CMD_ON_MASK;
+           prm_irqst_reg_offs = OMAP3_PRM_IRQSTATUS_MPU_OFFSET;
+           ocp_mod = OCP_MOD;
+   } else {
+           pr_warning("%s: Voltage scaling not yet enabled for"
+                   "this chip\n", __func__);
+           return -EINVAL;
+   }
+
+   /* Get volt_data corresponding to the target_volt */
+   volt_data = omap_voltage_get_voltdata(&vdd->voltdm, target_volt);
+   if (IS_ERR(volt_data)) {
+           /*
+            * If a match is not found but the target voltage is
+            * is the nominal vdd voltage allow scaling
+            */
+           if (target_volt != vdd->nominal_volt) {
+                   pr_warning("%s: Unable to get voltage table for vdd_%s"
+                           "during voltage scaling. Some really Wrong!",
+                           __func__, vdd->voltdm.name);
+                   return -ENODATA;
+           }
+           volt_data = NULL;
+   }
+
+   if (!volt_pmic_info.uv_to_vsel) {
+           pr_warning("%s: PMIC function to convert voltage in uV to"
+                   "vsel not registered. Hence unable to scale voltage"
+                   "for vdd_%s\n", __func__, vdd->voltdm.name);
+           return -ENODATA;
+   }
+

arch/arm/mach-omap2/voltage.c line 639

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+   target_vsel = volt_pmic_info.uv_to_vsel(target_volt);
+   current_vsel = voltage_read_reg(vdd->vp_offs.voltage);
+   smps_steps = abs(target_vsel - current_vsel);
+
+   /* Setting the ON voltage to the new target voltage */
+   vc_cmdval = voltage_read_reg(vdd->cmdval_reg);
+   vc_cmdval &= ~vc_cmd_on_mask;
+   vc_cmdval |= (target_vsel << vc_cmd_on_shift);
+   voltage_write_reg(vdd->cmdval_reg, vc_cmdval);
+

Up 'til here, this looks almost exactly like the vc_bypass version. Maybe they can be combined into a common pre-scale function?

Quoted 4 lines
arch/arm/mach-omap2/voltage.c new file +4 -0
+   /* Getting  vp errorgain based on the voltage */
+   if (volt_data)
+           vdd->vp_reg.vpconfig_errorgain =
+                                   volt_data->vp_errgain;
Quoted 5 lines
Quoted 5 lines

This also looks similar to the vc_bypass version.

After the full-series is applied, the comments are identical, but the
code is different. I suspect they should be the same though. Possibly
a good reason to have a common pre-scale function.

I will try combining into a common pre-scale fn. Not sure how many of these steps are common but will give it a try for sure

Quoted 83 lines
Quoted 83 lines
Quoted 83 lines
arch/arm/mach-omap2/voltage.c new file +82 -0
+
+   /*
+    * Clear all pending TransactionDone interrupt/status. Typical latency
+    * is <3us
+    */
+   while (timeout++ < VP_TRANXDONE_TIMEOUT) {
+           prm_write_mod_reg(vdd->vp_reg.tranxdone_status,
+                           ocp_mod, prm_irqst_reg_offs);
+           if (!(prm_read_mod_reg(ocp_mod, prm_irqst_reg_offs) &
+                           vdd->vp_reg.tranxdone_status))
+                           break;
+           udelay(1);
+   }
+   if (timeout >= VP_TRANXDONE_TIMEOUT) {
+           pr_warning("%s: vdd_%s TRANXDONE timeout exceeded."
+                   "Voltage change aborted", __func__, vdd->voltdm.name);
+           return -ETIMEDOUT;
+   }
+
+   /* Configure for VP-Force Update */
+   vpconfig = voltage_read_reg(vdd->vp_offs.vpconfig);
+   vpconfig &= ~(vdd->vp_reg.vpconfig_initvdd |
+                   vdd->vp_reg.vpconfig_forceupdate |
+                   vdd->vp_reg.vpconfig_initvoltage_mask |
+                   vdd->vp_reg.vpconfig_errorgain_mask);
+   vpconfig |= ((target_vsel <<
+                   vdd->vp_reg.vpconfig_initvoltage_shift) |
+                   (vdd->vp_reg.vpconfig_errorgain <<
+                    vdd->vp_reg.vpconfig_errorgain_shift));
+   voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+   /* Trigger initVDD value copy to voltage processor */
+   vpconfig |= vdd->vp_reg.vpconfig_initvdd;
+   voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+   /* Force update of voltage */
+   vpconfig |= vdd->vp_reg.vpconfig_forceupdate;
+   voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+   /*
+    * Wait for TransactionDone. Typical latency is <200us.
+    * Depends on SMPSWAITTIMEMIN/MAX and voltage change
+    */
+   timeout = 0;
+   omap_test_timeout((prm_read_mod_reg(ocp_mod, prm_irqst_reg_offs) &
+                   vdd->vp_reg.tranxdone_status),
+                   VP_TRANXDONE_TIMEOUT, timeout);
+   if (timeout >= VP_TRANXDONE_TIMEOUT)
+           pr_err("%s: vdd_%s TRANXDONE timeout exceeded."
+                   "TRANXDONE never got set after the voltage update\n",
+                   __func__, vdd->voltdm.name);
+
+   /*
+    * Wait for voltage to settle with SW wait-loop.
+    * SMPS slew rate / step size. 2us added as buffer.
+    */
+   smps_delay = ((smps_steps * volt_pmic_info.step_size) /
+                   volt_pmic_info.slew_rate) + 2;
+   udelay(smps_delay);
+
+   /*
+    * Disable TransactionDone interrupt , clear all status, clear
+    * control registers
+    */
+   timeout = 0;
+   while (timeout++ < VP_TRANXDONE_TIMEOUT) {
+           prm_write_mod_reg(vdd->vp_reg.tranxdone_status,
+                           ocp_mod, prm_irqst_reg_offs);
+           if (!(prm_read_mod_reg(ocp_mod, prm_irqst_reg_offs) &
+                           vdd->vp_reg.tranxdone_status))
+                           break;
+           udelay(1);
+   }
+   if (timeout >= VP_TRANXDONE_TIMEOUT)
+           pr_warning("%s: vdd_%s TRANXDONE timeout exceeded while trying"
+                   "to clear the TRANXDONE status\n",
+                   __func__, vdd->voltdm.name);
+
+   vpconfig = voltage_read_reg(vdd->vp_offs.vpconfig);
+   /* Clear initVDD copy trigger bit */
+   vpconfig &= ~vdd->vp_reg.vpconfig_initvdd;;
+   voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-omap2/voltage.c line 730

Quoted 5 lines
arch/arm/mach-omap2/voltage.c new file +5 -0
+   /* Clear force bit */
+   vpconfig &= ~vdd->vp_reg.vpconfig_forceupdate;
+   voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+   vdd->curr_volt = target_volt;

The smps_delay part and updating ->curr_volt is common to the two scale methods too. Maybe can be combined into a post-scale common function.

Will do this.

Quoted 18 lines
Quoted 18 lines
Quoted 4 lines
arch/arm/mach-omap2/voltage.c new file +3 -0
+
+   return 0;
+}

[...]

Quoted 11 lines
arch/arm/mach-omap2/voltage.c new file +11 -0
+void omap_vp_enable(struct voltagedomain *voltdm)
+{
+   struct omap_vdd_info *vdd;
+   u32 vpconfig;
+
+   if (!voltdm || IS_ERR(voltdm)) {
+           pr_warning("%s: VDD specified does not exist!\n", __func__);
+           return;
+   }
+
+   vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-omap2/voltage.c line 808

Quoted 5 lines
arch/arm/mach-omap2/voltage.c new file +5 -0
+
+   /* If VP is already enabled, do nothing. Return */
+   if (voltage_read_reg(vdd->vp_offs.vpconfig) &
+                           vdd->vp_reg.vpconfig_vpenable)
+           return;

Minor: is a register access here required? Why not just keep an 'vp_enabled' flag as part of the vdd struct?

I do not want to have the complications of maintaining a flag and ensuring exclusivity. But do you think having a register read here is bad? Latency cannot be much as it is a single register read. If you really think we should have a flag, I can change it.

Quoted 93 lines
Quoted 93 lines
Quoted 9 lines
arch/arm/mach-omap2/voltage.c new file +8 -0
+   /*
+    * This latching is required only if VC bypass method is used for
+    * voltage scaling during dvfs.
+    */
+   if (!voltscale_vpforceupdate)
+           vp_latch_vsel(vdd);
+
+   /* Enable VP */

arch/arm/mach-omap2/voltage.c

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+   vpconfig = voltage_read_reg(vdd->vp_offs.vpconfig);
+   voltage_write_reg(vdd->vp_offs.vpconfig,
+                           vpconfig | vdd->vp_reg.vpconfig_vpenable);
+}
+
+/**
+ * omap_vp_disable() - API to disable a particular VP
+ * @voltdm:        pointer to the VDD whose VP is to be disabled.
+ *
+ * This API disables a particular voltage processor. Needed by the

smartreflex

Quoted 12 lines

+ * class drivers.
+ */

arch/arm/mach-omap2/voltage.c new file +10 -0
+void omap_vp_disable(struct voltagedomain *voltdm)
+{
+   struct omap_vdd_info *vdd;
+   u32 vpconfig;
+   int timeout;
+
+   if (!voltdm || IS_ERR(voltdm)) {
+           pr_warning("%s: VDD specified does not exist!\n", __func__);
+           return;
+   }

arch/arm/mach-omap2/voltage.c line 848

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+
+   vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
+
+   /* If VP is already disabled, do nothing. Return */
+   if (!(voltage_read_reg(vdd->vp_offs.vpconfig) &
+                           vdd->vp_reg.vpconfig_vpenable)) {
+           pr_warning("%s: Trying to disable VP for vdd_%s when"
+                   "it is already disabled\n", __func__, voltdm->name);
+           return;
+   }

Same here... is a register read really needed if we can just check vdd->vp_enabled?

Quoted 33 lines
arch/arm/mach-omap2/voltage.c new file +33 -0
+
+   /* Disable VP */
+   vpconfig = voltage_read_reg(vdd->vp_offs.vpconfig);
+   vpconfig &= ~vdd->vp_reg.vpconfig_vpenable;
+   voltage_write_reg(vdd->vp_offs.vpconfig, vpconfig);
+
+   /*
+    * Wait for VP idle Typical latency is <2us. Maximum latency is ~100us
+    */
+   omap_test_timeout((voltage_read_reg(vdd->vp_offs.vstatus)),
+                           VP_IDLE_TIMEOUT, timeout);
+
+   if (timeout >= VP_IDLE_TIMEOUT)
+           pr_warning("%s: vdd_%s idle timedout\n",
+                   __func__, voltdm->name);
+   return;
+}
+
+/**
+ * omap_voltage_scale_vdd() - API to scale voltage of a particular
+ *                         voltage domain.
+ * @voltdm:        pointer to the VDD which is to be scaled.
+ * @target_volt:   The target voltage of the voltage domain
+ *
+ * This API should be called by the kernel to do the voltage scaling
+ * for a particular voltage domain during dvfs or any other situation.
+ */
+int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
+           unsigned long target_volt)
+{
+   struct omap_vdd_info *vdd;
+
+   if (!voltdm || IS_ERR(voltdm)) {

arch/arm/mach-omap2/voltage.c line 891

Quoted 10 lines
arch/arm/mach-omap2/voltage.c new file +10 -0
+           pr_warning("%s: VDD specified does not exist!\n", __func__);
+           return -EINVAL;
+   }
+
+   vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
+
+   if (voltscale_vpforceupdate)
+           return vp_forceupdate_scale_voltage(vdd, target_volt);
+   else
+           return vc_bypass_scale_voltage(vdd, target_volt);

Rather than the 'if' here, let's have a 'scale' function pointer associated with the VDD which gets updated if the method changes.

Quoted 2 lines
Quoted 2 lines

Not sure if would ever be useful, but that would also allow the scale method to be different across VDDs instead of having it global.

Sounds good to me. Only we will be maintaining a fn ptr per vdd basis for scaling the vdd. But then it is ok.

Quoted 12 lines
Quoted 12 lines

[...]

Quoted 9 lines
arch/arm/mach-omap2/voltage.c new file +9 -0
+void omap_change_voltscale_method(int voltscale_method)
+{
+   switch (voltscale_method) {
+   case VOLTSCALE_VPFORCEUPDATE:
+           voltscale_vpforceupdate = true;
+           return;
+   case VOLTSCALE_VCBYPASS:
+           voltscale_vpforceupdate = false;
+           return;
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-omap2/voltage.c line 945

Quoted 5 lines
arch/arm/mach-omap2/voltage.c new file +5 -0
+   default:
+           pr_warning("%s: Trying to change the method of voltage scaling"
+                   "to an unsupported one!\n", __func__);
+   }
+}

And this API should be changed to take a 'vdd' and just change the 'scale' function pointer.

Ok.

Regards
Thara

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

RE: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

Quoted 287 lines
Quoted 287 lines

-----Original Message-----
From: Sripathy, Vishwanath
Sent: Thursday, November 11, 2010 11:30 AM
To: Gopinath, Thara; [email protected]
Cc: [email protected]; [email protected]; Cousson, Benoit; Sawant, Anand
Subject: RE: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

Thara,

Quoted 274 lines

-----Original Message-----
From: Gopinath, Thara
Sent: Wednesday, October 27, 2010 9:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand; Gopinath, Thara
Subject: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

This patch adds voltage driver support for OMAP3. The driver allows configuring the voltage controller and voltage processors during init and exports APIs to enable/disable voltage processors, scale voltage and reset voltage. The driver also maintains the global voltage table on a per VDD basis which contains the various voltages supported by the VDD along with per voltage dependent data like smartreflex n-target value, errminlimit and voltage processor errorgain. The driver allows scaling of VDD voltages either through "vc bypass method" or through "vp forceupdate method" the choice being configurable through the board file.

This patch contains code originally in linux omap pm branch smartreflex driver. Major contributors to this driver are Lesly A M, Rajendra Nayak, Kalle Jokiniemi, Paul Walmsley, Nishant Menon, Kevin Hilman.

---
 arch/arm/mach-omap2/Makefile              |    3 +-
 arch/arm/mach-omap2/voltage.c             | 1158
+++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/voltage.h |  141 ++++
 3 files changed, 1301 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/voltage.c
 create mode 100644 arch/arm/plat-omap/include/plat/voltage.h
arch/arm/mach- renamed from arch/arm/mach-omap2/Makefile +0 -0

omap2/Makefile
index 0b6d9af..bfdabcc 100644

arch/arm/mach-omap2/Makefile +0 -0
@@ -51,7 +51,8 @@ obj-$(CONFIG_ARCH_OMAP2)		+=

sdrc2xxx.o
ifeq ($(CONFIG_PM),y)
obj-$(CONFIG_ARCH_OMAP2) += pm24xx.o
obj-$(CONFIG_ARCH_OMAP2) += sleep24xx.o pm_bus.o
-obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o
cpuidle34xx.o pm_bus.o
+obj-$(CONFIG_ARCH_OMAP3) += pm34xx.o sleep34xx.o
voltage.o \

arch/arm/mach-omap2/Makefile +1 -0
+					   cpuidle34xx.o pm_bus.o
 obj-$(CONFIG_ARCH_OMAP4)		+= pm44xx.o pm_bus.o
 obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
arch/arm/mach- renamed from arch/arm/mach-omap2/voltage.c +0 -0

omap2/voltage.c
new file mode 100644
index 0000000..5aa5109

arch/arm/mach-omap2/voltage.c new file +88 -0
@@ -0,0 +1,1158 @@
+/*
+ * OMAP3/OMAP4 Voltage Management Routines
+ *
+ * Author: Thara Gopinath	<[email protected]>
+ *
+ * Copyright (C) 2007 Texas Instruments, Inc.
+ * Rajendra Nayak <[email protected]>
+ * Lesly A M <[email protected]>
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Kalle Jokiniemi
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ * Thara Gopinath <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+
+#include <plat/common.h>
+#include <plat/voltage.h>
+
+#include "prm-regbits-34xx.h"
+
+#define VP_IDLE_TIMEOUT		200
+#define VP_TRANXDONE_TIMEOUT	300
+#define VOLTAGE_DIR_SIZE	16
+
+static struct dentry *voltage_dir;
+/* PRM voltage module */
+static u32 volt_mod;
+
+/* Voltage processor register offsets */
+struct vp_reg_offs {
+	u8 vpconfig;
+	u8 vstepmin;
+	u8 vstepmax;
+	u8 vlimitto;
+	u8 vstatus;
+	u8 voltage;
+};
+
+/* Voltage Processor bit field values, shifts and masks */
+struct vp_reg_val {
+	/* VPx_VPCONFIG */
+	u32 vpconfig_erroroffset;
+	u16 vpconfig_errorgain;
+	u32 vpconfig_errorgain_mask;
+	u8 vpconfig_errorgain_shift;
+	u32 vpconfig_initvoltage_mask;
+	u8 vpconfig_initvoltage_shift;
+	u32 vpconfig_timeouten;
+	u32 vpconfig_initvdd;
+	u32 vpconfig_forceupdate;
+	u32 vpconfig_vpenable;
+	/* VPx_VSTEPMIN */
+	u8 vstepmin_stepmin;
+	u16 vstepmin_smpswaittimemin;
+	u8 vstepmin_stepmin_shift;
+	u8 vstepmin_smpswaittimemin_shift;
+	/* VPx_VSTEPMAX */
+	u8 vstepmax_stepmax;
+	u16 vstepmax_smpswaittimemax;
+	u8 vstepmax_stepmax_shift;
+	u8 vstepmax_smpswaittimemax_shift;
+	/* VPx_VLIMITTO */
+	u16 vlimitto_vddmin;
+	u16 vlimitto_vddmax;
+	u16 vlimitto_timeout;
+	u16 vlimitto_vddmin_shift;
+	u16 vlimitto_vddmax_shift;
+	u16 vlimitto_timeout_shift;
+	/* PRM_IRQSTATUS*/
+	u32 tranxdone_status;
+};
+
+/**
+ * omap_vdd_info - Per Voltage Domain info
+ *
+ * @volt_data		: voltage table having the distinct voltages

supported
+ * by the domain and other associated per voltage
data.
+ * @vp_offs : structure containing the offsets for various
+ * vp registers
+ * @vp_reg : the register values, shifts, masks for various
+ * vp registers
+ * @voltdm : pointer to the voltage domain structure
+ * @debug_dir : debug directory for this voltage domain.
+ * @volt_data_count : number of distinct voltages supported by
this vdd.
+ * @nominal_volt : nominal voltage for this vdd.
+ * @curr_volt : current voltage for this vdd;
+ * cmdval_reg : voltage controller cmdval register.
+ * @vdd_sr_reg : the smartreflex register associated with
this VDD.
+ */

arch/arm/mach-omap2/voltage.c new file +26 -0
+struct omap_vdd_info{
+	struct omap_volt_data *volt_data;
+	struct vp_reg_offs vp_offs;
+	struct vp_reg_val vp_reg;
+	struct voltagedomain voltdm;
+	struct dentry *debug_dir;
+	int volt_data_count;
+	u32 nominal_volt;
+	u32 curr_volt;
+	u8 cmdval_reg;
+	u8 vdd_sr_reg;
+};
+
+static struct omap_vdd_info *vdd_info;
+/*
+ * Number of scalable voltage domains.
+ */
+static int nr_scalable_vdd;
+
+/* OMAP3 VDD sturctures */
+static struct omap_vdd_info omap3_vdd_info[] = {
+	{
+		.vp_offs = {
+			.vpconfig = OMAP3_PRM_VP1_CONFIG_OFFSET,
+			.vstepmin = OMAP3_PRM_VP1_VSTEPMIN_OFFSET,
+			.vstepmax =

OMAP3_PRM_VP1_VSTEPMAX_OFFSET,

arch/arm/mach-omap2/voltage.c new file +13 -0
+			.vlimitto = OMAP3_PRM_VP1_VLIMITTO_OFFSET,
+			.vstatus = OMAP3_PRM_VP1_STATUS_OFFSET,
+			.voltage = OMAP3_PRM_VP1_VOLTAGE_OFFSET,
+		},
+		.voltdm = {
+			.name = "mpu",
+		},
+	},
+	{
+		.vp_offs = {
+			.vpconfig = OMAP3_PRM_VP2_CONFIG_OFFSET,
+			.vstepmin = OMAP3_PRM_VP2_VSTEPMIN_OFFSET,
+			.vstepmax =

OMAP3_PRM_VP2_VSTEPMAX_OFFSET,

arch/arm/mach-omap2/voltage.c new file +43 -0
+			.vlimitto = OMAP3_PRM_VP2_VLIMITTO_OFFSET,
+			.vstatus = OMAP3_PRM_VP2_STATUS_OFFSET,
+			.voltage = OMAP3_PRM_VP2_VOLTAGE_OFFSET,
+		},
+		.voltdm = {
+			.name = "core",
+		},
+	},
+};
+
+#define OMAP3_NR_SCALABLE_VDD ARRAY_SIZE(omap3_vdd_info)
+
+/* TODO: OMAP4 register offsets */
+
+/*
+ * Default voltage controller settings.
+ */
+static struct omap_volt_vc_data vc_config = {
+	.clksetup = 0xff,
+	.voltsetup_time1 = 0xfff,
+	.voltsetup_time2 = 0xfff,
+	.voltoffset = 0xff,
+	.voltsetup2 = 0xff,
+	.vdd0_on = 0x30,        /* 1.2v */
+	.vdd0_onlp = 0x20,      /* 1.0v */
+	.vdd0_ret = 0x1e,       /* 0.975v */
+	.vdd0_off = 0x00,       /* 0.6v */
+	.vdd1_on = 0x2c,        /* 1.15v */
+	.vdd1_onlp = 0x20,      /* 1.0v */
+	.vdd1_ret = 0x1e,       /* .975v */
+	.vdd1_off = 0x00,       /* 0.6v */
+};
+
+/*
+ * Default PMIC Data
+ */
+static struct omap_volt_pmic_info volt_pmic_info = {
+	.slew_rate = 4000,
+	.step_size = 12500,
+};
+
+/*
+ * Structures containing OMAP3430/OMAP3630 voltage supported and

various
+ * data associated with it per voltage domain basis. Smartreflex Ntarget
+ * values are left as 0 as they have to be populated by smartreflex
+ * driver after reading the efuse.
+ */

arch/arm/mach-omap2/voltage.c new file +4 -0
+
+/* VDD1 */
+static struct omap_volt_data omap34xx_vdd1_volt_data[] = {
+	{.volt_nominal = 975000, .sr_errminlimit = 0xF4, .vp_errgain =

0x0C},

arch/arm/mach-omap2/voltage.c new file +1 -0
+	{.volt_nominal = 1075000, .sr_errminlimit = 0xF4, .vp_errgain =

0x0C},

arch/arm/mach-omap2/voltage.c new file +1 -0
+	{.volt_nominal = 1200000, .sr_errminlimit = 0xF9, .vp_errgain =

0x18},

arch/arm/mach-omap2/voltage.c new file +1 -0
+	{.volt_nominal = 1270000, .sr_errminlimit = 0xF9, .vp_errgain =

0x18},

arch/arm/mach-omap2/voltage.c new file +1 -0
+	{.volt_nominal = 1350000, .sr_errminlimit = 0xF9, .vp_errgain =

0x18},

arch/arm/mach-omap2/voltage.c new file +4 -0
+};
+
+static struct omap_volt_data omap36xx_vdd1_volt_data[] = {
+	{.volt_nominal = 930000, .sr_errminlimit = 0xF4, .vp_errgain =

0x0C},

arch/arm/mach-omap2/voltage.c new file +1 -0
+	{.volt_nominal = 1100000, .sr_errminlimit = 0xF9, .vp_errgain =
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

0x16},

arch/arm/mach-omap2/voltage.c new file +1 -0
+	{.volt_nominal = 1260000, .sr_errminlimit = 0xFA, .vp_errgain =

0x23},

arch/arm/mach-omap2/voltage.c new file +1 -0
+	{.volt_nominal = 1350000, .sr_errminlimit = 0xFA, .vp_errgain =

0x27},
+};

These 3630 voltage values do not mach with Values in OPP definition list (omap36xx_opp_def_list). Because of this, it fails to boot on OMP3630.

Will look into this and do the correction in the next version

Regards
Thara

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw

Re: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

Quoted 1 line · Thara
Quoted 1 line
Quoted 1 line

[...]

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

cpu_is_* checks are only acceptable at init time. This one happens during every scale. These VC settings should be set at init time only.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Same issue with forceupdate_scale.

These masks are needed only in vc bypass voltage scaling API. I was thinking that for using in just one API I need not maintain these variables in the generic vdd structure. But yes this will add a cpu_is_* check in this API. Is it preferred to have these variables defined in the common vdd structures and populated during init even if used only in one API?

Yes.

[...]

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
arch/arm/mach-omap2/voltage.c new file +11 -0
+void omap_vp_enable(struct voltagedomain *voltdm)
+{
+   struct omap_vdd_info *vdd;
+   u32 vpconfig;
+
+   if (!voltdm || IS_ERR(voltdm)) {
+           pr_warning("%s: VDD specified does not exist!\n", __func__);
+           return;
+   }
+
+   vdd = container_of(voltdm, struct omap_vdd_info, voltdm);
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-omap2/voltage.c line 808

Quoted 5 lines
arch/arm/mach-omap2/voltage.c new file +5 -0
+
+   /* If VP is already enabled, do nothing. Return */
+   if (voltage_read_reg(vdd->vp_offs.vpconfig) &
+                           vdd->vp_reg.vpconfig_vpenable)
+           return;

Minor: is a register access here required? Why not just keep an 'vp_enabled' flag as part of the vdd struct?

Quoted 2 lines

I do not want to have the complications of maintaining a flag and ensuring exclusivity.

Whether you use a flag or a register access, the ability to ensure exclusivity does not change.

Quoted 1 line

But do you think having a register read here is bad?

Yes.

s/bad/unnecessary/

Quoted 2 lines

Latency cannot be much as it is a single register read. If you really think we should have a flag, I can change it.

The PRCM is on L4, so accesses to PRCM registers are all slow and should be avoided if possible. This is an easy case where a register access can be prevented simply by caching.

Kevin

#9 lore raw

RE: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

In reply to a message not in the archive
Quoted 101 lines
Quoted 101 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, November 11, 2010 12:00 AM
To: Gopinath, Thara
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 1/9] OMAP3: PM: Adding voltage driver support for OMAP3

Quoted 12 lines · Thara Gopinath

This patch adds voltage driver support for OMAP3. The driver allows configuring the voltage controller and voltage processors during init and exports APIs to enable/disable voltage processors, scale voltage and reset voltage. The driver also maintains the global voltage table on a per VDD basis which contains the various voltages supported by the VDD along with per voltage dependent data like smartreflex n-target value, errminlimit and voltage processor errorgain. The driver allows scaling of VDD voltages either through "vc bypass method" or through "vp forceupdate method" the choice being configurable through the board file.

Quoted 6 lines

This patch contains code originally in linux omap pm branch smartreflex driver. Major contributors to this driver are Lesly A M, Rajendra Nayak, Kalle Jokiniemi, Paul Walmsley, Nishant Menon, Kevin Hilman.

All comments below are cut-and-paste from v3 review, and were not addressed in this update.

Quoted 3 lines
---
 arch/arm/mach-omap2/Makefile              |    3 +-
 arch/arm/mach-omap2/voltage.c             | 1158

+++++++++++++++++++++++++++++

Quoted 10 lines
 arch/arm/plat-omap/include/plat/voltage.h |  141 ++++
 3 files changed, 1301 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/voltage.c
 create mode 100644 arch/arm/plat-omap/include/plat/voltage.h
arch/arm/mach-omap2/Makefile +0 -0
index 0b6d9af..bfdabcc 100644

arch/arm/mach-omap2/Makefile obj-$(CONFIG_ARCH_OMAP2) += sdrc2xxx.o · line 54

Quoted 4 lines
arch/arm/mach-omap2/Makefile +0 -1
@@ -51,7 +51,8 @@ obj-$(CONFIG_ARCH_OMAP2)		+= sdrc2xxx.o
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)		+= sleep24xx.o pm_bus.o
-obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o cpuidle34xx.o

pm_bus.o

Quoted 47 lines
arch/arm/mach-omap2/Makefile +2 -0
+obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o voltage.o \
+					   cpuidle34xx.o pm_bus.o
 obj-$(CONFIG_ARCH_OMAP4)		+= pm44xx.o pm_bus.o
 obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
 
arch/arm/mach-omap2/voltage.c new file +36 -0
new file mode 100644
index 0000000..5aa5109
@@ -0,0 +1,1158 @@
+/*
+ * OMAP3/OMAP4 Voltage Management Routines
+ *
+ * Author: Thara Gopinath	<[email protected]>
+ *
+ * Copyright (C) 2007 Texas Instruments, Inc.
+ * Rajendra Nayak <[email protected]>
+ * Lesly A M <[email protected]>
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Kalle Jokiniemi
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ * Thara Gopinath <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+
+#include <plat/common.h>
+#include <plat/voltage.h>
+
+#include "prm-regbits-34xx.h"
+
+#define VP_IDLE_TIMEOUT		200
+#define VP_TRANXDONE_TIMEOUT	300
+#define VOLTAGE_DIR_SIZE	16
+
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-omap2/voltage.c line 39

Quoted 3 lines
arch/arm/mach-omap2/voltage.c new file +3 -0
+static struct dentry *voltage_dir;
+/* PRM voltage module */
+static u32 volt_mod;

There's no need for this to be a global, this should be a member of vdd_info (or the voltage domain.) That means the read/write functions will have to take an additional argument (vdd or voltdm) but that's cleaner to me.

Kevin,

The voltage_read and voltage_write APIs are used not only for the per vdd registers. We also access the vc registers through them and passing vdd or voltdm is not an option. Two options we have are
1. Keep the existing implementation
2. Have volt_mod/prm_mod per vdd basis in the omap_vdd_info struct. Introduce a new struct for storing vc parameters per SoC basis and have a prm_mod there also. Scrap voltage_read and voltage_write APIs and use prm_read and prm_write instead. The last step is because we do not want a voltage_read / voltage_write which looks exactly similar to prm_read/prm_write and do nothing but call into prm_read/prm_write.

Do let me know your thoughts as I m in the midst of the rework. I am assuming you would prefer option 2 and proceeding :-)!

Regards
Thara

#10 lore raw

PATCH v4 2/9 OMAP3: PM: Adding smartreflex driver support.

In reply to Thara Gopinath

SmartReflex modules do adaptive voltage control for real-time voltage adjustments. With Smartreflex the power supply voltage can be adapted to the silicon performance(manufacturing process, temperature induced performance, age induced performance etc).

There are differnet classes of smartreflex implementation.
Class-0: Manufacturing Test Calibration
Class-1: Boot-Time Software Calibration
Class-2: Continuous Software Calibration
Class-3: Continuous Hardware Calibration
Class-4: Fully Integrated Power Management

OMAP3 has two smartreflex modules one associated with VDD MPU and the other associated with VDD CORE.
This patch adds support for smartreflex driver. The driver is designed for Class-1 , Class-2 and Class-3 support and is a platform driver. Smartreflex driver can be enabled through a Kconfig option "SmartReflex support" under "System type"->"TI OMAP implementations" menu.

Smartreflex autocompensation feature can be enabled runtime through a debug fs option.
To enable smartreflex autocompensation feature
echo 1 > /debug/voltage/vdd_<X>/smartreflex/autocomp
To disable smartreflex autocompensation feature
echo 0 > /debug/voltage/vdd_<X>/smartreflex/autocomp

where X can be mpu, core , iva etc.

This patch contains code originally in linux omap pm branch. Major contributors to this driver are
Lesly A M, Rajendra Nayak, Kalle Jokiniemi, Paul Walmsley, Nishant Menon, Kevin Hilman.

---
 arch/arm/mach-omap2/Makefile                  |    1 +
 arch/arm/mach-omap2/smartreflex.c             |  975 +++++++++++++++++++++++++
 arch/arm/plat-omap/Kconfig                    |   36 +
 arch/arm/plat-omap/include/plat/smartreflex.h |  271 +++++++
 4 files changed, 1283 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/smartreflex.c
 create mode 100644 arch/arm/plat-omap/include/plat/smartreflex.h
arch/arm/mach-omap2/Makefile +1 -0
index bfdabcc..c97a1b5 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o voltage.o \
 					   cpuidle34xx.o pm_bus.o
 obj-$(CONFIG_ARCH_OMAP4)		+= pm44xx.o pm_bus.o
 obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
+obj-$(CONFIG_OMAP_SMARTREFLEX)          += smartreflex.o
 
 AFLAGS_sleep24xx.o			:=-Wa,-march=armv6
 AFLAGS_sleep34xx.o			:=-Wa,-march=armv7-a
arch/arm/mach-omap2/smartreflex.c new file +975 -0

975 lines not on this page · raw message

arch/arm/plat-omap/Kconfig +36 -0
index 92c5bb7..04b0bd2 100644
@@ -35,6 +35,42 @@ config OMAP_DEBUG_LEDS
 	depends on OMAP_DEBUG_DEVICES
 	default y if LEDS_CLASS
 
+config OMAP_SMARTREFLEX
+	bool "SmartReflex support"
+	depends on ARCH_OMAP3 && PM
+	help
+	  Say Y if you want to enable SmartReflex.
+
+	  SmartReflex can perform continuous dynamic voltage
+	  scaling around the nominal operating point voltage
+	  according to silicon characteristics and operating
+	  conditions. Enabling SmartReflex reduces power
+	  consumption.
+
+	  Please note, that by default SmartReflex is only
+	  initialized. To enable the automatic voltage
+	  compensation for vdd mpu  and vdd core from user space,
+	  user must write 1 to
+		/debug/voltage/vdd_<X>/smartreflex/autocomp,
+	  where X is mpu or core for OMAP3.
+	  Optionallly autocompensation can be enabled in the kernel
+	  by default during system init via the enable_on_init flag
+	  which an be passed as platform data to the smartreflex driver.
+
+config OMAP_SMARTREFLEX_TESTING
+	bool "Smartreflex testing support"
+	depends on OMAP_SMARTREFLEX
+	default n
+	help
+	  Say Y if you want to enable SmartReflex testing with SW hardcoded
+	  NVALUES intead of E-fuse NVALUES set in factory silicon testing.
+
+	  In some devices the E-fuse values have not been set, even though
+	  SmartReflex modules are included. Using these hardcoded values set
+	  in software, one can test the SmartReflex features without E-fuse.
+
+	  WARNING: Enabling this option may cause your device to hang!
+
 config OMAP_RESET_CLOCKS
 	bool "Reset unused clocks during boot"
 	depends on ARCH_OMAP
arch/arm/plat-omap/include/plat/smartreflex.h new file +271 -0

271 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#11 lore raw

PATCH v4 3/9 OMAP3: PM: Adding smartreflex device file.

In reply to Thara Gopinath

This patch adds support for device registration of various smartreflex module present in the system. This patch introduces the platform data for smartreflex devices which include the efused and test n-target vaules, module enable/disable pointers and a parameter to indicate whether smartreflex autocompensation needs to be enabled on init or not. Currently auocompensation is enabled on init by default for OMAP3430 ES3.1 chip.

---
 arch/arm/mach-omap2/Makefile    |    2 +-
 arch/arm/mach-omap2/sr_device.c |  177 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 178 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/sr_device.c
arch/arm/mach-omap2/Makefile +1 -1
index c97a1b5..42b0cc5 100644
@@ -55,7 +55,7 @@ obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o voltage.o \
 					   cpuidle34xx.o pm_bus.o
 obj-$(CONFIG_ARCH_OMAP4)		+= pm44xx.o pm_bus.o
 obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
-obj-$(CONFIG_OMAP_SMARTREFLEX)          += smartreflex.o
+obj-$(CONFIG_OMAP_SMARTREFLEX)          += sr_device.o smartreflex.o
 
 AFLAGS_sleep24xx.o			:=-Wa,-march=armv6
 AFLAGS_sleep34xx.o			:=-Wa,-march=armv7-a
arch/arm/mach-omap2/sr_device.c new file +177 -0

177 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#12 lore raw

RE: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

Thara,

Quoted 18 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Gopinath, Thara
Sent: Wednesday, October 27, 2010 9:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand; Gopinath, Thara
Subject: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

This patch adds support for device registration of various smartreflex module present in the system. This patch introduces the platform data for smartreflex devices which include the efused and test n-target vaules, module enable/disable pointers and a parameter to indicate whether smartreflex autocompensation needs to be enabled on init or not. Currently auocompensation is enabled on init by default for OMAP3430 ES3.1 chip.

Quoted 8 lines
---
 arch/arm/mach-omap2/Makefile    |    2 +-
 arch/arm/mach-omap2/sr_device.c |  177 
+++++++++++++++++++++++++++++++++++++++
 2 files changed, 178 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/sr_device.c

<<snip>>

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+static int sr_dev_init(struct omap_hwmod *oh, void *user)

Since *user is unused, you may rename it to *unused

Quoted 45 lines
arch/arm/mach-omap2/sr_device.c new file +10 -0
+{
+	struct omap_sr_data *sr_data;
+	struct omap_sr_dev_data *sr_dev_data;
+	struct omap_device *od;
+	char *name = "smartreflex";
+	static int i;
+
+	sr_data = kzalloc(sizeof(struct omap_sr_data), GFP_KERNEL);
+	if (!sr_data) {
+		pr_err("%s: Unable to allocate memory for %s 

sr_data.Error!\n",

arch/arm/mach-omap2/sr_device.c new file +23 -0
+			__func__, oh->name);
+		return -ENOMEM;
+	}
+
+	sr_dev_data = (struct omap_sr_dev_data *)oh->dev_attr;
+	if (unlikely(!sr_dev_data)) {
+		pr_err("%s: dev atrribute is NULL\n", __func__);
+		goto exit;
+	}
+
+	/*
+	 * OMAP3430 ES3.1 chips by default come with Efuse burnt
+	 * with parameters required for full functionality of
+	 * smartreflex AVS feature like ntarget values , sennenable
+	 * and senpenable. So enable the SR AVS feature during boot up
+	 * itself if it is a OMAP3430 ES3.1 chip.
+	 */
+	sr_data->enable_on_init = false;
+	if (cpu_is_omap343x())
+		if (omap_rev() == OMAP3430_REV_ES3_1)
+			sr_data->enable_on_init = true;
+
+	sr_data->voltdm = 

omap_voltage_domain_lookup(sr_dev_data->vdd_name);

(quoted diff) +2 -0
+	if (IS_ERR(sr_data->voltdm)) {
+		pr_err("%s: Unable to get voltage domain 

pointer for VDD %s\n",

arch/arm/mach-omap2/sr_device.c new file +7 -0
+			__func__, sr_dev_data->vdd_name);
+		goto exit;
+	}
+
+	sr_dev_data->volts_supported = omap_voltage_get_volttable(
+			sr_data->voltdm, &sr_dev_data->volt_data);
+	if (!sr_dev_data->volts_supported) {

arch/arm/mach-omap2/sr_device.c line 163

Quoted 10 lines
arch/arm/mach-omap2/sr_device.c new file +10 -0
+		pr_warning("%s: No Voltage table registerd fo VDD%d."
+			"Something really wrong\n\n", __func__, i + 1);
+		goto exit;
+	}
+
+	sr_set_nvalues(sr_dev_data, sr_data);
+
+	od = omap_device_build(name, i, oh, sr_data, sizeof(*sr_data),
+			       omap_sr_latency,
+			       ARRAY_SIZE(omap_sr_latency), 0);

Patch 4 should come before patch 3 in the series. Otherwise, this would fail during a git-bisect.

arch/arm/mach-omap2/sr_device.c line 166

Quoted 4 lines
(quoted diff) +2 -0
+	if (IS_ERR(od))
+		pr_warning("%s: Could not build omap_device for 

%s: %s.\n\n",

arch/arm/mach-omap2/sr_device.c new file +1 -0
+			__func__, name, oh->name);

Return error.

Quoted 21 lines
arch/arm/mach-omap2/sr_device.c new file +9 -0
+exit:
+	i++;
+	kfree(sr_data);
+	return 0;
+}
+
+static int __init omap_devinit_smartreflex(void)
+{
+	return omap_hwmod_for_each_by_class("smartreflex", 

sr_dev_init, NULL);

(quoted diff) +2 -0
+}
+device_initcall(omap_devinit_smartreflex);
Signature · 7 lines
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe 
linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

RE: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

Quoted 39 lines
Quoted 39 lines

-----Original Message-----
From: Varadarajan, Charulatha
Sent: Thursday, October 28, 2010 11:09 AM
To: Gopinath, Thara; [email protected]
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: RE: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

Thara,

Quoted 26 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Gopinath, Thara
Sent: Wednesday, October 27, 2010 9:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand; Gopinath, Thara
Subject: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

This patch adds support for device registration of various smartreflex module present in the system. This patch introduces the platform data for smartreflex devices which include the efused and test n-target vaules, module enable/disable pointers and a parameter to indicate whether smartreflex autocompensation needs to be enabled on init or not. Currently auocompensation is enabled on init by default for OMAP3430 ES3.1 chip.

---
 arch/arm/mach-omap2/Makefile    |    2 +-
 arch/arm/mach-omap2/sr_device.c |  177
+++++++++++++++++++++++++++++++++++++++
 2 files changed, 178 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/sr_device.c
Quoted 6 lines
Quoted 6 lines

<<snip>>

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+static int sr_dev_init(struct omap_hwmod *oh, void *user)

Since *user is unused, you may rename it to *unused

Ok will do.

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
arch/arm/mach-omap2/sr_device.c new file +10 -0
+{
+	struct omap_sr_data *sr_data;
+	struct omap_sr_dev_data *sr_dev_data;
+	struct omap_device *od;
+	char *name = "smartreflex";
+	static int i;
+
+	sr_data = kzalloc(sizeof(struct omap_sr_data), GFP_KERNEL);
+	if (!sr_data) {
+		pr_err("%s: Unable to allocate memory for %s

sr_data.Error!\n",

arch/arm/mach-omap2/sr_device.c new file +23 -0
+			__func__, oh->name);
+		return -ENOMEM;
+	}
+
+	sr_dev_data = (struct omap_sr_dev_data *)oh->dev_attr;
+	if (unlikely(!sr_dev_data)) {
+		pr_err("%s: dev atrribute is NULL\n", __func__);
+		goto exit;
+	}
+
+	/*
+	 * OMAP3430 ES3.1 chips by default come with Efuse burnt
+	 * with parameters required for full functionality of
+	 * smartreflex AVS feature like ntarget values , sennenable
+	 * and senpenable. So enable the SR AVS feature during boot up
+	 * itself if it is a OMAP3430 ES3.1 chip.
+	 */
+	sr_data->enable_on_init = false;
+	if (cpu_is_omap343x())
+		if (omap_rev() == OMAP3430_REV_ES3_1)
+			sr_data->enable_on_init = true;
+
+	sr_data->voltdm =

omap_voltage_domain_lookup(sr_dev_data->vdd_name);

(quoted diff) +2 -0
+	if (IS_ERR(sr_data->voltdm)) {
+		pr_err("%s: Unable to get voltage domain

pointer for VDD %s\n",

arch/arm/mach-omap2/sr_device.c new file +12 -0
+			__func__, sr_dev_data->vdd_name);
+		goto exit;
+	}
+
+	sr_dev_data->volts_supported = omap_voltage_get_volttable(
+			sr_data->voltdm, &sr_dev_data->volt_data);
+	if (!sr_dev_data->volts_supported) {
+		pr_warning("%s: No Voltage table registerd fo VDD%d."
+			"Something really wrong\n\n", __func__, i + 1);
+		goto exit;
+	}
+
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-omap2/sr_device.c line 163

Quoted 5 lines
arch/arm/mach-omap2/sr_device.c new file +5 -0
+	sr_set_nvalues(sr_dev_data, sr_data);
+
+	od = omap_device_build(name, i, oh, sr_data, sizeof(*sr_data),
+			       omap_sr_latency,
+			       ARRAY_SIZE(omap_sr_latency), 0);

Patch 4 should come before patch 3 in the series. Otherwise, this would fail during a git-bisect.

Why?? All patches individually compile and boot.

Quoted 29 lines
Quoted 29 lines

arch/arm/mach-omap2/sr_device.c line 166

Quoted 5 lines
(quoted diff) +2 -0
+	if (IS_ERR(od))
+		pr_warning("%s: Could not build omap_device for

%s: %s.\n\n",

arch/arm/mach-omap2/sr_device.c new file +1 -0
+			__func__, name, oh->name);

Return error.

Quoted 21 lines
arch/arm/mach-omap2/sr_device.c new file +9 -0
+exit:
+	i++;
+	kfree(sr_data);
+	return 0;
+}
+
+static int __init omap_devinit_smartreflex(void)
+{
+	return omap_hwmod_for_each_by_class("smartreflex",

sr_dev_init, NULL);

arch/arm/mach-omap2/sr_device.c new file +2 -1
+}
+device_initcall(omap_devinit_smartreflex);
--

1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw

RE: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

Quoted 119 lines

-----Original Message-----
From: Gopinath, Thara
Sent: Thursday, October 28, 2010 8:56 PM
To: Varadarajan, Charulatha; [email protected]
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: RE: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: Varadarajan, Charulatha
Sent: Thursday, October 28, 2010 11:09 AM
To: Gopinath, Thara; [email protected]
Cc: [email protected]; [email protected]; Cousson, Benoit;

Sripathy,

Quoted 32 lines
Quoted 32 lines

Vishwanath; Sawant, Anand
Subject: RE: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

Thara,

Quoted 26 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Gopinath, Thara
Sent: Wednesday, October 27, 2010 9:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand; Gopinath, Thara
Subject: [PATCH v4 3/9] OMAP3: PM: Adding smartreflex device file.

This patch adds support for device registration of various smartreflex module present in the system. This patch introduces the platform data for smartreflex devices which include the efused and test n-target vaules, module enable/disable pointers and a parameter to indicate whether smartreflex autocompensation needs to be enabled on init or not. Currently auocompensation is enabled on init by default for OMAP3430 ES3.1 chip.

---
 arch/arm/mach-omap2/Makefile    |    2 +-
 arch/arm/mach-omap2/sr_device.c |  177
+++++++++++++++++++++++++++++++++++++++
 2 files changed, 178 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-omap2/sr_device.c
Quoted 6 lines
Quoted 6 lines

<<snip>>

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+static int sr_dev_init(struct omap_hwmod *oh, void *user)

Since *user is unused, you may rename it to *unused

Ok will do.

Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
arch/arm/mach-omap2/sr_device.c new file +10 -0
+{
+	struct omap_sr_data *sr_data;
+	struct omap_sr_dev_data *sr_dev_data;
+	struct omap_device *od;
+	char *name = "smartreflex";
+	static int i;
+
+	sr_data = kzalloc(sizeof(struct omap_sr_data), GFP_KERNEL);
+	if (!sr_data) {
+		pr_err("%s: Unable to allocate memory for %s

sr_data.Error!\n",

arch/arm/mach-omap2/sr_device.c new file +23 -0
+			__func__, oh->name);
+		return -ENOMEM;
+	}
+
+	sr_dev_data = (struct omap_sr_dev_data *)oh->dev_attr;
+	if (unlikely(!sr_dev_data)) {
+		pr_err("%s: dev atrribute is NULL\n", __func__);
+		goto exit;
+	}
+
+	/*
+	 * OMAP3430 ES3.1 chips by default come with Efuse burnt
+	 * with parameters required for full functionality of
+	 * smartreflex AVS feature like ntarget values , sennenable
+	 * and senpenable. So enable the SR AVS feature during boot up
+	 * itself if it is a OMAP3430 ES3.1 chip.
+	 */
+	sr_data->enable_on_init = false;
+	if (cpu_is_omap343x())
+		if (omap_rev() == OMAP3430_REV_ES3_1)
+			sr_data->enable_on_init = true;
+
+	sr_data->voltdm =

omap_voltage_domain_lookup(sr_dev_data->vdd_name);

(quoted diff) +2 -0
+	if (IS_ERR(sr_data->voltdm)) {
+		pr_err("%s: Unable to get voltage domain

pointer for VDD %s\n",

arch/arm/mach-omap2/sr_device.c new file +12 -0
+			__func__, sr_dev_data->vdd_name);
+		goto exit;
+	}
+
+	sr_dev_data->volts_supported = omap_voltage_get_volttable(
+			sr_data->voltdm, &sr_dev_data->volt_data);
+	if (!sr_dev_data->volts_supported) {
+		pr_warning("%s: No Voltage table registerd fo VDD%d."
+			"Something really wrong\n\n", __func__, i + 1);
+		goto exit;
+	}
+
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-omap2/sr_device.c line 163

Quoted 5 lines
arch/arm/mach-omap2/sr_device.c new file +5 -0
+	sr_set_nvalues(sr_dev_data, sr_data);
+
+	od = omap_device_build(name, i, oh, sr_data, sizeof(*sr_data),
+			       omap_sr_latency,
+			       ARRAY_SIZE(omap_sr_latency), 0);

Patch 4 should come before patch 3 in the series. Otherwise, this would fail during a git-bisect.

Quoted 1 line

Why?? All patches individually compile and boot.

Oh data for SR is filled only in patch 4 but oh is being used here. Wouldn't that create a problem?

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines

arch/arm/mach-omap2/sr_device.c line 166

Quoted 6 lines
(quoted diff) +2 -0
+	if (IS_ERR(od))
+		pr_warning("%s: Could not build omap_device for

%s: %s.\n\n",

arch/arm/mach-omap2/sr_device.c new file +1 -0
+			__func__, name, oh->name);

Return error.

Quoted 21 lines
arch/arm/mach-omap2/sr_device.c new file +9 -0
+exit:
+	i++;
+	kfree(sr_data);
+	return 0;
+}
+
+static int __init omap_devinit_smartreflex(void)
+{
+	return omap_hwmod_for_each_by_class("smartreflex",

sr_dev_init, NULL);

arch/arm/mach-omap2/sr_device.c new file +2 -1
+}
+device_initcall(omap_devinit_smartreflex);
--

1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw

PATCH v4 4/9 OMAP3: PM: Adding smartreflex hwmod data

In reply to Thara Gopinath

This patch adds the smartreflex hwmod data for OMAP3430 and OMAP3630. A dev_attr is also added to the hwmod structure for each smartreflex module which contains SoC specific info like the efuse offsets, test n-values etc.

---
 arch/arm/mach-omap2/control.h              |   27 +++
 arch/arm/mach-omap2/omap_hwmod_3xxx_data.c |  249 ++++++++++++++++++++++++++++
 2 files changed, 276 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/control.h +27 -0
index b6c6b7c..d9b5bed 100644
@@ -148,6 +148,15 @@
 #define OMAP343X_CONTROL_TEST_KEY_11	(OMAP2_CONTROL_GENERAL + 0x00f4)
 #define OMAP343X_CONTROL_TEST_KEY_12	(OMAP2_CONTROL_GENERAL + 0x00f8)
 #define OMAP343X_CONTROL_TEST_KEY_13	(OMAP2_CONTROL_GENERAL + 0x00fc)
+#define OMAP343X_CONTROL_FUSE_OPP1_VDD1 (OMAP2_CONTROL_GENERAL + 0x0110)
+#define OMAP343X_CONTROL_FUSE_OPP2_VDD1 (OMAP2_CONTROL_GENERAL + 0x0114)
+#define OMAP343X_CONTROL_FUSE_OPP3_VDD1 (OMAP2_CONTROL_GENERAL + 0x0118)
+#define OMAP343X_CONTROL_FUSE_OPP4_VDD1 (OMAP2_CONTROL_GENERAL + 0x011c)
+#define OMAP343X_CONTROL_FUSE_OPP5_VDD1 (OMAP2_CONTROL_GENERAL + 0x0120)
+#define OMAP343X_CONTROL_FUSE_OPP1_VDD2 (OMAP2_CONTROL_GENERAL + 0x0124)
+#define OMAP343X_CONTROL_FUSE_OPP2_VDD2 (OMAP2_CONTROL_GENERAL + 0x0128)
+#define OMAP343X_CONTROL_FUSE_OPP3_VDD2 (OMAP2_CONTROL_GENERAL + 0x012c)
+#define OMAP343X_CONTROL_FUSE_SR        (OMAP2_CONTROL_GENERAL + 0x0130)
 #define OMAP343X_CONTROL_IVA2_BOOTADDR	(OMAP2_CONTROL_GENERAL + 0x0190)
 #define OMAP343X_CONTROL_IVA2_BOOTMOD	(OMAP2_CONTROL_GENERAL + 0x0194)
 #define OMAP343X_CONTROL_DEBOBS(i)	(OMAP2_CONTROL_GENERAL + 0x01B0 \
@@ -164,6 +173,14 @@
 #define OMAP343X_CONTROL_SRAMLDO5	(OMAP2_CONTROL_GENERAL + 0x02C0)
 #define OMAP343X_CONTROL_CSI		(OMAP2_CONTROL_GENERAL + 0x02C4)
 
+/* OMAP3630 only CONTROL_GENERAL register offsets */
+#define OMAP3630_CONTROL_FUSE_OPP1G_VDD1        (OMAP2_CONTROL_GENERAL + 0x0110)
+#define OMAP3630_CONTROL_FUSE_OPP50_VDD1        (OMAP2_CONTROL_GENERAL + 0x0114)
+#define OMAP3630_CONTROL_FUSE_OPP100_VDD1       (OMAP2_CONTROL_GENERAL + 0x0118)
+#define OMAP3630_CONTROL_FUSE_OPP120_VDD1       (OMAP2_CONTROL_GENERAL + 0x0120)
+#define OMAP3630_CONTROL_FUSE_OPP50_VDD2        (OMAP2_CONTROL_GENERAL + 0x0128)
+#define OMAP3630_CONTROL_FUSE_OPP100_VDD2       (OMAP2_CONTROL_GENERAL + 0x012C)
+
 /* AM35XX only CONTROL_GENERAL register offsets */
 #define AM35XX_CONTROL_MSUSPENDMUX_6    (OMAP2_CONTROL_GENERAL + 0x0038)
 #define AM35XX_CONTROL_DEVCONF2         (OMAP2_CONTROL_GENERAL + 0x0310)
@@ -243,6 +260,16 @@
 #define OMAP2_SYSBOOT_1_MASK		(1 << 1)
 #define OMAP2_SYSBOOT_0_MASK		(1 << 0)
 
+/* CONTROL_FUSE_SR bits */
+#define OMAP343X_SR2_SENNENABLE_MASK    (0x3 << 10)
+#define OMAP343X_SR2_SENNENABLE_SHIFT   10
+#define OMAP343X_SR2_SENPENABLE_MASK    (0x3 << 8)
+#define OMAP343X_SR2_SENPENABLE_SHIFT   8
+#define OMAP343X_SR1_SENNENABLE_MASK    (0x3 << 2)
+#define OMAP343X_SR1_SENNENABLE_SHIFT   2
+#define OMAP343X_SR1_SENPENABLE_MASK    (0x3 << 0)
+#define OMAP343X_SR1_SENPENABLE_SHIFT   0
+
 /* CONTROL_PBIAS_LITE bits */
 #define OMAP343X_PBIASLITESUPPLY_HIGH1	(1 << 15)
 #define OMAP343X_PBIASLITEVMODEERROR1	(1 << 11)
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c +249 -0

287 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#16 lore raw

PATCH v4 5/9 OMAP3: PM: Adding smartreflex class3 driver

In reply to Thara Gopinath

Smartreflex Class3 implementation continuously monitors silicon performance and instructs the Voltage Processors to increase or decrease the voltage.
This patch adds smartreflex class 3 driver. This driver hooks up with the generic smartreflex driver smartreflex.c to abstract out class specific implementations out of the generic driver.

Class3 driver is chosen as the default class driver for smartreflex. If any other class driver needs to be implemented, the init of that driver should be called from the board file. That way the new class driver will over-ride the Class3 driver.

---
 arch/arm/mach-omap2/Makefile             |    1 +
 arch/arm/mach-omap2/smartreflex-class3.c |   59 ++++++++++++++++++++++++++++++
 arch/arm/plat-omap/Kconfig               |    9 +++++
 3 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/smartreflex-class3.c
arch/arm/mach-omap2/Makefile +1 -0
index 42b0cc5..e194830 100644
@@ -56,6 +56,7 @@ obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o voltage.o \
 obj-$(CONFIG_ARCH_OMAP4)		+= pm44xx.o pm_bus.o
 obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
 obj-$(CONFIG_OMAP_SMARTREFLEX)          += sr_device.o smartreflex.o
+obj-$(CONFIG_OMAP_SMARTREFLEX_CLASS3)	+= smartreflex-class3.o
 
 AFLAGS_sleep24xx.o			:=-Wa,-march=armv6
 AFLAGS_sleep34xx.o			:=-Wa,-march=armv7-a
arch/arm/mach-omap2/smartreflex-class3.c new file +59 -0

59 lines not on this page · raw message

arch/arm/plat-omap/Kconfig +9 -0
index 04b0bd2..7ba92c2 100644
@@ -71,6 +71,15 @@ config OMAP_SMARTREFLEX_TESTING
 
 	  WARNING: Enabling this option may cause your device to hang!
 
+config OMAP_SMARTREFLEX_CLASS3
+	bool "Class 3 mode of Smartreflex Implementation"
+	depends on OMAP_SMARTREFLEX && TWL4030_CORE
+	help
+	  Say Y to enable Class 3 implementation of Smartreflex
+
+	  Class 3 implementation of Smartreflex employs continuous hardware
+	  voltage calibration.
+
 config OMAP_RESET_CLOCKS
 	bool "Reset unused clocks during boot"
 	depends on ARCH_OMAP
Signature · 1 line
1.7.0.4
#17 lore raw

PATCH v4 6/9 OMAP3: PM: Adding T2 enabling of smartreflex support

In reply to Thara Gopinath

This patch adds support in the twl4030 driver to hook up the API enabling smartreflex support on PMIC side with the smartreflex driver. Without this the OMAP smartreflex modules will not function.

---
 drivers/mfd/twl-core.c      |    7 +++++--
 drivers/mfd/twl4030-power.c |   29 +++++++++++++++++++++++++++++
 include/linux/i2c/twl.h     |    1 +
 3 files changed, 35 insertions(+), 2 deletions(-)
drivers/mfd/twl-core.c +5 -2
index 720e099..677b903 100644
@@ -1009,8 +1009,11 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	clocks_init(&client->dev, pdata->clock);
 
 	/* load power event scripts */
-	if (twl_has_power() && pdata->power)
-		twl4030_power_init(pdata->power);
+	if (twl_has_power()) {
+		twl4030_power_sr_init();
+		 if (pdata->power)
+			twl4030_power_init(pdata->power);
+	}
 
 	/* Maybe init the T2 Interrupt subsystem */
 	if (client->irq
drivers/mfd/twl4030-power.c +29 -0
index 7efa878..0e897a7 100644
@@ -31,6 +31,8 @@
 
 #include <asm/mach-types.h>
 
+#include <plat/smartreflex.h>
+
 static u8 twl4030_start_script_address = 0x2b;
 
 #define PWR_P1_SW_EVENTS	0x10
@@ -63,6 +65,10 @@ static u8 twl4030_start_script_address = 0x2b;
 #define R_MEMORY_ADDRESS	PHY_TO_OFF_PM_MASTER(0x59)
 #define R_MEMORY_DATA		PHY_TO_OFF_PM_MASTER(0x5a)
 
+/* Smartreflex Control */
+#define R_DCDC_GLOBAL_CFG	PHY_TO_OFF_PM_RECEIVER(0x61)
+#define CFG_ENABLE_SRFLX	0x08
+
 #define R_PROTECT_KEY		0x0E
 #define R_KEY_1			0xC0
 #define R_KEY_2			0x0C
@@ -511,6 +517,29 @@ int twl4030_remove_script(u8 flags)
 	return err;
 }
 
+/* API to enable smrtreflex on Triton side */
+static void twl4030_smartreflex_init(void)
+{
+	int ret = 0;
+	u8 read_val;
+
+	ret = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &read_val,
+			R_DCDC_GLOBAL_CFG);
+	read_val |= CFG_ENABLE_SRFLX;
+	ret |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, read_val,
+			R_DCDC_GLOBAL_CFG);
+}
+
+struct omap_sr_pmic_data twl4030_sr_data = {
+	.sr_pmic_init   = twl4030_smartreflex_init,
+};
+
+void __init twl4030_power_sr_init()
+{
+	/* Register the SR init API with the Smartreflex driver */
+	omap_sr_register_pmic(&twl4030_sr_data);
+}
+
 void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
 {
 	int err = 0;
include/linux/i2c/twl.h +1 -0
index 6de90bf..b02011e 100644
@@ -550,6 +550,7 @@ struct twl4030_power_data {
 };
 
 extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
+extern void twl4030_power_sr_init(void);
 extern int twl4030_remove_script(u8 flags);
 
 struct twl4030_codec_audio_data {
Signature · 1 line
1.7.0.4
#18 lore raw

PATCH v4 7/9 OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

In reply to Thara Gopinath

This patch adds debug support to the voltage and smartreflex drivers. This means a whole bunch of voltage processor and smartreflex parameters are now visible through the pm debugfs.
The voltage parameters can be viewed at

        /debug/voltage/vdd_<x>/<parameter>

and the smartreflex parameters can be viewed at
/debug/vdd_<x>/smartreflex/<parameter>

To enable overriding of these parameters from user side, write 1 into
/debug/voltage/vdd_<x>/override_volt_params

where <x> is mpu or core for OMAP3.

---
 arch/arm/mach-omap2/smartreflex.c         |   34 ++++-
 arch/arm/mach-omap2/voltage.c             |  219 ++++++++++++++++++++++++++++-
 arch/arm/plat-omap/include/plat/voltage.h |    1 +
 3 files changed, 248 insertions(+), 6 deletions(-)
arch/arm/mach-omap2/smartreflex.c +32 -2
index c24ae54..2669584 100644
@@ -555,8 +555,13 @@ int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
 		return -ENODATA;
 	}
 
-	/* errminlimit is opp dependent and hence linked to voltage */
-	sr->err_minlimit = volt_data->sr_errminlimit;
+	/*
+	 * errminlimit is opp dependent and hence linked to voltage.
+	 * If the override option is enabled, the user might have over ridden
+	 * this parameter, so do not get it from voltage table.
+	 */
+	if (!omap_voltage_override_params(voltdm))
+		sr->err_minlimit = volt_data->sr_errminlimit;
 
 	pm_runtime_get_sync(&sr->pdev->dev);
 
@@ -804,9 +809,28 @@ static int omap_sr_autocomp_store(void *data, u64 val)
 	return 0;
 }
 
+static int omap_sr_params_show(void *data, u64 *val)
+{
+	u32 *param = data;
+
+	*val = *param;
+	return 0;
+}
+
+static int omap_sr_params_store(void *data, u64 val)
+{
+	u32 *option = data;
+
+	*option = val;
+	return 0;
+}
+
 DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show,
 		omap_sr_autocomp_store, "%llu\n");
 
+DEFINE_SIMPLE_ATTRIBUTE(sr_params_fops, omap_sr_params_show,
+		omap_sr_params_store, "%llu\n");
+
 static int __init omap_sr_probe(struct platform_device *pdev)
 {
 	struct omap_sr *sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
@@ -889,6 +913,12 @@ static int __init omap_sr_probe(struct platform_device *pdev)
 
 	(void) debugfs_create_file("autocomp", S_IRUGO | S_IWUGO, dbg_dir,
 				(void *)sr_info, &pm_sr_fops);
+	(void) debugfs_create_file("errweight", S_IRUGO | S_IWUGO, dbg_dir,
+			&sr_info->err_weight, &sr_params_fops);
+	(void) debugfs_create_file("errmaxlimit", S_IRUGO | S_IWUGO, dbg_dir,
+			&sr_info->err_maxlimit, &sr_params_fops);
+	(void) debugfs_create_file("errminlimit", S_IRUGO | S_IWUGO, dbg_dir,
+			&sr_info->err_minlimit, &sr_params_fops);
 
 	return ret;
 
arch/arm/mach-omap2/voltage.c +215 -4

262 lines not on this page · raw message

arch/arm/plat-omap/include/plat/voltage.h +1 -0
index ecd7352..5677544 100644
@@ -127,6 +127,7 @@ struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
 		unsigned long volt);
 unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
 struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm);
+bool omap_voltage_override_params(struct voltagedomain *voltdm);
 #ifdef CONFIG_PM
 void omap_voltage_register_pmic(struct omap_volt_pmic_info *pmic_info);
 void omap_voltage_init_vc(struct omap_volt_vc_data *setup_vc);
Signature · 1 line
1.7.0.4
#19 lore raw

Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 11 lines · Thara Gopinath

This patch adds debug support to the voltage and smartreflex drivers. This means a whole bunch of voltage processor and smartreflex parameters are now visible through the pm debugfs.
The voltage parameters can be viewed at

        /debug/voltage/vdd_<x>/<parameter>

and the smartreflex parameters can be viewed at
/debug/vdd_<x>/smartreflex/<parameter>

To enable overriding of these parameters from user side, write 1 into
/debug/voltage/vdd_<x>/override_volt_params

Please just git rid of any sort of override parameter from sysfs.

Instead, you can detect in the sysfs code itself if any parameters were changed and then set the vdd->user_override flag.

Kevin

#20 lore raw

RE: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 21 lines
Quoted 21 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, November 11, 2010 12:43 AM
To: Gopinath, Thara
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 8 lines · Thara Gopinath

This patch adds debug support to the voltage and smartreflex drivers. This means a whole bunch of voltage processor and smartreflex parameters are now visible through the pm debugfs.
The voltage parameters can be viewed at

        /debug/voltage/vdd_<x>/<parameter>

and the smartreflex parameters can be viewed at
/debug/vdd_<x>/smartreflex/<parameter>

Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

To enable overriding of these parameters from user side, write 1 into
/debug/voltage/vdd_<x>/override_volt_params

Please just git rid of any sort of override parameter from sysfs.

Instead, you can detect in the sysfs code itself if any parameters were changed and then set the vdd->user_override flag.

But when will I unset this flag??

Regards
Thara

#21 lore raw

Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 23 lines · Thara
Quoted 23 lines
Quoted 23 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, November 11, 2010 12:43 AM
To: Gopinath, Thara
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 11 lines · Thara Gopinath

This patch adds debug support to the voltage and smartreflex drivers. This means a whole bunch of voltage processor and smartreflex parameters are now visible through the pm debugfs.
The voltage parameters can be viewed at

        /debug/voltage/vdd_<x>/<parameter>

and the smartreflex parameters can be viewed at
/debug/vdd_<x>/smartreflex/<parameter>

To enable overriding of these parameters from user side, write 1 into
/debug/voltage/vdd_<x>/override_volt_params

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

Please just git rid of any sort of override parameter from sysfs.

Instead, you can detect in the sysfs code itself if any parameters were changed and then set the vdd->user_override flag.

But when will I unset this flag??

You can't.

And, AFAICT, it wasn't clear from the current code or docs whether this could work or was expected to work either, e.g., if you set override_volt_params back to zero, to the original values all get reused?

If you want to provide this feature, then it should be documented and made clear that this is an intended goal.

Thinking about this more, the main thing I don't like about this approach is that the active code paths (enable & disable) have to check each time if any of these values have been overidden.

Rather than have several places in the active code paths where this override value is checked, there the sysfs methods should simply update the values that are used by the core code. This way, the core would not need to know about where the values came from (defalts, volt_data, user override, etc.)

If you want to provide a way to revert this, then maybe writing -1 will should switch that value back to the HW default, or volt_data default.

Kevin

#22 lore raw

RE: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 32 lines
Quoted 32 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Tuesday, November 16, 2010 3:43 AM
To: Gopinath, Thara
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 19 lines · Thara
Quoted 19 lines
Quoted 19 lines

-----Original Message-----
From: Kevin Hilman [mailto:[email protected]]
Sent: Thursday, November 11, 2010 12:43 AM
To: Gopinath, Thara
Cc: [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 8 lines · Thara Gopinath

This patch adds debug support to the voltage and smartreflex drivers. This means a whole bunch of voltage processor and smartreflex parameters are now visible through the pm debugfs.
The voltage parameters can be viewed at

        /debug/voltage/vdd_<x>/<parameter>

and the smartreflex parameters can be viewed at
/debug/vdd_<x>/smartreflex/<parameter>

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

To enable overriding of these parameters from user side, write 1 into
/debug/voltage/vdd_<x>/override_volt_params

Please just git rid of any sort of override parameter from sysfs.

Instead, you can detect in the sysfs code itself if any parameters were changed and then set the vdd->user_override flag.

But in the sys-fs code I do not have access to vdd. How do I then set this flag?

Quoted 16 lines
Quoted 16 lines
Quoted 2 lines

But when will I unset this flag??

You can't.

And, AFAICT, it wasn't clear from the current code or docs whether this could work or was expected to work either, e.g., if you set override_volt_params back to zero, to the original values all get reused?

If you want to provide this feature, then it should be documented and made clear that this is an intended goal.

Thinking about this more, the main thing I don't like about this approach is that the active code paths (enable & disable) have to check each time if any of these values have been overidden.

Quoted 8 lines
Quoted 8 lines

Rather than have several places in the active code paths where this override value is checked, there the sysfs methods should simply update the values that are used by the core code. This way, the core would not need to know about where the values came from (defalts, volt_data, user override, etc.)

If you want to provide a way to revert this, then maybe writing -1 will should switch that value back to the HW default, or volt_data default.

Kevin, Benoit, Nishant et al,

Without this override flag today there is no direct way of allowing user to write into these parameters. My question is, is there a need for the parameters to be over-written from the user-space? If yes, I need ideas on how to implement it with using override_volt_params !

Regards
Thara

#23 lore raw

Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Gopinath, Thara had written, on 12/08/2010 10:18 AM, the following:
[..]

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

And, AFAICT, it wasn't clear from the current code or docs whether this could work or was expected to work either, e.g., if you set override_volt_params back to zero, to the original values all get reused?

If you want to provide this feature, then it should be documented and made clear that this is an intended goal.

Thinking about this more, the main thing I don't like about this approach is that the active code paths (enable & disable) have to check each time if any of these values have been overidden.

Rather than have several places in the active code paths where this override value is checked, there the sysfs methods should simply update the values that are used by the core code. This way, the core would not need to know about where the values came from (defalts, volt_data, user override, etc.)

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

If you want to provide a way to revert this, then maybe writing -1 will should switch that value back to the HW default, or volt_data default.

Kevin, Benoit, Nishant et al,

Without this override flag today there is no direct way of allowing user to write into these parameters. My question is,

Glancing at the debug entries being overidden, as developer (debug users) working for tweaking parameters for their platform - yes - we will need some mechanism to runtime tweak and see the behavior without needing to rebuild the kernel everytime.

On production system (OS users): they should'nt be using this.

Quoted 3 lines

is there a need for the parameters to be over-written from the user-space? If yes, I need ideas on how to implement it with using override_volt_params !

Lets get the basics in kernel.org in some form! IMHO, all this double knobs are un-necessary overheads in codeflow for development only code- just provide the debugfs entries that reflect the data in their original structures, use the original structures everytime we go to a new transition (aka if you change the params in debugfs, they dont take effect till you do another transition).. but that is just my 2cents.

---
Regards,
Nishanth Menon

#24 lore raw

RE: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 48 lines
Quoted 48 lines

-----Original Message-----
From: Nishanth Menon [mailto:[email protected]]
Sent: Wednesday, December 08, 2010 10:05 PM
To: Gopinath, Thara
Cc: Kevin Hilman; [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Gopinath, Thara had written, on 12/08/2010 10:18 AM, the following:
[..]

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

And, AFAICT, it wasn't clear from the current code or docs whether this could work or was expected to work either, e.g., if you set override_volt_params back to zero, to the original values all get reused?

If you want to provide this feature, then it should be documented and made clear that this is an intended goal.

Thinking about this more, the main thing I don't like about this approach is that the active code paths (enable & disable) have to check each time if any of these values have been overidden.

Rather than have several places in the active code paths where this override value is checked, there the sysfs methods should simply update the values that are used by the core code. This way, the core would not need to know about where the values came from (defalts, volt_data, user override, etc.)

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

If you want to provide a way to revert this, then maybe writing -1 will should switch that value back to the HW default, or volt_data default.

Kevin, Benoit, Nishant et al,

Without this override flag today there is no direct way of allowing user to write into these parameters. My question is,

Glancing at the debug entries being overidden, as developer (debug users) working for tweaking parameters for their platform - yes - we will need some mechanism to runtime tweak and see the behavior without needing to rebuild the kernel everytime.

On production system (OS users): they should'nt be using this.

Quoted 3 lines

is there a need for the parameters to be over-written from the user-space? If yes, I need ideas on how to implement it with using override_volt_params !

Quoted 6 lines
Quoted 6 lines

Lets get the basics in kernel.org in some form! IMHO, all this double knobs are un-necessary overheads in codeflow for development only code- just provide the debugfs entries that reflect the data in their original structures, use the original structures everytime we go to a new transition (aka if you change the params in debugfs, they dont take effect till you do another transition).. but that is just my 2cents.

Nishant,
The issue here is most of these parameters are one time setting (during init) and need not be changed at all if the user does not wish to over-ride them for debug purpose. Hence the need for the checks (not double-hooks). But I agree with your point that let us get the basic in the kernel.org in some form. So for this first version that we plan to push to kernel.org, I plan to expose out these parameters to user space but not allow a write access to them. The write access part can be added later whenever required.

Regards
Thara

Quoted 4 lines
Quoted 4 lines

---
Regards,
Nishanth Menon

#25 lore raw

Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Gopinath, Thara wrote, on 12/09/2010 03:43 AM:

Quoted 55 lines
Quoted 48 lines
Quoted 48 lines

-----Original Message-----
From: Nishanth Menon [mailto:[email protected]]
Sent: Wednesday, December 08, 2010 10:05 PM
To: Gopinath, Thara
Cc: Kevin Hilman; [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Gopinath, Thara had written, on 12/08/2010 10:18 AM, the following:
[..]

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

And, AFAICT, it wasn't clear from the current code or docs whether this could work or was expected to work either, e.g., if you set override_volt_params back to zero, to the original values all get reused?

If you want to provide this feature, then it should be documented and made clear that this is an intended goal.

Thinking about this more, the main thing I don't like about this approach is that the active code paths (enable& disable) have to check each time if any of these values have been overidden.

Rather than have several places in the active code paths where this override value is checked, there the sysfs methods should simply update the values that are used by the core code. This way, the core would not need to know about where the values came from (defalts, volt_data, user override, etc.)

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

If you want to provide a way to revert this, then maybe writing -1 will should switch that value back to the HW default, or volt_data default.

Kevin, Benoit, Nishant et al,

Without this override flag today there is no direct way of allowing user to write into these parameters. My question is,

Glancing at the debug entries being overidden, as developer (debug users) working for tweaking parameters for their platform - yes - we will need some mechanism to runtime tweak and see the behavior without needing to rebuild the kernel everytime.

On production system (OS users): they should'nt be using this.

Quoted 3 lines

is there a need for the parameters to be over-written from the user-space? If yes, I need ideas on how to implement it with using override_volt_params !

Quoted 6 lines
Quoted 6 lines

Lets get the basics in kernel.org in some form! IMHO, all this double knobs are un-necessary overheads in codeflow for development only code- just provide the debugfs entries that reflect the data in their original structures, use the original structures everytime we go to a new transition (aka if you change the params in debugfs, they dont take effect till you do another transition).. but that is just my 2cents.

Quoted 4 lines

Nishant,
The issue here is most of these parameters are one time setting (during init) and need not be changed at all if the user does not wish to over-ride them for debug purpose. Hence the need for the checks (not double-hooks). But I agree

If they are init time thingy, then why not set it up so that when some one echo's to the debugfs, it writes to the register as well? That way you dont need to add runtime check and the debug developer does'nt need to worry about echo 1> magic_control_sys_fs_file (just kidding).

Quoted 4 lines

with your point that let us get the basic in the kernel.org in some form. So for this first version that we plan to push to kernel.org, I plan to expose out these parameters to user space but not allow a write access to them. The write access part can be added later whenever required.

Sure.. at this point, anything that actually works is welcome :)

Signature · 2 lines
Regards,
Nishanth Menon
#26 lore raw

RE: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Quoted 76 lines
Quoted 76 lines

-----Original Message-----
From: Menon, Nishanth
Sent: Thursday, December 09, 2010 4:54 PM
To: Gopinath, Thara
Cc: Kevin Hilman; [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Gopinath, Thara wrote, on 12/09/2010 03:43 AM:

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

-----Original Message-----
From: Nishanth Menon [mailto:[email protected]]
Sent: Wednesday, December 08, 2010 10:05 PM
To: Gopinath, Thara
Cc: Kevin Hilman; [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage

and

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Smartreflex drivers

Gopinath, Thara had written, on 12/08/2010 10:18 AM, the following:
[..]

Quoted 1 line
Quoted 1 line
Quoted 1 line

And, AFAICT, it wasn't clear from the current code or docs whether

this

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

could work or was expected to work either, e.g., if you set override_volt_params back to zero, to the original values all get

reused?

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

If you want to provide this feature, then it should be documented and made clear that this is an intended goal.

Thinking about this more, the main thing I don't like about this approach is that the active code paths (enable& disable) have to

check

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

each time if any of these values have been overidden.

Rather than have several places in the active code paths where this override value is checked, there the sysfs methods should simply

update

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

the values that are used by the core code. This way, the core would not need to know about where the values came from (defalts, volt_data, user override, etc.)

If you want to provide a way to revert this, then maybe writing -1

will

Quoted 24 lines
Quoted 17 lines
Quoted 17 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

should switch that value back to the HW default, or volt_data default.

Kevin, Benoit, Nishant et al,

Without this override flag today there is no direct way of allowing user to write into these parameters. My question is,

Glancing at the debug entries being overidden, as developer (debug users) working for tweaking parameters for their platform - yes - we will need some mechanism to runtime tweak and see the behavior without needing to rebuild the kernel everytime.

On production system (OS users): they should'nt be using this.

Quoted 3 lines

is there a need for the parameters to be over-written from the user-space? If yes, I need ideas on how to implement it with using override_volt_params !

Quoted 6 lines
Quoted 6 lines

Lets get the basics in kernel.org in some form! IMHO, all this double knobs are un-necessary overheads in codeflow for development only code- just provide the debugfs entries that reflect the data in their original structures, use the original structures everytime we go to a new transition (aka if you change the params in debugfs, they dont take effect till you do another transition).. but that is just my 2cents.

Quoted 2 lines

Nishant,
The issue here is most of these parameters are one time setting (during

init)

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

and need not be changed at all if the user does not wish to over-ride

them for

Quoted 1 line

debug purpose. Hence the need for the checks (not double-hooks). But

I agree
If they are init time thingy, then why not set it up so that when some one echo's to the debugfs, it writes to the register as well? That way you dont need to add runtime check and the debug developer does'nt need to worry about echo 1> magic_control_sys_fs_file (just kidding).

Yes but then for it the debugfs set get APIs should have access to the data structures which stores the register offset etc. Today I am using a single API to set any parameter any vdd. This will have to change. Maybe one API per parameter. I cannot currently think of any better solution :-)!

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines

with your point that let us get the basic in the kernel.org in some

form. So

Quoted 1 line

for this first version that we plan to push to kernel.org, I plan to

expose out

Quoted 1 line

these parameters to user space but not allow a write access to them.

The write

Quoted 1 line

access part can be added later whenever required.

Sure.. at this point, anything that actually works is welcome :)

Ok :-) !

Regards
Thara

#27 lore raw

Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

In reply to Gopinath, Thara

"Gopinath, Thara" <[email protected]> writes:

[...]

Quoted 4 lines

So for this first version that we plan to push to kernel.org, I plan to expose out these parameters to user space but not allow a write access to them. The write access part can be added later whenever required.

OK with me.

Kevin

#28 lore raw

Re: [PATCH v4 7/9] OMAP3: PM: Adding debug support to Voltage and Smartreflex drivers

Kevin Hilman had written, on 12/09/2010 11:19 AM, the following:

Quoted 10 lines

"Gopinath, Thara" <[email protected]> writes:

[...]

Quoted 4 lines

So for this first version that we plan to push to kernel.org, I plan to expose out these parameters to user space but not allow a write access to them. The write access part can be added later whenever required.

OK with me.

+1
Regards,
Nishanth Menon

#29 lore raw

PATCH v4 8/9 OMAP3: PM: Program correct init voltages for VDD1 and VDD2

In reply to Thara Gopinath

By default the system boots up at nominal voltage for every voltage domain in the system. This patch puts VDD1 and VDD2 to the correct boot up voltage as per the opp tables specified. This patch implements this by matching the rate of the main clock of the voltage domain with the opp table and picking up the correct voltage.

---
 arch/arm/mach-omap2/pm.c |   68 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/pm.c +68 -0
index 0fe905c..353e155 100644
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/err.h>
+#include <linux/opp.h>
 
 #include <plat/omap-pm.h>
 #include <plat/omap_device.h>
@@ -20,6 +21,7 @@
 
 #include <plat/powerdomain.h>
 #include <plat/clockdomain.h>
+#include <plat/voltage.h>
 
 #include "pm.h"
 
@@ -138,6 +140,67 @@ err:
 	return ret;
 }
 
+/*
+ * This API is to be called during init to put the various voltage
+ * domains to the voltage as per the opp table. Typically we boot up
+ * at the nominal voltage. So this function finds out the rate of
+ * the clock associated with the voltage domain, finds out the correct
+ * opp entry and puts the voltage domain to the voltage specifies
+ * in the opp entry
+ */
+static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name,
+						struct device *dev)
+{
+	struct voltagedomain *voltdm;
+	struct clk *clk;
+	struct opp *opp;
+	unsigned long freq, bootup_volt;
+
+	if (!vdd_name || !clk_name || !dev) {
+		printk(KERN_ERR "%s: Invalid parameters!\n", __func__);
+		goto exit;
+	}
+
+	voltdm = omap_voltage_domain_lookup(vdd_name);
+	if (IS_ERR(voltdm)) {
+		printk(KERN_ERR "%s: Unable to get vdd pointer for vdd_%s\n",
+			__func__, vdd_name);
+		goto exit;
+	}
+
+	clk =  clk_get(NULL, clk_name);
+	if (IS_ERR(clk)) {
+		printk(KERN_ERR "%s: unable to get clk %s\n",
+			__func__, clk_name);
+		goto exit;
+	}
+
+	freq = clk->rate;
+	clk_put(clk);
+
+	opp = opp_find_freq_ceil(dev, &freq);
+	if (IS_ERR(opp)) {
+		printk(KERN_ERR "%s: unable to find boot up OPP for vdd_%s\n",
+			__func__, vdd_name);
+		goto exit;
+	}
+
+	bootup_volt = opp_get_voltage(opp);
+	if (!bootup_volt) {
+		printk(KERN_ERR "%s: unable to find voltage corresponding"
+			"to the bootup OPP for vdd_%s\n", __func__, vdd_name);
+		goto exit;
+	}
+
+	omap_voltage_scale_vdd(voltdm, bootup_volt);
+	return 0;
+
+exit:
+	printk(KERN_ERR "%s: Unable to put vdd_%s to its init voltage\n\n",
+		__func__, vdd_name);
+	return -EINVAL;
+}
+
 static int __init omap2_common_pm_init(void)
 {
 	omap2_init_processor_devices();
@@ -145,6 +208,11 @@ static int __init omap2_common_pm_init(void)
 	if (cpu_is_omap34xx() || cpu_is_omap44xx())
 		omap_init_opp_table();
 
+	if (cpu_is_omap34xx()) {
+		omap2_set_init_voltage("mpu", "dpll1_ck", mpu_dev);
+		omap2_set_init_voltage("core", "l3_ick", l3_dev);
+	}
+
 	omap_pm_if_init();
 
 	return 0;
Signature · 1 line
1.7.0.4
#30 lore raw

PATCH v4 9/9 OMAP3: PM: Register TWL4030 pmic info with the voltage driver.

In reply to Thara Gopinath

This patch registers the TWL4030 PMIC specific informtion with the voltage driver. Failing this patch the voltage driver is unware of the formula to use for vsel to voltage and vice versa conversion.

---
 arch/arm/plat-omap/opp_twl_tps.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
arch/arm/plat-omap/opp_twl_tps.c +17 -0
index 112f106..4448fc5 100644
@@ -13,7 +13,10 @@
  * XXX This code should be part of some other TWL/TPS code.
  */
 
+#include <linux/module.h>
+
 #include <plat/opp_twl_tps.h>
+#include <plat/voltage.h>
 
 /**
  * omap_twl_vsel_to_vdc - convert TWL/TPS VSEL value to microvolts DC
@@ -39,3 +42,17 @@ u8 omap_twl_uv_to_vsel(unsigned long uv)
 	/* Round up to higher voltage */
 	return DIV_ROUND_UP(uv - 600000, 12500);
 }
+
+static struct omap_volt_pmic_info twl_volt_info = {
+	.slew_rate	= 4000,
+	.step_size	= 12500,
+	.vsel_to_uv	= omap_twl_vsel_to_uv,
+	.uv_to_vsel	= omap_twl_uv_to_vsel,
+};
+
+static int __init omap_twl_init(void)
+{
+	omap_voltage_register_pmic(&twl_volt_info);
+	return 0;
+}
+arch_initcall(omap_twl_init);
Signature · 1 line
1.7.0.4
#31 lore raw
In reply to Thara Gopinath

Gopinath, Thara had written, on 10/27/2010 11:10 AM, the following:

Quoted 3 lines

This patch series introduces smartreflex and voltage driver support for OMAP3430 and OMAP3630. SmartReflex modules do adaptive voltage control for real-time voltage adjustments.

[..]
thanks for the revamped set

Quoted 13 lines

This patch series is based against lo-master with the following additional patches applied.

	https://patchwork.kernel.org/patch/266911/
	https://patchwork.kernel.org/patch/266921/
	https://patchwork.kernel.org/patch/266931/
	https://patchwork.kernel.org/patch/183712/
	https://patchwork.kernel.org/patch/285872/

The entire series with the dependencies are available at
http://dev.omapzoom.org/?p=thara/omap-dvfs.git;a=summary
head: thara-pm-sr

Quoted 6 lines

This patch series has been tested on OMAP3430 SDP with omap2plus_defconfig with the following menuconfig options enabled.
System type -> TI OMAP Implementations -> Smartreflex Support System type -> TI OMAP Implementations ->
Class 3 mode of Smartreflex Implementation

Thanks for hosting the branch, Looking at:
http://dev.omapzoom.org/?p=thara/omap-dvfs.git;a=shortlog;h=refs/heads/thara-pm-sr
I am guessing DVFS is missing in this branch? Is it possible to give it a test drive?

Also curious should:
"OMAP: OPP: twl/tps: Introduce TWL/TPS-specific code should probably be " dropped with "OMAP3: PM: Register TWL4030 pmic info with the voltage" ?

[...]

my 2cents: If that tree were organized based on branches which depend on each other it will be easier to identify the dependencies :) probably:
kernel.org (now that l-o is merged - potential 2.6.37-rc1)

 |- clock patches  -\
 |- DVFS series    -|
 |- OMAP OPP series |

|-merged-based -
|-voltage layer & SR series perhaps
|- twl optimization
|- board changes
*** final code ***
Just 2 cents to make it easier for folks who are not in PM mostly to see how everything falls together in place..

Signature · 2 lines
Regards,
Nishanth Menon
#32 lore raw
Quoted 11 lines
Quoted 11 lines

-----Original Message-----
From: Menon, Nishanth
Sent: Wednesday, October 27, 2010 10:51 PM
To: Gopinath, Thara
Cc: [email protected]; [email protected]; [email protected]; Cousson, Benoit; Sripathy, Vishwanath; Sawant, Anand
Subject: Re: [PATCH v4 0/9] OMAP3: Adding Smartreflex and Voltage driver support

Quoted 6 lines
Quoted 6 lines

Gopinath, Thara had written, on 10/27/2010 11:10 AM, the following:

Quoted 3 lines

This patch series introduces smartreflex and voltage driver support for OMAP3430 and OMAP3630. SmartReflex modules do adaptive voltage control for real-time voltage adjustments.

[..]
thanks for the revamped set

You are most welcome!!

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

This patch series is based against lo-master with the following additional patches applied.

	https://patchwork.kernel.org/patch/266911/
	https://patchwork.kernel.org/patch/266921/
	https://patchwork.kernel.org/patch/266931/
	https://patchwork.kernel.org/patch/183712/
	https://patchwork.kernel.org/patch/285872/

The entire series with the dependencies are available at
http://dev.omapzoom.org/?p=thara/omap-dvfs.git;a=summary
head: thara-pm-sr

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

This patch series has been tested on OMAP3430 SDP with omap2plus_defconfig with the following menuconfig options enabled.
System type -> TI OMAP Implementations -> Smartreflex Support System type -> TI OMAP Implementations ->
Class 3 mode of Smartreflex Implementation

Thanks for hosting the branch, Looking at:

Again glad tat u liked it:-)

Quoted 4 lines
Quoted 4 lines

http://dev.omapzoom.org/?p=thara/omap-dvfs.git;a=shortlog;h=refs/heads/thara-
pm-sr
I am guessing DVFS is missing in this branch? Is it possible to give it a test drive?

Yes.. This is exactly what I am trying to do. Will keep you updated.

Quoted 4 lines
Quoted 4 lines

Also curious should:
"OMAP: OPP: twl/tps: Introduce TWL/TPS-specific code should probably be " dropped with "OMAP3: PM: Register TWL4030 pmic info with the voltage" ?

Hmm.. Last time I suggested moving the contents of this patch to twl-core.c
Nobody seemed to much keen. Hence I retained the plat-omap/opp-twl-tpl.c file.
In fact "OMAP3: PM: Register TWL4030 pmic info with the voltage" registers the
params from plat-omap/opp-twl-tpl.c. But if we have a consensus I will just drop this patch and have the pmic params passed from twl-core.c.

Quoted 17 lines
Quoted 10 lines

[...]

my 2cents: If that tree were organized based on branches which depend on each other it will be easier to identify the dependencies :) probably:
kernel.org (now that l-o is merged - potential 2.6.37-rc1)

 |- clock patches  -\
 |- DVFS series    -|
 |- OMAP OPP series |
Quoted 7 lines

|-merged-based -
|-voltage layer & SR series perhaps
|- twl optimization
|- board changes *** final code ***
Just 2 cents to make it easier for folks who are not in PM mostly to see how everything falls together in place..

I agree. But then I need some five patches on top of potential 2.6.37-rc1,
which are not present in any branch. Are you asking me to generate separate branches for all these patches?

Regards
Thara

#33 lore raw

"Gopinath, Thara" <[email protected]> writes:

[...]

Quoted 11 lines
Quoted 4 lines
Quoted 4 lines

Also curious should:
"OMAP: OPP: twl/tps: Introduce TWL/TPS-specific code should probably be " dropped with "OMAP3: PM: Register TWL4030 pmic info with the voltage" ?

Hmm.. Last time I suggested moving the contents of this patch to twl-core.c Nobody seemed to much keen. Hence I retained the plat-omap/opp-twl-tpl.c file. In fact "OMAP3: PM: Register TWL4030 pmic info with the voltage" registers the params from plat-omap/opp-twl-tpl.c. But if we have a consensus I will just drop this patch and have the pmic params passed from twl-core.c.

Sounds right to me.

Kevin