Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010 Broadcom Corporation |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
Greg Kroah-Hartman | a1c16ed | 2010-10-21 11:17:44 -0700 | [diff] [blame] | 16 | #include <linux/kernel.h> |
Brett Rudley | 3327989 | 2010-10-01 18:03:27 -0700 | [diff] [blame] | 17 | #include <linux/string.h> |
Brett Rudley | c6ac24e | 2010-10-26 11:55:23 -0700 | [diff] [blame] | 18 | #include <linux/module.h> |
| 19 | #include <linux/pci.h> |
| 20 | #ifdef BRCM_FULLMAC |
| 21 | #include <linux/netdevice.h> |
| 22 | #endif |
Greg Kroah-Hartman | a1c16ed | 2010-10-21 11:17:44 -0700 | [diff] [blame] | 23 | #include <bcmdefs.h> |
| 24 | #include <osl.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 25 | #include <bcmutils.h> |
| 26 | #include <siutils.h> |
| 27 | #include <bcmdevs.h> |
| 28 | #include <hndsoc.h> |
| 29 | #include <sbchipc.h> |
| 30 | #include <hndpmu.h> |
| 31 | #include "siutils_priv.h" |
| 32 | |
| 33 | #define PMU_ERROR(args) |
| 34 | |
| 35 | #ifdef BCMDBG |
| 36 | #define PMU_MSG(args) printf args |
| 37 | #else |
| 38 | #define PMU_MSG(args) |
| 39 | #endif /* BCMDBG */ |
| 40 | |
| 41 | /* To check in verbose debugging messages not intended |
| 42 | * to be on except on private builds. |
| 43 | */ |
| 44 | #define PMU_NONE(args) |
| 45 | |
| 46 | /* PLL controls/clocks */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 47 | static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 48 | u32 xtal); |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 49 | static u32 si_pmu1_cpuclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc); |
| 50 | static u32 si_pmu1_alpclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 51 | |
| 52 | /* PMU resources */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 53 | static bool si_pmu_res_depfltr_bb(si_t *sih); |
| 54 | static bool si_pmu_res_depfltr_ncb(si_t *sih); |
| 55 | static bool si_pmu_res_depfltr_paldo(si_t *sih); |
| 56 | static bool si_pmu_res_depfltr_npaldo(si_t *sih); |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 57 | static u32 si_pmu_res_deps(si_t *sih, struct osl_info *osh, chipcregs_t *cc, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 58 | u32 rsrcs, bool all); |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 59 | static uint si_pmu_res_uptime(si_t *sih, struct osl_info *osh, chipcregs_t *cc, |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 60 | u8 rsrc); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 61 | static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax); |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 62 | static void si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 63 | struct osl_info *osh, u8 spuravoid); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 64 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 65 | static void si_pmu_set_4330_plldivs(si_t *sih); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 66 | |
| 67 | /* FVCO frequency */ |
| 68 | #define FVCO_880 880000 /* 880MHz */ |
| 69 | #define FVCO_1760 1760000 /* 1760MHz */ |
| 70 | #define FVCO_1440 1440000 /* 1440MHz */ |
| 71 | #define FVCO_960 960000 /* 960MHz */ |
| 72 | |
| 73 | /* Read/write a chipcontrol reg */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 74 | u32 si_pmu_chipcontrol(si_t *sih, uint reg, u32 mask, u32 val) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 75 | { |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 76 | si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol_addr), ~0, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 77 | reg); |
| 78 | return si_corereg(sih, SI_CC_IDX, |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 79 | offsetof(chipcregs_t, chipcontrol_data), mask, val); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | /* Read/write a regcontrol reg */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 83 | u32 si_pmu_regcontrol(si_t *sih, uint reg, u32 mask, u32 val) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 84 | { |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 85 | si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_addr), ~0, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 86 | reg); |
| 87 | return si_corereg(sih, SI_CC_IDX, |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 88 | offsetof(chipcregs_t, regcontrol_data), mask, val); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /* Read/write a pllcontrol reg */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 92 | u32 si_pmu_pllcontrol(si_t *sih, uint reg, u32 mask, u32 val) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 93 | { |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 94 | si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pllcontrol_addr), ~0, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 95 | reg); |
| 96 | return si_corereg(sih, SI_CC_IDX, |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 97 | offsetof(chipcregs_t, pllcontrol_data), mask, val); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | /* PMU PLL update */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 101 | void si_pmu_pllupd(si_t *sih) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 102 | { |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 103 | si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, pmucontrol), |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 104 | PCTL_PLL_PLLCTL_UPD, PCTL_PLL_PLLCTL_UPD); |
| 105 | } |
| 106 | |
| 107 | /* Setup switcher voltage */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 108 | void si_pmu_set_switcher_voltage(si_t *sih, struct osl_info *osh, u8 bb_voltage, |
Greg Kroah-Hartman | 0d2f072 | 2010-10-08 14:28:21 -0700 | [diff] [blame] | 109 | u8 rf_voltage) |
| 110 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 111 | chipcregs_t *cc; |
| 112 | uint origidx; |
| 113 | |
| 114 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 115 | |
| 116 | /* Remember original core before switch to chipc */ |
| 117 | origidx = si_coreidx(sih); |
| 118 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 119 | ASSERT(cc != NULL); |
| 120 | |
| 121 | W_REG(osh, &cc->regcontrol_addr, 0x01); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 122 | W_REG(osh, &cc->regcontrol_data, (u32) (bb_voltage & 0x1f) << 22); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 123 | |
| 124 | W_REG(osh, &cc->regcontrol_addr, 0x00); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 125 | W_REG(osh, &cc->regcontrol_data, (u32) (rf_voltage & 0x1f) << 14); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 126 | |
| 127 | /* Return to original core */ |
| 128 | si_setcoreidx(sih, origidx); |
| 129 | } |
| 130 | |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 131 | void si_pmu_set_ldo_voltage(si_t *sih, struct osl_info *osh, u8 ldo, u8 voltage) |
Greg Kroah-Hartman | 0d2f072 | 2010-10-08 14:28:21 -0700 | [diff] [blame] | 132 | { |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 133 | u8 sr_cntl_shift = 0, rc_shift = 0, shift = 0, mask = 0; |
| 134 | u8 addr = 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 135 | |
| 136 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 137 | |
| 138 | switch (CHIPID(sih->chip)) { |
| 139 | case BCM4336_CHIP_ID: |
| 140 | switch (ldo) { |
| 141 | case SET_LDO_VOLTAGE_CLDO_PWM: |
| 142 | addr = 4; |
| 143 | rc_shift = 1; |
| 144 | mask = 0xf; |
| 145 | break; |
| 146 | case SET_LDO_VOLTAGE_CLDO_BURST: |
| 147 | addr = 4; |
| 148 | rc_shift = 5; |
| 149 | mask = 0xf; |
| 150 | break; |
| 151 | case SET_LDO_VOLTAGE_LNLDO1: |
| 152 | addr = 4; |
| 153 | rc_shift = 17; |
| 154 | mask = 0xf; |
| 155 | break; |
| 156 | default: |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 157 | ASSERT(false); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 158 | return; |
| 159 | } |
| 160 | break; |
| 161 | case BCM4330_CHIP_ID: |
| 162 | switch (ldo) { |
| 163 | case SET_LDO_VOLTAGE_CBUCK_PWM: |
| 164 | addr = 3; |
| 165 | rc_shift = 0; |
| 166 | mask = 0x1f; |
| 167 | break; |
| 168 | default: |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 169 | ASSERT(false); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 170 | break; |
| 171 | } |
| 172 | break; |
| 173 | default: |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 174 | ASSERT(false); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 175 | return; |
| 176 | } |
| 177 | |
| 178 | shift = sr_cntl_shift + rc_shift; |
| 179 | |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 180 | si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_addr), |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 181 | ~0, addr); |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 182 | si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, regcontrol_data), |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 183 | mask << shift, (voltage & mask) << shift); |
| 184 | } |
| 185 | |
| 186 | /* d11 slow to fast clock transition time in slow clock cycles */ |
| 187 | #define D11SCC_SLOW2FAST_TRANSITION 2 |
| 188 | |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 189 | u16 si_pmu_fast_pwrup_delay(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 190 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 191 | uint delay = PMU_MAX_TRANSITION_DLY; |
| 192 | chipcregs_t *cc; |
| 193 | uint origidx; |
| 194 | #ifdef BCMDBG |
| 195 | char chn[8]; |
| 196 | chn[0] = 0; /* to suppress compile error */ |
| 197 | #endif |
| 198 | |
| 199 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 200 | |
| 201 | /* Remember original core before switch to chipc */ |
| 202 | origidx = si_coreidx(sih); |
| 203 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 204 | ASSERT(cc != NULL); |
| 205 | |
| 206 | switch (CHIPID(sih->chip)) { |
| 207 | case BCM43224_CHIP_ID: |
| 208 | case BCM43225_CHIP_ID: |
| 209 | case BCM43421_CHIP_ID: |
| 210 | case BCM43235_CHIP_ID: |
| 211 | case BCM43236_CHIP_ID: |
| 212 | case BCM43238_CHIP_ID: |
| 213 | case BCM4331_CHIP_ID: |
| 214 | case BCM6362_CHIP_ID: |
| 215 | case BCM4313_CHIP_ID: |
| 216 | delay = ISSIM_ENAB(sih) ? 70 : 3700; |
| 217 | break; |
| 218 | case BCM4329_CHIP_ID: |
| 219 | if (ISSIM_ENAB(sih)) |
| 220 | delay = 70; |
| 221 | else { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 222 | u32 ilp = si_ilp_clock(sih); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 223 | delay = |
| 224 | (si_pmu_res_uptime(sih, osh, cc, RES4329_HT_AVAIL) + |
| 225 | D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp - |
| 226 | 1) / ilp); |
| 227 | delay = (11 * delay) / 10; |
| 228 | } |
| 229 | break; |
| 230 | case BCM4319_CHIP_ID: |
| 231 | delay = ISSIM_ENAB(sih) ? 70 : 3700; |
| 232 | break; |
| 233 | case BCM4336_CHIP_ID: |
| 234 | if (ISSIM_ENAB(sih)) |
| 235 | delay = 70; |
| 236 | else { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 237 | u32 ilp = si_ilp_clock(sih); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 238 | delay = |
| 239 | (si_pmu_res_uptime(sih, osh, cc, RES4336_HT_AVAIL) + |
| 240 | D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp - |
| 241 | 1) / ilp); |
| 242 | delay = (11 * delay) / 10; |
| 243 | } |
| 244 | break; |
| 245 | case BCM4330_CHIP_ID: |
| 246 | if (ISSIM_ENAB(sih)) |
| 247 | delay = 70; |
| 248 | else { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 249 | u32 ilp = si_ilp_clock(sih); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 250 | delay = |
| 251 | (si_pmu_res_uptime(sih, osh, cc, RES4330_HT_AVAIL) + |
| 252 | D11SCC_SLOW2FAST_TRANSITION) * ((1000000 + ilp - |
| 253 | 1) / ilp); |
| 254 | delay = (11 * delay) / 10; |
| 255 | } |
| 256 | break; |
| 257 | default: |
| 258 | break; |
| 259 | } |
| 260 | /* Return to original core */ |
| 261 | si_setcoreidx(sih, origidx); |
| 262 | |
Greg Kroah-Hartman | 7d4df48 | 2010-10-07 17:04:47 -0700 | [diff] [blame] | 263 | return (u16) delay; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 266 | u32 si_pmu_force_ilp(si_t *sih, struct osl_info *osh, bool force) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 267 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 268 | chipcregs_t *cc; |
| 269 | uint origidx; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 270 | u32 oldpmucontrol; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 271 | |
| 272 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 273 | |
| 274 | /* Remember original core before switch to chipc */ |
| 275 | origidx = si_coreidx(sih); |
| 276 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 277 | ASSERT(cc != NULL); |
| 278 | |
| 279 | oldpmucontrol = R_REG(osh, &cc->pmucontrol); |
| 280 | if (force) |
| 281 | W_REG(osh, &cc->pmucontrol, oldpmucontrol & |
| 282 | ~(PCTL_HT_REQ_EN | PCTL_ALP_REQ_EN)); |
| 283 | else |
| 284 | W_REG(osh, &cc->pmucontrol, oldpmucontrol | |
| 285 | (PCTL_HT_REQ_EN | PCTL_ALP_REQ_EN)); |
| 286 | |
| 287 | /* Return to original core */ |
| 288 | si_setcoreidx(sih, origidx); |
| 289 | |
| 290 | return oldpmucontrol; |
| 291 | } |
| 292 | |
| 293 | /* Setup resource up/down timers */ |
| 294 | typedef struct { |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 295 | u8 resnum; |
Greg Kroah-Hartman | 7d4df48 | 2010-10-07 17:04:47 -0700 | [diff] [blame] | 296 | u16 updown; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 297 | } pmu_res_updown_t; |
| 298 | |
| 299 | /* Change resource dependancies masks */ |
| 300 | typedef struct { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 301 | u32 res_mask; /* resources (chip specific) */ |
Greg Kroah-Hartman | 562c885 | 2010-10-05 11:04:17 -0700 | [diff] [blame] | 302 | s8 action; /* action */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 303 | u32 depend_mask; /* changes to the dependancies mask */ |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 304 | bool(*filter) (si_t *sih); /* action is taken when filter is NULL or return true */ |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 305 | } pmu_res_depend_t; |
| 306 | |
| 307 | /* Resource dependancies mask change action */ |
| 308 | #define RES_DEPEND_SET 0 /* Override the dependancies mask */ |
| 309 | #define RES_DEPEND_ADD 1 /* Add to the dependancies mask */ |
| 310 | #define RES_DEPEND_REMOVE -1 /* Remove from the dependancies mask */ |
| 311 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 312 | static const pmu_res_updown_t bcm4328a0_res_updown[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 313 | { |
| 314 | RES4328_EXT_SWITCHER_PWM, 0x0101}, { |
| 315 | RES4328_BB_SWITCHER_PWM, 0x1f01}, { |
| 316 | RES4328_BB_SWITCHER_BURST, 0x010f}, { |
| 317 | RES4328_BB_EXT_SWITCHER_BURST, 0x0101}, { |
| 318 | RES4328_ILP_REQUEST, 0x0202}, { |
| 319 | RES4328_RADIO_SWITCHER_PWM, 0x0f01}, { |
| 320 | RES4328_RADIO_SWITCHER_BURST, 0x0f01}, { |
| 321 | RES4328_ROM_SWITCH, 0x0101}, { |
| 322 | RES4328_PA_REF_LDO, 0x0f01}, { |
| 323 | RES4328_RADIO_LDO, 0x0f01}, { |
| 324 | RES4328_AFE_LDO, 0x0f01}, { |
| 325 | RES4328_PLL_LDO, 0x0f01}, { |
| 326 | RES4328_BG_FILTBYP, 0x0101}, { |
| 327 | RES4328_TX_FILTBYP, 0x0101}, { |
| 328 | RES4328_RX_FILTBYP, 0x0101}, { |
| 329 | RES4328_XTAL_PU, 0x0101}, { |
| 330 | RES4328_XTAL_EN, 0xa001}, { |
| 331 | RES4328_BB_PLL_FILTBYP, 0x0101}, { |
| 332 | RES4328_RF_PLL_FILTBYP, 0x0101}, { |
| 333 | RES4328_BB_PLL_PU, 0x0701} |
| 334 | }; |
| 335 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 336 | static const pmu_res_depend_t bcm4328a0_res_depend[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 337 | /* Adjust ILP request resource not to force ext/BB switchers into burst mode */ |
| 338 | { |
| 339 | PMURES_BIT(RES4328_ILP_REQUEST), |
| 340 | RES_DEPEND_SET, |
| 341 | PMURES_BIT(RES4328_EXT_SWITCHER_PWM) | |
| 342 | PMURES_BIT(RES4328_BB_SWITCHER_PWM), NULL} |
| 343 | }; |
| 344 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 345 | static const pmu_res_updown_t bcm4325a0_res_updown_qt[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 346 | { |
| 347 | RES4325_HT_AVAIL, 0x0300}, { |
| 348 | RES4325_BBPLL_PWRSW_PU, 0x0101}, { |
| 349 | RES4325_RFPLL_PWRSW_PU, 0x0101}, { |
| 350 | RES4325_ALP_AVAIL, 0x0100}, { |
| 351 | RES4325_XTAL_PU, 0x1000}, { |
| 352 | RES4325_LNLDO1_PU, 0x0800}, { |
| 353 | RES4325_CLDO_CBUCK_PWM, 0x0101}, { |
| 354 | RES4325_CBUCK_PWM, 0x0803} |
| 355 | }; |
| 356 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 357 | static const pmu_res_updown_t bcm4325a0_res_updown[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 358 | { |
| 359 | RES4325_XTAL_PU, 0x1501} |
| 360 | }; |
| 361 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 362 | static const pmu_res_depend_t bcm4325a0_res_depend[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 363 | /* Adjust OTP PU resource dependencies - remove BB BURST */ |
| 364 | { |
| 365 | PMURES_BIT(RES4325_OTP_PU), |
| 366 | RES_DEPEND_REMOVE, |
| 367 | PMURES_BIT(RES4325_BUCK_BOOST_BURST), NULL}, |
| 368 | /* Adjust ALP/HT Avail resource dependencies - bring up BB along if it is used. */ |
| 369 | { |
| 370 | PMURES_BIT(RES4325_ALP_AVAIL) | PMURES_BIT(RES4325_HT_AVAIL), |
| 371 | RES_DEPEND_ADD, |
| 372 | PMURES_BIT(RES4325_BUCK_BOOST_BURST) | |
| 373 | PMURES_BIT(RES4325_BUCK_BOOST_PWM), si_pmu_res_depfltr_bb}, |
| 374 | /* Adjust HT Avail resource dependencies - bring up RF switches along with HT. */ |
| 375 | { |
| 376 | PMURES_BIT(RES4325_HT_AVAIL), |
| 377 | RES_DEPEND_ADD, |
| 378 | PMURES_BIT(RES4325_RX_PWRSW_PU) | |
| 379 | PMURES_BIT(RES4325_TX_PWRSW_PU) | |
| 380 | PMURES_BIT(RES4325_LOGEN_PWRSW_PU) | |
| 381 | PMURES_BIT(RES4325_AFE_PWRSW_PU), NULL}, |
| 382 | /* Adjust ALL resource dependencies - remove CBUCK dependancies if it is not used. */ |
| 383 | { |
| 384 | PMURES_BIT(RES4325_ILP_REQUEST) | |
| 385 | PMURES_BIT(RES4325_ABUCK_BURST) | |
| 386 | PMURES_BIT(RES4325_ABUCK_PWM) | |
| 387 | PMURES_BIT(RES4325_LNLDO1_PU) | |
| 388 | PMURES_BIT(RES4325C1_LNLDO2_PU) | |
| 389 | PMURES_BIT(RES4325_XTAL_PU) | |
| 390 | PMURES_BIT(RES4325_ALP_AVAIL) | |
| 391 | PMURES_BIT(RES4325_RX_PWRSW_PU) | |
| 392 | PMURES_BIT(RES4325_TX_PWRSW_PU) | |
| 393 | PMURES_BIT(RES4325_RFPLL_PWRSW_PU) | |
| 394 | PMURES_BIT(RES4325_LOGEN_PWRSW_PU) | |
| 395 | PMURES_BIT(RES4325_AFE_PWRSW_PU) | |
| 396 | PMURES_BIT(RES4325_BBPLL_PWRSW_PU) | |
| 397 | PMURES_BIT(RES4325_HT_AVAIL), RES_DEPEND_REMOVE, |
| 398 | PMURES_BIT(RES4325B0_CBUCK_LPOM) | |
| 399 | PMURES_BIT(RES4325B0_CBUCK_BURST) | |
| 400 | PMURES_BIT(RES4325B0_CBUCK_PWM), si_pmu_res_depfltr_ncb} |
| 401 | }; |
| 402 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 403 | static const pmu_res_updown_t bcm4315a0_res_updown_qt[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 404 | { |
| 405 | RES4315_HT_AVAIL, 0x0101}, { |
| 406 | RES4315_XTAL_PU, 0x0100}, { |
| 407 | RES4315_LNLDO1_PU, 0x0100}, { |
| 408 | RES4315_PALDO_PU, 0x0100}, { |
| 409 | RES4315_CLDO_PU, 0x0100}, { |
| 410 | RES4315_CBUCK_PWM, 0x0100}, { |
| 411 | RES4315_CBUCK_BURST, 0x0100}, { |
| 412 | RES4315_CBUCK_LPOM, 0x0100} |
| 413 | }; |
| 414 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 415 | static const pmu_res_updown_t bcm4315a0_res_updown[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 416 | { |
| 417 | RES4315_XTAL_PU, 0x2501} |
| 418 | }; |
| 419 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 420 | static const pmu_res_depend_t bcm4315a0_res_depend[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 421 | /* Adjust OTP PU resource dependencies - not need PALDO unless write */ |
| 422 | { |
| 423 | PMURES_BIT(RES4315_OTP_PU), |
| 424 | RES_DEPEND_REMOVE, |
| 425 | PMURES_BIT(RES4315_PALDO_PU), si_pmu_res_depfltr_npaldo}, |
| 426 | /* Adjust ALP/HT Avail resource dependencies - bring up PALDO along if it is used. */ |
| 427 | { |
| 428 | PMURES_BIT(RES4315_ALP_AVAIL) | PMURES_BIT(RES4315_HT_AVAIL), |
| 429 | RES_DEPEND_ADD, |
| 430 | PMURES_BIT(RES4315_PALDO_PU), si_pmu_res_depfltr_paldo}, |
| 431 | /* Adjust HT Avail resource dependencies - bring up RF switches along with HT. */ |
| 432 | { |
| 433 | PMURES_BIT(RES4315_HT_AVAIL), |
| 434 | RES_DEPEND_ADD, |
| 435 | PMURES_BIT(RES4315_RX_PWRSW_PU) | |
| 436 | PMURES_BIT(RES4315_TX_PWRSW_PU) | |
| 437 | PMURES_BIT(RES4315_LOGEN_PWRSW_PU) | |
| 438 | PMURES_BIT(RES4315_AFE_PWRSW_PU), NULL}, |
| 439 | /* Adjust ALL resource dependencies - remove CBUCK dependancies if it is not used. */ |
| 440 | { |
| 441 | PMURES_BIT(RES4315_CLDO_PU) | PMURES_BIT(RES4315_ILP_REQUEST) | |
| 442 | PMURES_BIT(RES4315_LNLDO1_PU) | |
| 443 | PMURES_BIT(RES4315_OTP_PU) | |
| 444 | PMURES_BIT(RES4315_LNLDO2_PU) | |
| 445 | PMURES_BIT(RES4315_XTAL_PU) | |
| 446 | PMURES_BIT(RES4315_ALP_AVAIL) | |
| 447 | PMURES_BIT(RES4315_RX_PWRSW_PU) | |
| 448 | PMURES_BIT(RES4315_TX_PWRSW_PU) | |
| 449 | PMURES_BIT(RES4315_RFPLL_PWRSW_PU) | |
| 450 | PMURES_BIT(RES4315_LOGEN_PWRSW_PU) | |
| 451 | PMURES_BIT(RES4315_AFE_PWRSW_PU) | |
| 452 | PMURES_BIT(RES4315_BBPLL_PWRSW_PU) | |
| 453 | PMURES_BIT(RES4315_HT_AVAIL), RES_DEPEND_REMOVE, |
| 454 | PMURES_BIT(RES4315_CBUCK_LPOM) | |
| 455 | PMURES_BIT(RES4315_CBUCK_BURST) | |
| 456 | PMURES_BIT(RES4315_CBUCK_PWM), si_pmu_res_depfltr_ncb} |
| 457 | }; |
| 458 | |
| 459 | /* 4329 specific. needs to come back this issue later */ |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 460 | static const pmu_res_updown_t bcm4329_res_updown[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 461 | { |
| 462 | RES4329_XTAL_PU, 0x1501} |
| 463 | }; |
| 464 | |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 465 | static const pmu_res_depend_t bcm4329_res_depend[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 466 | /* Adjust HT Avail resource dependencies */ |
| 467 | { |
| 468 | PMURES_BIT(RES4329_HT_AVAIL), |
| 469 | RES_DEPEND_ADD, |
| 470 | PMURES_BIT(RES4329_CBUCK_LPOM) | |
| 471 | PMURES_BIT(RES4329_CBUCK_BURST) | |
| 472 | PMURES_BIT(RES4329_CBUCK_PWM) | |
| 473 | PMURES_BIT(RES4329_CLDO_PU) | |
| 474 | PMURES_BIT(RES4329_PALDO_PU) | |
| 475 | PMURES_BIT(RES4329_LNLDO1_PU) | |
| 476 | PMURES_BIT(RES4329_XTAL_PU) | |
| 477 | PMURES_BIT(RES4329_ALP_AVAIL) | |
| 478 | PMURES_BIT(RES4329_RX_PWRSW_PU) | |
| 479 | PMURES_BIT(RES4329_TX_PWRSW_PU) | |
| 480 | PMURES_BIT(RES4329_RFPLL_PWRSW_PU) | |
| 481 | PMURES_BIT(RES4329_LOGEN_PWRSW_PU) | |
| 482 | PMURES_BIT(RES4329_AFE_PWRSW_PU) | |
| 483 | PMURES_BIT(RES4329_BBPLL_PWRSW_PU), NULL} |
| 484 | }; |
| 485 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 486 | static const pmu_res_updown_t bcm4319a0_res_updown_qt[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 487 | { |
| 488 | RES4319_HT_AVAIL, 0x0101}, { |
| 489 | RES4319_XTAL_PU, 0x0100}, { |
| 490 | RES4319_LNLDO1_PU, 0x0100}, { |
| 491 | RES4319_PALDO_PU, 0x0100}, { |
| 492 | RES4319_CLDO_PU, 0x0100}, { |
| 493 | RES4319_CBUCK_PWM, 0x0100}, { |
| 494 | RES4319_CBUCK_BURST, 0x0100}, { |
| 495 | RES4319_CBUCK_LPOM, 0x0100} |
| 496 | }; |
| 497 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 498 | static const pmu_res_updown_t bcm4319a0_res_updown[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 499 | { |
| 500 | RES4319_XTAL_PU, 0x3f01} |
| 501 | }; |
| 502 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 503 | static const pmu_res_depend_t bcm4319a0_res_depend[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 504 | /* Adjust OTP PU resource dependencies - not need PALDO unless write */ |
| 505 | { |
| 506 | PMURES_BIT(RES4319_OTP_PU), |
| 507 | RES_DEPEND_REMOVE, |
| 508 | PMURES_BIT(RES4319_PALDO_PU), si_pmu_res_depfltr_npaldo}, |
| 509 | /* Adjust HT Avail resource dependencies - bring up PALDO along if it is used. */ |
| 510 | { |
| 511 | PMURES_BIT(RES4319_HT_AVAIL), |
| 512 | RES_DEPEND_ADD, |
| 513 | PMURES_BIT(RES4319_PALDO_PU), si_pmu_res_depfltr_paldo}, |
| 514 | /* Adjust HT Avail resource dependencies - bring up RF switches along with HT. */ |
| 515 | { |
| 516 | PMURES_BIT(RES4319_HT_AVAIL), |
| 517 | RES_DEPEND_ADD, |
| 518 | PMURES_BIT(RES4319_RX_PWRSW_PU) | |
| 519 | PMURES_BIT(RES4319_TX_PWRSW_PU) | |
| 520 | PMURES_BIT(RES4319_RFPLL_PWRSW_PU) | |
| 521 | PMURES_BIT(RES4319_LOGEN_PWRSW_PU) | |
| 522 | PMURES_BIT(RES4319_AFE_PWRSW_PU), NULL} |
| 523 | }; |
| 524 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 525 | static const pmu_res_updown_t bcm4336a0_res_updown_qt[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 526 | { |
| 527 | RES4336_HT_AVAIL, 0x0101}, { |
| 528 | RES4336_XTAL_PU, 0x0100}, { |
| 529 | RES4336_CLDO_PU, 0x0100}, { |
| 530 | RES4336_CBUCK_PWM, 0x0100}, { |
| 531 | RES4336_CBUCK_BURST, 0x0100}, { |
| 532 | RES4336_CBUCK_LPOM, 0x0100} |
| 533 | }; |
| 534 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 535 | static const pmu_res_updown_t bcm4336a0_res_updown[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 536 | { |
| 537 | RES4336_HT_AVAIL, 0x0D01} |
| 538 | }; |
| 539 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 540 | static const pmu_res_depend_t bcm4336a0_res_depend[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 541 | /* Just a dummy entry for now */ |
| 542 | { |
| 543 | PMURES_BIT(RES4336_RSVD), RES_DEPEND_ADD, 0, NULL} |
| 544 | }; |
| 545 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 546 | static const pmu_res_updown_t bcm4330a0_res_updown_qt[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 547 | { |
| 548 | RES4330_HT_AVAIL, 0x0101}, { |
| 549 | RES4330_XTAL_PU, 0x0100}, { |
| 550 | RES4330_CLDO_PU, 0x0100}, { |
| 551 | RES4330_CBUCK_PWM, 0x0100}, { |
| 552 | RES4330_CBUCK_BURST, 0x0100}, { |
| 553 | RES4330_CBUCK_LPOM, 0x0100} |
| 554 | }; |
| 555 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 556 | static const pmu_res_updown_t bcm4330a0_res_updown[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 557 | { |
| 558 | RES4330_HT_AVAIL, 0x0e02} |
| 559 | }; |
| 560 | |
Greg Kroah-Hartman | 17c4da1 | 2010-10-08 14:11:20 -0700 | [diff] [blame] | 561 | static const pmu_res_depend_t bcm4330a0_res_depend[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 562 | /* Just a dummy entry for now */ |
| 563 | { |
| 564 | PMURES_BIT(RES4330_HT_AVAIL), RES_DEPEND_ADD, 0, NULL} |
| 565 | }; |
| 566 | |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 567 | /* true if the power topology uses the buck boost to provide 3.3V to VDDIO_RF and WLAN PA */ |
Greg Kroah-Hartman | 0d2f072 | 2010-10-08 14:28:21 -0700 | [diff] [blame] | 568 | static bool si_pmu_res_depfltr_bb(si_t *sih) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 569 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 570 | return (sih->boardflags & BFL_BUCKBOOST) != 0; |
| 571 | } |
| 572 | |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 573 | /* true if the power topology doesn't use the cbuck. Key on chiprev also if the chip is BCM4325. */ |
Greg Kroah-Hartman | 0d2f072 | 2010-10-08 14:28:21 -0700 | [diff] [blame] | 574 | static bool si_pmu_res_depfltr_ncb(si_t *sih) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 575 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 576 | |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 577 | return (sih->boardflags & BFL_NOCBUCK) != 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 580 | /* true if the power topology uses the PALDO */ |
Greg Kroah-Hartman | 0d2f072 | 2010-10-08 14:28:21 -0700 | [diff] [blame] | 581 | static bool si_pmu_res_depfltr_paldo(si_t *sih) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 582 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 583 | return (sih->boardflags & BFL_PALDO) != 0; |
| 584 | } |
| 585 | |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 586 | /* true if the power topology doesn't use the PALDO */ |
Greg Kroah-Hartman | 0d2f072 | 2010-10-08 14:28:21 -0700 | [diff] [blame] | 587 | static bool si_pmu_res_depfltr_npaldo(si_t *sih) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 588 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 589 | return (sih->boardflags & BFL_PALDO) == 0; |
| 590 | } |
| 591 | |
| 592 | #define BCM94325_BBVDDIOSD_BOARDS(sih) (sih->boardtype == BCM94325DEVBU_BOARD || \ |
| 593 | sih->boardtype == BCM94325BGABU_BOARD) |
| 594 | |
| 595 | /* Determine min/max rsrc masks. Value 0 leaves hardware at default. */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 596 | static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 597 | { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 598 | u32 min_mask = 0, max_mask = 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 599 | uint rsrcs; |
| 600 | char *val; |
| 601 | |
| 602 | /* # resources */ |
| 603 | rsrcs = (sih->pmucaps & PCAP_RC_MASK) >> PCAP_RC_SHIFT; |
| 604 | |
| 605 | /* determine min/max rsrc masks */ |
| 606 | switch (CHIPID(sih->chip)) { |
| 607 | case BCM43224_CHIP_ID: |
| 608 | case BCM43225_CHIP_ID: |
| 609 | case BCM43421_CHIP_ID: |
| 610 | case BCM43235_CHIP_ID: |
| 611 | case BCM43236_CHIP_ID: |
| 612 | case BCM43238_CHIP_ID: |
| 613 | case BCM4331_CHIP_ID: |
| 614 | case BCM6362_CHIP_ID: |
| 615 | /* ??? */ |
| 616 | break; |
| 617 | |
| 618 | case BCM4329_CHIP_ID: |
| 619 | /* 4329 spedific issue. Needs to come back this issue later */ |
| 620 | /* Down to save the power. */ |
| 621 | min_mask = |
| 622 | PMURES_BIT(RES4329_CBUCK_LPOM) | |
| 623 | PMURES_BIT(RES4329_CLDO_PU); |
| 624 | /* Allow (but don't require) PLL to turn on */ |
| 625 | max_mask = 0x3ff63e; |
| 626 | break; |
| 627 | case BCM4319_CHIP_ID: |
| 628 | /* We only need a few resources to be kept on all the time */ |
| 629 | min_mask = PMURES_BIT(RES4319_CBUCK_LPOM) | |
| 630 | PMURES_BIT(RES4319_CLDO_PU); |
| 631 | |
| 632 | /* Allow everything else to be turned on upon requests */ |
| 633 | max_mask = ~(~0 << rsrcs); |
| 634 | break; |
| 635 | case BCM4336_CHIP_ID: |
| 636 | /* Down to save the power. */ |
| 637 | min_mask = |
| 638 | PMURES_BIT(RES4336_CBUCK_LPOM) | PMURES_BIT(RES4336_CLDO_PU) |
| 639 | | PMURES_BIT(RES4336_LDO3P3_PU) | PMURES_BIT(RES4336_OTP_PU) |
| 640 | | PMURES_BIT(RES4336_DIS_INT_RESET_PD); |
| 641 | /* Allow (but don't require) PLL to turn on */ |
| 642 | max_mask = 0x1ffffff; |
| 643 | break; |
| 644 | |
| 645 | case BCM4330_CHIP_ID: |
| 646 | /* Down to save the power. */ |
| 647 | min_mask = |
| 648 | PMURES_BIT(RES4330_CBUCK_LPOM) | PMURES_BIT(RES4330_CLDO_PU) |
| 649 | | PMURES_BIT(RES4330_DIS_INT_RESET_PD) | |
| 650 | PMURES_BIT(RES4330_LDO3P3_PU) | PMURES_BIT(RES4330_OTP_PU); |
| 651 | /* Allow (but don't require) PLL to turn on */ |
| 652 | max_mask = 0xfffffff; |
| 653 | break; |
| 654 | |
| 655 | case BCM4313_CHIP_ID: |
| 656 | min_mask = PMURES_BIT(RES4313_BB_PU_RSRC) | |
| 657 | PMURES_BIT(RES4313_XTAL_PU_RSRC) | |
| 658 | PMURES_BIT(RES4313_ALP_AVAIL_RSRC) | |
| 659 | PMURES_BIT(RES4313_BB_PLL_PWRSW_RSRC); |
| 660 | max_mask = 0xffff; |
| 661 | break; |
| 662 | default: |
| 663 | break; |
| 664 | } |
| 665 | |
| 666 | /* Apply nvram override to min mask */ |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 667 | val = getvar(NULL, "rmin"); |
| 668 | if (val != NULL) { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 669 | PMU_MSG(("Applying rmin=%s to min_mask\n", val)); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 670 | min_mask = (u32) simple_strtoul(val, NULL, 0); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 671 | } |
| 672 | /* Apply nvram override to max mask */ |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 673 | val = getvar(NULL, "rmax"); |
| 674 | if (val != NULL) { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 675 | PMU_MSG(("Applying rmax=%s to max_mask\n", val)); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 676 | max_mask = (u32) simple_strtoul(val, NULL, 0); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | *pmin = min_mask; |
| 680 | *pmax = max_mask; |
| 681 | } |
| 682 | |
| 683 | /* initialize PMU resources */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 684 | void si_pmu_res_init(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 685 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 686 | chipcregs_t *cc; |
| 687 | uint origidx; |
| 688 | const pmu_res_updown_t *pmu_res_updown_table = NULL; |
| 689 | uint pmu_res_updown_table_sz = 0; |
| 690 | const pmu_res_depend_t *pmu_res_depend_table = NULL; |
| 691 | uint pmu_res_depend_table_sz = 0; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 692 | u32 min_mask = 0, max_mask = 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 693 | char name[8], *val; |
| 694 | uint i, rsrcs; |
| 695 | |
| 696 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 697 | |
| 698 | /* Remember original core before switch to chipc */ |
| 699 | origidx = si_coreidx(sih); |
| 700 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 701 | ASSERT(cc != NULL); |
| 702 | |
| 703 | switch (CHIPID(sih->chip)) { |
| 704 | case BCM4329_CHIP_ID: |
| 705 | /* Optimize resources up/down timers */ |
| 706 | if (ISSIM_ENAB(sih)) { |
| 707 | pmu_res_updown_table = NULL; |
| 708 | pmu_res_updown_table_sz = 0; |
| 709 | } else { |
| 710 | pmu_res_updown_table = bcm4329_res_updown; |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 711 | pmu_res_updown_table_sz = ARRAY_SIZE(bcm4329_res_updown); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 712 | } |
| 713 | /* Optimize resources dependencies */ |
| 714 | pmu_res_depend_table = bcm4329_res_depend; |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 715 | pmu_res_depend_table_sz = ARRAY_SIZE(bcm4329_res_depend); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 716 | break; |
| 717 | |
| 718 | case BCM4319_CHIP_ID: |
| 719 | /* Optimize resources up/down timers */ |
| 720 | if (ISSIM_ENAB(sih)) { |
| 721 | pmu_res_updown_table = bcm4319a0_res_updown_qt; |
| 722 | pmu_res_updown_table_sz = |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 723 | ARRAY_SIZE(bcm4319a0_res_updown_qt); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 724 | } else { |
| 725 | pmu_res_updown_table = bcm4319a0_res_updown; |
| 726 | pmu_res_updown_table_sz = |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 727 | ARRAY_SIZE(bcm4319a0_res_updown); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 728 | } |
| 729 | /* Optimize resources dependancies masks */ |
| 730 | pmu_res_depend_table = bcm4319a0_res_depend; |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 731 | pmu_res_depend_table_sz = ARRAY_SIZE(bcm4319a0_res_depend); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 732 | break; |
| 733 | |
| 734 | case BCM4336_CHIP_ID: |
| 735 | /* Optimize resources up/down timers */ |
| 736 | if (ISSIM_ENAB(sih)) { |
| 737 | pmu_res_updown_table = bcm4336a0_res_updown_qt; |
| 738 | pmu_res_updown_table_sz = |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 739 | ARRAY_SIZE(bcm4336a0_res_updown_qt); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 740 | } else { |
| 741 | pmu_res_updown_table = bcm4336a0_res_updown; |
| 742 | pmu_res_updown_table_sz = |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 743 | ARRAY_SIZE(bcm4336a0_res_updown); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 744 | } |
| 745 | /* Optimize resources dependancies masks */ |
| 746 | pmu_res_depend_table = bcm4336a0_res_depend; |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 747 | pmu_res_depend_table_sz = ARRAY_SIZE(bcm4336a0_res_depend); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 748 | break; |
| 749 | |
| 750 | case BCM4330_CHIP_ID: |
| 751 | /* Optimize resources up/down timers */ |
| 752 | if (ISSIM_ENAB(sih)) { |
| 753 | pmu_res_updown_table = bcm4330a0_res_updown_qt; |
| 754 | pmu_res_updown_table_sz = |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 755 | ARRAY_SIZE(bcm4330a0_res_updown_qt); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 756 | } else { |
| 757 | pmu_res_updown_table = bcm4330a0_res_updown; |
| 758 | pmu_res_updown_table_sz = |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 759 | ARRAY_SIZE(bcm4330a0_res_updown); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 760 | } |
| 761 | /* Optimize resources dependancies masks */ |
| 762 | pmu_res_depend_table = bcm4330a0_res_depend; |
Greg Kroah-Hartman | 8d3d6a6 | 2010-10-08 11:47:11 -0700 | [diff] [blame] | 763 | pmu_res_depend_table_sz = ARRAY_SIZE(bcm4330a0_res_depend); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 764 | break; |
| 765 | |
| 766 | default: |
| 767 | break; |
| 768 | } |
| 769 | |
| 770 | /* # resources */ |
| 771 | rsrcs = (sih->pmucaps & PCAP_RC_MASK) >> PCAP_RC_SHIFT; |
| 772 | |
| 773 | /* Program up/down timers */ |
| 774 | while (pmu_res_updown_table_sz--) { |
| 775 | ASSERT(pmu_res_updown_table != NULL); |
| 776 | PMU_MSG(("Changing rsrc %d res_updn_timer to 0x%x\n", |
| 777 | pmu_res_updown_table[pmu_res_updown_table_sz].resnum, |
| 778 | pmu_res_updown_table[pmu_res_updown_table_sz].updown)); |
| 779 | W_REG(osh, &cc->res_table_sel, |
| 780 | pmu_res_updown_table[pmu_res_updown_table_sz].resnum); |
| 781 | W_REG(osh, &cc->res_updn_timer, |
| 782 | pmu_res_updown_table[pmu_res_updown_table_sz].updown); |
| 783 | } |
| 784 | /* Apply nvram overrides to up/down timers */ |
| 785 | for (i = 0; i < rsrcs; i++) { |
| 786 | snprintf(name, sizeof(name), "r%dt", i); |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 787 | val = getvar(NULL, name); |
| 788 | if (val == NULL) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 789 | continue; |
| 790 | PMU_MSG(("Applying %s=%s to rsrc %d res_updn_timer\n", name, |
| 791 | val, i)); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 792 | W_REG(osh, &cc->res_table_sel, (u32) i); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 793 | W_REG(osh, &cc->res_updn_timer, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 794 | (u32) simple_strtoul(val, NULL, 0)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | /* Program resource dependencies table */ |
| 798 | while (pmu_res_depend_table_sz--) { |
| 799 | ASSERT(pmu_res_depend_table != NULL); |
| 800 | if (pmu_res_depend_table[pmu_res_depend_table_sz].filter != NULL |
| 801 | && !(pmu_res_depend_table[pmu_res_depend_table_sz]. |
| 802 | filter) (sih)) |
| 803 | continue; |
| 804 | for (i = 0; i < rsrcs; i++) { |
| 805 | if ((pmu_res_depend_table[pmu_res_depend_table_sz]. |
| 806 | res_mask & PMURES_BIT(i)) == 0) |
| 807 | continue; |
| 808 | W_REG(osh, &cc->res_table_sel, i); |
| 809 | switch (pmu_res_depend_table[pmu_res_depend_table_sz]. |
| 810 | action) { |
| 811 | case RES_DEPEND_SET: |
| 812 | PMU_MSG(("Changing rsrc %d res_dep_mask to 0x%x\n", i, pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask)); |
| 813 | W_REG(osh, &cc->res_dep_mask, |
| 814 | pmu_res_depend_table |
| 815 | [pmu_res_depend_table_sz].depend_mask); |
| 816 | break; |
| 817 | case RES_DEPEND_ADD: |
| 818 | PMU_MSG(("Adding 0x%x to rsrc %d res_dep_mask\n", pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask, i)); |
| 819 | OR_REG(osh, &cc->res_dep_mask, |
| 820 | pmu_res_depend_table |
| 821 | [pmu_res_depend_table_sz].depend_mask); |
| 822 | break; |
| 823 | case RES_DEPEND_REMOVE: |
| 824 | PMU_MSG(("Removing 0x%x from rsrc %d res_dep_mask\n", pmu_res_depend_table[pmu_res_depend_table_sz].depend_mask, i)); |
| 825 | AND_REG(osh, &cc->res_dep_mask, |
| 826 | ~pmu_res_depend_table |
| 827 | [pmu_res_depend_table_sz].depend_mask); |
| 828 | break; |
| 829 | default: |
| 830 | ASSERT(0); |
| 831 | break; |
| 832 | } |
| 833 | } |
| 834 | } |
| 835 | /* Apply nvram overrides to dependancies masks */ |
| 836 | for (i = 0; i < rsrcs; i++) { |
| 837 | snprintf(name, sizeof(name), "r%dd", i); |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 838 | val = getvar(NULL, name); |
| 839 | if (val == NULL) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 840 | continue; |
| 841 | PMU_MSG(("Applying %s=%s to rsrc %d res_dep_mask\n", name, val, |
| 842 | i)); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 843 | W_REG(osh, &cc->res_table_sel, (u32) i); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 844 | W_REG(osh, &cc->res_dep_mask, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 845 | (u32) simple_strtoul(val, NULL, 0)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | /* Determine min/max rsrc masks */ |
| 849 | si_pmu_res_masks(sih, &min_mask, &max_mask); |
| 850 | |
| 851 | /* It is required to program max_mask first and then min_mask */ |
| 852 | |
| 853 | /* Program max resource mask */ |
| 854 | |
| 855 | if (max_mask) { |
| 856 | PMU_MSG(("Changing max_res_mask to 0x%x\n", max_mask)); |
| 857 | W_REG(osh, &cc->max_res_mask, max_mask); |
| 858 | } |
| 859 | |
| 860 | /* Program min resource mask */ |
| 861 | |
| 862 | if (min_mask) { |
| 863 | PMU_MSG(("Changing min_res_mask to 0x%x\n", min_mask)); |
| 864 | W_REG(osh, &cc->min_res_mask, min_mask); |
| 865 | } |
| 866 | |
| 867 | /* Add some delay; allow resources to come up and settle. */ |
mike.rapoport@gmail.com | 7383141 | 2010-10-13 00:09:07 +0200 | [diff] [blame] | 868 | mdelay(2); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 869 | |
| 870 | /* Return to original core */ |
| 871 | si_setcoreidx(sih, origidx); |
| 872 | } |
| 873 | |
| 874 | /* setup pll and query clock speed */ |
| 875 | typedef struct { |
Greg Kroah-Hartman | 7d4df48 | 2010-10-07 17:04:47 -0700 | [diff] [blame] | 876 | u16 freq; |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 877 | u8 xf; |
| 878 | u8 wbint; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 879 | u32 wbfrac; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 880 | } pmu0_xtaltab0_t; |
| 881 | |
| 882 | /* the following table is based on 880Mhz fvco */ |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 883 | static const pmu0_xtaltab0_t pmu0_xtaltab0[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 884 | { |
| 885 | 12000, 1, 73, 349525}, { |
| 886 | 13000, 2, 67, 725937}, { |
| 887 | 14400, 3, 61, 116508}, { |
| 888 | 15360, 4, 57, 305834}, { |
| 889 | 16200, 5, 54, 336579}, { |
| 890 | 16800, 6, 52, 399457}, { |
| 891 | 19200, 7, 45, 873813}, { |
| 892 | 19800, 8, 44, 466033}, { |
| 893 | 20000, 9, 44, 0}, { |
| 894 | 25000, 10, 70, 419430}, { |
| 895 | 26000, 11, 67, 725937}, { |
| 896 | 30000, 12, 58, 699050}, { |
| 897 | 38400, 13, 45, 873813}, { |
| 898 | 40000, 14, 45, 0}, { |
| 899 | 0, 0, 0, 0} |
| 900 | }; |
| 901 | |
| 902 | #define PMU0_XTAL0_DEFAULT 8 |
| 903 | |
| 904 | /* setup pll and query clock speed */ |
| 905 | typedef struct { |
Greg Kroah-Hartman | 7d4df48 | 2010-10-07 17:04:47 -0700 | [diff] [blame] | 906 | u16 fref; |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 907 | u8 xf; |
| 908 | u8 p1div; |
| 909 | u8 p2div; |
| 910 | u8 ndiv_int; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 911 | u32 ndiv_frac; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 912 | } pmu1_xtaltab0_t; |
| 913 | |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 914 | static const pmu1_xtaltab0_t pmu1_xtaltab0_880_4329[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 915 | { |
| 916 | 12000, 1, 3, 22, 0x9, 0xFFFFEF}, { |
| 917 | 13000, 2, 1, 6, 0xb, 0x483483}, { |
| 918 | 14400, 3, 1, 10, 0xa, 0x1C71C7}, { |
| 919 | 15360, 4, 1, 5, 0xb, 0x755555}, { |
| 920 | 16200, 5, 1, 10, 0x5, 0x6E9E06}, { |
| 921 | 16800, 6, 1, 10, 0x5, 0x3Cf3Cf}, { |
| 922 | 19200, 7, 1, 4, 0xb, 0x755555}, { |
| 923 | 19800, 8, 1, 11, 0x4, 0xA57EB}, { |
| 924 | 20000, 9, 1, 11, 0x4, 0x0}, { |
| 925 | 24000, 10, 3, 11, 0xa, 0x0}, { |
| 926 | 25000, 11, 5, 16, 0xb, 0x0}, { |
| 927 | 26000, 12, 1, 1, 0x21, 0xD89D89}, { |
| 928 | 30000, 13, 3, 8, 0xb, 0x0}, { |
| 929 | 37400, 14, 3, 1, 0x46, 0x969696}, { |
| 930 | 38400, 15, 1, 1, 0x16, 0xEAAAAA}, { |
| 931 | 40000, 16, 1, 2, 0xb, 0}, { |
| 932 | 0, 0, 0, 0, 0, 0} |
| 933 | }; |
| 934 | |
| 935 | /* the following table is based on 880Mhz fvco */ |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 936 | static const pmu1_xtaltab0_t pmu1_xtaltab0_880[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 937 | { |
| 938 | 12000, 1, 3, 22, 0x9, 0xFFFFEF}, { |
| 939 | 13000, 2, 1, 6, 0xb, 0x483483}, { |
| 940 | 14400, 3, 1, 10, 0xa, 0x1C71C7}, { |
| 941 | 15360, 4, 1, 5, 0xb, 0x755555}, { |
| 942 | 16200, 5, 1, 10, 0x5, 0x6E9E06}, { |
| 943 | 16800, 6, 1, 10, 0x5, 0x3Cf3Cf}, { |
| 944 | 19200, 7, 1, 4, 0xb, 0x755555}, { |
| 945 | 19800, 8, 1, 11, 0x4, 0xA57EB}, { |
| 946 | 20000, 9, 1, 11, 0x4, 0x0}, { |
| 947 | 24000, 10, 3, 11, 0xa, 0x0}, { |
| 948 | 25000, 11, 5, 16, 0xb, 0x0}, { |
| 949 | 26000, 12, 1, 2, 0x10, 0xEC4EC4}, { |
| 950 | 30000, 13, 3, 8, 0xb, 0x0}, { |
| 951 | 33600, 14, 1, 2, 0xd, 0x186186}, { |
| 952 | 38400, 15, 1, 2, 0xb, 0x755555}, { |
| 953 | 40000, 16, 1, 2, 0xb, 0}, { |
| 954 | 0, 0, 0, 0, 0, 0} |
| 955 | }; |
| 956 | |
| 957 | #define PMU1_XTALTAB0_880_12000K 0 |
| 958 | #define PMU1_XTALTAB0_880_13000K 1 |
| 959 | #define PMU1_XTALTAB0_880_14400K 2 |
| 960 | #define PMU1_XTALTAB0_880_15360K 3 |
| 961 | #define PMU1_XTALTAB0_880_16200K 4 |
| 962 | #define PMU1_XTALTAB0_880_16800K 5 |
| 963 | #define PMU1_XTALTAB0_880_19200K 6 |
| 964 | #define PMU1_XTALTAB0_880_19800K 7 |
| 965 | #define PMU1_XTALTAB0_880_20000K 8 |
| 966 | #define PMU1_XTALTAB0_880_24000K 9 |
| 967 | #define PMU1_XTALTAB0_880_25000K 10 |
| 968 | #define PMU1_XTALTAB0_880_26000K 11 |
| 969 | #define PMU1_XTALTAB0_880_30000K 12 |
| 970 | #define PMU1_XTALTAB0_880_37400K 13 |
| 971 | #define PMU1_XTALTAB0_880_38400K 14 |
| 972 | #define PMU1_XTALTAB0_880_40000K 15 |
| 973 | |
| 974 | /* the following table is based on 1760Mhz fvco */ |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 975 | static const pmu1_xtaltab0_t pmu1_xtaltab0_1760[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 976 | { |
| 977 | 12000, 1, 3, 44, 0x9, 0xFFFFEF}, { |
| 978 | 13000, 2, 1, 12, 0xb, 0x483483}, { |
| 979 | 14400, 3, 1, 20, 0xa, 0x1C71C7}, { |
| 980 | 15360, 4, 1, 10, 0xb, 0x755555}, { |
| 981 | 16200, 5, 1, 20, 0x5, 0x6E9E06}, { |
| 982 | 16800, 6, 1, 20, 0x5, 0x3Cf3Cf}, { |
| 983 | 19200, 7, 1, 18, 0x5, 0x17B425}, { |
| 984 | 19800, 8, 1, 22, 0x4, 0xA57EB}, { |
| 985 | 20000, 9, 1, 22, 0x4, 0x0}, { |
| 986 | 24000, 10, 3, 22, 0xa, 0x0}, { |
| 987 | 25000, 11, 5, 32, 0xb, 0x0}, { |
| 988 | 26000, 12, 1, 4, 0x10, 0xEC4EC4}, { |
| 989 | 30000, 13, 3, 16, 0xb, 0x0}, { |
| 990 | 38400, 14, 1, 10, 0x4, 0x955555}, { |
| 991 | 40000, 15, 1, 4, 0xb, 0}, { |
| 992 | 0, 0, 0, 0, 0, 0} |
| 993 | }; |
| 994 | |
| 995 | /* table index */ |
| 996 | #define PMU1_XTALTAB0_1760_12000K 0 |
| 997 | #define PMU1_XTALTAB0_1760_13000K 1 |
| 998 | #define PMU1_XTALTAB0_1760_14400K 2 |
| 999 | #define PMU1_XTALTAB0_1760_15360K 3 |
| 1000 | #define PMU1_XTALTAB0_1760_16200K 4 |
| 1001 | #define PMU1_XTALTAB0_1760_16800K 5 |
| 1002 | #define PMU1_XTALTAB0_1760_19200K 6 |
| 1003 | #define PMU1_XTALTAB0_1760_19800K 7 |
| 1004 | #define PMU1_XTALTAB0_1760_20000K 8 |
| 1005 | #define PMU1_XTALTAB0_1760_24000K 9 |
| 1006 | #define PMU1_XTALTAB0_1760_25000K 10 |
| 1007 | #define PMU1_XTALTAB0_1760_26000K 11 |
| 1008 | #define PMU1_XTALTAB0_1760_30000K 12 |
| 1009 | #define PMU1_XTALTAB0_1760_38400K 13 |
| 1010 | #define PMU1_XTALTAB0_1760_40000K 14 |
| 1011 | |
| 1012 | /* the following table is based on 1440Mhz fvco */ |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 1013 | static const pmu1_xtaltab0_t pmu1_xtaltab0_1440[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1014 | { |
| 1015 | 12000, 1, 1, 1, 0x78, 0x0}, { |
| 1016 | 13000, 2, 1, 1, 0x6E, 0xC4EC4E}, { |
| 1017 | 14400, 3, 1, 1, 0x64, 0x0}, { |
| 1018 | 15360, 4, 1, 1, 0x5D, 0xC00000}, { |
| 1019 | 16200, 5, 1, 1, 0x58, 0xE38E38}, { |
| 1020 | 16800, 6, 1, 1, 0x55, 0xB6DB6D}, { |
| 1021 | 19200, 7, 1, 1, 0x4B, 0}, { |
| 1022 | 19800, 8, 1, 1, 0x48, 0xBA2E8B}, { |
| 1023 | 20000, 9, 1, 1, 0x48, 0x0}, { |
| 1024 | 25000, 10, 1, 1, 0x39, 0x999999}, { |
| 1025 | 26000, 11, 1, 1, 0x37, 0x627627}, { |
| 1026 | 30000, 12, 1, 1, 0x30, 0x0}, { |
| 1027 | 37400, 13, 2, 1, 0x4D, 0x15E76}, { |
| 1028 | 38400, 13, 2, 1, 0x4B, 0x0}, { |
| 1029 | 40000, 14, 2, 1, 0x48, 0x0}, { |
| 1030 | 48000, 15, 2, 1, 0x3c, 0x0}, { |
| 1031 | 0, 0, 0, 0, 0, 0} |
| 1032 | }; |
| 1033 | |
| 1034 | /* table index */ |
| 1035 | #define PMU1_XTALTAB0_1440_12000K 0 |
| 1036 | #define PMU1_XTALTAB0_1440_13000K 1 |
| 1037 | #define PMU1_XTALTAB0_1440_14400K 2 |
| 1038 | #define PMU1_XTALTAB0_1440_15360K 3 |
| 1039 | #define PMU1_XTALTAB0_1440_16200K 4 |
| 1040 | #define PMU1_XTALTAB0_1440_16800K 5 |
| 1041 | #define PMU1_XTALTAB0_1440_19200K 6 |
| 1042 | #define PMU1_XTALTAB0_1440_19800K 7 |
| 1043 | #define PMU1_XTALTAB0_1440_20000K 8 |
| 1044 | #define PMU1_XTALTAB0_1440_25000K 9 |
| 1045 | #define PMU1_XTALTAB0_1440_26000K 10 |
| 1046 | #define PMU1_XTALTAB0_1440_30000K 11 |
| 1047 | #define PMU1_XTALTAB0_1440_37400K 12 |
| 1048 | #define PMU1_XTALTAB0_1440_38400K 13 |
| 1049 | #define PMU1_XTALTAB0_1440_40000K 14 |
| 1050 | #define PMU1_XTALTAB0_1440_48000K 15 |
| 1051 | |
| 1052 | #define XTAL_FREQ_24000MHZ 24000 |
| 1053 | #define XTAL_FREQ_30000MHZ 30000 |
| 1054 | #define XTAL_FREQ_37400MHZ 37400 |
| 1055 | #define XTAL_FREQ_48000MHZ 48000 |
| 1056 | |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 1057 | static const pmu1_xtaltab0_t pmu1_xtaltab0_960[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1058 | { |
| 1059 | 12000, 1, 1, 1, 0x50, 0x0}, { |
| 1060 | 13000, 2, 1, 1, 0x49, 0xD89D89}, { |
| 1061 | 14400, 3, 1, 1, 0x42, 0xAAAAAA}, { |
| 1062 | 15360, 4, 1, 1, 0x3E, 0x800000}, { |
| 1063 | 16200, 5, 1, 1, 0x39, 0x425ED0}, { |
| 1064 | 16800, 6, 1, 1, 0x39, 0x249249}, { |
| 1065 | 19200, 7, 1, 1, 0x32, 0x0}, { |
| 1066 | 19800, 8, 1, 1, 0x30, 0x7C1F07}, { |
| 1067 | 20000, 9, 1, 1, 0x30, 0x0}, { |
| 1068 | 25000, 10, 1, 1, 0x26, 0x666666}, { |
| 1069 | 26000, 11, 1, 1, 0x24, 0xEC4EC4}, { |
| 1070 | 30000, 12, 1, 1, 0x20, 0x0}, { |
| 1071 | 37400, 13, 2, 1, 0x33, 0x563EF9}, { |
| 1072 | 38400, 14, 2, 1, 0x32, 0x0}, { |
| 1073 | 40000, 15, 2, 1, 0x30, 0x0}, { |
| 1074 | 48000, 16, 2, 1, 0x28, 0x0}, { |
| 1075 | 0, 0, 0, 0, 0, 0} |
| 1076 | }; |
| 1077 | |
| 1078 | /* table index */ |
| 1079 | #define PMU1_XTALTAB0_960_12000K 0 |
| 1080 | #define PMU1_XTALTAB0_960_13000K 1 |
| 1081 | #define PMU1_XTALTAB0_960_14400K 2 |
| 1082 | #define PMU1_XTALTAB0_960_15360K 3 |
| 1083 | #define PMU1_XTALTAB0_960_16200K 4 |
| 1084 | #define PMU1_XTALTAB0_960_16800K 5 |
| 1085 | #define PMU1_XTALTAB0_960_19200K 6 |
| 1086 | #define PMU1_XTALTAB0_960_19800K 7 |
| 1087 | #define PMU1_XTALTAB0_960_20000K 8 |
| 1088 | #define PMU1_XTALTAB0_960_25000K 9 |
| 1089 | #define PMU1_XTALTAB0_960_26000K 10 |
| 1090 | #define PMU1_XTALTAB0_960_30000K 11 |
| 1091 | #define PMU1_XTALTAB0_960_37400K 12 |
| 1092 | #define PMU1_XTALTAB0_960_38400K 13 |
| 1093 | #define PMU1_XTALTAB0_960_40000K 14 |
| 1094 | #define PMU1_XTALTAB0_960_48000K 15 |
| 1095 | |
| 1096 | /* select xtal table for each chip */ |
Jason Cooper | b4f790e | 2010-10-11 10:02:58 -0400 | [diff] [blame] | 1097 | static const pmu1_xtaltab0_t *si_pmu1_xtaltab0(si_t *sih) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1098 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1099 | #ifdef BCMDBG |
| 1100 | char chn[8]; |
| 1101 | #endif |
| 1102 | switch (CHIPID(sih->chip)) { |
| 1103 | case BCM4329_CHIP_ID: |
| 1104 | return pmu1_xtaltab0_880_4329; |
| 1105 | case BCM4319_CHIP_ID: |
| 1106 | return pmu1_xtaltab0_1440; |
| 1107 | case BCM4336_CHIP_ID: |
| 1108 | return pmu1_xtaltab0_960; |
| 1109 | case BCM4330_CHIP_ID: |
| 1110 | if (CST4330_CHIPMODE_SDIOD(sih->chipst)) |
| 1111 | return pmu1_xtaltab0_960; |
| 1112 | else |
| 1113 | return pmu1_xtaltab0_1440; |
| 1114 | default: |
| 1115 | PMU_MSG(("si_pmu1_xtaltab0: Unknown chipid %s\n", |
| 1116 | bcm_chipname(sih->chip, chn, 8))); |
| 1117 | break; |
| 1118 | } |
| 1119 | ASSERT(0); |
| 1120 | return NULL; |
| 1121 | } |
| 1122 | |
| 1123 | /* select default xtal frequency for each chip */ |
Jason Cooper | b4f790e | 2010-10-11 10:02:58 -0400 | [diff] [blame] | 1124 | static const pmu1_xtaltab0_t *si_pmu1_xtaldef0(si_t *sih) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1125 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1126 | #ifdef BCMDBG |
| 1127 | char chn[8]; |
| 1128 | #endif |
| 1129 | |
| 1130 | switch (CHIPID(sih->chip)) { |
| 1131 | case BCM4329_CHIP_ID: |
| 1132 | /* Default to 38400Khz */ |
| 1133 | return &pmu1_xtaltab0_880_4329[PMU1_XTALTAB0_880_38400K]; |
| 1134 | case BCM4319_CHIP_ID: |
| 1135 | /* Default to 30000Khz */ |
| 1136 | return &pmu1_xtaltab0_1440[PMU1_XTALTAB0_1440_30000K]; |
| 1137 | case BCM4336_CHIP_ID: |
| 1138 | /* Default to 26000Khz */ |
| 1139 | return &pmu1_xtaltab0_960[PMU1_XTALTAB0_960_26000K]; |
| 1140 | case BCM4330_CHIP_ID: |
| 1141 | /* Default to 37400Khz */ |
| 1142 | if (CST4330_CHIPMODE_SDIOD(sih->chipst)) |
| 1143 | return &pmu1_xtaltab0_960[PMU1_XTALTAB0_960_37400K]; |
| 1144 | else |
| 1145 | return &pmu1_xtaltab0_1440[PMU1_XTALTAB0_1440_37400K]; |
| 1146 | default: |
| 1147 | PMU_MSG(("si_pmu1_xtaldef0: Unknown chipid %s\n", |
| 1148 | bcm_chipname(sih->chip, chn, 8))); |
| 1149 | break; |
| 1150 | } |
| 1151 | ASSERT(0); |
| 1152 | return NULL; |
| 1153 | } |
| 1154 | |
| 1155 | /* select default pll fvco for each chip */ |
Jason Cooper | b4f790e | 2010-10-11 10:02:58 -0400 | [diff] [blame] | 1156 | static u32 si_pmu1_pllfvco0(si_t *sih) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1157 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1158 | #ifdef BCMDBG |
| 1159 | char chn[8]; |
| 1160 | #endif |
| 1161 | |
| 1162 | switch (CHIPID(sih->chip)) { |
| 1163 | case BCM4329_CHIP_ID: |
| 1164 | return FVCO_880; |
| 1165 | case BCM4319_CHIP_ID: |
| 1166 | return FVCO_1440; |
| 1167 | case BCM4336_CHIP_ID: |
| 1168 | return FVCO_960; |
| 1169 | case BCM4330_CHIP_ID: |
| 1170 | if (CST4330_CHIPMODE_SDIOD(sih->chipst)) |
| 1171 | return FVCO_960; |
| 1172 | else |
| 1173 | return FVCO_1440; |
| 1174 | default: |
| 1175 | PMU_MSG(("si_pmu1_pllfvco0: Unknown chipid %s\n", |
| 1176 | bcm_chipname(sih->chip, chn, 8))); |
| 1177 | break; |
| 1178 | } |
| 1179 | ASSERT(0); |
| 1180 | return 0; |
| 1181 | } |
| 1182 | |
| 1183 | /* query alp/xtal clock frequency */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1184 | static u32 |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1185 | si_pmu1_alpclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1186 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1187 | const pmu1_xtaltab0_t *xt; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1188 | u32 xf; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1189 | |
| 1190 | /* Find the frequency in the table */ |
| 1191 | xf = (R_REG(osh, &cc->pmucontrol) & PCTL_XTALFREQ_MASK) >> |
| 1192 | PCTL_XTALFREQ_SHIFT; |
| 1193 | for (xt = si_pmu1_xtaltab0(sih); xt != NULL && xt->fref != 0; xt++) |
| 1194 | if (xt->xf == xf) |
| 1195 | break; |
| 1196 | /* Could not find it so assign a default value */ |
| 1197 | if (xt == NULL || xt->fref == 0) |
| 1198 | xt = si_pmu1_xtaldef0(sih); |
| 1199 | ASSERT(xt != NULL && xt->fref != 0); |
| 1200 | |
| 1201 | return xt->fref * 1000; |
| 1202 | } |
| 1203 | |
| 1204 | /* Set up PLL registers in the PMU as per the crystal speed. |
| 1205 | * XtalFreq field in pmucontrol register being 0 indicates the PLL |
| 1206 | * is not programmed and the h/w default is assumed to work, in which |
| 1207 | * case the xtal frequency is unknown to the s/w so we need to call |
| 1208 | * si_pmu1_xtaldef0() wherever it is needed to return a default value. |
| 1209 | */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1210 | static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, |
| 1211 | u32 xtal) |
Greg Kroah-Hartman | 0d2f072 | 2010-10-08 14:28:21 -0700 | [diff] [blame] | 1212 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1213 | const pmu1_xtaltab0_t *xt; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1214 | u32 tmp; |
| 1215 | u32 buf_strength = 0; |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 1216 | u8 ndiv_mode = 1; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1217 | |
| 1218 | /* Use h/w default PLL config */ |
| 1219 | if (xtal == 0) { |
| 1220 | PMU_MSG(("Unspecified xtal frequency, skip PLL configuration\n")); |
| 1221 | return; |
| 1222 | } |
| 1223 | |
| 1224 | /* Find the frequency in the table */ |
| 1225 | for (xt = si_pmu1_xtaltab0(sih); xt != NULL && xt->fref != 0; xt++) |
| 1226 | if (xt->fref == xtal) |
| 1227 | break; |
| 1228 | |
| 1229 | /* Check current PLL state, bail out if it has been programmed or |
| 1230 | * we don't know how to program it. |
| 1231 | */ |
| 1232 | if (xt == NULL || xt->fref == 0) { |
| 1233 | PMU_MSG(("Unsupported xtal frequency %d.%d MHz, skip PLL configuration\n", xtal / 1000, xtal % 1000)); |
| 1234 | return; |
| 1235 | } |
| 1236 | /* for 4319 bootloader already programs the PLL but bootloader does not program the |
| 1237 | PLL4 and PLL5. So Skip this check for 4319 |
| 1238 | */ |
| 1239 | if ((((R_REG(osh, &cc->pmucontrol) & PCTL_XTALFREQ_MASK) >> |
| 1240 | PCTL_XTALFREQ_SHIFT) == xt->xf) && |
| 1241 | !((CHIPID(sih->chip) == BCM4319_CHIP_ID) |
| 1242 | || (CHIPID(sih->chip) == BCM4330_CHIP_ID))) { |
| 1243 | PMU_MSG(("PLL already programmed for %d.%d MHz\n", |
| 1244 | xt->fref / 1000, xt->fref % 1000)); |
| 1245 | return; |
| 1246 | } |
| 1247 | |
| 1248 | PMU_MSG(("XTAL %d.%d MHz (%d)\n", xtal / 1000, xtal % 1000, xt->xf)); |
| 1249 | PMU_MSG(("Programming PLL for %d.%d MHz\n", xt->fref / 1000, |
| 1250 | xt->fref % 1000)); |
| 1251 | |
| 1252 | switch (CHIPID(sih->chip)) { |
| 1253 | case BCM4329_CHIP_ID: |
| 1254 | /* Change the BBPLL drive strength to 8 for all channels */ |
| 1255 | buf_strength = 0x888888; |
| 1256 | AND_REG(osh, &cc->min_res_mask, |
| 1257 | ~(PMURES_BIT(RES4329_BBPLL_PWRSW_PU) | |
| 1258 | PMURES_BIT(RES4329_HT_AVAIL))); |
| 1259 | AND_REG(osh, &cc->max_res_mask, |
| 1260 | ~(PMURES_BIT(RES4329_BBPLL_PWRSW_PU) | |
| 1261 | PMURES_BIT(RES4329_HT_AVAIL))); |
| 1262 | SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL, |
| 1263 | PMU_MAX_TRANSITION_DLY); |
| 1264 | ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL)); |
| 1265 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); |
| 1266 | if (xt->fref == 38400) |
| 1267 | tmp = 0x200024C0; |
| 1268 | else if (xt->fref == 37400) |
| 1269 | tmp = 0x20004500; |
| 1270 | else if (xt->fref == 26000) |
| 1271 | tmp = 0x200024C0; |
| 1272 | else |
| 1273 | tmp = 0x200005C0; /* Chip Dflt Settings */ |
| 1274 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 1275 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 1276 | tmp = |
| 1277 | R_REG(osh, |
| 1278 | &cc->pllcontrol_data) & PMU1_PLL0_PC5_CLK_DRV_MASK; |
| 1279 | if ((xt->fref == 38400) || (xt->fref == 37400) |
| 1280 | || (xt->fref == 26000)) |
| 1281 | tmp |= 0x15; |
| 1282 | else |
| 1283 | tmp |= 0x25; /* Chip Dflt Settings */ |
| 1284 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 1285 | break; |
| 1286 | |
| 1287 | case BCM4319_CHIP_ID: |
| 1288 | /* Change the BBPLL drive strength to 2 for all channels */ |
| 1289 | buf_strength = 0x222222; |
| 1290 | |
| 1291 | /* Make sure the PLL is off */ |
| 1292 | /* WAR65104: Disable the HT_AVAIL resource first and then |
| 1293 | * after a delay (more than downtime for HT_AVAIL) remove the |
| 1294 | * BBPLL resource; backplane clock moves to ALP from HT. |
| 1295 | */ |
| 1296 | AND_REG(osh, &cc->min_res_mask, |
| 1297 | ~(PMURES_BIT(RES4319_HT_AVAIL))); |
| 1298 | AND_REG(osh, &cc->max_res_mask, |
| 1299 | ~(PMURES_BIT(RES4319_HT_AVAIL))); |
| 1300 | |
mike.rapoport@gmail.com | 7383141 | 2010-10-13 00:09:07 +0200 | [diff] [blame] | 1301 | udelay(100); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1302 | AND_REG(osh, &cc->min_res_mask, |
| 1303 | ~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU))); |
| 1304 | AND_REG(osh, &cc->max_res_mask, |
| 1305 | ~(PMURES_BIT(RES4319_BBPLL_PWRSW_PU))); |
| 1306 | |
mike.rapoport@gmail.com | 7383141 | 2010-10-13 00:09:07 +0200 | [diff] [blame] | 1307 | udelay(100); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1308 | SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL, |
| 1309 | PMU_MAX_TRANSITION_DLY); |
| 1310 | ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL)); |
| 1311 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); |
| 1312 | tmp = 0x200005c0; |
| 1313 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 1314 | break; |
| 1315 | |
| 1316 | case BCM4336_CHIP_ID: |
| 1317 | AND_REG(osh, &cc->min_res_mask, |
| 1318 | ~(PMURES_BIT(RES4336_HT_AVAIL) | |
| 1319 | PMURES_BIT(RES4336_MACPHY_CLKAVAIL))); |
| 1320 | AND_REG(osh, &cc->max_res_mask, |
| 1321 | ~(PMURES_BIT(RES4336_HT_AVAIL) | |
| 1322 | PMURES_BIT(RES4336_MACPHY_CLKAVAIL))); |
mike.rapoport@gmail.com | 7383141 | 2010-10-13 00:09:07 +0200 | [diff] [blame] | 1323 | udelay(100); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1324 | SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL, |
| 1325 | PMU_MAX_TRANSITION_DLY); |
| 1326 | ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL)); |
| 1327 | break; |
| 1328 | |
| 1329 | case BCM4330_CHIP_ID: |
| 1330 | AND_REG(osh, &cc->min_res_mask, |
| 1331 | ~(PMURES_BIT(RES4330_HT_AVAIL) | |
| 1332 | PMURES_BIT(RES4330_MACPHY_CLKAVAIL))); |
| 1333 | AND_REG(osh, &cc->max_res_mask, |
| 1334 | ~(PMURES_BIT(RES4330_HT_AVAIL) | |
| 1335 | PMURES_BIT(RES4330_MACPHY_CLKAVAIL))); |
mike.rapoport@gmail.com | 7383141 | 2010-10-13 00:09:07 +0200 | [diff] [blame] | 1336 | udelay(100); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1337 | SPINWAIT(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL, |
| 1338 | PMU_MAX_TRANSITION_DLY); |
| 1339 | ASSERT(!(R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL)); |
| 1340 | break; |
| 1341 | |
| 1342 | default: |
| 1343 | ASSERT(0); |
| 1344 | } |
| 1345 | |
| 1346 | PMU_MSG(("Done masking\n")); |
| 1347 | |
| 1348 | /* Write p1div and p2div to pllcontrol[0] */ |
| 1349 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 1350 | tmp = R_REG(osh, &cc->pllcontrol_data) & |
| 1351 | ~(PMU1_PLL0_PC0_P1DIV_MASK | PMU1_PLL0_PC0_P2DIV_MASK); |
| 1352 | tmp |= |
| 1353 | ((xt-> |
| 1354 | p1div << PMU1_PLL0_PC0_P1DIV_SHIFT) & PMU1_PLL0_PC0_P1DIV_MASK) | |
| 1355 | ((xt-> |
| 1356 | p2div << PMU1_PLL0_PC0_P2DIV_SHIFT) & PMU1_PLL0_PC0_P2DIV_MASK); |
| 1357 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 1358 | |
| 1359 | if ((CHIPID(sih->chip) == BCM4330_CHIP_ID)) |
| 1360 | si_pmu_set_4330_plldivs(sih); |
| 1361 | |
| 1362 | if ((CHIPID(sih->chip) == BCM4329_CHIP_ID) |
| 1363 | && (CHIPREV(sih->chiprev) == 0)) { |
| 1364 | |
| 1365 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 1366 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 1367 | tmp = tmp & (~DOT11MAC_880MHZ_CLK_DIVISOR_MASK); |
| 1368 | tmp = tmp | DOT11MAC_880MHZ_CLK_DIVISOR_VAL; |
| 1369 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 1370 | } |
| 1371 | if ((CHIPID(sih->chip) == BCM4319_CHIP_ID) || |
| 1372 | (CHIPID(sih->chip) == BCM4336_CHIP_ID) || |
| 1373 | (CHIPID(sih->chip) == BCM4330_CHIP_ID)) |
| 1374 | ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MFB; |
| 1375 | else |
| 1376 | ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MASH; |
| 1377 | |
| 1378 | /* Write ndiv_int and ndiv_mode to pllcontrol[2] */ |
| 1379 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 1380 | tmp = R_REG(osh, &cc->pllcontrol_data) & |
| 1381 | ~(PMU1_PLL0_PC2_NDIV_INT_MASK | PMU1_PLL0_PC2_NDIV_MODE_MASK); |
| 1382 | tmp |= |
| 1383 | ((xt-> |
| 1384 | ndiv_int << PMU1_PLL0_PC2_NDIV_INT_SHIFT) & |
| 1385 | PMU1_PLL0_PC2_NDIV_INT_MASK) | ((ndiv_mode << |
| 1386 | PMU1_PLL0_PC2_NDIV_MODE_SHIFT) & |
| 1387 | PMU1_PLL0_PC2_NDIV_MODE_MASK); |
| 1388 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 1389 | |
| 1390 | /* Write ndiv_frac to pllcontrol[3] */ |
| 1391 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); |
| 1392 | tmp = R_REG(osh, &cc->pllcontrol_data) & ~PMU1_PLL0_PC3_NDIV_FRAC_MASK; |
| 1393 | tmp |= ((xt->ndiv_frac << PMU1_PLL0_PC3_NDIV_FRAC_SHIFT) & |
| 1394 | PMU1_PLL0_PC3_NDIV_FRAC_MASK); |
| 1395 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 1396 | |
| 1397 | /* Write clock driving strength to pllcontrol[5] */ |
| 1398 | if (buf_strength) { |
| 1399 | PMU_MSG(("Adjusting PLL buffer drive strength: %x\n", |
| 1400 | buf_strength)); |
| 1401 | |
| 1402 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 1403 | tmp = |
| 1404 | R_REG(osh, |
| 1405 | &cc->pllcontrol_data) & ~PMU1_PLL0_PC5_CLK_DRV_MASK; |
| 1406 | tmp |= (buf_strength << PMU1_PLL0_PC5_CLK_DRV_SHIFT); |
| 1407 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 1408 | } |
| 1409 | |
| 1410 | PMU_MSG(("Done pll\n")); |
| 1411 | |
| 1412 | /* to operate the 4319 usb in 24MHz/48MHz; chipcontrol[2][84:83] needs |
| 1413 | * to be updated. |
| 1414 | */ |
| 1415 | if ((CHIPID(sih->chip) == BCM4319_CHIP_ID) |
| 1416 | && (xt->fref != XTAL_FREQ_30000MHZ)) { |
| 1417 | W_REG(osh, &cc->chipcontrol_addr, PMU1_PLL0_CHIPCTL2); |
| 1418 | tmp = |
| 1419 | R_REG(osh, |
| 1420 | &cc->chipcontrol_data) & ~CCTL_4319USB_XTAL_SEL_MASK; |
| 1421 | if (xt->fref == XTAL_FREQ_24000MHZ) { |
| 1422 | tmp |= |
| 1423 | (CCTL_4319USB_24MHZ_PLL_SEL << |
| 1424 | CCTL_4319USB_XTAL_SEL_SHIFT); |
| 1425 | } else if (xt->fref == XTAL_FREQ_48000MHZ) { |
| 1426 | tmp |= |
| 1427 | (CCTL_4319USB_48MHZ_PLL_SEL << |
| 1428 | CCTL_4319USB_XTAL_SEL_SHIFT); |
| 1429 | } |
| 1430 | W_REG(osh, &cc->chipcontrol_data, tmp); |
| 1431 | } |
| 1432 | |
| 1433 | /* Flush deferred pll control registers writes */ |
| 1434 | if (sih->pmurev >= 2) |
| 1435 | OR_REG(osh, &cc->pmucontrol, PCTL_PLL_PLLCTL_UPD); |
| 1436 | |
| 1437 | /* Write XtalFreq. Set the divisor also. */ |
| 1438 | tmp = R_REG(osh, &cc->pmucontrol) & |
| 1439 | ~(PCTL_ILP_DIV_MASK | PCTL_XTALFREQ_MASK); |
| 1440 | tmp |= (((((xt->fref + 127) / 128) - 1) << PCTL_ILP_DIV_SHIFT) & |
| 1441 | PCTL_ILP_DIV_MASK) | |
| 1442 | ((xt->xf << PCTL_XTALFREQ_SHIFT) & PCTL_XTALFREQ_MASK); |
| 1443 | |
| 1444 | if ((CHIPID(sih->chip) == BCM4329_CHIP_ID) |
| 1445 | && CHIPREV(sih->chiprev) == 0) { |
| 1446 | /* clear the htstretch before clearing HTReqEn */ |
| 1447 | AND_REG(osh, &cc->clkstretch, ~CSTRETCH_HT); |
| 1448 | tmp &= ~PCTL_HT_REQ_EN; |
| 1449 | } |
| 1450 | |
| 1451 | W_REG(osh, &cc->pmucontrol, tmp); |
| 1452 | } |
| 1453 | |
| 1454 | /* query the CPU clock frequency */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1455 | static u32 |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1456 | si_pmu1_cpuclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1457 | { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1458 | u32 tmp, m1div; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1459 | #ifdef BCMDBG |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1460 | u32 ndiv_int, ndiv_frac, p2div, p1div, fvco; |
| 1461 | u32 fref; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1462 | #endif |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1463 | u32 FVCO = si_pmu1_pllfvco0(sih); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1464 | |
| 1465 | /* Read m1div from pllcontrol[1] */ |
| 1466 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 1467 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 1468 | m1div = (tmp & PMU1_PLL0_PC1_M1DIV_MASK) >> PMU1_PLL0_PC1_M1DIV_SHIFT; |
| 1469 | |
| 1470 | #ifdef BCMDBG |
| 1471 | /* Read p2div/p1div from pllcontrol[0] */ |
| 1472 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 1473 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 1474 | p2div = (tmp & PMU1_PLL0_PC0_P2DIV_MASK) >> PMU1_PLL0_PC0_P2DIV_SHIFT; |
| 1475 | p1div = (tmp & PMU1_PLL0_PC0_P1DIV_MASK) >> PMU1_PLL0_PC0_P1DIV_SHIFT; |
| 1476 | |
| 1477 | /* Calculate fvco based on xtal freq and ndiv and pdiv */ |
| 1478 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 1479 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 1480 | ndiv_int = |
| 1481 | (tmp & PMU1_PLL0_PC2_NDIV_INT_MASK) >> PMU1_PLL0_PC2_NDIV_INT_SHIFT; |
| 1482 | |
| 1483 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); |
| 1484 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 1485 | ndiv_frac = |
| 1486 | (tmp & PMU1_PLL0_PC3_NDIV_FRAC_MASK) >> |
| 1487 | PMU1_PLL0_PC3_NDIV_FRAC_SHIFT; |
| 1488 | |
| 1489 | fref = si_pmu1_alpclk0(sih, osh, cc) / 1000; |
| 1490 | |
| 1491 | fvco = (fref * ndiv_int) << 8; |
| 1492 | fvco += (fref * (ndiv_frac >> 12)) >> 4; |
| 1493 | fvco += (fref * (ndiv_frac & 0xfff)) >> 12; |
| 1494 | fvco >>= 8; |
| 1495 | fvco *= p2div; |
| 1496 | fvco /= p1div; |
| 1497 | fvco /= 1000; |
| 1498 | fvco *= 1000; |
| 1499 | |
| 1500 | PMU_MSG(("si_pmu1_cpuclk0: ndiv_int %u ndiv_frac %u p2div %u p1div %u fvco %u\n", ndiv_int, ndiv_frac, p2div, p1div, fvco)); |
| 1501 | |
| 1502 | FVCO = fvco; |
| 1503 | #endif /* BCMDBG */ |
| 1504 | |
| 1505 | /* Return ARM/SB clock */ |
| 1506 | return FVCO / m1div * 1000; |
| 1507 | } |
| 1508 | |
| 1509 | /* initialize PLL */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1510 | void si_pmu_pll_init(si_t *sih, struct osl_info *osh, uint xtalfreq) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1511 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1512 | chipcregs_t *cc; |
| 1513 | uint origidx; |
| 1514 | #ifdef BCMDBG |
| 1515 | char chn[8]; |
| 1516 | #endif |
| 1517 | |
| 1518 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 1519 | |
| 1520 | /* Remember original core before switch to chipc */ |
| 1521 | origidx = si_coreidx(sih); |
| 1522 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 1523 | ASSERT(cc != NULL); |
| 1524 | |
| 1525 | switch (CHIPID(sih->chip)) { |
| 1526 | case BCM4329_CHIP_ID: |
| 1527 | if (xtalfreq == 0) |
| 1528 | xtalfreq = 38400; |
| 1529 | si_pmu1_pllinit0(sih, osh, cc, xtalfreq); |
| 1530 | break; |
| 1531 | case BCM4313_CHIP_ID: |
| 1532 | case BCM43224_CHIP_ID: |
| 1533 | case BCM43225_CHIP_ID: |
| 1534 | case BCM43421_CHIP_ID: |
| 1535 | case BCM43235_CHIP_ID: |
| 1536 | case BCM43236_CHIP_ID: |
| 1537 | case BCM43238_CHIP_ID: |
| 1538 | case BCM4331_CHIP_ID: |
| 1539 | case BCM6362_CHIP_ID: |
| 1540 | /* ??? */ |
| 1541 | break; |
| 1542 | case BCM4319_CHIP_ID: |
| 1543 | case BCM4336_CHIP_ID: |
| 1544 | case BCM4330_CHIP_ID: |
| 1545 | si_pmu1_pllinit0(sih, osh, cc, xtalfreq); |
| 1546 | break; |
| 1547 | default: |
| 1548 | PMU_MSG(("No PLL init done for chip %s rev %d pmurev %d\n", |
| 1549 | bcm_chipname(sih->chip, chn, 8), sih->chiprev, |
| 1550 | sih->pmurev)); |
| 1551 | break; |
| 1552 | } |
| 1553 | |
| 1554 | #ifdef BCMDBG_FORCEHT |
| 1555 | OR_REG(osh, &cc->clk_ctl_st, CCS_FORCEHT); |
| 1556 | #endif |
| 1557 | |
| 1558 | /* Return to original core */ |
| 1559 | si_setcoreidx(sih, origidx); |
| 1560 | } |
| 1561 | |
| 1562 | /* query alp/xtal clock frequency */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1563 | u32 si_pmu_alp_clock(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1564 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1565 | chipcregs_t *cc; |
| 1566 | uint origidx; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1567 | u32 clock = ALP_CLOCK; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1568 | #ifdef BCMDBG |
| 1569 | char chn[8]; |
| 1570 | #endif |
| 1571 | |
| 1572 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 1573 | |
| 1574 | /* Remember original core before switch to chipc */ |
| 1575 | origidx = si_coreidx(sih); |
| 1576 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 1577 | ASSERT(cc != NULL); |
| 1578 | |
| 1579 | switch (CHIPID(sih->chip)) { |
| 1580 | case BCM43224_CHIP_ID: |
| 1581 | case BCM43225_CHIP_ID: |
| 1582 | case BCM43421_CHIP_ID: |
| 1583 | case BCM43235_CHIP_ID: |
| 1584 | case BCM43236_CHIP_ID: |
| 1585 | case BCM43238_CHIP_ID: |
| 1586 | case BCM4331_CHIP_ID: |
| 1587 | case BCM6362_CHIP_ID: |
| 1588 | case BCM4716_CHIP_ID: |
| 1589 | case BCM4748_CHIP_ID: |
| 1590 | case BCM47162_CHIP_ID: |
| 1591 | case BCM4313_CHIP_ID: |
| 1592 | case BCM5357_CHIP_ID: |
| 1593 | /* always 20Mhz */ |
| 1594 | clock = 20000 * 1000; |
| 1595 | break; |
| 1596 | case BCM4329_CHIP_ID: |
| 1597 | case BCM4319_CHIP_ID: |
| 1598 | case BCM4336_CHIP_ID: |
| 1599 | case BCM4330_CHIP_ID: |
| 1600 | |
| 1601 | clock = si_pmu1_alpclk0(sih, osh, cc); |
| 1602 | break; |
| 1603 | case BCM5356_CHIP_ID: |
| 1604 | /* always 25Mhz */ |
| 1605 | clock = 25000 * 1000; |
| 1606 | break; |
| 1607 | default: |
| 1608 | PMU_MSG(("No ALP clock specified " |
| 1609 | "for chip %s rev %d pmurev %d, using default %d Hz\n", |
| 1610 | bcm_chipname(sih->chip, chn, 8), sih->chiprev, |
| 1611 | sih->pmurev, clock)); |
| 1612 | break; |
| 1613 | } |
| 1614 | |
| 1615 | /* Return to original core */ |
| 1616 | si_setcoreidx(sih, origidx); |
| 1617 | return clock; |
| 1618 | } |
| 1619 | |
| 1620 | /* Find the output of the "m" pll divider given pll controls that start with |
| 1621 | * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc. |
| 1622 | */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1623 | static u32 |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1624 | si_pmu5_clock(si_t *sih, struct osl_info *osh, chipcregs_t *cc, uint pll0, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1625 | uint m) { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1626 | u32 tmp, div, ndiv, p1, p2, fc; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1627 | |
| 1628 | if ((pll0 & 3) || (pll0 > PMU4716_MAINPLL_PLL0)) { |
| 1629 | PMU_ERROR(("%s: Bad pll0: %d\n", __func__, pll0)); |
| 1630 | return 0; |
| 1631 | } |
| 1632 | |
| 1633 | /* Strictly there is an m5 divider, but I'm not sure we use it */ |
| 1634 | if ((m == 0) || (m > 4)) { |
| 1635 | PMU_ERROR(("%s: Bad m divider: %d\n", __func__, m)); |
| 1636 | return 0; |
| 1637 | } |
| 1638 | |
| 1639 | if (CHIPID(sih->chip) == BCM5357_CHIP_ID) { |
| 1640 | /* Detect failure in clock setting */ |
| 1641 | if ((R_REG(osh, &cc->chipstatus) & 0x40000) != 0) { |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1642 | return 133 * 1000000; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1643 | } |
| 1644 | } |
| 1645 | |
| 1646 | W_REG(osh, &cc->pllcontrol_addr, pll0 + PMU5_PLL_P1P2_OFF); |
| 1647 | (void)R_REG(osh, &cc->pllcontrol_addr); |
| 1648 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 1649 | p1 = (tmp & PMU5_PLL_P1_MASK) >> PMU5_PLL_P1_SHIFT; |
| 1650 | p2 = (tmp & PMU5_PLL_P2_MASK) >> PMU5_PLL_P2_SHIFT; |
| 1651 | |
| 1652 | W_REG(osh, &cc->pllcontrol_addr, pll0 + PMU5_PLL_M14_OFF); |
| 1653 | (void)R_REG(osh, &cc->pllcontrol_addr); |
| 1654 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 1655 | div = (tmp >> ((m - 1) * PMU5_PLL_MDIV_WIDTH)) & PMU5_PLL_MDIV_MASK; |
| 1656 | |
| 1657 | W_REG(osh, &cc->pllcontrol_addr, pll0 + PMU5_PLL_NM5_OFF); |
| 1658 | (void)R_REG(osh, &cc->pllcontrol_addr); |
| 1659 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 1660 | ndiv = (tmp & PMU5_PLL_NDIV_MASK) >> PMU5_PLL_NDIV_SHIFT; |
| 1661 | |
| 1662 | /* Do calculation in Mhz */ |
| 1663 | fc = si_pmu_alp_clock(sih, osh) / 1000000; |
| 1664 | fc = (p1 * ndiv * fc) / p2; |
| 1665 | |
| 1666 | PMU_NONE(("%s: p1=%d, p2=%d, ndiv=%d(0x%x), m%d=%d; fc=%d, clock=%d\n", |
| 1667 | __func__, p1, p2, ndiv, ndiv, m, div, fc, fc / div)); |
| 1668 | |
| 1669 | /* Return clock in Hertz */ |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1670 | return (fc / div) * 1000000; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1671 | } |
| 1672 | |
| 1673 | /* query backplane clock frequency */ |
| 1674 | /* For designs that feed the same clock to both backplane |
| 1675 | * and CPU just return the CPU clock speed. |
| 1676 | */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1677 | u32 si_pmu_si_clock(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1678 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1679 | chipcregs_t *cc; |
| 1680 | uint origidx; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1681 | u32 clock = HT_CLOCK; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1682 | #ifdef BCMDBG |
| 1683 | char chn[8]; |
| 1684 | #endif |
| 1685 | |
| 1686 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 1687 | |
| 1688 | /* Remember original core before switch to chipc */ |
| 1689 | origidx = si_coreidx(sih); |
| 1690 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 1691 | ASSERT(cc != NULL); |
| 1692 | |
| 1693 | switch (CHIPID(sih->chip)) { |
| 1694 | case BCM43224_CHIP_ID: |
| 1695 | case BCM43225_CHIP_ID: |
| 1696 | case BCM43421_CHIP_ID: |
| 1697 | case BCM4331_CHIP_ID: |
| 1698 | case BCM6362_CHIP_ID: |
| 1699 | /* 96MHz backplane clock */ |
| 1700 | clock = 96000 * 1000; |
| 1701 | break; |
| 1702 | case BCM4716_CHIP_ID: |
| 1703 | case BCM4748_CHIP_ID: |
| 1704 | case BCM47162_CHIP_ID: |
| 1705 | clock = |
| 1706 | si_pmu5_clock(sih, osh, cc, PMU4716_MAINPLL_PLL0, |
| 1707 | PMU5_MAINPLL_SI); |
| 1708 | break; |
| 1709 | case BCM4329_CHIP_ID: |
| 1710 | if (CHIPREV(sih->chiprev) == 0) |
| 1711 | clock = 38400 * 1000; |
| 1712 | else |
| 1713 | clock = si_pmu1_cpuclk0(sih, osh, cc); |
| 1714 | break; |
| 1715 | case BCM4319_CHIP_ID: |
| 1716 | case BCM4336_CHIP_ID: |
| 1717 | case BCM4330_CHIP_ID: |
| 1718 | clock = si_pmu1_cpuclk0(sih, osh, cc); |
| 1719 | break; |
| 1720 | case BCM4313_CHIP_ID: |
| 1721 | /* 80MHz backplane clock */ |
| 1722 | clock = 80000 * 1000; |
| 1723 | break; |
| 1724 | case BCM43235_CHIP_ID: |
| 1725 | case BCM43236_CHIP_ID: |
| 1726 | case BCM43238_CHIP_ID: |
| 1727 | clock = |
| 1728 | (cc->chipstatus & CST43236_BP_CLK) ? (120000 * |
| 1729 | 1000) : (96000 * |
| 1730 | 1000); |
| 1731 | break; |
| 1732 | case BCM5356_CHIP_ID: |
| 1733 | clock = |
| 1734 | si_pmu5_clock(sih, osh, cc, PMU5356_MAINPLL_PLL0, |
| 1735 | PMU5_MAINPLL_SI); |
| 1736 | break; |
| 1737 | case BCM5357_CHIP_ID: |
| 1738 | clock = |
| 1739 | si_pmu5_clock(sih, osh, cc, PMU5357_MAINPLL_PLL0, |
| 1740 | PMU5_MAINPLL_SI); |
| 1741 | break; |
| 1742 | default: |
| 1743 | PMU_MSG(("No backplane clock specified " |
| 1744 | "for chip %s rev %d pmurev %d, using default %d Hz\n", |
| 1745 | bcm_chipname(sih->chip, chn, 8), sih->chiprev, |
| 1746 | sih->pmurev, clock)); |
| 1747 | break; |
| 1748 | } |
| 1749 | |
| 1750 | /* Return to original core */ |
| 1751 | si_setcoreidx(sih, origidx); |
| 1752 | return clock; |
| 1753 | } |
| 1754 | |
| 1755 | /* query CPU clock frequency */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1756 | u32 si_pmu_cpu_clock(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1757 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1758 | chipcregs_t *cc; |
| 1759 | uint origidx; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1760 | u32 clock; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1761 | |
| 1762 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 1763 | |
| 1764 | if ((sih->pmurev >= 5) && |
| 1765 | !((CHIPID(sih->chip) == BCM4329_CHIP_ID) || |
| 1766 | (CHIPID(sih->chip) == BCM4319_CHIP_ID) || |
| 1767 | (CHIPID(sih->chip) == BCM43236_CHIP_ID) || |
| 1768 | (CHIPID(sih->chip) == BCM4336_CHIP_ID) || |
| 1769 | (CHIPID(sih->chip) == BCM4330_CHIP_ID))) { |
| 1770 | uint pll; |
| 1771 | |
| 1772 | switch (CHIPID(sih->chip)) { |
| 1773 | case BCM5356_CHIP_ID: |
| 1774 | pll = PMU5356_MAINPLL_PLL0; |
| 1775 | break; |
| 1776 | case BCM5357_CHIP_ID: |
| 1777 | pll = PMU5357_MAINPLL_PLL0; |
| 1778 | break; |
| 1779 | default: |
| 1780 | pll = PMU4716_MAINPLL_PLL0; |
| 1781 | break; |
| 1782 | } |
| 1783 | |
| 1784 | /* Remember original core before switch to chipc */ |
| 1785 | origidx = si_coreidx(sih); |
| 1786 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 1787 | ASSERT(cc != NULL); |
| 1788 | |
| 1789 | clock = si_pmu5_clock(sih, osh, cc, pll, PMU5_MAINPLL_CPU); |
| 1790 | |
| 1791 | /* Return to original core */ |
| 1792 | si_setcoreidx(sih, origidx); |
| 1793 | } else |
| 1794 | clock = si_pmu_si_clock(sih, osh); |
| 1795 | |
| 1796 | return clock; |
| 1797 | } |
| 1798 | |
| 1799 | /* query memory clock frequency */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1800 | u32 si_pmu_mem_clock(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1801 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1802 | chipcregs_t *cc; |
| 1803 | uint origidx; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1804 | u32 clock; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1805 | |
| 1806 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 1807 | |
| 1808 | if ((sih->pmurev >= 5) && |
| 1809 | !((CHIPID(sih->chip) == BCM4329_CHIP_ID) || |
| 1810 | (CHIPID(sih->chip) == BCM4319_CHIP_ID) || |
| 1811 | (CHIPID(sih->chip) == BCM4330_CHIP_ID) || |
| 1812 | (CHIPID(sih->chip) == BCM4336_CHIP_ID) || |
| 1813 | (CHIPID(sih->chip) == BCM43236_CHIP_ID))) { |
| 1814 | uint pll; |
| 1815 | |
| 1816 | switch (CHIPID(sih->chip)) { |
| 1817 | case BCM5356_CHIP_ID: |
| 1818 | pll = PMU5356_MAINPLL_PLL0; |
| 1819 | break; |
| 1820 | case BCM5357_CHIP_ID: |
| 1821 | pll = PMU5357_MAINPLL_PLL0; |
| 1822 | break; |
| 1823 | default: |
| 1824 | pll = PMU4716_MAINPLL_PLL0; |
| 1825 | break; |
| 1826 | } |
| 1827 | |
| 1828 | /* Remember original core before switch to chipc */ |
| 1829 | origidx = si_coreidx(sih); |
| 1830 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 1831 | ASSERT(cc != NULL); |
| 1832 | |
| 1833 | clock = si_pmu5_clock(sih, osh, cc, pll, PMU5_MAINPLL_MEM); |
| 1834 | |
| 1835 | /* Return to original core */ |
| 1836 | si_setcoreidx(sih, origidx); |
| 1837 | } else { |
| 1838 | clock = si_pmu_si_clock(sih, osh); |
| 1839 | } |
| 1840 | |
| 1841 | return clock; |
| 1842 | } |
| 1843 | |
| 1844 | /* Measure ILP clock frequency */ |
| 1845 | #define ILP_CALC_DUR 10 /* ms, make sure 1000 can be divided by it. */ |
| 1846 | |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1847 | static u32 ilpcycles_per_sec; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1848 | |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1849 | u32 si_pmu_ilp_clock(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1850 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1851 | if (ISSIM_ENAB(sih)) |
| 1852 | return ILP_CLOCK; |
| 1853 | |
| 1854 | if (ilpcycles_per_sec == 0) { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1855 | u32 start, end, delta; |
| 1856 | u32 origidx = si_coreidx(sih); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1857 | chipcregs_t *cc = si_setcoreidx(sih, SI_CC_IDX); |
| 1858 | ASSERT(cc != NULL); |
| 1859 | start = R_REG(osh, &cc->pmutimer); |
mike.rapoport@gmail.com | 7383141 | 2010-10-13 00:09:07 +0200 | [diff] [blame] | 1860 | mdelay(ILP_CALC_DUR); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1861 | end = R_REG(osh, &cc->pmutimer); |
| 1862 | delta = end - start; |
| 1863 | ilpcycles_per_sec = delta * (1000 / ILP_CALC_DUR); |
| 1864 | si_setcoreidx(sih, origidx); |
| 1865 | } |
| 1866 | |
| 1867 | return ilpcycles_per_sec; |
| 1868 | } |
| 1869 | |
| 1870 | /* SDIO Pad drive strength to select value mappings */ |
| 1871 | typedef struct { |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 1872 | u8 strength; /* Pad Drive Strength in mA */ |
| 1873 | u8 sel; /* Chip-specific select value */ |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1874 | } sdiod_drive_str_t; |
| 1875 | |
| 1876 | /* SDIO Drive Strength to sel value table for PMU Rev 1 */ |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 1877 | static const sdiod_drive_str_t sdiod_drive_strength_tab1[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1878 | { |
| 1879 | 4, 0x2}, { |
| 1880 | 2, 0x3}, { |
| 1881 | 1, 0x0}, { |
Jason Cooper | 914d69d | 2010-09-14 09:45:46 -0400 | [diff] [blame] | 1882 | 0, 0x0} |
| 1883 | }; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1884 | |
| 1885 | /* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 1886 | static const sdiod_drive_str_t sdiod_drive_strength_tab2[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1887 | { |
| 1888 | 12, 0x7}, { |
| 1889 | 10, 0x6}, { |
| 1890 | 8, 0x5}, { |
| 1891 | 6, 0x4}, { |
| 1892 | 4, 0x2}, { |
| 1893 | 2, 0x1}, { |
Jason Cooper | 914d69d | 2010-09-14 09:45:46 -0400 | [diff] [blame] | 1894 | 0, 0x0} |
| 1895 | }; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1896 | |
| 1897 | /* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ |
Jason Cooper | 2184ccb | 2010-10-11 10:02:57 -0400 | [diff] [blame] | 1898 | static const sdiod_drive_str_t sdiod_drive_strength_tab3[] = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1899 | { |
| 1900 | 32, 0x7}, { |
| 1901 | 26, 0x6}, { |
| 1902 | 22, 0x5}, { |
| 1903 | 16, 0x4}, { |
| 1904 | 12, 0x3}, { |
| 1905 | 8, 0x2}, { |
| 1906 | 4, 0x1}, { |
Jason Cooper | 914d69d | 2010-09-14 09:45:46 -0400 | [diff] [blame] | 1907 | 0, 0x0} |
| 1908 | }; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1909 | |
| 1910 | #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) |
| 1911 | |
| 1912 | void |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1913 | si_sdiod_drive_strength_init(si_t *sih, struct osl_info *osh, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1914 | u32 drivestrength) { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1915 | chipcregs_t *cc; |
| 1916 | uint origidx, intr_val = 0; |
| 1917 | sdiod_drive_str_t *str_tab = NULL; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1918 | u32 str_mask = 0; |
| 1919 | u32 str_shift = 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1920 | #ifdef BCMDBG |
| 1921 | char chn[8]; |
| 1922 | #endif |
| 1923 | |
| 1924 | if (!(sih->cccaps & CC_CAP_PMU)) { |
| 1925 | return; |
| 1926 | } |
| 1927 | |
| 1928 | /* Remember original core before switch to chipc */ |
| 1929 | cc = (chipcregs_t *) si_switch_core(sih, CC_CORE_ID, &origidx, |
| 1930 | &intr_val); |
| 1931 | |
| 1932 | switch (SDIOD_DRVSTR_KEY(sih->chip, sih->pmurev)) { |
Nohee Ko | 84b9fac | 2010-09-29 15:56:49 -0700 | [diff] [blame] | 1933 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): |
| 1934 | str_tab = (sdiod_drive_str_t *)&sdiod_drive_strength_tab1; |
| 1935 | str_mask = 0x30000000; |
| 1936 | str_shift = 28; |
| 1937 | break; |
| 1938 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): |
| 1939 | case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): |
| 1940 | str_tab = (sdiod_drive_str_t *)&sdiod_drive_strength_tab2; |
| 1941 | str_mask = 0x00003800; |
| 1942 | str_shift = 11; |
| 1943 | break; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1944 | case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): |
Jason Cooper | 29c4275 | 2010-09-14 09:45:43 -0400 | [diff] [blame] | 1945 | str_tab = (sdiod_drive_str_t *) &sdiod_drive_strength_tab3; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1946 | str_mask = 0x00003800; |
| 1947 | str_shift = 11; |
| 1948 | break; |
| 1949 | |
| 1950 | default: |
| 1951 | PMU_MSG(("No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", bcm_chipname(sih->chip, chn, 8), sih->chiprev, sih->pmurev)); |
| 1952 | |
| 1953 | break; |
| 1954 | } |
| 1955 | |
| 1956 | if (str_tab != NULL) { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1957 | u32 drivestrength_sel = 0; |
| 1958 | u32 cc_data_temp; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1959 | int i; |
| 1960 | |
| 1961 | for (i = 0; str_tab[i].strength != 0; i++) { |
| 1962 | if (drivestrength >= str_tab[i].strength) { |
| 1963 | drivestrength_sel = str_tab[i].sel; |
| 1964 | break; |
| 1965 | } |
| 1966 | } |
| 1967 | |
| 1968 | W_REG(osh, &cc->chipcontrol_addr, 1); |
| 1969 | cc_data_temp = R_REG(osh, &cc->chipcontrol_data); |
| 1970 | cc_data_temp &= ~str_mask; |
| 1971 | drivestrength_sel <<= str_shift; |
| 1972 | cc_data_temp |= drivestrength_sel; |
| 1973 | W_REG(osh, &cc->chipcontrol_data, cc_data_temp); |
| 1974 | |
| 1975 | PMU_MSG(("SDIO: %dmA drive strength selected, set to 0x%08x\n", |
| 1976 | drivestrength, cc_data_temp)); |
| 1977 | } |
| 1978 | |
| 1979 | /* Return to original core */ |
| 1980 | si_restore_core(sih, origidx, intr_val); |
| 1981 | } |
| 1982 | |
| 1983 | /* initialize PMU */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 1984 | void si_pmu_init(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 1985 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1986 | chipcregs_t *cc; |
| 1987 | uint origidx; |
| 1988 | |
| 1989 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 1990 | |
| 1991 | /* Remember original core before switch to chipc */ |
| 1992 | origidx = si_coreidx(sih); |
| 1993 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 1994 | ASSERT(cc != NULL); |
| 1995 | |
| 1996 | if (sih->pmurev == 1) |
| 1997 | AND_REG(osh, &cc->pmucontrol, ~PCTL_NOILP_ON_WAIT); |
| 1998 | else if (sih->pmurev >= 2) |
| 1999 | OR_REG(osh, &cc->pmucontrol, PCTL_NOILP_ON_WAIT); |
| 2000 | |
| 2001 | if ((CHIPID(sih->chip) == BCM4329_CHIP_ID) && (sih->chiprev == 2)) { |
| 2002 | /* Fix for 4329b0 bad LPOM state. */ |
| 2003 | W_REG(osh, &cc->regcontrol_addr, 2); |
| 2004 | OR_REG(osh, &cc->regcontrol_data, 0x100); |
| 2005 | |
| 2006 | W_REG(osh, &cc->regcontrol_addr, 3); |
| 2007 | OR_REG(osh, &cc->regcontrol_data, 0x4); |
| 2008 | } |
| 2009 | |
| 2010 | /* Return to original core */ |
| 2011 | si_setcoreidx(sih, origidx); |
| 2012 | } |
| 2013 | |
| 2014 | /* Return up time in ILP cycles for the given resource. */ |
| 2015 | static uint |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2016 | si_pmu_res_uptime(si_t *sih, struct osl_info *osh, chipcregs_t *cc, |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 2017 | u8 rsrc) { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2018 | u32 deps; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2019 | uint up, i, dup, dmax; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2020 | u32 min_mask = 0, max_mask = 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2021 | |
| 2022 | /* uptime of resource 'rsrc' */ |
| 2023 | W_REG(osh, &cc->res_table_sel, rsrc); |
| 2024 | up = (R_REG(osh, &cc->res_updn_timer) >> 8) & 0xff; |
| 2025 | |
| 2026 | /* direct dependancies of resource 'rsrc' */ |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 2027 | deps = si_pmu_res_deps(sih, osh, cc, PMURES_BIT(rsrc), false); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2028 | for (i = 0; i <= PMURES_MAX_RESNUM; i++) { |
| 2029 | if (!(deps & PMURES_BIT(i))) |
| 2030 | continue; |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 2031 | deps &= ~si_pmu_res_deps(sih, osh, cc, PMURES_BIT(i), true); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2032 | } |
| 2033 | si_pmu_res_masks(sih, &min_mask, &max_mask); |
| 2034 | deps &= ~min_mask; |
| 2035 | |
| 2036 | /* max uptime of direct dependancies */ |
| 2037 | dmax = 0; |
| 2038 | for (i = 0; i <= PMURES_MAX_RESNUM; i++) { |
| 2039 | if (!(deps & PMURES_BIT(i))) |
| 2040 | continue; |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 2041 | dup = si_pmu_res_uptime(sih, osh, cc, (u8) i); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2042 | if (dmax < dup) |
| 2043 | dmax = dup; |
| 2044 | } |
| 2045 | |
| 2046 | PMU_MSG(("si_pmu_res_uptime: rsrc %u uptime %u(deps 0x%08x uptime %u)\n", rsrc, up, deps, dmax)); |
| 2047 | |
| 2048 | return up + dmax + PMURES_UP_TRANSITION; |
| 2049 | } |
| 2050 | |
| 2051 | /* Return dependancies (direct or all/indirect) for the given resources */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2052 | static u32 |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2053 | si_pmu_res_deps(si_t *sih, struct osl_info *osh, chipcregs_t *cc, u32 rsrcs, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2054 | bool all) |
| 2055 | { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2056 | u32 deps = 0; |
| 2057 | u32 i; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2058 | |
| 2059 | for (i = 0; i <= PMURES_MAX_RESNUM; i++) { |
| 2060 | if (!(rsrcs & PMURES_BIT(i))) |
| 2061 | continue; |
| 2062 | W_REG(osh, &cc->res_table_sel, i); |
| 2063 | deps |= R_REG(osh, &cc->res_dep_mask); |
| 2064 | } |
| 2065 | |
| 2066 | return !all ? deps : (deps |
| 2067 | ? (deps | |
| 2068 | si_pmu_res_deps(sih, osh, cc, deps, |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 2069 | true)) : 0); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2070 | } |
| 2071 | |
| 2072 | /* power up/down OTP through PMU resources */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2073 | void si_pmu_otp_power(si_t *sih, struct osl_info *osh, bool on) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2074 | { |
| 2075 | chipcregs_t *cc; |
| 2076 | uint origidx; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2077 | u32 rsrcs = 0; /* rsrcs to turn on/off OTP power */ |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2078 | |
| 2079 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 2080 | |
| 2081 | /* Don't do anything if OTP is disabled */ |
| 2082 | if (si_is_otp_disabled(sih)) { |
| 2083 | PMU_MSG(("si_pmu_otp_power: OTP is disabled\n")); |
| 2084 | return; |
| 2085 | } |
| 2086 | |
| 2087 | /* Remember original core before switch to chipc */ |
| 2088 | origidx = si_coreidx(sih); |
| 2089 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 2090 | ASSERT(cc != NULL); |
| 2091 | |
| 2092 | switch (CHIPID(sih->chip)) { |
| 2093 | case BCM4329_CHIP_ID: |
| 2094 | rsrcs = PMURES_BIT(RES4329_OTP_PU); |
| 2095 | break; |
| 2096 | case BCM4319_CHIP_ID: |
| 2097 | rsrcs = PMURES_BIT(RES4319_OTP_PU); |
| 2098 | break; |
| 2099 | case BCM4336_CHIP_ID: |
| 2100 | rsrcs = PMURES_BIT(RES4336_OTP_PU); |
| 2101 | break; |
| 2102 | case BCM4330_CHIP_ID: |
| 2103 | rsrcs = PMURES_BIT(RES4330_OTP_PU); |
| 2104 | break; |
| 2105 | default: |
| 2106 | break; |
| 2107 | } |
| 2108 | |
| 2109 | if (rsrcs != 0) { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2110 | u32 otps; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2111 | |
| 2112 | /* Figure out the dependancies (exclude min_res_mask) */ |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 2113 | u32 deps = si_pmu_res_deps(sih, osh, cc, rsrcs, true); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2114 | u32 min_mask = 0, max_mask = 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2115 | si_pmu_res_masks(sih, &min_mask, &max_mask); |
| 2116 | deps &= ~min_mask; |
| 2117 | /* Turn on/off the power */ |
| 2118 | if (on) { |
| 2119 | PMU_MSG(("Adding rsrc 0x%x to min_res_mask\n", |
| 2120 | rsrcs | deps)); |
| 2121 | OR_REG(osh, &cc->min_res_mask, (rsrcs | deps)); |
| 2122 | SPINWAIT(!(R_REG(osh, &cc->res_state) & rsrcs), |
| 2123 | PMU_MAX_TRANSITION_DLY); |
| 2124 | ASSERT(R_REG(osh, &cc->res_state) & rsrcs); |
| 2125 | } else { |
| 2126 | PMU_MSG(("Removing rsrc 0x%x from min_res_mask\n", |
| 2127 | rsrcs | deps)); |
| 2128 | AND_REG(osh, &cc->min_res_mask, ~(rsrcs | deps)); |
| 2129 | } |
| 2130 | |
| 2131 | SPINWAIT((((otps = R_REG(osh, &cc->otpstatus)) & OTPS_READY) != |
| 2132 | (on ? OTPS_READY : 0)), 100); |
| 2133 | ASSERT((otps & OTPS_READY) == (on ? OTPS_READY : 0)); |
| 2134 | if ((otps & OTPS_READY) != (on ? OTPS_READY : 0)) |
| 2135 | PMU_MSG(("OTP ready bit not %s after wait\n", |
| 2136 | (on ? "ON" : "OFF"))); |
| 2137 | } |
| 2138 | |
| 2139 | /* Return to original core */ |
| 2140 | si_setcoreidx(sih, origidx); |
| 2141 | } |
| 2142 | |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2143 | void si_pmu_rcal(si_t *sih, struct osl_info *osh) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2144 | { |
| 2145 | chipcregs_t *cc; |
| 2146 | uint origidx; |
| 2147 | |
| 2148 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 2149 | |
| 2150 | /* Remember original core before switch to chipc */ |
| 2151 | origidx = si_coreidx(sih); |
| 2152 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 2153 | ASSERT(cc != NULL); |
| 2154 | |
| 2155 | switch (CHIPID(sih->chip)) { |
| 2156 | case BCM4329_CHIP_ID:{ |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 2157 | u8 rcal_code; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2158 | u32 val; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2159 | |
| 2160 | /* Kick RCal */ |
| 2161 | W_REG(osh, &cc->chipcontrol_addr, 1); |
| 2162 | |
| 2163 | /* Power Down RCAL Block */ |
| 2164 | AND_REG(osh, &cc->chipcontrol_data, ~0x04); |
| 2165 | |
| 2166 | /* Power Up RCAL block */ |
| 2167 | OR_REG(osh, &cc->chipcontrol_data, 0x04); |
| 2168 | |
| 2169 | /* Wait for completion */ |
| 2170 | SPINWAIT(0 == (R_REG(osh, &cc->chipstatus) & 0x08), |
| 2171 | 10 * 1000 * 1000); |
| 2172 | ASSERT(R_REG(osh, &cc->chipstatus) & 0x08); |
| 2173 | |
| 2174 | /* Drop the LSB to convert from 5 bit code to 4 bit code */ |
| 2175 | rcal_code = |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 2176 | (u8) (R_REG(osh, &cc->chipstatus) >> 5) & 0x0f; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2177 | |
| 2178 | PMU_MSG(("RCal completed, status 0x%x, code 0x%x\n", |
| 2179 | R_REG(osh, &cc->chipstatus), rcal_code)); |
| 2180 | |
| 2181 | /* Write RCal code into pmu_vreg_ctrl[32:29] */ |
| 2182 | W_REG(osh, &cc->regcontrol_addr, 0); |
| 2183 | val = |
| 2184 | R_REG(osh, |
| 2185 | &cc-> |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2186 | regcontrol_data) & ~((u32) 0x07 << 29); |
| 2187 | val |= (u32) (rcal_code & 0x07) << 29; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2188 | W_REG(osh, &cc->regcontrol_data, val); |
| 2189 | W_REG(osh, &cc->regcontrol_addr, 1); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2190 | val = R_REG(osh, &cc->regcontrol_data) & ~(u32) 0x01; |
| 2191 | val |= (u32) ((rcal_code >> 3) & 0x01); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2192 | W_REG(osh, &cc->regcontrol_data, val); |
| 2193 | |
| 2194 | /* Write RCal code into pmu_chip_ctrl[33:30] */ |
| 2195 | W_REG(osh, &cc->chipcontrol_addr, 0); |
| 2196 | val = |
| 2197 | R_REG(osh, |
| 2198 | &cc-> |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2199 | chipcontrol_data) & ~((u32) 0x03 << 30); |
| 2200 | val |= (u32) (rcal_code & 0x03) << 30; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2201 | W_REG(osh, &cc->chipcontrol_data, val); |
| 2202 | W_REG(osh, &cc->chipcontrol_addr, 1); |
| 2203 | val = |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2204 | R_REG(osh, &cc->chipcontrol_data) & ~(u32) 0x03; |
| 2205 | val |= (u32) ((rcal_code >> 2) & 0x03); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2206 | W_REG(osh, &cc->chipcontrol_data, val); |
| 2207 | |
| 2208 | /* Set override in pmu_chip_ctrl[29] */ |
| 2209 | W_REG(osh, &cc->chipcontrol_addr, 0); |
| 2210 | OR_REG(osh, &cc->chipcontrol_data, (0x01 << 29)); |
| 2211 | |
| 2212 | /* Power off RCal block */ |
| 2213 | W_REG(osh, &cc->chipcontrol_addr, 1); |
| 2214 | AND_REG(osh, &cc->chipcontrol_data, ~0x04); |
| 2215 | |
| 2216 | break; |
| 2217 | } |
| 2218 | default: |
| 2219 | break; |
| 2220 | } |
| 2221 | |
| 2222 | /* Return to original core */ |
| 2223 | si_setcoreidx(sih, origidx); |
| 2224 | } |
| 2225 | |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2226 | void si_pmu_spuravoid(si_t *sih, struct osl_info *osh, u8 spuravoid) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2227 | { |
| 2228 | chipcregs_t *cc; |
| 2229 | uint origidx, intr_val; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2230 | u32 tmp = 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2231 | |
| 2232 | /* Remember original core before switch to chipc */ |
| 2233 | cc = (chipcregs_t *) si_switch_core(sih, CC_CORE_ID, &origidx, |
| 2234 | &intr_val); |
| 2235 | ASSERT(cc != NULL); |
| 2236 | |
| 2237 | /* force the HT off */ |
| 2238 | if (CHIPID(sih->chip) == BCM4336_CHIP_ID) { |
| 2239 | tmp = R_REG(osh, &cc->max_res_mask); |
| 2240 | tmp &= ~RES4336_HT_AVAIL; |
| 2241 | W_REG(osh, &cc->max_res_mask, tmp); |
| 2242 | /* wait for the ht to really go away */ |
| 2243 | SPINWAIT(((R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL) == 0), |
| 2244 | 10000); |
| 2245 | ASSERT((R_REG(osh, &cc->clk_ctl_st) & CCS_HTAVAIL) == 0); |
| 2246 | } |
| 2247 | |
| 2248 | /* update the pll changes */ |
| 2249 | si_pmu_spuravoid_pllupdate(sih, cc, osh, spuravoid); |
| 2250 | |
| 2251 | /* enable HT back on */ |
| 2252 | if (CHIPID(sih->chip) == BCM4336_CHIP_ID) { |
| 2253 | tmp = R_REG(osh, &cc->max_res_mask); |
| 2254 | tmp |= RES4336_HT_AVAIL; |
| 2255 | W_REG(osh, &cc->max_res_mask, tmp); |
| 2256 | } |
| 2257 | |
| 2258 | /* Return to original core */ |
| 2259 | si_restore_core(sih, origidx, intr_val); |
| 2260 | } |
| 2261 | |
| 2262 | static void |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2263 | si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, struct osl_info *osh, |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 2264 | u8 spuravoid) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2265 | { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2266 | u32 tmp = 0; |
Greg Kroah-Hartman | 36ef9a1 | 2010-10-05 10:02:49 -0700 | [diff] [blame] | 2267 | u8 phypll_offset = 0; |
| 2268 | u8 bcm5357_bcm43236_p1div[] = { 0x1, 0x5, 0x5 }; |
| 2269 | u8 bcm5357_bcm43236_ndiv[] = { 0x30, 0xf6, 0xfc }; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2270 | |
| 2271 | switch (CHIPID(sih->chip)) { |
| 2272 | case BCM5357_CHIP_ID: |
| 2273 | case BCM43235_CHIP_ID: |
| 2274 | case BCM43236_CHIP_ID: |
| 2275 | case BCM43238_CHIP_ID: |
| 2276 | |
| 2277 | /* BCM5357 needs to touch PLL1_PLLCTL[02], so offset PLL0_PLLCTL[02] by 6 */ |
| 2278 | phypll_offset = (CHIPID(sih->chip) == BCM5357_CHIP_ID) ? 6 : 0; |
| 2279 | |
| 2280 | /* RMW only the P1 divider */ |
| 2281 | W_REG(osh, &cc->pllcontrol_addr, |
| 2282 | PMU1_PLL0_PLLCTL0 + phypll_offset); |
| 2283 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 2284 | tmp &= (~(PMU1_PLL0_PC0_P1DIV_MASK)); |
| 2285 | tmp |= |
| 2286 | (bcm5357_bcm43236_p1div[spuravoid] << |
| 2287 | PMU1_PLL0_PC0_P1DIV_SHIFT); |
| 2288 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 2289 | |
| 2290 | /* RMW only the int feedback divider */ |
| 2291 | W_REG(osh, &cc->pllcontrol_addr, |
| 2292 | PMU1_PLL0_PLLCTL2 + phypll_offset); |
| 2293 | tmp = R_REG(osh, &cc->pllcontrol_data); |
| 2294 | tmp &= ~(PMU1_PLL0_PC2_NDIV_INT_MASK); |
| 2295 | tmp |= |
| 2296 | (bcm5357_bcm43236_ndiv[spuravoid]) << |
| 2297 | PMU1_PLL0_PC2_NDIV_INT_SHIFT; |
| 2298 | W_REG(osh, &cc->pllcontrol_data, tmp); |
| 2299 | |
| 2300 | tmp = 1 << 10; |
| 2301 | break; |
| 2302 | |
| 2303 | case BCM4331_CHIP_ID: |
| 2304 | if (spuravoid == 2) { |
| 2305 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2306 | W_REG(osh, &cc->pllcontrol_data, 0x11500014); |
| 2307 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2308 | W_REG(osh, &cc->pllcontrol_data, 0x0FC00a08); |
| 2309 | } else if (spuravoid == 1) { |
| 2310 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2311 | W_REG(osh, &cc->pllcontrol_data, 0x11500014); |
| 2312 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2313 | W_REG(osh, &cc->pllcontrol_data, 0x0F600a08); |
| 2314 | } else { |
| 2315 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2316 | W_REG(osh, &cc->pllcontrol_data, 0x11100014); |
| 2317 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2318 | W_REG(osh, &cc->pllcontrol_data, 0x03000a08); |
| 2319 | } |
| 2320 | tmp = 1 << 10; |
| 2321 | break; |
| 2322 | |
| 2323 | case BCM43224_CHIP_ID: |
| 2324 | case BCM43225_CHIP_ID: |
| 2325 | case BCM43421_CHIP_ID: |
| 2326 | case BCM6362_CHIP_ID: |
| 2327 | if (spuravoid == 1) { |
| 2328 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2329 | W_REG(osh, &cc->pllcontrol_data, 0x11500010); |
| 2330 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 2331 | W_REG(osh, &cc->pllcontrol_data, 0x000C0C06); |
| 2332 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2333 | W_REG(osh, &cc->pllcontrol_data, 0x0F600a08); |
| 2334 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); |
| 2335 | W_REG(osh, &cc->pllcontrol_data, 0x00000000); |
| 2336 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); |
| 2337 | W_REG(osh, &cc->pllcontrol_data, 0x2001E920); |
| 2338 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 2339 | W_REG(osh, &cc->pllcontrol_data, 0x88888815); |
| 2340 | } else { |
| 2341 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2342 | W_REG(osh, &cc->pllcontrol_data, 0x11100010); |
| 2343 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 2344 | W_REG(osh, &cc->pllcontrol_data, 0x000c0c06); |
| 2345 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2346 | W_REG(osh, &cc->pllcontrol_data, 0x03000a08); |
| 2347 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); |
| 2348 | W_REG(osh, &cc->pllcontrol_data, 0x00000000); |
| 2349 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); |
| 2350 | W_REG(osh, &cc->pllcontrol_data, 0x200005c0); |
| 2351 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 2352 | W_REG(osh, &cc->pllcontrol_data, 0x88888815); |
| 2353 | } |
| 2354 | tmp = 1 << 10; |
| 2355 | break; |
| 2356 | |
| 2357 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2358 | W_REG(osh, &cc->pllcontrol_data, 0x11100008); |
| 2359 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 2360 | W_REG(osh, &cc->pllcontrol_data, 0x0c000c06); |
| 2361 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2362 | W_REG(osh, &cc->pllcontrol_data, 0x03000a08); |
| 2363 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); |
| 2364 | W_REG(osh, &cc->pllcontrol_data, 0x00000000); |
| 2365 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); |
| 2366 | W_REG(osh, &cc->pllcontrol_data, 0x200005c0); |
| 2367 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 2368 | W_REG(osh, &cc->pllcontrol_data, 0x88888855); |
| 2369 | |
| 2370 | tmp = 1 << 10; |
| 2371 | break; |
| 2372 | |
| 2373 | case BCM4716_CHIP_ID: |
| 2374 | case BCM4748_CHIP_ID: |
| 2375 | case BCM47162_CHIP_ID: |
| 2376 | if (spuravoid == 1) { |
| 2377 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2378 | W_REG(osh, &cc->pllcontrol_data, 0x11500060); |
| 2379 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 2380 | W_REG(osh, &cc->pllcontrol_data, 0x080C0C06); |
| 2381 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2382 | W_REG(osh, &cc->pllcontrol_data, 0x0F600000); |
| 2383 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); |
| 2384 | W_REG(osh, &cc->pllcontrol_data, 0x00000000); |
| 2385 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); |
| 2386 | W_REG(osh, &cc->pllcontrol_data, 0x2001E924); |
| 2387 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 2388 | W_REG(osh, &cc->pllcontrol_data, 0x88888815); |
| 2389 | } else { |
| 2390 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2391 | W_REG(osh, &cc->pllcontrol_data, 0x11100060); |
| 2392 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 2393 | W_REG(osh, &cc->pllcontrol_data, 0x080c0c06); |
| 2394 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2395 | W_REG(osh, &cc->pllcontrol_data, 0x03000000); |
| 2396 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); |
| 2397 | W_REG(osh, &cc->pllcontrol_data, 0x00000000); |
| 2398 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); |
| 2399 | W_REG(osh, &cc->pllcontrol_data, 0x200005c0); |
| 2400 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 2401 | W_REG(osh, &cc->pllcontrol_data, 0x88888815); |
| 2402 | } |
| 2403 | |
| 2404 | tmp = 3 << 9; |
| 2405 | break; |
| 2406 | |
| 2407 | case BCM4319_CHIP_ID: |
| 2408 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2409 | W_REG(osh, &cc->pllcontrol_data, 0x11100070); |
| 2410 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 2411 | W_REG(osh, &cc->pllcontrol_data, 0x1014140a); |
| 2412 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 2413 | W_REG(osh, &cc->pllcontrol_data, 0x88888854); |
| 2414 | |
| 2415 | if (spuravoid == 1) { /* spur_avoid ON, enable 41/82/164Mhz clock mode */ |
| 2416 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2417 | W_REG(osh, &cc->pllcontrol_data, 0x05201828); |
| 2418 | } else { /* enable 40/80/160Mhz clock mode */ |
| 2419 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2420 | W_REG(osh, &cc->pllcontrol_data, 0x05001828); |
| 2421 | } |
| 2422 | break; |
| 2423 | case BCM4336_CHIP_ID: |
| 2424 | /* Looks like these are only for default xtal freq 26MHz */ |
| 2425 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); |
| 2426 | W_REG(osh, &cc->pllcontrol_data, 0x02100020); |
| 2427 | |
| 2428 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); |
| 2429 | W_REG(osh, &cc->pllcontrol_data, 0x0C0C0C0C); |
| 2430 | |
| 2431 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); |
| 2432 | W_REG(osh, &cc->pllcontrol_data, 0x01240C0C); |
| 2433 | |
| 2434 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); |
| 2435 | W_REG(osh, &cc->pllcontrol_data, 0x202C2820); |
| 2436 | |
| 2437 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); |
| 2438 | W_REG(osh, &cc->pllcontrol_data, 0x88888825); |
| 2439 | |
| 2440 | W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); |
| 2441 | if (spuravoid == 1) { |
| 2442 | W_REG(osh, &cc->pllcontrol_data, 0x00EC4EC4); |
| 2443 | } else { |
| 2444 | W_REG(osh, &cc->pllcontrol_data, 0x00762762); |
| 2445 | } |
| 2446 | |
| 2447 | tmp = PCTL_PLL_PLLCTL_UPD; |
| 2448 | break; |
| 2449 | |
| 2450 | default: |
| 2451 | PMU_ERROR(("%s: unknown spuravoidance settings for chip %s, not changing PLL\n", __func__, bcm_chipname(sih->chip, chn, 8))); |
| 2452 | break; |
| 2453 | } |
| 2454 | |
| 2455 | tmp |= R_REG(osh, &cc->pmucontrol); |
| 2456 | W_REG(osh, &cc->pmucontrol, tmp); |
| 2457 | } |
| 2458 | |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2459 | bool si_pmu_is_otp_powered(si_t *sih, struct osl_info *osh) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2460 | { |
| 2461 | uint idx; |
| 2462 | chipcregs_t *cc; |
| 2463 | bool st; |
| 2464 | |
| 2465 | /* Remember original core before switch to chipc */ |
| 2466 | idx = si_coreidx(sih); |
| 2467 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 2468 | ASSERT(cc != NULL); |
| 2469 | |
| 2470 | switch (CHIPID(sih->chip)) { |
| 2471 | case BCM4329_CHIP_ID: |
| 2472 | st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4329_OTP_PU)) |
| 2473 | != 0; |
| 2474 | break; |
| 2475 | case BCM4319_CHIP_ID: |
| 2476 | st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4319_OTP_PU)) |
| 2477 | != 0; |
| 2478 | break; |
| 2479 | case BCM4336_CHIP_ID: |
| 2480 | st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4336_OTP_PU)) |
| 2481 | != 0; |
| 2482 | break; |
| 2483 | case BCM4330_CHIP_ID: |
| 2484 | st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4330_OTP_PU)) |
| 2485 | != 0; |
| 2486 | break; |
| 2487 | |
| 2488 | /* These chip doesn't use PMU bit to power up/down OTP. OTP always on. |
| 2489 | * Use OTP_INIT command to reset/refresh state. |
| 2490 | */ |
| 2491 | case BCM43224_CHIP_ID: |
| 2492 | case BCM43225_CHIP_ID: |
| 2493 | case BCM43421_CHIP_ID: |
| 2494 | case BCM43236_CHIP_ID: |
| 2495 | case BCM43235_CHIP_ID: |
| 2496 | case BCM43238_CHIP_ID: |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 2497 | st = true; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2498 | break; |
| 2499 | default: |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 2500 | st = true; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2501 | break; |
| 2502 | } |
| 2503 | |
| 2504 | /* Return to original core */ |
| 2505 | si_setcoreidx(sih, idx); |
| 2506 | return st; |
| 2507 | } |
| 2508 | |
| 2509 | void |
| 2510 | #if defined(BCMDBG) |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2511 | si_pmu_sprom_enable(si_t *sih, struct osl_info *osh, bool enable) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2512 | #else |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2513 | si_pmu_sprom_enable(si_t *sih, struct osl_info *osh, bool enable) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2514 | #endif |
| 2515 | { |
| 2516 | chipcregs_t *cc; |
| 2517 | uint origidx; |
| 2518 | |
| 2519 | /* Remember original core before switch to chipc */ |
| 2520 | origidx = si_coreidx(sih); |
| 2521 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 2522 | ASSERT(cc != NULL); |
| 2523 | |
| 2524 | /* Return to original core */ |
| 2525 | si_setcoreidx(sih, origidx); |
| 2526 | } |
| 2527 | |
| 2528 | /* initialize PMU chip controls and other chip level stuff */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2529 | void si_pmu_chip_init(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 2530 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2531 | uint origidx; |
| 2532 | |
| 2533 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 2534 | |
| 2535 | #ifdef CHIPC_UART_ALWAYS_ON |
Greg Kroah-Hartman | ce0f1b8 | 2010-10-08 11:44:45 -0700 | [diff] [blame] | 2536 | si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, clk_ctl_st), |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2537 | CCS_FORCEALP, CCS_FORCEALP); |
| 2538 | #endif /* CHIPC_UART_ALWAYS_ON */ |
| 2539 | |
| 2540 | /* Gate off SPROM clock and chip select signals */ |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 2541 | si_pmu_sprom_enable(sih, osh, false); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2542 | |
| 2543 | /* Remember original core */ |
| 2544 | origidx = si_coreidx(sih); |
| 2545 | |
| 2546 | /* Return to original core */ |
| 2547 | si_setcoreidx(sih, origidx); |
| 2548 | } |
| 2549 | |
| 2550 | /* initialize PMU switch/regulators */ |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2551 | void si_pmu_swreg_init(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 2552 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2553 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 2554 | |
| 2555 | switch (CHIPID(sih->chip)) { |
| 2556 | case BCM4336_CHIP_ID: |
| 2557 | /* Reduce CLDO PWM output voltage to 1.2V */ |
| 2558 | si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_CLDO_PWM, 0xe); |
| 2559 | /* Reduce CLDO BURST output voltage to 1.2V */ |
| 2560 | si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_CLDO_BURST, |
| 2561 | 0xe); |
| 2562 | /* Reduce LNLDO1 output voltage to 1.2V */ |
| 2563 | si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_LNLDO1, 0xe); |
| 2564 | if (CHIPREV(sih->chiprev) == 0) |
| 2565 | si_pmu_regcontrol(sih, 2, 0x400000, 0x400000); |
| 2566 | break; |
| 2567 | |
| 2568 | case BCM4330_CHIP_ID: |
| 2569 | /* CBUCK Voltage is 1.8 by default and set that to 1.5 */ |
| 2570 | si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_CBUCK_PWM, 0); |
| 2571 | break; |
| 2572 | default: |
| 2573 | break; |
| 2574 | } |
| 2575 | } |
| 2576 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 2577 | void si_pmu_radio_enable(si_t *sih, bool enable) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2578 | { |
| 2579 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 2580 | |
| 2581 | switch (CHIPID(sih->chip)) { |
| 2582 | case BCM4319_CHIP_ID: |
| 2583 | if (enable) |
| 2584 | si_write_wrapperreg(sih, AI_OOBSELOUTB74, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2585 | (u32) 0x868584); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2586 | else |
| 2587 | si_write_wrapperreg(sih, AI_OOBSELOUTB74, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2588 | (u32) 0x060584); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2589 | break; |
| 2590 | } |
| 2591 | } |
| 2592 | |
| 2593 | /* Wait for a particular clock level to be on the backplane */ |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2594 | u32 |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2595 | si_pmu_waitforclk_on_backplane(si_t *sih, struct osl_info *osh, u32 clk, |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2596 | u32 delay) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2597 | { |
| 2598 | chipcregs_t *cc; |
| 2599 | uint origidx; |
| 2600 | |
| 2601 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 2602 | |
| 2603 | /* Remember original core before switch to chipc */ |
| 2604 | origidx = si_coreidx(sih); |
| 2605 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 2606 | ASSERT(cc != NULL); |
| 2607 | |
| 2608 | if (delay) |
| 2609 | SPINWAIT(((R_REG(osh, &cc->pmustatus) & clk) != clk), delay); |
| 2610 | |
| 2611 | /* Return to original core */ |
| 2612 | si_setcoreidx(sih, origidx); |
| 2613 | |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 2614 | return R_REG(osh, &cc->pmustatus) & clk; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2615 | } |
| 2616 | |
| 2617 | /* |
| 2618 | * Measures the ALP clock frequency in KHz. Returns 0 if not possible. |
| 2619 | * Possible only if PMU rev >= 10 and there is an external LPO 32768Hz crystal. |
| 2620 | */ |
| 2621 | |
| 2622 | #define EXT_ILP_HZ 32768 |
| 2623 | |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame^] | 2624 | u32 si_pmu_measure_alpclk(si_t *sih, struct osl_info *osh) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 2625 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2626 | chipcregs_t *cc; |
| 2627 | uint origidx; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2628 | u32 alp_khz; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2629 | |
| 2630 | if (sih->pmurev < 10) |
| 2631 | return 0; |
| 2632 | |
| 2633 | ASSERT(sih->cccaps & CC_CAP_PMU); |
| 2634 | |
| 2635 | /* Remember original core before switch to chipc */ |
| 2636 | origidx = si_coreidx(sih); |
| 2637 | cc = si_setcoreidx(sih, SI_CC_IDX); |
| 2638 | ASSERT(cc != NULL); |
| 2639 | |
| 2640 | if (R_REG(osh, &cc->pmustatus) & PST_EXTLPOAVAIL) { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2641 | u32 ilp_ctr, alp_hz; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2642 | |
| 2643 | /* Enable the reg to measure the freq, in case disabled before */ |
| 2644 | W_REG(osh, &cc->pmu_xtalfreq, |
| 2645 | 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT); |
| 2646 | |
| 2647 | /* Delay for well over 4 ILP clocks */ |
mike.rapoport@gmail.com | 7383141 | 2010-10-13 00:09:07 +0200 | [diff] [blame] | 2648 | udelay(1000); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2649 | |
| 2650 | /* Read the latched number of ALP ticks per 4 ILP ticks */ |
| 2651 | ilp_ctr = |
| 2652 | R_REG(osh, |
| 2653 | &cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK; |
| 2654 | |
| 2655 | /* Turn off the PMU_XTALFREQ_REG_MEASURE_SHIFT bit to save power */ |
| 2656 | W_REG(osh, &cc->pmu_xtalfreq, 0); |
| 2657 | |
| 2658 | /* Calculate ALP frequency */ |
| 2659 | alp_hz = (ilp_ctr * EXT_ILP_HZ) / 4; |
| 2660 | |
| 2661 | /* Round to nearest 100KHz, and at the same time convert to KHz */ |
| 2662 | alp_khz = (alp_hz + 50000) / 100000 * 100; |
| 2663 | } else |
| 2664 | alp_khz = 0; |
| 2665 | |
| 2666 | /* Return to original core */ |
| 2667 | si_setcoreidx(sih, origidx); |
| 2668 | |
| 2669 | return alp_khz; |
| 2670 | } |
| 2671 | |
Greg Kroah-Hartman | 0d2f072 | 2010-10-08 14:28:21 -0700 | [diff] [blame] | 2672 | static void si_pmu_set_4330_plldivs(si_t *sih) |
Jason Cooper | a2627bc | 2010-09-14 09:45:31 -0400 | [diff] [blame] | 2673 | { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 2674 | u32 FVCO = si_pmu1_pllfvco0(sih) / 1000; |
| 2675 | u32 m1div, m2div, m3div, m4div, m5div, m6div; |
| 2676 | u32 pllc1, pllc2; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 2677 | |
| 2678 | m2div = m3div = m4div = m6div = FVCO / 80; |
| 2679 | m5div = FVCO / 160; |
| 2680 | |
| 2681 | if (CST4330_CHIPMODE_SDIOD(sih->chipst)) |
| 2682 | m1div = FVCO / 80; |
| 2683 | else |
| 2684 | m1div = FVCO / 90; |
| 2685 | pllc1 = |
| 2686 | (m1div << PMU1_PLL0_PC1_M1DIV_SHIFT) | (m2div << |
| 2687 | PMU1_PLL0_PC1_M2DIV_SHIFT) | |
| 2688 | (m3div << PMU1_PLL0_PC1_M3DIV_SHIFT) | (m4div << |
| 2689 | PMU1_PLL0_PC1_M4DIV_SHIFT); |
| 2690 | si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL1, ~0, pllc1); |
| 2691 | |
| 2692 | pllc2 = si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL1, 0, 0); |
| 2693 | pllc2 &= ~(PMU1_PLL0_PC2_M5DIV_MASK | PMU1_PLL0_PC2_M6DIV_MASK); |
| 2694 | pllc2 |= |
| 2695 | ((m5div << PMU1_PLL0_PC2_M5DIV_SHIFT) | |
| 2696 | (m6div << PMU1_PLL0_PC2_M6DIV_SHIFT)); |
| 2697 | si_pmu_pllcontrol(sih, PMU1_PLL0_PLLCTL2, ~0, pllc2); |
| 2698 | } |