7 #define __EXTERN_INLINE inline
10 #undef __EXTERN_INLINE
12 #include <linux/types.h>
13 #include <linux/pci.h>
14 #include <linux/sched.h>
18 #include <linux/rtc.h>
19 #include <linux/module.h>
22 #include <asm/ptrace.h>
25 #include <asm/pgalloc.h>
26 #include <asm/tlbflush.h>
37 #define DEBUG_CONFIG 0
40 # define DBG_CFG(args) printk args
42 # define DBG_CFG(args)
49 static struct io7 *io7_head =
NULL;
56 read_ev7_csr(
int pe,
unsigned long offset)
69 write_ev7_csr(
int pe,
unsigned long offset,
unsigned long q)
79 mk_resource_name(
int pe,
int port,
char *
str)
84 sprintf(tmp,
"PCI %s PE %d PORT %d", str, pe, port);
94 return (prev ? prev->next : io7_head);
102 for (io7 = io7_head; io7 && io7->pe != pe; io7 = io7->next)
108 static struct io7 *
__init
109 alloc_io7(
unsigned int pe)
124 for (h = 0; h < 4; h++) {
125 io7->ports[
h].io7 = io7;
126 io7->ports[
h].port =
h;
127 io7->ports[
h].enabled = 0;
133 if (
NULL == io7_head)
135 else if (io7_head->pe > io7->pe) {
136 io7->next = io7_head;
139 for (insp = io7_head; insp; insp = insp->next) {
140 if (insp->pe == io7->pe) {
146 if (
NULL == insp->next ||
147 insp->next->pe > io7->pe) {
148 io7->next = insp->next;
156 " - adding at head of list\n", io7->pe);
157 io7->next = io7_head;
176 for (port = 0; port < 4; port++) {
200 io7_init_hose(
struct io7 *io7,
int port)
202 static int hose_index = 0;
205 struct io7_port *io7_port = &io7->ports[
port];
209 hose->
index = hose_index++;
219 if (hose->
index == 0)
222 io7_port->csrs = csrs;
223 io7_port->hose = hose;
224 hose->sysdata = io7_port;
233 hose->sparse_mem_base = hose->sparse_io_base = 0;
243 hose->io_space->end = hose->io_space->start +
IO7_IO_SPACE - 1;
244 hose->io_space->name = mk_resource_name(io7->pe, port,
"IO");
248 hose->mem_space->end = hose->mem_space->start +
IO7_MEM_SPACE - 1;
249 hose->mem_space->name = mk_resource_name(io7->pe, port,
"MEM");
262 for (i = 0; i < 4; i++) {
286 hose, 0x00800000, 0x00800000, 0);
287 hose->sg_isa->align_entry = 8;
304 hose, 0xc0000000, 0x40000000, 0);
305 hose->sg_pci->align_entry = 8;
322 printk(
"FIXME: disabling master aborts\n");
332 marvel_init_io7(
struct io7 *io7)
336 printk(
"Initializing IO7 at PID %d\n", io7->pe);
346 for (i = 0; i < IO7_NUM_PORTS; i++) {
349 io7->ports[
i].enabled = 1;
350 io7_init_hose(io7, i);
364 pe = (node->
id >> 8) & 0xff;
365 printk(
"Found an IO7 at PID %d\n", pe);
371 marvel_find_console_vga_hose(
void)
377 int h = (pu64[30] >> 24) & 0xff;
386 printk(
"console graphics is on hose %d (console)\n", h);
399 hose = io7->ports[
port].hose;
402 printk(
"Console graphics on hose %d\n", hose->
index);
419 marvel_specify_io7(
char *str)
428 printk(
"User-specified IO7 at PID %lu\n", pid);
429 io7 = alloc_io7(pid);
430 if (io7) marvel_init_io7(io7);
433 if (pchar == str) pchar++;
439 __setup(
"io7=", marvel_specify_io7);
458 marvel_init_io7(io7);
461 marvel_find_console_vga_hose();
497 static inline unsigned long
499 unsigned int devfn,
int where)
501 return (hose->config_space_base | (bus << 16) | (devfn << 8) | where);
505 mk_conf_addr(
struct pci_bus *pbus,
unsigned int devfn,
int where)
508 struct io7_port *io7_port;
509 unsigned long addr = 0;
516 io7_port = hose->sysdata;
517 if (!io7_port->enabled)
527 addr = build_conf_addr(hose, bus, devfn, where);
529 DBG_CFG((
"mk_conf_addr: returning pci_addr 0x%lx\n", addr));
534 marvel_read_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
539 if (0 == (addr = mk_conf_addr(bus, devfn, where)))
550 *value = *(
vuip)addr;
560 marvel_write_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
565 if (0 == (addr = mk_conf_addr(bus, devfn, where)))
593 .read = marvel_read_config,
594 .write = marvel_write_config,
618 unsigned long function;
624 __marvel_access_rtc(
void *
info)
628 register unsigned long __r0
__asm__(
"$0");
630 register unsigned long __r17
__asm__(
"$17") = rtc_access->
index;
631 register unsigned long __r18
__asm__(
"$18") = rtc_access->
data;
633 __asm__ __volatile__(
634 "call_pal %4 # cserve rtc"
635 :
"=r"(__r16),
"=r"(__r17),
"=r"(__r18),
"=r"(__r0)
636 :
"i"(
PAL_cserve),
"0"(__r16),
"1"(__r17),
"2"(__r18)
637 :
"$1",
"$22",
"$23",
"$24",
"$25");
639 rtc_access->
data = __r0;
643 __marvel_rtc_io(
u8 b,
unsigned long addr,
int write)
652 if (write) index =
b;
657 rtc_access.index =
index;
659 rtc_access.function = 0x48 + !
write;
661 __marvel_access_rtc(&rtc_access);
663 ret =
bin2bcd(rtc_access.data);
682 unsigned long baddr,
last;
696 for (hose =
hose_head; hose; hose = hose->next) {
697 if ((addr >> 32) == (hose->mem_space->start >> 32))
706 baddr = addr - hose->mem_space->start;
707 last = baddr + size - 1;
722 baddr >= (
unsigned long)hose->sg_pci->dma_base &&
723 last < (
unsigned long)hose->sg_pci->dma_base + hose->sg_pci->size) {
728 baddr -= hose->sg_pci->dma_base;
729 last -= hose->sg_pci->dma_base;
740 ptes = hose->sg_pci->ptes;
741 for (vaddr = (
unsigned long)area->
addr;
746 printk(
"ioremap failed... pte not valid...\n");
752 if (__alpha_remap_area_pages(vaddr,
755 printk(
"FAILED to map...\n");
769 vaddr = baddr + hose->mem_space->start;
776 unsigned long addr = (
unsigned long) xaddr;
784 unsigned long addr = (
unsigned long) xaddr;
789 return (addr & 0xFF000000UL) == 0;
792 #define __marvel_is_port_kbd(a) (((a) == 0x60) || ((a) == 0x64))
793 #define __marvel_is_port_rtc(a) (((a) == 0x70) || ((a) == 0x71))
804 unsigned long addr = (
unsigned long) xaddr;
808 return __marvel_rtc_io(0, addr, 0);
809 else if (marvel_is_ioaddr(addr))
822 unsigned long addr = (
unsigned long) xaddr;
826 __marvel_rtc_io(b, addr, 1);
827 else if (marvel_is_ioaddr(addr))
831 #ifndef CONFIG_ALPHA_GENERIC
854 cpuid = (~(pa >> 35) & 0xff);
856 cpuid = ((pa >> 34) & 0x3) | ((pa >> (37 - 2)) & (0x1f << 2));
872 pa = (nid & 0x3) | ((nid & (0x1f << 2)) << 1);
881 return 16
UL * 1024 * 1024 * 1024;
890 #include <linux/slab.h>
936 if (status == -
EBUSY) {
938 "Attempted to release bound AGP memory - unbinding\n");
954 struct io7 *io7 = ((
struct io7_port *)agp->
hose->sysdata)->io7;
955 unsigned int new_rate = 0;
956 unsigned long agp_pll;
963 agp_pll = io7->csrs->POx_RST[IO7_AGP_PORT].csr;
988 printk(
"%s: unknown PLL setting RNGB=%lx (PLL6_CTL=%016lx)\n",
997 printk(
"Requested AGP Rate %dX not compatible "
998 "with PLL setting - using %dX\n",
1005 printk(
"Enabling AGP on hose %d: %dX%s RQ %d\n",
1030 static unsigned long
1034 unsigned long baddr = addr - aper->
arena->dma_base;
1037 if (addr < agp->aperture.bus_base ||
1039 printk(
"%s: addr out of range\n", __func__);
1045 printk(
"%s: pte not valid\n", __func__);
1053 .setup = marvel_agp_setup,
1054 .cleanup = marvel_agp_cleanup,
1055 .configure = marvel_agp_configure,
1056 .bind = marvel_agp_bind_memory,
1057 .unbind = marvel_agp_unbind_memory,
1058 .translate = marvel_agp_translate
1080 if (!io7->ports[IO7_AGP_PORT].enabled)
1083 h = io7->ports[IO7_AGP_PORT].hose;
1086 if (*addr != 0xffffffffu) {
1092 if (!hose || !hose->sg_pci)
1095 printk(
"MARVEL - using hose %d as AGP\n", hose->
index);
1100 csrs = ((
struct io7_port *)hose->sysdata)->csrs;