Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/prep Add support for the IBM ThinkPad 820 G10 displ...
details: https://anonhg.NetBSD.org/src/rev/384d17a58731
branches: trunk
changeset: 499925:384d17a58731
user: matt <matt%NetBSD.org@localhost>
date: Fri Dec 01 21:54:01 2000 +0000
description:
Add support for the IBM ThinkPad 820 G10 display (which is a WD90C24A behind
a funky PCI-VLBUS bridge).
diffstat:
sys/arch/prep/conf/files.prep | 13 +-
sys/arch/prep/include/gtenvar.h | 21 ++
sys/arch/prep/pci/gten.c | 394 ++++++++++++++++++++++++++++++++++++++++
sys/arch/prep/prep/machdep.c | 13 +-
4 files changed, 436 insertions(+), 5 deletions(-)
diffs (truncated from 499 to 300 lines):
diff -r a732514fe1d7 -r 384d17a58731 sys/arch/prep/conf/files.prep
--- a/sys/arch/prep/conf/files.prep Fri Dec 01 21:51:08 2000 +0000
+++ b/sys/arch/prep/conf/files.prep Fri Dec 01 21:54:01 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.prep,v 1.10 2000/11/27 21:50:13 matt Exp $
+# $NetBSD: files.prep,v 1.11 2000/12/01 21:54:01 matt Exp $
#
# prep-specific configuration info
#
@@ -59,6 +59,10 @@
attach cpu at mainbus
file arch/prep/prep/cpu.c cpu
+include "dev/wscons/files.wscons"
+include "dev/wsfont/files.wsfont"
+include "dev/rasops/files.rasops"
+
#
# PCI-only drivers
# XXX MUST BE INCLUDED BEFORE files.isa, as long as files.isa attaches
@@ -77,6 +81,11 @@
attach pcib at pci
file arch/prep/pci/pcib.c pcib
+# IBM G10 display on ThinkPad 820
+device gten: wsemuldisplaydev, rasops8
+attach gten at pci
+file arch/prep/pci/gten.c gten needs-flag
+
#
# ISA and mixed ISA+PCI drivers
#
@@ -106,8 +115,6 @@
attach pcconskbd at pckbc
file arch/prep/isa/pccons.c pc | pcconskbd needs-flag
-include "dev/wscons/files.wscons"
-
include "dev/pckbc/files.pckbc"
# ISA speaker generates keyboard beep
diff -r a732514fe1d7 -r 384d17a58731 sys/arch/prep/include/gtenvar.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/prep/include/gtenvar.h Fri Dec 01 21:54:01 2000 +0000
@@ -0,0 +1,21 @@
+#ifndef _MACHINE_GTENVAR_H
+#define _MACHINE_GTENVAR_H
+
+struct rasops_info;
+
+struct gten_softc {
+ struct device gt_dev;
+
+ struct rasops_info *gt_ri;
+ paddr_t gt_paddr;
+ bus_size_t gt_memsize;
+ bus_addr_t gt_memaddr;
+ int gt_nscreens;
+ u_char gt_cmap_red[256];
+ u_char gt_cmap_green[256];
+ u_char gt_cmap_blue[256];
+};
+
+int gten_cnattach(bus_space_tag_t);
+
+#endif /* _MACHINE_GTENVAR_H_ */
diff -r a732514fe1d7 -r 384d17a58731 sys/arch/prep/pci/gten.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/prep/pci/gten.c Fri Dec 01 21:54:01 2000 +0000
@@ -0,0 +1,394 @@
+/* $NetBSD: gten.c,v 1.1 2000/12/01 21:54:01 matt Exp $ */
+
+#include <sys/param.h>
+#include <sys/buf.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/systm.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <dev/pci/pcidevs.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/rasops/rasops.h>
+
+#include <machine/bus.h>
+#include <machine/gtenvar.h>
+
+int gten_match (struct device *, struct cfdata *, void *);
+void gten_attach (struct device *, struct device *, void *);
+int gten_print (void *, const char *);
+
+struct cfattach gten_ca = {
+ sizeof(struct gten_softc), gten_match, gten_attach,
+};
+
+static struct rasops_info gten_console_ri;
+static pcitag_t gten_console_pcitag;
+
+static struct wsscreen_descr gten_stdscreen = {
+ "std",
+ 0, 0,
+ 0,
+ 0, 0,
+ WSSCREEN_REVERSE
+};
+
+static const struct wsscreen_descr *_gten_scrlist[] = {
+ >en_stdscreen,
+ /* XXX other formats, graphics screen? */
+};
+
+static struct wsscreen_list gten_screenlist = {
+ sizeof(_gten_scrlist) / sizeof(struct wsscreen_descr *), _gten_scrlist
+};
+
+static int gten_ioctl (void *, u_long, caddr_t, int, struct proc *);
+static paddr_t gten_mmap (void *, off_t, int);
+static int gten_alloc_screen (void *, const struct wsscreen_descr *,
+ void **, int *, int *, long *);
+static void gten_free_screen (void *, void *);
+static int gten_show_screen (void *, void *, int,
+ void (*) (void *, int, int), void *);
+
+struct wsdisplay_accessops gten_accessops = {
+ gten_ioctl,
+ gten_mmap,
+ gten_alloc_screen,
+ gten_free_screen,
+ gten_show_screen,
+ 0 /* load_font */
+};
+
+static void gten_common_init (struct rasops_info *);
+static int gten_getcmap (struct gten_softc *, struct wsdisplay_cmap *);
+static int gten_putcmap (struct gten_softc *, struct wsdisplay_cmap *);
+
+int
+gten_match(struct device *parent, struct cfdata *match, void *aux)
+{
+ struct pci_attach_args *pa = aux;
+
+ if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_WD &&
+ PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_WD_90C)
+ return 2;
+
+ return 0;
+}
+
+void
+gten_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct gten_softc *gt = (struct gten_softc *)self;
+ struct pci_attach_args *pa = aux;
+ struct wsemuldisplaydev_attach_args a;
+ int console = (pa->pa_tag == gten_console_pcitag);
+ int error;
+ char devinfo[256], pbuf[10];
+
+ error = pci_mapreg_info(pa->pa_pc, pa->pa_tag, 0x14,
+ PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT,
+ >->gt_memaddr, >->gt_memsize, NULL);
+ if (error) {
+ printf(": can't determine memory size: error=%d\n",
+ error);
+ return;
+ }
+ if (console) {
+ gt->gt_ri = >en_console_ri;
+ gt->gt_nscreens = 1;
+ } else {
+ MALLOC(gt->gt_ri, struct rasops_info *, sizeof(*gt->gt_ri),
+ M_DEVBUF, M_NOWAIT);
+ if (gt->gt_ri == NULL) {
+ printf(": can't alloc memory\n");
+ return;
+ }
+ memset(gt->gt_ri, 0, sizeof(*gt->gt_ri));
+#if 0
+ error = pci_mapreg_map(pa, 0x14,
+ PCI_MAPREG_TYPE_MEM|PCI_MAPREG_MEM_TYPE_32BIT,
+ BUS_SPACE_MAP_LINEAR, NULL,
+ (bus_space_handle_t *) >->gt_ri->ri_bits,
+ NULL, NULL);
+#else
+ error = bus_space_map(pa->pa_memt, gt->gt_memaddr + 0xef9000,
+ 1024*1024, BUS_SPACE_MAP_LINEAR,
+ (bus_space_handle_t *) >->gt_ri->ri_bits);
+#endif
+ if (error) {
+ printf(": can't map frame buffer: error=%d\n", error);
+ return;
+ }
+
+ gten_common_init(gt->gt_ri);
+
+#if 0
+ int i, len, screenbytes;
+ screenbytes = ri->ri_stride * ri->ri_height;
+ for (i = 0; i < screenbytes; i += sizeof(u_int32_t))
+ *(u_int32_t *)(gt->gt_ri->ri_bits + i) = 0xffffffff;
+#endif
+ }
+
+ gt->gt_paddr = vtophys((vaddr_t)gt->gt_ri->ri_bits);
+ if (gt->gt_paddr == 0) {
+ printf(": cannot map framebuffer\n");
+ return;
+ }
+
+ pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
+ printf(": %s\n", devinfo);
+ format_bytes(pbuf, sizeof(pbuf), gt->gt_memsize);
+ printf("%s: %s, %d x %d, %dbpp\n", self->dv_xname, pbuf,
+ gt->gt_ri->ri_width, gt->gt_ri->ri_height, gt->gt_ri->ri_depth);
+
+ gt->gt_cmap_red[0] = gt->gt_cmap_green[0] = gt->gt_cmap_blue[0] = 0;
+ gt->gt_cmap_red[15] = gt->gt_cmap_red[255] = 0xff;
+ gt->gt_cmap_green[15] = gt->gt_cmap_green[255] = 0xff;
+ gt->gt_cmap_blue[15] = gt->gt_cmap_blue[255] = 0xff;
+
+ a.console = console;
+ a.scrdata = >en_screenlist;
+ a.accessops = >en_accessops;
+ a.accesscookie = gt;
+
+ config_found(self, &a, wsemuldisplaydevprint);
+}
+
+static void
+gten_common_init(struct rasops_info *ri)
+{
+ int32_t addr, width, height, linebytes, depth;
+ int i, screenbytes;
+
+ /* initialize rasops */
+ ri->ri_width = 640;
+ ri->ri_height = 480;
+ ri->ri_depth = 8;
+ ri->ri_stride = 640;
+ ri->ri_flg = RI_FORCEMONO | RI_FULLCLEAR | RI_CENTER;
+
+ rasops_init(ri, 24, 80);
+ /* black on white */
+ ri->ri_devcmap[0] = 0xffffffff; /* bg */
+ ri->ri_devcmap[1] = 0; /* fg */
+
+ gten_stdscreen.nrows = ri->ri_rows;
+ gten_stdscreen.ncols = ri->ri_cols;
+ gten_stdscreen.textops = &ri->ri_ops;
+ gten_stdscreen.capabilities = ri->ri_caps;
+
+ screenbytes = ri->ri_stride * ri->ri_height;
+ for (i = 0; i < screenbytes; i += sizeof(u_int32_t))
+ *(u_int32_t *)(ri->ri_bits + i) = 0xffffffff;
+}
+
+int
+gten_ioctl(v, cmd, data, flag, p)
+ void *v;
+ u_long cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+ struct gten_softc *gt = v;
+ struct wsdisplay_fbinfo *wdf;
+ struct grfinfo *gm;
+
+ switch (cmd) {
+ case WSDISPLAYIO_GTYPE:
+ *(u_int *)data = WSDISPLAY_TYPE_PCIMISC; /* XXX ? */
+ return 0;
+
+ case WSDISPLAYIO_GINFO:
+ wdf = (void *)data;
+ wdf->height = gt->gt_ri->ri_height;
+ wdf->width = gt->gt_ri->ri_width;
+ wdf->depth = gt->gt_ri->ri_depth;
+ wdf->cmsize = 256;
+ return 0;
+
+ case WSDISPLAYIO_GETCMAP:
+ return gten_getcmap(gt, (struct wsdisplay_cmap *)data);
+
+ case WSDISPLAYIO_PUTCMAP:
+ return gten_putcmap(gt, (struct wsdisplay_cmap *)data);
+ }
+ return -1;
+}
+
+paddr_t
+gten_mmap(v, offset, prot)
+ void *v;
Home |
Main Index |
Thread Index |
Old Index