xref: /openbsd-src/sys/arch/hppa/dev/asp.c (revision 51f66ac76fe2119d6ac8316b4a09dbb260bff705)
1*51f66ac7Skettenis /*	$OpenBSD: asp.c,v 1.15 2018/05/14 13:54:39 kettenis Exp $	*/
2b3d41c10Smickey 
3b3d41c10Smickey /*
4fef2e65fSmickey  * Copyright (c) 1998-2003 Michael Shalayeff
5b3d41c10Smickey  * All rights reserved.
6b3d41c10Smickey  *
7b3d41c10Smickey  * Redistribution and use in source and binary forms, with or without
8b3d41c10Smickey  * modification, are permitted provided that the following conditions
9b3d41c10Smickey  * are met:
10b3d41c10Smickey  * 1. Redistributions of source code must retain the above copyright
11b3d41c10Smickey  *    notice, this list of conditions and the following disclaimer.
12b3d41c10Smickey  * 2. Redistributions in binary form must reproduce the above copyright
13b3d41c10Smickey  *    notice, this list of conditions and the following disclaimer in the
14b3d41c10Smickey  *    documentation and/or other materials provided with the distribution.
15b3d41c10Smickey  *
16b3d41c10Smickey  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17b3d41c10Smickey  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18b3d41c10Smickey  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19fef2e65fSmickey  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20fef2e65fSmickey  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21fef2e65fSmickey  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22fef2e65fSmickey  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23fef2e65fSmickey  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24fef2e65fSmickey  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25fef2e65fSmickey  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26fef2e65fSmickey  * THE POSSIBILITY OF SUCH DAMAGE.
27b3d41c10Smickey  */
28b3d41c10Smickey 
29eac0f0a4Smickey /*
30eac0f0a4Smickey  * References:
31eac0f0a4Smickey  *
32eac0f0a4Smickey  * 1. Cobra/Coral I/O Subsystem External Reference Specification
33eac0f0a4Smickey  *    Hewlett-Packard
34eac0f0a4Smickey  *
35eac0f0a4Smickey  */
36eac0f0a4Smickey 
37b3d41c10Smickey #include <sys/param.h>
38b3d41c10Smickey #include <sys/systm.h>
39b3d41c10Smickey #include <sys/device.h>
40b3d41c10Smickey #include <sys/reboot.h>
41b3d41c10Smickey 
42b3d41c10Smickey #include <machine/bus.h>
43b3d41c10Smickey #include <machine/iomod.h>
44b3d41c10Smickey #include <machine/autoconf.h>
453a2eb88cSmickey #include <machine/cpufunc.h>
46b3d41c10Smickey 
47b3d41c10Smickey #include <hppa/dev/cpudevs.h>
48b3d41c10Smickey 
49b3d41c10Smickey #include <hppa/gsc/gscbusvar.h>
50b3d41c10Smickey 
510dae5a81Smickey struct asp_hwr {
520dae5a81Smickey 	u_int8_t asp_reset;
530dae5a81Smickey 	u_int8_t asp_resv[31];
540dae5a81Smickey 	u_int8_t asp_version;
550dae5a81Smickey 	u_int8_t asp_resv1[15];
560dae5a81Smickey 	u_int8_t asp_scsidsync;
570dae5a81Smickey 	u_int8_t asp_resv2[15];
580dae5a81Smickey 	u_int8_t asp_error;
590dae5a81Smickey };
600dae5a81Smickey 
610dae5a81Smickey struct asp_trs {
62*51f66ac7Skettenis 	struct gscbus_ic asp_ic;
630dae5a81Smickey 	u_int8_t  asp_cled;
64*51f66ac7Skettenis 	u_int8_t  asp_resv[3];
650dae5a81Smickey 	struct {
660dae5a81Smickey 		u_int		:20,
670dae5a81Smickey 			asp_spu	: 3,	/* SPU ID board jumper */
680dae5a81Smickey #define	ASP_SPUCOBRA	0
690dae5a81Smickey #define	ASP_SPUCORAL	1
700dae5a81Smickey #define	ASP_SPUBUSH	2
710dae5a81Smickey #define	ASP_SPUHARDBALL	3
720dae5a81Smickey #define	ASP_SPUSCORPIO	4
730dae5a81Smickey #define	ASP_SPUCORAL2	5
740dae5a81Smickey 			asp_sw	: 1,	/* front switch is normal */
750dae5a81Smickey 			asp_clk : 1,	/* SCSI clock is doubled */
760dae5a81Smickey 			asp_lan : 2,	/* LAN iface selector */
770dae5a81Smickey #define	ASP_LANINVAL	0
780dae5a81Smickey #define	ASP_LANAUI	1
790dae5a81Smickey #define	ASP_LANTHIN	2
800dae5a81Smickey #define	ASP_LANMISS	3
810dae5a81Smickey 			asp_lanf: 1,	/* LAN AUI fuse is ok */
820dae5a81Smickey 			asp_spwr: 1,	/* SCSI power ok */
830dae5a81Smickey 			asp_scsi: 3;	/* SCSI ctrl ID */
840dae5a81Smickey 	} _asp_ios;
850dae5a81Smickey #define	asp_spu		_asp_ios.asp_spu
860dae5a81Smickey #define	asp_sw		_asp_ios.asp_sw
870dae5a81Smickey #define	asp_clk		_asp_ios.asp_clk
880dae5a81Smickey #define	asp_lan		_asp_ios.asp_lan
890dae5a81Smickey #define	asp_lanf	_asp_ios.asp_lanf
900dae5a81Smickey #define	asp_spwr	_asp_ios.asp_spwr
910dae5a81Smickey #define	asp_scsi	_asp_ios.asp_scsi
920dae5a81Smickey };
930dae5a81Smickey 
943a2eb88cSmickey const struct asp_spus_tag {
953a2eb88cSmickey 	char	name[12];
963a2eb88cSmickey 	int	ledword;
973a2eb88cSmickey } asp_spus[] = {
983a2eb88cSmickey 	{ "Cobra", 0 },
993a2eb88cSmickey 	{ "Coral", 0 },
1003a2eb88cSmickey 	{ "Bushmaster", 0 },
1013a2eb88cSmickey 	{ "Hardball", 1 },
1023a2eb88cSmickey 	{ "Scorpio", 0 },
1033a2eb88cSmickey 	{ "Coral II", 1 },
1043a2eb88cSmickey 	{ "#6", 0 },
1053a2eb88cSmickey 	{ "#7", 0 }
10694a3c495Smickey };
10794a3c495Smickey 
10824b306f3Smickey #define	ASP_IOMASK	0xfe000000
1090dae5a81Smickey /* ASP "Primary Controller" HPA */
110b3d41c10Smickey #define	ASP_CHPA	0xF0800000
111b3d41c10Smickey 
112c4071fd1Smillert int	aspmatch(struct device *, void *, void *);
113c4071fd1Smillert void	aspattach(struct device *, struct device *, void *);
114b3d41c10Smickey 
115*51f66ac7Skettenis const struct cfattach asp_ca = {
116*51f66ac7Skettenis 	sizeof(struct device), aspmatch, aspattach
117b3d41c10Smickey };
118b3d41c10Smickey 
119b3d41c10Smickey struct cfdriver asp_cd = {
120b3d41c10Smickey 	NULL, "asp", DV_DULL
121b3d41c10Smickey };
122b3d41c10Smickey 
123b3d41c10Smickey int
aspmatch(parent,cfdata,aux)124b3d41c10Smickey aspmatch(parent, cfdata, aux)
125b3d41c10Smickey 	struct device *parent;
126b3d41c10Smickey 	void *cfdata;
127b3d41c10Smickey 	void *aux;
128b3d41c10Smickey {
129b3d41c10Smickey 	struct confargs *ca = aux;
130b3d41c10Smickey 	/* struct cfdata *cf = cfdata; */
131b3d41c10Smickey 
132b3d41c10Smickey 	if (ca->ca_type.iodc_type != HPPA_TYPE_BHA ||
133b3d41c10Smickey 	    ca->ca_type.iodc_sv_model != HPPA_BHA_ASP)
134b3d41c10Smickey 		return 0;
135b3d41c10Smickey 
136b3d41c10Smickey 	return 1;
137b3d41c10Smickey }
138b3d41c10Smickey 
139b3d41c10Smickey void
aspattach(parent,self,aux)140b3d41c10Smickey aspattach(parent, self, aux)
141b3d41c10Smickey 	struct device *parent;
142b3d41c10Smickey 	struct device *self;
143b3d41c10Smickey 	void *aux;
144b3d41c10Smickey {
145*51f66ac7Skettenis 	struct confargs *ca = aux;
146*51f66ac7Skettenis 	volatile struct asp_trs *trs;
147*51f66ac7Skettenis 	volatile struct asp_hwr *hw;
148*51f66ac7Skettenis 	struct gscbus_ic *ic;
149b3d41c10Smickey 	struct gsc_attach_args ga;
1500dae5a81Smickey 	bus_space_handle_t ioh;
151*51f66ac7Skettenis 	int s;
1520dae5a81Smickey 
1530dae5a81Smickey 	if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) {
1540cbea151Smickey 		printf(": can't map IO space\n");
1550dae5a81Smickey 		return;
1560dae5a81Smickey 	}
1570dae5a81Smickey 
158*51f66ac7Skettenis 	hw = (struct asp_hwr *)ca->ca_hpa;
159*51f66ac7Skettenis 	trs = (struct asp_trs *)ASP_CHPA;
160*51f66ac7Skettenis 	ic = (struct gscbus_ic *)&trs->asp_ic;
161b3d41c10Smickey 
1623867ea13Smiod #ifdef USELEDS
163*51f66ac7Skettenis 	machine_ledaddr = &trs->asp_cled;
164*51f66ac7Skettenis 	machine_ledword = asp_spus[trs->asp_spu].ledword;
1653867ea13Smiod #endif
166b3d41c10Smickey 
167b3d41c10Smickey 	/* reset ASP */
168*51f66ac7Skettenis 	/* hw->asp_reset = 1; */
169eac0f0a4Smickey 	/* delay(400000); */
170b3d41c10Smickey 
1710dae5a81Smickey 	s = splhigh();
172*51f66ac7Skettenis 	ic->imr = ~0;
173*51f66ac7Skettenis 	(void)ic->irr;
174*51f66ac7Skettenis 	ic->imr = 0;
1750dae5a81Smickey 	splx(s);
1760dae5a81Smickey 
1773a2eb88cSmickey 	printf (": %s rev %d, lan %d scsi %d\n",
178*51f66ac7Skettenis 	    asp_spus[trs->asp_spu].name, hw->asp_version,
179*51f66ac7Skettenis 	    trs->asp_lan, trs->asp_scsi);
180b3d41c10Smickey 
181b3d41c10Smickey 	ga.ga_ca = *ca;	/* clone from us */
182fa7c453aSmickey 	ga.ga_dp.dp_bc[0] = ga.ga_dp.dp_bc[1];
183fa7c453aSmickey 	ga.ga_dp.dp_bc[1] = ga.ga_dp.dp_bc[2];
184fa7c453aSmickey 	ga.ga_dp.dp_bc[2] = ga.ga_dp.dp_bc[3];
185fa7c453aSmickey 	ga.ga_dp.dp_bc[3] = ga.ga_dp.dp_bc[4];
186fa7c453aSmickey 	ga.ga_dp.dp_bc[4] = ga.ga_dp.dp_bc[5];
187fa7c453aSmickey 	ga.ga_dp.dp_bc[5] = ga.ga_dp.dp_mod;
188fa7c453aSmickey 	ga.ga_dp.dp_mod = 0;
189c10c4b2dSmickey 	ga.ga_hpamask = ASP_IOMASK;
190b3d41c10Smickey 	ga.ga_name = "gsc";
191*51f66ac7Skettenis 	ga.ga_parent = gsc_asp;
192*51f66ac7Skettenis 	ga.ga_ic = ic;
193b3d41c10Smickey 	config_found(self, &ga, gscprint);
194b3d41c10Smickey }
195