Commit 3370f17c authored by Dave Jones's avatar Dave Jones

[AGPGART] Replace enum users with own methods.

By introducing a few extra functions, we can kill off a few extra members
of the enum. More work from Christoph Hellwig.
parent aa056739
...@@ -121,44 +121,48 @@ static unsigned long ali_mask_memory(unsigned long addr, int type) ...@@ -121,44 +121,48 @@ static unsigned long ali_mask_memory(unsigned long addr, int type)
return addr | agp_bridge->masks[0].mask; return addr | agp_bridge->masks[0].mask;
} }
static void ali_cache_flush(void) static void m1541_cache_flush(void)
{ {
int i, page_count;
u32 temp;
global_cache_flush(); global_cache_flush();
if (agp_bridge->type == ALI_M1541) { page_count = 1 << A_SIZE_32(agp_bridge->current_size)->page_order;
int i, page_count; for (i = 0; i < PAGE_SIZE * page_count; i += PAGE_SIZE) {
u32 temp; pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
&temp);
page_count = 1 << A_SIZE_32(agp_bridge->current_size)->page_order; pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
for (i = 0; i < PAGE_SIZE * page_count; i += PAGE_SIZE) { (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); (agp_bridge->gatt_bus_addr + i)) |
pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, ALI_CACHE_FLUSH_EN));
(((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
(agp_bridge->gatt_bus_addr + i)) |
ALI_CACHE_FLUSH_EN));
}
} }
} }
static void *ali_alloc_page(void) static void *m1541_alloc_page(void)
{ {
void *adr = agp_generic_alloc_page(); void *addr = agp_generic_alloc_page();
u32 temp; u32 temp;
if (adr == 0) if (!addr)
return 0; return NULL;
pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
(((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN ));
return addr;
}
if (agp_bridge->type == ALI_M1541) { static void ali_destroy_page(void * addr)
pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); {
pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, if (addr) {
(((temp & ALI_CACHE_FLUSH_ADDR_MASK) | global_cache_flush(); /* is this really needed? --hch */
virt_to_phys(adr)) | agp_generic_destroy_page(addr);
ALI_CACHE_FLUSH_EN ));
} }
return adr;
} }
static void ali_destroy_page(void * addr) static void m1541_destroy_page(void * addr)
{ {
u32 temp; u32 temp;
...@@ -167,17 +171,14 @@ static void ali_destroy_page(void * addr) ...@@ -167,17 +171,14 @@ static void ali_destroy_page(void * addr)
global_cache_flush(); global_cache_flush();
if (agp_bridge->type == ALI_M1541) { pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp);
pci_read_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, &temp); pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL,
pci_write_config_dword(agp_bridge->dev, ALI_CACHE_FLUSH_CTRL, (((temp & ALI_CACHE_FLUSH_ADDR_MASK) |
(((temp & ALI_CACHE_FLUSH_ADDR_MASK) | virt_to_phys(addr)) | ALI_CACHE_FLUSH_EN));
virt_to_phys(addr)) |
ALI_CACHE_FLUSH_EN));
}
agp_generic_destroy_page(addr); agp_generic_destroy_page(addr);
} }
/* Setup function */ /* Setup function */
static struct gatt_mask ali_generic_masks[] = static struct gatt_mask ali_generic_masks[] =
{ {
...@@ -207,24 +208,49 @@ struct agp_bridge_data ali_generic_bridge = { ...@@ -207,24 +208,49 @@ struct agp_bridge_data ali_generic_bridge = {
.tlb_flush = ali_tlbflush, .tlb_flush = ali_tlbflush,
.mask_memory = ali_mask_memory, .mask_memory = ali_mask_memory,
.agp_enable = agp_generic_enable, .agp_enable = agp_generic_enable,
.cache_flush = ali_cache_flush, .cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table, .create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table, .free_gatt_table = agp_generic_free_gatt_table,
.insert_memory = agp_generic_insert_memory, .insert_memory = agp_generic_insert_memory,
.remove_memory = agp_generic_remove_memory, .remove_memory = agp_generic_remove_memory,
.alloc_by_type = agp_generic_alloc_by_type, .alloc_by_type = agp_generic_alloc_by_type,
.free_by_type = agp_generic_free_by_type, .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = ali_alloc_page, .agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = ali_destroy_page, .agp_destroy_page = ali_destroy_page,
.suspend = agp_generic_suspend, .suspend = agp_generic_suspend,
.resume = agp_generic_resume, .resume = agp_generic_resume,
}; };
struct agp_bridge_data ali_m1541_bridge = {
.type = ALI_GENERIC,
.masks = ali_generic_masks,
.aperture_sizes = (void *)ali_generic_sizes,
.size_type = U32_APER_SIZE,
.num_aperture_sizes = 7,
.configure = ali_configure,
.fetch_size = ali_fetch_size,
.cleanup = ali_cleanup,
.tlb_flush = ali_tlbflush,
.mask_memory = ali_mask_memory,
.agp_enable = agp_generic_enable,
.cache_flush = m1541_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
.insert_memory = agp_generic_insert_memory,
.remove_memory = agp_generic_remove_memory,
.alloc_by_type = agp_generic_alloc_by_type,
.free_by_type = agp_generic_free_by_type,
.agp_alloc_page = m1541_alloc_page,
.agp_destroy_page = m1541_destroy_page,
.suspend = agp_generic_suspend,
.resume = agp_generic_resume,
};
struct agp_device_ids ali_agp_device_ids[] __initdata = struct agp_device_ids ali_agp_device_ids[] __initdata =
{ {
{ {
.device_id = PCI_DEVICE_ID_AL_M1541, .device_id = PCI_DEVICE_ID_AL_M1541,
.chipset = ALI_M1541,
.chipset_name = "M1541", .chipset_name = "M1541",
}, },
{ {
...@@ -270,6 +296,7 @@ static int __init agp_ali_probe(struct pci_dev *pdev, ...@@ -270,6 +296,7 @@ static int __init agp_ali_probe(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
struct agp_device_ids *devs = ali_agp_device_ids; struct agp_device_ids *devs = ali_agp_device_ids;
struct agp_bridge_data *bridge;
u8 hidden_1621_id, cap_ptr; u8 hidden_1621_id, cap_ptr;
int j; int j;
...@@ -293,12 +320,13 @@ static int __init agp_ali_probe(struct pci_dev *pdev, ...@@ -293,12 +320,13 @@ static int __init agp_ali_probe(struct pci_dev *pdev,
printk(KERN_WARNING PFX "Trying generic ALi routines" printk(KERN_WARNING PFX "Trying generic ALi routines"
" for device id: %04x\n", pdev->device); " for device id: %04x\n", pdev->device);
bridge = &ali_generic_bridge;
goto generic; goto generic;
found: found:
switch (pdev->device == PCI_DEVICE_ID_AL_M1621) { switch (pdev->device) {
case PCI_DEVICE_ID_AL_M1541: case PCI_DEVICE_ID_AL_M1541:
ali_generic_bridge.type = ALI_M1541; bridge = &ali_m1541_bridge;
break; break;
case PCI_DEVICE_ID_AL_M1621: case PCI_DEVICE_ID_AL_M1621:
pci_read_config_byte(pdev, 0xFB, &hidden_1621_id); pci_read_config_byte(pdev, 0xFB, &hidden_1621_id);
...@@ -323,20 +351,22 @@ static int __init agp_ali_probe(struct pci_dev *pdev, ...@@ -323,20 +351,22 @@ static int __init agp_ali_probe(struct pci_dev *pdev,
default: default:
break; break;
} }
default:
bridge = &ali_generic_bridge;
} }
printk(KERN_INFO PFX "Detected ALi %s chipset\n", printk(KERN_INFO PFX "Detected ALi %s chipset\n",
devs[j].chipset_name); devs[j].chipset_name);
generic: generic:
ali_generic_bridge.dev = pdev; bridge->dev = pdev;
ali_generic_bridge.capndx = cap_ptr; bridge->capndx = cap_ptr;
/* Fill in the mode register */ /* Fill in the mode register */
pci_read_config_dword(pdev, pci_read_config_dword(pdev,
ali_generic_bridge.capndx+PCI_AGP_STATUS, bridge->capndx+PCI_AGP_STATUS,
&ali_generic_bridge.mode); &bridge->mode);
memcpy(agp_bridge, &ali_generic_bridge, sizeof(struct agp_bridge_data)); memcpy(agp_bridge, bridge, sizeof(struct agp_bridge_data));
ali_agp_driver.dev = pdev; ali_agp_driver.dev = pdev;
agp_register_driver(&ali_agp_driver); agp_register_driver(&ali_agp_driver);
......
...@@ -552,19 +552,11 @@ static int intel_fetch_size(void) ...@@ -552,19 +552,11 @@ static int intel_fetch_size(void)
return 0; return 0;
} }
static int intel_8xx_fetch_size(void) static int __intel_8xx_fetch_size(u8 temp)
{ {
int i; int i;
u8 temp;
struct aper_size_info_8 *values; struct aper_size_info_8 *values;
pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
/* Intel 815 chipsets have a _weird_ APSIZE register with only
* one non-reserved bit, so mask the others out ... */
if (agp_bridge->type == INTEL_I815)
temp &= (1 << 3);
values = A_SIZE_8(agp_bridge->aperture_sizes); values = A_SIZE_8(agp_bridge->aperture_sizes);
for (i = 0; i < agp_bridge->num_aperture_sizes; i++) { for (i = 0; i < agp_bridge->num_aperture_sizes; i++) {
...@@ -578,6 +570,25 @@ static int intel_8xx_fetch_size(void) ...@@ -578,6 +570,25 @@ static int intel_8xx_fetch_size(void)
return 0; return 0;
} }
static int intel_8xx_fetch_size(void)
{
u8 temp;
pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
return __intel_8xx_fetch_size(temp);
}
static int intel_815_fetch_size(void)
{
u8 temp;
/* Intel 815 chipsets have a _weird_ APSIZE register with only
* one non-reserved bit, so mask the others out ... */
pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
temp &= (1 << 3);
return __intel_8xx_fetch_size(temp);
}
static void intel_tlbflush(agp_memory * mem) static void intel_tlbflush(agp_memory * mem)
{ {
...@@ -1026,13 +1037,13 @@ struct agp_bridge_data intel_810_bridge = { ...@@ -1026,13 +1037,13 @@ struct agp_bridge_data intel_810_bridge = {
struct agp_bridge_data intel_815_bridge = { struct agp_bridge_data intel_815_bridge = {
.type = INTEL_I815, .type = INTEL_GENERIC,
.masks = intel_generic_masks, .masks = intel_generic_masks,
.aperture_sizes = (void *)intel_815_sizes, .aperture_sizes = (void *)intel_815_sizes,
.size_type = U8_APER_SIZE, .size_type = U8_APER_SIZE,
.num_aperture_sizes = 2, .num_aperture_sizes = 2,
.configure = intel_815_configure, .configure = intel_815_configure,
.fetch_size = intel_8xx_fetch_size, .fetch_size = intel_815_fetch_size,
.cleanup = intel_8xx_cleanup, .cleanup = intel_8xx_cleanup,
.tlb_flush = intel_8xx_tlbflush, .tlb_flush = intel_8xx_tlbflush,
.mask_memory = intel_mask_memory, .mask_memory = intel_mask_memory,
......
...@@ -38,12 +38,10 @@ ...@@ -38,12 +38,10 @@
enum chipset_type { enum chipset_type {
NOT_SUPPORTED, NOT_SUPPORTED,
INTEL_GENERIC, INTEL_GENERIC,
INTEL_I815,
VIA_GENERIC, VIA_GENERIC,
SIS_GENERIC, SIS_GENERIC,
AMD_GENERIC, AMD_GENERIC,
AMD_8151, AMD_8151,
ALI_M1541,
ALI_GENERIC, ALI_GENERIC,
SVWRKS_GENERIC, SVWRKS_GENERIC,
HP_ZX1, HP_ZX1,
......
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