Commit 4c1e49dc authored by James Simmons's avatar James Simmons

Code cleanups and bug fixes.

parent fcc694c7
...@@ -103,6 +103,7 @@ struct atyfb_par { ...@@ -103,6 +103,7 @@ struct atyfb_par {
int open; int open;
#endif #endif
#ifdef CONFIG_PMAC_PBOOK #ifdef CONFIG_PMAC_PBOOK
struct fb_info *next;
unsigned char *save_framebuffer; unsigned char *save_framebuffer;
unsigned long save_pll[64]; unsigned long save_pll[64];
#endif #endif
...@@ -286,7 +287,7 @@ extern void atyfb_fillrect(struct fb_info *info, struct fb_fillrect *rect); ...@@ -286,7 +287,7 @@ extern void atyfb_fillrect(struct fb_info *info, struct fb_fillrect *rect);
* Text console acceleration * Text console acceleration
*/ */
extern const struct display_switch fbcon_aty8; extern struct display_switch fbcon_aty8;
extern const struct display_switch fbcon_aty16; extern struct display_switch fbcon_aty16;
extern const struct display_switch fbcon_aty24; extern struct display_switch fbcon_aty24;
extern const struct display_switch fbcon_aty32; extern struct display_switch fbcon_aty32;
...@@ -206,7 +206,7 @@ static int encode_fix(struct fb_fix_screeninfo *fix, ...@@ -206,7 +206,7 @@ static int encode_fix(struct fb_fix_screeninfo *fix,
static void atyfb_set_dispsw(struct display *disp, static void atyfb_set_dispsw(struct display *disp,
struct fb_info *info); struct fb_info *info);
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
static int read_aty_sense(const struct fb_info *info); static int read_aty_sense(const struct atyfb_par *par);
#endif #endif
...@@ -462,63 +462,62 @@ static char *aty_ct_ram[8] __initdata = { ...@@ -462,63 +462,62 @@ static char *aty_ct_ram[8] __initdata = {
* Apple monitor sense * Apple monitor sense
*/ */
static int __init read_aty_sense(const struct fb_info *info) static int __init read_aty_sense(const struct atyfb_par *par)
{ {
int sense, i; int sense, i;
aty_st_le32(GP_IO, 0x31003100, info); /* drive outputs high */ aty_st_le32(GP_IO, 0x31003100, par); /* drive outputs high */
__delay(200); __delay(200);
aty_st_le32(GP_IO, 0, info); /* turn off outputs */ aty_st_le32(GP_IO, 0, par); /* turn off outputs */
__delay(2000); __delay(2000);
i = aty_ld_le32(GP_IO, info); /* get primary sense value */ i = aty_ld_le32(GP_IO, par); /* get primary sense value */
sense = ((i & 0x3000) >> 3) | (i & 0x100); sense = ((i & 0x3000) >> 3) | (i & 0x100);
/* drive each sense line low in turn and collect the other 2 */ /* drive each sense line low in turn and collect the other 2 */
aty_st_le32(GP_IO, 0x20000000, info); /* drive A low */ aty_st_le32(GP_IO, 0x20000000, par); /* drive A low */
__delay(2000); __delay(2000);
i = aty_ld_le32(GP_IO, info); i = aty_ld_le32(GP_IO, par);
sense |= ((i & 0x1000) >> 7) | ((i & 0x100) >> 4); sense |= ((i & 0x1000) >> 7) | ((i & 0x100) >> 4);
aty_st_le32(GP_IO, 0x20002000, info); /* drive A high again */ aty_st_le32(GP_IO, 0x20002000, par); /* drive A high again */
__delay(200); __delay(200);
aty_st_le32(GP_IO, 0x10000000, info); /* drive B low */ aty_st_le32(GP_IO, 0x10000000, par); /* drive B low */
__delay(2000); __delay(2000);
i = aty_ld_le32(GP_IO, info); i = aty_ld_le32(GP_IO, par);
sense |= ((i & 0x2000) >> 10) | ((i & 0x100) >> 6); sense |= ((i & 0x2000) >> 10) | ((i & 0x100) >> 6);
aty_st_le32(GP_IO, 0x10001000, info); /* drive B high again */ aty_st_le32(GP_IO, 0x10001000, par); /* drive B high again */
__delay(200); __delay(200);
aty_st_le32(GP_IO, 0x01000000, info); /* drive C low */ aty_st_le32(GP_IO, 0x01000000, par); /* drive C low */
__delay(2000); __delay(2000);
sense |= (aty_ld_le32(GP_IO, info) & 0x3000) >> 12; sense |= (aty_ld_le32(GP_IO, par) & 0x3000) >> 12;
aty_st_le32(GP_IO, 0, info); /* turn off outputs */ aty_st_le32(GP_IO, 0, par); /* turn off outputs */
return sense; return sense;
} }
#endif /* defined(CONFIG_PPC) */ #endif /* defined(CONFIG_PPC) */
#if defined(CONFIG_PMAC_PBOOK) || defined(CONFIG_PMAC_BACKLIGHT) #if defined(CONFIG_PMAC_PBOOK) || defined(CONFIG_PMAC_BACKLIGHT)
static void aty_st_lcd(int index, u32 val, const struct fb_info *info) static void aty_st_lcd(int index, u32 val, const struct atyfb_par *par)
{ {
unsigned long temp; unsigned long temp;
/* write addr byte */ /* write addr byte */
temp = aty_ld_le32(LCD_INDEX, info); temp = aty_ld_le32(LCD_INDEX, par);
aty_st_le32(LCD_INDEX, (temp & ~LCD_INDEX_MASK) | index, info); aty_st_le32(LCD_INDEX, (temp & ~LCD_INDEX_MASK) | index, par);
/* write the register value */ /* write the register value */
aty_st_le32(LCD_DATA, val, info); aty_st_le32(LCD_DATA, val, par);
} }
static u32 aty_ld_lcd(int index, const struct fb_info *info) static u32 aty_ld_lcd(int index, const struct atyfb_par *par)
{ {
unsigned long temp; unsigned long temp;
/* write addr byte */ /* write addr byte */
temp = aty_ld_le32(LCD_INDEX, info); temp = aty_ld_le32(LCD_INDEX, par);
aty_st_le32(LCD_INDEX, (temp & ~LCD_INDEX_MASK) | index, info); aty_st_le32(LCD_INDEX, (temp & ~LCD_INDEX_MASK) | index, par);
/* read the register value */ /* read the register value */
return aty_ld_le32(LCD_DATA, info); return aty_ld_le32(LCD_DATA, par);
} }
#endif /* CONFIG_PMAC_PBOOK || CONFIG_PMAC_BACKLIGHT */ #endif /* CONFIG_PMAC_PBOOK || CONFIG_PMAC_BACKLIGHT */
...@@ -1439,16 +1438,16 @@ static struct { ...@@ -1439,16 +1438,16 @@ static struct {
u8 b[2][256]; u8 b[2][256];
} atyfb_save; } atyfb_save;
static void atyfb_save_palette(struct fb_info *info, int enter) static void atyfb_save_palette(struct atyfb_par *par, int enter)
{ {
int i, tmp; int i, tmp;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
tmp = aty_ld_8(DAC_CNTL, info) & 0xfc; tmp = aty_ld_8(DAC_CNTL, par) & 0xfc;
if (M64_HAS(EXTRA_BRIGHT)) if (M64_HAS(EXTRA_BRIGHT))
tmp |= 0x2; tmp |= 0x2;
aty_st_8(DAC_CNTL, tmp, info); aty_st_8(DAC_CNTL, tmp, par);
aty_st_8(DAC_MASK, 0xff, info); aty_st_8(DAC_MASK, 0xff, par);
writeb(i, &par->aty_cmap_regs->rindex); writeb(i, &par->aty_cmap_regs->rindex);
atyfb_save.r[enter][i] = readb(&par->aty_cmap_regs->lut); atyfb_save.r[enter][i] = readb(&par->aty_cmap_regs->lut);
...@@ -1477,9 +1476,10 @@ static void atyfb_palette(int enter) ...@@ -1477,9 +1476,10 @@ static void atyfb_palette(int enter)
d->fb_info->fbops == &atyfb_ops && d->fb_info->fbops == &atyfb_ops &&
d->fb_info->display_fg && d->fb_info->display_fg &&
d->fb_info->display_fg->vc_num == i) { d->fb_info->display_fg->vc_num == i) {
atyfb_save_palette(d->fb_info, enter);
info = d->fb_info; info = d->fb_info;
par = (struct atyfb_par *) info->par; par = (struct atyfb_par *) info->par;
atyfb_save_palette(par, enter);
if (enter) { if (enter) {
atyfb_save.yoffset = par->crtc.yoffset; atyfb_save.yoffset = par->crtc.yoffset;
par->crtc.yoffset = 0; par->crtc.yoffset = 0;
...@@ -1506,32 +1506,32 @@ static struct fb_info *first_display = NULL; ...@@ -1506,32 +1506,32 @@ static struct fb_info *first_display = NULL;
* management registers. There's is some confusion about which * management registers. There's is some confusion about which
* chipID is a Rage LT or LT pro :( * chipID is a Rage LT or LT pro :(
*/ */
static int aty_power_mgmt_LT(int sleep, struct fb_info *info) static int aty_power_mgmt_LT(int sleep, struct atyfb_par *par)
{ {
unsigned int pm; unsigned int pm;
int timeout; int timeout;
pm = aty_ld_le32(POWER_MANAGEMENT_LG, info); pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
pm = (pm & ~PWR_MGT_MODE_MASK) | PWR_MGT_MODE_REG; pm = (pm & ~PWR_MGT_MODE_MASK) | PWR_MGT_MODE_REG;
aty_st_le32(POWER_MANAGEMENT_LG, pm, info); aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
pm = aty_ld_le32(POWER_MANAGEMENT_LG, info); pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
timeout = 200000; timeout = 200000;
if (sleep) { if (sleep) {
/* Sleep */ /* Sleep */
pm &= ~PWR_MGT_ON; pm &= ~PWR_MGT_ON;
aty_st_le32(POWER_MANAGEMENT_LG, pm, info); aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
pm = aty_ld_le32(POWER_MANAGEMENT_LG, info); pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
udelay(10); udelay(10);
pm &= ~(PWR_BLON | AUTO_PWR_UP); pm &= ~(PWR_BLON | AUTO_PWR_UP);
pm |= SUSPEND_NOW; pm |= SUSPEND_NOW;
aty_st_le32(POWER_MANAGEMENT_LG, pm, info); aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
pm = aty_ld_le32(POWER_MANAGEMENT_LG, info); pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
udelay(10); udelay(10);
pm |= PWR_MGT_ON; pm |= PWR_MGT_ON;
aty_st_le32(POWER_MANAGEMENT_LG, pm, info); aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
do { do {
pm = aty_ld_le32(POWER_MANAGEMENT_LG, info); pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
udelay(10); udelay(10);
if ((--timeout) == 0) if ((--timeout) == 0)
break; break;
...@@ -1540,18 +1540,18 @@ static int aty_power_mgmt_LT(int sleep, struct fb_info *info) ...@@ -1540,18 +1540,18 @@ static int aty_power_mgmt_LT(int sleep, struct fb_info *info)
} else { } else {
/* Wakeup */ /* Wakeup */
pm &= ~PWR_MGT_ON; pm &= ~PWR_MGT_ON;
aty_st_le32(POWER_MANAGEMENT_LG, pm, info); aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
pm = aty_ld_le32(POWER_MANAGEMENT_LG, info); pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
udelay(10); udelay(10);
pm |= (PWR_BLON | AUTO_PWR_UP); pm |= (PWR_BLON | AUTO_PWR_UP);
pm &= ~SUSPEND_NOW; pm &= ~SUSPEND_NOW;
aty_st_le32(POWER_MANAGEMENT_LG, pm, info); aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
pm = aty_ld_le32(POWER_MANAGEMENT_LG, info); pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
udelay(10); udelay(10);
pm |= PWR_MGT_ON; pm |= PWR_MGT_ON;
aty_st_le32(POWER_MANAGEMENT_LG, pm, info); aty_st_le32(POWER_MANAGEMENT_LG, pm, par);
do { do {
pm = aty_ld_le32(POWER_MANAGEMENT_LG, info); pm = aty_ld_le32(POWER_MANAGEMENT_LG, par);
udelay(10); udelay(10);
if ((--timeout) == 0) if ((--timeout) == 0)
break; break;
...@@ -1562,32 +1562,32 @@ static int aty_power_mgmt_LT(int sleep, struct fb_info *info) ...@@ -1562,32 +1562,32 @@ static int aty_power_mgmt_LT(int sleep, struct fb_info *info)
return timeout ? PBOOK_SLEEP_OK : PBOOK_SLEEP_REFUSE; return timeout ? PBOOK_SLEEP_OK : PBOOK_SLEEP_REFUSE;
} }
static int aty_power_mgmt_LTPro(int sleep, struct fb_info *info) static int aty_power_mgmt_LTPro(int sleep, struct atyfb_par *par)
{ {
unsigned int pm; unsigned int pm;
int timeout; int timeout;
pm = aty_ld_lcd(POWER_MANAGEMENT, info); pm = aty_ld_lcd(POWER_MANAGEMENT, par);
pm = (pm & ~PWR_MGT_MODE_MASK) | PWR_MGT_MODE_REG; pm = (pm & ~PWR_MGT_MODE_MASK) | PWR_MGT_MODE_REG;
aty_st_lcd(POWER_MANAGEMENT, pm, info); aty_st_lcd(POWER_MANAGEMENT, pm, par);
pm = aty_ld_lcd(POWER_MANAGEMENT, info); pm = aty_ld_lcd(POWER_MANAGEMENT, par);
timeout = 200; timeout = 200;
if (sleep) { if (sleep) {
/* Sleep */ /* Sleep */
pm &= ~PWR_MGT_ON; pm &= ~PWR_MGT_ON;
aty_st_lcd(POWER_MANAGEMENT, pm, info); aty_st_lcd(POWER_MANAGEMENT, pm, par);
pm = aty_ld_lcd(POWER_MANAGEMENT, info); pm = aty_ld_lcd(POWER_MANAGEMENT, par);
udelay(10); udelay(10);
pm &= ~(PWR_BLON | AUTO_PWR_UP); pm &= ~(PWR_BLON | AUTO_PWR_UP);
pm |= SUSPEND_NOW; pm |= SUSPEND_NOW;
aty_st_lcd(POWER_MANAGEMENT, pm, info); aty_st_lcd(POWER_MANAGEMENT, pm, par);
pm = aty_ld_lcd(POWER_MANAGEMENT, info); pm = aty_ld_lcd(POWER_MANAGEMENT, par);
udelay(10); udelay(10);
pm |= PWR_MGT_ON; pm |= PWR_MGT_ON;
aty_st_lcd(POWER_MANAGEMENT, pm, info); aty_st_lcd(POWER_MANAGEMENT, pm, par);
do { do {
pm = aty_ld_lcd(POWER_MANAGEMENT, info); pm = aty_ld_lcd(POWER_MANAGEMENT, par);
mdelay(1); mdelay(1);
if ((--timeout) == 0) if ((--timeout) == 0)
break; break;
...@@ -1596,18 +1596,18 @@ static int aty_power_mgmt_LTPro(int sleep, struct fb_info *info) ...@@ -1596,18 +1596,18 @@ static int aty_power_mgmt_LTPro(int sleep, struct fb_info *info)
} else { } else {
/* Wakeup */ /* Wakeup */
pm &= ~PWR_MGT_ON; pm &= ~PWR_MGT_ON;
aty_st_lcd(POWER_MANAGEMENT, pm, info); aty_st_lcd(POWER_MANAGEMENT, pm, par);
pm = aty_ld_lcd(POWER_MANAGEMENT, info); pm = aty_ld_lcd(POWER_MANAGEMENT, par);
udelay(10); udelay(10);
pm &= ~SUSPEND_NOW; pm &= ~SUSPEND_NOW;
pm |= (PWR_BLON | AUTO_PWR_UP); pm |= (PWR_BLON | AUTO_PWR_UP);
aty_st_lcd(POWER_MANAGEMENT, pm, info); aty_st_lcd(POWER_MANAGEMENT, pm, par);
pm = aty_ld_lcd(POWER_MANAGEMENT, info); pm = aty_ld_lcd(POWER_MANAGEMENT, par);
udelay(10); udelay(10);
pm |= PWR_MGT_ON; pm |= PWR_MGT_ON;
aty_st_lcd(POWER_MANAGEMENT, pm, info); aty_st_lcd(POWER_MANAGEMENT, pm, par);
do { do {
pm = aty_ld_lcd(POWER_MANAGEMENT, info); pm = aty_ld_lcd(POWER_MANAGEMENT, par);
mdelay(1); mdelay(1);
if ((--timeout) == 0) if ((--timeout) == 0)
break; break;
...@@ -1617,10 +1617,10 @@ static int aty_power_mgmt_LTPro(int sleep, struct fb_info *info) ...@@ -1617,10 +1617,10 @@ static int aty_power_mgmt_LTPro(int sleep, struct fb_info *info)
return timeout ? PBOOK_SLEEP_OK : PBOOK_SLEEP_REFUSE; return timeout ? PBOOK_SLEEP_OK : PBOOK_SLEEP_REFUSE;
} }
static int aty_power_mgmt(int sleep, struct fb_info *info) static int aty_power_mgmt(int sleep, struct atyfb_par *par)
{ {
return M64_HAS(LT_SLEEP) ? aty_power_mgmt_LT(sleep, info) return M64_HAS(LT_SLEEP) ? aty_power_mgmt_LT(sleep, par)
: aty_power_mgmt_LTPro(sleep, info); : aty_power_mgmt_LTPro(sleep, par);
} }
/* /*
...@@ -1635,7 +1635,7 @@ static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when) ...@@ -1635,7 +1635,7 @@ static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when)
result = PBOOK_SLEEP_OK; result = PBOOK_SLEEP_OK;
for (info = first_display; info != NULL; info = info->next) { for (info = first_display; info != NULL; info = par->next) {
struct fb_fix_screeninfo fix; struct fb_fix_screeninfo fix;
int nb; int nb;
...@@ -1659,7 +1659,7 @@ static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when) ...@@ -1659,7 +1659,7 @@ static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when)
wait_for_idle(par); wait_for_idle(par);
/* Stop accel engine (stop bus mastering) */ /* Stop accel engine (stop bus mastering) */
if (par->accel_flags & FB_ACCELF_TEXT) if (par->accel_flags & FB_ACCELF_TEXT)
aty_reset_engine(info); aty_reset_engine(par);
/* Backup fb content */ /* Backup fb content */
if (par->save_framebuffer) if (par->save_framebuffer)
...@@ -1670,11 +1670,11 @@ static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when) ...@@ -1670,11 +1670,11 @@ static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when)
atyfb_blank(VESA_POWERDOWN + 1, info); atyfb_blank(VESA_POWERDOWN + 1, info);
/* Set chip to "suspend" mode */ /* Set chip to "suspend" mode */
result = aty_power_mgmt(1, info); result = aty_power_mgmt(1, par);
break; break;
case PBOOK_WAKE: case PBOOK_WAKE:
/* Wakeup chip */ /* Wakeup chip */
result = aty_power_mgmt(0, info); result = aty_power_mgmt(0, par);
/* Restore fb content */ /* Restore fb content */
if (par->save_framebuffer) { if (par->save_framebuffer) {
...@@ -1684,7 +1684,7 @@ static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when) ...@@ -1684,7 +1684,7 @@ static int aty_sleep_notify(struct pmu_sleep_notifier *self, int when)
par->save_framebuffer = 0; par->save_framebuffer = 0;
} }
/* Restore display */ /* Restore display */
atyfb_set_par(par->par, info); atyfb_set_par(par, info);
atyfb_blank(0, info); atyfb_blank(0, info);
break; break;
} }
...@@ -1711,7 +1711,8 @@ static int backlight_conv[] = { ...@@ -1711,7 +1711,8 @@ static int backlight_conv[] = {
static int aty_set_backlight_enable(int on, int level, void *data) static int aty_set_backlight_enable(int on, int level, void *data)
{ {
struct fb_info *info = (struct fb_info *) data; struct fb_info *info = (struct fb_info *) data;
unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, info); struct atyfb_par *par = (struct atyfb_par *) info->par;
unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
reg |= (BLMOD_EN | BIASMOD_EN); reg |= (BLMOD_EN | BIASMOD_EN);
if (on && level > BACKLIGHT_OFF) { if (on && level > BACKLIGHT_OFF) {
...@@ -1721,8 +1722,7 @@ static int aty_set_backlight_enable(int on, int level, void *data) ...@@ -1721,8 +1722,7 @@ static int aty_set_backlight_enable(int on, int level, void *data)
reg &= ~BIAS_MOD_LEVEL_MASK; reg &= ~BIAS_MOD_LEVEL_MASK;
reg |= (backlight_conv[0] << BIAS_MOD_LEVEL_SHIFT); reg |= (backlight_conv[0] << BIAS_MOD_LEVEL_SHIFT);
} }
aty_st_lcd(LCD_MISC_CNTL, reg, info); aty_st_lcd(LCD_MISC_CNTL, reg, par);
return 0; return 0;
} }
...@@ -1784,7 +1784,7 @@ static int __init aty_init(struct fb_info *info, const char *name) ...@@ -1784,7 +1784,7 @@ static int __init aty_init(struct fb_info *info, const char *name)
if (!M64_HAS(INTEGRATED)) { if (!M64_HAS(INTEGRATED)) {
u32 stat0; u32 stat0;
u8 dac_type, dac_subtype, clk_type; u8 dac_type, dac_subtype, clk_type;
stat0 = aty_ld_le32(CONFIG_STAT0, info); stat0 = aty_ld_le32(CONFIG_STAT0, par);
par->bus_type = (stat0 >> 0) & 0x07; par->bus_type = (stat0 >> 0) & 0x07;
par->ram_type = (stat0 >> 3) & 0x07; par->ram_type = (stat0 >> 3) & 0x07;
ramname = aty_gx_ram[par->ram_type]; ramname = aty_gx_ram[par->ram_type];
...@@ -2093,7 +2093,7 @@ static int __init aty_init(struct fb_info *info, const char *name) ...@@ -2093,7 +2093,7 @@ static int __init aty_init(struct fb_info *info, const char *name)
default_vmode = VMODE_800_600_60; default_vmode = VMODE_800_600_60;
else else
default_vmode = VMODE_640_480_67; default_vmode = VMODE_640_480_67;
sense = read_aty_sense(info); sense = read_aty_sense(par);
printk(KERN_INFO printk(KERN_INFO
"atyfb: monitor sense=%x, mode %d\n", "atyfb: monitor sense=%x, mode %d\n",
sense, sense,
...@@ -2150,7 +2150,7 @@ static int __init aty_init(struct fb_info *info, const char *name) ...@@ -2150,7 +2150,7 @@ static int __init aty_init(struct fb_info *info, const char *name)
return 0; return 0;
} }
#ifdef __sparc__ #ifdef __sparc__
atyfb_save_palette(info, 0); atyfb_save_palette(par, 0);
#endif #endif
#ifdef CONFIG_FB_ATY_CT #ifdef CONFIG_FB_ATY_CT
...@@ -2258,7 +2258,7 @@ int __init atyfb_init(void) ...@@ -2258,7 +2258,7 @@ int __init atyfb_init(void)
/* /*
* Map memory-mapped registers. * Map memory-mapped registers.
*/ */
par->ati_regbase = addr + 0x7ffc00UL; default_par->ati_regbase = addr + 0x7ffc00UL;
info->fix.mmio_start = addr + 0x7ffc00UL; info->fix.mmio_start = addr + 0x7ffc00UL;
/* /*
...@@ -2361,9 +2361,9 @@ int __init atyfb_init(void) ...@@ -2361,9 +2361,9 @@ int __init atyfb_init(void)
/* /*
* Fix PROMs idea of MEM_CNTL settings... * Fix PROMs idea of MEM_CNTL settings...
*/ */
mem = aty_ld_le32(MEM_CNTL, info); mem = aty_ld_le32(MEM_CNTL, default_par);
chip_id = chip_id =
aty_ld_le32(CONFIG_CHIP_ID, info); aty_ld_le32(CONFIG_CHIP_ID, defualt_par);
if (((chip_id & CFG_CHIP_TYPE) == if (((chip_id & CFG_CHIP_TYPE) ==
VT_CHIP_ID) VT_CHIP_ID)
&& !((chip_id >> 24) & 1)) { && !((chip_id >> 24) & 1)) {
...@@ -2383,13 +2383,11 @@ int __init atyfb_init(void) ...@@ -2383,13 +2383,11 @@ int __init atyfb_init(void)
default: default:
break; break;
} }
if ((aty_ld_le32 if ((aty_ld_le32(CONFIG_STAT0, default_par) & 7) >= SDRAM)
(CONFIG_STAT0,
info) & 7) >= SDRAM)
mem &= ~(0x00700000); mem &= ~(0x00700000);
} }
mem &= ~(0xcf80e000); /* Turn off all undocumented bits. */ mem &= ~(0xcf80e000); /* Turn off all undocumented bits. */
aty_st_le32(MEM_CNTL, mem, info); aty_st_le32(MEM_CNTL, mem, default_par);
} }
/* /*
...@@ -2452,10 +2450,10 @@ int __init atyfb_init(void) ...@@ -2452,10 +2450,10 @@ int __init atyfb_init(void)
/* /*
* Read the PLL to figure actual Refresh Rate. * Read the PLL to figure actual Refresh Rate.
*/ */
clock_cntl = aty_ld_8(CLOCK_CNTL, info); clock_cntl = aty_ld_8(CLOCK_CNTL, default_par);
/* printk("atyfb: CLOCK_CNTL: %02x\n", clock_cntl); */ /* printk("atyfb: CLOCK_CNTL: %02x\n", clock_cntl); */
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
pll_regs[i] = aty_ld_pll(i, info); pll_regs[i] = aty_ld_pll(i, default_par);
/* /*
* PLL Reference Divider M: * PLL Reference Divider M:
...@@ -2555,21 +2553,21 @@ int __init atyfb_init(void) ...@@ -2555,21 +2553,21 @@ int __init atyfb_init(void)
/* /*
* Add /dev/fb mmap values. * Add /dev/fb mmap values.
*/ */
par->mmap_map[0].voff = 0x8000000000000000UL; default_par->mmap_map[0].voff = 0x8000000000000000UL;
par->mmap_map[0].poff = default_par->mmap_map[0].poff =
info->screen_base & PAGE_MASK; info->screen_base & PAGE_MASK;
par->mmap_map[0].size = default_par->mmap_map[0].size =
info->fix.smem_len; info->fix.smem_len;
par->mmap_map[0].prot_mask = _PAGE_CACHE; default_par->mmap_map[0].prot_mask = _PAGE_CACHE;
par->mmap_map[0].prot_flag = _PAGE_E; default_par->mmap_map[0].prot_flag = _PAGE_E;
par->mmap_map[1].voff = default_par->mmap_map[1].voff =
par->mmap_map[0].voff + default_par->mmap_map[0].voff +
info->fix.smem_len; info->fix.smem_len;
par->mmap_map[1].poff = default_par->mmap_map[1].poff =
par->ati_regbase & PAGE_MASK; default_par->ati_regbase & PAGE_MASK;
par->mmap_map[1].size = PAGE_SIZE; default_par->mmap_map[1].size = PAGE_SIZE;
par->mmap_map[1].prot_mask = _PAGE_CACHE; default_par->mmap_map[1].prot_mask = _PAGE_CACHE;
par->mmap_map[1].prot_flag = _PAGE_E; default_par->mmap_map[1].prot_flag = _PAGE_E;
#endif /* __sparc__ */ #endif /* __sparc__ */
#ifdef CONFIG_PMAC_PBOOK #ifdef CONFIG_PMAC_PBOOK
...@@ -2577,7 +2575,7 @@ int __init atyfb_init(void) ...@@ -2577,7 +2575,7 @@ int __init atyfb_init(void)
pmu_register_sleep_notifier pmu_register_sleep_notifier
(&aty_sleep_notifier); (&aty_sleep_notifier);
/* FIXME info->next = first_display; */ /* FIXME info->next = first_display; */
first_display = info; default_par->next = first_display;
#endif #endif
} }
} }
...@@ -2610,25 +2608,25 @@ int __init atyfb_init(void) ...@@ -2610,25 +2608,25 @@ int __init atyfb_init(void)
info->screen_base = (unsigned long)ioremap(phys_vmembase[m64_num], info->screen_base = (unsigned long)ioremap(phys_vmembase[m64_num],
phys_size[m64_num]); phys_size[m64_num]);
info->fix.smem_start = info->screen_base; /* Fake! */ info->fix.smem_start = info->screen_base; /* Fake! */
par->ati_regbase = (unsigned long)ioremap(phys_guiregbase[m64_num], default_par->ati_regbase = (unsigned long)ioremap(phys_guiregbase[m64_num],
0x10000) + 0xFC00ul; 0x10000) + 0xFC00ul;
info->fix.mmio_start = par->ati_regbase; /* Fake! */ info->fix.mmio_start = par->ati_regbase; /* Fake! */
aty_st_le32(CLOCK_CNTL, 0x12345678, info); aty_st_le32(CLOCK_CNTL, 0x12345678, default_par);
clock_r = aty_ld_le32(CLOCK_CNTL, info); clock_r = aty_ld_le32(CLOCK_CNTL, default_par);
switch (clock_r & 0x003F) { switch (clock_r & 0x003F) {
case 0x12: case 0x12:
par->clk_wr_offset = 3; /* */ default_par->clk_wr_offset = 3; /* */
break; break;
case 0x34: case 0x34:
par->clk_wr_offset = 2; /* Medusa ST-IO ISA Adapter etc. */ default_par->clk_wr_offset = 2; /* Medusa ST-IO ISA Adapter etc. */
break; break;
case 0x16: case 0x16:
par->clk_wr_offset = 1; /* */ default_par->clk_wr_offset = 1; /* */
break; break;
case 0x38: case 0x38:
par->clk_wr_offset = 0; /* Panther 1 ISA Adapter (Gerald) */ default_par->clk_wr_offset = 0; /* Panther 1 ISA Adapter (Gerald) */
break; break;
} }
......
...@@ -340,7 +340,7 @@ static void name(struct vc_data *conp, struct display *p, args) \ ...@@ -340,7 +340,7 @@ static void name(struct vc_data *conp, struct display *p, args) \
fbcon_cfb##width##_clear_margins(conp, p, bottom_only), \ fbcon_cfb##width##_clear_margins(conp, p, bottom_only), \
int bottom_only) \ int bottom_only) \
\ \
const struct display_switch fbcon_aty##width = { \ struct display_switch fbcon_aty##width = { \
setup: fbcon_cfb##width##_setup, \ setup: fbcon_cfb##width##_setup, \
bmove: fbcon_aty_bmove, \ bmove: fbcon_aty_bmove, \
clear: fbcon_aty_clear, \ clear: fbcon_aty_clear, \
......
...@@ -28,6 +28,14 @@ ...@@ -28,6 +28,14 @@
#include <asm/io.h> #include <asm/io.h>
#include <video/fbcon.h> #include <video/fbcon.h>
#if BITS_PER_LONG == 32
#define FB_READ fb_readl
#define FB_WRITE fb_writel
#else
#define FB_READ fb_readq
#define FB_WRITE fb_writeq
#endif
void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area) void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
{ {
int x2, y2, lineincr, shift, shift_right, shift_left, old_dx, old_dy; int x2, y2, lineincr, shift, shift_right, shift_left, old_dx, old_dy;
...@@ -137,19 +145,19 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area) ...@@ -137,19 +145,19 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
dst = (unsigned long *) dst1; dst = (unsigned long *) dst1;
src = (unsigned long *) src1; src = (unsigned long *) src1;
last = (fb_readl(src) & start_mask); last = (FB_READ(src) & start_mask);
if (shift > 0) if (shift > 0)
fb_writel(fb_readl(dst) | (last >> shift_right), dst); FB_WRITE(FB_READ(dst) | (last >> shift_right), dst);
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
dst++; dst++;
tmp = fb_readl(src); tmp = FB_READ(src);
src++; src++;
fb_writel((last << shift_left) | (tmp >> shift_right), dst); FB_WRITE((last << shift_left) | (tmp >> shift_right), dst);
last = tmp; last = tmp;
src++; src++;
} }
fb_writel(fb_readl(dst) | (last << shift_left), dst); FB_WRITE(FB_READ(dst) | (last << shift_left), dst);
src1 += lineincr; src1 += lineincr;
dst1 += lineincr; dst1 += lineincr;
} while (--height); } while (--height);
...@@ -161,19 +169,19 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area) ...@@ -161,19 +169,19 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
dst = (unsigned long *) dst1; dst = (unsigned long *) dst1;
src = (unsigned long *) src1; src = (unsigned long *) src1;
last = (fb_readl(src) & end_mask); last = (FB_READ(src) & end_mask);
if (shift < 0) if (shift < 0)
fb_writel(fb_readl(dst) | (last >> shift_right), dst); FB_WRITE(FB_READ(dst) | (last >> shift_right), dst);
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
dst--; dst--;
tmp = fb_readl(src); tmp = FB_READ(src);
src--; src--;
fb_writel((tmp << shift_left) | (last >> shift_right), dst); FB_WRITE((tmp << shift_left) | (last >> shift_right), dst);
last = tmp; last = tmp;
src--; src--;
} }
fb_writel(fb_readl(dst) | (last >> shift_right), dst); FB_WRITE(FB_READ(dst) | (last >> shift_right), dst);
src1 += lineincr; src1 += lineincr;
dst1 += lineincr; dst1 += lineincr;
} while (--height); } while (--height);
...@@ -187,16 +195,16 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area) ...@@ -187,16 +195,16 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
src = (unsigned long *) (src1 - start_index); src = (unsigned long *) (src1 - start_index);
if (start_mask) if (start_mask)
fb_writel(fb_readl(src) | start_mask, dst); FB_WRITE(FB_READ(src) | start_mask, dst);
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
fb_writel(fb_readl(src), dst); FB_WRITE(FB_READ(src), dst);
dst++; dst++;
src++; src++;
} }
if (end_mask) if (end_mask)
fb_writel(fb_readl(src) | end_mask, dst); FB_WRITE(FB_READ(src) | end_mask, dst);
src1 += lineincr; src1 += lineincr;
dst1 += lineincr; dst1 += lineincr;
} while (--height); } while (--height);
...@@ -207,9 +215,9 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area) ...@@ -207,9 +215,9 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
src = (unsigned long *) src1; src = (unsigned long *) src1;
if (start_mask) if (start_mask)
fb_writel(fb_readl(src) | start_mask, dst); FB_WRITE(FB_READ(src) | start_mask, dst);
for (j = 0; j < n; j++) { for (j = 0; j < n; j++) {
fb_writel(fb_readl(src), dst); FB_WRITE(FB_READ(src), dst);
dst--; dst--;
src--; src--;
} }
......
...@@ -22,6 +22,14 @@ ...@@ -22,6 +22,14 @@
#include <asm/types.h> #include <asm/types.h>
#include <video/fbcon.h> #include <video/fbcon.h>
#if BITS_PER_LONG == 32
#define FB_READ fb_readl
#define FB_WRITE fb_writel
#else
#define FB_READ fb_readq
#define FB_WRITE fb_writeq
#endif
void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect) void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect)
{ {
unsigned long start_index, end_index, start_mask = 0, end_mask = 0; unsigned long start_index, end_index, start_mask = 0, end_mask = 0;
...@@ -93,33 +101,19 @@ void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect) ...@@ -93,33 +101,19 @@ void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect)
dst = (unsigned long *) (dst1 - start_index); dst = (unsigned long *) (dst1 - start_index);
if (start_mask) { if (start_mask) {
#if BITS_PER_LONG == 32 FB_WRITE(FB_READ(dst) |
fb_writel(fb_readl(dst) |
start_mask, dst);
#else
fb_writeq(fb_readq(dst) |
start_mask, dst); start_mask, dst);
#endif
dst++; dst++;
} }
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
#if BITS_PER_LONG == 32 FB_WRITE(fg, dst);
fb_writel(fg, dst);
#else
fb_writeq(fg, dst);
#endif
dst++; dst++;
} }
if (end_mask) if (end_mask)
#if BITS_PER_LONG == 32 FB_WRITE(FB_READ(dst) | end_mask,
fb_writel(fb_readl(dst) | end_mask,
dst);
#else
fb_writeq(fb_readq(dst) | end_mask,
dst); dst);
#endif
dst1 += linesize; dst1 += linesize;
} while (--height); } while (--height);
break; break;
...@@ -128,33 +122,19 @@ void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect) ...@@ -128,33 +122,19 @@ void cfb_fillrect(struct fb_info *p, struct fb_fillrect *rect)
dst = (unsigned long *) (dst1 - start_index); dst = (unsigned long *) (dst1 - start_index);
if (start_mask) { if (start_mask) {
#if BITS_PER_LONG == 32 FB_WRITE(FB_READ(dst) ^
fb_writel(fb_readl(dst) ^
start_mask, dst); start_mask, dst);
#else
fb_writeq(fb_readq(dst) ^
start_mask, dst);
#endif
dst++; dst++;
} }
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
#if BITS_PER_LONG == 32 FB_WRITE(FB_READ(dst) ^ fg, dst);
fb_writel(fb_readl(dst) ^ fg, dst);
#else
fb_writeq(fb_readq(dst) ^ fg, dst);
#endif
dst++; dst++;
} }
if (end_mask) { if (end_mask) {
#if BITS_PER_LONG == 32 FB_WRITE(FB_READ(dst) ^ end_mask,
fb_writel(fb_readl(dst) ^ end_mask,
dst); dst);
#else
fb_writeq(fb_readq(dst) ^ end_mask,
dst);
#endif
} }
dst1 += linesize; dst1 += linesize;
} while (--height); } while (--height);
......
...@@ -397,7 +397,6 @@ static void __init offb_init_fb(const char *name, const char *full_name, ...@@ -397,7 +397,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
struct fb_fix_screeninfo *fix; struct fb_fix_screeninfo *fix;
struct fb_var_screeninfo *var; struct fb_var_screeninfo *var;
struct fb_info *info; struct fb_info *info;
int i;
if (!request_mem_region(res_start, res_size, "offb")) if (!request_mem_region(res_start, res_size, "offb"))
return; return;
...@@ -412,14 +411,15 @@ static void __init offb_init_fb(const char *name, const char *full_name, ...@@ -412,14 +411,15 @@ static void __init offb_init_fb(const char *name, const char *full_name,
return; return;
} }
info = size = sizeof(struct fb_info) + sizeof(struct display) + sizeof(u32) * 17;
kmalloc(sizeof(struct fb_info) + sizeof(struct display) +
sizeof(u32) * 17, GFP_ATOMIC); info = kmalloc(size, GFP_ATOMIC);
if (info == 0) { if (info == 0) {
release_mem_region(res_start, res_size); release_mem_region(res_start, res_size);
return; return;
} }
memset(info, 0, sizeof(*info)); memset(info, 0, size);
fix = &info->fix; fix = &info->fix;
var = &info->var; var = &info->var;
...@@ -463,7 +463,7 @@ static void __init offb_init_fb(const char *name, const char *full_name, ...@@ -463,7 +463,7 @@ static void __init offb_init_fb(const char *name, const char *full_name,
unsigned long base = address & 0xff000000UL; unsigned long base = address & 0xff000000UL;
par->cmap_adr = par->cmap_adr =
ioremap(base + 0x7ff000, 0x1000) + 0xcc0; ioremap(base + 0x7ff000, 0x1000) + 0xcc0;
par->cmap_data = info->cmap_adr + 1; par->cmap_data = par->cmap_adr + 1;
par->cmap_type = cmap_m64; par->cmap_type = cmap_m64;
} else if (device_is_compatible(dp, "pci1014,b7")) { } else if (device_is_compatible(dp, "pci1014,b7")) {
unsigned long regbase = dp->addrs[0].address; unsigned long regbase = dp->addrs[0].address;
...@@ -553,7 +553,7 @@ static void __init offb_init_fb(const char *name, const char *full_name, ...@@ -553,7 +553,7 @@ static void __init offb_init_fb(const char *name, const char *full_name,
} }
printk(KERN_INFO "fb%d: Open Firmware frame buffer device on %s\n", printk(KERN_INFO "fb%d: Open Firmware frame buffer device on %s\n",
GET_FB_IDX(info->info.node), full_name); GET_FB_IDX(info->node), full_name);
} }
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -1281,4 +1281,4 @@ do { \ ...@@ -1281,4 +1281,4 @@ do { \
} \ } \
} while (0) } while (0)
#endif PM3FB_H #endif /* PM3FB_H */
...@@ -73,7 +73,6 @@ struct display { ...@@ -73,7 +73,6 @@ struct display {
#endif #endif
/* Filled in by the low-level console driver */ /* Filled in by the low-level console driver */
struct vc_data *conp; /* pointer to console data */ struct vc_data *conp; /* pointer to console data */
struct fb_info *fb_info; /* frame buffer for this console */ struct fb_info *fb_info; /* frame buffer for this console */
int vrows; /* number of virtual rows */ int vrows; /* number of virtual rows */
......
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