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