Home | History | Annotate | Line # | Download | only in broadcom
bcm53xx_nand.c revision 1.2.10.2
      1  1.2.10.2  tls /*-
      2  1.2.10.2  tls  * Copyright (c) 2012 The NetBSD Foundation, Inc.
      3  1.2.10.2  tls  * All rights reserved.
      4  1.2.10.2  tls  *
      5  1.2.10.2  tls  * This code is derived from software contributed to The NetBSD Foundation
      6  1.2.10.2  tls  * by Matt Thomas of 3am Software Foundry.
      7  1.2.10.2  tls  *
      8  1.2.10.2  tls  * Redistribution and use in source and binary forms, with or without
      9  1.2.10.2  tls  * modification, are permitted provided that the following conditions
     10  1.2.10.2  tls  * are met:
     11  1.2.10.2  tls  * 1. Redistributions of source code must retain the above copyright
     12  1.2.10.2  tls  *    notice, this list of conditions and the following disclaimer.
     13  1.2.10.2  tls  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.2.10.2  tls  *    notice, this list of conditions and the following disclaimer in the
     15  1.2.10.2  tls  *    documentation and/or other materials provided with the distribution.
     16  1.2.10.2  tls  *
     17  1.2.10.2  tls  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     18  1.2.10.2  tls  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     19  1.2.10.2  tls  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     20  1.2.10.2  tls  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     21  1.2.10.2  tls  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     22  1.2.10.2  tls  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     23  1.2.10.2  tls  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  1.2.10.2  tls  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     25  1.2.10.2  tls  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     26  1.2.10.2  tls  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     27  1.2.10.2  tls  * POSSIBILITY OF SUCH DAMAGE.
     28  1.2.10.2  tls  */
     29  1.2.10.2  tls 
     30  1.2.10.2  tls #include "locators.h"
     31  1.2.10.2  tls 
     32  1.2.10.2  tls #include <sys/cdefs.h>
     33  1.2.10.2  tls 
     34  1.2.10.2  tls __KERNEL_RCSID(1, "$NetBSD: bcm53xx_nand.c,v 1.2.10.2 2014/08/20 00:02:45 tls Exp $");
     35  1.2.10.2  tls 
     36  1.2.10.2  tls #include <sys/param.h>
     37  1.2.10.2  tls #include <sys/bus.h>
     38  1.2.10.2  tls #include <sys/device.h>
     39  1.2.10.2  tls #include <sys/intr.h>
     40  1.2.10.2  tls #include <sys/systm.h>
     41  1.2.10.2  tls 
     42  1.2.10.2  tls #define NAND_PRIVATE
     43  1.2.10.2  tls 
     44  1.2.10.2  tls #include <arm/broadcom/bcm53xx_reg.h>
     45  1.2.10.2  tls #include <arm/broadcom/bcm53xx_var.h>
     46  1.2.10.2  tls 
     47  1.2.10.2  tls #include <dev/nand/nand.h>
     48  1.2.10.2  tls #include <dev/nand/onfi.h>
     49  1.2.10.2  tls 
     50  1.2.10.2  tls static int bcmnand_ccb_match(device_t, cfdata_t, void *);
     51  1.2.10.2  tls static void bcmnand_ccb_attach(device_t, device_t, void *);
     52  1.2.10.2  tls 
     53  1.2.10.2  tls struct bcmnand_softc {
     54  1.2.10.2  tls 	device_t sc_dev;
     55  1.2.10.2  tls 	bus_space_tag_t sc_bst;
     56  1.2.10.2  tls 	bus_space_handle_t sc_bsh;
     57  1.2.10.2  tls 	bus_dma_tag_t sc_dmat;
     58  1.2.10.2  tls };
     59  1.2.10.2  tls 
     60  1.2.10.2  tls CFATTACH_DECL_NEW(bcmnand_ccb, sizeof(struct bcmnand_softc),
     61  1.2.10.2  tls 	bcmnand_ccb_match, bcmnand_ccb_attach, NULL, NULL);
     62  1.2.10.2  tls 
     63  1.2.10.2  tls static int
     64  1.2.10.2  tls bcmnand_ccb_match(device_t parent, cfdata_t cf, void *aux)
     65  1.2.10.2  tls {
     66  1.2.10.2  tls 	struct bcmccb_attach_args * const ccbaa = aux;
     67  1.2.10.2  tls 	const struct bcm_locators * const loc = &ccbaa->ccbaa_loc;
     68  1.2.10.2  tls 
     69  1.2.10.2  tls 	if (strcmp(cf->cf_name, loc->loc_name))
     70  1.2.10.2  tls 		return 0;
     71  1.2.10.2  tls 
     72  1.2.10.2  tls 	KASSERT(cf->cf_loc[BCMCCBCF_PORT] == BCMCCBCF_PORT_DEFAULT);
     73  1.2.10.2  tls 
     74  1.2.10.2  tls 	return 1;
     75  1.2.10.2  tls }
     76  1.2.10.2  tls 
     77  1.2.10.2  tls static void
     78  1.2.10.2  tls bcmnand_ccb_attach(device_t parent, device_t self, void *aux)
     79  1.2.10.2  tls {
     80  1.2.10.2  tls 	struct bcmnand_softc * const sc = device_private(self);
     81  1.2.10.2  tls 	struct bcmccb_attach_args * const ccbaa = aux;
     82  1.2.10.2  tls 	const struct bcm_locators * const loc = &ccbaa->ccbaa_loc;
     83  1.2.10.2  tls 
     84  1.2.10.2  tls 	sc->sc_dev = self;
     85  1.2.10.2  tls 
     86  1.2.10.2  tls 	sc->sc_bst = ccbaa->ccbaa_ccb_bst;
     87  1.2.10.2  tls 	sc->sc_dmat = ccbaa->ccbaa_dmat;
     88  1.2.10.2  tls 	bus_space_subregion(sc->sc_bst, ccbaa->ccbaa_ccb_bsh,
     89  1.2.10.2  tls 	    loc->loc_offset, loc->loc_size, &sc->sc_bsh);
     90  1.2.10.2  tls 
     91  1.2.10.2  tls 	aprint_naive("\n");
     92  1.2.10.2  tls 	aprint_normal("\n");
     93  1.2.10.2  tls }
     94