Commit e4328d6b authored by Dave Jones's avatar Dave Jones

[AGPGART] Fix up PCI posting bugs.

Also remove a pointless wrapper.
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 30009319
...@@ -141,16 +141,6 @@ struct agp_bridge_data { ...@@ -141,16 +141,6 @@ struct agp_bridge_data {
char minor_version; char minor_version;
}; };
#define OUTREG64(mmap, addr, val) __raw_writeq((val), (mmap)+(addr))
#define OUTREG32(mmap, addr, val) __raw_writel((val), (mmap)+(addr))
#define OUTREG16(mmap, addr, val) __raw_writew((val), (mmap)+(addr))
#define OUTREG8(mmap, addr, val) __raw_writeb((val), (mmap)+(addr))
#define INREG64(mmap, addr) __raw_readq((mmap)+(addr))
#define INREG32(mmap, addr) __raw_readl((mmap)+(addr))
#define INREG16(mmap, addr) __raw_readw((mmap)+(addr))
#define INREG8(mmap, addr) __raw_readb((mmap)+(addr))
#define KB(x) ((x) * 1024) #define KB(x) ((x) * 1024)
#define MB(x) (KB (KB (x))) #define MB(x) (KB (KB (x)))
#define GB(x) (MB (KB (x))) #define GB(x) (MB (KB (x)))
......
...@@ -53,8 +53,10 @@ static int amd_create_page_map(struct amd_page_map *page_map) ...@@ -53,8 +53,10 @@ static int amd_create_page_map(struct amd_page_map *page_map)
} }
global_cache_flush(); global_cache_flush();
for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) {
writel(agp_bridge->scratch_page, page_map->remapped+i); writel(agp_bridge->scratch_page, page_map->remapped+i);
readl(page_map->remapped+i); /* PCI Posting. */
}
return 0; return 0;
} }
...@@ -167,6 +169,7 @@ static int amd_create_gatt_table(void) ...@@ -167,6 +169,7 @@ static int amd_create_gatt_table(void)
for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { for (i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
writel(virt_to_phys(amd_irongate_private.gatt_pages[i]->real) | 1, writel(virt_to_phys(amd_irongate_private.gatt_pages[i]->real) | 1,
page_dir.remapped+GET_PAGE_DIR_OFF(addr)); page_dir.remapped+GET_PAGE_DIR_OFF(addr));
readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */
} }
return 0; return 0;
...@@ -220,8 +223,8 @@ static int amd_irongate_configure(void) ...@@ -220,8 +223,8 @@ static int amd_irongate_configure(void)
amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096); amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
/* Write out the address of the gatt table */ /* Write out the address of the gatt table */
OUTREG32(amd_irongate_private.registers, AMD_ATTBASE, writel(agp_bridge->gatt_bus_addr, amd_irongate_private.registers+AMD_ATTBASE);
agp_bridge->gatt_bus_addr); readl(amd_irongate_private.registers+AMD_ATTBASE); /* PCI Posting. */
/* Write the Sync register */ /* Write the Sync register */
pci_write_config_byte(agp_bridge->dev, AMD_MODECNTL, 0x80); pci_write_config_byte(agp_bridge->dev, AMD_MODECNTL, 0x80);
...@@ -230,19 +233,19 @@ static int amd_irongate_configure(void) ...@@ -230,19 +233,19 @@ static int amd_irongate_configure(void)
pci_write_config_byte(agp_bridge->dev, AMD_MODECNTL2, 0x00); pci_write_config_byte(agp_bridge->dev, AMD_MODECNTL2, 0x00);
/* Write the enable register */ /* Write the enable register */
enable_reg = INREG16(amd_irongate_private.registers, AMD_GARTENABLE); enable_reg = readw(amd_irongate_private.registers+AMD_GARTENABLE);
enable_reg = (enable_reg | 0x0004); enable_reg = (enable_reg | 0x0004);
OUTREG16(amd_irongate_private.registers, AMD_GARTENABLE, enable_reg); writew(enable_reg, amd_irongate_private.registers+AMD_GARTENABLE);
readw(amd_irongate_private.registers+AMD_GARTENABLE); /* PCI Posting. */
/* Write out the size register */ /* Write out the size register */
pci_read_config_dword(agp_bridge->dev, AMD_APSIZE, &temp); pci_read_config_dword(agp_bridge->dev, AMD_APSIZE, &temp);
temp = (((temp & ~(0x0000000e)) | current_size->size_value) temp = (((temp & ~(0x0000000e)) | current_size->size_value) | 1);
| 0x00000001);
pci_write_config_dword(agp_bridge->dev, AMD_APSIZE, temp); pci_write_config_dword(agp_bridge->dev, AMD_APSIZE, temp);
/* Flush the tlb */ /* Flush the tlb */
OUTREG32(amd_irongate_private.registers, AMD_TLBFLUSH, 0x00000001); writel(1, amd_irongate_private.registers+AMD_TLBFLUSH);
readl(amd_irongate_private.registers+AMD_TLBFLUSH); /* PCI Posting.*/
return 0; return 0;
} }
...@@ -254,9 +257,10 @@ static void amd_irongate_cleanup(void) ...@@ -254,9 +257,10 @@ static void amd_irongate_cleanup(void)
previous_size = A_SIZE_LVL2(agp_bridge->previous_size); previous_size = A_SIZE_LVL2(agp_bridge->previous_size);
enable_reg = INREG16(amd_irongate_private.registers, AMD_GARTENABLE); enable_reg = readw(amd_irongate_private.registers+AMD_GARTENABLE);
enable_reg = (enable_reg & ~(0x0004)); enable_reg = (enable_reg & ~(0x0004));
OUTREG16(amd_irongate_private.registers, AMD_GARTENABLE, enable_reg); writew(enable_reg, amd_irongate_private.registers+AMD_GARTENABLE);
readw(amd_irongate_private.registers+AMD_GARTENABLE); /* PCI Posting. */
/* Write back the previous size and disable gart translation */ /* Write back the previous size and disable gart translation */
pci_read_config_dword(agp_bridge->dev, AMD_APSIZE, &temp); pci_read_config_dword(agp_bridge->dev, AMD_APSIZE, &temp);
...@@ -275,7 +279,8 @@ static void amd_irongate_cleanup(void) ...@@ -275,7 +279,8 @@ static void amd_irongate_cleanup(void)
static void amd_irongate_tlbflush(struct agp_memory *temp) static void amd_irongate_tlbflush(struct agp_memory *temp)
{ {
OUTREG32(amd_irongate_private.registers, AMD_TLBFLUSH, 0x00000001); writel(1, amd_irongate_private.registers+AMD_TLBFLUSH);
readl(amd_irongate_private.registers+AMD_TLBFLUSH); /* PCI Posting. */
} }
static int amd_insert_memory(struct agp_memory *mem, off_t pg_start, int type) static int amd_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
...@@ -310,6 +315,7 @@ static int amd_insert_memory(struct agp_memory *mem, off_t pg_start, int type) ...@@ -310,6 +315,7 @@ static int amd_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr; addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
cur_gatt = GET_GATT(addr); cur_gatt = GET_GATT(addr);
writel(agp_generic_mask_memory(mem->memory[i], mem->type), cur_gatt+GET_GATT_OFF(addr)); writel(agp_generic_mask_memory(mem->memory[i], mem->type), cur_gatt+GET_GATT_OFF(addr));
readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */
} }
amd_irongate_tlbflush(mem); amd_irongate_tlbflush(mem);
return 0; return 0;
...@@ -328,6 +334,7 @@ static int amd_remove_memory(struct agp_memory *mem, off_t pg_start, int type) ...@@ -328,6 +334,7 @@ static int amd_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
addr = (i * PAGE_SIZE) + agp_bridge->gart_bus_addr; addr = (i * PAGE_SIZE) + agp_bridge->gart_bus_addr;
cur_gatt = GET_GATT(addr); cur_gatt = GET_GATT(addr);
writel(agp_bridge->scratch_page, cur_gatt+GET_GATT_OFF(addr)); writel(agp_bridge->scratch_page, cur_gatt+GET_GATT_OFF(addr));
readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */
} }
amd_irongate_tlbflush(mem); amd_irongate_tlbflush(mem);
......
...@@ -72,8 +72,10 @@ static int ati_create_page_map(ati_page_map *page_map) ...@@ -72,8 +72,10 @@ static int ati_create_page_map(ati_page_map *page_map)
/*CACHE_FLUSH();*/ /*CACHE_FLUSH();*/
global_cache_flush(); global_cache_flush();
for(i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) for(i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) {
writel(agp_bridge->scratch_page, page_map->remapped+i); writel(agp_bridge->scratch_page, page_map->remapped+i);
readl(page_map->remapped+i); /* PCI Posting. */
}
return 0; return 0;
} }
...@@ -183,7 +185,8 @@ static int ati_fetch_size(void) ...@@ -183,7 +185,8 @@ static int ati_fetch_size(void)
static void ati_tlbflush(struct agp_memory * mem) static void ati_tlbflush(struct agp_memory * mem)
{ {
OUTREG32(ati_generic_private.registers, ATI_GART_CACHE_CNTRL, 1); writel(1, ati_generic_private.registers+ATI_GART_CACHE_CNTRL);
readl(ati_generic_private.registers+ATI_GART_CACHE_CNTRL); /* PCI Posting. */
} }
static void ati_cleanup(void) static void ati_cleanup(void)
...@@ -227,15 +230,16 @@ static int ati_configure(void) ...@@ -227,15 +230,16 @@ static int ati_configure(void)
agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); agp_bridge.gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
printk(KERN_INFO PFX "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr); printk(KERN_INFO PFX "IGP320 gart_bus_addr: %x\n", agp_bridge.gart_bus_addr);
*/ */
OUTREG32(ati_generic_private.registers, ATI_GART_FEATURE_ID, 0x60000); writel(0x60000, ati_generic_private.registers+ATI_GART_FEATURE_ID);
readl(ati_generic_private.registers+ATI_GART_FEATURE_ID); /* PCI Posting.*/
/* SIGNALED_SYSTEM_ERROR @ NB_STATUS */ /* SIGNALED_SYSTEM_ERROR @ NB_STATUS */
pci_read_config_dword(agp_bridge->dev, 4, &temp); pci_read_config_dword(agp_bridge->dev, 4, &temp);
pci_write_config_dword(agp_bridge->dev, 4, temp | (1<<14)); pci_write_config_dword(agp_bridge->dev, 4, temp | (1<<14));
/* Write out the address of the gatt table */ /* Write out the address of the gatt table */
OUTREG32(ati_generic_private.registers, ATI_GART_BASE, writel(agp_bridge->gatt_bus_addr, ati_generic_private.registers+ATI_GART_BASE);
agp_bridge->gatt_bus_addr); readl(ati_generic_private.registers+ATI_GART_BASE); /* PCI Posting. */
return 0; return 0;
} }
...@@ -288,6 +292,7 @@ static int ati_insert_memory(struct agp_memory * mem, ...@@ -288,6 +292,7 @@ static int ati_insert_memory(struct agp_memory * mem,
addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr; addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
cur_gatt = GET_GATT(addr); cur_gatt = GET_GATT(addr);
writel(agp_bridge->driver->mask_memory(mem->memory[i], mem->type), cur_gatt+GET_GATT_OFF(addr)); writel(agp_bridge->driver->mask_memory(mem->memory[i], mem->type), cur_gatt+GET_GATT_OFF(addr));
readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */
} }
agp_bridge->driver->tlb_flush(mem); agp_bridge->driver->tlb_flush(mem);
return 0; return 0;
...@@ -307,6 +312,7 @@ static int ati_remove_memory(struct agp_memory * mem, off_t pg_start, ...@@ -307,6 +312,7 @@ static int ati_remove_memory(struct agp_memory * mem, off_t pg_start,
addr = (i * PAGE_SIZE) + agp_bridge->gart_bus_addr; addr = (i * PAGE_SIZE) + agp_bridge->gart_bus_addr;
cur_gatt = GET_GATT(addr); cur_gatt = GET_GATT(addr);
writel(agp_bridge->scratch_page, cur_gatt+GET_GATT_OFF(addr)); writel(agp_bridge->scratch_page, cur_gatt+GET_GATT_OFF(addr));
readl(cur_gatt+GET_GATT_OFF(addr)); /* PCI Posting. */
} }
agp_bridge->driver->tlb_flush(mem); agp_bridge->driver->tlb_flush(mem);
...@@ -368,6 +374,7 @@ static int ati_create_gatt_table(void) ...@@ -368,6 +374,7 @@ static int ati_create_gatt_table(void)
for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) { for(i = 0; i < value->num_entries / 1024; i++, addr += 0x00400000) {
writel(virt_to_bus(ati_generic_private.gatt_pages[i]->real) | 1, writel(virt_to_bus(ati_generic_private.gatt_pages[i]->real) | 1,
page_dir.remapped+GET_PAGE_DIR_OFF(addr)); page_dir.remapped+GET_PAGE_DIR_OFF(addr));
readl(page_dir.remapped+GET_PAGE_DIR_OFF(addr)); /* PCI Posting. */
} }
return 0; return 0;
......
...@@ -88,7 +88,7 @@ static int __init hp_zx1_ioc_shared(void) ...@@ -88,7 +88,7 @@ static int __init hp_zx1_ioc_shared(void)
* - IOVA space is 1Gb in size * - IOVA space is 1Gb in size
* - first 512Mb is IOMMU, second 512Mb is GART * - first 512Mb is IOMMU, second 512Mb is GART
*/ */
hp->io_tlb_ps = INREG64(hp->ioc_regs, HP_ZX1_TCNFG); hp->io_tlb_ps = readq(hp->ioc_regs+HP_ZX1_TCNFG);
switch (hp->io_tlb_ps) { switch (hp->io_tlb_ps) {
case 0: hp->io_tlb_shift = 12; break; case 0: hp->io_tlb_shift = 12; break;
case 1: hp->io_tlb_shift = 13; break; case 1: hp->io_tlb_shift = 13; break;
...@@ -104,13 +104,13 @@ static int __init hp_zx1_ioc_shared(void) ...@@ -104,13 +104,13 @@ static int __init hp_zx1_ioc_shared(void)
hp->io_page_size = 1 << hp->io_tlb_shift; hp->io_page_size = 1 << hp->io_tlb_shift;
hp->io_pages_per_kpage = PAGE_SIZE / hp->io_page_size; hp->io_pages_per_kpage = PAGE_SIZE / hp->io_page_size;
hp->iova_base = INREG64(hp->ioc_regs, HP_ZX1_IBASE) & ~0x1; hp->iova_base = readq(hp->ioc_regs+HP_ZX1_IBASE) & ~0x1;
hp->gart_base = hp->iova_base + HP_ZX1_IOVA_SIZE - HP_ZX1_GART_SIZE; hp->gart_base = hp->iova_base + HP_ZX1_IOVA_SIZE - HP_ZX1_GART_SIZE;
hp->gart_size = HP_ZX1_GART_SIZE; hp->gart_size = HP_ZX1_GART_SIZE;
hp->gatt_entries = hp->gart_size / hp->io_page_size; hp->gatt_entries = hp->gart_size / hp->io_page_size;
hp->io_pdir = phys_to_virt(INREG64(hp->ioc_regs, HP_ZX1_PDIR_BASE)); hp->io_pdir = phys_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE));
hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)]; hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)];
if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) { if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) {
...@@ -174,7 +174,7 @@ hp_zx1_ioc_init (u64 hpa) ...@@ -174,7 +174,7 @@ hp_zx1_ioc_init (u64 hpa)
* If the IOTLB is currently disabled, we can take it over. * If the IOTLB is currently disabled, we can take it over.
* Otherwise, we have to share with sba_iommu. * Otherwise, we have to share with sba_iommu.
*/ */
hp->io_pdir_owner = (INREG64(hp->ioc_regs, HP_ZX1_IBASE) & 0x1) == 0; hp->io_pdir_owner = (readq(hp->ioc_regs+HP_ZX1_IBASE) & 0x1) == 0;
if (hp->io_pdir_owner) if (hp->io_pdir_owner)
return hp_zx1_ioc_owner(); return hp_zx1_ioc_owner();
...@@ -189,18 +189,18 @@ hp_zx1_lba_find_capability (volatile u8 __iomem *hpa, int cap) ...@@ -189,18 +189,18 @@ hp_zx1_lba_find_capability (volatile u8 __iomem *hpa, int cap)
u8 pos, id; u8 pos, id;
int ttl = 48; int ttl = 48;
status = INREG16(hpa, PCI_STATUS); status = readw(hpa+PCI_STATUS);
if (!(status & PCI_STATUS_CAP_LIST)) if (!(status & PCI_STATUS_CAP_LIST))
return 0; return 0;
pos = INREG8(hpa, PCI_CAPABILITY_LIST); pos = readb(hpa+PCI_CAPABILITY_LIST);
while (ttl-- && pos >= 0x40) { while (ttl-- && pos >= 0x40) {
pos &= ~3; pos &= ~3;
id = INREG8(hpa, pos + PCI_CAP_LIST_ID); id = readb(hpa+pos+PCI_CAP_LIST_ID);
if (id == 0xff) if (id == 0xff)
break; break;
if (id == cap) if (id == cap)
return pos; return pos;
pos = INREG8(hpa, pos + PCI_CAP_LIST_NEXT); pos = readb(hpa+pos+PCI_CAP_LIST_NEXT);
} }
return 0; return 0;
} }
...@@ -217,7 +217,7 @@ hp_zx1_lba_init (u64 hpa) ...@@ -217,7 +217,7 @@ hp_zx1_lba_init (u64 hpa)
hp->lba_cap_offset = hp_zx1_lba_find_capability(hp->lba_regs, PCI_CAP_ID_AGP); hp->lba_cap_offset = hp_zx1_lba_find_capability(hp->lba_regs, PCI_CAP_ID_AGP);
cap = INREG32(hp->lba_regs, hp->lba_cap_offset) & 0xff; cap = readl(hp->lba_regs+hp->lba_cap_offset) & 0xff;
if (cap != PCI_CAP_ID_AGP) { if (cap != PCI_CAP_ID_AGP) {
printk(KERN_ERR PFX "Invalid capability ID 0x%02x at 0x%x\n", printk(KERN_ERR PFX "Invalid capability ID 0x%02x at 0x%x\n",
cap, hp->lba_cap_offset); cap, hp->lba_cap_offset);
...@@ -245,15 +245,19 @@ hp_zx1_configure (void) ...@@ -245,15 +245,19 @@ hp_zx1_configure (void)
agp_bridge->gart_bus_addr = hp->gart_base; agp_bridge->gart_bus_addr = hp->gart_base;
agp_bridge->capndx = hp->lba_cap_offset; agp_bridge->capndx = hp->lba_cap_offset;
agp_bridge->mode = INREG32(hp->lba_regs, hp->lba_cap_offset + PCI_AGP_STATUS); agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS);
if (hp->io_pdir_owner) { if (hp->io_pdir_owner) {
OUTREG64(hp->ioc_regs, HP_ZX1_PDIR_BASE, virt_to_phys(hp->io_pdir)); writel(virt_to_phys(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE);
OUTREG64(hp->ioc_regs, HP_ZX1_TCNFG, hp->io_tlb_ps); readl(hp->ioc_regs+HP_ZX1_PDIR_BASE);
OUTREG64(hp->ioc_regs, HP_ZX1_IMASK, ~(HP_ZX1_IOVA_SIZE - 1)); writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG);
OUTREG64(hp->ioc_regs, HP_ZX1_IBASE, hp->iova_base | 0x1); readl(hp->ioc_regs+HP_ZX1_TCNFG);
OUTREG64(hp->ioc_regs, HP_ZX1_PCOM, hp->iova_base | log2(HP_ZX1_IOVA_SIZE)); writel(~(HP_ZX1_IOVA_SIZE-1), hp->ioc_regs+HP_ZX1_IMASK);
INREG64(hp->ioc_regs, HP_ZX1_PCOM); readl(hp->ioc_regs+HP_ZX1_IMASK);
writel(hp->iova_base|1, hp->ioc_regs+HP_ZX1_IBASE);
readl(hp->ioc_regs+HP_ZX1_IBASE);
writel(hp->iova_base|log2(HP_ZX1_IOVA_SIZE), hp->ioc_regs+HP_ZX1_PCOM);
readl(hp->ioc_regs+HP_ZX1_PCOM);
} }
return 0; return 0;
...@@ -265,8 +269,10 @@ hp_zx1_cleanup (void) ...@@ -265,8 +269,10 @@ hp_zx1_cleanup (void)
struct _hp_private *hp = &hp_private; struct _hp_private *hp = &hp_private;
if (hp->ioc_regs) { if (hp->ioc_regs) {
if (hp->io_pdir_owner) if (hp->io_pdir_owner) {
OUTREG64(hp->ioc_regs, HP_ZX1_IBASE, 0); writeq(0, hp->ioc_regs+HP_ZX1_IBASE);
readq(hp->ioc_regs+HP_ZX1_IBASE);
}
iounmap(hp->ioc_regs); iounmap(hp->ioc_regs);
} }
if (hp->lba_regs) if (hp->lba_regs)
...@@ -278,8 +284,8 @@ hp_zx1_tlbflush (struct agp_memory *mem) ...@@ -278,8 +284,8 @@ hp_zx1_tlbflush (struct agp_memory *mem)
{ {
struct _hp_private *hp = &hp_private; struct _hp_private *hp = &hp_private;
OUTREG64(hp->ioc_regs, HP_ZX1_PCOM, hp->gart_base | log2(hp->gart_size)); writeq(hp->gart_base | log2(hp->gart_size), hp->ioc_regs+HP_ZX1_PCOM);
INREG64(hp->ioc_regs, HP_ZX1_PCOM); readq(hp->ioc_regs+HP_ZX1_PCOM);
} }
static int static int
...@@ -401,12 +407,11 @@ hp_zx1_enable (u32 mode) ...@@ -401,12 +407,11 @@ hp_zx1_enable (u32 mode)
struct _hp_private *hp = &hp_private; struct _hp_private *hp = &hp_private;
u32 command; u32 command;
command = INREG32(hp->lba_regs, hp->lba_cap_offset + PCI_AGP_STATUS); command = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS);
command = agp_collect_device_status(mode, command); command = agp_collect_device_status(mode, command);
command |= 0x00000100; command |= 0x00000100;
OUTREG32(hp->lba_regs, hp->lba_cap_offset + PCI_AGP_COMMAND, command); writel(command, hp->lba_regs+hp->lba_cap_offset+PCI_AGP_COMMAND);
agp_device_command(command, (mode & AGP8X_MODE) != 0); agp_device_command(command, (mode & AGP8X_MODE) != 0);
} }
......
...@@ -117,7 +117,7 @@ static int intel_i810_configure(void) ...@@ -117,7 +117,7 @@ static int intel_i810_configure(void)
return -ENOMEM; return -ENOMEM;
} }
if ((INREG32(intel_i810_private.registers, I810_DRAM_CTL) if ((readl(intel_i810_private.registers+I810_DRAM_CTL)
& I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
/* This will need to be dynamically assigned */ /* This will need to be dynamically assigned */
printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n"); printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n");
...@@ -125,23 +125,23 @@ static int intel_i810_configure(void) ...@@ -125,23 +125,23 @@ static int intel_i810_configure(void)
} }
pci_read_config_dword(intel_i810_private.i810_dev, I810_GMADDR, &temp); pci_read_config_dword(intel_i810_private.i810_dev, I810_GMADDR, &temp);
agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
OUTREG32(intel_i810_private.registers, I810_PGETBL_CTL, writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_i810_private.registers+I810_PGETBL_CTL);
agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED); readl(intel_i810_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
global_cache_flush();
if (agp_bridge->driver->needs_scratch_page) { if (agp_bridge->driver->needs_scratch_page) {
for (i = 0; i < current_size->num_entries; i++) { for (i = 0; i < current_size->num_entries; i++) {
OUTREG32(intel_i810_private.registers, writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4));
I810_PTE_BASE + (i * 4), readl(intel_i810_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */
agp_bridge->scratch_page);
} }
} }
global_cache_flush();
return 0; return 0;
} }
static void intel_i810_cleanup(void) static void intel_i810_cleanup(void)
{ {
OUTREG32(intel_i810_private.registers, I810_PGETBL_CTL, 0); writel(I810_PGETBL_CTL, intel_i810_private.registers);
readl(intel_i810_private.registers); /* PCI Posting. */
iounmap(intel_i810_private.registers); iounmap(intel_i810_private.registers);
} }
...@@ -214,10 +214,8 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, ...@@ -214,10 +214,8 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
/* special insert */ /* special insert */
global_cache_flush(); global_cache_flush();
for (i = pg_start; i < (pg_start + mem->page_count); i++) { for (i = pg_start; i < (pg_start + mem->page_count); i++) {
OUTREG32(intel_i810_private.registers, writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, intel_i810_private.registers+I810_PTE_BASE+(i*4));
I810_PTE_BASE + (i * 4), readl(intel_i810_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
(i * 4096) | I810_PTE_LOCAL |
I810_PTE_VALID);
} }
global_cache_flush(); global_cache_flush();
agp_bridge->driver->tlb_flush(mem); agp_bridge->driver->tlb_flush(mem);
...@@ -231,9 +229,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, ...@@ -231,9 +229,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
insert: insert:
global_cache_flush(); global_cache_flush();
for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
OUTREG32(intel_i810_private.registers, writel(agp_bridge->driver->mask_memory(mem->memory[i], mem->type),
I810_PTE_BASE + (j * 4), intel_i810_private.registers+I810_PTE_BASE+(j*4));
agp_bridge->driver->mask_memory(mem->memory[i], mem->type)); readl(intel_i810_private.registers+I810_PTE_BASE+(j*4)); /* PCI Posting. */
} }
global_cache_flush(); global_cache_flush();
...@@ -247,9 +245,8 @@ static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start, ...@@ -247,9 +245,8 @@ static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
int i; int i;
for (i = pg_start; i < (mem->page_count + pg_start); i++) { for (i = pg_start; i < (mem->page_count + pg_start); i++) {
OUTREG32(intel_i810_private.registers, writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4));
I810_PTE_BASE + (i * 4), readl(intel_i810_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
agp_bridge->scratch_page);
} }
global_cache_flush(); global_cache_flush();
...@@ -390,8 +387,7 @@ static void intel_i830_init_gtt_entries(void) ...@@ -390,8 +387,7 @@ static void intel_i830_init_gtt_entries(void)
gtt_entries = MB(8) - KB(size); gtt_entries = MB(8) - KB(size);
break; break;
case I830_GMCH_GMS_LOCAL: case I830_GMCH_GMS_LOCAL:
rdct = INREG8(intel_i830_private.registers, rdct = readb(intel_i830_private.registers+I830_RDRAM_CHANNEL_TYPE);
I830_RDRAM_CHANNEL_TYPE);
gtt_entries = (I830_RDRAM_ND(rdct) + 1) * gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
MB(ddt[I830_RDRAM_DDT(rdct)]); MB(ddt[I830_RDRAM_DDT(rdct)]);
local = 1; local = 1;
...@@ -468,8 +464,8 @@ static int intel_i830_create_gatt_table(void) ...@@ -468,8 +464,8 @@ static int intel_i830_create_gatt_table(void)
if (!intel_i830_private.registers) if (!intel_i830_private.registers)
return (-ENOMEM); return (-ENOMEM);
temp = INREG32(intel_i830_private.registers,I810_PGETBL_CTL) & 0xfffff000; temp = readb(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
global_cache_flush(); global_cache_flush(); /* FIXME: ?? */
/* we have to call this as early as possible after the MMIO base address is known */ /* we have to call this as early as possible after the MMIO base address is known */
intel_i830_init_gtt_entries(); intel_i830_init_gtt_entries();
...@@ -535,13 +531,17 @@ static int intel_i830_configure(void) ...@@ -535,13 +531,17 @@ static int intel_i830_configure(void)
gmch_ctrl |= I830_GMCH_ENABLED; gmch_ctrl |= I830_GMCH_ENABLED;
pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
OUTREG32(intel_i830_private.registers,I810_PGETBL_CTL,agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED); writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL);
global_cache_flush(); readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
if (agp_bridge->driver->needs_scratch_page) if (agp_bridge->driver->needs_scratch_page) {
for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) {
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (i * 4),agp_bridge->scratch_page); writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4));
readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
}
}
global_cache_flush();
return (0); return (0);
} }
...@@ -550,8 +550,7 @@ static void intel_i830_cleanup(void) ...@@ -550,8 +550,7 @@ static void intel_i830_cleanup(void)
iounmap(intel_i830_private.registers); iounmap(intel_i830_private.registers);
} }
static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type)
int type)
{ {
int i,j,num_entries; int i,j,num_entries;
void *temp; void *temp;
...@@ -578,16 +577,16 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, ...@@ -578,16 +577,16 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start,
(mem->type != 0 && mem->type != AGP_PHYS_MEMORY)) (mem->type != 0 && mem->type != AGP_PHYS_MEMORY))
return (-EINVAL); return (-EINVAL);
global_cache_flush(); global_cache_flush(); /* FIXME: Necessary ?*/
for (i = 0, j = pg_start; i < mem->page_count; i++, j++) for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (j * 4), writel(agp_bridge->driver->mask_memory(mem->memory[i], mem->type),
agp_bridge->driver->mask_memory(mem->memory[i], mem->type)); intel_i830_private.registers+I810_PTE_BASE+(j*4));
readl(intel_i830_private.registers+I810_PTE_BASE+(j*4)); /* PCI Posting. */
}
global_cache_flush(); global_cache_flush();
agp_bridge->driver->tlb_flush(mem); agp_bridge->driver->tlb_flush(mem);
return(0); return(0);
} }
...@@ -603,13 +602,13 @@ static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start, ...@@ -603,13 +602,13 @@ static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start,
return (-EINVAL); return (-EINVAL);
} }
for (i = pg_start; i < (mem->page_count + pg_start); i++) for (i = pg_start; i < (mem->page_count + pg_start); i++) {
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (i * 4),agp_bridge->scratch_page); writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4));
readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
}
global_cache_flush(); global_cache_flush();
agp_bridge->driver->tlb_flush(mem); agp_bridge->driver->tlb_flush(mem);
return (0); return (0);
} }
...@@ -639,14 +638,17 @@ static int intel_i915_configure(void) ...@@ -639,14 +638,17 @@ static int intel_i915_configure(void)
gmch_ctrl |= I830_GMCH_ENABLED; gmch_ctrl |= I830_GMCH_ENABLED;
pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
OUTREG32(intel_i830_private.registers,I810_PGETBL_CTL,agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED); writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL);
global_cache_flush(); readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
if (agp_bridge->driver->needs_scratch_page) { if (agp_bridge->driver->needs_scratch_page) {
for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) {
OUTREG32(intel_i830_private.gtt, i, agp_bridge->scratch_page); writel(agp_bridge->scratch_page, intel_i830_private.gtt+i);
readl(intel_i830_private.gtt+i); /* PCI Posting. */
}
} }
global_cache_flush();
return (0); return (0);
} }
...@@ -686,13 +688,13 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start, ...@@ -686,13 +688,13 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
global_cache_flush(); global_cache_flush();
for (i = 0, j = pg_start; i < mem->page_count; i++, j++) for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
OUTREG32(intel_i830_private.gtt, j, agp_bridge->driver->mask_memory(mem->memory[i], mem->type)); writel(agp_bridge->driver->mask_memory(mem->memory[i], mem->type), intel_i830_private.gtt+j);
readl(intel_i830_private.gtt+j); /* PCI Posting. */
}
global_cache_flush(); global_cache_flush();
agp_bridge->driver->tlb_flush(mem); agp_bridge->driver->tlb_flush(mem);
return(0); return(0);
} }
...@@ -708,13 +710,13 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start, ...@@ -708,13 +710,13 @@ static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
return (-EINVAL); return (-EINVAL);
} }
for (i = pg_start; i < (mem->page_count + pg_start); i++) for (i = pg_start; i < (mem->page_count + pg_start); i++) {
OUTREG32(intel_i830_private.gtt, i, agp_bridge->scratch_page); writel(agp_bridge->scratch_page, intel_i830_private.gtt+i);
readl(intel_i830_private.gtt+i);
}
global_cache_flush(); global_cache_flush();
agp_bridge->driver->tlb_flush(mem); agp_bridge->driver->tlb_flush(mem);
return (0); return (0);
} }
...@@ -764,8 +766,8 @@ static int intel_i915_create_gatt_table(void) ...@@ -764,8 +766,8 @@ static int intel_i915_create_gatt_table(void)
if (!intel_i830_private.registers) if (!intel_i830_private.registers)
return (-ENOMEM); return (-ENOMEM);
temp = INREG32(intel_i830_private.registers,I810_PGETBL_CTL) & 0xfffff000; temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
global_cache_flush(); global_cache_flush(); /* FIXME: ? */
/* we have to call this as early as possible after the MMIO base address is known */ /* we have to call this as early as possible after the MMIO base address is known */
intel_i830_init_gtt_entries(); intel_i830_init_gtt_entries();
......
...@@ -111,8 +111,7 @@ static void intel_i830_init_gtt_entries(void) ...@@ -111,8 +111,7 @@ static void intel_i830_init_gtt_entries(void)
gtt_entries = MB(8) - KB(132); gtt_entries = MB(8) - KB(132);
break; break;
case I830_GMCH_GMS_LOCAL: case I830_GMCH_GMS_LOCAL:
rdct = INREG8(intel_i830_private.registers, rdct = readb(intel_i830_private.registers+I830_RDRAM_CHANNEL_TYPE);
I830_RDRAM_CHANNEL_TYPE);
gtt_entries = (I830_RDRAM_ND(rdct) + 1) * gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
MB(ddt[I830_RDRAM_DDT(rdct)]); MB(ddt[I830_RDRAM_DDT(rdct)]);
local = 1; local = 1;
...@@ -176,8 +175,8 @@ static int intel_i830_create_gatt_table(void) ...@@ -176,8 +175,8 @@ static int intel_i830_create_gatt_table(void)
if (!intel_i830_private.registers) if (!intel_i830_private.registers)
return (-ENOMEM); return (-ENOMEM);
temp = INREG32(intel_i830_private.registers,I810_PGETBL_CTL) & 0xfffff000; temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
global_cache_flush(); global_cache_flush(); /* FIXME: ?? */
/* we have to call this as early as possible after the MMIO base address is known */ /* we have to call this as early as possible after the MMIO base address is known */
intel_i830_init_gtt_entries(); intel_i830_init_gtt_entries();
...@@ -243,13 +242,16 @@ static int intel_i830_configure(void) ...@@ -243,13 +242,16 @@ static int intel_i830_configure(void)
gmch_ctrl |= I830_GMCH_ENABLED; gmch_ctrl |= I830_GMCH_ENABLED;
pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl); pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
OUTREG32(intel_i830_private.registers,I810_PGETBL_CTL,agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED); writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL);
global_cache_flush(); readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
if (agp_bridge->driver->needs_scratch_page)
for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++)
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (i * 4),agp_bridge->scratch_page);
if (agp_bridge->driver->needs_scratch_page) {
for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) {
writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4));
readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
}
}
global_cache_flush();
return (0); return (0);
} }
...@@ -286,11 +288,13 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, ...@@ -286,11 +288,13 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start,
(mem->type != 0 && mem->type != AGP_PHYS_MEMORY)) (mem->type != 0 && mem->type != AGP_PHYS_MEMORY))
return (-EINVAL); return (-EINVAL);
global_cache_flush(); global_cache_flush(); /* FIXME: ?? */
for (i = 0, j = pg_start; i < mem->page_count; i++, j++) for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (j * 4), writel(agp_bridge->driver->mask_memory(mem->memory[i], mem->type),
agp_bridge->driver->mask_memory(mem->memory[i], mem->type)); intel_i830_private.registers+I810_PTE_BASE+(j*4));
readl(intel_i830_private.registers+I810_PTE_BASE+(j*4)); /* PCI Posting. */
}
global_cache_flush(); global_cache_flush();
...@@ -311,13 +315,13 @@ static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start, ...@@ -311,13 +315,13 @@ static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start,
return (-EINVAL); return (-EINVAL);
} }
for (i = pg_start; i < (mem->page_count + pg_start); i++) for (i = pg_start; i < (mem->page_count + pg_start); i++) {
OUTREG32(intel_i830_private.registers,I810_PTE_BASE + (i * 4),agp_bridge->scratch_page); writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4));
readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
}
global_cache_flush(); global_cache_flush();
agp_bridge->driver->tlb_flush(mem); agp_bridge->driver->tlb_flush(mem);
return (0); return (0);
} }
......
...@@ -242,12 +242,12 @@ static int serverworks_fetch_size(void) ...@@ -242,12 +242,12 @@ static int serverworks_fetch_size(void)
*/ */
static void serverworks_tlbflush(struct agp_memory *temp) static void serverworks_tlbflush(struct agp_memory *temp)
{ {
OUTREG8(serverworks_private.registers, SVWRKS_POSTFLUSH, 1); writeb(1, serverworks_private.registers+SVWRKS_POSTFLUSH);
while(INREG8(serverworks_private.registers, SVWRKS_POSTFLUSH) == 1) while (readb(serverworks_private.registers+SVWRKS_POSTFLUSH) == 1)
cpu_relax(); cpu_relax();
OUTREG32(serverworks_private.registers, SVWRKS_DIRFLUSH, 1); writel(1, serverworks_private.registers+SVWRKS_DIRFLUSH);
while(INREG32(serverworks_private.registers, SVWRKS_DIRFLUSH) == 1) while(readl(serverworks_private.registers+SVWRKS_DIRFLUSH) == 1)
cpu_relax(); cpu_relax();
} }
...@@ -269,21 +269,20 @@ static int serverworks_configure(void) ...@@ -269,21 +269,20 @@ static int serverworks_configure(void)
return -ENOMEM; return -ENOMEM;
} }
OUTREG8(serverworks_private.registers, SVWRKS_GART_CACHE, 0x0a); writeb(0xA, serverworks_private.registers+SVWRKS_GART_CACHE);
readb(serverworks_private.registers+SVWRKS_GART_CACHE); /* PCI Posting. */
OUTREG32(serverworks_private.registers, SVWRKS_GATTBASE, writel(agp_bridge->gatt_bus_addr, serverworks_private.registers+SVWRKS_GATTBASE);
agp_bridge->gatt_bus_addr); readl(serverworks_private.registers+SVWRKS_GATTBASE); /* PCI Posting. */
cap_reg = INREG16(serverworks_private.registers, SVWRKS_COMMAND); cap_reg = readw(serverworks_private.registers+SVWRKS_COMMAND);
cap_reg &= ~0x0007; cap_reg &= ~0x0007;
cap_reg |= 0x4; cap_reg |= 0x4;
OUTREG16(serverworks_private.registers, SVWRKS_COMMAND, cap_reg); writew(cap_reg, serverworks_private.registers+SVWRKS_COMMAND);
pci_read_config_byte(serverworks_private.svrwrks_dev, pci_read_config_byte(serverworks_private.svrwrks_dev,SVWRKS_AGP_ENABLE, &enable_reg);
SVWRKS_AGP_ENABLE, &enable_reg);
enable_reg |= 0x1; /* Agp Enable bit */ enable_reg |= 0x1; /* Agp Enable bit */
pci_write_config_byte(serverworks_private.svrwrks_dev, pci_write_config_byte(serverworks_private.svrwrks_dev,SVWRKS_AGP_ENABLE, enable_reg);
SVWRKS_AGP_ENABLE, enable_reg);
serverworks_tlbflush(NULL); serverworks_tlbflush(NULL);
agp_bridge->capndx = pci_find_capability(serverworks_private.svrwrks_dev, PCI_CAP_ID_AGP); agp_bridge->capndx = pci_find_capability(serverworks_private.svrwrks_dev, PCI_CAP_ID_AGP);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment