scc_bfe_ebus.c revision 253900
126497Sache/*-
226497Sache * Copyright (c) 2004-2006 Marcel Moolenaar
326497Sache * All rights reserved.
426497Sache *
526497Sache * Redistribution and use in source and binary forms, with or without
626497Sache * modification, are permitted provided that the following conditions
726497Sache * are met:
8157184Sache *
926497Sache * 1. Redistributions of source code must retain the above copyright
10157184Sache *    notice, this list of conditions and the following disclaimer.
11157184Sache * 2. Redistributions in binary form must reproduce the above copyright
12157184Sache *    notice, this list of conditions and the following disclaimer in the
13157184Sache *    documentation and/or other materials provided with the distribution.
14157184Sache *
15157184Sache * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16157184Sache * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17157184Sache * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18157184Sache * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19157184Sache * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20157184Sache * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21157184Sache * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22157184Sache * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23157184Sache * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24157184Sache * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25157184Sache */
26157184Sache
27157184Sache#include <sys/cdefs.h>
28157184Sache__FBSDID("$FreeBSD: head/sys/dev/scc/scc_bfe_ebus.c 253900 2013-08-02 23:30:32Z marius $");
2926497Sache
30119610Sache#include <sys/param.h>
3126497Sache#include <sys/systm.h>
32119610Sache#include <sys/bus.h>
3326497Sache#include <sys/conf.h>
34119610Sache#include <sys/kernel.h>
3526497Sache#include <sys/module.h>
36119610Sache
37157184Sache#include <dev/ofw/ofw_bus.h>
38119610Sache
3926497Sache#include <machine/bus.h>
4026497Sache#include <sys/rman.h>
4135486Sache#include <machine/resource.h>
4235486Sache
43157184Sache#include <dev/scc/scc_bfe.h>
4435486Sache
4535486Sache#define	EBUS_REGSHFT	0
46119610Sache#define	EBUS_RCLK	29491200
47157184Sache
4835486Sachestatic int
4935486Sachescc_ebus_probe(device_t dev)
5035486Sache{
5135486Sache	struct scc_softc *sc;
5235486Sache	const char *cmpt, *nm;
53157184Sache
54157184Sache	sc = device_get_softc(dev);
55157184Sache	nm = ofw_bus_get_name(dev);
56157184Sache	cmpt = ofw_bus_get_compat(dev);
57157184Sache	if (cmpt == NULL)
58157184Sache		cmpt = "";
59119610Sache	if (!strcmp(nm, "se") || !strcmp(nm, "FJSV,se") ||
60136644Sache	    !strcmp(cmpt, "sab82532")) {
61119610Sache		device_set_desc(dev, "Siemens SAB 82532 dual channel SCC");
62119610Sache		sc->sc_class = &scc_sab82532_class;
63119610Sache		return (scc_bfe_probe(dev, EBUS_REGSHFT, EBUS_RCLK, 0));
64136644Sache	}
65119610Sache	return (ENXIO);
66119610Sache}
67119610Sache
68136644Sachestatic int
69136644Sachescc_ebus_attach(device_t dev)
70136644Sache{
71136644Sache
72157184Sache	return (scc_bfe_attach(dev, 0));
73157184Sache}
74157184Sache
75157184Sachestatic device_method_t scc_ebus_methods[] = {
76157184Sache	/* Device interface */
77157184Sache	DEVMETHOD(device_probe,		scc_ebus_probe),
78157184Sache	DEVMETHOD(device_attach,	scc_ebus_attach),
79157184Sache	DEVMETHOD(device_detach,	scc_bfe_detach),
80157184Sache
81157184Sache	DEVMETHOD(bus_alloc_resource,	scc_bus_alloc_resource),
82157184Sache	DEVMETHOD(bus_release_resource,	scc_bus_release_resource),
83157184Sache	DEVMETHOD(bus_get_resource,	scc_bus_get_resource),
84157184Sache	DEVMETHOD(bus_read_ivar,	scc_bus_read_ivar),
85157184Sache	DEVMETHOD(bus_setup_intr,	scc_bus_setup_intr),
86157184Sache	DEVMETHOD(bus_teardown_intr,	scc_bus_teardown_intr),
87157184Sache
88157184Sache	DEVMETHOD_END
89157184Sache};
90157184Sache
91157184Sachestatic driver_t scc_ebus_driver = {
92157184Sache	scc_driver_name,
93157184Sache	scc_ebus_methods,
94157184Sache	sizeof(struct scc_softc),
95157184Sache};
96157184Sache
97157184SacheDRIVER_MODULE(scc, ebus, scc_ebus_driver, scc_devclass, NULL, NULL);
98157184Sache