Home | History | Annotate | Line # | Download | only in imx
imx31_aips.c revision 1.2
      1 /*	$Id: imx31_aips.c,v 1.2 2008/04/27 18:58:44 matt Exp $	*/
      2 
      3 /* derived from:	*/
      4 /*	$NetBSD: imx31_aips.c,v 1.2 2008/04/27 18:58:44 matt 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  * 3. All advertising materials mentioning features or use of this software
     58  *    must display the following acknowledgement:
     59  *      This product includes software developed by the NetBSD
     60  *      Foundation, Inc. and its contributors.
     61  * 4. Neither the name of The NetBSD Foundation nor the names of its
     62  *    contributors may be used to endorse or promote products derived
     63  *    from this software without specific prior written permission.
     64  */
     65 /*-
     66  * Copyright (c) 1999
     67  *         Shin Takemura and PocketBSD Project. All rights reserved.
     68  *
     69  * Redistribution and use in source and binary forms, with or without
     70  * modification, are permitted provided that the following conditions
     71  * are met:
     72  * 1. Redistributions of source code must retain the above copyright
     73  *    notice, this list of conditions and the following disclaimer.
     74  * 2. Redistributions in binary form must reproduce the above copyright
     75  *    notice, this list of conditions and the following disclaimer in the
     76  *    documentation and/or other materials provided with the distribution.
     77  * 3. All advertising materials mentioning features or use of this software
     78  *    must display the following acknowledgement:
     79  *	This product includes software developed by the PocketBSD project
     80  *	and its contributors.
     81  * 4. Neither the name of the project nor the names of its contributors
     82  *    may be used to endorse or promote products derived from this software
     83  *    without specific prior written permission.
     84  *
     85  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     86  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     87  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     88  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     89  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     90  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     91  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     92  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     93  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     94  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     95  * SUCH DAMAGE.
     96  *
     97  */
     98 
     99 #include <sys/cdefs.h>
    100 __KERNEL_RCSID(0, "$Id: imx31_aips.c,v 1.2 2008/04/27 18:58:44 matt Exp $");
    101 
    102 #include "locators.h"
    103 
    104 #include <sys/param.h>
    105 #include <sys/systm.h>
    106 #include <sys/device.h>
    107 #include <sys/kernel.h>
    108 #include <sys/reboot.h>
    109 
    110 #include <machine/cpu.h>
    111 #include <machine/bus.h>
    112 
    113 #include <arm/cpufunc.h>
    114 #include <arm/mainbus/mainbus.h>
    115 
    116 #include <machine/intr.h>
    117 
    118 #include <arm/imx/imx31var.h>
    119 #include <arm/imx/imxuartreg.h>
    120 #include <arm/imx/imxuartvar.h>
    121 
    122 struct imxaips_softc {
    123 	struct device sc_dev;
    124 	bus_space_tag_t sc_bust;
    125 };
    126 
    127 /* prototypes */
    128 static int	imxaips_match(device_t , cfdata_t, void *);
    129 static void	imxaips_attach(device_t , device_t , void *);
    130 static int 	imxaips_search(device_t , cfdata_t, const int *, void *);
    131 static int	imxaips_print(void *, const char *);
    132 
    133 /* attach structures */
    134 CFATTACH_DECL(aips, sizeof(struct imxaips_softc),
    135     imxaips_match, imxaips_attach, NULL, NULL);
    136 
    137 static int
    138 imxaips_match(device_t parent, cfdata_t match, void *aux)
    139 {
    140 	return 1;
    141 }
    142 
    143 static void
    144 imxaips_attach(device_t parent, device_t self, void *aux)
    145 {
    146 	struct imxaips_softc * const sc = (struct imxaips_softc *)self;
    147 	struct ahb_attach_args * const ahba = aux;
    148 
    149 	sc->sc_bust = ahba->ahba_memt;
    150 
    151 	aprint_normal(": imx31 AHB-Lite 2.v6 to IP bus interface\n");
    152 
    153 	/*
    154 	 * Attach all other devices
    155 	 */
    156 	config_search_ia(imxaips_search, self, "aips", sc);
    157 }
    158 
    159 static int
    160 imxaips_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
    161 {
    162 	struct imxaips_softc * const sc = aux;
    163 	struct aips_attach_args aipsa;
    164 
    165 	aipsa.aipsa_name = "aisp";
    166 	aipsa.aipsa_memt = sc->sc_bust;
    167 	aipsa.aipsa_addr = cf->cf_loc[AIPSCF_ADDR];
    168 	aipsa.aipsa_size = cf->cf_loc[AIPSCF_SIZE];
    169 	aipsa.aipsa_intr = cf->cf_loc[AIPSCF_INTR];
    170 
    171 	if (config_match(parent, cf, &aipsa))
    172 		config_attach(parent, cf, &aipsa, imxaips_print);
    173 
    174 	return 0;
    175 }
    176 
    177 static int
    178 imxaips_print(void *aux, const char *name)
    179 {
    180 	struct aips_attach_args *aipsa = aux;
    181 
    182 	if (aipsa->aipsa_addr != AIPSCF_ADDR_DEFAULT) {
    183 		aprint_normal(" addr 0x%lx", aipsa->aipsa_addr);
    184 		if (aipsa->aipsa_size > AIPSCF_SIZE_DEFAULT)
    185 			aprint_normal("-0x%lx",
    186 			    aipsa->aipsa_addr + aipsa->aipsa_size-1);
    187 	}
    188 	if (aipsa->aipsa_intr != AIPSCF_INTR_DEFAULT)
    189 		aprint_normal(" intr %d", aipsa->aipsa_intr);
    190 
    191 	return (UNCONF);
    192 }
    193