This is a driver for the physical layer chips used in ATM interfaces.

It currently supports the PMC Sierra Lite, Ultra and 622 chips and
the IDT 77105. The driver handles media options and state in a consistent
manner for ATM drivers. The next commit to the midway driver will make
it use utopia.
This commit is contained in:
Hartmut Brandt 2003-06-12 14:28:32 +00:00
parent 74155a4873
commit 591f4054cb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116258
13 changed files with 3345 additions and 2 deletions

View File

@ -30,6 +30,8 @@
..
usb
..
utopia
..
wi
..
..

View File

@ -32,7 +32,7 @@ LDIRS= cam geom net netatalk netatm netgraph netinet netinet6 netipsec \
pccard posix4 sys vm
LSUBDIRS= cam/scsi dev/an dev/ic dev/iicbus dev/firewire dev/ofw \
dev/ppbus dev/smbus dev/usb dev/wi fs/devfs \
dev/ppbus dev/smbus dev/usb dev/wi dev/utopia fs/devfs \
fs/fdescfs fs/fifofs fs/msdosfs fs/ntfs fs/nullfs fs/nwfs fs/portalfs \
fs/procfs fs/smbfs fs/umapfs fs/unionfs isofs/cd9660 \
netatm/ipatm netatm/sigpvc netatm/spans netatm/uni \

View File

@ -256,6 +256,7 @@ MAN= aac.4 \
urio.4 \
usb.4 \
uscanner.4 \
utopia.4 \
uvisor.4 \
uvscom.4 \
vga.4 \

131
share/man/man4/utopia.4 Normal file
View File

@ -0,0 +1,131 @@
.\" Copyright (c) 2003
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" Author: Hartmut Brandt <harti@freebsd.org>
.\"
.\" $FreeBSD$
.Dd May 8, 2003
.Dt UTOPIA 4
.Os FreeBSD
.Sh NAME
.Nm utopia
.Nd Driver module for ATM PHY chips
.Sh SYNOPSIS
.Cd device utopia
.Sh DESCRIPTION
This module is used by all ATM drivers for cards that use S/Uni and IDT77105
chips to provide uniform functionality.
The module implements status monitoring
in either interrupt or polling mode, media option handling and application
access to chip registers.
.Pp
The driver implements several sysctls that accessible under the
.Cm hw.atm.XXX
tree, where
.Cm XXX
is the name of the ATM interface:
.Bl -tag -width XXX
.It Cm phy_regs
When reading this sysctl an array of 8-bit unsigned integers is returned
containing all accessible chip registers starting at register 0.
A register can be written by writing three 8-bit unsigned integers to the
sysctl: the register number, the new value and a bit mask.
This changes all bits in the register for which the corresponding bit in the
mask is one to the bit values from value.
Note, that not all registers may
be writeable.
.It Cm phy_loopback
allows to put the interface in one of several loopback modes.
Not all modes and all combinations of modes are supported on all chips.
The possible modes are:
.Bl -tag -width XXX
.It Dv UTP_LOOP_NONE (0x00)
No loopback, normal operation.
.It Dv UTP_LOOP_TIME (0x01)
Timing source loopback. When this is set the transmitter's clock is
derived from the receiver's clock.
.It Dv UTP_LOOP_DIAG (0x02)
Diagnostic loopback. In this mode the receiver's input is connected to the
transmitter's output. The receiver gets back everything that is sent. The
transmitter operates normally.
.It Dv UTP_LOOP_LINE (0x04)
Serial line loopback. This connects the line receiver to the line transmitter.
The chip transmits all cells back that it receives. The receiver operates
normally.
.It Dv UTP_LOOP_PARAL (0x08)
Parallel diagnostic loopback. This feeds back all transmitted cells into the
receiver between the parallel/serial converters. The transmitter
operates normally.
.It Dv UTP_LOOP_TWIST (0x10)
Twisted pair diagnostic loopback. Connects the high speed receive data to the
high speed transmit data. All received data is sent back. The receiver
operates normally.
.It Dv UTP_LOOP_PATH (0x20)
Diagnostic path loopback. This connectes the receiver input to the transmitter
output just between the path overhead processor and the byte mux. The
transmitter operates normally.
.El
.It Cm phy_type
This is the detected type of the phy chip. Currently the following chips are
supported:
.Bl -tag -width XXX
.It Dv UTP_TYPE_UNKNOWN (0)
The module could not determine the type of the PHY chip.
.It Dv UTP_TYPE_SUNI_LITE (1)
PMC-5346 (S/Uni-Lite)
.It Dv UTP_TYPE_SUNI_ULTRA (2)
PMC-5350 (S/Uni-Ultra)
.It Dv UTP_TYPE_SUNI_622 (3)
PMC-5355 (S/Uni-622)
.It Dv UTP_TYPE_IDT77105 (4)
IDT77105 (25.6MBit UTP interface)
.El
.It Cm phy_name
This is a string describing the type of the PHY chip.
.El
.Pp
The
.Nm
module also interfaces with the ifmedia system.
The module reports the current state of the carrier and will issue a
warning message when the carrier state changes.
While the physical media itself cannot be changed, several media options can:
.Bl -tag -width XXX
.It Cm SDH
If the PHY is a S/Uni this flag switches the interface into SDH mode.
If this option is not set (the default) the interface is in Sonet mode.
.It Cm noscramb
If the PHY is a S/Uni disable scrambling.
This may be useful for debugging purposes.
.It Cm unassigned
Normally the interface emits idle cells when there are no other cells to
transmit. This changes the default cell type to unassigned cells. This
may be needed for interworking with public networks. Works only for S/Unis.
.El
.Sh SEE ALSO
.Xr en 4,
.Xr utopia 9
.Sh AUTHOR
.An Harti Brandt Aq harti@freebsd.org .

View File

@ -189,6 +189,10 @@ see
.Xr ppbus 4
.It Pa usb/
The USB subsystem
.It Pa utopia/
Physical chip driver for ATM interfaces;
see
.Xr utopia 4
.It Pa wi/
The
.Xr wi 4

View File

@ -66,7 +66,7 @@ MAN= BUF_LOCK.9 BUF_LOCKFREE.9 BUF_LOCKINIT.9 BUF_REFCNT.9 \
spl.9 store.9 style.9 suser.9 swi.9 sx.9 \
sysctl_add_oid.9 sysctl_ctx_init.9 \
taskqueue.9 thread_exit.9 time.9 timeout.9 tvtohz.9 \
ucred.9 uidinfo.9 uio.9 \
ucred.9 uidinfo.9 uio.9 utopia.9 \
vaccess.9 vaccess_acl_posix1e.9 vcount.9 \
vfs_busy.9 vfs_getnewfsid.9 vfs_getvfs.9 \
vfs_mount.9 vfs_mountedon.9 vfs_rootmountalloc.9 \

305
share/man/man9/utopia.9 Normal file
View File

@ -0,0 +1,305 @@
.\" Copyright (c) 2003
.\" Fraunhofer Institute for Open Communication Systems (FhG Fokus).
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" Author: Hartmut Brandt <harti@freebsd.org>
.\"
.\" $FreeBSD$
.Dd May 8, 2003
.Dt UTOPIA 9
.Os FreeBSD
.Sh NAME
.Nm utopia
.Nd Driver module for ATM PHY chips
.Sh SYNOPSIS
.In dev/utopia/utopia.h
.Ft int
.Fn utopia_attach "struct utopia *utp" "struct ifatm *ifatm" "struct ifmedia *media" "struct mtx *lock" "struct sysctl_ctx_list *ctx" "struct sysctl_oid_list *tree" "const struct utopia_methods *vtab"
.Ft void
.Fn utopia_detach "struct utopia *utp"
.Ft int
.Fn utopia_start "struct utopia *utp"
.Ft void
.Fn utopia_stop "struct utopia *utp"
.Ft void
.Fn utopia_init_media "struct utopia *utp"
.Ft void
.Fn utopia_reset_media "struct utopia *utp"
.Ft int
.Fn utopia_reset "struct utopia *utp"
.Ft int
.Fn utopia_set_sdh "struct utopia *utp" "int sdh"
.Ft int
.Fn utopia_set_unass "struct utopia *utp" "int unass"
.Ft int
.Fn utopia_set_noscramb "struct utopia *utp" "int noscramb"
.Ft int
.Fn utopia_update_carrier "struct utopia *utp"
.Ft int
.Fn utopia_set_loopback "struct utopia *utp" "u_int mode"
.Ft void
.Fn utopia_intr "struct utopia *utp"
.Sh DESCRIPTION
This module is used by all ATM drivers for cards that use a number of known
PHY chips to provide uniform functionality.
The module implements status monitoring in either interrupt or polling mode,
media option handling and application access to PHY registers.
.Pp
To use this interface a driver must implement two functions for reading and
writing PHY registers and initialize the following structure with pointers
to these functions:
.Bd -literal -offset indent
struct utopia_methods {
int (*readregs)(struct ifatm *, u_int reg,
uint8_t *val, u_int *n);
int (*writereg)(struct ifatm *, u_int reg,
u_int mask, u_int val);
};
.Ed
.Pp
The
.Fn readregs
function should read PHY registers starting at register
.Fa reg .
The maximum number of registers to read is given by the integer pointed
to by
.Fa n .
The function should either return 0 on success or an error code.
In the first case
.Fa *n
should be set to the actual number of registers red.
The
.Fn writereg
function should write one register.
It must change all bits for which the corresponding bit in
.Fa mask
is 1 to the value of the corresponding bit in
.Fa val .
It returns either 0 on success or an error code.
.Pp
The ATM driver's private state block (softc) must begin with a
.Vt "struct ifatm" .
.Pp
The
.Vt "struct utopia"
holds the current state of the PHY chip and contains the following fields:
.Bd -literal -offset indent
struct utopia {
struct ifatm *ifatm; /* driver data */
struct ifmedia *media; /* driver supplied */
struct mtx *lock; /* driver supplied */
const struct utopia_methods *methods;
LIST_ENTRY(utopia) link; /* list of these structures */
u_int flags; /* flags set by the driver */
u_int state; /* current state */
u_int carrier; /* carrier state */
u_int loopback; /* loopback mode */
const struct utopia_chip *chip; /* chip operations */
};
.Ed
The public accessible fields have the following functions:
.Bl -tag -width XXX
.It Va ifatm
Pointer to the driver's private data (softc).
.It Va media
Pointer to the driver's media structure.
.Ir Va lock
Pointer to a mutex provided by the driver. This mutex is used to synchronize
with the kernel thread that handles device polling. It is locked in several
places:
.Bl -enum -offset indent
.It
In
.Fn utopia_detach
the mutex is locked to sleep and wait for the kernel thread to remove the
.Vt "struct utopia"
from the list of all utopia devices.
Before returning to the caller the mutex is unlocked.
.It
In the
.Nm
kernel thread the mutex is locked and the
.Fn utopia_carrier_update
function is called with this mutex locked.
This will result in the driver's
.Fn readregs
function beeing called with the mutex locked.
.It
In the sysctl handlers the mutex will be locked before calling into the driver's
.Fn readreg
or
.Fn writereg
functions.
.El
.It Va flags
Flags set by either the driver or the utopia module. The following flags are
defined:
.Bl -tag -width XXX
.It Dv UTP_FL_NORESET
If this flag is set the module will not try to write the
SUNI master reset register. (set by the driver)
.It Dv UTP_FL_POLL_CARRIER
If this flag is set the module will periodically poll the carrier state
(as opposed to interrupt driven carrier state changes). (set by the driver)
.El
.It Va state
Flags describing the current state of the phy chip. These are managed
by the module:
.Bl -tag -width XXX
.It Dv UTP_ST_ACTIVE
The driver is active and the phy registers can be accessed.
This is set by calling
.Fn utopia_start ,
which should be called either in the attach routine of the driver or
in the network interface initialisation routine (depending on whether the
registers are accessible all the time or only when the interface is up).
.It Dv UTP_ST_SDH
Interface is in SDH mode as opposed to SONET mode.
.It Dv UTP_ST_UNASS
Interface is producing unassigned cells instead of idle cells.
.It Dv UTP_ST_NOSCRAMB
Cell scrambling is switched off.
.It Dv UTP_ST_DETACH
(internal use) interface is currently detaching.
.It Dv UTP_ST_ATTACHED
The attach routine has been run successfully.
.El
.It Va carrier
The carrier state of the interface. This field can have one of three values:
.Bl -tag -width XXX
.It Dv UTP_CARR_UNKNOWN
Carrier state is still unknown.
.It Dv UTP_CARR_OK
Carrier has been detected.
.It Dv UTP_CARR_LOST
Carrier has been lost.
.El
.It Va loopback
This is the current loopback mode of the interface. Note, that not all
chips support all loopback modes. Refer to the chip documentation. The
following modes may be supported:
.Bl -tag -width XXX
.It Dv UTP_LOOP_NONE
No loopback, normal operation.
.It Dv UTP_LOOP_TIME
Timing source loopback. The transmitter clock is driven by the receive clock.
.It Dv UTP_LOOP_DIAG
Diagnostic loopback.
.It Dv UTP_LOOP_LINE
Serial line loopback.
.It Dv UTP_LOOP_PARAL
Parallel diagnostic loopback.
.It Dv UTP_LOOP_TWIST
Twisted pair diagnostic loopback.
.It Dv UTP_LOOP_PATH
Diagnostic path loopback.
.El
.It Va chip
This points the a function vector for chip specific functions. Two fields
in this vector a publically available:
.Bl -tag -width XXX
.It Va type
This is the type of the detected PHY chip.
One of:
.Bl -tag -width XXX
.It Dv UTP_TYPE_UNKNOWN (0)
.It Dv UTP_TYPE_SUNI_LITE (1)
.It Dv UTP_TYPE_SUNI_ULTRA (2)
.It Dv UTP_TYPE_SUNI_622 (3)
.It Dv UTP_TYPE_IDT77105 (4)
.El
.It Va name
This is a string with the name of the PHY chip.
.El
.El
.Pp
The following functions are used by the driver during attach/detach and/or
initialisation/stopping the interface:
.Bl -tag -width XXX
.It Fn utopia_attach
Attach the PHY chip. This is called with a preallocated
.Vt "struct utopia"
(which may be part of the driver's softc).
The module initializes all fields of the utopia state and the media field.
User settable flags should be set after the call to
.Fn utopia_attach .
This function may fail due to the inability to install the sysctl handlers.
In this case it will return -1.
On success 0 is returned and the
.Dv UTP_ST_ATTACHED
flag is set.
.It Fn utopia_detach
Remove the utopia attachment from the system. This cancels all outstanding polling
timeouts.
.It Fn utopia_start
Start operation of that PHY. This should be called at a time
when the PHY registers are known to be accessible. This may be either in
the driver's attach function or when the interface is set running.
.It Fn utopia_stop
Stop operation of the PHY attachment. This may be called either in the detach
function of the driver or when the interface is brought down.
.It Fn utopia_init_media
This must be called if the media field in the ATM MIB was changed. The function
makes sure, that the ifmedia fields contain the same information as the
ATM MIB.
.It Fn utopia_reset_media
This may be called to remove all media information from the ifmedia field.
.El
.Pp
The following functions can be used to modify the PHY state while the interface
is running:
.Bl -tag -width XXX
.It Fn utopia_reset
Reset the operational parameters to the default state (SONET, idle cells,
scrambling enabled). Returns 0 on success, an error code otherwise leaving
the state undefined.
.It Fn utopia_set_sdh
If the argument is zero the chip is switched to Sonet mode, if it is non-zero
the chip is switched to SDH mode. Returns 0 on success, an error code otherwise
leaving the previous state.
.It Fn utopia_set_unass
If the argument is zero the chip is switched to produce idle cells, if it is
non-zero the chip is switched to produce unassigned cells. Returns 0 on success,
an error code otherwise leaving the previous state.
.It Fn utopia_set_noscramb
If the argument is zero enables scrambling, if it is
non-zero disables scrambling. Returns 0 on success,
an error code otherwise leaving the previous state.
.It Fn utopia_update_carrier
Check the carrier state and update the carrier field in the state structure.
This will generate a message to the netgraph stack if the carrier state changes.
For chips that are polled this is called automatically, for interrupt
driven attachments this must be called on interrupts from the PHY chip.
.It Fn utopia_set_loopback
Set the loopback mode of the chip. Returns 0 on success, an error code
otherwise leaving the previous state.
.It Fn utopia_intr
Called when an interrupt from the PHY chip is detected. This resets the
interrupt state by reading all registers and, if the interrupt was from the
RSOP, checks the carrier state.
.El
.Sh SEE ALSO
.Xr utopia 4
.Sh AUTHOR
.An Harti Brandt Aq harti@freebsd.org .

119
sys/dev/utopia/idtphy.h Normal file
View File

@ -0,0 +1,119 @@
/*
* Copyright (c) 2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $FreeBSD$
*
* Register definitions for the following chips:
* IDT 77105
*/
#ifndef _DEV_UTOPIA_IDTPHY_H
#define _DEV_UTOPIA_IDTPHY_H
#define IDTPHY_REGO_MCR 0x00
#define IDTPHY_REGN_MCR "Master Control Register"
#define IDTPHY_REGX_MCR "\020\010UPLO\7DREC\6ECEI\5TDPC\4DRIC\3HALTTX\2BYTEM\1EI"
#define IDTPHY_REGM_MCR_UPL0 0x80
#define IDTPHY_REGM_MCR_DREC 0x40
#define IDTPHY_REGM_MCR_ECEI 0x20
#define IDTPHY_REGM_MCR_TDPC 0x10
#define IDTPHY_REGM_MCR_DRIC 0x08
#define IDTPHY_REGM_MCR_HALTTX 0x04
#define IDTPHY_REGM_MCR_BYTEM 0x02
#define IDTPHY_REGM_MCR_EI 0x01
#define IDTPHY_REGO_ISTAT 0x01
#define IDTPHY_REGN_ISTAT "Interrupt Status"
#define IDTPHY_REGX_ISTAT "\020\7GOOD\6HECE\5SCRE\4TPE\3RSCC\2RSE\1RFO"
#define IDTPHY_REGM_ISTAT_GOOD 0x40 /* good signal bit */
#define IDTPHY_REGM_ISTAT_HECE 0x20 /* HEC error */
#define IDTPHY_REGM_ISTAT_SCRE 0x10 /* short cell received error */
#define IDTPHY_REGM_ISTAT_TPE 0x08 /* transmit parity error */
#define IDTPHY_REGM_ISTAT_RSCC 0x04 /* receive signal condition change */
#define IDTPHY_REGM_ISTAT_RSE 0x02 /* receive symbol error */
#define IDTPHY_REGM_ISTAT_RFO 0x01 /* read FIFO overrun */
#define IDTPHY_REGO_DIAG 0x02
#define IDTPHY_REGN_DIAG "Diagnostic Control"
#define IDTPHY_REGX_DIAG "\020\010FTD\7ROS\6MULTI\5RFLUSH\4ITPE\3IHECE\11\3\0NORM\11\3\2PLOOP\11\3\3LLOOP"
#define IDTPHY_REGM_DIAG_FTD 0x80 /* Force TxClav Deassert */
#define IDTPHY_REGM_DIAG_ROS 0x40 /* RxClav Operation Select */
#define IDTPHY_REGM_DIAG_MULTI 0x20 /* Multi-phy operation */
#define IDTPHY_REGM_DIAG_RFLUSH 0x10 /* clear receive Fifo */
#define IDTPHY_REGM_DIAG_ITPE 0x08 /* insert transmit payload error */
#define IDTPHY_REGM_DIAG_IHECE 0x04 /* insert transmit HEC error */
#define IDTPHY_REGM_DIAG_LOOP 0x03 /* loopback mode */
#define IDTPHY_REGM_DIAG_LOOP_NONE 0x00 /* normal */
#define IDTPHY_REGM_DIAG_LOOP_PHY 0x02 /* PHY loopback */
#define IDTPHY_REGM_DIAG_LOOP_LINE 0x03 /* Line loopback */
#define IDTPHY_REGO_LHEC 0x03
#define IDTPHY_REGN_LHEC "LED Driver and HEC Status/Control"
#define IDTPHY_REGX_LHEC "\020\7DRHEC\6DTHEC\11\x18\0CYC1\11\x18\1CYC2\11\x18\2CYC4\11\x18\3CYC8\3FIFOE\2TXLED\1RXLED"
#define IDTPHY_REGM_LHEC_DRHEC 0x40 /* disable receive HEC */
#define IDTPHY_REGM_LHEC_DTHEC 0x20 /* disable transmit HEC */
#define IDTPHY_REGM_LHEC_RXREF 0x18 /* RxRef pulse width */
#define IDTPHY_REGM_LHEC_RXREF1 0x00 /* 1 pulse */
#define IDTPHY_REGM_LHEC_RXREF2 0x08 /* 2 pulse */
#define IDTPHY_REGM_LHEC_RXREF4 0x10 /* 4 pulse */
#define IDTPHY_REGM_LHEC_RXREF8 0x18 /* 8 pulse */
#define IDTPHY_REGM_LHEC_FIFOE 0x04 /* Fifo empty */
#define IDTPHY_REGM_LHEC_TXLED 0x02 /* Tx LED status */
#define IDTPHY_REGM_LHEC_RXLED 0x01 /* Rx LED status */
#define IDTPHY_REGO_CNT 0x04 /* +0x05 */
#define IDTPHY_REGN_CNT "Counter"
#define IDTPHY_REGO_CNTS 0x06
#define IDTPHY_REGN_CNTS "Counter select"
#define IDTPHY_REGX_CNTS "\020\4SEC\3TX\2RX\1HECE"
#define IDTPHY_REGM_CNTS_SEC 0x08 /* symbol error counter */
#define IDTPHY_REGM_CNTS_TX 0x04 /* Tx cells */
#define IDTPHY_REGM_CNTS_RX 0x02 /* Rx cells */
#define IDTPHY_REGM_CNTS_HECE 0x01 /* HEC errors */
#define IDTPHY_PRINT_77105 \
{ /* 00 */ \
UTP_REGT_BITS, IDTPHY_REGO_MCR, \
IDTPHY_REGN_MCR, IDTPHY_REGX_MCR }, \
{ /* 01 */ \
UTP_REGT_BITS, IDTPHY_REGO_ISTAT, \
IDTPHY_REGN_ISTAT, IDTPHY_REGX_ISTAT }, \
{ /* 02 */ \
UTP_REGT_BITS, IDTPHY_REGO_DIAG, \
IDTPHY_REGN_DIAG, IDTPHY_REGX_DIAG }, \
{ /* 03 */ \
UTP_REGT_BITS, IDTPHY_REGO_LHEC, \
IDTPHY_REGN_LHEC, IDTPHY_REGX_LHEC }, \
{ /* 04, 05 */ \
UTP_REGT_INT16, IDTPHY_REGO_CNT, \
IDTPHY_REGN_CNT, NULL }, \
{ /* 06 */ \
UTP_REGT_BITS, IDTPHY_REGO_CNTS, \
IDTPHY_REGN_CNTS, IDTPHY_REGX_CNTS }
#endif /* _DEV_UTOPIA_IDTPHY_H */

1515
sys/dev/utopia/suni.h Normal file

File diff suppressed because it is too large Load Diff

1082
sys/dev/utopia/utopia.c Normal file

File diff suppressed because it is too large Load Diff

175
sys/dev/utopia/utopia.h Normal file
View File

@ -0,0 +1,175 @@
/*
* Copyright (c) 2003
* Fraunhofer Institute for Open Communication Systems (FhG Fokus).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Author: Hartmut Brandt <harti@freebsd.org>
*
* $FreeBSD$
*/
#ifndef _DEV_UTOPIA_UTOPIA_H
#define _DEV_UTOPIA_UTOPIA_H
/* Structure for user-level register formatting */
struct utopia_print {
uint8_t type; /* register type */
uint8_t reg; /* register number */
const char *name; /* register name */
const char *fmt; /* format for printing */
};
/*
* Types of registers
*/
#define UTP_REGT_BITS 0x0 /* use printb to print */
#define UTP_REGT_INT8 0x1 /* 8 bit hex number */
#define UTP_REGT_INT10BITS 0x2 /* 10 bit hex number + 6 bit printb */
#define UTP_REGT_INT12 0x3 /* 12 bit LE hex */
#define UTP_REGT_INT16 0x4 /* 16 bit LE hex */
#define UTP_REGT_INT19 0x5 /* 19 bit LE hex */
#define UTP_REGT_INT20 0x6 /* 20 bit LE hex */
#define UTP_REGT_INT21 0x7 /* 21 bit LE hex */
/* number of additional registers per type */
#define UTP_REG_ADD 0, 0, 1, 1, 1, 2, 2, 2
/* flags field */
#define UTP_FL_NORESET 0x0001 /* cannot write MRESET register */
#define UTP_FL_POLL_CARRIER 0x0002 /* need to poll for carrier */
/* state field */
#define UTP_ST_ACTIVE 0x0001 /* registers accessible */
#define UTP_ST_SDH 0x0002 /* SDH or SONET */
#define UTP_ST_UNASS 0x0004 /* produce unassigned cells */
#define UTP_ST_NOSCRAMB 0x0008 /* no scrambling */
#define UTP_ST_DETACH 0x0010 /* detaching */
#define UTP_ST_ATTACHED 0x0020 /* successful attached */
/* carrier field */
#define UTP_CARR_UNKNOWN 0
#define UTP_CARR_OK 1
#define UTP_CARR_LOST 2
/* loopback field */
#define UTP_LOOP_NONE 0x0000
#define UTP_LOOP_TIME 0x0001 /* timing source loopback */
#define UTP_LOOP_DIAG 0x0002 /* diagnostic loopback */
#define UTP_LOOP_LINE 0x0004 /* serial line loopback */
#define UTP_LOOP_PARAL 0x0008 /* parallel diagnostic loopback */
#define UTP_LOOP_TWIST 0x0010 /* twisted pair diagnostic loopback */
#define UTP_LOOP_PATH 0x0020 /* diagnostic path loopback */
/* type */
#define UTP_TYPE_UNKNOWN 0
#define UTP_TYPE_SUNI_LITE 1
#define UTP_TYPE_SUNI_ULTRA 2
#define UTP_TYPE_SUNI_622 3
#define UTP_TYPE_IDT77105 4
#ifdef _KERNEL
#include <sys/queue.h>
/*
* These must be implemented by the card driver
*/
struct utopia_methods {
/* read at most n PHY registers starting at reg into val */
int (*readregs)(struct ifatm *, u_int reg, uint8_t *val, u_int *n);
/* change the bits given by mask to them in val in register reg */
int (*writereg)(struct ifatm *, u_int reg, u_int mask, u_int val);
};
/*
* Public state
*/
struct utopia {
struct ifatm *ifatm; /* driver data */
struct ifmedia *media; /* driver supplied */
struct mtx *lock; /* driver supplied */
const struct utopia_methods *methods;
LIST_ENTRY(utopia) link; /* list of these structures */
u_int flags; /* flags set by the driver */
u_int state; /* current state */
u_int carrier; /* carrier state */
u_int loopback; /* loopback mode */
const struct utopia_chip *chip; /* chip operations */
};
struct utopia_chip {
/* type and name of the chip */
u_int type;
const char *const name;
/* number of registers */
u_int nregs;
/* reset chip to known state */
int (*reset)(struct utopia *);
/* set SONET/SDH mode */
int (*set_sdh)(struct utopia *, int sdh);
/* set idle/unassigned cells */
int (*set_unass)(struct utopia *, int unass);
/* enable/disable scrambling */
int (*set_noscramb)(struct utopia *, int noscramb);
/* update carrier status */
int (*update_carrier)(struct utopia *);
/* set loopback mode */
int (*set_loopback)(struct utopia *, u_int mode);
/* handle interrupt */
void (*intr)(struct utopia *);
};
/*
* These are implemented in the common utopia code
*/
int utopia_attach(struct utopia *, struct ifatm *, struct ifmedia *,
struct mtx *, struct sysctl_ctx_list *, struct sysctl_oid_list *,
const struct utopia_methods *);
void utopia_detach(struct utopia *);
int utopia_start(struct utopia *);
void utopia_stop(struct utopia *);
void utopia_init_media(struct utopia *);
void utopia_reset_media(struct utopia *);
#define utopia_reset(S) ((S)->chip->reset((S)))
#define utopia_set_sdh(S, SDH) ((S)->chip->set_sdh((S), (SDH)))
#define utopia_set_unass(S, U) ((S)->chip->set_unass((S), (U)))
#define utopia_set_noscramb(S, N) ((S)->chip->set_noscramb((S), (N)))
#define utopia_update_carrier(S) ((S)->chip->update_carrier((S)))
#define utopia_set_loopback(S, L) ((S)->chip->set_loopback((S), (L)))
#define utopia_intr(S) ((S)->chip->intr((S)))
#endif /* _KERNEL */
#endif /* _DEV_UTOPIA_UTOPIA_H */

View File

@ -132,6 +132,7 @@ SUBDIR= accf_data \
urio \
usb \
uscanner \
utopia \
uvisor \
uvscom \
vpo \

View File

@ -0,0 +1,8 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../dev/utopia
KMOD= utopia
SRCS= utopia.c bus_if.h device_if.h
.include <bsd.kmod.mk>