xref: /freebsd/sys/dev/scc/scc_if.m (revision f1aad6d9b27cce6bf4d49e4b4c1a10188b732737)
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# $FreeBSD$
276174e6edSMarcel Moolenaar
286174e6edSMarcel Moolenaar#include <sys/param.h>
296174e6edSMarcel Moolenaar#include <sys/bus.h>
306174e6edSMarcel Moolenaar#include <machine/bus.h>
316174e6edSMarcel Moolenaar#include <sys/lock.h>
326174e6edSMarcel Moolenaar#include <sys/mutex.h>
336174e6edSMarcel Moolenaar#include <sys/rman.h>
346174e6edSMarcel Moolenaar#include <dev/scc/scc_bfe.h>
356174e6edSMarcel Moolenaar
366174e6edSMarcel Moolenaar# The SCC hardware interface. The core SCC code is hardware independent.
376174e6edSMarcel Moolenaar# The details of the hardware are abstracted by the SCC hardware interface.
386174e6edSMarcel Moolenaar
396174e6edSMarcel MoolenaarINTERFACE scc;
406174e6edSMarcel Moolenaar
41f1aad6d9SMarcel Moolenaar# Default implementations of some methods.
42f1aad6d9SMarcel MoolenaarCODE {
43f1aad6d9SMarcel Moolenaar	static int
44f1aad6d9SMarcel Moolenaar	default_enabled(struct scc_softc *this, struct scc_chan *ch)
45f1aad6d9SMarcel Moolenaar	{
46f1aad6d9SMarcel Moolenaar		return (1);
47f1aad6d9SMarcel Moolenaar	}
48f1aad6d9SMarcel Moolenaar}
49f1aad6d9SMarcel Moolenaar
506174e6edSMarcel Moolenaar# attach() - attach hardware.
516174e6edSMarcel Moolenaar# This method is called when the device is being attached. All resources
526174e6edSMarcel Moolenaar# have been allocated. The intend of this method is to setup the hardware
536174e6edSMarcel Moolenaar# for normal operation.
546174e6edSMarcel Moolenaar# The reset parameter informs the hardware driver whether a full device
556174e6edSMarcel Moolenaar# reset is allowed or not. This is important when one of the channels can
566174e6edSMarcel Moolenaar# be used as system console and a hardware reset would disrupt output.
576174e6edSMarcel MoolenaarMETHOD int attach {
586174e6edSMarcel Moolenaar	struct scc_softc *this;
596174e6edSMarcel Moolenaar	int reset;
606174e6edSMarcel Moolenaar};
616174e6edSMarcel Moolenaar
62f1aad6d9SMarcel Moolenaar# enabled()
63f1aad6d9SMarcel MoolenaarMETHOD int enabled {
64f1aad6d9SMarcel Moolenaar	struct scc_softc *this;
65f1aad6d9SMarcel Moolenaar	struct scc_chan *chan;
66f1aad6d9SMarcel Moolenaar} DEFAULT default_enabled;
67f1aad6d9SMarcel Moolenaar
68f1aad6d9SMarcel Moolenaar# iclear()
696174e6edSMarcel MoolenaarMETHOD void iclear {
706174e6edSMarcel Moolenaar	struct scc_softc *this;
716174e6edSMarcel Moolenaar	struct scc_chan *chan;
726174e6edSMarcel Moolenaar};
736174e6edSMarcel Moolenaar
746174e6edSMarcel Moolenaar# ipend() - query SCC for pending interrupts.
756174e6edSMarcel Moolenaar# When an interrupt is signalled, the handler will call this method to find
766174e6edSMarcel Moolenaar# out which of the interrupt sources needs attention. The handler will use
776174e6edSMarcel Moolenaar# this information to dispatch service routines that deal with each of the
786174e6edSMarcel Moolenaar# interrupt sources. An advantage of this approach is that it allows multi-
796174e6edSMarcel Moolenaar# port drivers (like puc(4)) to query multiple devices concurrently and
806174e6edSMarcel Moolenaar# service them on an interrupt priority basis. If the hardware cannot provide
816174e6edSMarcel Moolenaar# the information reliably, it is free to service the interrupt and return 0,
826174e6edSMarcel Moolenaar# meaning that no attention is required.
836174e6edSMarcel MoolenaarMETHOD int ipend {
846174e6edSMarcel Moolenaar	struct scc_softc *this;
856174e6edSMarcel Moolenaar}
866174e6edSMarcel Moolenaar
876174e6edSMarcel Moolenaar# probe() - detect hardware.
886174e6edSMarcel Moolenaar# This method is called as part of the bus probe to make sure the
896174e6edSMarcel Moolenaar# hardware exists. This function should also set the device description
906174e6edSMarcel Moolenaar# to something that represents the hardware.
916174e6edSMarcel MoolenaarMETHOD int probe {
926174e6edSMarcel Moolenaar	struct scc_softc *this;
936174e6edSMarcel Moolenaar};
94