| .. | .. |
|---|
| 47 | 47 | #define ATAFB_EXT |
|---|
| 48 | 48 | #define ATAFB_FALCON |
|---|
| 49 | 49 | |
|---|
| 50 | | -#include <linux/module.h> |
|---|
| 51 | 50 | #include <linux/kernel.h> |
|---|
| 52 | 51 | #include <linux/errno.h> |
|---|
| 53 | 52 | #include <linux/string.h> |
|---|
| .. | .. |
|---|
| 55 | 54 | #include <linux/delay.h> |
|---|
| 56 | 55 | #include <linux/init.h> |
|---|
| 57 | 56 | #include <linux/interrupt.h> |
|---|
| 57 | +#include <linux/platform_device.h> |
|---|
| 58 | 58 | |
|---|
| 59 | 59 | #include <asm/setup.h> |
|---|
| 60 | 60 | #include <linux/uaccess.h> |
|---|
| 61 | | -#include <asm/pgtable.h> |
|---|
| 62 | 61 | #include <asm/irq.h> |
|---|
| 63 | 62 | #include <asm/io.h> |
|---|
| 64 | 63 | |
|---|
| .. | .. |
|---|
| 77 | 76 | #define SWITCH_SND7 0x80 |
|---|
| 78 | 77 | #define SWITCH_NONE 0x00 |
|---|
| 79 | 78 | |
|---|
| 80 | | - |
|---|
| 81 | 79 | #define up(x, r) (((x) + (r) - 1) & ~((r)-1)) |
|---|
| 82 | | - |
|---|
| 83 | | - /* |
|---|
| 84 | | - * Interface to the world |
|---|
| 85 | | - */ |
|---|
| 86 | | - |
|---|
| 87 | | -static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); |
|---|
| 88 | | -static int atafb_set_par(struct fb_info *info); |
|---|
| 89 | | -static int atafb_setcolreg(unsigned int regno, unsigned int red, unsigned int green, |
|---|
| 90 | | - unsigned int blue, unsigned int transp, |
|---|
| 91 | | - struct fb_info *info); |
|---|
| 92 | | -static int atafb_blank(int blank, struct fb_info *info); |
|---|
| 93 | | -static int atafb_pan_display(struct fb_var_screeninfo *var, |
|---|
| 94 | | - struct fb_info *info); |
|---|
| 95 | | -static void atafb_fillrect(struct fb_info *info, |
|---|
| 96 | | - const struct fb_fillrect *rect); |
|---|
| 97 | | -static void atafb_copyarea(struct fb_info *info, |
|---|
| 98 | | - const struct fb_copyarea *region); |
|---|
| 99 | | -static void atafb_imageblit(struct fb_info *info, const struct fb_image *image); |
|---|
| 100 | | -static int atafb_ioctl(struct fb_info *info, unsigned int cmd, |
|---|
| 101 | | - unsigned long arg); |
|---|
| 102 | 80 | |
|---|
| 103 | 81 | |
|---|
| 104 | 82 | static int default_par; /* default resolution (0=none) */ |
|---|
| .. | .. |
|---|
| 784 | 762 | { |
|---|
| 785 | 763 | unsigned long addr; |
|---|
| 786 | 764 | par->hw.tt.mode = shifter_tt.tt_shiftmode; |
|---|
| 787 | | - par->hw.tt.sync = shifter.syncmode; |
|---|
| 788 | | - addr = ((shifter.bas_hi & 0xff) << 16) | |
|---|
| 789 | | - ((shifter.bas_md & 0xff) << 8) | |
|---|
| 790 | | - ((shifter.bas_lo & 0xff)); |
|---|
| 765 | + par->hw.tt.sync = shifter_st.syncmode; |
|---|
| 766 | + addr = ((shifter_st.bas_hi & 0xff) << 16) | |
|---|
| 767 | + ((shifter_st.bas_md & 0xff) << 8) | |
|---|
| 768 | + ((shifter_st.bas_lo & 0xff)); |
|---|
| 791 | 769 | par->screen_base = atari_stram_to_virt(addr); |
|---|
| 792 | 770 | } |
|---|
| 793 | 771 | |
|---|
| 794 | 772 | static void tt_set_par(struct atafb_par *par) |
|---|
| 795 | 773 | { |
|---|
| 796 | 774 | shifter_tt.tt_shiftmode = par->hw.tt.mode; |
|---|
| 797 | | - shifter.syncmode = par->hw.tt.sync; |
|---|
| 775 | + shifter_st.syncmode = par->hw.tt.sync; |
|---|
| 798 | 776 | /* only set screen_base if really necessary */ |
|---|
| 799 | 777 | if (current_par.screen_base != par->screen_base) |
|---|
| 800 | 778 | fbhw->set_screen_base(par->screen_base); |
|---|
| .. | .. |
|---|
| 1564 | 1542 | hw->f_shift = videl.f_shift; |
|---|
| 1565 | 1543 | hw->vid_control = videl.control; |
|---|
| 1566 | 1544 | hw->vid_mode = videl.mode; |
|---|
| 1567 | | - hw->sync = shifter.syncmode & 0x1; |
|---|
| 1545 | + hw->sync = shifter_st.syncmode & 0x1; |
|---|
| 1568 | 1546 | hw->xoffset = videl.xoffset & 0xf; |
|---|
| 1569 | 1547 | hw->hht = videl.hht; |
|---|
| 1570 | 1548 | hw->hbb = videl.hbb; |
|---|
| .. | .. |
|---|
| 1579 | 1557 | hw->vde = videl.vde; |
|---|
| 1580 | 1558 | hw->vss = videl.vss; |
|---|
| 1581 | 1559 | |
|---|
| 1582 | | - addr = (shifter.bas_hi & 0xff) << 16 | |
|---|
| 1583 | | - (shifter.bas_md & 0xff) << 8 | |
|---|
| 1584 | | - (shifter.bas_lo & 0xff); |
|---|
| 1560 | + addr = (shifter_st.bas_hi & 0xff) << 16 | |
|---|
| 1561 | + (shifter_st.bas_md & 0xff) << 8 | |
|---|
| 1562 | + (shifter_st.bas_lo & 0xff); |
|---|
| 1585 | 1563 | par->screen_base = atari_stram_to_virt(addr); |
|---|
| 1586 | 1564 | |
|---|
| 1587 | 1565 | /* derived parameters */ |
|---|
| .. | .. |
|---|
| 1626 | 1604 | /* Turn off external clocks. Read sets all output bits to 1. */ |
|---|
| 1627 | 1605 | *(volatile unsigned short *)0xffff9202; |
|---|
| 1628 | 1606 | } |
|---|
| 1629 | | - shifter.syncmode = hw->sync; |
|---|
| 1607 | + shifter_st.syncmode = hw->sync; |
|---|
| 1630 | 1608 | |
|---|
| 1631 | 1609 | videl.hht = hw->hht; |
|---|
| 1632 | 1610 | videl.hbb = hw->hbb; |
|---|
| .. | .. |
|---|
| 1713 | 1691 | ((blue & 0xfc00) >> 8)); |
|---|
| 1714 | 1692 | if (regno < 16) { |
|---|
| 1715 | 1693 | shifter_tt.color_reg[regno] = |
|---|
| 1716 | | - (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) | |
|---|
| 1717 | | - (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) | |
|---|
| 1718 | | - ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12); |
|---|
| 1694 | + ((((red & 0xe000) >> 13) | ((red & 0x1000) >> 12)) << 8) | |
|---|
| 1695 | + ((((green & 0xe000) >> 13) | ((green & 0x1000) >> 12)) << 4) | |
|---|
| 1696 | + ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12); |
|---|
| 1719 | 1697 | ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) | |
|---|
| 1720 | 1698 | ((green & 0xfc00) >> 5) | |
|---|
| 1721 | 1699 | ((blue & 0xf800) >> 11)); |
|---|
| .. | .. |
|---|
| 1973 | 1951 | { |
|---|
| 1974 | 1952 | unsigned long addr; |
|---|
| 1975 | 1953 | par->hw.st.mode = shifter_tt.st_shiftmode; |
|---|
| 1976 | | - par->hw.st.sync = shifter.syncmode; |
|---|
| 1977 | | - addr = ((shifter.bas_hi & 0xff) << 16) | |
|---|
| 1978 | | - ((shifter.bas_md & 0xff) << 8); |
|---|
| 1954 | + par->hw.st.sync = shifter_st.syncmode; |
|---|
| 1955 | + addr = ((shifter_st.bas_hi & 0xff) << 16) | |
|---|
| 1956 | + ((shifter_st.bas_md & 0xff) << 8); |
|---|
| 1979 | 1957 | if (ATARIHW_PRESENT(EXTD_SHIFTER)) |
|---|
| 1980 | | - addr |= (shifter.bas_lo & 0xff); |
|---|
| 1958 | + addr |= (shifter_st.bas_lo & 0xff); |
|---|
| 1981 | 1959 | par->screen_base = atari_stram_to_virt(addr); |
|---|
| 1982 | 1960 | } |
|---|
| 1983 | 1961 | |
|---|
| 1984 | 1962 | static void stste_set_par(struct atafb_par *par) |
|---|
| 1985 | 1963 | { |
|---|
| 1986 | 1964 | shifter_tt.st_shiftmode = par->hw.st.mode; |
|---|
| 1987 | | - shifter.syncmode = par->hw.st.sync; |
|---|
| 1965 | + shifter_st.syncmode = par->hw.st.sync; |
|---|
| 1988 | 1966 | /* only set screen_base if really necessary */ |
|---|
| 1989 | 1967 | if (current_par.screen_base != par->screen_base) |
|---|
| 1990 | 1968 | fbhw->set_screen_base(par->screen_base); |
|---|
| .. | .. |
|---|
| 2001 | 1979 | green >>= 12; |
|---|
| 2002 | 1980 | if (ATARIHW_PRESENT(EXTD_SHIFTER)) |
|---|
| 2003 | 1981 | shifter_tt.color_reg[regno] = |
|---|
| 2004 | | - (((red & 0xe) >> 1) | ((red & 1) << 3) << 8) | |
|---|
| 2005 | | - (((green & 0xe) >> 1) | ((green & 1) << 3) << 4) | |
|---|
| 2006 | | - ((blue & 0xe) >> 1) | ((blue & 1) << 3); |
|---|
| 1982 | + ((((red & 0xe) >> 1) | ((red & 1) << 3)) << 8) | |
|---|
| 1983 | + ((((green & 0xe) >> 1) | ((green & 1) << 3)) << 4) | |
|---|
| 1984 | + ((blue & 0xe) >> 1) | ((blue & 1) << 3); |
|---|
| 2007 | 1985 | else |
|---|
| 2008 | 1986 | shifter_tt.color_reg[regno] = |
|---|
| 2009 | 1987 | ((red & 0xe) << 7) | |
|---|
| .. | .. |
|---|
| 2039 | 2017 | unsigned long addr; |
|---|
| 2040 | 2018 | addr = atari_stram_to_phys(s_base); |
|---|
| 2041 | 2019 | /* Setup Screen Memory */ |
|---|
| 2042 | | - shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); |
|---|
| 2043 | | - shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); |
|---|
| 2020 | + shifter_st.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); |
|---|
| 2021 | + shifter_st.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); |
|---|
| 2044 | 2022 | if (ATARIHW_PRESENT(EXTD_SHIFTER)) |
|---|
| 2045 | | - shifter.bas_lo = (unsigned char)(addr & 0x0000ff); |
|---|
| 2023 | + shifter_st.bas_lo = (unsigned char)(addr & 0x0000ff); |
|---|
| 2046 | 2024 | } |
|---|
| 2047 | 2025 | |
|---|
| 2048 | 2026 | #endif /* ATAFB_STE */ |
|---|
| .. | .. |
|---|
| 2286 | 2264 | |
|---|
| 2287 | 2265 | addr = atari_stram_to_phys(s_base); |
|---|
| 2288 | 2266 | /* Setup Screen Memory */ |
|---|
| 2289 | | - shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); |
|---|
| 2290 | | - shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); |
|---|
| 2291 | | - shifter.bas_lo = (unsigned char)(addr & 0x0000ff); |
|---|
| 2267 | + shifter_st.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); |
|---|
| 2268 | + shifter_st.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); |
|---|
| 2269 | + shifter_st.bas_lo = (unsigned char)(addr & 0x0000ff); |
|---|
| 2292 | 2270 | } |
|---|
| 2293 | 2271 | |
|---|
| 2294 | 2272 | static int pan_display(struct fb_var_screeninfo *var, struct fb_info *info) |
|---|
| .. | .. |
|---|
| 3073 | 3051 | return 0; |
|---|
| 3074 | 3052 | } |
|---|
| 3075 | 3053 | |
|---|
| 3076 | | -int __init atafb_init(void) |
|---|
| 3054 | +static int __init atafb_probe(struct platform_device *pdev) |
|---|
| 3077 | 3055 | { |
|---|
| 3078 | 3056 | int pad, detected_mode, error; |
|---|
| 3079 | 3057 | unsigned int defmode = 0; |
|---|
| 3080 | 3058 | unsigned long mem_req; |
|---|
| 3081 | | - |
|---|
| 3082 | | -#ifndef MODULE |
|---|
| 3083 | 3059 | char *option = NULL; |
|---|
| 3084 | 3060 | |
|---|
| 3085 | 3061 | if (fb_get_options("atafb", &option)) |
|---|
| 3086 | 3062 | return -ENODEV; |
|---|
| 3087 | 3063 | atafb_setup(option); |
|---|
| 3088 | | -#endif |
|---|
| 3089 | | - printk("atafb_init: start\n"); |
|---|
| 3090 | | - |
|---|
| 3091 | | - if (!MACH_IS_ATARI) |
|---|
| 3092 | | - return -ENODEV; |
|---|
| 3064 | + dev_dbg(&pdev->dev, "%s: start\n", __func__); |
|---|
| 3093 | 3065 | |
|---|
| 3094 | 3066 | do { |
|---|
| 3095 | 3067 | #ifdef ATAFB_EXT |
|---|
| 3096 | 3068 | if (external_addr) { |
|---|
| 3097 | | - printk("atafb_init: initializing external hw\n"); |
|---|
| 3069 | + dev_dbg(&pdev->dev, "initializing external hw\n"); |
|---|
| 3098 | 3070 | fbhw = &ext_switch; |
|---|
| 3099 | 3071 | atafb_ops.fb_setcolreg = &ext_setcolreg; |
|---|
| 3100 | 3072 | defmode = DEFMODE_EXT; |
|---|
| .. | .. |
|---|
| 3103 | 3075 | #endif |
|---|
| 3104 | 3076 | #ifdef ATAFB_TT |
|---|
| 3105 | 3077 | if (ATARIHW_PRESENT(TT_SHIFTER)) { |
|---|
| 3106 | | - printk("atafb_init: initializing TT hw\n"); |
|---|
| 3078 | + dev_dbg(&pdev->dev, "initializing TT hw\n"); |
|---|
| 3107 | 3079 | fbhw = &tt_switch; |
|---|
| 3108 | 3080 | atafb_ops.fb_setcolreg = &tt_setcolreg; |
|---|
| 3109 | 3081 | defmode = DEFMODE_TT; |
|---|
| .. | .. |
|---|
| 3112 | 3084 | #endif |
|---|
| 3113 | 3085 | #ifdef ATAFB_FALCON |
|---|
| 3114 | 3086 | if (ATARIHW_PRESENT(VIDEL_SHIFTER)) { |
|---|
| 3115 | | - printk("atafb_init: initializing Falcon hw\n"); |
|---|
| 3087 | + dev_dbg(&pdev->dev, "initializing Falcon hw\n"); |
|---|
| 3116 | 3088 | fbhw = &falcon_switch; |
|---|
| 3117 | 3089 | atafb_ops.fb_setcolreg = &falcon_setcolreg; |
|---|
| 3118 | 3090 | error = request_irq(IRQ_AUTO_4, falcon_vbl_switcher, 0, |
|---|
| .. | .. |
|---|
| 3127 | 3099 | #ifdef ATAFB_STE |
|---|
| 3128 | 3100 | if (ATARIHW_PRESENT(STND_SHIFTER) || |
|---|
| 3129 | 3101 | ATARIHW_PRESENT(EXTD_SHIFTER)) { |
|---|
| 3130 | | - printk("atafb_init: initializing ST/E hw\n"); |
|---|
| 3102 | + dev_dbg(&pdev->dev, "initializing ST/E hw\n"); |
|---|
| 3131 | 3103 | fbhw = &st_switch; |
|---|
| 3132 | 3104 | atafb_ops.fb_setcolreg = &stste_setcolreg; |
|---|
| 3133 | 3105 | defmode = DEFMODE_STE; |
|---|
| .. | .. |
|---|
| 3135 | 3107 | } |
|---|
| 3136 | 3108 | fbhw = &st_switch; |
|---|
| 3137 | 3109 | atafb_ops.fb_setcolreg = &stste_setcolreg; |
|---|
| 3138 | | - printk("Cannot determine video hardware; defaulting to ST(e)\n"); |
|---|
| 3110 | + dev_warn(&pdev->dev, |
|---|
| 3111 | + "Cannot determine video hardware; defaulting to ST(e)\n"); |
|---|
| 3139 | 3112 | #else /* ATAFB_STE */ |
|---|
| 3140 | 3113 | /* no default driver included */ |
|---|
| 3141 | 3114 | /* Nobody will ever see this message :-) */ |
|---|
| .. | .. |
|---|
| 3175 | 3148 | kernel_set_cachemode(screen_base, screen_len, |
|---|
| 3176 | 3149 | IOMAP_WRITETHROUGH); |
|---|
| 3177 | 3150 | } |
|---|
| 3178 | | - printk("atafb: screen_base %p phys_screen_base %lx screen_len %d\n", |
|---|
| 3179 | | - screen_base, phys_screen_base, screen_len); |
|---|
| 3151 | + dev_info(&pdev->dev, "phys_screen_base %lx screen_len %d\n", |
|---|
| 3152 | + phys_screen_base, screen_len); |
|---|
| 3180 | 3153 | #ifdef ATAFB_EXT |
|---|
| 3181 | 3154 | } else { |
|---|
| 3182 | 3155 | /* Map the video memory (physical address given) to somewhere |
|---|
| .. | .. |
|---|
| 3223 | 3196 | fb_alloc_cmap(&(fb_info.cmap), 1 << fb_info.var.bits_per_pixel, 0); |
|---|
| 3224 | 3197 | |
|---|
| 3225 | 3198 | |
|---|
| 3226 | | - printk("Determined %dx%d, depth %d\n", |
|---|
| 3227 | | - fb_info.var.xres, fb_info.var.yres, fb_info.var.bits_per_pixel); |
|---|
| 3199 | + dev_info(&pdev->dev, "Determined %dx%d, depth %d\n", fb_info.var.xres, |
|---|
| 3200 | + fb_info.var.yres, fb_info.var.bits_per_pixel); |
|---|
| 3228 | 3201 | if ((fb_info.var.xres != fb_info.var.xres_virtual) || |
|---|
| 3229 | 3202 | (fb_info.var.yres != fb_info.var.yres_virtual)) |
|---|
| 3230 | | - printk(" virtual %dx%d\n", fb_info.var.xres_virtual, |
|---|
| 3231 | | - fb_info.var.yres_virtual); |
|---|
| 3203 | + dev_info(&pdev->dev, " virtual %dx%d\n", |
|---|
| 3204 | + fb_info.var.xres_virtual, fb_info.var.yres_virtual); |
|---|
| 3232 | 3205 | |
|---|
| 3233 | 3206 | if (register_framebuffer(&fb_info) < 0) { |
|---|
| 3234 | 3207 | #ifdef ATAFB_EXT |
|---|
| .. | .. |
|---|
| 3251 | 3224 | return 0; |
|---|
| 3252 | 3225 | } |
|---|
| 3253 | 3226 | |
|---|
| 3254 | | -module_init(atafb_init); |
|---|
| 3255 | | - |
|---|
| 3256 | | -#ifdef MODULE |
|---|
| 3257 | | -MODULE_LICENSE("GPL"); |
|---|
| 3258 | | - |
|---|
| 3259 | | -int cleanup_module(void) |
|---|
| 3227 | +static void atafb_shutdown(struct platform_device *pdev) |
|---|
| 3260 | 3228 | { |
|---|
| 3261 | | - unregister_framebuffer(&fb_info); |
|---|
| 3262 | | - return atafb_deinit(); |
|---|
| 3229 | + /* Unblank before kexec */ |
|---|
| 3230 | + if (fbhw->blank) |
|---|
| 3231 | + fbhw->blank(0); |
|---|
| 3263 | 3232 | } |
|---|
| 3264 | | -#endif /* MODULE */ |
|---|
| 3233 | + |
|---|
| 3234 | +static struct platform_driver atafb_driver = { |
|---|
| 3235 | + .shutdown = atafb_shutdown, |
|---|
| 3236 | + .driver = { |
|---|
| 3237 | + .name = "atafb", |
|---|
| 3238 | + }, |
|---|
| 3239 | +}; |
|---|
| 3240 | + |
|---|
| 3241 | +static int __init atafb_init(void) |
|---|
| 3242 | +{ |
|---|
| 3243 | + struct platform_device *pdev; |
|---|
| 3244 | + |
|---|
| 3245 | + if (!MACH_IS_ATARI) |
|---|
| 3246 | + return -ENODEV; |
|---|
| 3247 | + |
|---|
| 3248 | + pdev = platform_device_register_simple("atafb", -1, NULL, 0); |
|---|
| 3249 | + if (IS_ERR(pdev)) |
|---|
| 3250 | + return PTR_ERR(pdev); |
|---|
| 3251 | + |
|---|
| 3252 | + return platform_driver_probe(&atafb_driver, atafb_probe); |
|---|
| 3253 | +} |
|---|
| 3254 | + |
|---|
| 3255 | +device_initcall(atafb_init); |
|---|