Home | History | Annotate | Line # | Download | only in imx
      1 /*	$Id: imx31_aips.c,v 1.7 2021/08/07 16:18:44 thorpej Exp $	*/
      2 
      3 /* derived from:	*/
      4 /*	$NetBSD: imx31_aips.c,v 1.7 2021/08/07 16:18:44 thorpej Exp $ */
      5 
      6 /*
      7  * Copyright (c) 2002, 2005  Genetec Corporation.  All rights reserved.
      8  * Written by Hiroyuki Bessho for Genetec Corporation.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed for the NetBSD Project by
     21  *	Genetec Corporation.
     22  * 4. The name of Genetec Corporation may not be used to endorse or
     23  *    promote products derived from this software without specific prior
     24  *    written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  *
     38  *
     39  * Autoconfiguration support for the Intel PXA2[15]0 application
     40  * processor. This code is derived from arm/sa11x0/sa11x0.c
     41  */
     42 
     43 /*-
     44  * Copyright (c) 2001, The NetBSD Foundation, Inc.  All rights reserved.
     45  *
     46  * This code is derived from software contributed to The NetBSD Foundation
     47  * by IWAMOTO Toshihiro and Ichiro FUKUHARA.
     48  *
     49  * Redistribution and use in source and binary forms, with or without
     50  * modification, are permitted provided that the following conditions
     51  * are met:
     52  * 1. Redistributions of source code must retain the above copyright
     53  *    notice, this list of conditions and the following disclaimer.
     54  * 2. Redistributions in binary form must reproduce the above copyright
     55  *    notice, this list of conditions and the following disclaimer in the
     56  *    documentation and/or other materials provided with the distribution.
     57  *
     58  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     59  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     60  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     61  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     62  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     63  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     64  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     65  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     66  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     67  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     68  * POSSIBILITY OF SUCH DAMAGE.
     69  */
     70 /*-
     71  * Copyright (c) 1999
     72  *         Shin Takemura and PocketBSD Project. All rights reserved.
     73  *
     74  * Redistribution and use in source and binary forms, with or without
     75  * modification, are permitted provided that the following conditions
     76  * are met:
     77  * 1. Redistributions of source code must retain the above copyright
     78  *    notice, this list of conditions and the following disclaimer.
     79  * 2. Redistributions in binary form must reproduce the above copyright
     80  *    notice, this list of conditions and the following disclaimer in the
     81  *    documentation and/or other materials provided with the distribution.
     82  * 3. All advertising materials mentioning features or use of this software
     83  *    must display the following acknowledgement:
     84  *	This product includes software developed by the PocketBSD project
     85  *	and its contributors.
     86  * 4. Neither the name of the project nor the names of its contributors
     87  *    may be used to endorse or promote products derived from this software
     88  *    without specific prior written permission.
     89  *
     90  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     91  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     92  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     93  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     94  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     95  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     96  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     97  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     98  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     99  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    100  * SUCH DAMAGE.
    101  *
    102  */
    103 
    104 #include <sys/cdefs.h>
    105 __KERNEL_RCSID(0, "$Id: imx31_aips.c,v 1.7 2021/08/07 16:18:44 thorpej Exp $");
    106 
    107 #include "locators.h"
    108 
    109 #include <sys/param.h>
    110 #include <sys/systm.h>
    111 #include <sys/device.h>
    112 #include <sys/kernel.h>
    113 #include <sys/reboot.h>
    114 
    115 #include <machine/cpu.h>
    116 #include <sys/bus.h>
    117 
    118 #include <arm/cpufunc.h>
    119 #include <arm/mainbus/mainbus.h>
    120 
    121 #include <machine/intr.h>
    122 
    123 #include <arm/imx/imx31var.h>
    124 #include <arm/imx/imxuartreg.h>
    125 #include <arm/imx/imxuartvar.h>
    126 
    127 struct imxaips_softc {
    128 	bus_space_tag_t sc_bust;
    129 };
    130 
    131 /* prototypes */
    132 static int	imxaips_match(device_t , cfdata_t, void *);
    133 static void	imxaips_attach(device_t , device_t , void *);
    134 static int 	imxaips_search(device_t , cfdata_t, const int *, void *);
    135 static int	imxaips_print(void *, const char *);
    136 
    137 /* attach structures */
    138 CFATTACH_DECL_NEW(aips, sizeof(struct imxaips_softc),
    139     imxaips_match, imxaips_attach, NULL, NULL);
    140 
    141 static int
    142 imxaips_match(device_t parent, cfdata_t match, void *aux)
    143 {
    144 	return 1;
    145 }
    146 
    147 static void
    148 imxaips_attach(device_t parent, device_t self, void *aux)
    149 {
    150 	struct imxaips_softc * const sc = device_private(self);
    151 	struct ahb_attach_args * const ahba = aux;
    152 
    153 	sc->sc_bust = ahba->ahba_memt;
    154 
    155 	aprint_normal(": imx31 AHB-Lite 2.v6 to IP bus interface\n");
    156 
    157 	/*
    158 	 * Attach all other devices
    159 	 */
    160 	config_search(self, sc,
    161 	    CFARGS(.search = imxaips_search));
    162 }
    163 
    164 static int
    165 imxaips_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
    166 {
    167 	struct imxaips_softc * const sc = aux;
    168 	struct aips_attach_args aipsa;
    169 
    170 	aipsa.aipsa_name = "aisp";
    171 	aipsa.aipsa_memt = sc->sc_bust;
    172 	aipsa.aipsa_addr = cf->cf_loc[AIPSCF_ADDR];
    173 	aipsa.aipsa_size = cf->cf_loc[AIPSCF_SIZE];
    174 	aipsa.aipsa_intr = cf->cf_loc[AIPSCF_INTR];
    175 
    176 	if (config_probe(parent, cf, &aipsa))
    177 		config_attach(parent, cf, &aipsa, imxaips_print, CFARGS_NONE);
    178 
    179 	return 0;
    180 }
    181 
    182 static int
    183 imxaips_print(void *aux, const char *name)
    184 {
    185 	struct aips_attach_args *aipsa = aux;
    186 
    187 	if (aipsa->aipsa_addr != AIPSCF_ADDR_DEFAULT) {
    188 		aprint_normal(" addr 0x%lx", aipsa->aipsa_addr);
    189 		if (aipsa->aipsa_size > AIPSCF_SIZE_DEFAULT)
    190 			aprint_normal("-0x%lx",
    191 			    aipsa->aipsa_addr + aipsa->aipsa_size-1);
    192 	}
    193 	if (aipsa->aipsa_intr != AIPSCF_INTR_DEFAULT)
    194 		aprint_normal(" intr %d", aipsa->aipsa_intr);
    195 
    196 	return (UNCONF);
    197 }
    198