scc_bfe_ebus.c revision 178600
1157299Smarcel/*- 2157299Smarcel * Copyright (c) 2004-2006 Marcel Moolenaar 3157299Smarcel * All rights reserved. 4157299Smarcel * 5157299Smarcel * Redistribution and use in source and binary forms, with or without 6157299Smarcel * modification, are permitted provided that the following conditions 7157299Smarcel * are met: 8157299Smarcel * 9157299Smarcel * 1. Redistributions of source code must retain the above copyright 10157299Smarcel * notice, this list of conditions and the following disclaimer. 11157299Smarcel * 2. Redistributions in binary form must reproduce the above copyright 12157299Smarcel * notice, this list of conditions and the following disclaimer in the 13157299Smarcel * documentation and/or other materials provided with the distribution. 14157299Smarcel * 15157299Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16157299Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17157299Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18157299Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19157299Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20157299Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21157299Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22157299Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23157299Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24157299Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25157299Smarcel */ 26157299Smarcel 27157299Smarcel#include <sys/cdefs.h> 28157299Smarcel__FBSDID("$FreeBSD: head/sys/dev/scc/scc_bfe_ebus.c 178600 2008-04-26 18:40:59Z marcel $"); 29157299Smarcel 30157299Smarcel#include <sys/param.h> 31157299Smarcel#include <sys/systm.h> 32157299Smarcel#include <sys/bus.h> 33157299Smarcel#include <sys/conf.h> 34157299Smarcel#include <sys/kernel.h> 35157299Smarcel#include <sys/module.h> 36157299Smarcel 37157299Smarcel#include <dev/ofw/ofw_bus.h> 38157299Smarcel 39157299Smarcel#include <machine/bus.h> 40157299Smarcel#include <sys/rman.h> 41157299Smarcel#include <machine/resource.h> 42157299Smarcel 43157299Smarcel#include <dev/scc/scc_bfe.h> 44157299Smarcel 45157351Smarcel#define EBUS_REGSHFT 0 46157351Smarcel#define EBUS_RCLK 29491200 47157351Smarcel 48157299Smarcelstatic int 49157299Smarcelscc_ebus_probe(device_t dev) 50157299Smarcel{ 51157299Smarcel struct scc_softc *sc; 52157299Smarcel const char *cmpt, *nm; 53157299Smarcel 54157299Smarcel sc = device_get_softc(dev); 55157299Smarcel nm = ofw_bus_get_name(dev); 56157299Smarcel cmpt = ofw_bus_get_compat(dev); 57157299Smarcel if (cmpt == NULL) 58157299Smarcel cmpt = ""; 59157299Smarcel if (!strcmp(nm, "se") || !strcmp(cmpt, "sab82532")) { 60157299Smarcel device_set_desc(dev, "Siemens SAB 82532 dual channel SCC"); 61157299Smarcel sc->sc_class = &scc_sab82532_class; 62167822Smarcel return (scc_bfe_probe(dev, EBUS_REGSHFT, EBUS_RCLK, 0)); 63157299Smarcel } 64157299Smarcel return (ENXIO); 65157299Smarcel} 66157299Smarcel 67178600Smarcelstatic int 68178600Smarcelscc_ebus_attach(device_t dev) 69178600Smarcel{ 70178600Smarcel 71178600Smarcel return (scc_bfe_attach(dev, 0)); 72178600Smarcel} 73178600Smarcel 74157299Smarcelstatic device_method_t scc_ebus_methods[] = { 75157299Smarcel /* Device interface */ 76157299Smarcel DEVMETHOD(device_probe, scc_ebus_probe), 77178600Smarcel DEVMETHOD(device_attach, scc_ebus_attach), 78157299Smarcel DEVMETHOD(device_detach, scc_bfe_detach), 79157299Smarcel 80157299Smarcel DEVMETHOD(bus_alloc_resource, scc_bus_alloc_resource), 81157299Smarcel DEVMETHOD(bus_release_resource, scc_bus_release_resource), 82157299Smarcel DEVMETHOD(bus_get_resource, scc_bus_get_resource), 83157299Smarcel DEVMETHOD(bus_read_ivar, scc_bus_read_ivar), 84157299Smarcel DEVMETHOD(bus_setup_intr, scc_bus_setup_intr), 85157299Smarcel DEVMETHOD(bus_teardown_intr, scc_bus_teardown_intr), 86157299Smarcel DEVMETHOD(bus_print_child, bus_generic_print_child), 87157299Smarcel DEVMETHOD(bus_driver_added, bus_generic_driver_added), 88157299Smarcel { 0, 0 } 89157299Smarcel}; 90157299Smarcel 91157299Smarcelstatic driver_t scc_ebus_driver = { 92157299Smarcel scc_driver_name, 93157299Smarcel scc_ebus_methods, 94157299Smarcel sizeof(struct scc_softc), 95157299Smarcel}; 96157299Smarcel 97157299SmarcelDRIVER_MODULE(scc, ebus, scc_ebus_driver, scc_devclass, 0, 0); 98