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
37 * struct omap_vfsm_instance - per-voltage manager FSM register/bitfield
39 * @voltsetup_mask: SETUP_TIME* bitmask in the PRM_VOLTSETUP* register
40 * @voltsetup_reg: register offset of PRM_VOLTSETUP from PRM base
42 * XXX What about VOLTOFFSET/VOLTCTRL?
44 struct omap_vfsm_instance
{
50 * struct voltagedomain - omap voltage domain global structure.
51 * @name: Name of the voltage domain which can be used as a unique identifier.
52 * @scalable: Whether or not this voltage domain is scalable
53 * @node: list_head linking all voltage domains
54 * @pwrdm_list: list_head linking all powerdomains in this voltagedomain
55 * @vc: pointer to VC channel associated with this voltagedomain
56 * @vp: pointer to VP associated with this voltagedomain
57 * @read: read a VC/VP register
58 * @write: write a VC/VP register
59 * @read: read-modify-write a VC/VP register
60 * @sys_clk: system clock name/frequency, used for various timing calculations
61 * @scale: function used to scale the voltage of the voltagedomain
62 * @nominal_volt: current nominal voltage for this voltage domain
63 * @volt_data: voltage table having the distinct voltages supported
64 * by the domain and other associated per voltage data.
66 struct voltagedomain
{
69 struct list_head node
;
70 struct list_head pwrdm_list
;
71 struct omap_vc_channel
*vc
;
72 const struct omap_vfsm_instance
*vfsm
;
73 struct omap_vp_instance
*vp
;
74 struct omap_voltdm_pmic
*pmic
;
76 /* VC/VP register access functions: SoC specific */
77 u32 (*read
) (u8 offset
);
78 void (*write
) (u32 val
, u8 offset
);
79 u32 (*rmw
)(u32 mask
, u32 bits
, u8 offset
);
86 int (*scale
) (struct voltagedomain
*voltdm
,
87 unsigned long target_volt
);
90 struct omap_volt_data
*volt_data
;
94 * struct omap_volt_data - Omap voltage specific data.
95 * @voltage_nominal: The possible voltage value in uV
96 * @sr_efuse_offs: The offset of the efuse register(from system
97 * control module base address) from where to read
98 * the n-target value for the smartreflex module.
99 * @sr_errminlimit: Error min limit value for smartreflex. This value
100 * differs at differnet opp and thus is linked
102 * @vp_errorgain: Error gain value for the voltage processor. This
103 * field also differs according to the voltage/opp.
105 struct omap_volt_data
{
113 * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
114 * @slew_rate: PMIC slew rate (in uv/us)
115 * @step_size: PMIC voltage step size (in uv)
116 * @i2c_slave_addr: I2C slave address of PMIC
117 * @volt_reg_addr: voltage configuration register address
118 * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
119 * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
120 * @i2c_mcode: master code value for I2C high-speed preamble transmission
121 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
122 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
124 struct omap_voltdm_pmic
{
143 unsigned long (*vsel_to_uv
) (const u8 vsel
);
144 u8 (*uv_to_vsel
) (unsigned long uV
);
147 void omap_voltage_get_volttable(struct voltagedomain
*voltdm
,
148 struct omap_volt_data
**volt_data
);
149 struct omap_volt_data
*omap_voltage_get_voltdata(struct voltagedomain
*voltdm
,
151 int omap_voltage_register_pmic(struct voltagedomain
*voltdm
,
152 struct omap_voltdm_pmic
*pmic
);
153 void omap_change_voltscale_method(struct voltagedomain
*voltdm
,
154 int voltscale_method
);
155 int omap_voltage_late_init(void);
157 extern void omap2xxx_voltagedomains_init(void);
158 extern void omap3xxx_voltagedomains_init(void);
159 extern void omap44xx_voltagedomains_init(void);
161 struct voltagedomain
*voltdm_lookup(const char *name
);
162 void voltdm_init(struct voltagedomain
**voltdm_list
);
163 int voltdm_add_pwrdm(struct voltagedomain
*voltdm
, struct powerdomain
*pwrdm
);
164 int voltdm_for_each(int (*fn
)(struct voltagedomain
*voltdm
, void *user
),
166 int voltdm_for_each_pwrdm(struct voltagedomain
*voltdm
,
167 int (*fn
)(struct voltagedomain
*voltdm
,
168 struct powerdomain
*pwrdm
));
169 int voltdm_scale(struct voltagedomain
*voltdm
, unsigned long target_volt
);
170 void voltdm_reset(struct voltagedomain
*voltdm
);
171 unsigned long voltdm_get_voltage(struct voltagedomain
*voltdm
);