1188087Ssam/*-
2188089Ssam * Copyright (c) 2009 Roelof Jonkman, Carlson Wireless Inc.
3188087Ssam * Copyright (c) 2009 Sam Leffler, Errno Consulting
4188087Ssam * All rights reserved.
5188087Ssam *
6188087Ssam * Redistribution and use in source and binary forms, with or without
7188087Ssam * modification, are permitted provided that the following conditions
8188087Ssam * are met:
9188087Ssam * 1. Redistributions of source code must retain the above copyright
10188087Ssam *    notice, this list of conditions and the following disclaimer.
11188087Ssam * 2. Redistributions in binary form must reproduce the above copyright
12188087Ssam *    notice, this list of conditions and the following disclaimer in the
13188087Ssam *    documentation and/or other materials provided with the distribution.
14188087Ssam *
15188087Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16188087Ssam * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17188087Ssam * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18188087Ssam * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19188087Ssam * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20188087Ssam * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21188087Ssam * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22188087Ssam * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23188087Ssam * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24188087Ssam * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25188087Ssam */
26188087Ssam
27188087Ssam#include <sys/cdefs.h>
28188087Ssam__FBSDID("$FreeBSD$");
29188087Ssam
30188087Ssam#include <sys/param.h>
31188087Ssam#include <sys/systm.h>
32188087Ssam#include <sys/bus.h>
33188087Ssam#include <sys/conf.h>
34188087Ssam#include <sys/kernel.h>
35188087Ssam#include <sys/malloc.h>
36188087Ssam#include <sys/module.h>
37188087Ssam#include <sys/rman.h>
38188087Ssam#include <sys/sysctl.h>
39188087Ssam
40188087Ssam#include <machine/bus.h>
41188087Ssam
42188087Ssam#include <dev/cfi/cfi_var.h>
43188087Ssam
44188087Ssam#include <arm/xscale/ixp425/ixp425reg.h>
45188087Ssam#include <arm/xscale/ixp425/ixp425var.h>
46188087Ssam
47188087Ssamstatic int
48188087Ssamcfi_ixp4xx_probe(device_t dev)
49188087Ssam{
50188087Ssam	struct cfi_softc *sc = device_get_softc(dev);
51188087Ssam	/*
52188087Ssam	 * NB: we assume the boot loader sets up EXP_TIMING_CS0_OFFSET
53188087Ssam	 * according to the flash on the board.  If it does not then it
54188087Ssam	 * can be done here.
55188087Ssam	 */
56188087Ssam	if (bootverbose) {
57188087Ssam		struct ixp425_softc *sa =
58188087Ssam		    device_get_softc(device_get_parent(dev));
59188087Ssam		device_printf(dev, "EXP_TIMING_CS0_OFFSET 0x%x\n",
60188087Ssam		    EXP_BUS_READ_4(sa, EXP_TIMING_CS0_OFFSET));
61188087Ssam	}
62188087Ssam	sc->sc_width = 2;		/* NB: don't probe interface width */
63188087Ssam	return cfi_probe(dev);
64188087Ssam}
65188087Ssam
66188087Ssamstatic device_method_t cfi_ixp4xx_methods[] = {
67188087Ssam	/* device interface */
68188087Ssam	DEVMETHOD(device_probe,		cfi_ixp4xx_probe),
69188087Ssam	DEVMETHOD(device_attach,	cfi_attach),
70188087Ssam	DEVMETHOD(device_detach,	cfi_detach),
71188087Ssam
72246128Ssbz	DEVMETHOD_END
73188087Ssam};
74188087Ssam
75188087Ssamstatic driver_t cfi_ixp4xx_driver = {
76188087Ssam	cfi_driver_name,
77188087Ssam	cfi_ixp4xx_methods,
78188087Ssam	sizeof(struct cfi_softc),
79188087Ssam};
80188741SsamDRIVER_MODULE(cfi, ixp, cfi_ixp4xx_driver, cfi_devclass, 0, 0);
81