16174e6edSMarcel Moolenaar#- 26174e6edSMarcel Moolenaar# Copyright (c) 2004-2006 Marcel Moolenaar 36174e6edSMarcel Moolenaar# All rights reserved. 46174e6edSMarcel Moolenaar# 56174e6edSMarcel Moolenaar# Redistribution and use in source and binary forms, with or without 66174e6edSMarcel Moolenaar# modification, are permitted provided that the following conditions 76174e6edSMarcel Moolenaar# are met: 86174e6edSMarcel Moolenaar# 96174e6edSMarcel Moolenaar# 1. Redistributions of source code must retain the above copyright 106174e6edSMarcel Moolenaar# notice, this list of conditions and the following disclaimer. 116174e6edSMarcel Moolenaar# 2. Redistributions in binary form must reproduce the above copyright 126174e6edSMarcel Moolenaar# notice, this list of conditions and the following disclaimer in the 136174e6edSMarcel Moolenaar# documentation and/or other materials provided with the distribution. 146174e6edSMarcel Moolenaar# 156174e6edSMarcel Moolenaar# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 166174e6edSMarcel Moolenaar# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 176174e6edSMarcel Moolenaar# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 186174e6edSMarcel Moolenaar# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 196174e6edSMarcel Moolenaar# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 206174e6edSMarcel Moolenaar# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 216174e6edSMarcel Moolenaar# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 226174e6edSMarcel Moolenaar# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 236174e6edSMarcel Moolenaar# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 246174e6edSMarcel Moolenaar# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 256174e6edSMarcel Moolenaar# 266174e6edSMarcel Moolenaar 276174e6edSMarcel Moolenaar#include <sys/param.h> 286174e6edSMarcel Moolenaar#include <sys/bus.h> 296174e6edSMarcel Moolenaar#include <machine/bus.h> 306174e6edSMarcel Moolenaar#include <sys/lock.h> 316174e6edSMarcel Moolenaar#include <sys/mutex.h> 326174e6edSMarcel Moolenaar#include <sys/rman.h> 336174e6edSMarcel Moolenaar#include <dev/scc/scc_bfe.h> 346174e6edSMarcel Moolenaar 356174e6edSMarcel Moolenaar# The SCC hardware interface. The core SCC code is hardware independent. 366174e6edSMarcel Moolenaar# The details of the hardware are abstracted by the SCC hardware interface. 376174e6edSMarcel Moolenaar 386174e6edSMarcel MoolenaarINTERFACE scc; 396174e6edSMarcel Moolenaar 40f1aad6d9SMarcel Moolenaar# Default implementations of some methods. 41f1aad6d9SMarcel MoolenaarCODE { 42f1aad6d9SMarcel Moolenaar static int 43f1aad6d9SMarcel Moolenaar default_enabled(struct scc_softc *this, struct scc_chan *ch) 44f1aad6d9SMarcel Moolenaar { 45f1aad6d9SMarcel Moolenaar return (1); 46f1aad6d9SMarcel Moolenaar } 47f1aad6d9SMarcel Moolenaar} 48f1aad6d9SMarcel Moolenaar 496174e6edSMarcel Moolenaar# attach() - attach hardware. 506174e6edSMarcel Moolenaar# This method is called when the device is being attached. All resources 516174e6edSMarcel Moolenaar# have been allocated. The intend of this method is to setup the hardware 526174e6edSMarcel Moolenaar# for normal operation. 536174e6edSMarcel Moolenaar# The reset parameter informs the hardware driver whether a full device 546174e6edSMarcel Moolenaar# reset is allowed or not. This is important when one of the channels can 556174e6edSMarcel Moolenaar# be used as system console and a hardware reset would disrupt output. 566174e6edSMarcel MoolenaarMETHOD int attach { 576174e6edSMarcel Moolenaar struct scc_softc *this; 586174e6edSMarcel Moolenaar int reset; 596174e6edSMarcel Moolenaar}; 606174e6edSMarcel Moolenaar 61f1aad6d9SMarcel Moolenaar# enabled() 62f1aad6d9SMarcel MoolenaarMETHOD int enabled { 63f1aad6d9SMarcel Moolenaar struct scc_softc *this; 64f1aad6d9SMarcel Moolenaar struct scc_chan *chan; 65f1aad6d9SMarcel Moolenaar} DEFAULT default_enabled; 66f1aad6d9SMarcel Moolenaar 67f1aad6d9SMarcel Moolenaar# iclear() 68005f7c33SWarner LoshMETHOD int iclear { 696174e6edSMarcel Moolenaar struct scc_softc *this; 706174e6edSMarcel Moolenaar struct scc_chan *chan; 716174e6edSMarcel Moolenaar}; 726174e6edSMarcel Moolenaar 736174e6edSMarcel Moolenaar# ipend() - query SCC for pending interrupts. 746174e6edSMarcel Moolenaar# When an interrupt is signalled, the handler will call this method to find 756174e6edSMarcel Moolenaar# out which of the interrupt sources needs attention. The handler will use 766174e6edSMarcel Moolenaar# this information to dispatch service routines that deal with each of the 776174e6edSMarcel Moolenaar# interrupt sources. An advantage of this approach is that it allows multi- 786174e6edSMarcel Moolenaar# port drivers (like puc(4)) to query multiple devices concurrently and 796174e6edSMarcel Moolenaar# service them on an interrupt priority basis. If the hardware cannot provide 806174e6edSMarcel Moolenaar# the information reliably, it is free to service the interrupt and return 0, 816174e6edSMarcel Moolenaar# meaning that no attention is required. 826174e6edSMarcel MoolenaarMETHOD int ipend { 836174e6edSMarcel Moolenaar struct scc_softc *this; 846174e6edSMarcel Moolenaar} 856174e6edSMarcel Moolenaar 866174e6edSMarcel Moolenaar# probe() - detect hardware. 876174e6edSMarcel Moolenaar# This method is called as part of the bus probe to make sure the 886174e6edSMarcel Moolenaar# hardware exists. This function should also set the device description 896174e6edSMarcel Moolenaar# to something that represents the hardware. 906174e6edSMarcel MoolenaarMETHOD int probe { 916174e6edSMarcel Moolenaar struct scc_softc *this; 926174e6edSMarcel Moolenaar}; 93