Add CanBe power management controller support.

Submitted by:	KIYOHARA Takashi <kiyohara@kk.iij4u.or.jp>
This commit is contained in:
Yoshihiro Takahashi 2003-02-03 14:46:26 +00:00
parent 487fffcbf2
commit 83536948ae
11 changed files with 813 additions and 2 deletions

View File

@ -364,6 +364,9 @@ pc98/i386/busio.s standard
pc98/i386/busiosubr.c standard
pc98/i386/machdep.c standard
pc98/pc98/atapi.c optional wdc
pc98/pc98/canbepm.c optional canbepm
pc98/pc98/canbus.c optional canbus
pc98/pc98/canbus_if.m optional canbus
pc98/pc98/clock.c standard
pc98/pc98/fd.c optional fdc
pc98/pc98/isa_dma.c optional isa

View File

@ -254,7 +254,7 @@ MFILES?= kern/bus_if.m kern/device_if.m dev/iicbus/iicbb_if.m \
dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
dev/usb/usb_if.m dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m pci/agp_if.m \
opencrypto/crypto_if.m
opencrypto/crypto_if.m pc98/pc98/canbus_if.m
.for _srcsrc in ${MFILES}
.for _ext in c h

View File

@ -215,7 +215,9 @@ SUBDIR+=aac \
vesa
.elif ${MACHINE} == "pc98"
SUBDIR+=pcspeaker \
SUBDIR+=canbepm \
canbus \
pcspeaker \
pmc \
snc
.endif

View File

@ -0,0 +1,8 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../pc98/pc98
KMOD = canbepm
SRCS = canbepm.c
SRCS += device_if.h bus_if.h canbus_if.h
.include <bsd.kmod.mk>

View File

@ -0,0 +1,8 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../pc98/pc98
KMOD = canbus
SRCS = canbus.c
SRCS += device_if.h bus_if.h canbus_if.h canbus_if.c
.include <bsd.kmod.mk>

View File

@ -135,6 +135,8 @@ device npx
# Power management support (see NOTES for more options)
#device apm
#device pmc
#device canbus
#device canbepm
# Add suspend/resume support for the i8254.
#device pmtimer

135
sys/pc98/pc98/canbepm.c Normal file
View File

@ -0,0 +1,135 @@
/*-
* Copyright (c) 2000 Takanori Watanabe <wnabe@par.odn.ne.jp>
* Copyright (c) 2000 KIYOHARA Takashi <kiyohara@kk.iij4u.ne.jp>
*
* 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 AUTHOR 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 AUTHOR 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
*
* $FreeBSD$
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/reboot.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <pc98/pc98/canbusvars.h>
#include "canbus_if.h"
/* canbepm softc */
struct canbepm_softc {
device_t canbepm_dev; /* canbepm device */
eventhandler_tag canbepm_tag; /* event handler tag */
};
static void canbepm_soft_off (void *, int);
static void canbepm_identify (driver_t *, device_t);
static int canbepm_probe (device_t);
static int canbepm_attach (device_t);
static int canbepm_detach (device_t);
static device_method_t canbepm_methods[] = {
DEVMETHOD(device_identify, canbepm_identify),
DEVMETHOD(device_probe, canbepm_probe),
DEVMETHOD(device_attach, canbepm_attach),
DEVMETHOD(device_detach, canbepm_detach),
{0, 0}
};
static driver_t canbepm_driver = {
"canbepm",
canbepm_methods,
sizeof(struct canbepm_softc),
};
devclass_t canbepm_devclass;
DRIVER_MODULE(canbepm, canbus, canbepm_driver, canbepm_devclass, 0, 0);
MODULE_DEPEND(canbepm, canbus, 1, 1, 1);
static void
canbepm_soft_off (void *data, int howto)
{
struct canbepm_softc *sc = data;
u_int8_t poweroff_data[] = CANBE_POWEROFF_DATA;
if (!(howto & RB_POWEROFF))
return;
CANBUS_WRITE_MULTI(device_get_parent(sc->canbepm_dev), sc->canbepm_dev,
CANBE_POWER_CTRL, sizeof (poweroff_data), poweroff_data);
}
static void
canbepm_identify(driver_t *drv, device_t parent)
{
if (device_find_child(parent, "canbepm", 0) == NULL) {
if (BUS_ADD_CHILD(parent, 33, "canbepm", 0) == NULL)
device_printf(parent, "canbepm cannot attach\n");
}
}
static int
canbepm_probe(device_t dev)
{
device_set_desc(dev, "CanBe Power Management Controller");
return (0);
}
static int
canbepm_attach(device_t dev)
{
struct canbepm_softc *sc = device_get_softc(dev);
/* eventhandler regist */
sc->canbepm_tag = EVENTHANDLER_REGISTER(
shutdown_final, canbepm_soft_off, sc, SHUTDOWN_PRI_LAST);
sc->canbepm_dev = dev;
return (0);
}
static int
canbepm_detach(device_t dev)
{
struct canbepm_softc *sc = device_get_softc(dev);
/* eventhandler deregist */
EVENTHANDLER_DEREGISTER(shutdown_final, sc->canbepm_tag);
BUS_CHILD_DETACHED(device_get_parent(dev), dev);
return (0);
}

440
sys/pc98/pc98/canbus.c Normal file
View File

@ -0,0 +1,440 @@
/*-
* Copyright (c) 2000 Takanori Watanabe <wnabe@par.odn.ne.jp>
* Copyright (c) 2000 KIYOHARA Takashi <kiyohara@kk.iij4u.ne.jp>
*
* 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 AUTHOR 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 AUTHOR 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
*
* $FreeBSD$
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/sysctl.h>
#include <machine/clock.h>
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <pc98/pc98/canbus.h>
#include <pc98/pc98/canbusvars.h>
#include "canbus_if.h"
#define CANBE_IO_DELAY_TIME 5000
static MALLOC_DEFINE(M_CANBUSDEV, "canbusdev", "CanBe device");
struct canbus_device {
struct resource_list cbdev_resources;
};
/* canbus softc */
struct canbus_softc {
int io_delay_time; /* CanBe I/O delay time */
struct sysctl_ctx_list canbus_sysctl_ctx;
/* dynamic sysctl tree */
/* index register */
int index_id; /* index ID */
struct resource *index_res; /* index resouce */
bus_space_tag_t index_tag; /* index tag */
bus_space_handle_t index_handle; /* index handle */
/* data register */
int data_id; /* data ID */
struct resource *data_res; /* data resouce */
bus_space_tag_t data_tag; /* data tag */
bus_space_handle_t data_handle; /* data handle */
};
/* Device interface methods */
static void canbus_identify(driver_t *, device_t);
static int canbus_probe(device_t);
static int canbus_attach(device_t);
static int canbus_detach(device_t);
/* Bus interface methods */
static int canbus_print_child(device_t, device_t);
static device_t canbus_add_child(device_t, int, const char *, int);
static struct resource * canbus_alloc_resource(
device_t, device_t, int, int *, u_long, u_long, u_long, u_int);
static int canbus_activate_resource(
device_t, device_t, int, int, struct resource *);
static int canbus_deactivate_resource(
device_t, device_t, int, int, struct resource *);
static int canbus_release_resource(
device_t, device_t, int, int, struct resource *);
static int canbus_set_resource (
device_t, device_t, int, int, u_long, u_long);
static void canbus_delete_resource(device_t, device_t, int, int);
/* canbus local function */
static void set_ioresource(device_t dev);
static void delete_ioresource(device_t dev);
static int alloc_ioresource(device_t);
static void release_ioresource(device_t);
static int print_all_resources(device_t);
static device_method_t canbus_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, canbus_identify),
DEVMETHOD(device_probe, canbus_probe),
DEVMETHOD(device_attach, canbus_attach),
DEVMETHOD(device_detach, canbus_detach),
/* Bus interface */
DEVMETHOD(bus_print_child, canbus_print_child),
DEVMETHOD(bus_add_child, canbus_add_child),
DEVMETHOD(bus_alloc_resource, canbus_alloc_resource),
DEVMETHOD(bus_activate_resource, canbus_activate_resource),
DEVMETHOD(bus_deactivate_resource, canbus_deactivate_resource),
DEVMETHOD(bus_release_resource, canbus_release_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
DEVMETHOD(bus_set_resource, canbus_set_resource),
DEVMETHOD(bus_delete_resource, canbus_delete_resource),
/* CanBe interface */
DEVMETHOD(canbus_read, canbus_read),
DEVMETHOD(canbus_write, canbus_write),
DEVMETHOD(canbus_write_multi, canbus_write_multi),
{0, 0}
};
static driver_t canbus_driver = {
"canbus",
canbus_methods,
sizeof(struct canbus_softc),
};
devclass_t canbus_devclass;
DRIVER_MODULE(canbus, nexus, canbus_driver, canbus_devclass, 0, 0);
MODULE_VERSION(canbus, 1);
static void
canbus_identify(driver_t *drv, device_t parent)
{
if (device_find_child(parent, "canbus", 0) == NULL) {
if (BUS_ADD_CHILD(parent, 33, "canbus", 0) == NULL)
device_printf(parent, "canbus cannot attach\n");
}
}
static int
canbus_probe(device_t dev)
{
u_int8_t flag;
set_ioresource(dev);
if(alloc_ioresource(dev))
return (ENXIO);
flag = canbus_read(dev, NULL, CANBE_SOUND_INTR_ADDR);
release_ioresource(dev);
if (bootverbose)
device_printf(dev, "probe flag = 0x%x\n", flag);
if (flag != CANBE_SOUND_INTR_VAL0 && flag != CANBE_SOUND_INTR_VAL1 &&
flag != CANBE_SOUND_INTR_VAL2 && flag != CANBE_SOUND_INTR_VAL3) {
device_printf(dev, "Device Not Found\n");
return (ENXIO);
}
device_set_desc(dev, "CanBe I/O Bus");
return (0);
}
static int
canbus_attach(device_t dev)
{
struct canbus_softc *sc = device_get_softc(dev);
struct sysctl_oid *canbus_sysctl_tree;
sc->io_delay_time = CANBE_IO_DELAY_TIME;
/* I/O resource setup */
if(alloc_ioresource(dev))
return (ENXIO);
/* Dynamic sysctl tree setup */
sysctl_ctx_init(&sc->canbus_sysctl_ctx);
canbus_sysctl_tree = SYSCTL_ADD_NODE(&sc->canbus_sysctl_ctx,
SYSCTL_STATIC_CHILDREN(/* tree top */), OID_AUTO,
"canbus", CTLFLAG_RD, 0, "CanBe I/O Bus");
SYSCTL_ADD_INT(&sc->canbus_sysctl_ctx,
SYSCTL_CHILDREN(canbus_sysctl_tree), OID_AUTO, "io_delay_time",
CTLFLAG_RW, &sc->io_delay_time, 0, "CanBe Bus I/O delay time");
bus_generic_probe(dev);
bus_generic_attach(dev);
return (0);
}
static int
canbus_detach(device_t dev)
{
struct canbus_softc *sc = device_get_softc(dev);
/* I/O resource free */
release_ioresource(dev);
delete_ioresource(dev);
/* Dynamic sysctl tree destroy */
if (sysctl_ctx_free(&sc->canbus_sysctl_ctx)) {
device_printf(dev,
"can't free this context - other oids depend on it\n");
return (ENOTEMPTY);
}
return (0);
}
static int
canbus_print_child(device_t dev, device_t child)
{
int retval = 0;
retval += bus_print_child_header(dev, child);
retval += print_all_resources(child);
retval += bus_print_child_footer(dev, child);
return (retval);
}
static device_t
canbus_add_child(device_t bus, int order, const char *name, int unit)
{
device_t child;
struct canbus_device *cbdev;
child = device_add_child_ordered(bus, order, name, unit);
cbdev = malloc(
sizeof(struct canbus_device), M_CANBUSDEV, M_NOWAIT | M_ZERO);
if (!cbdev)
return (0);
resource_list_init(&cbdev->cbdev_resources);
device_set_ivars(child, cbdev);
return (child);
}
static struct resource *
canbus_alloc_resource(device_t dev, device_t child, int type,
int *rid, u_long start, u_long end, u_long count, u_int flags)
{
return (BUS_ALLOC_RESOURCE(device_get_parent(dev),
child, type, rid, start, end, count, flags));
}
static int
canbus_activate_resource(
device_t dev, device_t child, int type, int rid, struct resource *res)
{
return (BUS_ACTIVATE_RESOURCE(
device_get_parent(dev), child, type, rid, res));
}
static int
canbus_deactivate_resource(
device_t dev, device_t child, int type, int rid, struct resource *res)
{
return (BUS_DEACTIVATE_RESOURCE(
device_get_parent(dev), child, type, rid, res));
}
static int
canbus_release_resource(
device_t dev, device_t child, int type, int rid, struct resource *res)
{
return (BUS_RELEASE_RESOURCE(
device_get_parent(dev), child, type, rid, res));
}
static int
canbus_set_resource (
device_t dev, device_t child, int type, int rid, u_long start, u_long count)
{
struct canbus_device *cbdev =
(struct canbus_device *)device_get_ivars(child);
struct resource_list *rl = &cbdev->cbdev_resources;
resource_list_add(rl, type, rid, start, (start + count - 1), count);
return (0);
}
static void
canbus_delete_resource(device_t dev, device_t child, int type, int rid)
{
struct canbus_device *cbdev =
(struct canbus_device *)device_get_ivars(child);
struct resource_list *rl = &cbdev->cbdev_resources;
resource_list_delete(rl, type, rid);
}
u_int8_t
canbus_read(device_t dev, device_t child, int reg)
{
struct canbus_softc *sc = device_get_softc(dev);
bus_space_write_1(sc->index_tag, sc->index_handle, 0, reg);
return (bus_space_read_1(sc->data_tag, sc->data_handle, 0));
}
void
canbus_write(device_t dev, device_t child, int reg, u_int8_t val)
{
struct canbus_softc *sc = device_get_softc(dev);
bus_space_write_1(sc->index_tag, sc->index_handle, 0, reg);
bus_space_write_1(sc->data_tag, sc->data_handle, 0, val);
}
void
canbus_write_multi(device_t dev,
device_t child, int reg, const int count, const u_int8_t *vals)
{
struct canbus_softc *sc = device_get_softc(dev);
int i;
bus_space_write_1(sc->index_tag, sc->index_handle, 0, reg);
for (i = 0; i < count; i ++) {
bus_space_write_1(sc->data_tag, sc->data_handle, 0, vals[i]);
DELAY(sc->io_delay_time);
}
}
void
canbus_delay(device_t dev, device_t child)
{
struct canbus_softc *sc = device_get_softc(dev);
DELAY(sc->io_delay_time);
}
/*
* canbus local function.
*/
/*
* CanBe I/O resource set function
*/
static void
set_ioresource(device_t dev)
{
struct canbus_softc *sc = device_get_softc(dev);
sc->index_id = 0;
sc->data_id = 1;
bus_set_resource(
dev, SYS_RES_IOPORT, sc->index_id, CANBE_IOPORT_INDEX, 1);
bus_set_resource(
dev, SYS_RES_IOPORT, sc->data_id, CANBE_IOPORT_DATA, 1);
}
/*
* CanBe I/O resource delete function
*/
static void
delete_ioresource(device_t dev)
{
struct canbus_softc *sc = device_get_softc(dev);
bus_delete_resource(dev, SYS_RES_IOPORT, sc->index_id);
bus_delete_resource(dev, SYS_RES_IOPORT, sc->data_id);
}
/*
* CanBe I/O resource alloc function
*/
static int
alloc_ioresource(device_t dev)
{
struct canbus_softc *sc = device_get_softc(dev);
sc->index_res = bus_alloc_resource(
dev, SYS_RES_IOPORT, &sc->index_id, 0ul, ~0ul, 1, RF_ACTIVE);
sc->data_res = bus_alloc_resource(
dev, SYS_RES_IOPORT, &sc->data_id, 0ul, ~0ul, 1, RF_ACTIVE);
if (sc->index_res == NULL || sc->data_res == NULL) {
device_printf(dev, "could not map I/O\n");
return (ENXIO);
}
sc->index_tag = rman_get_bustag(sc->index_res);
sc->index_handle = rman_get_bushandle(sc->index_res);
sc->data_tag = rman_get_bustag(sc->data_res);
sc->data_handle = rman_get_bushandle(sc->data_res);
return (0);
}
/*
* CanBe I/O resource release function
*/
static void
release_ioresource(device_t dev)
{
struct canbus_softc *sc = device_get_softc(dev);
bus_release_resource(dev, SYS_RES_IOPORT, sc->index_id, sc->index_res);
bus_release_resource(dev, SYS_RES_IOPORT, sc->data_id, sc->data_res);
}
static int
print_all_resources(device_t dev)
{
struct canbus_device *cbdev =
(struct canbus_device *)device_get_ivars(dev);
struct resource_list *rl = &cbdev->cbdev_resources;
int retval = 0;
if (SLIST_FIRST(rl))
retval += printf(" at");
retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
return retval;
}

37
sys/pc98/pc98/canbus.h Normal file
View File

@ -0,0 +1,37 @@
/*-
* Copyright (c) 2000 Takanori Watanabe <wnabe@par.odn.ne.jp>
* Copyright (c) 2000 KIYOHARA Takashi <kiyohara@kk.iij4u.or.jp>
*
* 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 AUTHOR 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 AUTHOR 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
*
* $FreeBSD$
*/
#ifndef _PC98_PC98_CANBUS_H_
#define _PC98_PC98_CANBUS_H_
u_int8_t canbus_read(device_t, device_t, int);
void canbus_write(device_t, device_t, int, u_int8_t);
void canbus_write_multi(
device_t, device_t, int, const int, const u_int8_t *);
void canbus_delay(device_t, device_t);
#endif /* _PC98_PC98_CANBUS_H_ */

68
sys/pc98/pc98/canbus_if.m Normal file
View File

@ -0,0 +1,68 @@
#
# Copyright (c) 2002 KIYOHARA Takashi <kiyohara@kk.iij4u.or.jp>
#
# 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 AUTHOR 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 AUTHOR 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.
#
# $FreeBSD$
#
#include <sys/bus.h>
INTERFACE canbus;
#
# CanBe I/O read
#
METHOD u_int8_t read {
device_t dev;
device_t child;
int reg;
};
#
# CanBe I/O write
#
METHOD void write {
device_t dev;
device_t child;
int reg;
u_int8_t val;
};
#
# CanBe I/O write multi bytes
#
METHOD void write_multi {
device_t dev;
device_t child;
int reg;
const int count;
const u_int8_t * vals;
};
#
# CanBe I/O delay
#
METHOD void delay {
device_t dev;
device_t child;
};

108
sys/pc98/pc98/canbusvars.h Normal file
View File

@ -0,0 +1,108 @@
/*-
* Copyright (c) 2000 Takanori Watanabe <wnabe@par.odn.ne.jp>
* Copyright (c) 2000 KIYOHARA Takashi <kiyohara@kk.iij4u.or.jp>
*
* 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 AUTHOR 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 AUTHOR 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
*
* $FreeBSD$
*/
#ifndef _PC98_PC98_CANBUSVARS_H_
#define _PC98_PC98_CANBUSVARS_H_
/* CanBe I/O register */
#define CANBE_IOPORT_INDEX 0xf4a
#define CANBE_IOPORT_DATA 0xf4b
/*
* following registor purpose for spending -- unknown.
*/
#define CANBE_IOPORT1 0x0c24
#define CANBE_IOPORT2 0x0c2b
#define CANBE_IOPORT3 0x0c2d
/* CanBe register number */
#define CANBE_SOUND_INTR_ADDR 0x01
#define CANBE_RC_RESET 0x03
#define CANBE_MUTE_CTRL 0x04
#define CANBE_RC_DATA_STATUS 0x10
#define CANBE_RC_RECV_CODE 0x11
#define CANBE_POWER_CTRL 0x13
#define CANBE_RC_USED_INTR 0x14
/* CanBe sound interrupt address value */
#define CANBE_SOUND_INTR_VAL0 0x00
#define CANBE_SOUND_INTR_VAL1 0x02
#define CANBE_SOUND_INTR_VAL2 0x03
#define CANBE_SOUND_INTR_VAL3 0x08
/* CanBe remote controler reset */
#define CANBE_MIKE_THRUE 0x04
#define CANBE_CTRLR_RESET 0x01
/* CanBe mute control */
#define CANBE_MUTE 0x01
/* CanBe remote controler data status */
#define CANBE_RC_BUSY 0x02
#define CANBE_RC_STATUS 0x01
/* CanBe remote controler receive code */
#define CANBE_RC_DATA_CHUP 0x00
#define CANBE_RC_DATA_CHDOWN 0x01
#define CANBE_RC_DATA_VOLUP 0x02
#define CANBE_RC_DATA_VOLDOWN 0x03
#define CANBE_RC_DATA_EJECT 0x04
#define CANBE_RC_DATA_PLAY 0x05
#define CANBE_RC_DATA_MUTE 0x09
#define CANBE_RC_DATA_VIDEO 0x0a
#define CANBE_RC_DATA_NEXT 0x0c
#define CANBE_RC_DATA_PREVIOUS 0x0d
#define CANBE_RC_DATA_M_S 0x1d
#define CANBE_RC_DATA_UP 0x40
#define CANBE_RC_DATA_DOWN 0x41
#define CANBE_RC_DATA_LEFT 0x42
#define CANBE_RC_DATA_RIGHT 0x43
#define CANBE_RC_DATA_SIZE 0x4d
#define CANBE_RC_DATA_ESC 0x4e
#define CANBE_RC_DATA_CR 0x4f
#define CANBE_RC_DATA_TV 0x53
#define CANBE_RC_DATA_FREEZE 0x5d
#define CANBE_RC_DATA_CAPTURE 0x5e
/* CanBe power off data */
#define CANBE_POWEROFF_DATA { \
0x80, 0x06, 0x00, 0x00, \
0x80, 0x07, 0x00, 0x01, \
0x80, 0x01, 0x00, 0x00 \
}
/* CanBe remote controler used intr */
#define CANBE_RC_INTR 0x04
#define CANBE_RC_INTR_INT41 0x03 /* irq 10 */
#define CANBE_RC_INTR_INT1 0x02 /* irq 5 */
#define CANBE_RC_INTR_INT2 0x01 /* irq 6 */
#define CANBE_RC_INTR_INT0 0x00 /* irq 3 */
#endif /* _PC98_PC98_CANBUSVARS_H_ */