1176772Sraj/*- 2176772Sraj * Copyright (c) 2006 Marcel Moolenaar 3176772Sraj * All rights reserved. 4176772Sraj * 5176772Sraj * Redistribution and use in source and binary forms, with or without 6176772Sraj * modification, are permitted provided that the following conditions 7176772Sraj * are met: 8176772Sraj * 9176772Sraj * 1. Redistributions of source code must retain the above copyright 10176772Sraj * notice, this list of conditions and the following disclaimer. 11176772Sraj * 2. Redistributions in binary form must reproduce the above copyright 12176772Sraj * notice, this list of conditions and the following disclaimer in the 13176772Sraj * documentation and/or other materials provided with the distribution. 14176772Sraj * 15176772Sraj * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16176772Sraj * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17176772Sraj * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18176772Sraj * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19176772Sraj * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20176772Sraj * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21176772Sraj * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22176772Sraj * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23176772Sraj * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24176772Sraj * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25176772Sraj */ 26176772Sraj 27176772Sraj#include <sys/cdefs.h> 28176772Sraj__FBSDID("$FreeBSD: releng/10.3/sys/dev/scc/scc_bfe_quicc.c 253900 2013-08-02 23:30:32Z marius $"); 29176772Sraj 30176772Sraj#include <sys/param.h> 31176772Sraj#include <sys/systm.h> 32176772Sraj#include <sys/bus.h> 33176772Sraj#include <sys/conf.h> 34176772Sraj#include <sys/kernel.h> 35176772Sraj#include <sys/module.h> 36176772Sraj 37176772Sraj#include <dev/quicc/quicc_bus.h> 38176772Sraj 39176772Sraj#include <machine/bus.h> 40176772Sraj#include <sys/rman.h> 41176772Sraj#include <machine/resource.h> 42176772Sraj 43176772Sraj#include <dev/scc/scc_bfe.h> 44176772Sraj 45176772Srajstatic int 46176772Srajscc_quicc_probe(device_t dev) 47176772Sraj{ 48176772Sraj device_t parent; 49176772Sraj struct scc_softc *sc; 50176772Sraj uintptr_t devtype, rclk; 51176772Sraj int error; 52176772Sraj 53176772Sraj parent = device_get_parent(dev); 54176772Sraj 55176772Sraj error = BUS_READ_IVAR(parent, dev, QUICC_IVAR_DEVTYPE, &devtype); 56176772Sraj if (error) 57176772Sraj return (error); 58176772Sraj if (devtype != QUICC_DEVTYPE_SCC) 59176772Sraj return (ENXIO); 60176772Sraj 61176772Sraj device_set_desc(dev, "QUICC quad channel SCC"); 62176772Sraj 63176772Sraj sc = device_get_softc(dev); 64176772Sraj sc->sc_class = &scc_quicc_class; 65176772Sraj if (BUS_READ_IVAR(parent, dev, QUICC_IVAR_BRGCLK, &rclk)) 66176772Sraj rclk = 0; 67176772Sraj return (scc_bfe_probe(dev, 0, rclk, 0)); 68176772Sraj} 69176772Sraj 70178600Smarcelstatic int 71178600Smarcelscc_quicc_attach(device_t dev) 72178600Smarcel{ 73178600Smarcel 74178600Smarcel return (scc_bfe_attach(dev, 0)); 75178600Smarcel} 76178600Smarcel 77176772Srajstatic device_method_t scc_quicc_methods[] = { 78176772Sraj /* Device interface */ 79176772Sraj DEVMETHOD(device_probe, scc_quicc_probe), 80178600Smarcel DEVMETHOD(device_attach, scc_quicc_attach), 81176772Sraj DEVMETHOD(device_detach, scc_bfe_detach), 82176772Sraj 83176772Sraj DEVMETHOD(bus_alloc_resource, scc_bus_alloc_resource), 84176772Sraj DEVMETHOD(bus_release_resource, scc_bus_release_resource), 85176772Sraj DEVMETHOD(bus_get_resource, scc_bus_get_resource), 86176772Sraj DEVMETHOD(bus_read_ivar, scc_bus_read_ivar), 87176772Sraj DEVMETHOD(bus_setup_intr, scc_bus_setup_intr), 88176772Sraj DEVMETHOD(bus_teardown_intr, scc_bus_teardown_intr), 89227843Smarius 90227843Smarius DEVMETHOD_END 91176772Sraj}; 92176772Sraj 93176772Srajstatic driver_t scc_quicc_driver = { 94176772Sraj scc_driver_name, 95176772Sraj scc_quicc_methods, 96176772Sraj sizeof(struct scc_softc), 97176772Sraj}; 98176772Sraj 99253900SmariusDRIVER_MODULE(scc, quicc, scc_quicc_driver, scc_devclass, NULL, NULL); 100