From 536a4c8bb76e77217216bebd40178fb30ac5422b Mon Sep 17 00:00:00 2001 From: Afzal Mohammed Date: Tue, 29 Nov 2011 13:59:21 +0530 Subject: [PATCH] arm: omap: am33x: Move header files to plat/ dvfs.h is required by omap cpufreq driver that lives in drivers folder, so move it to plat/ directory. Also move voltage.h, vc.h & vp.h similarly to have clean header file inclusions Signed-off-by: Afzal Mohammed --- arch/arm/mach-omap2/dvfs.c | 2 +- arch/arm/mach-omap2/dvfs.h | 38 ----- arch/arm/mach-omap2/io.c | 2 +- arch/arm/mach-omap2/omap_opp_data.h | 2 +- arch/arm/mach-omap2/omap_twl.c | 2 +- arch/arm/mach-omap2/opp.c | 2 +- arch/arm/mach-omap2/pm.c | 2 +- arch/arm/mach-omap2/powerdomain.h | 2 +- arch/arm/mach-omap2/prm2xxx_3xxx.c | 3 +- arch/arm/mach-omap2/prm44xx.c | 2 +- arch/arm/mach-omap2/smartreflex.h | 2 +- arch/arm/mach-omap2/sr_device.c | 2 +- arch/arm/mach-omap2/vc.c | 4 +- arch/arm/mach-omap2/vc.h | 125 --------------- arch/arm/mach-omap2/vc3xxx_data.c | 5 +- arch/arm/mach-omap2/vc44xx_data.c | 3 +- arch/arm/mach-omap2/voltage.c | 7 +- arch/arm/mach-omap2/voltage.h | 219 -------------------------- arch/arm/mach-omap2/voltagedomains2xxx_data.c | 2 +- arch/arm/mach-omap2/voltagedomains33xx_data.c | 2 +- arch/arm/mach-omap2/voltagedomains3xxx_data.c | 6 +- arch/arm/mach-omap2/voltagedomains44xx_data.c | 4 +- arch/arm/mach-omap2/vp.c | 4 +- arch/arm/mach-omap2/vp.h | 128 --------------- arch/arm/mach-omap2/vp3xxx_data.c | 4 +- arch/arm/mach-omap2/vp44xx_data.c | 5 +- arch/arm/plat-omap/include/plat/dvfs.h | 38 +++++ arch/arm/plat-omap/include/plat/vc.h | 124 +++++++++++++++ arch/arm/plat-omap/include/plat/voltage.h | 205 +++++++++++++++++++++++- arch/arm/plat-omap/include/plat/vp.h | 128 +++++++++++++++ drivers/cpufreq/omap-cpufreq.c | 1 + 31 files changed, 525 insertions(+), 550 deletions(-) delete mode 100644 arch/arm/mach-omap2/dvfs.h delete mode 100644 arch/arm/mach-omap2/vc.h delete mode 100644 arch/arm/mach-omap2/voltage.h delete mode 100644 arch/arm/mach-omap2/vp.h create mode 100644 arch/arm/plat-omap/include/plat/dvfs.h create mode 100644 arch/arm/plat-omap/include/plat/vc.h create mode 100644 arch/arm/plat-omap/include/plat/vp.h diff --git a/arch/arm/mach-omap2/dvfs.c b/arch/arm/mach-omap2/dvfs.c index 74cbed5..2797a25 100644 --- a/arch/arm/mach-omap2/dvfs.c +++ b/arch/arm/mach-omap2/dvfs.c @@ -21,7 +21,7 @@ #include #include #include -#include "dvfs.h" +#include #include "smartreflex.h" #include "powerdomain.h" diff --git a/arch/arm/mach-omap2/dvfs.h b/arch/arm/mach-omap2/dvfs.h deleted file mode 100644 index da85c6d..0000000 --- a/arch/arm/mach-omap2/dvfs.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * OMAP3/OMAP4 DVFS Management Routines - * - * Author: Vishwanath BS - * - * Copyright (C) 2011 Texas Instruments, Inc. - * Vishwanath BS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef __ARCH_ARM_MACH_OMAP2_DVFS_H -#define __ARCH_ARM_MACH_OMAP2_DVFS_H -#include -#include "voltage.h" - -#ifdef CONFIG_PM -int omap_dvfs_register_device(struct device *dev, char *voltdm_name, - char *clk_name); -int omap_device_scale(struct device *req_dev, struct device *target_dev, - unsigned long rate); -#else -static inline int omap_dvfs_register_device(struct omap_hwmod *oh, - struct device *dev) -static inline int omap_dvfs_register_device(struct device *dev, - char *voltdm_name, char *clk_name) -{ - return -EINVAL; -} -static inline int omap_device_scale(struct device *req_dev, - struct device *target_dev, unsigned long rate) -{ - return -EINVAL; -} -#endif -#endif diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c index b722943..648ad1b 100644 --- a/arch/arm/mach-omap2/io.c +++ b/arch/arm/mach-omap2/io.c @@ -38,7 +38,7 @@ #include #include -#include "voltage.h" +#include #include "powerdomain.h" #include "clockdomain.h" diff --git a/arch/arm/mach-omap2/omap_opp_data.h b/arch/arm/mach-omap2/omap_opp_data.h index 867fe14b..489571b 100644 --- a/arch/arm/mach-omap2/omap_opp_data.h +++ b/arch/arm/mach-omap2/omap_opp_data.h @@ -20,8 +20,8 @@ #define __ARCH_ARM_MACH_OMAP2_OMAP_OPP_DATA_H #include +#include -#include "voltage.h" /* * *BIG FAT WARNING*: diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c index 91f3c2e..d5afb3f 100644 --- a/arch/arm/mach-omap2/omap_twl.c +++ b/arch/arm/mach-omap2/omap_twl.c @@ -17,8 +17,8 @@ #include #include #include +#include -#include "voltage.h" #include "pm.h" diff --git a/arch/arm/mach-omap2/opp.c b/arch/arm/mach-omap2/opp.c index 709720d..0fd5e4d 100644 --- a/arch/arm/mach-omap2/opp.c +++ b/arch/arm/mach-omap2/opp.c @@ -20,9 +20,9 @@ #include #include +#include #include "omap_opp_data.h" -#include "dvfs.h" /* Temp variable to allow multiple calls */ static u8 __initdata omap_table_init; diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c index 882dd3f..7070423 100644 --- a/arch/arm/mach-omap2/pm.c +++ b/arch/arm/mach-omap2/pm.c @@ -18,8 +18,8 @@ #include #include #include +#include -#include "voltage.h" #include "powerdomain.h" #include "clockdomain.h" #include "pm.h" diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h index 9efa823..44cd0d0 100644 --- a/arch/arm/mach-omap2/powerdomain.h +++ b/arch/arm/mach-omap2/powerdomain.h @@ -23,8 +23,8 @@ #include #include +#include -#include "voltage.h" /* Powerdomain basic power states */ #define PWRDM_POWER_OFF 0x0 diff --git a/arch/arm/mach-omap2/prm2xxx_3xxx.c b/arch/arm/mach-omap2/prm2xxx_3xxx.c index f02d87f..efd55cf 100644 --- a/arch/arm/mach-omap2/prm2xxx_3xxx.c +++ b/arch/arm/mach-omap2/prm2xxx_3xxx.c @@ -19,8 +19,7 @@ #include #include #include - -#include "vp.h" +#include #include "prm2xxx_3xxx.h" #include "cm2xxx_3xxx.h" diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c index 495a31a..5979803 100644 --- a/arch/arm/mach-omap2/prm44xx.c +++ b/arch/arm/mach-omap2/prm44xx.c @@ -20,8 +20,8 @@ #include #include #include +#include -#include "vp.h" #include "prm44xx.h" #include "prm-regbits-44xx.h" #include "prcm44xx.h" diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h index 5f35b9e..3eb6c34 100644 --- a/arch/arm/mach-omap2/smartreflex.h +++ b/arch/arm/mach-omap2/smartreflex.h @@ -21,8 +21,8 @@ #define __ASM_ARM_OMAP_SMARTREFLEX_H #include +#include -#include "voltage.h" /* * Different Smartreflex IPs version. The v1 is the 65nm version used in diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c index 9f43fcc..b19c3f4 100644 --- a/arch/arm/mach-omap2/sr_device.c +++ b/arch/arm/mach-omap2/sr_device.c @@ -23,9 +23,9 @@ #include #include +#include #include "smartreflex.h" -#include "voltage.h" #include "control.h" #include "pm.h" diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index 031d116..5fc751b 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c @@ -12,9 +12,9 @@ #include #include +#include +#include -#include "voltage.h" -#include "vc.h" #include "prm-regbits-34xx.h" #include "prm-regbits-44xx.h" #include "prm44xx.h" diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h deleted file mode 100644 index 478bf6b..0000000 --- a/arch/arm/mach-omap2/vc.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * OMAP3/4 Voltage Controller (VC) structure and macro definitions - * - * Copyright (C) 2007, 2010 Texas Instruments, Inc. - * Rajendra Nayak - * Lesly A M - * Thara Gopinath - * - * Copyright (C) 2008, 2011 Nokia Corporation - * Kalle Jokiniemi - * Paul Walmsley - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - */ -#ifndef __ARCH_ARM_MACH_OMAP2_VC_H -#define __ARCH_ARM_MACH_OMAP2_VC_H - -#include - -struct voltagedomain; - -/** - * struct omap_vc_common - per-VC register/bitfield data - * @cmd_on_mask: ON bitmask in PRM_VC_CMD_VAL* register - * @valid: VALID bitmask in PRM_VC_BYPASS_VAL register - * @bypass_val_reg: Offset of PRM_VC_BYPASS_VAL reg from PRM start - * @data_shift: DATA field shift in PRM_VC_BYPASS_VAL register - * @slaveaddr_shift: SLAVEADDR field shift in PRM_VC_BYPASS_VAL register - * @regaddr_shift: REGADDR field shift in PRM_VC_BYPASS_VAL register - * @cmd_on_shift: ON field shift in PRM_VC_CMD_VAL_* register - * @cmd_onlp_shift: ONLP field shift in PRM_VC_CMD_VAL_* register - * @cmd_ret_shift: RET field shift in PRM_VC_CMD_VAL_* register - * @cmd_off_shift: OFF field shift in PRM_VC_CMD_VAL_* register - * @i2c_cfg_reg: I2C configuration register offset - * @i2c_cfg_hsen_mask: high-speed mode bit field mask in I2C config register - * @i2c_mcode_mask: MCODE field mask for I2C config register - * - * XXX One of cmd_on_mask and cmd_on_shift are not needed - * XXX VALID should probably be a shift, not a mask - */ -struct omap_vc_common { - u32 cmd_on_mask; - u32 valid; - u8 bypass_val_reg; - u8 data_shift; - u8 slaveaddr_shift; - u8 regaddr_shift; - u8 cmd_on_shift; - u8 cmd_onlp_shift; - u8 cmd_ret_shift; - u8 cmd_off_shift; - u8 i2c_cfg_reg; - u8 i2c_cfg_hsen_mask; - u8 i2c_mcode_mask; -}; - -/* omap_vc_channel.flags values */ -#define OMAP_VC_CHANNEL_DEFAULT BIT(0) -#define OMAP_VC_CHANNEL_CFG_MUTANT BIT(1) - -/** - * struct omap_vc_channel - VC per-instance data - * @i2c_slave_addr: I2C slave address of PMIC for this VC channel - * @volt_reg_addr: voltage configuration register address - * @cmd_reg_addr: command configuration register address - * @setup_time: setup time (in sys_clk cycles) of regulator for this channel - * @cfg_channel: current value of VC channel configuration register - * @i2c_high_speed: whether or not to use I2C high-speed mode - * - * @common: pointer to VC common data for this platform - * @smps_sa_mask: i2c slave address bitmask in the PRM_VC_SMPS_SA register - * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register - * @smps_cmdra_mask: CMDRA* bitmask in the PRM_VC_CMD_RA register - * @cmdval_reg: register for on/ret/off voltage level values for this channel - * @smps_sa_reg: Offset of PRM_VC_SMPS_SA reg from PRM start - * @smps_volra_reg: Offset of PRM_VC_SMPS_VOL_RA reg from PRM start - * @smps_cmdra_reg: Offset of PRM_VC_SMPS_CMD_RA reg from PRM start - * @cfg_channel_reg: VC channel configuration register - * @cfg_channel_sa_shift: bit shift for slave address cfg_channel register - * @flags: VC channel-specific flags (optional) - */ -struct omap_vc_channel { - /* channel state */ - u16 i2c_slave_addr; - u16 volt_reg_addr; - u16 cmd_reg_addr; - u16 setup_time; - u8 cfg_channel; - bool i2c_high_speed; - - /* register access data */ - const struct omap_vc_common *common; - u32 smps_sa_mask; - u32 smps_volra_mask; - u32 smps_cmdra_mask; - u8 cmdval_reg; - u8 smps_sa_reg; - u8 smps_volra_reg; - u8 smps_cmdra_reg; - u8 cfg_channel_reg; - u8 cfg_channel_sa_shift; - u8 flags; -}; - -extern struct omap_vc_channel omap3_vc_mpu; -extern struct omap_vc_channel omap3_vc_core; - -extern struct omap_vc_channel omap4_vc_mpu; -extern struct omap_vc_channel omap4_vc_iva; -extern struct omap_vc_channel omap4_vc_core; - -void omap_vc_init_channel(struct voltagedomain *voltdm); -int omap_vc_pre_scale(struct voltagedomain *voltdm, - unsigned long target_volt, - u8 *target_vsel, u8 *current_vsel); -void omap_vc_post_scale(struct voltagedomain *voltdm, - unsigned long target_volt, - u8 target_vsel, u8 current_vsel); -int omap_vc_bypass_scale(struct voltagedomain *voltdm, - unsigned long target_volt); - -#endif - diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index cfe348e..588dd2e 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c @@ -19,11 +19,10 @@ #include #include +#include +#include #include "prm-regbits-34xx.h" -#include "voltage.h" - -#include "vc.h" /* * VC data common to 34xx/36xx chips diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index 2740a96..f36e195 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c @@ -19,13 +19,12 @@ #include #include +#include #include "prm44xx.h" #include "prm-regbits-44xx.h" #include "voltage.h" -#include "vc.h" - /* * VC data common to 44xx chips * XXX This stuff presumably belongs in the vc3xxx.c or vc.c file. diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 64070ac..c2a5a72 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c @@ -27,6 +27,9 @@ #include #include +#include +#include +#include #include "prm-regbits-34xx.h" #include "prm-regbits-44xx.h" @@ -35,12 +38,8 @@ #include "prminst44xx.h" #include "control.h" -#include "voltage.h" #include "powerdomain.h" -#include "vc.h" -#include "vp.h" - static LIST_HEAD(voltdm_list); /* Public functions */ diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h deleted file mode 100644 index 25053e2..0000000 --- a/arch/arm/mach-omap2/voltage.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * OMAP Voltage Management Routines - * - * Author: Thara Gopinath - * - * Copyright (C) 2009 Texas Instruments, Inc. - * Thara Gopinath - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H -#define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H - -#include - -#include "vc.h" -#include "vp.h" - -struct powerdomain; - -/* XXX document */ -#define VOLTSCALE_VPFORCEUPDATE 1 -#define VOLTSCALE_VCBYPASS 2 - -/* - * OMAP3 GENERIC setup times. Revisit to see if these needs to be - * passed from board or PMIC file - */ -#define OMAP3_CLKSETUP 0xff -#define OMAP3_VOLTOFFSET 0xff -#define OMAP3_VOLTSETUP2 0xff - -struct omap_vdd_info; - -/** - * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield - * data - * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register - * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base - * - * XXX What about VOLTOFFSET/VOLTCTRL? - */ -struct omap_vfsm_instance { - u32 voltsetup_mask; - u8 voltsetup_reg; -}; - -/** - * struct voltagedomain - omap voltage domain global structure. - * @name: Name of the voltage domain which can be used as a unique identifier. - * @scalable: Whether or not this voltage domain is scalable - * @node: list_head linking all voltage domains - * @pwrdm_list: list_head linking all powerdomains in this voltagedomain - * @vc: pointer to VC channel associated with this voltagedomain - * @vp: pointer to VP associated with this voltagedomain - * @read: read a VC/VP register - * @write: write a VC/VP register - * @read: read-modify-write a VC/VP register - * @sys_clk: system clock name/frequency, used for various timing calculations - * @scale: function used to scale the voltage of the voltagedomain - * @nominal_volt: current nominal voltage for this voltage domain - * @volt_data: voltage table having the distinct voltages supported - * by the domain and other associated per voltage data. - */ -struct voltagedomain { - char *name; - bool scalable; - struct list_head node; - struct list_head pwrdm_list; - struct omap_vc_channel *vc; - const struct omap_vfsm_instance *vfsm; - struct omap_vp_instance *vp; - struct omap_voltdm_pmic *pmic; - - /* VC/VP register access functions: SoC specific */ - u32 (*read) (u8 offset); - void (*write) (u32 val, u8 offset); - u32 (*rmw)(u32 mask, u32 bits, u8 offset); - - union { - const char *name; - u32 rate; - } sys_clk; - - int (*scale) (struct voltagedomain *voltdm, - unsigned long target_volt); - - u32 nominal_volt; - struct omap_volt_data *volt_data; - struct omap_vdd_info *vdd; - struct dentry *debug_dir; -}; - -/** - * struct omap_volt_data - Omap voltage specific data. - * @voltage_nominal: The possible voltage value in uV - * @sr_efuse_offs: The offset of the efuse register(from system - * control module base address) from where to read - * the n-target value for the smartreflex module. - * @sr_errminlimit: Error min limit value for smartreflex. This value - * differs at differnet opp and thus is linked - * with voltage. - * @vp_errorgain: Error gain value for the voltage processor. This - * field also differs according to the voltage/opp. - */ -struct omap_volt_data { - u32 volt_nominal; - u32 sr_efuse_offs; - u8 sr_errminlimit; - u8 vp_errgain; -}; - -/** - * struct omap_voltdm_pmic - PMIC specific data required by voltage driver. - * @slew_rate: PMIC slew rate (in uv/us) - * @step_size: PMIC voltage step size (in uv) - * @i2c_slave_addr: I2C slave address of PMIC - * @volt_reg_addr: voltage configuration register address - * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address - * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC - * @i2c_mcode: master code value for I2C high-speed preamble transmission - * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. - * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. - */ -struct omap_voltdm_pmic { - int slew_rate; - int step_size; - u32 on_volt; - u32 onlp_volt; - u32 ret_volt; - u32 off_volt; - u16 volt_setup_time; - u16 i2c_slave_addr; - u16 volt_reg_addr; - u16 cmd_reg_addr; - u8 vp_erroroffset; - u8 vp_vstepmin; - u8 vp_vstepmax; - u8 vp_vddmin; - u8 vp_vddmax; - u8 vp_timeout_us; - bool i2c_high_speed; - u8 i2c_mcode; - unsigned long (*vsel_to_uv) (const u8 vsel); - u8 (*uv_to_vsel) (unsigned long uV); -}; - -/** - * struct omap_vdd_dep_volt - Map table for voltage dependencies - * @main_vdd_volt : The main vdd voltage - * @dep_vdd_volt : The voltage at which the dependent vdd should be - * when the main vdd is at voltage - * - * Table containing the parent vdd voltage and the dependent vdd voltage - * corresponding to it. - */ -struct omap_vdd_dep_volt { - u32 main_vdd_volt; - u32 dep_vdd_volt; -}; - -/** - * struct omap_vdd_dep_info - Dependent vdd info - * @name : Dependent vdd name - * @_dep_voltdm : internal structure meant to prevent multiple lookups - * @dep_table : Table containing the dependent vdd voltage - * corresponding to every main vdd voltage. - * @nr_dep_entries : number of dependency voltage entries - */ -struct omap_vdd_dep_info { - char *name; - struct voltagedomain *_dep_voltdm; - struct omap_vdd_dep_volt *dep_table; - int nr_dep_entries; -}; - -/** - * 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. - * @dep_vdd_info : Array ending with a 0 terminator for dependency - * voltage information. - */ -struct omap_vdd_info { - struct omap_volt_data *volt_data; - struct omap_vdd_dep_info *dep_vdd_info; -}; - -void omap_voltage_get_volttable(struct voltagedomain *voltdm, - struct omap_volt_data **volt_data); -struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm, - unsigned long volt); -int omap_voltage_register_pmic(struct voltagedomain *voltdm, - struct omap_voltdm_pmic *pmic); -void omap_change_voltscale_method(struct voltagedomain *voltdm, - int voltscale_method); -int omap_voltage_late_init(void); - -extern void omap2xxx_voltagedomains_init(void); -extern void omap3xxx_voltagedomains_init(void); -extern void am33xx_voltagedomains_init(void); -extern void omap44xx_voltagedomains_init(void); - -struct voltagedomain *voltdm_lookup(const char *name); -void voltdm_init(struct voltagedomain **voltdm_list); -int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm); -int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user), - void *user); -int voltdm_for_each_pwrdm(struct voltagedomain *voltdm, - int (*fn)(struct voltagedomain *voltdm, - struct powerdomain *pwrdm)); -int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt); -void voltdm_reset(struct voltagedomain *voltdm); -unsigned long voltdm_get_voltage(struct voltagedomain *voltdm); -#endif diff --git a/arch/arm/mach-omap2/voltagedomains2xxx_data.c b/arch/arm/mach-omap2/voltagedomains2xxx_data.c index 7a41349..115a7ea 100644 --- a/arch/arm/mach-omap2/voltagedomains2xxx_data.c +++ b/arch/arm/mach-omap2/voltagedomains2xxx_data.c @@ -9,8 +9,8 @@ */ #include #include +#include -#include "voltage.h" static struct voltagedomain omap2_voltdm_core = { .name = "core", diff --git a/arch/arm/mach-omap2/voltagedomains33xx_data.c b/arch/arm/mach-omap2/voltagedomains33xx_data.c index f8c817a..46f0447 100644 --- a/arch/arm/mach-omap2/voltagedomains33xx_data.c +++ b/arch/arm/mach-omap2/voltagedomains33xx_data.c @@ -10,7 +10,7 @@ #include #include -#include "voltage.h" +#include static struct voltagedomain am33xx_voltdm_mpu = { .name = "mpu", diff --git a/arch/arm/mach-omap2/voltagedomains3xxx_data.c b/arch/arm/mach-omap2/voltagedomains3xxx_data.c index cca7005..d0ccf9a 100644 --- a/arch/arm/mach-omap2/voltagedomains3xxx_data.c +++ b/arch/arm/mach-omap2/voltagedomains3xxx_data.c @@ -20,12 +20,12 @@ #include #include +#include +#include +#include #include "prm-regbits-34xx.h" #include "omap_opp_data.h" -#include "voltage.h" -#include "vc.h" -#include "vp.h" /* * VDD data diff --git a/arch/arm/mach-omap2/voltagedomains44xx_data.c b/arch/arm/mach-omap2/voltagedomains44xx_data.c index 38f861d..748841c 100644 --- a/arch/arm/mach-omap2/voltagedomains44xx_data.c +++ b/arch/arm/mach-omap2/voltagedomains44xx_data.c @@ -22,6 +22,8 @@ #include #include +#include +#include #include "prm-regbits-44xx.h" #include "prm44xx.h" @@ -29,8 +31,6 @@ #include "prminst44xx.h" #include "voltage.h" #include "omap_opp_data.h" -#include "vc.h" -#include "vp.h" static const struct omap_vfsm_instance omap4_vdd_mpu_vfsm = { .voltsetup_reg = OMAP4_PRM_VOLTSETUP_MPU_RET_SLEEP_OFFSET, diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c index 66bd700..bb2ba63 100644 --- a/arch/arm/mach-omap2/vp.c +++ b/arch/arm/mach-omap2/vp.c @@ -2,9 +2,9 @@ #include #include +#include +#include -#include "voltage.h" -#include "vp.h" #include "prm-regbits-34xx.h" #include "prm-regbits-44xx.h" #include "prm44xx.h" diff --git a/arch/arm/mach-omap2/vp.h b/arch/arm/mach-omap2/vp.h deleted file mode 100644 index 7c155d2..0000000 --- a/arch/arm/mach-omap2/vp.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * OMAP3/4 Voltage Processor (VP) structure and macro definitions - * - * Copyright (C) 2007, 2010 Texas Instruments, Inc. - * Rajendra Nayak - * Lesly A M - * Thara Gopinath - * - * Copyright (C) 2008, 2011 Nokia Corporation - * Kalle Jokiniemi - * Paul Walmsley - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - */ -#ifndef __ARCH_ARM_MACH_OMAP2_VP_H -#define __ARCH_ARM_MACH_OMAP2_VP_H - -#include - -struct voltagedomain; - -/* - * Voltage Processor (VP) identifiers - */ -#define OMAP3_VP_VDD_MPU_ID 0 -#define OMAP3_VP_VDD_CORE_ID 1 -#define OMAP4_VP_VDD_CORE_ID 0 -#define OMAP4_VP_VDD_IVA_ID 1 -#define OMAP4_VP_VDD_MPU_ID 2 - -/* XXX document */ -#define VP_IDLE_TIMEOUT 200 -#define VP_TRANXDONE_TIMEOUT 300 - -/** - * struct omap_vp_ops - per-VP operations - * @check_txdone: check for VP transaction done - * @clear_txdone: clear VP transaction done status - */ -struct omap_vp_ops { - u32 (*check_txdone)(u8 vp_id); - void (*clear_txdone)(u8 vp_id); -}; - -/** - * struct omap_vp_common - register data common to all VDDs - * @vpconfig_erroroffset_mask: ERROROFFSET bitmask in the PRM_VP*_CONFIG reg - * @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg - * @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg - * @vpconfig_timeouten: TIMEOUT bitmask in the PRM_VP*_CONFIG reg - * @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg - * @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg - * @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg - * @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg - * @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg - * @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg - * @vstepmin_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg - * @vstepmin_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg - * @vstepmax_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg - * @vstepmax_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg - * @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg - * @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg - * @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg - * @vpvoltage_mask: VPVOLTAGE field mask in PRM_VP*_VOLTAGE reg - */ -struct omap_vp_common { - u32 vpconfig_erroroffset_mask; - u32 vpconfig_errorgain_mask; - u32 vpconfig_initvoltage_mask; - u8 vpconfig_timeouten; - u8 vpconfig_initvdd; - u8 vpconfig_forceupdate; - u8 vpconfig_vpenable; - u8 vstepmin_stepmin_shift; - u8 vstepmin_smpswaittimemin_shift; - u8 vstepmax_stepmax_shift; - u8 vstepmax_smpswaittimemax_shift; - u8 vlimitto_vddmin_shift; - u8 vlimitto_vddmax_shift; - u8 vlimitto_timeout_shift; - u8 vpvoltage_mask; - - const struct omap_vp_ops *ops; -}; - -/** - * struct omap_vp_instance - VP register offsets (per-VDD) - * @common: pointer to struct omap_vp_common * for this SoC - * @vpconfig: PRM_VP*_CONFIG reg offset from PRM start - * @vstepmin: PRM_VP*_VSTEPMIN reg offset from PRM start - * @vlimitto: PRM_VP*_VLIMITTO reg offset from PRM start - * @vstatus: PRM_VP*_VSTATUS reg offset from PRM start - * @voltage: PRM_VP*_VOLTAGE reg offset from PRM start - * @id: Unique identifier for VP instance. - * @enabled: flag to keep track of whether vp is enabled or not - * - * XXX vp_common is probably not needed since it is per-SoC - */ -struct omap_vp_instance { - const struct omap_vp_common *common; - u8 vpconfig; - u8 vstepmin; - u8 vstepmax; - u8 vlimitto; - u8 vstatus; - u8 voltage; - u8 id; - bool enabled; -}; - -extern struct omap_vp_instance omap3_vp_mpu; -extern struct omap_vp_instance omap3_vp_core; - -extern struct omap_vp_instance omap4_vp_mpu; -extern struct omap_vp_instance omap4_vp_iva; -extern struct omap_vp_instance omap4_vp_core; - -void omap_vp_init(struct voltagedomain *voltdm); -void omap_vp_enable(struct voltagedomain *voltdm); -void omap_vp_disable(struct voltagedomain *voltdm); -int omap_vp_forceupdate_scale(struct voltagedomain *voltdm, - unsigned long target_volt); -int omap_vp_update_errorgain(struct voltagedomain *voltdm, - unsigned long target_volt); - -#endif diff --git a/arch/arm/mach-omap2/vp3xxx_data.c b/arch/arm/mach-omap2/vp3xxx_data.c index 260c554..c57027c 100644 --- a/arch/arm/mach-omap2/vp3xxx_data.c +++ b/arch/arm/mach-omap2/vp3xxx_data.c @@ -20,11 +20,11 @@ #include #include +#include +#include #include "prm-regbits-34xx.h" -#include "voltage.h" -#include "vp.h" #include "prm2xxx_3xxx.h" static const struct omap_vp_ops omap3_vp_ops = { diff --git a/arch/arm/mach-omap2/vp44xx_data.c b/arch/arm/mach-omap2/vp44xx_data.c index b4e7704..90c6819 100644 --- a/arch/arm/mach-omap2/vp44xx_data.c +++ b/arch/arm/mach-omap2/vp44xx_data.c @@ -20,12 +20,11 @@ #include #include +#include +#include #include "prm44xx.h" #include "prm-regbits-44xx.h" -#include "voltage.h" - -#include "vp.h" static const struct omap_vp_ops omap4_vp_ops = { .check_txdone = omap4_prm_vp_check_txdone, diff --git a/arch/arm/plat-omap/include/plat/dvfs.h b/arch/arm/plat-omap/include/plat/dvfs.h new file mode 100644 index 0000000..5a73fe8 --- /dev/null +++ b/arch/arm/plat-omap/include/plat/dvfs.h @@ -0,0 +1,38 @@ +/* + * OMAP3/OMAP4 DVFS Management Routines + * + * Author: Vishwanath BS + * + * Copyright (C) 2011 Texas Instruments, Inc. + * Vishwanath BS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ARCH_ARM_MACH_OMAP2_DVFS_H +#define __ARCH_ARM_MACH_OMAP2_DVFS_H +#include +#include + +#ifdef CONFIG_PM +int omap_dvfs_register_device(struct device *dev, char *voltdm_name, + char *clk_name); +int omap_device_scale(struct device *req_dev, struct device *target_dev, + unsigned long rate); +#else +static inline int omap_dvfs_register_device(struct omap_hwmod *oh, + struct device *dev) +static inline int omap_dvfs_register_device(struct device *dev, + char *voltdm_name, char *clk_name) +{ + return -EINVAL; +} +static inline int omap_device_scale(struct device *req_dev, + struct device *target_dev, unsigned long rate) +{ + return -EINVAL; +} +#endif +#endif diff --git a/arch/arm/plat-omap/include/plat/vc.h b/arch/arm/plat-omap/include/plat/vc.h new file mode 100644 index 0000000..98b0569 --- /dev/null +++ b/arch/arm/plat-omap/include/plat/vc.h @@ -0,0 +1,124 @@ +/* + * OMAP3/4 Voltage Controller (VC) structure and macro definitions + * + * Copyright (C) 2007, 2010 Texas Instruments, Inc. + * Rajendra Nayak + * Lesly A M + * Thara Gopinath + * + * Copyright (C) 2008, 2011 Nokia Corporation + * Kalle Jokiniemi + * Paul Walmsley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + */ +#ifndef __ARCH_ARM_MACH_OMAP2_VC_H +#define __ARCH_ARM_MACH_OMAP2_VC_H + +#include + +struct voltagedomain; + +/** + * struct omap_vc_common - per-VC register/bitfield data + * @cmd_on_mask: ON bitmask in PRM_VC_CMD_VAL* register + * @valid: VALID bitmask in PRM_VC_BYPASS_VAL register + * @bypass_val_reg: Offset of PRM_VC_BYPASS_VAL reg from PRM start + * @data_shift: DATA field shift in PRM_VC_BYPASS_VAL register + * @slaveaddr_shift: SLAVEADDR field shift in PRM_VC_BYPASS_VAL register + * @regaddr_shift: REGADDR field shift in PRM_VC_BYPASS_VAL register + * @cmd_on_shift: ON field shift in PRM_VC_CMD_VAL_* register + * @cmd_onlp_shift: ONLP field shift in PRM_VC_CMD_VAL_* register + * @cmd_ret_shift: RET field shift in PRM_VC_CMD_VAL_* register + * @cmd_off_shift: OFF field shift in PRM_VC_CMD_VAL_* register + * @i2c_cfg_reg: I2C configuration register offset + * @i2c_cfg_hsen_mask: high-speed mode bit field mask in I2C config register + * @i2c_mcode_mask: MCODE field mask for I2C config register + * + * XXX One of cmd_on_mask and cmd_on_shift are not needed + * XXX VALID should probably be a shift, not a mask + */ +struct omap_vc_common { + u32 cmd_on_mask; + u32 valid; + u8 bypass_val_reg; + u8 data_shift; + u8 slaveaddr_shift; + u8 regaddr_shift; + u8 cmd_on_shift; + u8 cmd_onlp_shift; + u8 cmd_ret_shift; + u8 cmd_off_shift; + u8 i2c_cfg_reg; + u8 i2c_cfg_hsen_mask; + u8 i2c_mcode_mask; +}; + +/* omap_vc_channel.flags values */ +#define OMAP_VC_CHANNEL_DEFAULT BIT(0) +#define OMAP_VC_CHANNEL_CFG_MUTANT BIT(1) + +/** + * struct omap_vc_channel - VC per-instance data + * @i2c_slave_addr: I2C slave address of PMIC for this VC channel + * @volt_reg_addr: voltage configuration register address + * @cmd_reg_addr: command configuration register address + * @setup_time: setup time (in sys_clk cycles) of regulator for this channel + * @cfg_channel: current value of VC channel configuration register + * @i2c_high_speed: whether or not to use I2C high-speed mode + * + * @common: pointer to VC common data for this platform + * @smps_sa_mask: i2c slave address bitmask in the PRM_VC_SMPS_SA register + * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register + * @smps_cmdra_mask: CMDRA* bitmask in the PRM_VC_CMD_RA register + * @cmdval_reg: register for on/ret/off voltage level values for this channel + * @smps_sa_reg: Offset of PRM_VC_SMPS_SA reg from PRM start + * @smps_volra_reg: Offset of PRM_VC_SMPS_VOL_RA reg from PRM start + * @smps_cmdra_reg: Offset of PRM_VC_SMPS_CMD_RA reg from PRM start + * @cfg_channel_reg: VC channel configuration register + * @cfg_channel_sa_shift: bit shift for slave address cfg_channel register + * @flags: VC channel-specific flags (optional) + */ +struct omap_vc_channel { + /* channel state */ + u16 i2c_slave_addr; + u16 volt_reg_addr; + u16 cmd_reg_addr; + u16 setup_time; + u8 cfg_channel; + bool i2c_high_speed; + + /* register access data */ + const struct omap_vc_common *common; + u32 smps_sa_mask; + u32 smps_volra_mask; + u32 smps_cmdra_mask; + u8 cmdval_reg; + u8 smps_sa_reg; + u8 smps_volra_reg; + u8 smps_cmdra_reg; + u8 cfg_channel_reg; + u8 cfg_channel_sa_shift; + u8 flags; +}; + +extern struct omap_vc_channel omap3_vc_mpu; +extern struct omap_vc_channel omap3_vc_core; + +extern struct omap_vc_channel omap4_vc_mpu; +extern struct omap_vc_channel omap4_vc_iva; +extern struct omap_vc_channel omap4_vc_core; + +void omap_vc_init_channel(struct voltagedomain *voltdm); +int omap_vc_pre_scale(struct voltagedomain *voltdm, + unsigned long target_volt, + u8 *target_vsel, u8 *current_vsel); +void omap_vc_post_scale(struct voltagedomain *voltdm, + unsigned long target_volt, + u8 target_vsel, u8 current_vsel); +int omap_vc_bypass_scale(struct voltagedomain *voltdm, + unsigned long target_volt); + +#endif diff --git a/arch/arm/plat-omap/include/plat/voltage.h b/arch/arm/plat-omap/include/plat/voltage.h index 0a6a482..f309433 100644 --- a/arch/arm/plat-omap/include/plat/voltage.h +++ b/arch/arm/plat-omap/include/plat/voltage.h @@ -1,7 +1,10 @@ /* * OMAP Voltage Management Routines * - * Copyright (C) 2011, Texas Instruments, Inc. + * Author: Thara Gopinath + * + * Copyright (C) 2009 Texas Instruments, Inc. + * Thara Gopinath * * 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 @@ -11,10 +14,206 @@ #ifndef __ARCH_ARM_OMAP_VOLTAGE_H #define __ARCH_ARM_OMAP_VOLTAGE_H -struct voltagedomain; +#include + +#include +#include + +struct powerdomain; + +/* XXX document */ +#define VOLTSCALE_VPFORCEUPDATE 1 +#define VOLTSCALE_VCBYPASS 2 + +/* + * OMAP3 GENERIC setup times. Revisit to see if these needs to be + * passed from board or PMIC file + */ +#define OMAP3_CLKSETUP 0xff +#define OMAP3_VOLTOFFSET 0xff +#define OMAP3_VOLTSETUP2 0xff + +struct omap_vdd_info; + +/** + * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield + * data + * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register + * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base + * + * XXX What about VOLTOFFSET/VOLTCTRL? + */ +struct omap_vfsm_instance { + u32 voltsetup_mask; + u8 voltsetup_reg; +}; + +/** + * struct voltagedomain - omap voltage domain global structure. + * @name: Name of the voltage domain which can be used as a unique identifier. + * @scalable: Whether or not this voltage domain is scalable + * @node: list_head linking all voltage domains + * @pwrdm_list: list_head linking all powerdomains in this voltagedomain + * @vc: pointer to VC channel associated with this voltagedomain + * @vp: pointer to VP associated with this voltagedomain + * @read: read a VC/VP register + * @write: write a VC/VP register + * @read: read-modify-write a VC/VP register + * @sys_clk: system clock name/frequency, used for various timing calculations + * @scale: function used to scale the voltage of the voltagedomain + * @nominal_volt: current nominal voltage for this voltage domain + * @volt_data: voltage table having the distinct voltages supported + * by the domain and other associated per voltage data. + */ +struct voltagedomain { + char *name; + bool scalable; + struct list_head node; + struct list_head pwrdm_list; + struct omap_vc_channel *vc; + const struct omap_vfsm_instance *vfsm; + struct omap_vp_instance *vp; + struct omap_voltdm_pmic *pmic; + + /* VC/VP register access functions: SoC specific */ + u32 (*read) (u8 offset); + void (*write) (u32 val, u8 offset); + u32 (*rmw)(u32 mask, u32 bits, u8 offset); + + union { + const char *name; + u32 rate; + } sys_clk; + + int (*scale) (struct voltagedomain *voltdm, + unsigned long target_volt); + + u32 nominal_volt; + struct omap_volt_data *volt_data; + struct omap_vdd_info *vdd; + struct dentry *debug_dir; +}; + +/** + * struct omap_volt_data - Omap voltage specific data. + * @voltage_nominal: The possible voltage value in uV + * @sr_efuse_offs: The offset of the efuse register(from system + * control module base address) from where to read + * the n-target value for the smartreflex module. + * @sr_errminlimit: Error min limit value for smartreflex. This value + * differs at differnet opp and thus is linked + * with voltage. + * @vp_errorgain: Error gain value for the voltage processor. This + * field also differs according to the voltage/opp. + */ +struct omap_volt_data { + u32 volt_nominal; + u32 sr_efuse_offs; + u8 sr_errminlimit; + u8 vp_errgain; +}; + +/** + * struct omap_voltdm_pmic - PMIC specific data required by voltage driver. + * @slew_rate: PMIC slew rate (in uv/us) + * @step_size: PMIC voltage step size (in uv) + * @i2c_slave_addr: I2C slave address of PMIC + * @volt_reg_addr: voltage configuration register address + * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address + * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC + * @i2c_mcode: master code value for I2C high-speed preamble transmission + * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. + * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. + */ +struct omap_voltdm_pmic { + int slew_rate; + int step_size; + u32 on_volt; + u32 onlp_volt; + u32 ret_volt; + u32 off_volt; + u16 volt_setup_time; + u16 i2c_slave_addr; + u16 volt_reg_addr; + u16 cmd_reg_addr; + u8 vp_erroroffset; + u8 vp_vstepmin; + u8 vp_vstepmax; + u8 vp_vddmin; + u8 vp_vddmax; + u8 vp_timeout_us; + bool i2c_high_speed; + u8 i2c_mcode; + unsigned long (*vsel_to_uv) (const u8 vsel); + u8 (*uv_to_vsel) (unsigned long uV); +}; + +/** + * struct omap_vdd_dep_volt - Map table for voltage dependencies + * @main_vdd_volt : The main vdd voltage + * @dep_vdd_volt : The voltage at which the dependent vdd should be + * when the main vdd is at voltage + * + * Table containing the parent vdd voltage and the dependent vdd voltage + * corresponding to it. + */ +struct omap_vdd_dep_volt { + u32 main_vdd_volt; + u32 dep_vdd_volt; +}; + +/** + * struct omap_vdd_dep_info - Dependent vdd info + * @name : Dependent vdd name + * @_dep_voltdm : internal structure meant to prevent multiple lookups + * @dep_table : Table containing the dependent vdd voltage + * corresponding to every main vdd voltage. + * @nr_dep_entries : number of dependency voltage entries + */ +struct omap_vdd_dep_info { + char *name; + struct voltagedomain *_dep_voltdm; + struct omap_vdd_dep_volt *dep_table; + int nr_dep_entries; +}; + +/** + * 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. + * @dep_vdd_info : Array ending with a 0 terminator for dependency + * voltage information. + */ +struct omap_vdd_info { + struct omap_volt_data *volt_data; + struct omap_vdd_dep_info *dep_vdd_info; +}; + +void omap_voltage_get_volttable(struct voltagedomain *voltdm, + struct omap_volt_data **volt_data); +struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm, + unsigned long volt); +int omap_voltage_register_pmic(struct voltagedomain *voltdm, + struct omap_voltdm_pmic *pmic); +void omap_change_voltscale_method(struct voltagedomain *voltdm, + int voltscale_method); +int omap_voltage_late_init(void); + +extern void omap2xxx_voltagedomains_init(void); +extern void omap3xxx_voltagedomains_init(void); +extern void am33xx_voltagedomains_init(void); +extern void omap44xx_voltagedomains_init(void); struct voltagedomain *voltdm_lookup(const char *name); +void voltdm_init(struct voltagedomain **voltdm_list); +int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm); +int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user), + void *user); +int voltdm_for_each_pwrdm(struct voltagedomain *voltdm, + int (*fn)(struct voltagedomain *voltdm, + struct powerdomain *pwrdm)); int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt); +void voltdm_reset(struct voltagedomain *voltdm); unsigned long voltdm_get_voltage(struct voltagedomain *voltdm); - #endif diff --git a/arch/arm/plat-omap/include/plat/vp.h b/arch/arm/plat-omap/include/plat/vp.h new file mode 100644 index 0000000..7c155d2 --- /dev/null +++ b/arch/arm/plat-omap/include/plat/vp.h @@ -0,0 +1,128 @@ +/* + * OMAP3/4 Voltage Processor (VP) structure and macro definitions + * + * Copyright (C) 2007, 2010 Texas Instruments, Inc. + * Rajendra Nayak + * Lesly A M + * Thara Gopinath + * + * Copyright (C) 2008, 2011 Nokia Corporation + * Kalle Jokiniemi + * Paul Walmsley + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + */ +#ifndef __ARCH_ARM_MACH_OMAP2_VP_H +#define __ARCH_ARM_MACH_OMAP2_VP_H + +#include + +struct voltagedomain; + +/* + * Voltage Processor (VP) identifiers + */ +#define OMAP3_VP_VDD_MPU_ID 0 +#define OMAP3_VP_VDD_CORE_ID 1 +#define OMAP4_VP_VDD_CORE_ID 0 +#define OMAP4_VP_VDD_IVA_ID 1 +#define OMAP4_VP_VDD_MPU_ID 2 + +/* XXX document */ +#define VP_IDLE_TIMEOUT 200 +#define VP_TRANXDONE_TIMEOUT 300 + +/** + * struct omap_vp_ops - per-VP operations + * @check_txdone: check for VP transaction done + * @clear_txdone: clear VP transaction done status + */ +struct omap_vp_ops { + u32 (*check_txdone)(u8 vp_id); + void (*clear_txdone)(u8 vp_id); +}; + +/** + * struct omap_vp_common - register data common to all VDDs + * @vpconfig_erroroffset_mask: ERROROFFSET bitmask in the PRM_VP*_CONFIG reg + * @vpconfig_errorgain_mask: ERRORGAIN bitmask in the PRM_VP*_CONFIG reg + * @vpconfig_initvoltage_mask: INITVOLTAGE bitmask in the PRM_VP*_CONFIG reg + * @vpconfig_timeouten: TIMEOUT bitmask in the PRM_VP*_CONFIG reg + * @vpconfig_initvdd: INITVDD bitmask in the PRM_VP*_CONFIG reg + * @vpconfig_forceupdate: FORCEUPDATE bitmask in the PRM_VP*_CONFIG reg + * @vpconfig_vpenable: VPENABLE bitmask in the PRM_VP*_CONFIG reg + * @vpconfig_erroroffset_shift: ERROROFFSET field shift in PRM_VP*_CONFIG reg + * @vpconfig_errorgain_shift: ERRORGAIN field shift in PRM_VP*_CONFIG reg + * @vpconfig_initvoltage_shift: INITVOLTAGE field shift in PRM_VP*_CONFIG reg + * @vstepmin_stepmin_shift: VSTEPMIN field shift in the PRM_VP*_VSTEPMIN reg + * @vstepmin_smpswaittimemin_shift: SMPSWAITTIMEMIN field shift in PRM_VP*_VSTEPMIN reg + * @vstepmax_stepmax_shift: VSTEPMAX field shift in the PRM_VP*_VSTEPMAX reg + * @vstepmax_smpswaittimemax_shift: SMPSWAITTIMEMAX field shift in PRM_VP*_VSTEPMAX reg + * @vlimitto_vddmin_shift: VDDMIN field shift in PRM_VP*_VLIMITTO reg + * @vlimitto_vddmax_shift: VDDMAX field shift in PRM_VP*_VLIMITTO reg + * @vlimitto_timeout_shift: TIMEOUT field shift in PRM_VP*_VLIMITTO reg + * @vpvoltage_mask: VPVOLTAGE field mask in PRM_VP*_VOLTAGE reg + */ +struct omap_vp_common { + u32 vpconfig_erroroffset_mask; + u32 vpconfig_errorgain_mask; + u32 vpconfig_initvoltage_mask; + u8 vpconfig_timeouten; + u8 vpconfig_initvdd; + u8 vpconfig_forceupdate; + u8 vpconfig_vpenable; + u8 vstepmin_stepmin_shift; + u8 vstepmin_smpswaittimemin_shift; + u8 vstepmax_stepmax_shift; + u8 vstepmax_smpswaittimemax_shift; + u8 vlimitto_vddmin_shift; + u8 vlimitto_vddmax_shift; + u8 vlimitto_timeout_shift; + u8 vpvoltage_mask; + + const struct omap_vp_ops *ops; +}; + +/** + * struct omap_vp_instance - VP register offsets (per-VDD) + * @common: pointer to struct omap_vp_common * for this SoC + * @vpconfig: PRM_VP*_CONFIG reg offset from PRM start + * @vstepmin: PRM_VP*_VSTEPMIN reg offset from PRM start + * @vlimitto: PRM_VP*_VLIMITTO reg offset from PRM start + * @vstatus: PRM_VP*_VSTATUS reg offset from PRM start + * @voltage: PRM_VP*_VOLTAGE reg offset from PRM start + * @id: Unique identifier for VP instance. + * @enabled: flag to keep track of whether vp is enabled or not + * + * XXX vp_common is probably not needed since it is per-SoC + */ +struct omap_vp_instance { + const struct omap_vp_common *common; + u8 vpconfig; + u8 vstepmin; + u8 vstepmax; + u8 vlimitto; + u8 vstatus; + u8 voltage; + u8 id; + bool enabled; +}; + +extern struct omap_vp_instance omap3_vp_mpu; +extern struct omap_vp_instance omap3_vp_core; + +extern struct omap_vp_instance omap4_vp_mpu; +extern struct omap_vp_instance omap4_vp_iva; +extern struct omap_vp_instance omap4_vp_core; + +void omap_vp_init(struct voltagedomain *voltdm); +void omap_vp_enable(struct voltagedomain *voltdm); +void omap_vp_disable(struct voltagedomain *voltdm); +int omap_vp_forceupdate_scale(struct voltagedomain *voltdm, + unsigned long target_volt); +int omap_vp_update_errorgain(struct voltagedomain *voltdm, + unsigned long target_volt); + +#endif diff --git a/drivers/cpufreq/omap-cpufreq.c b/drivers/cpufreq/omap-cpufreq.c index ef6fe20..3a09634 100644 --- a/drivers/cpufreq/omap-cpufreq.c +++ b/drivers/cpufreq/omap-cpufreq.c @@ -33,6 +33,7 @@ #include #include #include +#include #include -- 1.9.1