Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Broadcom specific AMBA |
| 3 | * ChipCommon Power Management Unit driver |
| 4 | * |
Michael Büsch | eb032b9 | 2011-07-04 20:50:05 +0200 | [diff] [blame] | 5 | * Copyright 2009, Michael Buesch <m@bues.ch> |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 6 | * Copyright 2007, 2011, Broadcom Corporation |
| 7 | * Copyright 2011, 2012, Hauke Mehrtens <hauke@hauke-m.de> |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 8 | * |
| 9 | * Licensed under the GNU/GPL. See COPYING for details. |
| 10 | */ |
| 11 | |
| 12 | #include "bcma_private.h" |
Paul Gortmaker | 44a8e37 | 2011-07-27 21:21:04 -0400 | [diff] [blame] | 13 | #include <linux/export.h> |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 14 | #include <linux/bcma/bcma.h> |
| 15 | |
Rafał Miłecki | 8d4b9e3 | 2012-11-12 13:03:20 +0100 | [diff] [blame] | 16 | u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset) |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 17 | { |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 18 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, offset); |
| 19 | bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_ADDR); |
| 20 | return bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_DATA); |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 21 | } |
Rafał Miłecki | 8d4b9e3 | 2012-11-12 13:03:20 +0100 | [diff] [blame] | 22 | EXPORT_SYMBOL_GPL(bcma_chipco_pll_read); |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 23 | |
Rafał Miłecki | 3861b2c | 2011-09-16 12:33:58 +0200 | [diff] [blame] | 24 | void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value) |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 25 | { |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 26 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, offset); |
| 27 | bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_ADDR); |
| 28 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_DATA, value); |
Rafał Miłecki | 3861b2c | 2011-09-16 12:33:58 +0200 | [diff] [blame] | 29 | } |
| 30 | EXPORT_SYMBOL_GPL(bcma_chipco_pll_write); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 31 | |
Rafał Miłecki | 3861b2c | 2011-09-16 12:33:58 +0200 | [diff] [blame] | 32 | void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask, |
| 33 | u32 set) |
| 34 | { |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 35 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, offset); |
| 36 | bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_ADDR); |
| 37 | bcma_pmu_maskset32(cc, BCMA_CC_PMU_PLLCTL_DATA, mask, set); |
Rafał Miłecki | 3861b2c | 2011-09-16 12:33:58 +0200 | [diff] [blame] | 38 | } |
| 39 | EXPORT_SYMBOL_GPL(bcma_chipco_pll_maskset); |
| 40 | |
| 41 | void bcma_chipco_chipctl_maskset(struct bcma_drv_cc *cc, |
| 42 | u32 offset, u32 mask, u32 set) |
| 43 | { |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 44 | bcma_pmu_write32(cc, BCMA_CC_PMU_CHIPCTL_ADDR, offset); |
| 45 | bcma_pmu_read32(cc, BCMA_CC_PMU_CHIPCTL_ADDR); |
| 46 | bcma_pmu_maskset32(cc, BCMA_CC_PMU_CHIPCTL_DATA, mask, set); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 47 | } |
Rafał Miłecki | 3861b2c | 2011-09-16 12:33:58 +0200 | [diff] [blame] | 48 | EXPORT_SYMBOL_GPL(bcma_chipco_chipctl_maskset); |
| 49 | |
| 50 | void bcma_chipco_regctl_maskset(struct bcma_drv_cc *cc, u32 offset, u32 mask, |
| 51 | u32 set) |
| 52 | { |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 53 | bcma_pmu_write32(cc, BCMA_CC_PMU_REGCTL_ADDR, offset); |
| 54 | bcma_pmu_read32(cc, BCMA_CC_PMU_REGCTL_ADDR); |
| 55 | bcma_pmu_maskset32(cc, BCMA_CC_PMU_REGCTL_DATA, mask, set); |
Rafał Miłecki | 3861b2c | 2011-09-16 12:33:58 +0200 | [diff] [blame] | 56 | } |
| 57 | EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 58 | |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 59 | static u32 bcma_pmu_xtalfreq(struct bcma_drv_cc *cc) |
| 60 | { |
| 61 | u32 ilp_ctl, alp_hz; |
| 62 | |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 63 | if (!(bcma_pmu_read32(cc, BCMA_CC_PMU_STAT) & |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 64 | BCMA_CC_PMU_STAT_EXT_LPO_AVAIL)) |
| 65 | return 0; |
| 66 | |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 67 | bcma_pmu_write32(cc, BCMA_CC_PMU_XTAL_FREQ, |
| 68 | BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT)); |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 69 | usleep_range(1000, 2000); |
| 70 | |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 71 | ilp_ctl = bcma_pmu_read32(cc, BCMA_CC_PMU_XTAL_FREQ); |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 72 | ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK; |
| 73 | |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 74 | bcma_pmu_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0); |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 75 | |
| 76 | alp_hz = ilp_ctl * 32768 / 4; |
| 77 | return (alp_hz + 50000) / 100000 * 100; |
| 78 | } |
| 79 | |
| 80 | static void bcma_pmu2_pll_init0(struct bcma_drv_cc *cc, u32 xtalfreq) |
| 81 | { |
| 82 | struct bcma_bus *bus = cc->core->bus; |
| 83 | u32 freq_tgt_target = 0, freq_tgt_current; |
| 84 | u32 pll0, mask; |
| 85 | |
| 86 | switch (bus->chipinfo.id) { |
| 87 | case BCMA_CHIP_ID_BCM43142: |
| 88 | /* pmu2_xtaltab0_adfll_485 */ |
| 89 | switch (xtalfreq) { |
| 90 | case 12000: |
| 91 | freq_tgt_target = 0x50D52; |
| 92 | break; |
| 93 | case 20000: |
| 94 | freq_tgt_target = 0x307FE; |
| 95 | break; |
| 96 | case 26000: |
| 97 | freq_tgt_target = 0x254EA; |
| 98 | break; |
| 99 | case 37400: |
| 100 | freq_tgt_target = 0x19EF8; |
| 101 | break; |
| 102 | case 52000: |
| 103 | freq_tgt_target = 0x12A75; |
| 104 | break; |
| 105 | } |
| 106 | break; |
| 107 | } |
| 108 | |
| 109 | if (!freq_tgt_target) { |
| 110 | bcma_err(bus, "Unknown TGT frequency for xtalfreq %d\n", |
| 111 | xtalfreq); |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | pll0 = bcma_chipco_pll_read(cc, BCMA_CC_PMU15_PLL_PLLCTL0); |
| 116 | freq_tgt_current = (pll0 & BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK) >> |
| 117 | BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT; |
| 118 | |
| 119 | if (freq_tgt_current == freq_tgt_target) { |
| 120 | bcma_debug(bus, "Target TGT frequency already set\n"); |
| 121 | return; |
| 122 | } |
| 123 | |
| 124 | /* Turn off PLL */ |
| 125 | switch (bus->chipinfo.id) { |
| 126 | case BCMA_CHIP_ID_BCM43142: |
| 127 | mask = (u32)~(BCMA_RES_4314_HT_AVAIL | |
| 128 | BCMA_RES_4314_MACPHY_CLK_AVAIL); |
| 129 | |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 130 | bcma_pmu_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask); |
| 131 | bcma_pmu_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask); |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 132 | bcma_wait_value(cc->core, BCMA_CLKCTLST, |
| 133 | BCMA_CLKCTLST_HAVEHT, 0, 20000); |
| 134 | break; |
| 135 | } |
| 136 | |
| 137 | pll0 &= ~BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK; |
| 138 | pll0 |= freq_tgt_target << BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT; |
| 139 | bcma_chipco_pll_write(cc, BCMA_CC_PMU15_PLL_PLLCTL0, pll0); |
| 140 | |
| 141 | /* Flush */ |
| 142 | if (cc->pmu.rev >= 2) |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 143 | bcma_pmu_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD); |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 144 | |
| 145 | /* TODO: Do we need to update OTP? */ |
| 146 | } |
| 147 | |
| 148 | static void bcma_pmu_pll_init(struct bcma_drv_cc *cc) |
| 149 | { |
| 150 | struct bcma_bus *bus = cc->core->bus; |
| 151 | u32 xtalfreq = bcma_pmu_xtalfreq(cc); |
| 152 | |
| 153 | switch (bus->chipinfo.id) { |
| 154 | case BCMA_CHIP_ID_BCM43142: |
| 155 | if (xtalfreq == 0) |
| 156 | xtalfreq = 20000; |
| 157 | bcma_pmu2_pll_init0(cc, xtalfreq); |
| 158 | break; |
| 159 | } |
| 160 | } |
| 161 | |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 162 | static void bcma_pmu_resources_init(struct bcma_drv_cc *cc) |
| 163 | { |
| 164 | struct bcma_bus *bus = cc->core->bus; |
| 165 | u32 min_msk = 0, max_msk = 0; |
| 166 | |
| 167 | switch (bus->chipinfo.id) { |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 168 | case BCMA_CHIP_ID_BCM4313: |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 169 | min_msk = 0x200D; |
| 170 | max_msk = 0xFFFF; |
| 171 | break; |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 172 | case BCMA_CHIP_ID_BCM43142: |
| 173 | min_msk = BCMA_RES_4314_LPLDO_PU | |
| 174 | BCMA_RES_4314_PMU_SLEEP_DIS | |
| 175 | BCMA_RES_4314_PMU_BG_PU | |
| 176 | BCMA_RES_4314_CBUCK_LPOM_PU | |
| 177 | BCMA_RES_4314_CBUCK_PFM_PU | |
| 178 | BCMA_RES_4314_CLDO_PU | |
| 179 | BCMA_RES_4314_LPLDO2_LVM | |
| 180 | BCMA_RES_4314_WL_PMU_PU | |
| 181 | BCMA_RES_4314_LDO3P3_PU | |
| 182 | BCMA_RES_4314_OTP_PU | |
| 183 | BCMA_RES_4314_WL_PWRSW_PU | |
| 184 | BCMA_RES_4314_LQ_AVAIL | |
| 185 | BCMA_RES_4314_LOGIC_RET | |
| 186 | BCMA_RES_4314_MEM_SLEEP | |
| 187 | BCMA_RES_4314_MACPHY_RET | |
| 188 | BCMA_RES_4314_WL_CORE_READY; |
| 189 | max_msk = 0x3FFFFFFF; |
| 190 | break; |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 191 | default: |
Rafał Miłecki | 3d9d8af | 2012-07-05 22:07:32 +0200 | [diff] [blame] | 192 | bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n", |
| 193 | bus->chipinfo.id); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | /* Set the resource masks. */ |
| 197 | if (min_msk) |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 198 | bcma_pmu_write32(cc, BCMA_CC_PMU_MINRES_MSK, min_msk); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 199 | if (max_msk) |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 200 | bcma_pmu_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk); |
Hauke Mehrtens | 4795f09 | 2012-06-30 01:44:45 +0200 | [diff] [blame] | 201 | |
Rafał Miłecki | 1fd41a6 | 2012-09-25 10:17:22 +0200 | [diff] [blame] | 202 | /* |
| 203 | * Add some delay; allow resources to come up and settle. |
| 204 | * Delay is required for SoC (early init). |
| 205 | */ |
Hauke Mehrtens | 4795f09 | 2012-06-30 01:44:45 +0200 | [diff] [blame] | 206 | mdelay(2); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 207 | } |
| 208 | |
Rafał Miłecki | 984e5be | 2011-08-11 23:46:44 +0200 | [diff] [blame] | 209 | /* Disable to allow reading SPROM. Don't know the adventages of enabling it. */ |
| 210 | void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable) |
| 211 | { |
| 212 | struct bcma_bus *bus = cc->core->bus; |
| 213 | u32 val; |
| 214 | |
| 215 | val = bcma_cc_read32(cc, BCMA_CC_CHIPCTL); |
| 216 | if (enable) { |
| 217 | val |= BCMA_CHIPCTL_4331_EXTPA_EN; |
| 218 | if (bus->chipinfo.pkg == 9 || bus->chipinfo.pkg == 11) |
| 219 | val |= BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5; |
Hauke Mehrtens | 00eeedc | 2012-06-30 01:44:37 +0200 | [diff] [blame] | 220 | else if (bus->chipinfo.rev > 0) |
| 221 | val |= BCMA_CHIPCTL_4331_EXTPA_EN2; |
Rafał Miłecki | 984e5be | 2011-08-11 23:46:44 +0200 | [diff] [blame] | 222 | } else { |
| 223 | val &= ~BCMA_CHIPCTL_4331_EXTPA_EN; |
Hauke Mehrtens | 00eeedc | 2012-06-30 01:44:37 +0200 | [diff] [blame] | 224 | val &= ~BCMA_CHIPCTL_4331_EXTPA_EN2; |
Rafał Miłecki | 984e5be | 2011-08-11 23:46:44 +0200 | [diff] [blame] | 225 | val &= ~BCMA_CHIPCTL_4331_EXTPA_ON_GPIO2_5; |
| 226 | } |
| 227 | bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val); |
| 228 | } |
| 229 | |
Hauke Mehrtens | 94f3457 | 2012-08-05 16:54:41 +0200 | [diff] [blame] | 230 | static void bcma_pmu_workarounds(struct bcma_drv_cc *cc) |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 231 | { |
| 232 | struct bcma_bus *bus = cc->core->bus; |
| 233 | |
| 234 | switch (bus->chipinfo.id) { |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 235 | case BCMA_CHIP_ID_BCM4313: |
Hauke Mehrtens | b956254 | 2012-06-30 01:44:41 +0200 | [diff] [blame] | 236 | /* enable 12 mA drive strenth for 4313 and set chipControl |
| 237 | register bit 1 */ |
| 238 | bcma_chipco_chipctl_maskset(cc, 0, |
Hauke Mehrtens | 1f03bf0 | 2012-07-25 23:08:54 +0200 | [diff] [blame] | 239 | ~BCMA_CCTRL_4313_12MA_LED_DRIVE, |
Hauke Mehrtens | b956254 | 2012-06-30 01:44:41 +0200 | [diff] [blame] | 240 | BCMA_CCTRL_4313_12MA_LED_DRIVE); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 241 | break; |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 242 | case BCMA_CHIP_ID_BCM4331: |
| 243 | case BCMA_CHIP_ID_BCM43431: |
Seth Forshee | 69aaedd | 2012-06-01 09:13:17 -0500 | [diff] [blame] | 244 | /* Ext PA lines must be enabled for tx on BCM4331 */ |
| 245 | bcma_chipco_bcm4331_ext_pa_lines_ctl(cc, true); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 246 | break; |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 247 | case BCMA_CHIP_ID_BCM43224: |
Hauke Mehrtens | b956254 | 2012-06-30 01:44:41 +0200 | [diff] [blame] | 248 | case BCMA_CHIP_ID_BCM43421: |
| 249 | /* enable 12 mA drive strenth for 43224 and set chipControl |
| 250 | register bit 15 */ |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 251 | if (bus->chipinfo.rev == 0) { |
Hauke Mehrtens | b956254 | 2012-06-30 01:44:41 +0200 | [diff] [blame] | 252 | bcma_cc_maskset32(cc, BCMA_CC_CHIPCTL, |
Hauke Mehrtens | 1f03bf0 | 2012-07-25 23:08:54 +0200 | [diff] [blame] | 253 | ~BCMA_CCTRL_43224_GPIO_TOGGLE, |
Hauke Mehrtens | b956254 | 2012-06-30 01:44:41 +0200 | [diff] [blame] | 254 | BCMA_CCTRL_43224_GPIO_TOGGLE); |
| 255 | bcma_chipco_chipctl_maskset(cc, 0, |
Hauke Mehrtens | 1f03bf0 | 2012-07-25 23:08:54 +0200 | [diff] [blame] | 256 | ~BCMA_CCTRL_43224A0_12MA_LED_DRIVE, |
Hauke Mehrtens | b956254 | 2012-06-30 01:44:41 +0200 | [diff] [blame] | 257 | BCMA_CCTRL_43224A0_12MA_LED_DRIVE); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 258 | } else { |
Hauke Mehrtens | b956254 | 2012-06-30 01:44:41 +0200 | [diff] [blame] | 259 | bcma_chipco_chipctl_maskset(cc, 0, |
Hauke Mehrtens | 1f03bf0 | 2012-07-25 23:08:54 +0200 | [diff] [blame] | 260 | ~BCMA_CCTRL_43224B0_12MA_LED_DRIVE, |
Hauke Mehrtens | b956254 | 2012-06-30 01:44:41 +0200 | [diff] [blame] | 261 | BCMA_CCTRL_43224B0_12MA_LED_DRIVE); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 262 | } |
| 263 | break; |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 264 | default: |
Rafał Miłecki | 3d9d8af | 2012-07-05 22:07:32 +0200 | [diff] [blame] | 265 | bcma_debug(bus, "Workarounds unknown or not needed for device 0x%04X\n", |
| 266 | bus->chipinfo.id); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | |
Hauke Mehrtens | 49655bb | 2012-09-29 20:29:49 +0200 | [diff] [blame] | 270 | void bcma_pmu_early_init(struct bcma_drv_cc *cc) |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 271 | { |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 272 | struct bcma_bus *bus = cc->core->bus; |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 273 | u32 pmucap; |
| 274 | |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 275 | if (cc->core->id.rev >= 35 && |
| 276 | cc->capabilities_ext & BCMA_CC_CAP_EXT_AOB_PRESENT) { |
| 277 | cc->pmu.core = bcma_find_core(bus, BCMA_CORE_PMU); |
| 278 | if (!cc->pmu.core) |
| 279 | bcma_warn(bus, "Couldn't find expected PMU core"); |
| 280 | } |
| 281 | if (!cc->pmu.core) |
| 282 | cc->pmu.core = cc->core; |
| 283 | |
| 284 | pmucap = bcma_pmu_read32(cc, BCMA_CC_PMU_CAP); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 285 | cc->pmu.rev = (pmucap & BCMA_CC_PMU_CAP_REVISION); |
| 286 | |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 287 | bcma_debug(bus, "Found rev %u PMU (capabilities 0x%08X)\n", cc->pmu.rev, |
| 288 | pmucap); |
Hauke Mehrtens | 49655bb | 2012-09-29 20:29:49 +0200 | [diff] [blame] | 289 | } |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 290 | |
Hauke Mehrtens | 49655bb | 2012-09-29 20:29:49 +0200 | [diff] [blame] | 291 | void bcma_pmu_init(struct bcma_drv_cc *cc) |
| 292 | { |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 293 | if (cc->pmu.rev == 1) |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 294 | bcma_pmu_mask32(cc, BCMA_CC_PMU_CTL, |
| 295 | ~BCMA_CC_PMU_CTL_NOILPONW); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 296 | else |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 297 | bcma_pmu_set32(cc, BCMA_CC_PMU_CTL, |
| 298 | BCMA_CC_PMU_CTL_NOILPONW); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 299 | |
Rafał Miłecki | 88f9b65 | 2013-06-26 10:02:11 +0200 | [diff] [blame] | 300 | bcma_pmu_pll_init(cc); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 301 | bcma_pmu_resources_init(cc); |
Rafał Miłecki | 8369ae3 | 2011-05-09 18:56:46 +0200 | [diff] [blame] | 302 | bcma_pmu_workarounds(cc); |
| 303 | } |
Hauke Mehrtens | e3afe0e | 2011-07-23 01:20:10 +0200 | [diff] [blame] | 304 | |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 305 | u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc) |
Hauke Mehrtens | e3afe0e | 2011-07-23 01:20:10 +0200 | [diff] [blame] | 306 | { |
| 307 | struct bcma_bus *bus = cc->core->bus; |
| 308 | |
| 309 | switch (bus->chipinfo.id) { |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 310 | case BCMA_CHIP_ID_BCM4313: |
Hauke Mehrtens | d6b688c | 2013-03-27 17:23:10 +0100 | [diff] [blame] | 311 | case BCMA_CHIP_ID_BCM43224: |
| 312 | case BCMA_CHIP_ID_BCM43225: |
| 313 | case BCMA_CHIP_ID_BCM43227: |
| 314 | case BCMA_CHIP_ID_BCM43228: |
| 315 | case BCMA_CHIP_ID_BCM4331: |
| 316 | case BCMA_CHIP_ID_BCM43421: |
| 317 | case BCMA_CHIP_ID_BCM43428: |
| 318 | case BCMA_CHIP_ID_BCM43431: |
| 319 | case BCMA_CHIP_ID_BCM4716: |
| 320 | case BCMA_CHIP_ID_BCM47162: |
| 321 | case BCMA_CHIP_ID_BCM4748: |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 322 | case BCMA_CHIP_ID_BCM4749: |
Hauke Mehrtens | d6b688c | 2013-03-27 17:23:10 +0100 | [diff] [blame] | 323 | case BCMA_CHIP_ID_BCM5357: |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 324 | case BCMA_CHIP_ID_BCM53572: |
Hauke Mehrtens | d6b688c | 2013-03-27 17:23:10 +0100 | [diff] [blame] | 325 | case BCMA_CHIP_ID_BCM6362: |
Hauke Mehrtens | e3afe0e | 2011-07-23 01:20:10 +0200 | [diff] [blame] | 326 | /* always 20Mhz */ |
| 327 | return 20000 * 1000; |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 328 | case BCMA_CHIP_ID_BCM4706: |
Hauke Mehrtens | d6b688c | 2013-03-27 17:23:10 +0100 | [diff] [blame] | 329 | case BCMA_CHIP_ID_BCM5356: |
Hauke Mehrtens | e3afe0e | 2011-07-23 01:20:10 +0200 | [diff] [blame] | 330 | /* always 25Mhz */ |
| 331 | return 25000 * 1000; |
Hauke Mehrtens | d6b688c | 2013-03-27 17:23:10 +0100 | [diff] [blame] | 332 | case BCMA_CHIP_ID_BCM43460: |
| 333 | case BCMA_CHIP_ID_BCM4352: |
| 334 | case BCMA_CHIP_ID_BCM4360: |
| 335 | if (cc->status & BCMA_CC_CHIPST_4360_XTAL_40MZ) |
| 336 | return 40000 * 1000; |
| 337 | else |
| 338 | return 20000 * 1000; |
Hauke Mehrtens | e3afe0e | 2011-07-23 01:20:10 +0200 | [diff] [blame] | 339 | default: |
Rafał Miłecki | 3d9d8af | 2012-07-05 22:07:32 +0200 | [diff] [blame] | 340 | bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n", |
| 341 | bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK); |
Hauke Mehrtens | e3afe0e | 2011-07-23 01:20:10 +0200 | [diff] [blame] | 342 | } |
| 343 | return BCMA_CC_PMU_ALP_CLOCK; |
| 344 | } |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 345 | |
| 346 | /* Find the output of the "m" pll divider given pll controls that start with |
| 347 | * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc. |
| 348 | */ |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 349 | static u32 bcma_pmu_pll_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m) |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 350 | { |
| 351 | u32 tmp, div, ndiv, p1, p2, fc; |
| 352 | struct bcma_bus *bus = cc->core->bus; |
| 353 | |
| 354 | BUG_ON((pll0 & 3) || (pll0 > BCMA_CC_PMU4716_MAINPLL_PLL0)); |
| 355 | |
| 356 | BUG_ON(!m || m > 4); |
| 357 | |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 358 | if (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 || |
| 359 | bus->chipinfo.id == BCMA_CHIP_ID_BCM4749) { |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 360 | /* Detect failure in clock setting */ |
| 361 | tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT); |
| 362 | if (tmp & 0x40000) |
| 363 | return 133 * 1000000; |
| 364 | } |
| 365 | |
| 366 | tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_P1P2_OFF); |
| 367 | p1 = (tmp & BCMA_CC_PPL_P1_MASK) >> BCMA_CC_PPL_P1_SHIFT; |
| 368 | p2 = (tmp & BCMA_CC_PPL_P2_MASK) >> BCMA_CC_PPL_P2_SHIFT; |
| 369 | |
| 370 | tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_M14_OFF); |
| 371 | div = (tmp >> ((m - 1) * BCMA_CC_PPL_MDIV_WIDTH)) & |
| 372 | BCMA_CC_PPL_MDIV_MASK; |
| 373 | |
| 374 | tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PPL_NM5_OFF); |
| 375 | ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT; |
| 376 | |
| 377 | /* Do calculation in Mhz */ |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 378 | fc = bcma_pmu_get_alp_clock(cc) / 1000000; |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 379 | fc = (p1 * ndiv * fc) / p2; |
| 380 | |
| 381 | /* Return clock in Hertz */ |
| 382 | return (fc / div) * 1000000; |
| 383 | } |
| 384 | |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 385 | static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m) |
Hauke Mehrtens | 650cef38 | 2012-07-09 22:03:10 +0200 | [diff] [blame] | 386 | { |
| 387 | u32 tmp, ndiv, p1div, p2div; |
| 388 | u32 clock; |
| 389 | |
| 390 | BUG_ON(!m || m > 4); |
| 391 | |
| 392 | /* Get N, P1 and P2 dividers to determine CPU clock */ |
| 393 | tmp = bcma_chipco_pll_read(cc, pll0 + BCMA_CC_PMU6_4706_PROCPLL_OFF); |
| 394 | ndiv = (tmp & BCMA_CC_PMU6_4706_PROC_NDIV_INT_MASK) |
| 395 | >> BCMA_CC_PMU6_4706_PROC_NDIV_INT_SHIFT; |
| 396 | p1div = (tmp & BCMA_CC_PMU6_4706_PROC_P1DIV_MASK) |
| 397 | >> BCMA_CC_PMU6_4706_PROC_P1DIV_SHIFT; |
| 398 | p2div = (tmp & BCMA_CC_PMU6_4706_PROC_P2DIV_MASK) |
| 399 | >> BCMA_CC_PMU6_4706_PROC_P2DIV_SHIFT; |
| 400 | |
| 401 | tmp = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT); |
| 402 | if (tmp & BCMA_CC_CHIPST_4706_PKG_OPTION) |
| 403 | /* Low cost bonding: Fixed reference clock 25MHz and m = 4 */ |
| 404 | clock = (25000000 / 4) * ndiv * p2div / p1div; |
| 405 | else |
| 406 | /* Fixed reference clock 25MHz and m = 2 */ |
| 407 | clock = (25000000 / 2) * ndiv * p2div / p1div; |
| 408 | |
| 409 | if (m == BCMA_CC_PMU5_MAINPLL_SSB) |
| 410 | clock = clock / 4; |
| 411 | |
| 412 | return clock; |
| 413 | } |
| 414 | |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 415 | /* query bus clock frequency for PMU-enabled chipcommon */ |
Rafał Miłecki | dd4544f | 2013-01-08 20:06:23 +0000 | [diff] [blame] | 416 | u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc) |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 417 | { |
| 418 | struct bcma_bus *bus = cc->core->bus; |
| 419 | |
| 420 | switch (bus->chipinfo.id) { |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 421 | case BCMA_CHIP_ID_BCM4716: |
| 422 | case BCMA_CHIP_ID_BCM4748: |
| 423 | case BCMA_CHIP_ID_BCM47162: |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 424 | return bcma_pmu_pll_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0, |
| 425 | BCMA_CC_PMU5_MAINPLL_SSB); |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 426 | case BCMA_CHIP_ID_BCM5356: |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 427 | return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0, |
| 428 | BCMA_CC_PMU5_MAINPLL_SSB); |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 429 | case BCMA_CHIP_ID_BCM5357: |
| 430 | case BCMA_CHIP_ID_BCM4749: |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 431 | return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0, |
| 432 | BCMA_CC_PMU5_MAINPLL_SSB); |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 433 | case BCMA_CHIP_ID_BCM4706: |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 434 | return bcma_pmu_pll_clock_bcm4706(cc, |
| 435 | BCMA_CC_PMU4706_MAINPLL_PLL0, |
| 436 | BCMA_CC_PMU5_MAINPLL_SSB); |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 437 | case BCMA_CHIP_ID_BCM53572: |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 438 | return 75000000; |
| 439 | default: |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 440 | bcma_warn(bus, "No bus clock specified for %04X device, pmu rev. %d, using default %d Hz\n", |
Rafał Miłecki | 3d9d8af | 2012-07-05 22:07:32 +0200 | [diff] [blame] | 441 | bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK); |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 442 | } |
| 443 | return BCMA_CC_PMU_HT_CLOCK; |
| 444 | } |
Rafał Miłecki | dd4544f | 2013-01-08 20:06:23 +0000 | [diff] [blame] | 445 | EXPORT_SYMBOL_GPL(bcma_pmu_get_bus_clock); |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 446 | |
| 447 | /* query cpu clock frequency for PMU-enabled chipcommon */ |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 448 | u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc) |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 449 | { |
| 450 | struct bcma_bus *bus = cc->core->bus; |
| 451 | |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 452 | if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 453 | return 300000000; |
| 454 | |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 455 | /* New PMUs can have different clock for bus and CPU */ |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 456 | if (cc->pmu.rev >= 5) { |
| 457 | u32 pll; |
| 458 | switch (bus->chipinfo.id) { |
Hauke Mehrtens | 650cef38 | 2012-07-09 22:03:10 +0200 | [diff] [blame] | 459 | case BCMA_CHIP_ID_BCM4706: |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 460 | return bcma_pmu_pll_clock_bcm4706(cc, |
Hauke Mehrtens | 650cef38 | 2012-07-09 22:03:10 +0200 | [diff] [blame] | 461 | BCMA_CC_PMU4706_MAINPLL_PLL0, |
| 462 | BCMA_CC_PMU5_MAINPLL_CPU); |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 463 | case BCMA_CHIP_ID_BCM5356: |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 464 | pll = BCMA_CC_PMU5356_MAINPLL_PLL0; |
| 465 | break; |
Hauke Mehrtens | 4b4f5be | 2012-06-30 01:44:38 +0200 | [diff] [blame] | 466 | case BCMA_CHIP_ID_BCM5357: |
| 467 | case BCMA_CHIP_ID_BCM4749: |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 468 | pll = BCMA_CC_PMU5357_MAINPLL_PLL0; |
| 469 | break; |
| 470 | default: |
| 471 | pll = BCMA_CC_PMU4716_MAINPLL_PLL0; |
| 472 | break; |
| 473 | } |
| 474 | |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 475 | return bcma_pmu_pll_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU); |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 476 | } |
| 477 | |
Rafał Miłecki | 5b5ac41 | 2012-12-07 12:56:56 +0100 | [diff] [blame] | 478 | /* On old PMUs CPU has the same clock as the bus */ |
| 479 | return bcma_pmu_get_bus_clock(cc); |
Hauke Mehrtens | 908debc | 2011-07-23 01:20:11 +0200 | [diff] [blame] | 480 | } |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 481 | |
| 482 | static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset, |
| 483 | u32 value) |
| 484 | { |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 485 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, offset); |
| 486 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_DATA, value); |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid) |
| 490 | { |
| 491 | u32 tmp = 0; |
| 492 | u8 phypll_offset = 0; |
| 493 | u8 bcm5357_bcm43236_p1div[] = {0x1, 0x5, 0x5}; |
| 494 | u8 bcm5357_bcm43236_ndiv[] = {0x30, 0xf6, 0xfc}; |
| 495 | struct bcma_bus *bus = cc->core->bus; |
| 496 | |
| 497 | switch (bus->chipinfo.id) { |
| 498 | case BCMA_CHIP_ID_BCM5357: |
| 499 | case BCMA_CHIP_ID_BCM4749: |
| 500 | case BCMA_CHIP_ID_BCM53572: |
| 501 | /* 5357[ab]0, 43236[ab]0, and 6362b0 */ |
| 502 | |
| 503 | /* BCM5357 needs to touch PLL1_PLLCTL[02], |
| 504 | so offset PLL0_PLLCTL[02] by 6 */ |
| 505 | phypll_offset = (bus->chipinfo.id == BCMA_CHIP_ID_BCM5357 || |
| 506 | bus->chipinfo.id == BCMA_CHIP_ID_BCM4749 || |
| 507 | bus->chipinfo.id == BCMA_CHIP_ID_BCM53572) ? 6 : 0; |
| 508 | |
| 509 | /* RMW only the P1 divider */ |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 510 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 511 | BCMA_CC_PMU_PLL_CTL0 + phypll_offset); |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 512 | tmp = bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_DATA); |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 513 | tmp &= (~(BCMA_CC_PMU1_PLL0_PC0_P1DIV_MASK)); |
| 514 | tmp |= (bcm5357_bcm43236_p1div[spuravoid] << BCMA_CC_PMU1_PLL0_PC0_P1DIV_SHIFT); |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 515 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_DATA, tmp); |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 516 | |
| 517 | /* RMW only the int feedback divider */ |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 518 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_ADDR, |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 519 | BCMA_CC_PMU_PLL_CTL2 + phypll_offset); |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 520 | tmp = bcma_pmu_read32(cc, BCMA_CC_PMU_PLLCTL_DATA); |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 521 | tmp &= ~(BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_MASK); |
| 522 | tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT; |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 523 | bcma_pmu_write32(cc, BCMA_CC_PMU_PLLCTL_DATA, tmp); |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 524 | |
Hauke Mehrtens | e3f2ae1 | 2013-03-27 17:23:09 +0100 | [diff] [blame] | 525 | tmp = BCMA_CC_PMU_CTL_PLL_UPD; |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 526 | break; |
| 527 | |
| 528 | case BCMA_CHIP_ID_BCM4331: |
| 529 | case BCMA_CHIP_ID_BCM43431: |
| 530 | if (spuravoid == 2) { |
| 531 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 532 | 0x11500014); |
| 533 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 534 | 0x0FC00a08); |
| 535 | } else if (spuravoid == 1) { |
| 536 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 537 | 0x11500014); |
| 538 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 539 | 0x0F600a08); |
| 540 | } else { |
| 541 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 542 | 0x11100014); |
| 543 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 544 | 0x03000a08); |
| 545 | } |
Hauke Mehrtens | e3f2ae1 | 2013-03-27 17:23:09 +0100 | [diff] [blame] | 546 | tmp = BCMA_CC_PMU_CTL_PLL_UPD; |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 547 | break; |
| 548 | |
| 549 | case BCMA_CHIP_ID_BCM43224: |
| 550 | case BCMA_CHIP_ID_BCM43225: |
| 551 | case BCMA_CHIP_ID_BCM43421: |
| 552 | if (spuravoid == 1) { |
| 553 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 554 | 0x11500010); |
| 555 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1, |
| 556 | 0x000C0C06); |
| 557 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 558 | 0x0F600a08); |
| 559 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3, |
| 560 | 0x00000000); |
| 561 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4, |
| 562 | 0x2001E920); |
| 563 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5, |
| 564 | 0x88888815); |
| 565 | } else { |
| 566 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 567 | 0x11100010); |
| 568 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1, |
| 569 | 0x000c0c06); |
| 570 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 571 | 0x03000a08); |
| 572 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3, |
| 573 | 0x00000000); |
| 574 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4, |
| 575 | 0x200005c0); |
| 576 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5, |
| 577 | 0x88888815); |
| 578 | } |
Hauke Mehrtens | e3f2ae1 | 2013-03-27 17:23:09 +0100 | [diff] [blame] | 579 | tmp = BCMA_CC_PMU_CTL_PLL_UPD; |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 580 | break; |
| 581 | |
| 582 | case BCMA_CHIP_ID_BCM4716: |
| 583 | case BCMA_CHIP_ID_BCM4748: |
| 584 | case BCMA_CHIP_ID_BCM47162: |
| 585 | if (spuravoid == 1) { |
| 586 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 587 | 0x11500060); |
| 588 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1, |
| 589 | 0x080C0C06); |
| 590 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 591 | 0x0F600000); |
| 592 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3, |
| 593 | 0x00000000); |
| 594 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4, |
| 595 | 0x2001E924); |
| 596 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5, |
| 597 | 0x88888815); |
| 598 | } else { |
| 599 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 600 | 0x11100060); |
| 601 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1, |
| 602 | 0x080c0c06); |
| 603 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 604 | 0x03000000); |
| 605 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3, |
| 606 | 0x00000000); |
| 607 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4, |
| 608 | 0x200005c0); |
| 609 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5, |
| 610 | 0x88888815); |
| 611 | } |
| 612 | |
Hauke Mehrtens | e3f2ae1 | 2013-03-27 17:23:09 +0100 | [diff] [blame] | 613 | tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW; |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 614 | break; |
| 615 | |
Rafał Miłecki | 27cfdb0 | 2014-07-24 15:29:19 +0200 | [diff] [blame] | 616 | case BCMA_CHIP_ID_BCM43131: |
Rafał Miłecki | d1d3799 | 2014-07-15 19:44:28 +0200 | [diff] [blame] | 617 | case BCMA_CHIP_ID_BCM43217: |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 618 | case BCMA_CHIP_ID_BCM43227: |
| 619 | case BCMA_CHIP_ID_BCM43228: |
| 620 | case BCMA_CHIP_ID_BCM43428: |
| 621 | /* LCNXN */ |
| 622 | /* PLL Settings for spur avoidance on/off mode, |
| 623 | no on2 support for 43228A0 */ |
| 624 | if (spuravoid == 1) { |
| 625 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 626 | 0x01100014); |
| 627 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1, |
| 628 | 0x040C0C06); |
| 629 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 630 | 0x03140A08); |
| 631 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3, |
| 632 | 0x00333333); |
| 633 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4, |
| 634 | 0x202C2820); |
| 635 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5, |
| 636 | 0x88888815); |
| 637 | } else { |
| 638 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL0, |
| 639 | 0x11100014); |
| 640 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL1, |
| 641 | 0x040c0c06); |
| 642 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2, |
| 643 | 0x03000a08); |
| 644 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL3, |
| 645 | 0x00000000); |
| 646 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL4, |
| 647 | 0x200005c0); |
| 648 | bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5, |
| 649 | 0x88888815); |
| 650 | } |
Hauke Mehrtens | e3f2ae1 | 2013-03-27 17:23:09 +0100 | [diff] [blame] | 651 | tmp = BCMA_CC_PMU_CTL_PLL_UPD; |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 652 | break; |
| 653 | default: |
Rafał Miłecki | 3d9d8af | 2012-07-05 22:07:32 +0200 | [diff] [blame] | 654 | bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n", |
| 655 | bus->chipinfo.id); |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 656 | break; |
| 657 | } |
| 658 | |
Rafał Miłecki | b3c47af | 2016-01-19 08:45:26 +0100 | [diff] [blame] | 659 | tmp |= bcma_pmu_read32(cc, BCMA_CC_PMU_CTL); |
| 660 | bcma_pmu_write32(cc, BCMA_CC_PMU_CTL, tmp); |
Hauke Mehrtens | c586e10 | 2012-06-30 01:44:44 +0200 | [diff] [blame] | 661 | } |
| 662 | EXPORT_SYMBOL_GPL(bcma_pmu_spuravoid_pllupdate); |