3 * Copyright 2001 MontaVista Software Inc.
4 * Author: jsun@mvista.com or jsun@junsun.net
6 * arch/mips/ddb5xxx/common/nile4.c
7 * misc low-level routines for vrc-5xxx controllers.
9 * derived from original code by Geert Uytterhoeven <geert@sonycom.com>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
16 #include <linux/types.h>
17 #include <linux/kernel.h>
19 #include <asm/ddb5xxx/ddb5xxx.h>
22 ddb_calc_pdar(u32 phys, u32 size, int width,
23 int on_memory_bus, int pci_visible)
29 #if 0 /* We don't support 4 GB yet */
30 case 0x100000000: /* 4 GB */
34 case 0x80000000: /* 2 GB */
37 case 0x40000000: /* 1 GB */
40 case 0x20000000: /* 512 MB */
43 case 0x10000000: /* 256 MB */
46 case 0x08000000: /* 128 MB */
49 case 0x04000000: /* 64 MB */
52 case 0x02000000: /* 32 MB */
55 case 0x01000000: /* 16 MB */
58 case 0x00800000: /* 8 MB */
61 case 0x00400000: /* 4 MB */
64 case 0x00200000: /* 2 MB */
71 panic("nile4_set_pdar: unsupported size %p", (void *) size);
87 panic("nile4_set_pdar: unsupported width %d", width);
90 return maskbits | (on_memory_bus ? 0x10 : 0) |
91 (pci_visible ? 0x20 : 0) | (widthbits << 6) |
96 ddb_set_pdar(u32 pdar, u32 phys, u32 size, int width,
97 int on_memory_bus, int pci_visible)
99 u32 temp= ddb_calc_pdar(phys, size, width, on_memory_bus, pci_visible);
100 ddb_out32(pdar, temp);
101 ddb_out32(pdar + 4, 0);
104 * When programming a PDAR, the register should be read immediately
105 * after writing it. This ensures that address decoders are properly
107 * [jsun] is this really necessary?
114 * routines that mess with PCIINITx registers
117 void ddb_set_pmr(u32 pmr, u32 type, u32 addr, u32 options)
120 case DDB_PCICMD_IACK: /* PCI Interrupt Acknowledge */
121 case DDB_PCICMD_IO: /* PCI I/O Space */
122 case DDB_PCICMD_MEM: /* PCI Memory Space */
123 case DDB_PCICMD_CFG: /* PCI Configuration Space */
126 panic("nile4_set_pmr: invalid type %d", type);
128 ddb_out32(pmr, (type << 1) | (addr & 0xffe00000) | options );
129 ddb_out32(pmr + 4, 0);