diff options
author | David S. Miller <davem@davemloft.net> | 2008-09-10 07:13:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-11 02:14:46 -0400 |
commit | 87395fc6781ff269bad7f972b8abf2312a8ccdf6 (patch) | |
tree | 8b47f5a0b948cb3aac1f19f1d63d90e9be478909 /arch/sparc64/kernel/pci_fire.c | |
parent | e6e003720fd7123482f77dcec19e930d272937fe (diff) |
sparc64: Kill hand-crafted I/O accessors in PCI controller drivers.
Use existing upa_{read,write}q() interfaces instead.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci_fire.c')
-rw-r--r-- | arch/sparc64/kernel/pci_fire.c | 136 |
1 files changed, 57 insertions, 79 deletions
diff --git a/arch/sparc64/kernel/pci_fire.c b/arch/sparc64/kernel/pci_fire.c index 7e1a9b6717b5..9462b68f4894 100644 --- a/arch/sparc64/kernel/pci_fire.c +++ b/arch/sparc64/kernel/pci_fire.c | |||
@@ -12,27 +12,13 @@ | |||
12 | 12 | ||
13 | #include <asm/prom.h> | 13 | #include <asm/prom.h> |
14 | #include <asm/irq.h> | 14 | #include <asm/irq.h> |
15 | #include <asm/upa.h> | ||
15 | 16 | ||
16 | #include "pci_impl.h" | 17 | #include "pci_impl.h" |
17 | 18 | ||
18 | #define DRIVER_NAME "fire" | 19 | #define DRIVER_NAME "fire" |
19 | #define PFX DRIVER_NAME ": " | 20 | #define PFX DRIVER_NAME ": " |
20 | 21 | ||
21 | #define fire_read(__reg) \ | ||
22 | ({ u64 __ret; \ | ||
23 | __asm__ __volatile__("ldxa [%1] %2, %0" \ | ||
24 | : "=r" (__ret) \ | ||
25 | : "r" (__reg), "i" (ASI_PHYS_BYPASS_EC_E) \ | ||
26 | : "memory"); \ | ||
27 | __ret; \ | ||
28 | }) | ||
29 | #define fire_write(__reg, __val) \ | ||
30 | __asm__ __volatile__("stxa %0, [%1] %2" \ | ||
31 | : /* no outputs */ \ | ||
32 | : "r" (__val), "r" (__reg), \ | ||
33 | "i" (ASI_PHYS_BYPASS_EC_E) \ | ||
34 | : "memory") | ||
35 | |||
36 | #define FIRE_IOMMU_CONTROL 0x40000UL | 22 | #define FIRE_IOMMU_CONTROL 0x40000UL |
37 | #define FIRE_IOMMU_TSBBASE 0x40008UL | 23 | #define FIRE_IOMMU_TSBBASE 0x40008UL |
38 | #define FIRE_IOMMU_FLUSH 0x40100UL | 24 | #define FIRE_IOMMU_FLUSH 0x40100UL |
@@ -65,21 +51,21 @@ static int pci_fire_pbm_iommu_init(struct pci_pbm_info *pbm) | |||
65 | /* | 51 | /* |
66 | * Invalidate TLB Entries. | 52 | * Invalidate TLB Entries. |
67 | */ | 53 | */ |
68 | fire_write(iommu->iommu_flushinv, ~(u64)0); | 54 | upa_writeq(~(u64)0, iommu->iommu_flushinv); |
69 | 55 | ||
70 | err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask, | 56 | err = iommu_table_init(iommu, tsbsize * 8 * 1024, vdma[0], dma_mask, |
71 | pbm->numa_node); | 57 | pbm->numa_node); |
72 | if (err) | 58 | if (err) |
73 | return err; | 59 | return err; |
74 | 60 | ||
75 | fire_write(iommu->iommu_tsbbase, __pa(iommu->page_table) | 0x7UL); | 61 | upa_writeq(__pa(iommu->page_table) | 0x7UL, iommu->iommu_tsbbase); |
76 | 62 | ||
77 | control = fire_read(iommu->iommu_control); | 63 | control = upa_readq(iommu->iommu_control); |
78 | control |= (0x00000400 /* TSB cache snoop enable */ | | 64 | control |= (0x00000400 /* TSB cache snoop enable */ | |
79 | 0x00000300 /* Cache mode */ | | 65 | 0x00000300 /* Cache mode */ | |
80 | 0x00000002 /* Bypass enable */ | | 66 | 0x00000002 /* Bypass enable */ | |
81 | 0x00000001 /* Translation enable */); | 67 | 0x00000001 /* Translation enable */); |
82 | fire_write(iommu->iommu_control, control); | 68 | upa_writeq(control, iommu->iommu_control); |
83 | 69 | ||
84 | return 0; | 70 | return 0; |
85 | } | 71 | } |
@@ -161,7 +147,7 @@ struct pci_msiq_entry { | |||
161 | static int pci_fire_get_head(struct pci_pbm_info *pbm, unsigned long msiqid, | 147 | static int pci_fire_get_head(struct pci_pbm_info *pbm, unsigned long msiqid, |
162 | unsigned long *head) | 148 | unsigned long *head) |
163 | { | 149 | { |
164 | *head = fire_read(pbm->pbm_regs + EVENT_QUEUE_HEAD(msiqid)); | 150 | *head = upa_readq(pbm->pbm_regs + EVENT_QUEUE_HEAD(msiqid)); |
165 | return 0; | 151 | return 0; |
166 | } | 152 | } |
167 | 153 | ||
@@ -187,8 +173,7 @@ static int pci_fire_dequeue_msi(struct pci_pbm_info *pbm, unsigned long msiqid, | |||
187 | *msi = msi_num = ((ep->word0 & MSIQ_WORD0_DATA0) >> | 173 | *msi = msi_num = ((ep->word0 & MSIQ_WORD0_DATA0) >> |
188 | MSIQ_WORD0_DATA0_SHIFT); | 174 | MSIQ_WORD0_DATA0_SHIFT); |
189 | 175 | ||
190 | fire_write(pbm->pbm_regs + MSI_CLEAR(msi_num), | 176 | upa_writeq(MSI_CLEAR_EQWR_N, pbm->pbm_regs + MSI_CLEAR(msi_num)); |
191 | MSI_CLEAR_EQWR_N); | ||
192 | 177 | ||
193 | /* Clear the entry. */ | 178 | /* Clear the entry. */ |
194 | ep->word0 &= ~MSIQ_WORD0_FMT_TYPE; | 179 | ep->word0 &= ~MSIQ_WORD0_FMT_TYPE; |
@@ -204,7 +189,7 @@ static int pci_fire_dequeue_msi(struct pci_pbm_info *pbm, unsigned long msiqid, | |||
204 | static int pci_fire_set_head(struct pci_pbm_info *pbm, unsigned long msiqid, | 189 | static int pci_fire_set_head(struct pci_pbm_info *pbm, unsigned long msiqid, |
205 | unsigned long head) | 190 | unsigned long head) |
206 | { | 191 | { |
207 | fire_write(pbm->pbm_regs + EVENT_QUEUE_HEAD(msiqid), head); | 192 | upa_writeq(head, pbm->pbm_regs + EVENT_QUEUE_HEAD(msiqid)); |
208 | return 0; | 193 | return 0; |
209 | } | 194 | } |
210 | 195 | ||
@@ -213,17 +198,16 @@ static int pci_fire_msi_setup(struct pci_pbm_info *pbm, unsigned long msiqid, | |||
213 | { | 198 | { |
214 | u64 val; | 199 | u64 val; |
215 | 200 | ||
216 | val = fire_read(pbm->pbm_regs + MSI_MAP(msi)); | 201 | val = upa_readq(pbm->pbm_regs + MSI_MAP(msi)); |
217 | val &= ~(MSI_MAP_EQNUM); | 202 | val &= ~(MSI_MAP_EQNUM); |
218 | val |= msiqid; | 203 | val |= msiqid; |
219 | fire_write(pbm->pbm_regs + MSI_MAP(msi), val); | 204 | upa_writeq(val, pbm->pbm_regs + MSI_MAP(msi)); |
220 | 205 | ||
221 | fire_write(pbm->pbm_regs + MSI_CLEAR(msi), | 206 | upa_writeq(MSI_CLEAR_EQWR_N, pbm->pbm_regs + MSI_CLEAR(msi)); |
222 | MSI_CLEAR_EQWR_N); | ||
223 | 207 | ||
224 | val = fire_read(pbm->pbm_regs + MSI_MAP(msi)); | 208 | val = upa_readq(pbm->pbm_regs + MSI_MAP(msi)); |
225 | val |= MSI_MAP_VALID; | 209 | val |= MSI_MAP_VALID; |
226 | fire_write(pbm->pbm_regs + MSI_MAP(msi), val); | 210 | upa_writeq(val, pbm->pbm_regs + MSI_MAP(msi)); |
227 | 211 | ||
228 | return 0; | 212 | return 0; |
229 | } | 213 | } |
@@ -233,12 +217,12 @@ static int pci_fire_msi_teardown(struct pci_pbm_info *pbm, unsigned long msi) | |||
233 | unsigned long msiqid; | 217 | unsigned long msiqid; |
234 | u64 val; | 218 | u64 val; |
235 | 219 | ||
236 | val = fire_read(pbm->pbm_regs + MSI_MAP(msi)); | 220 | val = upa_readq(pbm->pbm_regs + MSI_MAP(msi)); |
237 | msiqid = (val & MSI_MAP_EQNUM); | 221 | msiqid = (val & MSI_MAP_EQNUM); |
238 | 222 | ||
239 | val &= ~MSI_MAP_VALID; | 223 | val &= ~MSI_MAP_VALID; |
240 | 224 | ||
241 | fire_write(pbm->pbm_regs + MSI_MAP(msi), val); | 225 | upa_writeq(val, pbm->pbm_regs + MSI_MAP(msi)); |
242 | 226 | ||
243 | return 0; | 227 | return 0; |
244 | } | 228 | } |
@@ -257,22 +241,19 @@ static int pci_fire_msiq_alloc(struct pci_pbm_info *pbm) | |||
257 | memset((char *)pages, 0, PAGE_SIZE << order); | 241 | memset((char *)pages, 0, PAGE_SIZE << order); |
258 | pbm->msi_queues = (void *) pages; | 242 | pbm->msi_queues = (void *) pages; |
259 | 243 | ||
260 | fire_write(pbm->pbm_regs + EVENT_QUEUE_BASE_ADDR_REG, | 244 | upa_writeq((EVENT_QUEUE_BASE_ADDR_ALL_ONES | |
261 | (EVENT_QUEUE_BASE_ADDR_ALL_ONES | | 245 | __pa(pbm->msi_queues)), |
262 | __pa(pbm->msi_queues))); | 246 | pbm->pbm_regs + EVENT_QUEUE_BASE_ADDR_REG); |
263 | 247 | ||
264 | fire_write(pbm->pbm_regs + IMONDO_DATA0, | 248 | upa_writeq(pbm->portid << 6, pbm->pbm_regs + IMONDO_DATA0); |
265 | pbm->portid << 6); | 249 | upa_writeq(0, pbm->pbm_regs + IMONDO_DATA1); |
266 | fire_write(pbm->pbm_regs + IMONDO_DATA1, 0); | ||
267 | 250 | ||
268 | fire_write(pbm->pbm_regs + MSI_32BIT_ADDR, | 251 | upa_writeq(pbm->msi32_start, pbm->pbm_regs + MSI_32BIT_ADDR); |
269 | pbm->msi32_start); | 252 | upa_writeq(pbm->msi64_start, pbm->pbm_regs + MSI_64BIT_ADDR); |
270 | fire_write(pbm->pbm_regs + MSI_64BIT_ADDR, | ||
271 | pbm->msi64_start); | ||
272 | 253 | ||
273 | for (i = 0; i < pbm->msiq_num; i++) { | 254 | for (i = 0; i < pbm->msiq_num; i++) { |
274 | fire_write(pbm->pbm_regs + EVENT_QUEUE_HEAD(i), 0); | 255 | upa_writeq(0, pbm->pbm_regs + EVENT_QUEUE_HEAD(i)); |
275 | fire_write(pbm->pbm_regs + EVENT_QUEUE_TAIL(i), 0); | 256 | upa_writeq(0, pbm->pbm_regs + EVENT_QUEUE_TAIL(i)); |
276 | } | 257 | } |
277 | 258 | ||
278 | return 0; | 259 | return 0; |
@@ -306,9 +287,9 @@ static int pci_fire_msiq_build_irq(struct pci_pbm_info *pbm, | |||
306 | /* XXX iterate amongst the 4 IRQ controllers XXX */ | 287 | /* XXX iterate amongst the 4 IRQ controllers XXX */ |
307 | int_ctrlr = (1UL << 6); | 288 | int_ctrlr = (1UL << 6); |
308 | 289 | ||
309 | val = fire_read(imap_reg); | 290 | val = upa_readq(imap_reg); |
310 | val |= (1UL << 63) | int_ctrlr; | 291 | val |= (1UL << 63) | int_ctrlr; |
311 | fire_write(imap_reg, val); | 292 | upa_writeq(val, imap_reg); |
312 | 293 | ||
313 | fixup = ((pbm->portid << 6) | devino) - int_ctrlr; | 294 | fixup = ((pbm->portid << 6) | devino) - int_ctrlr; |
314 | 295 | ||
@@ -316,9 +297,8 @@ static int pci_fire_msiq_build_irq(struct pci_pbm_info *pbm, | |||
316 | if (!virt_irq) | 297 | if (!virt_irq) |
317 | return -ENOMEM; | 298 | return -ENOMEM; |
318 | 299 | ||
319 | fire_write(pbm->pbm_regs + | 300 | upa_writeq(EVENT_QUEUE_CONTROL_SET_EN, |
320 | EVENT_QUEUE_CONTROL_SET(msiqid), | 301 | pbm->pbm_regs + EVENT_QUEUE_CONTROL_SET(msiqid)); |
321 | EVENT_QUEUE_CONTROL_SET_EN); | ||
322 | 302 | ||
323 | return virt_irq; | 303 | return virt_irq; |
324 | } | 304 | } |
@@ -386,49 +366,47 @@ static void pci_fire_hw_init(struct pci_pbm_info *pbm) | |||
386 | { | 366 | { |
387 | u64 val; | 367 | u64 val; |
388 | 368 | ||
389 | fire_write(pbm->controller_regs + FIRE_PARITY_CONTROL, | 369 | upa_writeq(FIRE_PARITY_ENAB, |
390 | FIRE_PARITY_ENAB); | 370 | pbm->controller_regs + FIRE_PARITY_CONTROL); |
391 | 371 | ||
392 | fire_write(pbm->controller_regs + FIRE_FATAL_RESET_CTL, | 372 | upa_writeq((FIRE_FATAL_RESET_SPARE | |
393 | (FIRE_FATAL_RESET_SPARE | | ||
394 | FIRE_FATAL_RESET_MB | | 373 | FIRE_FATAL_RESET_MB | |
395 | FIRE_FATAL_RESET_CPE | | 374 | FIRE_FATAL_RESET_CPE | |
396 | FIRE_FATAL_RESET_APE | | 375 | FIRE_FATAL_RESET_APE | |
397 | FIRE_FATAL_RESET_PIO | | 376 | FIRE_FATAL_RESET_PIO | |
398 | FIRE_FATAL_RESET_JW | | 377 | FIRE_FATAL_RESET_JW | |
399 | FIRE_FATAL_RESET_JI | | 378 | FIRE_FATAL_RESET_JI | |
400 | FIRE_FATAL_RESET_JR)); | 379 | FIRE_FATAL_RESET_JR), |
380 | pbm->controller_regs + FIRE_FATAL_RESET_CTL); | ||
401 | 381 | ||
402 | fire_write(pbm->controller_regs + FIRE_CORE_INTR_ENABLE, ~(u64)0); | 382 | upa_writeq(~(u64)0, pbm->controller_regs + FIRE_CORE_INTR_ENABLE); |
403 | 383 | ||
404 | val = fire_read(pbm->pbm_regs + FIRE_TLU_CTRL); | 384 | val = upa_readq(pbm->pbm_regs + FIRE_TLU_CTRL); |
405 | val |= (FIRE_TLU_CTRL_TIM | | 385 | val |= (FIRE_TLU_CTRL_TIM | |
406 | FIRE_TLU_CTRL_QDET | | 386 | FIRE_TLU_CTRL_QDET | |
407 | FIRE_TLU_CTRL_CFG); | 387 | FIRE_TLU_CTRL_CFG); |
408 | fire_write(pbm->pbm_regs + FIRE_TLU_CTRL, val); | 388 | upa_writeq(val, pbm->pbm_regs + FIRE_TLU_CTRL); |
409 | fire_write(pbm->pbm_regs + FIRE_TLU_DEV_CTRL, 0); | 389 | upa_writeq(0, pbm->pbm_regs + FIRE_TLU_DEV_CTRL); |
410 | fire_write(pbm->pbm_regs + FIRE_TLU_LINK_CTRL, | 390 | upa_writeq(FIRE_TLU_LINK_CTRL_CLK, |
411 | FIRE_TLU_LINK_CTRL_CLK); | 391 | pbm->pbm_regs + FIRE_TLU_LINK_CTRL); |
412 | 392 | ||
413 | fire_write(pbm->pbm_regs + FIRE_LPU_RESET, 0); | 393 | upa_writeq(0, pbm->pbm_regs + FIRE_LPU_RESET); |
414 | fire_write(pbm->pbm_regs + FIRE_LPU_LLCFG, | 394 | upa_writeq(FIRE_LPU_LLCFG_VC0, pbm->pbm_regs + FIRE_LPU_LLCFG); |
415 | FIRE_LPU_LLCFG_VC0); | 395 | upa_writeq((FIRE_LPU_FCTRL_UCTRL_N | FIRE_LPU_FCTRL_UCTRL_P), |
416 | fire_write(pbm->pbm_regs + FIRE_LPU_FCTRL_UCTRL, | 396 | pbm->pbm_regs + FIRE_LPU_FCTRL_UCTRL); |
417 | (FIRE_LPU_FCTRL_UCTRL_N | | 397 | upa_writeq(((0xffff << 16) | (0x0000 << 0)), |
418 | FIRE_LPU_FCTRL_UCTRL_P)); | 398 | pbm->pbm_regs + FIRE_LPU_TXL_FIFOP); |
419 | fire_write(pbm->pbm_regs + FIRE_LPU_TXL_FIFOP, | 399 | upa_writeq(3000000, pbm->pbm_regs + FIRE_LPU_LTSSM_CFG2); |
420 | ((0xffff << 16) | (0x0000 << 0))); | 400 | upa_writeq(500000, pbm->pbm_regs + FIRE_LPU_LTSSM_CFG3); |
421 | fire_write(pbm->pbm_regs + FIRE_LPU_LTSSM_CFG2, 3000000); | 401 | upa_writeq((2 << 16) | (140 << 8), |
422 | fire_write(pbm->pbm_regs + FIRE_LPU_LTSSM_CFG3, 500000); | 402 | pbm->pbm_regs + FIRE_LPU_LTSSM_CFG4); |
423 | fire_write(pbm->pbm_regs + FIRE_LPU_LTSSM_CFG4, | 403 | upa_writeq(0, pbm->pbm_regs + FIRE_LPU_LTSSM_CFG5); |
424 | (2 << 16) | (140 << 8)); | 404 | |
425 | fire_write(pbm->pbm_regs + FIRE_LPU_LTSSM_CFG5, 0); | 405 | upa_writeq(~(u64)0, pbm->pbm_regs + FIRE_DMC_IENAB); |
426 | 406 | upa_writeq(0, pbm->pbm_regs + FIRE_DMC_DBG_SEL_A); | |
427 | fire_write(pbm->pbm_regs + FIRE_DMC_IENAB, ~(u64)0); | 407 | upa_writeq(0, pbm->pbm_regs + FIRE_DMC_DBG_SEL_B); |
428 | fire_write(pbm->pbm_regs + FIRE_DMC_DBG_SEL_A, 0); | 408 | |
429 | fire_write(pbm->pbm_regs + FIRE_DMC_DBG_SEL_B, 0); | 409 | upa_writeq(~(u64)0, pbm->pbm_regs + FIRE_PEC_IENAB); |
430 | |||
431 | fire_write(pbm->pbm_regs + FIRE_PEC_IENAB, ~(u64)0); | ||
432 | } | 410 | } |
433 | 411 | ||
434 | static int __init pci_fire_pbm_init(struct pci_pbm_info *pbm, | 412 | static int __init pci_fire_pbm_init(struct pci_pbm_info *pbm, |