1254721Semaste/*- 2254721Semaste * Copyright (c) 2009 Roelof Jonkman, Carlson Wireless Inc. 3254721Semaste * Copyright (c) 2009 Sam Leffler, Errno Consulting 4254721Semaste * All rights reserved. 5254721Semaste * 6254721Semaste * Redistribution and use in source and binary forms, with or without 7254721Semaste * modification, are permitted provided that the following conditions 8254721Semaste * are met: 9254721Semaste * 1. Redistributions of source code must retain the above copyright 10254721Semaste * notice, this list of conditions and the following disclaimer. 11254721Semaste * 2. Redistributions in binary form must reproduce the above copyright 12254721Semaste * notice, this list of conditions and the following disclaimer in the 13254721Semaste * documentation and/or other materials provided with the distribution. 14254721Semaste * 15254721Semaste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16254721Semaste * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17254721Semaste * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18254721Semaste * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19254721Semaste * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20254721Semaste * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21254721Semaste * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22254721Semaste * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23254721Semaste * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24254721Semaste * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25254721Semaste */ 26254721Semaste 27254721Semaste#include <sys/cdefs.h> 28254721Semaste__FBSDID("$FreeBSD$"); 29254721Semaste 30254721Semaste#include <sys/param.h> 31254721Semaste#include <sys/systm.h> 32254721Semaste#include <sys/bus.h> 33254721Semaste#include <sys/conf.h> 34254721Semaste#include <sys/kernel.h> 35254721Semaste#include <sys/malloc.h> 36254721Semaste#include <sys/module.h> 37254721Semaste#include <sys/rman.h> 38254721Semaste#include <sys/sysctl.h> 39254721Semaste 40254721Semaste#include <machine/bus.h> 41254721Semaste 42254721Semaste#include <dev/cfi/cfi_var.h> 43254721Semaste 44254721Semaste#include <arm/xscale/ixp425/ixp425reg.h> 45254721Semaste#include <arm/xscale/ixp425/ixp425var.h> 46254721Semaste 47254721Semastestatic int 48254721Semastecfi_ixp4xx_probe(device_t dev) 49254721Semaste{ 50254721Semaste struct cfi_softc *sc = device_get_softc(dev); 51254721Semaste /* 52254721Semaste * NB: we assume the boot loader sets up EXP_TIMING_CS0_OFFSET 53254721Semaste * according to the flash on the board. If it does not then it 54254721Semaste * can be done here. 55254721Semaste */ 56254721Semaste if (bootverbose) { 57254721Semaste struct ixp425_softc *sa = 58254721Semaste device_get_softc(device_get_parent(dev)); 59254721Semaste device_printf(dev, "EXP_TIMING_CS0_OFFSET 0x%x\n", 60254721Semaste EXP_BUS_READ_4(sa, EXP_TIMING_CS0_OFFSET)); 61254721Semaste } 62254721Semaste sc->sc_width = 2; /* NB: don't probe interface width */ 63254721Semaste return cfi_probe(dev); 64254721Semaste} 65254721Semaste 66254721Semastestatic device_method_t cfi_ixp4xx_methods[] = { 67254721Semaste /* device interface */ 68254721Semaste DEVMETHOD(device_probe, cfi_ixp4xx_probe), 69254721Semaste DEVMETHOD(device_attach, cfi_attach), 70254721Semaste DEVMETHOD(device_detach, cfi_detach), 71254721Semaste 72254721Semaste DEVMETHOD_END 73254721Semaste}; 74254721Semaste 75254721Semastestatic driver_t cfi_ixp4xx_driver = { 76254721Semaste cfi_driver_name, 77254721Semaste cfi_ixp4xx_methods, 78254721Semaste sizeof(struct cfi_softc), 79254721Semaste}; 80254721SemasteDRIVER_MODULE(cfi, ixp, cfi_ixp4xx_driver, cfi_devclass, 0, 0); 81254721Semaste