7 #define __EXTERN_INLINE inline
10 #undef __EXTERN_INLINE
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/pci.h>
15 #include <linux/sched.h>
20 #include <asm/ptrace.h>
22 #include <asm/pgalloc.h>
23 #include <asm/tlbflush.h>
41 static int titan_pchip1_present;
47 #define DEBUG_CONFIG 0
50 # define DBG_CFG(args) printk args
52 # define DBG_CFG(args)
59 static inline volatile unsigned long *
68 volatile unsigned long *tig_addr = mk_tig_addr(offset);
69 return (
u8)(*tig_addr & 0xff);
73 titan_write_tig(
int offset,
u8 value)
75 volatile unsigned long *tig_addr = mk_tig_addr(offset);
76 *tig_addr = (
unsigned long)value;
115 mk_conf_addr(
struct pci_bus *pbus,
unsigned int device_fn,
int where,
116 unsigned long *
pci_addr,
unsigned char *type1)
122 DBG_CFG((
"mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x, "
123 "pci_addr=0x%p, type1=0x%p)\n",
124 bus, device_fn, where, pci_addr, type1));
130 addr = (bus << 16) | (device_fn << 8) | where;
131 addr |= hose->config_space_base;
134 DBG_CFG((
"mk_conf_addr: returning pci_addr 0x%lx\n", addr));
139 titan_read_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
145 if (mk_conf_addr(bus, devfn, where, &addr, &type1))
156 *value = *(
vuip)addr;
164 titan_write_config(
struct pci_bus *bus,
unsigned int devfn,
int where,
170 if (mk_conf_addr(bus, devfn, where, &addr, &type1))
196 .read = titan_read_config,
197 .write = titan_write_config,
207 volatile unsigned long *
csr;
221 if (((start ^ end) & 0xffff0000) == 0)
226 value = (start & 0xffff0000) >> 12;
242 return pctl.pctl_r_bits.apctl_v_agp_present;
264 hose->sparse_mem_base = 0;
265 hose->sparse_io_base = 0;
267 = (
TITAN_MEM(index) & 0xffffffffff
UL) | 0x80000000000UL;
269 = (
TITAN_IO(index) & 0xffffffffff
UL) | 0x80000000000UL;
280 hose->mem_space->end = hose->mem_space->start + 0xffffffff;
293 saved_config[
index].wsba[0] = port->
wsba[0].csr;
294 saved_config[
index].wsm[0] = port->
wsm[0].csr;
295 saved_config[
index].tba[0] = port->
tba[0].csr;
297 saved_config[
index].wsba[1] = port->
wsba[1].csr;
298 saved_config[
index].wsm[1] = port->
wsm[1].csr;
299 saved_config[
index].tba[1] = port->
tba[1].csr;
301 saved_config[
index].wsba[2] = port->
wsba[2].csr;
302 saved_config[
index].wsm[2] = port->
wsm[2].csr;
303 saved_config[
index].tba[2] = port->
tba[2].csr;
305 saved_config[
index].wsba[3] = port->
wsba[3].csr;
306 saved_config[
index].wsm[3] = port->
wsm[3].csr;
307 saved_config[
index].tba[3] = port->
tba[3].csr;
319 hose->sg_isa->align_entry = 8;
322 hose->sg_pci->align_entry = 4;
324 port->
wsba[0].csr = hose->sg_isa->dma_base | 3;
325 port->
wsm[0].csr = (hose->sg_isa->size - 1) & 0xfff00000;
330 port->
tba[1].csr = 0;
332 port->
wsba[2].csr = hose->sg_pci->dma_base | 3;
333 port->
wsm[2].csr = (hose->sg_pci->size - 1) & 0xfff00000;
336 port->
wsba[3].csr = 0;
344 if (titan_query_agp(port))
356 titan_init_one_pachip_port(&pachip0->
g_port, 0);
357 if (titan_pchip1_present)
358 titan_init_one_pachip_port(&pachip1->
g_port, 1);
359 titan_init_one_pachip_port(&pachip0->
a_port, 2);
360 if (titan_pchip1_present)
361 titan_init_one_pachip_port(&pachip1->
a_port, 3);
368 printk(
"%s: titan_init_arch()\n", __func__);
369 printk(
"%s: CChip registers:\n", __func__);
379 printk(
"%s: DChip registers:\n", __func__);
399 find_console_vga_hose();
405 port->
wsba[0].csr = saved_config[
index].wsba[0];
406 port->
wsm[0].csr = saved_config[
index].wsm[0];
407 port->
tba[0].csr = saved_config[
index].tba[0];
409 port->
wsba[1].csr = saved_config[
index].wsba[1];
410 port->
wsm[1].csr = saved_config[
index].wsm[1];
411 port->
tba[1].csr = saved_config[
index].tba[1];
413 port->
wsba[2].csr = saved_config[
index].wsba[2];
414 port->
wsm[2].csr = saved_config[
index].wsm[2];
415 port->
tba[2].csr = saved_config[
index].tba[2];
417 port->
wsba[3].csr = saved_config[
index].wsba[3];
418 port->
wsm[3].csr = saved_config[
index].wsm[3];
419 port->
tba[3].csr = saved_config[
index].tba[3];
425 if (titan_pchip1_present) {
426 titan_kill_one_pachip_port(&pachip1->
g_port, 1);
427 titan_kill_one_pachip_port(&pachip1->
a_port, 3);
429 titan_kill_one_pachip_port(&pachip0->
g_port, 0);
430 titan_kill_one_pachip_port(&pachip0->
a_port, 2);
457 unsigned long last = baddr + size - 1;
475 for (hose =
hose_head; hose; hose = hose->next)
476 if (hose->
index == h)
494 baddr >= (
unsigned long)hose->sg_pci->dma_base &&
495 last < (
unsigned long)hose->sg_pci->dma_base + hose->sg_pci->size){
500 baddr -= hose->sg_pci->dma_base;
501 last -= hose->sg_pci->dma_base;
510 printk(
"ioremap failed... no vm_area...\n");
514 ptes = hose->sg_pci->ptes;
515 for (vaddr = (
unsigned long)area->
addr;
520 printk(
"ioremap failed... pte not valid...\n");
526 if (__alpha_remap_area_pages(vaddr,
529 printk(
"FAILED to remap_area_pages...\n");
548 unsigned long addr = (
unsigned long) xaddr;
556 unsigned long addr = (
unsigned long) xaddr;
561 return (addr & 0x100000000UL) == 0;
564 #ifndef CONFIG_ALPHA_GENERIC
576 #include <linux/slab.h>
622 if (status == -
EBUSY) {
624 "Attempted to release bound AGP memory - unbinding\n");
641 pctl.pctl_q_whole = port->pctl.csr;
644 pctl.pctl_r_bits.apctl_v_agp_sba_en = agp->
mode.
bits.sba;
647 pctl.pctl_r_bits.apctl_v_agp_rate = 0;
649 pctl.pctl_r_bits.apctl_v_agp_rate = 1;
652 pctl.pctl_r_bits.apctl_v_agp_rate = 2;
656 pctl.pctl_r_bits.apctl_v_agp_hp_rd = 2;
657 pctl.pctl_r_bits.apctl_v_agp_lp_rd = 7;
662 pctl.pctl_r_bits.apctl_v_agp_en = agp->
mode.
bits.enable;
665 printk(
"Enabling AGP: %dX%s\n",
666 1 << pctl.pctl_r_bits.apctl_v_agp_rate,
667 pctl.pctl_r_bits.apctl_v_agp_sba_en ?
" - SBA" :
"");
670 port->pctl.csr = pctl.pctl_q_whole;
698 unsigned long baddr = addr - aper->
arena->dma_base;
701 if (addr < agp->aperture.bus_base ||
703 printk(
"%s: addr out of range\n", __func__);
709 printk(
"%s: pte not valid\n", __func__);
718 .setup = titan_agp_setup,
719 .cleanup = titan_agp_cleanup,
720 .configure = titan_agp_configure,
721 .bind = titan_agp_bind_memory,
722 .unbind = titan_agp_unbind_memory,
723 .translate = titan_agp_translate
739 if (titan_query_agp(port))
742 titan_pchip1_present &&
749 for (hose =
hose_head; hose; hose = hose->next)
750 if (hose->
index == hosenum)
753 if (!hose || !hose->sg_pci)