1209908Sraj/*-
2209908Sraj * Copyright (c) 2007, Juniper Networks, Inc.
3209908Sraj * All rights reserved.
4209908Sraj *
5209908Sraj * Redistribution and use in source and binary forms, with or without
6209908Sraj * modification, are permitted provided that the following conditions
7209908Sraj * are met:
8209908Sraj * 1. Redistributions of source code must retain the above copyright
9209908Sraj *    notice, this list of conditions and the following disclaimer.
10209908Sraj * 2. Redistributions in binary form must reproduce the above copyright
11209908Sraj *    notice, this list of conditions and the following disclaimer in the
12209908Sraj *    documentation and/or other materials provided with the distribution.
13209908Sraj * 3. Neither the name of the author nor the names of any co-contributors
14209908Sraj *    may be used to endorse or promote products derived from this software
15209908Sraj *    without specific prior written permission.
16209908Sraj *
17209908Sraj * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18209908Sraj * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19209908Sraj * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20209908Sraj * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21209908Sraj * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22209908Sraj * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23209908Sraj * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24209908Sraj * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25209908Sraj * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26209908Sraj * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27209908Sraj * SUCH DAMAGE.
28209908Sraj */
29209908Sraj
30209908Sraj#include <sys/cdefs.h>
31209908Sraj__FBSDID("$FreeBSD$");
32209908Sraj
33209908Sraj#include <sys/param.h>
34209908Sraj#include <sys/systm.h>
35209908Sraj#include <sys/bus.h>
36209908Sraj#include <sys/conf.h>
37209908Sraj#include <sys/kernel.h>
38209908Sraj#include <sys/module.h>
39209908Sraj
40209908Sraj#include <machine/bus.h>
41209908Sraj
42209908Sraj#include <dev/cfi/cfi_var.h>
43209908Sraj#include <dev/ofw/ofw_bus.h>
44209908Sraj#include <dev/ofw/ofw_bus_subr.h>
45209908Sraj
46209908Srajstatic int cfi_fdt_probe(device_t);
47209908Sraj
48209908Srajstatic device_method_t cfi_fdt_methods[] = {
49209908Sraj	/* device interface */
50209908Sraj	DEVMETHOD(device_probe,		cfi_fdt_probe),
51209908Sraj	DEVMETHOD(device_attach,	cfi_attach),
52209908Sraj	DEVMETHOD(device_detach,	cfi_detach),
53209908Sraj
54209908Sraj	{0, 0}
55209908Sraj};
56209908Sraj
57209908Srajstatic driver_t cfi_fdt_driver = {
58209908Sraj	cfi_driver_name,
59209908Sraj	cfi_fdt_methods,
60209908Sraj	sizeof(struct cfi_softc),
61209908Sraj};
62209908Sraj
63209908SrajDRIVER_MODULE (cfi, lbc, cfi_fdt_driver, cfi_devclass, 0, 0);
64209908Sraj
65209908Srajstatic int
66209908Srajcfi_fdt_probe(device_t dev)
67209908Sraj{
68209908Sraj
69209908Sraj	if (!ofw_bus_is_compatible(dev, "cfi-flash"))
70209908Sraj		return (ENXIO);
71209908Sraj
72209908Sraj	return (cfi_probe(dev));
73209908Sraj}
74