X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fvideo%2Faty%2Faty128fb.c;h=b7fc32c8f44ec67afd67b9ea3b5df6805341b6bc;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=f2d82d005f1249958977dc65fe15231d6e328b3a;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c index f2d82d005..b7fc32c8f 100644 --- a/drivers/video/aty/aty128fb.c +++ b/drivers/video/aty/aty128fb.c @@ -67,6 +67,7 @@ #include #ifdef CONFIG_PPC_PMAC +#include #include #include #include "../macmodes.h" @@ -167,6 +168,7 @@ static int aty128_probe(struct pci_dev *pdev, static void aty128_remove(struct pci_dev *pdev); static int aty128_pci_suspend(struct pci_dev *pdev, u32 state); static int aty128_pci_resume(struct pci_dev *pdev); +static int aty128_do_resume(struct pci_dev *pdev); /* supported Rage128 chipsets */ static struct pci_device_id aty128_pci_tbl[] = { @@ -397,7 +399,7 @@ struct aty128fb_par { struct aty128_ddafifo fifo_reg; u32 accel_flags; struct aty128_constants constants; /* PLL and others */ - void *regbase; /* remapped mmio */ + void __iomem *regbase; /* remapped mmio */ u32 vram_size; /* onboard video ram */ int chip_gen; const struct aty128_meminfo *mem; /* onboard mem info */ @@ -450,9 +452,8 @@ static int aty128_decode_var(struct fb_var_screeninfo *var, struct aty128fb_par *par); #if 0 static void __init aty128_get_pllinfo(struct aty128fb_par *par, - void *bios); -static void __init *aty128_map_ROM(struct pci_dev *pdev, const struct aty128fb_par *par); -static void __init aty128_unmap_ROM(struct pci_dev *dev, void * rom); + void __iomem *bios); +static void __init __iomem *aty128_map_ROM(struct pci_dev *pdev, const struct aty128fb_par *par); #endif static void aty128_timings(struct aty128fb_par *par); static void aty128_init_engine(struct aty128fb_par *par); @@ -788,30 +789,12 @@ static u32 depth_to_dst(u32 depth) #ifndef __sparc__ -static void __init aty128_unmap_ROM(struct pci_dev *dev, void * rom) +static void __iomem * __init aty128_map_ROM(const struct aty128fb_par *par, struct pci_dev *dev) { - struct resource *r = &dev->resource[PCI_ROM_RESOURCE]; - - iounmap(rom); - - /* Release the ROM resource if we used it in the first place */ - if (r->parent && r->flags & PCI_ROM_ADDRESS_ENABLE) { - release_resource(r); - r->flags &= ~PCI_ROM_ADDRESS_ENABLE; - r->end -= r->start; - r->start = 0; - } - /* This will disable and set address to unassigned */ - pci_write_config_dword(dev, dev->rom_base_reg, 0); -} - - -static void * __init aty128_map_ROM(const struct aty128fb_par *par, struct pci_dev *dev) -{ - struct resource *r; u16 dptr; u8 rom_type; - void *bios; + void __iomem *bios; + size_t rom_size; /* Fix from ATI for problem with Rage128 hardware not leaving ROM enabled */ unsigned int temp; @@ -821,26 +804,13 @@ static void * __init aty128_map_ROM(const struct aty128fb_par *par, struct pci_d aty_st_le32(RAGE128_MPP_TB_CONFIG, temp); temp = aty_ld_le32(RAGE128_MPP_TB_CONFIG); - /* no need to search for the ROM, just ask the card where it is. */ - r = &dev->resource[PCI_ROM_RESOURCE]; + bios = pci_map_rom(dev, &rom_size); - /* assign the ROM an address if it doesn't have one */ - if (r->parent == NULL) - pci_assign_resource(dev, PCI_ROM_RESOURCE); - - /* enable if needed */ - if (!(r->flags & PCI_ROM_ADDRESS_ENABLE)) { - pci_write_config_dword(dev, dev->rom_base_reg, - r->start | PCI_ROM_ADDRESS_ENABLE); - r->flags |= PCI_ROM_ADDRESS_ENABLE; - } - - bios = ioremap(r->start, r->end - r->start + 1); if (!bios) { printk(KERN_ERR "aty128fb: ROM failed to map\n"); return NULL; } - + /* Very simple test to make sure it appeared */ if (BIOS_IN16(0) != 0xaa55) { printk(KERN_ERR "aty128fb: Invalid ROM signature %x should be 0xaa55\n", @@ -899,11 +869,11 @@ static void * __init aty128_map_ROM(const struct aty128fb_par *par, struct pci_d return bios; failed: - aty128_unmap_ROM(dev, bios); + pci_unmap_rom(dev, bios); return NULL; } -static void __init aty128_get_pllinfo(struct aty128fb_par *par, unsigned char *bios) +static void __init aty128_get_pllinfo(struct aty128fb_par *par, unsigned char __iomem *bios) { unsigned int bios_hdr; unsigned int bios_pll; @@ -925,7 +895,7 @@ static void __init aty128_get_pllinfo(struct aty128fb_par *par, unsigned char *b } #ifdef CONFIG_X86 -static void * __devinit aty128_find_mem_vbios(struct aty128fb_par *par) +static void __iomem * __devinit aty128_find_mem_vbios(struct aty128fb_par *par) { /* I simplified this code as we used to miss the signatures in * a lot of case. It's now closer to XFree, we just don't check @@ -933,13 +903,13 @@ static void * __devinit aty128_find_mem_vbios(struct aty128fb_par *par) * if we end up having conflicts */ u32 segstart; - unsigned char *rom_base = NULL; + unsigned char __iomem *rom_base = NULL; for (segstart=0x000c0000; segstart<0x000f0000; segstart+=0x00001000) { - rom_base = (char *)ioremap(segstart, 0x10000); + rom_base = ioremap(segstart, 0x10000); if (rom_base == NULL) return NULL; - if ((*rom_base == 0x55) && (((*(rom_base + 1)) & 0xff) == 0xaa)) + if (readb(rom_base) == 0x55 && readb(rom_base + 1) == 0xaa) break; iounmap(rom_base); rom_base = NULL; @@ -1737,6 +1707,18 @@ int __init aty128fb_setup(char *options) * Initialisation */ +#ifdef CONFIG_PPC_PMAC +static void aty128_early_resume(void *data) +{ + struct aty128fb_par *par = data; + + if (try_acquire_console_sem()) + return; + aty128_do_resume(par->pdev); + release_console_sem(); +} +#endif /* CONFIG_PPC_PMAC */ + static int __init aty128_init(struct pci_dev *pdev, const struct pci_device_id *ent) { struct fb_info *info = pci_get_drvdata(pdev); @@ -1781,6 +1763,13 @@ static int __init aty128_init(struct pci_dev *pdev, const struct pci_device_id * var = default_var; #ifdef CONFIG_PPC_PMAC if (_machine == _MACH_Pmac) { + /* Indicate sleep capability */ + if (par->chip_gen == rage_M3) { + pmac_call_feature(PMAC_FTR_DEVICE_CAN_WAKE, NULL, 0, 1); + pmac_set_early_video_resume(aty128_early_resume, par); + } + + /* Find default mode */ if (mode_option) { if (!mac_find_mode(&var, info, mode_option, 8)) var = default_var; @@ -1885,7 +1874,7 @@ static int __init aty128_probe(struct pci_dev *pdev, const struct pci_device_id struct fb_info *info; int err; #ifndef __sparc__ - void *bios = NULL; + void __iomem *bios = NULL; #endif /* Enable device in PCI config */ @@ -1959,7 +1948,7 @@ static int __init aty128_probe(struct pci_dev *pdev, const struct pci_device_id else { printk(KERN_INFO "aty128fb: Rage128 BIOS located\n"); aty128_get_pllinfo(par, bios); - aty128_unmap_ROM(pdev, bios); + pci_unmap_rom(pdev, bios); } #endif /* __sparc__ */ @@ -2016,8 +2005,6 @@ static void __devexit aty128_remove(struct pci_dev *pdev) release_mem_region(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0)); - release_mem_region(pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1)); release_mem_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); framebuffer_release(info); @@ -2042,11 +2029,11 @@ static int aty128fb_blank(int blank, struct fb_info *fb) set_backlight_enable(0); #endif /* CONFIG_PMAC_BACKLIGHT */ - if (blank & VESA_VSYNC_SUSPEND) + if (blank & FB_BLANK_VSYNC_SUSPEND) state |= 2; - if (blank & VESA_HSYNC_SUSPEND) + if (blank & FB_BLANK_HSYNC_SUSPEND) state |= 1; - if (blank & VESA_POWERDOWN) + if (blank & FB_BLANK_POWERDOWN) state |= 4; aty_st_8(CRTC_EXT_CNTL+1, state); @@ -2363,7 +2350,7 @@ static int aty128_pci_suspend(struct pci_dev *pdev, u32 state) state = 2; #endif /* CONFIG_PPC_PMAC */ - if (state != 2 || state == pdev->dev.power_state) + if (state != 2 || state == pdev->dev.power.power_state) return 0; printk(KERN_DEBUG "aty128fb: suspending...\n"); @@ -2394,23 +2381,21 @@ static int aty128_pci_suspend(struct pci_dev *pdev, u32 state) release_console_sem(); - pdev->dev.power_state = state; + pdev->dev.power.power_state = state; return 0; } -static int aty128_pci_resume(struct pci_dev *pdev) +static int aty128_do_resume(struct pci_dev *pdev) { struct fb_info *info = pci_get_drvdata(pdev); struct aty128fb_par *par = info->par; - if (pdev->dev.power_state == 0) + if (pdev->dev.power.power_state == 0) return 0; - acquire_console_sem(); - /* Wakeup chip */ - if (pdev->dev.power_state == 2) + if (pdev->dev.power.power_state == 2) aty128_set_suspend(par, 0); par->asleep = 0; @@ -2428,15 +2413,25 @@ static int aty128_pci_resume(struct pci_dev *pdev) par->lock_blank = 0; aty128fb_blank(0, info); - release_console_sem(); - - pdev->dev.power_state = 0; + pdev->dev.power.power_state = 0; printk(KERN_DEBUG "aty128fb: resumed !\n"); return 0; } +static int aty128_pci_resume(struct pci_dev *pdev) +{ + int rc; + + acquire_console_sem(); + rc = aty128_do_resume(pdev); + release_console_sem(); + + return rc; +} + + int __init aty128fb_init(void) { #ifndef MODULE @@ -2464,10 +2459,10 @@ MODULE_AUTHOR("(c)1999-2003 Brad Douglas "); MODULE_DESCRIPTION("FBDev driver for ATI Rage128 / Pro cards"); MODULE_LICENSE("GPL"); module_param(mode_option, charp, 0); -MODULE_PARM_DESC(mode, "Specify resolution as \"x[-][@]\" "); +MODULE_PARM_DESC(mode_option, "Specify resolution as \"x[-][@]\" "); #ifdef CONFIG_MTRR module_param_named(nomtrr, mtrr, invbool, 0); -MODULE_PARM_DESC(mtrr, "bool: Disable MTRR support (0 or 1=disabled) (default=0)"); +MODULE_PARM_DESC(nomtrr, "bool: Disable MTRR support (0 or 1=disabled) (default=0)"); #endif #endif