diff --git a/sys/arch/hpcmips/conf/GENERIC b/sys/arch/hpcmips/conf/GENERIC index 8fc3279b4a6e..8235ffd306cd 100644 --- a/sys/arch/hpcmips/conf/GENERIC +++ b/sys/arch/hpcmips/conf/GENERIC @@ -2,11 +2,11 @@ # Distribution kernel (NEC VR based model) kernel config file # -# $NetBSD: GENERIC,v 1.58 2000/07/20 21:03:36 jeffs Exp $ +# $NetBSD: GENERIC,v 1.59 2000/07/22 08:53:33 takemura Exp $ # include "arch/hpcmips/conf/std.hpcmips" -#ident "GENERIC-$Revision: 1.58 $" +#ident "GENERIC-$Revision: 1.59 $" maxusers 8 @@ -115,6 +115,9 @@ vrpmu* at vrip? addr 0x0b0000a0 size 0x20 intr 1 # power switch vrdsu* at vrip? addr 0x0b0000e0 size 0x08 vrpiu* at vrip? addr 0x0b000120 size 0x1a0 intr 5 +#mqvideo0 at vrip? addr 0x0a000000 size 0x800000 # MQ200 video controller +#hpcfb* at mqvideo? + # Workstation Console attachments bivideo0 at mainbus0 hpcfb* at bivideo0 diff --git a/sys/arch/hpcmips/conf/files.hpcmips b/sys/arch/hpcmips/conf/files.hpcmips index 81afe0870add..6dd74eb2d876 100644 --- a/sys/arch/hpcmips/conf/files.hpcmips +++ b/sys/arch/hpcmips/conf/files.hpcmips @@ -1,4 +1,4 @@ -# $NetBSD: files.hpcmips,v 1.34 2000/07/02 10:01:30 takemura Exp $ +# $NetBSD: files.hpcmips,v 1.35 2000/07/22 08:53:34 takemura Exp $ # maxpartitions must be first item in files.${ARCH}. maxpartitions 8 @@ -174,6 +174,11 @@ file arch/hpcmips/vr/vrpiu.c vrpiu attach ohci at vrip with ohci_vrip file arch/hpcmips/dev/ohci_vrip.c ohci_vrip +device mqvideo: hpcfbif +attach mqvideo at vrip with mqvideo_vrip +file arch/hpcmips/vr/mq200_vrip.c mqvideo_vrip +file arch/hpcmips/dev/mq200.c mqvideo + # # TOSHIBA TX3912/3922 # diff --git a/sys/arch/hpcmips/dev/bivideo.c b/sys/arch/hpcmips/dev/bivideo.c index f99b7f799581..145c40ac6ce2 100644 --- a/sys/arch/hpcmips/dev/bivideo.c +++ b/sys/arch/hpcmips/dev/bivideo.c @@ -1,4 +1,4 @@ -/* $NetBSD: bivideo.c,v 1.9 2000/07/02 10:01:31 takemura Exp $ */ +/* $NetBSD: bivideo.c,v 1.10 2000/07/22 08:53:35 takemura Exp $ */ /*- * Copyright (c) 1999 @@ -37,7 +37,7 @@ static const char _copyright[] __attribute__ ((unused)) = "Copyright (c) 1999 Shin Takemura. All rights reserved."; static const char _rcsid[] __attribute__ ((unused)) = - "$Id: bivideo.c,v 1.9 2000/07/02 10:01:31 takemura Exp $"; + "$Id: bivideo.c,v 1.10 2000/07/22 08:53:35 takemura Exp $"; #include #include @@ -67,6 +67,11 @@ static const char _rcsid[] __attribute__ ((unused)) = #include #include +/* + * global variables + */ +int bivideo_dont_attach = 0; + /* * function prototypes */ @@ -109,7 +114,8 @@ bivideomatch(parent, match, aux) { struct mainbus_attach_args *ma = aux; - if (strcmp(ma->ma_name, match->cf_driver->cd_name)) + if (bivideo_dont_attach || + strcmp(ma->ma_name, match->cf_driver->cd_name)) return 0; return (1); diff --git a/sys/arch/hpcmips/dev/bivideovar.h b/sys/arch/hpcmips/dev/bivideovar.h index 93e01465f016..d431dea6e499 100644 --- a/sys/arch/hpcmips/dev/bivideovar.h +++ b/sys/arch/hpcmips/dev/bivideovar.h @@ -1 +1,31 @@ +/* $NetBSD: bivideovar.h,v 1.2 2000/07/22 08:53:35 takemura Exp $ */ + +/* + * Copyright (c) 2000 Takemura Shin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +extern int bivideo_dont_attach; int bivideo_getcnfb __P((struct hpcfb_fbconf* fb)); diff --git a/sys/arch/hpcmips/dev/hpcapm.c b/sys/arch/hpcmips/dev/hpcapm.c index 2653057d1d76..db21cf82b6b7 100644 --- a/sys/arch/hpcmips/dev/hpcapm.c +++ b/sys/arch/hpcmips/dev/hpcapm.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpcapm.c,v 1.1 2000/07/02 10:01:31 takemura Exp $ */ +/* $NetBSD: hpcapm.c,v 1.2 2000/07/22 08:53:35 takemura Exp $ */ /* * Copyright (c) 2000 Takemura Shin @@ -79,8 +79,8 @@ struct cfattach hpcapm_ca = { struct apmhpc_softc { struct device sc_dev; void *sc_apmdev; - unsigned int events; - int power_state; + volatile unsigned int events; + volatile int power_state; config_hook_tag sc_standby_hook; config_hook_tag sc_suspend_hook; }; @@ -157,22 +157,18 @@ hpcapm_hook(ctx, type, id, msg) s = splhigh(); switch (id) { case CONFIG_HOOK_PMEVENT_STANDBYREQ: - if (sc->power_state == APM_SYS_STANDBY) { - sc->power_state = APM_SYS_READY; - sc->events |= (1 << APM_NORMAL_RESUME); - } else { - DPRINTF(("hpcapm: standby req\n")); + if (sc->power_state != APM_SYS_STANDBY) { sc->events |= (1 << APM_USER_STANDBY_REQ); + } else { + sc->events |= (1 << APM_NORMAL_RESUME); } break; case CONFIG_HOOK_PMEVENT_SUSPENDREQ: - if (sc->power_state == APM_SYS_SUSPEND) { - sc->power_state = APM_SYS_READY; - DPRINTF(("hpcapm: resume\n")); - sc->events |= (1 << APM_NORMAL_RESUME); - } else { + if (sc->power_state != APM_SYS_SUSPEND) { DPRINTF(("hpcapm: suspend req\n")); sc->events |= (1 << APM_USER_SUSPEND_REQ); + } else { + sc->events |= (1 << APM_NORMAL_RESUME); } break; } @@ -225,6 +221,9 @@ hpcapm_set_powstate(scx, devid, powstat) case APM_SYS_SUSPEND: DPRINTF(("hpcapm: set power state SUSPEND...\n")); s = splhigh(); + config_hook_call(CONFIG_HOOK_PMEVENT, + CONFIG_HOOK_PMEVENT_HARDPOWER, + (void *)PWR_SUSPEND); sc->power_state = APM_SYS_SUSPEND; #if NVRIP > 0 if (platid_match(&platid, &platid_mask_CPU_MIPS_VR_41XX)) { @@ -252,6 +251,10 @@ hpcapm_set_powstate(scx, devid, powstat) vrip_intr_resume(); } #endif + config_hook_call(CONFIG_HOOK_PMEVENT, + CONFIG_HOOK_PMEVENT_HARDPOWER, + (void *)PWR_RESUME); + DPRINTF(("hpcapm: resume\n")); splx(s); break; case APM_SYS_OFF: @@ -303,6 +306,7 @@ hpcapm_get_event(scx, event_type, event_info) *event_type == APM_CRIT_RESUME) { /* pccard power off in the suspend state */ *event_info = 1; + sc->power_state = APM_SYS_READY; } else *event_info = 0; return (0); diff --git a/sys/arch/hpcmips/dev/mq200.c b/sys/arch/hpcmips/dev/mq200.c new file mode 100644 index 000000000000..e4f43d97c5dd --- /dev/null +++ b/sys/arch/hpcmips/dev/mq200.c @@ -0,0 +1,437 @@ +/* $NetBSD: mq200.c,v 1.1 2000/07/22 08:53:36 takemura Exp $ */ + +/*- + * Copyright (c) 2000 Takemura Shin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define MQ200DEBUG +#ifdef MQ200DEBUG +#ifndef MQ200DEBUG_CONF +#define MQ200DEBUG_CONF 1 +#endif +int mq200_debug = MQ200DEBUG_CONF; +#define DPRINTF(arg) do { if (mq200_debug) printf arg; } while(0); +#define DPRINTFN(n, arg) do { if (mq200_debug > (n)) printf arg; } while (0); +#else +#define DPRINTF(arg) do { } while (0); +#define DPRINTFN(n, arg) do { } while (0); +#endif + +/* + * function prototypes + */ +static void mq200_power __P((int, void *)); +static int mq200_hardpower __P((void *, int, long, void *)); +static int mq200_fbinit __P((struct hpcfb_fbconf *)); +static int mq200_ioctl __P((void *, u_long, caddr_t, int, struct proc *)); +static paddr_t mq200_mmap __P((void *, off_t offset, int)); + +/* + * static variables + */ +struct hpcfb_accessops mq200_ha = { + mq200_ioctl, mq200_mmap +}; + +int +mq200_probe(iot, ioh) + bus_space_tag_t iot; + bus_space_handle_t ioh; +{ + unsigned long regval; + + regval = bus_space_read_4(iot, ioh, MQ200_PC00R); + DPRINTF(("mq200 probe: vendor id=%04lx product id=%04lx\n", + regval & 0xffff, (regval >> 16) & 0xffff)); + if (regval != ((MQ200_PRODUCT_ID << 16) | MQ200_VENDOR_ID)) + return (0); + + return (1); +} + +void +mq200_attach(sc) + struct mq200_softc *sc; +{ + unsigned long regval; + struct hpcfb_attach_args ha; + int console = (bootinfo->bi_cnuse & BI_CNUSE_SERIAL) ? 0 : 1; + + regval = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MQ200_PC08R); + printf(": MQ200 Rev.%02lx video controller\n", regval & 0xff); + + /* Add a power hook to power saving */ + sc->sc_powerstate = MQ200_POWERSTATE_D0; + sc->sc_powerhook = powerhook_establish(mq200_power, sc); + if (sc->sc_powerhook == NULL) + printf("%s: WARNING: unable to establish power hook\n", + sc->sc_dev.dv_xname); + + /* Add a hard power hook to power saving */ + sc->sc_hardpowerhook = config_hook(CONFIG_HOOK_PMEVENT, + CONFIG_HOOK_PMEVENT_HARDPOWER, + CONFIG_HOOK_SHARE, + mq200_hardpower, sc); + if (sc->sc_hardpowerhook == NULL) + printf("%s: WARNING: unable to establish hard power hook\n", + sc->sc_dev.dv_xname); + + mq200_fbinit(&sc->sc_fbconf); + + if (console && hpcfb_cnattach(&sc->sc_fbconf) != 0) { + panic("mq200_attach: can't init fb console"); + } + + ha.ha_console = console; + ha.ha_accessops = &mq200_ha; + ha.ha_accessctx = sc; + ha.ha_curfbconf = 0; + ha.ha_nfbconf = 1; + ha.ha_fbconflist = &sc->sc_fbconf; + ha.ha_curdspconf = 0; + ha.ha_ndspconf = 1; + ha.ha_dspconflist = &sc->sc_dspconf; + + config_found(&sc->sc_dev, &ha, hpcfbprint); + + /* + * bivideo is no longer need + */ + bivideo_dont_attach = 1; +} + +static void +mq200_power(why, arg) + int why; + void *arg; +{ +#if 0 + struct mq200_softc *sc = arg; + + switch (why) { + case PWR_SUSPEND: + sc->sc_powerstate = MQ200_POWERSTATE_D2; + break; + case PWR_STANDBY: + sc->sc_powerstate = MQ200_POWERSTATE_D3; + break; + case PWR_RESUME: + sc->sc_powerstate = MQ200_POWERSTATE_D0; + break; + } + + printf("MQ200_PMCSR=%08x\n", sc->sc_powerstate); + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + MQ200_PMCSR, sc->sc_powerstate); +#endif +} + +static int +mq200_hardpower(ctx, type, id, msg) + void *ctx; + int type; + long id; + void *msg; +{ + struct mq200_softc *sc = ctx; + int why = (int)msg; + + switch (why) { + case PWR_SUSPEND: + sc->sc_powerstate = MQ200_POWERSTATE_D2; + break; + case PWR_STANDBY: + sc->sc_powerstate = MQ200_POWERSTATE_D3; + break; + case PWR_RESUME: + sc->sc_powerstate = MQ200_POWERSTATE_D0; + break; + } + + bus_space_write_4(sc->sc_iot, sc->sc_ioh, + MQ200_PMCSR, sc->sc_powerstate); + + /* + * you should wait until the + * power state transit sequence will end. + */ + { + unsigned long tmp; + do { + tmp = bus_space_read_4(sc->sc_iot, sc->sc_ioh, + MQ200_PMCSR); + } while ((tmp & 0x3) != (sc->sc_powerstate & 0x3)); + delay(100000); /* XXX */ + } + + return (0); +} + + +static int +mq200_fbinit(fb) + struct hpcfb_fbconf *fb; +{ + + /* + * get fb settings from bootinfo + */ + if (bootinfo == NULL || + bootinfo->fb_addr == 0 || + bootinfo->fb_line_bytes == 0 || + bootinfo->fb_width == 0 || + bootinfo->fb_height == 0) { + printf("no frame buffer infomation.\n"); + return (-1); + } + + /* zero fill */ + bzero(fb, sizeof(*fb)); + + fb->hf_conf_index = 0; /* configuration index */ + fb->hf_nconfs = 1; /* how many configurations */ + strcpy(fb->hf_name, "built-in video"); + /* frame buffer name */ + strcpy(fb->hf_conf_name, "default"); + /* configuration name */ + fb->hf_height = bootinfo->fb_height; + fb->hf_width = bootinfo->fb_width; + fb->hf_baseaddr = mips_ptob(mips_btop(bootinfo->fb_addr)); + fb->hf_offset = (u_long)bootinfo->fb_addr - fb->hf_baseaddr; + /* frame buffer start offset */ + fb->hf_bytes_per_line = bootinfo->fb_line_bytes; + fb->hf_nplanes = 1; + fb->hf_bytes_per_plane = bootinfo->fb_height * + bootinfo->fb_line_bytes; + + fb->hf_access_flags |= HPCFB_ACCESS_BYTE; + fb->hf_access_flags |= HPCFB_ACCESS_WORD; + fb->hf_access_flags |= HPCFB_ACCESS_DWORD; + + switch (bootinfo->fb_type) { + /* + * gray scale + */ + case BIFB_D2_M2L_3: + case BIFB_D2_M2L_3x2: + fb->hf_access_flags |= HPCFB_ACCESS_REVERSE; + /* fall through */ + case BIFB_D2_M2L_0: + case BIFB_D2_M2L_0x2: + fb->hf_class = HPCFB_CLASS_GRAYSCALE; + fb->hf_access_flags |= HPCFB_ACCESS_STATIC; + fb->hf_pack_width = 8; + fb->hf_pixels_per_pack = 4; + fb->hf_pixel_width = 2; + fb->hf_class_data_length = sizeof(struct hf_gray_tag); + fb->hf_u.hf_gray.hf_flags = 0; /* reserved for future use */ + break; + + /* + * indexed color + */ + case BIFB_D8_FF: + fb->hf_access_flags |= HPCFB_ACCESS_REVERSE; + /* fall through */ + case BIFB_D8_00: + fb->hf_class = HPCFB_CLASS_INDEXCOLOR; + fb->hf_access_flags |= HPCFB_ACCESS_STATIC; + fb->hf_pack_width = 8; + fb->hf_pixels_per_pack = 1; + fb->hf_pixel_width = 8; + fb->hf_class_data_length = sizeof(struct hf_indexed_tag); + fb->hf_u.hf_indexed.hf_flags = 0; /* reserved for future use */ + break; + + /* + * RGB color + */ + case BIFB_D16_FFFF: + fb->hf_access_flags |= HPCFB_ACCESS_REVERSE; + /* fall through */ + case BIFB_D16_0000: + fb->hf_class = HPCFB_CLASS_RGBCOLOR; + fb->hf_access_flags |= HPCFB_ACCESS_STATIC; +#if BYTE_ORDER == LITTLE_ENDIAN + fb->hf_swap_flags = HPCFB_SWAP_BYTE; +#endif + fb->hf_pack_width = 16; + fb->hf_pixels_per_pack = 1; + fb->hf_pixel_width = 16; + + fb->hf_class_data_length = sizeof(struct hf_rgb_tag); + fb->hf_u.hf_rgb.hf_flags = 0; /* reserved for future use */ + + fb->hf_u.hf_rgb.hf_red_width = 5; + fb->hf_u.hf_rgb.hf_red_shift = 11; + fb->hf_u.hf_rgb.hf_green_width = 6; + fb->hf_u.hf_rgb.hf_green_shift = 5; + fb->hf_u.hf_rgb.hf_blue_width = 5; + fb->hf_u.hf_rgb.hf_blue_shift = 0; + fb->hf_u.hf_rgb.hf_alpha_width = 0; + fb->hf_u.hf_rgb.hf_alpha_shift = 0; + break; + + default: + printf("unknown type (=%d).\n", bootinfo->fb_type); + return (-1); + break; + } + + return (0); /* no error */ +} + +int +mq200_ioctl(v, cmd, data, flag, p) + void *v; + u_long cmd; + caddr_t data; + int flag; + struct proc *p; +{ + struct mq200_softc *sc = (struct mq200_softc *)v; + struct hpcfb_fbconf *fbconf; + struct hpcfb_dspconf *dspconf; + struct wsdisplay_cmap *cmap; + + switch (cmd) { + case WSDISPLAYIO_GETCMAP: + cmap = (struct wsdisplay_cmap*)data; + + if (sc->sc_fbconf.hf_class != HPCFB_CLASS_INDEXCOLOR || + sc->sc_fbconf.hf_pack_width != 8 || + 256 <= cmap->index || + 256 < (cmap->index + cmap->count)) + return (EINVAL); + +#if 0 + if (!uvm_useracc(cmap->red, cmap->count, B_WRITE) || + !uvm_useracc(cmap->green, cmap->count, B_WRITE) || + !uvm_useracc(cmap->blue, cmap->count, B_WRITE)) + return (EFAULT); + + copyout(&bivideo_cmap_r[cmap->index], cmap->red, cmap->count); + copyout(&bivideo_cmap_g[cmap->index], cmap->green,cmap->count); + copyout(&bivideo_cmap_b[cmap->index], cmap->blue, cmap->count); +#endif + + return (0); + + case WSDISPLAYIO_PUTCMAP: + /* + * This driver can't set color map. + */ + return (EINVAL); + + case HPCFBIO_GCONF: + fbconf = (struct hpcfb_fbconf *)data; + if (fbconf->hf_conf_index != 0 && + fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) { + return (EINVAL); + } + *fbconf = sc->sc_fbconf; /* structure assignment */ + return (0); + case HPCFBIO_SCONF: + fbconf = (struct hpcfb_fbconf *)data; + if (fbconf->hf_conf_index != 0 && + fbconf->hf_conf_index != HPCFB_CURRENT_CONFIG) { + return (EINVAL); + } + /* + * nothing to do because we have only one configration + */ + return (0); + case HPCFBIO_GDSPCONF: + dspconf = (struct hpcfb_dspconf *)data; + if ((dspconf->hd_unit_index != 0 && + dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) || + (dspconf->hd_conf_index != 0 && + dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) { + return (EINVAL); + } + *dspconf = sc->sc_dspconf; /* structure assignment */ + return (0); + case HPCFBIO_SDSPCONF: + dspconf = (struct hpcfb_dspconf *)data; + if ((dspconf->hd_unit_index != 0 && + dspconf->hd_unit_index != HPCFB_CURRENT_UNIT) || + (dspconf->hd_conf_index != 0 && + dspconf->hd_conf_index != HPCFB_CURRENT_CONFIG)) { + return (EINVAL); + } + /* + * nothing to do + * because we have only one unit and one configration + */ + return (0); + case HPCFBIO_GOP: + case HPCFBIO_SOP: + /* + * curently not implemented... + */ + return (EINVAL); + } + + return (ENOTTY); +} + +paddr_t +mq200_mmap(ctx, offset, prot) + void *ctx; + off_t offset; + int prot; +{ + struct mq200_softc *sc = (struct mq200_softc *)ctx; + + if (offset < 0 || + (sc->sc_fbconf.hf_bytes_per_plane + + sc->sc_fbconf.hf_offset) < offset) + return -1; + + return mips_btop(sc->sc_fbconf.hf_baseaddr + offset); +} diff --git a/sys/arch/hpcmips/dev/mq200reg.h b/sys/arch/hpcmips/dev/mq200reg.h new file mode 100644 index 000000000000..cde8dc5226f2 --- /dev/null +++ b/sys/arch/hpcmips/dev/mq200reg.h @@ -0,0 +1,57 @@ +/* $NetBSD: mq200reg.h,v 1.1 2000/07/22 08:53:36 takemura Exp $ */ + +/*- + * Copyright (c) 2000 Takemura Shin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#define MQ200_VENDOR_ID 0x4d51 +#define MQ200_PRODUCT_ID 0x0200 + +#define MQ200_POWERSTATE_D0 0 +#define MQ200_POWERSTATE_D1 1 +#define MQ200_POWERSTATE_D2 2 +#define MQ200_POWERSTATE_D3 3 + +#define MQ200_FRAMEBUFFER 0x000000 /* frame buffer base address */ +#define MQ200_PM 0x600000 /* power management */ +#define MQ200_CC 0x602000 /* CPU interface */ +#define MQ200_MM 0x604000 /* memory interface unit */ +#define MQ200_IN 0x608000 /* interrupt controller */ +#define MQ200_GC 0x60a000 /* graphice controller */ +#define MQ200_GE 0x60c000 /* graphics engine */ +#define MQ200_FP 0x60e000 /* graphics engine */ +#define MQ200_DC 0x614000 /* device configration */ +#define MQ200_PC 0x616000 /* PCI configration */ + +/* PCI configuration space */ +#define MQ200_PC00R (MQ200_PC+0x00) /* device/vendor ID */ +#define MQ200_PC04R (MQ200_PC+0x04) /* command/status */ +#define MQ200_PC08R (MQ200_PC+0x04) /* calss code/revision */ + +#define MQ200_PMR (MQ200_PC+0x40) /* power management */ +#define MQ200_PMCSR (MQ200_PC+0x44) /* control/status */ diff --git a/sys/arch/hpcmips/dev/mq200var.h b/sys/arch/hpcmips/dev/mq200var.h new file mode 100644 index 000000000000..18c2e4d52c18 --- /dev/null +++ b/sys/arch/hpcmips/dev/mq200var.h @@ -0,0 +1,54 @@ +/* $NetBSD: mq200var.h,v 1.1 2000/07/22 08:53:37 takemura Exp $ */ + +/*- + * Copyright (c) 2000 Takemura Shin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +#include + +#include +#include + +#include +#include + +struct mq200_softc { + struct device sc_dev; + bus_addr_t sc_baseaddr; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + void *sc_powerhook; /* power management hook */ + config_hook_tag sc_hardpowerhook; + int sc_powerstate; + struct hpcfb_fbconf sc_fbconf; + struct hpcfb_dspconf sc_dspconf; +}; + +int mq200_probe __P((bus_space_tag_t, bus_space_handle_t)); +void mq200_attach __P((struct mq200_softc *)); diff --git a/sys/arch/hpcmips/hpcmips/mainbus.c b/sys/arch/hpcmips/hpcmips/mainbus.c index 162a870e8462..e6d418a4650d 100644 --- a/sys/arch/hpcmips/hpcmips/mainbus.c +++ b/sys/arch/hpcmips/hpcmips/mainbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: mainbus.c,v 1.6 2000/07/02 10:01:31 takemura Exp $ */ +/* $NetBSD: mainbus.c,v 1.7 2000/07/22 08:53:37 takemura Exp $ */ /*- * Copyright (c) 1999 @@ -105,7 +105,7 @@ mbattach(parent, self, aux) register struct device *mb = self; struct mainbus_attach_args ma; char *devnames[] = { - "txsim", "bivideo", "vrip", "btnmgr", "hpcapm", + "txsim", "vrip", "bivideo", "btnmgr", "hpcapm", }; printf("\n"); diff --git a/sys/arch/hpcmips/include/config_hook.h b/sys/arch/hpcmips/include/config_hook.h index 6a1858250096..f86da80babef 100644 --- a/sys/arch/hpcmips/include/config_hook.h +++ b/sys/arch/hpcmips/include/config_hook.h @@ -1,4 +1,4 @@ -/* $NetBSD: config_hook.h,v 1.4 2000/07/02 10:01:31 takemura Exp $ */ +/* $NetBSD: config_hook.h,v 1.5 2000/07/22 08:53:38 takemura Exp $ */ /*- * Copyright (c) 1999 @@ -34,6 +34,9 @@ * */ +#ifndef _CONFIG_HOOK_H_ +#define _CONFIG_HOOK_H_ + enum config_hook_mode { CONFIG_HOOK_SHARE, CONFIG_HOOK_REPLACE, @@ -84,6 +87,7 @@ int config_hook_call __P((int type, long id, void *msg)); #define CONFIG_HOOK_PMEVENT 2 #define CONFIG_HOOK_PMEVENT_STANDBYREQ 0 #define CONFIG_HOOK_PMEVENT_SUSPENDREQ 1 +#define CONFIG_HOOK_PMEVENT_HARDPOWER 2 #define CONFIG_HOOK_NTYPES 3 @@ -117,3 +121,5 @@ int config_hook_call __P((int type, long id, void *msg)); #define BTN_LIGHT_UP CONFIG_HOOK_BUTTONEVENT_LIGHT_UP #define BTN_LIGHT_DN CONFIG_HOOK_BUTTONEVENT_LIGHT_DOWN #endif /* CONFIG_HOOK_DEFINE_NICKNAME */ + +#endif /* _CONFIG_HOOK_H_ */ diff --git a/sys/arch/hpcmips/vr/mq200_vrip.c b/sys/arch/hpcmips/vr/mq200_vrip.c new file mode 100644 index 000000000000..8f8014e263ad --- /dev/null +++ b/sys/arch/hpcmips/vr/mq200_vrip.c @@ -0,0 +1,100 @@ +/* $NetBSD: mq200_vrip.c,v 1.1 2000/07/22 08:53:38 takemura Exp $ */ + +/*- + * Copyright (c) 2000 Takemura Shin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "locators.h" + +struct mq200_vrip_softc { + struct mq200_softc sc_mq200; +}; + +static int mq200_vrip_probe __P((struct device *, struct cfdata *, + void *)); +static void mq200_vrip_attach __P((struct device *, struct device *, + void *)); + +struct cfattach mqvideo_vrip_ca = { + sizeof(struct mq200_vrip_softc), mq200_vrip_probe, mq200_vrip_attach +}; + +static int +mq200_vrip_probe(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + struct vrip_attach_args *va = aux; + bus_space_handle_t ioh; + int res; + + if (va->va_addr == VRIPCF_ADDR_DEFAULT) + return (0); + + if (bus_space_map(va->va_iot, va->va_addr, va->va_size, 0, &ioh)) { + printf(": can't map i/o space\n"); + return 0; + } + res = mq200_probe(va->va_iot, ioh); + bus_space_unmap(va->va_iot, ioh, va->va_size); + + return (res); +} + + +static void +mq200_vrip_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct mq200_vrip_softc *vsc = (void *)self; + struct mq200_softc *sc = &vsc->sc_mq200; + struct vrip_attach_args *va = aux; + + sc->sc_baseaddr = va->va_addr; + sc->sc_iot = va->va_iot; + if (bus_space_map(va->va_iot, va->va_addr, va->va_size, 0, + &sc->sc_ioh)) { + printf(": can't map bus space\n"); + return; + } + + mq200_attach(sc); +}