lib/libfetch/common.c
@@ -1054,9 +1054,7 @@ fetch_ssl_setup_transport_layer(SSL_CTX *ctx, int verbose)
{ {
long ssl_ctx_options; long ssl_ctx_options;
- ssl_ctx_options = SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_TICKET;+ ssl_ctx_options = SSL_OP_ALL | SSL_OP_NO_SSLv3 | SSL_OP_NO_TICKET;
- if (getenv("SSL_ALLOW_SSL3") == NULL)
- ssl_ctx_options |= SSL_OP_NO_SSLv3;
if (getenv("SSL_NO_TLS1") != NULL) if (getenv("SSL_NO_TLS1") != NULL)
ssl_ctx_options |= SSL_OP_NO_TLSv1; ssl_ctx_options |= SSL_OP_NO_TLSv1;
if (getenv("SSL_NO_TLS1_1") != NULL) if (getenv("SSL_NO_TLS1_1") != NULL)
lib/libfetch/fetch.3
@@ -26,7 +26,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
-.Dd August 28, 2019+.Dd November 24, 2020
.Dt FETCH 3 .Dt FETCH 3
.Os .Os
.Sh NAME .Sh NAME
@@ -465,12 +465,10 @@ By default
allows TLSv1 and newer when negotiating the connecting with the remote allows TLSv1 and newer when negotiating the connecting with the remote
peer. peer.
You can change this behavior by setting the You can change this behavior by setting the
-.Ev SSL_ALLOW_SSL3
-environment variable to allow SSLv3 and
.Ev SSL_NO_TLS1 , .Ev SSL_NO_TLS1 ,
.Ev SSL_NO_TLS1_1 and .Ev SSL_NO_TLS1_1 and
.Ev SSL_NO_TLS1_2 .Ev SSL_NO_TLS1_2
-to disable TLS 1.0, 1.1 and 1.2 respectively.+environment variables to disable TLS 1.0, 1.1 and 1.2 respectively.
.Sh AUTHENTICATION .Sh AUTHENTICATION
Apart from setting the appropriate environment variables and Apart from setting the appropriate environment variables and
specifying the user name and password in the URL or the specifying the user name and password in the URL or the
@@ -675,8 +673,6 @@ IPv6 addresses must enclose the address in brackets.
If no port is specified, the default is 1080. If no port is specified, the default is 1080.
This setting will supercede a connection to an This setting will supercede a connection to an
.Ev HTTP_PROXY . .Ev HTTP_PROXY .
-.It Ev SSL_ALLOW_SSL3
-Allow SSL version 3 when negotiating the connection (not recommended).
.It Ev SSL_CA_CERT_FILE .It Ev SSL_CA_CERT_FILE
CA certificate bundle containing trusted CA certificates. CA certificate bundle containing trusted CA certificates.
Default value: See HTTPS SCHEME above. Default value: See HTTPS SCHEME above.
release/arm/BANANAPI.conf→/dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-EMBEDDED_TARGET_ARCH="armv7"
-EMBEDDED_TARGET="arm"
-EMBEDDEDBUILD=1
-EMBEDDEDPORTS="sysutils/u-boot-bananapi"
-FAT_SIZE="50m -b 1m"
-FAT_TYPE="16"
-IMAGE_SIZE="3072M"
-KERNEL="GENERIC"
-MD_ARGS="-x 63 -y 255"
-NODOC=1
-PART_SCHEME="MBR"
-export BOARDNAME="BANANAPI"
-
-arm_install_uboot() {
- UBOOT_DIR="/usr/local/share/u-boot/u-boot-bananapi"
- UBOOT_FILES="u-boot-sunxi-with-spl.bin"
- chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
- of=/dev/${mddev} bs=1k seek=8 conv=sync
-
- return 0
-}
release/arm/BEAGLEBONE.conf→/dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-EMBEDDED_TARGET_ARCH="armv7"
-EMBEDDED_TARGET="arm"
-EMBEDDEDBUILD=1
-EMBEDDEDPORTS="sysutils/u-boot-beaglebone"
-FAT_SIZE="50m"
-FAT_TYPE="16"
-IMAGE_SIZE="3072M"
-KERNEL="GENERIC"
-MD_ARGS="-x 63 -y 255"
-NODOC=1
-PART_SCHEME="MBR"
-export BOARDNAME="BEAGLEBONE"
-
-arm_install_uboot() {
- UBOOT_DIR="/usr/local/share/u-boot/u-boot-beaglebone"
- FATMOUNT="${DESTDIR%${KERNEL}}/fat"
- chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}"
- chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
- chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/MLO ${FATMOUNT}/MLO
- chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/u-boot.img ${FATMOUNT}/u-boot.img
- sync
- umount_loop ${CHROOTDIR}/${FATMOUNT}
- chroot ${CHROOTDIR} rmdir ${FATMOUNT}
-
- return 0
-}
release/arm/CUBIEBOARD.conf→/dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-EMBEDDED_TARGET_ARCH="armv7"
-EMBEDDED_TARGET="arm"
-EMBEDDEDBUILD=1
-EMBEDDEDPORTS="sysutils/u-boot-cubieboard"
-FAT_SIZE="50m -b 1m"
-FAT_TYPE="16"
-IMAGE_SIZE="3072M"
-KERNEL="GENERIC"
-MD_ARGS="-x 63 -y 255"
-NODOC=1
-PART_SCHEME="MBR"
-export BOARDNAME="CUBIEBOARD"
-
-arm_install_uboot() {
- UBOOT_DIR="/usr/local/share/u-boot/u-boot-cubieboard"
- UBOOT_FILES="u-boot-sunxi-with-spl.bin"
- chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
- of=/dev/${mddev} bs=1k seek=8 conv=sync
-
- return 0
-}
release/arm/CUBIEBOARD2.conf→/dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-EMBEDDED_TARGET_ARCH="armv7"
-EMBEDDED_TARGET="arm"
-EMBEDDEDBUILD=1
-EMBEDDEDPORTS="sysutils/u-boot-cubieboard2"
-FAT_SIZE="50m -b 1m"
-FAT_TYPE="16"
-IMAGE_SIZE="3072M"
-KERNEL="GENERIC"
-MD_ARGS="-x 63 -y 255"
-NODOC=1
-PART_SCHEME="MBR"
-export BOARDNAME="CUBIEBOARD2"
-
-arm_install_uboot() {
- UBOOT_DIR="/usr/local/share/u-boot/u-boot-cubieboard2"
- UBOOT_FILES="u-boot-sunxi-with-spl.bin"
- chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
- of=/dev/${mddev} bs=1k seek=8 conv=sync
-
- return 0
-}
release/arm/CUBOX-HUMMINGBOARD.conf→/dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-EMBEDDED_TARGET_ARCH="armv7"
-EMBEDDED_TARGET="arm"
-EMBEDDEDBUILD=1
-EMBEDDEDPORTS="sysutils/u-boot-cubox-hummingboard"
-FAT_SIZE="50m -b 16384"
-FAT_TYPE="16"
-IMAGE_SIZE="3072M"
-KERNEL="GENERIC"
-MD_ARGS="-x 63 -y 255"
-NODOC=1
-PART_SCHEME="MBR"
-export BOARDNAME="CUBOX-HUMMINGBOARD"
-
-arm_install_uboot() {
- UBOOT_DIR="/usr/local/share/u-boot/u-boot-cubox-hummingboard"
- UBOOT_FILES="u-boot.imx"
- chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
- of=/dev/${mddev} bs=512 seek=2 conv=sync
-
- return 0
-}
release/arm/GENERICSD.conf
@@ -6,11 +6,64 @@
EMBEDDED_TARGET_ARCH="armv7" EMBEDDED_TARGET_ARCH="armv7"
EMBEDDED_TARGET="arm" EMBEDDED_TARGET="arm"
EMBEDDEDBUILD=1 EMBEDDEDBUILD=1
+EMBEDDEDPORTS="sysutils/u-boot-beaglebone sysutils/u-boot-rpi2 sysutils/rpi-firmware"
FAT_SIZE="50m -b 1m" FAT_SIZE="50m -b 1m"
FAT_TYPE="16" FAT_TYPE="16"
IMAGE_SIZE="3072M" IMAGE_SIZE="3072M"
KERNEL="GENERIC" KERNEL="GENERIC"
MD_ARGS="-x 63 -y 255" MD_ARGS="-x 63 -y 255"
NODOC=1 NODOC=1
+BBB_UBOOT_DIR="/usr/local/share/u-boot/u-boot-beaglebone"
+RPI_UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi2"
+RPI_FIRMWARE_DIR="/usr/local/share/rpi-firmware"
+RPI_OL_DIR="${RPI_FIRMWARE_DIR}/overlays"
+OVERLAYS="mmc.dtbo"
PART_SCHEME="MBR" PART_SCHEME="MBR"
export BOARDNAME="GENERICSD" export BOARDNAME="GENERICSD"
+
+arm_install_uboot_rpi2() {
+ UBOOT_FILES="u-boot.bin"
+ RPI_FIRMWARE_FILES="bootcode.bin config.txt \
+ fixup.dat fixup_cd.dat fixup_db.dat fixup_x.dat \
+ start.elf start_cd.elf start_db.elf start_x.elf \
+ bcm2709-rpi-2-b.dtb"
+ FATMOUNT="${DESTDIR%${KERNEL}}/fat"
+ chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}"
+ chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
+ for _UF in ${UBOOT_FILES}; do
+ chroot ${CHROOTDIR} cp -p ${RPI_UBOOT_DIR}/${_UF} \
+ ${FATMOUNT}/${_UF}
+ done
+ for _UF in ${RPI_FIRMWARE_FILES}; do
+ chroot ${CHROOTDIR} cp -p ${RPI_FIRMWARE_DIR}/${_UF} \
+ ${FATMOUNT}/${_UF}
+ done
+ chroot ${CHROOTDIR} mkdir -p ${FATMOUNT}/overlays
+ for _OL in ${OVERLAYS}; do
+ chroot ${CHROOTDIR} cp -p ${RPI_OL_DIR}/${_OL} \
+ ${FATMOUNT}/overlays/${_OL}
+ done
+ sync
+ umount_loop ${CHROOTDIR}/${FATMOUNT}
+ chroot ${CHROOTDIR} rmdir ${FATMOUNT}
+
+ return 0
+}
+
+arm_install_uboot_bbb() {
+ FATMOUNT="${DESTDIR%${KERNEL}}/fat"
+ chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}"
+ chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
+ chroot ${CHROOTDIR} cp -p ${BBB_UBOOT_DIR}/MLO ${FATMOUNT}/MLO
+ chroot ${CHROOTDIR} cp -p ${BBB_UBOOT_DIR}/u-boot.img ${FATMOUNT}/u-boot.img
+ sync
+ umount_loop ${CHROOTDIR}/${FATMOUNT}
+ chroot ${CHROOTDIR} rmdir ${FATMOUNT}
+
+ return 0
+}
+
+arm_install_uboot() {
+ arm_install_uboot_bbb
+ arm_install_uboot_rpi2
+}
release/arm/PANDABOARD.conf→/dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-EMBEDDED_TARGET_ARCH="armv7"
-EMBEDDED_TARGET="arm"
-EMBEDDEDBUILD=1
-EMBEDDEDPORTS="sysutils/u-boot-pandaboard"
-FAT_SIZE="50m"
-FAT_TYPE="16"
-IMAGE_SIZE="3072M"
-KERNEL="GENERIC"
-MD_ARGS="-x 63 -y 255"
-NODOC=1
-PART_SCHEME="MBR"
-export BOARDNAME="PANDABOARD"
-
-arm_install_uboot() {
- UBOOT_DIR="/usr/local/share/u-boot/u-boot-pandaboard"
- FATMOUNT="${DESTDIR%${KERNEL}}/fat"
- chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}"
- chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
- chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/MLO ${FATMOUNT}/MLO
- chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/u-boot.img ${FATMOUNT}/u-boot.img
- sync
- umount_loop ${CHROOTDIR}/${FATMOUNT}
- chroot ${CHROOTDIR} rmdir ${FATMOUNT}
-
- return 0
-}
release/arm/RPI2.conf→/dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-EMBEDDED_TARGET_ARCH="armv7"
-EMBEDDED_TARGET="arm"
-EMBEDDEDBUILD=1
-EMBEDDEDPORTS="sysutils/u-boot-rpi2 sysutils/rpi-firmware"
-FAT_SIZE="50m"
-FAT_TYPE="16"
-IMAGE_SIZE="3072M"
-KERNEL="GENERIC"
-MD_ARGS="-x 63 -y 255"
-NODOC=1
-UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi2"
-RPI_FIRMWARE_DIR="/usr/local/share/rpi-firmware"
-OL_DIR="${RPI_FIRMWARE_DIR}/overlays"
-OVERLAYS="mmc.dtbo"
-PART_SCHEME="MBR"
-export BOARDNAME="RPI2"
-
-arm_install_uboot() {
- UBOOT_FILES="u-boot.bin"
- RPI_FIRMWARE_FILES="bootcode.bin config.txt \
- fixup.dat fixup_cd.dat fixup_db.dat fixup_x.dat \
- start.elf start_cd.elf start_db.elf start_x.elf \
- bcm2709-rpi-2-b.dtb"
- FATMOUNT="${DESTDIR%${KERNEL}}/fat"
- chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}"
- chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
- for _UF in ${UBOOT_FILES}; do
- chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/${_UF} \
- ${FATMOUNT}/${_UF}
- done
- for _UF in ${RPI_FIRMWARE_FILES}; do
- chroot ${CHROOTDIR} cp -p ${RPI_FIRMWARE_DIR}/${_UF} \
- ${FATMOUNT}/${_UF}
- done
- chroot ${CHROOTDIR} mkdir -p ${FATMOUNT}/overlays
- for _OL in ${OVERLAYS}; do
- chroot ${CHROOTDIR} cp -p ${OL_DIR}/${_OL} \
- ${FATMOUNT}/overlays/${_OL}
- done
- sync
- umount_loop ${CHROOTDIR}/${FATMOUNT}
- chroot ${CHROOTDIR} rmdir ${FATMOUNT}
-
- return 0
-}
release/arm/WANDBOARD.conf→/dev/null
@@ -1,26 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-EMBEDDED_TARGET_ARCH="armv7"
-EMBEDDED_TARGET="arm"
-EMBEDDEDBUILD=1
-EMBEDDEDPORTS="sysutils/u-boot-wandboard"
-FAT_SIZE="50m -b 16384"
-FAT_TYPE="16"
-IMAGE_SIZE="3072M"
-KERNEL="GENERIC"
-MD_ARGS="-x 63 -y 255"
-NODOC=1
-PART_SCHEME="MBR"
-export BOARDNAME="WANDBOARD"
-
-arm_install_uboot() {
- UBOOT_DIR="/usr/local/share/u-boot/u-boot-wandboard"
- UBOOT_FILES="u-boot.imx"
- chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
- of=/dev/${mddev} bs=512 seek=2 conv=sync
-
- return 0
-}
sbin/ping/ping.c
@@ -238,6 +238,7 @@ main(int argc, char *const *argv)
struct sigaction si_sa; struct sigaction si_sa;
size_t sz; size_t sz;
u_char *datap, packet[IP_MAXPACKET] __aligned(4); u_char *datap, packet[IP_MAXPACKET] __aligned(4);
+ const char *errstr;
char *ep, *source, *target, *payload; char *ep, *source, *target, *payload;
struct hostent *hp; struct hostent *hp;
#ifdef IPSEC_POLICY_IPSEC #ifdef IPSEC_POLICY_IPSEC
@@ -246,7 +247,7 @@ main(int argc, char *const *argv)
struct sockaddr_in *to; struct sockaddr_in *to;
double t; double t;
u_long alarmtimeout; u_long alarmtimeout;
- long ltmp;+ long long ltmp;
int almost_done, ch, df, hold, i, icmp_len, mib[4], preload; int almost_done, ch, df, hold, i, icmp_len, mib[4], preload;
int ssend_errno, srecv_errno, tos, ttl, pcp; int ssend_errno, srecv_errno, tos, ttl, pcp;
char ctrl[CMSG_SPACE(sizeof(struct timespec))]; char ctrl[CMSG_SPACE(sizeof(struct timespec))];
@@ -317,18 +318,18 @@ main(int argc, char *const *argv)
break; break;
case 'C': case 'C':
options |= F_IP_VLAN_PCP; options |= F_IP_VLAN_PCP;
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, -1, 7, &errstr);
- if (*ep || ep == optarg || ltmp > 7 || ltmp < -1)+ if (errstr != NULL)
errx(EX_USAGE, "invalid PCP: `%s'", optarg); errx(EX_USAGE, "invalid PCP: `%s'", optarg);
pcp = ltmp; pcp = ltmp;
break; break;
case 'c': case 'c':
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, 1, LONG_MAX, &errstr);
- if (*ep || ep == optarg || ltmp <= 0)+ if (errstr != NULL)
errx(EX_USAGE, errx(EX_USAGE,
"invalid count of packets to transmit: `%s'", "invalid count of packets to transmit: `%s'",
optarg); optarg);
- npackets = ltmp;+ npackets = (long)ltmp;
break; break;
case 'D': case 'D':
options |= F_HDRINCL; options |= F_HDRINCL;
@@ -346,49 +347,49 @@ main(int argc, char *const *argv)
setbuf(stdout, (char *)NULL); setbuf(stdout, (char *)NULL);
break; break;
case 'G': /* Maximum packet size for ping sweep */ case 'G': /* Maximum packet size for ping sweep */
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, 1, INT_MAX, &errstr);
- if (*ep || ep == optarg || ltmp <= 0)+ if (errstr != NULL) {
errx(EX_USAGE, "invalid packet size: `%s'", errx(EX_USAGE, "invalid packet size: `%s'",
optarg); optarg);
- if (uid != 0 && ltmp > DEFDATALEN) {+ }
- errno = EPERM;+ sweepmax = (int)ltmp;
- err(EX_NOPERM,+ if (uid != 0 && sweepmax > DEFDATALEN) {
- "packet size too large: %ld > %u",+ errc(EX_NOPERM, EPERM,
- ltmp, DEFDATALEN);+ "packet size too large: %d > %u",
+ sweepmax, DEFDATALEN);
} }
options |= F_SWEEP; options |= F_SWEEP;
- sweepmax = ltmp;
break; break;
case 'g': /* Minimum packet size for ping sweep */ case 'g': /* Minimum packet size for ping sweep */
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, 1, INT_MAX, &errstr);
- if (*ep || ep == optarg || ltmp <= 0)+ if (errstr != NULL) {
errx(EX_USAGE, "invalid packet size: `%s'", errx(EX_USAGE, "invalid packet size: `%s'",
optarg); optarg);
- if (uid != 0 && ltmp > DEFDATALEN) {+ }
- errno = EPERM;+ sweepmin = (int)ltmp;
- err(EX_NOPERM,+ if (uid != 0 && sweepmin > DEFDATALEN) {
- "packet size too large: %ld > %u",+ errc(EX_NOPERM, EPERM,
- ltmp, DEFDATALEN);+ "packet size too large: %d > %u",
+ sweepmin, DEFDATALEN);
} }
options |= F_SWEEP; options |= F_SWEEP;
- sweepmin = ltmp;
break; break;
case 'H': case 'H':
options &= ~F_NUMERIC; options &= ~F_NUMERIC;
break; break;
case 'h': /* Packet size increment for ping sweep */ case 'h': /* Packet size increment for ping sweep */
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, 1, INT_MAX, &errstr);
- if (*ep || ep == optarg || ltmp < 1)+ if (errstr != NULL) {
- errx(EX_USAGE, "invalid increment size: `%s'",+ errx(EX_USAGE, "invalid packet size: `%s'",
optarg); optarg);
- if (uid != 0 && ltmp > DEFDATALEN) {+ }
- errno = EPERM;+ sweepincr = (int)ltmp;
- err(EX_NOPERM,+ if (uid != 0 && sweepincr > DEFDATALEN) {
- "packet size too large: %ld > %u",+ errc(EX_NOPERM, EPERM,
- ltmp, DEFDATALEN);+ "packet size too large: %d > %u",
+ sweepincr, DEFDATALEN);
} }
options |= F_SWEEP; options |= F_SWEEP;
- sweepincr = ltmp;
break; break;
case 'I': /* multicast interface */ case 'I': /* multicast interface */
if (inet_aton(optarg, &ifaddr) == 0) if (inet_aton(optarg, &ifaddr) == 0)
@@ -414,15 +415,15 @@ main(int argc, char *const *argv)
loop = 0; loop = 0;
break; break;
case 'l': case 'l':
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, 0, INT_MAX, &errstr);
- if (*ep || ep == optarg || ltmp > INT_MAX || ltmp < 0)+ if (errstr != NULL)
errx(EX_USAGE, errx(EX_USAGE,
"invalid preload value: `%s'", optarg); "invalid preload value: `%s'", optarg);
if (uid) { if (uid) {
errno = EPERM; errno = EPERM;
err(EX_NOPERM, "-l flag"); err(EX_NOPERM, "-l flag");
} }
- preload = ltmp;+ preload = (int)ltmp;
break; break;
case 'M': case 'M':
switch(optarg[0]) { switch(optarg[0]) {
@@ -440,10 +441,10 @@ main(int argc, char *const *argv)
} }
break; break;
case 'm': /* TTL */ case 'm': /* TTL */
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, 0, MAXTTL, &errstr);
- if (*ep || ep == optarg || ltmp > MAXTTL || ltmp < 0)+ if (errstr != NULL)
errx(EX_USAGE, "invalid TTL: `%s'", optarg); errx(EX_USAGE, "invalid TTL: `%s'", optarg);
- ttl = ltmp;+ ttl = (int)ltmp;
options |= F_TTL; options |= F_TTL;
break; break;
case 'n': case 'n':
@@ -485,24 +486,24 @@ main(int argc, char *const *argv)
source = optarg; source = optarg;
break; break;
case 's': /* size of packet to send */ case 's': /* size of packet to send */
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, 0, INT_MAX, &errstr);
- if (*ep || ep == optarg || ltmp > INT_MAX || ltmp < 0)+ if (errstr != NULL)
errx(EX_USAGE, "invalid packet size: `%s'", errx(EX_USAGE, "invalid packet size: `%s'",
optarg); optarg);
- if (uid != 0 && ltmp > DEFDATALEN) {+ datalen = (int)ltmp;
+ if (uid != 0 && datalen > DEFDATALEN) {
errno = EPERM; errno = EPERM;
err(EX_NOPERM, err(EX_NOPERM,
- "packet size too large: %ld > %u",+ "packet size too large: %d > %u",
- ltmp, DEFDATALEN);+ datalen, DEFDATALEN);
} }
- datalen = ltmp;
break; break;
case 'T': /* multicast TTL */ case 'T': /* multicast TTL */
- ltmp = strtol(optarg, &ep, 0);+ ltmp = strtonum(optarg, 0, MAXTTL, &errstr);
- if (*ep || ep == optarg || ltmp > MAXTTL || ltmp < 0)+ if (errstr != NULL)
errx(EX_USAGE, "invalid multicast TTL: `%s'", errx(EX_USAGE, "invalid multicast TTL: `%s'",
optarg); optarg);
- mttl = ltmp;+ mttl = (unsigned char)ltmp;
options |= F_MTTL; options |= F_MTTL;
break; break;
case 't': case 't':
@@ -657,7 +658,7 @@ main(int argc, char *const *argv)
if (datalen >= TIMEVAL_LEN) /* can we time transfer */ if (datalen >= TIMEVAL_LEN) /* can we time transfer */
timing = 1; timing = 1;
- if (!(options & F_PINGFILLED))+ if ((options & (F_PINGFILLED | F_SWEEP)) == 0)
for (i = TIMEVAL_LEN; i < datalen; ++i) for (i = TIMEVAL_LEN; i < datalen; ++i)
*datap++ = i; *datap++ = i;
@@ -803,10 +804,15 @@ main(int argc, char *const *argv)
#endif #endif
if (sweepmax) { if (sweepmax) {
if (sweepmin > sweepmax) if (sweepmin > sweepmax)
- errx(EX_USAGE, "Maximum packet size must be no less than the minimum packet size");+ errx(EX_USAGE,
+ "Maximum packet size must be no less than the minimum packet size");
+
+ if (sweepmax > maxpayload - TIMEVAL_LEN)
+ errx(EX_USAGE, "Invalid sweep maximum");
if (datalen != DEFDATALEN) if (datalen != DEFDATALEN)
- errx(EX_USAGE, "Packet size and ping sweep are mutually exclusive");+ errx(EX_USAGE,
+ "Packet size and ping sweep are mutually exclusive");
if (npackets > 0) { if (npackets > 0) {
snpackets = npackets; snpackets = npackets;
@@ -971,11 +977,11 @@ main(int argc, char *const *argv)
} }
if (n == 0 || options & F_FLOOD) { if (n == 0 || options & F_FLOOD) {
if (sweepmax && sntransmitted == snpackets) { if (sweepmax && sntransmitted == snpackets) {
- for (i = 0; i < sweepincr ; ++i)+ if (datalen + sweepincr > sweepmax)
+ break;
+ for (i = 0; i < sweepincr; i++)
*datap++ = i; *datap++ = i;
datalen += sweepincr; datalen += sweepincr;
- if (datalen > sweepmax)
- break;
send_len = icmp_len + datalen; send_len = icmp_len + datalen;
sntransmitted = 0; sntransmitted = 0;
} }
share/man/man4/Makefile
@@ -448,6 +448,7 @@ MAN= aac.4 \
rl.4 \ rl.4 \
rndtest.4 \ rndtest.4 \
route.4 \ route.4 \
+ rtsx.4 \
rtwn.4 \ rtwn.4 \
rtwnfw.4 \ rtwnfw.4 \
rtwn_pci.4 \ rtwn_pci.4 \
share/man/man4/rtsx.4
@@ -0,0 +1,121 @@
+.\"
+.\" Copyright (c) 2020 Henri Hennebert <hlh@restart.be>
+.\" 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. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" 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 November 24, 2020
+.Dt RTSX 4
+.Os
+.Sh NAME
+.Nm rtsx
+.Nd Realtek SD card reader
+.Sh SYNOPSIS
+To compile this driver into the kernel, place the following
+lines in the kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device mmc"
+.Cd "device mmcsd"
+.Cd "device rtsx"
+.Ed
+.Pp
+Alternatively, to load the driver as a module at boot time,
+place the following lines in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+mmc_load="YES"
+mmcsd_load="YES"
+rtsx_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for Realtek SD card reader.
+Driver attaches mmc bus on card insertion and detaches it on card removing.
+.Sh HARDWARE
+The
+.Nm
+driver supports different specification compatible chips.
+The following chips have been verified to work:
+.Pp
+.Bl -bullet -compact
+.It
+RTS5209
+.It
+RTS5227
+.It
+RTS5229
+.It
+RTS522A
+.It
+RTS525A
+.It
+RTL8411B
+.El
+.Pp
+It should also work for:
+.Pp
+.Bl -bullet -compact
+.It
+RTS5249
+.It
+RTL8402
+.It
+RTL8411
+.El
+.Sh SEE ALSO
+.Xr mmc 4 ,
+.Xr mmcsd 4
+.Rs
+.%T "SD Specifications, Part 2, SD Host Controller, Simplified Specification"
+.%T "SanDisk Secure Digital Card"
+.Re
+.Sh HISTORY
+The
+.Nm
+driver was ported from
+.Ox
+with modifications found in Linux and
+.Nx .
+.Sh AUTHORS
+.An Henri Hennebert Aq Mt hlh@restart.be
+.An Gary Jennejohn Aq Mt gj@freebsd.org
+.An Jesper Schmitz Mouridsen Aq Mt jsm@FreeBSD.org
+.Sh CONTRIBUTORS
+.An Lutz Bichler Aq Mt Lutz.Bichler@gmail.com
+.Sh BUGS
+.Bl -bullet
+.It
+The timeouts experienced during card insert and during I/O are solved in version 1.0g.
+.It
+RTS522A on Lenovo P50s and Lenovo T470p, card detection and read-only switch are reversed.
+This is sovled by adding in
+.Em loader.conf(5) :
+.Bd -ragged
+.Cd dev.rtsx.0.inversion=1
+.Ed
+.It
+Mounting a filesystem with write access on a card write protected may involve a kernel crash.
+.It
+Suspend/Resume do not work under MMCCAM.
+.El
share/mk/bsd.init.mk
@@ -56,9 +56,13 @@ $xGRP= ${_gid}
# - make install is used without other targets. This is to avoid breaking # - make install is used without other targets. This is to avoid breaking
# things like 'make all install' or 'make foo install'. # things like 'make all install' or 'make foo install'.
# - non-build targets are called # - non-build targets are called
-.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL:U1} == 0 && \+.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} == 0
- ${BUILD_AT_LEVEL0:Uyes:tl} == "no" && !make(clean*) && !make(*clean)+# targets that are ok at level 0
+DIRDEPS_BUILD_LEVEL0_TARGETS += clean* destroy*
+M_ListToSkip?= O:u:S,^,N,:ts:
+.if ${.TARGETS:Uall:${DIRDEPS_BUILD_LEVEL0_TARGETS:${M_ListToSkip}}} != ""
_SKIP_BUILD= not building at level 0 _SKIP_BUILD= not building at level 0
+.endif
.elif !empty(.MAKEFLAGS:M-V${_V_DO_BUILD}) || \ .elif !empty(.MAKEFLAGS:M-V${_V_DO_BUILD}) || \
${.TARGETS:M*install*} == ${.TARGETS} || \ ${.TARGETS:M*install*} == ${.TARGETS} || \
${.TARGETS:Mclean*} == ${.TARGETS} || \ ${.TARGETS:Mclean*} == ${.TARGETS} || \
share/mk/dirdeps-options.mk
@@ -1,7 +1,7 @@
# $FreeBSD$ # $FreeBSD$
-# $Id: dirdeps-options.mk,v 1.9 2018/09/20 00:07:19 sjg Exp $+# $Id: dirdeps-options.mk,v 1.17 2020/08/07 01:57:38 sjg Exp $
# #
-# @(#) Copyright (c) 2018, Simon J. Gerraty+# @(#) Copyright (c) 2018-2020, Simon J. Gerraty
# #
# This file is provided in the hope that it will # This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY. # be of use. There is absolutely NO WARRANTY.
@@ -38,6 +38,11 @@
# to whatever applies for that dir, or it can rely on globals # to whatever applies for that dir, or it can rely on globals
# set in local.dirdeps-options.mk # set in local.dirdeps-options.mk
# Either way, we will .undef DIRDEPS.* when done. # Either way, we will .undef DIRDEPS.* when done.
+#
+# In some cases the value of MK_FOO might depend on TARGET_SPEC
+# so we qualify MK_FOO with .${TARGET_SPEC} and each component
+# TARGET_SPEC_VAR (in reverse order) before using MK_FOO.
+#
# This should have been set by Makefile.depend.options # This should have been set by Makefile.depend.options
# before including us # before including us
@@ -48,21 +53,43 @@ DIRDEPS_OPTIONS ?=
.if ${.MAKE.LEVEL} == 0 .if ${.MAKE.LEVEL} == 0
# :U below avoids potential errors when we := # :U below avoids potential errors when we :=
-.for o in ${DIRDEPS_OPTIONS:tu}+# some options can depend on TARGET_SPEC!
-DIRDEPS += ${DIRDEPS.$o.${MK_$o:U}:U}+DIRDEPS_OPTIONS_QUALIFIER_LIST ?= \
+ ${DEP_TARGET_SPEC:U${TARGET_SPEC}} \
+ ${TARGET_SPEC_VARSr:U${TARGET_SPEC_VARS}:@v@${DEP_$v:U${$v}}@}
+# note that we need to include $o in the variable _o$o
+# to ensure correct evaluation.
+.for o in ${DIRDEPS_OPTIONS}
+.undef _o$o _v$o
+.for x in ${DIRDEPS_OPTIONS_QUALIFIER_LIST}
+.if defined(MK_$o.$x)
+_o$o ?= MK_$o.$x
+_v$o ?= ${MK_$o.$x}
+.endif
+.endfor
+_v$o ?= ${MK_$o}
+.if ${_debug_reldir:U0}
+.info ${DEP_RELDIR:U${RELDIR}}.${DEP_TARGET_SPEC:U${TARGET_SPEC}}: o=$o ${_o$o:UMK_$o}=${_v$o:U} DIRDEPS += ${DIRDEPS.$o.${_v$o:U}:U}
+.endif
+DIRDEPS += ${DIRDEPS.$o.${_v$o:U}:U}
.endfor .endfor
DIRDEPS := ${DIRDEPS:O:u} DIRDEPS := ${DIRDEPS:O:u}
+.if ${_debug_reldir:U0}
+.info ${DEP_RELDIR:U${RELDIR}}: DIRDEPS=${DIRDEPS}
+.endif
# avoid cross contamination # avoid cross contamination
-.for o in ${DIRDEPS_OPTIONS:tu}+.for o in ${DIRDEPS_OPTIONS}
.undef DIRDEPS.$o.yes .undef DIRDEPS.$o.yes
.undef DIRDEPS.$o.no .undef DIRDEPS.$o.no
+.undef _o$o
+.undef _v$o
.endfor .endfor
.else .else
# whether options are enabled or not, # whether options are enabled or not,
# we want to filter out the relevant DIRDEPS.* # we want to filter out the relevant DIRDEPS.*
# we should only be included by meta.autodep.mk # we should only be included by meta.autodep.mk
# if dependencies are to be updated # if dependencies are to be updated
-.for o in ${DIRDEPS_OPTIONS:tu}+.for o in ${DIRDEPS_OPTIONS}
.for d in ${DIRDEPS.$o.yes} ${DIRDEPS.$o.no} .for d in ${DIRDEPS.$o.yes} ${DIRDEPS.$o.no}
.if exists(${SRCTOP}/$d) .if exists(${SRCTOP}/$d)
GENDIRDEPS_FILTER += N$d* GENDIRDEPS_FILTER += N$d*
share/mk/dirdeps-targets.mk
@@ -1,16 +1,16 @@
# $FreeBSD$ # $FreeBSD$
# RCSid: # RCSid:
-# $Id: dirdeps-targets.mk,v 1.9 2019/10/06 20:07:50 sjg Exp $+# $Id: dirdeps-targets.mk,v 1.22 2020/08/15 18:00:11 sjg Exp $
# #
-# @(#) Copyright (c) 2019 Simon J. Gerraty+# @(#) Copyright (c) 2019-2020 Simon J. Gerraty
# #
# This file is provided in the hope that it will # This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY. # be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise # Permission to copy, redistribute or otherwise
-# use this file is hereby granted provided that +# use this file is hereby granted provided that
# the above copyright notice and this notice are # the above copyright notice and this notice are
-# left intact. +# left intact.
-# +#
# Please send copies of changes and bug-fixes to: # Please send copies of changes and bug-fixes to:
# sjg@crufty.net # sjg@crufty.net
# #
@@ -26,7 +26,16 @@
# We then search those dirs for any Makefile.depend* # We then search those dirs for any Makefile.depend*
# Finally we select any that match conditions like REQUESTED_MACHINE # Finally we select any that match conditions like REQUESTED_MACHINE
# or TARGET_SPEC and initialize DIRDEPS accordingly. # or TARGET_SPEC and initialize DIRDEPS accordingly.
-# +#
+# We will check each of the initial DIRDEPS for Makefile.dirdeps.options
+# and include any found.
+# This makes it feasible to tweak options like MK_DIRDEPS_CACHE
+# for a specific target.
+#
+# If MK_STATIC_DIRDEPS_CACHE is defined we will check if the
+# initial DIRDEPS has a static cache (Makefile.dirdeps.cache).
+# This only makes sense for seriously expensive targets.
+#
.if ${.MAKE.LEVEL} == 0 .if ${.MAKE.LEVEL} == 0
# pickup customizations # pickup customizations
@@ -38,8 +47,11 @@ DIRDEPS_TARGETS_DIRS ?= targets targets/pseudo
# they need to be stripped when looking for target dirs # they need to be stripped when looking for target dirs
DIRDEPS_TARGETS_PREFIX_LIST ?= pkg- build- DIRDEPS_TARGETS_PREFIX_LIST ?= pkg- build-
+# some .TARGETS need filtering
+DIRDEPS_TARGETS_FILTER += Nall
+
# matching target dirs if any # matching target dirs if any
-tdirs := ${.TARGETS:Nall:${DIRDEPS_TARGETS_PREFIX_LIST:@p@S,^$p,,@:ts:}:@t@${DIRDEPS_TARGETS_DIRS:@d@$d/$t@}@:@d@${exists(${SRCTOP}/$d):?$d:}@}+tdirs := ${.TARGETS:${DIRDEPS_TARGETS_FILTER:ts:}:${DIRDEPS_TARGETS_PREFIX_LIST:@p@S,^$p,,@:ts:}:@t@${DIRDEPS_TARGETS_DIRS:@d@$d/$t@}@:@d@${exists(${SRCTOP}/$d):?$d:}@}
.if !empty(DEBUG_DIRDEPS_TARGETS) .if !empty(DEBUG_DIRDEPS_TARGETS)
.info tdirs=${tdirs} .info tdirs=${tdirs}
@@ -123,12 +135,38 @@ DIRDEPS := ${DIRDEPS:O:u}
.endif .endif
# if we got DIRDEPS get to work # if we got DIRDEPS get to work
.if !empty(DIRDEPS) .if !empty(DIRDEPS)
+DIRDEPS.dirs := ${DIRDEPS:S,^,${SRCTOP}/,:@d@${exists($d):?$d:${d:R}}@}
+# some targets what to tweak options we might want to process now
+.for m in ${DIRDEPS.dirs:S,$,/Makefile.dirdeps.options,}
+.-include <$m>
+.endfor
+.if defined(MK_STATIC_DIRDEPS_CACHE)
+# some targets are very expensive to compute dirdeps for
+# so we may have a static cache
+.for c in ${DIRDEPS.dirs:S,$,/Makefile.dirdeps.cache,}
+.if exists($c)
+STATIC_DIRDEPS_CACHE ?= $c
+.if ${MK_STATIC_DIRDEPS_CACHE} == "yes"
+DIRDEPS_CACHE ?= $c
+MK_DIRDEPS_CACHE = yes
+.endif
+.endif
+.endfor
+.if defined(STATIC_DIRDEPS_CACHE)
+.export STATIC_DIRDEPS_CACHE
+.endif
+.endif
+
+# allow a top-level makefile to do other stuff
+# before including dirdeps.mk
+.if ${MK_DIRDEPS_TARGETS_INCLUDE_DIRDEPS:Uyes} == "yes"
.include <dirdeps.mk> .include <dirdeps.mk>
+.endif
DIRDEPS_TARGETS_SKIP += all clean* destroy* DIRDEPS_TARGETS_SKIP += all clean* destroy*
.for t in ${.TARGETS:${DIRDEPS_TARGETS_SKIP:${M_ListToSkip}}} .for t in ${.TARGETS:${DIRDEPS_TARGETS_SKIP:${M_ListToSkip}}}
$t: dirdeps $t: dirdeps
-.endfor +.endfor
.endif .endif
.endif .endif
share/mk/dirdeps.mk
@@ -1,7 +1,8 @@
# $FreeBSD$ # $FreeBSD$
-# $Id: dirdeps.mk,v 1.100 2019/11/12 06:47:58 sjg Exp $+# $Id: dirdeps.mk,v 1.130 2020/11/02 00:34:30 sjg Exp $
-# Copyright (c) 2010-2013, Juniper Networks, Inc.+# Copyright (c) 2010-2020, Simon J. Gerraty
+# Copyright (c) 2010-2018, Juniper Networks, Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@@ -41,7 +42,7 @@
# or .<target_spec> suffix (see TARGET_SPEC_VARS below), # or .<target_spec> suffix (see TARGET_SPEC_VARS below),
# for example to force building something for the pseudo # for example to force building something for the pseudo
# machines "host" or "common" regardless of current ${MACHINE}. # machines "host" or "common" regardless of current ${MACHINE}.
-# +#
# All unqualified entries end up being qualified with .${TARGET_SPEC} # All unqualified entries end up being qualified with .${TARGET_SPEC}
# and partially qualified (if TARGET_SPEC_VARS has multiple # and partially qualified (if TARGET_SPEC_VARS has multiple
# entries) are also expanded to a full .<target_spec>. # entries) are also expanded to a full .<target_spec>.
@@ -50,29 +51,22 @@
# #
# The fully qualified directory entries are used to construct a # The fully qualified directory entries are used to construct a
# dependency graph that will drive the build later. # dependency graph that will drive the build later.
-# +#
# Also, for each fully qualified directory target, we will search # Also, for each fully qualified directory target, we will search
# using ${.MAKE.DEPENDFILE_PREFERENCE} to find additional # using ${.MAKE.DEPENDFILE_PREFERENCE} to find additional
# dependencies. We use Makefile.depend (default value for # dependencies. We use Makefile.depend (default value for
# .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to # .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to
# distinguish them from others. # distinguish them from others.
-# +#
# Before each Makefile.depend file is read, we set # Before each Makefile.depend file is read, we set
# DEP_RELDIR to be the RELDIR (path relative to SRCTOP) for # DEP_RELDIR to be the RELDIR (path relative to SRCTOP) for
# its directory, and DEP_MACHINE etc according to the .<target_spec> # its directory, and DEP_MACHINE etc according to the .<target_spec>
# represented by the suffix of the corresponding target. # represented by the suffix of the corresponding target.
-# +#
# Since each Makefile.depend file includes dirdeps.mk, this # Since each Makefile.depend file includes dirdeps.mk, this
# processing is recursive and results in .MAKE.LEVEL 0 learning the # processing is recursive and results in .MAKE.LEVEL 0 learning the
# dependencies of the tree wrt the initial directory (_DEP_RELDIR). # dependencies of the tree wrt the initial directory (_DEP_RELDIR).
# #
-# BUILD_AT_LEVEL0
-# Indicates whether .MAKE.LEVEL 0 builds anything:
-# if "no" sub-makes are used to build everything,
-# if "yes" sub-makes are only used to build for other machines.
-# It is best to use "no", but this can require fixing some
-# makefiles to not do anything at .MAKE.LEVEL 0.
-#
# TARGET_SPEC_VARS # TARGET_SPEC_VARS
# The default value is just MACHINE, and for most environments # The default value is just MACHINE, and for most environments
# this is sufficient. The _DIRDEP_USE target actually sets # this is sufficient. The _DIRDEP_USE target actually sets
@@ -113,12 +107,12 @@
# # make sure we know what TARGET_SPEC is # # make sure we know what TARGET_SPEC is
# # as we may need it to find Makefile.depend* # # as we may need it to find Makefile.depend*
# TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} # TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
-# +#
# The following variables can influence the initial DIRDEPS # The following variables can influence the initial DIRDEPS
# computation with regard to the TARGET_SPECs that will be # computation with regard to the TARGET_SPECs that will be
# built. # built.
# Most should also be considered by init.mk # Most should also be considered by init.mk
-# +#
# ONLY_TARGET_SPEC_LIST # ONLY_TARGET_SPEC_LIST
# Defines a list of TARGET_SPECs for which the current # Defines a list of TARGET_SPECs for which the current
# directory can be built. # directory can be built.
@@ -137,6 +131,19 @@
# A list of MACHINEs the current directory should not be # A list of MACHINEs the current directory should not be
# built for. # built for.
# #
+# _build_xtra_dirs
+# local.dirdeps.mk can add targets to this variable.
+# They will be hooked into the build, but independent of
+# any other DIRDEP.
+#
+# This allows for adding TESTS to the build, such that the build
+# if any test fails, but without the risk of introducing
+# circular dependencies.
+
+now_utc ?= ${%s:L:gmtime}
+.if !defined(start_utc)
+start_utc := ${now_utc}
+.endif
.if !target(bootstrap) && (make(bootstrap) || \ .if !target(bootstrap) && (make(bootstrap) || \
make(bootstrap-this) || \ make(bootstrap-this) || \
@@ -157,11 +164,6 @@ _DIRDEP_USE_LEVEL?= 0
_CURDIR ?= ${.CURDIR} _CURDIR ?= ${.CURDIR}
_OBJDIR ?= ${.OBJDIR} _OBJDIR ?= ${.OBJDIR}
-now_utc = ${%s:L:gmtime}
-.if !defined(start_utc)
-start_utc := ${now_utc}
-.endif
-
.if ${MAKEFILE:T} == ${.PARSEFILE} && empty(DIRDEPS) && ${.TARGETS:Uall:M*/*} != "" .if ${MAKEFILE:T} == ${.PARSEFILE} && empty(DIRDEPS) && ${.TARGETS:Uall:M*/*} != ""
# This little trick let's us do # This little trick let's us do
# #
@@ -208,12 +210,9 @@ DEP_$v ?= ${$v}
# so we need to construct a set of modifiers to fill in the gaps. # so we need to construct a set of modifiers to fill in the gaps.
.if ${MAKE_VERSION} >= 20170130 .if ${MAKE_VERSION} >= 20170130
_tspec_x := ${TARGET_SPEC_VARS:range} _tspec_x := ${TARGET_SPEC_VARS:range}
-.elif ${TARGET_SPEC_VARS:[#]} > 10
-# seriously? better have jot(1) or equivalent to produce suitable sequence
-_tspec_x := ${${JOT:Ujot} ${TARGET_SPEC_VARS:[#]}:L:sh}
.else .else
-# we can provide the sequence ourselves+# do it the hard way
-_tspec_x := ${1 2 3 4 5 6 7 8 9 10:L:[1..${TARGET_SPEC_VARS:[#]}]}+_tspec_x := ${TARGET_SPEC_VARS:[#]:@x@i=1;while [ $$i -le $x ]; do echo $$i; i=$$((i + 1)); done;@:sh}
.endif .endif
# this handles unqualified entries # this handles unqualified entries
M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.$${DEP_TARGET_SPEC}; M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.$${DEP_TARGET_SPEC};
@@ -223,6 +222,7 @@ _tspec_m$i := ${TARGET_SPEC_VARS:[2..$i]:@w@[^,]+@:ts,}
_tspec_a$i := ,${TARGET_SPEC_VARS:[$i..-1]:@v@$$$${DEP_$v}@:ts,} _tspec_a$i := ,${TARGET_SPEC_VARS:[$i..-1]:@v@$$$${DEP_$v}@:ts,}
M_dep_qual_fixes += C;(\.${_tspec_m$i})$$;\1${_tspec_a$i}; M_dep_qual_fixes += C;(\.${_tspec_m$i})$$;\1${_tspec_a$i};
.endfor .endfor
+TARGET_SPEC_VARSr := ${TARGET_SPEC_VARS:[-1..1]}
.else .else
# A harmless? default. # A harmless? default.
M_dep_qual_fixes = U M_dep_qual_fixes = U
@@ -307,6 +307,7 @@ DEP_MACHINE := ${_DEP_TARGET_SPEC}
# reset each time through # reset each time through
_build_all_dirs = _build_all_dirs =
+_build_xtra_dirs =
# the first time we are included the _DIRDEP_USE target will not be defined # the first time we are included the _DIRDEP_USE target will not be defined
# we can use this as a clue to do initialization and other one time things. # we can use this as a clue to do initialization and other one time things.
@@ -337,7 +338,18 @@ BUILD_DIRDEPS ?= yes
.if ${MK_DIRDEPS_CACHE} == "yes" .if ${MK_DIRDEPS_CACHE} == "yes"
# this is where we will cache all our work # this is where we will cache all our work
-DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}+DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${_TARGETS:U${.TARGETS}:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}
+.endif
+
+.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
+_debug_reldir = 1
+.else
+_debug_reldir = 0
+.endif
+.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} != ""
+_debug_search = 1
+.else
+_debug_search = 0
.endif .endif
# pickup customizations # pickup customizations
@@ -382,6 +394,18 @@ DIRDEPS_FILTER += M${_DEP_RELDIR}
DIRDEP_MAKE ?= ${.MAKE} DIRDEP_MAKE ?= ${.MAKE}
DIRDEP_DIR ?= ${.TARGET:R} DIRDEP_DIR ?= ${.TARGET:R}
+# if you want us to report load averages during build
+# DIRDEP_USE_PRELUDE += ${DIRDEP_LOADAVG_REPORT};
+
+DIRDEP_LOADAVG_CMD ?= ${UPTIME:Uuptime} | sed 's,.*\(load\),\1,'
+DIRDEP_LOADAVG_LAST = 0
+# yes the expression here is a bit complicated,
+# the trick is to only eval ${DIRDEP_LOADAVG_LAST::=${now_utc}}
+# when we want to report.
+DIRDEP_LOADAVG_REPORT = \
+ test -z "${"${expr ${now_utc} - ${DIRDEP_LOADAVG_INTEVAL:U60} - ${DIRDEP_LOADAVG_LAST}:L:sh:N-*}":?yes${DIRDEP_LOADAVG_LAST::=${now_utc}}:}" || \
+ echo "${TRACER}`${DIRDEP_LOADAVG_CMD}`"
+
# we suppress SUBDIR when visiting the leaves # we suppress SUBDIR when visiting the leaves
# we assume sys.mk will set MACHINE_ARCH # we assume sys.mk will set MACHINE_ARCH
# you can add extras to DIRDEP_USE_ENV # you can add extras to DIRDEP_USE_ENV
@@ -389,7 +413,7 @@ DIRDEP_DIR ?= ${.TARGET:R}
_DIRDEP_USE: .USE .MAKE _DIRDEP_USE: .USE .MAKE
@for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \ @for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \
test -s ${.TARGET:R}/$$m || continue; \ test -s ${.TARGET:R}/$$m || continue; \
- echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \+ echo "${TRACER}Checking ${.TARGET:S,${SRCTOP}/,,} for ${.TARGET:E} ..."; \
${DIRDEP_USE_PRELUDE} \ ${DIRDEP_USE_PRELUDE} \
MACHINE_ARCH= NO_SUBDIR=1 ${DIRDEP_USE_ENV} \ MACHINE_ARCH= NO_SUBDIR=1 ${DIRDEP_USE_ENV} \
TARGET_SPEC=${.TARGET:E} \ TARGET_SPEC=${.TARGET:E} \
@@ -468,10 +492,19 @@ dirdeps-cached: ${DIRDEPS_CACHE} .MAKE
@MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \ @MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \
dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no
+# leaf makefiles rarely work for building DIRDEPS_CACHE
+.if ${RELDIR} != "."
+BUILD_DIRDEPS_MAKEFILE ?= -f dirdeps.mk
+.endif
+
# these should generally do # these should generally do
-BUILD_DIRDEPS_MAKEFILE ?= ${MAKEFILE}+BUILD_DIRDEPS_MAKEFILE ?=
BUILD_DIRDEPS_TARGETS ?= ${.TARGETS} BUILD_DIRDEPS_TARGETS ?= ${.TARGETS}
+.if ${DIRDEPS_CACHE} != ${STATIC_DIRDEPS_CACHE:Uno} && ${DIRDEPS_CACHE:M${SRCTOP}/*} == ""
+# export this for dirdeps-cache-update.mk
+DYNAMIC_DIRDEPS_CACHE := ${DIRDEPS_CACHE}
+.export DYNAMIC_DIRDEPS_CACHE
# we need the .meta file to ensure we update if # we need the .meta file to ensure we update if
# any of the Makefile.depend* changed. # any of the Makefile.depend* changed.
# We do not want to compare the command line though. # We do not want to compare the command line though.
@@ -483,40 +516,34 @@ ${DIRDEPS_CACHE}: .META .NOMETA_CMP
+@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \ +@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \
DIRDEPS="${DIRDEPS}" \ DIRDEPS="${DIRDEPS}" \
TARGET_SPEC=${TARGET_SPEC} \ TARGET_SPEC=${TARGET_SPEC} \
- MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \+ MAKEFLAGS= ${DIRDEP_CACHE_MAKE:U${.MAKE}} -C ${_CURDIR} \
+ ${BUILD_DIRDEPS_MAKEFILE} \
${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \ ${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \
.MAKE.DEPENDFILE=.none \ .MAKE.DEPENDFILE=.none \
+ ${"${DEBUG_DIRDEPS:Nno}":?DEBUG_DIRDEPS='${DEBUG_DIRDEPS}':} \
${.MAKEFLAGS:tW:S,-D ,-D,g:tw:M*WITH*} \ ${.MAKEFLAGS:tW:S,-D ,-D,g:tw:M*WITH*} \
- 3>&1 1>&2 | sed 's,${SRCTOP},$${SRCTOP},g' >> ${.TARGET}.new && \+ ${.MAKEFLAGS:tW:S,-d ,-d,g:tw:M-d*} \
+ 3>&1 1>&2 | sed 's,${SRCTOP},$${SRCTOP},g;s,_{,$${,g' >> ${.TARGET}.new && \
mv ${.TARGET}.new ${.TARGET} mv ${.TARGET}.new ${.TARGET}
+.endif
.endif .endif
.elif !target(_count_dirdeps) .elif !target(_count_dirdeps)
# we want to capture the dirdeps count in the cache # we want to capture the dirdeps count in the cache
.END: _count_dirdeps .END: _count_dirdeps
_count_dirdeps: .NOMETA _count_dirdeps: .NOMETA
- @echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3+ @{ echo; echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} ${DIRDEP_INFO_XTRAS}'; } >&3
.endif .endif
.elif !make(dirdeps) && !target(_count_dirdeps) .elif !make(dirdeps) && !target(_count_dirdeps)
beforedirdeps: _count_dirdeps beforedirdeps: _count_dirdeps
_count_dirdeps: .NOMETA _count_dirdeps: .NOMETA
- @echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`"+ @echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} ${DIRDEP_INFO_XTRAS} seconds=`expr ${now_utc} - ${start_utc}`"
.endif .endif
.endif .endif
.if ${BUILD_DIRDEPS} == "yes" .if ${BUILD_DIRDEPS} == "yes"
-.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
-_debug_reldir = 1
-.else
-_debug_reldir = 0
-.endif
-.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} != ""
-_debug_search = 1
-.else
-_debug_search = 0
-.endif
# the rest is done repeatedly for every Makefile.depend we read. # the rest is done repeatedly for every Makefile.depend we read.
# if we are anything but the original dir we care only about the # if we are anything but the original dir we care only about the
@@ -568,19 +595,7 @@ _build_dirs =
.if ${DEP_RELDIR} == ${_DEP_RELDIR} .if ${DEP_RELDIR} == ${_DEP_RELDIR}
# pickup other machines for this dir if necessary # pickup other machines for this dir if necessary
-.if ${BUILD_AT_LEVEL0:Uyes} == "no"
_build_dirs += ${_machines:@m@${_CURDIR}.$m@} _build_dirs += ${_machines:@m@${_CURDIR}.$m@}
-.else
-_build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@}
-.if ${DEP_TARGET_SPEC} == ${TARGET_SPEC}
-# pickup local dependencies now
-.if ${MAKE_VERSION} < 20160220
-.-include <.depend>
-.else
-.dinclude <.depend>
-.endif
-.endif
-.endif
.endif .endif
.if ${_debug_reldir} .if ${_debug_reldir}
@@ -616,6 +631,7 @@ __qual_depdirs += ${__hostdpadd}
.endif .endif
.if ${_debug_reldir} .if ${_debug_reldir}
+.info DEP_DIRDEPS_FILTER=${DEP_DIRDEPS_FILTER:ts:}
.info depdirs=${__depdirs} .info depdirs=${__depdirs}
.info qualified=${__qual_depdirs} .info qualified=${__qual_depdirs}
.info unqualified=${__unqual_depdirs} .info unqualified=${__unqual_depdirs}
@@ -633,7 +649,7 @@ _build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
.endif # empty DIRDEPS .endif # empty DIRDEPS
-_build_all_dirs += ${_build_dirs}+_build_all_dirs += ${_build_dirs} ${_build_xtra_dirs}
_build_all_dirs := ${_build_all_dirs:O:u} _build_all_dirs := ${_build_all_dirs:O:u}
# Normally if doing make -V something, # Normally if doing make -V something,
@@ -642,19 +658,14 @@ _build_all_dirs := ${_build_all_dirs:O:u}
.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == "" .if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == ""
.if !empty(_build_all_dirs) .if !empty(_build_all_dirs)
.if ${BUILD_DIRDEPS_CACHE} == "yes" .if ${BUILD_DIRDEPS_CACHE} == "yes"
-# guard against _build_all_dirs being too big for a single command line+x!= echo; { echo; echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; } >&3
-# first get list of dirs that need _DIRDEP_USE+# guard against _new_dirdeps being too big for a single command line
-# then export that and _build_all_dirs
_new_dirdeps := ${_build_all_dirs:@x@${target($x):?:$x}@} _new_dirdeps := ${_build_all_dirs:@x@${target($x):?:$x}@}
-.export _new_dirdeps _build_all_dirs+.export _build_xtra_dirs _new_dirdeps
-x!= echo; { echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \
- echo "dirdeps: \\"; \
- for x in $$_build_all_dirs; do echo " $$x \\"; done; echo; \
- for x in $$_new_dirdeps; do echo "$$x: _DIRDEP_USE"; done; echo; } >&3
.if !empty(DEP_EXPORT_VARS) .if !empty(DEP_EXPORT_VARS)
# Discouraged, but there are always exceptions. # Discouraged, but there are always exceptions.
# Handle it here rather than explain how. # Handle it here rather than explain how.
-x!= { echo; ${DEP_EXPORT_VARS:@v@echo '$v=${$v}';@} echo '.export ${DEP_EXPORT_VARS}'; echo; } >&3; echo+x!= echo; { echo; ${DEP_EXPORT_VARS:@v@echo '$v=${$v}';@} echo '.export ${DEP_EXPORT_VARS}'; echo; } >&3
.endif .endif
.else .else
# this makes it all happen # this makes it all happen
@@ -673,6 +684,10 @@ DEP_EXPORT_VARS=
# this builds the dependency graph # this builds the dependency graph
.for m in ${_machines} .for m in ${_machines}
+.if ${BUILD_DIRDEPS_CACHE} == "yes" && !empty(_build_dirs)
+x!= echo; { echo; echo 'DIRDEPS.${_this_dir}.$m = \'; } >&3
+_cache_deps =
+.endif
# it would be nice to do :N${.TARGET} # it would be nice to do :N${.TARGET}
.if !empty(__qual_depdirs) .if !empty(__qual_depdirs)
.for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m} .for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m}
@@ -680,10 +695,7 @@ DEP_EXPORT_VARS=
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q} .info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q}
.endif .endif
.if ${BUILD_DIRDEPS_CACHE} == "yes" .if ${BUILD_DIRDEPS_CACHE} == "yes"
-_cache_deps := ${_build_dirs:M*.$q}+_cache_deps += ${_build_dirs:M*.$q}
-.export _cache_deps
-x!= echo; { echo "${_this_dir}.$m: \\"; \
- for x in $$_cache_deps; do echo " $$x \\"; done; echo; } >&3
.else .else
${_this_dir}.$m: ${_build_dirs:M*.$q} ${_this_dir}.$m: ${_build_dirs:M*.$q}
.endif .endif
@@ -693,10 +705,17 @@ ${_this_dir}.$m: ${_build_dirs:M*.$q}
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m} .info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m}
.endif .endif
.if ${BUILD_DIRDEPS_CACHE} == "yes" .if ${BUILD_DIRDEPS_CACHE} == "yes"
-_cache_deps := ${_build_dirs:M*.$m:N${_this_dir}.$m}+.if !empty(_build_dirs)
+_cache_deps += ${_build_dirs:M*.$m:N${_this_dir}.$m}
+.if !empty(_cache_deps)
.export _cache_deps .export _cache_deps
-x!= echo; { echo "${_this_dir}.$m: \\"; \+x!= echo; for x in $$_cache_deps; do echo " $$x \\"; done >&3
- for x in $$_cache_deps; do echo " $$x \\"; done; echo; } >&3+.endif
+x!= echo; { echo; echo '${_this_dir}.$m: $${DIRDEPS.${_this_dir}.$m}'; \
+ echo; echo 'dirdeps: ${_this_dir}.$m \'; \
+ for x in $$_build_xtra_dirs; do echo " $$x \\"; done; \
+ echo; for x in $$_new_dirdeps; do echo "$$x: _DIRDEP_USE"; done; } >&3
+.endif
.else .else
${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m} ${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
.endif .endif
@@ -766,6 +785,27 @@ _DEP_RELDIR := ${RELDIR}
# This is a final opportunity to add/hook global rules. # This is a final opportunity to add/hook global rules.
.-include <local.dirdeps-build.mk> .-include <local.dirdeps-build.mk>
+# skip _reldir_{finish,failed} if not included from Makefile.depend*
+# or not in meta mode
+.if !defined(WITHOUT_META_STATS) && ${.INCLUDEDFROMFILE:U:M${.MAKE.DEPENDFILE_PREFIX}*} != "" && ${.MAKE.MODE:Mmeta} != ""
+
+meta_stats= meta=${empty(.MAKE.META.FILES):?0:${.MAKE.META.FILES:[#]}} \
+ created=${empty(.MAKE.META.CREATED):?0:${.MAKE.META.CREATED:[#]}}
+
+.if !target(_reldir_finish)
+.END: _reldir_finish
+_reldir_finish: .NOMETA
+ @echo "${TRACER}Finished ${RELDIR}.${TARGET_SPEC} seconds=$$(( ${now_utc} - ${start_utc} )) ${meta_stats}"
+.endif
+
+.if !target(_reldir_failed)
+.ERROR: _reldir_failed
+_reldir_failed: .NOMETA
+ @echo "${TRACER}Failed ${RELDIR}.${TARGET_SPEC} seconds=$$(( ${now_utc} - ${start_utc} )) ${meta_stats}"
+.endif
+
+.endif
+
# pickup local dependencies # pickup local dependencies
.if ${MAKE_VERSION} < 20160220 .if ${MAKE_VERSION} < 20160220
.-include <.depend> .-include <.depend>
share/mk/gendirdeps.mk
@@ -1,18 +1,19 @@
# $FreeBSD$ # $FreeBSD$
-# $Id: gendirdeps.mk,v 1.41 2019/11/21 23:50:40 sjg Exp $+# $Id: gendirdeps.mk,v 1.46 2020/08/19 17:51:53 sjg Exp $
-# Copyright (c) 2010-2013, Juniper Networks, Inc.+# Copyright (c) 2011-2020, Simon J. Gerraty
+# Copyright (c) 2010-2018, Juniper Networks, Inc.
# All rights reserved. # All rights reserved.
-# +#
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions +# modification, are permitted provided that the following conditions
-# are met: +# are met:
# 1. Redistributions of source code must retain the above copyright # 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer. +# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright # 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the # notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution. +# documentation and/or other materials provided with the distribution.
-# +#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -23,7 +24,7 @@
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# #
# This makefile [re]generates ${.MAKE.DEPENDFILE} # This makefile [re]generates ${.MAKE.DEPENDFILE}
@@ -51,7 +52,7 @@ all:
_CURDIR ?= ${.CURDIR} _CURDIR ?= ${.CURDIR}
_OBJDIR ?= ${.OBJDIR} _OBJDIR ?= ${.OBJDIR}
_OBJTOP ?= ${OBJTOP} _OBJTOP ?= ${OBJTOP}
-_OBJROOT ?= ${OBJROOT:U${_OBJTOP}}+_OBJROOT ?= ${OBJROOT:U${_OBJTOP:H}}
.if ${_OBJROOT:M*/} .if ${_OBJROOT:M*/}
_slash=/ _slash=/
.else .else
@@ -104,7 +105,7 @@ GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_DIR_VARS:@v@S,${$v},_{${v}},@}
GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u} GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u}
.endif .endif
-# this (*should* be set in meta.sys.mk) +# this (*should* be set in meta.sys.mk)
# is the script that extracts what we want. # is the script that extracts what we want.
META2DEPS ?= ${.PARSEDIR}/meta2deps.sh META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
META2DEPS := ${META2DEPS} META2DEPS := ${META2DEPS}
@@ -122,7 +123,7 @@ _py_d =
.if ${META2DEPS:E} == "py" .if ${META2DEPS:E} == "py"
# we can afford to do this all the time. # we can afford to do this all the time.
DPDEPS ?= no DPDEPS ?= no
-META2DEPS_CMD = ${_time} ${PYTHON} ${META2DEPS} ${_py_d} +META2DEPS_CMD = ${_time} ${PYTHON} ${META2DEPS} ${_py_d}
.if ${DPDEPS:tl} != "no" .if ${DPDEPS:tl} != "no"
META2DEPS_CMD += -D ${DPDEPS} META2DEPS_CMD += -D ${DPDEPS}
.endif .endif
@@ -155,8 +156,8 @@ M2D_OBJROOTS += ${STAGE_ROOT}
# and tell it not to add machine qualifiers # and tell it not to add machine qualifiers
META2DEPS_ARGS += MACHINE=none META2DEPS_ARGS += MACHINE=none
.endif .endif
-.if defined(SB_BACKING_SB) +.if defined(SB_BACKING_SB)
-META2DEPS_CMD += -S ${SB_BACKING_SB}/src +META2DEPS_CMD += -S ${SB_BACKING_SB}/src
M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX} M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX}
.endif .endif
@@ -177,7 +178,7 @@ _meta_files := ${META_FILES:N\*.meta:O:u}
# assume a big list # assume a big list
_meta_files_arg= @meta.list _meta_files_arg= @meta.list
.if empty(_meta_files) && ${META_FILES:M\*.meta} != "" .if empty(_meta_files) && ${META_FILES:M\*.meta} != ""
-# XXX this should be considered a bad idea, +# XXX this should be considered a bad idea,
# since we cannot ignore stale .meta # since we cannot ignore stale .meta
x != cd ${_OBJDIR} && find . -name '*.meta' -print -o \( -type d ! -name . -prune \) | sed 's,^./,,' > meta.list; echo x != cd ${_OBJDIR} && find . -name '*.meta' -print -o \( -type d ! -name . -prune \) | sed 's,^./,,' > meta.list; echo
.elif ${_meta_files:[#]} > 500 .elif ${_meta_files:[#]} > 500
@@ -234,10 +235,10 @@ dir_list += ${ddeps}
# DIRDEPS represent things that had to have been built first # DIRDEPS represent things that had to have been built first
# so they should all be undir OBJTOP. # so they should all be undir OBJTOP.
-# Note that ${_OBJTOP}/bsd/include/machine will get reported +# Note that ${_OBJTOP}/bsd/include/machine will get reported
# to us as $SRCTOP/bsd/sys/$MACHINE_ARCH/include meaning we # to us as $SRCTOP/bsd/sys/$MACHINE_ARCH/include meaning we
# will want to visit bsd/include # will want to visit bsd/include
-# so we add +# so we add
# ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:} # ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:}
# to GENDIRDEPS_DIR_LIST_XTRAS # to GENDIRDEPS_DIR_LIST_XTRAS
_objtops = ${OBJTOP} ${_OBJTOP} ${_objtop} _objtops = ${OBJTOP} ${_OBJTOP} ${_objtop}
@@ -272,11 +273,11 @@ DIRDEPS = \
# We only consider things below $RELDIR/ if they have a makefile. # We only consider things below $RELDIR/ if they have a makefile.
# This is the same test that _DIRDEP_USE applies. # This is the same test that _DIRDEP_USE applies.
-# We have do a double test with dirdep_list as it _may_ contain +# We have do a double test with dirdep_list as it _may_ contain
# qualified dirs - if we got anything from a stage dir. # qualified dirs - if we got anything from a stage dir.
# qualdir_list we know are all qualified. # qualdir_list we know are all qualified.
# It would be nice do peform this check for all of DIRDEPS, # It would be nice do peform this check for all of DIRDEPS,
-# but we cannot assume that all of the tree is present, +# but we cannot assume that all of the tree is present,
# in fact we can only assume that RELDIR is. # in fact we can only assume that RELDIR is.
DIRDEPS += \ DIRDEPS += \
${dirdep_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/$d/$m):?$d:${exists(${SRCTOP}/${d:R}/$m):?$d:}}@}@} \ ${dirdep_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/$d/$m):?$d:${exists(${SRCTOP}/${d:R}/$m):?$d:}}@}@} \
@@ -309,7 +310,7 @@ SRC_DIRDEPS = \
SRC_DIRDEPS := ${SRC_DIRDEPS:${GENDIRDEPS_SRC_FILTER:UN/*:ts:}:C,//+,/,g:O:u} SRC_DIRDEPS := ${SRC_DIRDEPS:${GENDIRDEPS_SRC_FILTER:UN/*:ts:}:C,//+,/,g:O:u}
# if you want to capture SRC_DIRDEPS in .MAKE.DEPENDFILE put # if you want to capture SRC_DIRDEPS in .MAKE.DEPENDFILE put
-# SRC_DIRDEPS_FILE = ${_DEPENDFILE} +# SRC_DIRDEPS_FILE = ${_DEPENDFILE}
# in local.gendirdeps.mk # in local.gendirdeps.mk
.if ${SRC_DIRDEPS_FILE:Uno:tl} != "no" .if ${SRC_DIRDEPS_FILE:Uno:tl} != "no"
ECHO_SRC_DIRDEPS = echo 'SRC_DIRDEPS = \'; echo '${SRC_DIRDEPS:@d@ $d \\${.newline}@}'; echo; ECHO_SRC_DIRDEPS = echo 'SRC_DIRDEPS = \'; echo '${SRC_DIRDEPS:@d@ $d \\${.newline}@}'; echo;
@@ -324,7 +325,7 @@ ${SRC_DIRDEPS_FILE}: ${META_FILES} ${_this} ${META2DEPS}
.endif .endif
.endif .endif
.endif .endif
-_include_src_dirdeps ?= +_include_src_dirdeps ?=
all: ${_DEPENDFILE} all: ${_DEPENDFILE}
@@ -339,6 +340,8 @@ CAT_DEPEND ?= .depend
.PHONY: ${_DEPENDFILE} .PHONY: ${_DEPENDFILE}
.endif .endif
+LOCAL_DEPENDS_GUARD ?= _{.MAKE.LEVEL} > 0
+
# 'cat .depend' should suffice, but if we are mixing build modes # 'cat .depend' should suffice, but if we are mixing build modes
# .depend may contain things we don't want. # .depend may contain things we don't want.
# The sed command at the end of the stream, allows for the filters # The sed command at the end of the stream, allows for the filters
@@ -350,7 +353,7 @@ ${_DEPENDFILE}: .NOMETA ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):
${_include_src_dirdeps} \ ${_include_src_dirdeps} \
echo '.include <dirdeps.mk>'; \ echo '.include <dirdeps.mk>'; \
echo; \ echo; \
- echo '.if $${DEP_RELDIR} == $${_DEP_RELDIR}'; \+ echo '.if ${LOCAL_DEPENDS_GUARD}'; \
echo '# local dependencies - needed for -jN in clean tree'; \ echo '# local dependencies - needed for -jN in clean tree'; \
[ -s ${CAT_DEPEND} ] && { grep : ${CAT_DEPEND} | grep -v '[/\\]'; }; \ [ -s ${CAT_DEPEND} ] && { grep : ${CAT_DEPEND} | grep -v '[/\\]'; }; \
echo '.endif' ) | sed 's,_\([{(]\),$$\1,g' > $@.new${.MAKE.PID} echo '.endif' ) | sed 's,_\([{(]\),$$\1,g' > $@.new${.MAKE.PID}
share/mk/local.autodep.mk
@@ -8,6 +8,9 @@ UPDATE_DEPENDFILE= no
.endif .endif
.endif .endif
+NOSSPPICO?= .nossppico
+OBJ_EXTENSIONS+= ${NOSSPPICO}
+
CFLAGS+= ${CFLAGS_LAST} CFLAGS+= ${CFLAGS_LAST}
CXXFLAGS+= ${CXXFLAGS_LAST} CXXFLAGS+= ${CXXFLAGS_LAST}
LDFLAGS+= ${LDFLAGS_LAST} LDFLAGS+= ${LDFLAGS_LAST}
share/mk/local.dirdeps.mk
@@ -179,8 +179,6 @@ DIRDEPS+= usr.bin/yacc.host
.endif .endif
_DPADD= ${DPADD} ${_PROGS_DPADD} _DPADD= ${DPADD} ${_PROGS_DPADD}
.if !empty(_DPADD) .if !empty(_DPADD)
-# Taken from meta.autodep.mk (where it only does something with
-# BUILD_AT_LEVEL0, which we don't use).
# This only works for DPADD with full OBJ/SRC paths, which is mostly just # This only works for DPADD with full OBJ/SRC paths, which is mostly just
# _INTERNALLIBS. # _INTERNALLIBS.
_DP_DIRDEPS= \ _DP_DIRDEPS= \
share/mk/local.gendirdeps.mk
@@ -67,3 +67,6 @@ GENDIRDEPS_FILTER_VARS+= \
GENDIRDEPS_FILTER+= ${GENDIRDEPS_FILTER_DIR_VARS:@v@S,${$v},_{${v}},@} GENDIRDEPS_FILTER+= ${GENDIRDEPS_FILTER_DIR_VARS:@v@S,${$v},_{${v}},@}
GENDIRDEPS_FILTER+= ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u} GENDIRDEPS_FILTER+= ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u}
+
+# avoid churn for now
+LOCAL_DEPENDS_GUARD= _{DEP_RELDIR} == _{_DEP_RELDIR}
share/mk/local.meta.sys.mk
@@ -99,13 +99,10 @@ OBJTOP := ${HOST_OBJTOP}
.if ${.MAKE.LEVEL} == 0 || empty(PYTHON) .if ${.MAKE.LEVEL} == 0 || empty(PYTHON)
PYTHON ?= /usr/local/bin/python PYTHON ?= /usr/local/bin/python
.export PYTHON .export PYTHON
-# this works best if share/mk is ready for it.
-BUILD_AT_LEVEL0= no
# _SKIP_BUILD is not 100% as it requires wrapping all 'all:' targets to avoid # _SKIP_BUILD is not 100% as it requires wrapping all 'all:' targets to avoid
# building in MAKELEVEL0. Just prohibit 'all' entirely in this case to avoid # building in MAKELEVEL0. Just prohibit 'all' entirely in this case to avoid
# problems. # problems.
-.if ${MK_DIRDEPS_BUILD} == "yes" && \+.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} == 0
- ${.MAKE.LEVEL} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
.MAIN: dirdeps .MAIN: dirdeps
.if make(all) .if make(all)
.error DIRDEPS_BUILD: Please run '${MAKE}' instead of '${MAKE} all'. .error DIRDEPS_BUILD: Please run '${MAKE}' instead of '${MAKE} all'.
share/mk/meta.autodep.mk
@@ -1,5 +1,5 @@
# $FreeBSD$ # $FreeBSD$
-# $Id: meta.autodep.mk,v 1.50 2018/06/08 01:25:31 sjg Exp $+# $Id: meta.autodep.mk,v 1.53 2020/11/08 05:47:56 sjg Exp $
# #
# @(#) Copyright (c) 2010, Simon J. Gerraty # @(#) Copyright (c) 2010, Simon J. Gerraty
@@ -22,11 +22,10 @@ __${_this}__: .NOTMAIN
.-include <local.autodep.mk> .-include <local.autodep.mk>
PICO?= .pico PICO?= .pico
-NOSSPPICO?= .nossppico
.if defined(SRCS) .if defined(SRCS)
# it would be nice to be able to query .SUFFIXES # it would be nice to be able to query .SUFFIXES
-OBJ_EXTENSIONS+= .o .po .lo ${PICO} ${NOSSPPICO}+OBJ_EXTENSIONS+= .o .po .lo ${PICO}
# explicit dependencies help short-circuit .SUFFIX searches # explicit dependencies help short-circuit .SUFFIX searches
SRCS_DEP_FILTER+= N*.[hly] SRCS_DEP_FILTER+= N*.[hly]
@@ -59,7 +58,7 @@ _OBJTOP ?= ${OBJTOP}
_OBJROOT ?= ${OBJROOT:U${_OBJTOP}} _OBJROOT ?= ${OBJROOT:U${_OBJTOP}}
_DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T} _DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T}
-.if ${.MAKE.LEVEL} > 0 || ${BUILD_AT_LEVEL0:Uyes:tl} == "yes"+.if ${.MAKE.LEVEL} > 0
# do not allow auto update if we ever built this dir without filemon # do not allow auto update if we ever built this dir without filemon
NO_FILEMON_COOKIE = .nofilemon NO_FILEMON_COOKIE = .nofilemon
CLEANFILES += ${NO_FILEMON_COOKIE} CLEANFILES += ${NO_FILEMON_COOKIE}
@@ -75,10 +74,8 @@ UPDATE_DEPENDFILE = NO
.endif .endif
.if ${.MAKE.LEVEL} == 0 .if ${.MAKE.LEVEL} == 0
-.if ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
UPDATE_DEPENDFILE = NO UPDATE_DEPENDFILE = NO
.endif .endif
-.endif
.if !exists(${_DEPENDFILE}) .if !exists(${_DEPENDFILE})
_bootstrap_dirdeps = yes _bootstrap_dirdeps = yes
.endif .endif
@@ -182,7 +179,8 @@ DEPEND_SUFFIXES += .c .h .cpp .hpp .cxx .hxx .cc .hh
@case "${.MAKE.META.FILES:T:M*.po.*}" in \ @case "${.MAKE.META.FILES:T:M*.po.*}" in \
*.po.*) mv $@.${.MAKE.PID} $@;; \ *.po.*) mv $@.${.MAKE.PID} $@;; \
*) { cat $@.${.MAKE.PID}; \ *) { cat $@.${.MAKE.PID}; \
- sed 's,\${NOSSPPICO}:,.o:,;s,\${PICO}:,.o:,;s,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \+ sed ${OBJ_EXTENSIONS:N.o:N.po:@o@-e 's,\$o:,.o:,'@} \
+ -e 's,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \
rm -f $@.${.MAKE.PID};; \ rm -f $@.${.MAKE.PID};; \
esac esac
.else .else
@@ -285,9 +283,7 @@ ${_DEPENDFILE}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} $${.MAKE.MET
.endif .endif
.if ${_bootstrap_dirdeps} == "yes" .if ${_bootstrap_dirdeps} == "yes"
-.if ${BUILD_AT_LEVEL0:Uno} == "no"
DIRDEPS+= ${RELDIR}.${TARGET_SPEC:U${MACHINE}} DIRDEPS+= ${RELDIR}.${TARGET_SPEC:U${MACHINE}}
-.endif
# make sure this is included at least once # make sure this is included at least once
.include <dirdeps.mk> .include <dirdeps.mk>
.else .else
@@ -314,7 +310,7 @@ _reldir_finish: .NOMETA
_reldir_failed: .NOMETA _reldir_failed: .NOMETA
@echo "${TIME_STAMP} Failed ${RELDIR}.${TARGET_SPEC} seconds=$$(( ${now_utc} - ${start_utc} )) ${meta_stats}" @echo "${TIME_STAMP} Failed ${RELDIR}.${TARGET_SPEC} seconds=$$(( ${now_utc} - ${start_utc} )) ${meta_stats}"
-.if defined(WITH_META_STATS) && ${.MAKE.LEVEL} > 0+.if !defined(WITHOUT_META_STATS) && ${.MAKE.LEVEL} > 0
.END: _reldir_finish .END: _reldir_finish
.ERROR: _reldir_failed .ERROR: _reldir_failed
.endif .endif
share/mk/meta.stage.mk
@@ -1,15 +1,15 @@
# $FreeBSD$ # $FreeBSD$
-# $Id: meta.stage.mk,v 1.55 2017/10/27 01:17:09 sjg Exp $+# $Id: meta.stage.mk,v 1.60 2020/08/19 17:51:53 sjg Exp $
# #
# @(#) Copyright (c) 2011-2017, Simon J. Gerraty # @(#) Copyright (c) 2011-2017, Simon J. Gerraty
# #
# This file is provided in the hope that it will # This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY. # be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise # Permission to copy, redistribute or otherwise
-# use this file is hereby granted provided that +# use this file is hereby granted provided that
# the above copyright notice and this notice are # the above copyright notice and this notice are
-# left intact. +# left intact.
-# +#
# Please send copies of changes and bug-fixes to: # Please send copies of changes and bug-fixes to:
# sjg@crufty.net # sjg@crufty.net
# #
@@ -19,9 +19,11 @@
.if !target(__${.PARSEFILE}__) .if !target(__${.PARSEFILE}__)
# the guard target is defined later # the guard target is defined later
+.-include <local.meta.stage.mk>
+
.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != "" .if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != ""
# this is generally safer anyway # this is generally safer anyway
-_dirdep ?= ${RELDIR}.${MACHINE}+_dirdep ?= ${RELDIR}.${TARGET_SPEC:U${MACHINE}}
.else .else
_dirdep ?= ${RELDIR} _dirdep ?= ${RELDIR}
.endif .endif
@@ -68,7 +70,7 @@ LN_CP_SCRIPT = LnCp() { \
# a warning is handy when bootstapping different options. # a warning is handy when bootstapping different options.
STAGE_CONFLICT?= ERROR STAGE_CONFLICT?= ERROR
.if ${STAGE_CONFLICT:tl} == "error" .if ${STAGE_CONFLICT:tl} == "error"
-STAGE_CONFLICT_ACTION= exit 1;+STAGE_CONFLICT_ACTION= exit 1
.else .else
STAGE_CONFLICT_ACTION= STAGE_CONFLICT_ACTION=
.endif .endif
@@ -79,8 +81,10 @@ STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \
t=$$1; \ t=$$1; \
if [ -s $$t.dirdep ]; then \ if [ -s $$t.dirdep ]; then \
cmp -s .dirdep $$t.dirdep && return; \ cmp -s .dirdep $$t.dirdep && return; \
- echo "${STAGE_CONFLICT}: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \+ x=`cat $$t.dirdep`; \
- ${STAGE_CONFLICT_ACTION} \+ case "${RELDIR}:${_dirdep}" in $${x%.*}:$${x}*) ;; \
+ *) echo "${STAGE_CONFLICT}: $$t installed by $$x not ${_dirdep}" >&2; \
+ ${STAGE_CONFLICT_ACTION} ;; esac; \
fi; \ fi; \
LnCp .dirdep $$t.dirdep || exit 1; } LnCp .dirdep $$t.dirdep || exit 1; }
@@ -142,7 +146,7 @@ _STAGE_AS_BASENAME_USE: .USE .dirdep ${.TARGET:T}
.if !empty(STAGE_INCSDIR) .if !empty(STAGE_INCSDIR)
.if !empty(STAGE_INCS) .if !empty(STAGE_INCS)
-stage_incs: ${STAGE_INCS}+stage_incs: ${STAGE_INCS:N*\**}
.endif .endif
.if target(stage_incs) || !empty(.ALLTARGETS:Mstage_includes) .if target(stage_incs) || !empty(.ALLTARGETS:Mstage_includes)
STAGE_TARGETS += stage_incs STAGE_TARGETS += stage_incs
@@ -157,7 +161,7 @@ stage_incs: .dirdep
.if !empty(STAGE_LIBDIR) .if !empty(STAGE_LIBDIR)
.if !empty(STAGE_LIBS) .if !empty(STAGE_LIBS)
-stage_libs: ${STAGE_LIBS}+stage_libs: ${STAGE_LIBS:N*\**}
.endif .endif
.if target(stage_libs) .if target(stage_libs)
STAGE_TARGETS += stage_libs STAGE_TARGETS += stage_libs
@@ -192,7 +196,7 @@ CLEANFILES += ${STAGE_SETS:@s@stage*$s@}
# some makefiles need to populate multiple directories # some makefiles need to populate multiple directories
.for s in ${STAGE_SETS:O:u} .for s in ${STAGE_SETS:O:u}
.if !empty(STAGE_FILES.$s) .if !empty(STAGE_FILES.$s)
-stage_files.$s: ${STAGE_FILES.$s}+stage_files.$s: ${STAGE_FILES.$s:N*\**}
.endif .endif
.if target(stage_files.$s) || target(stage_files${s:S,^,.,:N._default}) .if target(stage_files.$s) || target(stage_files${s:S,^,.,:N._default})
STAGE_TARGETS += stage_files STAGE_TARGETS += stage_files
@@ -206,7 +210,7 @@ stage_files.$s: .dirdep
STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*} STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*}
stage_files: .dirdep stage_files: .dirdep
.endif .endif
- @${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s}+ @${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s:O}
@touch $@ @touch $@
.endif .endif
.endif .endif
@@ -263,7 +267,7 @@ CLEANFILES += ${STAGE_AS_SETS:@s@stage*$s@}
# both operations happen together # both operations happen together
.for s in ${STAGE_AS_SETS:O:u} .for s in ${STAGE_AS_SETS:O:u}
.if !empty(STAGE_AS.$s) .if !empty(STAGE_AS.$s)
-stage_as.$s: ${STAGE_AS.$s}+stage_as.$s: ${STAGE_AS.$s:N*\**}
.endif .endif
.if target(stage_as.$s) .if target(stage_as.$s)
STAGE_TARGETS += stage_as STAGE_TARGETS += stage_as
@@ -272,13 +276,13 @@ STAGE_AS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*}
.stage_as.$s: .stage_as.$s:
stage_as: stage_as.$s stage_as: stage_as.$s
stage_as.$s: .dirdep stage_as.$s: .dirdep
- @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@}+ @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:O:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@}
@touch $@ @touch $@
.endif .endif
.endif .endif
.if !empty(STAGE_AS_AND_SYMLINK.$s) .if !empty(STAGE_AS_AND_SYMLINK.$s)
-stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s}+stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s:N*\**}
.endif .endif
.if target(stage_as_and_symlink.$s) .if target(stage_as_and_symlink.$s)
STAGE_TARGETS += stage_as_and_symlink STAGE_TARGETS += stage_as_and_symlink
@@ -287,8 +291,8 @@ STAGE_AS_AND_SYMLINK.$s ?= ${.ALLSRC:N.dirdep:Nstage_*}
.stage_as_and_symlink.$s: .stage_as_and_symlink.$s:
stage_as_and_symlink: stage_as_and_symlink.$s stage_as_and_symlink: stage_as_and_symlink.$s
stage_as_and_symlink.$s: .dirdep stage_as_and_symlink.$s: .dirdep
- @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@}+ @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:O:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@}
- @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:@f@${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}} $f@}+ @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:O:@f@${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}} $f@}
@touch $@ @touch $@
.endif .endif
.endif .endif
share/mk/meta.subdir.mk
@@ -1,5 +1,5 @@
# $FreeBSD$ # $FreeBSD$
-# $Id: meta.subdir.mk,v 1.11 2015/11/24 22:26:51 sjg Exp $+# $Id: meta.subdir.mk,v 1.12 2020/08/19 17:51:53 sjg Exp $
# #
# @(#) Copyright (c) 2010, Simon J. Gerraty # @(#) Copyright (c) 2010, Simon J. Gerraty
@@ -7,10 +7,10 @@
# This file is provided in the hope that it will # This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY. # be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise # Permission to copy, redistribute or otherwise
-# use this file is hereby granted provided that +# use this file is hereby granted provided that
# the above copyright notice and this notice are # the above copyright notice and this notice are
-# left intact. +# left intact.
-# +#
# Please send copies of changes and bug-fixes to: # Please send copies of changes and bug-fixes to:
# sjg@crufty.net # sjg@crufty.net
# #
@@ -33,7 +33,7 @@ DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@}
.include <meta.autodep.mk> .include <meta.autodep.mk>
.else .else
# this is the cunning bit # this is the cunning bit
-# actually it is probably a bit risky +# actually it is probably a bit risky
# since we may pickup subdirs which are not relevant # since we may pickup subdirs which are not relevant
# the alternative is a walk through the tree though # the alternative is a walk through the tree though
# which is difficult without a sub-make. # which is difficult without a sub-make.
share/mk/meta.sys.mk
@@ -1,16 +1,16 @@
# $FreeBSD$ # $FreeBSD$
-# $Id: meta.sys.mk,v 1.34 2019/01/24 19:36:25 sjg Exp $+# $Id: meta.sys.mk,v 1.38 2020/08/19 17:51:53 sjg Exp $
# #
-# @(#) Copyright (c) 2010, Simon J. Gerraty+# @(#) Copyright (c) 2010-2020, Simon J. Gerraty
# #
# This file is provided in the hope that it will # This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY. # be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise # Permission to copy, redistribute or otherwise
-# use this file is hereby granted provided that +# use this file is hereby granted provided that
# the above copyright notice and this notice are # the above copyright notice and this notice are
-# left intact. +# left intact.
-# +#
# Please send copies of changes and bug-fixes to: # Please send copies of changes and bug-fixes to:
# sjg@crufty.net # sjg@crufty.net
# #
@@ -129,9 +129,11 @@ META_NOECHO= :
# ignore mtime of shell # ignore mtime of shell
# and mtime of makefiles does not matter in meta mode # and mtime of makefiles does not matter in meta mode
.MAKE.META.IGNORE_PATHS += \ .MAKE.META.IGNORE_PATHS += \
- ${MAKEFILE} \+ ${MAKEFILE} \
- ${SHELL} \+ ${MAKE_SHELL} \
- ${SYS_MK_DIR}+ ${SHELL} \
+ ${SYS_MK_DIR} \
+
.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" .if ${UPDATE_DEPENDFILE:Uyes:tl} != "no"
.if ${.MAKEFLAGS:Uno:M-k} != "" .if ${.MAKEFLAGS:Uno:M-k} != ""
@@ -154,12 +156,6 @@ dirdeps:
# the first .MAIN: is what counts # the first .MAIN: is what counts
# by default dirdeps is all we want at level0 # by default dirdeps is all we want at level0
.MAIN: dirdeps .MAIN: dirdeps
-# tell dirdeps.mk what we want
-BUILD_AT_LEVEL0 = no
-.endif
-.if ${.TARGETS:Nall} == ""
-# it works best if we do everything via sub-makes
-BUILD_AT_LEVEL0 ?= no
.endif .endif
.endif .endif
share/mk/meta2deps.py
@@ -25,7 +25,7 @@ We only pay attention to a subset of the information in the
'W' files opened for write or read-write, 'W' files opened for write or read-write,
for filemon V3 and earlier. for filemon V3 and earlier.
- +
'E' files executed. 'E' files executed.
'L' files linked 'L' files linked
@@ -38,19 +38,20 @@ We only pay attention to a subset of the information in the
""" """
RCSid: RCSid:
$FreeBSD$ $FreeBSD$
- $Id: meta2deps.py,v 1.27 2017/05/24 00:04:04 sjg Exp $+ $Id: meta2deps.py,v 1.34 2020/10/02 03:11:17 sjg Exp $
- Copyright (c) 2011-2013, Juniper Networks, Inc.+ Copyright (c) 2011-2020, Simon J. Gerraty
+ Copyright (c) 2011-2017, Juniper Networks, Inc.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions + modification, are permitted provided that the following conditions
- are met: + are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution. + documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@@ -62,8 +63,8 @@ RCSid:
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- +
""" """
import os, re, sys import os, re, sys
@@ -81,7 +82,11 @@ def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
if path.endswith('/.'): if path.endswith('/.'):
path = path[0:-2] path = path[0:-2]
if len(path) > 0 and path[0] == '/': if len(path) > 0 and path[0] == '/':
- return path+ if os.path.exists(path):
+ return path
+ if debug > 2:
+ print("skipping non-existent:", path, file=debug_out)
+ return None
if path == '.': if path == '.':
return cwd return cwd
if path.startswith('./'): if path.startswith('./'):
@@ -139,6 +144,8 @@ def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
rpath = resolve(path, cwd, last_dir, debug, debug_out) rpath = resolve(path, cwd, last_dir, debug, debug_out)
if rpath: if rpath:
path = rpath path = rpath
+ elif len(path) > 0 and path[0] == '/':
+ return None
if (path.find('/') < 0 or if (path.find('/') < 0 or
path.find('./') > 0 or path.find('./') > 0 or
path.endswith('/..')): path.endswith('/..')):
@@ -158,7 +165,7 @@ def sort_unique(list, cmp=None, key=None, reverse=False):
def add_trims(x): def add_trims(x):
return ['/' + x + '/', return ['/' + x + '/',
- '/' + x, + '/' + x,
x + '/', x + '/',
x] x]
@@ -175,7 +182,7 @@ class MetaFile:
obj_deps = [] obj_deps = []
src_deps = [] src_deps = []
file_deps = [] file_deps = []
- +
def __init__(self, name, conf={}): def __init__(self, name, conf={}):
"""if name is set we will parse it now. """if name is set we will parse it now.
conf can have the follwing keys: conf can have the follwing keys:
@@ -192,7 +199,7 @@ class MetaFile:
TARGET_SPEC TARGET_SPEC
Sometimes MACHINE isn't enough. Sometimes MACHINE isn't enough.
- +
HOST_TARGET HOST_TARGET
when we build for the pseudo machine 'host' when we build for the pseudo machine 'host'
the object tree uses HOST_TARGET rather than MACHINE. the object tree uses HOST_TARGET rather than MACHINE.
@@ -216,7 +223,7 @@ class MetaFile:
debug_out open file to send debug output to (sys.stderr) debug_out open file to send debug output to (sys.stderr)
""" """
- +
self.name = name self.name = name
self.debug = getv(conf, 'debug', 0) self.debug = getv(conf, 'debug', 0)
self.debug_out = getv(conf, 'debug_out', sys.stderr) self.debug_out = getv(conf, 'debug_out', sys.stderr)
@@ -304,11 +311,11 @@ class MetaFile:
self.obj_deps = [] self.obj_deps = []
self.src_deps = [] self.src_deps = []
self.file_deps = [] self.file_deps = []
- +
def dirdeps(self, sep='\n'): def dirdeps(self, sep='\n'):
"""return DIRDEPS""" """return DIRDEPS"""
return sep.strip() + sep.join(self.obj_deps) return sep.strip() + sep.join(self.obj_deps)
- +
def src_dirdeps(self, sep='\n'): def src_dirdeps(self, sep='\n'):
"""return SRC_DIRDEPS""" """return SRC_DIRDEPS"""
return sep.strip() + sep.join(self.src_deps) return sep.strip() + sep.join(self.src_deps)
@@ -327,7 +334,7 @@ class MetaFile:
def seenit(self, dir): def seenit(self, dir):
"""rememer that we have seen dir.""" """rememer that we have seen dir."""
self.seen[dir] = 1 self.seen[dir] = 1
- +
def add(self, list, data, clue=''): def add(self, list, data, clue=''):
"""add data to list if it isn't already there.""" """add data to list if it isn't already there."""
if data not in list: if data not in list:
@@ -386,10 +393,10 @@ class MetaFile:
# give a useful clue # give a useful clue
print('{}:{}: '.format(self.name, self.line), end=' ', file=sys.stderr) print('{}:{}: '.format(self.name, self.line), end=' ', file=sys.stderr)
raise raise
- +
def parse(self, name=None, file=None): def parse(self, name=None, file=None):
"""A meta file looks like: """A meta file looks like:
- +
# Meta data file "path" # Meta data file "path"
CMD "command-line" CMD "command-line"
CWD "cwd" CWD "cwd"
@@ -475,6 +482,10 @@ class MetaFile:
continue continue
elif w[0] == 'C': elif w[0] == 'C':
cwd = abspath(w[2], cwd, None, self.debug, self.debug_out) cwd = abspath(w[2], cwd, None, self.debug, self.debug_out)
+ if not cwd:
+ cwd = w[2]
+ if self.debug > 1:
+ print("missing cwd=", cwd, file=self.debug_out)
if cwd.endswith('/.'): if cwd.endswith('/.'):
cwd = cwd[0:-2] cwd = cwd[0:-2]
self.last_dir = pid_last_dir[pid] = cwd self.last_dir = pid_last_dir[pid] = cwd
@@ -491,13 +502,16 @@ class MetaFile:
if w[0] in 'ML': if w[0] in 'ML':
# these are special, tread src as read and # these are special, tread src as read and
# target as write # target as write
- self.parse_path(w[1].strip("'"), cwd, 'R', w)+ self.parse_path(w[2].strip("'"), cwd, 'R', w)
- self.parse_path(w[2].strip("'"), cwd, 'W', w)+ self.parse_path(w[3].strip("'"), cwd, 'W', w)
continue continue
elif w[0] in 'ERWS': elif w[0] in 'ERWS':
path = w[2] path = w[2]
+ if path == '.':
+ continue
self.parse_path(path, cwd, w[0], w) self.parse_path(path, cwd, w[0], w)
+ assert(version > 0)
if not file: if not file:
f.close() f.close()
@@ -563,7 +577,7 @@ class MetaFile:
print("ldir=", self.last_dir, file=self.debug_out) print("ldir=", self.last_dir, file=self.debug_out)
return return
- if op in 'ERW':+ if op in 'ER':
# finally, we get down to it # finally, we get down to it
if dir == self.cwd or dir == self.curdir: if dir == self.cwd or dir == self.curdir:
return return
@@ -591,13 +605,13 @@ class MetaFile:
self.seenit(w[2]) self.seenit(w[2])
self.seenit(dir) self.seenit(dir)
- +
def main(argv, klass=MetaFile, xopts='', xoptf=None): def main(argv, klass=MetaFile, xopts='', xoptf=None):
"""Simple driver for class MetaFile. """Simple driver for class MetaFile.
Usage: Usage:
script [options] [key=value ...] "meta" ... script [options] [key=value ...] "meta" ...
- +
Options and key=value pairs contribute to the Options and key=value pairs contribute to the
dictionary passed to MetaFile. dictionary passed to MetaFile.
@@ -605,7 +619,7 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
add "SRCTOP" to the "SRCTOPS" list. add "SRCTOP" to the "SRCTOPS" list.
-C "CURDIR" -C "CURDIR"
- +
-O "OBJROOT" -O "OBJROOT"
add "OBJROOT" to the "OBJROOTS" list. add "OBJROOT" to the "OBJROOTS" list.
@@ -616,7 +630,7 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
-H "HOST_TARGET" -H "HOST_TARGET"
-D "DPDEPS" -D "DPDEPS"
- +
-d bumps debug level -d bumps debug level
""" """
@@ -656,7 +670,7 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
debug = 0 debug = 0
output = True output = True
- +
opts, args = getopt.getopt(argv[1:], 'a:dS:C:O:R:m:D:H:qT:X:' + xopts) opts, args = getopt.getopt(argv[1:], 'a:dS:C:O:R:m:D:H:qT:X:' + xopts)
for o, a in opts: for o, a in opts:
if o == '-a': if o == '-a':
share/mk/meta2deps.sh
@@ -5,11 +5,11 @@
# #
# SYNOPSIS: # SYNOPSIS:
# meta2deps.sh SB="SB" "meta" ... # meta2deps.sh SB="SB" "meta" ...
-# +#
# DESCRIPTION: # DESCRIPTION:
# This script looks each "meta" file and extracts the # This script looks each "meta" file and extracts the
# information needed to deduce build and src dependencies. # information needed to deduce build and src dependencies.
-# +#
# To do this, we extract the 'CWD' record as well as all the # To do this, we extract the 'CWD' record as well as all the
# syscall traces which describe 'R'ead, 'C'hdir and 'E'xec # syscall traces which describe 'R'ead, 'C'hdir and 'E'xec
# syscalls. # syscalls.
@@ -76,20 +76,20 @@
# RCSid: # RCSid:
# $FreeBSD$ # $FreeBSD$
-# $Id: meta2deps.sh,v 1.12 2016/12/13 20:44:16 sjg Exp $+# $Id: meta2deps.sh,v 1.14 2020/10/02 03:11:17 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc. # Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved. # All rights reserved.
-# +#
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions +# modification, are permitted provided that the following conditions
-# are met: +# are met:
# 1. Redistributions of source code must retain the above copyright # 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer. +# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright # 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the # notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution. +# documentation and/or other materials provided with the distribution.
-# +#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -100,14 +100,14 @@
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
meta2src() { meta2src() {
cat /dev/null "$@" | cat /dev/null "$@" |
sed -n '/^R .*\.[chyl]$/s,^..[0-9]* ,,p' | sed -n '/^R .*\.[chyl]$/s,^..[0-9]* ,,p' |
sort -u sort -u
} }
- +
meta2dirs() { meta2dirs() {
cat /dev/null "$@" | cat /dev/null "$@" |
sed -n '/^R .*\/.*\.[a-z0-9][^\/]*$/s,^..[0-9]* \(.*\)/[^/]*$,\1,p' | sed -n '/^R .*\/.*\.[a-z0-9][^\/]*$/s,^..[0-9]* \(.*\)/[^/]*$,\1,p' |
@@ -142,6 +142,11 @@ _excludes_f() {
egrep -v "$EXCLUDES" egrep -v "$EXCLUDES"
} }
+error() {
+ echo "ERROR: $@" >&2
+ exit 1
+}
+
meta2deps() { meta2deps() {
DPDEPS= DPDEPS=
SRCTOPS=$SRCTOP SRCTOPS=$SRCTOP
@@ -168,7 +173,7 @@ meta2deps() {
case "$MACHINE" in case "$MACHINE" in
host) _ht=$HOST_TARGET;; host) _ht=$HOST_TARGET;;
esac esac
- +
for o in $OBJROOTS for o in $OBJROOTS
do do
case "$MACHINE,/$o/" in case "$MACHINE,/$o/" in
@@ -202,7 +207,7 @@ meta2deps() {
obj_re= obj_re=
add_list '|' -s '/*' src_re $SRCTOPS add_list '|' -s '/*' src_re $SRCTOPS
add_list '|' -s '*' obj_re $OBJROOTS add_list '|' -s '*' obj_re $OBJROOTS
- +
[ -z "$RELDIR" ] && unset DPDEPS [ -z "$RELDIR" ] && unset DPDEPS
tf=/tmp/m2d$$-$USER tf=/tmp/m2d$$-$USER
rm -f $tf.* rm -f $tf.*
@@ -235,8 +240,8 @@ meta2deps() {
;; ;;
*) cat /dev/null "$@";; *) cat /dev/null "$@";;
esac 2> /dev/null | esac 2> /dev/null |
- sed -e 's,^CWD,C C,;/^[CREFLM] /!d' -e "s,',,g" |+ sed -e 's,^CWD,C C,;/^[CREFLMV] /!d' -e "s,',,g" |
- $_excludes |+ $_excludes | ( version=no
while read op pid path junk while read op pid path junk
do do
: op=$op pid=$pid path=$path : op=$op pid=$pid path=$path
@@ -248,6 +253,12 @@ meta2deps() {
SB=`echo $CWD | sed 's,/obj.*,,'` SB=`echo $CWD | sed 's,/obj.*,,'`
fi fi
SRCTOP=${SRCTOP:-$SB/src} SRCTOP=${SRCTOP:-$SB/src}
+ case "$verion" in
+ no) ;; # ignore
+ 0) error "no filemon data";;
+ *) ;;
+ esac
+ version=0
continue continue
;; ;;
$pid,$pid) ;; $pid,$pid) ;;
@@ -262,6 +273,7 @@ meta2deps() {
esac esac
case "$op,$path" in case "$op,$path" in
+ V,*) version=$path; continue;;
W,*srcrel|*.dirdep) continue;; W,*srcrel|*.dirdep) continue;;
C,*) C,*)
case "$path" in case "$path" in
@@ -273,10 +285,10 @@ meta2deps() {
eval cwd_$pid=$cwd eval cwd_$pid=$cwd
continue continue
;; ;;
- F,*) # $path is new pid + F,*) # $path is new pid
eval cwd_$path=$cwd ldir_$path=$ldir eval cwd_$path=$cwd ldir_$path=$ldir
continue continue
- ;; + ;;
*) dir=${path%/*} *) dir=${path%/*}
case "$path" in case "$path" in
$src_re|$obj_re) ;; $src_re|$obj_re) ;;
@@ -367,6 +379,9 @@ meta2deps() {
echo $dir;; echo $dir;;
esac esac
done > $tf.dirdep done > $tf.dirdep
+ case "$version" in
+ 0) error "no filemon data";;
+ esac ) || exit 1
_nl=echo _nl=echo
for f in $tf.dirdep $tf.qual $tf.srcdep for f in $tf.dirdep $tf.qual $tf.srcdep
do do
sys/amd64/conf/GENERIC
@@ -354,6 +354,7 @@ device snd_via8233 # VIA VT8233x Audio
device mmc # MMC/SD bus device mmc # MMC/SD bus
device mmcsd # MMC/SD memory card device mmcsd # MMC/SD memory card
device sdhci # Generic PCI SD Host Controller device sdhci # Generic PCI SD Host Controller
+device rtsx # Realtek SD card reader
# VirtIO support # VirtIO support
device virtio # Generic VirtIO bus (required) device virtio # Generic VirtIO bus (required)
sys/arm/amlogic/aml8726/aml8726_ccm.c→/dev/null
@@ -1,228 +0,0 @@
-/*-
- * Copyright 2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 clock control module driver.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <arm/amlogic/aml8726/aml8726_soc.h>
-#include <arm/amlogic/aml8726/aml8726_ccm.h>
-
-struct aml8726_ccm_softc {
- device_t dev;
- struct aml8726_ccm_function *soc;
- struct resource *res[1];
- struct mtx mtx;
-};
-
-static struct resource_spec aml8726_ccm_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-#define AML_CCM_LOCK(sc) mtx_lock(&(sc)->mtx)
-#define AML_CCM_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
-#define AML_CCM_LOCK_INIT(sc) \
- mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
- "ccm", MTX_DEF)
-#define AML_CCM_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx);
-
-#define CSR_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
-#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-
-static int
-aml8726_ccm_configure_gates(struct aml8726_ccm_softc *sc)
-{
- struct aml8726_ccm_function *f;
- struct aml8726_ccm_gate *g;
- char *function_name;
- char *functions;
- phandle_t node;
- ssize_t len;
- uint32_t value;
-
- node = ofw_bus_get_node(sc->dev);
-
- len = OF_getprop_alloc(node, "functions",
- (void **)&functions);
-
- if (len < 0) {
- device_printf(sc->dev, "missing functions attribute in FDT\n");
- return (ENXIO);
- }
-
- function_name = functions;
-
- while (len) {
- for (f = sc->soc; f->name != NULL; f++)
- if (strncmp(f->name, function_name, len) == 0)
- break;
-
- if (f->name == NULL) {
- /* display message prior to queuing up next string */
- device_printf(sc->dev,
- "unknown function attribute %.*s in FDT\n",
- len, function_name);
- }
-
- /* queue up next string */
- while (*function_name && len) {
- function_name++;
- len--;
- }
- if (len) {
- function_name++;
- len--;
- }
-
- if (f->name == NULL)
- continue;
-
- AML_CCM_LOCK(sc);
-
- /*
- * Enable the clock gates necessary for the function.
- *
- * In some cases a clock may be shared across functions
- * (meaning don't disable a clock without ensuring that
- * it's not required by someone else).
- */
- for (g = f->gates; g->bits != 0x00000000; g++) {
- value = CSR_READ_4(sc, g->addr);
- value |= g->bits;
- CSR_WRITE_4(sc, g->addr, value);
- }
-
- AML_CCM_UNLOCK(sc);
- }
-
- OF_prop_free(functions);
-
- return (0);
-}
-
-static int
-aml8726_ccm_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-ccm"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 ccm");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_ccm_attach(device_t dev)
-{
- struct aml8726_ccm_softc *sc = device_get_softc(dev);
-
- sc->dev = dev;
-
- switch (aml8726_soc_hw_rev) {
- case AML_SOC_HW_REV_M3:
- sc->soc = aml8726_m3_ccm;
- break;
- case AML_SOC_HW_REV_M6:
- sc->soc = aml8726_m6_ccm;
- break;
- case AML_SOC_HW_REV_M8:
- sc->soc = aml8726_m8_ccm;
- break;
- case AML_SOC_HW_REV_M8B:
- sc->soc = aml8726_m8b_ccm;
- break;
- default:
- device_printf(dev, "unsupported SoC\n");
- return (ENXIO);
- /* NOTREACHED */
- }
-
- if (bus_alloc_resources(dev, aml8726_ccm_spec, sc->res)) {
- device_printf(dev, "can not allocate resources for device\n");
- return (ENXIO);
- }
-
- AML_CCM_LOCK_INIT(sc);
-
- return (aml8726_ccm_configure_gates(sc));
-}
-
-static int
-aml8726_ccm_detach(device_t dev)
-{
- struct aml8726_ccm_softc *sc = device_get_softc(dev);
-
- AML_CCM_LOCK_DESTROY(sc);
-
- bus_release_resources(dev, aml8726_ccm_spec, sc->res);
-
- return (0);
-}
-
-static device_method_t aml8726_ccm_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_ccm_probe),
- DEVMETHOD(device_attach, aml8726_ccm_attach),
- DEVMETHOD(device_detach, aml8726_ccm_detach),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_ccm_driver = {
- "ccm",
- aml8726_ccm_methods,
- sizeof(struct aml8726_ccm_softc),
-};
-
-static devclass_t aml8726_ccm_devclass;
-
-EARLY_DRIVER_MODULE(ccm, simplebus, aml8726_ccm_driver,
- aml8726_ccm_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_LATE);
sys/arm/amlogic/aml8726/aml8726_ccm.h→/dev/null
@@ -1,320 +0,0 @@
-/*-
- * Copyright 2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _ARM_AMLOGIC_AML8726_CCM_H
-#define _ARM_AMLOGIC_AML8726_CCM_H
-
-struct aml8726_ccm_gate {
- uint32_t addr;
- uint32_t bits;
-};
-
-struct aml8726_ccm_function {
- const char *name;
- struct aml8726_ccm_gate *gates;
-};
-
-/*
- * aml8726-m3
- */
-
-static struct aml8726_ccm_gate aml8726_m3_ethernet[] = {
- { 4, 0x00000008 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_i2c[] = {
- { 0, 0x00000200 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_rng[] = {
- { 0, 0x00001000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_sdio[] = {
- { 0, 0x00020000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_sdxc[] = {
- { 0, 0x00004000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_uart_a[] = {
- { 0, 0x00002000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_uart_b[] = {
- { 4, 0x00010000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_uart_c[] = {
- { 8, 0x00008000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_usb_a[] = {
- { 4, 0x00200000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m3_usb_b[] = {
- { 4, 0x00400000 },
- { 0, 0x00000000 }
-};
-
-struct aml8726_ccm_function aml8726_m3_ccm[] = {
- { "ethernet", aml8726_m3_ethernet },
- { "i2c", aml8726_m3_i2c },
- { "rng", aml8726_m3_rng },
- { "sdio", aml8726_m3_sdio },
- { "sdxc", aml8726_m3_sdxc },
- { "uart-a", aml8726_m3_uart_a },
- { "uart-b", aml8726_m3_uart_b },
- { "uart-c", aml8726_m3_uart_c },
- { "usb-a", aml8726_m3_usb_a },
- { "usb-b", aml8726_m3_usb_b },
- { NULL }
-};
-
-/*
- * aml8726-m6
- */
-
-static struct aml8726_ccm_gate aml8726_m6_ethernet[] = {
- { 4, 0x00000008 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_i2c[] = {
- { 0, 0x00000200 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_rng[] = {
- { 0, 0x00001000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_sdio[] = {
- { 0, 0x00020000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_sdxc[] = {
- { 0, 0x00004000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_uart_a[] = {
- { 0, 0x00002000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_uart_b[] = {
- { 4, 0x00010000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_uart_c[] = {
- { 8, 0x00008000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_usb_a[] = {
- { 4, 0x00200000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m6_usb_b[] = {
- { 4, 0x00400000 },
- { 0, 0x00000000 }
-};
-
-struct aml8726_ccm_function aml8726_m6_ccm[] = {
- { "ethernet", aml8726_m6_ethernet },
- { "i2c", aml8726_m6_i2c },
- { "rng", aml8726_m6_rng },
- { "sdio", aml8726_m6_sdio },
- { "sdxc", aml8726_m6_sdxc },
- { "uart-a", aml8726_m6_uart_a },
- { "uart-b", aml8726_m6_uart_b },
- { "uart-c", aml8726_m6_uart_c },
- { "usb-a", aml8726_m6_usb_a },
- { "usb-b", aml8726_m6_usb_b },
- { NULL }
-};
-
-/*
- * aml8726-m8
- */
-
-static struct aml8726_ccm_gate aml8726_m8_ethernet[] = {
- { 4, 0x00000008 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_i2c[] = {
- { 0, 0x00000200 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_rng[] = {
- { 0, 0x00001000 },
- { 16, 0x00200000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_sdio[] = {
- { 0, 0x00020000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_sdxc[] = {
- { 0, 0x00004000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_uart_a[] = {
- { 0, 0x00002000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_uart_b[] = {
- { 4, 0x00010000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_uart_c[] = {
- { 8, 0x00008000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_usb_a[] = {
- { 4, 0x00200000 },
- { 4, 0x04000000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8_usb_b[] = {
- { 4, 0x00400000 },
- { 4, 0x04000000 },
- { 0, 0x00000000 }
-};
-
-struct aml8726_ccm_function aml8726_m8_ccm[] = {
- { "ethernet", aml8726_m8_ethernet },
- { "i2c", aml8726_m8_i2c },
- { "rng", aml8726_m8_rng },
- { "sdio", aml8726_m8_sdio },
- { "sdxc", aml8726_m8_sdxc },
- { "uart-a", aml8726_m8_uart_a },
- { "uart-b", aml8726_m8_uart_b },
- { "uart-c", aml8726_m8_uart_c },
- { "usb-a", aml8726_m8_usb_a },
- { "usb-b", aml8726_m8_usb_b },
- { NULL }
-};
-
-/*
- * aml8726-m8b
- */
-
-static struct aml8726_ccm_gate aml8726_m8b_ethernet[] = {
- { 4, 0x00000008 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_i2c[] = {
- { 0, 0x00000200 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_rng[] = {
- { 0, 0x00001000 },
- { 16, 0x00200000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_sdio[] = {
- { 0, 0x00020000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_sdxc[] = {
- { 0, 0x00004000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_uart_a[] = {
- { 0, 0x00002000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_uart_b[] = {
- { 4, 0x00010000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_uart_c[] = {
- { 8, 0x00008000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_usb_a[] = {
- { 4, 0x00200000 },
- { 4, 0x04000000 },
- { 0, 0x00000000 }
-};
-
-static struct aml8726_ccm_gate aml8726_m8b_usb_b[] = {
- { 4, 0x00400000 },
- { 4, 0x04000000 },
- { 0, 0x00000000 }
-};
-
-struct aml8726_ccm_function aml8726_m8b_ccm[] = {
- { "ethernet", aml8726_m8b_ethernet },
- { "i2c", aml8726_m8b_i2c },
- { "rng", aml8726_m8b_rng },
- { "sdio", aml8726_m8b_sdio },
- { "sdxc", aml8726_m8b_sdxc },
- { "uart-a", aml8726_m8b_uart_a },
- { "uart-b", aml8726_m8b_uart_b },
- { "uart-c", aml8726_m8b_uart_c },
- { "usb-a", aml8726_m8b_usb_a },
- { "usb-b", aml8726_m8b_usb_b },
- { NULL }
-};
-
-#endif /* _ARM_AMLOGIC_AML8726_CCM_H */
sys/arm/amlogic/aml8726/aml8726_clkmsr.c→/dev/null
@@ -1,298 +0,0 @@
-/*-
- * Copyright 2014-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-/*
- * Amlogic aml8726 clock measurement driver.
- *
- * This allows various clock rates to be determine at runtime.
- * The measurements are done once and are not expected to change
- * (i.e. FDT fixup provides clk81 as bus-frequency to the MMC
- * and UART drivers which use the value when programming the
- * hardware).
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/malloc.h>
-#include <sys/rman.h>
-#include <sys/timetc.h>
-#include <sys/timeet.h>
-
-#include <machine/bus.h>
-#include <machine/cpu.h>
-#include <machine/fdt.h>
-
-#include <dev/fdt/fdt_common.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <arm/amlogic/aml8726/aml8726_soc.h>
-#include <arm/amlogic/aml8726/aml8726_clkmsr.h>
-
-static struct aml8726_clkmsr_clk {
- const char * name;
- uint32_t mux;
-} aml8726_clkmsr_clks[] = {
- { "clk81", 7 },
-};
-
-#define AML_CLKMSR_CLK81 0
-
-#define AML_CLKMSR_NCLKS nitems(aml8726_clkmsr_clks)
-
-struct aml8726_clkmsr_softc {
- device_t dev;
- struct resource * res[1];
-};
-
-static struct resource_spec aml8726_clkmsr_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-/*
- * Duration can range from 1uS to 65535 uS and should be chosen
- * based on the expected frequency result so to maximize resolution
- * and avoid overflowing the 16 bit result counter.
- */
-#define AML_CLKMSR_DURATION 32
-
-#define AML_CLKMSR_DUTY_REG 0
-#define AML_CLKMSR_0_REG 4
-#define AML_CLKMSR_0_BUSY (1U << 31)
-#define AML_CLKMSR_0_MUX_MASK (0x3f << 20)
-#define AML_CLKMSR_0_MUX_SHIFT 20
-#define AML_CLKMSR_0_MUX_EN (1 << 19)
-#define AML_CLKMSR_0_MEASURE (1 << 16)
-#define AML_CLKMSR_0_DURATION_MASK 0xffff
-#define AML_CLKMSR_0_DURATION_SHIFT 0
-#define AML_CLKMSR_1_REG 8
-#define AML_CLKMSR_2_REG 12
-#define AML_CLKMSR_2_RESULT_MASK 0xffff
-#define AML_CLKMSR_2_RESULT_SHIFT 0
-
-#define CSR_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
-#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-#define CSR_BARRIER(sc, reg) bus_barrier((sc)->res[0], reg, 4, \
- (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-static int
-aml8726_clkmsr_clock_frequency(struct aml8726_clkmsr_softc *sc, unsigned clock)
-{
- uint32_t value;
-
- if (clock >= AML_CLKMSR_NCLKS)
- return (0);
-
- /*
- * Locking is not used as this is only expected to be called from
- * FDT fixup (which occurs prior to driver initialization) or attach.
- */
-
- CSR_WRITE_4(sc, AML_CLKMSR_0_REG, 0);
-
- CSR_BARRIER(sc, AML_CLKMSR_0_REG);
-
- value = (aml8726_clkmsr_clks[clock].mux << AML_CLKMSR_0_MUX_SHIFT)
- | ((AML_CLKMSR_DURATION - 1) << AML_CLKMSR_0_DURATION_SHIFT)
- | AML_CLKMSR_0_MUX_EN
- | AML_CLKMSR_0_MEASURE;
- CSR_WRITE_4(sc, AML_CLKMSR_0_REG, value);
-
- CSR_BARRIER(sc, AML_CLKMSR_0_REG);
-
- while ((CSR_READ_4(sc, AML_CLKMSR_0_REG) & AML_CLKMSR_0_BUSY) != 0)
- cpu_spinwait();
-
- value &= ~AML_CLKMSR_0_MEASURE;
- CSR_WRITE_4(sc, AML_CLKMSR_0_REG, value);
-
- CSR_BARRIER(sc, AML_CLKMSR_0_REG);
-
- value = (((CSR_READ_4(sc, AML_CLKMSR_2_REG) & AML_CLKMSR_2_RESULT_MASK)
- >> AML_CLKMSR_2_RESULT_SHIFT) + AML_CLKMSR_DURATION / 2) /
- AML_CLKMSR_DURATION;
-
- return value;
-}
-
-static void
-aml8726_clkmsr_fixup_clk81(struct aml8726_clkmsr_softc *sc, int freq)
-{
- pcell_t prop;
- ssize_t len;
- phandle_t clk_node;
- phandle_t node;
-
- node = ofw_bus_get_node(sc->dev);
-
- len = OF_getencprop(node, "clocks", &prop, sizeof(prop));
- if ((len / sizeof(prop)) != 1 || prop == 0 ||
- (clk_node = OF_node_from_xref(prop)) == 0)
- return;
-
- len = OF_getencprop(clk_node, "clock-frequency", &prop, sizeof(prop));
- if ((len / sizeof(prop)) != 1 || prop != 0)
- return;
-
- freq = cpu_to_fdt32(freq);
-
- OF_setprop(clk_node, "clock-frequency", (void *)&freq, sizeof(freq));
-}
-
-static int
-aml8726_clkmsr_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-clkmsr"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 clkmsr");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_clkmsr_attach(device_t dev)
-{
- struct aml8726_clkmsr_softc *sc = device_get_softc(dev);
- int freq;
-
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, aml8726_clkmsr_spec, sc->res)) {
- device_printf(dev, "can not allocate resources for device\n");
- return (ENXIO);
- }
-
- freq = aml8726_clkmsr_clock_frequency(sc, AML_CLKMSR_CLK81);
- device_printf(sc->dev, "bus clock %u MHz\n", freq);
-
- aml8726_clkmsr_fixup_clk81(sc, freq * 1000000);
-
- return (0);
-}
-
-static int
-aml8726_clkmsr_detach(device_t dev)
-{
- struct aml8726_clkmsr_softc *sc = device_get_softc(dev);
-
- bus_release_resources(dev, aml8726_clkmsr_spec, sc->res);
-
- return (0);
-}
-
-static device_method_t aml8726_clkmsr_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_clkmsr_probe),
- DEVMETHOD(device_attach, aml8726_clkmsr_attach),
- DEVMETHOD(device_detach, aml8726_clkmsr_detach),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_clkmsr_driver = {
- "clkmsr",
- aml8726_clkmsr_methods,
- sizeof(struct aml8726_clkmsr_softc),
-};
-
-static devclass_t aml8726_clkmsr_devclass;
-
-EARLY_DRIVER_MODULE(clkmsr, simplebus, aml8726_clkmsr_driver,
- aml8726_clkmsr_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_EARLY);
-
-int
-aml8726_clkmsr_bus_frequency()
-{
- struct resource mem;
- struct aml8726_clkmsr_softc sc;
- phandle_t node;
- u_long pbase, psize;
- u_long start, size;
- int freq;
-
- KASSERT(aml8726_soc_hw_rev != AML_SOC_HW_REV_UNKNOWN,
- ("aml8726_soc_hw_rev isn't initialized"));
-
- /*
- * Try to access the clkmsr node directly i.e. through /aliases/.
- */
-
- if ((node = OF_finddevice("clkmsr")) != -1)
- if (fdt_is_compatible_strict(node, "amlogic,aml8726-clkmsr"))
- goto moveon;
-
- /*
- * Find the node the long way.
- */
- if ((node = OF_finddevice("/soc")) == -1)
- return (0);
-
- if ((node = fdt_find_compatible(node,
- "amlogic,aml8726-clkmsr", 1)) == 0)
- return (0);
-
-moveon:
- if (fdt_get_range(OF_parent(node), 0, &pbase, &psize) != 0
- || fdt_regsize(node, &start, &size) != 0)
- return (0);
-
- start += pbase;
-
- memset(&mem, 0, sizeof(mem));
-
- mem.r_bustag = fdtbus_bs_tag;
-
- if (bus_space_map(mem.r_bustag, start, size, 0, &mem.r_bushandle) != 0)
- return (0);
-
- /*
- * Build an incomplete (however sufficient for the purpose
- * of calling aml8726_clkmsr_clock_frequency) softc.
- */
-
- memset(&sc, 0, sizeof(sc));
-
- sc.res[0] = &mem;
-
- freq = aml8726_clkmsr_clock_frequency(&sc, AML_CLKMSR_CLK81) * 1000000;
-
- bus_space_unmap(mem.r_bustag, mem.r_bushandle, size);
-
- return (freq);
-}
sys/arm/amlogic/aml8726/aml8726_clkmsr.h→/dev/null
@@ -1,34 +0,0 @@
-/*-
- * Copyright 2014 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _ARM_AMLOGIC_AML8726_CLKMSR_H
-#define _ARM_AMLOGIC_AML8726_CLKMSR_H
-
-int aml8726_clkmsr_bus_frequency(void);
-
-#endif /* _ARM_AMLOGIC_AML8726_CLKMSR_H */
sys/arm/amlogic/aml8726/aml8726_fb.c→/dev/null
@@ -1,469 +0,0 @@
-/*-
- * Copyright 2013-2014 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 frame buffer driver.
- *
- * The current implementation has limited flexibility.
- * For example only progressive scan is supported when
- * using HDMI and the resolution / frame rate is not
- * negotiated.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-
-#include <sys/fbio.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/bus.h>
-#include <machine/cpu.h>
-#include <machine/fdt.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/vt/vt.h>
-
-#include <arm/amlogic/aml8726/aml8726_fb.h>
-
-#include "fb_if.h"
-
-enum aml8726_fb_output {
- aml8726_unknown_fb_output,
- aml8726_cvbs_fb_output,
- aml8726_hdmi_fb_output,
- aml8726_lcd_fb_output
-};
-
-struct aml8726_fb_clk {
- uint32_t freq;
- uint32_t video_pre;
- uint32_t video_post;
- uint32_t video_x;
- uint32_t hdmi_tx;
- uint32_t encp;
- uint32_t enci;
- uint32_t enct;
- uint32_t encl;
- uint32_t vdac0;
- uint32_t vdac1;
-};
-
-struct aml8726_fb_softc {
- device_t dev;
- struct resource *res[4];
- struct mtx mtx;
- void *ih_cookie;
- struct fb_info info;
- enum aml8726_fb_output output;
- struct aml8726_fb_clk clk;
-};
-
-static struct resource_spec aml8726_fb_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* CANVAS */
- { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* VIU */
- { SYS_RES_MEMORY, 2, RF_ACTIVE }, /* VPP */
- { SYS_RES_IRQ, 1, RF_ACTIVE }, /* INT_VIU_VSYNC */
- { -1, 0 }
-};
-
-#define AML_FB_LOCK(sc) mtx_lock(&(sc)->mtx)
-#define AML_FB_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
-#define AML_FB_LOCK_INIT(sc) \
- mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
- "fb", MTX_DEF)
-#define AML_FB_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx);
-
-#define CAV_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
-#define CAV_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-#define CAV_BARRIER(sc, reg) bus_barrier((sc)->res[0], reg, 4, \
- (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-#define VIU_WRITE_4(sc, reg, val) bus_write_4((sc)->res[1], reg, (val))
-#define VIU_READ_4(sc, reg) bus_read_4((sc)->res[1], reg)
-
-#define VPP_WRITE_4(sc, reg, val) bus_write_4((sc)->res[2], reg, (val))
-#define VPP_READ_4(sc, reg) bus_read_4((sc)->res[2], reg)
-
-#define CLK_WRITE_4(sc, reg, val) bus_write_4((sc)->res[X], reg, (val))
-#define CLK_READ_4(sc, reg) bus_read_4((sc)->res[X], reg)
-
-#define AML_FB_CLK_FREQ_SD 1080
-#define AML_FB_CLK_FREQ_HD 1488
-
-static void
-aml8726_fb_cfg_output(struct aml8726_fb_softc *sc)
-{
- /* XXX */
-}
-
-static void
-aml8726_fb_cfg_video(struct aml8726_fb_softc *sc)
-{
- uint32_t value;
-
- /*
- * basic initialization
- *
- * The fifo depth is in units of 8 so programming 32
- * sets the depth to 256.
- */
-
- value = (32 << AML_VIU_OSD_FIFO_CTRL_DEPTH_SHIFT);
- value |= AML_VIU_OSD_FIFO_CTRL_BURST_LEN_64;
- value |= (4 << AML_VIU_OSD_FIFO_CTRL_HOLD_LINES_SHIFT);
-
- VIU_WRITE_4(sc, AML_VIU_OSD1_FIFO_CTRL_REG, value);
- VIU_WRITE_4(sc, AML_VIU_OSD2_FIFO_CTRL_REG, value);
-
- value = VPP_READ_4(sc, AML_VPP_MISC_REG);
-
- value &= ~AML_VPP_MISC_PREBLEND_EN;
- value |= AML_VPP_MISC_POSTBLEND_EN;
- value &= ~(AML_VPP_MISC_OSD1_POSTBLEND | AML_VPP_MISC_OSD2_POSTBLEND
- | AML_VPP_MISC_VD1_POSTBLEND | AML_VPP_MISC_VD2_POSTBLEND);
-
- VPP_WRITE_4(sc, AML_VPP_MISC_REG, value);
-
- value = AML_VIU_OSD_CTRL_OSD_EN;
- value |= (0xff << AML_VIU_OSD_CTRL_GLOBAL_ALPHA_SHIFT);
-
- VIU_WRITE_4(sc, AML_VIU_OSD1_CTRL_REG, value);
- VIU_WRITE_4(sc, AML_VIU_OSD2_CTRL_REG, value);
-
- /* color mode for OSD1 block 0 */
-
- value = (AML_CAV_OSD1_INDEX << AML_VIU_OSD_BLK_CFG_W0_INDEX_SHIFT)
- | AML_VIU_OSD_BLK_CFG_W0_LITTLE_ENDIAN
- | AML_VIU_OSD_BLK_CFG_W0_BLKMODE_24
- | AML_VIU_OSD_BLK_CFG_W0_RGB_EN
- | AML_VIU_OSD_BLK_CFG_W0_CMATRIX_RGB;
-
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK0_CFG_W0_REG, value);
-
- /* geometry / scaling for OSD1 block 0 */
-
- value = ((sc->info.fb_width - 1) << AML_VIU_OSD_BLK_CFG_W1_X_END_SHIFT)
- & AML_VIU_OSD_BLK_CFG_W1_X_END_MASK;
- value |= (0 << AML_VIU_OSD_BLK_CFG_W1_X_START_SHIFT)
- & AML_VIU_OSD_BLK_CFG_W1_X_START_MASK;
-
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK0_CFG_W1_REG, value);
-
- value = ((sc->info.fb_height - 1) << AML_VIU_OSD_BLK_CFG_W2_Y_END_SHIFT)
- & AML_VIU_OSD_BLK_CFG_W2_Y_END_MASK;
- value |= (0 << AML_VIU_OSD_BLK_CFG_W2_Y_START_SHIFT)
- & AML_VIU_OSD_BLK_CFG_W2_Y_START_MASK;
-
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK0_CFG_W2_REG, value);
-
- value = ((sc->info.fb_width - 1) << AML_VIU_OSD_BLK_CFG_W3_H_END_SHIFT)
- & AML_VIU_OSD_BLK_CFG_W3_H_END_MASK;
- value |= (0 << AML_VIU_OSD_BLK_CFG_W3_H_START_SHIFT)
- & AML_VIU_OSD_BLK_CFG_W3_H_START_MASK;
-
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK0_CFG_W3_REG, value);
-
- value = ((sc->info.fb_height - 1) << AML_VIU_OSD_BLK_CFG_W4_V_END_SHIFT)
- & AML_VIU_OSD_BLK_CFG_W4_V_END_MASK;
- value |= (0 << AML_VIU_OSD_BLK_CFG_W4_V_START_SHIFT)
- & AML_VIU_OSD_BLK_CFG_W4_V_START_MASK;
-
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK0_CFG_W4_REG, value);
-
- /* Enable the OSD block now that it's fully configured */
-
- value = VIU_READ_4(sc, AML_VIU_OSD1_CTRL_REG);
-
- value &= ~AML_VIU_OSD_CTRL_OSD_BLK_EN_MASK;
- value |= 1 << AML_VIU_OSD_CTRL_OSD_BLK_EN_SHIFT;
-
- VIU_WRITE_4(sc, AML_VIU_OSD1_CTRL_REG, value);
-
- /* enable video processing of OSD1 */
-
- value = VPP_READ_4(sc, AML_VPP_MISC_REG);
-
- value |= AML_VPP_MISC_OSD1_POSTBLEND;
-
- VPP_WRITE_4(sc, AML_VPP_MISC_REG, value);
-}
-
-static void
-aml8726_fb_cfg_canvas(struct aml8726_fb_softc *sc)
-{
- uint32_t value;
- uint32_t width;
-
- /*
- * The frame buffer address and width are programmed in units of 8
- * (meaning they need to be aligned and the actual values divided
- * by 8 prior to programming the hardware).
- */
-
- width = (uint32_t)sc->info.fb_stride / 8;
-
- /* lower bits of the width */
- value = (width << AML_CAV_LUT_DATAL_WIDTH_SHIFT) &
- AML_CAV_LUT_DATAL_WIDTH_MASK;
-
- /* physical address */
- value |= (uint32_t)sc->info.fb_pbase / 8;
-
- CAV_WRITE_4(sc, AML_CAV_LUT_DATAL_REG, value);
-
- /* upper bits of the width */
- value = ((width >> AML_CAV_LUT_DATAL_WIDTH_WIDTH) <<
- AML_CAV_LUT_DATAH_WIDTH_SHIFT) & AML_CAV_LUT_DATAH_WIDTH_MASK;
-
- /* height */
- value |= ((uint32_t)sc->info.fb_height <<
- AML_CAV_LUT_DATAH_HEIGHT_SHIFT) & AML_CAV_LUT_DATAH_HEIGHT_MASK;
-
- /* mode */
- value |= AML_CAV_LUT_DATAH_BLKMODE_LINEAR;
-
- CAV_WRITE_4(sc, AML_CAV_LUT_DATAH_REG, value);
-
- CAV_WRITE_4(sc, AML_CAV_LUT_ADDR_REG, (AML_CAV_LUT_ADDR_WR_EN |
- (AML_CAV_OSD1_INDEX << AML_CAV_LUT_ADDR_INDEX_SHIFT)));
-
- CAV_BARRIER(sc, AML_CAV_LUT_ADDR_REG);
-}
-
-static void
-aml8726_fb_intr(void *arg)
-{
- struct aml8726_fb_softc *sc = (struct aml8726_fb_softc *)arg;
-
- AML_FB_LOCK(sc);
-
- AML_FB_UNLOCK(sc);
-}
-
-static int
-aml8726_fb_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-fb"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 FB");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_fb_attach(device_t dev)
-{
- struct aml8726_fb_softc *sc = device_get_softc(dev);
- int error;
- device_t child;
- pcell_t prop;
- phandle_t node;
-
- sc->dev = dev;
-
- sc->info.fb_name = device_get_nameunit(sc->dev);
-
- node = ofw_bus_get_node(dev);
-
- if (OF_getencprop(node, "width", &prop, sizeof(prop)) <= 0) {
- device_printf(dev, "missing width attribute in FDT\n");
- return (ENXIO);
- }
- if ((prop % 8) != 0) {
- device_printf(dev,
- "width attribute in FDT must be a multiple of 8\n");
- return (ENXIO);
- }
- sc->info.fb_width = prop;
-
- if (OF_getencprop(node, "height", &prop, sizeof(prop)) <= 0) {
- device_printf(dev, "missing height attribute in FDT\n");
- return (ENXIO);
- }
- sc->info.fb_height = prop;
-
- if (OF_getencprop(node, "depth", &prop, sizeof(prop)) <= 0) {
- device_printf(dev, "missing depth attribute in FDT\n");
- return (ENXIO);
- }
- if (prop != 24) {
- device_printf(dev,
- "depth attribute in FDT is an unsupported value\n");
- return (ENXIO);
- }
- sc->info.fb_depth = prop;
- sc->info.fb_bpp = prop;
-
- if (OF_getencprop(node, "linebytes", &prop, sizeof(prop)) <= 0) {
- device_printf(dev, "missing linebytes attribute in FDT\n");
- return (ENXIO);
- }
- if ((prop % 8) != 0) {
- device_printf(dev,
- "linebytes attribute in FDT must be a multiple of 8\n");
- return (ENXIO);
- }
- if (prop < (sc->info.fb_width * 3)) {
- device_printf(dev,
- "linebytes attribute in FDT is too small\n");
- return (ENXIO);
- }
- sc->info.fb_stride = prop;
-
- if (OF_getencprop(node, "address", &prop, sizeof(prop)) <= 0) {
- device_printf(dev, "missing address attribute in FDT\n");
- return (ENXIO);
- }
- if ((prop % 8) != 0) {
- device_printf(dev,
- "address attribute in FDT must be a multiple of 8\n");
- return (ENXIO);
- }
- sc->info.fb_pbase = prop;
- sc->info.fb_size = sc->info.fb_height * sc->info.fb_stride;
- sc->info.fb_vbase = (intptr_t)pmap_mapdev(sc->info.fb_pbase,
- sc->info.fb_size);
-
- if (bus_alloc_resources(dev, aml8726_fb_spec, sc->res)) {
- device_printf(dev, "could not allocate resources for device\n");
- pmap_unmapdev(sc->info.fb_vbase, sc->info.fb_size);
- return (ENXIO);
- }
-
- aml8726_fb_cfg_output(sc);
-
- aml8726_fb_cfg_video(sc);
-
- aml8726_fb_cfg_canvas(sc);
-
- AML_FB_LOCK_INIT(sc);
-
- error = bus_setup_intr(dev, sc->res[3], INTR_TYPE_MISC | INTR_MPSAFE,
- NULL, aml8726_fb_intr, sc, &sc->ih_cookie);
-
- if (error) {
- device_printf(dev, "could not setup interrupt handler\n");
- goto fail;
- }
-
- child = device_add_child(dev, "fbd", device_get_unit(dev));
-
- if (!child) {
- device_printf(dev, "could not add fbd\n");
- error = ENXIO;
- goto fail;
- }
-
- error = device_probe_and_attach(child);
-
- if (error) {
- device_printf(dev, "could not attach fbd\n");
- goto fail;
- }
-
- return (0);
-
-fail:
- if (sc->ih_cookie)
- bus_teardown_intr(dev, sc->res[3], sc->ih_cookie);
-
- AML_FB_LOCK_DESTROY(sc);
-
- bus_release_resources(dev, aml8726_fb_spec, sc->res);
-
- pmap_unmapdev(sc->info.fb_vbase, sc->info.fb_size);
-
- return (error);
-}
-
-static int
-aml8726_fb_detach(device_t dev)
-{
- struct aml8726_fb_softc *sc = device_get_softc(dev);
-
- bus_generic_detach(dev);
-
- bus_teardown_intr(dev, sc->res[3], sc->ih_cookie);
-
- AML_FB_LOCK_DESTROY(sc);
-
- bus_release_resources(dev, aml8726_fb_spec, sc->res);
-
- pmap_unmapdev(sc->info.fb_vbase, sc->info.fb_size);
-
- return (0);
-}
-
-static struct fb_info *
-aml8726_fb_getinfo(device_t dev)
-{
- struct aml8726_fb_softc *sc = device_get_softc(dev);
-
- return (&sc->info);
-}
-
-static device_method_t aml8726_fb_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_fb_probe),
- DEVMETHOD(device_attach, aml8726_fb_attach),
- DEVMETHOD(device_detach, aml8726_fb_detach),
-
- /* FB interface */
- DEVMETHOD(fb_getinfo, aml8726_fb_getinfo),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_fb_driver = {
- "fb",
- aml8726_fb_methods,
- sizeof(struct aml8726_fb_softc),
-};
-
-static devclass_t aml8726_fb_devclass;
-
-DRIVER_MODULE(fb, simplebus, aml8726_fb_driver, aml8726_fb_devclass, 0, 0);
sys/arm/amlogic/aml8726/aml8726_fb.h→/dev/null
@@ -1,162 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _ARM_AMLOGIC_AML8726_FB_H
-#define _ARM_AMLOGIC_AML8726_FB_H
-
-#define AML_CAV_OSD1_INDEX 0x40
-
-#define AML_CAV_LUT_DATAL_REG 0
-#define AML_CAV_LUT_DATAL_WIDTH_MASK (7 << 29)
-#define AML_CAV_LUT_DATAL_WIDTH_SHIFT 29
-#define AML_CAV_LUT_DATAL_WIDTH_WIDTH 3
-#define AML_CAV_LUT_DATAL_ADDR_MASK 0x1fffffff
-#define AML_CAV_LUT_DATAL_ADDR_SHIFT 0
-
-#define AML_CAV_LUT_DATAH_REG 4
-#define AML_CAV_LUT_DATAH_BLKMODE_MASK (3 << 24)
-#define AML_CAV_LUT_DATAH_BLKMODE_SHIFT 24
-#define AML_CAV_LUT_DATAH_BLKMODE_LINEAR (0 << 24)
-#define AML_CAV_LUT_DATAH_BLKMODE_32x32 (1 << 24)
-#define AML_CAV_LUT_DATAH_BLKMODE_64x32 (2 << 24)
-#define AML_CAV_LUT_DATAH_WRAP_X (1 << 23)
-#define AML_CAV_LUT_DATAH_WRAP_Y (1 << 22)
-#define AML_CAV_LUT_DATAH_HEIGHT_MASK (0x1fff << 9)
-#define AML_CAV_LUT_DATAH_HEIGHT_SHIFT 9
-#define AML_CAV_LUT_DATAH_WIDTH_MASK 0x1ff
-#define AML_CAV_LUT_DATAH_WIDTH_SHIFT 0
-
-#define AML_CAV_LUT_ADDR_REG 8
-#define AML_CAV_LUT_ADDR_WR_EN (1 << 9)
-#define AML_CAV_LUT_ADDR_RD_EN (1 << 8)
-#define AML_CAV_LUT_ADDR_INDEX_MASK 0xff
-#define AML_CAV_LUT_ADDR_INDEX_SHIFT 0
-
-#define AML_VIU_OSD1_CTRL_REG 64
-#define AML_VIU_OSD_CTRL_OSD_EN (1 << 21)
-#define AML_VIU_OSD_CTRL_GLOBAL_ALPHA_MASK (0x1ff << 12)
-#define AML_VIU_OSD_CTRL_GLOBAL_ALPHA_SHIFT 12
-#define AML_VIU_OSD_CTRL_OSD_BLK_EN_MASK (0xf << 0)
-#define AML_VIU_OSD_CTRL_OSD_BLK_EN_SHIFT 0
-
-#define AML_VIU_OSD1_BLK0_CFG_W0_REG 108
-#define AML_VIU_OSD1_BLK1_CFG_W0_REG 124
-#define AML_VIU_OSD1_BLK2_CFG_W0_REG 140
-#define AML_VIU_OSD1_BLK3_CFG_W0_REG 156
-#define AML_VIU_OSD_BLK_CFG_W0_INDEX_MASK (0xff << 16)
-#define AML_VIU_OSD_BLK_CFG_W0_INDEX_SHIFT 16
-#define AML_VIU_OSD_BLK_CFG_W0_LITTLE_ENDIAN (1 << 15)
-#define AML_VIU_OSD_BLK_CFG_W0_BLKMODE_24 (7 << 8)
-#define AML_VIU_OSD_BLK_CFG_W0_RGB_EN (1 << 7)
-#define AML_VIU_OSD_BLK_CFG_W0_CMATRIX_RGB (0 << 2)
-
-#define AML_VIU_OSD1_BLK0_CFG_W1_REG 112
-#define AML_VIU_OSD1_BLK1_CFG_W1_REG 128
-#define AML_VIU_OSD1_BLK2_CFG_W1_REG 144
-#define AML_VIU_OSD1_BLK3_CFG_W1_REG 160
-#define AML_VIU_OSD_BLK_CFG_W1_X_END_MASK (0x1fff << 16)
-#define AML_VIU_OSD_BLK_CFG_W1_X_END_SHIFT 16
-#define AML_VIU_OSD_BLK_CFG_W1_X_START_MASK 0x1fff
-#define AML_VIU_OSD_BLK_CFG_W1_X_START_SHIFT 0
-
-#define AML_VIU_OSD1_BLK0_CFG_W2_REG 116
-#define AML_VIU_OSD1_BLK1_CFG_W2_REG 132
-#define AML_VIU_OSD1_BLK2_CFG_W2_REG 148
-#define AML_VIU_OSD1_BLK3_CFG_W2_REG 164
-#define AML_VIU_OSD_BLK_CFG_W2_Y_END_MASK (0x1fff << 16)
-#define AML_VIU_OSD_BLK_CFG_W2_Y_END_SHIFT 16
-#define AML_VIU_OSD_BLK_CFG_W2_Y_START_MASK 0x1fff
-#define AML_VIU_OSD_BLK_CFG_W2_Y_START_SHIFT 0
-
-#define AML_VIU_OSD1_BLK0_CFG_W3_REG 120
-#define AML_VIU_OSD1_BLK1_CFG_W3_REG 136
-#define AML_VIU_OSD1_BLK2_CFG_W3_REG 152
-#define AML_VIU_OSD1_BLK3_CFG_W3_REG 168
-#define AML_VIU_OSD_BLK_CFG_W3_H_END_MASK (0xfff << 16)
-#define AML_VIU_OSD_BLK_CFG_W3_H_END_SHIFT 16
-#define AML_VIU_OSD_BLK_CFG_W3_H_START_MASK 0xfff
-#define AML_VIU_OSD_BLK_CFG_W3_H_START_SHIFT 0
-
-#define AML_VIU_OSD1_BLK0_CFG_W4_REG 76
-#define AML_VIU_OSD1_BLK1_CFG_W4_REG 80
-#define AML_VIU_OSD1_BLK2_CFG_W4_REG 84
-#define AML_VIU_OSD1_BLK3_CFG_W4_REG 88
-#define AML_VIU_OSD_BLK_CFG_W4_V_END_MASK (0xfff << 16)
-#define AML_VIU_OSD_BLK_CFG_W4_V_END_SHIFT 16
-#define AML_VIU_OSD_BLK_CFG_W4_V_START_MASK 0xfff
-#define AML_VIU_OSD_BLK_CFG_W4_V_START_SHIFT 0
-
-#define AML_VIU_OSD1_FIFO_CTRL_REG 172
-#define AML_VIU_OSD_FIFO_CTRL_DEPTH_MASK (0x3f << 12)
-#define AML_VIU_OSD_FIFO_CTRL_DEPTH_SHIFT 12
-#define AML_VIU_OSD_FIFO_CTRL_BURST_LEN_MASK (3 << 10)
-#define AML_VIU_OSD_FIFO_CTRL_BURST_LEN_24 (0 << 10)
-#define AML_VIU_OSD_FIFO_CTRL_BURST_LEN_32 (1 << 10)
-#define AML_VIU_OSD_FIFO_CTRL_BURST_LEN_48 (2 << 10)
-#define AML_VIU_OSD_FIFO_CTRL_BURST_LEN_64 (3 << 10)
-#define AML_VIU_OSD_FIFO_CTRL_HOLD_LINES_MASK (0x1f << 5)
-#define AML_VIU_OSD_FIFO_CTRL_HOLD_LINES_SHIFT 5
-#define AML_VIU_OSD_FIFO_CTRL_URGENT (1 << 0)
-
-/* OSD2 field meanings are the same as OSD1 */
-#define AML_VIU_OSD2_CTRL_REG 192
-#define AML_VIU_OSD2_BLK0_CFG_W0_REG 236
-#define AML_VIU_OSD2_BLK1_CFG_W0_REG 252
-#define AML_VIU_OSD2_BLK2_CFG_W0_REG 268
-#define AML_VIU_OSD2_BLK3_CFG_W0_REG 284
-#define AML_VIU_OSD2_BLK0_CFG_W1_REG 240
-#define AML_VIU_OSD2_BLK1_CFG_W1_REG 256
-#define AML_VIU_OSD2_BLK2_CFG_W1_REG 272
-#define AML_VIU_OSD2_BLK3_CFG_W1_REG 288
-#define AML_VIU_OSD2_BLK0_CFG_W2_REG 244
-#define AML_VIU_OSD2_BLK1_CFG_W2_REG 260
-#define AML_VIU_OSD2_BLK2_CFG_W2_REG 276
-#define AML_VIU_OSD2_BLK3_CFG_W2_REG 292
-#define AML_VIU_OSD2_BLK0_CFG_W3_REG 248
-#define AML_VIU_OSD2_BLK1_CFG_W3_REG 264
-#define AML_VIU_OSD2_BLK2_CFG_W3_REG 280
-#define AML_VIU_OSD2_BLK3_CFG_W3_REG 296
-#define AML_VIU_OSD2_BLK0_CFG_W4_REG 400
-#define AML_VIU_OSD2_BLK1_CFG_W4_REG 404
-#define AML_VIU_OSD2_BLK2_CFG_W4_REG 408
-#define AML_VIU_OSD2_BLK3_CFG_W4_REG 412
-#define AML_VIU_OSD2_FIFO_CTRL_REG 300
-
-#define AML_VPP_MISC_REG 152
-#define AML_VPP_MISC_OSD2_PREBLEND (1 << 17)
-#define AML_VPP_MISC_OSD1_PREBLEND (1 << 16)
-#define AML_VPP_MISC_VD2_PREBLEND (1 << 15)
-#define AML_VPP_MISC_VD1_PREBLEND (1 << 14)
-#define AML_VPP_MISC_OSD2_POSTBLEND (1 << 13)
-#define AML_VPP_MISC_OSD1_POSTBLEND (1 << 12)
-#define AML_VPP_MISC_VD2_POSTBLEND (1 << 11)
-#define AML_VPP_MISC_VD1_POSTBLEND (1 << 10)
-#define AML_VPP_MISC_POSTBLEND_EN (1 << 7)
-#define AML_VPP_MISC_PREBLEND_EN (1 << 6)
-
-#endif /* _ARM_AMLOGIC_AML8726_FB_H */
sys/arm/amlogic/aml8726/aml8726_gpio.c→/dev/null
@@ -1,370 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 GPIO driver.
- *
- * Note: The OEN register is active * low *. Setting a bit to zero
- * enables the output driver, setting a bit to one disables the driver.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-
-#include <sys/gpio.h>
-
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/gpio/gpiobusvar.h>
-
-#include "gpio_if.h"
-
-struct aml8726_gpio_softc {
- device_t dev;
- struct resource *res[3];
- struct mtx mtx;
- uint32_t npins;
- device_t busdev;
-};
-
-static struct resource_spec aml8726_gpio_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE | RF_SHAREABLE }, /* oen */
- { SYS_RES_MEMORY, 1, RF_ACTIVE | RF_SHAREABLE }, /* output */
- { SYS_RES_MEMORY, 2, RF_ACTIVE }, /* input */
- { -1, 0 }
-};
-
-#define AML_GPIO_LOCK(sc) mtx_lock(&(sc)->mtx)
-#define AML_GPIO_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
-#define AML_GPIO_LOCK_INIT(sc) \
- mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
- "gpio", MTX_DEF)
-#define AML_GPIO_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx);
-
-#define AML_GPIO_OE_N_REG 0
-#define AML_GPIO_OUT_REG 1
-#define AML_GPIO_IN_REG 2
-
-#define CSR_WRITE_4(sc, reg, val) bus_write_4((sc)->res[reg], 0, (val))
-#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[reg], 0)
-
-static int
-aml8726_gpio_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-gpio"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 GPIO");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_gpio_attach(device_t dev)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
- phandle_t node;
- pcell_t prop;
-
- sc->dev = dev;
-
- node = ofw_bus_get_node(dev);
-
- if (OF_getencprop(node, "pin-count",
- &prop, sizeof(prop)) <= 0) {
- device_printf(dev, "missing pin-count attribute in FDT\n");
- return (ENXIO);
- }
- sc->npins = prop;
-
- if (sc->npins > 32)
- return (ENXIO);
-
- if (bus_alloc_resources(dev, aml8726_gpio_spec, sc->res)) {
- device_printf(dev, "can not allocate resources for device\n");
- return (ENXIO);
- }
-
- /*
- * The GPIOAO OUT bits occupy the upper word of the OEN register.
- */
- if (rman_get_start(sc->res[1]) == rman_get_start(sc->res[0]))
- if (sc->npins > 16) {
- device_printf(dev,
- "too many pins for overlapping OEN and OUT\n");
- bus_release_resources(dev, aml8726_gpio_spec, sc->res);
- return (ENXIO);
- }
-
- AML_GPIO_LOCK_INIT(sc);
-
- sc->busdev = gpiobus_attach_bus(dev);
- if (sc->busdev == NULL) {
- AML_GPIO_LOCK_DESTROY(sc);
- bus_release_resources(dev, aml8726_gpio_spec, sc->res);
- return (ENXIO);
- }
-
- return (0);
-}
-
-static int
-aml8726_gpio_detach(device_t dev)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
-
- gpiobus_detach_bus(dev);
-
- AML_GPIO_LOCK_DESTROY(sc);
-
- bus_release_resources(dev, aml8726_gpio_spec, sc->res);
-
- return (0);
-}
-
-static device_t
-aml8726_gpio_get_bus(device_t dev)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
-
- return (sc->busdev);
-}
-
-static int
-aml8726_gpio_pin_max(device_t dev, int *maxpin)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
-
- *maxpin = (int)sc->npins;
-
- return (0);
-}
-
-/* Get a specific pin's capabilities. */
-static int
-aml8726_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
-
- if (pin >= sc->npins)
- return (EINVAL);
-
- *caps = (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT);
-
- return (0);
-}
-
-/* Get a specific pin's name. */
-static int
-aml8726_gpio_pin_getname(device_t dev, uint32_t pin, char *name)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
-
- if (pin >= sc->npins)
- return (EINVAL);
-
- snprintf(name, GPIOMAXNAME, "%s.%u", ofw_bus_get_name(dev), pin);
-
- return (0);
-}
-
-/* Get a specific pin's current in/out state. */
-static int
-aml8726_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
- uint32_t mask = 1U << pin;
-
- if (pin >= sc->npins)
- return (EINVAL);
-
- if ((CSR_READ_4(sc, AML_GPIO_OE_N_REG) & mask) == 0) {
- /* output */
- *flags = GPIO_PIN_OUTPUT;
- } else
- /* input */
- *flags = GPIO_PIN_INPUT;
-
- return (0);
-}
-
-/* Set a specific pin's in/out state. */
-static int
-aml8726_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
- uint32_t mask = 1U << pin;
-
- if (pin >= sc->npins)
- return (EINVAL);
-
- AML_GPIO_LOCK(sc);
-
- if ((flags & GPIO_PIN_OUTPUT) != 0) {
- /* Output. Turn on driver. */
- CSR_WRITE_4(sc, AML_GPIO_OE_N_REG,
- (CSR_READ_4(sc, AML_GPIO_OE_N_REG) & ~mask));
- } else {
- /* Input. Turn off driver. */
- CSR_WRITE_4(sc, AML_GPIO_OE_N_REG,
- (CSR_READ_4(sc, AML_GPIO_OE_N_REG) | mask));
- }
-
- AML_GPIO_UNLOCK(sc);
-
- return (0);
-}
-
-/* Set a specific output pin's value. */
-static int
-aml8726_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
- uint32_t mask;
-
- if (pin >= sc->npins || value > 1)
- return (EINVAL);
-
- /*
- * The GPIOAO OUT bits occupy the upper word of the OEN register.
- */
- if (rman_get_start(sc->res[1]) == rman_get_start(sc->res[0]))
- pin += 16;
-
- mask = 1U << pin;
-
- AML_GPIO_LOCK(sc);
-
- CSR_WRITE_4(sc, AML_GPIO_OUT_REG,
- ((CSR_READ_4(sc, AML_GPIO_OUT_REG) & ~mask) | (value << pin)));
-
- AML_GPIO_UNLOCK(sc);
-
- return (0);
-}
-
-/* Get a specific pin's input value. */
-static int
-aml8726_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *value)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
- uint32_t mask = 1U << pin;
-
- if (pin >= sc->npins)
- return (EINVAL);
-
- *value = (CSR_READ_4(sc, AML_GPIO_IN_REG) & mask) ? 1 : 0;
-
- return (0);
-}
-
-/* Toggle a pin's output value. */
-static int
-aml8726_gpio_pin_toggle(device_t dev, uint32_t pin)
-{
- struct aml8726_gpio_softc *sc = device_get_softc(dev);
- uint32_t mask;
-
- if (pin >= sc->npins)
- return (EINVAL);
-
- /*
- * The GPIOAO OUT bits occupy the upper word of the OEN register.
- */
- if (rman_get_start(sc->res[1]) == rman_get_start(sc->res[0]))
- pin += 16;
-
- mask = 1U << pin;
-
- AML_GPIO_LOCK(sc);
-
- CSR_WRITE_4(sc, AML_GPIO_OUT_REG,
- CSR_READ_4(sc, AML_GPIO_OUT_REG) ^ mask);
-
- AML_GPIO_UNLOCK(sc);
-
- return (0);
-}
-
-static phandle_t
-aml8726_gpio_get_node(device_t bus, device_t dev)
-{
-
- /* We only have one child, the GPIO bus, which needs our own node. */
- return (ofw_bus_get_node(bus));
-}
-
-static device_method_t aml8726_gpio_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_gpio_probe),
- DEVMETHOD(device_attach, aml8726_gpio_attach),
- DEVMETHOD(device_detach, aml8726_gpio_detach),
-
- /* GPIO interface */
- DEVMETHOD(gpio_get_bus, aml8726_gpio_get_bus),
- DEVMETHOD(gpio_pin_max, aml8726_gpio_pin_max),
- DEVMETHOD(gpio_pin_getname, aml8726_gpio_pin_getname),
- DEVMETHOD(gpio_pin_getflags, aml8726_gpio_pin_getflags),
- DEVMETHOD(gpio_pin_getcaps, aml8726_gpio_pin_getcaps),
- DEVMETHOD(gpio_pin_setflags, aml8726_gpio_pin_setflags),
- DEVMETHOD(gpio_pin_get, aml8726_gpio_pin_get),
- DEVMETHOD(gpio_pin_set, aml8726_gpio_pin_set),
- DEVMETHOD(gpio_pin_toggle, aml8726_gpio_pin_toggle),
-
- /* ofw_bus interface */
- DEVMETHOD(ofw_bus_get_node, aml8726_gpio_get_node),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_gpio_driver = {
- "gpio",
- aml8726_gpio_methods,
- sizeof(struct aml8726_gpio_softc),
-};
-
-static devclass_t aml8726_gpio_devclass;
-
-DRIVER_MODULE(aml8726_gpio, simplebus, aml8726_gpio_driver,
- aml8726_gpio_devclass, 0, 0);
sys/arm/amlogic/aml8726/aml8726_i2c.c→/dev/null
@@ -1,282 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 I2C driver.
- *
- * Currently this implementation doesn't take full advantage of the hardware.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-#include <sys/mutex.h>
-#include <sys/rman.h>
-
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/iicbus/iiconf.h>
-#include <dev/iicbus/iicbus.h>
-
-#include "iicbb_if.h"
-
-struct aml8726_iic_softc {
- device_t dev;
- struct resource *res[1];
- struct mtx mtx;
- device_t iicbb;
-};
-
-static struct resource_spec aml8726_iic_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-#define AML_I2C_LOCK(sc) mtx_lock(&(sc)->mtx)
-#define AML_I2C_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
-#define AML_I2C_LOCK_INIT(sc) \
- mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
- "i2c", MTX_DEF)
-#define AML_I2C_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx);
-
-#define AML_I2C_CTRL_REG 0
-#define AML_I2C_MANUAL_SDA_I (1 << 26)
-#define AML_I2C_MANUAL_SCL_I (1 << 25)
-#define AML_I2C_MANUAL_SDA_O (1 << 24)
-#define AML_I2C_MANUAL_SCL_O (1 << 23)
-#define AML_I2C_MANUAL_EN (1 << 22)
-
-#define CSR_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
-#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-
-static int
-aml8726_iic_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,meson6-i2c"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 I2C");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_iic_attach(device_t dev)
-{
- struct aml8726_iic_softc *sc = device_get_softc(dev);
- int error;
-
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, aml8726_iic_spec, sc->res)) {
- device_printf(dev, "can not allocate resources for device\n");
- return (ENXIO);
- }
-
- AML_I2C_LOCK_INIT(sc);
-
- sc->iicbb = device_add_child(dev, "iicbb", -1);
-
- if (sc->iicbb == NULL) {
- device_printf(dev, "could not add iicbb\n");
- error = ENXIO;
- goto fail;
- }
-
- error = device_probe_and_attach(sc->iicbb);
-
- if (error) {
- device_printf(dev, "could not attach iicbb\n");
- goto fail;
- }
-
- return (0);
-
-fail:
- AML_I2C_LOCK_DESTROY(sc);
- bus_release_resources(dev, aml8726_iic_spec, sc->res);
-
- return (error);
-}
-
-static int
-aml8726_iic_detach(device_t dev)
-{
- struct aml8726_iic_softc *sc = device_get_softc(dev);
- device_t child;
-
- /*
- * Detach the children before recursively deleting
- * in case a child has a pointer to a grandchild
- * which is used by the child's detach routine.
- *
- * Remember the child before detaching so we can
- * delete it (bus_generic_detach indirectly zeroes
- * sc->child_dev).
- */
- child = sc->iicbb;
- bus_generic_detach(dev);
- if (child)
- device_delete_child(dev, child);
-
- AML_I2C_LOCK_DESTROY(sc);
-
- bus_release_resources(dev, aml8726_iic_spec, sc->res);
-
- return (0);
-}
-
-static void
-aml8726_iic_child_detached(device_t dev, device_t child)
-{
- struct aml8726_iic_softc *sc = device_get_softc(dev);
-
- if (child == sc->iicbb)
- sc->iicbb = NULL;
-}
-
-static int
-aml8726_iic_callback(device_t dev, int index, caddr_t data)
-{
-
- return (0);
-}
-
-static int
-aml8726_iic_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr)
-{
- struct aml8726_iic_softc *sc = device_get_softc(dev);
-
- AML_I2C_LOCK(sc);
-
- CSR_WRITE_4(sc, AML_I2C_CTRL_REG,
- (CSR_READ_4(sc, AML_I2C_CTRL_REG) | AML_I2C_MANUAL_SDA_O |
- AML_I2C_MANUAL_SCL_O | AML_I2C_MANUAL_EN));
-
- AML_I2C_UNLOCK(sc);
-
- /* Wait for 10 usec */
- DELAY(10);
-
- return (IIC_ENOADDR);
-}
-
-static int
-aml8726_iic_getscl(device_t dev)
-{
- struct aml8726_iic_softc *sc = device_get_softc(dev);
-
- return (CSR_READ_4(sc, AML_I2C_CTRL_REG) & AML_I2C_MANUAL_SCL_I);
-}
-
-static int
-aml8726_iic_getsda(device_t dev)
-{
- struct aml8726_iic_softc *sc = device_get_softc(dev);
-
- return (CSR_READ_4(sc, AML_I2C_CTRL_REG) & AML_I2C_MANUAL_SDA_I);
-}
-
-static void
-aml8726_iic_setscl(device_t dev, int val)
-{
- struct aml8726_iic_softc *sc = device_get_softc(dev);
-
- AML_I2C_LOCK(sc);
-
- CSR_WRITE_4(sc, AML_I2C_CTRL_REG, ((CSR_READ_4(sc, AML_I2C_CTRL_REG) &
- ~AML_I2C_MANUAL_SCL_O) | (val ? AML_I2C_MANUAL_SCL_O : 0) |
- AML_I2C_MANUAL_EN));
-
- AML_I2C_UNLOCK(sc);
-}
-
-static void
-aml8726_iic_setsda(device_t dev, int val)
-{
- struct aml8726_iic_softc *sc = device_get_softc(dev);
-
- AML_I2C_LOCK(sc);
-
- CSR_WRITE_4(sc, AML_I2C_CTRL_REG, ((CSR_READ_4(sc, AML_I2C_CTRL_REG) &
- ~AML_I2C_MANUAL_SDA_O) | (val ? AML_I2C_MANUAL_SDA_O : 0) |
- AML_I2C_MANUAL_EN));
-
- AML_I2C_UNLOCK(sc);
-}
-
-static device_method_t aml8726_iic_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_iic_probe),
- DEVMETHOD(device_attach, aml8726_iic_attach),
- DEVMETHOD(device_detach, aml8726_iic_detach),
-
- /* bus interface */
- DEVMETHOD(bus_child_detached, aml8726_iic_child_detached),
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_driver_added, bus_generic_driver_added),
-
- /* IICBB interface */
- DEVMETHOD(iicbb_callback, aml8726_iic_callback),
- DEVMETHOD(iicbb_reset, aml8726_iic_reset),
-
- DEVMETHOD(iicbb_getscl, aml8726_iic_getscl),
- DEVMETHOD(iicbb_getsda, aml8726_iic_getsda),
- DEVMETHOD(iicbb_setscl, aml8726_iic_setscl),
- DEVMETHOD(iicbb_setsda, aml8726_iic_setsda),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_iic_driver = {
- "aml8726_iic",
- aml8726_iic_methods,
- sizeof(struct aml8726_iic_softc),
-};
-
-static devclass_t aml8726_iic_devclass;
-
-DRIVER_MODULE(aml8726_iic, simplebus, aml8726_iic_driver,
- aml8726_iic_devclass, 0, 0);
-DRIVER_MODULE(iicbb, aml8726_iic, iicbb_driver, iicbb_devclass, 0, 0);
-MODULE_DEPEND(aml8726_iic, iicbb, IICBB_MINVER, IICBB_PREFVER, IICBB_MAXVER);
-MODULE_VERSION(aml8726_iic, 1);
sys/arm/amlogic/aml8726/aml8726_identsoc.c→/dev/null
@@ -1,142 +0,0 @@
-/*-
- * Copyright 2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-/*
- * Amlogic aml8726 SoC identification.
- *
- * The SoC identification is used by some of the drivers in order to
- * handle hardware differences so the identification needs to happen
- * early in the boot process (e.g. before SMP startup).
- *
- * It's expected that the register addresses for identifying the SoC
- * are set in stone.
- *
- * Currently missing an entry for the aml8726-m and doesn't distinguish
- * between the m801, m802, m805, s802, s805, and s812 which are all
- * variations of the aml8726-m8.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/clock.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-
-#include <machine/bus.h>
-#include <machine/fdt.h>
-
-#include <arm/amlogic/aml8726/aml8726_soc.h>
-
-uint32_t aml8726_soc_hw_rev = AML_SOC_HW_REV_UNKNOWN;
-uint32_t aml8726_soc_metal_rev = AML_SOC_METAL_REV_UNKNOWN;
-
-static const struct {
- uint32_t hw_rev;
- char *desc;
-} aml8726_soc_desc[] = {
- { AML_SOC_HW_REV_M3, "aml8726-m3" },
- { AML_SOC_HW_REV_M6, "aml8726-m6" },
- { AML_SOC_HW_REV_M6TV, "aml8726-m6tv" },
- { AML_SOC_HW_REV_M6TVL, "aml8726-m6tvl" },
- { AML_SOC_HW_REV_M8, "aml8726-m8" },
- { AML_SOC_HW_REV_M8B, "aml8726-m8b" },
- { 0xff, NULL }
-};
-
-static const struct {
- uint32_t metal_rev;
- char *desc;
-} aml8726_m8_soc_rev[] = {
- { AML_SOC_M8_METAL_REV_A, "A" },
- { AML_SOC_M8_METAL_REV_M2_A, "MarkII A" },
- { AML_SOC_M8_METAL_REV_B, "B" },
- { AML_SOC_M8_METAL_REV_C, "C" },
- { 0xff, NULL }
-};
-
-void
-aml8726_identify_soc(void)
-{
- int err;
- struct resource res;
-
- memset(&res, 0, sizeof(res));
-
- res.r_bustag = fdtbus_bs_tag;
-
- err = bus_space_map(res.r_bustag, AML_SOC_CBUS_BASE_ADDR, 0x100000,
- 0, &res.r_bushandle);
-
- if (err)
- panic("Could not allocate resource for SoC identification\n");
-
- aml8726_soc_hw_rev = bus_read_4(&res, AML_SOC_HW_REV_REG);
-
- aml8726_soc_metal_rev = bus_read_4(&res, AML_SOC_METAL_REV_REG);
-
- bus_space_unmap(res.r_bustag, res.r_bushandle, 0x100000);
-}
-
-static void
-aml8726_identify_announce_soc(void *dummy)
-{
- int i;
-
- for (i = 0; aml8726_soc_desc[i].desc; i++)
- if (aml8726_soc_desc[i].hw_rev == aml8726_soc_hw_rev)
- break;
-
- if (aml8726_soc_desc[i].desc == NULL)
- panic("Amlogic unknown aml8726 SoC %#x\n", aml8726_soc_hw_rev);
-
- printf("Amlogic %s SoC", aml8726_soc_desc[i].desc);
-
- if (aml8726_soc_hw_rev == AML_SOC_HW_REV_M8) {
- for (i = 0; aml8726_m8_soc_rev[i].desc; i++)
- if (aml8726_m8_soc_rev[i].metal_rev ==
- aml8726_soc_metal_rev)
- break;
-
- if (aml8726_m8_soc_rev[i].desc == NULL)
- printf(", unknown rev %#x", aml8726_soc_metal_rev);
- else
- printf(", rev %s", aml8726_m8_soc_rev[i].desc);
- }
-
- printf("\n");
-}
-
-SYSINIT(aml8726_identify_announce_soc, SI_SUB_CPU, SI_ORDER_SECOND,
- aml8726_identify_announce_soc, NULL);
sys/arm/amlogic/aml8726/aml8726_if_dwc.c→/dev/null
@@ -1,98 +0,0 @@
-/*-
- * Copyright (c) 2015 Ganbold Tsagaankhuu <ganbold@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-
-#include <machine/bus.h>
-
-#include <dev/dwc/if_dwc.h>
-#include <dev/dwc/if_dwcvar.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include "if_dwc_if.h"
-
-static int
-aml8726_if_dwc_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "amlogic,meson6-dwmac"))
- return (ENXIO);
- device_set_desc(dev, "Amlogic Meson Gigabit Ethernet Controller");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_if_dwc_init(device_t dev)
-{
-
- return (0);
-}
-
-static int
-aml8726_if_dwc_mac_type(device_t dev)
-{
-
- return (DWC_GMAC_NORMAL_DESC);
-}
-
-static int
-aml8726_if_dwc_mii_clk(device_t dev)
-{
-
- return (GMAC_MII_CLK_100_150M_DIV62);
-}
-
-static device_method_t aml8726_dwc_methods[] = {
- DEVMETHOD(device_probe, aml8726_if_dwc_probe),
-
- DEVMETHOD(if_dwc_init, aml8726_if_dwc_init),
- DEVMETHOD(if_dwc_mac_type, aml8726_if_dwc_mac_type),
- DEVMETHOD(if_dwc_mii_clk, aml8726_if_dwc_mii_clk),
-
- DEVMETHOD_END
-};
-
-static devclass_t aml8726_dwc_devclass;
-
-extern driver_t dwc_driver;
-
-DEFINE_CLASS_1(dwc, aml8726_dwc_driver, aml8726_dwc_methods,
- sizeof(struct dwc_softc), dwc_driver);
-DRIVER_MODULE(aml8726_dwc, simplebus, aml8726_dwc_driver,
- aml8726_dwc_devclass, 0, 0);
-
-MODULE_DEPEND(aml8726_dwc, dwc, 1, 1, 1);
sys/arm/amlogic/aml8726/aml8726_l2cache.c→/dev/null
@@ -1,92 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Based on omap4_l2cache.c by Olivier Houchard
- *
- * 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$
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-
-#include <machine/bus.h>
-#include <machine/pl310.h>
-
-void
-platform_pl310_init(struct pl310_softc *sc)
-{
- uint32_t aux;
-
- aux = pl310_read4(sc, PL310_AUX_CTRL);
-
- /*
- * The Amlogic Linux platform code enables via AUX:
- *
- * Early BRESP
- * Full Line of Zero (which must match processor setting)
- * Data Prefetch
- *
- * and additionally on the m6 enables:
- *
- * Instruction Prefetch
- *
- * For the moment we only enable Data Prefetch ...
- * further refinements can happen as things mature.
- */
-
- /*
- * Disable instruction prefetch.
- */
- aux &= ~AUX_CTRL_INSTR_PREFETCH;
-
- /*
- * Enable data prefetch.
- */
- aux |= AUX_CTRL_DATA_PREFETCH;
-
- pl310_write4(sc, PL310_AUX_CTRL, aux);
-}
-
-void
-platform_pl310_write_ctrl(struct pl310_softc *sc, uint32_t val)
-{
-
- pl310_write4(sc, PL310_CTRL, val);
-}
-
-void
-platform_pl310_write_debug(struct pl310_softc *sc, uint32_t val)
-{
-
- pl310_write4(sc, PL310_DEBUG_CTRL, val);
-}
sys/arm/amlogic/aml8726/aml8726_machdep.c→/dev/null
@@ -1,196 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "opt_global.h"
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "opt_platform.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/devmap.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/bus.h>
-#include <machine/intr.h>
-#include <machine/machdep.h>
-#include <machine/platform.h>
-
-#include <dev/fdt/fdt_common.h>
-
-#include <arm/amlogic/aml8726/aml8726_soc.h>
-#include <arm/amlogic/aml8726/aml8726_clkmsr.h>
-
-#if defined(SOCDEV_PA) && defined(SOCDEV_VA)
-vm_offset_t aml8726_aobus_kva_base = SOCDEV_VA;
-#else
-vm_offset_t aml8726_aobus_kva_base;
-#endif
-
-static void
-aml8726_fixup_busfreq(void)
-{
- phandle_t node;
- pcell_t freq, prop;
- ssize_t len;
-
- /*
- * Set the bus-frequency for the SoC simple-bus if it
- * needs updating (meaning the current frequency is zero).
- */
-
- if ((freq = aml8726_clkmsr_bus_frequency()) == 0 ||
- (node = OF_finddevice("/soc")) == 0 ||
- fdt_is_compatible_strict(node, "simple-bus") == 0)
- while (1);
-
- freq = cpu_to_fdt32(freq);
-
- len = OF_getencprop(node, "bus-frequency", &prop, sizeof(prop));
- if ((len / sizeof(prop)) == 1 && prop == 0)
- OF_setprop(node, "bus-frequency", (void *)&freq, sizeof(freq));
-}
-
-vm_offset_t
-platform_lastaddr(void)
-{
-
- return (devmap_lastaddr());
-}
-
-void
-platform_probe_and_attach(void)
-{
-}
-
-void
-platform_gpio_init(void)
-{
-
- /*
- * The UART console driver used for debugging early boot code
- * needs to know the virtual base address of the aobus. It's
- * expected to equal SOCDEV_VA prior to initarm calling setttb
- * ... afterwards it needs to be updated due to the new page
- * tables.
- *
- * This means there's a deadzone in initarm between setttb
- * and platform_gpio_init during which printf can't be used.
- */
- aml8726_aobus_kva_base =
- (vm_offset_t)devmap_ptov(0xc8100000, 0x100000);
-
- /*
- * The hardware mux used by clkmsr is unique to the SoC (though
- * currently clk81 is at a fixed location, however that might
- * change in the future).
- */
- aml8726_identify_soc();
-
- /*
- * My aml8726-m3 development box which identifies the CPU as
- * a Cortex A9-r2 rev 4 randomly locks up during boot when WFI
- * is used.
- */
- switch (aml8726_soc_hw_rev) {
- case AML_SOC_HW_REV_M3:
- cpufuncs.cf_sleep = (void *)cpufunc_nullop;
- break;
- default:
- break;
- }
-
- /*
- * This FDT fixup should arguably be called through fdt_fixup_table,
- * however currently there's no mechanism to specify a fixup which
- * should always be invoked.
- *
- * It needs to be called prior to the console being initialized which
- * is why it's called here, rather than from platform_late_init.
- */
- aml8726_fixup_busfreq();
-}
-
-void
-platform_late_init(void)
-{
-}
-
-/*
- * Construct static devmap entries to map out the core
- * peripherals using 1mb section mappings.
- */
-int
-platform_devmap_init(void)
-{
-
- devmap_add_entry(0xc1100000, 0x200000); /* cbus */
- devmap_add_entry(0xc4200000, 0x100000); /* pl310 */
- devmap_add_entry(0xc4300000, 0x100000); /* periph */
- devmap_add_entry(0xc8000000, 0x100000); /* apbbus */
- devmap_add_entry(0xc8100000, 0x100000); /* aobus */
- devmap_add_entry(0xc9000000, 0x800000); /* ahbbus */
- devmap_add_entry(0xd9000000, 0x100000); /* ahb */
- devmap_add_entry(0xda000000, 0x100000); /* secbus */
-
- return (0);
-}
-
-#ifndef INTRNG
-#ifndef DEV_GIC
-static int
-fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
- int *pol)
-{
-
- /*
- * The single core chips have just an Amlogic PIC.
- */
- if (!fdt_is_compatible_strict(node, "amlogic,aml8726-pic"))
- return (ENXIO);
-
- *interrupt = fdt32_to_cpu(intr[1]);
- *trig = INTR_TRIGGER_EDGE;
- *pol = INTR_POLARITY_HIGH;
-
- return (0);
-}
-#endif
-
-fdt_pic_decode_t fdt_pic_table[] = {
-#ifdef DEV_GIC
- &gic_decode_fdt,
-#else
- &fdt_pic_decode_ic,
-#endif
- NULL
-};
-#endif /* INTRNG */
sys/arm/amlogic/aml8726/aml8726_machdep.h→/dev/null
@@ -1,41 +0,0 @@
-/*-
- * Copyright 2014 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _ARM_AMLOGIC_AML8726_MACHDEP_H
-#define _ARM_AMLOGIC_AML8726_MACHDEP_H
-
-/*
- * The aobus kvm base is supplied as a global variable * only *
- * for the convience of the aml8726 UART console driver which
- * is available for use to debug early boot code.
- *
- * This variable should not be used elsewhere.
- */
-extern vm_offset_t aml8726_aobus_kva_base;
-
-#endif /* _ARM_AMLOGIC_AML8726_MACHDEP_H */
sys/arm/amlogic/aml8726/aml8726_mmc.c→/dev/null
@@ -1,1114 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 MMC host controller driver.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-
-#include <sys/gpio.h>
-
-#include <machine/bus.h>
-#include <machine/cpu.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/mmc/bridge.h>
-#include <dev/mmc/mmcbrvar.h>
-
-#include <arm/amlogic/aml8726/aml8726_mmc.h>
-
-#include "gpio_if.h"
-#include "mmcbr_if.h"
-
-struct aml8726_mmc_gpio {
- device_t dev;
- uint32_t pin;
- uint32_t pol;
-};
-
-struct aml8726_mmc_softc {
- device_t dev;
- struct resource *res[2];
- struct mtx mtx;
- struct callout ch;
- uint32_t port;
- unsigned int ref_freq;
- struct aml8726_mmc_gpio pwr_en;
- int voltages[2];
- struct aml8726_mmc_gpio vselect;
- bus_dma_tag_t dmatag;
- bus_dmamap_t dmamap;
- void *ih_cookie;
- struct mmc_host host;
- int bus_busy;
- struct mmc_command *cmd;
- uint32_t stop_timeout;
-};
-
-static struct resource_spec aml8726_mmc_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_IRQ, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-#define AML_MMC_LOCK(sc) mtx_lock(&(sc)->mtx)
-#define AML_MMC_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
-#define AML_MMC_LOCK_ASSERT(sc) mtx_assert(&(sc)->mtx, MA_OWNED)
-#define AML_MMC_LOCK_INIT(sc) \
- mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
- "mmc", MTX_DEF)
-#define AML_MMC_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx);
-
-#define CSR_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
-#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-#define CSR_BARRIER(sc, reg) bus_barrier((sc)->res[0], reg, 4, \
- (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-#define PWR_ON_FLAG(pol) ((pol) == 0 ? GPIO_PIN_LOW : \
- GPIO_PIN_HIGH)
-#define PWR_OFF_FLAG(pol) ((pol) == 0 ? GPIO_PIN_HIGH : \
- GPIO_PIN_LOW)
-
-#define MSECS_TO_TICKS(ms) (((ms)*hz)/1000 + 1)
-
-static void aml8726_mmc_timeout(void *arg);
-
-static unsigned int
-aml8726_mmc_clk(phandle_t node)
-{
- pcell_t prop;
- ssize_t len;
- phandle_t clk_node;
-
- len = OF_getencprop(node, "clocks", &prop, sizeof(prop));
- if ((len / sizeof(prop)) != 1 || prop == 0 ||
- (clk_node = OF_node_from_xref(prop)) == 0)
- return (0);
-
- len = OF_getencprop(clk_node, "clock-frequency", &prop, sizeof(prop));
- if ((len / sizeof(prop)) != 1 || prop == 0)
- return (0);
-
- return ((unsigned int)prop);
-}
-
-static uint32_t
-aml8726_mmc_freq(struct aml8726_mmc_softc *sc, uint32_t divisor)
-{
-
- return (sc->ref_freq / ((divisor + 1) * 2));
-}
-
-static uint32_t
-aml8726_mmc_div(struct aml8726_mmc_softc *sc, uint32_t desired_freq)
-{
- uint32_t divisor;
-
- divisor = sc->ref_freq / (desired_freq * 2);
-
- if (divisor == 0)
- divisor = 1;
-
- divisor -= 1;
-
- if (aml8726_mmc_freq(sc, divisor) > desired_freq)
- divisor += 1;
-
- if (divisor > (AML_MMC_CONFIG_CMD_CLK_DIV_MASK >>
- AML_MMC_CONFIG_CMD_CLK_DIV_SHIFT)) {
- divisor = AML_MMC_CONFIG_CMD_CLK_DIV_MASK >>
- AML_MMC_CONFIG_CMD_CLK_DIV_SHIFT;
- }
-
- return (divisor);
-}
-
-static void
-aml8726_mmc_mapmem(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- bus_addr_t *busaddrp;
-
- /*
- * There should only be one bus space address since
- * bus_dma_tag_create was called with nsegments = 1.
- */
-
- busaddrp = (bus_addr_t *)arg;
- *busaddrp = segs->ds_addr;
-}
-
-static int
-aml8726_mmc_power_off(struct aml8726_mmc_softc *sc)
-{
-
- if (sc->pwr_en.dev == NULL)
- return (0);
-
- return (GPIO_PIN_SET(sc->pwr_en.dev, sc->pwr_en.pin,
- PWR_OFF_FLAG(sc->pwr_en.pol)));
-}
-
-static int
-aml8726_mmc_power_on(struct aml8726_mmc_softc *sc)
-{
-
- if (sc->pwr_en.dev == NULL)
- return (0);
-
- return (GPIO_PIN_SET(sc->pwr_en.dev, sc->pwr_en.pin,
- PWR_ON_FLAG(sc->pwr_en.pol)));
-}
-
-static void
-aml8726_mmc_soft_reset(struct aml8726_mmc_softc *sc, boolean_t enable_irq)
-{
- uint32_t icr;
-
- icr = AML_MMC_IRQ_CONFIG_SOFT_RESET;
-
- if (enable_irq == true)
- icr |= AML_MMC_IRQ_CONFIG_CMD_DONE_EN;
-
- CSR_WRITE_4(sc, AML_MMC_IRQ_CONFIG_REG, icr);
- CSR_BARRIER(sc, AML_MMC_IRQ_CONFIG_REG);
-}
-
-static int
-aml8726_mmc_start_command(struct aml8726_mmc_softc *sc, struct mmc_command *cmd)
-{
- struct mmc_ios *ios = &sc->host.ios;
- bus_addr_t baddr;
- uint32_t block_size;
- uint32_t bus_width;
- uint32_t cmdr;
- uint32_t extr;
- uint32_t mcfgr;
- uint32_t nbits_per_pkg;
- uint32_t timeout;
- int error;
- struct mmc_data *data;
-
- if (cmd->opcode > 0x3f)
- return (MMC_ERR_INVALID);
-
- /*
- * Ensure the hardware state machine is in a known state.
- */
- aml8726_mmc_soft_reset(sc, true);
-
- /*
- * Start and transmission bits are per section 4.7.2 of the:
- *
- * SD Specifications Part 1
- * Physical Layer Simplified Specification
- * Version 4.10
- */
- cmdr = AML_MMC_CMD_START_BIT | AML_MMC_CMD_TRANS_BIT_HOST | cmd->opcode;
- baddr = 0;
- extr = 0;
- mcfgr = sc->port;
- timeout = AML_MMC_CMD_TIMEOUT;
-
- /*
- * If this is a linked command, then use the previous timeout.
- */
- if (cmd == cmd->mrq->stop && sc->stop_timeout)
- timeout = sc->stop_timeout;
- sc->stop_timeout = 0;
-
- if ((cmd->flags & MMC_RSP_136) != 0) {
- cmdr |= AML_MMC_CMD_RESP_CRC7_FROM_8;
- cmdr |= (133 << AML_MMC_CMD_RESP_BITS_SHIFT);
- } else if ((cmd->flags & MMC_RSP_PRESENT) != 0)
- cmdr |= (45 << AML_MMC_CMD_RESP_BITS_SHIFT);
-
- if ((cmd->flags & MMC_RSP_CRC) == 0)
- cmdr |= AML_MMC_CMD_RESP_NO_CRC7;
-
- if ((cmd->flags & MMC_RSP_BUSY) != 0)
- cmdr |= AML_MMC_CMD_CHECK_DAT0_BUSY;
-
- data = cmd->data;
-
- if (data && data->len &&
- (data->flags & (MMC_DATA_READ | MMC_DATA_WRITE)) != 0) {
- block_size = data->len;
-
- if ((data->flags & MMC_DATA_MULTI) != 0) {
- block_size = MMC_SECTOR_SIZE;
- if ((data->len % block_size) != 0)
- return (MMC_ERR_INVALID);
- }
-
- cmdr |= (((data->len / block_size) - 1) <<
- AML_MMC_CMD_REP_PKG_CNT_SHIFT);
-
- mcfgr |= (data->flags & MMC_DATA_STREAM) ?
- AML_MMC_MULT_CONFIG_STREAM_EN : 0;
-
- /*
- * The number of bits per package equals the number
- * of data bits + the number of CRC bits. There are
- * 16 bits of CRC calculate per bus line.
- *
- * A completed package appears to be detected by when
- * a counter decremented by the width underflows, thus
- * a value of zero always transfers 1 (or 4 bits depending
- * on the mode) which is why bus_width is subtracted.
- */
- bus_width = (ios->bus_width == bus_width_4) ? 4 : 1;
- nbits_per_pkg = block_size * 8 + 16 * bus_width - bus_width;
- if (nbits_per_pkg > 0x3fff)
- return (MMC_ERR_INVALID);
-
- extr |= (nbits_per_pkg << AML_MMC_EXTENSION_PKT_SIZE_SHIFT);
-
- error = bus_dmamap_load(sc->dmatag, sc->dmamap,
- data->data, data->len, aml8726_mmc_mapmem, &baddr,
- BUS_DMA_NOWAIT);
- if (error)
- return (MMC_ERR_NO_MEMORY);
-
- if ((data->flags & MMC_DATA_READ) != 0) {
- cmdr |= AML_MMC_CMD_RESP_HAS_DATA;
- bus_dmamap_sync(sc->dmatag, sc->dmamap,
- BUS_DMASYNC_PREREAD);
- timeout = AML_MMC_READ_TIMEOUT *
- (data->len / block_size);
- } else {
- cmdr |= AML_MMC_CMD_CMD_HAS_DATA;
- bus_dmamap_sync(sc->dmatag, sc->dmamap,
- BUS_DMASYNC_PREWRITE);
- timeout = AML_MMC_WRITE_TIMEOUT *
- (data->len / block_size);
- }
-
- /*
- * Stop terminates a multiblock read / write and thus
- * can take as long to execute as an actual read / write.
- */
- if (cmd->mrq->stop != NULL)
- sc->stop_timeout = timeout;
- }
-
- sc->cmd = cmd;
-
- cmd->error = MMC_ERR_NONE;
-
- if (timeout > AML_MMC_MAX_TIMEOUT)
- timeout = AML_MMC_MAX_TIMEOUT;
-
- callout_reset(&sc->ch, MSECS_TO_TICKS(timeout),
- aml8726_mmc_timeout, sc);
-
- CSR_WRITE_4(sc, AML_MMC_CMD_ARGUMENT_REG, cmd->arg);
- CSR_WRITE_4(sc, AML_MMC_MULT_CONFIG_REG, mcfgr);
- CSR_WRITE_4(sc, AML_MMC_EXTENSION_REG, extr);
- CSR_WRITE_4(sc, AML_MMC_DMA_ADDR_REG, (uint32_t)baddr);
-
- CSR_WRITE_4(sc, AML_MMC_CMD_SEND_REG, cmdr);
- CSR_BARRIER(sc, AML_MMC_CMD_SEND_REG);
-
- return (MMC_ERR_NONE);
-}
-
-static void
-aml8726_mmc_finish_command(struct aml8726_mmc_softc *sc, int mmc_error)
-{
- int mmc_stop_error;
- struct mmc_command *cmd;
- struct mmc_command *stop_cmd;
- struct mmc_data *data;
-
- AML_MMC_LOCK_ASSERT(sc);
-
- /* Clear all interrupts since the request is no longer in flight. */
- CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, AML_MMC_IRQ_STATUS_CLEAR_IRQ);
- CSR_BARRIER(sc, AML_MMC_IRQ_STATUS_REG);
-
- /* In some cases (e.g. finish called via timeout) this is a NOP. */
- callout_stop(&sc->ch);
-
- cmd = sc->cmd;
- sc->cmd = NULL;
-
- cmd->error = mmc_error;
-
- data = cmd->data;
-
- if (data && data->len &&
- (data->flags & (MMC_DATA_READ | MMC_DATA_WRITE)) != 0) {
- if ((data->flags & MMC_DATA_READ) != 0)
- bus_dmamap_sync(sc->dmatag, sc->dmamap,
- BUS_DMASYNC_POSTREAD);
- else
- bus_dmamap_sync(sc->dmatag, sc->dmamap,
- BUS_DMASYNC_POSTWRITE);
- bus_dmamap_unload(sc->dmatag, sc->dmamap);
- }
-
- /*
- * If there's a linked stop command, then start the stop command.
- * In order to establish a known state attempt the stop command
- * even if the original request encountered an error.
- */
-
- stop_cmd = (cmd->mrq->stop != cmd) ? cmd->mrq->stop : NULL;
-
- if (stop_cmd != NULL) {
- mmc_stop_error = aml8726_mmc_start_command(sc, stop_cmd);
- if (mmc_stop_error == MMC_ERR_NONE) {
- AML_MMC_UNLOCK(sc);
- return;
- }
- stop_cmd->error = mmc_stop_error;
- }
-
- AML_MMC_UNLOCK(sc);
-
- /* Execute the callback after dropping the lock. */
- if (cmd->mrq)
- cmd->mrq->done(cmd->mrq);
-}
-
-static void
-aml8726_mmc_timeout(void *arg)
-{
- struct aml8726_mmc_softc *sc = (struct aml8726_mmc_softc *)arg;
-
- /*
- * The command failed to complete in time so forcefully
- * terminate it.
- */
- aml8726_mmc_soft_reset(sc, false);
-
- /*
- * Ensure the command has terminated before continuing on
- * to things such as bus_dmamap_sync / bus_dmamap_unload.
- */
- while ((CSR_READ_4(sc, AML_MMC_IRQ_STATUS_REG) &
- AML_MMC_IRQ_STATUS_CMD_BUSY) != 0)
- cpu_spinwait();
-
- aml8726_mmc_finish_command(sc, MMC_ERR_TIMEOUT);
-}
-
-static void
-aml8726_mmc_intr(void *arg)
-{
- struct aml8726_mmc_softc *sc = (struct aml8726_mmc_softc *)arg;
- uint32_t cmdr;
- uint32_t isr;
- uint32_t mcfgr;
- uint32_t previous_byte;
- uint32_t resp;
- int mmc_error;
- unsigned int i;
-
- AML_MMC_LOCK(sc);
-
- isr = CSR_READ_4(sc, AML_MMC_IRQ_STATUS_REG);
- cmdr = CSR_READ_4(sc, AML_MMC_CMD_SEND_REG);
-
- if (sc->cmd == NULL)
- goto spurious;
-
- mmc_error = MMC_ERR_NONE;
-
- if ((isr & AML_MMC_IRQ_STATUS_CMD_DONE_IRQ) != 0) {
- /* Check for CRC errors if the command has completed. */
- if ((cmdr & AML_MMC_CMD_RESP_NO_CRC7) == 0 &&
- (isr & AML_MMC_IRQ_STATUS_RESP_CRC7_OK) == 0)
- mmc_error = MMC_ERR_BADCRC;
- if ((cmdr & AML_MMC_CMD_RESP_HAS_DATA) != 0 &&
- (isr & AML_MMC_IRQ_STATUS_RD_CRC16_OK) == 0)
- mmc_error = MMC_ERR_BADCRC;
- if ((cmdr & AML_MMC_CMD_CMD_HAS_DATA) != 0 &&
- (isr & AML_MMC_IRQ_STATUS_WR_CRC16_OK) == 0)
- mmc_error = MMC_ERR_BADCRC;
- } else {
-spurious:
-
- /*
- * Clear spurious interrupts while leaving intacted any
- * interrupts that may have occurred after we read the
- * interrupt status register.
- */
-
- CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG,
- (AML_MMC_IRQ_STATUS_CLEAR_IRQ & isr));
- CSR_BARRIER(sc, AML_MMC_IRQ_STATUS_REG);
- AML_MMC_UNLOCK(sc);
- return;
- }
-
- if ((cmdr & AML_MMC_CMD_RESP_BITS_MASK) != 0) {
- mcfgr = sc->port;
- mcfgr |= AML_MMC_MULT_CONFIG_RESP_READOUT_EN;
- CSR_WRITE_4(sc, AML_MMC_MULT_CONFIG_REG, mcfgr);
-
- if ((cmdr & AML_MMC_CMD_RESP_CRC7_FROM_8) != 0) {
- /*
- * Controller supplies 135:8 instead of
- * 127:0 so discard the leading 8 bits
- * and provide a trailing 8 zero bits
- * where the CRC belongs.
- */
-
- previous_byte = 0;
-
- for (i = 0; i < 4; i++) {
- resp = CSR_READ_4(sc, AML_MMC_CMD_ARGUMENT_REG);
- sc->cmd->resp[3 - i] = (resp << 8) |
- previous_byte;
- previous_byte = (resp >> 24) & 0xff;
- }
- } else
- sc->cmd->resp[0] = CSR_READ_4(sc,
- AML_MMC_CMD_ARGUMENT_REG);
- }
-
- if ((isr & AML_MMC_IRQ_STATUS_CMD_BUSY) != 0 &&
- /*
- * A multiblock operation may keep the hardware
- * busy until stop transmission is executed.
- */
- (isr & AML_MMC_IRQ_STATUS_CMD_DONE_IRQ) == 0) {
- if (mmc_error == MMC_ERR_NONE)
- mmc_error = MMC_ERR_FAILED;
-
- /*
- * Issue a soft reset to terminate the command.
- *
- * Ensure the command has terminated before continuing on
- * to things such as bus_dmamap_sync / bus_dmamap_unload.
- */
-
- aml8726_mmc_soft_reset(sc, false);
-
- while ((CSR_READ_4(sc, AML_MMC_IRQ_STATUS_REG) &
- AML_MMC_IRQ_STATUS_CMD_BUSY) != 0)
- cpu_spinwait();
- }
-
- aml8726_mmc_finish_command(sc, mmc_error);
-}
-
-static int
-aml8726_mmc_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-mmc"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 MMC");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_mmc_attach(device_t dev)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(dev);
- char *function_name;
- char *voltages;
- char *voltage;
- int error;
- int nvoltages;
- pcell_t prop[3];
- phandle_t node;
- ssize_t len;
- device_t child;
-
- sc->dev = dev;
-
- node = ofw_bus_get_node(dev);
-
- sc->ref_freq = aml8726_mmc_clk(node);
-
- if (sc->ref_freq == 0) {
- device_printf(dev, "missing clocks attribute in FDT\n");
- return (ENXIO);
- }
-
- /*
- * The pins must be specified as part of the device in order
- * to know which port to used.
- */
-
- len = OF_getencprop(node, "pinctrl-0", prop, sizeof(prop));
-
- if ((len / sizeof(prop[0])) != 1 || prop[0] == 0) {
- device_printf(dev, "missing pinctrl-0 attribute in FDT\n");
- return (ENXIO);
- }
-
- len = OF_getprop_alloc(OF_node_from_xref(prop[0]), "amlogic,function",
- (void **)&function_name);
-
- if (len < 0) {
- device_printf(dev,
- "missing amlogic,function attribute in FDT\n");
- return (ENXIO);
- }
-
- if (strncmp("sdio-a", function_name, len) == 0)
- sc->port = AML_MMC_MULT_CONFIG_PORT_A;
- else if (strncmp("sdio-b", function_name, len) == 0)
- sc->port = AML_MMC_MULT_CONFIG_PORT_B;
- else if (strncmp("sdio-c", function_name, len) == 0)
- sc->port = AML_MMC_MULT_CONFIG_PORT_C;
- else {
- device_printf(dev, "unknown function attribute %.*s in FDT\n",
- len, function_name);
- OF_prop_free(function_name);
- return (ENXIO);
- }
-
- OF_prop_free(function_name);
-
- sc->pwr_en.dev = NULL;
-
- len = OF_getencprop(node, "mmc-pwr-en", prop, sizeof(prop));
- if (len > 0) {
- if ((len / sizeof(prop[0])) == 3) {
- sc->pwr_en.dev = OF_device_from_xref(prop[0]);
- sc->pwr_en.pin = prop[1];
- sc->pwr_en.pol = prop[2];
- }
-
- if (sc->pwr_en.dev == NULL) {
- device_printf(dev,
- "unable to process mmc-pwr-en attribute in FDT\n");
- return (ENXIO);
- }
-
- /* Turn off power and then configure the output driver. */
- if (aml8726_mmc_power_off(sc) != 0 ||
- GPIO_PIN_SETFLAGS(sc->pwr_en.dev, sc->pwr_en.pin,
- GPIO_PIN_OUTPUT) != 0) {
- device_printf(dev,
- "could not use gpio to control power\n");
- return (ENXIO);
- }
- }
-
- len = OF_getprop_alloc(node, "mmc-voltages",
- (void **)&voltages);
-
- if (len < 0) {
- device_printf(dev, "missing mmc-voltages attribute in FDT\n");
- return (ENXIO);
- }
-
- sc->voltages[0] = 0;
- sc->voltages[1] = 0;
-
- voltage = voltages;
- nvoltages = 0;
-
- while (len && nvoltages < 2) {
- if (strncmp("1.8", voltage, len) == 0)
- sc->voltages[nvoltages] = MMC_OCR_LOW_VOLTAGE;
- else if (strncmp("3.3", voltage, len) == 0)
- sc->voltages[nvoltages] = MMC_OCR_320_330 |
- MMC_OCR_330_340;
- else {
- device_printf(dev,
- "unknown voltage attribute %.*s in FDT\n",
- len, voltage);
- OF_prop_free(voltages);
- return (ENXIO);
- }
-
- nvoltages++;
-
- /* queue up next string */
- while (*voltage && len) {
- voltage++;
- len--;
- }
- if (len) {
- voltage++;
- len--;
- }
- }
-
- OF_prop_free(voltages);
-
- sc->vselect.dev = NULL;
-
- len = OF_getencprop(node, "mmc-vselect", prop, sizeof(prop));
- if (len > 0) {
- if ((len / sizeof(prop[0])) == 2) {
- sc->vselect.dev = OF_device_from_xref(prop[0]);
- sc->vselect.pin = prop[1];
- sc->vselect.pol = 1;
- }
-
- if (sc->vselect.dev == NULL) {
- device_printf(dev,
- "unable to process mmc-vselect attribute in FDT\n");
- return (ENXIO);
- }
-
- /*
- * With the power off select voltage 0 and then
- * configure the output driver.
- */
- if (GPIO_PIN_SET(sc->vselect.dev, sc->vselect.pin, 0) != 0 ||
- GPIO_PIN_SETFLAGS(sc->vselect.dev, sc->vselect.pin,
- GPIO_PIN_OUTPUT) != 0) {
- device_printf(dev,
- "could not use gpio to set voltage\n");
- return (ENXIO);
- }
- }
-
- if (nvoltages == 0) {
- device_printf(dev, "no voltages in FDT\n");
- return (ENXIO);
- } else if (nvoltages == 1 && sc->vselect.dev != NULL) {
- device_printf(dev, "only one voltage in FDT\n");
- return (ENXIO);
- } else if (nvoltages == 2 && sc->vselect.dev == NULL) {
- device_printf(dev, "too many voltages in FDT\n");
- return (ENXIO);
- }
-
- if (bus_alloc_resources(dev, aml8726_mmc_spec, sc->res)) {
- device_printf(dev, "could not allocate resources for device\n");
- return (ENXIO);
- }
-
- AML_MMC_LOCK_INIT(sc);
-
- error = bus_dma_tag_create(bus_get_dma_tag(dev), AML_MMC_ALIGN_DMA, 0,
- BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
- AML_MMC_MAX_DMA, 1, AML_MMC_MAX_DMA, 0, NULL, NULL, &sc->dmatag);
- if (error)
- goto fail;
-
- error = bus_dmamap_create(sc->dmatag, 0, &sc->dmamap);
-
- if (error)
- goto fail;
-
- error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE,
- NULL, aml8726_mmc_intr, sc, &sc->ih_cookie);
- if (error) {
- device_printf(dev, "could not setup interrupt handler\n");
- goto fail;
- }
-
- callout_init_mtx(&sc->ch, &sc->mtx, CALLOUT_RETURNUNLOCKED);
-
- sc->host.f_min = aml8726_mmc_freq(sc, aml8726_mmc_div(sc, 200000));
- sc->host.f_max = aml8726_mmc_freq(sc, aml8726_mmc_div(sc, 50000000));
- sc->host.host_ocr = sc->voltages[0] | sc->voltages[1];
- sc->host.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_HSPEED;
-
- child = device_add_child(dev, "mmc", -1);
-
- if (!child) {
- device_printf(dev, "could not add mmc\n");
- error = ENXIO;
- goto fail;
- }
-
- error = device_probe_and_attach(child);
-
- if (error) {
- device_printf(dev, "could not attach mmc\n");
- goto fail;
- }
-
- return (0);
-
-fail:
- if (sc->ih_cookie)
- bus_teardown_intr(dev, sc->res[1], sc->ih_cookie);
-
- if (sc->dmamap)
- bus_dmamap_destroy(sc->dmatag, sc->dmamap);
-
- if (sc->dmatag)
- bus_dma_tag_destroy(sc->dmatag);
-
- AML_MMC_LOCK_DESTROY(sc);
-
- aml8726_mmc_power_off(sc);
-
- bus_release_resources(dev, aml8726_mmc_spec, sc->res);
-
- return (error);
-}
-
-static int
-aml8726_mmc_detach(device_t dev)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(dev);
-
- AML_MMC_LOCK(sc);
-
- if (sc->cmd != NULL) {
- AML_MMC_UNLOCK(sc);
- return (EBUSY);
- }
-
- /*
- * Turn off the power, reset the hardware state machine,
- * disable the interrupts, and clear the interrupts.
- */
- (void)aml8726_mmc_power_off(sc);
- aml8726_mmc_soft_reset(sc, false);
- CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, AML_MMC_IRQ_STATUS_CLEAR_IRQ);
-
- /* This should be a NOP since no command was in flight. */
- callout_stop(&sc->ch);
-
- AML_MMC_UNLOCK(sc);
-
- bus_generic_detach(dev);
-
- bus_teardown_intr(dev, sc->res[1], sc->ih_cookie);
-
- bus_dmamap_destroy(sc->dmatag, sc->dmamap);
-
- bus_dma_tag_destroy(sc->dmatag);
-
- AML_MMC_LOCK_DESTROY(sc);
-
- bus_release_resources(dev, aml8726_mmc_spec, sc->res);
-
- return (0);
-}
-
-static int
-aml8726_mmc_shutdown(device_t dev)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(dev);
-
- /*
- * Turn off the power, reset the hardware state machine,
- * disable the interrupts, and clear the interrupts.
- */
- (void)aml8726_mmc_power_off(sc);
- aml8726_mmc_soft_reset(sc, false);
- CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, AML_MMC_IRQ_STATUS_CLEAR_IRQ);
-
- return (0);
-}
-
-static int
-aml8726_mmc_update_ios(device_t bus, device_t child)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(bus);
- struct mmc_ios *ios = &sc->host.ios;
- int error;
- int i;
- uint32_t cfgr;
-
- cfgr = (2 << AML_MMC_CONFIG_WR_CRC_STAT_SHIFT) |
- (2 << AML_MMC_CONFIG_WR_DELAY_SHIFT) |
- AML_MMC_CONFIG_DMA_ENDIAN_SBW |
- (39 << AML_MMC_CONFIG_CMD_ARG_BITS_SHIFT);
-
- switch (ios->bus_width) {
- case bus_width_4:
- cfgr |= AML_MMC_CONFIG_BUS_WIDTH_4;
- break;
- case bus_width_1:
- cfgr |= AML_MMC_CONFIG_BUS_WIDTH_1;
- break;
- default:
- return (EINVAL);
- }
-
- cfgr |= aml8726_mmc_div(sc, ios->clock) <<
- AML_MMC_CONFIG_CMD_CLK_DIV_SHIFT;
-
- CSR_WRITE_4(sc, AML_MMC_CONFIG_REG, cfgr);
-
- error = 0;
-
- switch (ios->power_mode) {
- case power_up:
- /*
- * Configure and power on the regulator so that the
- * voltage stabilizes prior to powering on the card.
- */
- if (sc->vselect.dev != NULL) {
- for (i = 0; i < 2; i++)
- if ((sc->voltages[i] & (1 << ios->vdd)) != 0)
- break;
- if (i >= 2)
- return (EINVAL);
- error = GPIO_PIN_SET(sc->vselect.dev,
- sc->vselect.pin, i);
- }
- break;
- case power_on:
- error = aml8726_mmc_power_on(sc);
- break;
- case power_off:
- error = aml8726_mmc_power_off(sc);
- break;
- default:
- return (EINVAL);
- }
-
- return (error);
-}
-
-static int
-aml8726_mmc_request(device_t bus, device_t child, struct mmc_request *req)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(bus);
- int mmc_error;
-
- AML_MMC_LOCK(sc);
-
- if (sc->cmd != NULL) {
- AML_MMC_UNLOCK(sc);
- return (EBUSY);
- }
-
- mmc_error = aml8726_mmc_start_command(sc, req->cmd);
-
- AML_MMC_UNLOCK(sc);
-
- /* Execute the callback after dropping the lock. */
- if (mmc_error != MMC_ERR_NONE) {
- req->cmd->error = mmc_error;
- req->done(req);
- }
-
- return (0);
-}
-
-static int
-aml8726_mmc_read_ivar(device_t bus, device_t child,
- int which, uintptr_t *result)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(bus);
-
- switch (which) {
- case MMCBR_IVAR_BUS_MODE:
- *(int *)result = sc->host.ios.bus_mode;
- break;
- case MMCBR_IVAR_BUS_WIDTH:
- *(int *)result = sc->host.ios.bus_width;
- break;
- case MMCBR_IVAR_CHIP_SELECT:
- *(int *)result = sc->host.ios.chip_select;
- break;
- case MMCBR_IVAR_CLOCK:
- *(int *)result = sc->host.ios.clock;
- break;
- case MMCBR_IVAR_F_MIN:
- *(int *)result = sc->host.f_min;
- break;
- case MMCBR_IVAR_F_MAX:
- *(int *)result = sc->host.f_max;
- break;
- case MMCBR_IVAR_HOST_OCR:
- *(int *)result = sc->host.host_ocr;
- break;
- case MMCBR_IVAR_MODE:
- *(int *)result = sc->host.mode;
- break;
- case MMCBR_IVAR_OCR:
- *(int *)result = sc->host.ocr;
- break;
- case MMCBR_IVAR_POWER_MODE:
- *(int *)result = sc->host.ios.power_mode;
- break;
- case MMCBR_IVAR_RETUNE_REQ:
- *(int *)result = return_req_none;
- case MMCBR_IVAR_VDD:
- *(int *)result = sc->host.ios.vdd;
- break;
- case MMCBR_IVAR_VCCQ:
- *result = sc->sc_host.ios.vccq;
- break;
- case MMCBR_IVAR_CAPS:
- *(int *)result = sc->host.caps;
- break;
- case MMCBR_IVAR_TIMING:
- *(int *)result = sc->sc_host.ios.timing;
- break;
- case MMCBR_IVAR_MAX_DATA:
- *(int *)result = AML_MMC_MAX_DMA / MMC_SECTOR_SIZE;
- break;
- case MMCBR_IVAR_MAX_BUSY_TIMEOUT:
- *(int *)result = 1000000; /* 1s max */
- break;
- default:
- return (EINVAL);
- }
-
- return (0);
-}
-
-static int
-aml8726_mmc_write_ivar(device_t bus, device_t child,
- int which, uintptr_t value)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(bus);
-
- switch (which) {
- case MMCBR_IVAR_BUS_MODE:
- sc->host.ios.bus_mode = value;
- break;
- case MMCBR_IVAR_BUS_WIDTH:
- sc->host.ios.bus_width = value;
- break;
- case MMCBR_IVAR_CHIP_SELECT:
- sc->host.ios.chip_select = value;
- break;
- case MMCBR_IVAR_CLOCK:
- sc->host.ios.clock = value;
- break;
- case MMCBR_IVAR_MODE:
- sc->host.mode = value;
- break;
- case MMCBR_IVAR_OCR:
- sc->host.ocr = value;
- break;
- case MMCBR_IVAR_POWER_MODE:
- sc->host.ios.power_mode = value;
- break;
- case MMCBR_IVAR_VDD:
- sc->host.ios.vdd = value;
- break;
- case MMCBR_IVAR_VCCQ:
- sc->sc_host.ios.vccq = value;
- break;
- case MMCBR_IVAR_TIMING:
- sc->sc_host.ios.timing = value;
- break;
- /* These are read-only */
- case MMCBR_IVAR_CAPS:
- case MMCBR_IVAR_HOST_OCR:
- case MMCBR_IVAR_F_MIN:
- case MMCBR_IVAR_F_MAX:
- case MMCBR_IVAR_MAX_DATA:
- default:
- return (EINVAL);
- }
-
- return (0);
-}
-
-static int
-aml8726_mmc_get_ro(device_t bus, device_t child)
-{
-
- return (0);
-}
-
-static int
-aml8726_mmc_acquire_host(device_t bus, device_t child)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(bus);
-
- AML_MMC_LOCK(sc);
-
- while (sc->bus_busy)
- mtx_sleep(sc, &sc->mtx, PZERO, "mmc", hz / 5);
- sc->bus_busy++;
-
- AML_MMC_UNLOCK(sc);
-
- return (0);
-}
-
-static int
-aml8726_mmc_release_host(device_t bus, device_t child)
-{
- struct aml8726_mmc_softc *sc = device_get_softc(bus);
-
- AML_MMC_LOCK(sc);
-
- sc->bus_busy--;
- wakeup(sc);
-
- AML_MMC_UNLOCK(sc);
-
- return (0);
-}
-
-static device_method_t aml8726_mmc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_mmc_probe),
- DEVMETHOD(device_attach, aml8726_mmc_attach),
- DEVMETHOD(device_detach, aml8726_mmc_detach),
- DEVMETHOD(device_shutdown, aml8726_mmc_shutdown),
-
- /* Bus interface */
- DEVMETHOD(bus_read_ivar, aml8726_mmc_read_ivar),
- DEVMETHOD(bus_write_ivar, aml8726_mmc_write_ivar),
-
- /* MMC bridge interface */
- DEVMETHOD(mmcbr_update_ios, aml8726_mmc_update_ios),
- DEVMETHOD(mmcbr_request, aml8726_mmc_request),
- DEVMETHOD(mmcbr_get_ro, aml8726_mmc_get_ro),
- DEVMETHOD(mmcbr_acquire_host, aml8726_mmc_acquire_host),
- DEVMETHOD(mmcbr_release_host, aml8726_mmc_release_host),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_mmc_driver = {
- "aml8726_mmc",
- aml8726_mmc_methods,
- sizeof(struct aml8726_mmc_softc),
-};
-
-static devclass_t aml8726_mmc_devclass;
-
-DRIVER_MODULE(aml8726_mmc, simplebus, aml8726_mmc_driver,
- aml8726_mmc_devclass, NULL, NULL);
-MODULE_DEPEND(aml8726_mmc, aml8726_gpio, 1, 1, 1);
-MMC_DECLARE_BRIDGE(aml8726_mmc);
sys/arm/amlogic/aml8726/aml8726_mmc.h→/dev/null
@@ -1,122 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _ARM_AMLOGIC_AML8726_MMC_H
-#define _ARM_AMLOGIC_AML8726_MMC_H
-
-#define AML_MMC_ALIGN_DMA 4
-#define AML_MMC_MAX_DMA 4096
-
-/*
- * Timeouts are in milliseconds
- *
- * Read and write are per section 4.6.2 of the:
- *
- * SD Specifications Part 1
- * Physical Layer Simplified Specification
- * Version 4.10
- */
-#define AML_MMC_CMD_TIMEOUT 50
-#define AML_MMC_READ_TIMEOUT 100
-#define AML_MMC_WRITE_TIMEOUT 500
-#define AML_MMC_MAX_TIMEOUT 5000
-
-#define AML_MMC_CMD_ARGUMENT_REG 0
-
-#define AML_MMC_CMD_SEND_REG 4
-#define AML_MMC_CMD_REP_PKG_CNT_MASK (0xffU << 24)
-#define AML_MMC_CMD_REP_PKG_CNT_SHIFT 24
-#define AML_MMC_CMD_CMD_HAS_DATA (1 << 20)
-#define AML_MMC_CMD_CHECK_DAT0_BUSY (1 << 19)
-#define AML_MMC_CMD_RESP_CRC7_FROM_8 (1 << 18)
-#define AML_MMC_CMD_RESP_HAS_DATA (1 << 17)
-#define AML_MMC_CMD_RESP_NO_CRC7 (1 << 16)
-#define AML_MMC_CMD_RESP_BITS_MASK (0xff << 8)
-#define AML_MMC_CMD_RESP_BITS_SHIFT 8
-#define AML_MMC_CMD_START_BIT (0 << 7)
-#define AML_MMC_CMD_TRANS_BIT_HOST (1 << 6)
-#define AML_MMC_CMD_INDEX_MASK 0x3f
-#define AML_MMC_CMD_INDEX_SHIFT 0
-
-#define AML_MMC_CONFIG_REG 8
-#define AML_MMC_CONFIG_WR_CRC_STAT_MASK (7U << 29)
-#define AML_MMC_CONFIG_WR_CRC_STAT_SHIFT 29
-#define AML_MMC_CONFIG_WR_DELAY_MASK (0x3f << 23)
-#define AML_MMC_CONFIG_WR_DELAY_SHIFT 23
-#define AML_MMC_CONFIG_DMA_ENDIAN_MASK (3 << 21)
-#define AML_MMC_CONFIG_DMA_ENDIAN_NC (0 << 21)
-#define AML_MMC_CONFIG_DMA_ENDIAN_SB (1 << 21)
-#define AML_MMC_CONFIG_DMA_ENDIAN_SW (2 << 21)
-#define AML_MMC_CONFIG_DMA_ENDIAN_SBW (3 << 21)
-#define AML_MMC_CONFIG_BUS_WIDTH_MASK (1 << 20)
-#define AML_MMC_CONFIG_BUS_WIDTH_1 (0 << 20)
-#define AML_MMC_CONFIG_BUS_WIDTH_4 (1 << 20)
-#define AML_MMC_CONFIG_DATA_NEG_EDGE (1 << 19)
-#define AML_MMC_CONFIG_DONT_DELAY_DATA (1 << 18)
-#define AML_MMC_CONFIG_CMD_ARG_BITS_MASK (0x3f << 12)
-#define AML_MMC_CONFIG_CMD_ARG_BITS_SHIFT 12
-#define AML_MMC_CONFIG_CMD_POS_EDGE (1 << 11)
-#define AML_MMC_CONFIG_CMD_NO_CRC (1 << 10)
-#define AML_MMC_CONFIG_CMD_CLK_DIV_MASK 0x3ff
-#define AML_MMC_CONFIG_CMD_CLK_DIV_SHIFT 0
-
-#define AML_MMC_IRQ_STATUS_REG 12
-#define AML_MMC_IRQ_STATUS_TIMER_CNT_MASK (0x1fffU << 19)
-#define AML_MMC_IRQ_STATUS_TIMER_CNT_SHIFT 19
-#define AML_MMC_IRQ_STATUS_TIMER_EN (1 << 18)
-#define AML_MMC_IRQ_STATUS_TIMEOUT_IRQ (1 << 16)
-#define AML_MMC_IRQ_STATUS_CMD_DONE_IRQ (1 << 9)
-#define AML_MMC_IRQ_STATUS_WR_CRC16_OK (1 << 7)
-#define AML_MMC_IRQ_STATUS_RD_CRC16_OK (1 << 6)
-#define AML_MMC_IRQ_STATUS_RESP_CRC7_OK (1 << 5)
-#define AML_MMC_IRQ_STATUS_CMD_BUSY (1 << 4)
-#define AML_MMC_IRQ_STATUS_CLEAR_IRQ 0x10700
-
-#define AML_MMC_IRQ_CONFIG_REG 16
-#define AML_MMC_IRQ_CONFIG_SOFT_RESET (1 << 15)
-#define AML_MMC_IRQ_CONFIG_CMD_DONE_EN (1 << 4)
-
-#define AML_MMC_MULT_CONFIG_REG 20
-#define AML_MMC_MULT_CONFIG_RESP_INDEX_MASK (0xf << 12)
-#define AML_MMC_MULT_CONFIG_RESP_INDEX_SHIFT 12
-#define AML_MMC_MULT_CONFIG_RESP_READOUT_EN (1 << 8)
-#define AML_MMC_MULT_CONFIG_STREAM_8_MODE (1 << 5)
-#define AML_MMC_MULT_CONFIG_STREAM_EN (1 << 4)
-#define AML_MMC_MULT_CONFIG_PORT_MASK 3
-#define AML_MMC_MULT_CONFIG_PORT_A 0
-#define AML_MMC_MULT_CONFIG_PORT_B 1
-#define AML_MMC_MULT_CONFIG_PORT_C 2
-
-#define AML_MMC_DMA_ADDR_REG 24
-
-#define AML_MMC_EXTENSION_REG 28
-#define AML_MMC_EXTENSION_NO_CRC16 (1 << 30)
-#define AML_MMC_EXTENSION_PKT_SIZE_MASK (0x3fff << 16)
-#define AML_MMC_EXTENSION_PKT_SIZE_SHIFT 16
-
-#endif /* _ARM_AMLOGIC_AML8726_MMC_H */
sys/arm/amlogic/aml8726/aml8726_mp.c→/dev/null
@@ -1,625 +0,0 @@
-/*-
- * Copyright 2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 multiprocessor support.
- *
- * Some processors require powering on which involves poking registers
- * on the aobus and cbus ... it's expected that these locations are set
- * in stone.
- *
- * Locking is not used as these routines should only be called by the BP
- * during startup and should complete prior to the APs being released (the
- * issue being to ensure that a register such as AML_SOC_CPU_CLK_CNTL_REG
- * is not concurrently modified).
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-#include <sys/smp.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/cpu.h>
-#include <machine/bus.h>
-#include <machine/smp.h>
-#include <machine/fdt.h>
-#include <machine/intr.h>
-
-#include <dev/fdt/fdt_common.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <arm/amlogic/aml8726/aml8726_soc.h>
-
-static const char *scu_compatible[] = {
- "arm,cortex-a5-scu",
- "arm,cortex-a9-scu",
- NULL
-};
-
-static const char *scu_errata_764369[] = {
- "arm,cortex-a9-scu",
- NULL
-};
-
-static const char *cpucfg_compatible[] = {
- "amlogic,aml8726-cpuconfig",
- NULL
-};
-
-static struct {
- boolean_t errata_764369;
- u_long scu_size;
- struct resource scu_res;
- u_long cpucfg_size;
- struct resource cpucfg_res;
- struct resource aobus_res;
- struct resource cbus_res;
-} aml8726_smp;
-
-#define AML_SCU_CONTROL_REG 0
-#define AML_SCU_CONTROL_ENABLE 1
-#define AML_SCU_CONFIG_REG 4
-#define AML_SCU_CONFIG_NCPU_MASK 0x3
-#define AML_SCU_CPU_PWR_STATUS_REG 8
-#define AML_SCU_CPU_PWR_STATUS_CPU3_MASK (3 << 24)
-#define AML_SCU_CPU_PWR_STATUS_CPU2_MASK (3 << 16)
-#define AML_SCU_CPU_PWR_STATUS_CPU1_MASK (3 << 8)
-#define AML_SCU_CPU_PWR_STATUS_CPU0_MASK 3
-#define AML_SCU_INV_TAGS_REG 12
-#define AML_SCU_DIAG_CONTROL_REG 48
-#define AML_SCU_DIAG_CONTROL_DISABLE_MIGBIT 1
-
-#define AML_CPUCONF_CONTROL_REG 0
-#define AML_CPUCONF_CPU1_ADDR_REG 4
-#define AML_CPUCONF_CPU2_ADDR_REG 8
-#define AML_CPUCONF_CPU3_ADDR_REG 12
-
-/* aobus */
-
-#define AML_M8_CPU_PWR_CNTL0_REG 0xe0
-#define AML_M8B_CPU_PWR_CNTL0_MODE_CPU3_MASK (3 << 22)
-#define AML_M8B_CPU_PWR_CNTL0_MODE_CPU2_MASK (3 << 20)
-#define AML_M8B_CPU_PWR_CNTL0_MODE_CPU1_MASK (3 << 18)
-
-#define AML_M8_CPU_PWR_CNTL0_ISO_CPU3 (1 << 3)
-#define AML_M8_CPU_PWR_CNTL0_ISO_CPU2 (1 << 2)
-#define AML_M8_CPU_PWR_CNTL0_ISO_CPU1 (1 << 1)
-
-#define AML_M8_CPU_PWR_CNTL1_REG 0xe4
-#define AML_M8B_CPU_PWR_CNTL1_PWR_CPU3 (1 << 19)
-#define AML_M8B_CPU_PWR_CNTL1_PWR_CPU2 (1 << 18)
-#define AML_M8B_CPU_PWR_CNTL1_PWR_CPU1 (1 << 17)
-
-#define AML_M8_CPU_PWR_CNTL1_MODE_CPU3_MASK (3 << 8)
-#define AML_M8_CPU_PWR_CNTL1_MODE_CPU2_MASK (3 << 6)
-#define AML_M8_CPU_PWR_CNTL1_MODE_CPU1_MASK (3 << 4)
-
-#define AML_M8B_CPU_PWR_MEM_PD0_REG 0xf4
-#define AML_M8B_CPU_PWR_MEM_PD0_CPU3 (0xf << 20)
-#define AML_M8B_CPU_PWR_MEM_PD0_CPU2 (0xf << 24)
-#define AML_M8B_CPU_PWR_MEM_PD0_CPU1 (0xf << 28)
-
-/* cbus */
-
-#define AML_SOC_CPU_CLK_CNTL_REG 0x419c
-#define AML_M8_CPU_CLK_CNTL_RESET_CPU3 (1 << 27)
-#define AML_M8_CPU_CLK_CNTL_RESET_CPU2 (1 << 26)
-#define AML_M8_CPU_CLK_CNTL_RESET_CPU1 (1 << 25)
-
-#define SCU_WRITE_4(reg, value) bus_write_4(&aml8726_smp.scu_res, \
- (reg), (value))
-#define SCU_READ_4(reg) bus_read_4(&aml8726_smp.scu_res, (reg))
-#define SCU_BARRIER(reg) bus_barrier(&aml8726_smp.scu_res, \
- (reg), 4, (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-#define CPUCONF_WRITE_4(reg, value) bus_write_4(&aml8726_smp.cpucfg_res, \
- (reg), (value))
-#define CPUCONF_READ_4(reg) bus_read_4(&aml8726_smp.cpucfg_res, \
- (reg))
-#define CPUCONF_BARRIER(reg) bus_barrier(&aml8726_smp.cpucfg_res, \
- (reg), 4, (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-#define AOBUS_WRITE_4(reg, value) bus_write_4(&aml8726_smp.aobus_res, \
- (reg), (value))
-#define AOBUS_READ_4(reg) bus_read_4(&aml8726_smp.aobus_res, \
- (reg))
-#define AOBUS_BARRIER(reg) bus_barrier(&aml8726_smp.aobus_res, \
- (reg), 4, (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-#define CBUS_WRITE_4(reg, value) bus_write_4(&aml8726_smp.cbus_res, \
- (reg), (value))
-#define CBUS_READ_4(reg) bus_read_4(&aml8726_smp.cbus_res, \
- (reg))
-#define CBUS_BARRIER(reg) bus_barrier(&aml8726_smp.cbus_res, \
- (reg), 4, (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-static phandle_t
-find_node_for_device(const char *device, const char **compatible)
-{
- int i;
- phandle_t node;
-
- /*
- * Try to access the node directly i.e. through /aliases/.
- */
-
- if ((node = OF_finddevice(device)) != -1)
- for (i = 0; compatible[i]; i++)
- if (fdt_is_compatible_strict(node, compatible[i]))
- return node;
-
- /*
- * Find the node the long way.
- */
-
- for (i = 0; compatible[i]; i++) {
- if ((node = OF_finddevice("/soc")) == -1)
- return (0);
-
- if ((node = fdt_find_compatible(node, compatible[i], 1)) != 0)
- return node;
- }
-
- return (0);
-}
-
-static int
-alloc_resource_for_node(phandle_t node, struct resource *res, u_long *size)
-{
- int err;
- u_long pbase, psize;
- u_long start;
-
- if ((err = fdt_get_range(OF_parent(node), 0, &pbase, &psize)) != 0 ||
- (err = fdt_regsize(node, &start, size)) != 0)
- return (err);
-
- start += pbase;
-
- memset(res, 0, sizeof(*res));
-
- res->r_bustag = fdtbus_bs_tag;
-
- err = bus_space_map(res->r_bustag, start, *size, 0, &res->r_bushandle);
-
- return (err);
-}
-
-static void
-power_on_cpu(int cpu)
-{
- uint32_t scpsr;
- uint32_t value;
-
- if (cpu <= 0)
- return;
-
- /*
- * Power on the CPU if the intricate details are known, otherwise
- * just hope for the best (it may have already be powered on by
- * the hardware / firmware).
- */
-
- switch (aml8726_soc_hw_rev) {
- case AML_SOC_HW_REV_M8:
- case AML_SOC_HW_REV_M8B:
- /*
- * Set the SCU power status for the CPU to normal mode.
- */
- scpsr = SCU_READ_4(AML_SCU_CPU_PWR_STATUS_REG);
- scpsr &= ~(AML_SCU_CPU_PWR_STATUS_CPU1_MASK << ((cpu - 1) * 8));
- SCU_WRITE_4(AML_SCU_CPU_PWR_STATUS_REG, scpsr);
- SCU_BARRIER(AML_SCU_CPU_PWR_STATUS_REG);
-
- if (aml8726_soc_hw_rev == AML_SOC_HW_REV_M8B) {
- /*
- * Reset may cause the current power status from the
- * actual CPU to be written to the SCU (over-writing
- * the value we've just written) so set it to normal
- * mode as well.
- */
- value = AOBUS_READ_4(AML_M8_CPU_PWR_CNTL0_REG);
- value &= ~(AML_M8B_CPU_PWR_CNTL0_MODE_CPU1_MASK <<
- ((cpu - 1) * 2));
- AOBUS_WRITE_4(AML_M8_CPU_PWR_CNTL0_REG, value);
- AOBUS_BARRIER(AML_M8_CPU_PWR_CNTL0_REG);
- }
-
- DELAY(5);
-
- /*
- * Assert reset.
- */
- value = CBUS_READ_4(AML_SOC_CPU_CLK_CNTL_REG);
- value |= AML_M8_CPU_CLK_CNTL_RESET_CPU1 << (cpu - 1);
- CBUS_WRITE_4(AML_SOC_CPU_CLK_CNTL_REG, value);
- CBUS_BARRIER(AML_SOC_CPU_CLK_CNTL_REG);
-
- if (aml8726_soc_hw_rev == AML_SOC_HW_REV_M8B) {
- /*
- * Release RAM pull-down.
- */
- value = AOBUS_READ_4(AML_M8B_CPU_PWR_MEM_PD0_REG);
- value &= ~((uint32_t)AML_M8B_CPU_PWR_MEM_PD0_CPU1 >>
- ((cpu - 1) * 4));
- AOBUS_WRITE_4(AML_M8B_CPU_PWR_MEM_PD0_REG, value);
- AOBUS_BARRIER(AML_M8B_CPU_PWR_MEM_PD0_REG);
- }
-
- /*
- * Power on CPU.
- */
- value = AOBUS_READ_4(AML_M8_CPU_PWR_CNTL1_REG);
- value &= ~(AML_M8_CPU_PWR_CNTL1_MODE_CPU1_MASK <<
- ((cpu - 1) * 2));
- AOBUS_WRITE_4(AML_M8_CPU_PWR_CNTL1_REG, value);
- AOBUS_BARRIER(AML_M8_CPU_PWR_CNTL1_REG);
-
- DELAY(10);
-
- if (aml8726_soc_hw_rev == AML_SOC_HW_REV_M8B) {
- /*
- * Wait for power on confirmation.
- */
- for ( ; ; ) {
- value = AOBUS_READ_4(AML_M8_CPU_PWR_CNTL1_REG);
- value &= AML_M8B_CPU_PWR_CNTL1_PWR_CPU1 <<
- (cpu - 1);
- if (value)
- break;
- DELAY(10);
- }
- }
-
- /*
- * Release peripheral clamp.
- */
- value = AOBUS_READ_4(AML_M8_CPU_PWR_CNTL0_REG);
- value &= ~(AML_M8_CPU_PWR_CNTL0_ISO_CPU1 << (cpu - 1));
- AOBUS_WRITE_4(AML_M8_CPU_PWR_CNTL0_REG, value);
- AOBUS_BARRIER(AML_M8_CPU_PWR_CNTL0_REG);
-
- /*
- * Release reset.
- */
- value = CBUS_READ_4(AML_SOC_CPU_CLK_CNTL_REG);
- value &= ~(AML_M8_CPU_CLK_CNTL_RESET_CPU1 << (cpu - 1));
- CBUS_WRITE_4(AML_SOC_CPU_CLK_CNTL_REG, value);
- CBUS_BARRIER(AML_SOC_CPU_CLK_CNTL_REG);
-
- if (aml8726_soc_hw_rev == AML_SOC_HW_REV_M8B) {
- /*
- * The Amlogic Linux platform code sets the SCU power
- * status for the CPU again for some reason so we
- * follow suit (perhaps in case the reset caused
- * a stale power status from the actual CPU to be
- * written to the SCU).
- */
- SCU_WRITE_4(AML_SCU_CPU_PWR_STATUS_REG, scpsr);
- SCU_BARRIER(AML_SCU_CPU_PWR_STATUS_REG);
- }
- break;
- default:
- break;
- }
-}
-
-void
-platform_mp_setmaxid(void)
-{
- int err;
- int i;
- int ncpu;
- phandle_t cpucfg_node;
- phandle_t scu_node;
- uint32_t value;
-
- if (mp_ncpus != 0)
- return;
-
- ncpu = 1;
-
- /*
- * Is the hardware necessary for SMP present?
- */
-
- if ((scu_node = find_node_for_device("scu", scu_compatible)) == 0)
- goto moveon;
-
- if ((cpucfg_node = find_node_for_device("cpuconfig",
- cpucfg_compatible)) == 0)
- goto moveon;
-
- if (alloc_resource_for_node(scu_node, &aml8726_smp.scu_res,
- &aml8726_smp.scu_size) != 0)
- panic("Could not allocate resource for SCU");
-
- if (alloc_resource_for_node(cpucfg_node, &aml8726_smp.cpucfg_res,
- &aml8726_smp.cpucfg_size) != 0)
- panic("Could not allocate resource for CPUCONFIG");
-
- /*
- * Strictly speaking the aobus and cbus may not be required in
- * order to start an AP (it depends on the processor), however
- * always mapping them in simplifies the code.
- */
-
- aml8726_smp.aobus_res.r_bustag = fdtbus_bs_tag;
-
- err = bus_space_map(aml8726_smp.aobus_res.r_bustag,
- AML_SOC_AOBUS_BASE_ADDR, 0x100000,
- 0, &aml8726_smp.aobus_res.r_bushandle);
-
- if (err)
- panic("Could not allocate resource for AOBUS");
-
- aml8726_smp.cbus_res.r_bustag = fdtbus_bs_tag;
-
- err = bus_space_map(aml8726_smp.cbus_res.r_bustag,
- AML_SOC_CBUS_BASE_ADDR, 0x100000,
- 0, &aml8726_smp.cbus_res.r_bushandle);
-
- if (err)
- panic("Could not allocate resource for CBUS");
-
- aml8726_smp.errata_764369 = false;
- for (i = 0; scu_errata_764369[i]; i++)
- if (fdt_is_compatible_strict(scu_node, scu_errata_764369[i])) {
- aml8726_smp.errata_764369 = true;
- break;
- }
-
- /*
- * Read the number of CPUs present.
- */
- value = SCU_READ_4(AML_SCU_CONFIG_REG);
- ncpu = (value & AML_SCU_CONFIG_NCPU_MASK) + 1;
-
-moveon:
- mp_ncpus = ncpu;
- mp_maxid = ncpu - 1;
-}
-
-void
-platform_mp_start_ap(void)
-{
- int i;
- uint32_t reg;
- uint32_t value;
- vm_paddr_t paddr;
-
- if (mp_ncpus < 2)
- return;
-
- /*
- * Invalidate SCU cache tags. The 0x0000ffff constant invalidates
- * all ways on all cores 0-3. Per the ARM docs, it's harmless to
- * write to the bits for cores that are not present.
- */
- SCU_WRITE_4(AML_SCU_INV_TAGS_REG, 0x0000ffff);
-
- if (aml8726_smp.errata_764369) {
- /*
- * 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.
- */
- value = SCU_READ_4(AML_SCU_DIAG_CONTROL_REG);
- value |= AML_SCU_DIAG_CONTROL_DISABLE_MIGBIT;
- SCU_WRITE_4(AML_SCU_DIAG_CONTROL_REG, value);
- }
-
- /*
- * Enable the SCU, then clean the cache on this core. After these
- * two operations the cache tag ram in the SCU is coherent with
- * the contents of the cache on this core. The other cores aren't
- * running yet so their caches can't contain valid data yet, however
- * we've initialized their SCU tag ram above, so they will be
- * coherent from startup.
- */
- value = SCU_READ_4(AML_SCU_CONTROL_REG);
- value |= AML_SCU_CONTROL_ENABLE;
- SCU_WRITE_4(AML_SCU_CONTROL_REG, value);
- SCU_BARRIER(AML_SCU_CONTROL_REG);
- dcache_wbinv_poc_all();
-
- /* Set the boot address and power on each AP. */
- paddr = pmap_kextract((vm_offset_t)mpentry);
- for (i = 1; i < mp_ncpus; i++) {
- reg = AML_CPUCONF_CPU1_ADDR_REG + ((i - 1) * 4);
- CPUCONF_WRITE_4(reg, paddr);
- CPUCONF_BARRIER(reg);
-
- power_on_cpu(i);
- }
-
- /*
- * Enable the APs.
- *
- * The Amlogic Linux platform code sets the lsb for some reason
- * in addition to the enable bit for each AP so we follow suit
- * (the lsb may be the enable bit for the BP, though in that case
- * it should already be set since it's currently running).
- */
- value = CPUCONF_READ_4(AML_CPUCONF_CONTROL_REG);
- value |= 1;
- for (i = 1; i < mp_ncpus; i++)
- value |= (1 << i);
- CPUCONF_WRITE_4(AML_CPUCONF_CONTROL_REG, value);
- CPUCONF_BARRIER(AML_CPUCONF_CONTROL_REG);
-
- /* Wakeup the now enabled APs */
- dsb();
- sev();
-
- /*
- * Free the resources which are not needed after startup.
- */
- bus_space_unmap(aml8726_smp.scu_res.r_bustag,
- aml8726_smp.scu_res.r_bushandle,
- aml8726_smp.scu_size);
- bus_space_unmap(aml8726_smp.cpucfg_res.r_bustag,
- aml8726_smp.cpucfg_res.r_bushandle,
- aml8726_smp.cpucfg_size);
- bus_space_unmap(aml8726_smp.aobus_res.r_bustag,
- aml8726_smp.aobus_res.r_bushandle,
- 0x100000);
- bus_space_unmap(aml8726_smp.cbus_res.r_bustag,
- aml8726_smp.cbus_res.r_bushandle,
- 0x100000);
- memset(&aml8726_smp, 0, sizeof(aml8726_smp));
-}
-
-/*
- * Stub drivers for cosmetic purposes.
- */
-struct aml8726_scu_softc {
- device_t dev;
-};
-
-static int
-aml8726_scu_probe(device_t dev)
-{
- int i;
-
- for (i = 0; scu_compatible[i]; i++)
- if (ofw_bus_is_compatible(dev, scu_compatible[i]))
- break;
-
- if (!scu_compatible[i])
- return (ENXIO);
-
- device_set_desc(dev, "ARM Snoop Control Unit");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_scu_attach(device_t dev)
-{
- struct aml8726_scu_softc *sc = device_get_softc(dev);
-
- sc->dev = dev;
-
- return (0);
-}
-
-static int
-aml8726_scu_detach(device_t dev)
-{
-
- return (0);
-}
-
-static device_method_t aml8726_scu_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_scu_probe),
- DEVMETHOD(device_attach, aml8726_scu_attach),
- DEVMETHOD(device_detach, aml8726_scu_detach),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_scu_driver = {
- "scu",
- aml8726_scu_methods,
- sizeof(struct aml8726_scu_softc),
-};
-
-static devclass_t aml8726_scu_devclass;
-
-EARLY_DRIVER_MODULE(scu, simplebus, aml8726_scu_driver, aml8726_scu_devclass,
- 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_MIDDLE);
-
-struct aml8726_cpucfg_softc {
- device_t dev;
-};
-
-static int
-aml8726_cpucfg_probe(device_t dev)
-{
- int i;
-
- for (i = 0; cpucfg_compatible[i]; i++)
- if (ofw_bus_is_compatible(dev, cpucfg_compatible[i]))
- break;
-
- if (!cpucfg_compatible[i])
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic CPU Config");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_cpucfg_attach(device_t dev)
-{
- struct aml8726_cpucfg_softc *sc = device_get_softc(dev);
-
- sc->dev = dev;
-
- return (0);
-}
-
-static int
-aml8726_cpucfg_detach(device_t dev)
-{
-
- return (0);
-}
-
-static device_method_t aml8726_cpucfg_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_cpucfg_probe),
- DEVMETHOD(device_attach, aml8726_cpucfg_attach),
- DEVMETHOD(device_detach, aml8726_cpucfg_detach),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_cpucfg_driver = {
- "cpuconfig",
- aml8726_cpucfg_methods,
- sizeof(struct aml8726_cpucfg_softc),
-};
-
-static devclass_t aml8726_cpucfg_devclass;
-
-EARLY_DRIVER_MODULE(cpuconfig, simplebus, aml8726_cpucfg_driver,
- aml8726_cpucfg_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_MIDDLE);
sys/arm/amlogic/aml8726/aml8726_pic.c→/dev/null
@@ -1,277 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 PIC driver.
- *
- * The current implementation doesn't include support for FIQ.
- *
- * There is a set of four interrupt controllers per cpu located in adjacent
- * memory addresses (the set for cpu 1 starts right after the set for cpu 0)
- * ... this allows for interrupt handling to be spread across the cpus.
- *
- * The multicore chips also have a GIC ... typically they run SMP kernels
- * which include the GIC driver in which case this driver is simply used
- * to disable the PIC.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-
-#include <machine/bus.h>
-#include <machine/intr.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-struct aml8726_pic_softc {
- device_t dev;
- struct resource * res[1];
-};
-
-static struct resource_spec aml8726_pic_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-/*
- * devclass_get_device / device_get_softc could be used
- * to dynamically locate this, however the pic is a
- * required device which can't be unloaded so there's
- * no need for the overhead.
- */
-static struct aml8726_pic_softc *aml8726_pic_sc = NULL;
-
-#define AML_PIC_NCNTRLS 4
-#define AML_PIC_IRQS_PER_CNTRL 32
-
-#define AML_PIC_NIRQS (AML_PIC_NCNTRLS * AML_PIC_IRQS_PER_CNTRL)
-
-#define AML_PIC_0_STAT_REG 0
-#define AML_PIC_0_STAT_CLR_REG 4
-#define AML_PIC_0_MASK_REG 8
-#define AML_PIC_0_FIRQ_SEL 12
-
-#define AML_PIC_1_STAT_REG 16
-#define AML_PIC_1_STAT_CLR_REG 20
-#define AML_PIC_1_MASK_REG 24
-#define AML_PIC_1_FIRQ_SEL 28
-
-#define AML_PIC_2_STAT_REG 32
-#define AML_PIC_2_STAT_CLR_REG 36
-#define AML_PIC_2_MASK_REG 40
-#define AML_PIC_2_FIRQ_SEL 44
-
-#define AML_PIC_3_STAT_REG 48
-#define AML_PIC_3_STAT_CLR_REG 52
-#define AML_PIC_3_MASK_REG 56
-#define AML_PIC_3_FIRQ_SEL 60
-
-#define AML_PIC_CTRL(x) ((x) >> 5)
-#define AML_PIC_BIT(x) (1 << ((x) & 0x1f))
-
-#define AML_PIC_STAT_REG(x) (AML_PIC_0_STAT_REG + AML_PIC_CTRL(x) * 16)
-#define AML_PIC_STAT_CLR_REG(x) (AML_PIC_0_STAT_CLR_REG + AML_PIC_CTRL(x) * 16)
-#define AML_PIC_MASK_REG(x) (AML_PIC_0_MASK_REG + AML_PIC_CTRL(x) * 16)
-#define AML_PIC_FIRQ_SEL(x) (AML_PIC_0_FIRQ_REG + AML_PIC_CTRL(x) * 16)
-
-#define CSR_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
-#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-#define CSR_BARRIER(sc, reg) bus_barrier((sc)->res[0], reg, 4, \
- (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-static void
-aml8726_pic_eoi(void *arg)
-{
- uintptr_t nb = (uintptr_t) arg;
-
- if (nb >= AML_PIC_NIRQS)
- return;
-
- arm_irq_memory_barrier(nb);
-
- CSR_WRITE_4(aml8726_pic_sc, AML_PIC_STAT_CLR_REG(nb), AML_PIC_BIT(nb));
-
- CSR_BARRIER(aml8726_pic_sc, AML_PIC_STAT_CLR_REG(nb));
-}
-
-static int
-aml8726_pic_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-pic"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 PIC");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_pic_attach(device_t dev)
-{
- struct aml8726_pic_softc *sc = device_get_softc(dev);
- int i;
-
- /* There should be exactly one instance. */
- if (aml8726_pic_sc != NULL)
- return (ENXIO);
-
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, aml8726_pic_spec, sc->res)) {
- device_printf(dev, "could not allocate resources for device\n");
- return (ENXIO);
- }
-
- /*
- * Disable, clear, and set the interrupts to normal mode.
- */
- for (i = 0; i < AML_PIC_NCNTRLS; i++) {
- CSR_WRITE_4(sc, AML_PIC_0_MASK_REG + i * 16, 0);
- CSR_WRITE_4(sc, AML_PIC_0_STAT_CLR_REG + i * 16, ~0u);
- CSR_WRITE_4(sc, AML_PIC_0_FIRQ_SEL + i * 16, 0);
- }
-
-#ifndef DEV_GIC
- arm_post_filter = aml8726_pic_eoi;
-#else
- device_printf(dev, "disabled in favor of gic\n");
-#endif
-
- aml8726_pic_sc = sc;
-
- return (0);
-}
-
-static int
-aml8726_pic_detach(device_t dev)
-{
-
- return (EBUSY);
-}
-
-static device_method_t aml8726_pic_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_pic_probe),
- DEVMETHOD(device_attach, aml8726_pic_attach),
- DEVMETHOD(device_detach, aml8726_pic_detach),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_pic_driver = {
- "pic",
- aml8726_pic_methods,
- sizeof(struct aml8726_pic_softc),
-};
-
-static devclass_t aml8726_pic_devclass;
-
-EARLY_DRIVER_MODULE(pic, simplebus, aml8726_pic_driver, aml8726_pic_devclass,
- 0, 0, BUS_PASS_INTERRUPT);
-
-#ifndef DEV_GIC
-int
-arm_get_next_irq(int last)
-{
- uint32_t value;
- int irq;
- int start;
-
- /*
- * The extra complexity is simply so that all IRQs are checked
- * round robin so a particularly busy interrupt can't prevent
- * other interrupts from being serviced.
- */
-
- start = (last + 1) % AML_PIC_NIRQS;
- irq = start;
-
- for ( ; ; ) {
- value = CSR_READ_4(aml8726_pic_sc, AML_PIC_STAT_REG(irq));
-
- for ( ; ; ) {
- if ((value & AML_PIC_BIT(irq)) != 0)
- return (irq);
-
- irq = (irq + 1) % AML_PIC_NIRQS;
-
- if (irq == start)
- return (-1);
-
- if ((irq % AML_PIC_IRQS_PER_CNTRL) == 0)
- break;
- }
- }
-}
-
-void
-arm_mask_irq(uintptr_t nb)
-{
- uint32_t mask;
-
- if (nb >= AML_PIC_NIRQS)
- return;
-
- mask = CSR_READ_4(aml8726_pic_sc, AML_PIC_MASK_REG(nb));
- mask &= ~AML_PIC_BIT(nb);
- CSR_WRITE_4(aml8726_pic_sc, AML_PIC_MASK_REG(nb), mask);
-
- CSR_BARRIER(aml8726_pic_sc, AML_PIC_MASK_REG(nb));
-
- aml8726_pic_eoi((void *)nb);
-}
-
-void
-arm_unmask_irq(uintptr_t nb)
-{
- uint32_t mask;
-
- if (nb >= AML_PIC_NIRQS)
- return;
-
- arm_irq_memory_barrier(nb);
-
- mask = CSR_READ_4(aml8726_pic_sc, AML_PIC_MASK_REG(nb));
- mask |= AML_PIC_BIT(nb);
- CSR_WRITE_4(aml8726_pic_sc, AML_PIC_MASK_REG(nb), mask);
-
- CSR_BARRIER(aml8726_pic_sc, AML_PIC_MASK_REG(nb));
-}
-#endif
sys/arm/amlogic/aml8726/aml8726_pinctrl.c→/dev/null
@@ -1,430 +0,0 @@
-/*-
- * Copyright 2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 pinctrl driver.
- *
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/fdt/fdt_pinctrl.h>
-
-#include <arm/amlogic/aml8726/aml8726_soc.h>
-#include <arm/amlogic/aml8726/aml8726_pinctrl.h>
-
-struct aml8726_pinctrl_softc {
- device_t dev;
- struct {
- struct aml8726_pinctrl_function *func;
- struct aml8726_pinctrl_pkg_pin *ppin;
- boolean_t pud_ctrl;
- } soc;
- struct resource *res[6];
- struct mtx mtx;
-};
-
-static struct resource_spec aml8726_pinctrl_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* mux */
- { SYS_RES_MEMORY, 1, RF_ACTIVE | RF_SHAREABLE }, /* pu/pd */
- { SYS_RES_MEMORY, 2, RF_ACTIVE | RF_SHAREABLE }, /* pull enable */
- { SYS_RES_MEMORY, 3, RF_ACTIVE }, /* ao mux */
- { SYS_RES_MEMORY, 4, RF_ACTIVE | RF_SHAREABLE }, /* ao pu/pd */
- { SYS_RES_MEMORY, 5, RF_ACTIVE | RF_SHAREABLE }, /* ao pull enable */
- { -1, 0 }
-};
-
-#define AML_PINCTRL_LOCK(sc) mtx_lock(&(sc)->mtx)
-#define AML_PINCTRL_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
-#define AML_PINCTRL_LOCK_INIT(sc) \
- mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
- "pinctrl", MTX_DEF)
-#define AML_PINCTRL_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx);
-
-#define MUX_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
-#define MUX_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-
-#define PUD_WRITE_4(sc, reg, val) bus_write_4((sc)->res[1], reg, (val))
-#define PUD_READ_4(sc, reg) bus_read_4((sc)->res[1], reg)
-
-#define PEN_WRITE_4(sc, reg, val) bus_write_4((sc)->res[2], reg, (val))
-#define PEN_READ_4(sc, reg) bus_read_4((sc)->res[2], reg)
-
-#define AOMUX_WRITE_4(sc, reg, val) bus_write_4((sc)->res[3], reg, (val))
-#define AOMUX_READ_4(sc, reg) bus_read_4((sc)->res[3], reg)
-
-#define AOPUD_WRITE_4(sc, reg, val) bus_write_4((sc)->res[4], reg, (val))
-#define AOPUD_READ_4(sc, reg) bus_read_4((sc)->res[4], reg)
-
-#define AOPEN_WRITE_4(sc, reg, val) bus_write_4((sc)->res[5], reg, (val))
-#define AOPEN_READ_4(sc, reg) bus_read_4((sc)->res[5], reg)
-
-static int
-aml8726_pinctrl_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-pinctrl"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 pinctrl");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_pinctrl_attach(device_t dev)
-{
- struct aml8726_pinctrl_softc *sc = device_get_softc(dev);
-
- sc->dev = dev;
-
- sc->soc.pud_ctrl = false;
-
- switch (aml8726_soc_hw_rev) {
- case AML_SOC_HW_REV_M3:
- sc->soc.func = aml8726_m3_pinctrl;
- sc->soc.ppin = aml8726_m3_pkg_pin;
- break;
- case AML_SOC_HW_REV_M6:
- sc->soc.func = aml8726_m6_pinctrl;
- sc->soc.ppin = aml8726_m6_pkg_pin;
- break;
- case AML_SOC_HW_REV_M8:
- sc->soc.func = aml8726_m8_pinctrl;
- sc->soc.ppin = aml8726_m8_pkg_pin;
- sc->soc.pud_ctrl = true;
- break;
- case AML_SOC_HW_REV_M8B:
- sc->soc.func = aml8726_m8b_pinctrl;
- sc->soc.ppin = aml8726_m8b_pkg_pin;
- sc->soc.pud_ctrl = true;
- break;
- default:
- device_printf(dev, "unsupported SoC\n");
- return (ENXIO);
- /* NOTREACHED */
- }
-
- if (bus_alloc_resources(dev, aml8726_pinctrl_spec, sc->res)) {
- device_printf(dev, "could not allocate resources for device\n");
- return (ENXIO);
- }
-
- AML_PINCTRL_LOCK_INIT(sc);
-
- fdt_pinctrl_register(dev, "amlogic,pins");
- fdt_pinctrl_configure_tree(dev);
-
- return (0);
-}
-
-static int
-aml8726_pinctrl_detach(device_t dev)
-{
- struct aml8726_pinctrl_softc *sc = device_get_softc(dev);
-
- AML_PINCTRL_LOCK_DESTROY(sc);
-
- bus_release_resources(dev, aml8726_pinctrl_spec, sc->res);
-
- return (0);
-}
-
-static int
-aml8726_pinctrl_configure_pins(device_t dev, phandle_t cfgxref)
-{
- struct aml8726_pinctrl_softc *sc = device_get_softc(dev);
- struct aml8726_pinctrl_function *cf;
- struct aml8726_pinctrl_function *f;
- struct aml8726_pinctrl_pkg_pin *pp;
- struct aml8726_pinctrl_pin *cp;
- struct aml8726_pinctrl_pin *p;
- enum aml8726_pinctrl_pull_mode pm;
- char *function_name;
- char *pins;
- char *pin_name;
- char *pull;
- phandle_t node;
- ssize_t len;
- uint32_t value;
-
- node = OF_node_from_xref(cfgxref);
-
- len = OF_getprop_alloc(node, "amlogic,function",
- (void **)&function_name);
-
- if (len < 0) {
- device_printf(dev,
- "missing amlogic,function attribute in FDT\n");
- return (ENXIO);
- }
-
- for (f = sc->soc.func; f->name != NULL; f++)
- if (strncmp(f->name, function_name, len) == 0)
- break;
-
- if (f->name == NULL) {
- device_printf(dev, "unknown function attribute %.*s in FDT\n",
- len, function_name);
- OF_prop_free(function_name);
- return (ENXIO);
- }
-
- OF_prop_free(function_name);
-
- len = OF_getprop_alloc(node, "amlogic,pull",
- (void **)&pull);
-
- pm = aml8726_unknown_pm;
-
- if (len > 0) {
- if (strncmp(pull, "enable", len) == 0)
- pm = aml8726_enable_pm;
- else if (strncmp(pull, "disable", len) == 0)
- pm = aml8726_disable_pm;
- else if (strncmp(pull, "down", len) == 0)
- pm = aml8726_enable_down_pm;
- else if (strncmp(pull, "up", len) == 0)
- pm = aml8726_enable_up_pm;
- else {
- device_printf(dev,
- "unknown pull attribute %.*s in FDT\n",
- len, pull);
- OF_prop_free(pull);
- return (ENXIO);
- }
- }
-
- OF_prop_free(pull);
-
- /*
- * Setting the pull direction isn't supported on all SoC.
- */
- switch (pm) {
- case aml8726_enable_down_pm:
- case aml8726_enable_up_pm:
- if (sc->soc.pud_ctrl == false) {
- device_printf(dev,
- "SoC doesn't support setting pull direction.\n");
- return (ENXIO);
- }
- break;
- default:
- break;
- }
-
- len = OF_getprop_alloc(node, "amlogic,pins",
- (void **)&pins);
-
- if (len < 0) {
- device_printf(dev, "missing amlogic,pins attribute in FDT\n");
- return (ENXIO);
- }
-
- pin_name = pins;
-
- while (len) {
- for (p = f->pins; p->name != NULL; p++)
- if (strncmp(p->name, pin_name, len) == 0)
- break;
-
- if (p->name == NULL) {
- /* display message prior to queuing up next string */
- device_printf(dev, "unknown pin attribute %.*s in FDT\n",
- len, pin_name);
- }
-
- /* queue up next string */
- while (*pin_name && len) {
- pin_name++;
- len--;
- }
- if (len) {
- pin_name++;
- len--;
- }
-
- if (p->name == NULL)
- continue;
-
- for (pp = sc->soc.ppin; pp->pkg_name != NULL; pp++)
- if (strcmp(pp->pkg_name, p->pkg_name) == 0)
- break;
-
- if (pp->pkg_name == NULL) {
- device_printf(dev,
- "missing entry for package pin %s\n",
- p->pkg_name);
- continue;
- }
-
- if (pm != aml8726_unknown_pm && pp->pull_bits == 0x00000000) {
- device_printf(dev,
- "missing pull info for package pin %s\n",
- p->pkg_name);
- continue;
- }
-
- AML_PINCTRL_LOCK(sc);
-
- /*
- * First clear all other mux bits associated with this
- * package pin. This may briefly configure the pin as
- * GPIO ... however this should be fine since after
- * reset the default GPIO mode is input.
- */
-
- for (cf = sc->soc.func; cf->name != NULL; cf++)
- for (cp = cf->pins; cp->name != NULL; cp++) {
- if (cp == p)
- continue;
- if (strcmp(cp->pkg_name, p->pkg_name) != 0)
- continue;
- if (cp->mux_bits == 0)
- continue;
- if (pp->aobus == false) {
- value = MUX_READ_4(sc, cp->mux_addr);
- value &= ~cp->mux_bits;
- MUX_WRITE_4(sc, cp->mux_addr, value);
- } else {
- value = AOMUX_READ_4(sc, cp->mux_addr);
- value &= ~cp->mux_bits;
- AOMUX_WRITE_4(sc, cp->mux_addr, value);
- }
- }
-
- /*
- * Now set the desired mux bits.
- *
- * In the case of GPIO there's no bits to set.
- */
-
- if (p->mux_bits != 0) {
- if (pp->aobus == false) {
- value = MUX_READ_4(sc, p->mux_addr);
- value |= p->mux_bits;
- MUX_WRITE_4(sc, p->mux_addr, value);
- } else {
- value = AOMUX_READ_4(sc, p->mux_addr);
- value |= p->mux_bits;
- AOMUX_WRITE_4(sc, p->mux_addr, value);
- }
- }
-
- /*
- * Finally set the pull mode if it was specified.
- */
-
- switch (pm) {
- case aml8726_enable_down_pm:
- case aml8726_enable_up_pm:
- if (pp->aobus == false) {
- value = PUD_READ_4(sc, pp->pull_addr);
- if (pm == aml8726_enable_down_pm)
- value &= ~pp->pull_bits;
- else
- value |= pp->pull_bits;
- PUD_WRITE_4(sc, pp->pull_addr, value);
- } else {
- value = AOPUD_READ_4(sc, pp->pull_addr);
- if (pm == aml8726_enable_down_pm)
- value &= ~(pp->pull_bits << 16);
- else
- value |= (pp->pull_bits << 16);
- AOPUD_WRITE_4(sc, pp->pull_addr, value);
- }
- /* FALLTHROUGH */
- case aml8726_disable_pm:
- case aml8726_enable_pm:
- if (pp->aobus == false) {
- value = PEN_READ_4(sc, pp->pull_addr);
- if (pm == aml8726_disable_pm)
- value &= ~pp->pull_bits;
- else
- value |= pp->pull_bits;
- PEN_WRITE_4(sc, pp->pull_addr, value);
- } else {
- value = AOPEN_READ_4(sc, pp->pull_addr);
- if (pm == aml8726_disable_pm)
- value &= ~pp->pull_bits;
- else
- value |= pp->pull_bits;
- AOPEN_WRITE_4(sc, pp->pull_addr, value);
- }
- break;
- default:
- break;
- }
-
- AML_PINCTRL_UNLOCK(sc);
- }
-
- OF_prop_free(pins);
-
- return (0);
-}
-
-static device_method_t aml8726_pinctrl_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_pinctrl_probe),
- DEVMETHOD(device_attach, aml8726_pinctrl_attach),
- DEVMETHOD(device_detach, aml8726_pinctrl_detach),
-
- /* fdt_pinctrl interface */
- DEVMETHOD(fdt_pinctrl_configure,aml8726_pinctrl_configure_pins),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_pinctrl_driver = {
- "pinctrl",
- aml8726_pinctrl_methods,
- sizeof(struct aml8726_pinctrl_softc),
-};
-
-static devclass_t aml8726_pinctrl_devclass;
-
-EARLY_DRIVER_MODULE(pinctrl, simplebus, aml8726_pinctrl_driver,
- aml8726_pinctrl_devclass, 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_LATE);
sys/arm/amlogic/aml8726/aml8726_pinctrl.h→/dev/null
@@ -1,1082 +0,0 @@
-/*-
- * Copyright 2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-/*
- * In addition to supplying entries for pins which need to be configured
- * by the operating system it's also necessary to supply entries for pins
- * which may have been configured by the firmware for a different purpose.
- */
-
-#ifndef _ARM_AMLOGIC_AML8726_PINCTRL_H
-#define _ARM_AMLOGIC_AML8726_PINCTRL_H
-
-enum aml8726_pinctrl_pull_mode {
- aml8726_unknown_pm,
- aml8726_disable_pm,
- aml8726_enable_pm,
- aml8726_enable_down_pm,
- aml8726_enable_up_pm
-};
-
-struct aml8726_pinctrl_pkg_pin {
- const char *pkg_name;
- boolean_t aobus;
- uint32_t pull_addr;
- uint32_t pull_bits;
-};
-
-struct aml8726_pinctrl_pin {
- const char *name;
- const char *pkg_name;
- uint32_t mux_addr;
- uint32_t mux_bits;
-};
-
-struct aml8726_pinctrl_function {
- const char *name;
- struct aml8726_pinctrl_pin *pins;
-};
-
-/*
- * aml8726-m3
- *
- * start size
- * cbus mux 0x202c 36
- * cbus pu_pd 0x203a 24
- * cbus pull_en 0x203a 24
- * aobus mux 0x0005 4
- * aobus pu_pd 0x000b 4
- * aobus pull_en 0x000b 4
- */
-
-static struct aml8726_pinctrl_pkg_pin aml8726_m3_pkg_pin[] = {
- { "card_0", false, 0, 0x00000000 },
- { "card_1", false, 0, 0x00000000 },
- { "card_2", false, 0, 0x00000000 },
- { "card_3", false, 0, 0x00000000 },
- { "card_4", false, 0, 0x00000000 },
- { "card_5", false, 0, 0x00000000 },
- { "card_6", false, 0, 0x00000000 },
-
- { "gpioc_10", false, 0, 0x00000000 },
- { "gpioc_11", false, 0, 0x00000000 },
- { "gpioc_12", false, 0, 0x00000000 },
- { "gpioc_13", false, 0, 0x00000000 },
-
- { "gpiox_13", false, 0, 0x00000000 },
- { "gpiox_14", false, 0, 0x00000000 },
- { "gpiox_15", false, 0, 0x00000000 },
- { "gpiox_16", false, 0, 0x00000000 },
- { "gpiox_17", false, 0, 0x00000000 },
- { "gpiox_18", false, 0, 0x00000000 },
- { "gpiox_19", false, 0, 0x00000000 },
- { "gpiox_20", false, 0, 0x00000000 },
- { "gpiox_21", false, 0, 0x00000000 },
- { "gpiox_22", false, 0, 0x00000000 },
- { "gpiox_23", false, 0, 0x00000000 },
- { "gpiox_24", false, 0, 0x00000000 },
- { "gpiox_25", false, 0, 0x00000000 },
- { "gpiox_26", false, 0, 0x00000000 },
- { "gpiox_27", false, 0, 0x00000000 },
- { "gpiox_28", false, 0, 0x00000000 },
-
- { "gpioy_0", false, 0, 0x00000000 },
- { "gpioy_1", false, 0, 0x00000000 },
- { "gpioy_2", false, 0, 0x00000000 },
- { "gpioy_3", false, 0, 0x00000000 },
- { "gpioy_4", false, 0, 0x00000000 },
- { "gpioy_5", false, 0, 0x00000000 },
- { "gpioy_6", false, 0, 0x00000000 },
- { "gpioy_7", false, 0, 0x00000000 },
- { "gpioy_8", false, 0, 0x00000000 },
- { "gpioy_9", false, 0, 0x00000000 },
-
- { "gpioao_0", true, 0, 0x00000000 },
- { "gpioao_1", true, 0, 0x00000000 },
- { "gpioao_2", true, 0, 0x00000000 },
- { "gpioao_3", true, 0, 0x00000000 },
- { "gpioao_4", true, 0, 0x00000000 },
- { "gpioao_5", true, 0, 0x00000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_gpio[] = {
- { "card_0", "card_0", 0, 0x00000000 },
- { "card_1", "card_1", 0, 0x00000000 },
- { "card_2", "card_2", 0, 0x00000000 },
- { "card_3", "card_3", 0, 0x00000000 },
- { "card_4", "card_4", 0, 0x00000000 },
- { "card_5", "card_5", 0, 0x00000000 },
- { "card_6", "card_6", 0, 0x00000000 },
-
- { "gpioc_10", "gpioc_10", 0, 0x00000000 },
- { "gpioc_11", "gpioc_11", 0, 0x00000000 },
- { "gpioc_12", "gpioc_12", 0, 0x00000000 },
- { "gpioc_13", "gpioc_13", 0, 0x00000000 },
-
- { "gpiox_13", "gpiox_13", 0, 0x00000000 },
- { "gpiox_14", "gpiox_14", 0, 0x00000000 },
- { "gpiox_15", "gpiox_15", 0, 0x00000000 },
- { "gpiox_16", "gpiox_16", 0, 0x00000000 },
- { "gpiox_17", "gpiox_17", 0, 0x00000000 },
- { "gpiox_18", "gpiox_18", 0, 0x00000000 },
- { "gpiox_19", "gpiox_19", 0, 0x00000000 },
- { "gpiox_20", "gpiox_20", 0, 0x00000000 },
- { "gpiox_21", "gpiox_21", 0, 0x00000000 },
- { "gpiox_22", "gpiox_22", 0, 0x00000000 },
- { "gpiox_23", "gpiox_23", 0, 0x00000000 },
- { "gpiox_24", "gpiox_24", 0, 0x00000000 },
- { "gpiox_25", "gpiox_25", 0, 0x00000000 },
- { "gpiox_26", "gpiox_26", 0, 0x00000000 },
- { "gpiox_27", "gpiox_27", 0, 0x00000000 },
- { "gpiox_28", "gpiox_28", 0, 0x00000000 },
-
- { "gpioy_0", "gpioy_0", 0, 0x00000000 },
- { "gpioy_1", "gpioy_1", 0, 0x00000000 },
- { "gpioy_2", "gpioy_2", 0, 0x00000000 },
- { "gpioy_3", "gpioy_3", 0, 0x00000000 },
- { "gpioy_4", "gpioy_4", 0, 0x00000000 },
- { "gpioy_5", "gpioy_5", 0, 0x00000000 },
- { "gpioy_6", "gpioy_6", 0, 0x00000000 },
- { "gpioy_7", "gpioy_7", 0, 0x00000000 },
- { "gpioy_8", "gpioy_8", 0, 0x00000000 },
- { "gpioy_9", "gpioy_9", 0, 0x00000000 },
-
- { "gpioao_0", "gpioao_0", 0, 0x00000000 },
- { "gpioao_1", "gpioao_1", 0, 0x00000000 },
- { "gpioao_2", "gpioao_2", 0, 0x00000000 },
- { "gpioao_3", "gpioao_3", 0, 0x00000000 },
- { "gpioao_4", "gpioao_4", 0, 0x00000000 },
- { "gpioao_5", "gpioao_5", 0, 0x00000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_ethernet[] = {
- { "clk50_in", "gpioy_0", 24, 0x00040000 },
- { "clk_out", "gpioy_0", 24, 0x00020000 },
- { "tx_en", "gpioy_5", 24, 0x00001000 },
- { "tx_d0", "gpioy_7", 24, 0x00000400 },
- { "tx_d1", "gpioy_6", 24, 0x00000800 },
- { "crs_dv", "gpioy_2", 24, 0x00008000 },
- { "rx_err", "gpioy_1", 24, 0x00010000 },
- { "rx_d0", "gpioy_4", 24, 0x00002000 },
- { "rx_d1", "gpioy_3", 24, 0x00004000 },
- { "mdc", "gpioy_8", 24, 0x00000200 },
- { "mdio", "gpioy_9", 24, 0x00000100 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_hdmi[] = {
- { "cec", "gpioc_13", 4, 0x02000000 },
- { "hpd", "gpioc_10", 4, 0x00400000 },
- { "scl", "gpioc_12", 4, 0x01000000 },
- { "sda", "gpioc_11", 4, 0x00800000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_i2c_a[] = {
- { "scl", "gpiox_26", 20, 0x04000000 },
- { "sda", "gpiox_25", 20, 0x08000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_i2c_b[] = {
- { "scl", "gpiox_28", 20, 0x40000000 },
- { "sda", "gpiox_27", 20, 0x80000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_sdio_b[] = {
- { "clk", "card_4", 8, 0x00000800 },
- { "cmd", "card_5", 8, 0x00000400 },
- { "d0", "card_0", 8, 0x00008000 },
- { "d1", "card_1", 8, 0x00004000 },
- { "d2", "card_2", 8, 0x00002000 },
- { "d3", "card_3", 8, 0x00001000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_sdxc_b[] = {
- { "clk", "card_4", 8, 0x00000020 },
- { "cmd", "card_5", 8, 0x00000010 },
- { "d0", "card_0", 8, 0x00000080 },
- { "d1", "card_1", 8, 0x00000040 },
- { "d2", "card_2", 8, 0x00000040 },
- { "d3", "card_3", 8, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_uart_a[] = {
- { "tx", "gpiox_13", 16, 0x00002000 },
- { "rx", "gpiox_14", 16, 0x00001000 },
- { "cts", "gpiox_15", 16, 0x00000800 },
- { "rts", "gpiox_16", 16, 0x00000400 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_uart_b[] = {
- { "tx", "gpiox_17", 16, 0x00000200 },
- { "rx", "gpiox_18", 16, 0x00000100 },
- { "cts", "gpiox_19", 16, 0x00000080 },
- { "rts", "gpiox_20", 16, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_uart_c[] = {
- { "tx", "gpiox_21", 16, 0x00000008 },
- { "rx", "gpiox_22", 16, 0x00000004 },
- { "cts", "gpiox_23", 16, 0x00000002 },
- { "rts", "gpiox_24", 16, 0x00000001 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_i2c_ao[] = {
- { "scl", "gpioao_4", 0, 0x00000400 },
- { "sda", "gpioao_5", 0, 0x00000200 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m3_uart_ao[] = {
- { "tx", "gpioao_0", 0, 0x00001000 },
- { "rx", "gpioao_1", 0, 0x00000800 },
- { "cts", "gpioao_2", 0, 0x00000400 },
- { "rts", "gpioao_3", 0, 0x00000200 },
- { NULL }
-};
-
-struct aml8726_pinctrl_function aml8726_m3_pinctrl[] = {
- { "gpio", aml8726_m3_gpio },
- { "ethernet", aml8726_m3_ethernet },
- { "hdmi", aml8726_m3_hdmi },
- { "i2c-a", aml8726_m3_i2c_a },
- { "i2c-b", aml8726_m3_i2c_b },
- { "sdio-b", aml8726_m3_sdio_b },
- { "sdxc-b", aml8726_m3_sdxc_b },
- { "uart-a", aml8726_m3_uart_a },
- { "uart-b", aml8726_m3_uart_b },
- { "uart-c", aml8726_m3_uart_c },
- { "i2c-ao", aml8726_m3_i2c_ao },
- { "uart-ao", aml8726_m3_uart_ao },
- { NULL }
-};
-
-/*
- * aml8726-m6
- *
- * start size
- * cbus mux 0x202c 40
- * cbus pu_pd 0x203a 24
- * cbus pull_en 0x203a 24
- * aobus mux 0x0005 4
- * aobus pu_pd 0x000b 4
- * aobus pull_en 0x000b 4
- *
- * For simplicity we don't support setting pull for gpioe and gpioz.
- */
-
-static struct aml8726_pinctrl_pkg_pin aml8726_m6_pkg_pin[] = {
- { "card_0", false, 12, 0x00100000 },
- { "card_1", false, 12, 0x00200000 },
- { "card_2", false, 12, 0x00400000 },
- { "card_3", false, 12, 0x00800000 },
- { "card_4", false, 12, 0x01000000 },
- { "card_5", false, 12, 0x02000000 },
- { "card_6", false, 12, 0x04000000 },
-
- { "gpioc_10", false, 8, 0x00000400 },
- { "gpioc_11", false, 8, 0x00000800 },
- { "gpioc_12", false, 8, 0x00001000 },
- { "gpioc_13", false, 8, 0x00002000 },
-
- { "gpiox_13", false, 16, 0x00002000 },
- { "gpiox_14", false, 16, 0x00004000 },
- { "gpiox_15", false, 16, 0x00008000 },
- { "gpiox_16", false, 16, 0x00010000 },
- { "gpiox_17", false, 16, 0x00020000 },
- { "gpiox_18", false, 16, 0x00040000 },
- { "gpiox_19", false, 16, 0x00080000 },
- { "gpiox_20", false, 16, 0x00100000 },
- { "gpiox_21", false, 16, 0x00200000 },
- { "gpiox_22", false, 16, 0x00400000 },
- { "gpiox_23", false, 16, 0x00800000 },
- { "gpiox_24", false, 16, 0x01000000 },
- { "gpiox_25", false, 16, 0x02000000 },
- { "gpiox_26", false, 16, 0x04000000 },
- { "gpiox_27", false, 16, 0x08000000 },
- { "gpiox_28", false, 16, 0x10000000 },
-
- { "gpioy_0", false, 20, 0x00000010 },
- { "gpioy_1", false, 20, 0x00000020 },
- { "gpioy_2", false, 20, 0x00000040 },
- { "gpioy_3", false, 20, 0x00000080 },
- { "gpioy_4", false, 20, 0x00000100 },
- { "gpioy_5", false, 20, 0x00000200 },
- { "gpioy_6", false, 20, 0x00000400 },
- { "gpioy_7", false, 20, 0x00000800 },
- { "gpioy_8", false, 20, 0x00001000 },
- { "gpioy_9", false, 20, 0x00002000 },
- { "gpioy_10", false, 20, 0x00004000 },
- { "gpioy_11", false, 20, 0x00008000 },
- { "gpioy_12", false, 20, 0x00010000 },
- { "gpioy_13", false, 20, 0x00020000 },
- { "gpioy_14", false, 20, 0x00040000 },
-
- { "gpioao_0", true, 0, 0x00000001 },
- { "gpioao_1", true, 0, 0x00000002 },
- { "gpioao_2", true, 0, 0x00000004 },
- { "gpioao_3", true, 0, 0x00000008 },
- { "gpioao_4", true, 0, 0x00000010 },
- { "gpioao_5", true, 0, 0x00000020 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_gpio[] = {
- { "card_0", "card_0", 0, 0x00000000 },
- { "card_1", "card_1", 0, 0x00000000 },
- { "card_2", "card_2", 0, 0x00000000 },
- { "card_3", "card_3", 0, 0x00000000 },
- { "card_4", "card_4", 0, 0x00000000 },
- { "card_5", "card_5", 0, 0x00000000 },
- { "card_6", "card_6", 0, 0x00000000 },
-
- { "gpioc_10", "gpioc_10", 0, 0x00000000 },
- { "gpioc_11", "gpioc_11", 0, 0x00000000 },
- { "gpioc_12", "gpioc_12", 0, 0x00000000 },
- { "gpioc_13", "gpioc_13", 0, 0x00000000 },
-
- { "gpiox_13", "gpiox_13", 0, 0x00000000 },
- { "gpiox_14", "gpiox_14", 0, 0x00000000 },
- { "gpiox_15", "gpiox_15", 0, 0x00000000 },
- { "gpiox_16", "gpiox_16", 0, 0x00000000 },
- { "gpiox_17", "gpiox_17", 0, 0x00000000 },
- { "gpiox_18", "gpiox_18", 0, 0x00000000 },
- { "gpiox_19", "gpiox_19", 0, 0x00000000 },
- { "gpiox_20", "gpiox_20", 0, 0x00000000 },
- { "gpiox_21", "gpiox_21", 0, 0x00000000 },
- { "gpiox_22", "gpiox_22", 0, 0x00000000 },
- { "gpiox_23", "gpiox_23", 0, 0x00000000 },
- { "gpiox_24", "gpiox_24", 0, 0x00000000 },
- { "gpiox_25", "gpiox_25", 0, 0x00000000 },
- { "gpiox_26", "gpiox_26", 0, 0x00000000 },
- { "gpiox_27", "gpiox_27", 0, 0x00000000 },
- { "gpiox_28", "gpiox_28", 0, 0x00000000 },
-
- { "gpioy_0", "gpioy_0", 0, 0x00000000 },
- { "gpioy_1", "gpioy_1", 0, 0x00000000 },
- { "gpioy_2", "gpioy_2", 0, 0x00000000 },
- { "gpioy_3", "gpioy_3", 0, 0x00000000 },
- { "gpioy_4", "gpioy_4", 0, 0x00000000 },
- { "gpioy_5", "gpioy_5", 0, 0x00000000 },
- { "gpioy_6", "gpioy_6", 0, 0x00000000 },
- { "gpioy_7", "gpioy_7", 0, 0x00000000 },
- { "gpioy_8", "gpioy_8", 0, 0x00000000 },
- { "gpioy_9", "gpioy_9", 0, 0x00000000 },
- { "gpioy_10", "gpioy_10", 0, 0x00000000 },
- { "gpioy_11", "gpioy_11", 0, 0x00000000 },
- { "gpioy_12", "gpioy_12", 0, 0x00000000 },
- { "gpioy_13", "gpioy_13", 0, 0x00000000 },
- { "gpioy_14", "gpioy_14", 0, 0x00000000 },
-
- { "gpioao_0", "gpioao_0", 0, 0x00000000 },
- { "gpioao_1", "gpioao_1", 0, 0x00000000 },
- { "gpioao_2", "gpioao_2", 0, 0x00000000 },
- { "gpioao_3", "gpioao_3", 0, 0x00000000 },
- { "gpioao_4", "gpioao_4", 0, 0x00000000 },
- { "gpioao_5", "gpioao_5", 0, 0x00000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_ethernet[] = {
- { "ref_clk_in", "gpioy_0", 24, 0x80000000 },
- { "ref_clk_out", "gpioy_0", 24, 0x40000000 },
- { "tx_clk", "gpioy_1", 24, 0x00040000 },
- { "tx_en", "gpioy_2", 24, 0x00020000 },
- { "tx_d0", "gpioy_6", 24, 0x00002000 },
- { "tx_d1", "gpioy_5", 24, 0x00004000 },
- { "tx_d2", "gpioy_4", 24, 0x00008000 },
- { "tx_d3", "gpioy_3", 24, 0x00010000 },
- { "rx_clk", "gpioy_7", 24, 0x00001000 },
- { "rx_dv", "gpioy_8", 24, 0x00000800 },
- { "rx_d0", "gpioy_12", 24, 0x00000080 },
- { "rx_d1", "gpioy_11", 24, 0x00000100 },
- { "rx_d2", "gpioy_10", 24, 0x00000200 },
- { "rx_d3", "gpioy_9", 24, 0x00000400 },
- { "mdc", "gpioy_14", 24, 0x00000020 },
- { "mdio", "gpioy_13", 24, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_hdmi[] = {
- { "cec", "gpioc_13", 4, 0x02000000 },
- { "hpd", "gpioc_10", 4, 0x00400000 },
- { "scl", "gpioc_12", 4, 0x01000000 },
- { "sda", "gpioc_11", 4, 0x00800000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_i2c_a[] = {
- { "scl", "gpiox_26", 20, 0x04000000 },
- { "sda", "gpiox_25", 20, 0x08000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_i2c_b[] = {
- { "scl", "gpiox_28", 20, 0x40000000 },
- { "sda", "gpiox_27", 20, 0x80000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_sdio_b[] = {
- { "clk", "card_4", 8, 0x00000800 },
- { "cmd", "card_5", 8, 0x00000400 },
- { "d0", "card_0", 8, 0x00008000 },
- { "d1", "card_1", 8, 0x00004000 },
- { "d2", "card_2", 8, 0x00002000 },
- { "d3", "card_3", 8, 0x00001000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_sdxc_b[] = {
- { "clk", "card_4", 8, 0x00000020 },
- { "cmd", "card_5", 8, 0x00000010 },
- { "d0", "card_0", 8, 0x00000080 },
- { "d1", "card_1", 8, 0x00000040 },
- { "d2", "card_2", 8, 0x00000040 },
- { "d3", "card_3", 8, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_uart_a[] = {
- { "tx", "gpiox_13", 16, 0x00002000 },
- { "rx", "gpiox_14", 16, 0x00001000 },
- { "cts", "gpiox_15", 16, 0x00000800 },
- { "rts", "gpiox_16", 16, 0x00000400 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_uart_b[] = {
- { "tx", "gpiox_17", 16, 0x00000200 },
- { "rx", "gpiox_18", 16, 0x00000100 },
- { "cts", "gpiox_19", 16, 0x00000080 },
- { "rts", "gpiox_20", 16, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_uart_c[] = {
- { "tx", "gpiox_21", 16, 0x00000008 },
- { "rx", "gpiox_22", 16, 0x00000004 },
- { "cts", "gpiox_23", 16, 0x00000002 },
- { "rts", "gpiox_24", 16, 0x00000001 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_i2c_ao[] = {
- { "scl", "gpioao_4", 0, 0x00000400 },
- { "sda", "gpioao_5", 0, 0x00000200 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m6_uart_ao[] = {
- { "tx", "gpioao_0", 0, 0x00001000 },
- { "rx", "gpioao_1", 0, 0x00000800 },
- { "cts", "gpioao_2", 0, 0x00000400 },
- { "rts", "gpioao_3", 0, 0x00000200 },
- { NULL }
-};
-
-struct aml8726_pinctrl_function aml8726_m6_pinctrl[] = {
- { "gpio", aml8726_m6_gpio },
- { "ethernet", aml8726_m6_ethernet },
- { "hdmi", aml8726_m6_hdmi },
- { "i2c-a", aml8726_m6_i2c_a },
- { "i2c-b", aml8726_m6_i2c_b },
- { "sdio-b", aml8726_m6_sdio_b },
- { "sdxc-b", aml8726_m6_sdxc_b },
- { "uart-a", aml8726_m6_uart_a },
- { "uart-b", aml8726_m6_uart_b },
- { "uart-c", aml8726_m6_uart_c },
- { "i2c-ao", aml8726_m6_i2c_ao },
- { "uart-ao", aml8726_m6_uart_ao },
- { NULL }
-};
-
-/*
- * aml8726-m8
- *
- * start size
- * cbus mux 0x202c 40
- * cbus pu_pd 0x203a 20
- * cbus pull_en 0x2048 20
- * aobus mux 0x0005 4
- * aobus pu_pd 0x000b 4
- * aobus pull_en 0x000b 4
- */
-
-static struct aml8726_pinctrl_pkg_pin aml8726_m8_pkg_pin[] = {
- { "boot_0", false, 8, 0x00000001 },
- { "boot_1", false, 8, 0x00000002 },
- { "boot_2", false, 8, 0x00000004 },
- { "boot_3", false, 8, 0x00000008 },
- { "boot_4", false, 8, 0x00000010 },
- { "boot_5", false, 8, 0x00000020 },
- { "boot_6", false, 8, 0x00000040 },
- { "boot_7", false, 8, 0x00000080 },
-
- { "boot_16", false, 8, 0x00010000 },
- { "boot_17", false, 8, 0x00020000 },
-
- { "card_0", false, 8, 0x00100000 },
- { "card_1", false, 8, 0x00200000 },
- { "card_2", false, 8, 0x00400000 },
- { "card_3", false, 8, 0x00800000 },
- { "card_4", false, 8, 0x01000000 },
- { "card_5", false, 8, 0x02000000 },
- { "card_6", false, 8, 0x04000000 },
-
- { "gpioh_0", false, 4, 0x00001000 },
- { "gpioh_1", false, 4, 0x00002000 },
- { "gpioh_2", false, 4, 0x00004000 },
- { "gpioh_3", false, 4, 0x00008000 },
-
- { "gpiox_12", false, 16, 0x00001000 },
- { "gpiox_13", false, 16, 0x00002000 },
- { "gpiox_14", false, 16, 0x00004000 },
- { "gpiox_15", false, 16, 0x00008000 },
- { "gpiox_16", false, 16, 0x00010000 },
- { "gpiox_17", false, 16, 0x00020000 },
- { "gpiox_18", false, 16, 0x00040000 },
- { "gpiox_19", false, 16, 0x00080000 },
-
- { "gpioy_0", false, 12, 0x00000001 },
- { "gpioy_1", false, 12, 0x00000002 },
- { "gpioy_2", false, 12, 0x00000004 },
- { "gpioy_3", false, 12, 0x00000008 },
-
- { "gpioz_2", false, 4, 0x00000004 },
- { "gpioz_3", false, 4, 0x00000008 },
- { "gpioz_4", false, 4, 0x00000010 },
- { "gpioz_5", false, 4, 0x00000020 },
- { "gpioz_6", false, 4, 0x00000040 },
- { "gpioz_7", false, 4, 0x00000080 },
- { "gpioz_8", false, 4, 0x00000100 },
- { "gpioz_9", false, 4, 0x00000200 },
- { "gpioz_10", false, 4, 0x00000400 },
- { "gpioz_11", false, 4, 0x00000800 },
- { "gpioz_12", false, 4, 0x00001000 },
- { "gpioz_13", false, 4, 0x00002000 },
-
- { "gpioao_0", true, 0, 0x00000001 },
- { "gpioao_1", true, 0, 0x00000002 },
- { "gpioao_2", true, 0, 0x00000004 },
- { "gpioao_3", true, 0, 0x00000008 },
- { "gpioao_4", true, 0, 0x00000010 },
- { "gpioao_5", true, 0, 0x00000020 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_gpio[] = {
- { "boot_0", "boot_0", 0, 0x00000000 },
- { "boot_1", "boot_1", 0, 0x00000000 },
- { "boot_2", "boot_2", 0, 0x00000000 },
- { "boot_3", "boot_3", 0, 0x00000000 },
- { "boot_4", "boot_4", 0, 0x00000000 },
- { "boot_5", "boot_5", 0, 0x00000000 },
- { "boot_6", "boot_6", 0, 0x00000000 },
- { "boot_7", "boot_7", 0, 0x00000000 },
-
- { "boot_16", "boot_16", 0, 0x00000000 },
- { "boot_17", "boot_17", 0, 0x00000000 },
-
- { "card_0", "card_0", 0, 0x00000000 },
- { "card_1", "card_1", 0, 0x00000000 },
- { "card_2", "card_2", 0, 0x00000000 },
- { "card_3", "card_3", 0, 0x00000000 },
- { "card_4", "card_4", 0, 0x00000000 },
- { "card_5", "card_5", 0, 0x00000000 },
- { "card_6", "card_6", 0, 0x00000000 },
-
- { "gpioh_0", "gpioh_0", 0, 0x00000000 },
- { "gpioh_1", "gpioh_1", 0, 0x00000000 },
- { "gpioh_2", "gpioh_2", 0, 0x00000000 },
- { "gpioh_3", "gpioh_3", 0, 0x00000000 },
-
- { "gpiox_12", "gpiox_12", 0, 0x00000000 },
- { "gpiox_13", "gpiox_13", 0, 0x00000000 },
- { "gpiox_14", "gpiox_14", 0, 0x00000000 },
- { "gpiox_15", "gpiox_15", 0, 0x00000000 },
- { "gpiox_16", "gpiox_16", 0, 0x00000000 },
- { "gpiox_17", "gpiox_17", 0, 0x00000000 },
- { "gpiox_18", "gpiox_18", 0, 0x00000000 },
- { "gpiox_19", "gpiox_19", 0, 0x00000000 },
-
- { "gpioy_0", "gpioy_0", 0, 0x00000000 },
- { "gpioy_1", "gpioy_1", 0, 0x00000000 },
- { "gpioy_2", "gpioy_2", 0, 0x00000000 },
- { "gpioy_3", "gpioy_3", 0, 0x00000000 },
-
- { "gpioz_2", "gpioz_2", 0, 0x00000000 },
- { "gpioz_3", "gpioz_3", 0, 0x00000000 },
- { "gpioz_4", "gpioz_4", 0, 0x00000000 },
- { "gpioz_5", "gpioz_5", 0, 0x00000000 },
- { "gpioz_6", "gpioz_6", 0, 0x00000000 },
- { "gpioz_7", "gpioz_7", 0, 0x00000000 },
- { "gpioz_8", "gpioz_8", 0, 0x00000000 },
- { "gpioz_9", "gpioz_9", 0, 0x00000000 },
- { "gpioz_10", "gpioz_10", 0, 0x00000000 },
- { "gpioz_11", "gpioz_11", 0, 0x00000000 },
- { "gpioz_12", "gpioz_12", 0, 0x00000000 },
- { "gpioz_13", "gpioz_13", 0, 0x00000000 },
-
- { "gpioao_0", "gpioao_0", 0, 0x00000000 },
- { "gpioao_1", "gpioao_1", 0, 0x00000000 },
- { "gpioao_2", "gpioao_2", 0, 0x00000000 },
- { "gpioao_3", "gpioao_3", 0, 0x00000000 },
- { "gpioao_4", "gpioao_4", 0, 0x00000000 },
- { "gpioao_5", "gpioao_5", 0, 0x00000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_ethernet[] = {
- { "tx_clk", "gpioz_4", 24, 0x00008000 },
- { "tx_en", "gpioz_5", 24, 0x00004000 },
- { "tx_d0", "gpioz_7", 24, 0x00001000 },
- { "tx_d1", "gpioz_6", 24, 0x00002000 },
- { "rx_clk_in", "gpioz_8", 24, 0x00000400 },
- { "rx_clk_out", "gpioz_8", 24, 0x00000200 },
- { "rx_dv", "gpioz_9", 24, 0x00000800 },
- { "rx_d0", "gpioz_11", 24, 0x00000080 },
- { "rx_d1", "gpioz_10", 24, 0x00000100 },
- { "mdc", "gpioz_13", 24, 0x00000020 },
- { "mdio", "gpioz_12", 24, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_hdmi[] = {
- { "cec", "gpioh_3", 4, 0x00800000 },
- { "hpd", "gpioh_0", 4, 0x04000000 },
- { "scl", "gpioh_2", 4, 0x01000000 },
- { "sda", "gpioh_1", 4, 0x02000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_i2c_a[] = {
- { "scl", "gpioz_12", 20, 0x00000040 },
- { "sda", "gpioz_11", 20, 0x00000080 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_i2c_b[] = {
- { "scl", "gpioz_3", 20, 0x04000000 },
- { "sda", "gpioz_2", 20, 0x08000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_sdio_b[] = {
- { "clk", "card_2", 8, 0x00000800 },
- { "cmd", "card_3", 8, 0x00000400 },
- { "d0", "card_1", 8, 0x00008000 },
- { "d1", "card_0", 8, 0x00004000 },
- { "d2", "card_5", 8, 0x00002000 },
- { "d3", "card_4", 8, 0x00001000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_sdxc_b[] = {
- { "clk", "card_2", 8, 0x00000020 },
- { "cmd", "card_3", 8, 0x00000010 },
- { "d0", "card_1", 8, 0x00000080 },
- { "d1", "card_0", 8, 0x00000040 },
- { "d2", "card_5", 8, 0x00000040 },
- { "d3", "card_4", 8, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_sdio_c[] = {
- { "clk", "boot_17", 24, 0x01000000 },
- { "cmd", "boot_16", 24, 0x02000000 },
- { "d0", "boot_0", 24, 0x20000000 },
- { "d1", "boot_1", 24, 0x10000000 },
- { "d2", "boot_2", 24, 0x08000000 },
- { "d3", "boot_3", 24, 0x04000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_sdxc_c[] = {
- { "clk", "boot_17", 16, 0x04000000 },
- { "cmd", "boot_16", 16, 0x08000000 },
- { "d0", "boot_0", 16, 0x40000000 },
- { "d1", "boot_1", 16, 0x20000000 },
- { "d2", "boot_2", 16, 0x20000000 },
- { "d3", "boot_3", 16, 0x20000000 },
- { "d4", "boot_4", 16, 0x10000000 },
- { "d5", "boot_5", 16, 0x10000000 },
- { "d6", "boot_6", 16, 0x10000000 },
- { "d7", "boot_7", 16, 0x10000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_uart_a[] = {
- { "tx", "gpiox_4", 16, 0x00020000 },
- { "rx", "gpiox_5", 16, 0x00010000 },
- { "cts", "gpiox_6", 16, 0x00008000 },
- { "rts", "gpiox_7", 16, 0x00004000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_uart_b[] = {
- { "tx", "gpiox_16", 16, 0x00000200 },
- { "rx", "gpiox_17", 16, 0x00000100 },
- { "cts", "gpiox_18", 16, 0x00000080 },
- { "rts", "gpiox_19", 16, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_uart_c[] = {
- { "tx", "gpioy_0", 4, 0x00080000 },
- { "rx", "gpioy_1", 4, 0x00040000 },
- { "cts", "gpioy_2", 4, 0x00020000 },
- { "rts", "gpioy_3", 4, 0x00010000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_i2c_ao[] = {
- { "scl", "gpioao_4", 0, 0x00000400 },
- { "sda", "gpioao_5", 0, 0x00000200 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8_uart_ao[] = {
- { "tx", "gpioao_0", 0, 0x00001000 },
- { "rx", "gpioao_1", 0, 0x00000800 },
- { "cts", "gpioao_2", 0, 0x00000400 },
- { "rts", "gpioao_3", 0, 0x00000200 },
- { NULL }
-};
-
-struct aml8726_pinctrl_function aml8726_m8_pinctrl[] = {
- { "gpio", aml8726_m8_gpio },
- { "ethernet", aml8726_m8_ethernet },
- { "hdmi", aml8726_m8_hdmi },
- { "i2c-a", aml8726_m8_i2c_a },
- { "i2c-b", aml8726_m8_i2c_b },
- { "sdio-b", aml8726_m8_sdio_b },
- { "sdxc-b", aml8726_m8_sdxc_b },
- { "sdio-c", aml8726_m8_sdio_c },
- { "sdxc-c", aml8726_m8_sdxc_c },
- { "uart-a", aml8726_m8_uart_a },
- { "uart-b", aml8726_m8_uart_b },
- { "uart-c", aml8726_m8_uart_c },
- { "i2c-ao", aml8726_m8_i2c_ao },
- { "uart-ao", aml8726_m8_uart_ao },
- { NULL }
-};
-
-/*
- * aml8726-m8b
- *
- * start size
- * cbus mux 0x202c 40
- * cbus pu_pd 0x203a 24
- * cbus pull_en 0x2048 24
- * aobus mux 0x0005 4
- * aobus pu_pd 0x000b 4
- * aobus pull_en 0x000b 4
- */
-
-static struct aml8726_pinctrl_pkg_pin aml8726_m8b_pkg_pin[] = {
- { "boot_0", false, 8, 0x00000001 },
- { "boot_1", false, 8, 0x00000002 },
- { "boot_2", false, 8, 0x00000004 },
- { "boot_3", false, 8, 0x00000008 },
- { "boot_4", false, 8, 0x00000010 },
- { "boot_5", false, 8, 0x00000020 },
- { "boot_6", false, 8, 0x00000040 },
- { "boot_7", false, 8, 0x00000080 },
- { "boot_8", false, 8, 0x00000100 },
- { "boot_9", false, 8, 0x00000200 },
- { "boot_10", false, 8, 0x00000400 },
-
- { "card_0", false, 8, 0x00100000 },
- { "card_1", false, 8, 0x00200000 },
- { "card_2", false, 8, 0x00400000 },
- { "card_3", false, 8, 0x00800000 },
- { "card_4", false, 8, 0x01000000 },
- { "card_5", false, 8, 0x02000000 },
- { "card_6", false, 8, 0x04000000 },
-
- { "dif_0p", false, 20, 0x00000100 },
- { "dif_0n", false, 20, 0x00000200 },
- { "dif_1p", false, 20, 0x00000400 },
- { "dif_1n", false, 20, 0x00000800 },
- { "dif_2p", false, 20, 0x00001000 },
- { "dif_2n", false, 20, 0x00002000 },
- { "dif_3p", false, 20, 0x00004000 },
- { "dif_3n", false, 20, 0x00008000 },
- { "dif_4p", false, 20, 0x00010000 },
- { "dif_4n", false, 20, 0x00020000 },
-
- { "gpiodv_24", false, 0, 0x01000000 },
- { "gpiodv_25", false, 0, 0x02000000 },
- { "gpiodv_26", false, 0, 0x04000000 },
- { "gpiodv_27", false, 0, 0x08000000 },
-
- { "gpioh_0", false, 4, 0x00010000 },
- { "gpioh_1", false, 4, 0x00020000 },
- { "gpioh_2", false, 4, 0x00040000 },
- { "gpioh_3", false, 4, 0x00080000 },
- { "gpioh_4", false, 4, 0x00100000 },
- { "gpioh_5", false, 4, 0x00200000 },
- { "gpioh_6", false, 4, 0x00400000 },
- { "gpioh_7", false, 4, 0x00800000 },
- { "gpioh_8", false, 4, 0x01000000 },
- { "gpioh_9", false, 4, 0x02000000 },
-
- { "gpiox_4", false, 16, 0x00000010 },
- { "gpiox_5", false, 16, 0x00000020 },
- { "gpiox_6", false, 16, 0x00000040 },
- { "gpiox_7", false, 16, 0x00000080 },
- { "gpiox_16", false, 16, 0x00010000 },
- { "gpiox_17", false, 16, 0x00020000 },
- { "gpiox_18", false, 16, 0x00040000 },
- { "gpiox_19", false, 16, 0x00080000 },
-
- { "gpioao_0", true, 0, 0x00000001 },
- { "gpioao_1", true, 0, 0x00000002 },
- { "gpioao_2", true, 0, 0x00000004 },
- { "gpioao_3", true, 0, 0x00000008 },
- { "gpioao_4", true, 0, 0x00000010 },
- { "gpioao_5", true, 0, 0x00000020 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_gpio[] = {
- { "boot_0", "boot_0", 0, 0x00000000 },
- { "boot_1", "boot_1", 0, 0x00000000 },
- { "boot_2", "boot_2", 0, 0x00000000 },
- { "boot_3", "boot_3", 0, 0x00000000 },
- { "boot_4", "boot_4", 0, 0x00000000 },
- { "boot_5", "boot_5", 0, 0x00000000 },
- { "boot_6", "boot_6", 0, 0x00000000 },
- { "boot_7", "boot_7", 0, 0x00000000 },
- { "boot_8", "boot_8", 0, 0x00000000 },
- { "boot_9", "boot_9", 0, 0x00000000 },
- { "boot_10", "boot_10", 0, 0x00000000 },
-
- { "card_0", "card_0", 0, 0x00000000 },
- { "card_1", "card_1", 0, 0x00000000 },
- { "card_2", "card_2", 0, 0x00000000 },
- { "card_3", "card_3", 0, 0x00000000 },
- { "card_4", "card_4", 0, 0x00000000 },
- { "card_5", "card_5", 0, 0x00000000 },
- { "card_6", "card_6", 0, 0x00000000 },
-
- { "dif_0p", "dif_0p", 0, 0x00000000 },
- { "dif_0n", "dif_0n", 0, 0x00000000 },
- { "dif_1p", "dif_1p", 0, 0x00000000 },
- { "dif_1n", "dif_1n", 0, 0x00000000 },
- { "dif_2p", "dif_2p", 0, 0x00000000 },
- { "dif_2n", "dif_2n", 0, 0x00000000 },
- { "dif_3p", "dif_3p", 0, 0x00000000 },
- { "dif_3n", "dif_3n", 0, 0x00000000 },
- { "dif_4p", "dif_4p", 0, 0x00000000 },
- { "dif_4n", "dif_4n", 0, 0x00000000 },
-
- { "gpiodv_24", "gpiodv_24", 0, 0x00000000 },
- { "gpiodv_25", "gpiodv_25", 0, 0x00000000 },
- { "gpiodv_26", "gpiodv_26", 0, 0x00000000 },
- { "gpiodv_27", "gpiodv_27", 0, 0x00000000 },
-
- { "gpioh_0", "gpioh_0", 0, 0x00000000 },
- { "gpioh_1", "gpioh_1", 0, 0x00000000 },
- { "gpioh_2", "gpioh_2", 0, 0x00000000 },
- { "gpioh_3", "gpioh_3", 0, 0x00000000 },
- { "gpioh_4", "gpioh_4", 0, 0x00000000 },
- { "gpioh_5", "gpioh_5", 0, 0x00000000 },
- { "gpioh_6", "gpioh_6", 0, 0x00000000 },
- { "gpioh_7", "gpioh_7", 0, 0x00000000 },
- { "gpioh_8", "gpioh_8", 0, 0x00000000 },
- { "gpioh_9", "gpioh_9", 0, 0x00000000 },
-
- { "gpiox_4", "gpiox_4", 0, 0x00000000 },
- { "gpiox_5", "gpiox_5", 0, 0x00000000 },
- { "gpiox_6", "gpiox_6", 0, 0x00000000 },
- { "gpiox_7", "gpiox_7", 0, 0x00000000 },
- { "gpiox_16", "gpiox_16", 0, 0x00000000 },
- { "gpiox_17", "gpiox_17", 0, 0x00000000 },
- { "gpiox_18", "gpiox_18", 0, 0x00000000 },
- { "gpiox_19", "gpiox_19", 0, 0x00000000 },
-
- { "gpioao_0", "gpioao_0", 0, 0x00000000 },
- { "gpioao_1", "gpioao_1", 0, 0x00000000 },
- { "gpioao_2", "gpioao_2", 0, 0x00000000 },
- { "gpioao_3", "gpioao_3", 0, 0x00000000 },
- { "gpioao_4", "gpioao_4", 0, 0x00000000 },
- { "gpioao_5", "gpioao_5", 0, 0x00000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_ethernet[] = {
- { "ref_clk", "dif_3n", 24, 0x00000100 },
- { "tx_clk", "gpioh_9", 24, 0x00000800 },
- { "tx_en", "dif_3p", 24, 0x00000040 },
- { "tx_d0", "gpioh_6", 28, 0x00100000 },
- { "tx_d1", "gpioh_5", 28, 0x00200000 },
- { "tx_d2", "gpioh_8", 24, 0x00001000 },
- { "tx_d3", "gpioh_7", 24, 0x00002000 },
- { "rx_clk", "dif_1n", 24, 0x00000008 },
- { "rx_dv", "dif_1p", 24, 0x00000004 },
- { "rx_d0", "dif_0n", 24, 0x00000002 },
- { "rx_d1", "dif_0p", 24, 0x00000001 },
- { "rx_d2", "dif_2n", 28, 0x00800000 },
- { "rx_d3", "dif_2p", 28, 0x00400000 },
- { "mdc", "dif_4p", 24, 0x00000200 },
- { "mdio", "dif_4n", 24, 0x00000400 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_hdmi[] = {
- { "cec", "gpioh_3", 4, 0x00800000 },
- { "hpd", "gpioh_0", 4, 0x04000000 },
- { "scl", "gpioh_2", 4, 0x01000000 },
- { "sda", "gpioh_1", 4, 0x02000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_i2c_a[] = {
- { "scl", "gpiodv_25", 36, 0x40000000 },
- { "sda", "gpiodv_24", 36, 0x80000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_i2c_b[] = {
- { "scl", "gpiodv_27", 36, 0x10000000 },
- { "sda", "gpiodv_26", 36, 0x20000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_sdio_b[] = {
- { "clk", "card_2", 8, 0x00000800 },
- { "cmd", "card_3", 8, 0x00000400 },
- { "d0", "card_1", 8, 0x00008000 },
- { "d1", "card_0", 8, 0x00004000 },
- { "d2", "card_5", 8, 0x00002000 },
- { "d3", "card_4", 8, 0x00001000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_sdxc_b[] = {
- { "clk", "card_2", 8, 0x00000020 },
- { "cmd", "card_3", 8, 0x00000010 },
- { "d0", "card_1", 8, 0x00000080 },
- { "d1", "card_0", 8, 0x00000040 },
- { "d2", "card_5", 8, 0x00000040 },
- { "d3", "card_4", 8, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_sdio_c[] = {
- { "clk", "boot_8", 24, 0x80000000 },
- { "cmd", "boot_10", 24, 0x40000000 },
- { "d0", "boot_0", 24, 0x20000000 },
- { "d1", "boot_1", 24, 0x10000000 },
- { "d2", "boot_2", 24, 0x08000000 },
- { "d3", "boot_3", 24, 0x04000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_sdxc_c[] = {
- { "clk", "boot_8", 28, 0x00080000 },
- { "cmd", "boot_10", 28, 0x00040000 },
- { "d0", "boot_0", 16, 0x40000000 },
- { "d1", "boot_1", 16, 0x20000000 },
- { "d2", "boot_2", 16, 0x20000000 },
- { "d3", "boot_3", 16, 0x20000000 },
- { "d4", "boot_4", 16, 0x10000000 },
- { "d5", "boot_5", 16, 0x10000000 },
- { "d6", "boot_6", 16, 0x10000000 },
- { "d7", "boot_7", 16, 0x10000000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_uart_a[] = {
- { "tx", "gpiox_4", 16, 0x00020000 },
- { "rx", "gpiox_5", 16, 0x00010000 },
- { "cts", "gpiox_6", 16, 0x00008000 },
- { "rts", "gpiox_7", 16, 0x00004000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_uart_b[] = {
- { "tx", "gpiox_16", 16, 0x00000200 },
- { "rx", "gpiox_17", 16, 0x00000100 },
- { "cts", "gpiox_18", 16, 0x00000080 },
- { "rts", "gpiox_19", 16, 0x00000040 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_uart_c[] = {
- { "tx", "gpiodv_24", 24, 0x00800000 },
- { "rx", "gpiodv_25", 24, 0x00400000 },
- { "cts", "gpiodv_26", 24, 0x00200000 },
- { "rts", "gpiodv_27", 24, 0x00100000 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_i2c_ao[] = {
- { "scl", "gpioao_4", 0, 0x00000400 },
- { "sda", "gpioao_5", 0, 0x00000200 },
- { NULL }
-};
-
-static struct aml8726_pinctrl_pin aml8726_m8b_uart_ao[] = {
- { "tx", "gpioao_0", 0, 0x00001000 },
- { "rx", "gpioao_1", 0, 0x00000800 },
- { "cts", "gpioao_2", 0, 0x00000400 },
- { "rts", "gpioao_3", 0, 0x00000200 },
- { NULL }
-};
-
-struct aml8726_pinctrl_function aml8726_m8b_pinctrl[] = {
- { "gpio", aml8726_m8b_gpio },
- { "ethernet", aml8726_m8b_ethernet },
- { "hdmi", aml8726_m8b_hdmi },
- { "i2c-a", aml8726_m8b_i2c_a },
- { "i2c-b", aml8726_m8b_i2c_b },
- { "sdio-b", aml8726_m8b_sdio_b },
- { "sdxc-b", aml8726_m8b_sdxc_b },
- { "sdio-c", aml8726_m8b_sdio_c },
- { "sdxc-c", aml8726_m8b_sdxc_c },
- { "uart-a", aml8726_m8b_uart_a },
- { "uart-b", aml8726_m8b_uart_b },
- { "uart-c", aml8726_m8b_uart_c },
- { "i2c-ao", aml8726_m8b_i2c_ao },
- { "uart-ao", aml8726_m8b_uart_ao },
- { NULL }
-};
-
-#endif /* _ARM_AMLOGIC_AML8726_PINCTRL_H */
sys/arm/amlogic/aml8726/aml8726_rng.c→/dev/null
@@ -1,152 +0,0 @@
-/*-
- * Copyright 2014 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 random number generator driver.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-#include <sys/random.h>
-
-#include <machine/bus.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-struct aml8726_rng_softc {
- device_t dev;
- struct resource *res[1];
- struct callout co;
- int ticks;
-};
-
-static struct resource_spec aml8726_rng_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-#define AML_RNG_0_REG 0
-#define AML_RNG_1_REG 4
-
-#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-
-static void
-aml8726_rng_harvest(void *arg)
-{
- struct aml8726_rng_softc *sc = arg;
- uint32_t rn[2];
-
- rn[0] = CSR_READ_4(sc, AML_RNG_0_REG);
- rn[1] = CSR_READ_4(sc, AML_RNG_1_REG);
-
- random_harvest(rn, sizeof(rn), RANDOM_PURE_AML8726);
-
- callout_reset(&sc->co, sc->ticks, aml8726_rng_harvest, sc);
-}
-
-static int
-aml8726_rng_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-rng"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 RNG");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_rng_attach(device_t dev)
-{
- struct aml8726_rng_softc *sc = device_get_softc(dev);
-
- sc->dev = dev;
-
- if (bus_alloc_resources(dev, aml8726_rng_spec, sc->res)) {
- device_printf(dev, "can not allocate resources for device\n");
- return (ENXIO);
- }
-
- /* Install a periodic collector for the RNG */
- if (hz > 100)
- sc->ticks = hz / 100;
- else
- sc->ticks = 1;
-
- callout_init(&sc->co, 1);
- callout_reset(&sc->co, sc->ticks, aml8726_rng_harvest, sc);
-
- return (0);
-}
-
-static int
-aml8726_rng_detach(device_t dev)
-{
- struct aml8726_rng_softc *sc = device_get_softc(dev);
-
- callout_drain(&sc->co);
-
- bus_release_resources(dev, aml8726_rng_spec, sc->res);
-
- return (0);
-}
-
-static device_method_t aml8726_rng_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_rng_probe),
- DEVMETHOD(device_attach, aml8726_rng_attach),
- DEVMETHOD(device_detach, aml8726_rng_detach),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_rng_driver = {
- "rng",
- aml8726_rng_methods,
- sizeof(struct aml8726_rng_softc),
-};
-
-static devclass_t aml8726_rng_devclass;
-
-DRIVER_MODULE(aml8726_rng, simplebus, aml8726_rng_driver,
- aml8726_rng_devclass, 0, 0);
-MODULE_DEPEND(aml8726_rng, random, 1, 1, 1);
sys/arm/amlogic/aml8726/aml8726_rtc.c→/dev/null
@@ -1,488 +0,0 @@
-/*-
- * Copyright 2013-2015 John Wehle <john@feith.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Amlogic aml8726 RTC driver.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/clock.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-
-#include <sys/time.h>
-
-#include <machine/bus.h>
-#include <machine/cpu.h>
-
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-
-#include <arm/amlogic/aml8726/aml8726_soc.h>
-
-#include "clock_if.h"
-
-/*
- * The RTC initialization various slightly between the different chips.
- *
- * aml8726-m1 aml8726-m3 aml8726-m6 (and later)
- * init-always true true false
- * xo-init 0x0004 0x3c0a 0x180a
- * gpo-init 0x100000 0x100000 0x500000
- */
-
-struct aml8726_rtc_init {
- boolean_t always;
- uint16_t xo;
- uint32_t gpo;
-};
-
-struct aml8726_rtc_softc {
- device_t dev;
- struct aml8726_rtc_init init;
- struct resource * res[2];
- struct mtx mtx;
-};
-
-static struct resource_spec aml8726_rtc_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_IRQ, 0, RF_ACTIVE },
- { -1, 0 }
-};
-
-#define AML_RTC_LOCK(sc) mtx_lock_spin(&(sc)->mtx)
-#define AML_RTC_UNLOCK(sc) mtx_unlock_spin(&(sc)->mtx)
-#define AML_RTC_LOCK_INIT(sc) \
- mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
- "rtc", MTX_SPIN)
-#define AML_RTC_LOCK_DESTROY(sc) mtx_destroy(&(sc)->mtx);
-
-#define AML_RTC_0_REG 0
-#define AML_RTC_SCLK (1 << 0)
-#define AML_RTC_SDI (1 << 2)
-#define AML_RTC_SEN (1 << 1)
-#define AML_RTC_AS (1 << 17)
-#define AML_RTC_ABSY (1 << 22)
-#define AML_RTC_IRQ_DIS (1 << 12)
-#define AML_RTC_1_REG 4
-#define AML_RTC_SDO (1 << 0)
-#define AML_RTC_SRDY (1 << 1)
-#define AML_RTC_2_REG 8
-#define AML_RTC_3_REG 12
-#define AML_RTC_MSR_BUSY (1 << 20)
-#define AML_RTC_MSR_CA (1 << 17)
-#define AML_RTC_MSR_DURATION_EN (1 << 16)
-#define AML_RTC_MSR_DURATION_MASK 0xffff
-#define AML_RTC_MSR_DURATION_SHIFT 0
-#define AML_RTC_4_REG 16
-
-#define AML_RTC_TIME_SREG 0
-#define AML_RTC_GPO_SREG 1
-#define AML_RTC_GPO_LEVEL (1 << 24)
-#define AML_RTC_GPO_BUSY (1 << 23)
-#define AML_RTC_GPO_ACTIVE_HIGH (1 << 22)
-#define AML_RTC_GPO_CMD_MASK (3 << 20)
-#define AML_RTC_GPO_CMD_SHIFT 20
-#define AML_RTC_GPO_CMD_NOW (1 << 20)
-#define AML_RTC_GPO_CMD_COUNT (2 << 20)
-#define AML_RTC_GPO_CMD_PULSE (3 << 20)
-#define AML_RTC_GPO_CNT_MASK 0xfffff
-#define AML_RTC_GPO_CNT_SHIFT 0
-
-#define CSR_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
-#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
-#define CSR_BARRIER(sc, reg) bus_barrier((sc)->res[0], reg, 4, \
- (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
-
-static int
-aml8726_rtc_start_transfer(struct aml8726_rtc_softc *sc)
-{
- unsigned i;
-
- /* idle the serial interface */
- CSR_WRITE_4(sc, AML_RTC_0_REG, (CSR_READ_4(sc, AML_RTC_0_REG) &
- ~(AML_RTC_SCLK | AML_RTC_SEN | AML_RTC_SDI)));
-
- CSR_BARRIER(sc, AML_RTC_0_REG);
-
- /* see if it is ready for a new cycle */
- for (i = 40; i; i--) {
- DELAY(5);
- if ( (CSR_READ_4(sc, AML_RTC_1_REG) & AML_RTC_SRDY) )
- break;
- }
-
- if (i == 0)
- return (EIO);
-
- /* start the cycle */
- CSR_WRITE_4(sc, AML_RTC_0_REG, (CSR_READ_4(sc, AML_RTC_0_REG) |
- AML_RTC_SEN));
-
- return (0);
-}
-
-static inline void
-aml8726_rtc_sclk_pulse(struct aml8726_rtc_softc *sc)
-{
-
- DELAY(5);
-
- CSR_WRITE_4(sc, AML_RTC_0_REG, (CSR_READ_4(sc, AML_RTC_0_REG) |
- AML_RTC_SCLK));
-
- CSR_BARRIER(sc, AML_RTC_0_REG);
-
- DELAY(5);
-
- CSR_WRITE_4(sc, AML_RTC_0_REG, (CSR_READ_4(sc, AML_RTC_0_REG) &
- ~AML_RTC_SCLK));
-
- CSR_BARRIER(sc, AML_RTC_0_REG);
-}
-
-static inline void
-aml8726_rtc_send_bit(struct aml8726_rtc_softc *sc, unsigned bit)
-{
-
- if (bit) {
- CSR_WRITE_4(sc, AML_RTC_0_REG, (CSR_READ_4(sc, AML_RTC_0_REG) |
- AML_RTC_SDI));
- } else {
- CSR_WRITE_4(sc, AML_RTC_0_REG, (CSR_READ_4(sc, AML_RTC_0_REG) &
- ~AML_RTC_SDI));
- }
-
- aml8726_rtc_sclk_pulse(sc);
-}
-
-static inline void
-aml8726_rtc_send_addr(struct aml8726_rtc_softc *sc, u_char addr)
-{
- unsigned mask;
-
- for (mask = 1 << 3; mask; mask >>= 1) {
- if (mask == 1) {
- /* final bit indicates read / write mode */
- CSR_WRITE_4(sc, AML_RTC_0_REG,
- (CSR_READ_4(sc, AML_RTC_0_REG) & ~AML_RTC_SEN));
- }
- aml8726_rtc_send_bit(sc, (addr & mask));
- }
-}
-
-static inline void
-aml8726_rtc_send_data(struct aml8726_rtc_softc *sc, uint32_t data)
-{
- unsigned mask;
-
- for (mask = 1U << 31; mask; mask >>= 1)
- aml8726_rtc_send_bit(sc, (data & mask));
-}
-
-static inline void
-aml8726_rtc_recv_data(struct aml8726_rtc_softc *sc, uint32_t *dp)
-{
- uint32_t data;
- unsigned i;
-
- data = 0;
-
- for (i = 0; i < 32; i++) {
- aml8726_rtc_sclk_pulse(sc);
- data <<= 1;
- data |= (CSR_READ_4(sc, AML_RTC_1_REG) & AML_RTC_SDO) ? 1 : 0;
- }
-
- *dp = data;
-}
-
-static int
-aml8726_rtc_sreg_read(struct aml8726_rtc_softc *sc, u_char sreg, uint32_t *val)
-{
- u_char addr;
- int error;
-
- /* read is indicated by lsb = 0 */
- addr = (sreg << 1) | 0;
-
- error = aml8726_rtc_start_transfer(sc);
-
- if (error)
- return (error);
-
- aml8726_rtc_send_addr(sc, addr);
- aml8726_rtc_recv_data(sc, val);
-
- return (0);
-}
-
-static int
-aml8726_rtc_sreg_write(struct aml8726_rtc_softc *sc, u_char sreg, uint32_t val)
-{
- u_char addr;
- int error;
-
- /* write is indicated by lsb = 1 */
- addr = (sreg << 1) | 1;
-
- error = aml8726_rtc_start_transfer(sc);
-
- if (error)
- return (error);
-
- aml8726_rtc_send_data(sc, val);
- aml8726_rtc_send_addr(sc, addr);
-
- return (0);
-}
-
-static int
-aml8726_rtc_initialize(struct aml8726_rtc_softc *sc)
-{
- int error;
- unsigned i;
-
- /* idle the serial interface */
- CSR_WRITE_4(sc, AML_RTC_0_REG, (CSR_READ_4(sc, AML_RTC_0_REG) &
- ~(AML_RTC_SCLK | AML_RTC_SEN | AML_RTC_SDI)));
-
- CSR_BARRIER(sc, AML_RTC_0_REG);
-
- /* see if it is ready for a new cycle */
- for (i = 40; i; i--) {
- DELAY(5);
- if ( (CSR_READ_4(sc, AML_RTC_1_REG) & AML_RTC_SRDY) )
- break;
- }
-
- if (sc->init.always == TRUE || (CSR_READ_4(sc, AML_RTC_1_REG) &
- AML_RTC_SRDY) == 0) {
- /*
- * The RTC has a 16 bit initialization register. The upper
- * bits can be written directly. The lower bits are written
- * through a shift register.
- */
-
- CSR_WRITE_4(sc, AML_RTC_4_REG, ((sc->init.xo >> 8) & 0xff));
-
- CSR_WRITE_4(sc, AML_RTC_0_REG,
- ((CSR_READ_4(sc, AML_RTC_0_REG) & 0xffffff) |
- ((uint32_t)(sc->init.xo & 0xff) << 24) | AML_RTC_AS |
- AML_RTC_IRQ_DIS));
-
- while ((CSR_READ_4(sc, AML_RTC_0_REG) & AML_RTC_ABSY) != 0)
- cpu_spinwait();
-
- DELAY(2);
-
- error = aml8726_rtc_sreg_write(sc, AML_RTC_GPO_SREG,
- sc->init.gpo);
-
- if (error)
- return (error);
- }
-
- return (0);
-}
-
-static int
-aml8726_rtc_check_xo(struct aml8726_rtc_softc *sc)
-{
- uint32_t now, previous;
- int i;
-
- /*
- * The RTC is driven by a 32.768khz clock meaning it's period
- * is roughly 30.5 us. Check that it's working (implying the
- * RTC could contain a valid value) by enabling count always
- * and seeing if the value changes after 200 us (per RTC User
- * Guide ... presumably the extra time is to cover XO startup).
- */
-
- CSR_WRITE_4(sc, AML_RTC_3_REG, (CSR_READ_4(sc, AML_RTC_3_REG) |
- AML_RTC_MSR_CA));
-
- previous = CSR_READ_4(sc, AML_RTC_2_REG);
-
- for (i = 0; i < 4; i++) {
- DELAY(50);
- now = CSR_READ_4(sc, AML_RTC_2_REG);
- if (now != previous)
- break;
- }
-
- CSR_WRITE_4(sc, AML_RTC_3_REG, (CSR_READ_4(sc, AML_RTC_3_REG) &
- ~AML_RTC_MSR_CA));
-
- if (now == previous)
- return (EINVAL);
-
- return (0);
-}
-
-static int
-aml8726_rtc_probe(device_t dev)
-{
-
- if (!ofw_bus_status_okay(dev))
- return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-rtc"))
- return (ENXIO);
-
- device_set_desc(dev, "Amlogic aml8726 RTC");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-aml8726_rtc_attach(device_t dev)
-{
- struct aml8726_rtc_softc *sc = device_get_softc(dev);
-
- sc->dev = dev;
-
- switch (aml8726_soc_hw_rev) {
- case AML_SOC_HW_REV_M3:
- sc->init.always = true;
- sc->init.xo = 0x3c0a;
- sc->init.gpo = 0x100000;
- break;
- case AML_SOC_HW_REV_M6:
- case AML_SOC_HW_REV_M8:
- case AML_SOC_HW_REV_M8B:
- sc->init.always = false;
- sc->init.xo = 0x180a;
- sc->init.gpo = 0x500000;
- break;
- default:
- device_printf(dev, "unsupported SoC\n");
- return (ENXIO);
- /* NOTREACHED */
- }
-
- if (bus_alloc_resources(dev, aml8726_rtc_spec, sc->res)) {
- device_printf(dev, "can not allocate resources for device\n");
- return (ENXIO);
- }
-
- aml8726_rtc_initialize(sc);
-
- if (aml8726_rtc_check_xo(sc) != 0) {
- device_printf(dev, "crystal oscillator check failed\n");
-
- bus_release_resources(dev, aml8726_rtc_spec, sc->res);
-
- return (ENXIO);
- }
-
- AML_RTC_LOCK_INIT(sc);
-
- clock_register(dev, 1000000);
-
- return (0);
-}
-
-static int
-aml8726_rtc_detach(device_t dev)
-{
-
- return (EBUSY);
-}
-
-static int
-aml8726_rtc_gettime(device_t dev, struct timespec *ts)
-{
- struct aml8726_rtc_softc *sc = device_get_softc(dev);
- uint32_t sec;
- int error;
-
- AML_RTC_LOCK(sc);
-
- error = aml8726_rtc_sreg_read(sc, AML_RTC_TIME_SREG, &sec);
-
- AML_RTC_UNLOCK(sc);
-
- ts->tv_sec = sec;
- ts->tv_nsec = 0;
-
- return (error);
-}
-
-static int
-aml8726_rtc_settime(device_t dev, struct timespec *ts)
-{
- struct aml8726_rtc_softc *sc = device_get_softc(dev);
- uint32_t sec;
- int error;
-
- sec = ts->tv_sec;
-
- /* Accuracy is only one second. */
- if (ts->tv_nsec >= 500000000)
- sec++;
-
- AML_RTC_LOCK(sc);
-
- error = aml8726_rtc_sreg_write(sc, AML_RTC_TIME_SREG, sec);
-
- AML_RTC_UNLOCK(sc);
-
- return (error);
-}
-
-static device_method_t aml8726_rtc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, aml8726_rtc_probe),
- DEVMETHOD(device_attach, aml8726_rtc_attach),
- DEVMETHOD(device_detach, aml8726_rtc_detach),
-
- /* Clock interface */
- DEVMETHOD(clock_gettime, aml8726_rtc_gettime),
- DEVMETHOD(clock_settime, aml8726_rtc_settime),
-
- DEVMETHOD_END
-};
-
-static driver_t aml8726_rtc_driver = {
- "rtc",
- aml8726_rtc_methods,
- sizeof(struct aml8726_rtc_softc),
-};
-
-static devclass_t aml8726_rtc_devclass;
-
-DRIVER_MODULE(rtc, simplebus, aml8726_rtc_driver, aml8726_rtc_devclass, 0, 0);
sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c→/dev/null
@@ -1,1395 +0,0 @@
-/*-
[diff truncated]