^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * linux/drivers/video/pmag-aa-fb.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright 2002 Karsten Merker <merker@debian.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * PMAG-AA TurboChannel framebuffer card support ... derived from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * pmag-ba-fb.c, which is Copyright (C) 1999, 2000, 2001 by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Michael Engel <engel@unix-ag.org>, Karsten Merker <merker@debian.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * and Harald Koerfgen <hkoerfg@web.de>, which itself is derived from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * "HP300 Topcat framebuffer support (derived from macfb of all things)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Phil Blundell <philb@gnu.org> 1998"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Copyright (c) 2016 Maciej W. Rozycki
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This file is subject to the terms and conditions of the GNU General
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Public License. See the file COPYING in the main directory of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * archive for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * 2002-09-28 Karsten Merker <merker@linuxtag.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * Version 0.01: First try to get a PMAG-AA running.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * 2003-02-24 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Version 0.02: Major code cleanup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * 2003-09-21 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * Hardware cursor support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * 2016-02-21 Maciej W. Rozycki <macro@linux-mips.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * Version 0.03: Rewritten for the new FB and TC APIs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/fb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include <linux/tc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include "bt455.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include "bt431.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /* Version information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define DRIVER_VERSION "0.03"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define DRIVER_AUTHOR "Karsten Merker <merker@linuxtag.org>"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define DRIVER_DESCRIPTION "PMAG-AA Framebuffer Driver"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * Bt455 RAM DAC register base offset (rel. to TC slot base address).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define PMAG_AA_BT455_OFFSET 0x100000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * Bt431 cursor generator offset (rel. to TC slot base address).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define PMAG_AA_BT431_OFFSET 0x180000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * Begin of PMAG-AA framebuffer memory relative to TC slot address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * resolution is 1280x1024x1 (8 bits deep, but only LSB is used).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define PMAG_AA_ONBOARD_FBMEM_OFFSET 0x200000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct aafb_par {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) void __iomem *mmio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct bt455_regs __iomem *bt455;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct bt431_regs __iomem *bt431;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static const struct fb_var_screeninfo aafb_defined = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) .xres = 1280,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) .yres = 1024,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) .xres_virtual = 2048,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .yres_virtual = 1024,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) .bits_per_pixel = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) .grayscale = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) .red.length = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) .green.length = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) .blue.length = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) .activate = FB_ACTIVATE_NOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) .accel_flags = FB_ACCEL_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) .pixclock = 7645,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) .left_margin = 224,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .right_margin = 32,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) .upper_margin = 33,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) .lower_margin = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) .hsync_len = 160,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .vsync_len = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .sync = FB_SYNC_ON_GREEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .vmode = FB_VMODE_NONINTERLACED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static const struct fb_fix_screeninfo aafb_fix = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .id = "PMAG-AA",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) .smem_len = (2048 * 1024),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .type = FB_TYPE_PACKED_PIXELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .visual = FB_VISUAL_MONO10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) .ypanstep = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) .ywrapstep = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .line_length = 2048,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .mmio_len = PMAG_AA_ONBOARD_FBMEM_OFFSET - PMAG_AA_BT455_OFFSET,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static int aafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct aafb_par *par = info->par;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) if (cursor->image.height > BT431_CURSOR_SIZE ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) cursor->image.width > BT431_CURSOR_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) bt431_erase_cursor(par->bt431);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if (!cursor->enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) bt431_erase_cursor(par->bt431);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (cursor->set & FB_CUR_SETPOS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) bt431_position_cursor(par->bt431,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) cursor->image.dx, cursor->image.dy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (cursor->set & FB_CUR_SETCMAP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) u8 fg = cursor->image.fg_color ? 0xf : 0x0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u8 bg = cursor->image.bg_color ? 0xf : 0x0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) bt455_write_cmap_entry(par->bt455, 8, bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) bt455_write_cmap_next(par->bt455, bg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) bt455_write_ovly_next(par->bt455, fg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (cursor->set & (FB_CUR_SETSIZE | FB_CUR_SETSHAPE | FB_CUR_SETIMAGE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) bt431_set_cursor(par->bt431,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) cursor->image.data, cursor->mask, cursor->rop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) cursor->image.width, cursor->image.height);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (cursor->enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) bt431_enable_cursor(par->bt431);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* 0 unblanks, any other blanks. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static int aafb_blank(int blank, struct fb_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct aafb_par *par = info->par;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) u8 val = blank ? 0x00 : 0x0f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) bt455_write_cmap_entry(par->bt455, 1, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static const struct fb_ops aafb_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) .fb_blank = aafb_blank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) .fb_fillrect = cfb_fillrect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) .fb_copyarea = cfb_copyarea,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) .fb_imageblit = cfb_imageblit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) .fb_cursor = aafb_cursor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) static int pmagaafb_probe(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct tc_dev *tdev = to_tc_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) resource_size_t start, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct fb_info *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct aafb_par *par;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) info = framebuffer_alloc(sizeof(struct aafb_par), dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (!info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) par = info->par;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) dev_set_drvdata(dev, info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) info->fbops = &aafb_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) info->fix = aafb_fix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) info->var = aafb_defined;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) info->flags = FBINFO_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* Request the I/O MEM resource. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) start = tdev->resource.start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) len = tdev->resource.end - start + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (!request_mem_region(start, len, dev_name(dev))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) printk(KERN_ERR "%s: Cannot reserve FB region\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) dev_name(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) err = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) goto err_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /* MMIO mapping setup. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) info->fix.mmio_start = start + PMAG_AA_BT455_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) par->mmio = ioremap(info->fix.mmio_start, info->fix.mmio_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (!par->mmio) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) printk(KERN_ERR "%s: Cannot map MMIO\n", dev_name(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) goto err_resource;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) par->bt455 = par->mmio - PMAG_AA_BT455_OFFSET + PMAG_AA_BT455_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) par->bt431 = par->mmio - PMAG_AA_BT455_OFFSET + PMAG_AA_BT431_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /* Frame buffer mapping setup. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) info->fix.smem_start = start + PMAG_AA_ONBOARD_FBMEM_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) info->screen_base = ioremap(info->fix.smem_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) info->fix.smem_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (!info->screen_base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) printk(KERN_ERR "%s: Cannot map FB\n", dev_name(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) goto err_mmio_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) info->screen_size = info->fix.smem_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* Init colormap. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) bt455_write_cmap_entry(par->bt455, 0, 0x0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) bt455_write_cmap_next(par->bt455, 0xf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /* Init hardware cursor. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) bt431_erase_cursor(par->bt431);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) bt431_init_cursor(par->bt431);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) err = register_framebuffer(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) printk(KERN_ERR "%s: Cannot register framebuffer\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) dev_name(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) goto err_smem_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) get_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) pr_info("fb%d: %s frame buffer device at %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) info->node, info->fix.id, dev_name(dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) err_smem_map:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) iounmap(info->screen_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) err_mmio_map:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) iounmap(par->mmio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) err_resource:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) release_mem_region(start, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) err_alloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) framebuffer_release(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) static int pmagaafb_remove(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct tc_dev *tdev = to_tc_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) struct fb_info *info = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) struct aafb_par *par = info->par;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) resource_size_t start, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) put_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) unregister_framebuffer(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) iounmap(info->screen_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) iounmap(par->mmio);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) start = tdev->resource.start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) len = tdev->resource.end - start + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) release_mem_region(start, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) framebuffer_release(info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * Initialise the framebuffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static const struct tc_device_id pmagaafb_tc_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) { "DEC ", "PMAG-AA " },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) MODULE_DEVICE_TABLE(tc, pmagaafb_tc_table);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) static struct tc_driver pmagaafb_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) .id_table = pmagaafb_tc_table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) .name = "pmagaafb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) .bus = &tc_bus_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) .probe = pmagaafb_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) .remove = pmagaafb_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) static int __init pmagaafb_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) #ifndef MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) if (fb_get_options("pmagaafb", NULL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) return tc_register_driver(&pmagaafb_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) static void __exit pmagaafb_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) tc_unregister_driver(&pmagaafb_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) module_init(pmagaafb_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) module_exit(pmagaafb_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) MODULE_AUTHOR(DRIVER_AUTHOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) MODULE_LICENSE("GPL");