Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 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 | |
Santosh Shilimkar | faacebc | 2011-01-05 16:27:04 +0530 | [diff] [blame] | 17 | #include <linux/err.h> |
| 18 | |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 19 | #include "vc.h" |
| 20 | #include "vp.h" |
| 21 | |
Kevin Hilman | e69c22b | 2011-03-16 16:13:15 -0700 | [diff] [blame] | 22 | struct powerdomain; |
| 23 | |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 24 | /* XXX document */ |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 25 | #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 Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 36 | struct omap_vdd_info; |
| 37 | |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 38 | /** |
| 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 | */ |
| 49 | struct omap_vfsm_instance_data { |
| 50 | u32 voltsetup_mask; |
| 51 | u8 voltsetup_reg; |
| 52 | u8 voltsetup_shift; |
| 53 | }; |
Thara Gopinath | bd38107 | 2010-12-10 23:15:23 +0530 | [diff] [blame] | 54 | |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 55 | /** |
| 56 | * struct voltagedomain - omap voltage domain global structure. |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 57 | * @name: Name of the voltage domain which can be used as a unique identifier. |
Kevin Hilman | 37efca7 | 2011-03-23 17:00:21 -0700 | [diff] [blame] | 58 | * @scalable: Whether or not this voltage domain is scalable |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 59 | * @node: list_head linking all voltage domains |
Kevin Hilman | e69c22b | 2011-03-16 16:13:15 -0700 | [diff] [blame] | 60 | * @pwrdm_list: list_head linking all powerdomains in this voltagedomain |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 61 | * @vdd: to be removed |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 62 | */ |
| 63 | struct voltagedomain { |
| 64 | char *name; |
Kevin Hilman | 37efca7 | 2011-03-23 17:00:21 -0700 | [diff] [blame] | 65 | bool scalable; |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 66 | struct list_head node; |
Kevin Hilman | e69c22b | 2011-03-16 16:13:15 -0700 | [diff] [blame] | 67 | struct list_head pwrdm_list; |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 68 | struct omap_vdd_info *vdd; |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 69 | }; |
| 70 | |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 71 | /** |
| 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 | */ |
| 83 | struct 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 | */ |
| 97 | struct 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 Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 117 | /** |
| 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 Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 130 | * @debug_dir : debug directory for this voltage domain. |
| 131 | * @curr_volt : current voltage for this vdd. |
Kevin Hilman | a7460daf | 2011-03-16 13:35:22 -0700 | [diff] [blame] | 132 | * @prm_irqst_mod : PRM module id used for PRM IRQ status register access |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 133 | * @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 | */ |
| 136 | struct 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 Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 143 | struct dentry *debug_dir; |
| 144 | u32 curr_volt; |
| 145 | bool vp_enabled; |
Kevin Hilman | a7460daf | 2011-03-16 13:35:22 -0700 | [diff] [blame] | 146 | |
| 147 | s16 prm_irqst_mod; |
Kevin Hilman | c39263c | 2011-03-16 17:20:35 -0700 | [diff] [blame] | 148 | u8 prm_irqst_reg; |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 149 | u32 (*read_reg) (u16 mod, u8 offset); |
| 150 | void (*write_reg) (u32 val, u16 mod, u8 offset); |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 151 | int (*volt_scale) (struct voltagedomain *voltdm, |
Paul Walmsley | c0718df | 2011-03-10 22:17:45 -0700 | [diff] [blame] | 152 | unsigned long target_volt); |
| 153 | }; |
| 154 | |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 155 | unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm); |
| 156 | void omap_vp_enable(struct voltagedomain *voltdm); |
| 157 | void omap_vp_disable(struct voltagedomain *voltdm); |
| 158 | int omap_voltage_scale_vdd(struct voltagedomain *voltdm, |
| 159 | unsigned long target_volt); |
| 160 | void omap_voltage_reset(struct voltagedomain *voltdm); |
| 161 | void omap_voltage_get_volttable(struct voltagedomain *voltdm, |
| 162 | struct omap_volt_data **volt_data); |
| 163 | struct omap_volt_data *omap_voltage_get_voltdata(struct voltagedomain *voltdm, |
| 164 | unsigned long volt); |
| 165 | unsigned long omap_voltage_get_nom_volt(struct voltagedomain *voltdm); |
| 166 | struct dentry *omap_voltage_get_dbgdir(struct voltagedomain *voltdm); |
| 167 | #ifdef CONFIG_PM |
| 168 | int omap_voltage_register_pmic(struct voltagedomain *voltdm, |
| 169 | struct omap_volt_pmic_info *pmic_info); |
| 170 | void omap_change_voltscale_method(struct voltagedomain *voltdm, |
| 171 | int voltscale_method); |
| 172 | int omap_voltage_late_init(void); |
| 173 | #else |
| 174 | static inline int omap_voltage_register_pmic(struct voltagedomain *voltdm, |
Santosh Shilimkar | d7e08f1 | 2011-01-05 16:27:02 +0530 | [diff] [blame] | 175 | struct omap_volt_pmic_info *pmic_info) |
| 176 | { |
| 177 | return -EINVAL; |
| 178 | } |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 179 | static inline void omap_change_voltscale_method(struct voltagedomain *voltdm, |
| 180 | int voltscale_method) {} |
| 181 | static inline int omap_voltage_late_init(void) |
| 182 | { |
| 183 | return -EINVAL; |
| 184 | } |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 185 | #endif |
| 186 | |
Kevin Hilman | aae030f | 2011-03-23 16:09:41 -0700 | [diff] [blame] | 187 | extern void omap2xxx_voltagedomains_init(void); |
Kevin Hilman | 81a6048 | 2011-03-16 14:25:45 -0700 | [diff] [blame] | 188 | extern void omap3xxx_voltagedomains_init(void); |
| 189 | extern void omap44xx_voltagedomains_init(void); |
| 190 | |
| 191 | struct voltagedomain *voltdm_lookup(const char *name); |
| 192 | void voltdm_init(struct voltagedomain **voltdm_list); |
Kevin Hilman | 048a703 | 2011-03-16 15:52:47 -0700 | [diff] [blame] | 193 | int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm); |
Kevin Hilman | e69c22b | 2011-03-16 16:13:15 -0700 | [diff] [blame] | 194 | int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user), |
| 195 | void *user); |
| 196 | int voltdm_for_each_pwrdm(struct voltagedomain *voltdm, |
| 197 | int (*fn)(struct voltagedomain *voltdm, |
| 198 | struct powerdomain *pwrdm)); |
Thara Gopinath | 2f34ce8 | 2010-05-29 22:02:21 +0530 | [diff] [blame] | 199 | #endif |