cfi_bus_nexus.c revision 188089
150397Sobrien/*- 250397Sobrien * Copyright (c) 2009 Roelof Jonkman, Carlson Wireless Inc. 350397Sobrien * Copyright (c) 2009 Sam Leffler, Errno Consulting 450397Sobrien * All rights reserved. 550397Sobrien * 650397Sobrien * Redistribution and use in source and binary forms, with or without 750397Sobrien * modification, are permitted provided that the following conditions 850397Sobrien * are met: 950397Sobrien * 1. Redistributions of source code must retain the above copyright 1050397Sobrien * notice, this list of conditions and the following disclaimer. 1150397Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1250397Sobrien * notice, this list of conditions and the following disclaimer in the 1390075Sobrien * documentation and/or other materials provided with the distribution. 1450397Sobrien * 1550397Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1650397Sobrien * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1750397Sobrien * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1850397Sobrien * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1950397Sobrien * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2050397Sobrien * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2150397Sobrien * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2250397Sobrien * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2350397Sobrien * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2450397Sobrien * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2550397Sobrien */ 2650397Sobrien 2750397Sobrien#include <sys/cdefs.h> 2850397Sobrien__FBSDID("$FreeBSD: head/sys/dev/cfi/cfi_bus_ixp4xx.c 188089 2009-02-03 19:21:15Z sam $"); 2950397Sobrien 3050397Sobrien#include <sys/param.h> 31117395Skan#include <sys/systm.h> 3250397Sobrien#include <sys/bus.h> 3350397Sobrien#include <sys/conf.h> 3450397Sobrien#include <sys/kernel.h> 35132718Skan#include <sys/malloc.h> 36132718Skan#include <sys/module.h> 37132718Skan#include <sys/rman.h> 38132718Skan#include <sys/sysctl.h> 39132718Skan 4050397Sobrien#include <machine/bus.h> 4150397Sobrien 4250397Sobrien#include <dev/cfi/cfi_var.h> 4350397Sobrien 4450397Sobrien#include <arm/xscale/ixp425/ixp425reg.h> 4550397Sobrien#include <arm/xscale/ixp425/ixp425var.h> 4650397Sobrien 4750397Sobrienstatic int 4850397Sobriencfi_ixp4xx_probe(device_t dev) 4950397Sobrien{ 5050397Sobrien struct cfi_softc *sc = device_get_softc(dev); 5150397Sobrien /* 5250397Sobrien * NB: we assume the boot loader sets up EXP_TIMING_CS0_OFFSET 5350397Sobrien * according to the flash on the board. If it does not then it 5450397Sobrien * can be done here. 5550397Sobrien */ 5650397Sobrien if (bootverbose) { 5750397Sobrien struct ixp425_softc *sa = 5850397Sobrien device_get_softc(device_get_parent(dev)); 5950397Sobrien device_printf(dev, "EXP_TIMING_CS0_OFFSET 0x%x\n", 6050397Sobrien EXP_BUS_READ_4(sa, EXP_TIMING_CS0_OFFSET)); 6150397Sobrien } 6250397Sobrien sc->sc_width = 2; /* NB: don't probe interface width */ 6350397Sobrien return cfi_probe(dev); 6450397Sobrien} 6550397Sobrien 6650397Sobrienstatic device_method_t cfi_ixp4xx_methods[] = { 6750397Sobrien /* device interface */ 6850397Sobrien DEVMETHOD(device_probe, cfi_ixp4xx_probe), 6950397Sobrien DEVMETHOD(device_attach, cfi_attach), 7050397Sobrien DEVMETHOD(device_detach, cfi_detach), 7150397Sobrien 7250397Sobrien {0, 0} 7350397Sobrien}; 7450397Sobrien 7550397Sobrienstatic driver_t cfi_ixp4xx_driver = { 7650397Sobrien cfi_driver_name, 7750397Sobrien cfi_ixp4xx_methods, 7850397Sobrien sizeof(struct cfi_softc), 7950397Sobrien}; 8050397SobrienDRIVER_MODULE (cfi, ixp, cfi_ixp4xx_driver, cfi_devclass, 0, 0); 8150397Sobrien