hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/video/fbdev/atafb.c
....@@ -47,7 +47,6 @@
4747 #define ATAFB_EXT
4848 #define ATAFB_FALCON
4949
50
-#include <linux/module.h>
5150 #include <linux/kernel.h>
5251 #include <linux/errno.h>
5352 #include <linux/string.h>
....@@ -55,10 +54,10 @@
5554 #include <linux/delay.h>
5655 #include <linux/init.h>
5756 #include <linux/interrupt.h>
57
+#include <linux/platform_device.h>
5858
5959 #include <asm/setup.h>
6060 #include <linux/uaccess.h>
61
-#include <asm/pgtable.h>
6261 #include <asm/irq.h>
6362 #include <asm/io.h>
6463
....@@ -77,28 +76,7 @@
7776 #define SWITCH_SND7 0x80
7877 #define SWITCH_NONE 0x00
7978
80
-
8179 #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);
10280
10381
10482 static int default_par; /* default resolution (0=none) */
....@@ -784,17 +762,17 @@
784762 {
785763 unsigned long addr;
786764 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));
791769 par->screen_base = atari_stram_to_virt(addr);
792770 }
793771
794772 static void tt_set_par(struct atafb_par *par)
795773 {
796774 shifter_tt.tt_shiftmode = par->hw.tt.mode;
797
- shifter.syncmode = par->hw.tt.sync;
775
+ shifter_st.syncmode = par->hw.tt.sync;
798776 /* only set screen_base if really necessary */
799777 if (current_par.screen_base != par->screen_base)
800778 fbhw->set_screen_base(par->screen_base);
....@@ -1564,7 +1542,7 @@
15641542 hw->f_shift = videl.f_shift;
15651543 hw->vid_control = videl.control;
15661544 hw->vid_mode = videl.mode;
1567
- hw->sync = shifter.syncmode & 0x1;
1545
+ hw->sync = shifter_st.syncmode & 0x1;
15681546 hw->xoffset = videl.xoffset & 0xf;
15691547 hw->hht = videl.hht;
15701548 hw->hbb = videl.hbb;
....@@ -1579,9 +1557,9 @@
15791557 hw->vde = videl.vde;
15801558 hw->vss = videl.vss;
15811559
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);
15851563 par->screen_base = atari_stram_to_virt(addr);
15861564
15871565 /* derived parameters */
....@@ -1626,7 +1604,7 @@
16261604 /* Turn off external clocks. Read sets all output bits to 1. */
16271605 *(volatile unsigned short *)0xffff9202;
16281606 }
1629
- shifter.syncmode = hw->sync;
1607
+ shifter_st.syncmode = hw->sync;
16301608
16311609 videl.hht = hw->hht;
16321610 videl.hbb = hw->hbb;
....@@ -1713,9 +1691,9 @@
17131691 ((blue & 0xfc00) >> 8));
17141692 if (regno < 16) {
17151693 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);
17191697 ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) |
17201698 ((green & 0xfc00) >> 5) |
17211699 ((blue & 0xf800) >> 11));
....@@ -1973,18 +1951,18 @@
19731951 {
19741952 unsigned long addr;
19751953 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);
19791957 if (ATARIHW_PRESENT(EXTD_SHIFTER))
1980
- addr |= (shifter.bas_lo & 0xff);
1958
+ addr |= (shifter_st.bas_lo & 0xff);
19811959 par->screen_base = atari_stram_to_virt(addr);
19821960 }
19831961
19841962 static void stste_set_par(struct atafb_par *par)
19851963 {
19861964 shifter_tt.st_shiftmode = par->hw.st.mode;
1987
- shifter.syncmode = par->hw.st.sync;
1965
+ shifter_st.syncmode = par->hw.st.sync;
19881966 /* only set screen_base if really necessary */
19891967 if (current_par.screen_base != par->screen_base)
19901968 fbhw->set_screen_base(par->screen_base);
....@@ -2001,9 +1979,9 @@
20011979 green >>= 12;
20021980 if (ATARIHW_PRESENT(EXTD_SHIFTER))
20031981 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);
20071985 else
20081986 shifter_tt.color_reg[regno] =
20091987 ((red & 0xe) << 7) |
....@@ -2039,10 +2017,10 @@
20392017 unsigned long addr;
20402018 addr = atari_stram_to_phys(s_base);
20412019 /* 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);
20442022 if (ATARIHW_PRESENT(EXTD_SHIFTER))
2045
- shifter.bas_lo = (unsigned char)(addr & 0x0000ff);
2023
+ shifter_st.bas_lo = (unsigned char)(addr & 0x0000ff);
20462024 }
20472025
20482026 #endif /* ATAFB_STE */
....@@ -2286,9 +2264,9 @@
22862264
22872265 addr = atari_stram_to_phys(s_base);
22882266 /* 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);
22922270 }
22932271
22942272 static int pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
....@@ -3073,28 +3051,22 @@
30733051 return 0;
30743052 }
30753053
3076
-int __init atafb_init(void)
3054
+static int __init atafb_probe(struct platform_device *pdev)
30773055 {
30783056 int pad, detected_mode, error;
30793057 unsigned int defmode = 0;
30803058 unsigned long mem_req;
3081
-
3082
-#ifndef MODULE
30833059 char *option = NULL;
30843060
30853061 if (fb_get_options("atafb", &option))
30863062 return -ENODEV;
30873063 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__);
30933065
30943066 do {
30953067 #ifdef ATAFB_EXT
30963068 if (external_addr) {
3097
- printk("atafb_init: initializing external hw\n");
3069
+ dev_dbg(&pdev->dev, "initializing external hw\n");
30983070 fbhw = &ext_switch;
30993071 atafb_ops.fb_setcolreg = &ext_setcolreg;
31003072 defmode = DEFMODE_EXT;
....@@ -3103,7 +3075,7 @@
31033075 #endif
31043076 #ifdef ATAFB_TT
31053077 if (ATARIHW_PRESENT(TT_SHIFTER)) {
3106
- printk("atafb_init: initializing TT hw\n");
3078
+ dev_dbg(&pdev->dev, "initializing TT hw\n");
31073079 fbhw = &tt_switch;
31083080 atafb_ops.fb_setcolreg = &tt_setcolreg;
31093081 defmode = DEFMODE_TT;
....@@ -3112,7 +3084,7 @@
31123084 #endif
31133085 #ifdef ATAFB_FALCON
31143086 if (ATARIHW_PRESENT(VIDEL_SHIFTER)) {
3115
- printk("atafb_init: initializing Falcon hw\n");
3087
+ dev_dbg(&pdev->dev, "initializing Falcon hw\n");
31163088 fbhw = &falcon_switch;
31173089 atafb_ops.fb_setcolreg = &falcon_setcolreg;
31183090 error = request_irq(IRQ_AUTO_4, falcon_vbl_switcher, 0,
....@@ -3127,7 +3099,7 @@
31273099 #ifdef ATAFB_STE
31283100 if (ATARIHW_PRESENT(STND_SHIFTER) ||
31293101 ATARIHW_PRESENT(EXTD_SHIFTER)) {
3130
- printk("atafb_init: initializing ST/E hw\n");
3102
+ dev_dbg(&pdev->dev, "initializing ST/E hw\n");
31313103 fbhw = &st_switch;
31323104 atafb_ops.fb_setcolreg = &stste_setcolreg;
31333105 defmode = DEFMODE_STE;
....@@ -3135,7 +3107,8 @@
31353107 }
31363108 fbhw = &st_switch;
31373109 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");
31393112 #else /* ATAFB_STE */
31403113 /* no default driver included */
31413114 /* Nobody will ever see this message :-) */
....@@ -3175,8 +3148,8 @@
31753148 kernel_set_cachemode(screen_base, screen_len,
31763149 IOMAP_WRITETHROUGH);
31773150 }
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);
31803153 #ifdef ATAFB_EXT
31813154 } else {
31823155 /* Map the video memory (physical address given) to somewhere
....@@ -3223,12 +3196,12 @@
32233196 fb_alloc_cmap(&(fb_info.cmap), 1 << fb_info.var.bits_per_pixel, 0);
32243197
32253198
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);
32283201 if ((fb_info.var.xres != fb_info.var.xres_virtual) ||
32293202 (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);
32323205
32333206 if (register_framebuffer(&fb_info) < 0) {
32343207 #ifdef ATAFB_EXT
....@@ -3251,14 +3224,32 @@
32513224 return 0;
32523225 }
32533226
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)
32603228 {
3261
- unregister_framebuffer(&fb_info);
3262
- return atafb_deinit();
3229
+ /* Unblank before kexec */
3230
+ if (fbhw->blank)
3231
+ fbhw->blank(0);
32633232 }
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);