From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Antonino A. Daplas" Subject: [PATCH 3/5] fbdev: Various mach64 changes Date: Wed, 20 Oct 2004 08:15:41 +0800 Sender: linux-fbdev-devel-admin@lists.sourceforge.net Message-ID: <200410200815.41690.adaplas@hotpop.com> Reply-To: linux-fbdev-devel@lists.sourceforge.net Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.12] helo=sc8-sf-mx2.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1CK43U-0002QX-Aw for linux-fbdev-devel@lists.sourceforge.net; Tue, 19 Oct 2004 17:10:16 -0700 Received: from smtp-out.hotpop.com ([38.113.3.71]) by sc8-sf-mx2.sourceforge.net with esmtp (Exim 4.41) id 1CK43T-0008Ot-6s for linux-fbdev-devel@lists.sourceforge.net; Tue, 19 Oct 2004 17:10:16 -0700 Received: from hotpop.com (kubrick.hotpop.com [38.113.3.103]) by smtp-out.hotpop.com (Postfix) with SMTP id 8BE981175D84 for ; Wed, 20 Oct 2004 00:10:08 +0000 (UTC) Content-Disposition: inline Errors-To: linux-fbdev-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Id: List-Post: List-Help: List-Subscribe: , List-Archive: Content-Type: text/plain; charset="iso-8859-1" To: Andrew Morton , Linux Fbdev development list Cc: Alexander Kern , Arnaud FONTAINE , Geert Uytterhoeven , James Simmons , Nicolas Souchu , Ville =?iso-8859-1?q?Syrj=E4l=E4?= Alexander Kern [PATCH] port Daniel Mantione 2.4 driver to 2.6 [PATCH] add more pci_id number [PATCH] add accelerated imgblit [PATCH] revert SDRAM_MAGIC_PLL to old behaviour [PATCH] do a "from BIOS" initialisation only by __i386__ Arnaud FONTAINE [PATCH atyfb] correction for 3D Rage Mobility L Geert Uytterhoeven [PATCH atyfb] Atari Atyfb fixes [PATCH atyfb] Atyfb on Mach64 GX or Atari [PATCH 468] m68k sparse floating point James Simmons [PATCH add] port to framebuffer_alloc api Nicolas Souchu [PATCH] I do not found a copy, but it was incorporated too Ville Syrj=E4l=E4 [PATCH] fix pan with doublescan [PATCH] another double scan fix [PATCH] disable linear aperture register access [PATCH] Memory type correction [PATCH] atyfb (2.6): Fix mmio_start [PATCH] atyfb (2.6): Fix mem_refresh_rate for Mobility [PATCH] atyfb (2.6): Add RGB565 support [PATCH] atyfb: Blank LCD by turning off backlight voltage [PATCH] atyfb: Rage LT LCD register access [PATCH] atyfb: vblank irq support [PATCH] atyfb: MTRR support Signed-off-by: Antonino Daplas =2D-- drivers/video/Kconfig | 19 drivers/video/aty/ati_ids.h | 1 drivers/video/aty/atyfb.h | 207 +- drivers/video/aty/atyfb_base.c | 3576 ++++++++++++++++++++++++---------= =2D---- drivers/video/aty/mach64_accel.c | 212 ++ drivers/video/aty/mach64_ct.c | 731 +++++-- drivers/video/aty/mach64_cursor.c | 309 +-- drivers/video/aty/mach64_gx.c | 20 drivers/video/aty/xlinit.c | 68 include/video/mach64.h | 351 +++ 10 files changed, 3680 insertions(+), 1814 deletions(-) diff -Nru a/drivers/video/Kconfig b/drivers/video/Kconfig =2D-- a/drivers/video/Kconfig 2004-10-17 14:02:58 +08:00 +++ b/drivers/video/Kconfig 2004-10-07 06:18:18 +08:00 @@ -750,6 +750,19 @@ framebuffer device. The ATI product support page for these boards is at . =20 +config FB_ATY_GENERIC_LCD + bool "Mach64 generic LCD support (EXPERIMENTAL)" + depends on FB_ATY_CT + help + Say Y if you have a laptop with an ATI Rage LT PRO, Rage Mobility, + Rage XC, or Rage XL chipset. + +config FB_ATY_XL_INIT + bool "Rage XL No-BIOS Init support" + depends on FB_ATY_CT + help + Say Y here to support booting a Rage XL without BIOS support. + config FB_ATY_GX bool "Mach64 GX support" if PCI depends on FB_ATY @@ -760,12 +773,6 @@ framebuffer device. The ATI product support page for these boards is at . =2D =2Dconfig FB_ATY_XL_INIT =2D bool " Rage XL No-BIOS Init support" if FB_ATY_CT =2D depends on FB_ATY =2D help =2D Say Y here to support booting a Rage XL without BIOS support. =20 config FB_SIS tristate "SiS acceleration" diff -Nru a/drivers/video/aty/ati_ids.h b/drivers/video/aty/ati_ids.h =2D-- a/drivers/video/aty/ati_ids.h 2004-10-19 20:22:38 +08:00 +++ b/drivers/video/aty/ati_ids.h 2004-10-07 06:18:18 +08:00 @@ -64,6 +64,7 @@ #define PCI_CHIP_MACH64LQ 0x4C51 #define PCI_CHIP_MACH64LR 0x4C52 #define PCI_CHIP_MACH64LS 0x4C53 +#define PCI_CHIP_MACH64LT 0x4C54 #define PCI_CHIP_RADEON_LW 0x4C57 #define PCI_CHIP_RADEON_LX 0x4C58 #define PCI_CHIP_RADEON_LY 0x4C59 diff -Nru a/drivers/video/aty/atyfb.h b/drivers/video/aty/atyfb.h =2D-- a/drivers/video/aty/atyfb.h 2004-10-19 20:22:40 +08:00 +++ b/drivers/video/aty/atyfb.h 2004-10-11 03:43:16 +08:00 @@ -3,6 +3,8 @@ */ =20 #include +#include +#include /* * Elements of the hardware specific atyfb_par structure */ @@ -10,16 +12,60 @@ struct crtc { u32 vxres; u32 vyres; + u32 xoffset; + u32 yoffset; + u32 bpp; u32 h_tot_disp; u32 h_sync_strt_wid; u32 v_tot_disp; u32 v_sync_strt_wid; + u32 vline_crnt_vline; u32 off_pitch; u32 gen_cntl; u32 dp_pix_width; /* acceleration */ u32 dp_chain_mask; /* acceleration */ +#ifdef CONFIG_FB_ATY_GENERIC_LCD + u32 horz_stretching; + u32 vert_stretching; + u32 ext_vert_stretch; + u32 shadow_h_tot_disp; + u32 shadow_h_sync_strt_wid; + u32 shadow_v_tot_disp; + u32 shadow_v_sync_strt_wid; + u32 lcd_gen_cntl; + u32 lcd_config_panel; + u32 lcd_index; +#endif +}; + +struct aty_interrupt { + wait_queue_head_t wait; + unsigned int count; + int pan_display; +}; + +struct pll_info { + int pll_max; + int pll_min; + int sclk, mclk, mclk_pm, xclk; + int ref_div; + int ref_clk; }; =20 +typedef struct { + u16 unknown1; + u16 PCLK_min_freq; + u16 PCLK_max_freq; + u16 unknown2; + u16 ref_freq; + u16 ref_divider; + u16 unknown3; + u16 MCLK_pwd; + u16 MCLK_max_freq; + u16 XCLK_max_freq; + u16 SCLK_freq; +} __attribute__ ((packed)) PLL_BLOCK_MACH64; + struct pll_514 { u8 m; u8 n; @@ -36,16 +82,39 @@ u8 pll_ref_div; u8 pll_gen_cntl; u8 mclk_fb_div; + u8 mclk_fb_mult; /* 2 ro 4 */ +/* u8 sclk_fb_div;*/ u8 pll_vclk_cntl; u8 vclk_post_div; u8 vclk_fb_div; u8 pll_ext_cntl; =2D u32 dsp_config; /* Mach64 GTB DSP */ =2D u32 dsp_on_off; /* Mach64 GTB DSP */ +/* u8 ext_vpll_cntl; + u8 spll_cntl2;*/ + u32 dsp_config; /* Mach64 GTB DSP */ + u32 dsp_on_off; /* Mach64 GTB DSP */ + u32 dsp_loop_latency; + u32 fifo_size; + u32 xclkpagefaultdelay; + u32 xclkmaxrasdelay; + u8 xclk_ref_div; + u8 xclk_post_div; u8 mclk_post_div_real; + u8 xclk_post_div_real; u8 vclk_post_div_real; + u8 features; +#ifdef CONFIG_FB_ATY_GENERIC_LCD + u32 xres; /* use for LCD stretching/scaling */ +#endif }; =20 +/* + for pll_ct.features +*/ +#define DONT_USE_SPLL 0x1 +#define DONT_USE_XDLL 0x2 +#define USE_CPUCLK 0x4 +#define POWERDOWN_PLL 0x8 + union aty_pll { struct pll_ct ct; struct pll_514 ibm514; @@ -56,42 +125,68 @@ * The hardware parameters for each card */ =20 =2Dstruct aty_cursor { =2D u8 bits[8][64]; =2D u8 mask[8][64]; =2D u8 *ram; =2D}; =2D struct atyfb_par { struct aty_cmap_regs *aty_cmap_regs; + struct { u8 red, green, blue; } palette[256]; const struct aty_dac_ops *dac_ops; const struct aty_pll_ops *pll_ops; =2D struct aty_cursor *cursor; =2D unsigned long ati_regbase; =2D unsigned long clk_wr_offset; + void *ati_regbase; + unsigned long clk_wr_offset; /* meaning overloaded, clock id by CT */ struct crtc crtc; union aty_pll pll; + struct pll_info pll_limits; u32 features; u32 ref_clk_per; u32 pll_per; u32 mclk_per; + u32 xclk_per; u8 bus_type; u8 ram_type; u8 mem_refresh_rate; =2D u8 blitter_may_be_busy; + u16 pci_id; u32 accel_flags; + int blitter_may_be_busy; + int asleep; + int lock_blank; + unsigned long res_start; + unsigned long res_size; #ifdef __sparc__ struct pci_mmap_map *mmap_map; u8 mmaped; +#endif int open; +#ifdef CONFIG_FB_ATY_GENERIC_LCD + unsigned long bios_base_phys; + unsigned long bios_base; + unsigned long lcd_table; + u16 lcd_width; + u16 lcd_height; + u32 lcd_pixclock; + u16 lcd_refreshrate; + u16 lcd_htotal; + u16 lcd_hdisp; + u16 lcd_hsync_dly; + u16 lcd_hsync_len; + u16 lcd_vtotal; + u16 lcd_vdisp; + u16 lcd_vsync_len; + u16 lcd_right_margin; + u16 lcd_lower_margin; + u16 lcd_hblank_len; + u16 lcd_vblank_len; #endif =2D#ifdef CONFIG_PMAC_PBOOK =2D struct fb_info *next; =2D unsigned char *save_framebuffer; =2D unsigned long save_pll[64]; + unsigned long aux_start; /* auxiliary aperture */ + unsigned long aux_size; + struct aty_interrupt vblank; + unsigned long irq_flags; + unsigned int irq; + spinlock_t int_lock; +#ifdef CONFIG_MTRR + int mtrr_aper; + int mtrr_reg; #endif }; =2D =20 + /* * ATI Mach64 features */ @@ -101,7 +196,7 @@ #define M64F_RESET_3D 0x00000001 #define M64F_MAGIC_FIFO 0x00000002 #define M64F_GTB_DSP 0x00000004 =2D#define M64F_FIFO_24 0x00000008 +#define M64F_FIFO_32 0x00000008 #define M64F_SDRAM_MAGIC_PLL 0x00000010 #define M64F_MAGIC_POSTDIV 0x00000020 #define M64F_INTEGRATED 0x00000040 @@ -116,9 +211,10 @@ #define M64F_G3_PB_1_1 0x00008000 #define M64F_G3_PB_1024x768 0x00010000 #define M64F_EXTRA_BRIGHT 0x00020000 =2D#define M64F_LT_SLEEP 0x00040000 +#define M64F_LT_LCD_REGS 0x00040000 #define M64F_XL_DLL 0x00080000 =2D +#define M64F_MFB_FORCE_4 0x00100000 +#define M64F_HW_TRIPLE 0x00200000 =20 /* * Register access @@ -137,8 +233,7 @@ #endif } =20 =2Dstatic inline void aty_st_le32(int regindex, u32 val, =2D const struct atyfb_par *par) +static inline void aty_st_le32(int regindex, u32 val, const struct atyfb_p= ar *par) { /* Hack for bloc 1, should be cleanly optimized by compiler */ if (regindex >=3D 0x400) @@ -163,8 +258,7 @@ #endif } =20 =2Dstatic inline void aty_st_8(int regindex, u8 val, =2D const struct atyfb_par *par) +static inline void aty_st_8(int regindex, u8 val, const struct atyfb_par *= par) { /* Hack for bloc 1, should be cleanly optimized by compiler */ if (regindex >=3D 0x400) @@ -177,17 +271,10 @@ #endif } =20 =2Dstatic inline u8 aty_ld_pll(int offset, const struct atyfb_par *par) =2D{ =2D u8 res; =2D =2D /* write addr byte */ =2D aty_st_8(CLOCK_CNTL + 1, (offset << 2), par); =2D /* read the register value */ =2D res =3D aty_ld_8(CLOCK_CNTL + 2, par); =2D return res; =2D} =2D +#if defined(CONFIG_PM) || defined(CONFIG_PMAC_BACKLIGHT) || defined (CONFI= G_FB_ATY_GENERIC_LCD) +extern void aty_st_lcd(int index, u32 val, const struct atyfb_par *par); +extern u32 aty_ld_lcd(int index, const struct atyfb_par *par); +#endif =20 /* * DAC operations @@ -195,14 +282,14 @@ =20 struct aty_dac_ops { int (*set_dac) (const struct fb_info * info, =2D const union aty_pll * pll, u32 bpp, u32 accel); + const union aty_pll * pll, u32 bpp, u32 accel); }; =20 =2Dextern const struct aty_dac_ops aty_dac_ibm514; /* IBM RGB514 */ =2Dextern const struct aty_dac_ops aty_dac_ati68860b; /* ATI 68860-B */ =2Dextern const struct aty_dac_ops aty_dac_att21c498; /* AT&T 21C498 */ =2Dextern const struct aty_dac_ops aty_dac_unsupported; /* unsupported */ =2Dextern const struct aty_dac_ops aty_dac_ct; /* Integrated */ +extern const struct aty_dac_ops aty_dac_ibm514; /* IBM RGB514 */ +extern const struct aty_dac_ops aty_dac_ati68860b; /* ATI 68860-B */ +extern const struct aty_dac_ops aty_dac_att21c498; /* AT&T 21C498 */ +extern const struct aty_dac_ops aty_dac_unsupported; /* unsupported */ +extern const struct aty_dac_ops aty_dac_ct; /* Integrated */ =20 =20 /* @@ -210,37 +297,32 @@ */ =20 struct aty_pll_ops { =2D int (*var_to_pll) (const struct fb_info * info, u32 vclk_per, =2D u8 bpp, union aty_pll * pll); =2D u32(*pll_to_var) (const struct fb_info * info, =2D const union aty_pll * pll); =2D void (*set_pll) (const struct fb_info * info, =2D const union aty_pll * pll); + int (*var_to_pll) (const struct fb_info * info, u32 vclk_per, u32 bpp, un= ion aty_pll * pll); + u32 (*pll_to_var) (const struct fb_info * info, const union aty_pll * pll= ); + void (*set_pll) (const struct fb_info * info, const union aty_pll * pll= ); + void (*get_pll) (const struct fb_info *info, union aty_pll * pll); + int (*init_pll) (const struct fb_info * info, union aty_pll * pll); }; =20 =2Dextern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */ =2Dextern const struct aty_pll_ops aty_pll_stg1703; /* STG 1703 */ =2Dextern const struct aty_pll_ops aty_pll_ch8398; /* Chrontel 8398 */ =2Dextern const struct aty_pll_ops aty_pll_att20c408; /* AT&T 20C408 */ =2Dextern const struct aty_pll_ops aty_pll_ibm514; /* IBM RGB514 */ =2Dextern const struct aty_pll_ops aty_pll_unsupported; /* unsupported */ =2Dextern const struct aty_pll_ops aty_pll_ct; /* Integrated */ +extern const struct aty_pll_ops aty_pll_ati18818_1; /* ATI 18818 */ +extern const struct aty_pll_ops aty_pll_stg1703; /* STG 1703 */ +extern const struct aty_pll_ops aty_pll_ch8398; /* Chrontel 8398 */ +extern const struct aty_pll_ops aty_pll_att20c408; /* AT&T 20C408 */ +extern const struct aty_pll_ops aty_pll_ibm514; /* IBM RGB514 */ +extern const struct aty_pll_ops aty_pll_unsupported; /* unsupported */ +extern const struct aty_pll_ops aty_pll_ct; /* Integrated */ =20 =20 =2Dextern void aty_set_pll_ct(const struct fb_info *info, =2D const union aty_pll *pll); =2Dextern void aty_calc_pll_ct(const struct fb_info *info, =2D struct pll_ct *pll); +extern void aty_set_pll_ct(const struct fb_info *info, const union aty_pll= *pll); +extern u8 aty_ld_pll_ct(int offset, const struct atyfb_par *par); =20 =20 /* * Hardware cursor support */ =20 =2Dextern struct aty_cursor *aty_init_cursor(struct fb_info *info); +extern int aty_init_cursor(struct fb_info *info); extern int atyfb_cursor(struct fb_info *info, struct fb_cursor *cursor); =2Dextern void aty_set_cursor_color(struct fb_info *info); =2Dextern void aty_set_cursor_shape(struct fb_info *info); =20 /* * Hardware acceleration @@ -260,6 +342,5 @@ } =20 extern void aty_reset_engine(const struct atyfb_par *par); =2Dextern void aty_init_engine(struct atyfb_par *par, =2D struct fb_info *info); +extern void aty_init_engine(struct atyfb_par *par, struct fb_info *info); =20 diff -Nru a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c =2D-- a/drivers/video/aty/atyfb_base.c 2004-10-19 20:22:41 +08:00 +++ b/drivers/video/aty/atyfb_base.c 2004-10-11 04:38:39 +08:00 @@ -1,6 +1,7 @@ /* * ATI Frame Buffer Device Driver Core * + * Copyright (C) 2004 Alex Kern * Copyright (C) 1997-2001 Geert Uytterhoeven * Copyright (C) 1998 Bernd Harries * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) @@ -24,10 +25,13 @@ * Harry AC Eaton * Anthony Tong * + * Generic LCD support written by Daniel Mantione, ported from 2.4.20 by = Alex Kern + * Many Thanks to Ville Syrj=E4l=E4 for patches and fixing nasting 16 bit= color bug. + * * This file is subject to the terms and conditions of the GNU General Pu= blic * License. See the file COPYING in the main directory of this archive for * more details. =2D * =20 + * * Many thanks to Nitya from ATI devrel for support and patience ! */ =20 @@ -38,15 +42,16 @@ - cursor support on all cards and all ramdacs. - cursor parameters controlable via ioctl()s. - guess PLL and MCLK based on the original PLL register values initial= ized =2D by the BIOS or Open Firmware (if they are initialized). + by Open Firmware (if they are initialized). BIOS is done =20 =2D (Anyone to help with this?) + (Anyone with Mac to help with this?) =20 **************************************************************************= ****/ =20 =20 #include #include +#include #include #include #include @@ -54,19 +59,20 @@ #include #include #include =2D#include #include #include #include #include =2D#include =2D#include +#include +#include +#include =20 #include #include =20 #include