diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 84d82eea2486..740b02f6d369 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -51,6 +51,15 @@
# xargs -n1 | sort | uniq -d;
# done
+# 2024xxxx: Remove Altera DE4 drivers
+OLD_FILES+=usr/share/man/man4/altera_atse.4.gz
+OLD_FILES+=usr/share/man/man4/altera_avgen.4.gz
+OLD_FILES+=usr/share/man/man4/altera_jtag_uart.4.gz
+OLD_FILES+=usr/share/man/man4/altera_sdcard.4.gz
+OLD_FILES+=usr/share/man/man4/altera_sdcardc.4.gz
+OLD_FILES+=usr/share/man/man4/atse.4.gz
+OLD_FILES+=usr/share/man/man4/berirom.4.gz
+
# 20240527: csh: Remove hardlink /.cshrc
OLD_FILES+=.cshrc
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index d5d8b8387a41..e2a33bb1f768 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -34,10 +34,6 @@ MAN= aac.4 \
alc.4 \
ale.4 \
alpm.4 \
- altera_atse.4 \
- altera_avgen.4 \
- altera_jtag_uart.4 \
- altera_sdcard.4 \
altq.4 \
amdpm.4 \
${_amdsbwd.4} \
@@ -70,7 +66,6 @@ MAN= aac.4 \
bce.4 \
bcm5974.4 \
bcma.4 \
- berirom.4 \
bfe.4 \
bge.4 \
${_bhyve.4} \
@@ -643,8 +638,6 @@ MLINKS+=age.4 if_age.4
MLINKS+=agp.4 agpgart.4
MLINKS+=alc.4 if_alc.4
MLINKS+=ale.4 if_ale.4
-MLINKS+=altera_atse.4 atse.4
-MLINKS+=altera_sdcard.4 altera_sdcardc.4
MLINKS+=altq.4 ALTQ.4
MLINKS+=ath.4 if_ath.4
MLINKS+=aue.4 if_aue.4
diff --git a/share/man/man4/altera_atse.4 b/share/man/man4/altera_atse.4
deleted file mode 100644
index 6bc88f8b45a2..000000000000
--- a/share/man/man4/altera_atse.4
+++ /dev/null
@@ -1,128 +0,0 @@
-.\"-
-.\" Copyright (c) 2013-2015 SRI International
-.\" All rights reserved.
-.\"
-.\" This software was developed by SRI International and the University of
-.\" Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
-.\" ("CTSRD"), as part of the DARPA CRASH research programme.
-.\"
-.\" 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.
-.\"
-.Dd March 23, 2015
-.Dt ALTERA_ATSE 4
-.Os
-.Sh NAME
-.Nm atse
-.Nd driver for the Altera Triple-Speed Ethernet MegaCore
-.Sh SYNOPSIS
-.Cd "device atse"
-.Cd "options ATSE_CFI_HACK"
-.Pp
-In
-.Pa /boot/device.hints :
-.Cd hint.atse.0.at="nexus0"
-.Cd hint.atse.0.maddr=0x7f007000
-.Cd hint.atse.0.msize=0x540
-.Cd hint.atse.0.rc_irq=1
-.Cd hint.atse.0.rx_maddr=0x7f007500
-.Cd hint.atse.0.rx_msize=0x8
-.Cd hint.atse.0.rxc_maddr=0x7f007520
-.Cd hint.atse.0.rxc_msize=0x20
-.Cd hint.atse.0.tx_irq=2
-.Cd hint.atse.0.tx_maddr=0x7f007400
-.Cd hint.atse.0.tx_msize=0x8
-.Cd hint.atse.0.txc_maddr=0x7f007420
-.Cd hint.atse.0.txc_msize=0x20
-.Cd hint.e1000phy.0.at="miibus0"
-.Cd hint.e1000phy.0.phyno=0
-.Pp
-In DTS file:
-.Cd ethernet@7f007000 {
-.Cd " compatible =" Qo Cd altera,atse Qc ;
-.Cd " reg = <0x7f007000 0x400"
-.Cd " 0x7f007500 0x8"
-.Cd " 0x7f007520 0x20"
-.Cd " 0x7f007400 0x8"
-.Cd " 0x7f007420 0x20>;"
-.Cd " interrupts = <1 2>;"
-.Cd };
-.Sh DESCRIPTION
-The
-.Nm
-device driver provides support for the Altera Triple-Speed Ethernet
-MegaCore.
-.Sh HARDWARE
-The current version of the
-.Nm
-driver supports the Ethernet MegaCore as described in version 11.1 of
-Altera's documentation when the device is configured with internal FIFOs.
-.Sh MAC SELECTION
-The default MAC address for each
-.Nm
-interface is derived from a value stored in
-.Xr cfi 4
-flash.
-The value is managed by the
-.Xr atsectl 8
-utility.
-.Pp
-Only a single MAC address may be stored in flash.
-If the address begins with the Altera prefix 00:07:ed and ends in 00 then
-up to 16 addresses will be derived from it by adding the unit number of
-the interface to the stored address.
-For other prefixes, the address will be assigned to atse0 and random
-addresses will be used for other interfaces.
-If the stored address is invalid, for example all zero's, multicast, or the
-default address shipped on all DE4 boards (00:07:ed:ff:ed:15) then a random
-address is generated when the device is attached.
-.Sh SEE ALSO
-.Xr miibus 4 ,
-.Xr netintro 4 ,
-.Xr ifconfig 8
-.Rs
-.%T Triple-Speed Ethernet MegaCore Function User Guide
-.%D November 2011
-.%I Altera Corporation
-.Re
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 10.0 .
-.Sh AUTHORS
-The
-.Nm
-device driver and this manual page were
-developed by SRI International and the University of Cambridge Computer
-Laboratory under DARPA/AFRL contract
-.Pq FA8750-10-C-0237
-.Pq Do CTSRD Dc ,
-as part of the DARPA CRASH research programme.
-This device driver was written by
-.An Bjoern A. Zeeb .
-.Sh BUGS
-The
-.Nm
-driver only supports a single configuration of the MegaCore as installed
-on the Terasic Technologies Altera DE4 Development and Education Board.
-.Pp
-Only gigabit Ethernet speeds are currently supported.
diff --git a/share/man/man4/altera_avgen.4 b/share/man/man4/altera_avgen.4
deleted file mode 100644
index 149a5f19366d..000000000000
--- a/share/man/man4/altera_avgen.4
+++ /dev/null
@@ -1,179 +0,0 @@
-.\"-
-.\" Copyright (c) 2012, 2016 Robert N. M. Watson
-.\" Copyright (c) 2015 SRI International
-.\" All rights reserved.
-.\"
-.\" This software was developed by SRI International and the University of
-.\" Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
-.\" ("CTSRD"), as part of the DARPA CRASH research programme.
-.\"
-.\" 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.
-.\"
-.Dd March 23, 2015
-.Dt ALTERA_AVGEN 4
-.Os
-.Sh NAME
-.Nm altera_avgen
-.Nd driver for generic Altera Avalon-bus-attached, memory-mapped devices
-.Sh SYNOPSIS
-.Cd "device altera_avgen"
-.Pp
-In
-.Pa /boot/device.hints :
-.Cd hint.altera_avgen.0.at="nexus0"
-.Cd hint.altera_avgen.0.maddr=0x7f00a000
-.Cd hint.altera_avgen.0.msize=20
-.Cd hint.altera_avgen.0.width=4
-.Cd hint.altera_avgen.0.fileio="rw"
-.Cd hint.altera_avgen.0.geomio="rw"
-.Cd hint.altera_avgen.0.mmapio="rwx"
-.Cd hint.altera_avgen.0.devname="berirom"
-.Cd hint.altera_avgen.0.devunit="0"
-.Pp
-In DTS file:
-.Cd avgen@0x7f00a000 {
-.D1 Cd compatible="sri-cambridge,avgen";
-.D1 Cd reg=<0x7f00a000 0x14>;
-.D1 Cd sri-cambridge,width=<4>;
-.D1 Cd sri-cambridge,fileio="rw";
-.D1 Cd sri-cambridge,geomio="rw";
-.D1 Cd sri-cambridge,mmapio="rwx";
-.D1 Cd sri-cambridge,devname="berirom";
-.D1 Cd sri-cambridge,devunit="0";
-.Cd };
-.Sh DESCRIPTION
-The
-.Nm
-device driver provides generic support for memory-mapped devices on the
-Altera Avalon bus.
-.Pa device.hints
-entries configure the address, size, I/O disposition, and
-.Pa /dev
-device node name that will be used.
-The
-.Xr mount 2 ,
-.Xr open 2 ,
-.Xr read 2 ,
-.Xr write 2 ,
-and
-.Xr mmap 2
-system calls (and variations) may be used on
-.Nm
-device nodes, subject to constraints imposed using
-.Pa device.hints
-or FDT entries.
-Although reading and writing mapped memory is supported,
-.Nm
-does not currently support directing device interrupts to userspace.
-.Pp
-A number of
-.Pa device.hints
-sub-fields or FDT configuration entries are available to configure
-.Nm
-device instances:
-.Bl -tag -width devunit
-.It maddr
-base physical address of the memory region to export; must be aligned to
-.Li width
-.It msize
-length of the memory region export; must be aligned to
-.Li width
-.It width
-Granularity at which
-.Xr read 2
-and
-.Xr write 2
-operations will be performed.
-Larger requests will be broken down into
-.Li width -sized
-operations; smaller requests will be rejected.
-I/O operations must be aligned to
-.Li width .
-.It fileio
-allowed file descriptor operations;
-.Li r
-authorizes
-.Xr read 2 ;
-.Li w
-authorizes
-.Xr write 2 .
-.It geomio
-configures the special device to be exposed using the
-.Xr disk 9
-interface, permitting filesystem mounting using
-.Xr mount 2 .
-.Li w
-authorizes block write, and
-.Li r
-authorizes block read.
-.It mmapio
-allowed
-.Xr mmap 2
-permissions;
-.Li w
-authorizes
-.Dv PROT_WRITE ;
-.Li r
-authorizes
-.Dv PROT_READ ;
-.Li x
-authorizes
-.Dv PROT_EXEC .
-.It devname
-specifies a device name relative to
-.Pa /dev .
-.It devunit
-specifies a device unit number; no unit number is used if this is unspecified.
-.El
-.Pp
-.Nm
-devices may be exposed via only one of file/memory-mapped I/O or
-.Nm geom
-I/O.
-.Sh SEE ALSO
-.Xr mmap 2 ,
-.Xr mount 2 ,
-.Xr open 2 ,
-.Xr read 2 ,
-.Xr unmount 2 ,
-.Xr write 2 ,
-.Xr geom 4
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 10.0 .
-.Sh AUTHORS
-The
-.Nm
-device driver and this manual page were
-developed by SRI International and the University of Cambridge Computer
-Laboratory under DARPA/AFRL contract
-.Pq FA8750-10-C-0237
-.Pq Do CTSRD Dc ,
-as part of the DARPA CRASH research programme.
-This device driver was written by
-.An Robert N. M. Watson .
-.Sh BUGS
-.Nm
-is intended to support the writing of userspace device drivers; however, it
-does not permit directing interrupts to userspace, only memory-mapped I/O.
diff --git a/share/man/man4/altera_jtag_uart.4 b/share/man/man4/altera_jtag_uart.4
deleted file mode 100644
index 7a9a4432a7b1..000000000000
--- a/share/man/man4/altera_jtag_uart.4
+++ /dev/null
@@ -1,135 +0,0 @@
-.\"-
-.\" Copyright (c) 2012 Robert N. M. Watson
-.\" Copyright (c) 2015 SRI International
-.\" All rights reserved.
-.\"
-.\" This software was developed by SRI International and the University of
-.\" Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
-.\" ("CTSRD"), as part of the DARPA CRASH research programme.
-.\"
-.\" 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.
-.\"
-.Dd March 23, 2015
-.Dt ALTERA_JTAG_UART 4
-.Os
-.Sh NAME
-.Nm altera_jtag_uart
-.Nd driver for the Altera JTAG UART Core
-.Sh SYNOPSIS
-.Cd "device altera_jtag_uart"
-.Pp
-In
-.Pa /boot/device.hints :
-.Cd hint.altera_jtag_uart.0.at="nexus0"
-.Cd hint.altera_jtag_uart.0.maddr=0x7f000000
-.Cd hint.altera_jtag_uart.0.msize=0x40
-.Cd hint.altera_jtag_uart.0.irq=0
-.Cd hint.altera_jtag_uart.1.at="nexus0"
-.Cd hint.altera_jtag_uart.1.maddr=0x7f001000
-.Cd hint.altera_jtag_uart.1.msize=0x40
-.Pp
-In DTS file:
-.Cd serial@7f000000 {
-.Cd " compatible =" Qo Cd altera,jtag_uart-11_0 Qc ;
-.Cd " reg = <0x7f000000 0x40>;"
-.Cd " interrupts = <0>;"
-.Cd };
-.Sh DESCRIPTION
-The
-.Nm
-device driver provides support for the Altera JTAG UART core, which allows
-multiple UART-like streams to be carried over JTAG.
-.Nm
-allows JTAG UART streams to be attached to both the low-level console
-interface, used for direct kernel input and output, and the
-.Xr tty 4
-layer, to be used with
-.Xr ttys 5
-and
-.Xr login 1 .
-Sequential Altera JTAG UART devices will appear as
-.Li ttyu0 ,
-.Li ttyu1 ,
-etc.
-.Sh HARDWARE
-Altera JTAG UART devices can be connected to using Altera's
-.Pa nios2-terminal
-program, with the instance selected using the
-.Li --instance
-argument on the management host.
-.Nm
-supports JTAG UART cores with or without interrupt lines connected; if the
-.Li irq
-portion of the
-.Pa device.hints
-entry is omitted, the driver will poll rather than configure interrupts.
-.Sh FILES
-.Bl -tag -width ".Pa /dev/ttyu?.init" -compact
-.It Pa /dev/ttyj?
-for callin ports
-.It Pa /dev/ttyj?.init
-.It Pa /dev/ttyj?.lock
-corresponding callin initial-state and lock-state devices
-.El
-.Sh SEE ALSO
-.Xr login 1 ,
-.Xr tty 4 ,
-.Xr ttys 5
-.Rs
-.%T Altera Embedded Peripherals IP User Guide
-.%D June 2011
-.%I Altera Corporation
-.%U http://www.altera.com/literature/ug/ug_embedded_ip.pdf
-.Re
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 10.0 .
-.Sh AUTHORS
-The
-.Nm
-device driver and this manual page were
-developed by SRI International and the University of Cambridge Computer
-Laboratory under DARPA/AFRL contract
-.Pq FA8750-10-C-0237
-.Pq Do CTSRD Dc ,
-as part of the DARPA CRASH research programme.
-This device driver was written by
-.An Robert N. M. Watson .
-.Sh BUGS
-.Nm
-must dynamically poll to detect when JTAG is present, in order to disable flow
-control in the event that there is no receiving endpoint.
-Otherwise, the boot may hang waiting for the JTAG client to be attached, and
-user processes attached to JTAG UART devices might block indefinitely.
-However, there is no way to flush the output buffer once JTAG is detected to
-have disappeared; this means that a small amount of stale output data will
-remain in the output buffer, being displayed by
-.Li nios2-terminal
-when it is connected.
-Loss of JTAG will not generate a hang-up event, as that is rarely the desired
-behaviour.
-.Pp
-.Li nios2-terminal
-does not place the client-side TTY in raw mode, and so by default will not
-pass all control characters through to the UART.
diff --git a/share/man/man4/altera_sdcard.4 b/share/man/man4/altera_sdcard.4
deleted file mode 100644
index 42dc8ac24a66..000000000000
--- a/share/man/man4/altera_sdcard.4
+++ /dev/null
@@ -1,123 +0,0 @@
-.\"-
-.\" Copyright (c) 2012 Robert N. M. Watson
-.\" Copyright (c) 2015 SRI International
-.\" All rights reserved.
-.\"
-.\" This software was developed by SRI International and the University of
-.\" Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
-.\" ("CTSRD"), as part of the DARPA CRASH research programme.
-.\"
-.\" 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.
-.\"
-.Dd March 23, 2015
-.Dt ALTERA_SDCARD 4
-.Os
-.Sh NAME
-.Nm altera_sdcard
-.Nd driver for the Altera University Program Secure Data Card IP Core
-.Sh SYNOPSIS
-.Cd "device altera_sdcard"
-.Pp
-In
-.Pa /boot/device.hints :
-.Cd hint.altera_sdcardc.0.at="nexus0"
-.Cd hint.altera_sdcardc.0.maddr=0x7f008000
-.Cd hint.altera_sdcardc.0.msize=0x400
-.Pp
-In DTS file:
-.Cd sdcard@7f008000 {
-.Cd " compatible =" Qo Cd altera,sdcard_11_2011 Qc ;
-.Cd " reg = <0x7f008000 0x400>;"
-.Cd };
-.Sh DESCRIPTION
-The
-.Nm
-device driver provides support for the Altera University Program Secure Data
-Card (SD Card) IP Core device.
-A controller device,
-.Li altera_sdcardcX ,
-will be attached during boot.
-Inserted disks are presented as
-.Xr disk 9
-devices,
-.Li altera_sdcardX ,
-corresponding to the controller number.
-.Sh HARDWARE
-The current version of the
-.Nm
-driver supports the SD Card IP core as described in the August 2011 version of
-Altera's documentation.
-The core supports only cards up to 2G (CSD 0); larger cards, or cards using
-newer CSD versions, will not be detected.
-The IP core has two key limitations: a lack of interrupt support, requiring
-timer-driven polling to detect I/O completion, and support for only single
-512-byte block read and write operations at a time.
-The combined effect of those two limits is that the system clock rate,
-.Dv HZ ,
-must be set to at least 200 in order to accomplish the maximum 100KB/s data
-rate supported by the IP core.
-.Sh SEE ALSO
-.Xr disk 9
-.Rs
-.%T Altera University Program Secure Data Card IP Core
-.%D August 2011
-.%I Altera Corporation - University Program
-.%U ftp://ftp.altera.com/up/pub/Altera_Material/11.0/University_Program_IP_Cores/Memory/SD_Card_Interface_for_SoPC_Builder.pdf
-.Re
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 10.0 .
-.Sh AUTHORS
-The
-.Nm
-device driver and this manual page were
-developed by SRI International and the University of Cambridge Computer
-Laboratory under DARPA/AFRL contract
-.Pq FA8750-10-C-0237
-.Pq Do CTSRD Dc ,
-as part of the DARPA CRASH research programme.
-This device driver was written by
-.An Robert N. M. Watson .
-.Sh BUGS
-.Nm
-contains a number of work-arounds for IP core bugs.
-Perhaps most critically,
-.Nm
-ignores the CRC error bit returned in the RR1 register, which appears to be
-unexpectedly set by the IP core.
-.Pp
-.Nm
-uses fixed polling intervals are used for card insertion/removal and
-I/O completion detection; an adaptive strategy might improve performance by
-reducing the latency to detecting completed I/O.
-However, in our experiments, using polling rates greater than 200 times a
-second did not improve performance.
-.Pp
-.Nm
-supports only a
-.Li nexus
-bus attachment, which is appropriate for system-on-chip busses such as
-Altera's Avalon bus.
-If the IP core is configured off of another bus type, then additional bus
-attachments will be required.
diff --git a/share/man/man4/berirom.4 b/share/man/man4/berirom.4
deleted file mode 100644
index 3d2742d526af..000000000000
--- a/share/man/man4/berirom.4
+++ /dev/null
@@ -1,83 +0,0 @@
-.\"-
-.\" Copyright (c) 2014 SRI International
-.\" Copyright (c) 2012 Robert N. M. Watson
-.\" All rights reserved.
-.\"
-.\" This software was developed by SRI International and the University of
-.\" Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
-.\" ("CTSRD"), as part of the DARPA CRASH research programme.
-.\"
-.\" 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd May 1, 2014
-.Dt BERIROM 4
-.Os
-.Sh NAME
-.Nm berirom
-.Nd driver for BERI hardware information ROM
-.Sh SYNOPSIS
-.Cd "device berirom"
-.Pp
-In
-.Pa sys/boot/fdt/dts/mips/beri.dts :
-.Cd berirom@0x7f00a000 {
-.Cd compatible = "sri-cambridge,berirom";
-.Cd reg = <0x7f00a000 0x1000>;
-.Cd };
-.Sh DESCRIPTION
-The
-.Nm
-device driver provides read access to the BERI hardware information ROM
-at
-/Pa /dev/berirom%d
-and for the first (usually only) instance at
-.Pa /dev/berirom .
-The
-.Nm
-device also parses and prints the CPU build time and Subversion revision
-of the CPU on attach.
-.Sh SEE ALSO
-.Xr read 2
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 11.0 .
-.Sh AUTHORS
-The
-.Nm
-device driver and this manual page were
-developed by SRI International and the University of Cambridge Computer
-Laboratory under DARPA/AFRL contract
-.Pq FA8750-10-C-0237
-.Pq Do CTSRD Dc ,
-as part of the DARPA CRASH research programme.
-This device driver was written by
-.An Brooks Davis .
-.Sh BUGS
-.Nm
-currently requires that
-.Fn read
-calls to request no more data than is available (currently 20 bytes) and
-that reads by on 4 byte boundaries.
diff --git a/sys/arm/altera/socfpga/files.socfpga b/sys/arm/altera/socfpga/files.socfpga
deleted file mode 100644
index 1cf8d95b9fa3..000000000000
--- a/sys/arm/altera/socfpga/files.socfpga
+++ /dev/null
@@ -1,18 +0,0 @@
-
-arm/altera/socfpga/socfpga_common.c standard
-arm/altera/socfpga/socfpga_machdep.c standard
-arm/altera/socfpga/socfpga_manager.c standard
-arm/altera/socfpga/socfpga_rstmgr.c standard
-arm/altera/socfpga/socfpga_mp.c optional smp
-
-dev/mmc/host/dwmmc_altera.c optional dwmmc
-
-# Arria 10
-arm/altera/socfpga/socfpga_a10_manager.c standard
-
-# BERI specific
-dev/beri/beri_ring.c optional beri_ring
-dev/beri/beri_mem.c optional beri_mem
-dev/beri/virtio/virtio.c optional beri_vtblk | vtbe
-dev/beri/virtio/virtio_block.c optional beri_vtblk
-dev/beri/virtio/network/if_vtbe.c optional vtbe
diff --git a/sys/arm/altera/socfpga/socfpga_a10_manager.c b/sys/arm/altera/socfpga/socfpga_a10_manager.c
deleted file mode 100644
index 01267bcaacf1..000000000000
--- a/sys/arm/altera/socfpga/socfpga_a10_manager.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*-
- * Copyright (c) 2017 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-/*
- * Intel Arria 10 FPGA Manager.
- * Chapter 4, Arria 10 Hard Processor System Technical Reference Manual.
- * Chapter A, FPGA Reconfiguration.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-
-#define FPGAMGR_DCLKCNT 0x8 /* DCLK Count Register */
-#define FPGAMGR_DCLKSTAT 0xC /* DCLK Status Register */
-#define FPGAMGR_GPO 0x10 /* General-Purpose Output Register */
-#define FPGAMGR_GPI 0x14 /* General-Purpose Input Register */
-#define FPGAMGR_MISCI 0x18 /* Miscellaneous Input Register */
-#define IMGCFG_CTRL_00 0x70
-#define S2F_CONDONE_OE (1 << 24)
-#define S2F_NSTATUS_OE (1 << 16)
-#define CTRL_00_NCONFIG (1 << 8)
-#define CTRL_00_NENABLE_CONDONE (1 << 2)
-#define CTRL_00_NENABLE_NSTATUS (1 << 1)
-#define CTRL_00_NENABLE_NCONFIG (1 << 0)
-#define IMGCFG_CTRL_01 0x74
-#define CTRL_01_S2F_NCE (1 << 24)
-#define CTRL_01_S2F_PR_REQUEST (1 << 16)
-#define CTRL_01_S2F_NENABLE_CONFIG (1 << 0)
-#define IMGCFG_CTRL_02 0x78
-#define CTRL_02_CDRATIO_S 16
-#define CTRL_02_CDRATIO_M (0x3 << CTRL_02_CDRATIO_S)
-#define CTRL_02_CFGWIDTH_16 (0 << 24)
-#define CTRL_02_CFGWIDTH_32 (1 << 24)
-#define CTRL_02_EN_CFG_DATA (1 << 8)
-#define CTRL_02_EN_CFG_CTRL (1 << 0)
-#define IMGCFG_STAT 0x80
-#define F2S_PR_ERROR (1 << 11)
-#define F2S_PR_DONE (1 << 10)
-#define F2S_PR_READY (1 << 9)
-#define F2S_MSEL_S 16
-#define F2S_MSEL_M (0x7 << F2S_MSEL_S)
-#define MSEL_PASSIVE_FAST 0
-#define MSEL_PASSIVE_SLOW 1
-#define F2S_NCONFIG_PIN (1 << 12)
-#define F2S_CONDONE_OE (1 << 7)
-#define F2S_NSTATUS_PIN (1 << 4)
-#define F2S_CONDONE_PIN (1 << 6)
-#define F2S_USERMODE (1 << 2)
-
-struct fpgamgr_a10_softc {
- struct resource *res[2];
- bus_space_tag_t bst_data;
- bus_space_handle_t bsh_data;
- struct cdev *mgr_cdev;
- device_t dev;
-};
-
-static struct resource_spec fpgamgr_a10_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_MEMORY, 1, RF_ACTIVE },
- { -1, 0 }
-};
-
-static int
-fpga_wait_dclk_pulses(struct fpgamgr_a10_softc *sc, int npulses)
-{
- int tout;
-
- /* Clear done bit, if any */
- if (READ4(sc, FPGAMGR_DCLKSTAT) != 0)
- WRITE4(sc, FPGAMGR_DCLKSTAT, 0x1);
-
- /* Request DCLK pulses */
- WRITE4(sc, FPGAMGR_DCLKCNT, npulses);
-
- /* Wait finish */
- tout = 1000;
- while (tout > 0) {
- if (READ4(sc, FPGAMGR_DCLKSTAT) == 1) {
- WRITE4(sc, FPGAMGR_DCLKSTAT, 0x1);
- break;
- }
- tout--;
- DELAY(10);
- }
- if (tout == 0) {
- device_printf(sc->dev,
- "Error: dclkpulses wait timeout\n");
- return (1);
- }
-
- return (0);
-}
-
-static int
-fpga_open(struct cdev *dev, int flags __unused,
- int fmt __unused, struct thread *td __unused)
-{
- struct fpgamgr_a10_softc *sc;
- int tout;
- int msel;
- int reg;
-
- sc = dev->si_drv1;
-
- /* Step 1 */
- reg = READ4(sc, IMGCFG_STAT);
- if ((reg & F2S_USERMODE) == 0) {
- device_printf(sc->dev, "Error: invalid mode\n");
- return (ENXIO);
- };
-
- /* Step 2 */
- reg = READ4(sc, IMGCFG_STAT);
- msel = (reg & F2S_MSEL_M) >> F2S_MSEL_S;
- if ((msel != MSEL_PASSIVE_FAST) && \
- (msel != MSEL_PASSIVE_SLOW)) {
- device_printf(sc->dev,
- "Error: invalid msel %d\n", msel);
- return (ENXIO);
- };
-
- /*
- * Step 3.
- * TODO: add support for compressed, encrypted images.
- */
- reg = READ4(sc, IMGCFG_CTRL_02);
- reg &= ~(CTRL_02_CDRATIO_M);
- WRITE4(sc, IMGCFG_CTRL_02, reg);
-
- reg = READ4(sc, IMGCFG_CTRL_02);
- reg &= ~CTRL_02_CFGWIDTH_32;
- WRITE4(sc, IMGCFG_CTRL_02, reg);
-
- /* Step 4. a */
- reg = READ4(sc, IMGCFG_CTRL_01);
- reg &= ~CTRL_01_S2F_PR_REQUEST;
- WRITE4(sc, IMGCFG_CTRL_01, reg);
-
- reg = READ4(sc, IMGCFG_CTRL_00);
- reg |= CTRL_00_NCONFIG;
- WRITE4(sc, IMGCFG_CTRL_00, reg);
-
- /* b */
- reg = READ4(sc, IMGCFG_CTRL_01);
- reg &= ~CTRL_01_S2F_NCE;
- WRITE4(sc, IMGCFG_CTRL_01, reg);
-
- /* c */
- reg = READ4(sc, IMGCFG_CTRL_02);
- reg |= CTRL_02_EN_CFG_CTRL;
- WRITE4(sc, IMGCFG_CTRL_02, reg);
-
- /* d */
- reg = READ4(sc, IMGCFG_CTRL_00);
- reg &= ~S2F_CONDONE_OE;
- reg &= ~S2F_NSTATUS_OE;
- reg |= CTRL_00_NCONFIG;
- reg |= CTRL_00_NENABLE_NSTATUS;
- reg |= CTRL_00_NENABLE_CONDONE;
- reg &= ~CTRL_00_NENABLE_NCONFIG;
- WRITE4(sc, IMGCFG_CTRL_00, reg);
-
- /* Step 5 */
- reg = READ4(sc, IMGCFG_CTRL_01);
- reg &= ~CTRL_01_S2F_NENABLE_CONFIG;
- WRITE4(sc, IMGCFG_CTRL_01, reg);
-
- /* Step 6 */
- fpga_wait_dclk_pulses(sc, 0x100);
-
- /* Step 7. a */
- reg = READ4(sc, IMGCFG_CTRL_01);
- reg |= CTRL_01_S2F_PR_REQUEST;
- WRITE4(sc, IMGCFG_CTRL_01, reg);
-
- /* b, c */
- fpga_wait_dclk_pulses(sc, 0x7ff);
-
- /* Step 8 */
- tout = 10;
- while (tout--) {
- reg = READ4(sc, IMGCFG_STAT);
- if (reg & F2S_PR_ERROR) {
- device_printf(sc->dev,
- "Error: PR failed on open.\n");
- return (ENXIO);
- }
- if (reg & F2S_PR_READY) {
- break;
- }
- }
- if (tout == 0) {
- device_printf(sc->dev,
- "Error: Timeout waiting PR ready bit.\n");
- return (ENXIO);
- }
-
- return (0);
-}
-
-static int
-fpga_close(struct cdev *dev, int flags __unused,
- int fmt __unused, struct thread *td __unused)
-{
- struct fpgamgr_a10_softc *sc;
- int tout;
- int reg;
-
- sc = dev->si_drv1;
-
- /* Step 10 */
- tout = 10;
- while (tout--) {
- reg = READ4(sc, IMGCFG_STAT);
- if (reg & F2S_PR_ERROR) {
- device_printf(sc->dev,
- "Error: PR failed.\n");
- return (ENXIO);
- }
- if (reg & F2S_PR_DONE) {
- break;
- }
- }
-
- /* Step 11 */
- reg = READ4(sc, IMGCFG_CTRL_01);
- reg &= ~CTRL_01_S2F_PR_REQUEST;
- WRITE4(sc, IMGCFG_CTRL_01, reg);
-
- /* Step 12, 13 */
- fpga_wait_dclk_pulses(sc, 0x100);
-
- /* Step 14 */
- reg = READ4(sc, IMGCFG_CTRL_02);
- reg &= ~CTRL_02_EN_CFG_CTRL;
- WRITE4(sc, IMGCFG_CTRL_02, reg);
-
- /* Step 15 */
- reg = READ4(sc, IMGCFG_CTRL_01);
- reg |= CTRL_01_S2F_NCE;
- WRITE4(sc, IMGCFG_CTRL_01, reg);
-
- /* Step 16 */
- reg = READ4(sc, IMGCFG_CTRL_01);
- reg |= CTRL_01_S2F_NENABLE_CONFIG;
- WRITE4(sc, IMGCFG_CTRL_01, reg);
-
- /* Step 17 */
- reg = READ4(sc, IMGCFG_STAT);
- if ((reg & F2S_USERMODE) == 0) {
- device_printf(sc->dev,
- "Error: invalid mode\n");
- return (ENXIO);
- };
-
- if ((reg & F2S_CONDONE_PIN) == 0) {
- device_printf(sc->dev,
- "Error: configuration not done\n");
- return (ENXIO);
- };
-
- if ((reg & F2S_NSTATUS_PIN) == 0) {
- device_printf(sc->dev,
- "Error: nstatus pin\n");
- return (ENXIO);
- };
-
- return (0);
-}
-
-static int
-fpga_write(struct cdev *dev, struct uio *uio, int ioflag)
-{
- struct fpgamgr_a10_softc *sc;
- uint32_t buffer;
-
- sc = dev->si_drv1;
-
- /*
- * Step 9.
- * Device supports 4-byte writes only.
- */
-
- while (uio->uio_resid >= 4) {
- uiomove(&buffer, 4, uio);
- bus_space_write_4(sc->bst_data, sc->bsh_data,
- 0x0, buffer);
- }
-
- switch (uio->uio_resid) {
- case 3:
- uiomove(&buffer, 3, uio);
- buffer &= 0xffffff;
- bus_space_write_4(sc->bst_data, sc->bsh_data,
- 0x0, buffer);
- break;
- case 2:
- uiomove(&buffer, 2, uio);
- buffer &= 0xffff;
- bus_space_write_4(sc->bst_data, sc->bsh_data,
- 0x0, buffer);
- break;
- case 1:
- uiomove(&buffer, 1, uio);
- buffer &= 0xff;
- bus_space_write_4(sc->bst_data, sc->bsh_data,
- 0x0, buffer);
- break;
- default:
- break;
- };
-
- return (0);
-}
-
-static int
-fpga_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
- struct thread *td)
-{
-
- return (0);
-}
-
-static struct cdevsw fpga_cdevsw = {
- .d_version = D_VERSION,
- .d_open = fpga_open,
- .d_close = fpga_close,
- .d_write = fpga_write,
- .d_ioctl = fpga_ioctl,
- .d_name = "FPGA Manager",
-};
-
-static int
-fpgamgr_a10_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "altr,socfpga-a10-fpga-mgr"))
- return (ENXIO);
-
- device_set_desc(dev, "Arria 10 FPGA Manager");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-fpgamgr_a10_attach(device_t dev)
-{
- struct fpgamgr_a10_softc *sc;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, fpgamgr_a10_spec, sc->res)) {
- device_printf(dev, "Could not allocate resources.\n");
- return (ENXIO);
- }
-
- /* Memory interface */
- sc->bst_data = rman_get_bustag(sc->res[1]);
- sc->bsh_data = rman_get_bushandle(sc->res[1]);
-
- sc->mgr_cdev = make_dev(&fpga_cdevsw, 0, UID_ROOT, GID_WHEEL,
- 0600, "fpga%d", device_get_unit(sc->dev));
-
- if (sc->mgr_cdev == NULL) {
- device_printf(dev, "Failed to create character device.\n");
- return (ENXIO);
- }
-
- sc->mgr_cdev->si_drv1 = sc;
-
- return (0);
-}
-
-static device_method_t fpgamgr_a10_methods[] = {
- DEVMETHOD(device_probe, fpgamgr_a10_probe),
- DEVMETHOD(device_attach, fpgamgr_a10_attach),
- { 0, 0 }
-};
-
-static driver_t fpgamgr_a10_driver = {
- "fpgamgr_a10",
- fpgamgr_a10_methods,
- sizeof(struct fpgamgr_a10_softc),
-};
-
-DRIVER_MODULE(fpgamgr_a10, simplebus, fpgamgr_a10_driver, 0, 0);
diff --git a/sys/arm/altera/socfpga/socfpga_common.c b/sys/arm/altera/socfpga/socfpga_common.c
deleted file mode 100644
index 6d9af3145dad..000000000000
--- a/sys/arm/altera/socfpga/socfpga_common.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * Copyright (c) 2014 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include
-#include
-#include
-#include
-
-#include
-
-#include
-#include
-
-#include
diff --git a/sys/arm/altera/socfpga/socfpga_common.h b/sys/arm/altera/socfpga/socfpga_common.h
deleted file mode 100644
index 3ab85a71c2a0..000000000000
--- a/sys/arm/altera/socfpga/socfpga_common.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * Copyright (c) 2014 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#define READ4(_sc, _reg) bus_read_4((_sc)->res[0], _reg)
-#define READ2(_sc, _reg) bus_read_2((_sc)->res[0], _reg)
-#define READ1(_sc, _reg) bus_read_1((_sc)->res[0], _reg)
-#define WRITE4(_sc, _reg, _val) bus_write_4((_sc)->res[0], _reg, _val)
-#define WRITE2(_sc, _reg, _val) bus_write_2((_sc)->res[0], _reg, _val)
-#define WRITE1(_sc, _reg, _val) bus_write_1((_sc)->res[0], _reg, _val)
diff --git a/sys/arm/altera/socfpga/socfpga_l3regs.h b/sys/arm/altera/socfpga/socfpga_l3regs.h
deleted file mode 100644
index 2fc4a7859588..000000000000
--- a/sys/arm/altera/socfpga/socfpga_l3regs.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * Copyright (c) 2014 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#define L3REGS_REMAP 0x0 /* Remap */
-#define REMAP_LWHPS2FPGA (1 << 4)
-#define REMAP_HPS2FPGA (1 << 3)
-#define REMAP_MPUZERO (1 << 0)
-#define L3REGS_L4MAIN 0x8 /* L4 main peripherals security */
-#define L3REGS_L4SP 0xC /* L4 SP Peripherals Security */
-#define L3REGS_L4MP 0x10 /* L4 MP Peripherals Security */
-#define L3REGS_L4OSC1 0x14 /* L4 OSC1 Peripherals Security */
-#define L3REGS_L4SPIM 0x18 /* L4 SPIM Peripherals Security */
-#define L3REGS_STM 0x1C /* STM Peripheral Security */
-#define L3REGS_LWHPS2FPGAREGS 0x20 /* LWHPS2FPGA AXI Bridge Security */
-#define L3REGS_USB1 0x28 /* USB1 Peripheral Security */
-#define L3REGS_NANDDATA 0x2C /* NAND Flash Controller Data Sec */
-#define L3REGS_USB0 0x80 /* USB0 Peripheral Security */
-#define L3REGS_NANDREGS 0x84 /* NAND Flash Controller Security */
-#define L3REGS_QSPIDATA 0x88 /* QSPI Flash Controller Data Sec */
-#define L3REGS_FPGAMGRDATA 0x8C /* FPGA Manager Data Peripheral Sec */
-#define L3REGS_HPS2FPGAREGS 0x90 /* HPS2FPGA AXI Bridge Perip. Sec */
-#define L3REGS_ACP 0x94 /* MPU ACP Peripheral Security */
-#define L3REGS_ROM 0x98 /* ROM Peripheral Security */
-#define L3REGS_OCRAM 0x9C /* On-chip RAM Peripheral Security */
-#define L3REGS_SDRDATA 0xA0 /* SDRAM Data Peripheral Security */
diff --git a/sys/arm/altera/socfpga/socfpga_machdep.c b/sys/arm/altera/socfpga/socfpga_machdep.c
deleted file mode 100644
index e01383810177..000000000000
--- a/sys/arm/altera/socfpga/socfpga_machdep.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*-
- * Copyright (c) 2014-2017 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include "opt_platform.h"
-
-#include
-#include
-#include
-#include
-
-#include
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include "platform_if.h"
-
-#if defined(SOC_ALTERA_CYCLONE5)
-static int
-socfpga_devmap_init(platform_t plat)
-{
-
- /* UART */
- devmap_add_entry(0xffc00000, 0x100000);
-
- /*
- * USB OTG
- *
- * We use static device map for USB due to some bug in the Altera
- * which throws Translation Fault (P) exception on high load.
- * It might be caused due to some power save options being turned
- * on or something else.
- */
- devmap_add_entry(0xffb00000, 0x100000);
-
- /* dwmmc */
- devmap_add_entry(0xff700000, 0x100000);
-
- /* scu */
- devmap_add_entry(0xfff00000, 0x100000);
-
- /* FPGA memory window, 256MB */
- devmap_add_entry(0xd0000000, 0x10000000);
-
- return (0);
-}
-#endif
-
-#if defined(SOC_ALTERA_ARRIA10)
-static int
-socfpga_a10_devmap_init(platform_t plat)
-{
-
- /* UART */
- devmap_add_entry(0xffc00000, 0x100000);
-
- /* USB OTG */
- devmap_add_entry(0xffb00000, 0x100000);
-
- /* dwmmc */
- devmap_add_entry(0xff800000, 0x100000);
-
- /* scu */
- devmap_add_entry(0xfff00000, 0x100000);
-
- return (0);
-}
-#endif
-
-static void
-_socfpga_cpu_reset(bus_size_t reg)
-{
- uint32_t paddr;
- bus_addr_t vaddr;
- phandle_t node;
-
- if (rstmgr_warmreset(reg) == 0)
- goto end;
-
- node = OF_finddevice("/soc/rstmgr");
- if (node == -1)
- goto end;
-
- if ((OF_getencprop(node, "reg", &paddr, sizeof(paddr))) > 0) {
- if (bus_space_map(fdtbus_bs_tag, paddr, 0x8, 0, &vaddr) == 0) {
- bus_space_write_4(fdtbus_bs_tag, vaddr,
- reg, CTRL_SWWARMRSTREQ);
- }
- }
-
-end:
- while (1);
-}
-
-#if defined(SOC_ALTERA_CYCLONE5)
-static void
-socfpga_cpu_reset(platform_t plat)
-{
-
- _socfpga_cpu_reset(RSTMGR_CTRL);
-}
-#endif
-
-#if defined(SOC_ALTERA_ARRIA10)
-static void
-socfpga_a10_cpu_reset(platform_t plat)
-{
-
- _socfpga_cpu_reset(RSTMGR_A10_CTRL);
-}
-#endif
-
-#if defined(SOC_ALTERA_CYCLONE5)
-static platform_method_t socfpga_methods[] = {
- PLATFORMMETHOD(platform_devmap_init, socfpga_devmap_init),
- PLATFORMMETHOD(platform_cpu_reset, socfpga_cpu_reset),
-#ifdef SMP
- PLATFORMMETHOD(platform_mp_setmaxid, socfpga_mp_setmaxid),
- PLATFORMMETHOD(platform_mp_start_ap, socfpga_mp_start_ap),
-#endif
- PLATFORMMETHOD_END,
-};
-FDT_PLATFORM_DEF(socfpga, "socfpga", 0, "altr,socfpga-cyclone5", 200);
-#endif
-
-#if defined(SOC_ALTERA_ARRIA10)
-static platform_method_t socfpga_a10_methods[] = {
- PLATFORMMETHOD(platform_devmap_init, socfpga_a10_devmap_init),
- PLATFORMMETHOD(platform_cpu_reset, socfpga_a10_cpu_reset),
-#ifdef SMP
- PLATFORMMETHOD(platform_mp_setmaxid, socfpga_mp_setmaxid),
- PLATFORMMETHOD(platform_mp_start_ap, socfpga_a10_mp_start_ap),
-#endif
- PLATFORMMETHOD_END,
-};
-FDT_PLATFORM_DEF(socfpga_a10, "socfpga", 0, "altr,socfpga-arria10", 200);
-#endif
diff --git a/sys/arm/altera/socfpga/socfpga_manager.c b/sys/arm/altera/socfpga/socfpga_manager.c
deleted file mode 100644
index d25d34ab80e7..000000000000
--- a/sys/arm/altera/socfpga/socfpga_manager.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/*-
- * Copyright (c) 2014 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-/*
- * Altera FPGA Manager.
- * Chapter 4, Cyclone V Device Handbook (CV-5V2 2014.07.22)
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-
-/* FPGA Manager Module Registers */
-#define FPGAMGR_STAT 0x0 /* Status Register */
-#define STAT_MSEL_MASK 0x1f
-#define STAT_MSEL_SHIFT 3
-#define STAT_MODE_SHIFT 0
-#define STAT_MODE_MASK 0x7
-#define FPGAMGR_CTRL 0x4 /* Control Register */
-#define CTRL_AXICFGEN (1 << 8)
-#define CTRL_CDRATIO_MASK 0x3
-#define CTRL_CDRATIO_SHIFT 6
-#define CTRL_CFGWDTH_MASK 1
-#define CTRL_CFGWDTH_SHIFT 9
-#define CTRL_NCONFIGPULL (1 << 2)
-#define CTRL_NCE (1 << 1)
-#define CTRL_EN (1 << 0)
-#define FPGAMGR_DCLKCNT 0x8 /* DCLK Count Register */
-#define FPGAMGR_DCLKSTAT 0xC /* DCLK Status Register */
-#define FPGAMGR_GPO 0x10 /* General-Purpose Output Register */
-#define FPGAMGR_GPI 0x14 /* General-Purpose Input Register */
-#define FPGAMGR_MISCI 0x18 /* Miscellaneous Input Register */
-
-/* Configuration Monitor (MON) Registers */
-#define GPIO_INTEN 0x830 /* Interrupt Enable Register */
-#define GPIO_INTMASK 0x834 /* Interrupt Mask Register */
-#define GPIO_INTTYPE_LEVEL 0x838 /* Interrupt Level Register */
-#define GPIO_INT_POLARITY 0x83C /* Interrupt Polarity Register */
-#define GPIO_INTSTATUS 0x840 /* Interrupt Status Register */
-#define GPIO_RAW_INTSTATUS 0x844 /* Raw Interrupt Status Register */
-#define GPIO_PORTA_EOI 0x84C /* Clear Interrupt Register */
-#define PORTA_EOI_NS (1 << 0)
-#define GPIO_EXT_PORTA 0x850 /* External Port A Register */
-#define EXT_PORTA_CDP (1 << 10) /* Configuration done */
-#define GPIO_LS_SYNC 0x860 /* Synchronization Level Register */
-#define GPIO_VER_ID_CODE 0x86C /* GPIO Version Register */
-#define GPIO_CONFIG_REG2 0x870 /* Configuration Register 2 */
-#define GPIO_CONFIG_REG1 0x874 /* Configuration Register 1 */
-
-#define MSEL_PP16_FAST_NOAES_NODC 0x0
-#define MSEL_PP16_FAST_AES_NODC 0x1
-#define MSEL_PP16_FAST_AESOPT_DC 0x2
-#define MSEL_PP16_SLOW_NOAES_NODC 0x4
-#define MSEL_PP16_SLOW_AES_NODC 0x5
-#define MSEL_PP16_SLOW_AESOPT_DC 0x6
-#define MSEL_PP32_FAST_NOAES_NODC 0x8
-#define MSEL_PP32_FAST_AES_NODC 0x9
-#define MSEL_PP32_FAST_AESOPT_DC 0xa
-#define MSEL_PP32_SLOW_NOAES_NODC 0xc
-#define MSEL_PP32_SLOW_AES_NODC 0xd
-#define MSEL_PP32_SLOW_AESOPT_DC 0xe
-
-#define CFGWDTH_16 0
-#define CFGWDTH_32 1
-
-#define CDRATIO_1 0
-#define CDRATIO_2 1
-#define CDRATIO_4 2
-#define CDRATIO_8 3
-
-#define FPGAMGR_MODE_POWEROFF 0x0
-#define FPGAMGR_MODE_RESET 0x1
-#define FPGAMGR_MODE_CONFIG 0x2
-#define FPGAMGR_MODE_INIT 0x3
-#define FPGAMGR_MODE_USER 0x4
-
-struct cfgmgr_mode {
- int msel;
- int cfgwdth;
- int cdratio;
-};
-
-static struct cfgmgr_mode cfgmgr_modes[] = {
- { MSEL_PP16_FAST_NOAES_NODC, CFGWDTH_16, CDRATIO_1 },
- { MSEL_PP16_FAST_AES_NODC, CFGWDTH_16, CDRATIO_2 },
- { MSEL_PP16_FAST_AESOPT_DC, CFGWDTH_16, CDRATIO_4 },
- { MSEL_PP16_SLOW_NOAES_NODC, CFGWDTH_16, CDRATIO_1 },
- { MSEL_PP16_SLOW_AES_NODC, CFGWDTH_16, CDRATIO_2 },
- { MSEL_PP16_SLOW_AESOPT_DC, CFGWDTH_16, CDRATIO_4 },
- { MSEL_PP32_FAST_NOAES_NODC, CFGWDTH_32, CDRATIO_1 },
- { MSEL_PP32_FAST_AES_NODC, CFGWDTH_32, CDRATIO_4 },
- { MSEL_PP32_FAST_AESOPT_DC, CFGWDTH_32, CDRATIO_8 },
- { MSEL_PP32_SLOW_NOAES_NODC, CFGWDTH_32, CDRATIO_1 },
- { MSEL_PP32_SLOW_AES_NODC, CFGWDTH_32, CDRATIO_4 },
- { MSEL_PP32_SLOW_AESOPT_DC, CFGWDTH_32, CDRATIO_8 },
- { -1, -1, -1 },
-};
-
-struct fpgamgr_softc {
- struct resource *res[3];
- bus_space_tag_t bst_data;
- bus_space_handle_t bsh_data;
- struct cdev *mgr_cdev;
- device_t dev;
-};
-
-static struct resource_spec fpgamgr_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_MEMORY, 1, RF_ACTIVE },
- { SYS_RES_IRQ, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-static int
-fpgamgr_state_get(struct fpgamgr_softc *sc)
-{
- int reg;
-
- reg = READ4(sc, FPGAMGR_STAT);
- reg >>= STAT_MODE_SHIFT;
- reg &= STAT_MODE_MASK;
-
- return reg;
-}
-
-static int
-fpgamgr_state_wait(struct fpgamgr_softc *sc, int state)
-{
- int tout;
-
- tout = 1000;
- while (tout > 0) {
- if (fpgamgr_state_get(sc) == state)
- break;
- tout--;
- DELAY(10);
- }
- if (tout == 0) {
- return (1);
- }
-
- return (0);
-}
-
-static int
-fpga_open(struct cdev *dev, int flags __unused,
- int fmt __unused, struct thread *td __unused)
-{
- struct fpgamgr_softc *sc;
- struct cfgmgr_mode *mode;
- int msel;
- int reg;
- int i;
-
- sc = dev->si_drv1;
-
- msel = READ4(sc, FPGAMGR_STAT);
- msel >>= STAT_MSEL_SHIFT;
- msel &= STAT_MSEL_MASK;
-
- mode = NULL;
- for (i = 0; cfgmgr_modes[i].msel != -1; i++) {
- if (msel == cfgmgr_modes[i].msel) {
- mode = &cfgmgr_modes[i];
- break;
- }
- }
- if (mode == NULL) {
- device_printf(sc->dev, "Can't configure: unknown mode\n");
- return (ENXIO);
- }
-
- reg = READ4(sc, FPGAMGR_CTRL);
- reg &= ~(CTRL_CDRATIO_MASK << CTRL_CDRATIO_SHIFT);
- reg |= (mode->cdratio << CTRL_CDRATIO_SHIFT);
- reg &= ~(CTRL_CFGWDTH_MASK << CTRL_CFGWDTH_SHIFT);
- reg |= (mode->cfgwdth << CTRL_CFGWDTH_SHIFT);
- reg &= ~(CTRL_NCE);
- WRITE4(sc, FPGAMGR_CTRL, reg);
-
- /* Enable configuration */
- reg = READ4(sc, FPGAMGR_CTRL);
- reg |= (CTRL_EN);
- WRITE4(sc, FPGAMGR_CTRL, reg);
-
- /* Reset FPGA */
- reg = READ4(sc, FPGAMGR_CTRL);
- reg |= (CTRL_NCONFIGPULL);
- WRITE4(sc, FPGAMGR_CTRL, reg);
-
- /* Wait reset state */
- if (fpgamgr_state_wait(sc, FPGAMGR_MODE_RESET)) {
- device_printf(sc->dev, "Can't get RESET state\n");
- return (ENXIO);
- }
-
- /* Release from reset */
- reg = READ4(sc, FPGAMGR_CTRL);
- reg &= ~(CTRL_NCONFIGPULL);
- WRITE4(sc, FPGAMGR_CTRL, reg);
-
- if (fpgamgr_state_wait(sc, FPGAMGR_MODE_CONFIG)) {
- device_printf(sc->dev, "Can't get CONFIG state\n");
- return (ENXIO);
- }
-
- /* Clear nSTATUS edge interrupt */
- WRITE4(sc, GPIO_PORTA_EOI, PORTA_EOI_NS);
-
- /* Enter configuration state */
- reg = READ4(sc, FPGAMGR_CTRL);
- reg |= (CTRL_AXICFGEN);
- WRITE4(sc, FPGAMGR_CTRL, reg);
-
- return (0);
-}
-
-static int
-fpga_wait_dclk_pulses(struct fpgamgr_softc *sc, int npulses)
-{
- int tout;
-
- /* Clear done bit, if any */
- if (READ4(sc, FPGAMGR_DCLKSTAT) != 0)
- WRITE4(sc, FPGAMGR_DCLKSTAT, 0x1);
-
- /* Request DCLK pulses */
- WRITE4(sc, FPGAMGR_DCLKCNT, npulses);
-
- /* Wait finish */
- tout = 1000;
- while (tout > 0) {
- if (READ4(sc, FPGAMGR_DCLKSTAT) == 1) {
- WRITE4(sc, FPGAMGR_DCLKSTAT, 0x1);
- break;
- }
- tout--;
- DELAY(10);
- }
- if (tout == 0) {
- return (1);
- }
-
- return (0);
-}
-
-static int
-fpga_close(struct cdev *dev, int flags __unused,
- int fmt __unused, struct thread *td __unused)
-{
- struct fpgamgr_softc *sc;
- int reg;
-
- sc = dev->si_drv1;
-
- reg = READ4(sc, GPIO_EXT_PORTA);
- if ((reg & EXT_PORTA_CDP) == 0) {
- device_printf(sc->dev, "Err: configuration failed\n");
- return (ENXIO);
- }
-
- /* Exit configuration state */
- reg = READ4(sc, FPGAMGR_CTRL);
- reg &= ~(CTRL_AXICFGEN);
- WRITE4(sc, FPGAMGR_CTRL, reg);
-
- /* Wait dclk pulses */
- if (fpga_wait_dclk_pulses(sc, 4)) {
- device_printf(sc->dev, "Can't proceed 4 dclk pulses\n");
- return (ENXIO);
- }
-
- if (fpgamgr_state_wait(sc, FPGAMGR_MODE_USER)) {
- device_printf(sc->dev, "Can't get USER mode\n");
- return (ENXIO);
- }
-
- /* Disable configuration */
- reg = READ4(sc, FPGAMGR_CTRL);
- reg &= ~(CTRL_EN);
- WRITE4(sc, FPGAMGR_CTRL, reg);
-
- return (0);
-}
-
-static int
-fpga_write(struct cdev *dev, struct uio *uio, int ioflag)
-{
- struct fpgamgr_softc *sc;
- int buffer;
-
- sc = dev->si_drv1;
-
- /*
- * Device supports 4-byte copy only.
- * TODO: add padding for <4 bytes.
- */
-
- while (uio->uio_resid > 0) {
- uiomove(&buffer, 4, uio);
- bus_space_write_4(sc->bst_data, sc->bsh_data,
- 0x0, buffer);
- }
-
- return (0);
-}
-
-static int
-fpga_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags,
- struct thread *td)
-{
-
- return (0);
-}
-
-static struct cdevsw fpga_cdevsw = {
- .d_version = D_VERSION,
- .d_open = fpga_open,
- .d_close = fpga_close,
- .d_write = fpga_write,
- .d_ioctl = fpga_ioctl,
- .d_name = "FPGA Manager",
-};
-
-static int
-fpgamgr_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "altr,socfpga-fpga-mgr"))
- return (ENXIO);
-
- device_set_desc(dev, "FPGA Manager");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-fpgamgr_attach(device_t dev)
-{
- struct fpgamgr_softc *sc;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, fpgamgr_spec, sc->res)) {
- device_printf(dev, "could not allocate resources\n");
- return (ENXIO);
- }
-
- /* Memory interface */
- sc->bst_data = rman_get_bustag(sc->res[1]);
- sc->bsh_data = rman_get_bushandle(sc->res[1]);
-
- sc->mgr_cdev = make_dev(&fpga_cdevsw, 0, UID_ROOT, GID_WHEEL,
- 0600, "fpga%d", device_get_unit(sc->dev));
-
- if (sc->mgr_cdev == NULL) {
- device_printf(dev, "Failed to create character device.\n");
- return (ENXIO);
- }
-
- sc->mgr_cdev->si_drv1 = sc;
-
- return (0);
-}
-
-static device_method_t fpgamgr_methods[] = {
- DEVMETHOD(device_probe, fpgamgr_probe),
- DEVMETHOD(device_attach, fpgamgr_attach),
- { 0, 0 }
-};
-
-static driver_t fpgamgr_driver = {
- "fpgamgr",
- fpgamgr_methods,
- sizeof(struct fpgamgr_softc),
-};
-
-DRIVER_MODULE(fpgamgr, simplebus, fpgamgr_driver, 0, 0);
diff --git a/sys/arm/altera/socfpga/socfpga_mp.c b/sys/arm/altera/socfpga/socfpga_mp.c
deleted file mode 100644
index fd752b11267c..000000000000
--- a/sys/arm/altera/socfpga/socfpga_mp.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/*-
- * Copyright (c) 2014-2017 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include "opt_platform.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#define SCU_PHYSBASE 0xFFFEC000
-#define SCU_PHYSBASE_A10 0xFFFFC000
-#define SCU_SIZE 0x100
-
-#define SCU_CONTROL_REG 0x00
-#define SCU_CONTROL_ENABLE (1 << 0)
-#define SCU_CONFIG_REG 0x04
-#define SCU_CONFIG_REG_NCPU_MASK 0x03
-#define SCU_CPUPOWER_REG 0x08
-#define SCU_INV_TAGS_REG 0x0c
-#define SCU_DIAG_CONTROL 0x30
-#define SCU_DIAG_DISABLE_MIGBIT (1 << 0)
-#define SCU_FILTER_START_REG 0x40
-#define SCU_FILTER_END_REG 0x44
-#define SCU_SECURE_ACCESS_REG 0x50
-#define SCU_NONSECURE_ACCESS_REG 0x54
-
-#define RSTMGR_PHYSBASE 0xFFD05000
-#define RSTMGR_SIZE 0x100
-
-#define RAM_PHYSBASE 0x0
-#define RAM_SIZE 0x1000
-
-#define SOCFPGA_ARRIA10 1
-#define SOCFPGA_CYCLONE5 2
-
-extern char *mpentry_addr;
-static void socfpga_trampoline(void);
-
-static void
-socfpga_trampoline(void)
-{
-
- __asm __volatile(
- "ldr pc, 1f\n"
- ".globl mpentry_addr\n"
- "mpentry_addr:\n"
- "1: .space 4\n");
-}
-
-void
-socfpga_mp_setmaxid(platform_t plat)
-{
- int hwcpu, ncpu;
-
- /* If we've already set this don't bother to do it again. */
- if (mp_ncpus != 0)
- return;
-
- hwcpu = 2;
-
- ncpu = hwcpu;
- TUNABLE_INT_FETCH("hw.ncpu", &ncpu);
- if (ncpu < 1 || ncpu > hwcpu)
- ncpu = hwcpu;
-
- mp_ncpus = ncpu;
- mp_maxid = ncpu - 1;
-}
-
-static void
-_socfpga_mp_start_ap(uint32_t platid)
-{
- bus_space_handle_t scu, rst, ram;
- int reg;
-
- switch (platid) {
-#if defined(SOC_ALTERA_ARRIA10)
- case SOCFPGA_ARRIA10:
- if (bus_space_map(fdtbus_bs_tag, SCU_PHYSBASE_A10,
- SCU_SIZE, 0, &scu) != 0)
- panic("Couldn't map the SCU\n");
- break;
-#endif
-#if defined(SOC_ALTERA_CYCLONE5)
- case SOCFPGA_CYCLONE5:
- if (bus_space_map(fdtbus_bs_tag, SCU_PHYSBASE,
- SCU_SIZE, 0, &scu) != 0)
- panic("Couldn't map the SCU\n");
- break;
-#endif
- default:
- panic("Unknown platform id %d\n", platid);
- }
-
- if (bus_space_map(fdtbus_bs_tag, RSTMGR_PHYSBASE,
- RSTMGR_SIZE, 0, &rst) != 0)
- panic("Couldn't map the reset manager (RSTMGR)\n");
- if (bus_space_map(fdtbus_bs_tag, RAM_PHYSBASE,
- RAM_SIZE, 0, &ram) != 0)
- panic("Couldn't map the first physram page\n");
-
- /* Invalidate SCU cache tags */
- bus_space_write_4(fdtbus_bs_tag, scu,
- SCU_INV_TAGS_REG, 0x0000ffff);
-
- /*
- * Erratum ARM/MP: 764369 (problems with cache maintenance).
- * Setting the "disable-migratory bit" in the undocumented SCU
- * Diagnostic Control Register helps work around the problem.
- */
- reg = bus_space_read_4(fdtbus_bs_tag, scu, SCU_DIAG_CONTROL);
- reg |= (SCU_DIAG_DISABLE_MIGBIT);
- bus_space_write_4(fdtbus_bs_tag, scu, SCU_DIAG_CONTROL, reg);
-
- /* Put CPU1 to reset state */
- switch (platid) {
-#if defined(SOC_ALTERA_ARRIA10)
- case SOCFPGA_ARRIA10:
- bus_space_write_4(fdtbus_bs_tag, rst,
- RSTMGR_A10_MPUMODRST, MPUMODRST_CPU1);
- break;
-#endif
-#if defined(SOC_ALTERA_CYCLONE5)
- case SOCFPGA_CYCLONE5:
- bus_space_write_4(fdtbus_bs_tag, rst,
- RSTMGR_MPUMODRST, MPUMODRST_CPU1);
- break;
-#endif
- default:
- panic("Unknown platform id %d\n", platid);
- }
-
- /* Enable the SCU, then clean the cache on this core */
- reg = bus_space_read_4(fdtbus_bs_tag, scu, SCU_CONTROL_REG);
- reg |= (SCU_CONTROL_ENABLE);
- bus_space_write_4(fdtbus_bs_tag, scu, SCU_CONTROL_REG, reg);
-
- /* Set up trampoline code */
- mpentry_addr = (char *)pmap_kextract((vm_offset_t)mpentry);
- bus_space_write_region_4(fdtbus_bs_tag, ram, 0,
- (uint32_t *)&socfpga_trampoline, 8);
-
- dcache_wbinv_poc_all();
-
- /* Put CPU1 out from reset */
- switch (platid) {
-#if defined(SOC_ALTERA_ARRIA10)
- case SOCFPGA_ARRIA10:
- bus_space_write_4(fdtbus_bs_tag, rst,
- RSTMGR_A10_MPUMODRST, 0);
- break;
-#endif
-#if defined(SOC_ALTERA_CYCLONE5)
- case SOCFPGA_CYCLONE5:
- bus_space_write_4(fdtbus_bs_tag, rst,
- RSTMGR_MPUMODRST, 0);
- break;
-#endif
- default:
- panic("Unknown platform id %d\n", platid);
- }
-
- dsb();
- sev();
-
- bus_space_unmap(fdtbus_bs_tag, scu, SCU_SIZE);
- bus_space_unmap(fdtbus_bs_tag, rst, RSTMGR_SIZE);
- bus_space_unmap(fdtbus_bs_tag, ram, RAM_SIZE);
-}
-
-#if defined(SOC_ALTERA_ARRIA10)
-void
-socfpga_a10_mp_start_ap(platform_t plat)
-{
-
- _socfpga_mp_start_ap(SOCFPGA_ARRIA10);
-}
-#endif
-
-#if defined(SOC_ALTERA_CYCLONE5)
-void
-socfpga_mp_start_ap(platform_t plat)
-{
-
- _socfpga_mp_start_ap(SOCFPGA_CYCLONE5);
-}
-#endif
diff --git a/sys/arm/altera/socfpga/socfpga_mp.h b/sys/arm/altera/socfpga/socfpga_mp.h
deleted file mode 100644
index d724296faa7e..000000000000
--- a/sys/arm/altera/socfpga/socfpga_mp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * Copyright (c) 2017 Andrew Turner
- * 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 ``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 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.
- */
-
-#ifndef _SOCFPGA_MP_H_
-#define _SOCFPGA_MP_H_
-
-void socfpga_mp_setmaxid(platform_t);
-void socfpga_mp_start_ap(platform_t);
-void socfpga_a10_mp_start_ap(platform_t);
-
-#endif /* _SOCFPGA_MP_H_ */
diff --git a/sys/arm/altera/socfpga/socfpga_rstmgr.c b/sys/arm/altera/socfpga/socfpga_rstmgr.c
deleted file mode 100644
index 4fbed06e3954..000000000000
--- a/sys/arm/altera/socfpga/socfpga_rstmgr.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/*-
- * Copyright (c) 2014-2017 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-/*
- * SOCFPGA Reset Manager.
- * Chapter 3, Cyclone V Device Handbook (CV-5V2 2014.07.22)
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-struct rstmgr_softc {
- struct resource *res[1];
- bus_space_tag_t bst;
- bus_space_handle_t bsh;
- device_t dev;
-};
-
-struct rstmgr_softc *rstmgr_sc;
-
-static struct resource_spec rstmgr_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-enum {
- RSTMGR_SYSCTL_FPGA2HPS,
- RSTMGR_SYSCTL_LWHPS2FPGA,
- RSTMGR_SYSCTL_HPS2FPGA
-};
-
-static int
-l3remap(struct rstmgr_softc *sc, int remap, int enable)
-{
- uint32_t paddr;
- bus_addr_t vaddr;
- phandle_t node;
- int reg;
-
- /*
- * Control whether bridge is visible to L3 masters or not.
- * Register is write-only.
- */
-
- reg = REMAP_MPUZERO;
- if (enable)
- reg |= (remap);
- else
- reg &= ~(remap);
-
- node = OF_finddevice("l3regs");
- if (node == -1) {
- device_printf(sc->dev, "Can't find l3regs node\n");
- return (1);
- }
-
- if ((OF_getencprop(node, "reg", &paddr, sizeof(paddr))) > 0) {
- if (bus_space_map(fdtbus_bs_tag, paddr, 0x4, 0, &vaddr) == 0) {
- bus_space_write_4(fdtbus_bs_tag, vaddr,
- L3REGS_REMAP, reg);
- return (0);
- }
- }
-
- return (1);
-}
-
-static int
-rstmgr_sysctl(SYSCTL_HANDLER_ARGS)
-{
- struct rstmgr_softc *sc;
- int enable;
- int remap;
- int err;
- int reg;
- int bit;
-
- sc = arg1;
-
- switch (arg2) {
- case RSTMGR_SYSCTL_FPGA2HPS:
- bit = BRGMODRST_FPGA2HPS;
- remap = 0;
- break;
- case RSTMGR_SYSCTL_LWHPS2FPGA:
- bit = BRGMODRST_LWHPS2FPGA;
- remap = REMAP_LWHPS2FPGA;
- break;
- case RSTMGR_SYSCTL_HPS2FPGA:
- bit = BRGMODRST_HPS2FPGA;
- remap = REMAP_HPS2FPGA;
- break;
- default:
- return (1);
- }
-
- reg = READ4(sc, RSTMGR_BRGMODRST);
- enable = reg & bit ? 0 : 1;
-
- err = sysctl_handle_int(oidp, &enable, 0, req);
- if (err || !req->newptr)
- return (err);
-
- if (enable == 1)
- reg &= ~(bit);
- else if (enable == 0)
- reg |= (bit);
- else
- return (EINVAL);
-
- WRITE4(sc, RSTMGR_BRGMODRST, reg);
- l3remap(sc, remap, enable);
-
- return (0);
-}
-
-int
-rstmgr_warmreset(uint32_t reg)
-{
- struct rstmgr_softc *sc;
-
- sc = rstmgr_sc;
- if (sc == NULL)
- return (1);
-
- /* Request warm reset */
- WRITE4(sc, reg, CTRL_SWWARMRSTREQ);
-
- return (0);
-}
-
-static int
-rstmgr_add_sysctl(struct rstmgr_softc *sc)
-{
- struct sysctl_oid_list *children;
- struct sysctl_ctx_list *ctx;
-
- ctx = device_get_sysctl_ctx(sc->dev);
- children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev));
-
- SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "fpga2hps",
- CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
- sc, RSTMGR_SYSCTL_FPGA2HPS,
- rstmgr_sysctl, "I", "Enable fpga2hps bridge");
- SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "lwhps2fpga",
- CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
- sc, RSTMGR_SYSCTL_LWHPS2FPGA,
- rstmgr_sysctl, "I", "Enable lwhps2fpga bridge");
- SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "hps2fpga",
- CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT,
- sc, RSTMGR_SYSCTL_HPS2FPGA,
- rstmgr_sysctl, "I", "Enable hps2fpga bridge");
-
- return (0);
-}
-
-static int
-rstmgr_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "altr,rst-mgr"))
- return (ENXIO);
-
- device_set_desc(dev, "Reset Manager");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-rstmgr_attach(device_t dev)
-{
- struct rstmgr_softc *sc;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, rstmgr_spec, sc->res)) {
- device_printf(dev, "could not allocate resources\n");
- return (ENXIO);
- }
-
- /* Memory interface */
- sc->bst = rman_get_bustag(sc->res[0]);
- sc->bsh = rman_get_bushandle(sc->res[0]);
-
- rstmgr_sc = sc;
- rstmgr_add_sysctl(sc);
-
- return (0);
-}
-
-static device_method_t rstmgr_methods[] = {
- DEVMETHOD(device_probe, rstmgr_probe),
- DEVMETHOD(device_attach, rstmgr_attach),
- { 0, 0 }
-};
-
-static driver_t rstmgr_driver = {
- "rstmgr",
- rstmgr_methods,
- sizeof(struct rstmgr_softc),
-};
-
-DRIVER_MODULE(rstmgr, simplebus, rstmgr_driver, 0, 0);
diff --git a/sys/arm/altera/socfpga/socfpga_rstmgr.h b/sys/arm/altera/socfpga/socfpga_rstmgr.h
deleted file mode 100644
index 6ef152b5ddba..000000000000
--- a/sys/arm/altera/socfpga/socfpga_rstmgr.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 2014 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#define RSTMGR_STAT 0x0 /* Status */
-#define RSTMGR_CTRL 0x4 /* Control */
-#define CTRL_SWWARMRSTREQ (1 << 1) /* Trigger warm reset */
-#define RSTMGR_COUNTS 0x8 /* Reset Cycles Count */
-#define RSTMGR_MPUMODRST 0x10 /* MPU Module Reset */
-#define MPUMODRST_CPU1 (1 << 1)
-#define RSTMGR_PERMODRST 0x14 /* Peripheral Module Reset */
-#define RSTMGR_PER2MODRST 0x18 /* Peripheral 2 Module Reset */
-#define RSTMGR_BRGMODRST 0x1C /* Bridge Module Reset */
-#define BRGMODRST_FPGA2HPS (1 << 2)
-#define BRGMODRST_LWHPS2FPGA (1 << 1)
-#define BRGMODRST_HPS2FPGA (1 << 0)
-#define RSTMGR_MISCMODRST 0x20 /* Miscellaneous Module Reset */
-
-#define RSTMGR_A10_CTRL 0xC /* Control */
-#define RSTMGR_A10_MPUMODRST 0x20 /* MPU Module Reset */
-
-int rstmgr_warmreset(uint32_t reg);
diff --git a/sys/arm/altera/socfpga/std.socfpga b/sys/arm/altera/socfpga/std.socfpga
deleted file mode 100644
index 273fa9820943..000000000000
--- a/sys/arm/altera/socfpga/std.socfpga
+++ /dev/null
@@ -1,6 +0,0 @@
-
-cpu CPU_CORTEXA
-machine arm armv7
-makeoptions CONF_CFLAGS="-march=armv7a"
-
-files "../altera/socfpga/files.socfpga"
diff --git a/sys/conf/files b/sys/conf/files
index 24a61eed4eea..33faf6522e06 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -879,20 +879,6 @@ contrib/alpine-hal/eth/al_hal_eth_main.c optional al_eth \
dev/alc/if_alc.c optional alc pci
dev/ale/if_ale.c optional ale pci
dev/alpm/alpm.c optional alpm pci
-dev/altera/altpll/altpll.c optional altera_pll
-dev/altera/altpll/altpll_fdt.c optional altera_pll fdt fdt_clock
-dev/altera/avgen/altera_avgen.c optional altera_avgen
-dev/altera/avgen/altera_avgen_fdt.c optional altera_avgen fdt
-dev/altera/avgen/altera_avgen_nexus.c optional altera_avgen
-dev/altera/msgdma/msgdma.c optional altera_msgdma xdma
-dev/altera/sdcard/altera_sdcard.c optional altera_sdcard
-dev/altera/sdcard/altera_sdcard_disk.c optional altera_sdcard
-dev/altera/sdcard/altera_sdcard_io.c optional altera_sdcard
-dev/altera/sdcard/altera_sdcard_fdt.c optional altera_sdcard fdt
-dev/altera/sdcard/altera_sdcard_nexus.c optional altera_sdcard
-dev/altera/softdma/softdma.c optional altera_softdma xdma fdt
-dev/altera/pio/pio.c optional altera_pio
-dev/altera/pio/pio_if.m optional altera_pio
dev/amdpm/amdpm.c optional amdpm pci | nfpm pci
dev/amdsmb/amdsmb.c optional amdsmb pci
#
diff --git a/sys/conf/options b/sys/conf/options
index 5f2d5036a18b..3b6d5a6f68b3 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -71,7 +71,6 @@ TSLOGSIZE opt_global.h
# Miscellaneous options.
ALQ
-ALTERA_SDCARD_FAST_SIM opt_altera_sdcard.h
ATSE_CFI_HACK opt_cfi.h
AUDIT opt_global.h
BOOTHOWTO opt_global.h
@@ -844,12 +843,6 @@ AH_INTERRUPT_DEBUGGING opt_ah.h
# XXX do not use this for AR9130
AH_AR5416_INTERRUPT_MITIGATION opt_ah.h
-# options for the Altera mSGDMA driver (altera_msgdma)
-ALTERA_MSGDMA_DESC_STD opt_altera_msgdma.h
-ALTERA_MSGDMA_DESC_EXT opt_altera_msgdma.h
-ALTERA_MSGDMA_DESC_PF_STD opt_altera_msgdma.h
-ALTERA_MSGDMA_DESC_PF_EXT opt_altera_msgdma.h
-
# options for the Broadcom BCM43xx driver (bwi)
BWI_DEBUG opt_bwi.h
BWI_DEBUG_VERBOSE opt_bwi.h
diff --git a/sys/dev/altera/altpll/altpll.c b/sys/dev/altera/altpll/altpll.c
deleted file mode 100644
index 72a1e519baf6..000000000000
--- a/sys/dev/altera/altpll/altpll.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/*-
- * Copyright (c) 2012 Robert N. M. Watson
- * Copyright (c) 2015 Ed Maste
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-
-/*
- * Device driver for the Altera reconfigurable PLL.
- */
-
-devclass_t altpll_devclass;
-
-static d_mmap_t altpll_reg_mmap;
-static d_read_t altpll_reg_read;
-static d_write_t altpll_reg_write;
-
-static struct cdevsw altpll_reg_cdevsw = {
- .d_version = D_VERSION,
- .d_mmap = altpll_reg_mmap,
- .d_read = altpll_reg_read,
- .d_write = altpll_reg_write,
- .d_name = "altpll",
-};
-
-/*
- * Calculate best multiplier and divisor for a specified frequency.
- */
-static int
-altpll_calc_params(struct altpll_softc *sc, uint64_t output_frequency,
- uint32_t *mulp, uint32_t *divp)
-{
- int64_t e, besterr;
- uint32_t div, mul;
-
- if (output_frequency == 0)
- return (EINVAL);
-
- besterr = INT64_MAX;
- for (mul = 1; mul < 64; mul++) {
- div = (sc->ap_base_frequency * mul + (output_frequency / 2)) /
- output_frequency;
- if (div == 0)
- continue;
- e = output_frequency - sc->ap_base_frequency * mul / div;
- if (e < 0)
- e = -e;
- if (e < besterr) {
- besterr = e;
- *mulp = mul;
- *divp = div;
- }
- }
- return (besterr < INT64_MAX ? 0 : EINVAL);
-}
-
-/*
- * Configure the counter_type registers for a given PLL parameter.
- */
-static int
-altpll_write_param(struct altpll_softc *sc, uint32_t param_offset, uint32_t val)
-{
- int high_count, low_count;
-
- high_count = (val + 1) / 2;
- low_count = val - high_count;
-
- bus_write_4(sc->ap_reg_res, param_offset + ALTPLL_OFF_PARAM_HIGH_COUNT,
- htole32(high_count));
- bus_write_4(sc->ap_reg_res, param_offset + ALTPLL_OFF_PARAM_LOW_COUNT,
- htole32(low_count));
- bus_write_4(sc->ap_reg_res, param_offset + ALTPLL_OFF_PARAM_BYPASS,
- htole32(val == 1 ? 1 : 0));
- bus_write_4(sc->ap_reg_res, param_offset + ALTPLL_OFF_PARAM_ODD_COUNT,
- htole32(val & 0x1 ? 1 : 0));
-
- return (0);
-}
-
-/*
- * Configure all PLL counter parameters.
- */
-static int
-altpll_write_params(struct altpll_softc *sc, uint32_t mul, uint32_t div,
- uint32_t c0)
-{
- uint32_t status;
- int retry;
-
- altpll_write_param(sc, ALTPLL_OFF_TYPE_N, div);
- altpll_write_param(sc, ALTPLL_OFF_TYPE_M, mul);
- altpll_write_param(sc, ALTPLL_OFF_TYPE_C0, c0);
- /*
- * Program C1 with the same parameters as C0. It seems the PLL does not
- * run correctly otherwise.
- */
- altpll_write_param(sc, ALTPLL_OFF_TYPE_C1, c0);
- /* Trigger the transfer. */
- bus_write_4(sc->ap_reg_res, ALTPLL_OFF_TRANSFER, htole32(0xff));
- /* Wait for the transfer to complete. */
- status = bus_read_4(sc->ap_reg_res, ALTPLL_OFF_TRANSFER);
- for (retry = 0;
- status != htole32(ALTPLL_TRANSFER_COMPLETE) && retry < 10; retry++)
- status = bus_read_4(sc->ap_reg_res, ALTPLL_OFF_TRANSFER);
- if (status != htole32(ALTPLL_TRANSFER_COMPLETE)) {
- device_printf(sc->ap_dev,
- "timed out waiting for transfer to PLL\n");
- /* XXXEM ignore error for now - not set by old FPGA bitfiles. */
- }
-
- return (0);
-}
-
-/*
- * fdt_clock interface to set the frequency.
- */
-int
-altpll_set_frequency(device_t dev, uint64_t frequency)
-{
- uint32_t mul, div;
- int error;
- struct altpll_softc *sc;
-
- sc = device_get_softc(dev);
-
- mul = div = 0; /* XXX Quiet GCC uninitialized warning */
- error = altpll_calc_params(sc, frequency, &mul, &div);
- if (error)
- return (error);
- error = altpll_write_params(sc, mul, div, 1);
- return (error);
-}
-
-/*
- * All I/O to/from the altpll register device must be 32-bit, and aligned
- * to 32-bit.
- */
-static int
-altpll_reg_read(struct cdev *dev, struct uio *uio, int flag)
-{
- struct altpll_softc *sc;
- u_long offset, size;
- uint32_t v;
- int error;
-
- if (uio->uio_offset < 0 || uio->uio_offset % 4 != 0 ||
- uio->uio_resid % 4 != 0)
- return (ENODEV);
- sc = dev->si_drv1;
- size = rman_get_size(sc->ap_reg_res);
- error = 0;
- if ((uio->uio_offset + uio->uio_resid < 0) ||
- (uio->uio_offset + uio->uio_resid > size))
- return (ENODEV);
- while (uio->uio_resid > 0) {
- offset = uio->uio_offset;
- if (offset + sizeof(v) > size)
- return (ENODEV);
- v = bus_read_4(sc->ap_reg_res, offset);
- error = uiomove(&v, sizeof(v), uio);
- if (error)
- return (error);
- }
- return (error);
-}
-
-static int
-altpll_reg_write(struct cdev *dev, struct uio *uio, int flag)
-{
- struct altpll_softc *sc;
- u_long offset, size;
- uint32_t v;
- int error;
-
- if (uio->uio_offset < 0 || uio->uio_offset % 4 != 0 ||
- uio->uio_resid % 4 != 0)
- return (ENODEV);
- sc = dev->si_drv1;
- size = rman_get_size(sc->ap_reg_res);
- error = 0;
- while (uio->uio_resid > 0) {
- offset = uio->uio_offset;
- if (offset + sizeof(v) > size)
- return (ENODEV);
- error = uiomove(&v, sizeof(v), uio);
- if (error)
- return (error);
- bus_write_4(sc->ap_reg_res, offset, v);
- }
- return (error);
-}
-
-static int
-altpll_reg_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
- int nprot, vm_memattr_t *memattr)
-{
- struct altpll_softc *sc;
- int error;
-
- sc = dev->si_drv1;
- error = 0;
- if (trunc_page(offset) == offset &&
- rman_get_size(sc->ap_reg_res) >= offset + PAGE_SIZE) {
- *paddr = rman_get_start(sc->ap_reg_res) + offset;
- *memattr = VM_MEMATTR_UNCACHEABLE;
- } else {
- error = ENODEV;
- }
- return (error);
-}
-
-int
-altpll_attach(struct altpll_softc *sc)
-{
-
- sc->ap_reg_cdev = make_dev(&altpll_reg_cdevsw, sc->ap_unit,
- UID_ROOT, GID_WHEEL, 0400, "altpll%d", sc->ap_unit);
- if (sc->ap_reg_cdev == NULL) {
- device_printf(sc->ap_dev, "%s: make_dev failed\n", __func__);
- return (ENXIO);
- }
- /* XXXRW: Slight race between make_dev(9) and here. */
- sc->ap_reg_cdev->si_drv1 = sc;
- return (0);
-}
-
-void
-altpll_detach(struct altpll_softc *sc)
-{
-
- if (sc->ap_reg_cdev != NULL)
- destroy_dev(sc->ap_reg_cdev);
-}
diff --git a/sys/dev/altera/altpll/altpll.h b/sys/dev/altera/altpll/altpll.h
deleted file mode 100644
index 955599b05269..000000000000
--- a/sys/dev/altera/altpll/altpll.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * Copyright (c) 2015 Ed Maste
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _DEV_ALTPLL_H_
-#define _DEV_ALTPLL_H_
-
-struct altpll_softc {
- /*
- * Bus-related fields.
- */
- device_t ap_dev;
- int ap_unit;
-
- /*
- * The device node and memory-mapped I/O region.
- */
- struct cdev *ap_reg_cdev;
- struct resource *ap_reg_res;
- int ap_reg_rid;
-
- /*
- * PLL parameters.
- */
- uint64_t ap_base_frequency;
-};
-
-/*
- * Altera PLL "register offsets."
- *
- * Communication with the ALTPLL_RECONFIG IP core happens over a proprietary
- * serial interface. A small perhipheral caches the parameters and streams them
- * to the PLL by trigging a write with a specified address bit high. From the
- * driver's perspective we just pretend to have a set of 32-bit registers.
- *
- * Address Bits Description
- * 1-0 Always zero (word aligned)
- * 5-2 Counter type
- * 8-6 Counter parameter
- * 9 Set to 1 and write for transfer to PLL.
- * Read returns 0x0d when the transfer is complete.
- */
-#define ALTPLL_OFF_TYPE_N (0<<2)
-#define ALTPLL_OFF_TYPE_M (1<<2)
-#define ALTPLL_OFF_TYPE_C0 (4<<2)
-#define ALTPLL_OFF_TYPE_C1 (5<<2)
-#define ALTPLL_OFF_PARAM_HIGH_COUNT (0<<6)
-#define ALTPLL_OFF_PARAM_LOW_COUNT (1<<6)
-#define ALTPLL_OFF_PARAM_BYPASS (4<<6)
-#define ALTPLL_OFF_PARAM_ODD_COUNT (5<<6)
-#define ALTPLL_OFF_TRANSFER (1<<9)
-#define ALTPLL_TRANSFER_COMPLETE 0x0d
-
-#define ALTPLL_DEFAULT_FREQUENCY 50000000
-
-/*
- * Driver setup routines from the bus attachment/teardown.
- */
-int altpll_attach(struct altpll_softc *sc);
-void altpll_detach(struct altpll_softc *sc);
-
-/*
- * fdt_clock interface.
- */
-int altpll_set_frequency(device_t, uint64_t);
-
-extern devclass_t altpll_devclass;
-
-#endif /* _DEV_ALTPLL_H_ */
diff --git a/sys/dev/altera/altpll/altpll_fdt.c b/sys/dev/altera/altpll/altpll_fdt.c
deleted file mode 100644
index ef01dccaa14f..000000000000
--- a/sys/dev/altera/altpll/altpll_fdt.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-
- * Copyright (c) 2012-2013 Robert N. M. Watson
- * Copyright (c) 2014-2015 Ed Maste
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include "fb_if.h"
-
-static int
-altpll_fdt_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_is_compatible(dev, "sri-cambridge,altpll")) {
- device_set_desc(dev, "Altera reconfigurable PLL");
- return (BUS_PROBE_DEFAULT);
- }
- return (ENXIO);
-}
-
-static int
-altpll_fdt_attach(device_t dev)
-{
- struct altpll_softc *sc;
- phandle_t node;
- pcell_t freq;
- int error;
-
- sc = device_get_softc(dev);
- sc->ap_dev = dev;
- sc->ap_unit = device_get_unit(dev);
-
- /*
- * Altpll's FDT entry has a single memory resource for its control
- * registers.
- */
- sc->ap_reg_rid = 0;
- sc->ap_reg_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
- &sc->ap_reg_rid, RF_ACTIVE);
- if (sc->ap_reg_res == NULL) {
- device_printf(dev, "couldn't map register memory\n");
- error = ENXIO;
- goto error;
- }
- if (rman_get_start(sc->ap_reg_res) % PAGE_SIZE != 0) {
- device_printf(dev, "improper register address\n");
- error = ENXIO;
- goto error;
- }
- device_printf(sc->ap_dev, "registers at mem %#jx-%#jx\n",
- rman_get_start(sc->ap_reg_res),
- rman_get_start(sc->ap_reg_res) +
- rman_get_size(sc->ap_reg_res));
- if ((node = ofw_bus_get_node(dev)) == -1) {
- error = ENXIO;
- goto error;
- }
- OF_getencprop(node, "clock-frequency", &freq, sizeof(freq));
- if (freq > 0)
- sc->ap_base_frequency = freq;
- else
- sc->ap_base_frequency = ALTPLL_DEFAULT_FREQUENCY;
-
- if ((error = altpll_attach(sc)) != 0)
- goto error;
- fdt_clock_register_provider(dev);
- return (0);
-
-error:
- if (sc->ap_reg_res != NULL)
- bus_release_resource(dev, SYS_RES_MEMORY, sc->ap_reg_rid,
- sc->ap_reg_res);
- return (error);
-}
-
-static int
-altpll_fdt_detach(device_t dev)
-{
- struct altpll_softc *sc;
-
- sc = device_get_softc(dev);
- altpll_detach(sc);
- bus_release_resource(dev, SYS_RES_MEMORY, sc->ap_reg_rid,
- sc->ap_reg_res);
- return (0);
-}
-
-static device_method_t altpll_fdt_methods[] = {
- DEVMETHOD(device_probe, altpll_fdt_probe),
- DEVMETHOD(device_attach, altpll_fdt_attach),
- DEVMETHOD(device_detach, altpll_fdt_detach),
- DEVMETHOD(fdt_clock_set_frequency, altpll_set_frequency),
- { 0, 0 }
-};
-
-static driver_t altpll_fdt_driver = {
- "altpll",
- altpll_fdt_methods,
- sizeof(struct altpll_softc),
-};
-
-DRIVER_MODULE(altpll, simplebus, altpll_fdt_driver,
- altpll_devclass, 0, 0);
-// CHERI CHANGES START
-// {
-// "updated": 20230509,
-// "target_type": "kernel",
-// "changes_purecap": [
-// "other"
-// ],
-// "change_comment": "pointer printing"
-// }
-// CHERI CHANGES END
diff --git a/sys/dev/altera/atse/if_atse.c b/sys/dev/altera/atse/if_atse.c
deleted file mode 100644
index 923292484207..000000000000
--- a/sys/dev/altera/atse/if_atse.c
+++ /dev/null
@@ -1,1597 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012, 2013 Bjoern A. Zeeb
- * Copyright (c) 2014 Robert N. M. Watson
- * Copyright (c) 2016-2017 Ruslan Bukin
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-11-C-0249)
- * ("MRC2"), as part of the DARPA MRC research programme.
- *
- * 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.
- */
-/*
- * Altera Triple-Speed Ethernet MegaCore, Function User Guide
- * UG-01008-3.0, Software Version: 12.0, June 2012.
- * Available at the time of writing at:
- * http://www.altera.com/literature/ug/ug_ethernet.pdf
- *
- * We are using an Marvell E1111 (Alaska) PHY on the DE4. See mii/e1000phy.c.
- */
-/*
- * XXX-BZ NOTES:
- * - ifOutBroadcastPkts are only counted if both ether dst and src are all-1s;
- * seems an IP core bug, they count ether broadcasts as multicast. Is this
- * still the case?
- * - figure out why the TX FIFO fill status and intr did not work as expected.
- * - test 100Mbit/s and 10Mbit/s
- * - blacklist the one special factory programmed ethernet address (for now
- * hardcoded, later from loader?)
- * - resolve all XXX, left as reminders to shake out details later
- * - Jumbo frame support
- */
-
-#include
-#include "opt_device_polling.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-
-#define RX_QUEUE_SIZE 4096
-#define TX_QUEUE_SIZE 4096
-#define NUM_RX_MBUF 512
-#define BUFRING_SIZE 8192
-
-#include
-
-/* XXX once we'd do parallel attach, we need a global lock for this. */
-#define ATSE_ETHERNET_OPTION_BITS_UNDEF 0
-#define ATSE_ETHERNET_OPTION_BITS_READ 1
-static int atse_ethernet_option_bits_flag = ATSE_ETHERNET_OPTION_BITS_UNDEF;
-static uint8_t atse_ethernet_option_bits[ALTERA_ETHERNET_OPTION_BITS_LEN];
-
-/*
- * Softc and critical resource locking.
- */
-#define ATSE_LOCK(_sc) mtx_lock(&(_sc)->atse_mtx)
-#define ATSE_UNLOCK(_sc) mtx_unlock(&(_sc)->atse_mtx)
-#define ATSE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->atse_mtx, MA_OWNED)
-
-#define ATSE_DEBUG
-#undef ATSE_DEBUG
-
-#ifdef ATSE_DEBUG
-#define DPRINTF(format, ...) printf(format, __VA_ARGS__)
-#else
-#define DPRINTF(format, ...)
-#endif
-
-/*
- * Register space access macros.
- */
-static inline void
-csr_write_4(struct atse_softc *sc, uint32_t reg, uint32_t val4,
- const char *f, const int l)
-{
-
- val4 = htole32(val4);
- DPRINTF("[%s:%d] CSR W %s 0x%08x (0x%08x) = 0x%08x\n", f, l,
- "atse_mem_res", reg, reg * 4, val4);
- bus_write_4(sc->atse_mem_res, reg * 4, val4);
-}
-
-static inline uint32_t
-csr_read_4(struct atse_softc *sc, uint32_t reg, const char *f, const int l)
-{
- uint32_t val4;
-
- val4 = le32toh(bus_read_4(sc->atse_mem_res, reg * 4));
- DPRINTF("[%s:%d] CSR R %s 0x%08x (0x%08x) = 0x%08x\n", f, l,
- "atse_mem_res", reg, reg * 4, val4);
-
- return (val4);
-}
-
-/*
- * See page 5-2 that it's all dword offsets and the MS 16 bits need to be zero
- * on write and ignored on read.
- */
-static inline void
-pxx_write_2(struct atse_softc *sc, bus_addr_t bmcr, uint32_t reg, uint16_t val,
- const char *f, const int l, const char *s)
-{
- uint32_t val4;
-
- val4 = htole32(val & 0x0000ffff);
- DPRINTF("[%s:%d] %s W %s 0x%08x (0x%08jx) = 0x%08x\n", f, l, s,
- "atse_mem_res", reg, (bmcr + reg) * 4, val4);
- bus_write_4(sc->atse_mem_res, (bmcr + reg) * 4, val4);
-}
-
-static inline uint16_t
-pxx_read_2(struct atse_softc *sc, bus_addr_t bmcr, uint32_t reg, const char *f,
- const int l, const char *s)
-{
- uint32_t val4;
- uint16_t val;
-
- val4 = bus_read_4(sc->atse_mem_res, (bmcr + reg) * 4);
- val = le32toh(val4) & 0x0000ffff;
- DPRINTF("[%s:%d] %s R %s 0x%08x (0x%08jx) = 0x%04x\n", f, l, s,
- "atse_mem_res", reg, (bmcr + reg) * 4, val);
-
- return (val);
-}
-
-#define CSR_WRITE_4(sc, reg, val) \
- csr_write_4((sc), (reg), (val), __func__, __LINE__)
-#define CSR_READ_4(sc, reg) \
- csr_read_4((sc), (reg), __func__, __LINE__)
-#define PCS_WRITE_2(sc, reg, val) \
- pxx_write_2((sc), sc->atse_bmcr0, (reg), (val), __func__, __LINE__, \
- "PCS")
-#define PCS_READ_2(sc, reg) \
- pxx_read_2((sc), sc->atse_bmcr0, (reg), __func__, __LINE__, "PCS")
-#define PHY_WRITE_2(sc, reg, val) \
- pxx_write_2((sc), sc->atse_bmcr1, (reg), (val), __func__, __LINE__, \
- "PHY")
-#define PHY_READ_2(sc, reg) \
- pxx_read_2((sc), sc->atse_bmcr1, (reg), __func__, __LINE__, "PHY")
-
-static void atse_tick(void *);
-static int atse_detach(device_t);
-
-static int
-atse_rx_enqueue(struct atse_softc *sc, uint32_t n)
-{
- struct mbuf *m;
- int i;
-
- for (i = 0; i < n; i++) {
- m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
- if (m == NULL) {
- device_printf(sc->dev,
- "%s: Can't alloc rx mbuf\n", __func__);
- return (-1);
- }
-
- m->m_pkthdr.len = m->m_len = m->m_ext.ext_size;
- xdma_enqueue_mbuf(sc->xchan_rx, &m, 0, 4, 4, XDMA_DEV_TO_MEM);
- }
-
- return (0);
-}
-
-static int
-atse_xdma_tx_intr(void *arg, xdma_transfer_status_t *status)
-{
- xdma_transfer_status_t st;
- struct atse_softc *sc;
- if_t ifp;
- struct mbuf *m;
- int err;
-
- sc = arg;
-
- ATSE_LOCK(sc);
-
- ifp = sc->atse_ifp;
-
- for (;;) {
- err = xdma_dequeue_mbuf(sc->xchan_tx, &m, &st);
- if (err != 0) {
- break;
- }
-
- if (st.error != 0) {
- if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
- }
-
- m_freem(m);
- sc->txcount--;
- }
-
- if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
-
- ATSE_UNLOCK(sc);
-
- return (0);
-}
-
-static int
-atse_xdma_rx_intr(void *arg, xdma_transfer_status_t *status)
-{
- xdma_transfer_status_t st;
- struct atse_softc *sc;
- if_t ifp;
- struct mbuf *m;
- int err;
- uint32_t cnt_processed;
-
- sc = arg;
-
- ATSE_LOCK(sc);
-
- ifp = sc->atse_ifp;
-
- cnt_processed = 0;
- for (;;) {
- err = xdma_dequeue_mbuf(sc->xchan_rx, &m, &st);
- if (err != 0) {
- break;
- }
- cnt_processed++;
-
- if (st.error != 0) {
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
- m_freem(m);
- continue;
- }
-
- m->m_pkthdr.len = m->m_len = st.transferred;
- m->m_pkthdr.rcvif = ifp;
- m_adj(m, ETHER_ALIGN);
- ATSE_UNLOCK(sc);
- if_input(ifp, m);
- ATSE_LOCK(sc);
- }
-
- atse_rx_enqueue(sc, cnt_processed);
-
- ATSE_UNLOCK(sc);
-
- return (0);
-}
-
-static int
-atse_transmit_locked(if_t ifp)
-{
- struct atse_softc *sc;
- struct mbuf *m;
- struct buf_ring *br;
- int error;
- int enq;
-
- sc = if_getsoftc(ifp);
- br = sc->br;
-
- enq = 0;
-
- while ((m = drbr_peek(ifp, br)) != NULL) {
- error = xdma_enqueue_mbuf(sc->xchan_tx, &m, 0, 4, 4, XDMA_MEM_TO_DEV);
- if (error != 0) {
- /* No space in request queue available yet. */
- drbr_putback(ifp, br, m);
- break;
- }
-
- drbr_advance(ifp, br);
-
- sc->txcount++;
- enq++;
-
- /* If anyone is interested give them a copy. */
- ETHER_BPF_MTAP(ifp, m);
- }
-
- if (enq > 0)
- xdma_queue_submit(sc->xchan_tx);
-
- return (0);
-}
-
-static int
-atse_transmit(if_t ifp, struct mbuf *m)
-{
- struct atse_softc *sc;
- struct buf_ring *br;
- int error;
-
- sc = if_getsoftc(ifp);
- br = sc->br;
-
- ATSE_LOCK(sc);
-
- mtx_lock(&sc->br_mtx);
-
- if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) {
- error = drbr_enqueue(ifp, sc->br, m);
- mtx_unlock(&sc->br_mtx);
- ATSE_UNLOCK(sc);
- return (error);
- }
-
- if ((sc->atse_flags & ATSE_FLAGS_LINK) == 0) {
- error = drbr_enqueue(ifp, sc->br, m);
- mtx_unlock(&sc->br_mtx);
- ATSE_UNLOCK(sc);
- return (error);
- }
-
- error = drbr_enqueue(ifp, br, m);
- if (error) {
- mtx_unlock(&sc->br_mtx);
- ATSE_UNLOCK(sc);
- return (error);
- }
- error = atse_transmit_locked(ifp);
-
- mtx_unlock(&sc->br_mtx);
- ATSE_UNLOCK(sc);
-
- return (error);
-}
-
-static void
-atse_qflush(if_t ifp)
-{
- struct atse_softc *sc;
-
- sc = if_getsoftc(ifp);
-
- printf("%s\n", __func__);
-}
-
-static int
-atse_stop_locked(struct atse_softc *sc)
-{
- uint32_t mask, val4;
- if_t ifp;
- int i;
-
- ATSE_LOCK_ASSERT(sc);
-
- callout_stop(&sc->atse_tick);
-
- ifp = sc->atse_ifp;
- if_setdrvflagbits(ifp, 0, (IFF_DRV_RUNNING | IFF_DRV_OACTIVE));
-
- /* Disable MAC transmit and receive datapath. */
- mask = BASE_CFG_COMMAND_CONFIG_TX_ENA|BASE_CFG_COMMAND_CONFIG_RX_ENA;
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- val4 &= ~mask;
- CSR_WRITE_4(sc, BASE_CFG_COMMAND_CONFIG, val4);
-
- /* Wait for bits to be cleared; i=100 is excessive. */
- for (i = 0; i < 100; i++) {
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- if ((val4 & mask) == 0) {
- break;
- }
- DELAY(10);
- }
-
- if ((val4 & mask) != 0) {
- device_printf(sc->atse_dev, "Disabling MAC TX/RX timed out.\n");
- /* Punt. */
- }
-
- sc->atse_flags &= ~ATSE_FLAGS_LINK;
-
- return (0);
-}
-
-static u_int
-atse_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
-{
- uint64_t *h = arg;
- uint8_t *addr, x, y;
- int i, j;
-
- addr = LLADDR(sdl);
- x = 0;
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- y = addr[i] & 0x01;
- for (j = 1; j < 8; j++)
- y ^= (addr[i] >> j) & 0x01;
- x |= (y << i);
- }
- *h |= (1 << x);
-
- return (1);
-}
-
-static int
-atse_rxfilter_locked(struct atse_softc *sc)
-{
- if_t ifp;
- uint32_t val4;
- int i;
-
- /* XXX-BZ can we find out if we have the MHASH synthesized? */
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- /* For simplicity always hash full 48 bits of addresses. */
- if ((val4 & BASE_CFG_COMMAND_CONFIG_MHASH_SEL) != 0)
- val4 &= ~BASE_CFG_COMMAND_CONFIG_MHASH_SEL;
-
- ifp = sc->atse_ifp;
- if (if_getflags(ifp) & IFF_PROMISC) {
- val4 |= BASE_CFG_COMMAND_CONFIG_PROMIS_EN;
- } else {
- val4 &= ~BASE_CFG_COMMAND_CONFIG_PROMIS_EN;
- }
-
- CSR_WRITE_4(sc, BASE_CFG_COMMAND_CONFIG, val4);
-
- if (if_getflags(ifp) & IFF_ALLMULTI) {
- /* Accept all multicast addresses. */
- for (i = 0; i <= MHASH_LEN; i++)
- CSR_WRITE_4(sc, MHASH_START + i, 0x1);
- } else {
- /*
- * Can hold MHASH_LEN entries.
- * XXX-BZ bitstring.h would be more general.
- */
- uint64_t h;
-
- /*
- * Re-build and re-program hash table. First build the
- * bit-field "yes" or "no" for each slot per address, then
- * do all the programming afterwards.
- */
- h = 0;
- (void)if_foreach_llmaddr(ifp, atse_hash_maddr, &h);
- for (i = 0; i <= MHASH_LEN; i++) {
- CSR_WRITE_4(sc, MHASH_START + i,
- (h & (1 << i)) ? 0x01 : 0x00);
- }
- }
-
- return (0);
-}
-
-static int
-atse_ethernet_option_bits_read_fdt(device_t dev)
-{
- struct resource *res;
- device_t fdev;
- int i, rid;
-
- if (atse_ethernet_option_bits_flag & ATSE_ETHERNET_OPTION_BITS_READ) {
- return (0);
- }
-
- fdev = device_find_child(device_get_parent(dev), "cfi", 0);
- if (fdev == NULL) {
- return (ENOENT);
- }
-
- rid = 0;
- res = bus_alloc_resource_any(fdev, SYS_RES_MEMORY, &rid,
- RF_ACTIVE | RF_SHAREABLE);
- if (res == NULL) {
- return (ENXIO);
- }
-
- for (i = 0; i < ALTERA_ETHERNET_OPTION_BITS_LEN; i++) {
- atse_ethernet_option_bits[i] = bus_read_1(res,
- ALTERA_ETHERNET_OPTION_BITS_OFF + i);
- }
-
- bus_release_resource(fdev, SYS_RES_MEMORY, rid, res);
- atse_ethernet_option_bits_flag |= ATSE_ETHERNET_OPTION_BITS_READ;
-
- return (0);
-}
-
-static int
-atse_ethernet_option_bits_read(device_t dev)
-{
- int error;
-
- error = atse_ethernet_option_bits_read_fdt(dev);
- if (error == 0)
- return (0);
-
- device_printf(dev, "Cannot read Ethernet addresses from flash.\n");
-
- return (error);
-}
-
-static int
-atse_get_eth_address(struct atse_softc *sc)
-{
- unsigned long hostid;
- uint32_t val4;
- int unit;
-
- /*
- * Make sure to only ever do this once. Otherwise a reset would
- * possibly change our ethernet address, which is not good at all.
- */
- if (sc->atse_eth_addr[0] != 0x00 || sc->atse_eth_addr[1] != 0x00 ||
- sc->atse_eth_addr[2] != 0x00) {
- return (0);
- }
-
- if ((atse_ethernet_option_bits_flag &
- ATSE_ETHERNET_OPTION_BITS_READ) == 0) {
- goto get_random;
- }
-
- val4 = atse_ethernet_option_bits[0] << 24;
- val4 |= atse_ethernet_option_bits[1] << 16;
- val4 |= atse_ethernet_option_bits[2] << 8;
- val4 |= atse_ethernet_option_bits[3];
- /* They chose "safe". */
- if (val4 != le32toh(0x00005afe)) {
- device_printf(sc->atse_dev, "Magic '5afe' is not safe: 0x%08x. "
- "Falling back to random numbers for hardware address.\n",
- val4);
- goto get_random;
- }
-
- sc->atse_eth_addr[0] = atse_ethernet_option_bits[4];
- sc->atse_eth_addr[1] = atse_ethernet_option_bits[5];
- sc->atse_eth_addr[2] = atse_ethernet_option_bits[6];
- sc->atse_eth_addr[3] = atse_ethernet_option_bits[7];
- sc->atse_eth_addr[4] = atse_ethernet_option_bits[8];
- sc->atse_eth_addr[5] = atse_ethernet_option_bits[9];
-
- /* Handle factory default ethernet address: 00:07:ed:ff:ed:15 */
- if (sc->atse_eth_addr[0] == 0x00 && sc->atse_eth_addr[1] == 0x07 &&
- sc->atse_eth_addr[2] == 0xed && sc->atse_eth_addr[3] == 0xff &&
- sc->atse_eth_addr[4] == 0xed && sc->atse_eth_addr[5] == 0x15) {
- device_printf(sc->atse_dev, "Factory programmed Ethernet "
- "hardware address blacklisted. Falling back to random "
- "address to avoid collisions.\n");
- device_printf(sc->atse_dev, "Please re-program your flash.\n");
- goto get_random;
- }
-
- if (sc->atse_eth_addr[0] == 0x00 && sc->atse_eth_addr[1] == 0x00 &&
- sc->atse_eth_addr[2] == 0x00 && sc->atse_eth_addr[3] == 0x00 &&
- sc->atse_eth_addr[4] == 0x00 && sc->atse_eth_addr[5] == 0x00) {
- device_printf(sc->atse_dev, "All zero's Ethernet hardware "
- "address blacklisted. Falling back to random address.\n");
- device_printf(sc->atse_dev, "Please re-program your flash.\n");
- goto get_random;
- }
-
- if (ETHER_IS_MULTICAST(sc->atse_eth_addr)) {
- device_printf(sc->atse_dev, "Multicast Ethernet hardware "
- "address blacklisted. Falling back to random address.\n");
- device_printf(sc->atse_dev, "Please re-program your flash.\n");
- goto get_random;
- }
-
- /*
- * If we find an Altera prefixed address with a 0x0 ending
- * adjust by device unit. If not and this is not the first
- * Ethernet, go to random.
- */
- unit = device_get_unit(sc->atse_dev);
- if (unit == 0x00) {
- return (0);
- }
-
- if (unit > 0x0f) {
- device_printf(sc->atse_dev, "We do not support Ethernet "
- "addresses for more than 16 MACs. Falling back to "
- "random hadware address.\n");
- goto get_random;
- }
- if ((sc->atse_eth_addr[0] & ~0x2) != 0 ||
- sc->atse_eth_addr[1] != 0x07 || sc->atse_eth_addr[2] != 0xed ||
- (sc->atse_eth_addr[5] & 0x0f) != 0x0) {
- device_printf(sc->atse_dev, "Ethernet address not meeting our "
- "multi-MAC standards. Falling back to random hadware "
- "address.\n");
- goto get_random;
- }
- sc->atse_eth_addr[5] |= (unit & 0x0f);
-
- return (0);
-
-get_random:
- /*
- * Fall back to random code we also use on bridge(4).
- */
- getcredhostid(curthread->td_ucred, &hostid);
- if (hostid == 0) {
- arc4rand(sc->atse_eth_addr, ETHER_ADDR_LEN, 1);
- sc->atse_eth_addr[0] &= ~1;/* clear multicast bit */
- sc->atse_eth_addr[0] |= 2; /* set the LAA bit */
- } else {
- sc->atse_eth_addr[0] = 0x2;
- sc->atse_eth_addr[1] = (hostid >> 24) & 0xff;
- sc->atse_eth_addr[2] = (hostid >> 16) & 0xff;
- sc->atse_eth_addr[3] = (hostid >> 8 ) & 0xff;
- sc->atse_eth_addr[4] = hostid & 0xff;
- sc->atse_eth_addr[5] = sc->atse_unit & 0xff;
- }
-
- return (0);
-}
-
-static int
-atse_set_eth_address(struct atse_softc *sc, int n)
-{
- uint32_t v0, v1;
-
- v0 = (sc->atse_eth_addr[3] << 24) | (sc->atse_eth_addr[2] << 16) |
- (sc->atse_eth_addr[1] << 8) | sc->atse_eth_addr[0];
- v1 = (sc->atse_eth_addr[5] << 8) | sc->atse_eth_addr[4];
-
- if (n & ATSE_ETH_ADDR_DEF) {
- CSR_WRITE_4(sc, BASE_CFG_MAC_0, v0);
- CSR_WRITE_4(sc, BASE_CFG_MAC_1, v1);
- }
- if (n & ATSE_ETH_ADDR_SUPP1) {
- CSR_WRITE_4(sc, SUPPL_ADDR_SMAC_0_0, v0);
- CSR_WRITE_4(sc, SUPPL_ADDR_SMAC_0_1, v1);
- }
- if (n & ATSE_ETH_ADDR_SUPP2) {
- CSR_WRITE_4(sc, SUPPL_ADDR_SMAC_1_0, v0);
- CSR_WRITE_4(sc, SUPPL_ADDR_SMAC_1_1, v1);
- }
- if (n & ATSE_ETH_ADDR_SUPP3) {
- CSR_WRITE_4(sc, SUPPL_ADDR_SMAC_2_0, v0);
- CSR_WRITE_4(sc, SUPPL_ADDR_SMAC_2_1, v1);
- }
- if (n & ATSE_ETH_ADDR_SUPP4) {
- CSR_WRITE_4(sc, SUPPL_ADDR_SMAC_3_0, v0);
- CSR_WRITE_4(sc, SUPPL_ADDR_SMAC_3_1, v1);
- }
-
- return (0);
-}
-
-static int
-atse_reset(struct atse_softc *sc)
-{
- uint32_t val4, mask;
- uint16_t val;
- int i;
-
- /* 1. External PHY Initialization using MDIO. */
- /*
- * We select the right MDIO space in atse_attach() and let MII do
- * anything else.
- */
-
- /* 2. PCS Configuration Register Initialization. */
- /* a. Set auto negotiation link timer to 1.6ms for SGMII. */
- PCS_WRITE_2(sc, PCS_EXT_LINK_TIMER_0, 0x0D40);
- PCS_WRITE_2(sc, PCS_EXT_LINK_TIMER_1, 0x0003);
-
- /* b. Configure SGMII. */
- val = PCS_EXT_IF_MODE_SGMII_ENA|PCS_EXT_IF_MODE_USE_SGMII_AN;
- PCS_WRITE_2(sc, PCS_EXT_IF_MODE, val);
-
- /* c. Enable auto negotiation. */
- /* Ignore Bits 6,8,13; should be set,set,unset. */
- val = PCS_READ_2(sc, PCS_CONTROL);
- val &= ~(PCS_CONTROL_ISOLATE|PCS_CONTROL_POWERDOWN);
- val &= ~PCS_CONTROL_LOOPBACK; /* Make this a -link1 option? */
- val |= PCS_CONTROL_AUTO_NEGOTIATION_ENABLE;
- PCS_WRITE_2(sc, PCS_CONTROL, val);
-
- /* d. PCS reset. */
- val = PCS_READ_2(sc, PCS_CONTROL);
- val |= PCS_CONTROL_RESET;
- PCS_WRITE_2(sc, PCS_CONTROL, val);
-
- /* Wait for reset bit to clear; i=100 is excessive. */
- for (i = 0; i < 100; i++) {
- val = PCS_READ_2(sc, PCS_CONTROL);
- if ((val & PCS_CONTROL_RESET) == 0) {
- break;
- }
- DELAY(10);
- }
-
- if ((val & PCS_CONTROL_RESET) != 0) {
- device_printf(sc->atse_dev, "PCS reset timed out.\n");
- return (ENXIO);
- }
-
- /* 3. MAC Configuration Register Initialization. */
- /* a. Disable MAC transmit and receive datapath. */
- mask = BASE_CFG_COMMAND_CONFIG_TX_ENA|BASE_CFG_COMMAND_CONFIG_RX_ENA;
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- val4 &= ~mask;
- /* Samples in the manual do have the SW_RESET bit set here, why? */
- CSR_WRITE_4(sc, BASE_CFG_COMMAND_CONFIG, val4);
- /* Wait for bits to be cleared; i=100 is excessive. */
- for (i = 0; i < 100; i++) {
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- if ((val4 & mask) == 0) {
- break;
- }
- DELAY(10);
- }
- if ((val4 & mask) != 0) {
- device_printf(sc->atse_dev, "Disabling MAC TX/RX timed out.\n");
- return (ENXIO);
- }
- /* b. MAC FIFO configuration. */
- CSR_WRITE_4(sc, BASE_CFG_TX_SECTION_EMPTY, FIFO_DEPTH_TX - 16);
- CSR_WRITE_4(sc, BASE_CFG_TX_ALMOST_FULL, 3);
- CSR_WRITE_4(sc, BASE_CFG_TX_ALMOST_EMPTY, 8);
- CSR_WRITE_4(sc, BASE_CFG_RX_SECTION_EMPTY, FIFO_DEPTH_RX - 16);
- CSR_WRITE_4(sc, BASE_CFG_RX_ALMOST_FULL, 8);
- CSR_WRITE_4(sc, BASE_CFG_RX_ALMOST_EMPTY, 8);
-#if 0
- CSR_WRITE_4(sc, BASE_CFG_TX_SECTION_FULL, 16);
- CSR_WRITE_4(sc, BASE_CFG_RX_SECTION_FULL, 16);
-#else
- /* For store-and-forward mode, set this threshold to 0. */
- CSR_WRITE_4(sc, BASE_CFG_TX_SECTION_FULL, 0);
- CSR_WRITE_4(sc, BASE_CFG_RX_SECTION_FULL, 0);
-#endif
- /* c. MAC address configuration. */
- /* Also intialize supplementary addresses to our primary one. */
- /* XXX-BZ FreeBSD really needs to grow and API for using these. */
- atse_get_eth_address(sc);
- atse_set_eth_address(sc, ATSE_ETH_ADDR_ALL);
-
- /* d. MAC function configuration. */
- CSR_WRITE_4(sc, BASE_CFG_FRM_LENGTH, 1518); /* Default. */
- CSR_WRITE_4(sc, BASE_CFG_TX_IPG_LENGTH, 12);
- CSR_WRITE_4(sc, BASE_CFG_PAUSE_QUANT, 0xFFFF);
-
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- /*
- * If 1000BASE-X/SGMII PCS is initialized, set the ETH_SPEED (bit 3)
- * and ENA_10 (bit 25) in command_config register to 0. If half duplex
- * is reported in the PHY/PCS status register, set the HD_ENA (bit 10)
- * to 1 in command_config register.
- * BZ: We shoot for 1000 instead.
- */
-#if 0
- val4 |= BASE_CFG_COMMAND_CONFIG_ETH_SPEED;
-#else
- val4 &= ~BASE_CFG_COMMAND_CONFIG_ETH_SPEED;
-#endif
- val4 &= ~BASE_CFG_COMMAND_CONFIG_ENA_10;
-#if 0
- /*
- * We do not want to set this, otherwise, we could not even send
- * random raw ethernet frames for various other research. By default
- * FreeBSD will use the right ether source address.
- */
- val4 |= BASE_CFG_COMMAND_CONFIG_TX_ADDR_INS;
-#endif
- val4 |= BASE_CFG_COMMAND_CONFIG_PAD_EN;
- val4 &= ~BASE_CFG_COMMAND_CONFIG_CRC_FWD;
-#if 0
- val4 |= BASE_CFG_COMMAND_CONFIG_CNTL_FRM_ENA;
-#endif
-#if 1
- val4 |= BASE_CFG_COMMAND_CONFIG_RX_ERR_DISC;
-#endif
- val &= ~BASE_CFG_COMMAND_CONFIG_LOOP_ENA; /* link0? */
- CSR_WRITE_4(sc, BASE_CFG_COMMAND_CONFIG, val4);
-
- /*
- * Make sure we do not enable 32bit alignment; FreeBSD cannot
- * cope with the additional padding (though we should!?).
- * Also make sure we get the CRC appended.
- */
- val4 = CSR_READ_4(sc, TX_CMD_STAT);
- val4 &= ~(TX_CMD_STAT_OMIT_CRC|TX_CMD_STAT_TX_SHIFT16);
- CSR_WRITE_4(sc, TX_CMD_STAT, val4);
-
- val4 = CSR_READ_4(sc, RX_CMD_STAT);
- val4 &= ~RX_CMD_STAT_RX_SHIFT16;
- val4 |= RX_CMD_STAT_RX_SHIFT16;
- CSR_WRITE_4(sc, RX_CMD_STAT, val4);
-
- /* e. Reset MAC. */
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- val4 |= BASE_CFG_COMMAND_CONFIG_SW_RESET;
- CSR_WRITE_4(sc, BASE_CFG_COMMAND_CONFIG, val4);
- /* Wait for bits to be cleared; i=100 is excessive. */
- for (i = 0; i < 100; i++) {
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- if ((val4 & BASE_CFG_COMMAND_CONFIG_SW_RESET) == 0) {
- break;
- }
- DELAY(10);
- }
- if ((val4 & BASE_CFG_COMMAND_CONFIG_SW_RESET) != 0) {
- device_printf(sc->atse_dev, "MAC reset timed out.\n");
- return (ENXIO);
- }
-
- /* f. Enable MAC transmit and receive datapath. */
- mask = BASE_CFG_COMMAND_CONFIG_TX_ENA|BASE_CFG_COMMAND_CONFIG_RX_ENA;
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- val4 |= mask;
- CSR_WRITE_4(sc, BASE_CFG_COMMAND_CONFIG, val4);
- /* Wait for bits to be cleared; i=100 is excessive. */
- for (i = 0; i < 100; i++) {
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
- if ((val4 & mask) == mask) {
- break;
- }
- DELAY(10);
- }
- if ((val4 & mask) != mask) {
- device_printf(sc->atse_dev, "Enabling MAC TX/RX timed out.\n");
- return (ENXIO);
- }
-
- return (0);
-}
-
-static void
-atse_init_locked(struct atse_softc *sc)
-{
- if_t ifp;
- struct mii_data *mii;
- uint8_t *eaddr;
-
- ATSE_LOCK_ASSERT(sc);
- ifp = sc->atse_ifp;
-
- if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) {
- return;
- }
-
- /*
- * Must update the ether address if changed. Given we do not handle
- * in atse_ioctl() but it's in the general framework, just always
- * do it here before atse_reset().
- */
- eaddr = if_getlladdr(sc->atse_ifp);
- bcopy(eaddr, &sc->atse_eth_addr, ETHER_ADDR_LEN);
-
- /* Make things frind to halt, cleanup, ... */
- atse_stop_locked(sc);
-
- atse_reset(sc);
-
- /* ... and fire up the engine again. */
- atse_rxfilter_locked(sc);
-
- sc->atse_flags &= ATSE_FLAGS_LINK; /* Preserve. */
-
- mii = device_get_softc(sc->atse_miibus);
-
- sc->atse_flags &= ~ATSE_FLAGS_LINK;
- mii_mediachg(mii);
-
- if_setdrvflagbits(ifp, IFF_DRV_RUNNING, 0);
- if_setdrvflagbits(ifp, 0, IFF_DRV_OACTIVE);
-
- callout_reset(&sc->atse_tick, hz, atse_tick, sc);
-}
-
-static void
-atse_init(void *xsc)
-{
- struct atse_softc *sc;
-
- /*
- * XXXRW: There is some argument that we should immediately do RX
- * processing after enabling interrupts, or one may not fire if there
- * are buffered packets.
- */
- sc = (struct atse_softc *)xsc;
- ATSE_LOCK(sc);
- atse_init_locked(sc);
- ATSE_UNLOCK(sc);
-}
-
-static int
-atse_ioctl(if_t ifp, u_long command, caddr_t data)
-{
- struct atse_softc *sc;
- struct ifreq *ifr;
- int error, mask;
-
- error = 0;
- sc = if_getsoftc(ifp);
- ifr = (struct ifreq *)data;
-
- switch (command) {
- case SIOCSIFFLAGS:
- ATSE_LOCK(sc);
- if (if_getflags(ifp) & IFF_UP) {
- if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0 &&
- ((if_getflags(ifp) ^ sc->atse_if_flags) &
- (IFF_PROMISC | IFF_ALLMULTI)) != 0)
- atse_rxfilter_locked(sc);
- else
- atse_init_locked(sc);
- } else if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
- atse_stop_locked(sc);
- sc->atse_if_flags = if_getflags(ifp);
- ATSE_UNLOCK(sc);
- break;
- case SIOCSIFCAP:
- ATSE_LOCK(sc);
- mask = ifr->ifr_reqcap ^ if_getcapenable(ifp);
- ATSE_UNLOCK(sc);
- break;
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- ATSE_LOCK(sc);
- atse_rxfilter_locked(sc);
- ATSE_UNLOCK(sc);
- break;
- case SIOCGIFMEDIA:
- case SIOCSIFMEDIA:
- {
- struct mii_data *mii;
- struct ifreq *ifr;
-
- mii = device_get_softc(sc->atse_miibus);
- ifr = (struct ifreq *)data;
- error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
- break;
- }
- default:
- error = ether_ioctl(ifp, command, data);
- break;
- }
-
- return (error);
-}
-
-static void
-atse_tick(void *xsc)
-{
- struct atse_softc *sc;
- struct mii_data *mii;
- if_t ifp;
-
- sc = (struct atse_softc *)xsc;
- ATSE_LOCK_ASSERT(sc);
- ifp = sc->atse_ifp;
-
- mii = device_get_softc(sc->atse_miibus);
- mii_tick(mii);
- if ((sc->atse_flags & ATSE_FLAGS_LINK) == 0) {
- atse_miibus_statchg(sc->atse_dev);
- }
-
- callout_reset(&sc->atse_tick, hz, atse_tick, sc);
-}
-
-/*
- * Set media options.
- */
-static int
-atse_ifmedia_upd(if_t ifp)
-{
- struct atse_softc *sc;
- struct mii_data *mii;
- struct mii_softc *miisc;
- int error;
-
- sc = if_getsoftc(ifp);
-
- ATSE_LOCK(sc);
- mii = device_get_softc(sc->atse_miibus);
- LIST_FOREACH(miisc, &mii->mii_phys, mii_list) {
- PHY_RESET(miisc);
- }
- error = mii_mediachg(mii);
- ATSE_UNLOCK(sc);
-
- return (error);
-}
-
-/*
- * Report current media status.
- */
-static void
-atse_ifmedia_sts(if_t ifp, struct ifmediareq *ifmr)
-{
- struct atse_softc *sc;
- struct mii_data *mii;
-
- sc = if_getsoftc(ifp);
-
- ATSE_LOCK(sc);
- mii = device_get_softc(sc->atse_miibus);
- mii_pollstat(mii);
- ifmr->ifm_active = mii->mii_media_active;
- ifmr->ifm_status = mii->mii_media_status;
- ATSE_UNLOCK(sc);
-}
-
-static struct atse_mac_stats_regs {
- const char *name;
- const char *descr; /* Mostly copied from Altera datasheet. */
-} atse_mac_stats_regs[] = {
- [0x1a] =
- { "aFramesTransmittedOK",
- "The number of frames that are successfully transmitted including "
- "the pause frames." },
- { "aFramesReceivedOK",
- "The number of frames that are successfully received including the "
- "pause frames." },
- { "aFrameCheckSequenceErrors",
- "The number of receive frames with CRC error." },
- { "aAlignmentErrors",
- "The number of receive frames with alignment error." },
- { "aOctetsTransmittedOK",
- "The lower 32 bits of the number of data and padding octets that "
- "are successfully transmitted." },
- { "aOctetsReceivedOK",
- "The lower 32 bits of the number of data and padding octets that "
- " are successfully received." },
- { "aTxPAUSEMACCtrlFrames",
- "The number of pause frames transmitted." },
- { "aRxPAUSEMACCtrlFrames",
- "The number received pause frames received." },
- { "ifInErrors",
- "The number of errored frames received." },
- { "ifOutErrors",
- "The number of transmit frames with either a FIFO overflow error, "
- "a FIFO underflow error, or a error defined by the user "
- "application." },
- { "ifInUcastPkts",
- "The number of valid unicast frames received." },
- { "ifInMulticastPkts",
- "The number of valid multicast frames received. The count does "
- "not include pause frames." },
- { "ifInBroadcastPkts",
- "The number of valid broadcast frames received." },
- { "ifOutDiscards",
- "This statistics counter is not in use. The MAC function does not "
- "discard frames that are written to the FIFO buffer by the user "
- "application." },
- { "ifOutUcastPkts",
- "The number of valid unicast frames transmitted." },
- { "ifOutMulticastPkts",
- "The number of valid multicast frames transmitted, excluding pause "
- "frames." },
- { "ifOutBroadcastPkts",
- "The number of valid broadcast frames transmitted." },
- { "etherStatsDropEvents",
- "The number of frames that are dropped due to MAC internal errors "
- "when FIFO buffer overflow persists." },
- { "etherStatsOctets",
- "The lower 32 bits of the total number of octets received. This "
- "count includes both good and errored frames." },
- { "etherStatsPkts",
- "The total number of good and errored frames received." },
- { "etherStatsUndersizePkts",
- "The number of frames received with length less than 64 bytes. "
- "This count does not include errored frames." },
- { "etherStatsOversizePkts",
- "The number of frames received that are longer than the value "
- "configured in the frm_length register. This count does not "
- "include errored frames." },
- { "etherStatsPkts64Octets",
- "The number of 64-byte frames received. This count includes good "
- "and errored frames." },
- { "etherStatsPkts65to127Octets",
- "The number of received good and errored frames between the length "
- "of 65 and 127 bytes." },
- { "etherStatsPkts128to255Octets",
- "The number of received good and errored frames between the length "
- "of 128 and 255 bytes." },
- { "etherStatsPkts256to511Octets",
- "The number of received good and errored frames between the length "
- "of 256 and 511 bytes." },
- { "etherStatsPkts512to1023Octets",
- "The number of received good and errored frames between the length "
- "of 512 and 1023 bytes." },
- { "etherStatsPkts1024to1518Octets",
- "The number of received good and errored frames between the length "
- "of 1024 and 1518 bytes." },
- { "etherStatsPkts1519toXOctets",
- "The number of received good and errored frames between the length "
- "of 1519 and the maximum frame length configured in the frm_length "
- "register." },
- { "etherStatsJabbers",
- "Too long frames with CRC error." },
- { "etherStatsFragments",
- "Too short frames with CRC error." },
- /* 0x39 unused, 0x3a/b non-stats. */
- [0x3c] =
- /* Extended Statistics Counters */
- { "msb_aOctetsTransmittedOK",
- "Upper 32 bits of the number of data and padding octets that are "
- "successfully transmitted." },
- { "msb_aOctetsReceivedOK",
- "Upper 32 bits of the number of data and padding octets that are "
- "successfully received." },
- { "msb_etherStatsOctets",
- "Upper 32 bits of the total number of octets received. This count "
- "includes both good and errored frames." }
-};
-
-static int
-sysctl_atse_mac_stats_proc(SYSCTL_HANDLER_ARGS)
-{
- struct atse_softc *sc;
- int error, offset, s;
-
- sc = arg1;
- offset = arg2;
-
- s = CSR_READ_4(sc, offset);
- error = sysctl_handle_int(oidp, &s, 0, req);
- if (error || !req->newptr) {
- return (error);
- }
-
- return (0);
-}
-
-static struct atse_rx_err_stats_regs {
- const char *name;
- const char *descr;
-} atse_rx_err_stats_regs[] = {
-#define ATSE_RX_ERR_FIFO_THRES_EOP 0 /* FIFO threshold reached, on EOP. */
-#define ATSE_RX_ERR_ELEN 1 /* Frame/payload length not valid. */
-#define ATSE_RX_ERR_CRC32 2 /* CRC-32 error. */
-#define ATSE_RX_ERR_FIFO_THRES_TRUNC 3 /* FIFO thresh., truncated frame. */
-#define ATSE_RX_ERR_4 4 /* ? */
-#define ATSE_RX_ERR_5 5 /* / */
-
- { "rx_err_fifo_thres_eop",
- "FIFO threshold reached, reported on EOP." },
- { "rx_err_fifo_elen",
- "Frame or payload length not valid." },
- { "rx_err_fifo_crc32",
- "CRC-32 error." },
- { "rx_err_fifo_thres_trunc",
- "FIFO threshold reached, truncated frame" },
- { "rx_err_4",
- "?" },
- { "rx_err_5",
- "?" },
-};
-
-static int
-sysctl_atse_rx_err_stats_proc(SYSCTL_HANDLER_ARGS)
-{
- struct atse_softc *sc;
- int error, offset, s;
-
- sc = arg1;
- offset = arg2;
-
- s = sc->atse_rx_err[offset];
- error = sysctl_handle_int(oidp, &s, 0, req);
- if (error || !req->newptr) {
- return (error);
- }
-
- return (0);
-}
-
-static void
-atse_sysctl_stats_attach(device_t dev)
-{
- struct sysctl_ctx_list *sctx;
- struct sysctl_oid *soid;
- struct atse_softc *sc;
- int i;
-
- sc = device_get_softc(dev);
- sctx = device_get_sysctl_ctx(dev);
- soid = device_get_sysctl_tree(dev);
-
- /* MAC statistics. */
- for (i = 0; i < nitems(atse_mac_stats_regs); i++) {
- if (atse_mac_stats_regs[i].name == NULL ||
- atse_mac_stats_regs[i].descr == NULL) {
- continue;
- }
-
- SYSCTL_ADD_PROC(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
- atse_mac_stats_regs[i].name,
- CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
- sc, i, sysctl_atse_mac_stats_proc, "IU",
- atse_mac_stats_regs[i].descr);
- }
-
- /* rx_err[]. */
- for (i = 0; i < ATSE_RX_ERR_MAX; i++) {
- if (atse_rx_err_stats_regs[i].name == NULL ||
- atse_rx_err_stats_regs[i].descr == NULL) {
- continue;
- }
-
- SYSCTL_ADD_PROC(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
- atse_rx_err_stats_regs[i].name,
- CTLTYPE_UINT | CTLFLAG_RD | CTLFLAG_NEEDGIANT,
- sc, i, sysctl_atse_rx_err_stats_proc, "IU",
- atse_rx_err_stats_regs[i].descr);
- }
-}
-
-/*
- * Generic device handling routines.
- */
-int
-atse_attach(device_t dev)
-{
- struct atse_softc *sc;
- if_t ifp;
- uint32_t caps;
- int error;
-
- sc = device_get_softc(dev);
- sc->dev = dev;
-
- /* Get xDMA controller */
- sc->xdma_tx = xdma_ofw_get(sc->dev, "tx");
- if (sc->xdma_tx == NULL) {
- device_printf(dev, "Can't find DMA controller.\n");
- return (ENXIO);
- }
-
- /*
- * Only final (EOP) write can be less than "symbols per beat" value
- * so we have to defrag mbuf chain.
- * Chapter 15. On-Chip FIFO Memory Core.
- * Embedded Peripherals IP User Guide.
- */
- caps = XCHAN_CAP_NOSEG;
-
- /* Alloc xDMA virtual channel. */
- sc->xchan_tx = xdma_channel_alloc(sc->xdma_tx, caps);
- if (sc->xchan_tx == NULL) {
- device_printf(dev, "Can't alloc virtual DMA channel.\n");
- return (ENXIO);
- }
-
- /* Setup interrupt handler. */
- error = xdma_setup_intr(sc->xchan_tx, 0,
- atse_xdma_tx_intr, sc, &sc->ih_tx);
- if (error) {
- device_printf(sc->dev,
- "Can't setup xDMA interrupt handler.\n");
- return (ENXIO);
- }
-
- xdma_prep_sg(sc->xchan_tx,
- TX_QUEUE_SIZE, /* xchan requests queue size */
- MCLBYTES, /* maxsegsize */
- 8, /* maxnsegs */
- 16, /* alignment */
- 0, /* boundary */
- BUS_SPACE_MAXADDR_32BIT,
- BUS_SPACE_MAXADDR);
-
- /* Get RX xDMA controller */
- sc->xdma_rx = xdma_ofw_get(sc->dev, "rx");
- if (sc->xdma_rx == NULL) {
- device_printf(dev, "Can't find DMA controller.\n");
- return (ENXIO);
- }
-
- /* Alloc xDMA virtual channel. */
- sc->xchan_rx = xdma_channel_alloc(sc->xdma_rx, caps);
- if (sc->xchan_rx == NULL) {
- device_printf(dev, "Can't alloc virtual DMA channel.\n");
- return (ENXIO);
- }
-
- /* Setup interrupt handler. */
- error = xdma_setup_intr(sc->xchan_rx, XDMA_INTR_NET,
- atse_xdma_rx_intr, sc, &sc->ih_rx);
- if (error) {
- device_printf(sc->dev,
- "Can't setup xDMA interrupt handler.\n");
- return (ENXIO);
- }
-
- xdma_prep_sg(sc->xchan_rx,
- RX_QUEUE_SIZE, /* xchan requests queue size */
- MCLBYTES, /* maxsegsize */
- 1, /* maxnsegs */
- 16, /* alignment */
- 0, /* boundary */
- BUS_SPACE_MAXADDR_32BIT,
- BUS_SPACE_MAXADDR);
-
- mtx_init(&sc->br_mtx, "buf ring mtx", NULL, MTX_DEF);
- sc->br = buf_ring_alloc(BUFRING_SIZE, M_DEVBUF,
- M_NOWAIT, &sc->br_mtx);
- if (sc->br == NULL) {
- return (ENOMEM);
- }
-
- atse_ethernet_option_bits_read(dev);
-
- mtx_init(&sc->atse_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
- MTX_DEF);
-
- callout_init_mtx(&sc->atse_tick, &sc->atse_mtx, 0);
-
- /*
- * We are only doing single-PHY with this driver currently. The
- * defaults would be right so that BASE_CFG_MDIO_ADDR0 points to the
- * 1st PHY address (0) apart from the fact that BMCR0 is always
- * the PCS mapping, so we always use BMCR1. See Table 5-1 0xA0-0xBF.
- */
-#if 0 /* Always PCS. */
- sc->atse_bmcr0 = MDIO_0_START;
- CSR_WRITE_4(sc, BASE_CFG_MDIO_ADDR0, 0x00);
-#endif
- /* Always use matching PHY for atse[0..]. */
- sc->atse_phy_addr = device_get_unit(dev);
- sc->atse_bmcr1 = MDIO_1_START;
- CSR_WRITE_4(sc, BASE_CFG_MDIO_ADDR1, sc->atse_phy_addr);
-
- /* Reset the adapter. */
- atse_reset(sc);
-
- /* Setup interface. */
- ifp = sc->atse_ifp = if_alloc(IFT_ETHER);
- if (ifp == NULL) {
- device_printf(dev, "if_alloc() failed\n");
- error = ENOSPC;
- goto err;
- }
- if_setsoftc(ifp, sc);
- if_initname(ifp, device_get_name(dev), device_get_unit(dev));
- if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
- if_setioctlfn(ifp, atse_ioctl);
- if_settransmitfn(ifp, atse_transmit);
- if_setqflushfn(ifp, atse_qflush);
- if_setinitfn(ifp, atse_init);
- if_setsendqlen(ifp, ATSE_TX_LIST_CNT - 1);
- if_setsendqready(ifp);
-
- /* MII setup. */
- error = mii_attach(dev, &sc->atse_miibus, ifp, atse_ifmedia_upd,
- atse_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, 0);
- if (error != 0) {
- device_printf(dev, "attaching PHY failed: %d\n", error);
- goto err;
- }
-
- /* Call media-indepedent attach routine. */
- ether_ifattach(ifp, sc->atse_eth_addr);
-
- /* Tell the upper layer(s) about vlan mtu support. */
- if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));
- if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
- if_setcapenable(ifp, if_getcapabilities(ifp));
-
-err:
- if (error != 0) {
- atse_detach(dev);
- }
-
- if (error == 0) {
- atse_sysctl_stats_attach(dev);
- }
-
- atse_rx_enqueue(sc, NUM_RX_MBUF);
- xdma_queue_submit(sc->xchan_rx);
-
- return (error);
-}
-
-static int
-atse_detach(device_t dev)
-{
- struct atse_softc *sc;
- if_t ifp;
-
- sc = device_get_softc(dev);
- KASSERT(mtx_initialized(&sc->atse_mtx), ("%s: mutex not initialized",
- device_get_nameunit(dev)));
- ifp = sc->atse_ifp;
-
- /* Only cleanup if attach succeeded. */
- if (device_is_attached(dev)) {
- ATSE_LOCK(sc);
- atse_stop_locked(sc);
- ATSE_UNLOCK(sc);
- callout_drain(&sc->atse_tick);
- ether_ifdetach(ifp);
- }
- if (sc->atse_miibus != NULL) {
- device_delete_child(dev, sc->atse_miibus);
- }
-
- if (ifp != NULL) {
- if_free(ifp);
- }
-
- mtx_destroy(&sc->atse_mtx);
-
- xdma_channel_free(sc->xchan_tx);
- xdma_channel_free(sc->xchan_rx);
- xdma_put(sc->xdma_tx);
- xdma_put(sc->xdma_rx);
-
- return (0);
-}
-
-/* Shared between nexus and fdt implementation. */
-void
-atse_detach_resources(device_t dev)
-{
- struct atse_softc *sc;
-
- sc = device_get_softc(dev);
-
- if (sc->atse_mem_res != NULL) {
- bus_release_resource(dev, SYS_RES_MEMORY, sc->atse_mem_rid,
- sc->atse_mem_res);
- sc->atse_mem_res = NULL;
- }
-}
-
-int
-atse_detach_dev(device_t dev)
-{
- int error;
-
- error = atse_detach(dev);
- if (error) {
- /* We are basically in undefined state now. */
- device_printf(dev, "atse_detach() failed: %d\n", error);
- return (error);
- }
-
- atse_detach_resources(dev);
-
- return (0);
-}
-
-int
-atse_miibus_readreg(device_t dev, int phy, int reg)
-{
- struct atse_softc *sc;
- int val;
-
- sc = device_get_softc(dev);
-
- /*
- * We currently do not support re-mapping of MDIO space on-the-fly
- * but de-facto hard-code the phy#.
- */
- if (phy != sc->atse_phy_addr) {
- return (0);
- }
-
- val = PHY_READ_2(sc, reg);
-
- return (val);
-}
-
-int
-atse_miibus_writereg(device_t dev, int phy, int reg, int data)
-{
- struct atse_softc *sc;
-
- sc = device_get_softc(dev);
-
- /*
- * We currently do not support re-mapping of MDIO space on-the-fly
- * but de-facto hard-code the phy#.
- */
- if (phy != sc->atse_phy_addr) {
- return (0);
- }
-
- PHY_WRITE_2(sc, reg, data);
- return (0);
-}
-
-void
-atse_miibus_statchg(device_t dev)
-{
- struct atse_softc *sc;
- struct mii_data *mii;
- if_t ifp;
- uint32_t val4;
-
- sc = device_get_softc(dev);
- ATSE_LOCK_ASSERT(sc);
-
- mii = device_get_softc(sc->atse_miibus);
- ifp = sc->atse_ifp;
- if (mii == NULL || ifp == NULL ||
- (if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) {
- return;
- }
-
- val4 = CSR_READ_4(sc, BASE_CFG_COMMAND_CONFIG);
-
- /* Assume no link. */
- sc->atse_flags &= ~ATSE_FLAGS_LINK;
-
- if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
- (IFM_ACTIVE | IFM_AVALID)) {
- switch (IFM_SUBTYPE(mii->mii_media_active)) {
- case IFM_10_T:
- val4 |= BASE_CFG_COMMAND_CONFIG_ENA_10;
- val4 &= ~BASE_CFG_COMMAND_CONFIG_ETH_SPEED;
- sc->atse_flags |= ATSE_FLAGS_LINK;
- break;
- case IFM_100_TX:
- val4 &= ~BASE_CFG_COMMAND_CONFIG_ENA_10;
- val4 &= ~BASE_CFG_COMMAND_CONFIG_ETH_SPEED;
- sc->atse_flags |= ATSE_FLAGS_LINK;
- break;
- case IFM_1000_T:
- val4 &= ~BASE_CFG_COMMAND_CONFIG_ENA_10;
- val4 |= BASE_CFG_COMMAND_CONFIG_ETH_SPEED;
- sc->atse_flags |= ATSE_FLAGS_LINK;
- break;
- default:
- break;
- }
- }
-
- if ((sc->atse_flags & ATSE_FLAGS_LINK) == 0) {
- /* Need to stop the MAC? */
- return;
- }
-
- if (IFM_OPTIONS(mii->mii_media_active & IFM_FDX) != 0) {
- val4 &= ~BASE_CFG_COMMAND_CONFIG_HD_ENA;
- } else {
- val4 |= BASE_CFG_COMMAND_CONFIG_HD_ENA;
- }
-
- /* flow control? */
-
- /* Make sure the MAC is activated. */
- val4 |= BASE_CFG_COMMAND_CONFIG_TX_ENA;
- val4 |= BASE_CFG_COMMAND_CONFIG_RX_ENA;
-
- CSR_WRITE_4(sc, BASE_CFG_COMMAND_CONFIG, val4);
-}
-
-MODULE_DEPEND(atse, ether, 1, 1, 1);
-MODULE_DEPEND(atse, miibus, 1, 1, 1);
diff --git a/sys/dev/altera/atse/if_atse_fdt.c b/sys/dev/altera/atse/if_atse_fdt.c
deleted file mode 100644
index 77fa930ee945..000000000000
--- a/sys/dev/altera/atse/if_atse_fdt.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2013 Bjoern A. Zeeb
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-11-C-0249)
- * ("MRC2"), as part of the DARPA MRC research programme.
- *
- * 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.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-
-/* "device miibus" required. See GENERIC if you get errors here. */
-#include "miibus_if.h"
-
-static int
-atse_probe_fdt(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "altera,atse")) {
- return (ENXIO);
- }
-
- device_set_desc(dev, "Altera Triple-Speed Ethernet MegaCore");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-atse_attach_fdt(device_t dev)
-{
- struct atse_softc *sc;
- int error;
-
- sc = device_get_softc(dev);
- sc->atse_dev = dev;
- sc->atse_unit = device_get_unit(dev);
-
- /*
- * FDT has the list of our resources. Given we are using multiple
- * memory regions and possibly multiple interrupts, we need to attach
- * them in the order specified in .dts:
- * MAC, RX and RXC FIFO, TX and TXC FIFO; RX INTR, TX INTR.
- */
-
- /* MAC: Avalon-MM, atse management register region. */
- sc->atse_mem_rid = 0;
- sc->atse_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
- &sc->atse_mem_rid, RF_ACTIVE);
- if (sc->atse_mem_res == NULL) {
- device_printf(dev, "failed to map memory for ctrl region\n");
- /* Cleanup. */
- atse_detach_resources(dev);
-
- return (ENXIO);
- }
- if (bootverbose)
- device_printf(sc->atse_dev, "MAC ctrl region at mem %p-%p\n",
- (void *)rman_get_start(sc->atse_mem_res),
- (void *)(rman_get_start(sc->atse_mem_res) +
- rman_get_size(sc->atse_mem_res)));
-
- error = atse_attach(dev);
- if (error) {
- /* Cleanup. */
- atse_detach_resources(dev);
-
- return (error);
- }
-
- return (0);
-}
-
-static device_method_t atse_methods_fdt[] = {
- /* Device interface */
- DEVMETHOD(device_probe, atse_probe_fdt),
- DEVMETHOD(device_attach, atse_attach_fdt),
- DEVMETHOD(device_detach, atse_detach_dev),
-
- /* MII interface */
- DEVMETHOD(miibus_readreg, atse_miibus_readreg),
- DEVMETHOD(miibus_writereg, atse_miibus_writereg),
- DEVMETHOD(miibus_statchg, atse_miibus_statchg),
-
- DEVMETHOD_END
-};
-
-static driver_t atse_driver_fdt = {
- "atse",
- atse_methods_fdt,
- sizeof(struct atse_softc)
-};
-
-DRIVER_MODULE(atse, simplebus, atse_driver_fdt, 0, 0);
-DRIVER_MODULE(miibus, atse, miibus_driver, 0, 0);
diff --git a/sys/dev/altera/atse/if_atse_nexus.c b/sys/dev/altera/atse/if_atse_nexus.c
deleted file mode 100644
index 22a66dd305d4..000000000000
--- a/sys/dev/altera/atse/if_atse_nexus.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012,2013 Bjoern A. Zeeb
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-11-C-0249)
- * ("MRC2"), as part of the DARPA MRC research programme.
- *
- * 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.
- */
-
-#include
-#include "opt_device_polling.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-
-/* "device miibus" required. See GENERIC if you get errors here. */
-#include "miibus_if.h"
-
-MODULE_DEPEND(atse, ether, 1, 1, 1);
-MODULE_DEPEND(atse, miibus, 1, 1, 1);
-
-/*
- * Device routines for interacting with nexus (probe, attach, detach) & helpers.
- * XXX We should add suspend/resume later.
- */
-static int __unused
-atse_resource_int(device_t dev, const char *resname, int *v)
-{
- int error;
-
- error = resource_int_value(device_get_name(dev), device_get_unit(dev),
- resname, v);
- if (error != 0) {
- /* If it does not exist, we fail, so not ingoring ENOENT. */
- device_printf(dev, "could not fetch '%s' hint\n", resname);
- return (error);
- }
-
- return (0);
-}
-
-static int __unused
-atse_resource_long(device_t dev, const char *resname, long *v)
-{
- int error;
-
- error = resource_long_value(device_get_name(dev), device_get_unit(dev),
- resname, v);
- if (error != 0) {
- /* If it does not exist, we fail, so not ingoring ENOENT. */
- device_printf(dev, "could not fetch '%s' hint\n", resname);
- return (error);
- }
-
- return (0);
-}
-
-static int
-atse_probe_nexus(device_t dev)
-{
-
- device_set_desc(dev, "Altera Triple-Speed Ethernet MegaCore");
-
- return (BUS_PROBE_NOWILDCARD);
-}
-
-static int
-atse_attach_nexus(device_t dev)
-{
- struct atse_softc *sc;
- int error;
-
- sc = device_get_softc(dev);
- sc->atse_dev = dev;
- sc->atse_unit = device_get_unit(dev);
-
- /* Avalon-MM, atse management register region. */
- sc->atse_mem_rid = 0;
- sc->atse_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
- &sc->atse_mem_rid, RF_ACTIVE);
- if (sc->atse_mem_res == NULL) {
- device_printf(dev, "failed to map memory for ctrl region\n");
- return (ENXIO);
- }
-
- error = atse_attach(dev);
- if (error) {
- /* Cleanup. */
- atse_detach_resources(dev);
- return (error);
- }
-
- return (0);
-}
-
-static device_method_t atse_methods_nexus[] = {
- /* Device interface */
- DEVMETHOD(device_probe, atse_probe_nexus),
- DEVMETHOD(device_attach, atse_attach_nexus),
- DEVMETHOD(device_detach, atse_detach_dev),
-
- /* MII interface */
- DEVMETHOD(miibus_readreg, atse_miibus_readreg),
- DEVMETHOD(miibus_writereg, atse_miibus_writereg),
- DEVMETHOD(miibus_statchg, atse_miibus_statchg),
-
- DEVMETHOD_END
-};
-
-static driver_t atse_driver_nexus = {
- "atse",
- atse_methods_nexus,
- sizeof(struct atse_softc)
-};
-
-DRIVER_MODULE(atse, nexus, atse_driver_nexus, 0, 0);
-DRIVER_MODULE(miibus, atse, miibus_driver, 0, 0);
diff --git a/sys/dev/altera/atse/if_atsereg.h b/sys/dev/altera/atse/if_atsereg.h
deleted file mode 100644
index 2f7643f27094..000000000000
--- a/sys/dev/altera/atse/if_atsereg.h
+++ /dev/null
@@ -1,464 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012 Bjoern A. Zeeb
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-11-C-0249)
- * ("MRC2"), as part of the DARPA MRC research programme.
- *
- * 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.
- */
-
-#ifndef _DEV_IF_ATSEREG_H
-#define _DEV_IF_ATSEREG_H
-
-#include
-
-#define ATSE_VENDOR 0x6af7
-#define ATSE_DEVICE 0x00bd
-
-/* See hints file/fdt for ctrl port and Avalon FIFO addresses. */
-
-/* Section 3. Parameter Settings. */
-/*
- * This is a lot of options that affect the way things are synthesized.
- * We cannot really make them all hints and most of them might be stale.
- */
-
-/* 3-1 Core Configuration */
-#if 0
-static const char *atse_core_core_variation[] = {
- [0] = "10/100/1000 Mbps Ethernet MAC only",
- [1] = "10/100/1000 Mbps Ethernet MAC with 1000BASE-X/SGMII PCS",
- [2] = "1000BASE-X/SGMII PCS only",
- [3] = "1000 Mbps Small MAC",
- [4] = "10/100 Mbps Small MAC",
- NULL
-};
-static const char *atse_core_interface[] = {
- [0] = "MII", /* Core variation 4. */
- [1] = "GMII", /* Core variation 3. */
- [2] = "RGMII", /* Core variation 0,1,3. */
- [3] = "MII/GMII", /* Core variation 0,1. */
- NULL
-};
-#endif
-#define CORE_CORE_VARIATION 1 /* atse_core_core_variation[] */
-#define CORE_INTERFACE 3 /* atse_core_interface[] */
-#define CORE_USE_INTERNAL_FIFO 1
-#define CORE_NUMBER_OF_PORTS 1 /* Internal FIFO count. */
-#define CORE_USE_TRANSCEIVER_BLOCK 1 /* SGMII PCS transceiver:
- * LVDS I/O. */
-
-/* 3-2 MAC Options. */
-/* Ethernet MAC Options. */
-#define MAC_ENABLE_10_100_HDX_SUPPORT 0
-#define MAC_ENABLE_RG_G_MII_LOOPBACK 0
-#define MAC_ENABLE_SUPL_MAC_UCAST_ADDR 0 /* Supplementary MAC unicast. */
-#define MAC_INCLUDE_STATISTICS_COUNTERS 0
-#define MAC_STATISTICS_COUNTERS_64BIT 0
-#define MAC_INCLUDE_MC_HASHTABLE 0 /* Multicast. */
-#define MAC_ALIGN_PKTHDR_32BIT 1
-#define MAC_ENABLE_FDX_FLOW_CTRL 0
-#define MAC_ENABLE_VLAN_DETECTION 0 /* VLAN and stacked VLANs. */
-#define MAC_ENABLE_MAGIC_PKT_DETECTION 0
-/* MDIO Module. */
-#define MAC_MDIO_INCLUDE_MDIO_MODULE 1
-#define MAC_MDIO_HOST_CLOCK_DIVISOR 40 /* Not just On/Off. */
-
-/* 3-4 FIFO Options. */
-/* Width and Memory Type. */
-#if 0
-static char *fifo_memory_block[] = {
- [0] = "M4K",
- [1] = "M9K",
- [2] = "M144K",
- [3] = "MRAM",
- [4] = "AUTO",
- NULL
-};
-#endif
-#define FIFO_MEMORY_BLOCK 4
-#define FIFO_WITDH 32 /* Other: 8 bits. */
-/* Depth. */
-#define FIFO_DEPTH_TX 2048 /* 64 .. 64k, 2048x32bits. */
-#define FIFO_DEPTH_RX 2048 /* 64 .. 64k, 2048x32bits. */
-
-#define ATSE_TX_LIST_CNT 5 /* Certainly not bufferbloat. */
-
-/* 3-4 PCS/Transceiver Options */
-/* PCS Options. */
-#define PCS_TXRX_PHY_ID 0x00000000 /* 32 bits */
-#define PCS_TXRX_ENABLE_SGMII_BRIDGE 0
-/* Transceiver Options. */
-#define PCS_TXRX_EXP_POWER_DOWN_SIGNAL 0 /* Export power down signal. */
-#define PCS_TXRX_ENABLE_DYNAMIC_RECONF 0 /* Dynamic trans. reconfig. */
-#define PCS_TXRX_STARTING_CHANNEL 0 /* 0..284. */
-
-/* -------------------------------------------------------------------------- */
-
-/* XXX more values based on the bitmaps provided. Cleanup. */
-/* See regs above. */
-#define AVALON_FIFO_TX_BLOCK_DIAGRAM 0
-#define AVALON_FIFO_TX_BLOCK_DIAGRAM_SHOW_SIGANLS 0
-#define AVALON_FIFO_TX_PARAM_SINGLE_RESET_MODE 0
-#define AVALON_FIFO_TX_BASIC_OPTS_DEPTH 16
-#define AVALON_FIFO_TX_BASIC_OPTS_ALLOW_BACKPRESSURE 1
-#define AVALON_FIFO_TX_BASIC_OPTS_CLOCK_SETTING "Single Clock Mode"
-#define AVALON_FIFO_TX_BASIC_OPTS_FIFO_IMPL "Construct FIFO from embedded memory blocks"
-#define AVALON_FIFO_TX_STATUS_PORT_CREATE_STATUS_INT_FOR_INPUT 1
-#define AVALON_FIFO_TX_STATUS_PORT_CREATE_STATUS_INT_FOR_OUTPUT 0
-#define AVALON_FIFO_TX_STATUS_PORT_ENABLE_IRQ_FOR_STATUS_PORT 1
-#define AVALON_FIFO_TX_INPUT_TYPE "AVALONMM_WRITE"
-#define AVALON_FIFO_TX_OUTPUT_TYPE "AVALONST_SOURCE"
-#define AVALON_FIFO_TX_AVALON_MM_PORT_SETTINGS_DATA_WIDTH ""
-#define AVALON_FIFO_TX_AVALON_ST_PORT_SETTINGS_BITS_PER_SYMBOL 8
-#define AVALON_FIFO_TX_AVALON_ST_PORT_SETTINGS_SYM_PER_BEAT 4
-#define AVALON_FIFO_TX_AVALON_ST_PORT_SETTINGS_ERROR_WIDTH 1
-#define AVALON_FIFO_TX_AVALON_ST_PORT_SETTINGS_CHANNEL_WIDTH 0
-#define AVALON_FIFO_TX_AVALON_ST_PORT_SETTINGS_ENABLE_PACKET_DATA 1
-
-#define AVALON_FIFO_RX_BLOCK_DIAGRAM 0
-#define AVALON_FIFO_RX_BLOCK_DIAGRAM_SHOW_SIGNALS 0
-#define AVALON_FIFO_RX_PARAM_SINGLE_RESET_MODE 0
-#define AVALON_FIFO_RX_BASIC_OPTS_DEPTH 16
-#define AVALON_FIFO_RX_BASIC_OPTS_ALLOW_BACKPRESSURE 1
-#define AVALON_FIFO_RX_BASIC_OPTS_CLOCK_SETTING "Single Clock Mode"
-#define AVALON_FIFO_RX_BASIC_OPTS_FIFO_IMPL "Construct FIFO from embedded memory blocks"
-#define AVALON_FIFO_RX_STATUS_PORT_CREATE_STATUS_INT_FOR_INPUT 1
-#define AVALON_FIFO_RX_STATUS_PORT_CREATE_STATUS_INT_FOR_OUTPUT 0
-#define AVALON_FIFO_RX_STATUS_PORT_ENABLE_IRQ_FOR_STATUS_PORT 1
-#define AVALON_FIFO_RX_INPUT_TYPE "AVALONST_SINK"
-#define AVALON_FIFO_RX_OUTPUT_TYPE "AVALONMM_READ"
-#define AVALON_FIFO_RX_AVALON_MM_PORT_SETTINGS_DATA_WIDTH ""
-#define AVALON_FIFO_RX_AVALON_ST_PORT_SETTINGS_BITS_PER_SYMBOL 8
-#define AVALON_FIFO_RX_AVALON_ST_PORT_SETTINGS_SYM_PER_BEAT 4
-#define AVALON_FIFO_RX_AVALON_ST_PORT_SETTINGS_ERROR_WIDTH 6
-#define AVALON_FIFO_RX_AVALON_ST_PORT_SETTINGS_CHANNEL_WIDTH 0
-#define AVALON_FIFO_RX_AVALON_ST_PORT_SETTINGS_ENABLE_PACKET_DATA 1
-
-/* -------------------------------------------------------------------------- */
-
-/* 5. Configuration Register Space. */
-
-/* 5-1, MAC Configuration Register Space; Dword offsets. */
-/* 0x00 - 0x17, Base Configuration. */
-#define BASE_CONFIG_REV 0x00 /* ro, IP Core ver. */
-#define BASE_CFG_REV_VER_MASK 0x0000FFFF
-#define BASE_CFG_REV_CUST_VERSION__MASK 0xFFFF0000
-
-#define BASE_CFG_SCRATCH 0x01 /* rw, 0 */
-
-#define BASE_CFG_COMMAND_CONFIG 0x02 /* rw, 0 */
-#define BASE_CFG_COMMAND_CONFIG_TX_ENA (1<<0) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_RX_ENA (1<<1) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_XON_GEN (1<<2) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_ETH_SPEED (1<<3) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_PROMIS_EN (1<<4) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_PAD_EN (1<<5) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_CRC_FWD (1<<6) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_PAUSE_FWD (1<<7) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_PAUSE_IGNORE (1<<8) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_TX_ADDR_INS (1<<9) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_HD_ENA (1<<10) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_EXCESS_COL (1<<11) /* ro */
-#define BASE_CFG_COMMAND_CONFIG_LATE_COL (1<<12) /* ro */
-#define BASE_CFG_COMMAND_CONFIG_SW_RESET (1<<13) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_MHASH_SEL (1<<14) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_LOOP_ENA (1<<15) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_TX_ADDR_SEL (1<<16|1<<17|1<<18) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_MAGIC_ENA (1<<19) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_SLEEP (1<<20) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_WAKEUP (1<<21) /* ro */
-#define BASE_CFG_COMMAND_CONFIG_XOFF_GEN (1<<22) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_CNTL_FRM_ENA (1<<23) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_NO_LGTH_CHECK (1<<24) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_ENA_10 (1<<25) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_RX_ERR_DISC (1<<26) /* rw */
-#define BASE_CFG_COMMAND_CONFIG_DISABLE_READ_TIMEOUT (1<<27) /* rw */
- /* 28-30 Reserved. */ /* - */
-#define BASE_CFG_COMMAND_CONFIG_CNT_RESET (1<<31) /* rw */
-
-#define BASE_CFG_MAC_0 0x03 /* rw, 0 */
-#define BASE_CFG_MAC_1 0x04 /* rw, 0 */
-#define BASE_CFG_FRM_LENGTH 0x05 /* rw/ro, 1518 */
-#define BASE_CFG_PAUSE_QUANT 0x06 /* rw, 0 */
-#define BASE_CFG_RX_SECTION_EMPTY 0x07 /* rw/ro, 0 */
-#define BASE_CFG_RX_SECTION_FULL 0x08 /* rw/ro, 0 */
-#define BASE_CFG_TX_SECTION_EMPTY 0x09 /* rw/ro, 0 */
-#define BASE_CFG_TX_SECTION_FULL 0x0A /* rw/ro, 0 */
-#define BASE_CFG_RX_ALMOST_EMPTY 0x0B /* rw/ro, 0 */
-#define BASE_CFG_RX_ALMOST_FULL 0x0C /* rw/ro, 0 */
-#define BASE_CFG_TX_ALMOST_EMPTY 0x0D /* rw/ro, 0 */
-#define BASE_CFG_TX_ALMOST_FULL 0x0E /* rw/ro, 0 */
-#define BASE_CFG_MDIO_ADDR0 0x0F /* rw, 0 */
-#define BASE_CFG_MDIO_ADDR1 0x10 /* rw, 1 */
-#define BASE_CFG_HOLDOFF_QUANT 0x11 /* rw, 0xFFFF */
-/* 0x12-0x16 Reserved. */ /* -, 0 */
-#define BASE_CFG_TX_IPG_LENGTH 0x17 /* rw, 0 */
-
-/* 0x18 - 0x38, Statistics Counters. */
-#define STATS_A_MAC_ID_0 0x18 /* ro */
-#define STATS_A_MAC_ID_1 0x19 /* ro */
-#define STATS_A_FRAMES_TX_OK 0x1A /* ro */
-#define STATS_A_FRAMES_RX_OK 0x1B /* ro */
-#define STATS_A_FCS_ERRORS 0x1C /* ro */
-#define STATS_A_ALIGNMENT_ERRORS 0x1D /* ro */
-#define STATS_A_OCTETS_TX_OK 0x1E /* ro */
-#define STATS_A_OCTETS_RX_OK 0x1F /* ro */
-#define STATS_A_TX_PAUSE_MAX_CTRL_FRAME 0x20 /* ro */
-#define STATS_A_RX_PAUSE_MAX_CTRL_FRAME 0x21 /* ro */
-#define STATS_IF_IN_ERRORS 0x22 /* ro */
-#define STATS_IF_OUT_ERRORS 0x23 /* ro */
-#define STATS_IF_IN_UCAST_PKTS 0x24 /* ro */
-#define STATS_IF_IN_MULTICAST_PKTS 0x25 /* ro */
-#define STATS_IF_IN_BROADCAST_PKTS 0x26 /* ro */
-#define STATS_IF_OUT_DISCARDS 0x27 /* ro */
-#define STATS_IF_OUT_UCAST_PKTS 0x28 /* ro */
-#define STATS_IF_OUT_MULTICAST_PKTS 0x29 /* ro */
-#define STATS_IF_OUT_BROADCAST_PKTS 0x2A /* ro */
-#define STATS_ETHER_STATS_DROP_EVENT 0x2B /* ro */
-#define STATS_ETHER_STATS_OCTETS 0x2C /* ro */
-#define STATS_ETHER_STATS_PKTS 0x2D /* ro */
-#define STATS_ETHER_STATS_USIZE_PKTS 0x2E /* ro */
-#define STATS_ETHER_STATS_OSIZE_PKTS 0x2F /* ro */
-#define STATS_ETHER_STATS_PKTS_64_OCTETS 0x30 /* ro */
-#define STATS_ETHER_STATS_PKTS_65_TO_127_OCTETS 0x31 /* ro */
-#define STATS_ETHER_STATS_PKTS_128_TO_255_OCTETS 0x32 /* ro */
-#define STATS_ETHER_STATS_PKTS_256_TO_511_OCTETS 0x33 /* ro */
-#define STATS_ETHER_STATS_PKTS_512_TO_1023_OCTETS 0x34 /* ro */
-#define STATS_ETHER_STATS_PKTS_1024_TO_1518_OCTETS 0x35 /* ro */
-#define STATS_ETHER_STATS_PKTS_1519_TO_X_OCTETS 0x36 /* ro */
-#define STATS_ETHER_STATS_JABBERS 0x37 /* ro */
-#define STATS_ETHER_STATS_FRAGMENTS 0x38 /* ro */
- /* 0x39, Reserved. */ /* - */
-
-/* 0x3A, Transmit Command. */
-#define TX_CMD_STAT 0x3A /* rw */
-#define TX_CMD_STAT_OMIT_CRC (1<<17)
-#define TX_CMD_STAT_TX_SHIFT16 (1<<18)
-
-/* 0x3B, Receive Command. */
-#define RX_CMD_STAT 0x3B /* rw */
-#define RX_CMD_STAT_RX_SHIFT16 (1<<25)
-
-/* 0x3C - 0x3E, Extended Statistics Counters. */
-#define ESTATS_MSB_A_OCTETS_TX_OK 0x3C /* ro */
-#define ESTATS_MSB_A_OCTETS_RX_OK 0x3D /* ro */
-#define ESTATS_MSB_ETHER_STATS_OCTETS 0x3E /* ro */
-
-/* 0x3F, Reserved. */
-
-/* 0x40 - 0x7F, Multicast Hash Table. */
-#define MHASH_START 0x40
-#define MHASH_LEN 0x3F
-
-/* 0x80 - 0x9F, MDIO Space 0 or PCS Function Configuration. */
-#define MDIO_0_START 0x80
-
-/* The following are offsets to the first PCS register at 0x80. */
-/* See sys/dev/mii/mii.h. */
-#define PCS_CONTROL 0x00 /* rw */
- /* Bits 0:4, Reserved. */ /* - */
-#define PCS_CONTROL_UNIDIRECTIONAL_ENABLE (1<<5) /* rw */
-#define PCS_CONTROL_SPEED_SELECTION (1<<6|1<<13) /* ro */
-#define PCS_CONTROL_COLLISION_TEST (1<<7) /* ro */
-#define PCS_CONTROL_DUPLEX_MODE (1<<8) /* ro */
-#define PCS_CONTROL_RESTART_AUTO_NEGOTIATION (1<<9) /* rw */
-#define PCS_CONTROL_ISOLATE (1<<10) /* rw */
-#define PCS_CONTROL_POWERDOWN (1<<11) /* rw */
-#define PCS_CONTROL_AUTO_NEGOTIATION_ENABLE (1<<12) /* rw */
- /* See bit 6 above. */ /* ro */
-#define PCS_CONTROL_LOOPBACK (1<<14) /* rw */
-#define PCS_CONTROL_RESET (1<<15) /* rw */
-
-#define PCS_STATUS 0x01 /* ro */
-#define PCS_STATUS_EXTENDED_CAPABILITY (1<<0) /* ro */
-#define PCS_STATUS_JABBER_DETECT (1<<1) /* -, 0 */
-#define PCS_STATUS_LINK_STATUS (1<<2) /* ro */
-#define PCS_STATUS_AUTO_NEGOTIATION_ABILITY (1<<3) /* ro */
-#define PCS_STATUS_REMOTE_FAULT (1<<4) /* -, 0 */
-#define PCS_STATUS_AUTO_NEGOTIATION_COMPLETE (1<<5) /* ro */
-#define PCS_STATUS_MF_PREAMBLE_SUPPRESSION (1<<6) /* -, 0 */
-#define PCS_STATUS_UNIDIRECTIONAL_ABILITY (1<<7) /* ro */
-#define PCS_STATUS_EXTENDED_STATUS (1<<8) /* -, 0 */
-#define PCS_STATUS_100BASET2_HALF_DUPLEX (1<<9) /* ro */
-#define PCS_STATUS_100BASET2_FULL_DUPLEX (1<<10) /* ro */
-#define PCS_STATUS_10MBPS_HALF_DUPLEX (1<<11) /* ro */
-#define PCS_STATUS_10MBPS_FULL_DUPLEX (1<<12) /* ro */
-#define PCS_STATUS_100BASE_X_HALF_DUPLEX (1<<13) /* ro */
-#define PCS_STATUS_100BASE_X_FULL_DUPLEX (1<<14) /* ro */
-#define PCS_STATUS_100BASE_T4 (1<<15) /* ro */
-
-#define PCS_PHY_IDENTIFIER_0 0x02 /* ro */
-#define PCS_PHY_IDENTIFIER_1 0x03 /* ro */
-
-#define PCS_DEV_ABILITY 0x04 /* rw */
- /* 1000BASE-X */
- /* Bits 0:4, Reserved. */ /* - */
-#define PCS_DEV_ABILITY_1000BASE_X_FD (1<<5) /* rw */
-#define PCS_DEV_ABILITY_1000BASE_X_HD (1<<6) /* rw */
-#define PCS_DEV_ABILITY_1000BASE_X_PS1 (1<<7) /* rw */
-#define PCS_DEV_ABILITY_1000BASE_X_PS2 (1<<8) /* rw */
- /* Bits 9:11, Reserved. */ /* - */
-#define PCS_DEV_ABILITY_1000BASE_X_RF1 (1<<12) /* rw */
-#define PCS_DEV_ABILITY_1000BASE_X_RF2 (1<<13) /* rw */
-#define PCS_DEV_ABILITY_1000BASE_X_ACK (1<<14) /* rw */
-#define PCS_DEV_ABILITY_1000BASE_X_NP (1<<15) /* rw */
-
-#define PCS_PARTNER_ABILITY 0x05 /* ro */
- /* 1000BASE-X */
- /* Bits 0:4, Reserved. */ /* - */
-#define PCS_PARTNER_ABILITY_1000BASE_X_FD (1<<5) /* ro */
-#define PCS_PARTNER_ABILITY_1000BASE_X_HD (1<<6) /* ro */
-#define PCS_PARTNER_ABILITY_1000BASE_X_PS1 (1<<7) /* ro */
-#define PCS_PARTNER_ABILITY_1000BASE_X_PS2 (1<<8) /* ro */
- /* Bits 9:11, Reserved. */ /* - */
-#define PCS_PARTNER_ABILITY_1000BASE_X_RF1 (1<<12) /* ro */
-#define PCS_PARTNER_ABILITY_1000BASE_X_RF2 (1<<13) /* ro */
-#define PCS_PARTNER_ABILITY_1000BASE_X_ACK (1<<14) /* ro */
-#define PCS_PARTNER_ABILITY_1000BASE_X_NP (1<<15) /* ro */
- /* SGMII */
- /* Bits 0:9, Reserved. */ /* - */
-#define PCS_PARTNER_ABILITY_SGMII_COPPER_SPEED0 (1<<10) /* ro */
-#define PCS_PARTNER_ABILITY_SGMII_COPPER_SPEED1 (1<<11) /* ro */
-#define PCS_PARTNER_ABILITY_SGMII_COPPER_DUPLEX_STATUS (1<<12) /* ro */
- /* Bit 13, Reserved. */ /* - */
-#define PCS_PARTNER_ABILITY_SGMII_ACK (1<<14) /* ro */
-#define PCS_PARTNER_ABILITY_SGMII_COPPER_LINK_STATUS (1<<15) /* ro */
-
-#define PCS_AN_EXPANSION 0x06 /* ro */
-#define PCS_AN_EXPANSION_LINK_PARTNER_AUTO_NEGOTIATION_ABLE (1<<0) /* ro */
-#define PCS_AN_EXPANSION_PAGE_RECEIVE (1<<1) /* ro */
-#define PCS_AN_EXPANSION_NEXT_PAGE_ABLE (1<<2) /* -, 0 */
- /* Bits 3:15, Reserved. */ /* - */
-
-#define PCS_DEVICE_NEXT_PAGE 0x07 /* ro */
-#define PCS_PARTNER_NEXT_PAGE 0x08 /* ro */
-#define PCS_MASTER_SLAVE_CNTL 0x09 /* ro */
-#define PCS_MASTER_SLAVE_STAT 0x0A /* ro */
- /* 0x0B - 0x0E, Reserved */ /* - */
-#define PCS_EXTENDED_STATUS 0x0F /* ro */
-/* Specific Extended Registers. */
-#define PCS_EXT_SCRATCH 0x10 /* rw */
-#define PCS_EXT_REV 0x11 /* ro */
-#define PCS_EXT_LINK_TIMER_0 0x12 /* rw */
-#define PCS_EXT_LINK_TIMER_1 0x13 /* rw */
-#define PCS_EXT_IF_MODE 0x14 /* rw */
-#define PCS_EXT_IF_MODE_SGMII_ENA (1<<0) /* rw */
-#define PCS_EXT_IF_MODE_USE_SGMII_AN (1<<1) /* rw */
-#define PCS_EXT_IF_MODE_SGMII_SPEED1 (1<<2) /* rw */
-#define PCS_EXT_IF_MODE_SGMII_SPEED0 (1<<3) /* rw */
-#define PCS_EXT_IF_MODE_SGMII_DUPLEX (1<<4) /* rw */
- /* Bits 5:15, Reserved. */ /* - */
-
-#define PCS_EXT_DISABLE_READ_TIMEOUT 0x15 /* rw */
-#define PCS_EXT_READ_TIMEOUT 0x16 /* r0 */
- /* 0x17-0x1F, Reserved. */
-
-/* 0xA0 - 0xBF, MDIO Space 1. */
-#define MDIO_1_START 0xA0
-#define ATSE_BMCR MDIO_1_START
-
-/* 0xC0 - 0xC7, Supplementary Address. */
-#define SUPPL_ADDR_SMAC_0_0 0xC0 /* rw */
-#define SUPPL_ADDR_SMAC_0_1 0xC1 /* rw */
-#define SUPPL_ADDR_SMAC_1_0 0xC2 /* rw */
-#define SUPPL_ADDR_SMAC_1_1 0xC3 /* rw */
-#define SUPPL_ADDR_SMAC_2_0 0xC4 /* rw */
-#define SUPPL_ADDR_SMAC_2_1 0xC5 /* rw */
-#define SUPPL_ADDR_SMAC_3_0 0xC6 /* rw */
-#define SUPPL_ADDR_SMAC_3_1 0xC7 /* rw */
-
-/* 0xC8 - 0xCF, Reserved; set to zero, ignore on read. */
-/* 0xD7 - 0xFF, Reserved; set to zero, ignore on read. */
-
-/* -------------------------------------------------------------------------- */
-
-/* DE4 Intel Strata Flash Ethernet Option Bits area. */
-/* XXX-BZ this is something a loader will have to handle for us. */
-#define ALTERA_ETHERNET_OPTION_BITS_OFF 0x00008000
-#define ALTERA_ETHERNET_OPTION_BITS_LEN 0x00007fff
-
-/* -------------------------------------------------------------------------- */
-
-struct atse_softc {
- if_t atse_ifp;
- struct resource *atse_mem_res;
- device_t atse_miibus;
- device_t atse_dev;
- int atse_unit;
- int atse_mem_rid;
- int atse_phy_addr;
- int atse_if_flags;
- bus_addr_t atse_bmcr0;
- bus_addr_t atse_bmcr1;
- uint32_t atse_flags;
-#define ATSE_FLAGS_LINK 0x00000001
-#define ATSE_FLAGS_ERROR 0x00000002
-#define ATSE_FLAGS_SOP_SEEN 0x00000004
- uint8_t atse_eth_addr[ETHER_ADDR_LEN];
-#define ATSE_ETH_ADDR_DEF 0x01
-#define ATSE_ETH_ADDR_SUPP1 0x02
-#define ATSE_ETH_ADDR_SUPP2 0x04
-#define ATSE_ETH_ADDR_SUPP3 0x08
-#define ATSE_ETH_ADDR_SUPP4 0x10
-#define ATSE_ETH_ADDR_ALL 0x1f
- int16_t atse_rx_cycles; /* POLLING */
-#define RX_CYCLES_IN_INTR 5
- uint32_t atse_rx_err[6];
-#define ATSE_RX_ERR_FIFO_THRES_EOP 0 /* FIFO threshold reached, on EOP. */
-#define ATSE_RX_ERR_ELEN 1 /* Frame/payload length not valid. */
-#define ATSE_RX_ERR_CRC32 2 /* CRC-32 error. */
-#define ATSE_RX_ERR_FIFO_THRES_TRUNC 3 /* FIFO thresh., truncated frame. */
-#define ATSE_RX_ERR_4 4 /* ? */
-#define ATSE_RX_ERR_5 5 /* / */
-#define ATSE_RX_ERR_MAX 6
- struct callout atse_tick;
- struct mtx atse_mtx;
- device_t dev;
-
- /* xDMA */
- xdma_controller_t *xdma_tx;
- xdma_channel_t *xchan_tx;
- void *ih_tx;
- int txcount;
-
- xdma_controller_t *xdma_rx;
- xdma_channel_t *xchan_rx;
- void *ih_rx;
-
- struct buf_ring *br;
- struct mtx br_mtx;
-};
-
-int atse_attach(device_t);
-int atse_detach_dev(device_t);
-void atse_detach_resources(device_t);
-
-int atse_miibus_readreg(device_t, int, int);
-int atse_miibus_writereg(device_t, int, int, int);
-void atse_miibus_statchg(device_t);
-
-#endif /* _DEV_IF_ATSEREG_H */
diff --git a/sys/dev/altera/avgen/altera_avgen.c b/sys/dev/altera/avgen/altera_avgen.c
deleted file mode 100644
index 846167c649f8..000000000000
--- a/sys/dev/altera/avgen/altera_avgen.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012-2013, 2016 Robert N. M. Watson
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include
-#include
-
-#include
-
-#include
-
-/*
- * Generic device driver for allowing read(), write(), and mmap() on
- * memory-mapped, Avalon-attached devices. There is no actual dependence on
- * Avalon, so conceivably this should just be soc_dev or similar, since many
- * system-on-chip bus environments would work fine with the same code.
- */
-
-static d_mmap_t altera_avgen_mmap;
-static d_read_t altera_avgen_read;
-static d_write_t altera_avgen_write;
-
-#define ALTERA_AVGEN_DEVNAME "altera_avgen"
-#define ALTERA_AVGEN_DEVNAME_FMT (ALTERA_AVGEN_DEVNAME "%d")
-
-static struct cdevsw avg_cdevsw = {
- .d_version = D_VERSION,
- .d_mmap = altera_avgen_mmap,
- .d_read = altera_avgen_read,
- .d_write = altera_avgen_write,
- .d_name = ALTERA_AVGEN_DEVNAME,
-};
-
-#define ALTERA_AVGEN_SECTORSIZE 512 /* Not configurable at this time. */
-
-static int
-altera_avgen_read(struct cdev *dev, struct uio *uio, int flag)
-{
- struct altera_avgen_softc *sc;
- u_long offset, size;
-#ifdef NOTYET
- uint64_t v8;
-#endif
- uint32_t v4;
- uint16_t v2;
- uint8_t v1;
- u_int width;
- int error;
-
- sc = dev->si_drv1;
- if ((sc->avg_flags & ALTERA_AVALON_FLAG_READ) == 0)
- return (EACCES);
- width = sc->avg_width;
- if (uio->uio_offset < 0 || uio->uio_offset % width != 0 ||
- uio->uio_resid % width != 0)
- return (ENODEV);
- size = rman_get_size(sc->avg_res);
- if ((uio->uio_offset + uio->uio_resid < 0) ||
- (uio->uio_offset + uio->uio_resid > size))
- return (ENODEV);
- while (uio->uio_resid > 0) {
- offset = uio->uio_offset;
- if (offset + width > size)
- return (ENODEV);
- switch (width) {
- case 1:
- v1 = bus_read_1(sc->avg_res, offset);
- error = uiomove(&v1, sizeof(v1), uio);
- break;
-
- case 2:
- v2 = bus_read_2(sc->avg_res, offset);
- error = uiomove(&v2, sizeof(v2), uio);
- break;
-
- case 4:
- v4 = bus_read_4(sc->avg_res, offset);
- error = uiomove(&v4, sizeof(v4), uio);
- break;
-
-#ifdef NOTYET
- case 8:
- v8 = bus_read_8(sc->avg_res, offset);
- error = uiomove(&v8, sizeof(v8), uio);
- break;
-
-#endif
-
- default:
- panic("%s: unexpected widthment %u", __func__, width);
- }
- if (error)
- return (error);
- }
- return (0);
-}
-
-static int
-altera_avgen_write(struct cdev *dev, struct uio *uio, int flag)
-{
- struct altera_avgen_softc *sc;
- u_long offset, size;
-#ifdef NOTYET
- uint64_t v8;
-#endif
- uint32_t v4;
- uint16_t v2;
- uint8_t v1;
- u_int width;
- int error;
-
- sc = dev->si_drv1;
- if ((sc->avg_flags & ALTERA_AVALON_FLAG_WRITE) == 0)
- return (EACCES);
- width = sc->avg_width;
- if (uio->uio_offset < 0 || uio->uio_offset % width != 0 ||
- uio->uio_resid % width != 0)
- return (ENODEV);
- size = rman_get_size(sc->avg_res);
- while (uio->uio_resid > 0) {
- offset = uio->uio_offset;
- if (offset + width > size)
- return (ENODEV);
- switch (width) {
- case 1:
- error = uiomove(&v1, sizeof(v1), uio);
- if (error)
- return (error);
- bus_write_1(sc->avg_res, offset, v1);
- break;
-
- case 2:
- error = uiomove(&v2, sizeof(v2), uio);
- if (error)
- return (error);
- bus_write_2(sc->avg_res, offset, v2);
- break;
-
- case 4:
- error = uiomove(&v4, sizeof(v4), uio);
- if (error)
- return (error);
- bus_write_4(sc->avg_res, offset, v4);
- break;
-
-#ifdef NOTYET
- case 8:
- error = uiomove(&v8, sizeof(v8), uio);
- if (error)
- return (error);
- bus_write_8(sc->avg_res, offset, v8);
- break;
-#endif
-
- default:
- panic("%s: unexpected width %u", __func__, width);
- }
- }
- return (0);
-}
-
-static int
-altera_avgen_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
- int nprot, vm_memattr_t *memattr)
-{
- struct altera_avgen_softc *sc;
-
- sc = dev->si_drv1;
- if (nprot & VM_PROT_READ) {
- if ((sc->avg_flags & ALTERA_AVALON_FLAG_MMAP_READ) == 0)
- return (EACCES);
- }
- if (nprot & VM_PROT_WRITE) {
- if ((sc->avg_flags & ALTERA_AVALON_FLAG_MMAP_WRITE) == 0)
- return (EACCES);
- }
- if (nprot & VM_PROT_EXECUTE) {
- if ((sc->avg_flags & ALTERA_AVALON_FLAG_MMAP_EXEC) == 0)
- return (EACCES);
- }
- if (trunc_page(offset) == offset &&
- offset + PAGE_SIZE > offset &&
- rman_get_size(sc->avg_res) >= offset + PAGE_SIZE) {
- *paddr = rman_get_start(sc->avg_res) + offset;
- *memattr = VM_MEMATTR_UNCACHEABLE;
- } else
- return (ENODEV);
- return (0);
-}
-
-/*
- * NB: We serialise block reads and writes in case the OS is generating
- * concurrent I/O against the same block, in which case we want one I/O (or
- * another) to win. This is not sufficient to provide atomicity for the
- * sector in the presence of a fail stop -- however, we're just writing this
- * to non-persistent DRAM .. right?
- */
-static void
-altera_avgen_disk_strategy(struct bio *bp)
-{
- struct altera_avgen_softc *sc;
- void *data;
- long bcount;
- daddr_t pblkno;
- int error;
-
- sc = bp->bio_disk->d_drv1;
- data = bp->bio_data;
- bcount = bp->bio_bcount;
- pblkno = bp->bio_pblkno;
- error = 0;
-
- /*
- * Serialize block reads / writes.
- */
- mtx_lock(&sc->avg_disk_mtx);
- switch (bp->bio_cmd) {
- case BIO_READ:
- if (!(sc->avg_flags & ALTERA_AVALON_FLAG_GEOM_READ)) {
- error = EROFS;
- break;
- }
- switch (sc->avg_width) {
- case 1:
- bus_read_region_1(sc->avg_res,
- bp->bio_pblkno * ALTERA_AVGEN_SECTORSIZE,
- (uint8_t *)data, bcount);
- break;
-
- case 2:
- bus_read_region_2(sc->avg_res,
- bp->bio_pblkno * ALTERA_AVGEN_SECTORSIZE,
- (uint16_t *)data, bcount / 2);
- break;
-
- case 4:
- bus_read_region_4(sc->avg_res,
- bp->bio_pblkno * ALTERA_AVGEN_SECTORSIZE,
- (uint32_t *)data, bcount / 4);
- break;
-
- default:
- panic("%s: unexpected width %u", __func__,
- sc->avg_width);
- }
- break;
-
- case BIO_WRITE:
- if (!(sc->avg_flags & ALTERA_AVALON_FLAG_GEOM_WRITE)) {
- biofinish(bp, NULL, EROFS);
- break;
- }
- switch (sc->avg_width) {
- case 1:
- bus_write_region_1(sc->avg_res,
- bp->bio_pblkno * ALTERA_AVGEN_SECTORSIZE,
- (uint8_t *)data, bcount);
- break;
-
- case 2:
- bus_write_region_2(sc->avg_res,
- bp->bio_pblkno * ALTERA_AVGEN_SECTORSIZE,
- (uint16_t *)data, bcount / 2);
- break;
-
- case 4:
- bus_write_region_4(sc->avg_res,
- bp->bio_pblkno * ALTERA_AVGEN_SECTORSIZE,
- (uint32_t *)data, bcount / 4);
- break;
-
- default:
- panic("%s: unexpected width %u", __func__,
- sc->avg_width);
- }
- break;
-
- default:
- error = EOPNOTSUPP;
- break;
- }
- mtx_unlock(&sc->avg_disk_mtx);
- biofinish(bp, NULL, error);
-}
-
-static int
-altera_avgen_process_options(struct altera_avgen_softc *sc,
- const char *str_fileio, const char *str_geomio, const char *str_mmapio,
- const char *str_devname, int devunit)
-{
- const char *cp;
- device_t dev = sc->avg_dev;
-
- /*
- * Check for valid combinations of options.
- */
- if (str_fileio == NULL && str_geomio == NULL && str_mmapio == NULL) {
- device_printf(dev,
- "at least one of %s, %s, or %s must be specified\n",
- ALTERA_AVALON_STR_FILEIO, ALTERA_AVALON_STR_GEOMIO,
- ALTERA_AVALON_STR_MMAPIO);
- return (ENXIO);
- }
-
- /*
- * Validity check: a device can either be a GEOM device (in which case
- * we use GEOM to register the device node), or a special device --
- * but not both as that causes a collision in /dev.
- */
- if (str_geomio != NULL && (str_fileio != NULL || str_mmapio != NULL)) {
- device_printf(dev,
- "at most one of %s and (%s or %s) may be specified\n",
- ALTERA_AVALON_STR_GEOMIO, ALTERA_AVALON_STR_FILEIO,
- ALTERA_AVALON_STR_MMAPIO);
- return (ENXIO);
- }
-
- /*
- * Ensure that a unit is specified if a name is also specified.
- */
- if (str_devname == NULL && devunit != -1) {
- device_printf(dev, "%s requires %s be specified\n",
- ALTERA_AVALON_STR_DEVUNIT, ALTERA_AVALON_STR_DEVNAME);
- return (ENXIO);
- }
-
- /*
- * Extract, digest, and save values.
- */
- switch (sc->avg_width) {
- case 1:
- case 2:
- case 4:
-#ifdef NOTYET
- case 8:
-#endif
- break;
-
- default:
- device_printf(dev, "%s unsupported value %u\n",
- ALTERA_AVALON_STR_WIDTH, sc->avg_width);
- return (ENXIO);
- }
- sc->avg_flags = 0;
- if (str_fileio != NULL) {
- for (cp = str_fileio; *cp != '\0'; cp++) {
- switch (*cp) {
- case ALTERA_AVALON_CHAR_READ:
- sc->avg_flags |= ALTERA_AVALON_FLAG_READ;
- break;
-
- case ALTERA_AVALON_CHAR_WRITE:
- sc->avg_flags |= ALTERA_AVALON_FLAG_WRITE;
- break;
-
- default:
- device_printf(dev,
- "invalid %s character %c\n",
- ALTERA_AVALON_STR_FILEIO, *cp);
- return (ENXIO);
- }
- }
- }
- if (str_geomio != NULL) {
- for (cp = str_geomio; *cp != '\0'; cp++){
- switch (*cp) {
- case ALTERA_AVALON_CHAR_READ:
- sc->avg_flags |= ALTERA_AVALON_FLAG_GEOM_READ;
- break;
-
- case ALTERA_AVALON_CHAR_WRITE:
- sc->avg_flags |= ALTERA_AVALON_FLAG_GEOM_WRITE;
- break;
-
- default:
- device_printf(dev,
- "invalid %s character %c\n",
- ALTERA_AVALON_STR_GEOMIO, *cp);
- return (ENXIO);
- }
- }
- }
- if (str_mmapio != NULL) {
- for (cp = str_mmapio; *cp != '\0'; cp++) {
- switch (*cp) {
- case ALTERA_AVALON_CHAR_READ:
- sc->avg_flags |= ALTERA_AVALON_FLAG_MMAP_READ;
- break;
-
- case ALTERA_AVALON_CHAR_WRITE:
- sc->avg_flags |=
- ALTERA_AVALON_FLAG_MMAP_WRITE;
- break;
-
- case ALTERA_AVALON_CHAR_EXEC:
- sc->avg_flags |= ALTERA_AVALON_FLAG_MMAP_EXEC;
- break;
-
- default:
- device_printf(dev,
- "invalid %s character %c\n",
- ALTERA_AVALON_STR_MMAPIO, *cp);
- return (ENXIO);
- }
- }
- }
- return (0);
-}
-
-int
-altera_avgen_attach(struct altera_avgen_softc *sc, const char *str_fileio,
- const char *str_geomio, const char *str_mmapio, const char *str_devname,
- int devunit)
-{
- device_t dev = sc->avg_dev;
- int error;
-
- error = altera_avgen_process_options(sc, str_fileio, str_geomio,
- str_mmapio, str_devname, devunit);
- if (error)
- return (error);
-
- if (rman_get_size(sc->avg_res) >= PAGE_SIZE || str_mmapio != NULL) {
- if (rman_get_size(sc->avg_res) % PAGE_SIZE != 0) {
- device_printf(dev,
- "memory region not even multiple of page size\n");
- return (ENXIO);
- }
- if (rman_get_start(sc->avg_res) % PAGE_SIZE != 0) {
- device_printf(dev, "memory region not page-aligned\n");
- return (ENXIO);
- }
- }
-
- /*
- * If a GEOM permission is requested, then create the device via GEOM.
- * Otherwise, create a special device. We checked during options
- * processing that both weren't requested a once.
- */
- if (str_devname != NULL) {
- sc->avg_name = strdup(str_devname, M_TEMP);
- devunit = sc->avg_unit;
- } else
- sc->avg_name = strdup(ALTERA_AVGEN_DEVNAME, M_TEMP);
- if (sc->avg_flags & (ALTERA_AVALON_FLAG_GEOM_READ |
- ALTERA_AVALON_FLAG_GEOM_WRITE)) {
- mtx_init(&sc->avg_disk_mtx, "altera_avgen_disk", NULL,
- MTX_DEF);
- sc->avg_disk = disk_alloc();
- sc->avg_disk->d_drv1 = sc;
- sc->avg_disk->d_strategy = altera_avgen_disk_strategy;
- if (devunit == -1)
- devunit = 0;
- sc->avg_disk->d_name = sc->avg_name;
- sc->avg_disk->d_unit = devunit;
-
- /*
- * NB: As avg_res is a multiple of PAGE_SIZE, it is also a
- * multiple of ALTERA_AVGEN_SECTORSIZE.
- */
- sc->avg_disk->d_sectorsize = ALTERA_AVGEN_SECTORSIZE;
- sc->avg_disk->d_mediasize = rman_get_size(sc->avg_res);
- sc->avg_disk->d_maxsize = ALTERA_AVGEN_SECTORSIZE;
- disk_create(sc->avg_disk, DISK_VERSION);
- } else {
- /* Device node allocation. */
- if (str_devname == NULL) {
- str_devname = ALTERA_AVGEN_DEVNAME_FMT;
- devunit = sc->avg_unit;
- }
- if (devunit != -1)
- sc->avg_cdev = make_dev(&avg_cdevsw, sc->avg_unit,
- UID_ROOT, GID_WHEEL, S_IRUSR | S_IWUSR, "%s%d",
- str_devname, devunit);
- else
- sc->avg_cdev = make_dev(&avg_cdevsw, sc->avg_unit,
- UID_ROOT, GID_WHEEL, S_IRUSR | S_IWUSR,
- "%s", str_devname);
- if (sc->avg_cdev == NULL) {
- device_printf(sc->avg_dev, "%s: make_dev failed\n",
- __func__);
- return (ENXIO);
- }
-
- /* XXXRW: Slight race between make_dev(9) and here. */
- sc->avg_cdev->si_drv1 = sc;
- }
- return (0);
-}
-
-void
-altera_avgen_detach(struct altera_avgen_softc *sc)
-{
-
- KASSERT((sc->avg_disk != NULL) || (sc->avg_cdev != NULL),
- ("%s: neither GEOM nor special device", __func__));
-
- if (sc->avg_disk != NULL) {
- disk_gone(sc->avg_disk);
- disk_destroy(sc->avg_disk);
- free(sc->avg_name, M_TEMP);
- mtx_destroy(&sc->avg_disk_mtx);
- } else {
- destroy_dev(sc->avg_cdev);
- }
-}
diff --git a/sys/dev/altera/avgen/altera_avgen.h b/sys/dev/altera/avgen/altera_avgen.h
deleted file mode 100644
index ffa813b8ec65..000000000000
--- a/sys/dev/altera/avgen/altera_avgen.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012, 2016 Robert N. M. Watson
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#ifndef _DEV_ALTERA_AVALON_H_
-#define _DEV_ALTERA_AVALON_H_
-
-struct altera_avgen_softc {
- /*
- * Bus-related fields.
- */
- device_t avg_dev;
- int avg_unit;
- char *avg_name;
-
- /*
- * The device node and memory-mapped I/O region.
- */
- struct cdev *avg_cdev;
- struct resource *avg_res;
- int avg_rid;
-
- /*
- * Access properties configured by device.hints.
- */
- u_int avg_flags;
- u_int avg_width;
- u_int avg_sectorsize;
-
- /*
- * disk(9) state, if required for this device.
- */
- struct disk *avg_disk;
- struct mtx avg_disk_mtx;
-};
-
-/*
- * Various flags extracted from device.hints to configure operations on the
- * device.
- */
-#define ALTERA_AVALON_FLAG_READ 0x01
-#define ALTERA_AVALON_FLAG_WRITE 0x02
-#define ALTERA_AVALON_FLAG_MMAP_READ 0x04
-#define ALTERA_AVALON_FLAG_MMAP_WRITE 0x08
-#define ALTERA_AVALON_FLAG_MMAP_EXEC 0x10
-#define ALTERA_AVALON_FLAG_GEOM_READ 0x20
-#define ALTERA_AVALON_FLAG_GEOM_WRITE 0x40
-
-#define ALTERA_AVALON_CHAR_READ 'r'
-#define ALTERA_AVALON_CHAR_WRITE 'w'
-#define ALTERA_AVALON_CHAR_EXEC 'x'
-
-#define ALTERA_AVALON_STR_WIDTH "width"
-#define ALTERA_AVALON_STR_FILEIO "fileio"
-#define ALTERA_AVALON_STR_GEOMIO "geomio"
-#define ALTERA_AVALON_STR_MMAPIO "mmapio"
-#define ALTERA_AVALON_STR_DEVNAME "devname"
-#define ALTERA_AVALON_STR_DEVUNIT "devunit"
-
-/*
- * Driver setup routines from the bus attachment/teardown.
- */
-int altera_avgen_attach(struct altera_avgen_softc *sc,
- const char *str_fileio, const char *str_geomio,
- const char *str_mmapio, const char *str_devname, int devunit);
-void altera_avgen_detach(struct altera_avgen_softc *sc);
-
-#endif /* _DEV_ALTERA_AVALON_H_ */
diff --git a/sys/dev/altera/avgen/altera_avgen_fdt.c b/sys/dev/altera/avgen/altera_avgen_fdt.c
deleted file mode 100644
index ad12fc9df265..000000000000
--- a/sys/dev/altera/avgen/altera_avgen_fdt.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012-2013, 2016 Robert N. M. Watson
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-
-static int
-altera_avgen_fdt_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (ofw_bus_is_compatible(dev, "sri-cambridge,avgen")) {
- device_set_desc(dev, "Generic Altera Avalon device attachment");
- return (BUS_PROBE_DEFAULT);
- }
- return (ENXIO);
-}
-
-static int
-altera_avgen_fdt_attach(device_t dev)
-{
- struct altera_avgen_softc *sc;
- char *str_fileio, *str_geomio, *str_mmapio;
- char *str_devname;
- phandle_t node;
- pcell_t cell;
- int devunit, error;
-
- sc = device_get_softc(dev);
- sc->avg_dev = dev;
- sc->avg_unit = device_get_unit(dev);
-
- /*
- * Query driver-specific OpenFirmware properties to determine how to
- * expose the device via /dev.
- */
- str_fileio = NULL;
- str_geomio = NULL;
- str_mmapio = NULL;
- str_devname = NULL;
- devunit = -1;
- sc->avg_width = 1;
- node = ofw_bus_get_node(dev);
- if (OF_getprop(node, "sri-cambridge,width", &cell, sizeof(cell)) > 0)
- sc->avg_width = cell;
- (void)OF_getprop_alloc(node, "sri-cambridge,fileio",
- (void **)&str_fileio);
- (void)OF_getprop_alloc(node, "sri-cambridge,geomio",
- (void **)&str_geomio);
- (void)OF_getprop_alloc(node, "sri-cambridge,mmapio",
- (void **)&str_mmapio);
- (void)OF_getprop_alloc(node, "sri-cambridge,devname",
- (void **)&str_devname);
- if (OF_getprop(node, "sri-cambridge,devunit", &cell, sizeof(cell)) > 0)
- devunit = cell;
-
- /* Memory allocation and checking. */
- sc->avg_rid = 0;
- sc->avg_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
- &sc->avg_rid, RF_ACTIVE);
- if (sc->avg_res == NULL) {
- device_printf(dev, "couldn't map memory\n");
- return (ENXIO);
- }
- error = altera_avgen_attach(sc, str_fileio, str_geomio, str_mmapio,
- str_devname, devunit);
- if (error != 0)
- bus_release_resource(dev, SYS_RES_MEMORY, sc->avg_rid,
- sc->avg_res);
- if (str_fileio != NULL)
- OF_prop_free(str_fileio);
- if (str_geomio != NULL)
- OF_prop_free(str_geomio);
- if (str_mmapio != NULL)
- OF_prop_free(str_mmapio);
- if (str_devname != NULL)
- OF_prop_free(str_devname);
- return (error);
-}
-
-static int
-altera_avgen_fdt_detach(device_t dev)
-{
- struct altera_avgen_softc *sc;
-
- sc = device_get_softc(dev);
- altera_avgen_detach(sc);
- bus_release_resource(dev, SYS_RES_MEMORY, sc->avg_rid, sc->avg_res);
- return (0);
-}
-
-static device_method_t altera_avgen_fdt_methods[] = {
- DEVMETHOD(device_probe, altera_avgen_fdt_probe),
- DEVMETHOD(device_attach, altera_avgen_fdt_attach),
- DEVMETHOD(device_detach, altera_avgen_fdt_detach),
- { 0, 0 }
-};
-
-static driver_t altera_avgen_fdt_driver = {
- "altera_avgen",
- altera_avgen_fdt_methods,
- sizeof(struct altera_avgen_softc),
-};
-
-DRIVER_MODULE(avgen, simplebus, altera_avgen_fdt_driver, 0, 0);
diff --git a/sys/dev/altera/avgen/altera_avgen_nexus.c b/sys/dev/altera/avgen/altera_avgen_nexus.c
deleted file mode 100644
index 67448bc83f9c..000000000000
--- a/sys/dev/altera/avgen/altera_avgen_nexus.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2012-2013, 2016 Robert N. M. Watson
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-
-#include
-
-static int
-altera_avgen_nexus_probe(device_t dev)
-{
-
- device_set_desc(dev, "Generic Altera Avalon device attachment");
- return (BUS_PROBE_NOWILDCARD);
-}
-
-static int
-altera_avgen_nexus_attach(device_t dev)
-{
- struct altera_avgen_softc *sc;
- const char *str_fileio, *str_geomio, *str_mmapio;
- const char *str_devname;
- int devunit, error;
-
- sc = device_get_softc(dev);
- sc->avg_dev = dev;
- sc->avg_unit = device_get_unit(dev);
-
- /*
- * Query non-standard hints to find out what operations are permitted
- * on the device, and whether it is cached.
- */
- str_fileio = NULL;
- str_geomio = NULL;
- str_mmapio = NULL;
- str_devname = NULL;
- devunit = -1;
- sc->avg_width = 1;
- error = resource_int_value(device_get_name(dev), device_get_unit(dev),
- ALTERA_AVALON_STR_WIDTH, &sc->avg_width);
- if (error != 0 && error != ENOENT) {
- device_printf(dev, "invalid %s\n", ALTERA_AVALON_STR_WIDTH);
- return (error);
- }
- (void)resource_string_value(device_get_name(dev),
- device_get_unit(dev), ALTERA_AVALON_STR_FILEIO, &str_fileio);
- (void)resource_string_value(device_get_name(dev),
- device_get_unit(dev), ALTERA_AVALON_STR_GEOMIO, &str_geomio);
- (void)resource_string_value(device_get_name(dev),
- device_get_unit(dev), ALTERA_AVALON_STR_MMAPIO, &str_mmapio);
- (void)resource_string_value(device_get_name(dev),
- device_get_unit(dev), ALTERA_AVALON_STR_DEVNAME, &str_devname);
- (void)resource_int_value(device_get_name(dev), device_get_unit(dev),
- ALTERA_AVALON_STR_DEVUNIT, &devunit);
-
- /* Memory allocation and checking. */
- sc->avg_rid = 0;
- sc->avg_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
- &sc->avg_rid, RF_ACTIVE);
- if (sc->avg_res == NULL) {
- device_printf(dev, "couldn't map memory\n");
- return (ENXIO);
- }
- error = altera_avgen_attach(sc, str_fileio, str_geomio, str_mmapio,
- str_devname, devunit);
- if (error != 0)
- bus_release_resource(dev, SYS_RES_MEMORY, sc->avg_rid,
- sc->avg_res);
- return (error);
-}
-
-static int
-altera_avgen_nexus_detach(device_t dev)
-{
- struct altera_avgen_softc *sc;
-
- sc = device_get_softc(dev);
- altera_avgen_detach(sc);
- bus_release_resource(dev, SYS_RES_MEMORY, sc->avg_rid, sc->avg_res);
- return (0);
-}
-
-static device_method_t altera_avgen_nexus_methods[] = {
- DEVMETHOD(device_probe, altera_avgen_nexus_probe),
- DEVMETHOD(device_attach, altera_avgen_nexus_attach),
- DEVMETHOD(device_detach, altera_avgen_nexus_detach),
- { 0, 0 }
-};
-
-static driver_t altera_avgen_nexus_driver = {
- "altera_avgen",
- altera_avgen_nexus_methods,
- sizeof(struct altera_avgen_softc),
-};
-
-DRIVER_MODULE(avgen, nexus, altera_avgen_nexus_driver, 0, 0);
diff --git a/sys/dev/altera/jtag_uart/altera_jtag_uart.h b/sys/dev/altera/jtag_uart/altera_jtag_uart.h
deleted file mode 100644
index 9bbc8624cd98..000000000000
--- a/sys/dev/altera/jtag_uart/altera_jtag_uart.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2011-2012 Robert N. M. Watson
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#ifndef _DEV_ALTERA_JTAG_UART_H_
-#define _DEV_ALTERA_JTAG_UART_H_
-
-struct altera_jtag_uart_softc {
- device_t ajus_dev;
- int ajus_unit;
-
- /*
- * Hardware resources.
- */
- struct resource *ajus_irq_res;
- int ajus_irq_rid;
- void *ajus_irq_cookie;
- struct resource *ajus_mem_res;
- int ajus_mem_rid;
-
- /*
- * TTY resources.
- */
- struct tty *ajus_ttyp;
- int ajus_alt_break_state;
-
- /*
- * Driver resources.
- */
- u_int ajus_flags;
- struct mtx *ajus_lockp;
- struct mtx ajus_lock;
- struct callout ajus_io_callout;
- struct callout ajus_ac_callout;
-
- /*
- * One-character buffer required because it's not possible to peek at
- * the input FIFO without reading it.
- */
- int ajus_buffer_valid;
- int *ajus_buffer_validp;
- uint8_t ajus_buffer_data;
- uint8_t *ajus_buffer_datap;
- int ajus_jtag_present;
- int *ajus_jtag_presentp;
- u_int ajus_jtag_missed;
- u_int *ajus_jtag_missedp;
-};
-
-#define AJU_TTYNAME "ttyj"
-
-/*
- * Flag values for ajus_flags.
- */
-#define ALTERA_JTAG_UART_FLAG_CONSOLE 0x00000001 /* Is console. */
-
-/*
- * Because tty-level use of the I/O ports completes with low-level console
- * use, spinlocks must be employed here.
- */
-#define AJU_CONSOLE_LOCK_INIT() do { \
- mtx_init(&aju_cons_lock, "aju_cons_lock", NULL, MTX_SPIN); \
-} while (0)
-
-#define AJU_CONSOLE_LOCK() do { \
- if (!kdb_active) \
- mtx_lock_spin(&aju_cons_lock); \
-} while (0)
-
-#define AJU_CONSOLE_LOCK_ASSERT() { \
- if (!kdb_active) \
- mtx_assert(&aju_cons_lock, MA_OWNED); \
-} while (0)
-
-#define AJU_CONSOLE_UNLOCK() do { \
- if (!kdb_active) \
- mtx_unlock_spin(&aju_cons_lock); \
-} while (0)
-
-#define AJU_LOCK_INIT(sc) do { \
- mtx_init(&(sc)->ajus_lock, "aju_lock", NULL, MTX_SPIN); \
-} while (0)
-
-#define AJU_LOCK_DESTROY(sc) do { \
- mtx_destroy(&(sc)->ajus_lock); \
-} while (0)
-
-#define AJU_LOCK(sc) do { \
- mtx_lock_spin((sc)->ajus_lockp); \
-} while (0)
-
-#define AJU_LOCK_ASSERT(sc) do { \
- mtx_assert((sc)->ajus_lockp, MA_OWNED); \
-} while (0)
-
-#define AJU_UNLOCK(sc) do { \
- mtx_unlock_spin((sc)->ajus_lockp); \
-} while (0)
-
-/*
- * When a TTY-level Altera JTAG UART instance is also the low-level console,
- * the TTY layer borrows the console-layer lock and buffer rather than using
- * its own.
- */
-extern struct mtx aju_cons_lock;
-extern char aju_cons_buffer_data;
-extern int aju_cons_buffer_valid;
-extern int aju_cons_jtag_present;
-extern u_int aju_cons_jtag_missed;
-
-/*
- * Base physical address of the JTAG UART in BERI.
- */
-#define BERI_UART_BASE 0xff7f000000 /* JTAG UART */
-
-/*-
- * Routines for interacting with the BERI console JTAG UART. Programming
- * details from the June 2011 "Embedded Peripherals User Guide" by Altera
- * Corporation, tables 6-2 (JTAG UART Core Register Map), 6-3 (Data Register
- * Bits), and 6-4 (Control Register Bits).
- *
- * Offsets of data and control registers relative to the base. Altera
- * conventions are maintained in BERI.
- */
-#define ALTERA_JTAG_UART_DATA_OFF 0x00000000
-#define ALTERA_JTAG_UART_CONTROL_OFF 0x00000004
-
-/*
- * Offset 0: 'data' register -- bits 31-16 (RAVAIL), 15 (RVALID),
- * 14-8 (Reserved), 7-0 (DATA).
- *
- * DATA - One byte read or written.
- * RAVAIL - Bytes available to read (excluding the current byte).
- * RVALID - Whether the byte in DATA is valid.
- */
-#define ALTERA_JTAG_UART_DATA_DATA 0x000000ff
-#define ALTERA_JTAG_UART_DATA_RESERVED 0x00007f00
-#define ALTERA_JTAG_UART_DATA_RVALID 0x00008000
-#define ALTERA_JTAG_UART_DATA_RAVAIL 0xffff0000
-#define ALTERA_JTAG_UART_DATA_RAVAIL_SHIFT 16
-
-/*-
- * Offset 1: 'control' register -- bits 31-16 (WSPACE), 15-11 (Reserved),
- * 10 (AC), 9 (WI), 8 (RI), 7..2 (Reserved), 1 (WE), 0 (RE).
- *
- * RE - Enable read interrupts.
- * WE - Enable write interrupts.
- * RI - Read interrupt pending.
- * WI - Write interrupt pending.
- * AC - Activity bit; set to '1' to clear to '0'.
- * WSPACE - Space available in the write FIFO.
- */
-#define ALTERA_JTAG_UART_CONTROL_RE 0x00000001
-#define ALTERA_JTAG_UART_CONTROL_WE 0x00000002
-#define ALTERA_JTAG_UART_CONTROL_RESERVED0 0x000000fc
-#define ALTERA_JTAG_UART_CONTROL_RI 0x00000100
-#define ALTERA_JTAG_UART_CONTROL_WI 0x00000200
-#define ALTERA_JTAG_UART_CONTROL_AC 0x00000400
-#define ALTERA_JTAG_UART_CONTROL_RESERVED1 0x0000f800
-#define ALTERA_JTAG_UART_CONTROL_WSPACE 0xffff0000
-#define ALTERA_JTAG_UART_CONTROL_WSPACE_SHIFT 16
-
-/*
- * Driver attachment functions for Nexus.
- */
-int altera_jtag_uart_attach(struct altera_jtag_uart_softc *sc);
-void altera_jtag_uart_detach(struct altera_jtag_uart_softc *sc);
-
-#endif /* _DEV_ALTERA_JTAG_UART_H_ */
diff --git a/sys/dev/altera/jtag_uart/altera_jtag_uart_cons.c b/sys/dev/altera/jtag_uart/altera_jtag_uart_cons.c
deleted file mode 100644
index 215a951aabfb..000000000000
--- a/sys/dev/altera/jtag_uart/altera_jtag_uart_cons.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2011-2012 Robert N. M. Watson
- * All rights reserved.
- *
- * This software was developed by SRI International and the University of
- * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
- * ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * 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.
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include