diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2015-01-25 05:11:14 -0500 |
---|---|---|
committer | Kalle Valo <kvalo@codeaurora.org> | 2015-01-29 03:53:08 -0500 |
commit | b504075f5903b969a54ef3a6ae994c0872edb259 (patch) | |
tree | c3026773a3f9dead1b204b0a6858394cdcd9776e /drivers/bcma | |
parent | ae8ce289e55e6f9911016f73ac85dcb2e0c0c9c1 (diff) |
bcma: add early_init function for PCIe core and move some fix into it
There are some PCIe core fixes that need to be applied before accessing
SPROM, otherwise reading it may fail.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/bcma')
-rw-r--r-- | drivers/bcma/driver_pci.c | 66 | ||||
-rw-r--r-- | drivers/bcma/main.c | 7 |
2 files changed, 51 insertions, 22 deletions
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c index b85a505603e6..786666488a2d 100644 --- a/drivers/bcma/driver_pci.c +++ b/drivers/bcma/driver_pci.c | |||
@@ -145,6 +145,47 @@ static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device, | |||
145 | } | 145 | } |
146 | 146 | ||
147 | /************************************************** | 147 | /************************************************** |
148 | * Early init. | ||
149 | **************************************************/ | ||
150 | |||
151 | static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc) | ||
152 | { | ||
153 | struct bcma_device *core = pc->core; | ||
154 | u16 val16, core_index; | ||
155 | uint regoff; | ||
156 | |||
157 | regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET); | ||
158 | core_index = (u16)core->core_index; | ||
159 | |||
160 | val16 = pcicore_read16(pc, regoff); | ||
161 | if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT) | ||
162 | != core_index) { | ||
163 | val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) | | ||
164 | (val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK); | ||
165 | pcicore_write16(pc, regoff, val16); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | /* | ||
170 | * Apply some early fixes required before accessing SPROM. | ||
171 | * See also si_pci_fixcfg. | ||
172 | */ | ||
173 | void bcma_core_pci_early_init(struct bcma_drv_pci *pc) | ||
174 | { | ||
175 | if (pc->early_setup_done) | ||
176 | return; | ||
177 | |||
178 | pc->hostmode = bcma_core_pci_is_in_hostmode(pc); | ||
179 | if (pc->hostmode) | ||
180 | goto out; | ||
181 | |||
182 | bcma_core_pci_fixcfg(pc); | ||
183 | |||
184 | out: | ||
185 | pc->early_setup_done = true; | ||
186 | } | ||
187 | |||
188 | /************************************************** | ||
148 | * Workarounds. | 189 | * Workarounds. |
149 | **************************************************/ | 190 | **************************************************/ |
150 | 191 | ||
@@ -175,24 +216,6 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc) | |||
175 | tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN); | 216 | tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN); |
176 | } | 217 | } |
177 | 218 | ||
178 | static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc) | ||
179 | { | ||
180 | struct bcma_device *core = pc->core; | ||
181 | u16 val16, core_index; | ||
182 | uint regoff; | ||
183 | |||
184 | regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET); | ||
185 | core_index = (u16)core->core_index; | ||
186 | |||
187 | val16 = pcicore_read16(pc, regoff); | ||
188 | if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT) | ||
189 | != core_index) { | ||
190 | val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) | | ||
191 | (val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK); | ||
192 | pcicore_write16(pc, regoff, val16); | ||
193 | } | ||
194 | } | ||
195 | |||
196 | /* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */ | 219 | /* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */ |
197 | /* Needs to happen when coming out of 'standby'/'hibernate' */ | 220 | /* Needs to happen when coming out of 'standby'/'hibernate' */ |
198 | static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc) | 221 | static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc) |
@@ -216,7 +239,6 @@ static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc) | |||
216 | 239 | ||
217 | static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc) | 240 | static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc) |
218 | { | 241 | { |
219 | bcma_core_pci_fixcfg(pc); | ||
220 | bcma_pcicore_serdes_workaround(pc); | 242 | bcma_pcicore_serdes_workaround(pc); |
221 | bcma_core_pci_config_fixup(pc); | 243 | bcma_core_pci_config_fixup(pc); |
222 | } | 244 | } |
@@ -226,11 +248,11 @@ void bcma_core_pci_init(struct bcma_drv_pci *pc) | |||
226 | if (pc->setup_done) | 248 | if (pc->setup_done) |
227 | return; | 249 | return; |
228 | 250 | ||
229 | pc->hostmode = bcma_core_pci_is_in_hostmode(pc); | 251 | bcma_core_pci_early_init(pc); |
252 | |||
230 | if (pc->hostmode) | 253 | if (pc->hostmode) |
231 | bcma_core_pci_hostmode_init(pc); | 254 | bcma_core_pci_hostmode_init(pc); |
232 | 255 | else | |
233 | if (!pc->hostmode) | ||
234 | bcma_core_pci_clientmode_init(pc); | 256 | bcma_core_pci_clientmode_init(pc); |
235 | } | 257 | } |
236 | 258 | ||
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index 73b2ee3de972..38bde6eab8a4 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c | |||
@@ -402,6 +402,13 @@ int bcma_bus_register(struct bcma_bus *bus) | |||
402 | bcma_core_chipcommon_early_init(&bus->drv_cc); | 402 | bcma_core_chipcommon_early_init(&bus->drv_cc); |
403 | } | 403 | } |
404 | 404 | ||
405 | /* Early init PCIE core */ | ||
406 | core = bcma_find_core(bus, BCMA_CORE_PCIE); | ||
407 | if (core) { | ||
408 | bus->drv_pci[0].core = core; | ||
409 | bcma_core_pci_early_init(&bus->drv_pci[0]); | ||
410 | } | ||
411 | |||
405 | /* Cores providing flash access go before SPROM init */ | 412 | /* Cores providing flash access go before SPROM init */ |
406 | list_for_each_entry(core, &bus->cores, list) { | 413 | list_for_each_entry(core, &bus->cores, list) { |
407 | if (bcma_is_core_needed_early(core->id.id)) | 414 | if (bcma_is_core_needed_early(core->id.id)) |