OMAP3+: voltage: move/rename curr_volt from vdd_info into struct voltagedomain
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-omap2 / voltage.h
blob0bd71a2910ab9f1aca6e8dda36a9867cf5914d90
1 /*
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>
19 #include "vc.h"
20 #include "vp.h"
22 struct powerdomain;
24 /* XXX document */
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
36 struct omap_vdd_info;
38 /**
39 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
40 * data
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 {
47 u32 voltsetup_mask;
48 u8 voltsetup_reg;
51 /**
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 * @vp: pointer to VP associated with this voltagedomain
59 * @read: read a VC/VP register
60 * @write: write a VC/VP register
61 * @read: read-modify-write a VC/VP register
62 * @sys_clk: system clock name/frequency, used for various timing calculations
63 * @vdd: to be removed
64 * @scale: function used to scale the voltage of the voltagedomain
65 * @nominal_volt: current nominal voltage for this voltage domain
67 struct voltagedomain {
68 char *name;
69 bool scalable;
70 struct list_head node;
71 struct list_head pwrdm_list;
72 struct omap_vc_channel *vc;
73 const struct omap_vfsm_instance *vfsm;
74 struct omap_vp_instance *vp;
75 struct omap_voltdm_pmic *pmic;
77 /* VC/VP register access functions: SoC specific */
78 u32 (*read) (u8 offset);
79 void (*write) (u32 val, u8 offset);
80 u32 (*rmw)(u32 mask, u32 bits, u8 offset);
82 union {
83 const char *name;
84 u32 rate;
85 } sys_clk;
87 int (*scale) (struct voltagedomain *voltdm,
88 unsigned long target_volt);
89 u32 nominal_volt;
91 struct omap_vdd_info *vdd;
94 /**
95 * struct omap_volt_data - Omap voltage specific data.
96 * @voltage_nominal: The possible voltage value in uV
97 * @sr_efuse_offs: The offset of the efuse register(from system
98 * control module base address) from where to read
99 * the n-target value for the smartreflex module.
100 * @sr_errminlimit: Error min limit value for smartreflex. This value
101 * differs at differnet opp and thus is linked
102 * with voltage.
103 * @vp_errorgain: Error gain value for the voltage processor. This
104 * field also differs according to the voltage/opp.
106 struct omap_volt_data {
107 u32 volt_nominal;
108 u32 sr_efuse_offs;
109 u8 sr_errminlimit;
110 u8 vp_errgain;
114 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
115 * @slew_rate: PMIC slew rate (in uv/us)
116 * @step_size: PMIC voltage step size (in uv)
117 * @i2c_slave_addr: I2C slave address of PMIC
118 * @volt_reg_addr: voltage configuration register address
119 * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
120 * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
121 * @i2c_mcode: master code value for I2C high-speed preamble transmission
122 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
123 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
125 struct omap_voltdm_pmic {
126 int slew_rate;
127 int step_size;
128 u32 on_volt;
129 u32 onlp_volt;
130 u32 ret_volt;
131 u32 off_volt;
132 u16 volt_setup_time;
133 u16 i2c_slave_addr;
134 u16 volt_reg_addr;
135 u16 cmd_reg_addr;
136 u8 vp_erroroffset;
137 u8 vp_vstepmin;
138 u8 vp_vstepmax;
139 u8 vp_vddmin;
140 u8 vp_vddmax;
141 u8 vp_timeout_us;
142 bool i2c_high_speed;
143 u8 i2c_mcode;
144 unsigned long (*vsel_to_uv) (const u8 vsel);
145 u8 (*uv_to_vsel) (unsigned long uV);
149 * omap_vdd_info - Per Voltage Domain info
151 * @volt_data : voltage table having the distinct voltages supported
152 * by the domain and other associated per voltage data.
154 struct omap_vdd_info {
155 struct omap_volt_data *volt_data;
158 void omap_voltage_get_volttable(struct voltagedomain *voltdm,
159 struct omap_volt_data **volt_data);
160 struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
161 unsigned long volt);
162 unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
163 #ifdef CONFIG_PM
164 int omap_voltage_register_pmic(struct voltagedomain *voltdm,
165 struct omap_voltdm_pmic *pmic);
166 void omap_change_voltscale_method(struct voltagedomain *voltdm,
167 int voltscale_method);
168 int omap_voltage_late_init(void);
169 #else
170 static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm,
171 struct omap_voltdm_pmic *pmic)
173 return -EINVAL;
175 static inline void omap_change_voltscale_method(struct voltagedomain *voltdm,
176 int voltscale_method) {}
177 static inline int omap_voltage_late_init(void)
179 return -EINVAL;
181 #endif
183 extern void omap2xxx_voltagedomains_init(void);
184 extern void omap3xxx_voltagedomains_init(void);
185 extern void omap44xx_voltagedomains_init(void);
187 struct voltagedomain *voltdm_lookup(const char *name);
188 void voltdm_init(struct voltagedomain **voltdm_list);
189 int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
190 int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
191 void *user);
192 int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
193 int (*fn)(struct voltagedomain *voltdm,
194 struct powerdomain *pwrdm));
195 int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
196 void voltdm_reset(struct voltagedomain *voltdm);
197 #endif