1157351Smarcel/*-
2157351Smarcel * Copyright (c) 2006 Marcel Moolenaar
3157351Smarcel * All rights reserved.
4157351Smarcel *
5157351Smarcel * Redistribution and use in source and binary forms, with or without
6157351Smarcel * modification, are permitted provided that the following conditions
7157351Smarcel * are met:
8157351Smarcel *
9157351Smarcel * 1. Redistributions of source code must retain the above copyright
10157351Smarcel *    notice, this list of conditions and the following disclaimer.
11157351Smarcel * 2. Redistributions in binary form must reproduce the above copyright
12157351Smarcel *    notice, this list of conditions and the following disclaimer in the
13157351Smarcel *    documentation and/or other materials provided with the distribution.
14157351Smarcel *
15157351Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16157351Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17157351Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18157351Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19157351Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20157351Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21157351Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22157351Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23157351Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24157351Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25157351Smarcel */
26157351Smarcel
27157351Smarcel#include <sys/cdefs.h>
28157351Smarcel__FBSDID("$FreeBSD: releng/10.2/sys/dev/scc/scc_bfe_macio.c 253900 2013-08-02 23:30:32Z marius $");
29157351Smarcel
30157351Smarcel#include <sys/param.h>
31157351Smarcel#include <sys/systm.h>
32157351Smarcel#include <sys/bus.h>
33157351Smarcel#include <sys/conf.h>
34157351Smarcel#include <sys/kernel.h>
35157351Smarcel#include <sys/module.h>
36157351Smarcel
37157351Smarcel#include <dev/ofw/ofw_bus.h>
38157351Smarcel
39157351Smarcel#include <machine/bus.h>
40157351Smarcel#include <sys/rman.h>
41157351Smarcel#include <machine/resource.h>
42157351Smarcel
43157351Smarcel#include <dev/scc/scc_bfe.h>
44157351Smarcel
45157351Smarcel#define	MACIO_REGSHFT	4
46157351Smarcel#define	MACIO_RCLK	230400
47157351Smarcel
48157351Smarcelstatic int
49157351Smarcelscc_macio_probe(device_t dev)
50157351Smarcel{
51157351Smarcel	struct scc_softc *sc;
52157351Smarcel	const char *nm;
53157351Smarcel
54157351Smarcel	sc = device_get_softc(dev);
55157351Smarcel	nm = ofw_bus_get_name(dev);
56157351Smarcel	if (!strcmp(nm, "escc")) {
57157351Smarcel		device_set_desc(dev, "Zilog Z8530 dual channel SCC");
58157351Smarcel		sc->sc_class = &scc_z8530_class;
59167822Smarcel		return (scc_bfe_probe(dev, MACIO_REGSHFT, MACIO_RCLK, 0));
60157351Smarcel	}
61157351Smarcel	return (ENXIO);
62157351Smarcel}
63157351Smarcel
64178600Smarcelstatic int
65178600Smarcelscc_macio_attach(device_t dev)
66178600Smarcel{
67178600Smarcel
68178600Smarcel	return (scc_bfe_attach(dev, 3));
69178600Smarcel}
70178600Smarcel
71157351Smarcelstatic device_method_t scc_macio_methods[] = {
72157351Smarcel	/* Device interface */
73157351Smarcel	DEVMETHOD(device_probe,		scc_macio_probe),
74178600Smarcel	DEVMETHOD(device_attach,	scc_macio_attach),
75157351Smarcel	DEVMETHOD(device_detach,	scc_bfe_detach),
76157351Smarcel
77157351Smarcel	DEVMETHOD(bus_alloc_resource,	scc_bus_alloc_resource),
78157351Smarcel	DEVMETHOD(bus_release_resource,	scc_bus_release_resource),
79157351Smarcel	DEVMETHOD(bus_get_resource,	scc_bus_get_resource),
80157351Smarcel	DEVMETHOD(bus_read_ivar,	scc_bus_read_ivar),
81157351Smarcel	DEVMETHOD(bus_setup_intr,	scc_bus_setup_intr),
82157351Smarcel	DEVMETHOD(bus_teardown_intr,	scc_bus_teardown_intr),
83227843Smarius
84227843Smarius	DEVMETHOD_END
85157351Smarcel};
86157351Smarcel
87157351Smarcelstatic driver_t scc_macio_driver = {
88157351Smarcel	scc_driver_name,
89157351Smarcel	scc_macio_methods,
90157351Smarcel	sizeof(struct scc_softc),
91157351Smarcel};
92157351Smarcel
93253900SmariusDRIVER_MODULE(scc, macio, scc_macio_driver, scc_devclass, NULL, NULL);
94