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