Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/init.h> |
| 3 | #include <linux/debugfs.h> |
| 4 | |
| 5 | #include <plat/common.h> |
| 6 | |
| 7 | #include "voltage.h" |
| 8 | #include "vp.h" |
| 9 | #include "prm-regbits-34xx.h" |
| 10 | #include "prm-regbits-44xx.h" |
| 11 | #include "prm44xx.h" |
| 12 | |
| 13 | static void __init vp_debugfs_init(struct voltagedomain *voltdm); |
| 14 | |
| 15 | static void vp_latch_vsel(struct voltagedomain *voltdm) |
| 16 | { |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 17 | struct omap_vp_instance *vp = voltdm->vp; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 18 | u32 vpconfig; |
| 19 | unsigned long uvdc; |
| 20 | char vsel; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 21 | |
| 22 | uvdc = omap_voltage_get_nom_volt(voltdm); |
| 23 | if (!uvdc) { |
| 24 | pr_warning("%s: unable to find current voltage for vdd_%s\n", |
| 25 | __func__, voltdm->name); |
| 26 | return; |
| 27 | } |
| 28 | |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 29 | if (!voltdm->pmic || !voltdm->pmic->uv_to_vsel) { |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 30 | pr_warning("%s: PMIC function to convert voltage in uV to" |
| 31 | " vsel not registered\n", __func__); |
| 32 | return; |
| 33 | } |
| 34 | |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 35 | vsel = voltdm->pmic->uv_to_vsel(uvdc); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 36 | |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 37 | vpconfig = voltdm->read(vp->vpconfig); |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 38 | vpconfig &= ~(vp->common->vpconfig_initvoltage_mask | |
| 39 | vp->common->vpconfig_initvdd); |
| 40 | vpconfig |= vsel << vp->common->vpconfig_initvoltage_shift; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 41 | |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 42 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 43 | |
| 44 | /* Trigger initVDD value copy to voltage processor */ |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 45 | voltdm->write((vpconfig | vp->common->vpconfig_initvdd), |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 46 | vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 47 | |
| 48 | /* Clear initVDD copy trigger bit */ |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 49 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | /* Generic voltage init functions */ |
| 53 | void __init omap_vp_init(struct voltagedomain *voltdm) |
| 54 | { |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 55 | struct omap_vp_instance *vp = voltdm->vp; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 56 | struct omap_vdd_info *vdd = voltdm->vdd; |
| 57 | u32 vp_val; |
| 58 | |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 59 | if (!voltdm->read || !voltdm->write) { |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 60 | pr_err("%s: No read/write API for accessing vdd_%s regs\n", |
| 61 | __func__, voltdm->name); |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | vp_val = vdd->vp_rt_data.vpconfig_erroroffset | |
| 66 | (vdd->vp_rt_data.vpconfig_errorgain << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 67 | vp->common->vpconfig_errorgain_shift) | |
| 68 | vp->common->vpconfig_timeouten; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 69 | voltdm->write(vp_val, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 70 | |
| 71 | vp_val = ((vdd->vp_rt_data.vstepmin_smpswaittimemin << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 72 | vp->common->vstepmin_smpswaittimemin_shift) | |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 73 | (vdd->vp_rt_data.vstepmin_stepmin << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 74 | vp->common->vstepmin_stepmin_shift)); |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 75 | voltdm->write(vp_val, vp->vstepmin); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 76 | |
| 77 | vp_val = ((vdd->vp_rt_data.vstepmax_smpswaittimemax << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 78 | vp->common->vstepmax_smpswaittimemax_shift) | |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 79 | (vdd->vp_rt_data.vstepmax_stepmax << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 80 | vp->common->vstepmax_stepmax_shift)); |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 81 | voltdm->write(vp_val, vp->vstepmax); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 82 | |
| 83 | vp_val = ((vdd->vp_rt_data.vlimitto_vddmax << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 84 | vp->common->vlimitto_vddmax_shift) | |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 85 | (vdd->vp_rt_data.vlimitto_vddmin << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 86 | vp->common->vlimitto_vddmin_shift) | |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 87 | (vdd->vp_rt_data.vlimitto_timeout << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 88 | vp->common->vlimitto_timeout_shift)); |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 89 | voltdm->write(vp_val, vp->vlimitto); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 90 | |
| 91 | vp_debugfs_init(voltdm); |
| 92 | } |
| 93 | |
| 94 | /* VP force update method of voltage scaling */ |
| 95 | int omap_vp_forceupdate_scale(struct voltagedomain *voltdm, |
| 96 | unsigned long target_volt) |
| 97 | { |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 98 | struct omap_vp_instance *vp = voltdm->vp; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 99 | u32 vpconfig; |
| 100 | u8 target_vsel, current_vsel; |
| 101 | int ret, timeout = 0; |
| 102 | |
| 103 | ret = omap_vc_pre_scale(voltdm, target_volt, &target_vsel, ¤t_vsel); |
| 104 | if (ret) |
| 105 | return ret; |
| 106 | |
| 107 | /* |
| 108 | * Clear all pending TransactionDone interrupt/status. Typical latency |
| 109 | * is <3us |
| 110 | */ |
| 111 | while (timeout++ < VP_TRANXDONE_TIMEOUT) { |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 112 | vp->common->ops->clear_txdone(vp->id); |
| 113 | if (!vp->common->ops->check_txdone(vp->id)) |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 114 | break; |
| 115 | udelay(1); |
| 116 | } |
| 117 | if (timeout >= VP_TRANXDONE_TIMEOUT) { |
| 118 | pr_warning("%s: vdd_%s TRANXDONE timeout exceeded." |
| 119 | "Voltage change aborted", __func__, voltdm->name); |
| 120 | return -ETIMEDOUT; |
| 121 | } |
| 122 | |
| 123 | /* Configure for VP-Force Update */ |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 124 | vpconfig = voltdm->read(vp->vpconfig); |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 125 | vpconfig &= ~(vp->common->vpconfig_initvdd | |
| 126 | vp->common->vpconfig_forceupdate | |
| 127 | vp->common->vpconfig_initvoltage_mask); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 128 | vpconfig |= ((target_vsel << |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 129 | vp->common->vpconfig_initvoltage_shift)); |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 130 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 131 | |
| 132 | /* Trigger initVDD value copy to voltage processor */ |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 133 | vpconfig |= vp->common->vpconfig_initvdd; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 134 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 135 | |
| 136 | /* Force update of voltage */ |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 137 | vpconfig |= vp->common->vpconfig_forceupdate; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 138 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 139 | |
| 140 | /* |
| 141 | * Wait for TransactionDone. Typical latency is <200us. |
| 142 | * Depends on SMPSWAITTIMEMIN/MAX and voltage change |
| 143 | */ |
| 144 | timeout = 0; |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 145 | omap_test_timeout(vp->common->ops->check_txdone(vp->id), |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 146 | VP_TRANXDONE_TIMEOUT, timeout); |
| 147 | if (timeout >= VP_TRANXDONE_TIMEOUT) |
| 148 | pr_err("%s: vdd_%s TRANXDONE timeout exceeded." |
| 149 | "TRANXDONE never got set after the voltage update\n", |
| 150 | __func__, voltdm->name); |
| 151 | |
| 152 | omap_vc_post_scale(voltdm, target_volt, target_vsel, current_vsel); |
| 153 | |
| 154 | /* |
| 155 | * Disable TransactionDone interrupt , clear all status, clear |
| 156 | * control registers |
| 157 | */ |
| 158 | timeout = 0; |
| 159 | while (timeout++ < VP_TRANXDONE_TIMEOUT) { |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 160 | vp->common->ops->clear_txdone(vp->id); |
| 161 | if (!vp->common->ops->check_txdone(vp->id)) |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 162 | break; |
| 163 | udelay(1); |
| 164 | } |
| 165 | |
| 166 | if (timeout >= VP_TRANXDONE_TIMEOUT) |
| 167 | pr_warning("%s: vdd_%s TRANXDONE timeout exceeded while trying" |
| 168 | "to clear the TRANXDONE status\n", |
| 169 | __func__, voltdm->name); |
| 170 | |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 171 | vpconfig = voltdm->read(vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 172 | /* Clear initVDD copy trigger bit */ |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 173 | vpconfig &= ~vp->common->vpconfig_initvdd; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 174 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 175 | /* Clear force bit */ |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 176 | vpconfig &= ~vp->common->vpconfig_forceupdate; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 177 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 178 | |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * omap_vp_get_curr_volt() - API to get the current vp voltage. |
| 184 | * @voltdm: pointer to the VDD. |
| 185 | * |
| 186 | * This API returns the current voltage for the specified voltage processor |
| 187 | */ |
| 188 | unsigned long omap_vp_get_curr_volt(struct voltagedomain *voltdm) |
| 189 | { |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 190 | struct omap_vp_instance *vp = voltdm->vp; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 191 | u8 curr_vsel; |
| 192 | |
| 193 | if (!voltdm || IS_ERR(voltdm)) { |
| 194 | pr_warning("%s: VDD specified does not exist!\n", __func__); |
| 195 | return 0; |
| 196 | } |
| 197 | |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 198 | if (!voltdm->read) { |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 199 | pr_err("%s: No read API for reading vdd_%s regs\n", |
| 200 | __func__, voltdm->name); |
| 201 | return 0; |
| 202 | } |
| 203 | |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 204 | curr_vsel = voltdm->read(vp->voltage); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 205 | |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 206 | if (!voltdm->pmic || !voltdm->pmic->vsel_to_uv) { |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 207 | pr_warning("%s: PMIC function to convert vsel to voltage" |
| 208 | "in uV not registerd\n", __func__); |
| 209 | return 0; |
| 210 | } |
| 211 | |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 212 | return voltdm->pmic->vsel_to_uv(curr_vsel); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | /** |
| 216 | * omap_vp_enable() - API to enable a particular VP |
| 217 | * @voltdm: pointer to the VDD whose VP is to be enabled. |
| 218 | * |
| 219 | * This API enables a particular voltage processor. Needed by the smartreflex |
| 220 | * class drivers. |
| 221 | */ |
| 222 | void omap_vp_enable(struct voltagedomain *voltdm) |
| 223 | { |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 224 | struct omap_vp_instance *vp; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 225 | u32 vpconfig; |
| 226 | |
| 227 | if (!voltdm || IS_ERR(voltdm)) { |
| 228 | pr_warning("%s: VDD specified does not exist!\n", __func__); |
| 229 | return; |
| 230 | } |
| 231 | |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 232 | vp = voltdm->vp; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 233 | if (!voltdm->read || !voltdm->write) { |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 234 | pr_err("%s: No read/write API for accessing vdd_%s regs\n", |
| 235 | __func__, voltdm->name); |
| 236 | return; |
| 237 | } |
| 238 | |
| 239 | /* If VP is already enabled, do nothing. Return */ |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 240 | if (vp->enabled) |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 241 | return; |
| 242 | |
| 243 | vp_latch_vsel(voltdm); |
| 244 | |
| 245 | /* Enable VP */ |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 246 | vpconfig = voltdm->read(vp->vpconfig); |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 247 | vpconfig |= vp->common->vpconfig_vpenable; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 248 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 249 | vp->enabled = true; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | /** |
| 253 | * omap_vp_disable() - API to disable a particular VP |
| 254 | * @voltdm: pointer to the VDD whose VP is to be disabled. |
| 255 | * |
| 256 | * This API disables a particular voltage processor. Needed by the smartreflex |
| 257 | * class drivers. |
| 258 | */ |
| 259 | void omap_vp_disable(struct voltagedomain *voltdm) |
| 260 | { |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 261 | struct omap_vp_instance *vp; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 262 | u32 vpconfig; |
| 263 | int timeout; |
| 264 | |
| 265 | if (!voltdm || IS_ERR(voltdm)) { |
| 266 | pr_warning("%s: VDD specified does not exist!\n", __func__); |
| 267 | return; |
| 268 | } |
| 269 | |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 270 | vp = voltdm->vp; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 271 | if (!voltdm->read || !voltdm->write) { |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 272 | pr_err("%s: No read/write API for accessing vdd_%s regs\n", |
| 273 | __func__, voltdm->name); |
| 274 | return; |
| 275 | } |
| 276 | |
| 277 | /* If VP is already disabled, do nothing. Return */ |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 278 | if (!vp->enabled) { |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 279 | pr_warning("%s: Trying to disable VP for vdd_%s when" |
| 280 | "it is already disabled\n", __func__, voltdm->name); |
| 281 | return; |
| 282 | } |
| 283 | |
| 284 | /* Disable VP */ |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 285 | vpconfig = voltdm->read(vp->vpconfig); |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 286 | vpconfig &= ~vp->common->vpconfig_vpenable; |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 287 | voltdm->write(vpconfig, vp->vpconfig); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 288 | |
| 289 | /* |
| 290 | * Wait for VP idle Typical latency is <2us. Maximum latency is ~100us |
| 291 | */ |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 292 | omap_test_timeout((voltdm->read(vp->vstatus)), |
| 293 | VP_IDLE_TIMEOUT, timeout); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 294 | |
| 295 | if (timeout >= VP_IDLE_TIMEOUT) |
| 296 | pr_warning("%s: vdd_%s idle timedout\n", |
| 297 | __func__, voltdm->name); |
| 298 | |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 299 | vp->enabled = false; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 300 | |
| 301 | return; |
| 302 | } |
| 303 | |
| 304 | /* Voltage debugfs support */ |
| 305 | static int vp_volt_debug_get(void *data, u64 *val) |
| 306 | { |
| 307 | struct voltagedomain *voltdm = (struct voltagedomain *)data; |
Kevin Hilman | b7ea803 | 2011-04-04 15:25:07 -0700 | [diff] [blame^] | 308 | struct omap_vp_instance *vp = voltdm->vp; |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 309 | struct omap_vdd_info *vdd = voltdm->vdd; |
| 310 | u8 vsel; |
| 311 | |
| 312 | if (!vdd) { |
| 313 | pr_warning("Wrong paramater passed\n"); |
| 314 | return -EINVAL; |
| 315 | } |
| 316 | |
Kevin Hilman | 4bcc475 | 2011-03-28 10:40:15 -0700 | [diff] [blame] | 317 | vsel = voltdm->read(vp->voltage); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 318 | |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 319 | if (!voltdm->pmic->vsel_to_uv) { |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 320 | pr_warning("PMIC function to convert vsel to voltage" |
| 321 | "in uV not registerd\n"); |
| 322 | return -EINVAL; |
| 323 | } |
| 324 | |
Kevin Hilman | ce8ebe0 | 2011-03-30 11:01:10 -0700 | [diff] [blame] | 325 | *val = voltdm->pmic->vsel_to_uv(vsel); |
Kevin Hilman | 01f48d3 | 2011-03-21 14:29:13 -0700 | [diff] [blame] | 326 | return 0; |
| 327 | } |
| 328 | |
| 329 | DEFINE_SIMPLE_ATTRIBUTE(vp_volt_debug_fops, vp_volt_debug_get, NULL, "%llu\n"); |
| 330 | |
| 331 | static void __init vp_debugfs_init(struct voltagedomain *voltdm) |
| 332 | { |
| 333 | struct omap_vdd_info *vdd = voltdm->vdd; |
| 334 | struct dentry *debug_dir; |
| 335 | |
| 336 | debug_dir = debugfs_create_dir("vp", vdd->debug_dir); |
| 337 | if (IS_ERR(debug_dir)) |
| 338 | pr_err("%s: Unable to create VP debugfs dir dir\n", __func__); |
| 339 | |
| 340 | (void) debugfs_create_x16("errorgain", S_IRUGO, debug_dir, |
| 341 | &(vdd->vp_rt_data.vpconfig_errorgain)); |
| 342 | (void) debugfs_create_x16("smpswaittimemin", S_IRUGO, |
| 343 | debug_dir, |
| 344 | &(vdd->vp_rt_data.vstepmin_smpswaittimemin)); |
| 345 | (void) debugfs_create_x8("stepmin", S_IRUGO, debug_dir, |
| 346 | &(vdd->vp_rt_data.vstepmin_stepmin)); |
| 347 | (void) debugfs_create_x16("smpswaittimemax", S_IRUGO, |
| 348 | debug_dir, |
| 349 | &(vdd->vp_rt_data.vstepmax_smpswaittimemax)); |
| 350 | (void) debugfs_create_x8("stepmax", S_IRUGO, debug_dir, |
| 351 | &(vdd->vp_rt_data.vstepmax_stepmax)); |
| 352 | (void) debugfs_create_x8("vddmax", S_IRUGO, debug_dir, |
| 353 | &(vdd->vp_rt_data.vlimitto_vddmax)); |
| 354 | (void) debugfs_create_x8("vddmin", S_IRUGO, debug_dir, |
| 355 | &(vdd->vp_rt_data.vlimitto_vddmin)); |
| 356 | (void) debugfs_create_x16("timeout", S_IRUGO, debug_dir, |
| 357 | &(vdd->vp_rt_data.vlimitto_timeout)); |
| 358 | (void) debugfs_create_file("curr_volt", S_IRUGO, debug_dir, |
| 359 | (void *) voltdm, &vp_volt_debug_fops); |
| 360 | } |