scc_bfe_sbus.c revision 253900
1213237Sgonzo/*-
2213237Sgonzo * Copyright (c) 2004-2006 Marcel Moolenaar
3213237Sgonzo * All rights reserved.
4213237Sgonzo *
5213237Sgonzo * Redistribution and use in source and binary forms, with or without
6213237Sgonzo * modification, are permitted provided that the following conditions
7213237Sgonzo * are met:
8213237Sgonzo *
9213237Sgonzo * 1. Redistributions of source code must retain the above copyright
10213237Sgonzo *    notice, this list of conditions and the following disclaimer.
11213237Sgonzo * 2. Redistributions in binary form must reproduce the above copyright
12213237Sgonzo *    notice, this list of conditions and the following disclaimer in the
13213237Sgonzo *    documentation and/or other materials provided with the distribution.
14213237Sgonzo *
15213277Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16213277Sgonzo * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17213277Sgonzo * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18213277Sgonzo * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19213277Sgonzo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20213277Sgonzo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21213277Sgonzo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22213277Sgonzo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23213277Sgonzo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24213277Sgonzo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25213277Sgonzo */
26213237Sgonzo
27213237Sgonzo#include <sys/cdefs.h>
28213237Sgonzo__FBSDID("$FreeBSD: head/sys/dev/scc/scc_bfe_sbus.c 253900 2013-08-02 23:30:32Z marius $");
29213237Sgonzo
30213237Sgonzo#include <sys/param.h>
31266105Sloos#include <sys/systm.h>
32266105Sloos#include <sys/bus.h>
33213237Sgonzo#include <sys/conf.h>
34213237Sgonzo#include <sys/kernel.h>
35213237Sgonzo#include <sys/module.h>
36213237Sgonzo
37213237Sgonzo#include <dev/ofw/ofw_bus.h>
38213237Sgonzo
39213237Sgonzo#include <machine/bus.h>
40213237Sgonzo#include <sys/rman.h>
41213237Sgonzo#include <machine/resource.h>
42213237Sgonzo
43266105Sloos#include <dev/scc/scc_bfe.h>
44266105Sloos
45266105Sloos#define	SBUS_REGSHFT	1
46266105Sloos#define	SBUS_RCLK	307200
47266105Sloos
48266105Sloosstatic int
49270236Sloosscc_sbus_probe(device_t dev)
50270236Sloos{
51213237Sgonzo	struct scc_softc *sc;
52213237Sgonzo	const char *nm;
53213237Sgonzo
54213237Sgonzo	sc = device_get_softc(dev);
55213237Sgonzo	nm = ofw_bus_get_name(dev);
56228258Sadrian	if (!strcmp(nm, "zs")) {
57228258Sadrian		device_set_desc(dev, "Zilog Z8530 dual channel SCC");
58213237Sgonzo		sc->sc_class = &scc_z8530_class;
59213237Sgonzo		return (scc_bfe_probe(dev, SBUS_REGSHFT, SBUS_RCLK, 0));
60213237Sgonzo	}
61213237Sgonzo	return (ENXIO);
62213237Sgonzo}
63228258Sadrian
64228258Sadrianstatic int
65213237Sgonzoscc_sbus_attach(device_t dev)
66213237Sgonzo{
67213237Sgonzo
68213237Sgonzo	return (scc_bfe_attach(dev, 0));
69213237Sgonzo}
70213237Sgonzo
71213237Sgonzostatic device_method_t scc_sbus_methods[] = {
72213237Sgonzo	/* Device interface */
73213237Sgonzo	DEVMETHOD(device_probe,		scc_sbus_probe),
74213237Sgonzo	DEVMETHOD(device_attach,	scc_sbus_attach),
75213237Sgonzo	DEVMETHOD(device_detach,	scc_bfe_detach),
76213237Sgonzo
77213237Sgonzo	DEVMETHOD(bus_alloc_resource,	scc_bus_alloc_resource),
78213237Sgonzo	DEVMETHOD(bus_release_resource,	scc_bus_release_resource),
79213237Sgonzo	DEVMETHOD(bus_get_resource,	scc_bus_get_resource),
80213237Sgonzo	DEVMETHOD(bus_read_ivar,	scc_bus_read_ivar),
81213237Sgonzo	DEVMETHOD(bus_setup_intr,	scc_bus_setup_intr),
82213237Sgonzo	DEVMETHOD(bus_teardown_intr,	scc_bus_teardown_intr),
83266105Sloos
84266105Sloos	DEVMETHOD_END
85266105Sloos};
86266105Sloos
87213237Sgonzostatic driver_t scc_sbus_driver = {
88266105Sloos	scc_driver_name,
89213237Sgonzo	scc_sbus_methods,
90213237Sgonzo	sizeof(struct scc_softc),
91213237Sgonzo};
92213237Sgonzo
93213237SgonzoDRIVER_MODULE(scc, fhc, scc_sbus_driver, scc_devclass, NULL, NULL);
94213237SgonzoDRIVER_MODULE(scc, sbus, scc_sbus_driver, scc_devclass, NULL, NULL);
95213237Sgonzo