Skip to content

Commit

Permalink
Merge branch 'for_3.6/pm/sr-move' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/khilman/linux-omap-pm into devel-driver
  • Loading branch information
Tony Lindgren committed Jun 26, 2012
2 parents b955eef + 21ff63a commit 9e74f21
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 179 deletions.
5 changes: 3 additions & 2 deletions arch/arm/mach-omap2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ obj-$(CONFIG_ARCH_OMAP3) += cpuidle34xx.o
obj-$(CONFIG_ARCH_OMAP4) += pm44xx.o omap-mpuss-lowpower.o
obj-$(CONFIG_ARCH_OMAP4) += cpuidle44xx.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

obj-$(CONFIG_POWER_AVS_OMAP) += sr_device.o
obj-$(CONFIG_POWER_AVS_OMAP_CLASS3) += smartreflex-class3.o

AFLAGS_sleep24xx.o :=-Wa,-march=armv6
AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a$(plus_sec)
Expand Down
12 changes: 6 additions & 6 deletions arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*
* XXX these should be marked initdata for multi-OMAP kernels
*/
#include <linux/power/smartreflex.h>

#include <plat/omap_hwmod.h>
#include <mach/irqs.h>
#include <plat/cpu.h>
Expand All @@ -29,8 +31,6 @@
#include <plat/dmtimer.h>

#include "omap_hwmod_common_data.h"

#include "smartreflex.h"
#include "prm-regbits-34xx.h"
#include "cm-regbits-34xx.h"
#include "wd_timer.h"
Expand Down Expand Up @@ -1325,7 +1325,7 @@ static struct omap_hwmod_irq_info omap3_smartreflex_mpu_irqs[] = {
};

static struct omap_hwmod omap34xx_sr1_hwmod = {
.name = "sr1",
.name = "smartreflex_mpu_iva",
.class = &omap34xx_smartreflex_hwmod_class,
.main_clk = "sr1_fck",
.prcm = {
Expand All @@ -1343,7 +1343,7 @@ static struct omap_hwmod omap34xx_sr1_hwmod = {
};

static struct omap_hwmod omap36xx_sr1_hwmod = {
.name = "sr1",
.name = "smartreflex_mpu_iva",
.class = &omap36xx_smartreflex_hwmod_class,
.main_clk = "sr1_fck",
.prcm = {
Expand All @@ -1370,7 +1370,7 @@ static struct omap_hwmod_irq_info omap3_smartreflex_core_irqs[] = {
};

static struct omap_hwmod omap34xx_sr2_hwmod = {
.name = "sr2",
.name = "smartreflex_core",
.class = &omap34xx_smartreflex_hwmod_class,
.main_clk = "sr2_fck",
.prcm = {
Expand All @@ -1388,7 +1388,7 @@ static struct omap_hwmod omap34xx_sr2_hwmod = {
};

static struct omap_hwmod omap36xx_sr2_hwmod = {
.name = "sr2",
.name = "smartreflex_core",
.class = &omap36xx_smartreflex_hwmod_class,
.main_clk = "sr2_fck",
.prcm = {
Expand Down
3 changes: 1 addition & 2 deletions arch/arm/mach-omap2/omap_hwmod_44xx_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include <linux/io.h>
#include <linux/power/smartreflex.h>

#include <plat/omap_hwmod.h>
#include <plat/cpu.h>
Expand All @@ -32,8 +33,6 @@
#include <plat/common.h>

#include "omap_hwmod_common_data.h"

#include "smartreflex.h"
#include "cm1_44xx.h"
#include "cm2_44xx.h"
#include "prm44xx.h"
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extern void enable_omap3630_toggle_l2_on_restore(void);
static inline void enable_omap3630_toggle_l2_on_restore(void) { }
#endif /* defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3) */

#ifdef CONFIG_OMAP_SMARTREFLEX
#ifdef CONFIG_POWER_AVS_OMAP
extern int omap_devinit_smartreflex(void);
extern void omap_enable_smartreflex_on_init(void);
#else
Expand Down
29 changes: 15 additions & 14 deletions arch/arm/mach-omap2/smartreflex-class3.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,37 @@
* published by the Free Software Foundation.
*/

#include "smartreflex.h"
#include <linux/power/smartreflex.h>
#include "voltage.h"

static int sr_class3_enable(struct voltagedomain *voltdm)
static int sr_class3_enable(struct omap_sr *sr)
{
unsigned long volt = voltdm_get_voltage(voltdm);
unsigned long volt = voltdm_get_voltage(sr->voltdm);

if (!volt) {
pr_warning("%s: Curr voltage unknown. Cannot enable sr_%s\n",
__func__, voltdm->name);
pr_warning("%s: Curr voltage unknown. Cannot enable %s\n",
__func__, sr->name);
return -ENODATA;
}

omap_vp_enable(voltdm);
return sr_enable(voltdm, volt);
omap_vp_enable(sr->voltdm);
return sr_enable(sr->voltdm, volt);
}

static int sr_class3_disable(struct voltagedomain *voltdm, int is_volt_reset)
static int sr_class3_disable(struct omap_sr *sr, int is_volt_reset)
{
sr_disable_errgen(voltdm);
omap_vp_disable(voltdm);
sr_disable(voltdm);
sr_disable_errgen(sr->voltdm);
omap_vp_disable(sr->voltdm);
sr_disable(sr->voltdm);
if (is_volt_reset)
voltdm_reset(voltdm);
voltdm_reset(sr->voltdm);

return 0;
}

static int sr_class3_configure(struct voltagedomain *voltdm)
static int sr_class3_configure(struct omap_sr *sr)
{
return sr_configure_errgen(voltdm);
return sr_configure_errgen(sr->voltdm);
}

/* SR class3 structure */
Expand Down
39 changes: 32 additions & 7 deletions arch/arm/mach-omap2/sr_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/power/smartreflex.h>

#include <linux/err.h>
#include <linux/slab.h>
#include <linux/io.h>

#include <plat/omap_device.h>

#include "smartreflex.h"
#include "voltage.h"
#include "control.h"
#include "pm.h"
Expand All @@ -36,16 +36,25 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
struct omap_sr_data *sr_data)
{
struct omap_sr_nvalue_table *nvalue_table;
int i, count = 0;
int i, j, count = 0;

sr_data->nvalue_count = 0;
sr_data->nvalue_table = NULL;

while (volt_data[count].volt_nominal)
count++;

nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count,
GFP_KERNEL);

for (i = 0; i < count; i++) {
if (!nvalue_table) {
pr_err("OMAP: SmartReflex: cannot allocate memory for n-value table\n");
return;
}

for (i = 0, j = 0; i < count; i++) {
u32 v;

/*
* In OMAP4 the efuse registers are 24 bit aligned.
* A __raw_readl will fail for non-32 bit aligned address
Expand All @@ -58,15 +67,30 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
omap_ctrl_readb(offset + 1) << 8 |
omap_ctrl_readb(offset + 2) << 16;
} else {
v = omap_ctrl_readl(volt_data[i].sr_efuse_offs);
v = omap_ctrl_readl(volt_data[i].sr_efuse_offs);
}

nvalue_table[i].efuse_offs = volt_data[i].sr_efuse_offs;
nvalue_table[i].nvalue = v;
/*
* Many OMAP SoCs don't have the eFuse values set.
* For example, pretty much all OMAP3xxx before
* ES3.something.
*
* XXX There needs to be some way for board files or
* userspace to add these in.
*/
if (v == 0)
continue;

nvalue_table[j].nvalue = v;
nvalue_table[j].efuse_offs = volt_data[i].sr_efuse_offs;
nvalue_table[j].errminlimit = volt_data[i].sr_errminlimit;
nvalue_table[j].volt_nominal = volt_data[i].volt_nominal;

j++;
}

sr_data->nvalue_table = nvalue_table;
sr_data->nvalue_count = count;
sr_data->nvalue_count = j;
}

static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
Expand All @@ -93,6 +117,7 @@ static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
goto exit;
}

sr_data->name = oh->name;
sr_data->ip_type = oh->class->rev;
sr_data->senn_mod = 0x1;
sr_data->senp_mod = 0x1;
Expand Down
21 changes: 2 additions & 19 deletions arch/arm/mach-omap2/voltage.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <linux/err.h>

#include <plat/voltage.h>

#include "vc.h"
#include "vp.h"

Expand Down Expand Up @@ -90,25 +92,6 @@ struct voltagedomain {
struct omap_volt_data *volt_data;
};

/**
* struct omap_volt_data - Omap voltage specific data.
* @voltage_nominal: The possible voltage value in uV
* @sr_efuse_offs: The offset of the efuse register(from system
* control module base address) from where to read
* the n-target value for the smartreflex module.
* @sr_errminlimit: Error min limit value for smartreflex. This value
* differs at differnet opp and thus is linked
* with voltage.
* @vp_errorgain: Error gain value for the voltage processor. This
* field also differs according to the voltage/opp.
*/
struct omap_volt_data {
u32 volt_nominal;
u32 sr_efuse_offs;
u8 sr_errminlimit;
u8 vp_errgain;
};

/**
* struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
* @slew_rate: PMIC slew rate (in uv/us)
Expand Down
31 changes: 15 additions & 16 deletions arch/arm/plat-omap/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,30 @@ config OMAP_DEBUG_LEDS
depends on OMAP_DEBUG_DEVICES
default y if LEDS_CLASS

config OMAP_SMARTREFLEX
bool "SmartReflex support"
depends on (ARCH_OMAP3 || ARCH_OMAP4) && PM
config POWER_AVS_OMAP
bool "AVS(Adaptive Voltage Scaling) support for OMAP IP versions 1&2"
depends on POWER_AVS && (ARCH_OMAP3 || ARCH_OMAP4) && 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.
Say Y to enable AVS(Adaptive Voltage Scaling)
support on OMAP containing the version 1 or
version 2 of the SmartReflex IP.
V1 is the 65nm version used in OMAP3430.
V2 is the update for the 45nm version of the IP used in OMAP3630
and OMAP4430

Please note, that by default SmartReflex is only
initialized. To enable the automatic voltage
compensation for vdd mpu and vdd core from user space,
initialized and not enabled. 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.
/debug/smartreflex/sr_<X>/autocomp,
where X is mpu_iva or core for OMAP3.
Optionally 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_CLASS3
config POWER_AVS_OMAP_CLASS3
bool "Class 3 mode of Smartreflex Implementation"
depends on OMAP_SMARTREFLEX && TWL4030_CORE
depends on POWER_AVS_OMAP && TWL4030_CORE
help
Say Y to enable Class 3 implementation of Smartreflex

Expand Down
21 changes: 20 additions & 1 deletion arch/arm/plat-omap/include/plat/voltage.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,29 @@
#ifndef __ARCH_ARM_OMAP_VOLTAGE_H
#define __ARCH_ARM_OMAP_VOLTAGE_H

/**
* struct omap_volt_data - Omap voltage specific data.
* @voltage_nominal: The possible voltage value in uV
* @sr_efuse_offs: The offset of the efuse register(from system
* control module base address) from where to read
* the n-target value for the smartreflex module.
* @sr_errminlimit: Error min limit value for smartreflex. This value
* differs at differnet opp and thus is linked
* with voltage.
* @vp_errorgain: Error gain value for the voltage processor. This
* field also differs according to the voltage/opp.
*/
struct omap_volt_data {
u32 volt_nominal;
u32 sr_efuse_offs;
u8 sr_errminlimit;
u8 vp_errgain;
};
struct voltagedomain;

struct voltagedomain *voltdm_lookup(const char *name);
int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);

struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
unsigned long volt);
#endif
2 changes: 2 additions & 0 deletions drivers/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,5 @@ config AB8500_BATTERY_THERM_ON_BATCTRL
Say Y to enable battery temperature measurements using
thermistor connected on BATCTRL ADC.
endif # POWER_SUPPLY

source "drivers/power/avs/Kconfig"
1 change: 1 addition & 0 deletions drivers/power/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o
obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o
obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o
obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
obj-$(CONFIG_POWER_AVS) += avs/
obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o
12 changes: 12 additions & 0 deletions drivers/power/avs/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
menuconfig POWER_AVS
tristate "Adaptive Voltage Scaling class support"
help
AVS is a power management technique which finely controls the
operating voltage of a device in order to optimize (i.e. reduce)
its power consumption.
At a given operating point the voltage is adapted depending on
static factors (chip manufacturing process) and dynamic factors
(temperature depending performance).
AVS is also called SmartReflex on OMAP devices.

Say Y here to enable Adaptive Voltage Scaling class support.
1 change: 1 addition & 0 deletions drivers/power/avs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
obj-$(CONFIG_POWER_AVS_OMAP) += smartreflex.o
Loading

0 comments on commit 9e74f21

Please sign in to comment.