#include <linux/aperture.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/uaccess.h>
#include <linux/fb.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/ioport.h>
#include <linux/console.h>
#include <linux/backlight.h>
#include <asm/io.h>
#ifdef CONFIG_PPC_PMAC
#include <asm/machdep.h>
#include <asm/pmac_feature.h>
#include "../macmodes.h"
#endif
#ifdef CONFIG_PMAC_BACKLIGHT
#include <asm/backlight.h>
#endif
#ifdef CONFIG_BOOTX_TEXT
#include <asm/btext.h>
#endif
#include <video/aty128.h>
#undef DEBUG
#ifdef DEBUG
#define DBG …
#else
#define DBG(fmt, args...) …
#endif
#ifndef CONFIG_PPC_PMAC
static const struct fb_var_screeninfo default_var = …;
#else
static const struct fb_var_screeninfo default_var = {
1024, 768, 1024, 768, 0, 0, 8, 0,
{0, 8, 0}, {0, 8, 0}, {0, 8, 0}, {0, 0, 0},
0, 0, -1, -1, 0, 12699, 160, 32, 28, 1, 96, 3,
FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
FB_VMODE_NONINTERLACED
};
#endif
static const struct fb_videomode defaultmode = …;
enum { … };
static char * const r128_family[] = …;
static int aty128_probe(struct pci_dev *pdev,
const struct pci_device_id *ent);
static void aty128_remove(struct pci_dev *pdev);
static int aty128_pci_suspend_late(struct device *dev, pm_message_t state);
static int __maybe_unused aty128_pci_suspend(struct device *dev);
static int __maybe_unused aty128_pci_hibernate(struct device *dev);
static int __maybe_unused aty128_pci_freeze(struct device *dev);
static int __maybe_unused aty128_pci_resume(struct device *dev);
static int aty128_do_resume(struct pci_dev *pdev);
static const struct dev_pm_ops aty128_pci_pm_ops = …;
static const struct pci_device_id aty128_pci_tbl[] = …;
MODULE_DEVICE_TABLE(pci, aty128_pci_tbl);
static struct pci_driver aty128fb_driver = …;
#ifndef CONFIG_PPC
PLL_BLOCK;
#endif
struct aty128_meminfo { … };
static const struct aty128_meminfo sdr_128 = …;
static const struct aty128_meminfo sdr_sgram = …;
static const struct aty128_meminfo ddr_sgram = …;
static const struct fb_fix_screeninfo aty128fb_fix = …;
static char *mode_option = …;
#ifdef CONFIG_PPC_PMAC
static int default_vmode = VMODE_1024_768_60;
static int default_cmode = CMODE_8;
#endif
static int default_crt_on = …;
static int default_lcd_on = …;
static bool mtrr = …;
#ifdef CONFIG_FB_ATY128_BACKLIGHT
static int backlight = … IS_BUILTIN(…);
#endif
struct aty128_constants { … };
struct aty128_crtc { … };
struct aty128_pll { … };
struct aty128_ddafifo { … };
struct aty128fb_par { … };
#define round_div(n, d) …
static int aty128fb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info);
static int aty128fb_set_par(struct fb_info *info);
static int aty128fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info);
static int aty128fb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *fb);
static int aty128fb_blank(int blank, struct fb_info *fb);
static int aty128fb_ioctl(struct fb_info *info, u_int cmd, unsigned long arg);
static int aty128fb_sync(struct fb_info *info);
static int aty128_encode_var(struct fb_var_screeninfo *var,
const struct aty128fb_par *par);
static int aty128_decode_var(struct fb_var_screeninfo *var,
struct aty128fb_par *par);
static void aty128_timings(struct aty128fb_par *par);
static void aty128_init_engine(struct aty128fb_par *par);
static void aty128_reset_engine(const struct aty128fb_par *par);
static void aty128_flush_pixel_cache(const struct aty128fb_par *par);
static void do_wait_for_fifo(u16 entries, struct aty128fb_par *par);
static void wait_for_fifo(u16 entries, struct aty128fb_par *par);
static void wait_for_idle(struct aty128fb_par *par);
static u32 depth_to_dst(u32 depth);
#ifdef CONFIG_FB_ATY128_BACKLIGHT
static void aty128_bl_set_power(struct fb_info *info, int power);
#endif
#define BIOS_IN8(v) …
#define BIOS_IN16(v) …
#define BIOS_IN32(v) …
static const struct fb_ops aty128fb_ops = …;
static inline u32 _aty_ld_le32(volatile unsigned int regindex,
const struct aty128fb_par *par)
{ … }
static inline void _aty_st_le32(volatile unsigned int regindex, u32 val,
const struct aty128fb_par *par)
{ … }
static inline u8 _aty_ld_8(unsigned int regindex,
const struct aty128fb_par *par)
{ … }
static inline void _aty_st_8(unsigned int regindex, u8 val,
const struct aty128fb_par *par)
{ … }
#define aty_ld_le32(regindex) …
#define aty_st_le32(regindex, val) …
#define aty_ld_8(regindex) …
#define aty_st_8(regindex, val) …
#define aty_ld_pll(pll_index) …
#define aty_st_pll(pll_index, val) …
static u32 _aty_ld_pll(unsigned int pll_index,
const struct aty128fb_par *par)
{ … }
static void _aty_st_pll(unsigned int pll_index, u32 val,
const struct aty128fb_par *par)
{ … }
static int aty_pll_readupdate(const struct aty128fb_par *par)
{ … }
static void aty_pll_wait_readupdate(const struct aty128fb_par *par)
{ … }
static void aty_pll_writeupdate(const struct aty128fb_par *par)
{ … }
static int register_test(const struct aty128fb_par *par)
{ … }
static void do_wait_for_fifo(u16 entries, struct aty128fb_par *par)
{ … }
static void wait_for_idle(struct aty128fb_par *par)
{ … }
static void wait_for_fifo(u16 entries, struct aty128fb_par *par)
{ … }
static void aty128_flush_pixel_cache(const struct aty128fb_par *par)
{ … }
static void aty128_reset_engine(const struct aty128fb_par *par)
{ … }
static void aty128_init_engine(struct aty128fb_par *par)
{ … }
static u32 depth_to_dst(u32 depth)
{ … }
#ifndef __sparc__
static void __iomem *aty128_map_ROM(const struct aty128fb_par *par,
struct pci_dev *dev)
{ … }
static void aty128_get_pllinfo(struct aty128fb_par *par,
unsigned char __iomem *bios)
{ … }
#ifdef CONFIG_X86
static void __iomem *aty128_find_mem_vbios(struct aty128fb_par *par)
{ … }
#endif
#endif
static void aty128_timings(struct aty128fb_par *par)
{ … }
static void aty128_set_crtc(const struct aty128_crtc *crtc,
const struct aty128fb_par *par)
{ … }
static int aty128_var_to_crtc(const struct fb_var_screeninfo *var,
struct aty128_crtc *crtc,
const struct aty128fb_par *par)
{ … }
static int aty128_pix_width_to_var(int pix_width, struct fb_var_screeninfo *var)
{ … }
static int aty128_crtc_to_var(const struct aty128_crtc *crtc,
struct fb_var_screeninfo *var)
{ … }
static void aty128_set_crt_enable(struct aty128fb_par *par, int on)
{ … }
static void aty128_set_lcd_enable(struct aty128fb_par *par, int on)
{ … }
static void aty128_set_pll(struct aty128_pll *pll,
const struct aty128fb_par *par)
{ … }
static int aty128_var_to_pll(u32 period_in_ps, struct aty128_pll *pll,
const struct aty128fb_par *par)
{ … }
static int aty128_pll_to_var(const struct aty128_pll *pll,
struct fb_var_screeninfo *var)
{ … }
static void aty128_set_fifo(const struct aty128_ddafifo *dsp,
const struct aty128fb_par *par)
{ … }
static int aty128_ddafifo(struct aty128_ddafifo *dsp,
const struct aty128_pll *pll,
u32 depth,
const struct aty128fb_par *par)
{ … }
static int aty128fb_set_par(struct fb_info *info)
{ … }
static int aty128_decode_var(struct fb_var_screeninfo *var,
struct aty128fb_par *par)
{ … }
static int aty128_encode_var(struct fb_var_screeninfo *var,
const struct aty128fb_par *par)
{ … }
static int aty128fb_check_var(struct fb_var_screeninfo *var,
struct fb_info *info)
{ … }
static int aty128fb_pan_display(struct fb_var_screeninfo *var,
struct fb_info *fb)
{ … }
static void aty128_st_pal(u_int regno, u_int red, u_int green, u_int blue,
struct aty128fb_par *par)
{ … }
static int aty128fb_sync(struct fb_info *info)
{ … }
#ifndef MODULE
static int aty128fb_setup(char *options)
{ … }
#endif
#ifdef CONFIG_FB_ATY128_BACKLIGHT
#define MAX_LEVEL …
static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
int level)
{ … }
#define BACKLIGHT_LVDS_OFF
#undef BACKLIGHT_DAC_OFF
static int aty128_bl_update_status(struct backlight_device *bd)
{ … }
static const struct backlight_ops aty128_bl_data = …;
static void aty128_bl_set_power(struct fb_info *info, int power)
{ … }
static void aty128_bl_init(struct aty128fb_par *par)
{ … }
static void aty128_bl_exit(struct backlight_device *bd)
{ … }
#endif
#ifdef CONFIG_PPC_PMAC__disabled
static void aty128_early_resume(void *data)
{
struct aty128fb_par *par = data;
if (!console_trylock())
return;
pci_restore_state(par->pdev);
aty128_do_resume(par->pdev);
console_unlock();
}
#endif
static int aty128_init(struct pci_dev *pdev, const struct pci_device_id *ent)
{ … }
#ifdef CONFIG_PCI
static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ … }
static void aty128_remove(struct pci_dev *pdev)
{ … }
#endif
static int aty128fb_blank(int blank, struct fb_info *fb)
{ … }
static int aty128fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
u_int transp, struct fb_info *info)
{ … }
#define ATY_MIRROR_LCD_ON …
#define ATY_MIRROR_CRT_ON …
#define FBIO_ATY128_GET_MIRROR …
#define FBIO_ATY128_SET_MIRROR …
static int aty128fb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
{ … }
static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
{ … }
static int aty128_pci_suspend_late(struct device *dev, pm_message_t state)
{ … }
static int __maybe_unused aty128_pci_suspend(struct device *dev)
{ … }
static int __maybe_unused aty128_pci_hibernate(struct device *dev)
{ … }
static int __maybe_unused aty128_pci_freeze(struct device *dev)
{ … }
static int aty128_do_resume(struct pci_dev *pdev)
{ … }
static int __maybe_unused aty128_pci_resume(struct device *dev)
{ … }
static int aty128fb_init(void)
{ … }
static void __exit aty128fb_exit(void)
{ … }
module_init(…) …;
module_exit(aty128fb_exit);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
module_param(mode_option, charp, 0);
MODULE_PARM_DESC(…) …;
module_param_named(nomtrr, mtrr, invbool, 0);
MODULE_PARM_DESC(…) …;