Home | History | Annotate | Line # | Download | only in tsarm
tspld.c revision 1.14
      1 /*	$NetBSD: tspld.c,v 1.14 2008/04/28 20:23:17 martin Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2004 Jesse Off
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  * POSSIBILITY OF SUCH DAMAGE.
     27  *
     28  */
     29 
     30 #include <sys/cdefs.h>
     31 __KERNEL_RCSID(0, "$NetBSD: tspld.c,v 1.14 2008/04/28 20:23:17 martin Exp $");
     32 
     33 #include <sys/param.h>
     34 #include <sys/callout.h>
     35 #include <sys/kernel.h>
     36 #include <sys/sysctl.h>
     37 #include <sys/systm.h>
     38 #include <sys/device.h>
     39 #include <sys/wdog.h>
     40 
     41 #include <machine/bus.h>
     42 #include <machine/cpu.h>
     43 #include <machine/autoconf.h>
     44 #include "isa.h"
     45 #if NISA > 0
     46 #include <dev/isa/isavar.h>
     47 #include <machine/isa_machdep.h>
     48 #endif
     49 
     50 #include <evbarm/tsarm/tsarmreg.h>
     51 #include <evbarm/tsarm/tspldvar.h>
     52 #include <arm/ep93xx/ep93xxvar.h>
     53 #include <arm/ep93xx/ep93xxreg.h>
     54 #include <arm/ep93xx/epgpioreg.h>
     55 #include <arm/arm32/machdep.h>
     56 #include <arm/cpufunc.h>
     57 #include <dev/sysmon/sysmonvar.h>
     58 
     59 int	tspldmatch (struct device *, struct cfdata *, void *);
     60 void	tspldattach (struct device *, struct device *, void *);
     61 static int	tspld_wdog_setmode (struct sysmon_wdog *);
     62 static int	tspld_wdog_tickle (struct sysmon_wdog *);
     63 int tspld_search (struct device *, struct cfdata *, const int *, void *);
     64 int tspld_print (void *, const char *);
     65 void boardtemp_poll (void *);
     66 
     67 struct tspld_softc {
     68         struct device           sc_dev;
     69         bus_space_tag_t         sc_iot;
     70 	bus_space_handle_t	sc_wdogfeed_ioh;
     71 	bus_space_handle_t	sc_wdogctrl_ioh;
     72 	struct sysmon_wdog	sc_wdog;
     73 	bus_space_handle_t	sc_ssph;
     74 	bus_space_handle_t	sc_gpioh;
     75 	unsigned const char *	sc_com2mode;
     76 	unsigned const char *	sc_model;
     77 	unsigned char		sc_pldrev[4];
     78 	uint32_t		sc_rs485;
     79 	uint32_t		sc_adc;
     80 	uint32_t		sc_jp[6];
     81 	uint32_t		sc_blaster_present;
     82 	uint32_t		sc_blaster_boot;
     83 	uint32_t		boardtemp;
     84 	uint32_t		boardtemp_5s;
     85 	uint32_t		boardtemp_30s;
     86 	struct callout		boardtemp_callout;
     87 };
     88 
     89 CFATTACH_DECL(tspld, sizeof(struct tspld_softc),
     90     tspldmatch, tspldattach, NULL, NULL);
     91 
     92 void	tspld_callback __P((struct device *));
     93 
     94 #define GPIO_GET(x)	bus_space_read_4(sc->sc_iot, sc->sc_gpioh, \
     95 	(EP93XX_GPIO_ ## x))
     96 
     97 #define GPIO_SET(x, y)	bus_space_write_4(sc->sc_iot, sc->sc_gpioh, \
     98 	(EP93XX_GPIO_ ## x), (y))
     99 
    100 #define GPIO_SETBITS(x, y)	bus_space_write_4(sc->sc_iot, sc->sc_gpioh, \
    101 	(EP93XX_GPIO_ ## x), GPIO_GET(x) | (y))
    102 
    103 #define GPIO_CLEARBITS(x, y)	bus_space_write_4(sc->sc_iot, sc->sc_gpioh, \
    104 	(EP93XX_GPIO_ ## x), GPIO_GET(x) & (~(y)))
    105 
    106 #define SSP_GET(x)	bus_space_read_4(sc->sc_iot, sc->sc_ssph, \
    107 	(EP93XX_SSP_ ## x))
    108 
    109 #define SSP_SET(x, y)	bus_space_write_4(sc->sc_iot, sc->sc_ssph, \
    110 	(EP93XX_SSP_ ## x), (y))
    111 
    112 #define SSP_SETBITS(x, y)	bus_space_write_4(sc->sc_iot, sc->sc_ssph, \
    113 	(EP93XX_SSP_ ## x), SSP_GET(x) | (y))
    114 
    115 #define SSP_CLEARBITS(x, y)	bus_space_write_4(sc->sc_iot, sc->sc_ssph, \
    116 	(EP93XX_SSP_ ## x), SSP_GET(x) & (~(y)))
    117 
    118 int
    119 tspldmatch(parent, match, aux)
    120 	struct device *parent;
    121 	struct cfdata *match;
    122 	void *aux;
    123 {
    124 
    125 	return 1;
    126 }
    127 
    128 void
    129 boardtemp_poll(arg)
    130 	void *arg;
    131 {
    132 	struct tspld_softc *sc = arg;
    133 	u_int16_t val;
    134 
    135 	/* Disable chip select */
    136 	GPIO_SET(PFDDR, 0x0);
    137 
    138 	val = SSP_GET(SSPDR) & 0xffff;
    139 	sc->boardtemp = ((int16_t)val >> 3) * 62500;
    140 	sc->boardtemp_5s = sc->boardtemp_5s / 20 * 19 + sc->boardtemp / 20;
    141 	sc->boardtemp_30s = sc->boardtemp_30s / 120 * 119 + sc->boardtemp / 120;
    142 
    143 	callout_schedule(&sc->boardtemp_callout, hz / 4);
    144 
    145 	/* Enable chip select */
    146 	GPIO_SET(PFDDR, 0x4);
    147 
    148 	/* Send read command */
    149 	SSP_SET(SSPDR, 0x8000);
    150 }
    151 
    152 void
    153 tspldattach(parent, self, aux)
    154 	struct device *parent, *self;
    155 	void *aux;
    156 {
    157 	int	i, rev, features, jp, model;
    158 	struct tspld_softc *sc = (struct tspld_softc *)self;
    159 	bus_space_handle_t 	ioh;
    160         const struct sysctlnode *node;
    161 
    162 	if (sysctl_createv(NULL, 0, NULL, NULL,
    163 				CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw",
    164 				NULL, NULL, 0, NULL, 0,
    165 				CTL_HW, CTL_EOL) != 0) {
    166 		printf("%s: could not create sysctl\n",
    167 			sc->sc_dev.dv_xname);
    168 		return;
    169 	}
    170 	if (sysctl_createv(NULL, 0, NULL, &node,
    171         			0, CTLTYPE_NODE, sc->sc_dev.dv_xname,
    172         			NULL,
    173         			NULL, 0, NULL, 0,
    174 				CTL_HW, CTL_CREATE, CTL_EOL) != 0) {
    175                 printf("%s: could not create sysctl\n",
    176 			sc->sc_dev.dv_xname);
    177 		return;
    178 	}
    179 
    180 	sc->sc_iot = &ep93xx_bs_tag;
    181 	bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_MODEL, 2, 0,
    182 		&ioh);
    183 	model = bus_space_read_2(sc->sc_iot, ioh, 0) & 0x7;
    184 	sc->sc_model = (model ? "TS-7250" : "TS-7200");
    185 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    186         			0, CTLTYPE_STRING, "boardmodel",
    187         			SYSCTL_DESCR("Technologic Systems board model"),
    188         			NULL, 0, __UNCONST(sc->sc_model), 0,
    189 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    190 				!= 0) {
    191                 printf("%s: could not create sysctl\n",
    192 			sc->sc_dev.dv_xname);
    193 		return;
    194 	}
    195 	bus_space_unmap(sc->sc_iot, ioh, 2);
    196 
    197 	bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_PLDREV, 2, 0,
    198 		&ioh);
    199 	rev = bus_space_read_2(sc->sc_iot, ioh, 0) & 0x7;
    200 	rev = 'A' + rev - 1;
    201 	sc->sc_pldrev[0] = rev;
    202 	sc->sc_pldrev[1] = 0;
    203 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    204         			0, CTLTYPE_STRING, "pldrev",
    205         			SYSCTL_DESCR("CPLD revision"),
    206         			NULL, 0, sc->sc_pldrev, 0,
    207 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    208 				!= 0) {
    209                 printf("%s: could not create sysctl\n",
    210 			sc->sc_dev.dv_xname);
    211 		return;
    212 	}
    213 	bus_space_unmap(sc->sc_iot, ioh, 2);
    214 
    215 	bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_FEATURES, 2, 0,
    216 		&ioh);
    217 	features = bus_space_read_2(sc->sc_iot, ioh, 0) & 0x7;
    218 	bus_space_unmap(sc->sc_iot, ioh, 2);
    219 
    220         bus_space_map(sc->sc_iot, TS7XXX_IO8_HWBASE + TS7XXX_STATUS1, 1, 0,
    221 		&ioh);
    222 	i = bus_space_read_1(sc->sc_iot, ioh, 0) & 0x1f;
    223 	jp = (~((i & 0x18) >> 1) & 0xc) | (i & 0x3);
    224 	bus_space_unmap(sc->sc_iot, ioh, 1);
    225 
    226 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    227         			0, CTLTYPE_INT, "blaster_present",
    228         			SYSCTL_DESCR("Whether or not a TS-9420/TS-9202 blaster board is connected"),
    229         			NULL, 0, &sc->sc_blaster_present, 0,
    230 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    231 				!= 0) {
    232                 printf("%s: could not create sysctl\n",
    233 			sc->sc_dev.dv_xname);
    234 		return;
    235 	}
    236 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    237         			0, CTLTYPE_INT, "blaster_boot",
    238         			SYSCTL_DESCR("Whether or not a blast board was used to boot"),
    239         			NULL, 0, &sc->sc_blaster_boot, 0,
    240 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    241 				!= 0) {
    242                 printf("%s: could not create sysctl\n",
    243 			sc->sc_dev.dv_xname);
    244 		return;
    245 	}
    246         bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_STATUS2, 2, 0,
    247 		&ioh);
    248 	i = bus_space_read_2(sc->sc_iot, ioh, 0) & 0x6;
    249 	sc->sc_blaster_boot = sc->sc_blaster_present = 0;
    250 	if (i & 0x2)
    251 		sc->sc_blaster_boot = 1;
    252 	if (i & 0x4)
    253 		sc->sc_blaster_present = 1;
    254 	jp |= (i << 4);
    255 	bus_space_unmap(sc->sc_iot, ioh, 1);
    256 
    257 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    258         			0, CTLTYPE_INT, "rs485_avail",
    259         			SYSCTL_DESCR("RS485 level driver for COM2 available"),
    260         			NULL, 0, &sc->sc_rs485, 0,
    261 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    262 				!= 0) {
    263                 printf("%s: could not create sysctl\n",
    264 			sc->sc_dev.dv_xname);
    265 		return;
    266 	}
    267 	sc->sc_com2mode = "rs232";
    268 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    269         			0, CTLTYPE_STRING, "com2_mode",
    270         			SYSCTL_DESCR("line driver type for COM2"),
    271         			NULL, 0, __UNCONST(sc->sc_com2mode), 0,
    272 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    273 				!= 0) {
    274                 printf("%s: could not create sysctl\n",
    275 			sc->sc_dev.dv_xname);
    276 		return;
    277 	}
    278 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    279         			0, CTLTYPE_INT, "max197adc_avail",
    280         			SYSCTL_DESCR("Maxim 197 Analog to Digital Converter available"),
    281         			NULL, 0, &sc->sc_adc, 0,
    282 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    283 				!= 0) {
    284                 printf("%s: could not create sysctl\n",
    285 			sc->sc_dev.dv_xname);
    286 		return;
    287 	}
    288 	printf(": Technologic Systems %s rev %c, features 0x%x",
    289 		sc->sc_model, rev, features);
    290 	sc->sc_adc = sc->sc_rs485 = 0;
    291 	if (features == 0x1) {
    292 		printf("<MAX197-ADC>");
    293 		sc->sc_adc = 1;
    294 	} else if (features == 0x2) {
    295 		printf("<RS485>");
    296 		sc->sc_rs485 = 1;
    297 	} else if (features == 0x3) {
    298 		printf("<MAX197-ADC,RS485>");
    299 		sc->sc_adc = sc->sc_rs485 = 1;
    300 	}
    301 	printf("\n");
    302 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    303         			0, CTLTYPE_INT, "jp1",
    304         			SYSCTL_DESCR("onboard jumper setting"),
    305         			NULL, 0, &sc->sc_jp[0], 0,
    306 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    307 				!= 0) {
    308                 printf("%s: could not create sysctl\n",
    309 			sc->sc_dev.dv_xname);
    310 		return;
    311 	}
    312 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    313         			0, CTLTYPE_INT, "jp2",
    314         			SYSCTL_DESCR("onboard jumper setting"),
    315         			NULL, 0, &sc->sc_jp[1], 0,
    316 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    317 				!= 0) {
    318                 printf("%s: could not create sysctl\n",
    319 			sc->sc_dev.dv_xname);
    320 		return;
    321 	}
    322 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    323         			0, CTLTYPE_INT, "jp3",
    324         			SYSCTL_DESCR("onboard jumper setting"),
    325         			NULL, 0, &sc->sc_jp[2], 0,
    326 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    327 				!= 0) {
    328                 printf("%s: could not create sysctl\n",
    329 			sc->sc_dev.dv_xname);
    330 		return;
    331 	}
    332 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    333         			0, CTLTYPE_INT, "jp4",
    334         			SYSCTL_DESCR("onboard jumper setting"),
    335         			NULL, 0, &sc->sc_jp[3], 0,
    336 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    337 				!= 0) {
    338                 printf("%s: could not create sysctl\n",
    339 			sc->sc_dev.dv_xname);
    340 		return;
    341 	}
    342 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    343         			0, CTLTYPE_INT, "jp5",
    344         			SYSCTL_DESCR("onboard jumper setting"),
    345         			NULL, 0, &sc->sc_jp[4], 0,
    346 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    347 				!= 0) {
    348                 printf("%s: could not create sysctl\n",
    349 			sc->sc_dev.dv_xname);
    350 		return;
    351 	}
    352 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    353         			0, CTLTYPE_INT, "jp6",
    354         			SYSCTL_DESCR("onboard jumper setting"),
    355         			NULL, 0, &sc->sc_jp[5], 0,
    356 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    357 				!= 0) {
    358                 printf("%s: could not create sysctl\n",
    359 			sc->sc_dev.dv_xname);
    360 		return;
    361 	}
    362 	printf("%s: jumpers 0x%x", sc->sc_dev.dv_xname, jp);
    363 	if (jp) {
    364 		printf("<");
    365 		for(i = 0; i < 5; i++) {
    366 			if (jp & (1 << i)) {
    367 				sc->sc_jp[i + 1] = 1;
    368 				printf("JP%d", i + 2);
    369 				jp &= ~(1 << i);
    370 				if (jp) printf(",");
    371 			} else {
    372 				sc->sc_jp[i + 2] = 0;
    373 			}
    374 		}
    375 		printf(">");
    376 	}
    377 	printf("\n");
    378 
    379 
    380         bus_space_map(sc->sc_iot, EP93XX_APB_HWBASE + EP93XX_APB_SSP,
    381 		EP93XX_APB_SSP_SIZE, 0, &sc->sc_ssph);
    382         bus_space_map(sc->sc_iot, EP93XX_APB_HWBASE + EP93XX_APB_GPIO,
    383 		EP93XX_APB_GPIO_SIZE, 0, &sc->sc_gpioh);
    384 	SSP_SETBITS(SSPCR1, 0x10);
    385 	SSP_SET(SSPCR0, 0xf);
    386 	SSP_SET(SSPCPSR, 0xfe);
    387 	SSP_CLEARBITS(SSPCR1, 0x10);
    388 	SSP_SETBITS(SSPCR1, 0x10);
    389 	GPIO_SET(PFDR, 0x0);
    390 	callout_init(&sc->boardtemp_callout, 0);
    391 	callout_setfunc(&sc->boardtemp_callout, boardtemp_poll, sc);
    392 	boardtemp_poll(sc);
    393 	delay(1000);
    394 	boardtemp_poll(sc);
    395 	sc->boardtemp_5s = sc->boardtemp_30s = sc->boardtemp;
    396 #define DEGF(c)	((c) * 9 / 5 + 32000000)
    397 	printf("%s: board temperature %d.%02d degC (%d.%02d degF)\n",
    398 		sc->sc_dev.dv_xname,
    399 		sc->boardtemp / 1000000, sc->boardtemp / 10000 % 100,
    400 		DEGF(sc->boardtemp) / 1000000, DEGF(sc->boardtemp) / 10000 % 100);
    401 #undef DEGF
    402 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    403         			0, CTLTYPE_INT, "board_temp",
    404         			SYSCTL_DESCR("board temperature in micro degrees Celsius"),
    405         			NULL, 0, &sc->boardtemp, 0,
    406 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    407 				!= 0) {
    408                 printf("%s: could not create sysctl\n",
    409 			sc->sc_dev.dv_xname);
    410 		return;
    411 	}
    412 
    413 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    414         			0, CTLTYPE_INT, "board_temp_5s",
    415         			SYSCTL_DESCR("5 second average board temperature in micro degrees Celsius"),
    416         			NULL, 0, &sc->boardtemp_5s, 0,
    417 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    418 				!= 0) {
    419                 printf("%s: could not create sysctl\n",
    420 			sc->sc_dev.dv_xname);
    421 		return;
    422 	}
    423 
    424 	if ((i = sysctl_createv(NULL, 0, NULL, NULL,
    425         			0, CTLTYPE_INT, "board_temp_30s",
    426         			SYSCTL_DESCR("30 second average board temperature in micro degrees Celsius"),
    427         			NULL, 0, &sc->boardtemp_30s, 0,
    428 				CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
    429 				!= 0) {
    430                 printf("%s: could not create sysctl\n",
    431 			sc->sc_dev.dv_xname);
    432 		return;
    433 	}
    434 
    435         bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_WDOGCTRL, 2, 0,
    436 		&sc->sc_wdogctrl_ioh);
    437         bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_WDOGFEED, 2, 0,
    438 		&sc->sc_wdogfeed_ioh);
    439 
    440 	sc->sc_wdog.smw_name = sc->sc_dev.dv_xname;
    441 	sc->sc_wdog.smw_cookie = sc;
    442 	sc->sc_wdog.smw_setmode = tspld_wdog_setmode;
    443 	sc->sc_wdog.smw_tickle = tspld_wdog_tickle;
    444 	sc->sc_wdog.smw_period = 8;
    445 	sysmon_wdog_register(&sc->sc_wdog);
    446 	tspld_wdog_setmode(&sc->sc_wdog);
    447 
    448 	/* Set the on board peripherals bus callback */
    449 	config_defer(self, tspld_callback);
    450 }
    451 
    452 int
    453 tspld_search(parent, cf, ldesc, aux)
    454 	struct device *parent;
    455 	struct cfdata *cf;
    456 	const int *ldesc;
    457 	void *aux;
    458 {
    459 	struct tspld_softc *sc = (struct tspld_softc *)parent;
    460 	struct tspld_attach_args sa;
    461 
    462 	sa.ta_iot = sc->sc_iot;
    463 
    464 	if (config_match(parent, cf, &sa) > 0)
    465 		config_attach(parent, cf, &sa, tspld_print);
    466 
    467 	return (0);
    468 }
    469 
    470 int
    471 tspld_print(aux, name)
    472 	void *aux;
    473 	const char *name;
    474 {
    475 
    476 	return (UNCONF);
    477 }
    478 
    479 void
    480 tspld_callback(self)
    481 	struct device *self;
    482 {
    483 #if NISA > 0
    484 	extern void isa_bs_mallocok(void);
    485 	struct isabus_attach_args iba;
    486 
    487 	/*
    488 	 * Attach the ISA bus behind this bridge.
    489 	 */
    490 	memset(&iba, 0, sizeof(iba));
    491 	iba.iba_iot = &isa_io_bs_tag;
    492 	iba.iba_memt = &isa_mem_bs_tag;
    493 	isa_bs_mallocok();
    494 	config_found_ia(self, "isabus", &iba, isabusprint);
    495 #endif
    496 	/*
    497 	 *  Attach each devices
    498 	 */
    499 	config_search_ia(tspld_search, self, "tspldbus", NULL);
    500 
    501 }
    502 
    503 static int
    504 tspld_wdog_tickle(smw)
    505 	struct sysmon_wdog *smw;
    506 {
    507 	struct tspld_softc *sc = (struct tspld_softc *)smw->smw_cookie;
    508 
    509 	bus_space_write_2(sc->sc_iot, sc->sc_wdogfeed_ioh, 0, 0x5);
    510 	return 0;
    511 }
    512 
    513 static int
    514 tspld_wdog_setmode(smw)
    515 	struct sysmon_wdog *smw;
    516 {
    517 	int i, ret = 0;
    518 	struct tspld_softc *sc = (struct tspld_softc *)smw->smw_cookie;
    519 
    520 	i = disable_interrupts(I32_bit|F32_bit);
    521 	if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
    522 		bus_space_write_2(sc->sc_iot, sc->sc_wdogfeed_ioh, 0, 0x5);
    523 		bus_space_write_2(sc->sc_iot, sc->sc_wdogctrl_ioh, 0, 0);
    524 	} else {
    525 		bus_space_write_2(sc->sc_iot, sc->sc_wdogfeed_ioh, 0, 0x5);
    526 		switch (smw->smw_period) {
    527 		case 1:
    528 			bus_space_write_2(sc->sc_iot, sc->sc_wdogctrl_ioh, 0,
    529 				0x3);
    530 			break;
    531 		case 2:
    532 			bus_space_write_2(sc->sc_iot, sc->sc_wdogctrl_ioh, 0,
    533 				0x5);
    534 			break;
    535 		case 4:
    536 			bus_space_write_2(sc->sc_iot, sc->sc_wdogctrl_ioh, 0,
    537 				0x6);
    538 			break;
    539 		case 8:
    540 			bus_space_write_2(sc->sc_iot, sc->sc_wdogctrl_ioh, 0,
    541 				0x7);
    542 			break;
    543 		default:
    544 			ret = EINVAL;
    545 		}
    546 	}
    547 	restore_interrupts(i);
    548 	return ret;
    549 }
    550