2 * arch/ppc/kernel/gt64260_common.c
4 * Common routines for the Marvell/Galileo GT64260 (Discovery) host bridge,
5 * interrupt controller, memory controller, serial controller, enet controller,
8 * Author: Mark A. Greer <mgreer@mvista.com>
10 * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
11 * the terms of the GNU General Public License version 2.1. This program
12 * is licensed "as is" without any warranty of any kind, whether express
17 * The GT64260 port is the result of hard work from many people from
18 * many companies. In particular, employees of Marvell/Galileo, Mission
19 * Critical Linux, Xyterra, Zuma Networks, and MontaVista Software were
24 * At last count, the 64260-B-0 has 65 errata and 24 restrictions. The odds of
25 * you getting it to work well, under stress, for a long period of time are
26 * low. If nothing else, you will likely run into an interrupt controller
29 * The newer 64260A-B-0 is much improved but has its own problems.
30 * Dave Wilhardt <dwilhardt@zyterra.com> has discovered that you must set
31 * up your PCI snoop regions to be prefetchable with 4-word bursts AND set the
32 * "Memory Write and Invalidate bit" (bit 4) in the cmd reg of each PCI device
33 * before coherency works between PCI and other devices. Many thanks to Dave.
35 * There is now a 64260B-B-0 but I have not yet had one to test so I don't
36 * know if it will work--MAG.
38 #include <linux/kernel.h>
39 #include <linux/init.h>
40 #include <linux/pci.h>
41 #include <linux/slab.h>
42 #include <linux/module.h>
44 #include <asm/byteorder.h>
47 #include <asm/uaccess.h>
48 #include <asm/machdep.h>
49 #include <asm/pci-bridge.h>
50 #include <asm/gt64260.h>
51 #include <asm/delay.h>
55 u32 gt64260_revision; /* Revision of the chip */
56 u8 gt64260_pci_exclude_bridge = TRUE;
58 spinlock_t gt64260_lock = SPIN_LOCK_UNLOCKED;
59 spinlock_t gt64260_rmw_lock = SPIN_LOCK_UNLOCKED;
62 *****************************************************************************
64 * Bridge Initialization Routines
66 *****************************************************************************
68 static void gt64260_check_errata(struct pci_controller *hose_a,
69 struct pci_controller *hose_b);
70 static void __init gt64260_setup_mem_windows(gt64260_bridge_info_t *info);
73 * Typical '_find_bridges()' routine for boards with a GT64260 bridge.
75 * Assumes that gt64260_base the virtual base address of the bridge's registers.
78 gt64260_find_bridges(gt64260_bridge_info_t *info,
79 int ((*map_irq)(struct pci_dev *, unsigned char, unsigned char)))
81 struct pci_controller *hose_a, *hose_b;
82 u32 io_base_a, io_base_b, val;
86 hose_a = info->hose_a;
87 hose_b = info->hose_b;
89 if ((hose_a == (struct pci_controller *)NULL) &&
90 (hose_b == (struct pci_controller *)NULL)) {
93 ppc_md.progress("gt64260_find_bridges: no hoses", 0x0);
95 printk("gt64260_find_bridges: No PCI hoses\n");
100 * Map in PCI I/O region.
101 * ioremap() typically grows down. Try to put io_base_a lower
102 * than io_base_b so allocate hose_b's PCI io space first.
104 if (hose_b != (struct pci_controller *)NULL) {
105 io_base_b = (u32)ioremap(info->pci_1_io_start_proc,
106 info->pci_1_io_size);
107 isa_io_base = io_base_b;
111 * We need to scan the PCI bus before doing the bridge init because
112 * we need the buses enumerated. This is okay because the only regs
113 * that are accessed during the scanning are the PCI config addr/data
114 * pair on the bridge and config registers on PCI devices (and the
115 * bridge's regs on the PCI bus will be excluded).
119 * Set up the PCI resources/hose structure and the scan the PCI buses
120 * under the first PCI hose.
122 if (hose_a != (struct pci_controller *)NULL) {
123 io_base_a = (u32)ioremap(info->pci_0_io_start_proc,
124 info->pci_0_io_size);
125 isa_io_base = io_base_a;
127 setup_indirect_pci(hose_a,
128 info->phys_base_addr + GT64260_PCI_0_CONFIG_ADDR,
129 info->phys_base_addr + GT64260_PCI_0_CONFIG_DATA);
131 pci_init_resource(&hose_a->io_resource,
132 io_base_a - isa_io_base,
133 io_base_a - isa_io_base + info->pci_0_io_size - 1,
135 "host bridge PCI bus 0");
136 hose_a->io_space.start = info->pci_0_io_start_pci;
137 hose_a->io_space.end = info->pci_0_io_start_pci +
138 info->pci_0_io_size - 1;
139 hose_a->io_base_virt = (void *)isa_io_base;
141 pci_init_resource(&hose_a->mem_resources[0],
142 info->pci_0_mem_start_proc,
143 info->pci_0_mem_start_proc + info->pci_0_mem_size - 1,
145 "host bridge PCI bus 0");
146 hose_a->mem_space.start = info->pci_0_mem_start_pci_lo;
147 hose_a->mem_space.end = info->pci_0_mem_start_pci_lo +
148 info->pci_0_mem_size - 1;
149 hose_a->pci_mem_offset = (info->pci_0_mem_start_proc -
150 info->pci_0_mem_start_pci_lo);
151 /* Can't walk PCI bus until bridge is initialized */
154 /* Now scan the second PCI hose */
155 if (hose_b != (struct pci_controller *)NULL) {
156 setup_indirect_pci(hose_b,
157 info->phys_base_addr + GT64260_PCI_1_CONFIG_ADDR,
158 info->phys_base_addr + GT64260_PCI_1_CONFIG_DATA);
160 pci_init_resource(&hose_b->io_resource,
161 io_base_b - isa_io_base,
162 io_base_b - isa_io_base + info->pci_1_io_size - 1,
164 "host bridge PCI bus 1");
165 hose_b->io_space.start = info->pci_1_io_start_pci;
166 hose_b->io_space.end = info->pci_1_io_start_pci +
167 info->pci_1_io_size - 1;
168 hose_b->io_base_virt = (void *)isa_io_base;
170 pci_init_resource(&hose_b->mem_resources[0],
171 info->pci_1_mem_start_proc,
172 info->pci_1_mem_start_proc + info->pci_1_mem_size - 1,
174 "host bridge PCI bus 1");
175 hose_b->mem_space.start = info->pci_1_mem_start_pci_lo;
176 hose_b->mem_space.end = info->pci_1_mem_start_pci_lo +
177 info->pci_1_mem_size - 1;
178 hose_b->pci_mem_offset = (info->pci_1_mem_start_proc -
179 info->pci_1_mem_start_pci_lo);
180 /* Can't walk PCI bus until bridge is initialized */
183 /* Now we can initialize the bridge for real */
184 if ((rc = gt64260_bridge_init(info)) != 0) {
185 if (hose_a != (struct pci_controller *)NULL) {
186 iounmap((void *)hose_a->cfg_addr);
187 iounmap((void *)hose_a->cfg_data);
190 if (hose_b != (struct pci_controller *)NULL) {
191 iounmap((void *)hose_b->cfg_addr);
192 iounmap((void *)hose_b->cfg_data);
198 pci_dram_offset = 0; /* System mem at same addr on PCI & cpu bus */
200 ppc_md.pci_exclude_device = gt64260_pci_exclude_device;
201 ppc_md.pci_swizzle = common_swizzle;
202 ppc_md.pci_map_irq = map_irq;
204 /* Now that the bridge is set up, its safe to scan the PCI buses */
205 if (hose_a != (struct pci_controller *)NULL) {
206 hose_a->first_busno = 0;
207 hose_a->last_busno = 0xff;
209 hose_a->last_busno = pciauto_bus_scan(hose_a,
210 hose_a->first_busno);
213 if (hose_b != (struct pci_controller *)NULL) {
214 hose_b->first_busno = 0;
215 hose_b->last_busno = 0xff;
217 if (hose_a != (struct pci_controller *)NULL) {
218 hose_b->first_busno = hose_a->last_busno + 1;
220 /* Set bus number for second hose */
221 val = gt_read(GT64260_PCI_1_P2P_CONFIG);
223 val |= ((hose_b->first_busno & 0xff) << 16);
224 gt_write(GT64260_PCI_1_P2P_CONFIG, val);
225 (void)gt_read(GT64260_PCI_1_P2P_CONFIG);/* Flush FIFO */
228 hose_b->last_busno = pciauto_bus_scan(hose_b,
229 hose_b->first_busno);
233 * Set up the CPU memory-related windows and the PCI BARs based on how
234 * the CPU SCS windows are set up. Although, not clearly documented,
235 * testing has shown that you need the PCI SCS windows to match the
238 gt64260_setup_mem_windows(info);
240 /* Check for errata and adjust accordingly */
241 gt64260_check_errata(info->hose_a, info->hose_b);
244 } /* gt64260_find_bridges() */
247 * gt64260_bridge_init()
249 * Perform bridge initialization for a "typical" setup for a PPC system.
252 gt64260_bridge_init(gt64260_bridge_info_t *info)
258 /* Bit 12 MUST be 0. */
259 gt_clr_bits(GT64260_CPU_CONFIG, (1<<12));
262 * Turn off timer/counters. Not turning off watchdog timer because
263 * can't read its reg on the 64260A so don't know if we'll be enabling
266 gt_clr_bits(GT64260_TIMR_CNTR_0_3_CNTL,
267 ((1<<0) | (1<<8) | (1<<16) | (1<<24)));
268 gt_clr_bits(GT64260_TIMR_CNTR_4_7_CNTL,
269 ((1<<0) | (1<<8) | (1<<16) | (1<<24)));
272 * Shut down CPU windows and PCI BAR's so there aren't any conflicts
273 * with the new windows we're about to set up.
275 * Note: Can't disable CPU SCS, snoop, and protection windows because
276 * we're [probably] running out of one of those windows.
278 gt64260_cpu_disable_windows();
279 gt64260_pci_bar_enable(0, 0); /* Disable BARs on PCI side of bridge */
280 gt64260_pci_bar_enable(1, 0);
283 * Set up various parts of the bridge including CPU->PCI windows.
284 * Depending on the board, there may be only one hose that needs to
287 if (info->hose_a != (struct pci_controller *)NULL) {
288 save_exclude = gt64260_pci_exclude_bridge;
289 gt64260_pci_exclude_bridge = FALSE;
291 /* Set class code to indicate host bridge */
292 early_read_config_dword(info->hose_a,
297 u32_val &= 0x000000ff;
298 gt64260_revision = u32_val; /* a 64260 or 64260A? */
299 u32_val |= (PCI_CLASS_BRIDGE_HOST << 16);
300 early_write_config_dword(info->hose_a,
305 /* Enable 64260 to be PCI master & respond to PCI MEM cycles */
306 early_read_config_word(info->hose_a,
311 u16_val |= (PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
312 early_write_config_word(info->hose_a,
318 /* Set latency timer, cache line size, clear BIST */
319 u32_val = (info->pci_0_latency<<8) | (L1_CACHE_LINE_SIZE>>2);
320 early_write_config_dword(info->hose_a,
326 gt64260_pci_exclude_bridge = save_exclude;
328 /* Set windows from CPU to PCI I/O and MEM space */
329 gt64260_cpu_set_pci_io_window(0,
330 info->pci_0_io_start_proc,
331 info->pci_0_io_start_pci,
333 info->pci_0_io_swap);
335 gt64260_cpu_set_pci_mem_window(0,
337 info->pci_0_mem_start_proc,
338 info->pci_0_mem_start_pci_hi,
339 info->pci_0_mem_start_pci_lo,
340 info->pci_0_mem_size,
341 info->pci_0_mem_swap);
344 if (info->hose_b != (struct pci_controller *)NULL) {
345 save_exclude = gt64260_pci_exclude_bridge;
346 gt64260_pci_exclude_bridge = FALSE;
348 /* Set class code to indicate host bridge */
349 early_read_config_dword(info->hose_b,
354 u32_val &= 0x000000ff;
355 gt64260_revision = u32_val; /* a 64260 or 64260A? */
356 u32_val |= (PCI_CLASS_BRIDGE_HOST << 16);
357 early_write_config_dword(info->hose_b,
363 /* Enable 64260 to be PCI master & respond to PCI MEM cycles */
364 early_read_config_word(info->hose_b,
369 u16_val |= (PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
370 early_write_config_word(info->hose_b,
376 /* Set latency timer, cache line size, clear BIST */
377 u32_val = (info->pci_1_latency<<8) | (L1_CACHE_LINE_SIZE>>2);
378 early_write_config_dword(info->hose_b,
384 gt64260_pci_exclude_bridge = save_exclude;
386 /* Set windows from CPU to PCI I/O and MEM space */
387 gt64260_cpu_set_pci_io_window(1,
388 info->pci_1_io_start_proc,
389 info->pci_1_io_start_pci,
391 info->pci_1_io_swap);
393 gt64260_cpu_set_pci_mem_window(1,
395 info->pci_1_mem_start_proc,
396 info->pci_1_mem_start_pci_hi,
397 info->pci_1_mem_start_pci_lo,
398 info->pci_1_mem_size,
399 info->pci_1_mem_swap);
403 } /* gt64260_bridge_init() */
406 * gt64260_setup_mem_windows()
408 * Set up all the CPU and PCI windows to match how the CPU SCS size windows
409 * are set up. Although this doesn't appear to be necessary according to the
410 * manual, it appears to be necessary from experience with the chip.
412 * This routine is the result of a patch from Uri Lublin <uri@sangate.com>.
415 gt64260_setup_mem_windows(gt64260_bridge_info_t *info)
417 u32 low, hi, size, window, enable_bits;
420 } scs_offset_table[GT64260_CPU_SCS_DECODE_WINDOWS] = {
421 {GT64260_CPU_SCS_DECODE_0_BOT, GT64260_CPU_SCS_DECODE_0_TOP},
422 {GT64260_CPU_SCS_DECODE_1_BOT, GT64260_CPU_SCS_DECODE_1_TOP},
423 {GT64260_CPU_SCS_DECODE_2_BOT, GT64260_CPU_SCS_DECODE_2_TOP},
424 {GT64260_CPU_SCS_DECODE_3_BOT, GT64260_CPU_SCS_DECODE_3_TOP}
428 * Assume that GT64260_CPU_SCS_DECODE_WINDOWS,
429 * GT64260_CPU_SNOOP_WINDOWS, GT64260_PCI_SCS_WINDOWS, and
430 * GT64260_PCI_SNOOP_WINDOWS are all the equal.
431 * Also assume that GT64260_CPU_PROT_WINDOWS >=
432 * GT64260_CPU_SCS_DECODE_WINDOWS and
433 * GT64260_PCI_ACC_CNTL_WINDOWS >= GT64260_PCI_SCS_WINDOWS.
436 #define SCS_ADDR(a) (((a) & 0x0fff) << 20)
439 for (window=0; window<GT64260_CPU_SCS_DECODE_WINDOWS; window++) {
440 low = gt_read(scs_offset_table[window].low);
441 hi = gt_read(scs_offset_table[window].hi);
446 size = (low <= hi) ? (hi - low + (SCS_ADDR(1))) : 0;
448 enable_bits |= (1 << window);
451 printk(__FUNCTION__ ": scs window: %d, %x (%x)\n",
454 gt64260_cpu_prot_set_window(window, low, size,
455 info->cpu_prot_options[window]);
456 gt64260_cpu_snoop_set_window(window, low, size,
457 info->cpu_snoop_options[window]);
459 if (info->hose_a != (struct pci_controller *)NULL) {
460 gt64260_pci_slave_scs_set_window(info->hose_a,
461 window, low, low, size);
462 gt64260_pci_acc_cntl_set_window(0, window, 0,
464 info->pci_0_acc_cntl_options[window]);
465 gt64260_pci_snoop_set_window(0, window, 0,
467 info->pci_0_snoop_options[window]);
469 if (info->hose_b != (struct pci_controller *)NULL) {
470 gt64260_pci_slave_scs_set_window(info->hose_b,
471 window, low, low, size);
472 gt64260_pci_acc_cntl_set_window(1, window, 0,
474 info->pci_1_acc_cntl_options[window]);
475 gt64260_pci_snoop_set_window(1, window, 0,
477 info->pci_1_snoop_options[window]);
482 if (info->hose_a != (struct pci_controller *)NULL) {
483 gt64260_pci_bar_enable(0, enable_bits);
486 if (info->hose_b != (struct pci_controller *)NULL) {
487 gt64260_pci_bar_enable(1, enable_bits);
494 * gt64260_check_errata()
496 * Apply applicable errata and restrictions from 0.5 of the
497 * Errata and Restrictions document from Marvell/Galileo.
500 gt64260_check_errata(struct pci_controller *hose_a,
501 struct pci_controller *hose_b)
506 /* Currently 2 versions, 64260 and 64260A */
507 if (gt64260_revision == GT64260) {
508 save_exclude = gt64260_pci_exclude_bridge;
509 gt64260_pci_exclude_bridge = FALSE;
511 if (hose_a != (struct pci_controller *)NULL) {
513 early_read_config_dword(hose_a,
518 val &= ~(PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY);
519 early_write_config_dword(hose_a,
525 gt_clr_bits(GT64260_PCI_0_CMD,
526 ((1<<4) | (1<<5) | (1<<9)));
528 gt_clr_bits(GT64260_PCI_0_CMD,
529 ((1<<4) | (1<<5) | (1<<9)));
531 gt_clr_bits(GT64260_PCI_0_CMD, (1<<13));
534 if (hose_b != (struct pci_controller *)NULL) {
535 early_read_config_dword(hose_b,
540 val &= ~(PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY);
541 early_write_config_dword(hose_b,
547 gt_clr_bits(GT64260_PCI_1_CMD,
548 ((1<<4) | (1<<5) | (1<<9)));
550 gt_clr_bits(GT64260_PCI_1_CMD,
551 ((1<<4) | (1<<5) | (1<<9)));
552 gt_clr_bits(GT64260_PCI_1_CMD, (1<<13));
555 gt64260_pci_exclude_bridge = save_exclude;
558 gt_clr_bits(GT64260_CPU_SNOOP_BASE_0, 0xfffcf000);
559 gt_clr_bits(GT64260_CPU_SNOOP_BASE_1, 0xfffcf000);
560 gt_clr_bits(GT64260_CPU_SNOOP_BASE_2, 0xfffcf000);
561 gt_clr_bits(GT64260_CPU_SNOOP_BASE_3, 0xfffcf000);
564 gt_set_bits(GT64260_SDRAM_CONFIG, (1<<26));
566 } else if (gt64260_revision == GT64260A) {
568 /* cpu read buffer to buffer 1 (reg 0x0448) */
569 gt_set_bits(GT64260_SDRAM_CONFIG, (1<<26));
571 /* No longer errata so turn on */
572 /* Enable pci read/write combine, master write trigger,
573 * disable slave sync barrier
574 * readmultiple (reg 0x0c00 and 0x0c80)
576 if (hose_a != (struct pci_controller *)NULL) {
577 gt_set_bits(GT64260_PCI_0_CMD,
578 ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
581 if (hose_b != (struct pci_controller *)NULL) {
582 gt_set_bits(GT64260_PCI_1_CMD,
583 ((1<<4) | (1<<5) | (1<<9) | (1<<13)));
588 } /* gt64260_check_errata() */
592 *****************************************************************************
594 * General Window Setting Routines
596 *****************************************************************************
600 gt64260_set_32bit_window(u32 base_addr,
609 /* Set up the window on the CPU side */
610 gt_write(bot_reg, (base_addr >> 20) | other_bits);
611 gt_write(top_reg, (base_addr + size - 1) >> 20);
612 } else { /* Disable window */
613 gt_write(top_reg, 0x00000000);
614 gt_write(bot_reg, 0x00000fff | other_bits);
617 val = gt_read(bot_reg); /* Flush FIFO */
619 } /* gt64260_set_32bit_window() */
622 gt64260_set_64bit_window(u32 base_addr_hi,
632 if ((rc = gt64260_set_32bit_window(base_addr_lo,
638 gt_write(bot_reg_hi, base_addr_hi);
639 base_addr_hi = gt_read(bot_reg_hi); /* Flush FIFO */
643 } /* gt64260_set_64bit_window() */
647 *****************************************************************************
649 * CPU Configuration Routines
651 *****************************************************************************
656 gt64260_cpu_scs_set_window(u32 window,
661 cpu_scs_windows[GT64260_CPU_SCS_DECODE_WINDOWS][2] = {
662 { GT64260_CPU_SCS_DECODE_0_BOT, GT64260_CPU_SCS_DECODE_0_TOP },
663 { GT64260_CPU_SCS_DECODE_1_BOT, GT64260_CPU_SCS_DECODE_1_TOP },
664 { GT64260_CPU_SCS_DECODE_2_BOT, GT64260_CPU_SCS_DECODE_2_TOP },
665 { GT64260_CPU_SCS_DECODE_3_BOT, GT64260_CPU_SCS_DECODE_3_TOP },
666 }; /* cpu_scs_windows[][] */
669 if (window < GT64260_CPU_SCS_DECODE_WINDOWS) {
670 rc = gt64260_set_32bit_window(base_addr,
673 cpu_scs_windows[window][0],
674 cpu_scs_windows[window][1]);
678 } /* gt64260_cpu_scs_set_window() */
682 gt64260_cpu_cs_set_window(u32 window,
687 cpu_cs_windows[GT64260_CPU_CS_DECODE_WINDOWS][2] = {
688 { GT64260_CPU_CS_DECODE_0_BOT, GT64260_CPU_CS_DECODE_0_TOP },
689 { GT64260_CPU_CS_DECODE_1_BOT, GT64260_CPU_CS_DECODE_1_TOP },
690 { GT64260_CPU_CS_DECODE_2_BOT, GT64260_CPU_CS_DECODE_2_TOP },
691 { GT64260_CPU_CS_DECODE_3_BOT, GT64260_CPU_CS_DECODE_3_TOP },
692 }; /* cpu_cs_windows[][] */
695 if (window < GT64260_CPU_CS_DECODE_WINDOWS) {
696 rc = gt64260_set_32bit_window(base_addr,
699 cpu_cs_windows[window][0],
700 cpu_cs_windows[window][1]);
704 } /* gt64260_cpu_cs_set_window() */
707 gt64260_cpu_boot_set_window(u32 base_addr,
712 rc = gt64260_set_32bit_window(base_addr,
715 GT64260_CPU_BOOT_CS_DECODE_0_BOT,
716 GT64260_CPU_BOOT_CS_DECODE_0_TOP);
719 } /* gt64260_cpu_boot_set_window() */
722 * gt64260_cpu_set_pci_io_window()
724 * Set up a CPU window into PCI I/O or MEM space.
725 * Always do Read/Modify/Write to window regs.
728 gt64260_cpu_pci_set_window(u32 cpu_base_addr,
739 if ((rc = gt64260_set_32bit_window(cpu_base_addr,
745 /* Set up CPU->PCI remapping (on lower 32 bits) */
746 gt_write(remap_reg, pci_base_addr >> 20);
747 val = gt_read(bot_reg); /* Flush FIFO */
751 } /* gt64260_cpu_pci_set_window() */
755 * gt64260_cpu_set_pci_io_window()
757 * Set up a CPU window into PCI I/O space.
758 * Always do Read/Modify/Write to window regs.
761 gt64260_cpu_set_pci_io_window(u32 pci_bus,
767 /* 2 PCI buses with 1 I/O window each (from CPU point of view) */
769 cpu_pci_io_windows[GT64260_PCI_BUSES][3] = {
770 { GT64260_CPU_PCI_0_IO_DECODE_BOT,
771 GT64260_CPU_PCI_0_IO_DECODE_TOP,
772 GT64260_CPU_PCI_0_IO_REMAP },
774 { GT64260_CPU_PCI_1_IO_DECODE_BOT,
775 GT64260_CPU_PCI_1_IO_DECODE_TOP,
776 GT64260_CPU_PCI_1_IO_REMAP },
777 }; /* cpu_pci_io_windows[][] */
780 if (pci_bus < GT64260_PCI_BUSES) {
781 rc = gt64260_cpu_pci_set_window(cpu_base_addr,
785 cpu_pci_io_windows[pci_bus][0],
786 cpu_pci_io_windows[pci_bus][1],
787 cpu_pci_io_windows[pci_bus][2]);
791 } /* gt64260_cpu_set_pci_io_window() */
794 * gt64260_cpu_set_pci_mem_window()
796 * Set up a CPU window into PCI MEM space (4 PCI MEM windows per PCI bus).
797 * Always do Read/Modify/Write to window regs.
800 gt64260_cpu_set_pci_mem_window(u32 pci_bus,
803 u32 pci_base_addr_hi,
804 u32 pci_base_addr_lo,
808 /* 2 PCI buses with 4 memory windows each (from CPU point of view) */
810 cpu_pci_mem_windows[GT64260_PCI_BUSES][GT64260_PCI_MEM_WINDOWS_PER_BUS][4] = {
812 { GT64260_CPU_PCI_0_MEM_0_DECODE_BOT,
813 GT64260_CPU_PCI_0_MEM_0_DECODE_TOP,
814 GT64260_CPU_PCI_0_MEM_0_REMAP_HI,
815 GT64260_CPU_PCI_0_MEM_0_REMAP_LO },
817 { GT64260_CPU_PCI_0_MEM_1_DECODE_BOT,
818 GT64260_CPU_PCI_0_MEM_1_DECODE_TOP,
819 GT64260_CPU_PCI_0_MEM_1_REMAP_HI,
820 GT64260_CPU_PCI_0_MEM_1_REMAP_LO },
822 { GT64260_CPU_PCI_0_MEM_2_DECODE_BOT,
823 GT64260_CPU_PCI_0_MEM_2_DECODE_TOP,
824 GT64260_CPU_PCI_0_MEM_2_REMAP_HI,
825 GT64260_CPU_PCI_0_MEM_2_REMAP_LO },
827 { GT64260_CPU_PCI_0_MEM_3_DECODE_BOT,
828 GT64260_CPU_PCI_0_MEM_3_DECODE_TOP,
829 GT64260_CPU_PCI_0_MEM_3_REMAP_HI,
830 GT64260_CPU_PCI_0_MEM_3_REMAP_LO }
834 { GT64260_CPU_PCI_1_MEM_0_DECODE_BOT,
835 GT64260_CPU_PCI_1_MEM_0_DECODE_TOP,
836 GT64260_CPU_PCI_1_MEM_0_REMAP_HI,
837 GT64260_CPU_PCI_1_MEM_0_REMAP_LO },
839 { GT64260_CPU_PCI_1_MEM_1_DECODE_BOT,
840 GT64260_CPU_PCI_1_MEM_1_DECODE_TOP,
841 GT64260_CPU_PCI_1_MEM_1_REMAP_HI,
842 GT64260_CPU_PCI_1_MEM_1_REMAP_LO },
844 { GT64260_CPU_PCI_1_MEM_2_DECODE_BOT,
845 GT64260_CPU_PCI_1_MEM_2_DECODE_TOP,
846 GT64260_CPU_PCI_1_MEM_2_REMAP_HI,
847 GT64260_CPU_PCI_1_MEM_2_REMAP_LO },
849 { GT64260_CPU_PCI_1_MEM_3_DECODE_BOT,
850 GT64260_CPU_PCI_1_MEM_3_DECODE_TOP,
851 GT64260_CPU_PCI_1_MEM_3_REMAP_HI,
852 GT64260_CPU_PCI_1_MEM_3_REMAP_LO },
854 }; /* cpu_pci_mem_windows[][][] */
855 u32 remap_reg, remap;
858 if ((pci_bus < GT64260_PCI_BUSES) &&
859 (window < GT64260_PCI_MEM_WINDOWS_PER_BUS)) {
861 if (gt64260_cpu_pci_set_window(
866 cpu_pci_mem_windows[pci_bus][window][0],
867 cpu_pci_mem_windows[pci_bus][window][1],
868 cpu_pci_mem_windows[pci_bus][window][3]) == 0) {
870 remap_reg = cpu_pci_mem_windows[pci_bus][window][2];
871 gt_write(remap_reg, pci_base_addr_hi);
873 remap = gt_read(remap_reg); /* Flush FIFO */
880 } /* gt64260_cpu_set_pci_mem_window() */
883 gt64260_cpu_prot_set_window(u32 window,
889 cpu_prot_windows[GT64260_CPU_PROT_WINDOWS][2] = {
890 { GT64260_CPU_PROT_BASE_0, GT64260_CPU_PROT_TOP_0 },
891 { GT64260_CPU_PROT_BASE_1, GT64260_CPU_PROT_TOP_1 },
892 { GT64260_CPU_PROT_BASE_2, GT64260_CPU_PROT_TOP_2 },
893 { GT64260_CPU_PROT_BASE_3, GT64260_CPU_PROT_TOP_3 },
894 { GT64260_CPU_PROT_BASE_4, GT64260_CPU_PROT_TOP_4 },
895 { GT64260_CPU_PROT_BASE_5, GT64260_CPU_PROT_TOP_5 },
896 { GT64260_CPU_PROT_BASE_6, GT64260_CPU_PROT_TOP_6 },
897 { GT64260_CPU_PROT_BASE_7, GT64260_CPU_PROT_TOP_7 },
898 }; /* cpu_prot_windows[][] */
901 if (window < GT64260_CPU_PROT_WINDOWS) {
902 rc = gt64260_set_32bit_window(base_addr,
905 cpu_prot_windows[window][0],
906 cpu_prot_windows[window][1]);
910 } /* gt64260_cpu_prot_set_window() */
913 gt64260_cpu_snoop_set_window(u32 window,
919 cpu_snoop_windows[GT64260_CPU_SNOOP_WINDOWS][2] = {
920 { GT64260_CPU_SNOOP_BASE_0, GT64260_CPU_SNOOP_TOP_0 },
921 { GT64260_CPU_SNOOP_BASE_1, GT64260_CPU_SNOOP_TOP_1 },
922 { GT64260_CPU_SNOOP_BASE_2, GT64260_CPU_SNOOP_TOP_2 },
923 { GT64260_CPU_SNOOP_BASE_3, GT64260_CPU_SNOOP_TOP_3 },
924 }; /* cpu_snoop_windows[][] */
927 if ((window < GT64260_CPU_SNOOP_WINDOWS) &&
928 (snoop_type <= GT64260_CPU_SNOOP_WB)) {
930 rc = gt64260_set_32bit_window(base_addr,
933 cpu_snoop_windows[window][0],
934 cpu_snoop_windows[window][1]);
938 } /* gt64260_cpu_snoop_set_window() */
941 gt64260_cpu_disable_windows(void)
945 /* Leave SCS windows alone because we're running from memory */
948 * Note: Don't put any progress msgs between shutting down CS windows
949 * and re-enabling them because the console device may be behind one
952 for (window=0; window<GT64260_PCI_CS_WINDOWS; window++) {
953 gt64260_cpu_cs_set_window(window, 0, 0);
956 gt64260_cpu_boot_set_window(0, 0);
958 for (pci_bus=0; pci_bus<GT64260_PCI_BUSES; pci_bus++) {
959 gt64260_cpu_set_pci_io_window(pci_bus, 0, 0, 0, 0);
961 for (window=0;window<GT64260_PCI_MEM_WINDOWS_PER_BUS;window++) {
962 gt64260_cpu_set_pci_mem_window(pci_bus,
969 } /* gt64260_cpu_disable_windows() */
973 *****************************************************************************
975 * PCI Slave Window Configuration Routines
977 *****************************************************************************
981 gt64260_pci_bar_enable(u32 pci_bus,
987 if (pci_bus < GT64260_PCI_BUSES) {
988 reg = (pci_bus == 0) ? GT64260_PCI_0_SLAVE_BAR_REG_ENABLES :
989 GT64260_PCI_1_SLAVE_BAR_REG_ENABLES;
991 /* Note: '0' enables, '1' disables */
992 gt_write(reg, ~enable_bits);
993 gt_read(reg); /* Flush FIFO */
999 } /* gt64260_pci_bar_enable() */
1002 gt64260_pci_slave_set_window(struct pci_controller *hose,
1007 u32 pci_cfg_hdr_offset,
1015 pci_base_addr &= 0xfffff000;
1016 cpu_base_addr &= 0xfffff000;
1017 bar_size &= 0xfffff000;
1018 devfn = PCI_DEVFN(0, pci_cfg_fcn);
1020 gt_write(bar_size_reg, (bar_size - 1) & 0xfffff000);
1021 gt_write(remap_reg, cpu_base_addr);
1022 gt_read(remap_reg); /* Flush FIFO */
1024 save_exclude = gt64260_pci_exclude_bridge;
1025 gt64260_pci_exclude_bridge = FALSE;
1026 early_read_config_dword(hose,
1034 printk(__FUNCTION__ ": setting busno %08x, devfn %08x, offset %08x -> %08x\n",
1035 hose->first_busno, devfn, pci_cfg_hdr_offset, pci_base_addr | val);
1038 early_write_config_dword(hose,
1042 pci_base_addr | val);
1043 gt64260_pci_exclude_bridge = save_exclude;
1046 } /* gt64260_pci_slave_set_window() */
1049 gt64260_pci_slave_scs_set_window(struct pci_controller *hose,
1056 pci_scs_windows[GT64260_PCI_BUSES][GT64260_PCI_SCS_WINDOWS][4] = {
1059 GT64260_PCI_0_SLAVE_SCS_0_SIZE,
1060 GT64260_PCI_0_SLAVE_SCS_0_REMAP },
1062 GT64260_PCI_0_SLAVE_SCS_1_SIZE,
1063 GT64260_PCI_0_SLAVE_SCS_1_REMAP },
1065 GT64260_PCI_0_SLAVE_SCS_2_SIZE,
1066 GT64260_PCI_0_SLAVE_SCS_2_REMAP },
1068 GT64260_PCI_0_SLAVE_SCS_3_SIZE,
1069 GT64260_PCI_0_SLAVE_SCS_3_REMAP },
1073 GT64260_PCI_1_SLAVE_SCS_0_SIZE,
1074 GT64260_PCI_1_SLAVE_SCS_0_REMAP },
1076 GT64260_PCI_1_SLAVE_SCS_1_SIZE,
1077 GT64260_PCI_1_SLAVE_SCS_1_REMAP },
1079 GT64260_PCI_1_SLAVE_SCS_2_SIZE,
1080 GT64260_PCI_1_SLAVE_SCS_2_REMAP },
1082 GT64260_PCI_1_SLAVE_SCS_3_SIZE,
1083 GT64260_PCI_1_SLAVE_SCS_3_REMAP },
1085 }; /* pci_scs_windows[][][] */
1089 if (window < GT64260_PCI_SCS_WINDOWS) {
1090 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1093 printk(__FUNCTION__ ": bus %d: hose->first_busno: %d\n", pci_bus, hose->first_busno);
1095 rc = gt64260_pci_slave_set_window(
1100 pci_scs_windows[pci_bus][window][0],
1101 pci_scs_windows[pci_bus][window][1],
1102 pci_scs_windows[pci_bus][window][2],
1103 pci_scs_windows[pci_bus][window][3]);
1107 } /* gt64260_pci_slave_scs_set_window() */
1111 gt64260_pci_slave_cs_set_window(struct pci_controller *hose,
1118 pci_cs_windows[GT64260_PCI_BUSES][GT64260_PCI_CS_WINDOWS][4] = {
1121 GT64260_PCI_0_SLAVE_CS_0_SIZE,
1122 GT64260_PCI_0_SLAVE_CS_0_REMAP },
1124 GT64260_PCI_0_SLAVE_CS_1_SIZE,
1125 GT64260_PCI_0_SLAVE_CS_1_REMAP },
1127 GT64260_PCI_0_SLAVE_CS_2_SIZE,
1128 GT64260_PCI_0_SLAVE_CS_2_REMAP },
1130 GT64260_PCI_0_SLAVE_CS_3_SIZE,
1131 GT64260_PCI_0_SLAVE_CS_3_REMAP },
1135 GT64260_PCI_1_SLAVE_CS_0_SIZE,
1136 GT64260_PCI_1_SLAVE_CS_0_REMAP },
1138 GT64260_PCI_1_SLAVE_CS_1_SIZE,
1139 GT64260_PCI_1_SLAVE_CS_1_REMAP },
1141 GT64260_PCI_1_SLAVE_CS_2_SIZE,
1142 GT64260_PCI_1_SLAVE_CS_2_REMAP },
1144 GT64260_PCI_1_SLAVE_CS_3_SIZE,
1145 GT64260_PCI_1_SLAVE_CS_3_REMAP },
1147 }; /* pci_cs_windows[][][] */
1151 if (window < GT64260_PCI_CS_WINDOWS) {
1152 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1154 rc = gt64260_pci_slave_set_window(
1159 pci_cs_windows[pci_bus][window][0],
1160 pci_cs_windows[pci_bus][window][1],
1161 pci_cs_windows[pci_bus][window][2],
1162 pci_cs_windows[pci_bus][window][3]);
1166 } /* gt64260_pci_slave_cs_set_window() */
1169 gt64260_pci_slave_boot_set_window(struct pci_controller *hose,
1175 pci_boot_table[GT64260_PCI_BUSES][2] = {
1177 GT64260_PCI_0_SLAVE_BOOT_SIZE,
1178 GT64260_PCI_0_SLAVE_BOOT_REMAP,
1181 GT64260_PCI_1_SLAVE_BOOT_SIZE,
1182 GT64260_PCI_1_SLAVE_BOOT_REMAP,
1184 }; /* pci_boot_table[][] */
1188 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1190 rc = gt64260_pci_slave_set_window(hose,
1196 pci_boot_table[pci_bus][0],
1197 pci_boot_table[pci_bus][1]);
1200 } /* gt64260_pci_slave_boot_set_window() */
1203 gt64260_pci_slave_p2p_mem_set_window(struct pci_controller *hose,
1206 u32 other_bus_base_addr,
1210 pci_p2p_mem_windows[GT64260_PCI_BUSES][GT64260_PCI_P2P_MEM_WINDOWS][4]={
1213 GT64260_PCI_0_SLAVE_P2P_MEM_0_SIZE,
1214 GT64260_PCI_0_SLAVE_P2P_MEM_0_REMAP_LO },
1216 GT64260_PCI_0_SLAVE_P2P_MEM_1_SIZE,
1217 GT64260_PCI_0_SLAVE_P2P_MEM_1_REMAP_LO },
1221 GT64260_PCI_1_SLAVE_P2P_MEM_0_SIZE,
1222 GT64260_PCI_1_SLAVE_P2P_MEM_0_REMAP_LO },
1224 GT64260_PCI_1_SLAVE_P2P_MEM_1_SIZE,
1225 GT64260_PCI_1_SLAVE_P2P_MEM_1_REMAP_LO },
1227 }; /* pci_p2p_mem_windows[][][] */
1231 if (window < GT64260_PCI_P2P_MEM_WINDOWS) {
1232 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1234 rc = gt64260_pci_slave_set_window(
1237 other_bus_base_addr,
1239 pci_p2p_mem_windows[pci_bus][window][0],
1240 pci_p2p_mem_windows[pci_bus][window][1],
1241 pci_p2p_mem_windows[pci_bus][window][2],
1242 pci_p2p_mem_windows[pci_bus][window][3]);
1246 } /* gt64260_pci_slave_p2p_mem_set_window() */
1249 gt64260_pci_slave_p2p_io_set_window(struct pci_controller *hose,
1251 u32 other_bus_base_addr,
1255 pci_p2p_io_table[GT64260_PCI_BUSES][2] = {
1257 GT64260_PCI_0_SLAVE_P2P_IO_SIZE,
1258 GT64260_PCI_0_SLAVE_P2P_IO_REMAP,
1261 GT64260_PCI_1_SLAVE_P2P_IO_SIZE,
1262 GT64260_PCI_1_SLAVE_P2P_IO_REMAP,
1264 }; /* pci_p2p_io_table[][] */
1268 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1270 rc = gt64260_pci_slave_set_window(hose,
1272 other_bus_base_addr,
1276 pci_p2p_io_table[pci_bus][0],
1277 pci_p2p_io_table[pci_bus][1]);
1280 } /* gt64260_pci_slave_p2p_io_set_window() */
1283 gt64260_pci_slave_dac_scs_set_window(struct pci_controller *hose,
1285 u32 pci_base_addr_hi,
1286 u32 pci_base_addr_lo,
1291 pci_dac_scs_windows[GT64260_PCI_BUSES][GT64260_PCI_DAC_SCS_WINDOWS][5]={
1294 GT64260_PCI_0_SLAVE_DAC_SCS_0_SIZE,
1295 GT64260_PCI_0_SLAVE_DAC_SCS_0_REMAP },
1297 GT64260_PCI_0_SLAVE_DAC_SCS_1_SIZE,
1298 GT64260_PCI_0_SLAVE_DAC_SCS_1_REMAP },
1300 GT64260_PCI_0_SLAVE_DAC_SCS_2_SIZE,
1301 GT64260_PCI_0_SLAVE_DAC_SCS_2_REMAP },
1303 GT64260_PCI_0_SLAVE_DAC_SCS_3_SIZE,
1304 GT64260_PCI_0_SLAVE_DAC_SCS_3_REMAP },
1308 GT64260_PCI_1_SLAVE_DAC_SCS_0_SIZE,
1309 GT64260_PCI_1_SLAVE_DAC_SCS_0_REMAP },
1311 GT64260_PCI_1_SLAVE_DAC_SCS_1_SIZE,
1312 GT64260_PCI_1_SLAVE_DAC_SCS_1_REMAP },
1314 GT64260_PCI_1_SLAVE_DAC_SCS_2_SIZE,
1315 GT64260_PCI_1_SLAVE_DAC_SCS_2_REMAP },
1317 GT64260_PCI_1_SLAVE_DAC_SCS_3_SIZE,
1318 GT64260_PCI_1_SLAVE_DAC_SCS_3_REMAP },
1320 }; /* pci_dac_scs_windows[][][] */
1324 if (window < GT64260_PCI_DAC_SCS_WINDOWS) {
1325 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1327 rc = gt64260_pci_slave_set_window(
1332 pci_dac_scs_windows[pci_bus][window][0],
1333 pci_dac_scs_windows[pci_bus][window][1],
1334 pci_dac_scs_windows[pci_bus][window][3],
1335 pci_dac_scs_windows[pci_bus][window][4]);
1337 early_write_config_dword(
1340 PCI_DEVFN(0, pci_dac_scs_windows[pci_bus][window][0]),
1341 pci_dac_scs_windows[pci_bus][window][2],
1346 } /* gt64260_pci_slave_dac_scs_set_window() */
1349 gt64260_pci_slave_dac_cs_set_window(struct pci_controller *hose,
1351 u32 pci_base_addr_hi,
1352 u32 pci_base_addr_lo,
1357 pci_dac_cs_windows[GT64260_PCI_BUSES][GT64260_PCI_DAC_CS_WINDOWS][5] = {
1360 GT64260_PCI_0_SLAVE_DAC_CS_0_SIZE,
1361 GT64260_PCI_0_SLAVE_DAC_CS_0_REMAP },
1363 GT64260_PCI_0_SLAVE_DAC_CS_1_SIZE,
1364 GT64260_PCI_0_SLAVE_DAC_CS_1_REMAP },
1366 GT64260_PCI_0_SLAVE_DAC_CS_2_SIZE,
1367 GT64260_PCI_0_SLAVE_DAC_CS_2_REMAP },
1369 GT64260_PCI_0_SLAVE_DAC_CS_3_SIZE,
1370 GT64260_PCI_0_SLAVE_DAC_CS_3_REMAP },
1374 GT64260_PCI_1_SLAVE_DAC_CS_0_SIZE,
1375 GT64260_PCI_1_SLAVE_DAC_CS_0_REMAP },
1377 GT64260_PCI_1_SLAVE_DAC_CS_1_SIZE,
1378 GT64260_PCI_1_SLAVE_DAC_CS_1_REMAP },
1380 GT64260_PCI_1_SLAVE_DAC_CS_2_SIZE,
1381 GT64260_PCI_1_SLAVE_DAC_CS_2_REMAP },
1383 GT64260_PCI_1_SLAVE_DAC_CS_3_SIZE,
1384 GT64260_PCI_1_SLAVE_DAC_CS_3_REMAP },
1386 }; /* pci_dac_cs_windows[][][] */
1390 if (window < GT64260_PCI_CS_WINDOWS) {
1391 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1393 rc = gt64260_pci_slave_set_window(
1398 pci_dac_cs_windows[pci_bus][window][0],
1399 pci_dac_cs_windows[pci_bus][window][1],
1400 pci_dac_cs_windows[pci_bus][window][3],
1401 pci_dac_cs_windows[pci_bus][window][4]);
1403 early_write_config_dword(
1406 PCI_DEVFN(0, pci_dac_cs_windows[pci_bus][window][0]),
1407 pci_dac_cs_windows[pci_bus][window][2],
1412 } /* gt64260_pci_slave_dac_cs_set_window() */
1415 gt64260_pci_slave_dac_boot_set_window(struct pci_controller *hose,
1416 u32 pci_base_addr_hi,
1417 u32 pci_base_addr_lo,
1422 pci_dac_boot_table[GT64260_PCI_BUSES][2] = {
1424 GT64260_PCI_0_SLAVE_DAC_BOOT_SIZE,
1425 GT64260_PCI_0_SLAVE_DAC_BOOT_REMAP,
1428 GT64260_PCI_1_SLAVE_DAC_BOOT_SIZE,
1429 GT64260_PCI_1_SLAVE_DAC_BOOT_REMAP,
1431 }; /* pci_dac_boot_table[][] */
1435 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1437 rc = gt64260_pci_slave_set_window(hose,
1443 pci_dac_boot_table[pci_bus][0],
1444 pci_dac_boot_table[pci_bus][1]);
1446 early_write_config_dword(hose,
1453 } /* gt64260_pci_slave_dac_boot_set_window() */
1456 gt64260_pci_slave_dac_p2p_mem_set_window(struct pci_controller *hose,
1458 u32 pci_base_addr_hi,
1459 u32 pci_base_addr_lo,
1460 u32 other_bus_base_addr,
1464 pci_dac_p2p_mem_windows[GT64260_PCI_BUSES][GT64260_PCI_DAC_P2P_MEM_WINDOWS][5] = {
1467 GT64260_PCI_0_SLAVE_DAC_P2P_MEM_0_SIZE,
1468 GT64260_PCI_0_SLAVE_DAC_P2P_MEM_0_REMAP_LO },
1470 GT64260_PCI_0_SLAVE_DAC_P2P_MEM_1_SIZE,
1471 GT64260_PCI_0_SLAVE_DAC_P2P_MEM_1_REMAP_LO },
1475 GT64260_PCI_0_SLAVE_DAC_P2P_MEM_0_SIZE,
1476 GT64260_PCI_0_SLAVE_DAC_P2P_MEM_0_REMAP_LO },
1478 GT64260_PCI_0_SLAVE_DAC_P2P_MEM_1_SIZE,
1479 GT64260_PCI_0_SLAVE_DAC_P2P_MEM_1_REMAP_LO },
1481 }; /* pci_dac_p2p_windows[][][] */
1485 if (window < GT64260_PCI_P2P_MEM_WINDOWS) {
1486 pci_bus = (hose->first_busno == 0) ? 0 : 1;
1488 rc = gt64260_pci_slave_set_window(
1491 other_bus_base_addr,
1493 pci_dac_p2p_mem_windows[pci_bus][window][0],
1494 pci_dac_p2p_mem_windows[pci_bus][window][1],
1495 pci_dac_p2p_mem_windows[pci_bus][window][3],
1496 pci_dac_p2p_mem_windows[pci_bus][window][4]);
1498 early_write_config_dword(
1501 PCI_DEVFN(0, pci_dac_p2p_mem_windows[pci_bus][window][0]),
1502 pci_dac_p2p_mem_windows[pci_bus][window][2],
1507 } /* gt64260_pci_slave_dac_p2p_mem_set_window() */
1512 *****************************************************************************
1514 * PCI Control Configuration Routines
1516 *****************************************************************************
1521 gt64260_pci_acc_cntl_set_window(u32 pci_bus,
1529 pci_acc_cntl_windows[GT64260_PCI_BUSES][GT64260_PCI_ACC_CNTL_WINDOWS][3] = {
1531 { GT64260_PCI_0_ACC_CNTL_0_BASE_HI,
1532 GT64260_PCI_0_ACC_CNTL_0_BASE_LO,
1533 GT64260_PCI_0_ACC_CNTL_0_TOP },
1535 { GT64260_PCI_0_ACC_CNTL_1_BASE_HI,
1536 GT64260_PCI_0_ACC_CNTL_1_BASE_LO,
1537 GT64260_PCI_0_ACC_CNTL_1_TOP },
1539 { GT64260_PCI_0_ACC_CNTL_2_BASE_HI,
1540 GT64260_PCI_0_ACC_CNTL_2_BASE_LO,
1541 GT64260_PCI_0_ACC_CNTL_2_TOP },
1543 { GT64260_PCI_0_ACC_CNTL_3_BASE_HI,
1544 GT64260_PCI_0_ACC_CNTL_3_BASE_LO,
1545 GT64260_PCI_0_ACC_CNTL_3_TOP },
1547 { GT64260_PCI_0_ACC_CNTL_4_BASE_HI,
1548 GT64260_PCI_0_ACC_CNTL_4_BASE_LO,
1549 GT64260_PCI_0_ACC_CNTL_4_TOP },
1551 { GT64260_PCI_0_ACC_CNTL_5_BASE_HI,
1552 GT64260_PCI_0_ACC_CNTL_5_BASE_LO,
1553 GT64260_PCI_0_ACC_CNTL_5_TOP },
1555 { GT64260_PCI_0_ACC_CNTL_6_BASE_HI,
1556 GT64260_PCI_0_ACC_CNTL_6_BASE_LO,
1557 GT64260_PCI_0_ACC_CNTL_6_TOP },
1559 { GT64260_PCI_0_ACC_CNTL_7_BASE_HI,
1560 GT64260_PCI_0_ACC_CNTL_7_BASE_LO,
1561 GT64260_PCI_0_ACC_CNTL_7_TOP },
1564 { GT64260_PCI_1_ACC_CNTL_0_BASE_HI,
1565 GT64260_PCI_1_ACC_CNTL_0_BASE_LO,
1566 GT64260_PCI_1_ACC_CNTL_0_TOP },
1568 { GT64260_PCI_1_ACC_CNTL_1_BASE_HI,
1569 GT64260_PCI_1_ACC_CNTL_1_BASE_LO,
1570 GT64260_PCI_1_ACC_CNTL_1_TOP },
1572 { GT64260_PCI_1_ACC_CNTL_2_BASE_HI,
1573 GT64260_PCI_1_ACC_CNTL_2_BASE_LO,
1574 GT64260_PCI_1_ACC_CNTL_2_TOP },
1576 { GT64260_PCI_1_ACC_CNTL_3_BASE_HI,
1577 GT64260_PCI_1_ACC_CNTL_3_BASE_LO,
1578 GT64260_PCI_1_ACC_CNTL_3_TOP },
1580 { GT64260_PCI_1_ACC_CNTL_4_BASE_HI,
1581 GT64260_PCI_1_ACC_CNTL_4_BASE_LO,
1582 GT64260_PCI_1_ACC_CNTL_4_TOP },
1584 { GT64260_PCI_1_ACC_CNTL_5_BASE_HI,
1585 GT64260_PCI_1_ACC_CNTL_5_BASE_LO,
1586 GT64260_PCI_1_ACC_CNTL_5_TOP },
1588 { GT64260_PCI_1_ACC_CNTL_6_BASE_HI,
1589 GT64260_PCI_1_ACC_CNTL_6_BASE_LO,
1590 GT64260_PCI_1_ACC_CNTL_6_TOP },
1592 { GT64260_PCI_1_ACC_CNTL_7_BASE_HI,
1593 GT64260_PCI_1_ACC_CNTL_7_BASE_LO,
1594 GT64260_PCI_1_ACC_CNTL_7_TOP },
1596 }; /* pci_acc_cntl_windows[][][] */
1599 if ((pci_bus < GT64260_PCI_BUSES) &&
1600 (window < GT64260_PCI_ACC_CNTL_WINDOWS)) {
1602 rc = gt64260_set_64bit_window(
1607 pci_acc_cntl_windows[pci_bus][window][0],
1608 pci_acc_cntl_windows[pci_bus][window][1],
1609 pci_acc_cntl_windows[pci_bus][window][2]);
1613 } /* gt64260_pci_acc_cntl_set_window() */
1616 gt64260_pci_snoop_set_window(u32 pci_bus,
1624 pci_snoop_windows[GT64260_PCI_BUSES][GT64260_PCI_SNOOP_WINDOWS][3] = {
1626 { GT64260_PCI_0_SNOOP_0_BASE_HI,
1627 GT64260_PCI_0_SNOOP_0_BASE_LO,
1628 GT64260_PCI_0_SNOOP_0_TOP },
1630 { GT64260_PCI_0_SNOOP_1_BASE_HI,
1631 GT64260_PCI_0_SNOOP_1_BASE_LO,
1632 GT64260_PCI_0_SNOOP_1_TOP },
1634 { GT64260_PCI_0_SNOOP_2_BASE_HI,
1635 GT64260_PCI_0_SNOOP_2_BASE_LO,
1636 GT64260_PCI_0_SNOOP_2_TOP },
1638 { GT64260_PCI_0_SNOOP_3_BASE_HI,
1639 GT64260_PCI_0_SNOOP_3_BASE_LO,
1640 GT64260_PCI_0_SNOOP_3_TOP },
1643 { GT64260_PCI_1_SNOOP_0_BASE_HI,
1644 GT64260_PCI_1_SNOOP_0_BASE_LO,
1645 GT64260_PCI_1_SNOOP_0_TOP },
1647 { GT64260_PCI_1_SNOOP_1_BASE_HI,
1648 GT64260_PCI_1_SNOOP_1_BASE_LO,
1649 GT64260_PCI_1_SNOOP_1_TOP },
1651 { GT64260_PCI_1_SNOOP_2_BASE_HI,
1652 GT64260_PCI_1_SNOOP_2_BASE_LO,
1653 GT64260_PCI_1_SNOOP_2_TOP },
1655 { GT64260_PCI_1_SNOOP_3_BASE_HI,
1656 GT64260_PCI_1_SNOOP_3_BASE_LO,
1657 GT64260_PCI_1_SNOOP_3_TOP },
1659 }; /* pci_snoop_windows[][][] */
1662 if ((pci_bus < GT64260_PCI_BUSES) &&
1663 (window < GT64260_PCI_SNOOP_WINDOWS)) {
1665 rc = gt64260_set_64bit_window(
1670 pci_snoop_windows[pci_bus][window][0],
1671 pci_snoop_windows[pci_bus][window][1],
1672 pci_snoop_windows[pci_bus][window][2]);
1676 } /* gt64260_pci_snoop_set_window() */
1679 *****************************************************************************
1681 * 64260's Register Base Address Routines
1683 *****************************************************************************
1687 * gt64260_remap_bridge_regs()
1689 * Move the bridge's register to the specified base address.
1690 * Assume that there are no other windows overlapping this area and that
1691 * all but the highest 3 nibbles are 0.
1694 gt64260_set_base(u32 new_phys_base)
1700 val = gt_read(GT64260_INTERNAL_SPACE_DECODE);
1701 val = (new_phys_base >> 20) | (val & 0xffff0000);
1702 gt_write(GT64260_INTERNAL_SPACE_DECODE, val);
1704 iounmap((void *)gt64260_base);
1705 gt64260_base = (u32)ioremap((new_phys_base & 0xfff00000),
1706 GT64260_INTERNAL_SPACE_SIZE);
1708 /* Wait for bridge to move its regs */
1709 while ((gt_read(GT64260_INTERNAL_SPACE_DECODE)!=val) && (limit-- > 0));
1716 } /* gt64260_remap_bridge_regs() */
1719 * gt64260_get_base()
1721 * Return the current virtual base address of the 64260's registers.
1724 gt64260_get_base(u32 *base)
1726 *base = gt64260_base;
1728 } /* gt64260_remap_bridge_regs() */
1732 *****************************************************************************
1734 * Exclude PCI config space access to bridge itself
1736 *****************************************************************************
1740 * gt64260_exclude_pci_device()
1742 * This routine causes the PCI subsystem to skip the PCI device in slot 0
1743 * (which is the 64260 itself) unless explicitly allowed.
1746 gt64260_pci_exclude_device(u8 bus, u8 devfn)
1748 struct pci_controller *hose;
1750 hose = pci_bus_to_hose(bus);
1752 /* Skip slot 0 on both hoses */
1753 if ((gt64260_pci_exclude_bridge == TRUE) &&
1754 (PCI_SLOT(devfn) == 0) &&
1755 (hose->first_busno == bus)) {
1756 return PCIBIOS_DEVICE_NOT_FOUND;
1759 return PCIBIOS_SUCCESSFUL;
1761 } /* gt64260_pci_exclude_device() */
1764 *****************************************************************************
1768 *****************************************************************************
1771 * gt64260_get_mem_size()
1773 * Read memory controller's registers to determine the amount of memory
1774 * in the system. Assumes that the memeory controller has been set up
1775 * to the proper memory size.
1778 gt64260_get_mem_size(void)
1781 cpu_scs_windows[GT64260_CPU_SCS_DECODE_WINDOWS][2] = {
1782 { GT64260_CPU_SCS_DECODE_0_BOT, GT64260_CPU_SCS_DECODE_0_TOP },
1783 { GT64260_CPU_SCS_DECODE_1_BOT, GT64260_CPU_SCS_DECODE_1_TOP },
1784 { GT64260_CPU_SCS_DECODE_2_BOT, GT64260_CPU_SCS_DECODE_2_TOP },
1785 { GT64260_CPU_SCS_DECODE_3_BOT, GT64260_CPU_SCS_DECODE_3_TOP },
1786 }; /* cpu_scs_windows[][] */
1787 u32 window, top, bot;
1788 static u32 total = 0;
1789 static int first_time = 1;
1792 for (window=0; window<GT64260_CPU_SCS_DECODE_WINDOWS; window++){
1793 bot = gt_read(cpu_scs_windows[window][0]) << 20;
1794 top = (gt_read(cpu_scs_windows[window][1]) << 20) +
1797 if (top > bot) { /* Is window really open? */
1798 total += (top - bot);
1806 } /* gt64260_get_mem_size() */
1808 #if defined(CONFIG_SERIAL_TEXT_DEBUG)
1810 *****************************************************************************
1812 * Low-level MPSC/UART I/O routines
1814 *****************************************************************************
1820 * Dump a character out the MPSC port for gt64260_mpsc_progress
1821 * this assumes the baud rate has already been set up and the
1822 * MPSC initialized by the bootloader or firmware.
1829 gt_write(GT64260_MPSC_0_CHR_1, c);
1831 gt_write(GT64260_MPSC_0_CHR_2, 0x200);
1838 puthex(unsigned long val)
1843 for (i = 7; i >= 0; i--) {
1844 gt_putc("0123456789ABCDEF"[(val>>28) & 0x0f]);
1853 gt64260_mpsc_progress(char *s, unsigned short hex)
1855 /* spit stuff out the 64260 mpsc */
1858 while ((c = *s++) != 0){
1860 if ( c == '\n' ) gt_putc('\r');
1868 #endif /* CONFIG_DEBUG_TEXT */
1870 EXPORT_SYMBOL(gt64260_set_base);
1871 EXPORT_SYMBOL(gt64260_get_base);