1*c7fb772bSthorpej /* $NetBSD: ixp425_sip.c,v 1.15 2021/08/07 16:18:46 thorpej Exp $ */
200eb02e3Sichiro
300eb02e3Sichiro /*
400eb02e3Sichiro * Copyright (c) 2003
500eb02e3Sichiro * Ichiro FUKUHARA <ichiro@ichiro.org>.
600eb02e3Sichiro * All rights reserved.
700eb02e3Sichiro *
800eb02e3Sichiro * Redistribution and use in source and binary forms, with or without
900eb02e3Sichiro * modification, are permitted provided that the following conditions
1000eb02e3Sichiro * are met:
1100eb02e3Sichiro * 1. Redistributions of source code must retain the above copyright
1200eb02e3Sichiro * notice, this list of conditions and the following disclaimer.
1300eb02e3Sichiro * 2. Redistributions in binary form must reproduce the above copyright
1400eb02e3Sichiro * notice, this list of conditions and the following disclaimer in the
1500eb02e3Sichiro * documentation and/or other materials provided with the distribution.
1600eb02e3Sichiro *
1700eb02e3Sichiro * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
1800eb02e3Sichiro * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1900eb02e3Sichiro * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2000eb02e3Sichiro * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
2100eb02e3Sichiro * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2200eb02e3Sichiro * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2300eb02e3Sichiro * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2400eb02e3Sichiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2500eb02e3Sichiro * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2600eb02e3Sichiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2700eb02e3Sichiro * SUCH DAMAGE.
2800eb02e3Sichiro */
2900eb02e3Sichiro
3000eb02e3Sichiro #include <sys/cdefs.h>
31*c7fb772bSthorpej __KERNEL_RCSID(0, "$NetBSD: ixp425_sip.c,v 1.15 2021/08/07 16:18:46 thorpej Exp $");
3200eb02e3Sichiro
3300eb02e3Sichiro /*
3400eb02e3Sichiro * Slow peripheral bus of IXP425 Processor
3500eb02e3Sichiro */
3600eb02e3Sichiro
3700eb02e3Sichiro #include <sys/param.h>
3800eb02e3Sichiro #include <sys/systm.h>
3900eb02e3Sichiro #include <sys/device.h>
4000eb02e3Sichiro
4100eb02e3Sichiro #include <machine/autoconf.h>
42ed9977b1Sdyoung #include <sys/bus.h>
4300eb02e3Sichiro
44fb2c5211Sscw #include <arm/xscale/ixp425var.h>
4500eb02e3Sichiro #include <arm/xscale/ixp425_sipvar.h>
4600eb02e3Sichiro
4700eb02e3Sichiro #include "locators.h"
4800eb02e3Sichiro
49a2b8c7fbSmsaitoh static int ixpsip_match(device_t, cfdata_t, void *);
50a2b8c7fbSmsaitoh static void ixpsip_attach(device_t, device_t, void *);
51a2b8c7fbSmsaitoh static int ixpsip_search(device_t, cfdata_t, const int *, void *);
5200eb02e3Sichiro static int ixpsip_print(void *, const char *);
5300eb02e3Sichiro
54a2b8c7fbSmsaitoh CFATTACH_DECL_NEW(ixpsip, sizeof(struct ixpsip_softc),
5500eb02e3Sichiro ixpsip_match, ixpsip_attach, NULL, NULL);
5600eb02e3Sichiro
57e9cd0753Sscw struct ixpsip_softc *ixpsip_softc;
5800eb02e3Sichiro
5900eb02e3Sichiro int
ixpsip_match(device_t parent,cfdata_t cf,void * aux)60a2b8c7fbSmsaitoh ixpsip_match(device_t parent, cfdata_t cf, void *aux)
6100eb02e3Sichiro {
6200eb02e3Sichiro return (1);
6300eb02e3Sichiro }
6400eb02e3Sichiro
6500eb02e3Sichiro void
ixpsip_attach(device_t parent,device_t self,void * aux)66a2b8c7fbSmsaitoh ixpsip_attach(device_t parent, device_t self, void *aux)
6700eb02e3Sichiro {
68a2b8c7fbSmsaitoh struct ixpsip_softc *sc = device_private(self);
695801c731Sscw sc->sc_iot = &ixp425_bs_tag;
7000eb02e3Sichiro
71e9cd0753Sscw ixpsip_softc = sc;
72e9cd0753Sscw
7300eb02e3Sichiro printf("\n");
7400eb02e3Sichiro
75e9cd0753Sscw if (bus_space_map(sc->sc_iot, IXP425_EXP_HWBASE, IXP425_EXP_SIZE,
76e9cd0753Sscw 0, &sc->sc_ioh)) {
77e9cd0753Sscw printf("%s: Can't map expansion bus control registers!\n",
78a2b8c7fbSmsaitoh device_xname(self));
79e9cd0753Sscw return;
80e9cd0753Sscw }
81e9cd0753Sscw
8200eb02e3Sichiro /*
8300eb02e3Sichiro * Attach each devices
8400eb02e3Sichiro */
852685996bSthorpej config_search(self, NULL,
86*c7fb772bSthorpej CFARGS(.search = ixpsip_search));
8700eb02e3Sichiro }
8800eb02e3Sichiro
8900eb02e3Sichiro int
ixpsip_search(device_t parent,cfdata_t cf,const int * ldesc,void * aux)90a2b8c7fbSmsaitoh ixpsip_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
9100eb02e3Sichiro {
92a2b8c7fbSmsaitoh struct ixpsip_softc *sc = device_private(parent);
9300eb02e3Sichiro struct ixpsip_attach_args sa;
9400eb02e3Sichiro
9500eb02e3Sichiro sa.sa_iot = sc->sc_iot;
9600eb02e3Sichiro sa.sa_addr = cf->cf_loc[IXPSIPCF_ADDR];
9700eb02e3Sichiro sa.sa_size = cf->cf_loc[IXPSIPCF_SIZE];
984d110df4Sichiro sa.sa_index = cf->cf_loc[IXPSIPCF_INDEX];
9900eb02e3Sichiro sa.sa_intr = cf->cf_loc[IXPSIPCF_INTR];
10000eb02e3Sichiro
1012685996bSthorpej if (config_probe(parent, cf, &sa))
102*c7fb772bSthorpej config_attach(parent, cf, &sa, ixpsip_print, CFARGS_NONE);
10300eb02e3Sichiro
10400eb02e3Sichiro return (0);
10500eb02e3Sichiro }
10600eb02e3Sichiro
10700eb02e3Sichiro static int
ixpsip_print(void * aux,const char * name)108b65e980aSichiro ixpsip_print(void *aux, const char *name)
10900eb02e3Sichiro {
110a2b8c7fbSmsaitoh struct ixpsip_attach_args *sa = aux;
11100eb02e3Sichiro
11200eb02e3Sichiro if (sa->sa_size)
11300eb02e3Sichiro aprint_normal(" addr 0x%lx", sa->sa_addr);
11400eb02e3Sichiro if (sa->sa_size > 1)
11500eb02e3Sichiro aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
1164d110df4Sichiro if (sa->sa_index > 1)
1174d110df4Sichiro aprint_normal(" index %d", sa->sa_index);
11800eb02e3Sichiro if (sa->sa_intr > 1)
11900eb02e3Sichiro aprint_normal(" intr %d", sa->sa_intr);
12000eb02e3Sichiro
12100eb02e3Sichiro return (UNCONF);
12200eb02e3Sichiro }
123