@@ -1054,9 +1054,7 @@ fetch_ssl_setup_ | |||
{ | { | ||
long ssl_ctx_options; | long ssl_ctx_options; | ||
- ssl_ctx_options = SSL_OP_ALL | | + 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) |
@@ -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. |
@@ -1,26 +0,0 @@ | |||
-#!/bin/sh | |||
-# | |||
-# $FreeBSD$ | |||
-# | |||
- | |||
-EMBEDDED_TARGET_ | |||
-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_uboo | |||
- 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 | |||
-} |
@@ -1,31 +0,0 @@ | |||
-#!/bin/sh | |||
-# | |||
-# $FreeBSD$ | |||
-# | |||
- | |||
-EMBEDDED_TARGET_ | |||
-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_uboo | |||
- 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 | |||
-} |
@@ -1,26 +0,0 @@ | |||
-#!/bin/sh | |||
-# | |||
-# $FreeBSD$ | |||
-# | |||
- | |||
-EMBEDDED_TARGET_ | |||
-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_uboo | |||
- 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 | |||
-} |
@@ -1,26 +0,0 @@ | |||
-#!/bin/sh | |||
-# | |||
-# $FreeBSD$ | |||
-# | |||
- | |||
-EMBEDDED_TARGET_ | |||
-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_uboo | |||
- 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 | |||
-} |
@@ -1,26 +0,0 @@ | |||
-#!/bin/sh | |||
-# | |||
-# $FreeBSD$ | |||
-# | |||
- | |||
-EMBEDDED_TARGET_ | |||
-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_uboo | |||
- 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 | |||
-} |
@@ -6,11 +6,64 @@ | |||
EMBEDDED_TARGET_ | EMBEDDED_TARGET_ | ||
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 | |||
+RPI_OL_DIR="${RPI_FIRMWARE_DIR | |||
+OVERLAYS="mmc.dtbo" | |||
PART_SCHEME="MBR" | PART_SCHEME="MBR" | ||
export BOARDNAME="GENERICSD" | export BOARDNAME="GENERICSD" | ||
+ | |||
+arm_install_uboo | |||
+ UBOOT_FILES="u-boot.bin" | |||
+ RPI_FIRMWARE_FIL | |||
+ 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_FIL | |||
+ chroot ${CHROOTDIR} cp -p ${RPI_FIRMWARE_DIR | |||
+ ${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_uboo | |||
+ 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_uboo | |||
+ arm_install_uboo | |||
+ arm_install_uboo | |||
+} |
@@ -1,31 +0,0 @@ | |||
-#!/bin/sh | |||
-# | |||
-# $FreeBSD$ | |||
-# | |||
- | |||
-EMBEDDED_TARGET_ | |||
-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_uboo | |||
- 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 | |||
-} |
@@ -1,50 +0,0 @@ | |||
-#!/bin/sh | |||
-# | |||
-# $FreeBSD$ | |||
-# | |||
- | |||
-EMBEDDED_TARGET_ | |||
-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 | |||
-OL_DIR="${RPI_FIRMWARE_DIR | |||
-OVERLAYS="mmc.dtbo" | |||
-PART_SCHEME="MBR" | |||
-export BOARDNAME="RPI2" | |||
- | |||
-arm_install_uboo | |||
- UBOOT_FILES="u-boot.bin" | |||
- RPI_FIRMWARE_FIL | |||
- 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_FIL | |||
- chroot ${CHROOTDIR} cp -p ${RPI_FIRMWARE_DIR | |||
- ${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 | |||
-} |
@@ -1,26 +0,0 @@ | |||
-#!/bin/sh | |||
-# | |||
-# $FreeBSD$ | |||
-# | |||
- | |||
-EMBEDDED_TARGET_ | |||
-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_uboo | |||
- 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 | |||
-} |
@@ -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_IPS | #ifdef IPSEC_POLICY_IPS | ||
@@ -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 = | + 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 = | + 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 = | + 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 = | + 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 = | + ltmp = strtonum(optarg, 1, INT_MAX, &errstr); | ||
- if (*ep || ep == optarg || ltmp < 1) | + if (errstr != NULL) { | ||
- errx(EX_USAGE, "invalid | + 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 = | + 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 = | + 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 = | + 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: | + "packet size too large: %d > %u", | ||
- | + datalen, DEFDATALEN); | ||
} | } | ||
- datalen = ltmp; | |||
break; | break; | ||
case 'T': /* multicast TTL */ | case 'T': /* multicast TTL */ | ||
- ltmp = | + 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 ( | + 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, | + 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, | + 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; | ||
} | } |
@@ -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 \ |
@@ -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 |
@@ -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. | +.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_LE | |||
+M_ListToSkip?= O:u:S,^,N,:ts: | |||
+.if ${.TARGETS:Uall:${DIRDEPS_BUILD_LE | |||
_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} || \ |
@@ -1,7 +1,7 @@ | |||
# $FreeBSD$ | # $FreeBSD$ | ||
-# $Id: dirdeps-options.mk,v 1. | +# $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_ | ||
+ ${DEP_TARGET_SPEC:U${TARGET_SPEC}} \ | |||
+ ${TARGET_SPEC_VARS | |||
+# 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_ | |||
+.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 ${ | +.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 ${ | +.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_FILTE | GENDIRDEPS_FILTE |
@@ -1,16 +1,16 @@ | |||
# $FreeBSD$ | # $FreeBSD$ | ||
# RCSid: | # RCSid: | ||
-# $Id: dirdeps-targets.mk,v 1. | +# $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_MACHIN | # Finally we select any that match conditions like REQUESTED_MACHIN | ||
# 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_DIRDEP | |||
+# 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_ | |||
# they need to be stripped when looking for target dirs | # they need to be stripped when looking for target dirs | ||
DIRDEPS_TARGETS_ | DIRDEPS_TARGETS_ | ||
+# some .TARGETS need filtering | |||
+DIRDEPS_TARGETS_ | |||
+ | |||
# matching target dirs if any | # matching target dirs if any | ||
-tdirs := ${. | +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_TA | .if !empty(DEBUG_DIRDEPS_TA | ||
.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_DIRDEP | |||
+# 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_C | |||
+.if ${MK_STATIC_DIRDEP | |||
+DIRDEPS_CACHE ?= $c | |||
+MK_DIRDEPS_CACHE | |||
+.endif | |||
+.endif | |||
+.endfor | |||
+.if defined(STATIC_DIRDEPS_C | |||
+.export STATIC_DIRDEPS_C | |||
+.endif | |||
+.endif | |||
+ | |||
+# allow a top-level makefile to do other stuff | |||
+# before including dirdeps.mk | |||
+.if ${MK_DIRDEPS_TARGE | |||
.include <dirdeps.mk> | .include <dirdeps.mk> | ||
+.endif | |||
DIRDEPS_TARGETS_ | DIRDEPS_TARGETS_ | ||
.for t in ${.TARGETS:${DIRDEPS_TARGETS_ | .for t in ${.TARGETS:${DIRDEPS_TARGETS_ | ||
$t: dirdeps | $t: dirdeps | ||
-.endfor | +.endfor | ||
.endif | .endif | ||
.endif | .endif |
@@ -1,7 +1,8 @@ | |||
# $FreeBSD$ | # $FreeBSD$ | ||
-# $Id: dirdeps.mk,v 1. | +# $Id: dirdeps.mk,v 1.130 2020/11/02 00:34:30 sjg Exp $ | ||
-# Copyright (c) 2010- | +# 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 | # or .<target_spec> suffix (see TARGET_SPEC_VARS | ||
# 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 | # and partially qualified (if TARGET_SPEC_VARS | ||
# 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_PREFE | # using ${.MAKE.DEPENDFILE_PREFE | ||
# dependencies. We use Makefile.depend (default value for | # dependencies. We use Makefile.depend (default value for | ||
# .MAKE.DEPENDFILE_PREFI | # .MAKE.DEPENDFILE_PREFI | ||
# 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 | # TARGET_SPEC = ${TARGET_SPEC_VARS | ||
-# | +# | ||
# 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 | # ONLY_TARGET_SPEC | ||
# 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_LEVE | |||
_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 | _tspec_x := ${TARGET_SPEC_VARS | ||
-.elif ${TARGET_SPEC_VARS | |||
-# seriously? better have jot(1) or equivalent to produce suitable sequence | |||
-_tspec_x := ${${JOT:Ujot} ${TARGET_SPEC_VARS | |||
.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 | ||
.endif | .endif | ||
# this handles unqualified entries | # this handles unqualified entries | ||
M_dep_qual_fixes | M_dep_qual_fixes | ||
@@ -223,6 +222,7 @@ _tspec_m$i := ${TARGET_SPEC_VA | |||
_tspec_a$i := ,${TARGET_SPEC_VARS | _tspec_a$i := ,${TARGET_SPEC_VARS | ||
M_dep_qual_fixes | M_dep_qual_fixes | ||
.endfor | .endfor | ||
+TARGET_SPEC_VARS | |||
.else | .else | ||
# A harmless? default. | # A harmless? default. | ||
M_dep_qual_fixes | M_dep_qual_fixes | ||
@@ -307,6 +307,7 @@ DEP_MACHINE := ${_DEP_TARGET_SP | |||
# 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 | .if ${MK_DIRDEPS_CACHE | ||
# this is where we will cache all our work | # this is where we will cache all our work | ||
-DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${. | +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_PRELU | |||
+ | |||
+DIRDEP_LOADAVG_C | |||
+DIRDEP_LOADAVG_L | |||
+# yes the expression here is a bit complicated, | |||
+# the trick is to only eval ${DIRDEP_LOADAVG_L | |||
+# when we want to report. | |||
+DIRDEP_LOADAVG_R | |||
+ test -z "${"${expr ${now_utc} - ${DIRDEP_LOADAVG_I | |||
+ echo "${TRACER}`${DIRDEP_LOADAVG_C | |||
+ | |||
# 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_PREFERE | @for m in ${.MAKE.MAKEFILE_PREFERE | ||
test -s ${.TARGET:R}/$$m || continue; \ | test -s ${.TARGET:R}/$$m || continue; \ | ||
- echo "${TRACER}Checking ${. | + echo "${TRACER}Checking ${.TARGET:S,${SRCTOP}/,,} for ${.TARGET:E} ..."; \ | ||
${DIRDEP_USE_PRELU | ${DIRDEP_USE_PRELU | ||
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} | |||
@MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \ | @MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \ | ||
dirdeps MK_DIRDEPS_CACHE | dirdeps MK_DIRDEPS_CACHE | ||
+# leaf makefiles rarely work for building DIRDEPS_CACHE | |||
+.if ${RELDIR} != "." | |||
+BUILD_DIRDEPS_MA | |||
+.endif | |||
+ | |||
# these should generally do | # these should generally do | ||
-BUILD_DIRDEPS_MAKEFILE ?= | +BUILD_DIRDEPS_MAKEFILE ?= | ||
BUILD_DIRDEPS_TA | BUILD_DIRDEPS_TA | ||
+.if ${DIRDEPS_CACHE} != ${STATIC_DIRDEPS_C | |||
+# export this for dirdeps-cache-update.mk | |||
+DYNAMIC_DIRDEPS_ | |||
+.export DYNAMIC_DIRDEPS_ | |||
# 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} | |||
+@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} | + MAKEFLAGS= ${DIRDEP_CACHE_MAKE:U${.MAKE}} -C ${_CURDIR} \ | ||
+ ${BUILD_DIRDEPS_MA | |||
${BUILD_DIRDEPS_TA | ${BUILD_DIRDEPS_TA | ||
.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; 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_FILT | |||
.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:${ | |||
.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_dir | |||
.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_CA | .if ${BUILD_DIRDEPS_CA | ||
-# 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 | +.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; } | +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_CA | |||
+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 | .for q in ${__qual_depdirs:${M_dep_qual_fixes | ||
@@ -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_CA | .if ${BUILD_DIRDEPS_CA | ||
-_cache_deps | +_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: | |||
.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_CA | .if ${BUILD_DIRDEPS_CA | ||
-_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 | |||
+ 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_STA | |||
+ | |||
+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> |
@@ -1,18 +1,19 @@ | |||
# $FreeBSD$ | # $FreeBSD$ | ||
-# $Id: gendirdeps.mk,v 1. | +# $Id: gendirdeps.mk,v 1.46 2020/08/19 17:51:53 sjg Exp $ | ||
-# Copyright (c) | +# 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${ | +_OBJROOT ?= ${OBJROOT:U${_OBJTOP:H}} | ||
.if ${_OBJROOT:M*/} | .if ${_OBJROOT:M*/} | ||
_slash=/ | _slash=/ | ||
.else | .else | ||
@@ -104,7 +105,7 @@ GENDIRDEPS_FILTE | |||
GENDIRDEPS_FILTE | GENDIRDEPS_FILTE | ||
.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\* | |||
# 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_L | # to GENDIRDEPS_DIR_L | ||
_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_PREFERE | ${dirdep_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERE | ||
@@ -309,7 +310,7 @@ SRC_DIRDEPS = \ | |||
SRC_DIRDEPS := ${SRC_DIRDEPS:${GENDIRDEPS_SRC_F | SRC_DIRDEPS := ${SRC_DIRDEPS:${GENDIRDEPS_SRC_F | ||
# 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 | .if ${SRC_DIRDEPS_FILE | ||
ECHO_SRC_DIRDEPS | ECHO_SRC_DIRDEPS | ||
@@ -324,7 +325,7 @@ ${SRC_DIRDEPS_FI | |||
.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_GU | |||
+ | |||
# '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.d | |||
${_include_src_dir | ${_include_src_dir | ||
echo '.include <dirdeps.mk>'; \ | echo '.include <dirdeps.mk>'; \ | ||
echo; \ | echo; \ | ||
- echo '.if | + 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} |
@@ -8,6 +8,9 @@ UPDATE_DEPENDFIL | |||
.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} |
@@ -179,8 +179,6 @@ DIRDEPS+= usr.bin/yacc.hos | |||
.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, | |||
# 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= \ |
@@ -67,3 +67,6 @@ GENDIRDEPS_FILTE | |||
GENDIRDEPS_FILTE | GENDIRDEPS_FILTE | ||
GENDIRDEPS_FILTE | GENDIRDEPS_FILTE | ||
+ | |||
+# avoid churn for now | |||
+LOCAL_DEPENDS_GU |
@@ -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'. |
@@ -1,5 +1,5 @@ | |||
# $FreeBSD$ | # $FreeBSD$ | ||
-# $Id: meta.autodep.mk,v 1. | +# $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} | +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 | +.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_COOKI | NO_FILEMON_COOKI | ||
CLEANFILES += ${NO_FILEMON_COOKI | CLEANFILES += ${NO_FILEMON_COOKI | ||
@@ -75,10 +74,8 @@ UPDATE_DEPENDFIL | |||
.endif | .endif | ||
.if ${.MAKE.LEVEL} == 0 | .if ${.MAKE.LEVEL} == 0 | ||
-.if ${BUILD_AT_LEVEL0:Uyes:tl} == "no" | |||
UPDATE_DEPENDFIL | UPDATE_DEPENDFIL | ||
.endif | .endif | ||
-.endif | |||
.if !exists(${_DEPENDFILE}) | .if !exists(${_DEPENDFILE}) | ||
_bootstrap_dirde | _bootstrap_dirde | ||
.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}/gen | |||
.endif | .endif | ||
.if ${_bootstrap_dirde | .if ${_bootstrap_dirde | ||
-.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 | +.if !defined(WITHOUT_META_STATS) && ${.MAKE.LEVEL} > 0 | ||
.END: _reldir_finish | .END: _reldir_finish | ||
.ERROR: _reldir_failed | .ERROR: _reldir_failed | ||
.endif | .endif |
@@ -1,15 +1,15 @@ | |||
# $FreeBSD$ | # $FreeBSD$ | ||
-# $Id: meta.stage.mk,v 1. | +# $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_PREFE | .if ${.MAKE.DEPENDFILE_PREFE | ||
# 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 | +STAGE_CONFLICT_ACTION= exit 1 | ||
.else | .else | ||
STAGE_CONFLICT_A | STAGE_CONFLICT_A | ||
.endif | .endif | ||
@@ -79,8 +81,10 @@ STAGE_DIRDEP_SCR | |||
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_A | + case "${RELDIR}:${_dirdep}" in $${x%.*}:$${x}*) ;; \ | ||
+ *) echo "${STAGE_CONFLICT}: $$t installed by $$x not ${_dirdep}" >&2; \ | |||
+ ${STAGE_CONFLICT_A | |||
fi; \ | fi; \ | ||
LnCp .dirdep $$t.dirdep || exit 1; } | LnCp .dirdep $$t.dirdep || exit 1; } | ||
@@ -142,7 +146,7 @@ _STAGE_AS_BASENA | |||
.if !empty(STAGE_INCSDIR) | .if !empty(STAGE_INCSDIR) | ||
.if !empty(STAGE_INCS) | .if !empty(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: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@ | |||
# 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. | +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. | + @${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: | |||
# 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. | +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.dird | |||
.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. | + @${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_SYM | .if !empty(STAGE_AS_AND_SYM | ||
-stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK. | +stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s:N*\**} | ||
.endif | .endif | ||
.if target(stage_as_and_sym | .if target(stage_as_and_sym | ||
STAGE_TARGETS += stage_as_and_sym | STAGE_TARGETS += stage_as_and_sym | ||
@@ -287,8 +291,8 @@ STAGE_AS_AND_SYM | |||
.stage_as_and_sym | .stage_as_and_sym | ||
stage_as_and_sym | stage_as_and_sym | ||
stage_as_and_sym | stage_as_and_sym | ||
- @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK. | + @${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. | + @${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 |
@@ -1,5 +1,5 @@ | |||
# $FreeBSD$ | # $FreeBSD$ | ||
-# $Id: meta.subdir.mk,v 1. | +# $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: | |||
.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. |
@@ -1,16 +1,16 @@ | |||
# $FreeBSD$ | # $FreeBSD$ | ||
-# $Id: meta.sys.mk,v 1. | +# $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_DEPENDFIL | .if ${UPDATE_DEPENDFIL | ||
.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 |
@@ -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. | + $Id: meta2deps.py,v 1.34 2020/10/02 03:11:17 sjg Exp $ | ||
- Copyright (c) 2011- | + 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.st | |||
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.st | |||
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 | |||
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[ | + self.parse_path(w[2].strip("'"), cwd, 'R', w) | ||
- self.parse_path(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 | + 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': |
@@ -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. | +# $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,;/^[ | + 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 |
@@ -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) |
@@ -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_soft | |||
- device_t dev; | |||
- struct aml8726_ccm_func | |||
- 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_INI | |||
- mtx_init(&(sc)->mtx, device_get_nameu | |||
- "ccm", MTX_DEF) | |||
-#define AML_CCM_LOCK_DES | |||
- | |||
-#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_conf | |||
-{ | |||
- struct aml8726_ccm_func | |||
- struct aml8726_ccm_gate | |||
- char *function_name; | |||
- char *functions; | |||
- phandle_t node; | |||
- ssize_t len; | |||
- uint32_t value; | |||
- | |||
- node = ofw_bus_get_node | |||
- | |||
- len = OF_getprop_alloc | |||
- (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_prob | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 ccm"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_ccm_atta | |||
-{ | |||
- struct aml8726_ccm_soft | |||
- | |||
- sc->dev = dev; | |||
- | |||
- switch (aml8726_soc_hw_r | |||
- case AML_SOC_HW_REV_M | |||
- sc->soc = aml8726_m3_ccm; | |||
- break; | |||
- case AML_SOC_HW_REV_M | |||
- sc->soc = aml8726_m6_ccm; | |||
- break; | |||
- case AML_SOC_HW_REV_M | |||
- sc->soc = aml8726_m8_ccm; | |||
- break; | |||
- case AML_SOC_HW_REV_M | |||
- sc->soc = aml8726_m8b_ccm; | |||
- break; | |||
- default: | |||
- device_printf(dev, "unsupported SoC\n"); | |||
- return (ENXIO); | |||
- /* NOTREACHED */ | |||
- } | |||
- | |||
- if (bus_alloc_resour | |||
- device_printf(dev, "can not allocate resources for device\n"); | |||
- return (ENXIO); | |||
- } | |||
- | |||
- AML_CCM_LOCK_INI | |||
- | |||
- return (aml8726_ccm_conf | |||
-} | |||
- | |||
-static int | |||
-aml8726_ccm_deta | |||
-{ | |||
- struct aml8726_ccm_soft | |||
- | |||
- AML_CCM_LOCK_DES | |||
- | |||
- bus_release_reso | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static device_method_t aml8726_ccm_meth | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_ccm_prob | |||
- DEVMETHOD(device_attach, aml8726_ccm_atta | |||
- DEVMETHOD(device_detach, aml8726_ccm_deta | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_ccm_driv | |||
- "ccm", | |||
- aml8726_ccm_meth | |||
- sizeof(struct aml8726_ccm_soft | |||
-}; | |||
- | |||
-static devclass_t aml8726_ccm_devc | |||
- | |||
-EARLY_DRIVER_MOD | |||
- aml8726_ccm_devc |
@@ -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_AML | |||
-#define _ARM_AMLOGIC_AML | |||
- | |||
-struct aml8726_ccm_gate | |||
- uint32_t addr; | |||
- uint32_t bits; | |||
-}; | |||
- | |||
-struct aml8726_ccm_func | |||
- const char *name; | |||
- struct aml8726_ccm_gate | |||
-}; | |||
- | |||
-/* | |||
- * aml8726-m3 | |||
- */ | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00000008 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00000200 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00001000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00020000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00004000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00002000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00010000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 8, 0x00008000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00200000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00400000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-struct aml8726_ccm_func | |||
- { "ethernet", aml8726_m3_ether | |||
- { "i2c", aml8726_m3_i2c }, | |||
- { "rng", aml8726_m3_rng }, | |||
- { "sdio", aml8726_m3_sdio }, | |||
- { "sdxc", aml8726_m3_sdxc }, | |||
- { "uart-a", aml8726_m3_uart_ | |||
- { "uart-b", aml8726_m3_uart_ | |||
- { "uart-c", aml8726_m3_uart_ | |||
- { "usb-a", aml8726_m3_usb_a | |||
- { "usb-b", aml8726_m3_usb_b | |||
- { NULL } | |||
-}; | |||
- | |||
-/* | |||
- * aml8726-m6 | |||
- */ | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00000008 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00000200 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00001000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00020000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00004000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00002000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00010000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 8, 0x00008000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00200000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00400000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-struct aml8726_ccm_func | |||
- { "ethernet", aml8726_m6_ether | |||
- { "i2c", aml8726_m6_i2c }, | |||
- { "rng", aml8726_m6_rng }, | |||
- { "sdio", aml8726_m6_sdio }, | |||
- { "sdxc", aml8726_m6_sdxc }, | |||
- { "uart-a", aml8726_m6_uart_ | |||
- { "uart-b", aml8726_m6_uart_ | |||
- { "uart-c", aml8726_m6_uart_ | |||
- { "usb-a", aml8726_m6_usb_a | |||
- { "usb-b", aml8726_m6_usb_b | |||
- { NULL } | |||
-}; | |||
- | |||
-/* | |||
- * aml8726-m8 | |||
- */ | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00000008 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00000200 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00001000 }, | |||
- { 16, 0x00200000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00020000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00004000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00002000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00010000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 8, 0x00008000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00200000 }, | |||
- { 4, 0x04000000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00400000 }, | |||
- { 4, 0x04000000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-struct aml8726_ccm_func | |||
- { "ethernet", aml8726_m8_ether | |||
- { "i2c", aml8726_m8_i2c }, | |||
- { "rng", aml8726_m8_rng }, | |||
- { "sdio", aml8726_m8_sdio }, | |||
- { "sdxc", aml8726_m8_sdxc }, | |||
- { "uart-a", aml8726_m8_uart_ | |||
- { "uart-b", aml8726_m8_uart_ | |||
- { "uart-c", aml8726_m8_uart_ | |||
- { "usb-a", aml8726_m8_usb_a | |||
- { "usb-b", aml8726_m8_usb_b | |||
- { NULL } | |||
-}; | |||
- | |||
-/* | |||
- * aml8726-m8b | |||
- */ | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00000008 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00000200 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00001000 }, | |||
- { 16, 0x00200000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00020000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00004000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 0, 0x00002000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00010000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 8, 0x00008000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00200000 }, | |||
- { 4, 0x04000000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-static struct aml8726_ccm_gate | |||
- { 4, 0x00400000 }, | |||
- { 4, 0x04000000 }, | |||
- { 0, 0x00000000 } | |||
-}; | |||
- | |||
-struct aml8726_ccm_func | |||
- { "ethernet", aml8726_m8b_ethe | |||
- { "i2c", aml8726_m8b_i2c }, | |||
- { "rng", aml8726_m8b_rng }, | |||
- { "sdio", aml8726_m8b_sdio | |||
- { "sdxc", aml8726_m8b_sdxc | |||
- { "uart-a", aml8726_m8b_uart | |||
- { "uart-b", aml8726_m8b_uart | |||
- { "uart-c", aml8726_m8b_uart | |||
- { "usb-a", aml8726_m8b_usb_ | |||
- { "usb-b", aml8726_m8b_usb_ | |||
- { NULL } | |||
-}; | |||
- | |||
-#endif /* _ARM_AMLOGIC_AML |
@@ -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_c | |||
- const char * name; | |||
- uint32_t mux; | |||
-} aml8726_clkmsr_c | |||
- { "clk81", 7 }, | |||
-}; | |||
- | |||
-#define AML_CLKMSR_CLK81 | |||
- | |||
-#define AML_CLKMSR_NCLKS | |||
- | |||
-struct aml8726_clkmsr_s | |||
- device_t dev; | |||
- struct resource * res[1]; | |||
-}; | |||
- | |||
-static struct resource_spec aml8726_clkmsr_s | |||
- { 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_DURAT | |||
- | |||
-#define AML_CLKMSR_DUTY_ | |||
-#define AML_CLKMSR_0_REG | |||
-#define AML_CLKMSR_0_BUS | |||
-#define AML_CLKMSR_0_MUX | |||
-#define AML_CLKMSR_0_MUX | |||
-#define AML_CLKMSR_0_MUX | |||
-#define AML_CLKMSR_0_MEA | |||
-#define AML_CLKMSR_0_DUR | |||
-#define AML_CLKMSR_0_DUR | |||
-#define AML_CLKMSR_1_REG | |||
-#define AML_CLKMSR_2_REG | |||
-#define AML_CLKMSR_2_RES | |||
-#define AML_CLKMSR_2_RES | |||
- | |||
-#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_BARRIE | |||
- | |||
-static int | |||
-aml8726_clkmsr_c | |||
-{ | |||
- 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 | |||
- | |||
- CSR_BARRIER(sc, AML_CLKMSR_0_REG | |||
- | |||
- value = (aml8726_clkmsr_c | |||
- | ((AML_CLKMSR_DURAT | |||
- | AML_CLKMSR_0_MUX | |||
- | AML_CLKMSR_0_MEA | |||
- CSR_WRITE_4(sc, AML_CLKMSR_0_REG | |||
- | |||
- CSR_BARRIER(sc, AML_CLKMSR_0_REG | |||
- | |||
- while ((CSR_READ_4(sc, AML_CLKMSR_0_REG | |||
- cpu_spinwait(); | |||
- | |||
- value &= ~AML_CLKMSR_0_MEA | |||
- CSR_WRITE_4(sc, AML_CLKMSR_0_REG | |||
- | |||
- CSR_BARRIER(sc, AML_CLKMSR_0_REG | |||
- | |||
- value = (((CSR_READ_4(sc, AML_CLKMSR_2_REG | |||
- >> AML_CLKMSR_2_RES | |||
- AML_CLKMSR_DURAT | |||
- | |||
- return value; | |||
-} | |||
- | |||
-static void | |||
-aml8726_clkmsr_f | |||
-{ | |||
- pcell_t prop; | |||
- ssize_t len; | |||
- phandle_t clk_node; | |||
- phandle_t node; | |||
- | |||
- node = ofw_bus_get_node | |||
- | |||
- len = OF_getencprop(node, "clocks", &prop, sizeof(prop)); | |||
- if ((len / sizeof(prop)) != 1 || prop == 0 || | |||
- (clk_node = OF_node_from_xre | |||
- 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_p | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 clkmsr"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_clkmsr_a | |||
-{ | |||
- struct aml8726_clkmsr_s | |||
- int freq; | |||
- | |||
- sc->dev = dev; | |||
- | |||
- if (bus_alloc_resour | |||
- device_printf(dev, "can not allocate resources for device\n"); | |||
- return (ENXIO); | |||
- } | |||
- | |||
- freq = aml8726_clkmsr_c | |||
- device_printf(sc->dev, "bus clock %u MHz\n", freq); | |||
- | |||
- aml8726_clkmsr_f | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_clkmsr_d | |||
-{ | |||
- struct aml8726_clkmsr_s | |||
- | |||
- bus_release_reso | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static device_method_t aml8726_clkmsr_m | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_clkmsr_p | |||
- DEVMETHOD(device_attach, aml8726_clkmsr_a | |||
- DEVMETHOD(device_detach, aml8726_clkmsr_d | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_clkmsr_d | |||
- "clkmsr", | |||
- aml8726_clkmsr_m | |||
- sizeof(struct aml8726_clkmsr_s | |||
-}; | |||
- | |||
-static devclass_t aml8726_clkmsr_d | |||
- | |||
-EARLY_DRIVER_MOD | |||
- aml8726_clkmsr_d | |||
- | |||
-int | |||
-aml8726_clkmsr_b | |||
-{ | |||
- struct resource mem; | |||
- struct aml8726_clkmsr_s | |||
- phandle_t node; | |||
- u_long pbase, psize; | |||
- u_long start, size; | |||
- int freq; | |||
- | |||
- KASSERT(aml8726_soc_hw_r | |||
- ("aml8726_soc_hw_r | |||
- | |||
- /* | |||
- * Try to access the clkmsr node directly i.e. through /aliases/. | |||
- */ | |||
- | |||
- if ((node = OF_finddevice("clkmsr")) != -1) | |||
- if (fdt_is_compatibl | |||
- goto moveon; | |||
- | |||
- /* | |||
- * Find the node the long way. | |||
- */ | |||
- if ((node = OF_finddevice("/soc")) == -1) | |||
- return (0); | |||
- | |||
- if ((node = fdt_find_compati | |||
- "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_c | |||
- */ | |||
- | |||
- memset(&sc, 0, sizeof(sc)); | |||
- | |||
- sc.res[0] = &mem; | |||
- | |||
- freq = aml8726_clkmsr_c | |||
- | |||
- bus_space_unmap(mem.r_bustag, mem.r_bushandle, size); | |||
- | |||
- return (freq); | |||
-} |
@@ -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_AML | |||
-#define _ARM_AMLOGIC_AML | |||
- | |||
-int aml8726_clkmsr_b | |||
- | |||
-#endif /* _ARM_AMLOGIC_AML |
@@ -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_outpu | |||
- aml8726_unknown_ | |||
- aml8726_cvbs_fb_ | |||
- aml8726_hdmi_fb_ | |||
- aml8726_lcd_fb_o | |||
-}; | |||
- | |||
-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_outpu | |||
- 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 | |||
- mtx_init(&(sc)->mtx, device_get_nameu | |||
- "fb", MTX_DEF) | |||
-#define AML_FB_LOCK_DEST | |||
- | |||
-#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_BARRIE | |||
- | |||
-#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_ | |||
-#define AML_FB_CLK_FREQ_ | |||
- | |||
-static void | |||
-aml8726_fb_cfg_o | |||
-{ | |||
- /* XXX */ | |||
-} | |||
- | |||
-static void | |||
-aml8726_fb_cfg_v | |||
-{ | |||
- 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 | |||
- value |= AML_VIU_OSD_FIFO | |||
- value |= (4 << AML_VIU_OSD_FIFO | |||
- | |||
- VIU_WRITE_4(sc, AML_VIU_OSD1_FIF | |||
- VIU_WRITE_4(sc, AML_VIU_OSD2_FIF | |||
- | |||
- value = VPP_READ_4(sc, AML_VPP_MISC_REG | |||
- | |||
- value &= ~AML_VPP_MISC_PRE | |||
- value |= AML_VPP_MISC_POS | |||
- value &= ~(AML_VPP_MISC_OSD | |||
- | AML_VPP_MISC_VD1 | |||
- | |||
- VPP_WRITE_4(sc, AML_VPP_MISC_REG | |||
- | |||
- value = AML_VIU_OSD_CTRL | |||
- value |= (0xff << AML_VIU_OSD_CTRL | |||
- | |||
- VIU_WRITE_4(sc, AML_VIU_OSD1_CTR | |||
- VIU_WRITE_4(sc, AML_VIU_OSD2_CTR | |||
- | |||
- /* color mode for OSD1 block 0 */ | |||
- | |||
- value = (AML_CAV_OSD1_IND | |||
- | AML_VIU_OSD_BLK_ | |||
- | AML_VIU_OSD_BLK_ | |||
- | AML_VIU_OSD_BLK_ | |||
- | AML_VIU_OSD_BLK_ | |||
- | |||
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK | |||
- | |||
- /* geometry / scaling for OSD1 block 0 */ | |||
- | |||
- value = ((sc->info.fb_width - 1) << AML_VIU_OSD_BLK_ | |||
- & AML_VIU_OSD_BLK_ | |||
- value |= (0 << AML_VIU_OSD_BLK_ | |||
- & AML_VIU_OSD_BLK_ | |||
- | |||
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK | |||
- | |||
- value = ((sc->info.fb_height - 1) << AML_VIU_OSD_BLK_ | |||
- & AML_VIU_OSD_BLK_ | |||
- value |= (0 << AML_VIU_OSD_BLK_ | |||
- & AML_VIU_OSD_BLK_ | |||
- | |||
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK | |||
- | |||
- value = ((sc->info.fb_width - 1) << AML_VIU_OSD_BLK_ | |||
- & AML_VIU_OSD_BLK_ | |||
- value |= (0 << AML_VIU_OSD_BLK_ | |||
- & AML_VIU_OSD_BLK_ | |||
- | |||
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK | |||
- | |||
- value = ((sc->info.fb_height - 1) << AML_VIU_OSD_BLK_ | |||
- & AML_VIU_OSD_BLK_ | |||
- value |= (0 << AML_VIU_OSD_BLK_ | |||
- & AML_VIU_OSD_BLK_ | |||
- | |||
- VIU_WRITE_4(sc, AML_VIU_OSD1_BLK | |||
- | |||
- /* Enable the OSD block now that it's fully configured */ | |||
- | |||
- value = VIU_READ_4(sc, AML_VIU_OSD1_CTR | |||
- | |||
- value &= ~AML_VIU_OSD_CTRL | |||
- value |= 1 << AML_VIU_OSD_CTRL | |||
- | |||
- VIU_WRITE_4(sc, AML_VIU_OSD1_CTR | |||
- | |||
- /* enable video processing of OSD1 */ | |||
- | |||
- value = VPP_READ_4(sc, AML_VPP_MISC_REG | |||
- | |||
- value |= AML_VPP_MISC_OSD | |||
- | |||
- VPP_WRITE_4(sc, AML_VPP_MISC_REG | |||
-} | |||
- | |||
-static void | |||
-aml8726_fb_cfg_c | |||
-{ | |||
- 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_DATA | |||
- AML_CAV_LUT_DATA | |||
- | |||
- /* physical address */ | |||
- value |= (uint32_t)sc->info.fb_pbase / 8; | |||
- | |||
- CAV_WRITE_4(sc, AML_CAV_LUT_DATA | |||
- | |||
- /* upper bits of the width */ | |||
- value = ((width >> AML_CAV_LUT_DATA | |||
- AML_CAV_LUT_DATA | |||
- | |||
- /* height */ | |||
- value |= ((uint32_t)sc->info.fb_height << | |||
- AML_CAV_LUT_DATA | |||
- | |||
- /* mode */ | |||
- value |= AML_CAV_LUT_DATA | |||
- | |||
- CAV_WRITE_4(sc, AML_CAV_LUT_DATA | |||
- | |||
- CAV_WRITE_4(sc, AML_CAV_LUT_ADDR | |||
- (AML_CAV_OSD1_IND | |||
- | |||
- CAV_BARRIER(sc, AML_CAV_LUT_ADDR | |||
-} | |||
- | |||
-static void | |||
-aml8726_fb_intr(void *arg) | |||
-{ | |||
- struct aml8726_fb_softc | |||
- | |||
- AML_FB_LOCK(sc); | |||
- | |||
- AML_FB_UNLOCK(sc); | |||
-} | |||
- | |||
-static int | |||
-aml8726_fb_probe | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 FB"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_fb_attac | |||
-{ | |||
- struct aml8726_fb_softc | |||
- int error; | |||
- device_t child; | |||
- pcell_t prop; | |||
- phandle_t node; | |||
- | |||
- sc->dev = dev; | |||
- | |||
- sc->info.fb_name = device_get_nameu | |||
- | |||
- node = ofw_bus_get_node | |||
- | |||
- 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_resour | |||
- 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_o | |||
- | |||
- aml8726_fb_cfg_v | |||
- | |||
- aml8726_fb_cfg_c | |||
- | |||
- AML_FB_LOCK_INIT | |||
- | |||
- error = bus_setup_intr(dev, sc->res[3], INTR_TYPE_MISC | INTR_MPSAFE, | |||
- NULL, aml8726_fb_intr, | |||
- | |||
- if (error) { | |||
- device_printf(dev, "could not setup interrupt handler\n"); | |||
- goto fail; | |||
- } | |||
- | |||
- child = device_add_child | |||
- | |||
- if (!child) { | |||
- device_printf(dev, "could not add fbd\n"); | |||
- error = ENXIO; | |||
- goto fail; | |||
- } | |||
- | |||
- error = device_probe_and | |||
- | |||
- if (error) { | |||
- device_printf(dev, "could not attach fbd\n"); | |||
- goto fail; | |||
- } | |||
- | |||
- return (0); | |||
- | |||
-fail: | |||
- if (sc->ih_cookie) | |||
- bus_teardown_int | |||
- | |||
- AML_FB_LOCK_DEST | |||
- | |||
- bus_release_reso | |||
- | |||
- pmap_unmapdev(sc->info.fb_vbase, sc->info.fb_size); | |||
- | |||
- return (error); | |||
-} | |||
- | |||
-static int | |||
-aml8726_fb_detac | |||
-{ | |||
- struct aml8726_fb_softc | |||
- | |||
- bus_generic_deta | |||
- | |||
- bus_teardown_int | |||
- | |||
- AML_FB_LOCK_DEST | |||
- | |||
- bus_release_reso | |||
- | |||
- pmap_unmapdev(sc->info.fb_vbase, sc->info.fb_size); | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static struct fb_info * | |||
-aml8726_fb_getin | |||
-{ | |||
- struct aml8726_fb_softc | |||
- | |||
- return (&sc->info); | |||
-} | |||
- | |||
-static device_method_t aml8726_fb_metho | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_fb_probe | |||
- DEVMETHOD(device_attach, aml8726_fb_attac | |||
- DEVMETHOD(device_detach, aml8726_fb_detac | |||
- | |||
- /* FB interface */ | |||
- DEVMETHOD(fb_getinfo, aml8726_fb_getin | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_fb_drive | |||
- "fb", | |||
- aml8726_fb_metho | |||
- sizeof(struct aml8726_fb_softc | |||
-}; | |||
- | |||
-static devclass_t aml8726_fb_devcl | |||
- | |||
-DRIVER_MODULE(fb, simplebus, aml8726_fb_drive |
@@ -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_AML | |||
-#define _ARM_AMLOGIC_AML | |||
- | |||
-#define AML_CAV_OSD1_IND | |||
- | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
- | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
-#define AML_CAV_LUT_DATA | |||
- | |||
-#define AML_CAV_LUT_ADDR | |||
-#define AML_CAV_LUT_ADDR | |||
-#define AML_CAV_LUT_ADDR | |||
-#define AML_CAV_LUT_ADDR | |||
-#define AML_CAV_LUT_ADDR | |||
- | |||
-#define AML_VIU_OSD1_CTR | |||
-#define AML_VIU_OSD_CTRL | |||
-#define AML_VIU_OSD_CTRL | |||
-#define AML_VIU_OSD_CTRL | |||
-#define AML_VIU_OSD_CTRL | |||
-#define AML_VIU_OSD_CTRL | |||
- | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
- | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
- | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
- | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
- | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD1_BLK | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
-#define AML_VIU_OSD_BLK_ | |||
- | |||
-#define AML_VIU_OSD1_FIF | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
-#define AML_VIU_OSD_FIFO | |||
- | |||
-/* OSD2 field meanings are the same as OSD1 */ | |||
-#define AML_VIU_OSD2_CTR | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_BLK | |||
-#define AML_VIU_OSD2_FIF | |||
- | |||
-#define AML_VPP_MISC_REG | |||
-#define AML_VPP_MISC_OSD | |||
-#define AML_VPP_MISC_OSD | |||
-#define AML_VPP_MISC_VD2 | |||
-#define AML_VPP_MISC_VD1 | |||
-#define AML_VPP_MISC_OSD | |||
-#define AML_VPP_MISC_OSD | |||
-#define AML_VPP_MISC_VD2 | |||
-#define AML_VPP_MISC_VD1 | |||
-#define AML_VPP_MISC_POS | |||
-#define AML_VPP_MISC_PRE | |||
- | |||
-#endif /* _ARM_AMLOGIC_AML |
@@ -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_sof | |||
- device_t dev; | |||
- struct resource *res[3]; | |||
- struct mtx mtx; | |||
- uint32_t npins; | |||
- device_t busdev; | |||
-}; | |||
- | |||
-static struct resource_spec aml8726_gpio_spe | |||
- { 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_IN | |||
- mtx_init(&(sc)->mtx, device_get_nameu | |||
- "gpio", MTX_DEF) | |||
-#define AML_GPIO_LOCK_DE | |||
- | |||
-#define AML_GPIO_OE_N_RE | |||
-#define AML_GPIO_OUT_REG | |||
-#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_pro | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 GPIO"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_gpio_att | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- phandle_t node; | |||
- pcell_t prop; | |||
- | |||
- sc->dev = dev; | |||
- | |||
- node = ofw_bus_get_node | |||
- | |||
- 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_resour | |||
- 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_reso | |||
- return (ENXIO); | |||
- } | |||
- | |||
- AML_GPIO_LOCK_IN | |||
- | |||
- sc->busdev = gpiobus_attach_b | |||
- if (sc->busdev == NULL) { | |||
- AML_GPIO_LOCK_DE | |||
- bus_release_reso | |||
- return (ENXIO); | |||
- } | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_gpio_det | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- | |||
- gpiobus_detach_b | |||
- | |||
- AML_GPIO_LOCK_DE | |||
- | |||
- bus_release_reso | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static device_t | |||
-aml8726_gpio_get | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- | |||
- return (sc->busdev); | |||
-} | |||
- | |||
-static int | |||
-aml8726_gpio_pin | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- | |||
- *maxpin = (int)sc->npins; | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-/* Get a specific pin's capabilities. */ | |||
-static int | |||
-aml8726_gpio_pin | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- | |||
- 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 | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- | |||
- if (pin >= sc->npins) | |||
- return (EINVAL); | |||
- | |||
- snprintf(name, GPIOMAXNAME, "%s.%u", ofw_bus_get_name | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-/* Get a specific pin's current in/out state. */ | |||
-static int | |||
-aml8726_gpio_pin | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- uint32_t mask = 1U << pin; | |||
- | |||
- if (pin >= sc->npins) | |||
- return (EINVAL); | |||
- | |||
- if ((CSR_READ_4(sc, AML_GPIO_OE_N_RE | |||
- /* 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 | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- 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_RE | |||
- (CSR_READ_4(sc, AML_GPIO_OE_N_RE | |||
- } else { | |||
- /* Input. Turn off driver. */ | |||
- CSR_WRITE_4(sc, AML_GPIO_OE_N_RE | |||
- (CSR_READ_4(sc, AML_GPIO_OE_N_RE | |||
- } | |||
- | |||
- AML_GPIO_UNLOCK(sc); | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-/* Set a specific output pin's value. */ | |||
-static int | |||
-aml8726_gpio_pin | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- 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 | |||
- | |||
- AML_GPIO_UNLOCK(sc); | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-/* Get a specific pin's input value. */ | |||
-static int | |||
-aml8726_gpio_pin | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- 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 | |||
-{ | |||
- struct aml8726_gpio_sof | |||
- 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 | |||
- | |||
- AML_GPIO_UNLOCK(sc); | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static phandle_t | |||
-aml8726_gpio_get | |||
-{ | |||
- | |||
- /* We only have one child, the GPIO bus, which needs our own node. */ | |||
- return (ofw_bus_get_node | |||
-} | |||
- | |||
-static device_method_t aml8726_gpio_met | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_gpio_pro | |||
- DEVMETHOD(device_attach, aml8726_gpio_att | |||
- DEVMETHOD(device_detach, aml8726_gpio_det | |||
- | |||
- /* GPIO interface */ | |||
- DEVMETHOD(gpio_get_bus, aml8726_gpio_get | |||
- DEVMETHOD(gpio_pin_max, aml8726_gpio_pin | |||
- DEVMETHOD(gpio_pin_getname | |||
- DEVMETHOD(gpio_pin_getflag | |||
- DEVMETHOD(gpio_pin_getcaps | |||
- DEVMETHOD(gpio_pin_setflag | |||
- DEVMETHOD(gpio_pin_get, aml8726_gpio_pin | |||
- DEVMETHOD(gpio_pin_set, aml8726_gpio_pin | |||
- DEVMETHOD(gpio_pin_toggle, | |||
- | |||
- /* ofw_bus interface */ | |||
- DEVMETHOD(ofw_bus_get_node | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_gpio_dri | |||
- "gpio", | |||
- aml8726_gpio_met | |||
- sizeof(struct aml8726_gpio_sof | |||
-}; | |||
- | |||
-static devclass_t aml8726_gpio_dev | |||
- | |||
-DRIVER_MODULE(aml8726_gpio, simplebus, aml8726_gpio_dri | |||
- aml8726_gpio_dev |
@@ -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_soft | |||
- 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_INI | |||
- mtx_init(&(sc)->mtx, device_get_nameu | |||
- "i2c", MTX_DEF) | |||
-#define AML_I2C_LOCK_DES | |||
- | |||
-#define AML_I2C_CTRL_REG | |||
-#define AML_I2C_MANUAL_S | |||
-#define AML_I2C_MANUAL_S | |||
-#define AML_I2C_MANUAL_S | |||
-#define AML_I2C_MANUAL_S | |||
-#define AML_I2C_MANUAL_E | |||
- | |||
-#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_prob | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 I2C"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_iic_atta | |||
-{ | |||
- struct aml8726_iic_soft | |||
- int error; | |||
- | |||
- sc->dev = dev; | |||
- | |||
- if (bus_alloc_resour | |||
- device_printf(dev, "can not allocate resources for device\n"); | |||
- return (ENXIO); | |||
- } | |||
- | |||
- AML_I2C_LOCK_INI | |||
- | |||
- sc->iicbb = device_add_child | |||
- | |||
- if (sc->iicbb == NULL) { | |||
- device_printf(dev, "could not add iicbb\n"); | |||
- error = ENXIO; | |||
- goto fail; | |||
- } | |||
- | |||
- error = device_probe_and | |||
- | |||
- if (error) { | |||
- device_printf(dev, "could not attach iicbb\n"); | |||
- goto fail; | |||
- } | |||
- | |||
- return (0); | |||
- | |||
-fail: | |||
- AML_I2C_LOCK_DES | |||
- bus_release_reso | |||
- | |||
- return (error); | |||
-} | |||
- | |||
-static int | |||
-aml8726_iic_deta | |||
-{ | |||
- struct aml8726_iic_soft | |||
- 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_deta | |||
- * sc->child_dev). | |||
- */ | |||
- child = sc->iicbb; | |||
- bus_generic_deta | |||
- if (child) | |||
- device_delete_ch | |||
- | |||
- AML_I2C_LOCK_DES | |||
- | |||
- bus_release_reso | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static void | |||
-aml8726_iic_chil | |||
-{ | |||
- struct aml8726_iic_soft | |||
- | |||
- if (child == sc->iicbb) | |||
- sc->iicbb = NULL; | |||
-} | |||
- | |||
-static int | |||
-aml8726_iic_call | |||
-{ | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_iic_rese | |||
-{ | |||
- struct aml8726_iic_soft | |||
- | |||
- AML_I2C_LOCK(sc); | |||
- | |||
- CSR_WRITE_4(sc, AML_I2C_CTRL_REG | |||
- (CSR_READ_4(sc, AML_I2C_CTRL_REG | |||
- AML_I2C_MANUAL_S | |||
- | |||
- AML_I2C_UNLOCK(sc); | |||
- | |||
- /* Wait for 10 usec */ | |||
- DELAY(10); | |||
- | |||
- return (IIC_ENOADDR); | |||
-} | |||
- | |||
-static int | |||
-aml8726_iic_gets | |||
-{ | |||
- struct aml8726_iic_soft | |||
- | |||
- return (CSR_READ_4(sc, AML_I2C_CTRL_REG | |||
-} | |||
- | |||
-static int | |||
-aml8726_iic_gets | |||
-{ | |||
- struct aml8726_iic_soft | |||
- | |||
- return (CSR_READ_4(sc, AML_I2C_CTRL_REG | |||
-} | |||
- | |||
-static void | |||
-aml8726_iic_sets | |||
-{ | |||
- struct aml8726_iic_soft | |||
- | |||
- AML_I2C_LOCK(sc); | |||
- | |||
- CSR_WRITE_4(sc, AML_I2C_CTRL_REG | |||
- ~AML_I2C_MANUAL_S | |||
- AML_I2C_MANUAL_E | |||
- | |||
- AML_I2C_UNLOCK(sc); | |||
-} | |||
- | |||
-static void | |||
-aml8726_iic_sets | |||
-{ | |||
- struct aml8726_iic_soft | |||
- | |||
- AML_I2C_LOCK(sc); | |||
- | |||
- CSR_WRITE_4(sc, AML_I2C_CTRL_REG | |||
- ~AML_I2C_MANUAL_S | |||
- AML_I2C_MANUAL_E | |||
- | |||
- AML_I2C_UNLOCK(sc); | |||
-} | |||
- | |||
-static device_method_t aml8726_iic_meth | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_iic_prob | |||
- DEVMETHOD(device_attach, aml8726_iic_atta | |||
- DEVMETHOD(device_detach, aml8726_iic_deta | |||
- | |||
- /* bus interface */ | |||
- DEVMETHOD(bus_child_detach | |||
- DEVMETHOD(bus_print_child, | |||
- DEVMETHOD(bus_driver_added | |||
- | |||
- /* IICBB interface */ | |||
- DEVMETHOD(iicbb_callback, aml8726_iic_call | |||
- DEVMETHOD(iicbb_reset, aml8726_iic_rese | |||
- | |||
- DEVMETHOD(iicbb_getscl, aml8726_iic_gets | |||
- DEVMETHOD(iicbb_getsda, aml8726_iic_gets | |||
- DEVMETHOD(iicbb_setscl, aml8726_iic_sets | |||
- DEVMETHOD(iicbb_setsda, aml8726_iic_sets | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_iic_driv | |||
- "aml8726_iic", | |||
- aml8726_iic_meth | |||
- sizeof(struct aml8726_iic_soft | |||
-}; | |||
- | |||
-static devclass_t aml8726_iic_devc | |||
- | |||
-DRIVER_MODULE(aml8726_iic, simplebus, aml8726_iic_driv | |||
- aml8726_iic_devc | |||
-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); |
@@ -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_r | |||
-uint32_t aml8726_soc_meta | |||
- | |||
-static const struct { | |||
- uint32_t hw_rev; | |||
- char *desc; | |||
-} aml8726_soc_desc | |||
- { AML_SOC_HW_REV_M | |||
- { AML_SOC_HW_REV_M | |||
- { AML_SOC_HW_REV_M | |||
- { AML_SOC_HW_REV_M | |||
- { AML_SOC_HW_REV_M | |||
- { AML_SOC_HW_REV_M | |||
- { 0xff, NULL } | |||
-}; | |||
- | |||
-static const struct { | |||
- uint32_t metal_rev; | |||
- char *desc; | |||
-} aml8726_m8_soc_r | |||
- { AML_SOC_M8_METAL | |||
- { AML_SOC_M8_METAL | |||
- { AML_SOC_M8_METAL | |||
- { AML_SOC_M8_METAL | |||
- { 0xff, NULL } | |||
-}; | |||
- | |||
-void | |||
-aml8726_identify | |||
-{ | |||
- 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_BAS | |||
- 0, &res.r_bushandle); | |||
- | |||
- if (err) | |||
- panic("Could not allocate resource for SoC identification\n"); | |||
- | |||
- aml8726_soc_hw_r | |||
- | |||
- aml8726_soc_meta | |||
- | |||
- bus_space_unmap(res.r_bustag, res.r_bushandle, 0x100000); | |||
-} | |||
- | |||
-static void | |||
-aml8726_identify | |||
-{ | |||
- int i; | |||
- | |||
- for (i = 0; aml8726_soc_desc | |||
- if (aml8726_soc_desc | |||
- break; | |||
- | |||
- if (aml8726_soc_desc | |||
- panic("Amlogic unknown aml8726 SoC %#x\n", aml8726_soc_hw_r | |||
- | |||
- printf("Amlogic %s SoC", aml8726_soc_desc | |||
- | |||
- if (aml8726_soc_hw_r | |||
- for (i = 0; aml8726_m8_soc_r | |||
- if (aml8726_m8_soc_r | |||
- aml8726_soc_meta | |||
- break; | |||
- | |||
- if (aml8726_m8_soc_r | |||
- printf(", unknown rev %#x", aml8726_soc_meta | |||
- else | |||
- printf(", rev %s", aml8726_m8_soc_r | |||
- } | |||
- | |||
- printf("\n"); | |||
-} | |||
- | |||
-SYSINIT(aml8726_identify | |||
- aml8726_identify |
@@ -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_p | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- device_set_desc(dev, "Amlogic Meson Gigabit Ethernet Controller"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_if_dwc_i | |||
-{ | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_if_dwc_m | |||
-{ | |||
- | |||
- return (DWC_GMAC_NORMAL_ | |||
-} | |||
- | |||
-static int | |||
-aml8726_if_dwc_m | |||
-{ | |||
- | |||
- return (GMAC_MII_CLK_100 | |||
-} | |||
- | |||
-static device_method_t aml8726_dwc_meth | |||
- DEVMETHOD(device_probe, aml8726_if_dwc_p | |||
- | |||
- DEVMETHOD(if_dwc_init, aml8726_if_dwc_i | |||
- DEVMETHOD(if_dwc_mac_type, | |||
- DEVMETHOD(if_dwc_mii_clk, aml8726_if_dwc_m | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static devclass_t aml8726_dwc_devc | |||
- | |||
-extern driver_t dwc_driver; | |||
- | |||
-DEFINE_CLASS_1(dwc, aml8726_dwc_driv | |||
- sizeof(struct dwc_softc), dwc_driver); | |||
-DRIVER_MODULE(aml8726_dwc, simplebus, aml8726_dwc_driv | |||
- aml8726_dwc_devc | |||
- | |||
-MODULE_DEPEND(aml8726_dwc, dwc, 1, 1, 1); |
@@ -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_i | |||
-{ | |||
- 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_P | |||
- | |||
- /* | |||
- * Enable data prefetch. | |||
- */ | |||
- aux |= AUX_CTRL_DATA_PR | |||
- | |||
- pl310_write4(sc, PL310_AUX_CTRL, aux); | |||
-} | |||
- | |||
-void | |||
-platform_pl310_w | |||
-{ | |||
- | |||
- pl310_write4(sc, PL310_CTRL, val); | |||
-} | |||
- | |||
-void | |||
-platform_pl310_w | |||
-{ | |||
- | |||
- pl310_write4(sc, PL310_DEBUG_CTRL | |||
-} |
@@ -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_kv | |||
-#else | |||
-vm_offset_t aml8726_aobus_kv | |||
-#endif | |||
- | |||
-static void | |||
-aml8726_fixup_bu | |||
-{ | |||
- 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_b | |||
- (node = OF_finddevice("/soc")) == 0 || | |||
- fdt_is_compatibl | |||
- 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_lastadd | |||
-{ | |||
- | |||
- return (devmap_lastaddr()); | |||
-} | |||
- | |||
-void | |||
-platform_probe_a | |||
-{ | |||
-} | |||
- | |||
-void | |||
-platform_gpio_in | |||
-{ | |||
- | |||
- /* | |||
- * 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_in | |||
- */ | |||
- aml8726_aobus_kv | |||
- (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 | |||
- | |||
- /* | |||
- * 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_r | |||
- case AML_SOC_HW_REV_M | |||
- 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_in | |||
- */ | |||
- aml8726_fixup_bu | |||
-} | |||
- | |||
-void | |||
-platform_late_in | |||
-{ | |||
-} | |||
- | |||
-/* | |||
- * Construct static devmap entries to map out the core | |||
- * peripherals using 1mb section mappings. | |||
- */ | |||
-int | |||
-platform_devmap_ | |||
-{ | |||
- | |||
- devmap_add_entry | |||
- devmap_add_entry | |||
- devmap_add_entry | |||
- devmap_add_entry | |||
- devmap_add_entry | |||
- devmap_add_entry | |||
- devmap_add_entry | |||
- devmap_add_entry | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-#ifndef INTRNG | |||
-#ifndef DEV_GIC | |||
-static int | |||
-fdt_pic_decode_i | |||
- int *pol) | |||
-{ | |||
- | |||
- /* | |||
- * The single core chips have just an Amlogic PIC. | |||
- */ | |||
- if (!fdt_is_compatibl | |||
- return (ENXIO); | |||
- | |||
- *interrupt = fdt32_to_cpu(intr[1]); | |||
- *trig = INTR_TRIGGER_EDG | |||
- *pol = INTR_POLARITY_HI | |||
- | |||
- return (0); | |||
-} | |||
-#endif | |||
- | |||
-fdt_pic_decode_t | |||
-#ifdef DEV_GIC | |||
- &gic_decode_fdt, | |||
-#else | |||
- &fdt_pic_decode_i | |||
-#endif | |||
- NULL | |||
-}; | |||
-#endif /* INTRNG */ |
@@ -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_AML | |||
-#define _ARM_AMLOGIC_AML | |||
- | |||
-/* | |||
- * 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_kv | |||
- | |||
-#endif /* _ARM_AMLOGIC_AML |
@@ -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_soft | |||
- device_t dev; | |||
- struct resource *res[2]; | |||
- struct mtx mtx; | |||
- struct callout ch; | |||
- uint32_t port; | |||
- unsigned int ref_freq; | |||
- struct aml8726_mmc_gpio | |||
- int voltages[2]; | |||
- struct aml8726_mmc_gpio | |||
- 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_ASS | |||
-#define AML_MMC_LOCK_INI | |||
- mtx_init(&(sc)->mtx, device_get_nameu | |||
- "mmc", MTX_DEF) | |||
-#define AML_MMC_LOCK_DES | |||
- | |||
-#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_BARRIE | |||
- | |||
-#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_time | |||
- | |||
-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_xre | |||
- 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 | |||
-{ | |||
- | |||
- return (sc->ref_freq / ((divisor + 1) * 2)); | |||
-} | |||
- | |||
-static uint32_t | |||
-aml8726_mmc_div(struct aml8726_mmc_soft | |||
-{ | |||
- uint32_t divisor; | |||
- | |||
- divisor = sc->ref_freq / (desired_freq * 2); | |||
- | |||
- if (divisor == 0) | |||
- divisor = 1; | |||
- | |||
- divisor -= 1; | |||
- | |||
- if (aml8726_mmc_freq | |||
- divisor += 1; | |||
- | |||
- if (divisor > (AML_MMC_CONFIG_C | |||
- AML_MMC_CONFIG_C | |||
- divisor = AML_MMC_CONFIG_C | |||
- AML_MMC_CONFIG_C | |||
- } | |||
- | |||
- return (divisor); | |||
-} | |||
- | |||
-static void | |||
-aml8726_mmc_mapm | |||
-{ | |||
- bus_addr_t *busaddrp; | |||
- | |||
- /* | |||
- * There should only be one bus space address since | |||
- * bus_dma_tag_crea | |||
- */ | |||
- | |||
- busaddrp = (bus_addr_t *)arg; | |||
- *busaddrp = segs->ds_addr; | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_powe | |||
-{ | |||
- | |||
- 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_powe | |||
-{ | |||
- | |||
- 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 | |||
-{ | |||
- uint32_t icr; | |||
- | |||
- icr = AML_MMC_IRQ_CONF | |||
- | |||
- if (enable_irq == true) | |||
- icr |= AML_MMC_IRQ_CONF | |||
- | |||
- CSR_WRITE_4(sc, AML_MMC_IRQ_CONF | |||
- CSR_BARRIER(sc, AML_MMC_IRQ_CONF | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_star | |||
-{ | |||
- 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 | |||
- | |||
- /* | |||
- * 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_STAR | |||
- baddr = 0; | |||
- extr = 0; | |||
- mcfgr = sc->port; | |||
- timeout = AML_MMC_CMD_TIME | |||
- | |||
- /* | |||
- * 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 | |||
- cmdr |= (133 << AML_MMC_CMD_RESP | |||
- } else if ((cmd->flags & MMC_RSP_PRESENT) != 0) | |||
- cmdr |= (45 << AML_MMC_CMD_RESP | |||
- | |||
- if ((cmd->flags & MMC_RSP_CRC) == 0) | |||
- cmdr |= AML_MMC_CMD_RESP | |||
- | |||
- if ((cmd->flags & MMC_RSP_BUSY) != 0) | |||
- cmdr |= AML_MMC_CMD_CHEC | |||
- | |||
- 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_ | |||
- | |||
- mcfgr |= (data->flags & MMC_DATA_STREAM) ? | |||
- AML_MMC_MULT_CON | |||
- | |||
- /* | |||
- * 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_EXTENSIO | |||
- | |||
- error = bus_dmamap_load(sc->dmatag, sc->dmamap, | |||
- data->data, data->len, aml8726_mmc_mapm | |||
- BUS_DMA_NOWAIT); | |||
- if (error) | |||
- return (MMC_ERR_NO_MEMOR | |||
- | |||
- if ((data->flags & MMC_DATA_READ) != 0) { | |||
- cmdr |= AML_MMC_CMD_RESP | |||
- bus_dmamap_sync(sc->dmatag, sc->dmamap, | |||
- BUS_DMASYNC_PRER | |||
- timeout = AML_MMC_READ_TIM | |||
- (data->len / block_size); | |||
- } else { | |||
- cmdr |= AML_MMC_CMD_CMD_ | |||
- bus_dmamap_sync(sc->dmatag, sc->dmamap, | |||
- BUS_DMASYNC_PREW | |||
- timeout = AML_MMC_WRITE_TI | |||
- (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_TIME | |||
- timeout = AML_MMC_MAX_TIME | |||
- | |||
- callout_reset(&sc->ch, MSECS_TO_TICKS(timeout), | |||
- aml8726_mmc_time | |||
- | |||
- CSR_WRITE_4(sc, AML_MMC_CMD_ARGU | |||
- CSR_WRITE_4(sc, AML_MMC_MULT_CON | |||
- CSR_WRITE_4(sc, AML_MMC_EXTENSIO | |||
- CSR_WRITE_4(sc, AML_MMC_DMA_ADDR | |||
- | |||
- CSR_WRITE_4(sc, AML_MMC_CMD_SEND | |||
- CSR_BARRIER(sc, AML_MMC_CMD_SEND | |||
- | |||
- return (MMC_ERR_NONE); | |||
-} | |||
- | |||
-static void | |||
-aml8726_mmc_fini | |||
-{ | |||
- int mmc_stop_error; | |||
- struct mmc_command *cmd; | |||
- struct mmc_command *stop_cmd; | |||
- struct mmc_data *data; | |||
- | |||
- AML_MMC_LOCK_ASS | |||
- | |||
- /* Clear all interrupts since the request is no longer in flight. */ | |||
- CSR_WRITE_4(sc, AML_MMC_IRQ_STAT | |||
- CSR_BARRIER(sc, AML_MMC_IRQ_STAT | |||
- | |||
- /* 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_POST | |||
- else | |||
- bus_dmamap_sync(sc->dmatag, sc->dmamap, | |||
- BUS_DMASYNC_POST | |||
- bus_dmamap_unloa | |||
- } | |||
- | |||
- /* | |||
- * 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_star | |||
- 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_time | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- | |||
- /* | |||
- * The command failed to complete in time so forcefully | |||
- * terminate it. | |||
- */ | |||
- aml8726_mmc_soft | |||
- | |||
- /* | |||
- * Ensure the command has terminated before continuing on | |||
- * to things such as bus_dmamap_sync / bus_dmamap_unloa | |||
- */ | |||
- while ((CSR_READ_4(sc, AML_MMC_IRQ_STAT | |||
- AML_MMC_IRQ_STAT | |||
- cpu_spinwait(); | |||
- | |||
- aml8726_mmc_fini | |||
-} | |||
- | |||
-static void | |||
-aml8726_mmc_intr | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- 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_STAT | |||
- cmdr = CSR_READ_4(sc, AML_MMC_CMD_SEND | |||
- | |||
- if (sc->cmd == NULL) | |||
- goto spurious; | |||
- | |||
- mmc_error = MMC_ERR_NONE; | |||
- | |||
- if ((isr & AML_MMC_IRQ_STAT | |||
- /* Check for CRC errors if the command has completed. */ | |||
- if ((cmdr & AML_MMC_CMD_RESP | |||
- (isr & AML_MMC_IRQ_STAT | |||
- mmc_error = MMC_ERR_BADCRC; | |||
- if ((cmdr & AML_MMC_CMD_RESP | |||
- (isr & AML_MMC_IRQ_STAT | |||
- mmc_error = MMC_ERR_BADCRC; | |||
- if ((cmdr & AML_MMC_CMD_CMD_ | |||
- (isr & AML_MMC_IRQ_STAT | |||
- 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_STAT | |||
- (AML_MMC_IRQ_STAT | |||
- CSR_BARRIER(sc, AML_MMC_IRQ_STAT | |||
- AML_MMC_UNLOCK(sc); | |||
- return; | |||
- } | |||
- | |||
- if ((cmdr & AML_MMC_CMD_RESP | |||
- mcfgr = sc->port; | |||
- mcfgr |= AML_MMC_MULT_CON | |||
- CSR_WRITE_4(sc, AML_MMC_MULT_CON | |||
- | |||
- if ((cmdr & AML_MMC_CMD_RESP | |||
- /* | |||
- * 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_ARGU | |||
- 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_ARGU | |||
- } | |||
- | |||
- if ((isr & AML_MMC_IRQ_STAT | |||
- /* | |||
- * A multiblock operation may keep the hardware | |||
- * busy until stop transmission is executed. | |||
- */ | |||
- (isr & AML_MMC_IRQ_STAT | |||
- 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_unloa | |||
- */ | |||
- | |||
- aml8726_mmc_soft | |||
- | |||
- while ((CSR_READ_4(sc, AML_MMC_IRQ_STAT | |||
- AML_MMC_IRQ_STAT | |||
- cpu_spinwait(); | |||
- } | |||
- | |||
- aml8726_mmc_fini | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_prob | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 MMC"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_atta | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- 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 | |||
- | |||
- 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 | |||
- (void **)&function_name); | |||
- | |||
- if (len < 0) { | |||
- device_printf(dev, | |||
- "missing amlogic,function | |||
- return (ENXIO); | |||
- } | |||
- | |||
- if (strncmp("sdio-a", function_name, len) == 0) | |||
- sc->port = AML_MMC_MULT_CON | |||
- else if (strncmp("sdio-b", function_name, len) == 0) | |||
- sc->port = AML_MMC_MULT_CON | |||
- else if (strncmp("sdio-c", function_name, len) == 0) | |||
- sc->port = AML_MMC_MULT_CON | |||
- 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_x | |||
- 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_powe | |||
- GPIO_PIN_SETFLAG | |||
- GPIO_PIN_OUTPUT) != 0) { | |||
- device_printf(dev, | |||
- "could not use gpio to control power\n"); | |||
- return (ENXIO); | |||
- } | |||
- } | |||
- | |||
- len = OF_getprop_alloc | |||
- (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_VOLT | |||
- 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_x | |||
- 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_SETFLAG | |||
- 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_resour | |||
- device_printf(dev, "could not allocate resources for device\n"); | |||
- return (ENXIO); | |||
- } | |||
- | |||
- AML_MMC_LOCK_INI | |||
- | |||
- error = bus_dma_tag_crea | |||
- BUS_SPACE_MAXADD | |||
- AML_MMC_MAX_DMA, | |||
- if (error) | |||
- goto fail; | |||
- | |||
- error = bus_dmamap_creat | |||
- | |||
- if (error) | |||
- goto fail; | |||
- | |||
- error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_MISC | INTR_MPSAFE, | |||
- NULL, aml8726_mmc_intr | |||
- if (error) { | |||
- device_printf(dev, "could not setup interrupt handler\n"); | |||
- goto fail; | |||
- } | |||
- | |||
- callout_init_mtx | |||
- | |||
- sc->host.f_min = aml8726_mmc_freq | |||
- sc->host.f_max = aml8726_mmc_freq | |||
- sc->host.host_ocr = sc->voltages[0] | sc->voltages[1]; | |||
- sc->host.caps = MMC_CAP_4_BIT_DA | |||
- | |||
- child = device_add_child | |||
- | |||
- if (!child) { | |||
- device_printf(dev, "could not add mmc\n"); | |||
- error = ENXIO; | |||
- goto fail; | |||
- } | |||
- | |||
- error = device_probe_and | |||
- | |||
- if (error) { | |||
- device_printf(dev, "could not attach mmc\n"); | |||
- goto fail; | |||
- } | |||
- | |||
- return (0); | |||
- | |||
-fail: | |||
- if (sc->ih_cookie) | |||
- bus_teardown_int | |||
- | |||
- if (sc->dmamap) | |||
- bus_dmamap_destr | |||
- | |||
- if (sc->dmatag) | |||
- bus_dma_tag_dest | |||
- | |||
- AML_MMC_LOCK_DES | |||
- | |||
- aml8726_mmc_powe | |||
- | |||
- bus_release_reso | |||
- | |||
- return (error); | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_deta | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- | |||
- 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_powe | |||
- aml8726_mmc_soft | |||
- CSR_WRITE_4(sc, AML_MMC_IRQ_STAT | |||
- | |||
- /* This should be a NOP since no command was in flight. */ | |||
- callout_stop(&sc->ch); | |||
- | |||
- AML_MMC_UNLOCK(sc); | |||
- | |||
- bus_generic_deta | |||
- | |||
- bus_teardown_int | |||
- | |||
- bus_dmamap_destr | |||
- | |||
- bus_dma_tag_dest | |||
- | |||
- AML_MMC_LOCK_DES | |||
- | |||
- bus_release_reso | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_shut | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- | |||
- /* | |||
- * Turn off the power, reset the hardware state machine, | |||
- * disable the interrupts, and clear the interrupts. | |||
- */ | |||
- (void)aml8726_mmc_powe | |||
- aml8726_mmc_soft | |||
- CSR_WRITE_4(sc, AML_MMC_IRQ_STAT | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_upda | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- struct mmc_ios *ios = &sc->host.ios; | |||
- int error; | |||
- int i; | |||
- uint32_t cfgr; | |||
- | |||
- cfgr = (2 << AML_MMC_CONFIG_W | |||
- (2 << AML_MMC_CONFIG_W | |||
- AML_MMC_CONFIG_D | |||
- (39 << AML_MMC_CONFIG_C | |||
- | |||
- switch (ios->bus_width) { | |||
- case bus_width_4: | |||
- cfgr |= AML_MMC_CONFIG_B | |||
- break; | |||
- case bus_width_1: | |||
- cfgr |= AML_MMC_CONFIG_B | |||
- break; | |||
- default: | |||
- return (EINVAL); | |||
- } | |||
- | |||
- cfgr |= aml8726_mmc_div(sc, ios->clock) << | |||
- AML_MMC_CONFIG_C | |||
- | |||
- CSR_WRITE_4(sc, AML_MMC_CONFIG_R | |||
- | |||
- 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_powe | |||
- break; | |||
- case power_off: | |||
- error = aml8726_mmc_powe | |||
- break; | |||
- default: | |||
- return (EINVAL); | |||
- } | |||
- | |||
- return (error); | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_requ | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- int mmc_error; | |||
- | |||
- AML_MMC_LOCK(sc); | |||
- | |||
- if (sc->cmd != NULL) { | |||
- AML_MMC_UNLOCK(sc); | |||
- return (EBUSY); | |||
- } | |||
- | |||
- mmc_error = aml8726_mmc_star | |||
- | |||
- 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 | |||
- int which, uintptr_t *result) | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- | |||
- switch (which) { | |||
- case MMCBR_IVAR_BUS_M | |||
- *(int *)result = sc->host.ios.bus_mode; | |||
- break; | |||
- case MMCBR_IVAR_BUS_W | |||
- *(int *)result = sc->host.ios.bus_width; | |||
- break; | |||
- case MMCBR_IVAR_CHIP_ | |||
- *(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_ | |||
- *(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 | |||
- *(int *)result = sc->host.ios.power_mode; | |||
- break; | |||
- case MMCBR_IVAR_RETUN | |||
- *(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_TIMIN | |||
- *(int *)result = sc->sc_host.ios.timing; | |||
- break; | |||
- case MMCBR_IVAR_MAX_D | |||
- *(int *)result = AML_MMC_MAX_DMA / MMC_SECTOR_SIZE; | |||
- break; | |||
- case MMCBR_IVAR_MAX_B | |||
- *(int *)result = 1000000; /* 1s max */ | |||
- break; | |||
- default: | |||
- return (EINVAL); | |||
- } | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_writ | |||
- int which, uintptr_t value) | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- | |||
- switch (which) { | |||
- case MMCBR_IVAR_BUS_M | |||
- sc->host.ios.bus_mode = value; | |||
- break; | |||
- case MMCBR_IVAR_BUS_W | |||
- sc->host.ios.bus_width = value; | |||
- break; | |||
- case MMCBR_IVAR_CHIP_ | |||
- 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 | |||
- 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_TIMIN | |||
- sc->sc_host.ios.timing = value; | |||
- break; | |||
- /* These are read-only */ | |||
- case MMCBR_IVAR_CAPS: | |||
- case MMCBR_IVAR_HOST_ | |||
- case MMCBR_IVAR_F_MIN | |||
- case MMCBR_IVAR_F_MAX | |||
- case MMCBR_IVAR_MAX_D | |||
- default: | |||
- return (EINVAL); | |||
- } | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_get_ | |||
-{ | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_mmc_acqu | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- | |||
- 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_rele | |||
-{ | |||
- struct aml8726_mmc_soft | |||
- | |||
- AML_MMC_LOCK(sc); | |||
- | |||
- sc->bus_busy--; | |||
- wakeup(sc); | |||
- | |||
- AML_MMC_UNLOCK(sc); | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static device_method_t aml8726_mmc_meth | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_mmc_prob | |||
- DEVMETHOD(device_attach, aml8726_mmc_atta | |||
- DEVMETHOD(device_detach, aml8726_mmc_deta | |||
- DEVMETHOD(device_shutdown, | |||
- | |||
- /* Bus interface */ | |||
- DEVMETHOD(bus_read_ivar, aml8726_mmc_read | |||
- DEVMETHOD(bus_write_ivar, aml8726_mmc_writ | |||
- | |||
- /* MMC bridge interface */ | |||
- DEVMETHOD(mmcbr_update_ios | |||
- DEVMETHOD(mmcbr_request, aml8726_mmc_requ | |||
- DEVMETHOD(mmcbr_get_ro, aml8726_mmc_get_ | |||
- DEVMETHOD(mmcbr_acquire_ho | |||
- DEVMETHOD(mmcbr_release_ho | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_mmc_driv | |||
- "aml8726_mmc", | |||
- aml8726_mmc_meth | |||
- sizeof(struct aml8726_mmc_soft | |||
-}; | |||
- | |||
-static devclass_t aml8726_mmc_devc | |||
- | |||
-DRIVER_MODULE(aml8726_mmc, simplebus, aml8726_mmc_driv | |||
- aml8726_mmc_devc | |||
-MODULE_DEPEND(aml8726_mmc, aml8726_gpio, 1, 1, 1); | |||
-MMC_DECLARE_BRID |
@@ -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_AML | |||
-#define _ARM_AMLOGIC_AML | |||
- | |||
-#define AML_MMC_ALIGN_DM | |||
-#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_TIME | |||
-#define AML_MMC_READ_TIM | |||
-#define AML_MMC_WRITE_TI | |||
-#define AML_MMC_MAX_TIME | |||
- | |||
-#define AML_MMC_CMD_ARGU | |||
- | |||
-#define AML_MMC_CMD_SEND | |||
-#define AML_MMC_CMD_REP_ | |||
-#define AML_MMC_CMD_REP_ | |||
-#define AML_MMC_CMD_CMD_ | |||
-#define AML_MMC_CMD_CHEC | |||
-#define AML_MMC_CMD_RESP | |||
-#define AML_MMC_CMD_RESP | |||
-#define AML_MMC_CMD_RESP | |||
-#define AML_MMC_CMD_RESP | |||
-#define AML_MMC_CMD_RESP | |||
-#define AML_MMC_CMD_STAR | |||
-#define AML_MMC_CMD_TRAN | |||
-#define AML_MMC_CMD_INDE | |||
-#define AML_MMC_CMD_INDE | |||
- | |||
-#define AML_MMC_CONFIG_R | |||
-#define AML_MMC_CONFIG_W | |||
-#define AML_MMC_CONFIG_W | |||
-#define AML_MMC_CONFIG_W | |||
-#define AML_MMC_CONFIG_W | |||
-#define AML_MMC_CONFIG_D | |||
-#define AML_MMC_CONFIG_D | |||
-#define AML_MMC_CONFIG_D | |||
-#define AML_MMC_CONFIG_D | |||
-#define AML_MMC_CONFIG_D | |||
-#define AML_MMC_CONFIG_B | |||
-#define AML_MMC_CONFIG_B | |||
-#define AML_MMC_CONFIG_B | |||
-#define AML_MMC_CONFIG_D | |||
-#define AML_MMC_CONFIG_D | |||
-#define AML_MMC_CONFIG_C | |||
-#define AML_MMC_CONFIG_C | |||
-#define AML_MMC_CONFIG_C | |||
-#define AML_MMC_CONFIG_C | |||
-#define AML_MMC_CONFIG_C | |||
-#define AML_MMC_CONFIG_C | |||
- | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
-#define AML_MMC_IRQ_STAT | |||
- | |||
-#define AML_MMC_IRQ_CONF | |||
-#define AML_MMC_IRQ_CONF | |||
-#define AML_MMC_IRQ_CONF | |||
- | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
-#define AML_MMC_MULT_CON | |||
- | |||
-#define AML_MMC_DMA_ADDR | |||
- | |||
-#define AML_MMC_EXTENSIO | |||
-#define AML_MMC_EXTENSIO | |||
-#define AML_MMC_EXTENSIO | |||
-#define AML_MMC_EXTENSIO | |||
- | |||
-#endif /* _ARM_AMLOGIC_AML |
@@ -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_ | |||
- * 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_76436 | |||
- "arm,cortex-a9-scu", | |||
- NULL | |||
-}; | |||
- | |||
-static const char *cpucfg_compatibl | |||
- "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_ | |||
-#define AML_SCU_CONTROL_ | |||
-#define AML_SCU_CONFIG_R | |||
-#define AML_SCU_CONFIG_N | |||
-#define AML_SCU_CPU_PWR_ | |||
-#define AML_SCU_CPU_PWR_ | |||
-#define AML_SCU_CPU_PWR_ | |||
-#define AML_SCU_CPU_PWR_ | |||
-#define AML_SCU_CPU_PWR_ | |||
-#define AML_SCU_INV_TAGS | |||
-#define AML_SCU_DIAG_CON | |||
-#define AML_SCU_DIAG_CON | |||
- | |||
-#define AML_CPUCONF_CONT | |||
-#define AML_CPUCONF_CPU1 | |||
-#define AML_CPUCONF_CPU2 | |||
-#define AML_CPUCONF_CPU3 | |||
- | |||
-/* aobus */ | |||
- | |||
-#define AML_M8_CPU_PWR_C | |||
-#define AML_M8B_CPU_PWR_ | |||
-#define AML_M8B_CPU_PWR_ | |||
-#define AML_M8B_CPU_PWR_ | |||
- | |||
-#define AML_M8_CPU_PWR_C | |||
-#define AML_M8_CPU_PWR_C | |||
-#define AML_M8_CPU_PWR_C | |||
- | |||
-#define AML_M8_CPU_PWR_C | |||
-#define AML_M8B_CPU_PWR_ | |||
-#define AML_M8B_CPU_PWR_ | |||
-#define AML_M8B_CPU_PWR_ | |||
- | |||
-#define AML_M8_CPU_PWR_C | |||
-#define AML_M8_CPU_PWR_C | |||
-#define AML_M8_CPU_PWR_C | |||
- | |||
-#define AML_M8B_CPU_PWR_ | |||
-#define AML_M8B_CPU_PWR_ | |||
-#define AML_M8B_CPU_PWR_ | |||
-#define AML_M8B_CPU_PWR_ | |||
- | |||
-/* cbus */ | |||
- | |||
-#define AML_SOC_CPU_CLK_ | |||
-#define AML_M8_CPU_CLK_C | |||
-#define AML_M8_CPU_CLK_C | |||
-#define AML_M8_CPU_CLK_C | |||
- | |||
-#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_BARRIE | |||
- | |||
-#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_BARRIE | |||
- | |||
-#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_BARRIE | |||
- | |||
-#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_BARRIE | |||
- | |||
-static phandle_t | |||
-find_node_for_de | |||
-{ | |||
- 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_compatibl | |||
- 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_compati | |||
- return node; | |||
- } | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-alloc_resource_f | |||
-{ | |||
- 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_r | |||
- case AML_SOC_HW_REV_M | |||
- case AML_SOC_HW_REV_M | |||
- /* | |||
- * Set the SCU power status for the CPU to normal mode. | |||
- */ | |||
- scpsr = SCU_READ_4(AML_SCU_CPU_PWR_ | |||
- scpsr &= ~(AML_SCU_CPU_PWR_ | |||
- SCU_WRITE_4(AML_SCU_CPU_PWR_ | |||
- SCU_BARRIER(AML_SCU_CPU_PWR_ | |||
- | |||
- if (aml8726_soc_hw_r | |||
- /* | |||
- * 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_C | |||
- value &= ~(AML_M8B_CPU_PWR_ | |||
- ((cpu - 1) * 2)); | |||
- AOBUS_WRITE_4(AML_M8_CPU_PWR_C | |||
- AOBUS_BARRIER(AML_M8_CPU_PWR_C | |||
- } | |||
- | |||
- DELAY(5); | |||
- | |||
- /* | |||
- * Assert reset. | |||
- */ | |||
- value = CBUS_READ_4(AML_SOC_CPU_CLK_ | |||
- value |= AML_M8_CPU_CLK_C | |||
- CBUS_WRITE_4(AML_SOC_CPU_CLK_ | |||
- CBUS_BARRIER(AML_SOC_CPU_CLK_ | |||
- | |||
- if (aml8726_soc_hw_r | |||
- /* | |||
- * Release RAM pull-down. | |||
- */ | |||
- value = AOBUS_READ_4(AML_M8B_CPU_PWR_ | |||
- value &= ~((uint32_t)AML_M8B_CPU_PWR_ | |||
- ((cpu - 1) * 4)); | |||
- AOBUS_WRITE_4(AML_M8B_CPU_PWR_ | |||
- AOBUS_BARRIER(AML_M8B_CPU_PWR_ | |||
- } | |||
- | |||
- /* | |||
- * Power on CPU. | |||
- */ | |||
- value = AOBUS_READ_4(AML_M8_CPU_PWR_C | |||
- value &= ~(AML_M8_CPU_PWR_C | |||
- ((cpu - 1) * 2)); | |||
- AOBUS_WRITE_4(AML_M8_CPU_PWR_C | |||
- AOBUS_BARRIER(AML_M8_CPU_PWR_C | |||
- | |||
- DELAY(10); | |||
- | |||
- if (aml8726_soc_hw_r | |||
- /* | |||
- * Wait for power on confirmation. | |||
- */ | |||
- for ( ; ; ) { | |||
- value = AOBUS_READ_4(AML_M8_CPU_PWR_C | |||
- value &= AML_M8B_CPU_PWR_ | |||
- (cpu - 1); | |||
- if (value) | |||
- break; | |||
- DELAY(10); | |||
- } | |||
- } | |||
- | |||
- /* | |||
- * Release peripheral clamp. | |||
- */ | |||
- value = AOBUS_READ_4(AML_M8_CPU_PWR_C | |||
- value &= ~(AML_M8_CPU_PWR_C | |||
- AOBUS_WRITE_4(AML_M8_CPU_PWR_C | |||
- AOBUS_BARRIER(AML_M8_CPU_PWR_C | |||
- | |||
- /* | |||
- * Release reset. | |||
- */ | |||
- value = CBUS_READ_4(AML_SOC_CPU_CLK_ | |||
- value &= ~(AML_M8_CPU_CLK_C | |||
- CBUS_WRITE_4(AML_SOC_CPU_CLK_ | |||
- CBUS_BARRIER(AML_SOC_CPU_CLK_ | |||
- | |||
- if (aml8726_soc_hw_r | |||
- /* | |||
- * 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_ | |||
- SCU_BARRIER(AML_SCU_CPU_PWR_ | |||
- } | |||
- break; | |||
- default: | |||
- break; | |||
- } | |||
-} | |||
- | |||
-void | |||
-platform_mp_setm | |||
-{ | |||
- 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_de | |||
- goto moveon; | |||
- | |||
- if ((cpucfg_node = find_node_for_de | |||
- cpucfg_compatibl | |||
- goto moveon; | |||
- | |||
- if (alloc_resource_f | |||
- &aml8726_smp.scu_size) != 0) | |||
- panic("Could not allocate resource for SCU"); | |||
- | |||
- if (alloc_resource_f | |||
- &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_BA | |||
- 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_BAS | |||
- 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_76436 | |||
- if (fdt_is_compatibl | |||
- aml8726_smp.errata_764369 = true; | |||
- break; | |||
- } | |||
- | |||
- /* | |||
- * Read the number of CPUs present. | |||
- */ | |||
- value = SCU_READ_4(AML_SCU_CONFIG_R | |||
- ncpu = (value & AML_SCU_CONFIG_N | |||
- | |||
-moveon: | |||
- mp_ncpus = ncpu; | |||
- mp_maxid = ncpu - 1; | |||
-} | |||
- | |||
-void | |||
-platform_mp_star | |||
-{ | |||
- 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 | |||
- | |||
- 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_CON | |||
- value |= AML_SCU_DIAG_CON | |||
- SCU_WRITE_4(AML_SCU_DIAG_CON | |||
- } | |||
- | |||
- /* | |||
- * 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_ | |||
- value |= AML_SCU_CONTROL_ | |||
- SCU_WRITE_4(AML_SCU_CONTROL_ | |||
- SCU_BARRIER(AML_SCU_CONTROL_ | |||
- dcache_wbinv_poc | |||
- | |||
- /* 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 | |||
- 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_CONT | |||
- value |= 1; | |||
- for (i = 1; i < mp_ncpus; i++) | |||
- value |= (1 << i); | |||
- CPUCONF_WRITE_4(AML_CPUCONF_CONT | |||
- CPUCONF_BARRIER(AML_CPUCONF_CONT | |||
- | |||
- /* 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_soft | |||
- device_t dev; | |||
-}; | |||
- | |||
-static int | |||
-aml8726_scu_prob | |||
-{ | |||
- int i; | |||
- | |||
- for (i = 0; scu_compatible[i]; i++) | |||
- if (ofw_bus_is_compa | |||
- break; | |||
- | |||
- if (!scu_compatible[i]) | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "ARM Snoop Control Unit"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_scu_atta | |||
-{ | |||
- struct aml8726_scu_soft | |||
- | |||
- sc->dev = dev; | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_scu_deta | |||
-{ | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static device_method_t aml8726_scu_meth | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_scu_prob | |||
- DEVMETHOD(device_attach, aml8726_scu_atta | |||
- DEVMETHOD(device_detach, aml8726_scu_deta | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_scu_driv | |||
- "scu", | |||
- aml8726_scu_meth | |||
- sizeof(struct aml8726_scu_soft | |||
-}; | |||
- | |||
-static devclass_t aml8726_scu_devc | |||
- | |||
-EARLY_DRIVER_MOD | |||
- 0, 0, BUS_PASS_CPU + BUS_PASS_ORDER_M | |||
- | |||
-struct aml8726_cpucfg_s | |||
- device_t dev; | |||
-}; | |||
- | |||
-static int | |||
-aml8726_cpucfg_p | |||
-{ | |||
- int i; | |||
- | |||
- for (i = 0; cpucfg_compatibl | |||
- if (ofw_bus_is_compa | |||
- break; | |||
- | |||
- if (!cpucfg_compatibl | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic CPU Config"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_cpucfg_a | |||
-{ | |||
- struct aml8726_cpucfg_s | |||
- | |||
- sc->dev = dev; | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_cpucfg_d | |||
-{ | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static device_method_t aml8726_cpucfg_m | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_cpucfg_p | |||
- DEVMETHOD(device_attach, aml8726_cpucfg_a | |||
- DEVMETHOD(device_detach, aml8726_cpucfg_d | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_cpucfg_d | |||
- "cpuconfig", | |||
- aml8726_cpucfg_m | |||
- sizeof(struct aml8726_cpucfg_s | |||
-}; | |||
- | |||
-static devclass_t aml8726_cpucfg_d | |||
- | |||
-EARLY_DRIVER_MOD | |||
- aml8726_cpucfg_d |
@@ -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_soft | |||
- device_t dev; | |||
- struct resource * res[1]; | |||
-}; | |||
- | |||
-static struct resource_spec aml8726_pic_spec | |||
- { SYS_RES_MEMORY, 0, RF_ACTIVE }, | |||
- { -1, 0 } | |||
-}; | |||
- | |||
-/* | |||
- * devclass_get_dev | |||
- * 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_soft | |||
- | |||
-#define AML_PIC_NCNTRLS 4 | |||
-#define AML_PIC_IRQS_PER | |||
- | |||
-#define AML_PIC_NIRQS (AML_PIC_NCNTRLS * AML_PIC_IRQS_PER | |||
- | |||
-#define AML_PIC_0_STAT_R | |||
-#define AML_PIC_0_STAT_C | |||
-#define AML_PIC_0_MASK_R | |||
-#define AML_PIC_0_FIRQ_S | |||
- | |||
-#define AML_PIC_1_STAT_R | |||
-#define AML_PIC_1_STAT_C | |||
-#define AML_PIC_1_MASK_R | |||
-#define AML_PIC_1_FIRQ_S | |||
- | |||
-#define AML_PIC_2_STAT_R | |||
-#define AML_PIC_2_STAT_C | |||
-#define AML_PIC_2_MASK_R | |||
-#define AML_PIC_2_FIRQ_S | |||
- | |||
-#define AML_PIC_3_STAT_R | |||
-#define AML_PIC_3_STAT_C | |||
-#define AML_PIC_3_MASK_R | |||
-#define AML_PIC_3_FIRQ_S | |||
- | |||
-#define AML_PIC_CTRL(x) ((x) >> 5) | |||
-#define AML_PIC_BIT(x) (1 << ((x) & 0x1f)) | |||
- | |||
-#define AML_PIC_STAT_REG | |||
-#define AML_PIC_STAT_CLR | |||
-#define AML_PIC_MASK_REG | |||
-#define AML_PIC_FIRQ_SEL | |||
- | |||
-#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_BARRIE | |||
- | |||
-static void | |||
-aml8726_pic_eoi(void *arg) | |||
-{ | |||
- uintptr_t nb = (uintptr_t) arg; | |||
- | |||
- if (nb >= AML_PIC_NIRQS) | |||
- return; | |||
- | |||
- arm_irq_memory_b | |||
- | |||
- CSR_WRITE_4(aml8726_pic_sc, AML_PIC_STAT_CLR | |||
- | |||
- CSR_BARRIER(aml8726_pic_sc, AML_PIC_STAT_CLR | |||
-} | |||
- | |||
-static int | |||
-aml8726_pic_prob | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 PIC"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_pic_atta | |||
-{ | |||
- struct aml8726_pic_soft | |||
- int i; | |||
- | |||
- /* There should be exactly one instance. */ | |||
- if (aml8726_pic_sc != NULL) | |||
- return (ENXIO); | |||
- | |||
- sc->dev = dev; | |||
- | |||
- if (bus_alloc_resour | |||
- 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_R | |||
- CSR_WRITE_4(sc, AML_PIC_0_STAT_C | |||
- CSR_WRITE_4(sc, AML_PIC_0_FIRQ_S | |||
- } | |||
- | |||
-#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_deta | |||
-{ | |||
- | |||
- return (EBUSY); | |||
-} | |||
- | |||
-static device_method_t aml8726_pic_meth | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_pic_prob | |||
- DEVMETHOD(device_attach, aml8726_pic_atta | |||
- DEVMETHOD(device_detach, aml8726_pic_deta | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_pic_driv | |||
- "pic", | |||
- aml8726_pic_meth | |||
- sizeof(struct aml8726_pic_soft | |||
-}; | |||
- | |||
-static devclass_t aml8726_pic_devc | |||
- | |||
-EARLY_DRIVER_MOD | |||
- 0, 0, BUS_PASS_INTERRU | |||
- | |||
-#ifndef DEV_GIC | |||
-int | |||
-arm_get_next_irq | |||
-{ | |||
- 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 | |||
- | |||
- 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 | |||
- 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 | |||
- mask &= ~AML_PIC_BIT(nb); | |||
- CSR_WRITE_4(aml8726_pic_sc, AML_PIC_MASK_REG | |||
- | |||
- CSR_BARRIER(aml8726_pic_sc, AML_PIC_MASK_REG | |||
- | |||
- aml8726_pic_eoi((void *)nb); | |||
-} | |||
- | |||
-void | |||
-arm_unmask_irq(uintptr_t nb) | |||
-{ | |||
- uint32_t mask; | |||
- | |||
- if (nb >= AML_PIC_NIRQS) | |||
- return; | |||
- | |||
- arm_irq_memory_b | |||
- | |||
- mask = CSR_READ_4(aml8726_pic_sc, AML_PIC_MASK_REG | |||
- mask |= AML_PIC_BIT(nb); | |||
- CSR_WRITE_4(aml8726_pic_sc, AML_PIC_MASK_REG | |||
- | |||
- CSR_BARRIER(aml8726_pic_sc, AML_PIC_MASK_REG | |||
-} | |||
-#endif |
@@ -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_ | |||
- device_t dev; | |||
- struct { | |||
- struct aml8726_pinctrl_ | |||
- struct aml8726_pinctrl_ | |||
- boolean_t pud_ctrl; | |||
- } soc; | |||
- struct resource *res[6]; | |||
- struct mtx mtx; | |||
-}; | |||
- | |||
-static struct resource_spec aml8726_pinctrl_ | |||
- { 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 | |||
-#define AML_PINCTRL_UNLO | |||
-#define AML_PINCTRL_LOCK | |||
- mtx_init(&(sc)->mtx, device_get_nameu | |||
- "pinctrl", MTX_DEF) | |||
-#define AML_PINCTRL_LOCK | |||
- | |||
-#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_ | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 pinctrl"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_pinctrl_ | |||
-{ | |||
- struct aml8726_pinctrl_ | |||
- | |||
- sc->dev = dev; | |||
- | |||
- sc->soc.pud_ctrl = false; | |||
- | |||
- switch (aml8726_soc_hw_r | |||
- case AML_SOC_HW_REV_M | |||
- sc->soc.func = aml8726_m3_pinct | |||
- sc->soc.ppin = aml8726_m3_pkg_p | |||
- break; | |||
- case AML_SOC_HW_REV_M | |||
- sc->soc.func = aml8726_m6_pinct | |||
- sc->soc.ppin = aml8726_m6_pkg_p | |||
- break; | |||
- case AML_SOC_HW_REV_M | |||
- sc->soc.func = aml8726_m8_pinct | |||
- sc->soc.ppin = aml8726_m8_pkg_p | |||
- sc->soc.pud_ctrl = true; | |||
- break; | |||
- case AML_SOC_HW_REV_M | |||
- sc->soc.func = aml8726_m8b_pinc | |||
- sc->soc.ppin = aml8726_m8b_pkg_ | |||
- sc->soc.pud_ctrl = true; | |||
- break; | |||
- default: | |||
- device_printf(dev, "unsupported SoC\n"); | |||
- return (ENXIO); | |||
- /* NOTREACHED */ | |||
- } | |||
- | |||
- if (bus_alloc_resour | |||
- device_printf(dev, "could not allocate resources for device\n"); | |||
- return (ENXIO); | |||
- } | |||
- | |||
- AML_PINCTRL_LOCK | |||
- | |||
- fdt_pinctrl_regi | |||
- fdt_pinctrl_conf | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_pinctrl_ | |||
-{ | |||
- struct aml8726_pinctrl_ | |||
- | |||
- AML_PINCTRL_LOCK | |||
- | |||
- bus_release_reso | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_pinctrl_ | |||
-{ | |||
- struct aml8726_pinctrl_ | |||
- struct aml8726_pinctrl_ | |||
- struct aml8726_pinctrl_ | |||
- struct aml8726_pinctrl_ | |||
- struct aml8726_pinctrl_ | |||
- struct aml8726_pinctrl_ | |||
- enum aml8726_pinctrl_ | |||
- char *function_name; | |||
- char *pins; | |||
- char *pin_name; | |||
- char *pull; | |||
- phandle_t node; | |||
- ssize_t len; | |||
- uint32_t value; | |||
- | |||
- node = OF_node_from_xre | |||
- | |||
- len = OF_getprop_alloc | |||
- (void **)&function_name); | |||
- | |||
- if (len < 0) { | |||
- device_printf(dev, | |||
- "missing amlogic,function | |||
- 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 | |||
- (void **)&pull); | |||
- | |||
- pm = aml8726_unknown_ | |||
- | |||
- if (len > 0) { | |||
- if (strncmp(pull, "enable", len) == 0) | |||
- pm = aml8726_enable_p | |||
- else if (strncmp(pull, "disable", len) == 0) | |||
- pm = aml8726_disable_ | |||
- else if (strncmp(pull, "down", len) == 0) | |||
- pm = aml8726_enable_d | |||
- else if (strncmp(pull, "up", len) == 0) | |||
- pm = aml8726_enable_u | |||
- 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_d | |||
- case aml8726_enable_u | |||
- 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 | |||
- (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_ | |||
- device_printf(dev, | |||
- "missing pull info for package pin %s\n", | |||
- p->pkg_name); | |||
- continue; | |||
- } | |||
- | |||
- AML_PINCTRL_LOCK | |||
- | |||
- /* | |||
- * 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_d | |||
- case aml8726_enable_u | |||
- if (pp->aobus == false) { | |||
- value = PUD_READ_4(sc, pp->pull_addr); | |||
- if (pm == aml8726_enable_d | |||
- 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_d | |||
- value &= ~(pp->pull_bits << 16); | |||
- else | |||
- value |= (pp->pull_bits << 16); | |||
- AOPUD_WRITE_4(sc, pp->pull_addr, value); | |||
- } | |||
- /* FALLTHROUGH */ | |||
- case aml8726_disable_ | |||
- case aml8726_enable_p | |||
- if (pp->aobus == false) { | |||
- value = PEN_READ_4(sc, pp->pull_addr); | |||
- if (pm == aml8726_disable_ | |||
- 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_ | |||
- value &= ~pp->pull_bits; | |||
- else | |||
- value |= pp->pull_bits; | |||
- AOPEN_WRITE_4(sc, pp->pull_addr, value); | |||
- } | |||
- break; | |||
- default: | |||
- break; | |||
- } | |||
- | |||
- AML_PINCTRL_UNLO | |||
- } | |||
- | |||
- OF_prop_free(pins); | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static device_method_t aml8726_pinctrl_ | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_pinctrl_ | |||
- DEVMETHOD(device_attach, aml8726_pinctrl_ | |||
- DEVMETHOD(device_detach, aml8726_pinctrl_ | |||
- | |||
- /* fdt_pinctrl interface */ | |||
- DEVMETHOD(fdt_pinctrl_conf | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_pinctrl_ | |||
- "pinctrl", | |||
- aml8726_pinctrl_ | |||
- sizeof(struct aml8726_pinctrl_ | |||
-}; | |||
- | |||
-static devclass_t aml8726_pinctrl_ | |||
- | |||
-EARLY_DRIVER_MOD | |||
- aml8726_pinctrl_ |
@@ -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_AML | |||
-#define _ARM_AMLOGIC_AML | |||
- | |||
-enum aml8726_pinctrl_ | |||
- aml8726_unknown_ | |||
- aml8726_disable_ | |||
- aml8726_enable_p | |||
- aml8726_enable_d | |||
- aml8726_enable_u | |||
-}; | |||
- | |||
-struct aml8726_pinctrl_ | |||
- const char *pkg_name; | |||
- boolean_t aobus; | |||
- uint32_t pull_addr; | |||
- uint32_t pull_bits; | |||
-}; | |||
- | |||
-struct aml8726_pinctrl_ | |||
- const char *name; | |||
- const char *pkg_name; | |||
- uint32_t mux_addr; | |||
- uint32_t mux_bits; | |||
-}; | |||
- | |||
-struct aml8726_pinctrl_ | |||
- const char *name; | |||
- struct aml8726_pinctrl_ | |||
-}; | |||
- | |||
-/* | |||
- * 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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "scl", "gpiox_26", 20, 0x04000000 }, | |||
- { "sda", "gpiox_25", 20, 0x08000000 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "scl", "gpiox_28", 20, 0x40000000 }, | |||
- { "sda", "gpiox_27", 20, 0x80000000 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "scl", "gpioao_4", 0, 0x00000400 }, | |||
- { "sda", "gpioao_5", 0, 0x00000200 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "tx", "gpioao_0", 0, 0x00001000 }, | |||
- { "rx", "gpioao_1", 0, 0x00000800 }, | |||
- { "cts", "gpioao_2", 0, 0x00000400 }, | |||
- { "rts", "gpioao_3", 0, 0x00000200 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-struct aml8726_pinctrl_ | |||
- { "gpio", aml8726_m3_gpio }, | |||
- { "ethernet", aml8726_m3_ether | |||
- { "hdmi", aml8726_m3_hdmi }, | |||
- { "i2c-a", aml8726_m3_i2c_a | |||
- { "i2c-b", aml8726_m3_i2c_b | |||
- { "sdio-b", aml8726_m3_sdio_ | |||
- { "sdxc-b", aml8726_m3_sdxc_ | |||
- { "uart-a", aml8726_m3_uart_ | |||
- { "uart-b", aml8726_m3_uart_ | |||
- { "uart-c", aml8726_m3_uart_ | |||
- { "i2c-ao", aml8726_m3_i2c_a | |||
- { "uart-ao", aml8726_m3_uart_ | |||
- { 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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "scl", "gpiox_26", 20, 0x04000000 }, | |||
- { "sda", "gpiox_25", 20, 0x08000000 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "scl", "gpiox_28", 20, 0x40000000 }, | |||
- { "sda", "gpiox_27", 20, 0x80000000 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "scl", "gpioao_4", 0, 0x00000400 }, | |||
- { "sda", "gpioao_5", 0, 0x00000200 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "tx", "gpioao_0", 0, 0x00001000 }, | |||
- { "rx", "gpioao_1", 0, 0x00000800 }, | |||
- { "cts", "gpioao_2", 0, 0x00000400 }, | |||
- { "rts", "gpioao_3", 0, 0x00000200 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-struct aml8726_pinctrl_ | |||
- { "gpio", aml8726_m6_gpio }, | |||
- { "ethernet", aml8726_m6_ether | |||
- { "hdmi", aml8726_m6_hdmi }, | |||
- { "i2c-a", aml8726_m6_i2c_a | |||
- { "i2c-b", aml8726_m6_i2c_b | |||
- { "sdio-b", aml8726_m6_sdio_ | |||
- { "sdxc-b", aml8726_m6_sdxc_ | |||
- { "uart-a", aml8726_m6_uart_ | |||
- { "uart-b", aml8726_m6_uart_ | |||
- { "uart-c", aml8726_m6_uart_ | |||
- { "i2c-ao", aml8726_m6_i2c_a | |||
- { "uart-ao", aml8726_m6_uart_ | |||
- { 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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "scl", "gpioz_12", 20, 0x00000040 }, | |||
- { "sda", "gpioz_11", 20, 0x00000080 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "scl", "gpioz_3", 20, 0x04000000 }, | |||
- { "sda", "gpioz_2", 20, 0x08000000 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "scl", "gpioao_4", 0, 0x00000400 }, | |||
- { "sda", "gpioao_5", 0, 0x00000200 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "tx", "gpioao_0", 0, 0x00001000 }, | |||
- { "rx", "gpioao_1", 0, 0x00000800 }, | |||
- { "cts", "gpioao_2", 0, 0x00000400 }, | |||
- { "rts", "gpioao_3", 0, 0x00000200 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-struct aml8726_pinctrl_ | |||
- { "gpio", aml8726_m8_gpio }, | |||
- { "ethernet", aml8726_m8_ether | |||
- { "hdmi", aml8726_m8_hdmi }, | |||
- { "i2c-a", aml8726_m8_i2c_a | |||
- { "i2c-b", aml8726_m8_i2c_b | |||
- { "sdio-b", aml8726_m8_sdio_ | |||
- { "sdxc-b", aml8726_m8_sdxc_ | |||
- { "sdio-c", aml8726_m8_sdio_ | |||
- { "sdxc-c", aml8726_m8_sdxc_ | |||
- { "uart-a", aml8726_m8_uart_ | |||
- { "uart-b", aml8726_m8_uart_ | |||
- { "uart-c", aml8726_m8_uart_ | |||
- { "i2c-ao", aml8726_m8_i2c_a | |||
- { "uart-ao", aml8726_m8_uart_ | |||
- { 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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "scl", "gpiodv_25", 36, 0x40000000 }, | |||
- { "sda", "gpiodv_24", 36, 0x80000000 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "scl", "gpiodv_27", 36, 0x10000000 }, | |||
- { "sda", "gpiodv_26", 36, 0x20000000 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "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_ | |||
- { "scl", "gpioao_4", 0, 0x00000400 }, | |||
- { "sda", "gpioao_5", 0, 0x00000200 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-static struct aml8726_pinctrl_ | |||
- { "tx", "gpioao_0", 0, 0x00001000 }, | |||
- { "rx", "gpioao_1", 0, 0x00000800 }, | |||
- { "cts", "gpioao_2", 0, 0x00000400 }, | |||
- { "rts", "gpioao_3", 0, 0x00000200 }, | |||
- { NULL } | |||
-}; | |||
- | |||
-struct aml8726_pinctrl_ | |||
- { "gpio", aml8726_m8b_gpio | |||
- { "ethernet", aml8726_m8b_ethe | |||
- { "hdmi", aml8726_m8b_hdmi | |||
- { "i2c-a", aml8726_m8b_i2c_ | |||
- { "i2c-b", aml8726_m8b_i2c_ | |||
- { "sdio-b", aml8726_m8b_sdio | |||
- { "sdxc-b", aml8726_m8b_sdxc | |||
- { "sdio-c", aml8726_m8b_sdio | |||
- { "sdxc-c", aml8726_m8b_sdxc | |||
- { "uart-a", aml8726_m8b_uart | |||
- { "uart-b", aml8726_m8b_uart | |||
- { "uart-c", aml8726_m8b_uart | |||
- { "i2c-ao", aml8726_m8b_i2c_ | |||
- { "uart-ao", aml8726_m8b_uart | |||
- { NULL } | |||
-}; | |||
- | |||
-#endif /* _ARM_AMLOGIC_AML |
@@ -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_soft | |||
- 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_harv | |||
-{ | |||
- struct aml8726_rng_soft | |||
- 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_AML8 | |||
- | |||
- callout_reset(&sc->co, sc->ticks, aml8726_rng_harv | |||
-} | |||
- | |||
-static int | |||
-aml8726_rng_prob | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 RNG"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_rng_atta | |||
-{ | |||
- struct aml8726_rng_soft | |||
- | |||
- sc->dev = dev; | |||
- | |||
- if (bus_alloc_resour | |||
- 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_harv | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_rng_deta | |||
-{ | |||
- struct aml8726_rng_soft | |||
- | |||
- callout_drain(&sc->co); | |||
- | |||
- bus_release_reso | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static device_method_t aml8726_rng_meth | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_rng_prob | |||
- DEVMETHOD(device_attach, aml8726_rng_atta | |||
- DEVMETHOD(device_detach, aml8726_rng_deta | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_rng_driv | |||
- "rng", | |||
- aml8726_rng_meth | |||
- sizeof(struct aml8726_rng_soft | |||
-}; | |||
- | |||
-static devclass_t aml8726_rng_devc | |||
- | |||
-DRIVER_MODULE(aml8726_rng, simplebus, aml8726_rng_driv | |||
- aml8726_rng_devc | |||
-MODULE_DEPEND(aml8726_rng, random, 1, 1, 1); |
@@ -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_soft | |||
- device_t dev; | |||
- struct aml8726_rtc_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_INI | |||
- mtx_init(&(sc)->mtx, device_get_nameu | |||
- "rtc", MTX_SPIN) | |||
-#define AML_RTC_LOCK_DES | |||
- | |||
-#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 | |||
-#define AML_RTC_MSR_CA (1 << 17) | |||
-#define AML_RTC_MSR_DURA | |||
-#define AML_RTC_MSR_DURA | |||
-#define AML_RTC_MSR_DURA | |||
-#define AML_RTC_4_REG 16 | |||
- | |||
-#define AML_RTC_TIME_SRE | |||
-#define AML_RTC_GPO_SREG | |||
-#define AML_RTC_GPO_LEVE | |||
-#define AML_RTC_GPO_BUSY | |||
-#define AML_RTC_GPO_ACTI | |||
-#define AML_RTC_GPO_CMD_ | |||
-#define AML_RTC_GPO_CMD_ | |||
-#define AML_RTC_GPO_CMD_ | |||
-#define AML_RTC_GPO_CMD_ | |||
-#define AML_RTC_GPO_CMD_ | |||
-#define AML_RTC_GPO_CNT_ | |||
-#define AML_RTC_GPO_CNT_ | |||
- | |||
-#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_BARRIE | |||
- | |||
-static int | |||
-aml8726_rtc_star | |||
-{ | |||
- 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 | |||
-{ | |||
- | |||
- 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 | |||
-{ | |||
- | |||
- 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 | |||
-} | |||
- | |||
-static inline void | |||
-aml8726_rtc_send | |||
-{ | |||
- 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 | |||
- } | |||
-} | |||
- | |||
-static inline void | |||
-aml8726_rtc_send | |||
-{ | |||
- unsigned mask; | |||
- | |||
- for (mask = 1U << 31; mask; mask >>= 1) | |||
- aml8726_rtc_send | |||
-} | |||
- | |||
-static inline void | |||
-aml8726_rtc_recv | |||
-{ | |||
- uint32_t data; | |||
- unsigned i; | |||
- | |||
- data = 0; | |||
- | |||
- for (i = 0; i < 32; i++) { | |||
- aml8726_rtc_sclk | |||
- data <<= 1; | |||
- data |= (CSR_READ_4(sc, AML_RTC_1_REG) & AML_RTC_SDO) ? 1 : 0; | |||
- } | |||
- | |||
- *dp = data; | |||
-} | |||
- | |||
-static int | |||
-aml8726_rtc_sreg | |||
-{ | |||
- u_char addr; | |||
- int error; | |||
- | |||
- /* read is indicated by lsb = 0 */ | |||
- addr = (sreg << 1) | 0; | |||
- | |||
- error = aml8726_rtc_star | |||
- | |||
- if (error) | |||
- return (error); | |||
- | |||
- aml8726_rtc_send | |||
- aml8726_rtc_recv | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_rtc_sreg | |||
-{ | |||
- u_char addr; | |||
- int error; | |||
- | |||
- /* write is indicated by lsb = 1 */ | |||
- addr = (sreg << 1) | 1; | |||
- | |||
- error = aml8726_rtc_star | |||
- | |||
- if (error) | |||
- return (error); | |||
- | |||
- aml8726_rtc_send | |||
- aml8726_rtc_send | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_rtc_init | |||
-{ | |||
- 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 | |||
- sc->init.gpo); | |||
- | |||
- if (error) | |||
- return (error); | |||
- } | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_rtc_chec | |||
-{ | |||
- 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_prob | |||
-{ | |||
- | |||
- if (!ofw_bus_status_o | |||
- return (ENXIO); | |||
- | |||
- if (!ofw_bus_is_compa | |||
- return (ENXIO); | |||
- | |||
- device_set_desc(dev, "Amlogic aml8726 RTC"); | |||
- | |||
- return (BUS_PROBE_DEFAUL | |||
-} | |||
- | |||
-static int | |||
-aml8726_rtc_atta | |||
-{ | |||
- struct aml8726_rtc_soft | |||
- | |||
- sc->dev = dev; | |||
- | |||
- switch (aml8726_soc_hw_r | |||
- case AML_SOC_HW_REV_M | |||
- sc->init.always = true; | |||
- sc->init.xo = 0x3c0a; | |||
- sc->init.gpo = 0x100000; | |||
- break; | |||
- case AML_SOC_HW_REV_M | |||
- case AML_SOC_HW_REV_M | |||
- case AML_SOC_HW_REV_M | |||
- 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_resour | |||
- device_printf(dev, "can not allocate resources for device\n"); | |||
- return (ENXIO); | |||
- } | |||
- | |||
- aml8726_rtc_init | |||
- | |||
- if (aml8726_rtc_chec | |||
- device_printf(dev, "crystal oscillator check failed\n"); | |||
- | |||
- bus_release_reso | |||
- | |||
- return (ENXIO); | |||
- } | |||
- | |||
- AML_RTC_LOCK_INI | |||
- | |||
- clock_register(dev, 1000000); | |||
- | |||
- return (0); | |||
-} | |||
- | |||
-static int | |||
-aml8726_rtc_deta | |||
-{ | |||
- | |||
- return (EBUSY); | |||
-} | |||
- | |||
-static int | |||
-aml8726_rtc_gett | |||
-{ | |||
- struct aml8726_rtc_soft | |||
- uint32_t sec; | |||
- int error; | |||
- | |||
- AML_RTC_LOCK(sc); | |||
- | |||
- error = aml8726_rtc_sreg | |||
- | |||
- AML_RTC_UNLOCK(sc); | |||
- | |||
- ts->tv_sec = sec; | |||
- ts->tv_nsec = 0; | |||
- | |||
- return (error); | |||
-} | |||
- | |||
-static int | |||
-aml8726_rtc_sett | |||
-{ | |||
- struct aml8726_rtc_soft | |||
- 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 | |||
- | |||
- AML_RTC_UNLOCK(sc); | |||
- | |||
- return (error); | |||
-} | |||
- | |||
-static device_method_t aml8726_rtc_meth | |||
- /* Device interface */ | |||
- DEVMETHOD(device_probe, aml8726_rtc_prob | |||
- DEVMETHOD(device_attach, aml8726_rtc_atta | |||
- DEVMETHOD(device_detach, aml8726_rtc_deta | |||
- | |||
- /* Clock interface */ | |||
- DEVMETHOD(clock_gettime, aml8726_rtc_gett | |||
- DEVMETHOD(clock_settime, aml8726_rtc_sett | |||
- | |||
- DEVMETHOD_END | |||
-}; | |||
- | |||
-static driver_t aml8726_rtc_driv | |||
- "rtc", | |||
- aml8726_rtc_meth | |||
- sizeof(struct aml8726_rtc_soft | |||
-}; | |||
- | |||
-static devclass_t aml8726_rtc_devc | |||
- | |||
-DRIVER_MODULE(rtc, simplebus, aml8726_rtc_driv |
@@ -1,1395 +0,0 @@ | |||
-/*- | |||
[diff truncated] |