2 * OMAP Voltage Management Routines
4 * Author: Thara Gopinath <thara@ti.com>
6 * Copyright (C) 2009 Texas Instruments, Inc.
7 * Thara Gopinath <thara@ti.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
15 #define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
17 #include <linux/err.h>
25 #define VOLTSCALE_VPFORCEUPDATE 1
26 #define VOLTSCALE_VCBYPASS 2
29 * OMAP3 GENERIC setup times. Revisit to see if these needs to be
30 * passed from board or PMIC file
32 #define OMAP3_CLKSETUP 0xff
33 #define OMAP3_VOLTOFFSET 0xff
34 #define OMAP3_VOLTSETUP2 0xff
39 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
41 * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
42 * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
44 * XXX What about VOLTOFFSET/VOLTCTRL?
46 struct omap_vfsm_instance {
52 * struct voltagedomain - omap voltage domain global structure.
53 * @name: Name of the voltage domain which can be used as a unique identifier.
54 * @scalable: Whether or not this voltage domain is scalable
55 * @node: list_head linking all voltage domains
56 * @pwrdm_list: list_head linking all powerdomains in this voltagedomain
57 * @vc: pointer to VC channel associated with this voltagedomain
58 * @read: read a VC/VP register
59 * @write: write a VC/VP register
60 * @read: read-modify-write a VC/VP register
63 struct voltagedomain {
66 struct list_head node;
67 struct list_head pwrdm_list;
68 struct omap_vc_channel *vc;
69 const struct omap_vfsm_instance *vfsm;
71 /* VC/VP register access functions: SoC specific */
72 u32 (*read) (u8 offset);
73 void (*write) (u32 val, u8 offset);
74 u32 (*rmw)(u32 mask, u32 bits, u8 offset);
76 struct omap_vdd_info *vdd;
80 * struct omap_volt_data - Omap voltage specific data.
81 * @voltage_nominal: The possible voltage value in uV
82 * @sr_efuse_offs: The offset of the efuse register(from system
83 * control module base address) from where to read
84 * the n-target value for the smartreflex module.
85 * @sr_errminlimit: Error min limit value for smartreflex. This value
86 * differs at differnet opp and thus is linked
88 * @vp_errorgain: Error gain value for the voltage processor. This
89 * field also differs according to the voltage/opp.
91 struct omap_volt_data {
99 * struct omap_volt_pmic_info - PMIC specific data required by voltage driver.
100 * @slew_rate: PMIC slew rate (in uv/us)
101 * @step_size: PMIC voltage step size (in uv)
102 * @i2c_slave_addr: I2C slave address of PMIC
103 * @volt_reg_addr: voltage configuration register address
104 * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
105 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
106 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
108 struct omap_volt_pmic_info {
125 unsigned long (*vsel_to_uv) (const u8 vsel);
126 u8 (*uv_to_vsel) (unsigned long uV);
130 * omap_vdd_info - Per Voltage Domain info
132 * @volt_data : voltage table having the distinct voltages supported
133 * by the domain and other associated per voltage data.
134 * @pmic_info : pmic specific parameters which should be populted by
136 * @vp_data : the register values, shifts, masks for various
138 * @vp_rt_data : VP data derived at runtime, not predefined
139 * @debug_dir : debug directory for this voltage domain.
140 * @curr_volt : current voltage for this vdd.
141 * @vp_enabled : flag to keep track of whether vp is enabled or not
142 * @volt_scale : API to scale the voltage of the vdd.
144 struct omap_vdd_info {
145 struct omap_volt_data *volt_data;
146 struct omap_volt_pmic_info *pmic_info;
147 struct omap_vp_instance_data *vp_data;
148 struct omap_vp_runtime_data vp_rt_data;
149 struct dentry *debug_dir;
153 int (*volt_scale) (struct voltagedomain *voltdm,
154 unsigned long target_volt);
157 int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
158 unsigned long target_volt);
159 void omap_voltage_reset(struct voltagedomain *voltdm);
160 void omap_voltage_get_volttable(struct voltagedomain *voltdm,
161 struct omap_volt_data **volt_data);
162 struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
164 unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
165 struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm);
167 int omap_voltage_register_pmic(struct voltagedomain *voltdm,
168 struct omap_volt_pmic_info *pmic_info);
169 void omap_change_voltscale_method(struct voltagedomain *voltdm,
170 int voltscale_method);
171 int omap_voltage_late_init(void);
173 static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm,
174 struct omap_volt_pmic_info *pmic_info)
178 static inline void omap_change_voltscale_method(struct voltagedomain *voltdm,
179 int voltscale_method) {}
180 static inline int omap_voltage_late_init(void)
186 extern void omap2xxx_voltagedomains_init(void);
187 extern void omap3xxx_voltagedomains_init(void);
188 extern void omap44xx_voltagedomains_init(void);
190 struct voltagedomain *voltdm_lookup(const char *name);
191 void voltdm_init(struct voltagedomain **voltdm_list);
192 int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
193 int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
195 int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
196 int (*fn)(struct voltagedomain *voltdm,
197 struct powerdomain *pwrdm));