blob: 5063ab33af7bc60b6539d381a1702d3929e45b74 [file] [log] [blame]
Thara Gopinath2f34ce82010-05-29 22:02:21 +05301/*
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
Santosh Shilimkarfaacebc2011-01-05 16:27:04 +053017#include <linux/err.h>
18
Paul Walmsleyc0718df2011-03-10 22:17:45 -070019#include "vc.h"
20#include "vp.h"
21
Kevin Hilmane69c22b2011-03-16 16:13:15 -070022struct powerdomain;
23
Paul Walmsleyc0718df2011-03-10 22:17:45 -070024/* XXX document */
Thara Gopinath2f34ce82010-05-29 22:02:21 +053025#define VOLTSCALE_VPFORCEUPDATE 1
26#define VOLTSCALE_VCBYPASS 2
27
28/*
29 * OMAP3 GENERIC setup times. Revisit to see if these needs to be
30 * passed from board or PMIC file
31 */
32#define OMAP3_CLKSETUP 0xff
33#define OMAP3_VOLTOFFSET 0xff
34#define OMAP3_VOLTSETUP2 0xff
35
Kevin Hilman81a60482011-03-16 14:25:45 -070036struct omap_vdd_info;
37
Paul Walmsleyc0718df2011-03-10 22:17:45 -070038/**
39 * struct omap_vfsm_instance_data - 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 * @voltsetup_shift: SETUP_TIME* field shift in the PRM_VOLTSETUP* register
44 *
45 * XXX What about VOLTOFFSET/VOLTCTRL?
46 * XXX It is not necessary to have both a _mask and a _shift for the same
47 * bitfield - remove one!
48 */
49struct omap_vfsm_instance_data {
50 u32 voltsetup_mask;
51 u8 voltsetup_reg;
52 u8 voltsetup_shift;
53};
Thara Gopinathbd381072010-12-10 23:15:23 +053054
Thara Gopinath2f34ce82010-05-29 22:02:21 +053055/**
56 * struct voltagedomain - omap voltage domain global structure.
Kevin Hilman81a60482011-03-16 14:25:45 -070057 * @name: Name of the voltage domain which can be used as a unique identifier.
Kevin Hilman37efca72011-03-23 17:00:21 -070058 * @scalable: Whether or not this voltage domain is scalable
Kevin Hilman81a60482011-03-16 14:25:45 -070059 * @node: list_head linking all voltage domains
Kevin Hilmane69c22b2011-03-16 16:13:15 -070060 * @pwrdm_list: list_head linking all powerdomains in this voltagedomain
Kevin Hilman81a60482011-03-16 14:25:45 -070061 * @vdd: to be removed
Thara Gopinath2f34ce82010-05-29 22:02:21 +053062 */
63struct voltagedomain {
64 char *name;
Kevin Hilman37efca72011-03-23 17:00:21 -070065 bool scalable;
Kevin Hilman81a60482011-03-16 14:25:45 -070066 struct list_head node;
Kevin Hilmane69c22b2011-03-16 16:13:15 -070067 struct list_head pwrdm_list;
Kevin Hilman81a60482011-03-16 14:25:45 -070068 struct omap_vdd_info *vdd;
Thara Gopinath2f34ce82010-05-29 22:02:21 +053069};
70
Thara Gopinath2f34ce82010-05-29 22:02:21 +053071/**
72 * struct omap_volt_data - Omap voltage specific data.
73 * @voltage_nominal: The possible voltage value in uV
74 * @sr_efuse_offs: The offset of the efuse register(from system
75 * control module base address) from where to read
76 * the n-target value for the smartreflex module.
77 * @sr_errminlimit: Error min limit value for smartreflex. This value
78 * differs at differnet opp and thus is linked
79 * with voltage.
80 * @vp_errorgain: Error gain value for the voltage processor. This
81 * field also differs according to the voltage/opp.
82 */
83struct omap_volt_data {
84 u32 volt_nominal;
85 u32 sr_efuse_offs;
86 u8 sr_errminlimit;
87 u8 vp_errgain;
88};
89
90/**
91 * struct omap_volt_pmic_info - PMIC specific data required by voltage driver.
92 * @slew_rate: PMIC slew rate (in uv/us)
93 * @step_size: PMIC voltage step size (in uv)
94 * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV.
95 * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value.
96 */
97struct omap_volt_pmic_info {
98 int slew_rate;
99 int step_size;
100 u32 on_volt;
101 u32 onlp_volt;
102 u32 ret_volt;
103 u32 off_volt;
104 u16 volt_setup_time;
105 u8 vp_erroroffset;
106 u8 vp_vstepmin;
107 u8 vp_vstepmax;
108 u8 vp_vddmin;
109 u8 vp_vddmax;
110 u8 vp_timeout_us;
111 u8 i2c_slave_addr;
112 u8 pmic_reg;
113 unsigned long (*vsel_to_uv) (const u8 vsel);
114 u8 (*uv_to_vsel) (unsigned long uV);
115};
116
Paul Walmsleyc0718df2011-03-10 22:17:45 -0700117/**
118 * omap_vdd_info - Per Voltage Domain info
119 *
120 * @volt_data : voltage table having the distinct voltages supported
121 * by the domain and other associated per voltage data.
122 * @pmic_info : pmic specific parameters which should be populted by
123 * the pmic drivers.
124 * @vp_data : the register values, shifts, masks for various
125 * vp registers
126 * @vp_rt_data : VP data derived at runtime, not predefined
127 * @vc_data : structure containing various various vc registers,
128 * shifts, masks etc.
129 * @vfsm : voltage manager FSM data
Paul Walmsleyc0718df2011-03-10 22:17:45 -0700130 * @debug_dir : debug directory for this voltage domain.
131 * @curr_volt : current voltage for this vdd.
Kevin Hilmana7460daf2011-03-16 13:35:22 -0700132 * @prm_irqst_mod : PRM module id used for PRM IRQ status register access
Paul Walmsleyc0718df2011-03-10 22:17:45 -0700133 * @vp_enabled : flag to keep track of whether vp is enabled or not
134 * @volt_scale : API to scale the voltage of the vdd.
135 */
136struct omap_vdd_info {
137 struct omap_volt_data *volt_data;
138 struct omap_volt_pmic_info *pmic_info;
139 struct omap_vp_instance_data *vp_data;
140 struct omap_vp_runtime_data vp_rt_data;
141 struct omap_vc_instance_data *vc_data;
142 const struct omap_vfsm_instance_data *vfsm;
Paul Walmsleyc0718df2011-03-10 22:17:45 -0700143 struct dentry *debug_dir;
144 u32 curr_volt;
145 bool vp_enabled;
Kevin Hilmana7460daf2011-03-16 13:35:22 -0700146
147 s16 prm_irqst_mod;
Kevin Hilmanc39263c2011-03-16 17:20:35 -0700148 u8 prm_irqst_reg;
Paul Walmsleyc0718df2011-03-10 22:17:45 -0700149 u32 (*read_reg) (u16 mod, u8 offset);
150 void (*write_reg) (u32 val, u16 mod, u8 offset);
Kevin Hilman81a60482011-03-16 14:25:45 -0700151 int (*volt_scale) (struct voltagedomain *voltdm,
Paul Walmsleyc0718df2011-03-10 22:17:45 -0700152 unsigned long target_volt);
153};
154
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530155unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm);
156void omap_vp_enable(struct voltagedomain *voltdm);
157void omap_vp_disable(struct voltagedomain *voltdm);
158int omap_voltage_scale_vdd(struct voltagedomain *voltdm,
159 unsigned long target_volt);
160void omap_voltage_reset(struct voltagedomain *voltdm);
161void omap_voltage_get_volttable(struct voltagedomain *voltdm,
162 struct omap_volt_data **volt_data);
163struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm,
164 unsigned long volt);
165unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm);
166struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm);
167#ifdef CONFIG_PM
168int omap_voltage_register_pmic(struct voltagedomain *voltdm,
169 struct omap_volt_pmic_info *pmic_info);
170void omap_change_voltscale_method(struct voltagedomain *voltdm,
171 int voltscale_method);
172int omap_voltage_late_init(void);
173#else
174static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm,
Santosh Shilimkard7e08f12011-01-05 16:27:02 +0530175 struct omap_volt_pmic_info *pmic_info)
176{
177 return -EINVAL;
178}
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530179static inline void omap_change_voltscale_method(struct voltagedomain *voltdm,
180 int voltscale_method) {}
181static inline int omap_voltage_late_init(void)
182{
183 return -EINVAL;
184}
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530185#endif
186
Kevin Hilmanaae030f2011-03-23 16:09:41 -0700187extern void omap2xxx_voltagedomains_init(void);
Kevin Hilman81a60482011-03-16 14:25:45 -0700188extern void omap3xxx_voltagedomains_init(void);
189extern void omap44xx_voltagedomains_init(void);
190
191struct voltagedomain *voltdm_lookup(const char *name);
192void voltdm_init(struct voltagedomain **voltdm_list);
Kevin Hilman048a7032011-03-16 15:52:47 -0700193int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm);
Kevin Hilmane69c22b2011-03-16 16:13:15 -0700194int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user),
195 void *user);
196int voltdm_for_each_pwrdm(struct voltagedomain *voltdm,
197 int (*fn)(struct voltagedomain *voltdm,
198 struct powerdomain *pwrdm));
Thara Gopinath2f34ce82010-05-29 22:02:21 +0530199#endif