xref: /freebsd/sys/dev/scc/scc_bfe_macio.c (revision ffc08b2147740cc10894d007ae0ab0c8facbe207)
1ffc08b21SMarcel Moolenaar /*-
2ffc08b21SMarcel Moolenaar  * Copyright (c) 2006 Marcel Moolenaar
3ffc08b21SMarcel Moolenaar  * All rights reserved.
4ffc08b21SMarcel Moolenaar  *
5ffc08b21SMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
6ffc08b21SMarcel Moolenaar  * modification, are permitted provided that the following conditions
7ffc08b21SMarcel Moolenaar  * are met:
8ffc08b21SMarcel Moolenaar  *
9ffc08b21SMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
10ffc08b21SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
11ffc08b21SMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
12ffc08b21SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
13ffc08b21SMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
14ffc08b21SMarcel Moolenaar  *
15ffc08b21SMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16ffc08b21SMarcel Moolenaar  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17ffc08b21SMarcel Moolenaar  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18ffc08b21SMarcel Moolenaar  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19ffc08b21SMarcel Moolenaar  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20ffc08b21SMarcel Moolenaar  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21ffc08b21SMarcel Moolenaar  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22ffc08b21SMarcel Moolenaar  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23ffc08b21SMarcel Moolenaar  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24ffc08b21SMarcel Moolenaar  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25ffc08b21SMarcel Moolenaar  */
26ffc08b21SMarcel Moolenaar 
27ffc08b21SMarcel Moolenaar #include <sys/cdefs.h>
28ffc08b21SMarcel Moolenaar __FBSDID("$FreeBSD$");
29ffc08b21SMarcel Moolenaar 
30ffc08b21SMarcel Moolenaar #include <sys/param.h>
31ffc08b21SMarcel Moolenaar #include <sys/systm.h>
32ffc08b21SMarcel Moolenaar #include <sys/bus.h>
33ffc08b21SMarcel Moolenaar #include <sys/conf.h>
34ffc08b21SMarcel Moolenaar #include <sys/kernel.h>
35ffc08b21SMarcel Moolenaar #include <sys/module.h>
36ffc08b21SMarcel Moolenaar 
37ffc08b21SMarcel Moolenaar #include <dev/ofw/ofw_bus.h>
38ffc08b21SMarcel Moolenaar 
39ffc08b21SMarcel Moolenaar #include <machine/bus.h>
40ffc08b21SMarcel Moolenaar #include <sys/rman.h>
41ffc08b21SMarcel Moolenaar #include <machine/resource.h>
42ffc08b21SMarcel Moolenaar 
43ffc08b21SMarcel Moolenaar #include <dev/scc/scc_bfe.h>
44ffc08b21SMarcel Moolenaar 
45ffc08b21SMarcel Moolenaar #define	MACIO_REGSHFT	4
46ffc08b21SMarcel Moolenaar #define	MACIO_RCLK	230400
47ffc08b21SMarcel Moolenaar 
48ffc08b21SMarcel Moolenaar static int
49ffc08b21SMarcel Moolenaar scc_macio_probe(device_t dev)
50ffc08b21SMarcel Moolenaar {
51ffc08b21SMarcel Moolenaar 	struct scc_softc *sc;
52ffc08b21SMarcel Moolenaar 	const char *nm;
53ffc08b21SMarcel Moolenaar 
54ffc08b21SMarcel Moolenaar 	sc = device_get_softc(dev);
55ffc08b21SMarcel Moolenaar 	nm = ofw_bus_get_name(dev);
56ffc08b21SMarcel Moolenaar 	if (!strcmp(nm, "escc")) {
57ffc08b21SMarcel Moolenaar 		device_set_desc(dev, "Zilog Z8530 dual channel SCC");
58ffc08b21SMarcel Moolenaar 		sc->sc_class = &scc_z8530_class;
59ffc08b21SMarcel Moolenaar 		return (scc_bfe_probe(dev, MACIO_REGSHFT, MACIO_RCLK));
60ffc08b21SMarcel Moolenaar 	}
61ffc08b21SMarcel Moolenaar 	return (ENXIO);
62ffc08b21SMarcel Moolenaar }
63ffc08b21SMarcel Moolenaar 
64ffc08b21SMarcel Moolenaar static device_method_t scc_macio_methods[] = {
65ffc08b21SMarcel Moolenaar 	/* Device interface */
66ffc08b21SMarcel Moolenaar 	DEVMETHOD(device_probe,		scc_macio_probe),
67ffc08b21SMarcel Moolenaar 	DEVMETHOD(device_attach,	scc_bfe_attach),
68ffc08b21SMarcel Moolenaar 	DEVMETHOD(device_detach,	scc_bfe_detach),
69ffc08b21SMarcel Moolenaar 
70ffc08b21SMarcel Moolenaar 	DEVMETHOD(bus_alloc_resource,	scc_bus_alloc_resource),
71ffc08b21SMarcel Moolenaar 	DEVMETHOD(bus_release_resource,	scc_bus_release_resource),
72ffc08b21SMarcel Moolenaar 	DEVMETHOD(bus_get_resource,	scc_bus_get_resource),
73ffc08b21SMarcel Moolenaar 	DEVMETHOD(bus_read_ivar,	scc_bus_read_ivar),
74ffc08b21SMarcel Moolenaar 	DEVMETHOD(bus_setup_intr,	scc_bus_setup_intr),
75ffc08b21SMarcel Moolenaar 	DEVMETHOD(bus_teardown_intr,	scc_bus_teardown_intr),
76ffc08b21SMarcel Moolenaar 	DEVMETHOD(bus_print_child,	bus_generic_print_child),
77ffc08b21SMarcel Moolenaar 	DEVMETHOD(bus_driver_added,	bus_generic_driver_added),
78ffc08b21SMarcel Moolenaar 	{ 0, 0 }
79ffc08b21SMarcel Moolenaar };
80ffc08b21SMarcel Moolenaar 
81ffc08b21SMarcel Moolenaar static driver_t scc_macio_driver = {
82ffc08b21SMarcel Moolenaar 	scc_driver_name,
83ffc08b21SMarcel Moolenaar 	scc_macio_methods,
84ffc08b21SMarcel Moolenaar 	sizeof(struct scc_softc),
85ffc08b21SMarcel Moolenaar };
86ffc08b21SMarcel Moolenaar 
87ffc08b21SMarcel Moolenaar DRIVER_MODULE(scc, macio, scc_macio_driver, scc_devclass, 0, 0);
88