xref: /freebsd/sys/dev/scc/scc_if.m (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1#-
2# Copyright (c) 2004-2006 Marcel Moolenaar
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25#
26# $FreeBSD$
27
28#include <sys/param.h>
29#include <sys/bus.h>
30#include <machine/bus.h>
31#include <sys/lock.h>
32#include <sys/mutex.h>
33#include <sys/rman.h>
34#include <dev/scc/scc_bfe.h>
35
36# The SCC hardware interface. The core SCC code is hardware independent.
37# The details of the hardware are abstracted by the SCC hardware interface.
38
39INTERFACE scc;
40
41# Default implementations of some methods.
42CODE {
43	static int
44	default_enabled(struct scc_softc *this, struct scc_chan *ch)
45	{
46		return (1);
47	}
48}
49
50# attach() - attach hardware.
51# This method is called when the device is being attached. All resources
52# have been allocated. The intend of this method is to setup the hardware
53# for normal operation.
54# The reset parameter informs the hardware driver whether a full device
55# reset is allowed or not. This is important when one of the channels can
56# be used as system console and a hardware reset would disrupt output.
57METHOD int attach {
58	struct scc_softc *this;
59	int reset;
60};
61
62# enabled()
63METHOD int enabled {
64	struct scc_softc *this;
65	struct scc_chan *chan;
66} DEFAULT default_enabled;
67
68# iclear()
69METHOD int iclear {
70	struct scc_softc *this;
71	struct scc_chan *chan;
72};
73
74# ipend() - query SCC for pending interrupts.
75# When an interrupt is signalled, the handler will call this method to find
76# out which of the interrupt sources needs attention. The handler will use
77# this information to dispatch service routines that deal with each of the
78# interrupt sources. An advantage of this approach is that it allows multi-
79# port drivers (like puc(4)) to query multiple devices concurrently and
80# service them on an interrupt priority basis. If the hardware cannot provide
81# the information reliably, it is free to service the interrupt and return 0,
82# meaning that no attention is required.
83METHOD int ipend {
84	struct scc_softc *this;
85}
86
87# probe() - detect hardware.
88# This method is called as part of the bus probe to make sure the
89# hardware exists. This function should also set the device description
90# to something that represents the hardware.
91METHOD int probe {
92	struct scc_softc *this;
93};
94