]> Pileus Git - ~andy/linux/blob - arch/arm/mach-omap2/voltage.h
697095551bb62ccc4a46eb5362e155b3520b9971
[~andy/linux] / arch / arm / mach-omap2 / voltage.h
1 /*
2  * OMAP Voltage Management Routines
3  *
4  * Author: Thara Gopinath       <thara@ti.com>
5  *
6  * Copyright (C) 2009 Texas Instruments, Inc.
7  * Thara Gopinath <thara@ti.com>
8  *
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.
12  */
13
14 #ifndef __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
15 #define __ARCH_ARM_MACH_OMAP2_VOLTAGE_H
16
17 #include <linux/err.h>
18
19 #include <linux/platform_data/voltage-omap.h>
20
21 #include "vc.h"
22 #include "vp.h"
23
24 struct powerdomain;
25
26 /* XXX document */
27 #define VOLTSCALE_VPFORCEUPDATE         1
28 #define VOLTSCALE_VCBYPASS              2
29
30 /*
31  * OMAP3 GENERIC setup times. Revisit to see if these needs to be
32  * passed from board or PMIC file
33  */
34 #define OMAP3_CLKSETUP          0xff
35 #define OMAP3_VOLTOFFSET        0xff
36 #define OMAP3_VOLTSETUP2        0xff
37
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
43  *
44  * XXX What about VOLTOFFSET/VOLTCTRL?
45  */
46 struct omap_vfsm_instance {
47         u32 voltsetup_mask;
48         u8 voltsetup_reg;
49 };
50
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  * @scale: function used to scale the voltage of the voltagedomain
64  * @nominal_volt: current nominal voltage for this voltage domain
65  * @volt_data: voltage table having the distinct voltages supported
66  *             by the domain and other associated per voltage data.
67  */
68 struct voltagedomain {
69         char *name;
70         bool scalable;
71         struct list_head node;
72         struct list_head pwrdm_list;
73         struct omap_vc_channel *vc;
74         const struct omap_vfsm_instance *vfsm;
75         struct omap_vp_instance *vp;
76         struct omap_voltdm_pmic *pmic;
77         struct omap_vp_param *vp_param;
78         struct omap_vc_param *vc_param;
79
80         /* VC/VP register access functions: SoC specific */
81         u32 (*read) (u8 offset);
82         void (*write) (u32 val, u8 offset);
83         u32 (*rmw)(u32 mask, u32 bits, u8 offset);
84
85         union {
86                 const char *name;
87                 u32 rate;
88         } sys_clk;
89
90         int (*scale) (struct voltagedomain *voltdm,
91                       unsigned long target_volt);
92
93         u32 nominal_volt;
94         struct omap_volt_data *volt_data;
95 };
96
97 /* Min and max voltages from OMAP perspective */
98 #define OMAP3430_VP1_VLIMITTO_VDDMIN    850000
99 #define OMAP3430_VP1_VLIMITTO_VDDMAX    1425000
100 #define OMAP3430_VP2_VLIMITTO_VDDMIN    900000
101 #define OMAP3430_VP2_VLIMITTO_VDDMAX    1150000
102
103 #define OMAP3630_VP1_VLIMITTO_VDDMIN    900000
104 #define OMAP3630_VP1_VLIMITTO_VDDMAX    1350000
105 #define OMAP3630_VP2_VLIMITTO_VDDMIN    900000
106 #define OMAP3630_VP2_VLIMITTO_VDDMAX    1200000
107
108 #define OMAP4_VP_MPU_VLIMITTO_VDDMIN    830000
109 #define OMAP4_VP_MPU_VLIMITTO_VDDMAX    1410000
110 #define OMAP4_VP_IVA_VLIMITTO_VDDMIN    830000
111 #define OMAP4_VP_IVA_VLIMITTO_VDDMAX    1260000
112 #define OMAP4_VP_CORE_VLIMITTO_VDDMIN   830000
113 #define OMAP4_VP_CORE_VLIMITTO_VDDMAX   1200000
114
115 /**
116  * struct omap_voltdm_pmic - PMIC specific data required by voltage driver.
117  * @slew_rate:  PMIC slew rate (in uv/us)
118  * @step_size:  PMIC voltage step size (in uv)
119  * @i2c_slave_addr: I2C slave address of PMIC
120  * @volt_reg_addr: voltage configuration register address
121  * @cmd_reg_addr: command (on, on-LP, ret, off) configuration register address
122  * @i2c_high_speed: whether VC uses I2C high-speed mode to PMIC
123  * @i2c_mcode: master code value for I2C high-speed preamble transmission
124  * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
125  * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
126  */
127 struct omap_voltdm_pmic {
128         int slew_rate;
129         int step_size;
130         u16 volt_setup_time;
131         u16 i2c_slave_addr;
132         u16 volt_reg_addr;
133         u16 cmd_reg_addr;
134         u8 vp_erroroffset;
135         u8 vp_vstepmin;
136         u8 vp_vstepmax;
137         u32 vddmin;
138         u32 vddmax;
139         u8 vp_timeout_us;
140         bool i2c_high_speed;
141         u8 i2c_mcode;
142         unsigned long (*vsel_to_uv) (const u8 vsel);
143         u8 (*uv_to_vsel) (unsigned long uV);
144 };
145
146 struct omap_vp_param {
147         u32 vddmax;
148         u32 vddmin;
149 };
150
151 struct omap_vc_param {
152         u32 on;
153         u32 onlp;
154         u32 ret;
155         u32 off;
156 };
157
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 int omap_voltage_register_pmic(struct voltagedomain *voltdm,
163                                struct omap_voltdm_pmic *pmic);
164 void omap_change_voltscale_method(struct voltagedomain *voltdm,
165                 int voltscale_method);
166 int omap_voltage_late_init(void);
167
168 extern void omap2xxx_voltagedomains_init(void);
169 extern void omap3xxx_voltagedomains_init(void);
170 extern void am33xx_voltagedomains_init(void);
171 extern void omap44xx_voltagedomains_init(void);
172
173 struct voltagedomain *voltdm_lookup(const char *name);
174 void voltdm_init(struct voltagedomain **voltdm_list);
175 int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
176 int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
177                     void *user);
178 int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
179                           int (*fn)(struct voltagedomain *voltdm,
180                                     struct powerdomain *pwrdm));
181 int voltdm_scale(struct voltagedomain *voltdm, unsigned long target_volt);
182 void voltdm_reset(struct voltagedomain *voltdm);
183 unsigned long voltdm_get_voltage(struct voltagedomain *voltdm);
184 #endif