2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer as
12 * the first lines of this file unmodified.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * from: FreeBSD: src/sys/isa/atkbdc_isa.c,v 1.31 2005/05/29 04:42:28 nyan Exp
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/module.h>
41 #include <sys/malloc.h>
42 #include <machine/resource.h>
45 #include <dev/atkbdc/atkbdc_subr.h>
46 #include <dev/atkbdc/atkbdcreg.h>
48 MALLOC_DEFINE(M_ATKBDDEV, "atkbddev", "AT Keyboard device");
50 devclass_t atkbdc_devclass;
53 atkbdc_print_child(device_t bus, device_t dev)
55 atkbdc_device_t *kbdcdev;
60 kbdcdev = (atkbdc_device_t *)device_get_ivars(dev);
62 retval += bus_print_child_header(bus, dev);
63 flags = device_get_flags(dev);
65 retval += printf(" flags 0x%x", flags);
66 irq = bus_get_resource_start(dev, SYS_RES_IRQ, kbdcdev->rid);
68 retval += printf(" irq %jd", irq);
69 retval += bus_print_child_footer(bus, dev);
75 atkbdc_read_ivar(device_t bus, device_t dev, int index, uintptr_t *val)
77 atkbdc_device_t *ivar;
79 ivar = (atkbdc_device_t *)device_get_ivars(dev);
81 case KBDC_IVAR_VENDORID:
82 *val = (u_long)ivar->vendorid;
84 case KBDC_IVAR_SERIAL:
85 *val = (u_long)ivar->serial;
87 case KBDC_IVAR_LOGICALID:
88 *val = (u_long)ivar->logicalid;
90 case KBDC_IVAR_COMPATID:
91 *val = (u_long)ivar->compatid;
100 atkbdc_write_ivar(device_t bus, device_t dev, int index, uintptr_t val)
102 atkbdc_device_t *ivar;
104 ivar = (atkbdc_device_t *)device_get_ivars(dev);
106 case KBDC_IVAR_VENDORID:
107 ivar->vendorid = (u_int32_t)val;
109 case KBDC_IVAR_SERIAL:
110 ivar->serial = (u_int32_t)val;
112 case KBDC_IVAR_LOGICALID:
113 ivar->logicalid = (u_int32_t)val;
115 case KBDC_IVAR_COMPATID:
116 ivar->compatid = (u_int32_t)val;
125 *atkbdc_get_resource_list(device_t bus, device_t dev)
127 atkbdc_device_t *ivar;
129 ivar = (atkbdc_device_t *)device_get_ivars(dev);
130 return &ivar->resources;