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# $FreeBSD$ 27157299Smarcel 28157299Smarcel#include <sys/param.h> 29157299Smarcel#include <sys/bus.h> 30157299Smarcel#include <machine/bus.h> 31157299Smarcel#include <sys/lock.h> 32157299Smarcel#include <sys/mutex.h> 33157299Smarcel#include <sys/rman.h> 34157299Smarcel#include <dev/scc/scc_bfe.h> 35157299Smarcel 36157299Smarcel# The SCC hardware interface. The core SCC code is hardware independent. 37157299Smarcel# The details of the hardware are abstracted by the SCC hardware interface. 38157299Smarcel 39157299SmarcelINTERFACE scc; 40157299Smarcel 41167996Smarcel# Default implementations of some methods. 42167996SmarcelCODE { 43167996Smarcel static int 44167996Smarcel default_enabled(struct scc_softc *this, struct scc_chan *ch) 45167996Smarcel { 46167996Smarcel return (1); 47167996Smarcel } 48167996Smarcel} 49167996Smarcel 50157299Smarcel# attach() - attach hardware. 51157299Smarcel# This method is called when the device is being attached. All resources 52157299Smarcel# have been allocated. The intend of this method is to setup the hardware 53157299Smarcel# for normal operation. 54157299Smarcel# The reset parameter informs the hardware driver whether a full device 55157299Smarcel# reset is allowed or not. This is important when one of the channels can 56157299Smarcel# be used as system console and a hardware reset would disrupt output. 57157299SmarcelMETHOD int attach { 58157299Smarcel struct scc_softc *this; 59157299Smarcel int reset; 60157299Smarcel}; 61157299Smarcel 62167996Smarcel# enabled() 63167996SmarcelMETHOD int enabled { 64167996Smarcel struct scc_softc *this; 65167996Smarcel struct scc_chan *chan; 66167996Smarcel} DEFAULT default_enabled; 67167996Smarcel 68167996Smarcel# iclear() 69188174SimpMETHOD int iclear { 70157299Smarcel struct scc_softc *this; 71157299Smarcel struct scc_chan *chan; 72157299Smarcel}; 73157299Smarcel 74157299Smarcel# ipend() - query SCC for pending interrupts. 75157299Smarcel# When an interrupt is signalled, the handler will call this method to find 76157299Smarcel# out which of the interrupt sources needs attention. The handler will use 77157299Smarcel# this information to dispatch service routines that deal with each of the 78157299Smarcel# interrupt sources. An advantage of this approach is that it allows multi- 79157299Smarcel# port drivers (like puc(4)) to query multiple devices concurrently and 80157299Smarcel# service them on an interrupt priority basis. If the hardware cannot provide 81157299Smarcel# the information reliably, it is free to service the interrupt and return 0, 82157299Smarcel# meaning that no attention is required. 83157299SmarcelMETHOD int ipend { 84157299Smarcel struct scc_softc *this; 85157299Smarcel} 86157299Smarcel 87157299Smarcel# probe() - detect hardware. 88157299Smarcel# This method is called as part of the bus probe to make sure the 89157299Smarcel# hardware exists. This function should also set the device description 90157299Smarcel# to something that represents the hardware. 91157299SmarcelMETHOD int probe { 92157299Smarcel struct scc_softc *this; 93157299Smarcel}; 94