xref: /netbsd-src/sys/arch/arm/ixp12x0/ixpsip.c (revision c7fb772b85b2b5d4cfb282f868f454b4701534fd)
1*c7fb772bSthorpej /*	$NetBSD: ixpsip.c,v 1.16 2021/08/07 16:18:44 thorpej Exp $ */
27374c0afSichiro 
37374c0afSichiro /*
47374c0afSichiro  * Copyright (c) 2002
57374c0afSichiro  *	Ichiro FUKUHARA <ichiro@ichiro.org>.
67374c0afSichiro  * All rights reserved.
77374c0afSichiro  *
87374c0afSichiro  * Redistribution and use in source and binary forms, with or without
97374c0afSichiro  * modification, are permitted provided that the following conditions
107374c0afSichiro  * are met:
117374c0afSichiro  * 1. Redistributions of source code must retain the above copyright
127374c0afSichiro  *    notice, this list of conditions and the following disclaimer.
137374c0afSichiro  * 2. Redistributions in binary form must reproduce the above copyright
147374c0afSichiro  *    notice, this list of conditions and the following disclaimer in the
157374c0afSichiro  *    documentation and/or other materials provided with the distribution.
167374c0afSichiro  *
177374c0afSichiro  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
187374c0afSichiro  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
197374c0afSichiro  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
207374c0afSichiro  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
217374c0afSichiro  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
227374c0afSichiro  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
237374c0afSichiro  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
247374c0afSichiro  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
257374c0afSichiro  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
267374c0afSichiro  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
277374c0afSichiro  * SUCH DAMAGE.
287374c0afSichiro  */
297374c0afSichiro 
304691b478Sigy #include <sys/cdefs.h>
31*c7fb772bSthorpej __KERNEL_RCSID(0, "$NetBSD: ixpsip.c,v 1.16 2021/08/07 16:18:44 thorpej Exp $");
324691b478Sigy 
337374c0afSichiro /*
347374c0afSichiro  * Slow peripheral bus of ixp12x0 Processor
357374c0afSichiro  */
367374c0afSichiro 
377374c0afSichiro #include <sys/param.h>
387374c0afSichiro #include <sys/systm.h>
397374c0afSichiro #include <sys/device.h>
407374c0afSichiro 
417374c0afSichiro #include <machine/autoconf.h>
42ed9977b1Sdyoung #include <sys/bus.h>
437374c0afSichiro 
4410876962Sigy #include <arm/ixp12x0/ixp12x0var.h>
457374c0afSichiro #include <arm/ixp12x0/ixpsipvar.h>
467374c0afSichiro 
477374c0afSichiro #include "locators.h"
487374c0afSichiro 
49cbab9cadSchs static int	ixpsip_match(device_t, cfdata_t, void *);
50cbab9cadSchs static void	ixpsip_attach(device_t, device_t, void *);
51cbab9cadSchs static int	ixpsip_search(device_t, cfdata_t, const int *, void *);
527374c0afSichiro static int	ixpsip_print(void *, const char *);
537374c0afSichiro 
54cbab9cadSchs CFATTACH_DECL_NEW(ixpsip, sizeof(struct ixpsip_softc),
55c5e91d44Sthorpej     ixpsip_match, ixpsip_attach, NULL, NULL);
567374c0afSichiro 
577374c0afSichiro int
ixpsip_match(device_t parent,cfdata_t cf,void * aux)58cbab9cadSchs ixpsip_match(device_t parent, cfdata_t cf, void *aux)
597374c0afSichiro {
607374c0afSichiro 	return (1);
617374c0afSichiro }
627374c0afSichiro 
637374c0afSichiro void
ixpsip_attach(device_t parent,device_t self,void * aux)64cbab9cadSchs ixpsip_attach(device_t parent, device_t self, void *aux)
657374c0afSichiro {
66cbab9cadSchs 	struct ixpsip_softc *sc = device_private(self);
6710876962Sigy 	sc->sc_iot = &ixp12x0_bs_tag;
687374c0afSichiro 
697374c0afSichiro 	printf("\n");
707374c0afSichiro 
717374c0afSichiro 	/*
727374c0afSichiro 	 *  Attach each devices
737374c0afSichiro 	 */
742685996bSthorpej 	config_search(self, NULL,
75*c7fb772bSthorpej 	    CFARGS(.search = ixpsip_search));
767374c0afSichiro }
777374c0afSichiro 
787374c0afSichiro int
ixpsip_search(device_t parent,cfdata_t cf,const int * ldesc,void * aux)79cbab9cadSchs ixpsip_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
807374c0afSichiro {
81cbab9cadSchs 	struct ixpsip_softc *sc = device_private(parent);
827374c0afSichiro 	struct ixpsip_attach_args sa;
837374c0afSichiro 
847374c0afSichiro 	sa.sa_iot = sc->sc_iot;
857374c0afSichiro 	sa.sa_addr = cf->cf_loc[IXPSIPCF_ADDR];
867374c0afSichiro 	sa.sa_size = cf->cf_loc[IXPSIPCF_SIZE];
877374c0afSichiro 	sa.sa_intr = cf->cf_loc[IXPSIPCF_INTR];
887374c0afSichiro 
892685996bSthorpej 	if (config_probe(parent, cf, &sa))
90*c7fb772bSthorpej 		config_attach(parent, cf, &sa, ixpsip_print, CFARGS_NONE);
917374c0afSichiro 
927374c0afSichiro 	return (0);
937374c0afSichiro }
947374c0afSichiro 
957374c0afSichiro static int
ixpsip_print(void * aux,const char * name)96454af1c0Sdsl ixpsip_print(void *aux, const char *name)
977374c0afSichiro {
98cbab9cadSchs         struct ixpsip_attach_args *sa = aux;
997374c0afSichiro 
1007374c0afSichiro 	if (sa->sa_size)
101359ed654Sthorpej 		aprint_normal(" addr 0x%lx", sa->sa_addr);
1027374c0afSichiro 	if (sa->sa_size > 1)
103359ed654Sthorpej 		aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
1047374c0afSichiro 	if (sa->sa_intr > 1)
105359ed654Sthorpej 		aprint_normal(" intr %d", sa->sa_intr);
1067374c0afSichiro 
1077374c0afSichiro 	return (UNCONF);
1087374c0afSichiro }
109