Merge Official Source
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
commit
b0919e9a81
@ -1,2 +1,2 @@
|
||||
LINUX_VERSION-6.6 = .27
|
||||
LINUX_KERNEL_HASH-6.6.27 = 639e50060e3c8f23ed017cb10cfeacc6ba88ff5583812bb76859b4cc6a128291
|
||||
LINUX_VERSION-6.6 = .28
|
||||
LINUX_KERNEL_HASH-6.6.28 = 818716ed13e7dba6aaeae24e3073993e260812ed128d10272e94b922ee6d3394
|
||||
|
||||
@ -32,6 +32,30 @@ xor() {
|
||||
printf "%0${retlen}x" "$ret"
|
||||
}
|
||||
|
||||
data_2bin() {
|
||||
local data=$1
|
||||
local len=${#1}
|
||||
local bin_data
|
||||
|
||||
for i in $(seq 0 2 $(($len - 1))); do
|
||||
bin_data="${bin_data}\x${data:i:2}"
|
||||
done
|
||||
|
||||
echo -ne $bin_data
|
||||
}
|
||||
|
||||
data_2xor_val() {
|
||||
local data=$1
|
||||
local len=${#1}
|
||||
local xor_data
|
||||
|
||||
for i in $(seq 0 4 $(($len - 1))); do
|
||||
xor_data="${xor_data}${data:i:4} "
|
||||
done
|
||||
|
||||
echo -n ${xor_data:0:-1}
|
||||
}
|
||||
|
||||
append() {
|
||||
local var="$1"
|
||||
local value="$2"
|
||||
|
||||
@ -70,7 +70,7 @@ caldata_extract_reverse() {
|
||||
local caldata
|
||||
|
||||
mtd=$(find_mtd_chardev "$part")
|
||||
reversed=$(hexdump -v -s $offset -n $count -e '/1 "%02x "' $mtd)
|
||||
reversed=$(hexdump -v -s $offset -n $count -e '1/1 "%02x "' $mtd)
|
||||
|
||||
for byte in $reversed; do
|
||||
caldata="\x${byte}${caldata}"
|
||||
@ -122,49 +122,43 @@ caldata_valid() {
|
||||
return $?
|
||||
}
|
||||
|
||||
caldata_patch_chksum() {
|
||||
local mac=$1
|
||||
local mac_offset=$(($2))
|
||||
caldata_patch_data() {
|
||||
local data=$1
|
||||
local data_count=$((${#1} / 2))
|
||||
local data_offset=$(($2))
|
||||
local chksum_offset=$(($3))
|
||||
local target=$4
|
||||
local xor_mac
|
||||
local xor_fw_mac
|
||||
local xor_fw_chksum
|
||||
local fw_data
|
||||
local fw_chksum
|
||||
|
||||
xor_mac=${mac//:/}
|
||||
xor_mac="${xor_mac:0:4} ${xor_mac:4:4} ${xor_mac:8:4}"
|
||||
|
||||
xor_fw_mac=$(hexdump -v -n 6 -s $mac_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
|
||||
xor_fw_mac="${xor_fw_mac:0:4} ${xor_fw_mac:4:4} ${xor_fw_mac:8:4}"
|
||||
|
||||
xor_fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '/1 "%02x"' /lib/firmware/$FIRMWARE)
|
||||
xor_fw_chksum=$(xor $xor_fw_chksum $xor_fw_mac $xor_mac)
|
||||
|
||||
printf "%b" "\x${xor_fw_chksum:0:2}\x${xor_fw_chksum:2:2}" | \
|
||||
dd of=$target conv=notrunc bs=1 seek=$chksum_offset count=2
|
||||
}
|
||||
|
||||
caldata_patch_mac() {
|
||||
local mac=$1
|
||||
local mac_offset=$(($2))
|
||||
local chksum_offset=$3
|
||||
local target=$4
|
||||
|
||||
[ -z "$mac" -o -z "$mac_offset" ] && return
|
||||
[ -z "$data" -o -z "$data_offset" ] && return
|
||||
|
||||
[ -n "$target" ] || target=/lib/firmware/$FIRMWARE
|
||||
|
||||
[ -n "$chksum_offset" ] && caldata_patch_chksum "$mac" "$mac_offset" "$chksum_offset" "$target"
|
||||
fw_data=$(hexdump -v -n $data_count -s $data_offset -e '1/1 "%02x"' $target)
|
||||
|
||||
macaddr_2bin $mac | dd of=$target conv=notrunc oflag=seek_bytes bs=6 seek=$mac_offset count=1 || \
|
||||
caldata_die "failed to write MAC address to eeprom file"
|
||||
if [ "$data" != "$fw_data" ]; then
|
||||
|
||||
if [ -n "$chksum_offset" ]; then
|
||||
fw_chksum=$(hexdump -v -n 2 -s $chksum_offset -e '1/1 "%02x"' $target)
|
||||
fw_chksum=$(xor $fw_chksum $(data_2xor_val $fw_data) $(data_2xor_val $data))
|
||||
|
||||
data_2bin $fw_chksum | \
|
||||
dd of=$target conv=notrunc bs=1 seek=$chksum_offset count=2 || \
|
||||
caldata_die "failed to write chksum to eeprom file"
|
||||
fi
|
||||
|
||||
data_2bin $data | \
|
||||
dd of=$target conv=notrunc bs=1 seek=$data_offset count=$data_count || \
|
||||
caldata_die "failed to write data to eeprom file"
|
||||
fi
|
||||
}
|
||||
|
||||
ath9k_patch_mac() {
|
||||
local mac=$1
|
||||
local target=$2
|
||||
|
||||
caldata_patch_mac "$mac" 0x2 "" "$target"
|
||||
caldata_patch_data "${mac//:/}" 0x2 "" "$target"
|
||||
}
|
||||
|
||||
ath9k_patch_mac_crc() {
|
||||
@ -173,12 +167,52 @@ ath9k_patch_mac_crc() {
|
||||
local chksum_offset=$((mac_offset - 10))
|
||||
local target=$4
|
||||
|
||||
caldata_patch_mac "$mac" "$mac_offset" "$chksum_offset" "$target"
|
||||
caldata_patch_data "${mac//:/}" "$mac_offset" "$chksum_offset" "$target"
|
||||
}
|
||||
|
||||
ath10k_patch_mac() {
|
||||
local mac=$1
|
||||
local target=$2
|
||||
|
||||
caldata_patch_mac "$mac" 0x6 0x2 "$target"
|
||||
caldata_patch_data "${mac//:/}" 0x6 0x2 "$target"
|
||||
}
|
||||
|
||||
ath11k_patch_mac() {
|
||||
local mac=$1
|
||||
# mac_id from 0 to 5
|
||||
local mac_id=$2
|
||||
local target=$3
|
||||
|
||||
[ -z "$mac_id" ] && return
|
||||
|
||||
caldata_patch_data "${mac//:/}" $(printf "0x%x" $(($mac_id * 0x6 + 0xe))) 0xa "$target"
|
||||
}
|
||||
|
||||
ath10k_remove_regdomain() {
|
||||
local target=$1
|
||||
|
||||
caldata_patch_data "0000" 0xc 0x2 "$target"
|
||||
}
|
||||
|
||||
ath11k_remove_regdomain() {
|
||||
local target=$1
|
||||
local regdomain
|
||||
local regdomain_data
|
||||
|
||||
regdomain=$(hexdump -v -n 2 -s 0x34 -e '1/1 "%02x"' $target)
|
||||
caldata_patch_data "0000" 0x34 0xa "$target"
|
||||
|
||||
for offset in 0x450 0x458 0x500 0x5a8; do
|
||||
regdomain_data=$(hexdump -v -n 2 -s $offset -e '1/1 "%02x"' $target)
|
||||
|
||||
if [ "$regdomain" == "$regdomain_data" ]; then
|
||||
caldata_patch_data "0000" $offset 0xa "$target"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
ath11k_set_macflag() {
|
||||
local target=$1
|
||||
|
||||
caldata_patch_data "0100" 0x3e 0xa "$target"
|
||||
}
|
||||
|
||||
@ -279,12 +279,6 @@ macaddr_random() {
|
||||
echo "$(macaddr_unsetbit_mc "$(macaddr_setbit_la "${randsrc}")")"
|
||||
}
|
||||
|
||||
macaddr_2bin() {
|
||||
local mac=$1
|
||||
|
||||
echo -ne \\x${mac//:/\\x}
|
||||
}
|
||||
|
||||
macaddr_canonicalize() {
|
||||
local mac="$1"
|
||||
local canon=""
|
||||
|
||||
@ -59,6 +59,11 @@ qnap,301w)
|
||||
[ -n "$idx" ] && \
|
||||
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x20000" "0x20000" "1"
|
||||
;;
|
||||
spectrum,sax1v1k)
|
||||
mmcpart="$(find_mmc_part 0:APPSBLENV)"
|
||||
[ -n "$mmcpart" ] && \
|
||||
ubootenv_add_uci_config "$mmcpart" "0x0" "0x40000" "0x40000" "1"
|
||||
;;
|
||||
esac
|
||||
|
||||
config_load ubootenv
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_VERSION:=2014.10
|
||||
PKG_RELEASE:=16
|
||||
|
||||
PKG_HASH:=d3b132a7a9b3f3182b7aad71c2dfbd4fc15bea83e12c76134eb3ffefc07d1c71
|
||||
|
||||
include $(INCLUDE_DIR)/u-boot.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define U-Boot/Default
|
||||
BUILD_TARGET:=oxnas
|
||||
BUILD_DEVICES:=Default
|
||||
HIDDEN:=y
|
||||
endef
|
||||
|
||||
define U-Boot/ox820
|
||||
NAME:=Oxford/PLX NAS7820
|
||||
endef
|
||||
|
||||
UBOOT_TARGETS:=ox820
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
|
||||
$(CP) $(PKG_BUILD_DIR)/u-boot.bin $(STAGING_DIR_IMAGE)/u-boot.bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage/U-Boot))
|
||||
@ -1,37 +0,0 @@
|
||||
From df9fb90120423c4c55b66a5dc09af23f605a406b Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Mon, 1 Dec 2014 21:37:25 +0100
|
||||
Subject: [PATCH] disk/part.c: use unsigned format when printing capacity
|
||||
To: u-boot@lists.denx.de
|
||||
|
||||
Large disks otherwise produce highly unplausible output such as
|
||||
Capacity: 1907729.0 MB = 1863.0 GB (-387938128 x 512)
|
||||
|
||||
As supposedly all size-related decimals are unsigned, use unsigned
|
||||
format in printf statement, resulting in a correct capacity being
|
||||
displayed:
|
||||
Capacity: 1907729.0 MB = 1863.0 GB (3907029168 x 512)
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
disk/part.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/disk/part.c
|
||||
+++ b/disk/part.c
|
||||
@@ -229,13 +229,13 @@ void dev_print (block_dev_desc_t *dev_de
|
||||
printf (" Supports 48-bit addressing\n");
|
||||
#endif
|
||||
#if defined(CONFIG_SYS_64BIT_LBA)
|
||||
- printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%Ld x %ld)\n",
|
||||
+ printf (" Capacity: %lu.%lu MB = %lu.%lu GB (%Lu x %lu)\n",
|
||||
mb_quot, mb_rem,
|
||||
gb_quot, gb_rem,
|
||||
lba,
|
||||
dev_desc->blksz);
|
||||
#else
|
||||
- printf (" Capacity: %ld.%ld MB = %ld.%ld GB (%ld x %ld)\n",
|
||||
+ printf (" Capacity: %lu.%lu MB = %lu.%lu GB (%lu x %lu)\n",
|
||||
mb_quot, mb_rem,
|
||||
gb_quot, gb_rem,
|
||||
(ulong)lba,
|
||||
@ -1,52 +0,0 @@
|
||||
--- a/tools/socfpgaimage.c
|
||||
+++ b/tools/socfpgaimage.c
|
||||
@@ -74,12 +74,12 @@ static uint16_t hdr_checksum(struct socf
|
||||
static void build_header(uint8_t *buf, uint8_t version, uint8_t flags,
|
||||
uint16_t length_bytes)
|
||||
{
|
||||
- header.validation = htole32(VALIDATION_WORD);
|
||||
+ header.validation = cpu_to_le32(VALIDATION_WORD);
|
||||
header.version = version;
|
||||
header.flags = flags;
|
||||
- header.length_u32 = htole16(length_bytes/4);
|
||||
+ header.length_u32 = cpu_to_le16(length_bytes/4);
|
||||
header.zero = 0;
|
||||
- header.checksum = htole16(hdr_checksum(&header));
|
||||
+ header.checksum = cpu_to_le16(hdr_checksum(&header));
|
||||
|
||||
memcpy(buf, &header, sizeof(header));
|
||||
}
|
||||
@@ -92,12 +92,12 @@ static int verify_header(const uint8_t *
|
||||
{
|
||||
memcpy(&header, buf, sizeof(header));
|
||||
|
||||
- if (le32toh(header.validation) != VALIDATION_WORD)
|
||||
+ if (le32_to_cpu(header.validation) != VALIDATION_WORD)
|
||||
return -1;
|
||||
- if (le16toh(header.checksum) != hdr_checksum(&header))
|
||||
+ if (le16_to_cpu(header.checksum) != hdr_checksum(&header))
|
||||
return -1;
|
||||
|
||||
- return le16toh(header.length_u32) * 4;
|
||||
+ return le16_to_cpu(header.length_u32) * 4;
|
||||
}
|
||||
|
||||
/* Sign the buffer and return the signed buffer size */
|
||||
@@ -116,7 +116,7 @@ static int sign_buffer(uint8_t *buf,
|
||||
/* Calculate and apply the CRC */
|
||||
calc_crc = ~pbl_crc32(0, (char *)buf, len);
|
||||
|
||||
- *((uint32_t *)(buf + len)) = htole32(calc_crc);
|
||||
+ *((uint32_t *)(buf + len)) = cpu_to_le32(calc_crc);
|
||||
|
||||
if (!pad_64k)
|
||||
return len + 4;
|
||||
@@ -150,7 +150,7 @@ static int verify_buffer(const uint8_t *
|
||||
|
||||
calc_crc = ~pbl_crc32(0, (const char *)buf, len);
|
||||
|
||||
- buf_crc = le32toh(*((uint32_t *)(buf + len)));
|
||||
+ buf_crc = le32_to_cpu(*((uint32_t *)(buf + len)));
|
||||
|
||||
if (buf_crc != calc_crc) {
|
||||
fprintf(stderr, "CRC32 does not match (%08x != %08x)\n",
|
||||
@ -1,54 +0,0 @@
|
||||
--- a/common/spl/Makefile
|
||||
+++ b/common/spl/Makefile
|
||||
@@ -19,4 +19,5 @@ obj-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc
|
||||
obj-$(CONFIG_SPL_USB_SUPPORT) += spl_usb.o
|
||||
obj-$(CONFIG_SPL_FAT_SUPPORT) += spl_fat.o
|
||||
obj-$(CONFIG_SPL_SATA_SUPPORT) += spl_sata.o
|
||||
+obj-$(CONFIG_SPL_BLOCK_SUPPORT) += spl_block.o
|
||||
endif
|
||||
--- a/common/spl/spl.c
|
||||
+++ b/common/spl/spl.c
|
||||
@@ -191,6 +191,14 @@ void board_init_r(gd_t *dummy1, ulong du
|
||||
spl_spi_load_image();
|
||||
break;
|
||||
#endif
|
||||
+#ifdef CONFIG_SPL_BLOCK_SUPPORT
|
||||
+ case BOOT_DEVICE_BLOCK:
|
||||
+ {
|
||||
+ extern void spl_block_load_image(void);
|
||||
+ spl_block_load_image();
|
||||
+ break;
|
||||
+ }
|
||||
+#endif
|
||||
#ifdef CONFIG_SPL_ETH_SUPPORT
|
||||
case BOOT_DEVICE_CPGMAC:
|
||||
#ifdef CONFIG_SPL_ETH_DEVICE
|
||||
--- a/common/cmd_nvedit.c
|
||||
+++ b/common/cmd_nvedit.c
|
||||
@@ -49,6 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||
!defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
|
||||
!defined(CONFIG_ENV_IS_IN_REMOTE) && \
|
||||
!defined(CONFIG_ENV_IS_IN_UBI) && \
|
||||
+ !defined(CONFIG_ENV_IS_IN_EXT4) && \
|
||||
!defined(CONFIG_ENV_IS_NOWHERE)
|
||||
# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
|
||||
SPI_FLASH|NVRAM|MMC|FAT|REMOTE|UBI} or CONFIG_ENV_IS_NOWHERE
|
||||
--- a/common/Makefile
|
||||
+++ b/common/Makefile
|
||||
@@ -63,6 +63,7 @@ obj-$(CONFIG_ENV_IS_IN_ONENAND) += env_o
|
||||
obj-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
|
||||
obj-$(CONFIG_ENV_IS_IN_REMOTE) += env_remote.o
|
||||
obj-$(CONFIG_ENV_IS_IN_UBI) += env_ubi.o
|
||||
+obj-$(CONFIG_ENV_IS_IN_EXT4) += env_ext4.o
|
||||
obj-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
|
||||
|
||||
# command
|
||||
@@ -213,6 +214,8 @@ obj-$(CONFIG_UPDATE_TFTP) += update.o
|
||||
obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
|
||||
obj-$(CONFIG_CMD_DFU) += cmd_dfu.o
|
||||
obj-$(CONFIG_CMD_GPT) += cmd_gpt.o
|
||||
+else
|
||||
+obj-$(CONFIG_SPL_BLOCK_SUPPORT) += cmd_ide.o
|
||||
endif
|
||||
|
||||
ifdef CONFIG_SPL_BUILD
|
||||
@ -1,142 +0,0 @@
|
||||
From e719404ee1241af679a51879eaad291bc27e4817 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 2 Dec 2014 14:46:05 +0100
|
||||
Subject: [PATCH] net/phy: add back icplus driver
|
||||
|
||||
IC+ phy driver was removed due to the lack of users some time ago.
|
||||
Add it back, so we can use it.
|
||||
---
|
||||
drivers/net/phy/Makefile | 1 +
|
||||
drivers/net/phy/icplus.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
drivers/net/phy/phy.c | 3 ++
|
||||
3 files changed, 84 insertions(+)
|
||||
create mode 100644 drivers/net/phy/icplus.c
|
||||
|
||||
--- a/drivers/net/phy/Makefile
|
||||
+++ b/drivers/net/phy/Makefile
|
||||
@@ -15,6 +15,7 @@ obj-$(CONFIG_PHY_ATHEROS) += atheros.o
|
||||
obj-$(CONFIG_PHY_BROADCOM) += broadcom.o
|
||||
obj-$(CONFIG_PHY_DAVICOM) += davicom.o
|
||||
obj-$(CONFIG_PHY_ET1011C) += et1011c.o
|
||||
+obj-$(CONFIG_PHY_ICPLUS) += icplus.o
|
||||
obj-$(CONFIG_PHY_LXT) += lxt.o
|
||||
obj-$(CONFIG_PHY_MARVELL) += marvell.o
|
||||
obj-$(CONFIG_PHY_MICREL) += micrel.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/phy/icplus.c
|
||||
@@ -0,0 +1,93 @@
|
||||
+/*
|
||||
+ * ICPlus PHY drivers
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: GPL-2.0+
|
||||
+ *
|
||||
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
|
||||
+ */
|
||||
+#include <phy.h>
|
||||
+
|
||||
+/* IP101A/G - IP1001 */
|
||||
+#define IP10XX_SPEC_CTRL_STATUS 16 /* Spec. Control Register */
|
||||
+#define IP1001_SPEC_CTRL_STATUS_2 20 /* IP1001 Spec. Control Reg 2 */
|
||||
+#define IP1001_PHASE_SEL_MASK 3 /* IP1001 RX/TXPHASE_SEL */
|
||||
+#define IP1001_APS_ON 11 /* IP1001 APS Mode bit */
|
||||
+#define IP101A_G_APS_ON 2 /* IP101A/G APS Mode bit */
|
||||
+#define IP101A_G_IRQ_CONF_STATUS 0x11 /* Conf Info IRQ & Status Reg */
|
||||
+#define IP101A_G_IRQ_PIN_USED (1<<15) /* INTR pin used */
|
||||
+#define IP101A_G_IRQ_DEFAULT IP101A_G_IRQ_PIN_USED
|
||||
+#define IP1001LF_DRIVE_MASK (15 << 5)
|
||||
+#define IP1001LF_RXCLKDRIVE_HI (2 << 5)
|
||||
+#define IP1001LF_RXDDRIVE_HI (2 << 7)
|
||||
+#define IP1001LF_RXCLKDRIVE_M (1 << 5)
|
||||
+#define IP1001LF_RXDDRIVE_M (1 << 7)
|
||||
+#define IP1001LF_RXCLKDRIVE_L (0 << 5)
|
||||
+#define IP1001LF_RXDDRIVE_L (0 << 7)
|
||||
+#define IP1001LF_RXCLKDRIVE_VL (3 << 5)
|
||||
+#define IP1001LF_RXDDRIVE_VL (3 << 7)
|
||||
+
|
||||
+static int ip1001_config(struct phy_device *phydev)
|
||||
+{
|
||||
+ int c;
|
||||
+
|
||||
+ /* Enable Auto Power Saving mode */
|
||||
+ c = phy_read(phydev, MDIO_DEVAD_NONE, IP1001_SPEC_CTRL_STATUS_2);
|
||||
+ if (c < 0)
|
||||
+ return c;
|
||||
+ c |= IP1001_APS_ON;
|
||||
+ c = phy_write(phydev, MDIO_DEVAD_NONE, IP1001_SPEC_CTRL_STATUS_2, c);
|
||||
+ if (c < 0)
|
||||
+ return c;
|
||||
+
|
||||
+ /* INTR pin used: speed/link/duplex will cause an interrupt */
|
||||
+ c = phy_write(phydev, MDIO_DEVAD_NONE, IP101A_G_IRQ_CONF_STATUS,
|
||||
+ IP101A_G_IRQ_DEFAULT);
|
||||
+ if (c < 0)
|
||||
+ return c;
|
||||
+
|
||||
+ if (phydev->interface == PHY_INTERFACE_MODE_RGMII) {
|
||||
+ /*
|
||||
+ * Additional delay (2ns) used to adjust RX clock phase
|
||||
+ * at RGMII interface
|
||||
+ */
|
||||
+ c = phy_read(phydev, MDIO_DEVAD_NONE, IP10XX_SPEC_CTRL_STATUS);
|
||||
+ if (c < 0)
|
||||
+ return c;
|
||||
+
|
||||
+ c |= IP1001_PHASE_SEL_MASK;
|
||||
+ /* adjust digtial drive strength */
|
||||
+ c &= ~IP1001LF_DRIVE_MASK;
|
||||
+ c |= IP1001LF_RXCLKDRIVE_M;
|
||||
+ c |= IP1001LF_RXDDRIVE_M;
|
||||
+ c = phy_write(phydev, MDIO_DEVAD_NONE, IP10XX_SPEC_CTRL_STATUS,
|
||||
+ c);
|
||||
+ if (c < 0)
|
||||
+ return c;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int ip1001_startup(struct phy_device *phydev)
|
||||
+{
|
||||
+ genphy_update_link(phydev);
|
||||
+ genphy_parse_link(phydev);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+static struct phy_driver IP1001_driver = {
|
||||
+ .name = "ICPlus IP1001",
|
||||
+ .uid = 0x02430d90,
|
||||
+ .mask = 0x0ffffff0,
|
||||
+ .features = PHY_GBIT_FEATURES,
|
||||
+ .config = &ip1001_config,
|
||||
+ .startup = &ip1001_startup,
|
||||
+ .shutdown = &genphy_shutdown,
|
||||
+};
|
||||
+
|
||||
+int phy_icplus_init(void)
|
||||
+{
|
||||
+ phy_register(&IP1001_driver);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
--- a/drivers/net/phy/phy.c
|
||||
+++ b/drivers/net/phy/phy.c
|
||||
@@ -454,6 +454,9 @@ int phy_init(void)
|
||||
#ifdef CONFIG_PHY_ET1011C
|
||||
phy_et1011c_init();
|
||||
#endif
|
||||
+#ifdef CONFIG_PHY_ICPLUS
|
||||
+ phy_icplus_init();
|
||||
+#endif
|
||||
#ifdef CONFIG_PHY_LXT
|
||||
phy_lxt_init();
|
||||
#endif
|
||||
--- a/include/phy.h
|
||||
+++ b/include/phy.h
|
||||
@@ -225,6 +225,7 @@ int phy_atheros_init(void);
|
||||
int phy_broadcom_init(void);
|
||||
int phy_davicom_init(void);
|
||||
int phy_et1011c_init(void);
|
||||
+int phy_icplus_init(void);
|
||||
int phy_lxt_init(void);
|
||||
int phy_marvell_init(void);
|
||||
int phy_micrel_init(void);
|
||||
@ -1,101 +0,0 @@
|
||||
--- a/arch/arm/include/asm/mach-types.h
|
||||
+++ b/arch/arm/include/asm/mach-types.h
|
||||
@@ -212,6 +212,7 @@ extern unsigned int __machine_arch_type;
|
||||
#define MACH_TYPE_EDB9307A 1128
|
||||
#define MACH_TYPE_OMAP_3430SDP 1138
|
||||
#define MACH_TYPE_VSTMS 1140
|
||||
+#define MACH_TYPE_OXNAS 1152
|
||||
#define MACH_TYPE_MICRO9M 1169
|
||||
#define MACH_TYPE_BUG 1179
|
||||
#define MACH_TYPE_AT91SAM9263EK 1202
|
||||
--- a/drivers/block/Makefile
|
||||
+++ b/drivers/block/Makefile
|
||||
@@ -21,3 +21,4 @@ obj-$(CONFIG_IDE_SIL680) += sil680.o
|
||||
obj-$(CONFIG_SANDBOX) += sandbox.o
|
||||
obj-$(CONFIG_SCSI_SYM53C8XX) += sym53c8xx.o
|
||||
obj-$(CONFIG_SYSTEMACE) += systemace.o
|
||||
+obj-$(CONFIG_IDE_PLX) += plxsata_ide.o
|
||||
--- a/drivers/usb/host/Makefile
|
||||
+++ b/drivers/usb/host/Makefile
|
||||
@@ -33,6 +33,7 @@ obj-$(CONFIG_USB_EHCI_MX6) += ehci-mx6.o
|
||||
obj-$(CONFIG_USB_EHCI_OMAP) += ehci-omap.o
|
||||
obj-$(CONFIG_USB_EHCI_PPC4XX) += ehci-ppc4xx.o
|
||||
obj-$(CONFIG_USB_EHCI_MARVELL) += ehci-marvell.o
|
||||
+obj-$(CONFIG_USB_EHCI_OXNAS) += ehci-oxnas.o
|
||||
obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
|
||||
obj-$(CONFIG_USB_EHCI_SPEAR) += ehci-spear.o
|
||||
obj-$(CONFIG_USB_EHCI_SUNXI) += ehci-sunxi.o
|
||||
--- a/tools/.gitignore
|
||||
+++ b/tools/.gitignore
|
||||
@@ -9,6 +9,7 @@
|
||||
/mkenvimage
|
||||
/mkimage
|
||||
/mkexynosspl
|
||||
+/mkox820crc
|
||||
/mpc86x_clk
|
||||
/mxsboot
|
||||
/mksunxiboot
|
||||
--- a/tools/Makefile
|
||||
+++ b/tools/Makefile
|
||||
@@ -143,6 +143,12 @@ hostprogs-$(CONFIG_KIRKWOOD) += kwboot
|
||||
hostprogs-y += proftool
|
||||
hostprogs-$(CONFIG_STATIC_RELA) += relocate-rela
|
||||
|
||||
+
|
||||
+hostprogs-$(CONFIG_OX820) += mkox820crc$(SFX)
|
||||
+
|
||||
+mkox820crc$(SFX)-objs := mkox820crc.o lib/crc32.o
|
||||
+
|
||||
+
|
||||
# We build some files with extra pedantic flags to try to minimize things
|
||||
# that won't build on some weird host compiler -- though there are lots of
|
||||
# exceptions for files that aren't complaint.
|
||||
--- a/drivers/serial/ns16550.c
|
||||
+++ b/drivers/serial/ns16550.c
|
||||
@@ -118,6 +118,14 @@ int ns16550_calc_divisor(NS16550_t port,
|
||||
}
|
||||
port->osc_12m_sel = 0; /* clear if previsouly set */
|
||||
#endif
|
||||
+#ifdef CONFIG_OX820
|
||||
+ {
|
||||
+ /* with additional 3 bit fractional */
|
||||
+ u32 div = (CONFIG_SYS_NS16550_CLK + baudrate) / (baudrate * 2);
|
||||
+ port->reg9 = (div & 7) << 5;
|
||||
+ return (div >> 3);
|
||||
+ }
|
||||
+#endif
|
||||
|
||||
return DIV_ROUND_CLOSEST(clock, mode_x_div * baudrate);
|
||||
}
|
||||
--- a/scripts/Makefile.spl
|
||||
+++ b/scripts/Makefile.spl
|
||||
@@ -202,6 +202,9 @@ OBJCOPYFLAGS_$(SPL_BIN).bin = $(SPL_OBJC
|
||||
|
||||
$(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN) FORCE
|
||||
$(call if_changed,objcopy)
|
||||
+ifdef CONFIG_OX820
|
||||
+ $(OBJTREE)/tools/mkox820crc $@
|
||||
+endif
|
||||
|
||||
LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
|
||||
ifneq ($(CONFIG_SPL_TEXT_BASE),)
|
||||
--- a/arch/arm/Kconfig
|
||||
+++ b/arch/arm/Kconfig
|
||||
@@ -488,6 +488,9 @@ config TARGET_BALLOON3
|
||||
config TARGET_H2200
|
||||
bool "Support h2200"
|
||||
|
||||
+config TARGET_OX820
|
||||
+ bool "Support ox820"
|
||||
+
|
||||
config TARGET_PALMLD
|
||||
bool "Support palmld"
|
||||
|
||||
@@ -650,6 +653,7 @@ source "board/logicpd/imx27lite/Kconfig"
|
||||
source "board/logicpd/imx31_litekit/Kconfig"
|
||||
source "board/mpl/vcma9/Kconfig"
|
||||
source "board/olimex/mx23_olinuxino/Kconfig"
|
||||
+source "board/ox820/Kconfig"
|
||||
source "board/palmld/Kconfig"
|
||||
source "board/palmtc/Kconfig"
|
||||
source "board/palmtreo680/Kconfig"
|
||||
@ -1,87 +0,0 @@
|
||||
From: Hans de Goede <hdegoede@redhat.com>
|
||||
Date: Sat, 7 Feb 2015 21:52:40 +0000 (+0100)
|
||||
Subject: Add linux/compiler-gcc5.h to fix builds with gcc5
|
||||
X-Git-Tag: v2015.04-rc2~31
|
||||
X-Git-Url: http://git.denx.de/?p=u-boot.git;a=commitdiff_plain;h=478b02f1a7043b673565075ea5016376f3293b23
|
||||
|
||||
Add linux/compiler-gcc5.h to fix builds with gcc5
|
||||
|
||||
Add linux/compiler-gcc5/h from the kernel sources at:
|
||||
|
||||
commit 5631b8fba640a4ab2f8a954f63a603fa34eda96b
|
||||
Author: Steven Noonan <steven@uplinklabs.net>
|
||||
Date: Sat Oct 25 15:09:42 2014 -0700
|
||||
|
||||
compiler/gcc4+: Remove inaccurate comment about 'asm goto' miscompiles
|
||||
|
||||
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
||||
---
|
||||
|
||||
--- /dev/null
|
||||
+++ b/include/linux/compiler-gcc5.h
|
||||
@@ -0,0 +1,65 @@
|
||||
+#ifndef __LINUX_COMPILER_H
|
||||
+#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
|
||||
+#endif
|
||||
+
|
||||
+#define __used __attribute__((__used__))
|
||||
+#define __must_check __attribute__((warn_unused_result))
|
||||
+#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
|
||||
+
|
||||
+/* Mark functions as cold. gcc will assume any path leading to a call
|
||||
+ to them will be unlikely. This means a lot of manual unlikely()s
|
||||
+ are unnecessary now for any paths leading to the usual suspects
|
||||
+ like BUG(), printk(), panic() etc. [but let's keep them for now for
|
||||
+ older compilers]
|
||||
+
|
||||
+ Early snapshots of gcc 4.3 don't support this and we can't detect this
|
||||
+ in the preprocessor, but we can live with this because they're unreleased.
|
||||
+ Maketime probing would be overkill here.
|
||||
+
|
||||
+ gcc also has a __attribute__((__hot__)) to move hot functions into
|
||||
+ a special section, but I don't see any sense in this right now in
|
||||
+ the kernel context */
|
||||
+#define __cold __attribute__((__cold__))
|
||||
+
|
||||
+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
|
||||
+
|
||||
+#ifndef __CHECKER__
|
||||
+# define __compiletime_warning(message) __attribute__((warning(message)))
|
||||
+# define __compiletime_error(message) __attribute__((error(message)))
|
||||
+#endif /* __CHECKER__ */
|
||||
+
|
||||
+/*
|
||||
+ * Mark a position in code as unreachable. This can be used to
|
||||
+ * suppress control flow warnings after asm blocks that transfer
|
||||
+ * control elsewhere.
|
||||
+ *
|
||||
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
|
||||
+ * this in the preprocessor, but we can live with this because they're
|
||||
+ * unreleased. Really, we need to have autoconf for the kernel.
|
||||
+ */
|
||||
+#define unreachable() __builtin_unreachable()
|
||||
+
|
||||
+/* Mark a function definition as prohibited from being cloned. */
|
||||
+#define __noclone __attribute__((__noclone__))
|
||||
+
|
||||
+/*
|
||||
+ * Tell the optimizer that something else uses this function or variable.
|
||||
+ */
|
||||
+#define __visible __attribute__((externally_visible))
|
||||
+
|
||||
+/*
|
||||
+ * GCC 'asm goto' miscompiles certain code sequences:
|
||||
+ *
|
||||
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
|
||||
+ *
|
||||
+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
|
||||
+ *
|
||||
+ * (asm goto is automatically volatile - the naming reflects this.)
|
||||
+ */
|
||||
+#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
|
||||
+
|
||||
+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
|
||||
+#define __HAVE_BUILTIN_BSWAP32__
|
||||
+#define __HAVE_BUILTIN_BSWAP64__
|
||||
+#define __HAVE_BUILTIN_BSWAP16__
|
||||
+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
|
||||
@ -1,306 +0,0 @@
|
||||
From: Hans de Goede <hdegoede@redhat.com>
|
||||
Date: Sat, 7 Feb 2015 21:52:40 +0000 (+0100)
|
||||
Subject: Add linux/compiler-gcc6.h to fix builds with gcc6
|
||||
X-Git-Tag: v2015.04-rc2~31
|
||||
X-Git-Url: http://git.denx.de/?p=u-boot.git;a=commitdiff_plain;h=478b02f1a7043b673565075ea5016376f3293b23
|
||||
|
||||
Add linux/compiler-gcc6.h to fix builds with gcc6
|
||||
|
||||
Add linux/compiler-gcc6/h from the kernel sources at:
|
||||
|
||||
commit 5631b8fba640a4ab2f8a954f63a603fa34eda96b
|
||||
Author: Steven Noonan <steven@uplinklabs.net>
|
||||
Date: Sat Oct 25 15:09:42 2014 -0700
|
||||
|
||||
compiler/gcc4+: Remove inaccurate comment about 'asm goto' miscompiles
|
||||
|
||||
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
||||
---
|
||||
|
||||
--- /dev/null
|
||||
+++ b/include/linux/compiler-gcc6.h
|
||||
@@ -0,0 +1,284 @@
|
||||
+#ifndef __LINUX_COMPILER_H
|
||||
+#error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Common definitions for all gcc versions go here.
|
||||
+ */
|
||||
+#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ + __GNUC_MINOR__ * 100 \
|
||||
+ + __GNUC_PATCHLEVEL__)
|
||||
+
|
||||
+/* Optimization barrier */
|
||||
+
|
||||
+/* The "volatile" is due to gcc bugs */
|
||||
+#define barrier() __asm__ __volatile__("": : :"memory")
|
||||
+/*
|
||||
+ * This version is i.e. to prevent dead stores elimination on @ptr
|
||||
+ * where gcc and llvm may behave differently when otherwise using
|
||||
+ * normal barrier(): while gcc behavior gets along with a normal
|
||||
+ * barrier(), llvm needs an explicit input variable to be assumed
|
||||
+ * clobbered. The issue is as follows: while the inline asm might
|
||||
+ * access any memory it wants, the compiler could have fit all of
|
||||
+ * @ptr into memory registers instead, and since @ptr never escaped
|
||||
+ * from that, it proofed that the inline asm wasn't touching any of
|
||||
+ * it. This version works well with both compilers, i.e. we're telling
|
||||
+ * the compiler that the inline asm absolutely may see the contents
|
||||
+ * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
|
||||
+ */
|
||||
+#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
|
||||
+
|
||||
+/*
|
||||
+ * This macro obfuscates arithmetic on a variable address so that gcc
|
||||
+ * shouldn't recognize the original var, and make assumptions about it.
|
||||
+ *
|
||||
+ * This is needed because the C standard makes it undefined to do
|
||||
+ * pointer arithmetic on "objects" outside their boundaries and the
|
||||
+ * gcc optimizers assume this is the case. In particular they
|
||||
+ * assume such arithmetic does not wrap.
|
||||
+ *
|
||||
+ * A miscompilation has been observed because of this on PPC.
|
||||
+ * To work around it we hide the relationship of the pointer and the object
|
||||
+ * using this macro.
|
||||
+ *
|
||||
+ * Versions of the ppc64 compiler before 4.1 had a bug where use of
|
||||
+ * RELOC_HIDE could trash r30. The bug can be worked around by changing
|
||||
+ * the inline assembly constraint from =g to =r, in this particular
|
||||
+ * case either is valid.
|
||||
+ */
|
||||
+#define RELOC_HIDE(ptr, off) \
|
||||
+({ \
|
||||
+ unsigned long __ptr; \
|
||||
+ __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \
|
||||
+ (typeof(ptr)) (__ptr + (off)); \
|
||||
+})
|
||||
+
|
||||
+/* Make the optimizer believe the variable can be manipulated arbitrarily. */
|
||||
+#define OPTIMIZER_HIDE_VAR(var) \
|
||||
+ __asm__ ("" : "=r" (var) : "0" (var))
|
||||
+
|
||||
+#ifdef __CHECKER__
|
||||
+#define __must_be_array(a) 0
|
||||
+#else
|
||||
+/* &a[0] degrades to a pointer: a different type from an array */
|
||||
+#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Force always-inline if the user requests it so via the .config,
|
||||
+ * or if gcc is too old:
|
||||
+ */
|
||||
+#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
|
||||
+ !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
|
||||
+#define inline inline __attribute__((always_inline)) notrace
|
||||
+#define __inline__ __inline__ __attribute__((always_inline)) notrace
|
||||
+#define __inline __inline __attribute__((always_inline)) notrace
|
||||
+#else
|
||||
+/* A lot of inline functions can cause havoc with function tracing */
|
||||
+#define inline inline notrace
|
||||
+#define __inline__ __inline__ notrace
|
||||
+#define __inline __inline notrace
|
||||
+#endif
|
||||
+
|
||||
+#define __always_inline inline __attribute__((always_inline))
|
||||
+#define noinline __attribute__((noinline))
|
||||
+
|
||||
+#define __deprecated __attribute__((deprecated))
|
||||
+#define __packed __attribute__((packed))
|
||||
+#define __weak __attribute__((weak))
|
||||
+#define __alias(symbol) __attribute__((alias(#symbol)))
|
||||
+
|
||||
+/*
|
||||
+ * it doesn't make sense on ARM (currently the only user of __naked)
|
||||
+ * to trace naked functions because then mcount is called without
|
||||
+ * stack and frame pointer being set up and there is no chance to
|
||||
+ * restore the lr register to the value before mcount was called.
|
||||
+ *
|
||||
+ * The asm() bodies of naked functions often depend on standard calling
|
||||
+ * conventions, therefore they must be noinline and noclone.
|
||||
+ *
|
||||
+ * GCC 4.[56] currently fail to enforce this, so we must do so ourselves.
|
||||
+ * See GCC PR44290.
|
||||
+ */
|
||||
+#define __naked __attribute__((naked)) noinline __noclone notrace
|
||||
+
|
||||
+#define __noreturn __attribute__((noreturn))
|
||||
+
|
||||
+/*
|
||||
+ * From the GCC manual:
|
||||
+ *
|
||||
+ * Many functions have no effects except the return value and their
|
||||
+ * return value depends only on the parameters and/or global
|
||||
+ * variables. Such a function can be subject to common subexpression
|
||||
+ * elimination and loop optimization just as an arithmetic operator
|
||||
+ * would be.
|
||||
+ * [...]
|
||||
+ */
|
||||
+#define __pure __attribute__((pure))
|
||||
+#define __aligned(x) __attribute__((aligned(x)))
|
||||
+#define __printf(a, b) __attribute__((format(printf, a, b)))
|
||||
+#define __scanf(a, b) __attribute__((format(scanf, a, b)))
|
||||
+#define __attribute_const__ __attribute__((__const__))
|
||||
+#define __maybe_unused __attribute__((unused))
|
||||
+#define __always_unused __attribute__((unused))
|
||||
+
|
||||
+/* gcc version specific checks */
|
||||
+
|
||||
+#if GCC_VERSION < 30200
|
||||
+# error Sorry, your compiler is too old - please upgrade it.
|
||||
+#endif
|
||||
+
|
||||
+#if GCC_VERSION < 30300
|
||||
+# define __used __attribute__((__unused__))
|
||||
+#else
|
||||
+# define __used __attribute__((__used__))
|
||||
+#endif
|
||||
+
|
||||
+#ifdef CONFIG_GCOV_KERNEL
|
||||
+# if GCC_VERSION < 30400
|
||||
+# error "GCOV profiling support for gcc versions below 3.4 not included"
|
||||
+# endif /* __GNUC_MINOR__ */
|
||||
+#endif /* CONFIG_GCOV_KERNEL */
|
||||
+
|
||||
+#if GCC_VERSION >= 30400
|
||||
+#define __must_check __attribute__((warn_unused_result))
|
||||
+#define __malloc __attribute__((__malloc__))
|
||||
+#endif
|
||||
+
|
||||
+#if GCC_VERSION >= 40000
|
||||
+
|
||||
+/* GCC 4.1.[01] miscompiles __weak */
|
||||
+#ifdef __KERNEL__
|
||||
+# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
|
||||
+# error Your version of gcc miscompiles the __weak directive
|
||||
+# endif
|
||||
+#endif
|
||||
+
|
||||
+#define __used __attribute__((__used__))
|
||||
+#define __compiler_offsetof(a, b) \
|
||||
+ __builtin_offsetof(a, b)
|
||||
+
|
||||
+#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
|
||||
+# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
|
||||
+#endif
|
||||
+
|
||||
+#if GCC_VERSION >= 40300
|
||||
+/* Mark functions as cold. gcc will assume any path leading to a call
|
||||
+ * to them will be unlikely. This means a lot of manual unlikely()s
|
||||
+ * are unnecessary now for any paths leading to the usual suspects
|
||||
+ * like BUG(), printk(), panic() etc. [but let's keep them for now for
|
||||
+ * older compilers]
|
||||
+ *
|
||||
+ * Early snapshots of gcc 4.3 don't support this and we can't detect this
|
||||
+ * in the preprocessor, but we can live with this because they're unreleased.
|
||||
+ * Maketime probing would be overkill here.
|
||||
+ *
|
||||
+ * gcc also has a __attribute__((__hot__)) to move hot functions into
|
||||
+ * a special section, but I don't see any sense in this right now in
|
||||
+ * the kernel context
|
||||
+ */
|
||||
+#define __cold __attribute__((__cold__))
|
||||
+
|
||||
+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
|
||||
+
|
||||
+#ifndef __CHECKER__
|
||||
+# define __compiletime_warning(message) __attribute__((warning(message)))
|
||||
+# define __compiletime_error(message) __attribute__((error(message)))
|
||||
+#endif /* __CHECKER__ */
|
||||
+#endif /* GCC_VERSION >= 40300 */
|
||||
+
|
||||
+#if GCC_VERSION >= 40500
|
||||
+/*
|
||||
+ * Mark a position in code as unreachable. This can be used to
|
||||
+ * suppress control flow warnings after asm blocks that transfer
|
||||
+ * control elsewhere.
|
||||
+ *
|
||||
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
|
||||
+ * this in the preprocessor, but we can live with this because they're
|
||||
+ * unreleased. Really, we need to have autoconf for the kernel.
|
||||
+ */
|
||||
+#define unreachable() __builtin_unreachable()
|
||||
+
|
||||
+/* Mark a function definition as prohibited from being cloned. */
|
||||
+#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
|
||||
+
|
||||
+#endif /* GCC_VERSION >= 40500 */
|
||||
+
|
||||
+#if GCC_VERSION >= 40600
|
||||
+/*
|
||||
+ * When used with Link Time Optimization, gcc can optimize away C functions or
|
||||
+ * variables which are referenced only from assembly code. __visible tells the
|
||||
+ * optimizer that something else uses this function or variable, thus preventing
|
||||
+ * this.
|
||||
+ */
|
||||
+#define __visible __attribute__((externally_visible))
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
+#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
|
||||
+/*
|
||||
+ * __assume_aligned(n, k): Tell the optimizer that the returned
|
||||
+ * pointer can be assumed to be k modulo n. The second argument is
|
||||
+ * optional (default 0), so we use a variadic macro to make the
|
||||
+ * shorthand.
|
||||
+ *
|
||||
+ * Beware: Do not apply this to functions which may return
|
||||
+ * ERR_PTRs. Also, it is probably unwise to apply it to functions
|
||||
+ * returning extra information in the low bits (but in that case the
|
||||
+ * compiler should see some alignment anyway, when the return value is
|
||||
+ * massaged by 'flags = ptr & 3; ptr &= ~3;').
|
||||
+ */
|
||||
+#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * GCC 'asm goto' miscompiles certain code sequences:
|
||||
+ *
|
||||
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
|
||||
+ *
|
||||
+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
|
||||
+ *
|
||||
+ * (asm goto is automatically volatile - the naming reflects this.)
|
||||
+ */
|
||||
+#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
|
||||
+
|
||||
+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
|
||||
+#if GCC_VERSION >= 40400
|
||||
+#define __HAVE_BUILTIN_BSWAP32__
|
||||
+#define __HAVE_BUILTIN_BSWAP64__
|
||||
+#endif
|
||||
+#if GCC_VERSION >= 40800
|
||||
+#define __HAVE_BUILTIN_BSWAP16__
|
||||
+#endif
|
||||
+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
|
||||
+
|
||||
+#if GCC_VERSION >= 50000
|
||||
+#define KASAN_ABI_VERSION 4
|
||||
+#elif GCC_VERSION >= 40902
|
||||
+#define KASAN_ABI_VERSION 3
|
||||
+#endif
|
||||
+
|
||||
+#if GCC_VERSION >= 40902
|
||||
+/*
|
||||
+ * Tell the compiler that address safety instrumentation (KASAN)
|
||||
+ * should not be applied to that function.
|
||||
+ * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
|
||||
+ */
|
||||
+#define __no_sanitize_address __attribute__((no_sanitize_address))
|
||||
+#endif
|
||||
+
|
||||
+#endif /* gcc version >= 40000 specific checks */
|
||||
+
|
||||
+#if !defined(__noclone)
|
||||
+#define __noclone /* not needed */
|
||||
+#endif
|
||||
+
|
||||
+#if !defined(__no_sanitize_address)
|
||||
+#define __no_sanitize_address
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * A trick to suppress uninitialized variable warning without generating any
|
||||
+ * code
|
||||
+ */
|
||||
+#define uninitialized_var(x) x = x
|
||||
@ -1,287 +0,0 @@
|
||||
--- /dev/null
|
||||
+++ b/include/linux/compiler-gcc7.h
|
||||
@@ -0,0 +1,284 @@
|
||||
+#ifndef __LINUX_COMPILER_H
|
||||
+#error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Common definitions for all gcc versions go here.
|
||||
+ */
|
||||
+#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ + __GNUC_MINOR__ * 100 \
|
||||
+ + __GNUC_PATCHLEVEL__)
|
||||
+
|
||||
+/* Optimization barrier */
|
||||
+
|
||||
+/* The "volatile" is due to gcc bugs */
|
||||
+#define barrier() __asm__ __volatile__("": : :"memory")
|
||||
+/*
|
||||
+ * This version is i.e. to prevent dead stores elimination on @ptr
|
||||
+ * where gcc and llvm may behave differently when otherwise using
|
||||
+ * normal barrier(): while gcc behavior gets along with a normal
|
||||
+ * barrier(), llvm needs an explicit input variable to be assumed
|
||||
+ * clobbered. The issue is as follows: while the inline asm might
|
||||
+ * access any memory it wants, the compiler could have fit all of
|
||||
+ * @ptr into memory registers instead, and since @ptr never escaped
|
||||
+ * from that, it proofed that the inline asm wasn't touching any of
|
||||
+ * it. This version works well with both compilers, i.e. we're telling
|
||||
+ * the compiler that the inline asm absolutely may see the contents
|
||||
+ * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
|
||||
+ */
|
||||
+#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
|
||||
+
|
||||
+/*
|
||||
+ * This macro obfuscates arithmetic on a variable address so that gcc
|
||||
+ * shouldn't recognize the original var, and make assumptions about it.
|
||||
+ *
|
||||
+ * This is needed because the C standard makes it undefined to do
|
||||
+ * pointer arithmetic on "objects" outside their boundaries and the
|
||||
+ * gcc optimizers assume this is the case. In particular they
|
||||
+ * assume such arithmetic does not wrap.
|
||||
+ *
|
||||
+ * A miscompilation has been observed because of this on PPC.
|
||||
+ * To work around it we hide the relationship of the pointer and the object
|
||||
+ * using this macro.
|
||||
+ *
|
||||
+ * Versions of the ppc64 compiler before 4.1 had a bug where use of
|
||||
+ * RELOC_HIDE could trash r30. The bug can be worked around by changing
|
||||
+ * the inline assembly constraint from =g to =r, in this particular
|
||||
+ * case either is valid.
|
||||
+ */
|
||||
+#define RELOC_HIDE(ptr, off) \
|
||||
+({ \
|
||||
+ unsigned long __ptr; \
|
||||
+ __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \
|
||||
+ (typeof(ptr)) (__ptr + (off)); \
|
||||
+})
|
||||
+
|
||||
+/* Make the optimizer believe the variable can be manipulated arbitrarily. */
|
||||
+#define OPTIMIZER_HIDE_VAR(var) \
|
||||
+ __asm__ ("" : "=r" (var) : "0" (var))
|
||||
+
|
||||
+#ifdef __CHECKER__
|
||||
+#define __must_be_array(a) 0
|
||||
+#else
|
||||
+/* &a[0] degrades to a pointer: a different type from an array */
|
||||
+#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * Force always-inline if the user requests it so via the .config,
|
||||
+ * or if gcc is too old:
|
||||
+ */
|
||||
+#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
|
||||
+ !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
|
||||
+#define inline inline __attribute__((always_inline)) notrace
|
||||
+#define __inline__ __inline__ __attribute__((always_inline)) notrace
|
||||
+#define __inline __inline __attribute__((always_inline)) notrace
|
||||
+#else
|
||||
+/* A lot of inline functions can cause havoc with function tracing */
|
||||
+#define inline inline notrace
|
||||
+#define __inline__ __inline__ notrace
|
||||
+#define __inline __inline notrace
|
||||
+#endif
|
||||
+
|
||||
+#define __always_inline inline __attribute__((always_inline))
|
||||
+#define noinline __attribute__((noinline))
|
||||
+
|
||||
+#define __deprecated __attribute__((deprecated))
|
||||
+#define __packed __attribute__((packed))
|
||||
+#define __weak __attribute__((weak))
|
||||
+#define __alias(symbol) __attribute__((alias(#symbol)))
|
||||
+
|
||||
+/*
|
||||
+ * it doesn't make sense on ARM (currently the only user of __naked)
|
||||
+ * to trace naked functions because then mcount is called without
|
||||
+ * stack and frame pointer being set up and there is no chance to
|
||||
+ * restore the lr register to the value before mcount was called.
|
||||
+ *
|
||||
+ * The asm() bodies of naked functions often depend on standard calling
|
||||
+ * conventions, therefore they must be noinline and noclone.
|
||||
+ *
|
||||
+ * GCC 4.[56] currently fail to enforce this, so we must do so ourselves.
|
||||
+ * See GCC PR44290.
|
||||
+ */
|
||||
+#define __naked __attribute__((naked)) noinline __noclone notrace
|
||||
+
|
||||
+#define __noreturn __attribute__((noreturn))
|
||||
+
|
||||
+/*
|
||||
+ * From the GCC manual:
|
||||
+ *
|
||||
+ * Many functions have no effects except the return value and their
|
||||
+ * return value depends only on the parameters and/or global
|
||||
+ * variables. Such a function can be subject to common subexpression
|
||||
+ * elimination and loop optimization just as an arithmetic operator
|
||||
+ * would be.
|
||||
+ * [...]
|
||||
+ */
|
||||
+#define __pure __attribute__((pure))
|
||||
+#define __aligned(x) __attribute__((aligned(x)))
|
||||
+#define __printf(a, b) __attribute__((format(printf, a, b)))
|
||||
+#define __scanf(a, b) __attribute__((format(scanf, a, b)))
|
||||
+#define __attribute_const__ __attribute__((__const__))
|
||||
+#define __maybe_unused __attribute__((unused))
|
||||
+#define __always_unused __attribute__((unused))
|
||||
+
|
||||
+/* gcc version specific checks */
|
||||
+
|
||||
+#if GCC_VERSION < 30200
|
||||
+# error Sorry, your compiler is too old - please upgrade it.
|
||||
+#endif
|
||||
+
|
||||
+#if GCC_VERSION < 30300
|
||||
+# define __used __attribute__((__unused__))
|
||||
+#else
|
||||
+# define __used __attribute__((__used__))
|
||||
+#endif
|
||||
+
|
||||
+#ifdef CONFIG_GCOV_KERNEL
|
||||
+# if GCC_VERSION < 30400
|
||||
+# error "GCOV profiling support for gcc versions below 3.4 not included"
|
||||
+# endif /* __GNUC_MINOR__ */
|
||||
+#endif /* CONFIG_GCOV_KERNEL */
|
||||
+
|
||||
+#if GCC_VERSION >= 30400
|
||||
+#define __must_check __attribute__((warn_unused_result))
|
||||
+#define __malloc __attribute__((__malloc__))
|
||||
+#endif
|
||||
+
|
||||
+#if GCC_VERSION >= 40000
|
||||
+
|
||||
+/* GCC 4.1.[01] miscompiles __weak */
|
||||
+#ifdef __KERNEL__
|
||||
+# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101
|
||||
+# error Your version of gcc miscompiles the __weak directive
|
||||
+# endif
|
||||
+#endif
|
||||
+
|
||||
+#define __used __attribute__((__used__))
|
||||
+#define __compiler_offsetof(a, b) \
|
||||
+ __builtin_offsetof(a, b)
|
||||
+
|
||||
+#if GCC_VERSION >= 40100 && GCC_VERSION < 40600
|
||||
+# define __compiletime_object_size(obj) __builtin_object_size(obj, 0)
|
||||
+#endif
|
||||
+
|
||||
+#if GCC_VERSION >= 40300
|
||||
+/* Mark functions as cold. gcc will assume any path leading to a call
|
||||
+ * to them will be unlikely. This means a lot of manual unlikely()s
|
||||
+ * are unnecessary now for any paths leading to the usual suspects
|
||||
+ * like BUG(), printk(), panic() etc. [but let's keep them for now for
|
||||
+ * older compilers]
|
||||
+ *
|
||||
+ * Early snapshots of gcc 4.3 don't support this and we can't detect this
|
||||
+ * in the preprocessor, but we can live with this because they're unreleased.
|
||||
+ * Maketime probing would be overkill here.
|
||||
+ *
|
||||
+ * gcc also has a __attribute__((__hot__)) to move hot functions into
|
||||
+ * a special section, but I don't see any sense in this right now in
|
||||
+ * the kernel context
|
||||
+ */
|
||||
+#define __cold __attribute__((__cold__))
|
||||
+
|
||||
+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
|
||||
+
|
||||
+#ifndef __CHECKER__
|
||||
+# define __compiletime_warning(message) __attribute__((warning(message)))
|
||||
+# define __compiletime_error(message) __attribute__((error(message)))
|
||||
+#endif /* __CHECKER__ */
|
||||
+#endif /* GCC_VERSION >= 40300 */
|
||||
+
|
||||
+#if GCC_VERSION >= 40500
|
||||
+/*
|
||||
+ * Mark a position in code as unreachable. This can be used to
|
||||
+ * suppress control flow warnings after asm blocks that transfer
|
||||
+ * control elsewhere.
|
||||
+ *
|
||||
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
|
||||
+ * this in the preprocessor, but we can live with this because they're
|
||||
+ * unreleased. Really, we need to have autoconf for the kernel.
|
||||
+ */
|
||||
+#define unreachable() __builtin_unreachable()
|
||||
+
|
||||
+/* Mark a function definition as prohibited from being cloned. */
|
||||
+#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))
|
||||
+
|
||||
+#endif /* GCC_VERSION >= 40500 */
|
||||
+
|
||||
+#if GCC_VERSION >= 40600
|
||||
+/*
|
||||
+ * When used with Link Time Optimization, gcc can optimize away C functions or
|
||||
+ * variables which are referenced only from assembly code. __visible tells the
|
||||
+ * optimizer that something else uses this function or variable, thus preventing
|
||||
+ * this.
|
||||
+ */
|
||||
+#define __visible __attribute__((externally_visible))
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
+#if GCC_VERSION >= 40900 && !defined(__CHECKER__)
|
||||
+/*
|
||||
+ * __assume_aligned(n, k): Tell the optimizer that the returned
|
||||
+ * pointer can be assumed to be k modulo n. The second argument is
|
||||
+ * optional (default 0), so we use a variadic macro to make the
|
||||
+ * shorthand.
|
||||
+ *
|
||||
+ * Beware: Do not apply this to functions which may return
|
||||
+ * ERR_PTRs. Also, it is probably unwise to apply it to functions
|
||||
+ * returning extra information in the low bits (but in that case the
|
||||
+ * compiler should see some alignment anyway, when the return value is
|
||||
+ * massaged by 'flags = ptr & 3; ptr &= ~3;').
|
||||
+ */
|
||||
+#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__)))
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * GCC 'asm goto' miscompiles certain code sequences:
|
||||
+ *
|
||||
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
|
||||
+ *
|
||||
+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
|
||||
+ *
|
||||
+ * (asm goto is automatically volatile - the naming reflects this.)
|
||||
+ */
|
||||
+#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
|
||||
+
|
||||
+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
|
||||
+#if GCC_VERSION >= 40400
|
||||
+#define __HAVE_BUILTIN_BSWAP32__
|
||||
+#define __HAVE_BUILTIN_BSWAP64__
|
||||
+#endif
|
||||
+#if GCC_VERSION >= 40800
|
||||
+#define __HAVE_BUILTIN_BSWAP16__
|
||||
+#endif
|
||||
+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
|
||||
+
|
||||
+#if GCC_VERSION >= 50000
|
||||
+#define KASAN_ABI_VERSION 4
|
||||
+#elif GCC_VERSION >= 40902
|
||||
+#define KASAN_ABI_VERSION 3
|
||||
+#endif
|
||||
+
|
||||
+#if GCC_VERSION >= 40902
|
||||
+/*
|
||||
+ * Tell the compiler that address safety instrumentation (KASAN)
|
||||
+ * should not be applied to that function.
|
||||
+ * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
|
||||
+ */
|
||||
+#define __no_sanitize_address __attribute__((no_sanitize_address))
|
||||
+#endif
|
||||
+
|
||||
+#endif /* gcc version >= 40000 specific checks */
|
||||
+
|
||||
+#if !defined(__noclone)
|
||||
+#define __noclone /* not needed */
|
||||
+#endif
|
||||
+
|
||||
+#if !defined(__no_sanitize_address)
|
||||
+#define __no_sanitize_address
|
||||
+#endif
|
||||
+
|
||||
+/*
|
||||
+ * A trick to suppress uninitialized variable warning without generating any
|
||||
+ * code
|
||||
+ */
|
||||
+#define uninitialized_var(x) x = x
|
||||
@ -1,11 +0,0 @@
|
||||
--- a/common/cmd_bootm.c
|
||||
+++ b/common/cmd_bootm.c
|
||||
@@ -77,7 +77,7 @@ static int do_bootm_subcommand(cmd_tbl_t
|
||||
return CMD_RET_USAGE;
|
||||
}
|
||||
|
||||
- if (state != BOOTM_STATE_START && images.state >= state) {
|
||||
+ if (!(state & BOOTM_STATE_START) && images.state >= state) {
|
||||
printf("Trying to execute a command out of order\n");
|
||||
return CMD_RET_USAGE;
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
#
|
||||
# (C) Copyright 2000-2006
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
#
|
||||
# (C) Copyright 2008-2009 Freescale Semiconductor, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
|
||||
obj-y += reset.o
|
||||
obj-y += timer.o
|
||||
obj-y += clock.o
|
||||
obj-y += pinmux.o
|
||||
@ -1,97 +0,0 @@
|
||||
#include <common.h>
|
||||
#include <asm/arch/sysctl.h>
|
||||
#include <asm/arch/cpu.h>
|
||||
#include <asm/arch/clock.h>
|
||||
|
||||
typedef struct {
|
||||
unsigned short mhz;
|
||||
unsigned char refdiv;
|
||||
unsigned char outdiv;
|
||||
unsigned int fbdiv;
|
||||
unsigned short bwadj;
|
||||
unsigned short sfreq;
|
||||
unsigned int sslope;
|
||||
} PLL_CONFIG;
|
||||
|
||||
const PLL_CONFIG C_PLL_CONFIG[] = {
|
||||
{ 500, 1, 2, 3932160, 119, 208, 189 }, // 500 MHz
|
||||
{ 525, 2, 1, 4128768, 125, 139, 297 }, // 525 MHz
|
||||
{ 550, 2, 1, 4325376, 131, 139, 311 }, // 550 MHz
|
||||
{ 575, 2, 1, 4521984, 137, 139, 326 }, // 575 MHz
|
||||
{ 600, 2, 1, 4718592, 143, 138, 339 }, // 600 MHz
|
||||
{ 625, 1, 1, 3276800, 99, 208, 157 }, // 625 MHz
|
||||
{ 650, 1, 1, 3407872, 103, 208, 164 }, // 650 MHz
|
||||
{ 675, 1, 1, 3538944, 107, 208, 170 }, // 675 MHz
|
||||
{ 700, 0, 0, 917504, 27, 416, 22 }, // 700 MHz
|
||||
{ 725, 1, 1, 3801088, 115, 208, 182 }, // 725 MHz
|
||||
{ 750, 0, 0, 983040, 29, 416, 23 }, // 750 MHz
|
||||
{ 775, 3, 0, 4063232, 123, 104, 390 }, // 775 MHz
|
||||
{ 800, 3, 0, 4194304, 127, 104, 403 }, // 800 MHz
|
||||
{ 825, 3, 0, 4325376, 131, 104, 415 }, // 825 MHz
|
||||
{ 850, 2, 0, 3342336, 101, 139, 241 }, // 850 MHz
|
||||
{ 875, 2, 0, 3440640, 104, 139, 248 }, // 875 MHz
|
||||
{ 900, 2, 0, 3538944, 107, 139, 255 }, // 900 MHz
|
||||
{ 925, 2, 0, 3637248, 110, 139, 262 }, // 925 MHz
|
||||
{ 950, 2, 0, 3735552, 113, 139, 269 }, // 950 MHz
|
||||
{ 975, 2, 0, 3833856, 116, 139, 276 }, // 975 MHz
|
||||
{ 1000, 2, 0, 3932160, 119, 139, 283 }, // 1000 MHz
|
||||
};
|
||||
|
||||
#define PLL_BYPASS (1<<1)
|
||||
#define SAT_ENABLE (1<<3)
|
||||
|
||||
#define PLL_OUTDIV_SHIFT 4
|
||||
#define PLL_REFDIV_SHIFT 8
|
||||
#define PLL_BWADJ_SHIFT 16
|
||||
|
||||
#define PLL_LOW_FREQ 500
|
||||
#define PLL_FREQ_STEP 25
|
||||
static void plla_configure(int outdiv, int refdiv, int fbdiv, int bwadj,
|
||||
int sfreq, int sslope)
|
||||
{
|
||||
setbits_le32(SYS_CTRL_PLLA_CTRL0, PLL_BYPASS);
|
||||
udelay(10);
|
||||
reset_block(SYS_CTRL_RST_PLLA, 1);
|
||||
udelay(10);
|
||||
|
||||
writel((refdiv << PLL_REFDIV_SHIFT) | (outdiv << PLL_OUTDIV_SHIFT) |
|
||||
SAT_ENABLE | PLL_BYPASS,
|
||||
SYS_CTRL_PLLA_CTRL0);
|
||||
|
||||
writel(fbdiv, SYS_CTRL_PLLA_CTRL1);
|
||||
writel((bwadj << PLL_BWADJ_SHIFT) | sfreq, SYS_CTRL_PLLA_CTRL2);
|
||||
writel(sslope, SYS_CTRL_PLLA_CTRL3);
|
||||
|
||||
udelay(10); // 5us delay required (from TCI datasheet), use 10us
|
||||
|
||||
reset_block(SYS_CTRL_RST_PLLA, 0);
|
||||
|
||||
udelay(100); // Delay for PLL to lock
|
||||
|
||||
printf(" plla_ctrl0 : %08x\n", readl(SYS_CTRL_PLLA_CTRL0));
|
||||
printf(" plla_ctrl1 : %08x\n", readl(SYS_CTRL_PLLA_CTRL1));
|
||||
printf(" plla_ctrl2 : %08x\n", readl(SYS_CTRL_PLLA_CTRL2));
|
||||
printf(" plla_ctrl3 : %08x\n", readl(SYS_CTRL_PLLA_CTRL3));
|
||||
|
||||
clrbits_le32(SYS_CTRL_PLLA_CTRL0, PLL_BYPASS); // Take PLL out of bypass
|
||||
puts("\nPLLA Set\n");
|
||||
}
|
||||
|
||||
int plla_set_config(int mhz)
|
||||
{
|
||||
int index = (mhz - PLL_LOW_FREQ) / PLL_FREQ_STEP;
|
||||
const PLL_CONFIG *cfg;
|
||||
|
||||
if (index < 0 || index > ARRAY_SIZE(C_PLL_CONFIG)) {
|
||||
debug("Freq %d MHz out of range, default to lowest\n", mhz);
|
||||
index = 0;
|
||||
}
|
||||
cfg = &C_PLL_CONFIG[index];
|
||||
|
||||
printf("Attempting to set PLLA to %d MHz ...\n", (unsigned) cfg->mhz);
|
||||
plla_configure(cfg->outdiv, cfg->refdiv, cfg->fbdiv, cfg->bwadj,
|
||||
cfg->sfreq, cfg->sslope);
|
||||
|
||||
return cfg->mhz;
|
||||
}
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
#include <common.h>
|
||||
#include <asm/arch/pinmux.h>
|
||||
|
||||
void pinmux_set(int bank, int pin, int func)
|
||||
{
|
||||
u32 reg;
|
||||
u32 base;
|
||||
/* TODO: check parameters */
|
||||
|
||||
if (bank == PINMUX_BANK_MFA)
|
||||
base = SYS_CONTROL_BASE;
|
||||
else
|
||||
base = SEC_CONTROL_BASE;
|
||||
|
||||
clrbits_le32(base + PINMUX_SECONDARY_SEL, BIT(pin));
|
||||
clrbits_le32(base + PINMUX_TERTIARY_SEL, BIT(pin));
|
||||
clrbits_le32(base + PINMUX_QUATERNARY_SEL, BIT(pin));
|
||||
clrbits_le32(base + PINMUX_DEBUG_SEL, BIT(pin));
|
||||
clrbits_le32(base + PINMUX_ALTERNATIVE_SEL, BIT(pin));
|
||||
|
||||
switch (func) {
|
||||
case PINMUX_GPIO:
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
case PINMUX_2:
|
||||
reg = base + PINMUX_SECONDARY_SEL;
|
||||
break;
|
||||
case PINMUX_3:
|
||||
reg = base + PINMUX_TERTIARY_SEL;
|
||||
break;
|
||||
case PINMUX_4:
|
||||
reg = base + PINMUX_QUATERNARY_SEL;
|
||||
break;
|
||||
case PINMUX_DEBUG:
|
||||
reg = base + PINMUX_DEBUG_SEL;
|
||||
break;
|
||||
case PINMUX_ALT:
|
||||
reg = base + PINMUX_ALTERNATIVE_SEL;
|
||||
break;
|
||||
}
|
||||
setbits_le32(reg, BIT(pin));
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
#include <common.h>
|
||||
#include <asm/arch/sysctl.h>
|
||||
#include <asm/arch/pinmux.h>
|
||||
#include <asm/arch/clock.h>
|
||||
|
||||
void reset_cpu(ulong addr)
|
||||
{
|
||||
u32 value;
|
||||
|
||||
// Assert reset to cores as per power on defaults
|
||||
// Don't touch the DDR interface as things will come to an impromptu stop
|
||||
// NB Possibly should be asserting reset for PLLB, but there are timing
|
||||
// concerns here according to the docs
|
||||
|
||||
value =
|
||||
BIT(SYS_CTRL_RST_COPRO ) |
|
||||
BIT(SYS_CTRL_RST_USBHS ) |
|
||||
BIT(SYS_CTRL_RST_USBHSPHYA ) |
|
||||
BIT(SYS_CTRL_RST_MACA ) |
|
||||
BIT(SYS_CTRL_RST_PCIEA ) |
|
||||
BIT(SYS_CTRL_RST_SGDMA ) |
|
||||
BIT(SYS_CTRL_RST_CIPHER ) |
|
||||
BIT(SYS_CTRL_RST_SATA ) |
|
||||
BIT(SYS_CTRL_RST_SATA_LINK ) |
|
||||
BIT(SYS_CTRL_RST_SATA_PHY ) |
|
||||
BIT(SYS_CTRL_RST_PCIEPHY ) |
|
||||
BIT(SYS_CTRL_RST_STATIC ) |
|
||||
BIT(SYS_CTRL_RST_UART1 ) |
|
||||
BIT(SYS_CTRL_RST_UART2 ) |
|
||||
BIT(SYS_CTRL_RST_MISC ) |
|
||||
BIT(SYS_CTRL_RST_I2S ) |
|
||||
BIT(SYS_CTRL_RST_SD ) |
|
||||
BIT(SYS_CTRL_RST_MACB ) |
|
||||
BIT(SYS_CTRL_RST_PCIEB ) |
|
||||
BIT(SYS_CTRL_RST_VIDEO ) |
|
||||
BIT(SYS_CTRL_RST_USBHSPHYB ) |
|
||||
BIT(SYS_CTRL_RST_USBDEV );
|
||||
|
||||
writel(value, SYS_CTRL_RST_SET_CTRL);
|
||||
|
||||
// Release reset to cores as per power on defaults
|
||||
writel(BIT(SYS_CTRL_RST_GPIO), SYS_CTRL_RST_CLR_CTRL);
|
||||
|
||||
// Disable clocks to cores as per power-on defaults - must leave DDR
|
||||
// related clocks enabled otherwise we'll stop rather abruptly.
|
||||
value =
|
||||
BIT(SYS_CTRL_CLK_COPRO) |
|
||||
BIT(SYS_CTRL_CLK_DMA) |
|
||||
BIT(SYS_CTRL_CLK_CIPHER) |
|
||||
BIT(SYS_CTRL_CLK_SD) |
|
||||
BIT(SYS_CTRL_CLK_SATA) |
|
||||
BIT(SYS_CTRL_CLK_I2S) |
|
||||
BIT(SYS_CTRL_CLK_USBHS) |
|
||||
BIT(SYS_CTRL_CLK_MAC) |
|
||||
BIT(SYS_CTRL_CLK_PCIEA) |
|
||||
BIT(SYS_CTRL_CLK_STATIC) |
|
||||
BIT(SYS_CTRL_CLK_MACB) |
|
||||
BIT(SYS_CTRL_CLK_PCIEB) |
|
||||
BIT(SYS_CTRL_CLK_REF600) |
|
||||
BIT(SYS_CTRL_CLK_USBDEV);
|
||||
|
||||
writel(value, SYS_CTRL_CLK_CLR_CTRL);
|
||||
|
||||
// Enable clocks to cores as per power-on defaults
|
||||
|
||||
// Set sys-control pin mux'ing as per power-on defaults
|
||||
|
||||
writel(0, SYS_CONTROL_BASE + PINMUX_SECONDARY_SEL);
|
||||
writel(0, SYS_CONTROL_BASE + PINMUX_TERTIARY_SEL);
|
||||
writel(0, SYS_CONTROL_BASE + PINMUX_QUATERNARY_SEL);
|
||||
writel(0, SYS_CONTROL_BASE + PINMUX_DEBUG_SEL);
|
||||
writel(0, SYS_CONTROL_BASE + PINMUX_ALTERNATIVE_SEL);
|
||||
writel(0, SYS_CONTROL_BASE + PINMUX_PULLUP_SEL);
|
||||
|
||||
writel(0, SEC_CONTROL_BASE + PINMUX_SECONDARY_SEL);
|
||||
writel(0, SEC_CONTROL_BASE + PINMUX_TERTIARY_SEL);
|
||||
writel(0, SEC_CONTROL_BASE + PINMUX_QUATERNARY_SEL);
|
||||
writel(0, SEC_CONTROL_BASE + PINMUX_DEBUG_SEL);
|
||||
writel(0, SEC_CONTROL_BASE + PINMUX_ALTERNATIVE_SEL);
|
||||
writel(0, SEC_CONTROL_BASE + PINMUX_PULLUP_SEL);
|
||||
|
||||
// No need to save any state, as the ROM loader can determine whether reset
|
||||
// is due to power cycling or programatic action, just hit the (self-
|
||||
// clearing) CPU reset bit of the block reset register
|
||||
value =
|
||||
BIT(SYS_CTRL_RST_SCU) |
|
||||
BIT(SYS_CTRL_RST_ARM0) |
|
||||
BIT(SYS_CTRL_RST_ARM1);
|
||||
|
||||
writel(value, SYS_CTRL_RST_SET_CTRL);
|
||||
}
|
||||
@ -1,129 +0,0 @@
|
||||
/*
|
||||
* (C) Copyright 2004
|
||||
* Texas Instruments
|
||||
* Richard Woodruff <r-woodruff2@ti.com>
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
|
||||
* Marius Groeger <mgroeger@sysgo.de>
|
||||
* Alex Zuepke <azu@sysgo.de>
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#define TIMER_CLOCK (CONFIG_SYS_CLK_FREQ / (1 << (CONFIG_TIMER_PRESCALE * 4)))
|
||||
#define TIMER_LOAD_VAL 0xFFFFFF
|
||||
|
||||
/* macro to read the 32 bit timer */
|
||||
#define READ_TIMER (TIMER_LOAD_VAL - readl(CONFIG_SYS_TIMERBASE + TIMER_CURR)) \
|
||||
/ (TIMER_CLOCK / CONFIG_SYS_HZ)
|
||||
|
||||
#define READ_TIMER_HW (TIMER_LOAD_VAL - readl(CONFIG_SYS_TIMERBASE + TIMER_CURR))
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
int timer_init (void)
|
||||
{
|
||||
int32_t val;
|
||||
|
||||
/* Start the counter ticking up */
|
||||
writel(TIMER_LOAD_VAL, CONFIG_SYS_TIMERBASE + TIMER_LOAD); /* reload value on overflow*/
|
||||
|
||||
val = (CONFIG_TIMER_PRESCALE << TIMER_PRESCALE_SHIFT) |
|
||||
(TIMER_MODE_PERIODIC << TIMER_MODE_SHIFT) |
|
||||
(TIMER_ENABLE << TIMER_ENABLE_SHIFT); /* mask to enable timer*/
|
||||
writel(val, CONFIG_SYS_TIMERBASE + TIMER_CTRL); /* start timer */
|
||||
|
||||
/* reset time */
|
||||
gd->arch.lastinc = READ_TIMER; /* capture current incrementer value */
|
||||
gd->arch.tbl = 0; /* start "advancing" time stamp */
|
||||
|
||||
return(0);
|
||||
}
|
||||
/*
|
||||
* timer without interrupts
|
||||
*/
|
||||
ulong get_timer (ulong base)
|
||||
{
|
||||
return get_timer_masked () - base;
|
||||
}
|
||||
|
||||
/* delay x useconds AND preserve advance timestamp value */
|
||||
void __udelay (unsigned long usec)
|
||||
{
|
||||
ulong tmo, tmp;
|
||||
|
||||
if (usec > 100000) { /* if "big" number, spread normalization to seconds */
|
||||
tmo = usec / 1000; /* start to normalize for usec to ticks per sec */
|
||||
tmo *= CONFIG_SYS_HZ; /* find number of "ticks" to wait to achieve target */
|
||||
tmo /= 1000; /* finish normalize. */
|
||||
|
||||
tmp = get_timer (0); /* get current timestamp */
|
||||
while (get_timer (tmp) < tmo)/* loop till event */
|
||||
/*NOP*/;
|
||||
} else { /* else small number, convert to hw ticks */
|
||||
tmo = usec * (TIMER_CLOCK / 1000) / 1000;
|
||||
/* timeout is no more than 0.1s, and the hw timer will roll over at most once */
|
||||
tmp = READ_TIMER_HW;
|
||||
while (((READ_TIMER_HW -tmp) & TIMER_LOAD_VAL) < tmo)/* loop till event */
|
||||
/*NOP*/;
|
||||
}
|
||||
}
|
||||
|
||||
ulong get_timer_masked (void)
|
||||
{
|
||||
ulong now = READ_TIMER; /* current tick value */
|
||||
|
||||
if (now >= gd->arch.lastinc) { /* normal mode (non roll) */
|
||||
/* move stamp fordward with absoulte diff ticks */
|
||||
gd->arch.tbl += (now - gd->arch.lastinc);
|
||||
} else {
|
||||
/* we have rollover of incrementer */
|
||||
gd->arch.tbl += ((TIMER_LOAD_VAL / (TIMER_CLOCK / CONFIG_SYS_HZ))
|
||||
- gd->arch.lastinc) + now;
|
||||
}
|
||||
gd->arch.lastinc = now;
|
||||
return gd->arch.tbl;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function is derived from PowerPC code (read timebase as long long).
|
||||
* On ARM it just returns the timer value.
|
||||
*/
|
||||
unsigned long long get_ticks(void)
|
||||
{
|
||||
return get_timer(0);
|
||||
}
|
||||
/*
|
||||
* This function is derived from PowerPC code (timebase clock frequency).
|
||||
* On ARM it returns the number of timer ticks per second.
|
||||
*/
|
||||
ulong get_tbclk (void)
|
||||
{
|
||||
ulong tbclk;
|
||||
tbclk = CONFIG_SYS_HZ;
|
||||
return tbclk;
|
||||
}
|
||||
@ -1,84 +0,0 @@
|
||||
#ifndef _NAS782X_CLOCK_H
|
||||
#define _NAS782X_CLOCK_H
|
||||
|
||||
#include <asm/arch/sysctl.h>
|
||||
#include <asm/arch/cpu.h>
|
||||
|
||||
/* bit numbers of clock control register */
|
||||
#define SYS_CTRL_CLK_COPRO 0
|
||||
#define SYS_CTRL_CLK_DMA 1
|
||||
#define SYS_CTRL_CLK_CIPHER 2
|
||||
#define SYS_CTRL_CLK_SD 3
|
||||
#define SYS_CTRL_CLK_SATA 4
|
||||
#define SYS_CTRL_CLK_I2S 5
|
||||
#define SYS_CTRL_CLK_USBHS 6
|
||||
#define SYS_CTRL_CLK_MACA 7
|
||||
#define SYS_CTRL_CLK_MAC SYS_CTRL_CLK_MACA
|
||||
#define SYS_CTRL_CLK_PCIEA 8
|
||||
#define SYS_CTRL_CLK_STATIC 9
|
||||
#define SYS_CTRL_CLK_MACB 10
|
||||
#define SYS_CTRL_CLK_PCIEB 11
|
||||
#define SYS_CTRL_CLK_REF600 12
|
||||
#define SYS_CTRL_CLK_USBDEV 13
|
||||
#define SYS_CTRL_CLK_DDR 14
|
||||
#define SYS_CTRL_CLK_DDRPHY 15
|
||||
#define SYS_CTRL_CLK_DDRCK 16
|
||||
|
||||
/* bit numbers of reset control register */
|
||||
#define SYS_CTRL_RST_SCU 0
|
||||
#define SYS_CTRL_RST_COPRO 1
|
||||
#define SYS_CTRL_RST_ARM0 2
|
||||
#define SYS_CTRL_RST_ARM1 3
|
||||
#define SYS_CTRL_RST_USBHS 4
|
||||
#define SYS_CTRL_RST_USBHSPHYA 5
|
||||
#define SYS_CTRL_RST_MACA 6
|
||||
#define SYS_CTRL_RST_MAC SYS_CTRL_RST_MACA
|
||||
#define SYS_CTRL_RST_PCIEA 7
|
||||
#define SYS_CTRL_RST_SGDMA 8
|
||||
#define SYS_CTRL_RST_CIPHER 9
|
||||
#define SYS_CTRL_RST_DDR 10
|
||||
#define SYS_CTRL_RST_SATA 11
|
||||
#define SYS_CTRL_RST_SATA_LINK 12
|
||||
#define SYS_CTRL_RST_SATA_PHY 13
|
||||
#define SYS_CTRL_RST_PCIEPHY 14
|
||||
#define SYS_CTRL_RST_STATIC 15
|
||||
#define SYS_CTRL_RST_GPIO 16
|
||||
#define SYS_CTRL_RST_UART1 17
|
||||
#define SYS_CTRL_RST_UART2 18
|
||||
#define SYS_CTRL_RST_MISC 19
|
||||
#define SYS_CTRL_RST_I2S 20
|
||||
#define SYS_CTRL_RST_SD 21
|
||||
#define SYS_CTRL_RST_MACB 22
|
||||
#define SYS_CTRL_RST_PCIEB 23
|
||||
#define SYS_CTRL_RST_VIDEO 24
|
||||
#define SYS_CTRL_RST_DDR_PHY 25
|
||||
#define SYS_CTRL_RST_USBHSPHYB 26
|
||||
#define SYS_CTRL_RST_USBDEV 27
|
||||
#define SYS_CTRL_RST_ARMDBG 29
|
||||
#define SYS_CTRL_RST_PLLA 30
|
||||
#define SYS_CTRL_RST_PLLB 31
|
||||
|
||||
static inline void reset_block(int block, int reset)
|
||||
{
|
||||
u32 reg;
|
||||
if (reset)
|
||||
reg = SYS_CTRL_RST_SET_CTRL;
|
||||
else
|
||||
reg = SYS_CTRL_RST_CLR_CTRL;
|
||||
|
||||
writel(BIT(block), reg);
|
||||
}
|
||||
|
||||
static inline void enable_clock(int block)
|
||||
{
|
||||
writel(BIT(block), SYS_CTRL_CLK_SET_CTRL);
|
||||
}
|
||||
|
||||
static inline void disable_clock(int block)
|
||||
{
|
||||
writel(BIT(block), SYS_CTRL_CLK_CLR_CTRL);
|
||||
}
|
||||
|
||||
int plla_set_config(int idx);
|
||||
|
||||
#endif /* _NAS782X_CLOCK_H */
|
||||
@ -1,26 +0,0 @@
|
||||
#ifndef _NAS782X_CPU_H
|
||||
#define _NAS782X_CPU_H
|
||||
|
||||
#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
|
||||
#include <asm/types.h>
|
||||
#include <asm/io.h>
|
||||
#endif /* !(__KERNEL_STRICT_NAMES || __ASSEMBLY__) */
|
||||
|
||||
#include <asm/arch/hardware.h>
|
||||
#include <asm/arch/timer.h>
|
||||
|
||||
#ifndef __KERNEL_STRICT_NAMES
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#define BIT(x) (1 << (x))
|
||||
|
||||
/* fix "implicit declaration of function" warnning */
|
||||
void *memalign(size_t alignment, size_t bytes);
|
||||
void free(void* mem);
|
||||
void *malloc(size_t bytes);
|
||||
void *calloc(size_t n, size_t elem_size);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __KERNEL_STRICT_NAMES */
|
||||
|
||||
#endif /* _NAS782X_CPU_H */
|
||||
@ -1,30 +0,0 @@
|
||||
#ifndef _NAS782X_HARDWARE_H
|
||||
#define _NAS782X_HARDWARE_H
|
||||
|
||||
/* Core addresses */
|
||||
#define USB_HOST_BASE 0x40200000
|
||||
#define MACA_BASE 0x40400000
|
||||
#define MACB_BASE 0x40800000
|
||||
#define MAC_BASE MACA_BASE
|
||||
#define STATIC_CS0_BASE 0x41000000
|
||||
#define STATIC_CS1_BASE 0x41400000
|
||||
#define STATIC_CONTROL_BASE 0x41C00000
|
||||
#define SATA_DATA_BASE 0x42000000 /* non-functional, DMA just needs an address */
|
||||
#define GPIO_1_BASE 0x44000000
|
||||
#define GPIO_2_BASE 0x44100000
|
||||
#define UART_1_BASE 0x44200000
|
||||
#define UART_2_BASE 0x44300000
|
||||
#define SYS_CONTROL_BASE 0x44e00000
|
||||
#define SEC_CONTROL_BASE 0x44f00000
|
||||
#define RPSA_BASE 0x44400000
|
||||
#define RPSC_BASE 0x44500000
|
||||
#define DDR_BASE 0x44700000
|
||||
|
||||
#define SATA_BASE 0x45900000
|
||||
#define SATA_0_REGS_BASE 0x45900000
|
||||
#define SATA_1_REGS_BASE 0x45910000
|
||||
#define SATA_DMA_REGS_BASE 0x459a0000
|
||||
#define SATA_SGDMA_REGS_BASE 0x459b0000
|
||||
#define SATA_HOST_REGS_BASE 0x459e0000
|
||||
|
||||
#endif /* _NAS782X_HARDWARE_H */
|
||||
@ -1,46 +0,0 @@
|
||||
#ifndef _NAS782X_PINMUX_H
|
||||
#define _NAS782X_PINMUX_H
|
||||
|
||||
#include <asm/arch/cpu.h>
|
||||
|
||||
#define PINMUX_GPIO 0
|
||||
#define PINMUX_2 1
|
||||
#define PINMUX_3 2
|
||||
#define PINMUX_4 3
|
||||
#define PINMUX_DEBUG 4
|
||||
#define PINMUX_ALT 5
|
||||
|
||||
#define PINMUX_BANK_MFA 0
|
||||
#define PINMUX_BANK_MFB 1
|
||||
|
||||
/* System control multi-function pin function selection */
|
||||
#define PINMUX_SECONDARY_SEL 0x14
|
||||
#define PINMUX_TERTIARY_SEL 0x8c
|
||||
#define PINMUX_QUATERNARY_SEL 0x94
|
||||
#define PINMUX_DEBUG_SEL 0x9c
|
||||
#define PINMUX_ALTERNATIVE_SEL 0xa4
|
||||
#define PINMUX_PULLUP_SEL 0xac
|
||||
|
||||
#define PINMUX_UARTA_SIN PINMUX_ALT
|
||||
#define PINMUX_UARTA_SOUT PINMUX_ALT
|
||||
|
||||
#define PINMUX_STATIC_DATA0 PINMUX_2
|
||||
#define PINMUX_STATIC_DATA1 PINMUX_2
|
||||
#define PINMUX_STATIC_DATA2 PINMUX_2
|
||||
#define PINMUX_STATIC_DATA3 PINMUX_2
|
||||
#define PINMUX_STATIC_DATA4 PINMUX_2
|
||||
#define PINMUX_STATIC_DATA5 PINMUX_2
|
||||
#define PINMUX_STATIC_DATA6 PINMUX_2
|
||||
#define PINMUX_STATIC_DATA7 PINMUX_2
|
||||
#define PINMUX_STATIC_NWE PINMUX_2
|
||||
#define PINMUX_STATIC_NOE PINMUX_2
|
||||
#define PINMUX_STATIC_NCS PINMUX_2
|
||||
#define PINMUX_STATIC_ADDR18 PINMUX_2
|
||||
#define PINMUX_STATIC_ADDR19 PINMUX_2
|
||||
|
||||
#define PINMUX_MACA_MDC PINMUX_2
|
||||
#define PINMUX_MACA_MDIO PINMUX_2
|
||||
|
||||
extern void pinmux_set(int bank, int pin, int func);
|
||||
|
||||
#endif /* _NAS782X_PINMUX_H */
|
||||
@ -1,6 +0,0 @@
|
||||
#ifndef _NAS782X_SPL_H
|
||||
#define _NAS782X_SPL_H
|
||||
|
||||
#include <asm/arch/cpu.h>
|
||||
|
||||
#endif /* _NAS782X_SPL_H */
|
||||
@ -1,125 +0,0 @@
|
||||
#ifndef _NAS782X_SYSCTL_H
|
||||
#define _NAS782X_SYSCTL_H
|
||||
|
||||
#if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
|
||||
#include <asm/types.h>
|
||||
#endif /* !(__KERNEL_STRICT_NAMES || __ASSEMBLY__) */
|
||||
|
||||
#include <asm/arch/hardware.h>
|
||||
|
||||
/**
|
||||
* System block reset and clock control
|
||||
*/
|
||||
#define SYS_CTRL_PCI_STAT (SYS_CONTROL_BASE + 0x20)
|
||||
#define SYS_CTRL_CLK_SET_CTRL (SYS_CONTROL_BASE + 0x2C)
|
||||
#define SYS_CTRL_CLK_CLR_CTRL (SYS_CONTROL_BASE + 0x30)
|
||||
#define SYS_CTRL_RST_SET_CTRL (SYS_CONTROL_BASE + 0x34)
|
||||
#define SYS_CTRL_RST_CLR_CTRL (SYS_CONTROL_BASE + 0x38)
|
||||
#define SYS_CTRL_PLLSYS_CTRL (SYS_CONTROL_BASE + 0x48)
|
||||
#define SYS_CTRL_PLLSYS_KEY_CTRL (SYS_CONTROL_BASE + 0x6C)
|
||||
#define SYS_CTRL_GMAC_CTRL (SYS_CONTROL_BASE + 0x78)
|
||||
|
||||
/* Scratch registers */
|
||||
#define SYS_CTRL_SCRATCHWORD0 (SYS_CONTROL_BASE + 0xc4)
|
||||
#define SYS_CTRL_SCRATCHWORD1 (SYS_CONTROL_BASE + 0xc8)
|
||||
#define SYS_CTRL_SCRATCHWORD2 (SYS_CONTROL_BASE + 0xcc)
|
||||
#define SYS_CTRL_SCRATCHWORD3 (SYS_CONTROL_BASE + 0xd0)
|
||||
|
||||
#define SYS_CTRL_PLLA_CTRL0 (SYS_CONTROL_BASE + 0x1F0)
|
||||
#define SYS_CTRL_PLLA_CTRL1 (SYS_CONTROL_BASE + 0x1F4)
|
||||
#define SYS_CTRL_PLLA_CTRL2 (SYS_CONTROL_BASE + 0x1F8)
|
||||
#define SYS_CTRL_PLLA_CTRL3 (SYS_CONTROL_BASE + 0x1FC)
|
||||
|
||||
#define SYS_CTRL_GMAC_AUTOSPEED 3
|
||||
#define SYS_CTRL_GMAC_RGMII 2
|
||||
#define SYS_CTRL_GMAC_SIMPLE_MUX 1
|
||||
#define SYS_CTRL_GMAC_CKEN_GTX 0
|
||||
|
||||
#define SYS_CTRL_CKCTRL_CTRL_ADDR (SYS_CONTROL_BASE + 0x64)
|
||||
|
||||
#define SYS_CTRL_CKCTRL_PCI_DIV_BIT 0
|
||||
#define SYS_CTRL_CKCTRL_SLOW_BIT 8
|
||||
|
||||
|
||||
#define SYS_CTRL_USBHSMPH_CTRL (SYS_CONTROL_BASE + 0x40)
|
||||
#define SYS_CTRL_USBHSMPH_STAT (SYS_CONTROL_BASE + 0x44)
|
||||
#define SYS_CTRL_REF300_DIV (SYS_CONTROL_BASE + 0xF8)
|
||||
#define SYS_CTRL_USBHSPHY_CTRL (SYS_CONTROL_BASE + 0x84)
|
||||
#define SYS_CTRL_USB_CTRL (SYS_CONTROL_BASE + 0x90)
|
||||
|
||||
/* System control multi-function pin function selection */
|
||||
#define SYS_CTRL_SECONDARY_SEL (SYS_CONTROL_BASE + 0x14)
|
||||
#define SYS_CTRL_TERTIARY_SEL (SYS_CONTROL_BASE + 0x8c)
|
||||
#define SYS_CTRL_QUATERNARY_SEL (SYS_CONTROL_BASE + 0x94)
|
||||
#define SYS_CTRL_DEBUG_SEL (SYS_CONTROL_BASE + 0x9c)
|
||||
#define SYS_CTRL_ALTERNATIVE_SEL (SYS_CONTROL_BASE + 0xa4)
|
||||
#define SYS_CTRL_PULLUP_SEL (SYS_CONTROL_BASE + 0xac)
|
||||
|
||||
/* Secure control multi-function pin function selection */
|
||||
#define SEC_CTRL_SECONDARY_SEL (SEC_CONTROL_BASE + 0x14)
|
||||
#define SEC_CTRL_TERTIARY_SEL (SEC_CONTROL_BASE + 0x8c)
|
||||
#define SEC_CTRL_QUATERNARY_SEL (SEC_CONTROL_BASE + 0x94)
|
||||
#define SEC_CTRL_DEBUG_SEL (SEC_CONTROL_BASE + 0x9c)
|
||||
#define SEC_CTRL_ALTERNATIVE_SEL (SEC_CONTROL_BASE + 0xa4)
|
||||
#define SEC_CTRL_PULLUP_SEL (SEC_CONTROL_BASE + 0xac)
|
||||
|
||||
#define SEC_CTRL_COPRO_CTRL (SEC_CONTROL_BASE + 0x68)
|
||||
#define SEC_CTRL_SECURE_CTRL (SEC_CONTROL_BASE + 0x98)
|
||||
#define SEC_CTRL_LEON_DEBUG (SEC_CONTROL_BASE + 0xF0)
|
||||
#define SEC_CTRL_PLLB_DIV_CTRL (SEC_CONTROL_BASE + 0xF8)
|
||||
#define SEC_CTRL_PLLB_CTRL0 (SEC_CONTROL_BASE + 0x1F0)
|
||||
#define SEC_CTRL_PLLB_CTRL1 (SEC_CONTROL_BASE + 0x1F4)
|
||||
#define SEC_CTRL_PLLB_CTRL8 (SEC_CONTROL_BASE + 0x1F4)
|
||||
|
||||
#define REF300_DIV_INT_SHIFT 8
|
||||
#define REF300_DIV_FRAC_SHIFT 0
|
||||
#define REF300_DIV_INT(val) ((val) << REF300_DIV_INT_SHIFT)
|
||||
#define REF300_DIV_FRAC(val) ((val) << REF300_DIV_FRAC_SHIFT)
|
||||
|
||||
#define USBHSPHY_SUSPENDM_MANUAL_ENABLE 16
|
||||
#define USBHSPHY_SUSPENDM_MANUAL_STATE 15
|
||||
#define USBHSPHY_ATE_ESET 14
|
||||
#define USBHSPHY_TEST_DIN 6
|
||||
#define USBHSPHY_TEST_ADD 2
|
||||
#define USBHSPHY_TEST_DOUT_SEL 1
|
||||
#define USBHSPHY_TEST_CLK 0
|
||||
|
||||
#define USB_CTRL_USBAPHY_CKSEL_SHIFT 5
|
||||
#define USB_CLK_XTAL0_XTAL1 (0 << USB_CTRL_USBAPHY_CKSEL_SHIFT)
|
||||
#define USB_CLK_XTAL0 (1 << USB_CTRL_USBAPHY_CKSEL_SHIFT)
|
||||
#define USB_CLK_INTERNAL (2 << USB_CTRL_USBAPHY_CKSEL_SHIFT)
|
||||
|
||||
#define USBAMUX_DEVICE BIT(4)
|
||||
|
||||
#define USBPHY_REFCLKDIV_SHIFT 2
|
||||
#define USB_PHY_REF_12MHZ (0 << USBPHY_REFCLKDIV_SHIFT)
|
||||
#define USB_PHY_REF_24MHZ (1 << USBPHY_REFCLKDIV_SHIFT)
|
||||
#define USB_PHY_REF_48MHZ (2 << USBPHY_REFCLKDIV_SHIFT)
|
||||
|
||||
#define USB_CTRL_USB_CKO_SEL_BIT 0
|
||||
|
||||
#define USB_INT_CLK_XTAL 0
|
||||
#define USB_INT_CLK_REF300 2
|
||||
#define USB_INT_CLK_PLLB 3
|
||||
|
||||
#define SYS_CTRL_GMAC_AUTOSPEED 3
|
||||
#define SYS_CTRL_GMAC_RGMII 2
|
||||
#define SYS_CTRL_GMAC_SIMPLE_MUX 1
|
||||
#define SYS_CTRL_GMAC_CKEN_GTX 0
|
||||
|
||||
|
||||
#define PLLB_ENSAT 3
|
||||
#define PLLB_OUTDIV 4
|
||||
#define PLLB_REFDIV 8
|
||||
#define PLLB_DIV_INT_SHIFT 8
|
||||
#define PLLB_DIV_FRAC_SHIFT 0
|
||||
#define PLLB_DIV_INT(val) ((val) << PLLB_DIV_INT_SHIFT)
|
||||
#define PLLB_DIV_FRAC(val) ((val) << PLLB_DIV_FRAC_SHIFT)
|
||||
|
||||
#ifndef __KERNEL_STRICT_NAMES
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __KERNEL_STRICT_NAMES */
|
||||
|
||||
#endif /* _NAS782X_SYSCTL_H */
|
||||
@ -1,23 +0,0 @@
|
||||
#ifndef _NAS782X_TIMER_H
|
||||
#define _NAS782X_TIMER_H
|
||||
|
||||
#define TIMER1_BASE (RPSA_BASE + 0x200)
|
||||
#define TIMER2_BASE (RPSA_BASE + 0x220)
|
||||
|
||||
#define TIMER_LOAD 0
|
||||
#define TIMER_CURR 4
|
||||
#define TIMER_CTRL 8
|
||||
#define TIMER_INTR 0x0C
|
||||
|
||||
#define TIMER_PRESCALE_SHIFT 2
|
||||
#define TIMER_PRESCALE_1 0
|
||||
#define TIMER_PRESCALE_16 1
|
||||
#define TIMER_PRESCALE_256 2
|
||||
#define TIMER_MODE_SHIFT 6
|
||||
#define TIMER_MODE_FREE_RUNNING 0
|
||||
#define TIMER_MODE_PERIODIC 1
|
||||
#define TIMER_ENABLE_SHIFT 7
|
||||
#define TIMER_DISABLE 0
|
||||
#define TIMER_ENABLE 1
|
||||
|
||||
#endif /* _NAS782X_TIMER_H */
|
||||
@ -1,15 +0,0 @@
|
||||
if TARGET_OX820
|
||||
|
||||
config SYS_CPU
|
||||
default "arm1136"
|
||||
|
||||
config SYS_SOC
|
||||
default "nas782x"
|
||||
|
||||
config SYS_BOARD
|
||||
default "ox820"
|
||||
|
||||
config SYS_CONFIG_NAME
|
||||
default "ox820"
|
||||
|
||||
endif
|
||||
@ -1,6 +0,0 @@
|
||||
SHEEVAPLUG BOARD
|
||||
M: Daniel Golle <daniel@makrotopia.org>
|
||||
S: Maintained
|
||||
F: board/ox820/
|
||||
F: include/configs/ox820.h
|
||||
F: configs/ox820_defconfig
|
||||
@ -1,15 +0,0 @@
|
||||
#
|
||||
# (C) Copyright 2000-2006
|
||||
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
#
|
||||
# (C) Copyright 2008-2009 Freescale Semiconductor, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
|
||||
obj-y += ox820.o
|
||||
obj-y += lowlevel_init.o
|
||||
|
||||
obj-$(CONFIG_SPL_BUILD) += spl_start.o
|
||||
obj-$(CONFIG_SPL_BUILD) += ddr.o
|
||||
|
||||
@ -1,477 +0,0 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* File: ddr_oxsemi.c
|
||||
*
|
||||
* Description: Declarations for DDR routines and data objects
|
||||
*
|
||||
* Author: Julien Margetts
|
||||
*
|
||||
* Copyright: Oxford Semiconductor Ltd, 2009
|
||||
*/
|
||||
#include <common.h>
|
||||
#include <asm/arch/clock.h>
|
||||
|
||||
#include "ddr.h"
|
||||
|
||||
typedef unsigned int UINT;
|
||||
|
||||
// DDR TIMING PARAMETERS
|
||||
typedef struct {
|
||||
unsigned int holdoff_cmd_A;
|
||||
unsigned int holdoff_cmd_ARW;
|
||||
unsigned int holdoff_cmd_N;
|
||||
unsigned int holdoff_cmd_LM;
|
||||
unsigned int holdoff_cmd_R;
|
||||
unsigned int holdoff_cmd_W;
|
||||
unsigned int holdoff_cmd_PC;
|
||||
unsigned int holdoff_cmd_RF;
|
||||
unsigned int holdoff_bank_R;
|
||||
unsigned int holdoff_bank_W;
|
||||
unsigned int holdoff_dir_RW;
|
||||
unsigned int holdoff_dir_WR;
|
||||
unsigned int holdoff_FAW;
|
||||
unsigned int latency_CAS;
|
||||
unsigned int latency_WL;
|
||||
unsigned int recovery_WR;
|
||||
unsigned int width_update;
|
||||
unsigned int odt_offset;
|
||||
unsigned int odt_drive_all;
|
||||
unsigned int use_fixed_re;
|
||||
unsigned int delay_wr_to_re;
|
||||
unsigned int wr_slave_ratio;
|
||||
unsigned int rd_slave_ratio0;
|
||||
unsigned int rd_slave_ratio1;
|
||||
} T_DDR_TIMING_PARAMETERS;
|
||||
|
||||
// DDR CONFIG PARAMETERS
|
||||
|
||||
typedef struct {
|
||||
unsigned int ddr_mode;
|
||||
unsigned int width;
|
||||
unsigned int blocs;
|
||||
unsigned int banks8;
|
||||
unsigned int rams;
|
||||
unsigned int asize;
|
||||
unsigned int speed;
|
||||
unsigned int cmd_mode_wr_cl_bl;
|
||||
} T_DDR_CONFIG_PARAMETERS;
|
||||
|
||||
//cmd_mode_wr_cl_bl
|
||||
//when SDR : cmd_mode_wr_cl_bl = 0x80200002 + (latency_CAS_RAM * 16) + (recovery_WR - 1) * 512; -- Sets write rec XX, CL=XX; BL=8
|
||||
//else cmd_mode_wr_cl_bl = 0x80200003 + (latency_CAS_RAM * 16) + (recovery_WR - 1) * 512; -- Sets write rec XX, CL=XX; BL=8
|
||||
|
||||
// cmd_ bank_ dir_ lat_ rec_ width_ odt_ odt_ fix delay ratio
|
||||
// A F C update offset all re re_to_we w r0 r1
|
||||
// R L P R R W A A W W
|
||||
//Timing Parameters A W N M R W C F R W W R W S L R
|
||||
static const T_DDR_TIMING_PARAMETERS C_TP_DDR2_25E_CL5_1GB = { 4, 5, 0, 2, 4, 4,
|
||||
5, 51, 23, 24, 9, 11, 18, 5, 4, 6, 3, 2, 0, 1, 2, 75, 56, 56 }; //elida device.
|
||||
static const T_DDR_TIMING_PARAMETERS C_TP_DDR2_25E_CL5_2GB = { 4, 5, 0, 2, 4, 4,
|
||||
5, 79, 22, 24, 9, 11, 20, 5, 4, 6, 3, 2, 0, 1, 2, 75, 56, 56 };
|
||||
static const T_DDR_TIMING_PARAMETERS C_TP_DDR2_25_CL6_1GB = { 4, 5, 0, 2, 4, 4,
|
||||
4, 51, 22, 26, 10, 12, 18, 6, 5, 6, 3, 2, 0, 1, 2, 75, 56, 56 }; // 400MHz, Speedgrade 25 timings (1Gb parts)
|
||||
|
||||
// D B B R A S
|
||||
// D W L K A S P
|
||||
//Config Parameters R D C 8 M Z D CMD_MODE
|
||||
//static const T_DDR_CONFIG_PARAMETERS C_CP_DDR2_25E_CL5 = { 2,16, 1, 0, 1, 32,25,0x80200A53}; // 64 MByte
|
||||
static const T_DDR_CONFIG_PARAMETERS C_CP_DDR2_25E_CL5 = { 2, 16, 1, 1, 1, 64,
|
||||
25, 0x80200A53 }; // 128 MByte
|
||||
static const T_DDR_CONFIG_PARAMETERS C_CP_DDR2_25_CL6 = { 2, 16, 1, 1, 1, 128,
|
||||
25, 0x80200A63 }; // 256 MByte
|
||||
|
||||
static void ddr_phy_poll_until_locked(void)
|
||||
{
|
||||
volatile UINT reg_tmp = 0;
|
||||
volatile UINT locked = 0;
|
||||
|
||||
//Extra read to put in delay before starting to poll...
|
||||
reg_tmp = *(volatile UINT *) C_DDR_REG_PHY2; // read
|
||||
|
||||
//POLL C_DDR_PHY2_REG register until clock and flock
|
||||
//!!! Ideally have a timeout on this.
|
||||
while (locked == 0) {
|
||||
reg_tmp = *(volatile UINT *) C_DDR_REG_PHY2; // read
|
||||
|
||||
//locked when bits 30 and 31 are set
|
||||
if (reg_tmp & 0xC0000000) {
|
||||
locked = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ddr_poll_until_not_busy(void)
|
||||
{
|
||||
volatile UINT reg_tmp = 0;
|
||||
volatile UINT busy = 1;
|
||||
|
||||
//Extra read to put in delay before starting to poll...
|
||||
reg_tmp = *(volatile UINT *) C_DDR_STAT_REG; // read
|
||||
|
||||
//POLL DDR_STAT register until no longer busy
|
||||
//!!! Ideally have a timeout on this.
|
||||
while (busy == 1) {
|
||||
reg_tmp = *(volatile UINT *) C_DDR_STAT_REG; // read
|
||||
|
||||
//when bit 31 is clear - core is no longer busy
|
||||
if ((reg_tmp & 0x80000000) == 0x00000000) {
|
||||
busy = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ddr_issue_command(int commmand)
|
||||
{
|
||||
*(volatile UINT *) C_DDR_CMD_REG = commmand;
|
||||
ddr_poll_until_not_busy();
|
||||
}
|
||||
|
||||
static void ddr_timing_initialisation(
|
||||
const T_DDR_TIMING_PARAMETERS *ddr_timing_parameters)
|
||||
{
|
||||
volatile UINT reg_tmp = 0;
|
||||
/* update the DDR controller registers for timing parameters */
|
||||
reg_tmp = (ddr_timing_parameters->holdoff_cmd_A << 0);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_cmd_ARW << 4);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_cmd_N << 8);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_cmd_LM << 12);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_cmd_R << 16);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_cmd_W << 20);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_cmd_PC << 24);
|
||||
*(volatile UINT *) C_DDR_REG_TIMING0 = reg_tmp;
|
||||
|
||||
reg_tmp = (ddr_timing_parameters->holdoff_cmd_RF << 0);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_bank_R << 8);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_bank_W << 16);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_dir_RW << 24);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_dir_WR << 28);
|
||||
*(volatile UINT *) C_DDR_REG_TIMING1 = reg_tmp;
|
||||
|
||||
reg_tmp = (ddr_timing_parameters->latency_CAS << 0);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->latency_WL << 4);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->holdoff_FAW << 8);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->width_update << 16);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->odt_offset << 21);
|
||||
reg_tmp = reg_tmp + (ddr_timing_parameters->odt_drive_all << 24);
|
||||
|
||||
*(volatile UINT *) C_DDR_REG_TIMING2 = reg_tmp;
|
||||
|
||||
/* Program the timing parameters in the PHY too */
|
||||
reg_tmp = (ddr_timing_parameters->use_fixed_re << 16)
|
||||
| (ddr_timing_parameters->delay_wr_to_re << 8)
|
||||
| (ddr_timing_parameters->latency_WL << 4)
|
||||
| (ddr_timing_parameters->latency_CAS << 0);
|
||||
|
||||
*(volatile UINT *) C_DDR_REG_PHY_TIMING = reg_tmp;
|
||||
|
||||
reg_tmp = ddr_timing_parameters->wr_slave_ratio;
|
||||
|
||||
*(volatile UINT *) C_DDR_REG_PHY_WR_RATIO = reg_tmp;
|
||||
|
||||
reg_tmp = ddr_timing_parameters->rd_slave_ratio0;
|
||||
reg_tmp += ddr_timing_parameters->rd_slave_ratio1 << 8;
|
||||
|
||||
*(volatile UINT *) C_DDR_REG_PHY_RD_RATIO = reg_tmp;
|
||||
|
||||
}
|
||||
|
||||
static void ddr_normal_initialisation(
|
||||
const T_DDR_CONFIG_PARAMETERS *ddr_config_parameters, int mhz)
|
||||
{
|
||||
int i;
|
||||
volatile UINT tmp = 0;
|
||||
volatile UINT reg_tmp = 0;
|
||||
volatile UINT emr_cmd = 0;
|
||||
UINT refresh;
|
||||
|
||||
//Total size of memory in Mbits...
|
||||
tmp = ddr_config_parameters->rams * ddr_config_parameters->asize
|
||||
* ddr_config_parameters->width;
|
||||
//Deduce value to program into DDR_CFG register...
|
||||
switch (tmp) {
|
||||
case 16:
|
||||
reg_tmp = 0x00020000 * 1;
|
||||
break;
|
||||
case 32:
|
||||
reg_tmp = 0x00020000 * 2;
|
||||
break;
|
||||
case 64:
|
||||
reg_tmp = 0x00020000 * 3;
|
||||
break;
|
||||
case 128:
|
||||
reg_tmp = 0x00020000 * 4;
|
||||
break;
|
||||
case 256:
|
||||
reg_tmp = 0x00020000 * 5;
|
||||
break;
|
||||
case 512:
|
||||
reg_tmp = 0x00020000 * 6;
|
||||
break;
|
||||
case 1024:
|
||||
reg_tmp = 0x00020000 * 7;
|
||||
break;
|
||||
case 2048:
|
||||
reg_tmp = 0x00020000 * 8;
|
||||
break;
|
||||
default:
|
||||
reg_tmp = 0; //forces sims not to work if badly configured
|
||||
}
|
||||
|
||||
//Memory width
|
||||
tmp = ddr_config_parameters->rams * ddr_config_parameters->width;
|
||||
switch (tmp) {
|
||||
case 8:
|
||||
reg_tmp = reg_tmp + 0x00400000;
|
||||
break;
|
||||
case 16:
|
||||
reg_tmp = reg_tmp + 0x00200000;
|
||||
break;
|
||||
case 32:
|
||||
reg_tmp = reg_tmp + 0x00000000;
|
||||
break;
|
||||
default:
|
||||
reg_tmp = 0; //forces sims not to work if badly configured
|
||||
}
|
||||
|
||||
//Setup DDR Mode
|
||||
switch (ddr_config_parameters->ddr_mode) {
|
||||
case 0:
|
||||
reg_tmp = reg_tmp + 0x00000000;
|
||||
break; //SDR
|
||||
case 1:
|
||||
reg_tmp = reg_tmp + 0x40000000;
|
||||
break; //DDR
|
||||
case 2:
|
||||
reg_tmp = reg_tmp + 0x80000000;
|
||||
break; //DDR2
|
||||
default:
|
||||
reg_tmp = 0; //forces sims not to work if badly configured
|
||||
}
|
||||
|
||||
//Setup Banks
|
||||
if (ddr_config_parameters->banks8 == 1) {
|
||||
reg_tmp = reg_tmp + 0x00800000;
|
||||
}
|
||||
|
||||
//Program DDR_CFG register...
|
||||
*(volatile UINT *) C_DDR_CFG_REG = reg_tmp;
|
||||
|
||||
//Configure PHY0 reg - se_mode is bit 1,
|
||||
//needs to be 1 for DDR (single_ended drive)
|
||||
switch (ddr_config_parameters->ddr_mode) {
|
||||
case 0:
|
||||
reg_tmp = 2 + (0 << 4);
|
||||
break; //SDR
|
||||
case 1:
|
||||
reg_tmp = 2 + (4 << 4);
|
||||
break; //DDR
|
||||
case 2:
|
||||
reg_tmp = 0 + (4 << 4);
|
||||
break; //DDR2
|
||||
default:
|
||||
reg_tmp = 0;
|
||||
}
|
||||
|
||||
//Program DDR_PHY0 register...
|
||||
*(volatile UINT *) C_DDR_REG_PHY0 = reg_tmp;
|
||||
|
||||
//Read DDR_PHY* registers to exercise paths for vcd
|
||||
reg_tmp = *(volatile UINT *) C_DDR_REG_PHY3;
|
||||
reg_tmp = *(volatile UINT *) C_DDR_REG_PHY2;
|
||||
reg_tmp = *(volatile UINT *) C_DDR_REG_PHY1;
|
||||
reg_tmp = *(volatile UINT *) C_DDR_REG_PHY0;
|
||||
|
||||
//Start up sequences - Different dependant on DDR mode
|
||||
switch (ddr_config_parameters->ddr_mode) {
|
||||
case 2: //DDR2
|
||||
//Start-up sequence: follows procedure described in Micron datasheet.
|
||||
//start up DDR PHY DLL
|
||||
reg_tmp = 0x00022828; // dll on, start point and inc = h28
|
||||
*(volatile UINT *) C_DDR_REG_PHY2 = reg_tmp;
|
||||
|
||||
reg_tmp = 0x00032828; // start on, dll on, start point and inc = h28
|
||||
*(volatile UINT *) C_DDR_REG_PHY2 = reg_tmp;
|
||||
|
||||
ddr_phy_poll_until_locked();
|
||||
|
||||
udelay(200); //200us
|
||||
|
||||
//Startup SDRAM...
|
||||
//!!! Software: CK should be running for 200us before wake-up
|
||||
ddr_issue_command( C_CMD_WAKE_UP);
|
||||
ddr_issue_command( C_CMD_NOP);
|
||||
ddr_issue_command( C_CMD_PRECHARGE_ALL);
|
||||
ddr_issue_command( C_CMD_DDR2_EMR2);
|
||||
ddr_issue_command( C_CMD_DDR2_EMR3);
|
||||
|
||||
emr_cmd = C_CMD_DDR2_EMR1 + C_CMD_ODT_75 + C_CMD_REDUCED_DRIVE
|
||||
+ C_CMD_ENABLE_DLL;
|
||||
|
||||
ddr_issue_command(emr_cmd);
|
||||
//Sets CL=3; BL=8 but also reset DLL to trigger a DLL initialisation...
|
||||
udelay(1); //1us
|
||||
ddr_issue_command(
|
||||
ddr_config_parameters->cmd_mode_wr_cl_bl
|
||||
+ C_CMD_RESET_DLL);
|
||||
udelay(1); //1us
|
||||
|
||||
//!!! Software: Wait 200 CK cycles before...
|
||||
//for(i=1; i<=2; i++) {
|
||||
ddr_issue_command(C_CMD_PRECHARGE_ALL);
|
||||
// !!! Software: Wait here at least 8 CK cycles
|
||||
//}
|
||||
//need a wait here to ensure PHY DLL lock before the refresh is issued
|
||||
udelay(1); //1us
|
||||
for (i = 1; i <= 2; i++) {
|
||||
ddr_issue_command( C_CMD_AUTO_REFRESH);
|
||||
//!!! Software: Wait here at least 8 CK cycles to satify tRFC
|
||||
udelay(1); //1us
|
||||
}
|
||||
//As before but without 'RESET_DLL' bit set...
|
||||
ddr_issue_command(ddr_config_parameters->cmd_mode_wr_cl_bl);
|
||||
udelay(1); //1us
|
||||
// OCD commands
|
||||
ddr_issue_command(emr_cmd + C_CMD_MODE_DDR2_OCD_DFLT);
|
||||
ddr_issue_command(emr_cmd + C_CMD_MODE_DDR2_OCD_EXIT);
|
||||
break;
|
||||
|
||||
default:
|
||||
break; //Do nothing
|
||||
}
|
||||
|
||||
//Enable auto-refresh
|
||||
|
||||
// 8192 Refreshes required every 64ms, so maximum refresh period is 7.8125 us
|
||||
// We have a 400 MHz DDR clock (2.5ns period) so max period is 3125 cycles
|
||||
// Our core now does 8 refreshes in a go, so we multiply this period by 8
|
||||
|
||||
refresh = (64000 * mhz) / 8192; // Refresh period in clocks
|
||||
|
||||
reg_tmp = *(volatile UINT *) C_DDR_CFG_REG; // read
|
||||
#ifdef BURST_REFRESH_ENABLE
|
||||
reg_tmp |= C_CFG_REFRESH_ENABLE | (refresh * 8);
|
||||
reg_tmp |= C_CFG_BURST_REFRESH_ENABLE;
|
||||
#else
|
||||
reg_tmp |= C_CFG_REFRESH_ENABLE | (refresh * 1);
|
||||
reg_tmp &= ~C_CFG_BURST_REFRESH_ENABLE;
|
||||
#endif
|
||||
*(volatile UINT *) C_DDR_CFG_REG = reg_tmp;
|
||||
|
||||
//Verify register contents
|
||||
reg_tmp = *(volatile UINT *) C_DDR_REG_PHY2; // read
|
||||
//printf("Warning XXXXXXXXXXXXXXXXXXXXXX - get bad read data from C_DDR_PHY2_REG, though it looks OK on bus XXXXXXXXXXXXXXXXXX");
|
||||
//TBD Check_data (read_data, dll_reg, "Error: bad C_DDR_PHY2_REG read", tb_pass);
|
||||
reg_tmp = *(volatile UINT *) C_DDR_CFG_REG; // read
|
||||
//TBD Check_data (read_data, cfg_reg, "Error: bad DDR_CFG read", tb_pass);
|
||||
|
||||
//disable optimised wrapping
|
||||
if (ddr_config_parameters->ddr_mode == 2) {
|
||||
reg_tmp = 0xFFFF0000;
|
||||
*(volatile UINT *) C_DDR_REG_IGNORE = reg_tmp;
|
||||
}
|
||||
|
||||
//enable midbuffer followon
|
||||
reg_tmp = *(volatile UINT *) C_DDR_ARB_REG; // read
|
||||
reg_tmp = 0xFFFF0000 | reg_tmp;
|
||||
*(volatile UINT *) C_DDR_ARB_REG = reg_tmp;
|
||||
|
||||
// Enable write behind coherency checking for all clients
|
||||
|
||||
reg_tmp = 0xFFFF0000;
|
||||
*(volatile UINT *) C_DDR_AHB4_REG = reg_tmp;
|
||||
|
||||
//Wait for 200 clock cycles for SDRAM DLL to lock...
|
||||
udelay(1); //1us
|
||||
}
|
||||
|
||||
// Function used to Setup DDR core
|
||||
|
||||
void ddr_setup(int mhz)
|
||||
{
|
||||
static const T_DDR_TIMING_PARAMETERS *ddr_timing_parameters =
|
||||
&C_TP_DDR2_25_CL6_1GB;
|
||||
static const T_DDR_CONFIG_PARAMETERS *ddr_config_parameters =
|
||||
&C_CP_DDR2_25_CL6;
|
||||
|
||||
//Bring core out of Reset
|
||||
*(volatile UINT *) C_DDR_BLKEN_REG = C_BLKEN_DDR_ON;
|
||||
|
||||
//DDR TIMING INITIALISTION
|
||||
ddr_timing_initialisation(ddr_timing_parameters);
|
||||
|
||||
//DDR NORMAL INITIALISATION
|
||||
ddr_normal_initialisation(ddr_config_parameters, mhz);
|
||||
|
||||
// route all writes through one client
|
||||
*(volatile UINT *) C_DDR_TRANSACTION_ROUTING = (0
|
||||
<< DDR_ROUTE_CPU0_INSTR_SHIFT)
|
||||
| (1 << DDR_ROUTE_CPU0_RDDATA_SHIFT)
|
||||
| (3 << DDR_ROUTE_CPU0_WRDATA_SHIFT)
|
||||
| (2 << DDR_ROUTE_CPU1_INSTR_SHIFT)
|
||||
| (3 << DDR_ROUTE_CPU1_RDDATA_SHIFT)
|
||||
| (3 << DDR_ROUTE_CPU1_WRDATA_SHIFT);
|
||||
|
||||
//Bring all clients out of reset
|
||||
*(volatile UINT *) C_DDR_BLKEN_REG = C_BLKEN_DDR_ON + 0x0000FFFF;
|
||||
|
||||
}
|
||||
|
||||
void set_ddr_timing(unsigned int w, unsigned int i)
|
||||
{
|
||||
unsigned int reg;
|
||||
unsigned int wnow = 16;
|
||||
unsigned int inow = 32;
|
||||
|
||||
/* reset all timing controls to known value (31) */
|
||||
writel(DDR_PHY_TIMING_W_RST | DDR_PHY_TIMING_I_RST, DDR_PHY_TIMING);
|
||||
writel(DDR_PHY_TIMING_W_RST | DDR_PHY_TIMING_I_RST | DDR_PHY_TIMING_CK,
|
||||
DDR_PHY_TIMING);
|
||||
writel(DDR_PHY_TIMING_W_RST | DDR_PHY_TIMING_I_RST, DDR_PHY_TIMING);
|
||||
|
||||
/* step up or down read delay to the requested value */
|
||||
while (wnow != w) {
|
||||
if (wnow < w) {
|
||||
reg = DDR_PHY_TIMING_INC;
|
||||
wnow++;
|
||||
} else {
|
||||
reg = 0;
|
||||
wnow--;
|
||||
}
|
||||
writel(DDR_PHY_TIMING_W_CE | reg, DDR_PHY_TIMING);
|
||||
writel(DDR_PHY_TIMING_CK | DDR_PHY_TIMING_W_CE | reg,
|
||||
DDR_PHY_TIMING);
|
||||
writel(DDR_PHY_TIMING_W_CE | reg, DDR_PHY_TIMING);
|
||||
}
|
||||
|
||||
/* now write delay */
|
||||
while (inow != i) {
|
||||
if (inow < i) {
|
||||
reg = DDR_PHY_TIMING_INC;
|
||||
inow++;
|
||||
} else {
|
||||
reg = 0;
|
||||
inow--;
|
||||
}
|
||||
writel(DDR_PHY_TIMING_I_CE | reg, DDR_PHY_TIMING);
|
||||
writel(DDR_PHY_TIMING_CK | DDR_PHY_TIMING_I_CE | reg,
|
||||
DDR_PHY_TIMING);
|
||||
writel(DDR_PHY_TIMING_I_CE | reg, DDR_PHY_TIMING);
|
||||
}
|
||||
}
|
||||
|
||||
//Function used to Setup SDRAM in DDR/SDR mode
|
||||
void init_ddr(int mhz)
|
||||
{
|
||||
/* start clocks */
|
||||
enable_clock(SYS_CTRL_CLK_DDRPHY);
|
||||
enable_clock(SYS_CTRL_CLK_DDR);
|
||||
enable_clock(SYS_CTRL_CLK_DDRCK);
|
||||
|
||||
/* bring phy and core out of reset */
|
||||
reset_block(SYS_CTRL_RST_DDR_PHY, 0);
|
||||
reset_block(SYS_CTRL_RST_DDR, 0);
|
||||
|
||||
/* DDR runs at half the speed of the CPU */
|
||||
ddr_setup(mhz >> 1);
|
||||
return;
|
||||
}
|
||||
@ -1,148 +0,0 @@
|
||||
/*******************************************************************
|
||||
*
|
||||
* File: ddr_oxsemi.h
|
||||
*
|
||||
* Description: Declarations for DDR routines and data objects
|
||||
*
|
||||
* Author: Julien Margetts
|
||||
*
|
||||
* Copyright: Oxford Semiconductor Ltd, 2009
|
||||
*/
|
||||
|
||||
void ddr_oxsemi_setup(int mhz);
|
||||
|
||||
/* define to refresh in bursts of 8 */
|
||||
#define BURST_REFRESH_ENABLE
|
||||
|
||||
#define DDR_BASE 0x44700000
|
||||
|
||||
#define C_DDR_CFG_REG (DDR_BASE + 0x00)
|
||||
#define C_CFG_DDR 0x80000000
|
||||
#define C_CFG_SDR 0x00000000
|
||||
#define C_CFG_WIDTH8 0x00200000
|
||||
#define C_CFG_WIDTH16 0x00100000
|
||||
#define C_CFG_WIDTH32 0x00000000
|
||||
#define C_CFG_SIZE_FACTOR 0x00020000
|
||||
#define C_CFG_REFRESH_ENABLE 0x00010000
|
||||
#define C_CFG_BURST_REFRESH_ENABLE 0x01000000
|
||||
#define C_CFG_SIZE(x) (x << 17)
|
||||
#define CFG_SIZE_2MB 1
|
||||
#define CFG_SIZE_4MB 2
|
||||
#define CFG_SIZE_8MB 3
|
||||
#define CFG_SIZE_16MB 4
|
||||
#define CFG_SIZE_32MB 5
|
||||
#define CFG_SIZE_64MB 6
|
||||
#define CFG_SIZE_128MB 7
|
||||
|
||||
#define C_DDR_BLKEN_REG (DDR_BASE + 0x04)
|
||||
#define C_BLKEN_DDR_ON 0x80000000
|
||||
|
||||
#define C_DDR_STAT_REG (DDR_BASE + 0x08)
|
||||
|
||||
#define C_DDR_CMD_REG (DDR_BASE + 0x0C)
|
||||
#define C_CMD_SEND_COMMAND (1UL << 31) | (1 << 21) // RAS/CAS/WE/CS all low(active), CKE High, indicates
|
||||
#define C_CMD_WAKE_UP 0x80FC0000 // Asserts CKE
|
||||
#define C_CMD_MODE_SDR 0x80200022 // Sets CL=2 BL=4
|
||||
#define C_CMD_MODE_DDR 0x80200063 // Sets CL=2.5 BL=8
|
||||
#define C_CMD_RESET_DLL 0x00000100 // A8=1 Use in conjunction with C_CMD_MODE_DDR
|
||||
#define C_CMD_PRECHARGE_ALL 0x80280400
|
||||
#define C_CMD_AUTO_REFRESH 0x80240000
|
||||
#define C_CMD_SELF_REFRESH 0x80040000 // As AUTO-REFRESH but with CKE low
|
||||
#define C_CMD_NOP 0x803C0000 // NOP just to insert guaranteed delay
|
||||
#define C_CMD_DDR2_EMR1 0x80210000 // Load extended mode register 1 with zeros (for init), CKE still set
|
||||
//#define C_CMD_DDR2_EMR1 0x80210400 // Load extended mode register 1 with zeros (for init), CKE still set
|
||||
#define C_CMD_ENABLE_DLL 0x00000000 // Values used in conjuction with C_CMD_DDR2_EMR1
|
||||
#define C_CMD_DISABLE_DLL 0x00000001
|
||||
#define C_CMD_REDUCED_DRIVE 0x00000002
|
||||
#define C_CMD_ODT_DISABLED 0x00000000
|
||||
#define C_CMD_ODT_50 0x00000044
|
||||
#define C_CMD_ODT_75 0x00000004
|
||||
#define C_CMD_ODT_150 0x00000040
|
||||
#define C_CMD_MODE_DDR2_OCD_DFLT 0x00000380
|
||||
#define C_CMD_MODE_DDR2_OCD_EXIT 0x00000000
|
||||
|
||||
#define C_CMD_DDR2_EMR2 0x80220000 // Load extended mode register 2 with zeros (for init), CKE still set
|
||||
#define C_CMD_DDR2_EMR3 0x80230000 // Load extended mode register 3 with zeros (for init), CKE still set
|
||||
|
||||
#define C_DDR_AHB_REG (DDR_BASE + 0x10)
|
||||
#define C_AHB_NO_RCACHES 0xFFFF0000
|
||||
#define C_AHB_FLUSH_ALL_RCACHES 0x0000FFFF
|
||||
#define C_AHB_FLUSH_AHB0_RCACHE 0x00000001
|
||||
#define C_AHB_FLUSH_AHB1_RCACHE 0x00000002
|
||||
|
||||
#define C_DDR_DLL_REG (DDR_BASE + 0x14)
|
||||
#define C_DLL_DISABLED 0x00000000
|
||||
#define C_DLL_MANUAL 0x80000000
|
||||
#define C_DLL_AUTO_OFFSET 0xA0000000
|
||||
#define C_DLL_AUTO_IN_REFRESH 0xC0000000
|
||||
#define C_DLL_AUTOMATIC 0xE0000000
|
||||
|
||||
#define C_DDR_MON_REG (DDR_BASE + 0x18)
|
||||
#define C_MON_ALL 0x00000010
|
||||
#define C_MON_CLIENT 0x00000000
|
||||
|
||||
#define C_DDR_DIAG_REG (DDR_BASE + 0x1C)
|
||||
#define C_DDR_DIAG2_REG (DDR_BASE + 0x20)
|
||||
|
||||
#define C_DDR_IOC_REG (DDR_BASE + 0x24)
|
||||
#define C_DDR_IOC_PWR_DWN (1 << 10)
|
||||
#define C_DDR_IOC_SEL_SSTL (1 << 9)
|
||||
#define C_DDR_IOC_CK_DRIVE(x) ((x) << 6)
|
||||
#define C_DDR_IOC_DQ_DRIVE(x) ((x) << 3)
|
||||
#define C_DDR_IOC_XX_DRIVE(x) ((x) << 0)
|
||||
|
||||
#define C_DDR_ARB_REG (DDR_BASE + 0x28)
|
||||
#define C_DDR_ARB_MIDBUF (1 << 4)
|
||||
#define C_DDR_ARB_LRUBANK (1 << 3)
|
||||
#define C_DDR_ARB_REQAGE (1 << 2)
|
||||
#define C_DDR_ARB_DATDIR (1 << 1)
|
||||
#define C_DDR_ARB_DATDIR_NC (1 << 0)
|
||||
|
||||
#define C_TOP_ADDRESS_BIT_TEST 22
|
||||
#define C_MEM_BASE C_SDRAM_BASE
|
||||
|
||||
#define C_MEM_TEST_BASE 0
|
||||
#define C_MEM_TEST_LEN 1920
|
||||
#define C_MAX_RAND_ACCESS_LEN 16
|
||||
|
||||
#define C_DDR_REG_IGNORE (DDR_BASE + 0x2C)
|
||||
#define C_DDR_AHB4_REG (DDR_BASE + 0x44)
|
||||
|
||||
#define C_DDR_REG_TIMING0 (DDR_BASE + 0x34)
|
||||
#define C_DDR_REG_TIMING1 (DDR_BASE + 0x38)
|
||||
#define C_DDR_REG_TIMING2 (DDR_BASE + 0x3C)
|
||||
|
||||
#define C_DDR_REG_PHY0 (DDR_BASE + 0x48)
|
||||
#define C_DDR_REG_PHY1 (DDR_BASE + 0x4C)
|
||||
#define C_DDR_REG_PHY2 (DDR_BASE + 0x50)
|
||||
#define C_DDR_REG_PHY3 (DDR_BASE + 0x54)
|
||||
|
||||
#define C_DDR_REG_GENERIC (DDR_BASE + 0x60)
|
||||
|
||||
#define C_OXSEMI_DDRC_SIGNATURE 0x054415AA
|
||||
|
||||
#define DDR_PHY_BASE (DDR_BASE + 0x80000)
|
||||
#define DDR_PHY_TIMING (DDR_PHY_BASE + 0x48)
|
||||
#define DDR_PHY_TIMING_CK (1 << 12)
|
||||
#define DDR_PHY_TIMING_INC (1 << 13)
|
||||
#define DDR_PHY_TIMING_W_CE (1 << 14)
|
||||
#define DDR_PHY_TIMING_W_RST (1 << 15)
|
||||
#define DDR_PHY_TIMING_I_CE (1 << 16)
|
||||
#define DDR_PHY_TIMING_I_RST (1 << 17)
|
||||
|
||||
#define C_DDR_REG_PHY_TIMING (DDR_PHY_BASE + 0x50)
|
||||
#define C_DDR_REG_PHY_WR_RATIO (DDR_PHY_BASE + 0x74)
|
||||
#define C_DDR_REG_PHY_RD_RATIO (DDR_PHY_BASE + 0x78)
|
||||
|
||||
#define C_DDR_TRANSACTION_ROUTING (DDR_PHY_BASE + 0xC8)
|
||||
#define DDR_ROUTE_CPU0_INSTR_SHIFT 0
|
||||
#define DDR_ROUTE_CPU0_RDDATA_SHIFT 4
|
||||
#define DDR_ROUTE_CPU0_WRDATA_SHIFT 6
|
||||
#define DDR_ROUTE_CPU1_INSTR_SHIFT 8
|
||||
#define DDR_ROUTE_CPU1_RDDATA_SHIFT 12
|
||||
#define DDR_ROUTE_CPU1_WRDATA_SHIFT 14
|
||||
|
||||
unsigned int ddrc_signature(void);
|
||||
void set_ddr_timing(unsigned int w, unsigned int i);
|
||||
int pause(unsigned int us);
|
||||
void set_ddr_sel(int val);
|
||||
@ -1,20 +0,0 @@
|
||||
#include <config.h>
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
|
||||
.globl lowlevel_init
|
||||
lowlevel_init:
|
||||
/*
|
||||
* Copy exception table to relocated address in internal SRAM
|
||||
*/
|
||||
ldr r0, src /* Address of exception table in flash */
|
||||
ldr r1, dest /* Relocated address of exception table */
|
||||
ldmia r0!, {r3-r10} /* Copy exception table and jump values from */
|
||||
stmia r1!, {r3-r10} /* FLASH to relocated address */
|
||||
ldmia r0!, {r3-r10}
|
||||
stmia r1!, {r3-r10}
|
||||
mov pc, lr
|
||||
|
||||
src: .word CONFIG_SYS_TEXT_BASE
|
||||
dest: .word CONFIG_SRAM_BASE
|
||||
|
||||
#endif
|
||||
@ -1,374 +0,0 @@
|
||||
#include <common.h>
|
||||
#include <spl.h>
|
||||
#include <phy.h>
|
||||
#include <netdev.h>
|
||||
#include <ide.h>
|
||||
#include <nand.h>
|
||||
#include <asm/arch/spl.h>
|
||||
#include <asm/arch/pinmux.h>
|
||||
#include <asm/arch/clock.h>
|
||||
#include <asm/arch/sysctl.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#ifdef CONFIG_SPL_BUILD
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DILIGENCE (1048576/4)
|
||||
static int test_memory(u32 memory)
|
||||
{
|
||||
volatile u32 *read;
|
||||
volatile u32 *write;
|
||||
const u32 INIT_PATTERN = 0xAA55AA55;
|
||||
const u32 INC_PATTERN = 0x01030507;
|
||||
u32 pattern;
|
||||
int check;
|
||||
int i;
|
||||
|
||||
check = 0;
|
||||
read = write = (volatile u32 *) memory;
|
||||
pattern = INIT_PATTERN;
|
||||
for (i = 0; i < DILIGENCE; i++) {
|
||||
*write++ = pattern;
|
||||
pattern += INC_PATTERN;
|
||||
}
|
||||
puts("testing\n");
|
||||
pattern = INIT_PATTERN;
|
||||
for (i = 0; i < DILIGENCE; i++) {
|
||||
check += (pattern == *read++) ? 1 : 0;
|
||||
pattern += INC_PATTERN;
|
||||
}
|
||||
return (check == DILIGENCE) ? 0 : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void uart_init(void)
|
||||
{
|
||||
/* Reset UART1 */
|
||||
reset_block(SYS_CTRL_RST_UART1, 1);
|
||||
udelay(100);
|
||||
reset_block(SYS_CTRL_RST_UART1, 0);
|
||||
udelay(100);
|
||||
|
||||
/* Setup pin mux'ing for UART1 */
|
||||
pinmux_set(PINMUX_BANK_MFA, 30, PINMUX_UARTA_SIN);
|
||||
pinmux_set(PINMUX_BANK_MFA, 31, PINMUX_UARTA_SOUT);
|
||||
}
|
||||
|
||||
extern void init_ddr(int mhz);
|
||||
|
||||
void board_inithw(void)
|
||||
{
|
||||
int plla_freq;
|
||||
#ifdef DEBUG
|
||||
int i;
|
||||
#endif /* DEBUG */
|
||||
|
||||
timer_init();
|
||||
uart_init();
|
||||
preloader_console_init();
|
||||
|
||||
plla_freq = plla_set_config(CONFIG_PLLA_FREQ_MHZ);
|
||||
init_ddr(plla_freq);
|
||||
|
||||
#ifdef DEBUG
|
||||
if(test_memory(CONFIG_SYS_SDRAM_BASE)) {
|
||||
puts("memory test failed\n");
|
||||
} else {
|
||||
puts("memory test done\n");
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
#ifdef CONFIG_SPL_BSS_DRAM_START
|
||||
extern char __bss_dram_start[];
|
||||
extern char __bss_dram_end[];
|
||||
memset(&__bss_dram_start, 0, __bss_dram_end - __bss_dram_start);
|
||||
#endif
|
||||
}
|
||||
|
||||
void board_init_f(ulong dummy)
|
||||
{
|
||||
/* Set the stack pointer. */
|
||||
asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK));
|
||||
|
||||
/* Clear the BSS. */
|
||||
memset(__bss_start, 0, __bss_end - __bss_start);
|
||||
|
||||
/* Set global data pointer. */
|
||||
gd = &gdata;
|
||||
|
||||
board_inithw();
|
||||
|
||||
board_init_r(NULL, 0);
|
||||
}
|
||||
|
||||
u32 spl_boot_device(void)
|
||||
{
|
||||
return CONFIG_SPL_BOOT_DEVICE;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_BLOCK_SUPPORT
|
||||
void spl_block_device_init(void)
|
||||
{
|
||||
ide_init();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SPL_OS_BOOT
|
||||
int spl_start_uboot(void)
|
||||
{
|
||||
/* break into full u-boot on 'c' */
|
||||
return (serial_tstc() && serial_getc() == 'c');
|
||||
}
|
||||
#endif
|
||||
|
||||
void spl_display_print(void)
|
||||
{
|
||||
/* print a hint, so that we will not use the wrong SPL by mistake */
|
||||
puts(" Boot device: " BOOT_DEVICE_TYPE "\n" );
|
||||
}
|
||||
|
||||
void lowlevel_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef USE_DL_PREFIX
|
||||
/* quick and dirty memory allocation */
|
||||
static ulong next_mem = CONFIG_SPL_MALLOC_START;
|
||||
|
||||
void *memalign(size_t alignment, size_t bytes)
|
||||
{
|
||||
ulong mem = ALIGN(next_mem, alignment);
|
||||
|
||||
next_mem = mem + bytes;
|
||||
|
||||
if (next_mem > CONFIG_SYS_SDRAM_BASE + CONFIG_MIN_SDRAM_SIZE) {
|
||||
printf("spl: out of memory\n");
|
||||
hang();
|
||||
}
|
||||
|
||||
return (void *)mem;
|
||||
}
|
||||
|
||||
void free(void* mem)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_SPL_BUILD */
|
||||
|
||||
int board_early_init_f(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define STATIC_CTL_BANK0 (STATIC_CONTROL_BASE + 4)
|
||||
#define STATIC_READ_CYCLE_SHIFT 0
|
||||
#define STATIC_DELAYED_OE (1 << 7)
|
||||
#define STATIC_WRITE_CYCLE_SHIFT 8
|
||||
#define STATIC_WRITE_PULSE_SHIFT 16
|
||||
#define STATIC_WRITE_BURST_EN (1 << 23)
|
||||
#define STATIC_TURN_AROUND_SHIFT 24
|
||||
#define STATIC_BUFFER_PRESENT (1 << 28)
|
||||
#define STATIC_READ_BURST_EN (1 << 29)
|
||||
#define STATIC_BUS_WIDTH8 (0 << 30)
|
||||
#define STATIC_BUS_WIDTH16 (1 << 30)
|
||||
#define STATIC_BUS_WIDTH32 (2 << 30)
|
||||
|
||||
void nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
unsigned long nandaddr = (unsigned long) this->IO_ADDR_W;
|
||||
|
||||
if (ctrl & NAND_CTRL_CHANGE) {
|
||||
nandaddr &= ~(BIT(NAND_ALE_ADDR_PIN) | BIT(NAND_CLE_ADDR_PIN));
|
||||
if (ctrl & NAND_CLE)
|
||||
nandaddr |= BIT(NAND_CLE_ADDR_PIN);
|
||||
else if (ctrl & NAND_ALE)
|
||||
nandaddr |= BIT(NAND_ALE_ADDR_PIN);
|
||||
this->IO_ADDR_W = (void __iomem *) nandaddr;
|
||||
}
|
||||
|
||||
if (cmd != NAND_CMD_NONE)
|
||||
writeb(cmd, (void __iomem *) nandaddr);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_BOOT_FROM_NAND)
|
||||
|
||||
int nand_dev_ready(struct mtd_info *mtd)
|
||||
{
|
||||
struct nand_chip *chip = mtd->priv;
|
||||
|
||||
udelay(chip->chip_delay);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
|
||||
{
|
||||
int i;
|
||||
struct nand_chip *chip = mtd->priv;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
buf[i] = readb(chip->IO_ADDR_R);
|
||||
}
|
||||
|
||||
void nand_dev_reset(struct nand_chip *chip)
|
||||
{
|
||||
writeb(NAND_CMD_RESET, chip->IO_ADDR_W + BIT(NAND_CLE_ADDR_PIN));
|
||||
udelay(chip->chip_delay);
|
||||
writeb(NAND_CMD_STATUS, chip->IO_ADDR_W + BIT(NAND_CLE_ADDR_PIN));
|
||||
while (!(readb(chip->IO_ADDR_R) & NAND_STATUS_READY)) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define nand_dev_reset(chip) /* framework will reset the chip anyway */
|
||||
#define nand_read_buf NULL /* framework will provide a default one */
|
||||
#define nand_dev_ready NULL /* dev_ready is optional */
|
||||
|
||||
#endif
|
||||
|
||||
int board_nand_init(struct nand_chip *chip)
|
||||
{
|
||||
/* Block reset Static core */
|
||||
reset_block(SYS_CTRL_RST_STATIC, 1);
|
||||
reset_block(SYS_CTRL_RST_STATIC, 0);
|
||||
|
||||
/* Enable clock to Static core */
|
||||
enable_clock(SYS_CTRL_CLK_STATIC);
|
||||
|
||||
/* enable flash support on static bus.
|
||||
* Enable static bus onto GPIOs, only CS0 */
|
||||
pinmux_set(PINMUX_BANK_MFA, 12, PINMUX_STATIC_DATA0);
|
||||
pinmux_set(PINMUX_BANK_MFA, 13, PINMUX_STATIC_DATA1);
|
||||
pinmux_set(PINMUX_BANK_MFA, 14, PINMUX_STATIC_DATA2);
|
||||
pinmux_set(PINMUX_BANK_MFA, 15, PINMUX_STATIC_DATA3);
|
||||
pinmux_set(PINMUX_BANK_MFA, 16, PINMUX_STATIC_DATA4);
|
||||
pinmux_set(PINMUX_BANK_MFA, 17, PINMUX_STATIC_DATA5);
|
||||
pinmux_set(PINMUX_BANK_MFA, 18, PINMUX_STATIC_DATA6);
|
||||
pinmux_set(PINMUX_BANK_MFA, 19, PINMUX_STATIC_DATA7);
|
||||
|
||||
pinmux_set(PINMUX_BANK_MFA, 20, PINMUX_STATIC_NWE);
|
||||
pinmux_set(PINMUX_BANK_MFA, 21, PINMUX_STATIC_NOE);
|
||||
pinmux_set(PINMUX_BANK_MFA, 22, PINMUX_STATIC_NCS);
|
||||
pinmux_set(PINMUX_BANK_MFA, 23, PINMUX_STATIC_ADDR18);
|
||||
pinmux_set(PINMUX_BANK_MFA, 24, PINMUX_STATIC_ADDR19);
|
||||
|
||||
/* Setup the static bus CS0 to access FLASH */
|
||||
|
||||
writel((0x3f << STATIC_READ_CYCLE_SHIFT)
|
||||
| (0x3f << STATIC_WRITE_CYCLE_SHIFT)
|
||||
| (0x1f << STATIC_WRITE_PULSE_SHIFT)
|
||||
| (0x03 << STATIC_TURN_AROUND_SHIFT) |
|
||||
STATIC_BUS_WIDTH16,
|
||||
STATIC_CTL_BANK0);
|
||||
|
||||
chip->cmd_ctrl = nand_hwcontrol;
|
||||
chip->ecc.mode = NAND_ECC_SOFT;
|
||||
chip->chip_delay = 30;
|
||||
chip->dev_ready = nand_dev_ready;
|
||||
chip->read_buf = nand_read_buf;
|
||||
|
||||
nand_dev_reset(chip);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int board_init(void)
|
||||
{
|
||||
gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
|
||||
gd->bd->bi_arch_number = MACH_TYPE_OXNAS;
|
||||
|
||||
/* assume uart is already initialized by SPL */
|
||||
|
||||
#if defined(CONFIG_START_IDE)
|
||||
puts("IDE: ");
|
||||
ide_init();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* copied from board/evb64260/sdram_init.c */
|
||||
/*
|
||||
* Check memory range for valid RAM. A simple memory test determines
|
||||
* the actually available RAM size between addresses `base' and
|
||||
* `base + maxsize'. Some (not all) hardware errors are detected:
|
||||
* - short between address lines
|
||||
* - short between data lines
|
||||
*/
|
||||
static long int dram_size (long int *base, long int maxsize)
|
||||
{
|
||||
volatile long int *addr, *b = base;
|
||||
long int cnt, val, save1, save2;
|
||||
|
||||
#define STARTVAL (CONFIG_MIN_SDRAM_SIZE / 2) /* start test at half size */
|
||||
for (cnt = STARTVAL / sizeof (long); cnt < maxsize / sizeof (long);
|
||||
cnt <<= 1) {
|
||||
addr = base + cnt; /* pointer arith! */
|
||||
|
||||
save1 = *addr; /* save contents of addr */
|
||||
save2 = *b; /* save contents of base */
|
||||
|
||||
*addr = cnt; /* write cnt to addr */
|
||||
*b = 0; /* put null at base */
|
||||
|
||||
/* check at base address */
|
||||
if ((*b) != 0) {
|
||||
*addr = save1; /* restore *addr */
|
||||
*b = save2; /* restore *b */
|
||||
return (0);
|
||||
}
|
||||
val = *addr; /* read *addr */
|
||||
|
||||
*addr = save1;
|
||||
*b = save2;
|
||||
|
||||
if (val != cnt) {
|
||||
/* fix boundary condition.. STARTVAL means zero */
|
||||
if (cnt == STARTVAL / sizeof (long))
|
||||
cnt = 0;
|
||||
return (cnt * sizeof (long));
|
||||
}
|
||||
}
|
||||
return maxsize;
|
||||
}
|
||||
|
||||
int dram_init(void)
|
||||
{
|
||||
gd->ram_size = dram_size((long int *)CONFIG_SYS_SDRAM_BASE,
|
||||
CONFIG_MAX_SDRAM_SIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int board_eth_init(bd_t *bis)
|
||||
{
|
||||
u32 value;
|
||||
|
||||
/* set the pin multiplexers to enable talking to Ethernent Phys */
|
||||
pinmux_set(PINMUX_BANK_MFA, 3, PINMUX_MACA_MDC);
|
||||
pinmux_set(PINMUX_BANK_MFA, 4, PINMUX_MACA_MDIO);
|
||||
|
||||
// Ensure the MAC block is properly reset
|
||||
reset_block(SYS_CTRL_RST_MAC, 1);
|
||||
udelay(10);
|
||||
reset_block(SYS_CTRL_RST_MAC, 0);
|
||||
|
||||
// Enable the clock to the MAC block
|
||||
enable_clock(SYS_CTRL_CLK_MAC);
|
||||
|
||||
value = readl(SYS_CTRL_GMAC_CTRL);
|
||||
/* Use simple mux for 25/125 Mhz clock switching */
|
||||
value |= BIT(SYS_CTRL_GMAC_SIMPLE_MUX);
|
||||
/* Enable GMII_GTXCLK to follow GMII_REFCLK - required for gigabit PHY */
|
||||
value |= BIT(SYS_CTRL_GMAC_CKEN_GTX);
|
||||
/* set auto tx speed */
|
||||
value |= BIT(SYS_CTRL_GMAC_AUTOSPEED);
|
||||
|
||||
writel(value, SYS_CTRL_GMAC_CTRL);
|
||||
|
||||
return designware_initialize(MAC_BASE, PHY_INTERFACE_MODE_RGMII);
|
||||
}
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
.section .init
|
||||
.globl _spl_start
|
||||
_spl_start:
|
||||
b _start
|
||||
b _start+0x4
|
||||
b _start+0x8
|
||||
b _start+0xc
|
||||
b _start+0x10
|
||||
b _start+0x14
|
||||
b _start+0x18
|
||||
b _start+0x1c
|
||||
.space 0x30 - (. - _spl_start)
|
||||
.ascii "BOOT" /* 0x30 signature*/
|
||||
.word 0x50 /* 0x34 header size itself */
|
||||
.word 0 /* 0x38 */
|
||||
.word 0x5000f000 /* boot report location */
|
||||
.word _start /* 0x40 */
|
||||
|
||||
main_crc_size: .word code_size /* 0x44 filled by linker */
|
||||
main_crc: .word 0 /* 0x48 fill later */
|
||||
header_crc: .word 0 /* 0x4C header crc*/
|
||||
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
|
||||
* on behalf of DENX Software Engineering GmbH
|
||||
*
|
||||
* January 2004 - Changed to support H4 device
|
||||
* Copyright (c) 2004-2008 Texas Instruments
|
||||
*
|
||||
* (C) Copyright 2002
|
||||
* Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
sram (rwx) : ORIGIN = CONFIG_SPL_TEXT_BASE, LENGTH = CONFIG_SPL_MAX_SIZE
|
||||
dram : ORIGIN = CONFIG_SPL_BSS_DRAM_START, LENGTH = CONFIG_SPL_BSS_DRAM_SIZE
|
||||
}
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_spl_start)
|
||||
SECTIONS
|
||||
{
|
||||
.text.0 :
|
||||
{
|
||||
*(.init*)
|
||||
}
|
||||
|
||||
|
||||
/* Start of the rest of the SPL */
|
||||
code_start = . ;
|
||||
|
||||
.text.1 :
|
||||
{
|
||||
*(.text*)
|
||||
}
|
||||
|
||||
. = ALIGN(4);
|
||||
.rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
|
||||
|
||||
. = ALIGN(4);
|
||||
.data : {
|
||||
*(.data*)
|
||||
}
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
__image_copy_end = .;
|
||||
code_size = . - code_start;
|
||||
|
||||
.rel.dyn : {
|
||||
__rel_dyn_start = .;
|
||||
*(.rel*)
|
||||
__rel_dyn_end = .;
|
||||
}
|
||||
|
||||
. = ALIGN(0x800);
|
||||
|
||||
_end = .;
|
||||
|
||||
.bss.sram __rel_dyn_start (OVERLAY) : {
|
||||
__bss_start = .;
|
||||
*(.bss.stdio_devices)
|
||||
*(.bss.serial_current)
|
||||
. = ALIGN(4);
|
||||
__bss_end = .;
|
||||
}
|
||||
|
||||
.bss : {
|
||||
__bss_dram_start = .;
|
||||
*(.bss*)
|
||||
__bss_dram_end = .;
|
||||
} > dram
|
||||
|
||||
/DISCARD/ : { *(.bss*) }
|
||||
/DISCARD/ : { *(.dynsym) }
|
||||
/DISCARD/ : { *(.dynstr*) }
|
||||
/DISCARD/ : { *(.dynsym*) }
|
||||
/DISCARD/ : { *(.dynamic*) }
|
||||
/DISCARD/ : { *(.hash*) }
|
||||
/DISCARD/ : { *(.plt*) }
|
||||
/DISCARD/ : { *(.interp*) }
|
||||
/DISCARD/ : { *(.gnu*) }
|
||||
}
|
||||
@ -1,116 +0,0 @@
|
||||
/*
|
||||
* (c) Copyright 2011 by Tigris Elektronik GmbH
|
||||
*
|
||||
* Author:
|
||||
* Maximilian Schwerin <mvs@tigris.de>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
|
||||
#include <command.h>
|
||||
#include <environment.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <malloc.h>
|
||||
#include <search.h>
|
||||
#include <errno.h>
|
||||
#include <ext4fs.h>
|
||||
|
||||
char *env_name_spec = "EXT4";
|
||||
|
||||
env_t *env_ptr;
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
int env_init(void)
|
||||
{
|
||||
/* use default */
|
||||
gd->env_addr = (ulong)&default_environment[0];
|
||||
gd->env_valid = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CMD_SAVEENV
|
||||
int saveenv(void)
|
||||
{
|
||||
env_t env_new;
|
||||
ssize_t len;
|
||||
char *res;
|
||||
block_dev_desc_t *dev_desc = NULL;
|
||||
int dev = EXT4_ENV_DEVICE;
|
||||
int part = EXT4_ENV_PART;
|
||||
int err;
|
||||
|
||||
res = (char *)&env_new.data;
|
||||
len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
|
||||
if (len < 0) {
|
||||
error("Cannot export environment: errno = %d\n", errno);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dev_desc = get_dev(EXT4_ENV_INTERFACE, dev);
|
||||
if (dev_desc == NULL) {
|
||||
printf("Failed to find %s%d\n",
|
||||
EXT4_ENV_INTERFACE, dev);
|
||||
return 1;
|
||||
}
|
||||
|
||||
err = ext4_register_device(dev_desc, part);
|
||||
if (err) {
|
||||
printf("Failed to register %s%d:%d\n",
|
||||
EXT4_ENV_INTERFACE, dev, part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
env_new.crc = crc32(0, env_new.data, ENV_SIZE);
|
||||
err = ext4fs_write(EXT4_ENV_FILE, (void *)&env_new, sizeof(env_t));
|
||||
ext4fs_close();
|
||||
if (err == -1) {
|
||||
printf("\n** Unable to write \"%s\" from %s%d:%d **\n",
|
||||
EXT4_ENV_FILE, EXT4_ENV_INTERFACE, dev, part);
|
||||
return 1;
|
||||
}
|
||||
|
||||
puts("done\n");
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_CMD_SAVEENV */
|
||||
|
||||
void env_relocate_spec(void)
|
||||
{
|
||||
char buf[CONFIG_ENV_SIZE];
|
||||
block_dev_desc_t *dev_desc = NULL;
|
||||
int dev = EXT4_ENV_DEVICE;
|
||||
int part = EXT4_ENV_PART;
|
||||
int err;
|
||||
|
||||
dev_desc = get_dev(EXT4_ENV_INTERFACE, dev);
|
||||
if (dev_desc == NULL) {
|
||||
printf("Failed to find %s%d\n",
|
||||
EXT4_ENV_INTERFACE, dev);
|
||||
set_default_env(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
err = ext4_register_device(dev_desc, part);
|
||||
if (err) {
|
||||
printf("Failed to register %s%d:%d\n",
|
||||
EXT4_ENV_INTERFACE, dev, part);
|
||||
set_default_env(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
err = ext4_read_file(EXT4_ENV_FILE, (uchar *)&buf, 0, CONFIG_ENV_SIZE);
|
||||
ext4fs_close();
|
||||
|
||||
if (err == -1) {
|
||||
printf("\n** Unable to read \"%s\" from %s%d:%d **\n",
|
||||
EXT4_ENV_FILE, EXT4_ENV_INTERFACE, dev, part);
|
||||
set_default_env(NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
env_import(buf, 1);
|
||||
}
|
||||
@ -1,236 +0,0 @@
|
||||
/*
|
||||
* (C) Copyright 2013
|
||||
*
|
||||
* Ma Haijun <mahaijuns@gmail.com>
|
||||
*
|
||||
* See file CREDITS for list of people who contributed to this
|
||||
* project.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*/
|
||||
#include <common.h>
|
||||
#include <spl.h>
|
||||
#include <asm/u-boot.h>
|
||||
#include <asm/utils.h>
|
||||
#include <version.h>
|
||||
#include <part.h>
|
||||
#include <fat.h>
|
||||
#include <ext4fs.h>
|
||||
|
||||
/* should be implemented by board */
|
||||
extern void spl_block_device_init(void);
|
||||
|
||||
block_dev_desc_t * spl_get_block_device(void)
|
||||
{
|
||||
block_dev_desc_t * device;
|
||||
|
||||
spl_block_device_init();
|
||||
|
||||
device = get_dev(CONFIG_SPL_BLOCKDEV_INTERFACE, CONFIG_SPL_BLOCKDEV_ID);
|
||||
if (!device) {
|
||||
printf("blk device %s%d not exists\n",
|
||||
CONFIG_SPL_BLOCKDEV_INTERFACE,
|
||||
CONFIG_SPL_BLOCKDEV_ID);
|
||||
hang();
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_FAT_SUPPORT
|
||||
static int block_load_image_fat(const char *filename)
|
||||
{
|
||||
int err;
|
||||
struct image_header *header;
|
||||
|
||||
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
|
||||
sizeof(struct image_header));
|
||||
|
||||
err = file_fat_read(filename, header, sizeof(struct image_header));
|
||||
if (err <= 0)
|
||||
goto end;
|
||||
|
||||
spl_parse_image_header(header);
|
||||
|
||||
err = file_fat_read(filename, (u8 *)spl_image.load_addr, 0);
|
||||
|
||||
end:
|
||||
if (err <= 0)
|
||||
printf("spl: error reading image %s, err - %d\n",
|
||||
filename, err);
|
||||
|
||||
return (err <= 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_OS_BOOT
|
||||
static int block_load_image_fat_os(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = file_fat_read(CONFIG_SPL_FAT_LOAD_ARGS_NAME,
|
||||
(void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
|
||||
if (err <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return block_load_image_fat(CONFIG_SPL_FAT_LOAD_KERNEL_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
void spl_block_load_image(void)
|
||||
{
|
||||
int err;
|
||||
block_dev_desc_t * device;
|
||||
|
||||
device = spl_get_block_device();
|
||||
err = fat_register_device(device, CONFIG_BLOCKDEV_FAT_BOOT_PARTITION);
|
||||
if (err) {
|
||||
printf("spl: fat register err - %d\n", err);
|
||||
hang();
|
||||
}
|
||||
#ifdef CONFIG_SPL_OS_BOOT
|
||||
if (spl_start_uboot() || block_load_image_fat_os())
|
||||
#endif
|
||||
{
|
||||
err = block_load_image_fat(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME);
|
||||
if (err)
|
||||
hang();
|
||||
}
|
||||
}
|
||||
#elif defined(CONFIG_SPL_EXT4_SUPPORT) /* end CONFIG_SPL_FAT_SUPPORT */
|
||||
static int block_load_image_ext4(const char *filename)
|
||||
{
|
||||
int err;
|
||||
struct image_header *header;
|
||||
|
||||
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
|
||||
sizeof(struct image_header));
|
||||
|
||||
err = ext4_read_file(filename, header, 0, sizeof(struct image_header));
|
||||
if (err <= 0)
|
||||
goto end;
|
||||
|
||||
spl_parse_image_header(header);
|
||||
|
||||
err = ext4_read_file(filename, (u8 *)spl_image.load_addr, 0, 0);
|
||||
|
||||
end:
|
||||
return (err <= 0);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_OS_BOOT
|
||||
static int block_load_image_ext4_os(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = ext4_read_file(CONFIG_SPL_EXT4_LOAD_ARGS_NAME,
|
||||
(void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, 0);
|
||||
if (err <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return block_load_image_ext4(CONFIG_SPL_EXT4_LOAD_KERNEL_NAME);
|
||||
}
|
||||
#endif
|
||||
|
||||
void spl_block_load_image(void)
|
||||
{
|
||||
int err;
|
||||
block_dev_desc_t * device;
|
||||
|
||||
device = spl_get_block_device();
|
||||
err = ext4_register_device(device, CONFIG_BLOCKDEV_EXT4_BOOT_PARTITION);
|
||||
if (err) {
|
||||
hang();
|
||||
}
|
||||
#ifdef CONFIG_SPL_OS_BOOT
|
||||
if (spl_start_uboot() || block_load_image_ext4_os())
|
||||
#endif
|
||||
{
|
||||
err = block_load_image_ext4(CONFIG_SPL_EXT4_LOAD_PAYLOAD_NAME);
|
||||
if (err)
|
||||
hang();
|
||||
}
|
||||
}
|
||||
#else /* end CONFIG_SPL_EXT4_SUPPORT */
|
||||
static int block_load_image_raw(block_dev_desc_t * device, lbaint_t sector)
|
||||
{
|
||||
int n;
|
||||
u32 image_size_sectors;
|
||||
struct image_header *header;
|
||||
|
||||
header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
|
||||
sizeof(struct image_header));
|
||||
|
||||
/* read image header to find the image size & load address */
|
||||
n = device->block_read(device->dev, sector, 1, header);
|
||||
|
||||
if (n != 1) {
|
||||
printf("spl: blk read err\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
spl_parse_image_header(header);
|
||||
|
||||
/* convert size to sectors - round up */
|
||||
image_size_sectors = (spl_image.size + 512 - 1) / 512;
|
||||
n = device->block_read(device->dev, sector, image_size_sectors,
|
||||
(void *)spl_image.load_addr);
|
||||
|
||||
if (n != image_size_sectors) {
|
||||
printf("spl: blk read err\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPL_OS_BOOT
|
||||
static int block_load_image_raw_os(block_dev_desc_t * device)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = device->block_read(device->dev, CONFIG_SYS_BLOCK_RAW_MODE_ARGS_SECTOR,
|
||||
CONFIG_SYS_BLOCK_RAW_MODE_ARGS_SECTORS,
|
||||
(u32 *)CONFIG_SYS_SPL_ARGS_ADDR);
|
||||
/* flush cache after read */
|
||||
flush_cache(addr, CONFIG_SYS_BLOCK_RAW_MODE_ARGS_SECTORS * 512);
|
||||
|
||||
if (n != CONFIG_SYS_BLOCK_RAW_MODE_ARGS_SECTORS) {
|
||||
printf("args blk read error\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return block_load_image_raw(device, CONFIG_SYS_BLOCK_RAW_MODE_KERNEL_SECTOR);
|
||||
}
|
||||
#endif
|
||||
|
||||
void spl_block_load_image(void)
|
||||
{
|
||||
int err;
|
||||
block_dev_desc_t * device;
|
||||
|
||||
device = spl_get_block_device();
|
||||
#ifdef CONFIG_SPL_OS_BOOT
|
||||
if (spl_start_uboot() || block_load_image_raw_os(device))
|
||||
#endif
|
||||
{
|
||||
err = block_load_image_raw(device,
|
||||
CONFIG_SYS_BLOCK_RAW_MODE_U_BOOT_SECTOR);
|
||||
if (err)
|
||||
hang();
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_SPL_FAT_SUPPORT */
|
||||
@ -1,3 +0,0 @@
|
||||
CONFIG_ARM=y
|
||||
CONFIG_OX820=y
|
||||
CONFIG_TARGET_OX820=y
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* drivers/usb/host/ehci-oxnas.c
|
||||
*
|
||||
* Tzachi Perelstein <tzachi@marvell.com>
|
||||
*
|
||||
* This file is licensed under the terms of the GNU General Public
|
||||
* License version 2. This program is licensed "as is" without any
|
||||
* warranty of any kind, whether express or implied.
|
||||
*/
|
||||
#include <common.h>
|
||||
#include <asm/arch/hardware.h>
|
||||
#include <asm/arch/sysctl.h>
|
||||
#include <asm/arch/clock.h>
|
||||
|
||||
#include "ehci.h"
|
||||
|
||||
static struct ehci_hcor *ghcor;
|
||||
|
||||
static int start_oxnas_usb_ehci(void)
|
||||
{
|
||||
#ifdef CONFIG_USB_PLLB_CLK
|
||||
reset_block(SYS_CTRL_RST_PLLB, 0);
|
||||
enable_clock(SYS_CTRL_CLK_REF600);
|
||||
|
||||
writel((1 << PLLB_ENSAT) | (1 << PLLB_OUTDIV) | (2 << PLLB_REFDIV),
|
||||
SEC_CTRL_PLLB_CTRL0);
|
||||
/* 600MHz pllb divider for 12MHz */
|
||||
writel(PLLB_DIV_INT(50) | PLLB_DIV_FRAC(0), SEC_CTRL_PLLB_DIV_CTRL);
|
||||
#else
|
||||
/* ref 300 divider for 12MHz */
|
||||
writel(REF300_DIV_INT(25) | REF300_DIV_FRAC(0), SYS_CTRL_REF300_DIV);
|
||||
#endif
|
||||
|
||||
/* Ensure the USB block is properly reset */
|
||||
reset_block(SYS_CTRL_RST_USBHS, 1);
|
||||
reset_block(SYS_CTRL_RST_USBHS, 0);
|
||||
|
||||
reset_block(SYS_CTRL_RST_USBHSPHYA, 1);
|
||||
reset_block(SYS_CTRL_RST_USBHSPHYA, 0);
|
||||
|
||||
reset_block(SYS_CTRL_RST_USBHSPHYB, 1);
|
||||
reset_block(SYS_CTRL_RST_USBHSPHYB, 0);
|
||||
|
||||
/* Force the high speed clock to be generated all the time, via serial
|
||||
programming of the USB HS PHY */
|
||||
writel((2UL << USBHSPHY_TEST_ADD) |
|
||||
(0xe0UL << USBHSPHY_TEST_DIN), SYS_CTRL_USBHSPHY_CTRL);
|
||||
|
||||
writel((1UL << USBHSPHY_TEST_CLK) |
|
||||
(2UL << USBHSPHY_TEST_ADD) |
|
||||
(0xe0UL << USBHSPHY_TEST_DIN), SYS_CTRL_USBHSPHY_CTRL);
|
||||
|
||||
writel((0xfUL << USBHSPHY_TEST_ADD) |
|
||||
(0xaaUL << USBHSPHY_TEST_DIN), SYS_CTRL_USBHSPHY_CTRL);
|
||||
|
||||
writel((1UL << USBHSPHY_TEST_CLK) |
|
||||
(0xfUL << USBHSPHY_TEST_ADD) |
|
||||
(0xaaUL << USBHSPHY_TEST_DIN), SYS_CTRL_USBHSPHY_CTRL);
|
||||
|
||||
#ifdef CONFIG_USB_PLLB_CLK /* use pllb clock */
|
||||
writel(USB_CLK_INTERNAL | USB_INT_CLK_PLLB, SYS_CTRL_USB_CTRL);
|
||||
#else /* use ref300 derived clock */
|
||||
writel(USB_CLK_INTERNAL | USB_INT_CLK_REF300, SYS_CTRL_USB_CTRL);
|
||||
#endif
|
||||
/* Enable the clock to the USB block */
|
||||
enable_clock(SYS_CTRL_CLK_USBHS);
|
||||
|
||||
return 0;
|
||||
}
|
||||
int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,
|
||||
struct ehci_hcor **hcor)
|
||||
{
|
||||
start_oxnas_usb_ehci();
|
||||
*hccr = (struct ehci_hccr *)(USB_HOST_BASE + 0x100);
|
||||
*hcor = (struct ehci_hcor *)((uint32_t)*hccr +
|
||||
HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
|
||||
ghcor = *hcor;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ehci_hcd_stop(int index)
|
||||
{
|
||||
reset_block(SYS_CTRL_RST_USBHS, 1);
|
||||
disable_clock(SYS_CTRL_CLK_USBHS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern void __ehci_set_usbmode(int index);
|
||||
void ehci_set_usbmode(int index)
|
||||
{
|
||||
#define or_txttfill_tuning _reserved_1_[0]
|
||||
u32 tmp;
|
||||
|
||||
__ehci_set_usbmode(index);
|
||||
|
||||
tmp = ehci_readl(&ghcor->or_txfilltuning);
|
||||
tmp &= ~0x00ff0000;
|
||||
tmp |= 0x003f0000; /* set burst pre load count to 0x40 (63 * 4 bytes) */
|
||||
tmp |= 0x16; /* set sheduler overhead to 22 * 1.267us (HS) or 22 * 6.33us (FS/LS)*/
|
||||
ehci_writel(&ghcor->or_txfilltuning, tmp);
|
||||
|
||||
tmp = ehci_readl(&ghcor->or_txttfill_tuning);
|
||||
tmp |= 0x2; /* set sheduler overhead to 2 * 6.333us */
|
||||
ehci_writel(&ghcor->or_txttfill_tuning, tmp);
|
||||
}
|
||||
@ -1,384 +0,0 @@
|
||||
#ifndef __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
|
||||
/* High Level Configuration Options */
|
||||
#define CONFIG_ARM1136
|
||||
#define CONFIG_OX820
|
||||
#define CONFIG_SYS_GENERIC_BOARD
|
||||
#define CONFIG_BOARD_EARLY_INIT_F
|
||||
|
||||
#include <asm/arch/cpu.h> /* get chip and board defs */
|
||||
|
||||
/* make cmd_ide.c quiet when compile */
|
||||
#define __io
|
||||
|
||||
/*#define CONFIG_ARCH_CPU_INIT*/
|
||||
/*#define CONFIG_DISPLAY_CPUINFO*/
|
||||
/*#define CONFIG_DISPLAY_BOARDINFO*/
|
||||
/*#define CONFIG_BOARD_EARLY_INIT_F*/
|
||||
/*#define CONFIG_SKIP_LOWLEVEL_INIT*/
|
||||
|
||||
/* mem */
|
||||
#define CONFIG_SYS_SDRAM_BASE 0x60000000
|
||||
#define CONFIG_NR_DRAM_BANKS 1
|
||||
#define CONFIG_MIN_SDRAM_SIZE (128 * 1024 * 1024) /* 128 MB */
|
||||
#define CONFIG_MAX_SDRAM_SIZE (512 * 1024 * 1024) /* 512 MB */
|
||||
#define CONFIG_SRAM_BASE 0x50000000
|
||||
#define CONFIG_SRAM_SIZE (64 * 1024)
|
||||
|
||||
/* need do dma so better keep dcache off */
|
||||
#define CONFIG_SYS_DCACHE_OFF
|
||||
|
||||
/* clock */
|
||||
#define CONFIG_PLLA_FREQ_MHZ 800
|
||||
#define CONFIG_RPSCLK 6250000
|
||||
#define CONFIG_SYS_HZ 1000
|
||||
#define CONFIG_SYS_CLK_FREQ CONFIG_RPSCLK
|
||||
#define CONFIG_SYS_TIMERBASE TIMER1_BASE
|
||||
#define CONFIG_TIMER_PRESCALE TIMER_PRESCALE_16
|
||||
|
||||
/* serial */
|
||||
#define CONFIG_SYS_NS16550
|
||||
#define CONFIG_SYS_NS16550_SERIAL
|
||||
#define CONFIG_SYS_NS16550_CLK CONFIG_RPSCLK
|
||||
#define CONFIG_SYS_NS16550_REG_SIZE 1
|
||||
#define CONFIG_BAUDRATE 115200
|
||||
#define CONFIG_SYS_NS16550_COM1 UART_1_BASE
|
||||
#define CONFIG_CONS_INDEX 1
|
||||
|
||||
/* ide */
|
||||
#define CONFIG_SYS_ATA_BASE_ADDR 0
|
||||
#define CONFIG_SYS_ATA_DATA_OFFSET 0
|
||||
#define CONFIG_SYS_ATA_REG_OFFSET 0
|
||||
#define CONFIG_SYS_ATA_ALT_OFFSET 0
|
||||
#define CONFIG_IDE_PLX
|
||||
#define CONFIG_SYS_IDE_MAXDEVICE 2
|
||||
#define CONFIG_SYS_IDE_MAXBUS 1
|
||||
#define CONFIG_IDE_PREINIT
|
||||
#define CONFIG_LBA48
|
||||
|
||||
/* nand */
|
||||
#define CONFIG_NAND
|
||||
#define CONFIG_SYS_MAX_NAND_DEVICE 1
|
||||
#define CONFIG_SYS_NAND_BASE STATIC_CS0_BASE
|
||||
#define NAND_CLE_ADDR_PIN 19
|
||||
#define NAND_ALE_ADDR_PIN 18
|
||||
#define MTDPARTS_DEFAULT "mtdparts=41000000.nand:" \
|
||||
"14m(boot)," \
|
||||
"-(ubi)"
|
||||
#define MTDIDS_DEFAULT "nand0=41000000.nand"
|
||||
#define UBIPART_DEFAULT "ubi"
|
||||
|
||||
/* net */
|
||||
#define CONFIG_DESIGNWARE_ETH
|
||||
#define CONFIG_DW_ALTDESCRIPTOR
|
||||
#define CONFIG_MII
|
||||
#define CONFIG_CMD_MII
|
||||
#define CONFIG_PHYLIB
|
||||
#define CONFIG_PHY_REALTEK
|
||||
#define CONFIG_PHY_ICPLUS
|
||||
|
||||
/* spl */
|
||||
#ifdef CONFIG_SPL_BUILD
|
||||
#define USE_DL_PREFIX /* rename malloc free etc, so we can override them */
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOOT_FROM_NAND) || defined(CONFIG_BOOT_FROM_SATA)
|
||||
#define CONFIG_SPL
|
||||
#define CONFIG_SPL_FRAMEWORK
|
||||
#define CONFIG_SPL_LIBCOMMON_SUPPORT
|
||||
#define CONFIG_SPL_SERIAL_SUPPORT
|
||||
#define CONFIG_SPL_LIBGENERIC_SUPPORT
|
||||
#define CONFIG_SPL_TEXT_BASE 0x50000000
|
||||
#define CONFIG_SPL_STACK (CONFIG_SRAM_BASE + (48 * 1024))
|
||||
#define CONFIG_SPL_DISPLAY_PRINT
|
||||
#define CONFIG_SPL_BSS_DRAM_START 0x65000000
|
||||
#define CONFIG_SPL_BSS_DRAM_SIZE 0x01000000
|
||||
#define CONFIG_SPL_MALLOC_START 0x66000000
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BOOT_FROM_NAND)
|
||||
#define CONFIG_SPL_NAND_SUPPORT
|
||||
#define BOOT_DEVICE_TYPE "NAND"
|
||||
#define BOOT_DEVICE_NAND 0xfeedbacc
|
||||
#define CONFIG_SPL_BOOT_DEVICE BOOT_DEVICE_NAND
|
||||
#define CONFIG_SPL_NAND_SIMPLE
|
||||
#define CONFIG_SPL_NAND_ECC
|
||||
#define CONFIG_SPL_NAND_SOFTECC
|
||||
#define CONFIG_SYS_NAND_ECCSIZE 512
|
||||
#define CONFIG_SYS_NAND_ECCBYTES 6
|
||||
#define CONFIG_SYS_NAND_ECCPOS {40, 41, 42, 43, 44, 45, 46, 47, \
|
||||
48, 49, 50, 51, 52, 53, 54, 55, \
|
||||
56, 57, 58, 59, 60, 61, 62, 63}
|
||||
#define CONFIG_SYS_NAND_PAGE_SIZE 2048
|
||||
#define CONFIG_SYS_NAND_OOBSIZE 64
|
||||
#define CONFIG_SYS_NAND_BLOCK_SIZE (128 * 1024)
|
||||
#define CONFIG_SYS_NAND_BAD_BLOCK_POS 0
|
||||
/* pages per erase block */
|
||||
#define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / CONFIG_SYS_NAND_PAGE_SIZE)
|
||||
/* nand spl use 1 erase block, and use bit to byte encode for reliability */
|
||||
#define CONFIG_SPL_MAX_SIZE (128 * 1024 / 8)
|
||||
#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x00040000
|
||||
/* spl kernel load is not enabled */
|
||||
#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS 0x00200000
|
||||
#define CONFIG_CMD_SPL_NAND_OFS 0
|
||||
#define CONFIG_CMD_SPL_WRITE_SIZE 1024
|
||||
#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + 0x100)
|
||||
/* CONFIG_BOOT_FROM_NAND end */
|
||||
|
||||
#elif defined(CONFIG_BOOT_FROM_SATA)
|
||||
#define CONFIG_SPL_BLOCK_SUPPORT
|
||||
#define BOOT_DEVICE_TYPE "SATA"
|
||||
#define BOOT_DEVICE_BLOCK 860202
|
||||
#define CONFIG_SPL_BOOT_DEVICE BOOT_DEVICE_BLOCK
|
||||
#define CONFIG_SPL_MAX_SIZE (36 * 1024)
|
||||
#define CONFIG_SPL_LIBDISK_SUPPORT
|
||||
#define CONFIG_SPL_BLOCKDEV_INTERFACE "ide"
|
||||
#define CONFIG_SPL_BLOCKDEV_ID 0
|
||||
|
||||
#ifdef CONFIG_BOOT_FROM_FAT /* u-boot in fat partition */
|
||||
|
||||
#define CONFIG_SPL_FAT_SUPPORT
|
||||
|
||||
#define CONFIG_BLOCKDEV_FAT_BOOT_PARTITION 1 /* first partition */
|
||||
#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME "u-boot.img" /* u-boot file name */
|
||||
/* enable U-Boot Falcon Mode */
|
||||
#define CONFIG_CMD_SPL
|
||||
#define CONFIG_SPL_OS_BOOT
|
||||
#define CONFIG_SPL_FAT_LOAD_ARGS_NAME "bootargs.bin" /* boot parameters */
|
||||
#define CONFIG_SPL_FAT_LOAD_KERNEL_NAME "falcon.img" /* kernel */
|
||||
#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + 0x100)
|
||||
|
||||
#elif CONFIG_BOOT_FROM_EXT4
|
||||
|
||||
#define CONFIG_SPL_EXT4_SUPPORT
|
||||
#define CONFIG_BLOCKDEV_EXT4_BOOT_PARTITION 1 /* first partition */
|
||||
#define CONFIG_SPL_EXT4_LOAD_PAYLOAD_NAME "/boot/u-boot.img" /* u-boot file name */
|
||||
/* enable U-Boot Falcon Mode */
|
||||
#define CONFIG_CMD_SPL
|
||||
#define CONFIG_SPL_OS_BOOT
|
||||
#define CONFIG_SPL_EXT4_LOAD_ARGS_NAME "/boot/bootargs.bin" /* boot parameters */
|
||||
#define CONFIG_SPL_EXT4_LOAD_KERNEL_NAME "/boot/falcon.img" /* kernel */
|
||||
#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + 0x100)
|
||||
|
||||
#else /* u-boot in raw sectors */
|
||||
|
||||
#define CONFIG_SYS_BLOCK_RAW_MODE_U_BOOT_SECTOR 1024
|
||||
/* spl kernel load is not enabled */
|
||||
#define CONFIG_SYS_BLOCK_RAW_MODE_KERNEL_SECTOR 4096
|
||||
#define CONFIG_SYS_BLOCK_RAW_MODE_ARGS_SECTOR 0
|
||||
#define CONFIG_SYS_BLOCK_RAW_MODE_ARGS_SECTORS (1024 / 512)
|
||||
#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + 0x100)
|
||||
|
||||
#endif /* CONFIG_BOOT_FROM_FAT */
|
||||
/* CONFIG_BOOT_FROM_SATA end */
|
||||
|
||||
#else
|
||||
/* generic, no spl support */
|
||||
#endif
|
||||
|
||||
/* boot */
|
||||
#define CONFIG_IDENT_STRING " for OXNAS"
|
||||
#define CONFIG_MACH_TYPE MACH_TYPE_OXNAS
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
/* Enable devicetree support */
|
||||
#define CONFIG_OF_LIBFDT
|
||||
#endif
|
||||
#define CONFIG_SETUP_MEMORY_TAGS
|
||||
#define CONFIG_CMDLINE_TAG
|
||||
#define CONFIG_INITRD_TAG
|
||||
#define CONFIG_BOOTDELAY 1
|
||||
#define CONFIG_ZERO_BOOTDELAY_CHECK
|
||||
#define CONFIG_DEFAULT_CONSOLE_PARM "console=ttyS0,115200n8 earlyprintk=serial"
|
||||
/* Boot Argument Buffer Size */
|
||||
#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
|
||||
/* memtest works on */
|
||||
#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE)
|
||||
#define CONFIG_SYS_AUTOLOAD "no"
|
||||
|
||||
#define CONFIG_DEFAULT_CONSOLE CONFIG_DEFAULT_CONSOLE_PARM "\0"
|
||||
#define CONFIG_BOOTARGS CONFIG_DEFAULT_CONSOLE_PARM
|
||||
#define CONFIG_BOOTCOMMAND "run nandboot"
|
||||
#define CONFIG_BOOT_RETRY_TIME -1
|
||||
#define CONFIG_RESET_TO_RETRY 60
|
||||
|
||||
#define CONFIG_NETCONSOLE
|
||||
#define CONFIG_IPADDR 192.168.50.100
|
||||
#define CONFIG_SERVERIP 192.168.50.59
|
||||
|
||||
/* A sane default configuration...
|
||||
* When booting without a valid environment in ubi, first to loading and booting
|
||||
* the kernel image directly above U-Boot, maybe both were loaded there by
|
||||
* another bootloader.
|
||||
* Also use that same offset (0x90000) to load the rescue image later on (by
|
||||
* adding it onto the flash address where U-Boot is supposed to be stored by
|
||||
* the legacy loader, 0x440000, resulting in offset 0x4d0000 on the flash).
|
||||
* When coming up with a valid environment in ubi, first try to load the
|
||||
* kernel from a ubi volume kernel, if that fails, fallback to the rescue
|
||||
* image stored in boot partition. As a last resort try booting via
|
||||
* DHCP/TFTP.
|
||||
* In case there is no valid environment, first probe for a uimage in ram left
|
||||
* behind by the first bootloader on a tftp boot.
|
||||
* If that fails, switch to normal boot order and save environment.
|
||||
* The loader is supposed to be written to flash at offset 0x440000 and loaded to
|
||||
* RAM at 0x64000000
|
||||
*/
|
||||
#define CONFIG_EXTRA_ENV_SETTINGS \
|
||||
"load_kernel_ubi=ubi readvol 0x62000000 kernel;\0" \
|
||||
"load_kernel_rescue=nand read 0x62000000 0x4e0000 0x400000;\0" \
|
||||
"load_kernel_dhcp=dhcp 0x62000000 oxnas-rescue.bin;\0" \
|
||||
"boot_kernel=bootm 0x62000000;\0" \
|
||||
"boot_ubi=run load_kernel_ubi && run boot_kernel;\0" \
|
||||
"boot_rescue=run load_kernel_rescue && run boot_kernel;\0" \
|
||||
"boot_dhcp=run load_kernel_dhcp && run boot_kernel;\0" \
|
||||
"normalboot=run boot_ubi; run boot_rescue; run boot_dhcp;\0" \
|
||||
"firstboot=bootm 0x640a0000; setenv bootcmd run normalboot; " \
|
||||
"setenv firstboot; saveenv; run bootcmd; \0" \
|
||||
"bootcmd=run firstboot; \0" \
|
||||
"console=" CONFIG_DEFAULT_CONSOLE \
|
||||
"bootargs=" CONFIG_BOOTARGS "\0" \
|
||||
"mtdids=" MTDIDS_DEFAULT "\0" \
|
||||
"mtdparts=" MTDPARTS_DEFAULT "\0" \
|
||||
|
||||
/* env */
|
||||
#if defined(CONFIG_BOOT_FROM_NAND)
|
||||
#define CONFIG_ENV_IS_IN_NAND
|
||||
#define CONFIG_ENV_OFFSET 0x000C0000
|
||||
#define CONFIG_ENV_SIZE 0x00020000
|
||||
#define CONFIG_ENV_OFFSET_REDUND 0x00100000
|
||||
#define CONFIG_ENV_SIZE_REDUND 0x00020000
|
||||
#define CONFIG_ENV_RANGE (CONFIG_ENV_SIZE * 2)
|
||||
/* CONFIG_BOOT_FROM_NAND end */
|
||||
|
||||
#elif defined(CONFIG_BOOT_FROM_SATA)
|
||||
#ifdef CONFIG_BOOT_FROM_EXT4
|
||||
#define CONFIG_ENV_IS_IN_EXT4
|
||||
#define CONFIG_START_IDE
|
||||
#define EXT4_ENV_INTERFACE "ide"
|
||||
#define EXT4_ENV_DEVICE 0
|
||||
#define EXT4_ENV_PART 1
|
||||
#define EXT4_ENV_FILE "/boot/u-boot.env"
|
||||
#define CONFIG_ENV_SIZE (16 * 1024)
|
||||
#else
|
||||
#define CONFIG_ENV_IS_IN_FAT
|
||||
#define CONFIG_START_IDE
|
||||
#define FAT_ENV_INTERFACE "ide"
|
||||
#define FAT_ENV_DEVICE 0
|
||||
#define FAT_ENV_PART 1
|
||||
#define FAT_ENV_FILE "u-boot.env"
|
||||
#define CONFIG_ENV_SIZE (16 * 1024)
|
||||
#endif
|
||||
/* CONFIG_BOOT_FROM_SATA end */
|
||||
#elif defined(CONFIG_BOOT_FROM_SATA)
|
||||
|
||||
#else
|
||||
/* generic */
|
||||
#define CONFIG_ENV_IS_IN_UBI 1
|
||||
#define CONFIG_ENV_UBI_PART UBIPART_DEFAULT
|
||||
#define CONFIG_ENV_UBI_VOLUME "ubootenv"
|
||||
#define CONFIG_ENV_UBI_VOLUME_REDUND "ubootenv2"
|
||||
#define CONFIG_ENV_SIZE (16 * 1024)
|
||||
#endif
|
||||
|
||||
/* allow to overwrite serial and ethaddr */
|
||||
#define CONFIG_ENV_OVERWRITE
|
||||
|
||||
#define CONFIG_SYS_MONITOR_LEN (512 * 1024)
|
||||
#define CONFIG_SYS_TEXT_BASE 0x64000000
|
||||
#define CONFIG_SYS_INIT_SP_ADDR 0x65000000
|
||||
/* Size of malloc() pool */
|
||||
#define CONFIG_SYS_MALLOC_LEN (1 * 1024 * 1024)
|
||||
|
||||
/* Miscellaneous configurable options */
|
||||
#define CONFIG_SYS_LONGHELP /* undef to save memory */
|
||||
#define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */
|
||||
#define CONFIG_SYS_PROMPT "OX820 # "
|
||||
#define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size*/
|
||||
#define CONFIG_SYS_PBSIZE 1024 /* Print Buffer Size */
|
||||
#define CONFIG_SYS_MAXARGS 32 /* max number of command args */
|
||||
#define CONFIG_CMDLINE_EDITING
|
||||
#define CONFIG_AUTO_COMPLETE
|
||||
|
||||
/* usb */
|
||||
#define CONFIG_USB_MAX_CONTROLLER_COUNT 1
|
||||
#define CONFIG_USB_EHCI
|
||||
#define CONFIG_EHCI_IS_TDI
|
||||
/* #define CONFIG_USB_EHCI_TXFIFO_THRESH 0x3F */
|
||||
#define CONFIG_USB_PLLB_CLK
|
||||
#define CONFIG_USB_EHCI_OXNAS
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
#define CONFIG_USB_STORAGE
|
||||
#endif
|
||||
#define CONFIG_CMD_USB
|
||||
|
||||
/* cmds */
|
||||
#define CONFIG_SYS_NO_FLASH
|
||||
#include <config_cmd_default.h>
|
||||
|
||||
#define CONFIG_CMD_SAVEENV
|
||||
#define CONFIG_CMD_ASKENV
|
||||
#define CONFIG_CMD_GREPENV
|
||||
#define CONFIG_CMD_ENV_FLAGS
|
||||
|
||||
#define CONFIG_CMD_NET
|
||||
#define CONFIG_CMD_DHCP
|
||||
#define CONFIG_CMD_NFS
|
||||
#define CONFIG_CMD_PING
|
||||
#define CONFIG_CMD_PXE
|
||||
|
||||
#define CONFIG_CMD_NAND
|
||||
#define CONFIG_CMD_MTDPARTS
|
||||
#define CONFIG_CMD_UBI
|
||||
#define CONFIG_CMD_UBIFS
|
||||
|
||||
#define CONFIG_CMD_IDE
|
||||
#define CONFIG_CMD_FAT
|
||||
#define CONFIG_FAT_WRITE
|
||||
#define CONFIG_CMD_EXT2
|
||||
#define CONFIG_CMD_EXT4
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
#define CONFIG_CMD_EXT4_WRITE
|
||||
#endif
|
||||
|
||||
#define CONFIG_CMD_ZIP
|
||||
#define CONFIG_CMD_UNZIP
|
||||
#define CONFIG_CMD_TIME
|
||||
#define CONFIG_CMD_SETEXPR
|
||||
#define CONFIG_CMD_MD5SUM
|
||||
#define CONFIG_CMD_HASH
|
||||
#define CONFIG_CMD_INI
|
||||
#define CONFIG_CMD_GETTIME
|
||||
#define CONFIG_CMD_BOOTMENU
|
||||
#define CONFIG_CMD_ELF
|
||||
#define CONFIG_CMD_BOOTZ
|
||||
|
||||
#define CONFIG_DOS_PARTITION
|
||||
#define CONFIG_EFI_PARTITION
|
||||
|
||||
/* for CONFIG_CMD_MTDPARTS */
|
||||
#define CONFIG_MTD_DEVICE
|
||||
/* for CONFIG_CMD_UBI */
|
||||
#define CONFIG_MTD_PARTITIONS
|
||||
/* for CONFIG_CMD_UBI */
|
||||
#define CONFIG_RBTREE
|
||||
|
||||
/* optional, for CONFIG_CMD_BOOTM & required by CONFIG_CMD_UBIFS */
|
||||
#define CONFIG_LZO
|
||||
#define CONFIG_LZMA
|
||||
#define CONFIG_BZIP2
|
||||
|
||||
/* for CONFIG_CMD_ZIP */
|
||||
#define CONFIG_GZIP_COMPRESSED
|
||||
/* for CONFIG_CMD_MD5SUM */
|
||||
#define CONFIG_MD5
|
||||
#define CONFIG_MD5SUM_VERIFY
|
||||
/* enable CONFIG_CMD_HASH's verification feature */
|
||||
#define CONFIG_HASH_VERIFY
|
||||
#define CONFIG_REGEX
|
||||
/* for CONFIG_CMD_BOOTMENU & CONFIG_CMD_PXE */
|
||||
#define CONFIG_MENU
|
||||
|
||||
/* for new FIT uImage format generated in OpenWrt */
|
||||
#define CONFIG_FIT
|
||||
|
||||
#endif /* __CONFIG_H */
|
||||
@ -1,126 +0,0 @@
|
||||
/* J J Larworthy 27 September 2006 */
|
||||
|
||||
/* file to read the boot sector of a dis and the loaded image and report
|
||||
* if the boot rom would accept the data as intact and suitable for use
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
extern uint32_t crc32(uint32_t, const unsigned char *, unsigned int);
|
||||
|
||||
#define NUMBER_VECTORS 12
|
||||
struct {
|
||||
unsigned int start_vector[NUMBER_VECTORS];
|
||||
char code[4];
|
||||
unsigned int header_length;
|
||||
unsigned int reserved[3];
|
||||
unsigned int length;
|
||||
unsigned int img_CRC;
|
||||
unsigned int CRC;
|
||||
} img_header;
|
||||
|
||||
void print_usage(void)
|
||||
{
|
||||
printf("update_header file.bin\n");
|
||||
}
|
||||
|
||||
void print_header(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("vectors in header\n");
|
||||
for (i = 0; i < NUMBER_VECTORS; i++) {
|
||||
printf("%d:0x%08x\n", i, img_header.start_vector[i]);
|
||||
}
|
||||
printf("length:%8x\nimg_CRC:0x%08x\nHeader CRC:0x%08x\n",
|
||||
img_header.length, img_header.img_CRC, img_header.CRC);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int in_file;
|
||||
int status;
|
||||
int unsigned crc;
|
||||
int file_length;
|
||||
int len;
|
||||
|
||||
struct stat file_stat;
|
||||
|
||||
void *executable;
|
||||
|
||||
in_file = open(argv[1], O_RDWR);
|
||||
|
||||
if (in_file < 0) {
|
||||
printf("failed to open file:%s\n", argv[optind]);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
status = fstat(in_file, &file_stat);
|
||||
|
||||
/* read header and obtain size of image */
|
||||
status = read(in_file, &img_header, sizeof(img_header));
|
||||
|
||||
file_length = file_stat.st_size - sizeof(img_header);
|
||||
|
||||
if (img_header.length != file_length) {
|
||||
printf("size in header:%d, size of file: %d\n",
|
||||
img_header.length, file_length);
|
||||
}
|
||||
img_header.length = file_length;
|
||||
|
||||
/* read working image and CRC */
|
||||
executable = malloc(file_length);
|
||||
|
||||
status = read(in_file, executable, file_length);
|
||||
|
||||
if (status != file_length) {
|
||||
printf("Failed to load image\n");
|
||||
free(executable);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* verify image CRC */
|
||||
crc = crc32(0, (const unsigned char *) executable, img_header.length);
|
||||
|
||||
if (crc != img_header.img_CRC) {
|
||||
printf("New Image CRC:0x%08x, hdr:0x%08x\n", crc,
|
||||
img_header.img_CRC);
|
||||
img_header.img_CRC = crc;
|
||||
}
|
||||
memcpy(img_header.code, "BOOT", 4);
|
||||
img_header.header_length = sizeof(img_header);
|
||||
|
||||
/* check header CRC */
|
||||
crc = crc32(0, (const unsigned char *) &img_header,
|
||||
sizeof(img_header) - sizeof(unsigned int));
|
||||
if (crc != img_header.CRC) {
|
||||
printf("New header CRC - crc:0x%08x hdr:0x%08x\n", crc,
|
||||
img_header.CRC);
|
||||
img_header.CRC = crc;
|
||||
}
|
||||
|
||||
/* re-write the file */
|
||||
status = lseek(in_file, 0, SEEK_SET);
|
||||
if (status != 0) {
|
||||
printf("failed to rewind\n");
|
||||
free(executable);
|
||||
return 1;
|
||||
}
|
||||
len = write(in_file, &img_header, sizeof(img_header));
|
||||
assert(len == sizeof(img_header));
|
||||
len = write(in_file, executable, file_length);
|
||||
assert(len == file_length);
|
||||
close(in_file);
|
||||
free(executable);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -46,6 +46,7 @@ ALLWIFIBOARDS:= \
|
||||
prpl_haze \
|
||||
qnap_301w \
|
||||
redmi_ax6 \
|
||||
spectrum_sax1v1k \
|
||||
wallys_dr40x9 \
|
||||
xiaomi_ax3600 \
|
||||
xiaomi_ax9000 \
|
||||
@ -165,6 +166,7 @@ $(eval $(call generate-ipq-wifi-package,netgear_wax630,Netgear WAX630))
|
||||
$(eval $(call generate-ipq-wifi-package,qnap_301w,QNAP 301w))
|
||||
$(eval $(call generate-ipq-wifi-package,prpl_haze,prpl Haze))
|
||||
$(eval $(call generate-ipq-wifi-package,redmi_ax6,Redmi AX6))
|
||||
$(eval $(call generate-ipq-wifi-package,spectrum_sax1v1k,Spectrum SAX1V1K))
|
||||
$(eval $(call generate-ipq-wifi-package,wallys_dr40x9,Wallys DR40X9))
|
||||
$(eval $(call generate-ipq-wifi-package,xiaomi_ax3600,Xiaomi AX3600))
|
||||
$(eval $(call generate-ipq-wifi-package,xiaomi_ax9000,Xiaomi AX9000))
|
||||
|
||||
@ -407,6 +407,40 @@ endef
|
||||
|
||||
$(eval $(call KernelPackage,phy-aquantia))
|
||||
|
||||
define KernelPackage/dsa-tag-dsa
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Marvell DSA type DSA and EDSA taggers
|
||||
KCONFIG:= CONFIG_NET_DSA_TAG_DSA_COMMON \
|
||||
CONFIG_NET_DSA_TAG_DSA \
|
||||
CONFIG_NET_DSA_TAG_EDSA \
|
||||
CONFIG_NET_DSA=y
|
||||
FILES:=$(LINUX_DIR)/net/dsa/tag_dsa.ko
|
||||
AUTOLOAD:=$(call AutoLoad,40,tag_dsa,1)
|
||||
endef
|
||||
|
||||
define KernelPackage/dsa-tag-dsa/description
|
||||
Kernel modules for Marvell DSA and EDSA tagging
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,dsa-tag-dsa))
|
||||
|
||||
define KernelPackage/dsa-mv88e6xxx
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
TITLE:=Marvell MV88E6XXX DSA Switch
|
||||
DEPENDS:=+kmod-ptp +kmod-phy-marvell +kmod-dsa-tag-dsa
|
||||
KCONFIG:=CONFIG_NET_DSA_MV88E6XXX \
|
||||
CONFIG_NET_DSA_MV88E6XXX_PTP=y \
|
||||
CONFIG_NET_DSA=y
|
||||
FILES:=$(LINUX_DIR)/drivers/net/dsa/mv88e6xxx/mv88e6xxx.ko
|
||||
AUTOLOAD:=$(call AutoLoad,41,mv88e6xxx,1)
|
||||
endef
|
||||
|
||||
define KernelPackage/dsa-mv88e6xxx/description
|
||||
Kernel modules for MV88E6XXX DSA switches
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,dsa-mv88e6xxx))
|
||||
|
||||
|
||||
define KernelPackage/swconfig
|
||||
SUBMENU:=$(NETWORK_DEVICES_MENU)
|
||||
|
||||
@ -15,9 +15,9 @@ PKG_LICENSE_FILES:=
|
||||
|
||||
PKG_SOURCE_URL:=https://github.com/kaloz/mwlwifi
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2023-11-29
|
||||
PKG_SOURCE_VERSION:=ebf3167445f108346dcff9a31a708534c0bd7cc5
|
||||
PKG_MIRROR_HASH:=6dffc08208305366b9c25133b74693d5c2e544c1076b7b4ed846628c66be56c1
|
||||
PKG_SOURCE_DATE:=2024-04-19
|
||||
PKG_SOURCE_VERSION:=a737d348ef4fe00434b2bc44b2b6a68ea833d95b
|
||||
PKG_MIRROR_HASH:=d55f69c2fa48d02ba535b72b108fc77f5f13a52b29130a631489a053f1670d2c
|
||||
|
||||
PKG_MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
@ -8,13 +8,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mbedtls
|
||||
PKG_VERSION:=2.28.7
|
||||
PKG_RELEASE:=2
|
||||
PKG_VERSION:=2.28.8
|
||||
PKG_RELEASE:=1
|
||||
PKG_BUILD_FLAGS:=no-mips16 gc-sections no-lto
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/ARMmbed/mbedtls/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=1df6073f0cf6a4e1953890bf5e0de2a8c7e6be50d6d6c69fa9fefcb1d14e981a
|
||||
PKG_HASH:=4fef7de0d8d542510d726d643350acb3cdb9dc76ad45611b59c9aa08372b4213
|
||||
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
PKG_LICENSE_FILES:=gpl-2.0.txt
|
||||
|
||||
@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=wolfssl
|
||||
PKG_VERSION:=5.6.6-stable
|
||||
PKG_VERSION:=5.7.0-stable
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/wolfSSL/wolfssl/archive/v$(PKG_VERSION)
|
||||
PKG_HASH:=3d2ca672d41c2c2fa667885a80d6fa03c3e91f0f4f72f87aef2bc947e8c87237
|
||||
PKG_HASH:=2de93e8af588ee856fe67a6d7fce23fc1b226b74d710b0e3946bc8061f6aa18f
|
||||
|
||||
PKG_FIXUP:=libtool libtool-abiver
|
||||
PKG_INSTALL:=1
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
--- a/wolfssl/wolfcrypt/settings.h
|
||||
+++ b/wolfssl/wolfcrypt/settings.h
|
||||
@@ -2774,7 +2774,7 @@ extern void uITRON4_free(void *p) ;
|
||||
@@ -2945,7 +2945,7 @@ extern void uITRON4_free(void *p) ;
|
||||
|
||||
/* warning for not using harden build options (default with ./configure) */
|
||||
/* do not warn if big integer support is disabled */
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ubox
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/ubox.git
|
||||
PKG_SOURCE_DATE:=2024-01-24
|
||||
PKG_SOURCE_VERSION:=2c5887cb46883a28d69071c4349c3dabbbe3972c
|
||||
PKG_MIRROR_HASH:=5b7b00c358cc53b842c25e6f6dd21bf429d4913204a8186a72b13447658927cf
|
||||
PKG_SOURCE_DATE:=2024-03-02
|
||||
PKG_SOURCE_VERSION:=d413903016c4dc9190926e38ff72fbf7d3d69115
|
||||
PKG_MIRROR_HASH:=51f529b8b686725954bd8ea17b6734c1b5bb3ad8eb0bc57d19c89694a78d651c
|
||||
CMAKE_INSTALL:=1
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
@ -90,10 +90,10 @@ ubilayout() {
|
||||
rootsize="$( round_up "$( stat -c%s "$2" )" 1024 )"
|
||||
;;
|
||||
esac
|
||||
ubivol $vol_id rootfs "$2" "$autoresize" "$rootsize" dynamic
|
||||
ubivol $vol_id rootfs "$2" "$autoresize" "$rootsize"
|
||||
|
||||
vol_id=$(( vol_id + 1 ))
|
||||
[ "$rootfs_type" = "ubifs" ] || ubivol $vol_id rootfs_data "" 1 dymamic
|
||||
[ "$rootfs_type" = "ubifs" ] || ubivol $vol_id rootfs_data "" 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@ -99,3 +99,13 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
subs r9, r9, #1 @ decrement the index
|
||||
bge loop2
|
||||
subs r4, r4, #1 @ decrement the way
|
||||
--- a/arch/arm/boot/compressed/vmlinux.lds.S
|
||||
+++ b/arch/arm/boot/compressed/vmlinux.lds.S
|
||||
@@ -41,6 +41,7 @@ SECTIONS
|
||||
*(.start)
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
+ *(.init.text)
|
||||
ARM_STUBS_TEXT
|
||||
}
|
||||
.table : ALIGN(4) {
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
From f13b2b33c7674fa0988dfaa9adb95d7d912b489f Mon Sep 17 00:00:00 2001
|
||||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
||||
Date: Wed, 10 Apr 2024 20:42:38 +0100
|
||||
Subject: [PATCH 1/2] net: dsa: introduce dsa_phylink_to_port()
|
||||
|
||||
We convert from a phylink_config struct to a dsa_port struct in many
|
||||
places, let's provide a helper for this.
|
||||
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
||||
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
|
||||
Link: https://lore.kernel.org/r/E1rudqA-006K9B-85@rmk-PC.armlinux.org.uk
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
include/net/dsa.h | 6 ++++++
|
||||
net/dsa/port.c | 12 ++++++------
|
||||
2 files changed, 12 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/include/net/dsa.h
|
||||
+++ b/include/net/dsa.h
|
||||
@@ -337,6 +337,12 @@ struct dsa_port {
|
||||
struct list_head vlans;
|
||||
};
|
||||
|
||||
+static inline struct dsa_port *
|
||||
+dsa_phylink_to_port(struct phylink_config *config)
|
||||
+{
|
||||
+ return container_of(config, struct dsa_port, pl_config);
|
||||
+}
|
||||
+
|
||||
/* TODO: ideally DSA ports would have a single dp->link_dp member,
|
||||
* and no dst->rtable nor this struct dsa_link would be needed,
|
||||
* but this would require some more complex tree walking,
|
||||
--- a/net/dsa/port.c
|
||||
+++ b/net/dsa/port.c
|
||||
@@ -1552,7 +1552,7 @@ static void dsa_port_phylink_validate(st
|
||||
unsigned long *supported,
|
||||
struct phylink_link_state *state)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
if (!ds->ops->phylink_validate) {
|
||||
@@ -1567,7 +1567,7 @@ static void dsa_port_phylink_validate(st
|
||||
static void dsa_port_phylink_mac_pcs_get_state(struct phylink_config *config,
|
||||
struct phylink_link_state *state)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
int err;
|
||||
|
||||
@@ -1589,7 +1589,7 @@ static struct phylink_pcs *
|
||||
dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
@@ -1603,7 +1603,7 @@ static void dsa_port_phylink_mac_config(
|
||||
unsigned int mode,
|
||||
const struct phylink_link_state *state)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
if (!ds->ops->phylink_mac_config)
|
||||
@@ -1614,7 +1614,7 @@ static void dsa_port_phylink_mac_config(
|
||||
|
||||
static void dsa_port_phylink_mac_an_restart(struct phylink_config *config)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
if (!ds->ops->phylink_mac_an_restart)
|
||||
@@ -1627,7 +1627,7 @@ static void dsa_port_phylink_mac_link_do
|
||||
unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct phy_device *phydev = NULL;
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
@@ -1650,7 +1650,7 @@ static void dsa_port_phylink_mac_link_up
|
||||
int speed, int duplex,
|
||||
bool tx_pause, bool rx_pause)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
if (!ds->ops->phylink_mac_link_up) {
|
||||
@ -0,0 +1,117 @@
|
||||
From c22d8240fcd73a1c3ec8dcb055bd583fb970c375 Mon Sep 17 00:00:00 2001
|
||||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
||||
Date: Wed, 10 Apr 2024 20:42:43 +0100
|
||||
Subject: [PATCH 2/2] net: dsa: allow DSA switch drivers to provide their own
|
||||
phylink mac ops
|
||||
|
||||
Rather than having a shim for each and every phylink MAC operation,
|
||||
allow DSA switch drivers to provide their own ops structure. When a
|
||||
DSA driver provides the phylink MAC operations, the shimmed ops must
|
||||
not be provided, so fail an attempt to register a switch with both
|
||||
the phylink_mac_ops in struct dsa_switch and the phylink_mac_*
|
||||
operations populated in dsa_switch_ops populated.
|
||||
|
||||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
||||
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
|
||||
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Link: https://lore.kernel.org/r/E1rudqF-006K9H-Cc@rmk-PC.armlinux.org.uk
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
include/net/dsa.h | 5 +++++
|
||||
net/dsa/dsa.c | 11 +++++++++++
|
||||
net/dsa/port.c | 26 ++++++++++++++++++++------
|
||||
3 files changed, 36 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/include/net/dsa.h
|
||||
+++ b/include/net/dsa.h
|
||||
@@ -468,6 +468,11 @@ struct dsa_switch {
|
||||
const struct dsa_switch_ops *ops;
|
||||
|
||||
/*
|
||||
+ * Allow a DSA switch driver to override the phylink MAC ops
|
||||
+ */
|
||||
+ const struct phylink_mac_ops *phylink_mac_ops;
|
||||
+
|
||||
+ /*
|
||||
* Slave mii_bus and devices for the individual ports.
|
||||
*/
|
||||
u32 phys_mii_mask;
|
||||
--- a/net/dsa/port.c
|
||||
+++ b/net/dsa/port.c
|
||||
@@ -1675,6 +1675,7 @@ static const struct phylink_mac_ops dsa_
|
||||
|
||||
int dsa_port_phylink_create(struct dsa_port *dp)
|
||||
{
|
||||
+ const struct phylink_mac_ops *mac_ops;
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
phy_interface_t mode;
|
||||
struct phylink *pl;
|
||||
@@ -1694,8 +1695,12 @@ int dsa_port_phylink_create(struct dsa_p
|
||||
if (ds->ops->phylink_get_caps)
|
||||
ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config);
|
||||
|
||||
- pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn),
|
||||
- mode, &dsa_port_phylink_mac_ops);
|
||||
+ mac_ops = &dsa_port_phylink_mac_ops;
|
||||
+ if (ds->phylink_mac_ops)
|
||||
+ mac_ops = ds->phylink_mac_ops;
|
||||
+
|
||||
+ pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), mode,
|
||||
+ mac_ops);
|
||||
if (IS_ERR(pl)) {
|
||||
pr_err("error creating PHYLINK: %ld\n", PTR_ERR(pl));
|
||||
return PTR_ERR(pl);
|
||||
@@ -1961,12 +1966,23 @@ static void dsa_shared_port_validate_of(
|
||||
dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
|
||||
}
|
||||
|
||||
+static void dsa_shared_port_link_down(struct dsa_port *dp)
|
||||
+{
|
||||
+ struct dsa_switch *ds = dp->ds;
|
||||
+
|
||||
+ if (ds->phylink_mac_ops && ds->phylink_mac_ops->mac_link_down)
|
||||
+ ds->phylink_mac_ops->mac_link_down(&dp->pl_config, MLO_AN_FIXED,
|
||||
+ PHY_INTERFACE_MODE_NA);
|
||||
+ else if (ds->ops->phylink_mac_link_down)
|
||||
+ ds->ops->phylink_mac_link_down(ds, dp->index, MLO_AN_FIXED,
|
||||
+ PHY_INTERFACE_MODE_NA);
|
||||
+}
|
||||
+
|
||||
int dsa_shared_port_link_register_of(struct dsa_port *dp)
|
||||
{
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
bool missing_link_description;
|
||||
bool missing_phy_mode;
|
||||
- int port = dp->index;
|
||||
|
||||
dsa_shared_port_validate_of(dp, &missing_phy_mode,
|
||||
&missing_link_description);
|
||||
@@ -1982,9 +1998,7 @@ int dsa_shared_port_link_register_of(str
|
||||
"Skipping phylink registration for %s port %d\n",
|
||||
dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
|
||||
} else {
|
||||
- if (ds->ops->phylink_mac_link_down)
|
||||
- ds->ops->phylink_mac_link_down(ds, port,
|
||||
- MLO_AN_FIXED, PHY_INTERFACE_MODE_NA);
|
||||
+ dsa_shared_port_link_down(dp);
|
||||
|
||||
return dsa_shared_port_phylink_register(dp);
|
||||
}
|
||||
--- a/net/dsa/dsa2.c
|
||||
+++ b/net/dsa/dsa2.c
|
||||
@@ -1736,6 +1736,15 @@ static int dsa_switch_probe(struct dsa_s
|
||||
if (!ds->num_ports)
|
||||
return -EINVAL;
|
||||
|
||||
+ if (ds->phylink_mac_ops) {
|
||||
+ if (ds->ops->phylink_mac_select_pcs ||
|
||||
+ ds->ops->phylink_mac_config ||
|
||||
+ ds->ops->phylink_mac_link_down ||
|
||||
+ ds->ops->phylink_mac_link_up ||
|
||||
+ ds->ops->adjust_link)
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
if (np) {
|
||||
err = dsa_switch_parse_of(ds, np);
|
||||
if (err)
|
||||
@ -0,0 +1,135 @@
|
||||
From 5754b3bdcd872aa229881b8f07f84a8404c7d72a Mon Sep 17 00:00:00 2001
|
||||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
||||
Date: Fri, 12 Apr 2024 16:15:34 +0100
|
||||
Subject: [PATCH 1/5] net: dsa: mt7530: provide own phylink MAC operations
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Convert mt753x to provide its own phylink MAC operations, thus avoiding
|
||||
the shim layer in DSA's port.c
|
||||
|
||||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
||||
Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Link: https://lore.kernel.org/r/E1rvIco-006bQu-Fq@rmk-PC.armlinux.org.uk
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 46 +++++++++++++++++++++++++---------------
|
||||
1 file changed, 29 insertions(+), 17 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2841,28 +2841,34 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
}
|
||||
|
||||
static struct phylink_pcs *
|
||||
-mt753x_phylink_mac_select_pcs(struct dsa_switch *ds, int port,
|
||||
+mt753x_phylink_mac_select_pcs(struct phylink_config *config,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
+ struct mt7530_priv *priv = dp->ds->priv;
|
||||
|
||||
switch (interface) {
|
||||
case PHY_INTERFACE_MODE_TRGMII:
|
||||
- return &priv->pcs[port].pcs;
|
||||
+ return &priv->pcs[dp->index].pcs;
|
||||
case PHY_INTERFACE_MODE_SGMII:
|
||||
case PHY_INTERFACE_MODE_1000BASEX:
|
||||
case PHY_INTERFACE_MODE_2500BASEX:
|
||||
- return priv->ports[port].sgmii_pcs;
|
||||
+ return priv->ports[dp->index].sgmii_pcs;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
-mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
+mt753x_phylink_mac_config(struct phylink_config *config, unsigned int mode,
|
||||
const struct phylink_link_state *state)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
+ struct dsa_switch *ds = dp->ds;
|
||||
+ struct mt7530_priv *priv;
|
||||
+ int port = dp->index;
|
||||
+
|
||||
+ priv = ds->priv;
|
||||
|
||||
if ((port == 5 || port == 6) && priv->info->mac_port_config)
|
||||
priv->info->mac_port_config(ds, port, mode, state->interface);
|
||||
@@ -2872,23 +2878,25 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
mt7530_set(priv, MT7530_PMCR_P(port), PMCR_EXT_PHY);
|
||||
}
|
||||
|
||||
-static void mt753x_phylink_mac_link_down(struct dsa_switch *ds, int port,
|
||||
+static void mt753x_phylink_mac_link_down(struct phylink_config *config,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
+ struct mt7530_priv *priv = dp->ds->priv;
|
||||
|
||||
- mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||
+ mt7530_clear(priv, MT7530_PMCR_P(dp->index), PMCR_LINK_SETTINGS_MASK);
|
||||
}
|
||||
|
||||
-static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
+static void mt753x_phylink_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phydev,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev,
|
||||
int speed, int duplex,
|
||||
bool tx_pause, bool rx_pause)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
+ struct mt7530_priv *priv = dp->ds->priv;
|
||||
u32 mcr;
|
||||
|
||||
mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
|
||||
@@ -2923,7 +2931,7 @@ static void mt753x_phylink_mac_link_up(s
|
||||
}
|
||||
}
|
||||
|
||||
- mt7530_set(priv, MT7530_PMCR_P(port), mcr);
|
||||
+ mt7530_set(priv, MT7530_PMCR_P(dp->index), mcr);
|
||||
}
|
||||
|
||||
static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
|
||||
@@ -3148,16 +3156,19 @@ const struct dsa_switch_ops mt7530_switc
|
||||
.port_mirror_add = mt753x_port_mirror_add,
|
||||
.port_mirror_del = mt753x_port_mirror_del,
|
||||
.phylink_get_caps = mt753x_phylink_get_caps,
|
||||
- .phylink_mac_select_pcs = mt753x_phylink_mac_select_pcs,
|
||||
- .phylink_mac_config = mt753x_phylink_mac_config,
|
||||
- .phylink_mac_link_down = mt753x_phylink_mac_link_down,
|
||||
- .phylink_mac_link_up = mt753x_phylink_mac_link_up,
|
||||
.get_mac_eee = mt753x_get_mac_eee,
|
||||
.set_mac_eee = mt753x_set_mac_eee,
|
||||
.master_state_change = mt753x_conduit_state_change,
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(mt7530_switch_ops);
|
||||
|
||||
+static const struct phylink_mac_ops mt753x_phylink_mac_ops = {
|
||||
+ .mac_select_pcs = mt753x_phylink_mac_select_pcs,
|
||||
+ .mac_config = mt753x_phylink_mac_config,
|
||||
+ .mac_link_down = mt753x_phylink_mac_link_down,
|
||||
+ .mac_link_up = mt753x_phylink_mac_link_up,
|
||||
+};
|
||||
+
|
||||
const struct mt753x_info mt753x_table[] = {
|
||||
[ID_MT7621] = {
|
||||
.id = ID_MT7621,
|
||||
@@ -3227,6 +3238,7 @@ mt7530_probe_common(struct mt7530_priv *
|
||||
priv->dev = dev;
|
||||
priv->ds->priv = priv;
|
||||
priv->ds->ops = &mt7530_switch_ops;
|
||||
+ priv->ds->phylink_mac_ops = &mt753x_phylink_mac_ops;
|
||||
mutex_init(&priv->reg_mutex);
|
||||
dev_set_drvdata(dev, priv);
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
From d4097ddef078a113643a6dcde01e99741f852adb Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Sat, 13 Apr 2024 16:01:39 +0300
|
||||
Subject: [PATCH 2/5] net: dsa: mt7530: fix mirroring frames received on local
|
||||
port
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This switch intellectual property provides a bit on the ARL global control
|
||||
register which controls allowing mirroring frames which are received on the
|
||||
local port (monitor port). This bit is unset after reset.
|
||||
|
||||
This ability must be enabled to fully support the port mirroring feature on
|
||||
this switch intellectual property.
|
||||
|
||||
Therefore, this patch fixes the traffic not being reflected on a port,
|
||||
which would be configured like below:
|
||||
|
||||
tc qdisc add dev swp0 clsact
|
||||
|
||||
tc filter add dev swp0 ingress matchall skip_sw \
|
||||
action mirred egress mirror dev swp0
|
||||
|
||||
As a side note, this configuration provides the hairpinning feature for a
|
||||
single port.
|
||||
|
||||
Fixes: 37feab6076aa ("net: dsa: mt7530: add support for port mirroring")
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 6 ++++++
|
||||
drivers/net/dsa/mt7530.h | 4 ++++
|
||||
2 files changed, 10 insertions(+)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2471,6 +2471,9 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
|
||||
}
|
||||
|
||||
+ /* Allow mirroring frames received on the local port (monitor port). */
|
||||
+ mt7530_set(priv, MT753X_AGC, LOCAL_EN);
|
||||
+
|
||||
/* Setup VLAN ID 0 for VLAN-unaware bridges */
|
||||
ret = mt7530_setup_vlan0(priv);
|
||||
if (ret)
|
||||
@@ -2582,6 +2585,9 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
|
||||
}
|
||||
|
||||
+ /* Allow mirroring frames received on the local port (monitor port). */
|
||||
+ mt7530_set(priv, MT753X_AGC, LOCAL_EN);
|
||||
+
|
||||
/* Flush the FDB table */
|
||||
ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
|
||||
if (ret < 0)
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -32,6 +32,10 @@ enum mt753x_id {
|
||||
#define SYSC_REG_RSTCTRL 0x34
|
||||
#define RESET_MCM BIT(2)
|
||||
|
||||
+/* Register for ARL global control */
|
||||
+#define MT753X_AGC 0xc
|
||||
+#define LOCAL_EN BIT(7)
|
||||
+
|
||||
/* Registers to mac forward control for unknown frames */
|
||||
#define MT7530_MFC 0x10
|
||||
#define BC_FFP(x) (((x) & 0xff) << 24)
|
||||
@ -0,0 +1,49 @@
|
||||
From 019a17a5e76940ea86114838d1d638d4dc8d3750 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Sat, 13 Apr 2024 16:01:40 +0300
|
||||
Subject: [PATCH 3/5] net: dsa: mt7530: fix port mirroring for MT7988 SoC
|
||||
switch
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The "MT7988A Wi-Fi 7 Generation Router Platform: Datasheet (Open Version)
|
||||
v0.1" document shows bits 16 to 18 as the MIRROR_PORT field of the CPU
|
||||
forward control register. Currently, the MT7530 DSA subdriver configures
|
||||
bits 0 to 2 of the CPU forward control register which breaks the port
|
||||
mirroring feature for the MT7988 SoC switch.
|
||||
|
||||
Fix this by using the MT7531_MIRROR_PORT_GET() and MT7531_MIRROR_PORT_SET()
|
||||
macros which utilise the correct bits.
|
||||
|
||||
Fixes: 110c18bfed41 ("net: dsa: mt7530: introduce driver for MT7988 built-in switch")
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Acked-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1876,14 +1876,16 @@ mt7530_port_vlan_del(struct dsa_switch *
|
||||
|
||||
static int mt753x_mirror_port_get(unsigned int id, u32 val)
|
||||
{
|
||||
- return (id == ID_MT7531) ? MT7531_MIRROR_PORT_GET(val) :
|
||||
- MIRROR_PORT(val);
|
||||
+ return (id == ID_MT7531 || id == ID_MT7988) ?
|
||||
+ MT7531_MIRROR_PORT_GET(val) :
|
||||
+ MIRROR_PORT(val);
|
||||
}
|
||||
|
||||
static int mt753x_mirror_port_set(unsigned int id, u32 val)
|
||||
{
|
||||
- return (id == ID_MT7531) ? MT7531_MIRROR_PORT_SET(val) :
|
||||
- MIRROR_PORT(val);
|
||||
+ return (id == ID_MT7531 || id == ID_MT7988) ?
|
||||
+ MT7531_MIRROR_PORT_SET(val) :
|
||||
+ MIRROR_PORT(val);
|
||||
}
|
||||
|
||||
static int mt753x_port_mirror_add(struct dsa_switch *ds, int port,
|
||||
@ -0,0 +1,238 @@
|
||||
From 5053a6cf1d50d785078562470d2a63695a9f3bf2 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Thu, 18 Apr 2024 08:35:30 +0300
|
||||
Subject: [PATCH 4/5] net: dsa: mt7530-mdio: read PHY address of switch from
|
||||
device tree
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Read the PHY address the switch listens on from the reg property of the
|
||||
switch node on the device tree. This change brings support for MT7530
|
||||
switches on boards with such bootstrapping configuration where the switch
|
||||
listens on a different PHY address than the hardcoded PHY address on the
|
||||
driver, 31.
|
||||
|
||||
As described on the "MT7621 Programming Guide v0.4" document, the MT7530
|
||||
switch and its PHYs can be configured to listen on the range of 7-12,
|
||||
15-20, 23-28, and 31 and 0-4 PHY addresses.
|
||||
|
||||
There are operations where the switch PHY registers are used. For the PHY
|
||||
address of the control PHY, transform the MT753X_CTRL_PHY_ADDR constant
|
||||
into a macro and use it. The PHY address for the control PHY is 0 when the
|
||||
switch listens on 31. In any other case, it is one greater than the PHY
|
||||
address the switch listens on.
|
||||
|
||||
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Tested-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530-mdio.c | 28 +++++++++++++-------------
|
||||
drivers/net/dsa/mt7530.c | 37 +++++++++++++++++++++++------------
|
||||
drivers/net/dsa/mt7530.h | 4 +++-
|
||||
3 files changed, 41 insertions(+), 28 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530-mdio.c
|
||||
+++ b/drivers/net/dsa/mt7530-mdio.c
|
||||
@@ -18,7 +18,8 @@
|
||||
static int
|
||||
mt7530_regmap_write(void *context, unsigned int reg, unsigned int val)
|
||||
{
|
||||
- struct mii_bus *bus = context;
|
||||
+ struct mt7530_priv *priv = context;
|
||||
+ struct mii_bus *bus = priv->bus;
|
||||
u16 page, r, lo, hi;
|
||||
int ret;
|
||||
|
||||
@@ -27,36 +28,35 @@ mt7530_regmap_write(void *context, unsig
|
||||
lo = val & 0xffff;
|
||||
hi = val >> 16;
|
||||
|
||||
- /* MT7530 uses 31 as the pseudo port */
|
||||
- ret = bus->write(bus, 0x1f, 0x1f, page);
|
||||
+ ret = bus->write(bus, priv->mdiodev->addr, 0x1f, page);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
- ret = bus->write(bus, 0x1f, r, lo);
|
||||
+ ret = bus->write(bus, priv->mdiodev->addr, r, lo);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
- ret = bus->write(bus, 0x1f, 0x10, hi);
|
||||
+ ret = bus->write(bus, priv->mdiodev->addr, 0x10, hi);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val)
|
||||
{
|
||||
- struct mii_bus *bus = context;
|
||||
+ struct mt7530_priv *priv = context;
|
||||
+ struct mii_bus *bus = priv->bus;
|
||||
u16 page, r, lo, hi;
|
||||
int ret;
|
||||
|
||||
page = (reg >> 6) & 0x3ff;
|
||||
r = (reg >> 2) & 0xf;
|
||||
|
||||
- /* MT7530 uses 31 as the pseudo port */
|
||||
- ret = bus->write(bus, 0x1f, 0x1f, page);
|
||||
+ ret = bus->write(bus, priv->mdiodev->addr, 0x1f, page);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
- lo = bus->read(bus, 0x1f, r);
|
||||
- hi = bus->read(bus, 0x1f, 0x10);
|
||||
+ lo = bus->read(bus, priv->mdiodev->addr, r);
|
||||
+ hi = bus->read(bus, priv->mdiodev->addr, 0x10);
|
||||
|
||||
*val = (hi << 16) | (lo & 0xffff);
|
||||
|
||||
@@ -107,8 +107,7 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock;
|
||||
mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
|
||||
|
||||
- regmap = devm_regmap_init(priv->dev,
|
||||
- &mt7530_regmap_bus, priv->bus,
|
||||
+ regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus, priv,
|
||||
mt7531_pcs_config[i]);
|
||||
if (IS_ERR(regmap)) {
|
||||
ret = PTR_ERR(regmap);
|
||||
@@ -153,6 +152,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
|
||||
priv->bus = mdiodev->bus;
|
||||
priv->dev = &mdiodev->dev;
|
||||
+ priv->mdiodev = mdiodev;
|
||||
|
||||
ret = mt7530_probe_common(priv);
|
||||
if (ret)
|
||||
@@ -203,8 +203,8 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
regmap_config->reg_stride = 4;
|
||||
regmap_config->max_register = MT7530_CREV;
|
||||
regmap_config->disable_locking = true;
|
||||
- priv->regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus,
|
||||
- priv->bus, regmap_config);
|
||||
+ priv->regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus, priv,
|
||||
+ regmap_config);
|
||||
if (IS_ERR(priv->regmap))
|
||||
return PTR_ERR(priv->regmap);
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -86,22 +86,26 @@ core_read_mmd_indirect(struct mt7530_pri
|
||||
int value, ret;
|
||||
|
||||
/* Write the desired MMD Devad */
|
||||
- ret = bus->write(bus, 0, MII_MMD_CTRL, devad);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_CTRL, devad);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the desired MMD register address */
|
||||
- ret = bus->write(bus, 0, MII_MMD_DATA, prtad);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA, prtad);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Select the Function : DATA with no post increment */
|
||||
- ret = bus->write(bus, 0, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Read the content of the MMD's selected register */
|
||||
- value = bus->read(bus, 0, MII_MMD_DATA);
|
||||
+ value = bus->read(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA);
|
||||
|
||||
return value;
|
||||
err:
|
||||
@@ -118,22 +122,26 @@ core_write_mmd_indirect(struct mt7530_pr
|
||||
int ret;
|
||||
|
||||
/* Write the desired MMD Devad */
|
||||
- ret = bus->write(bus, 0, MII_MMD_CTRL, devad);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_CTRL, devad);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the desired MMD register address */
|
||||
- ret = bus->write(bus, 0, MII_MMD_DATA, prtad);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA, prtad);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Select the Function : DATA with no post increment */
|
||||
- ret = bus->write(bus, 0, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the data into MMD's selected register */
|
||||
- ret = bus->write(bus, 0, MII_MMD_DATA, data);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA, data);
|
||||
err:
|
||||
if (ret < 0)
|
||||
dev_err(&bus->dev,
|
||||
@@ -2670,16 +2678,19 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
* phy_[read,write]_mmd_indirect is called, we provide our own
|
||||
* mt7531_ind_mmd_phy_[read,write] to complete this function.
|
||||
*/
|
||||
- val = mt7531_ind_c45_phy_read(priv, MT753X_CTRL_PHY_ADDR,
|
||||
+ val = mt7531_ind_c45_phy_read(priv,
|
||||
+ MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
MDIO_MMD_VEND2, CORE_PLL_GROUP4);
|
||||
val |= MT7531_RG_SYSPLL_DMY2 | MT7531_PHY_PLL_BYPASS_MODE;
|
||||
val &= ~MT7531_PHY_PLL_OFF;
|
||||
- mt7531_ind_c45_phy_write(priv, MT753X_CTRL_PHY_ADDR, MDIO_MMD_VEND2,
|
||||
- CORE_PLL_GROUP4, val);
|
||||
+ mt7531_ind_c45_phy_write(priv,
|
||||
+ MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MDIO_MMD_VEND2, CORE_PLL_GROUP4, val);
|
||||
|
||||
/* Disable EEE advertisement on the switch PHYs. */
|
||||
- for (i = MT753X_CTRL_PHY_ADDR;
|
||||
- i < MT753X_CTRL_PHY_ADDR + MT7530_NUM_PHYS; i++) {
|
||||
+ for (i = MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr);
|
||||
+ i < MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr) + MT7530_NUM_PHYS;
|
||||
+ i++) {
|
||||
mt7531_ind_c45_phy_write(priv, i, MDIO_MMD_AN, MDIO_AN_EEE_ADV,
|
||||
0);
|
||||
}
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -629,7 +629,7 @@ enum mt7531_clk_skew {
|
||||
#define MT7531_PHY_PLL_OFF BIT(5)
|
||||
#define MT7531_PHY_PLL_BYPASS_MODE BIT(4)
|
||||
|
||||
-#define MT753X_CTRL_PHY_ADDR 0
|
||||
+#define MT753X_CTRL_PHY_ADDR(addr) ((addr + 1) & 0x1f)
|
||||
|
||||
#define CORE_PLL_GROUP5 0x404
|
||||
#define RG_LCDDS_PCW_NCPO1(x) ((x) & 0xffff)
|
||||
@@ -771,6 +771,7 @@ struct mt753x_info {
|
||||
* @irq_enable: IRQ enable bits, synced to SYS_INT_EN
|
||||
* @create_sgmii: Pointer to function creating SGMII PCS instance(s)
|
||||
* @active_cpu_ports: Holding the active CPU ports
|
||||
+ * @mdiodev: The pointer to the MDIO device structure
|
||||
*/
|
||||
struct mt7530_priv {
|
||||
struct device *dev;
|
||||
@@ -797,6 +798,7 @@ struct mt7530_priv {
|
||||
u32 irq_enable;
|
||||
int (*create_sgmii)(struct mt7530_priv *priv);
|
||||
u8 active_cpu_ports;
|
||||
+ struct mdio_device *mdiodev;
|
||||
};
|
||||
|
||||
struct mt7530_hw_vlan_entry {
|
||||
@ -0,0 +1,186 @@
|
||||
From 9764a08b3d260f4e7799d34bbfe64463db940d74 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Thu, 18 Apr 2024 08:35:31 +0300
|
||||
Subject: [PATCH 5/5] net: dsa: mt7530: simplify core operations
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The core_rmw() function calls core_read_mmd_indirect() to read the
|
||||
requested register, and then calls core_write_mmd_indirect() to write the
|
||||
requested value to the register. Because Clause 22 is used to access Clause
|
||||
45 registers, some operations on core_write_mmd_indirect() are
|
||||
unnecessarily run. Get rid of core_read_mmd_indirect() and
|
||||
core_write_mmd_indirect(), and run only the necessary operations on
|
||||
core_write() and core_rmw().
|
||||
|
||||
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Tested-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 108 ++++++++++++++++-----------------------
|
||||
1 file changed, 43 insertions(+), 65 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -74,116 +74,94 @@ static const struct mt7530_mib_desc mt75
|
||||
MIB_DESC(1, 0xb8, "RxArlDrop"),
|
||||
};
|
||||
|
||||
-/* Since phy_device has not yet been created and
|
||||
- * phy_{read,write}_mmd_indirect is not available, we provide our own
|
||||
- * core_{read,write}_mmd_indirect with core_{clear,write,set} wrappers
|
||||
- * to complete this function.
|
||||
- */
|
||||
-static int
|
||||
-core_read_mmd_indirect(struct mt7530_priv *priv, int prtad, int devad)
|
||||
+static void
|
||||
+mt7530_mutex_lock(struct mt7530_priv *priv)
|
||||
+{
|
||||
+ if (priv->bus)
|
||||
+ mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mt7530_mutex_unlock(struct mt7530_priv *priv)
|
||||
+{
|
||||
+ if (priv->bus)
|
||||
+ mutex_unlock(&priv->bus->mdio_lock);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+core_write(struct mt7530_priv *priv, u32 reg, u32 val)
|
||||
{
|
||||
struct mii_bus *bus = priv->bus;
|
||||
- int value, ret;
|
||||
+ int ret;
|
||||
+
|
||||
+ mt7530_mutex_lock(priv);
|
||||
|
||||
/* Write the desired MMD Devad */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_CTRL, devad);
|
||||
+ MII_MMD_CTRL, MDIO_MMD_VEND2);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the desired MMD register address */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_DATA, prtad);
|
||||
+ MII_MMD_DATA, reg);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Select the Function : DATA with no post increment */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
|
||||
+ MII_MMD_CTRL, MDIO_MMD_VEND2 | MII_MMD_CTRL_NOINCR);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
- /* Read the content of the MMD's selected register */
|
||||
- value = bus->read(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_DATA);
|
||||
-
|
||||
- return value;
|
||||
+ /* Write the data into MMD's selected register */
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA, val);
|
||||
err:
|
||||
- dev_err(&bus->dev, "failed to read mmd register\n");
|
||||
+ if (ret < 0)
|
||||
+ dev_err(&bus->dev, "failed to write mmd register\n");
|
||||
|
||||
- return ret;
|
||||
+ mt7530_mutex_unlock(priv);
|
||||
}
|
||||
|
||||
-static int
|
||||
-core_write_mmd_indirect(struct mt7530_priv *priv, int prtad,
|
||||
- int devad, u32 data)
|
||||
+static void
|
||||
+core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
|
||||
{
|
||||
struct mii_bus *bus = priv->bus;
|
||||
+ u32 val;
|
||||
int ret;
|
||||
|
||||
+ mt7530_mutex_lock(priv);
|
||||
+
|
||||
/* Write the desired MMD Devad */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_CTRL, devad);
|
||||
+ MII_MMD_CTRL, MDIO_MMD_VEND2);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the desired MMD register address */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_DATA, prtad);
|
||||
+ MII_MMD_DATA, reg);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Select the Function : DATA with no post increment */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
|
||||
+ MII_MMD_CTRL, MDIO_MMD_VEND2 | MII_MMD_CTRL_NOINCR);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
+ /* Read the content of the MMD's selected register */
|
||||
+ val = bus->read(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA);
|
||||
+ val &= ~mask;
|
||||
+ val |= set;
|
||||
/* Write the data into MMD's selected register */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_DATA, data);
|
||||
+ MII_MMD_DATA, val);
|
||||
err:
|
||||
if (ret < 0)
|
||||
- dev_err(&bus->dev,
|
||||
- "failed to write mmd register\n");
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-static void
|
||||
-mt7530_mutex_lock(struct mt7530_priv *priv)
|
||||
-{
|
||||
- if (priv->bus)
|
||||
- mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
|
||||
-}
|
||||
-
|
||||
-static void
|
||||
-mt7530_mutex_unlock(struct mt7530_priv *priv)
|
||||
-{
|
||||
- if (priv->bus)
|
||||
- mutex_unlock(&priv->bus->mdio_lock);
|
||||
-}
|
||||
-
|
||||
-static void
|
||||
-core_write(struct mt7530_priv *priv, u32 reg, u32 val)
|
||||
-{
|
||||
- mt7530_mutex_lock(priv);
|
||||
-
|
||||
- core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
|
||||
-
|
||||
- mt7530_mutex_unlock(priv);
|
||||
-}
|
||||
-
|
||||
-static void
|
||||
-core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
|
||||
-{
|
||||
- u32 val;
|
||||
-
|
||||
- mt7530_mutex_lock(priv);
|
||||
-
|
||||
- val = core_read_mmd_indirect(priv, reg, MDIO_MMD_VEND2);
|
||||
- val &= ~mask;
|
||||
- val |= set;
|
||||
- core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
|
||||
+ dev_err(&bus->dev, "failed to write mmd register\n");
|
||||
|
||||
mt7530_mutex_unlock(priv);
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
From f13b2b33c7674fa0988dfaa9adb95d7d912b489f Mon Sep 17 00:00:00 2001
|
||||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
||||
Date: Wed, 10 Apr 2024 20:42:38 +0100
|
||||
Subject: [PATCH 1/2] net: dsa: introduce dsa_phylink_to_port()
|
||||
|
||||
We convert from a phylink_config struct to a dsa_port struct in many
|
||||
places, let's provide a helper for this.
|
||||
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
||||
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
|
||||
Link: https://lore.kernel.org/r/E1rudqA-006K9B-85@rmk-PC.armlinux.org.uk
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
include/net/dsa.h | 6 ++++++
|
||||
net/dsa/port.c | 12 ++++++------
|
||||
2 files changed, 12 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/include/net/dsa.h
|
||||
+++ b/include/net/dsa.h
|
||||
@@ -327,6 +327,12 @@ struct dsa_port {
|
||||
};
|
||||
};
|
||||
|
||||
+static inline struct dsa_port *
|
||||
+dsa_phylink_to_port(struct phylink_config *config)
|
||||
+{
|
||||
+ return container_of(config, struct dsa_port, pl_config);
|
||||
+}
|
||||
+
|
||||
/* TODO: ideally DSA ports would have a single dp->link_dp member,
|
||||
* and no dst->rtable nor this struct dsa_link would be needed,
|
||||
* but this would require some more complex tree walking,
|
||||
--- a/net/dsa/port.c
|
||||
+++ b/net/dsa/port.c
|
||||
@@ -1572,7 +1572,7 @@ static struct phylink_pcs *
|
||||
dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
@@ -1586,7 +1586,7 @@ static int dsa_port_phylink_mac_prepare(
|
||||
unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
int err = 0;
|
||||
|
||||
@@ -1601,7 +1601,7 @@ static void dsa_port_phylink_mac_config(
|
||||
unsigned int mode,
|
||||
const struct phylink_link_state *state)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
if (!ds->ops->phylink_mac_config)
|
||||
@@ -1614,7 +1614,7 @@ static int dsa_port_phylink_mac_finish(s
|
||||
unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
int err = 0;
|
||||
|
||||
@@ -1629,7 +1629,7 @@ static void dsa_port_phylink_mac_link_do
|
||||
unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct phy_device *phydev = NULL;
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
@@ -1652,7 +1652,7 @@ static void dsa_port_phylink_mac_link_up
|
||||
int speed, int duplex,
|
||||
bool tx_pause, bool rx_pause)
|
||||
{
|
||||
- struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
|
||||
if (!ds->ops->phylink_mac_link_up) {
|
||||
@ -0,0 +1,119 @@
|
||||
From c22d8240fcd73a1c3ec8dcb055bd583fb970c375 Mon Sep 17 00:00:00 2001
|
||||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
||||
Date: Wed, 10 Apr 2024 20:42:43 +0100
|
||||
Subject: [PATCH 2/2] net: dsa: allow DSA switch drivers to provide their own
|
||||
phylink mac ops
|
||||
|
||||
Rather than having a shim for each and every phylink MAC operation,
|
||||
allow DSA switch drivers to provide their own ops structure. When a
|
||||
DSA driver provides the phylink MAC operations, the shimmed ops must
|
||||
not be provided, so fail an attempt to register a switch with both
|
||||
the phylink_mac_ops in struct dsa_switch and the phylink_mac_*
|
||||
operations populated in dsa_switch_ops populated.
|
||||
|
||||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
||||
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
|
||||
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Link: https://lore.kernel.org/r/E1rudqF-006K9H-Cc@rmk-PC.armlinux.org.uk
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
include/net/dsa.h | 5 +++++
|
||||
net/dsa/dsa.c | 11 +++++++++++
|
||||
net/dsa/port.c | 26 ++++++++++++++++++++------
|
||||
3 files changed, 36 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/include/net/dsa.h
|
||||
+++ b/include/net/dsa.h
|
||||
@@ -458,6 +458,11 @@ struct dsa_switch {
|
||||
const struct dsa_switch_ops *ops;
|
||||
|
||||
/*
|
||||
+ * Allow a DSA switch driver to override the phylink MAC ops
|
||||
+ */
|
||||
+ const struct phylink_mac_ops *phylink_mac_ops;
|
||||
+
|
||||
+ /*
|
||||
* Slave mii_bus and devices for the individual ports.
|
||||
*/
|
||||
u32 phys_mii_mask;
|
||||
--- a/net/dsa/dsa.c
|
||||
+++ b/net/dsa/dsa.c
|
||||
@@ -1510,6 +1510,17 @@ static int dsa_switch_probe(struct dsa_s
|
||||
if (!ds->num_ports)
|
||||
return -EINVAL;
|
||||
|
||||
+ if (ds->phylink_mac_ops) {
|
||||
+ if (ds->ops->phylink_mac_select_pcs ||
|
||||
+ ds->ops->phylink_mac_prepare ||
|
||||
+ ds->ops->phylink_mac_config ||
|
||||
+ ds->ops->phylink_mac_finish ||
|
||||
+ ds->ops->phylink_mac_link_down ||
|
||||
+ ds->ops->phylink_mac_link_up ||
|
||||
+ ds->ops->adjust_link)
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
if (np) {
|
||||
err = dsa_switch_parse_of(ds, np);
|
||||
if (err)
|
||||
--- a/net/dsa/port.c
|
||||
+++ b/net/dsa/port.c
|
||||
@@ -1677,6 +1677,7 @@ static const struct phylink_mac_ops dsa_
|
||||
|
||||
int dsa_port_phylink_create(struct dsa_port *dp)
|
||||
{
|
||||
+ const struct phylink_mac_ops *mac_ops;
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
phy_interface_t mode;
|
||||
struct phylink *pl;
|
||||
@@ -1700,8 +1701,12 @@ int dsa_port_phylink_create(struct dsa_p
|
||||
}
|
||||
}
|
||||
|
||||
- pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn),
|
||||
- mode, &dsa_port_phylink_mac_ops);
|
||||
+ mac_ops = &dsa_port_phylink_mac_ops;
|
||||
+ if (ds->phylink_mac_ops)
|
||||
+ mac_ops = ds->phylink_mac_ops;
|
||||
+
|
||||
+ pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), mode,
|
||||
+ mac_ops);
|
||||
if (IS_ERR(pl)) {
|
||||
pr_err("error creating PHYLINK: %ld\n", PTR_ERR(pl));
|
||||
return PTR_ERR(pl);
|
||||
@@ -1967,12 +1972,23 @@ static void dsa_shared_port_validate_of(
|
||||
dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
|
||||
}
|
||||
|
||||
+static void dsa_shared_port_link_down(struct dsa_port *dp)
|
||||
+{
|
||||
+ struct dsa_switch *ds = dp->ds;
|
||||
+
|
||||
+ if (ds->phylink_mac_ops && ds->phylink_mac_ops->mac_link_down)
|
||||
+ ds->phylink_mac_ops->mac_link_down(&dp->pl_config, MLO_AN_FIXED,
|
||||
+ PHY_INTERFACE_MODE_NA);
|
||||
+ else if (ds->ops->phylink_mac_link_down)
|
||||
+ ds->ops->phylink_mac_link_down(ds, dp->index, MLO_AN_FIXED,
|
||||
+ PHY_INTERFACE_MODE_NA);
|
||||
+}
|
||||
+
|
||||
int dsa_shared_port_link_register_of(struct dsa_port *dp)
|
||||
{
|
||||
struct dsa_switch *ds = dp->ds;
|
||||
bool missing_link_description;
|
||||
bool missing_phy_mode;
|
||||
- int port = dp->index;
|
||||
|
||||
dsa_shared_port_validate_of(dp, &missing_phy_mode,
|
||||
&missing_link_description);
|
||||
@@ -1988,9 +2004,7 @@ int dsa_shared_port_link_register_of(str
|
||||
"Skipping phylink registration for %s port %d\n",
|
||||
dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
|
||||
} else {
|
||||
- if (ds->ops->phylink_mac_link_down)
|
||||
- ds->ops->phylink_mac_link_down(ds, port,
|
||||
- MLO_AN_FIXED, PHY_INTERFACE_MODE_NA);
|
||||
+ dsa_shared_port_link_down(dp);
|
||||
|
||||
return dsa_shared_port_phylink_register(dp);
|
||||
}
|
||||
@ -24,7 +24,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2860,15 +2860,6 @@ static void mt753x_phylink_mac_link_down
|
||||
@@ -3021,15 +3021,6 @@ static void mt753x_phylink_mac_link_down
|
||||
mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
@@ -2956,8 +2947,6 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
@@ -3117,8 +3108,6 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
return ret;
|
||||
mt7530_write(priv, MT7530_PMCR_P(port),
|
||||
PMCR_CPU_PORT_SETTING(priv->id));
|
||||
|
||||
@ -46,7 +46,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2182,24 +2182,40 @@ mt7530_free_irq_common(struct mt7530_pri
|
||||
@@ -2343,24 +2343,40 @@ mt7530_free_irq_common(struct mt7530_pri
|
||||
static void
|
||||
mt7530_free_irq(struct mt7530_priv *priv)
|
||||
{
|
||||
@ -92,7 +92,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
bus->priv = priv;
|
||||
bus->name = KBUILD_MODNAME "-mii";
|
||||
snprintf(bus->id, MII_BUS_ID_SIZE, KBUILD_MODNAME "-%d", idx++);
|
||||
@@ -2210,16 +2226,18 @@ mt7530_setup_mdio(struct mt7530_priv *pr
|
||||
@@ -2371,16 +2387,18 @@ mt7530_setup_mdio(struct mt7530_priv *pr
|
||||
bus->parent = dev;
|
||||
bus->phy_mask = ~ds->phys_mii_mask;
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1071,10 +1071,6 @@ mt753x_cpu_port_enable(struct dsa_switch
|
||||
@@ -1232,10 +1232,6 @@ mt753x_cpu_port_enable(struct dsa_switch
|
||||
mt7530_set(priv, MT7530_MFC, BC_FFP(BIT(port)) | UNM_FFP(BIT(port)) |
|
||||
UNU_FFP(BIT(port)));
|
||||
|
||||
@ -49,7 +49,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
/* Add the CPU port to the CPU port bitmap for MT7531 and the switch on
|
||||
* the MT7988 SoC. Trapped frames will be forwarded to the CPU port that
|
||||
* is affine to the inbound user port.
|
||||
@@ -3128,6 +3124,36 @@ static int mt753x_set_mac_eee(struct dsa
|
||||
@@ -3289,6 +3285,36 @@ static int mt753x_set_mac_eee(struct dsa
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static int mt7988_pad_setup(struct dsa_switch *ds, phy_interface_t interface)
|
||||
{
|
||||
return 0;
|
||||
@@ -3183,6 +3209,7 @@ const struct dsa_switch_ops mt7530_switc
|
||||
@@ -3344,6 +3370,7 @@ const struct dsa_switch_ops mt7530_switc
|
||||
.phylink_mac_link_up = mt753x_phylink_mac_link_up,
|
||||
.get_mac_eee = mt753x_get_mac_eee,
|
||||
.set_mac_eee = mt753x_set_mac_eee,
|
||||
@ -107,7 +107,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
#define MIRROR_EN BIT(3)
|
||||
#define MIRROR_PORT(x) ((x) & 0x7)
|
||||
#define MIRROR_MASK 0x7
|
||||
@@ -780,6 +780,7 @@ struct mt753x_info {
|
||||
@@ -785,6 +785,7 @@ struct mt753x_info {
|
||||
* @irq_domain: IRQ domain of the switch irq_chip
|
||||
* @irq_enable: IRQ enable bits, synced to SYS_INT_EN
|
||||
* @create_sgmii: Pointer to function creating SGMII PCS instance(s)
|
||||
@ -115,7 +115,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
*/
|
||||
struct mt7530_priv {
|
||||
struct device *dev;
|
||||
@@ -806,6 +807,7 @@ struct mt7530_priv {
|
||||
@@ -811,6 +812,7 @@ struct mt7530_priv {
|
||||
struct irq_domain *irq_domain;
|
||||
u32 irq_enable;
|
||||
int (*create_sgmii)(struct mt7530_priv *priv, bool dual_sgmii);
|
||||
|
||||
@ -25,7 +25,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -703,7 +703,7 @@ struct mt7530_port {
|
||||
@@ -708,7 +708,7 @@ struct mt7530_port {
|
||||
|
||||
/* Port 5 interface select definitions */
|
||||
enum p5_interface_select {
|
||||
@ -34,7 +34,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
P5_INTF_SEL_PHY_P0,
|
||||
P5_INTF_SEL_PHY_P4,
|
||||
P5_INTF_SEL_GMAC5,
|
||||
@@ -796,7 +796,7 @@ struct mt7530_priv {
|
||||
@@ -801,7 +801,7 @@ struct mt7530_priv {
|
||||
bool mcm;
|
||||
phy_interface_t p6_interface;
|
||||
phy_interface_t p5_interface;
|
||||
|
||||
@ -100,7 +100,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
@@ -2524,6 +2510,12 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
@@ -2685,6 +2671,12 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
/* all MACs must be forced link-down before sw reset */
|
||||
for (i = 0; i < MT7530_NUM_PORTS; i++)
|
||||
mt7530_write(priv, MT7530_PMCR_P(i), MT7531_FORCE_LNK);
|
||||
@@ -2533,21 +2525,18 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
@@ -2694,21 +2686,18 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
|
||||
SYS_CTRL_REG_RST);
|
||||
|
||||
@ -141,7 +141,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK,
|
||||
MT7531_GPIO0_INTERRUPT);
|
||||
@@ -2607,11 +2596,6 @@ static void mt7530_mac_port_get_caps(str
|
||||
@@ -2768,11 +2757,6 @@ static void mt7530_mac_port_get_caps(str
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port,
|
||||
struct phylink_config *config)
|
||||
{
|
||||
@@ -2624,7 +2608,7 @@ static void mt7531_mac_port_get_caps(str
|
||||
@@ -2785,7 +2769,7 @@ static void mt7531_mac_port_get_caps(str
|
||||
break;
|
||||
|
||||
case 5: /* 2nd cpu port supports either rgmii or sgmii/8023z */
|
||||
@ -162,7 +162,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
phy_interface_set_rgmii(config->supported_interfaces);
|
||||
break;
|
||||
}
|
||||
@@ -2691,7 +2675,7 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
@@ -2852,7 +2836,7 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
{
|
||||
u32 val;
|
||||
|
||||
@ -171,7 +171,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
dev_err(priv->dev, "RGMII mode is not available for port %d\n",
|
||||
port);
|
||||
return -EINVAL;
|
||||
@@ -2934,7 +2918,7 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
@@ -3095,7 +3079,7 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
|
||||
switch (port) {
|
||||
case 5:
|
||||
@ -180,7 +180,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
interface = PHY_INTERFACE_MODE_RGMII;
|
||||
else
|
||||
interface = PHY_INTERFACE_MODE_2500BASEX;
|
||||
@@ -3086,7 +3070,7 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3247,7 +3231,7 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
if (priv->create_sgmii) {
|
||||
@ -191,7 +191,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
}
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -707,7 +707,6 @@ enum p5_interface_select {
|
||||
@@ -712,7 +712,6 @@ enum p5_interface_select {
|
||||
P5_INTF_SEL_PHY_P0,
|
||||
P5_INTF_SEL_PHY_P4,
|
||||
P5_INTF_SEL_GMAC5,
|
||||
@ -199,7 +199,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
};
|
||||
|
||||
struct mt7530_priv;
|
||||
@@ -776,6 +775,8 @@ struct mt753x_info {
|
||||
@@ -781,6 +780,8 @@ struct mt753x_info {
|
||||
* registers
|
||||
* @p6_interface Holding the current port 6 interface
|
||||
* @p5_intf_sel: Holding the current port 5 interface select
|
||||
@ -208,7 +208,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
* @irq: IRQ number of the switch
|
||||
* @irq_domain: IRQ domain of the switch irq_chip
|
||||
* @irq_enable: IRQ enable bits, synced to SYS_INT_EN
|
||||
@@ -797,6 +798,7 @@ struct mt7530_priv {
|
||||
@@ -802,6 +803,7 @@ struct mt7530_priv {
|
||||
phy_interface_t p6_interface;
|
||||
phy_interface_t p5_interface;
|
||||
enum p5_interface_select p5_intf_sel;
|
||||
@ -216,7 +216,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
u8 mirror_rx;
|
||||
u8 mirror_tx;
|
||||
struct mt7530_port ports[MT7530_NUM_PORTS];
|
||||
@@ -806,7 +808,7 @@ struct mt7530_priv {
|
||||
@@ -811,7 +813,7 @@ struct mt7530_priv {
|
||||
int irq;
|
||||
struct irq_domain *irq_domain;
|
||||
u32 irq_enable;
|
||||
|
||||
@ -37,7 +37,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2574,12 +2574,14 @@ static void mt7530_mac_port_get_caps(str
|
||||
@@ -2735,12 +2735,14 @@ static void mt7530_mac_port_get_caps(str
|
||||
struct phylink_config *config)
|
||||
{
|
||||
switch (port) {
|
||||
@ -54,7 +54,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
phy_interface_set_rgmii(config->supported_interfaces);
|
||||
__set_bit(PHY_INTERFACE_MODE_MII,
|
||||
config->supported_interfaces);
|
||||
@@ -2587,7 +2589,8 @@ static void mt7530_mac_port_get_caps(str
|
||||
@@ -2748,7 +2750,8 @@ static void mt7530_mac_port_get_caps(str
|
||||
config->supported_interfaces);
|
||||
break;
|
||||
|
||||
@ -64,7 +64,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
__set_bit(PHY_INTERFACE_MODE_RGMII,
|
||||
config->supported_interfaces);
|
||||
__set_bit(PHY_INTERFACE_MODE_TRGMII,
|
||||
@@ -2602,19 +2605,24 @@ static void mt7531_mac_port_get_caps(str
|
||||
@@ -2763,19 +2766,24 @@ static void mt7531_mac_port_get_caps(str
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
switch (port) {
|
||||
@ -92,7 +92,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
__set_bit(PHY_INTERFACE_MODE_SGMII,
|
||||
config->supported_interfaces);
|
||||
__set_bit(PHY_INTERFACE_MODE_1000BASEX,
|
||||
@@ -2633,11 +2641,13 @@ static void mt7988_mac_port_get_caps(str
|
||||
@@ -2794,11 +2802,13 @@ static void mt7988_mac_port_get_caps(str
|
||||
phy_interface_zero(config->supported_interfaces);
|
||||
|
||||
switch (port) {
|
||||
@ -107,7 +107,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
case 6:
|
||||
__set_bit(PHY_INTERFACE_MODE_INTERNAL,
|
||||
config->supported_interfaces);
|
||||
@@ -2801,12 +2811,12 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2962,12 +2972,12 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
u32 mcr_cur, mcr_new;
|
||||
|
||||
switch (port) {
|
||||
@ -122,7 +122,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
if (priv->p5_interface == state->interface)
|
||||
break;
|
||||
|
||||
@@ -2816,7 +2826,7 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2977,7 +2987,7 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
if (priv->p5_intf_sel != P5_DISABLED)
|
||||
priv->p5_interface = state->interface;
|
||||
break;
|
||||
|
||||
@ -52,7 +52,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2362,16 +2362,15 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2523,16 +2523,15 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
return ret;
|
||||
|
||||
/* Setup port 5 */
|
||||
@ -75,7 +75,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
for_each_child_of_node(dn, mac_np) {
|
||||
if (!of_device_is_compatible(mac_np,
|
||||
"mediatek,eth-mac"))
|
||||
@@ -2402,6 +2401,8 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2563,6 +2562,8 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
of_node_put(phy_node);
|
||||
break;
|
||||
}
|
||||
@ -84,7 +84,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GPIOLIB
|
||||
@@ -2412,8 +2413,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2573,8 +2574,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
}
|
||||
#endif /* CONFIG_GPIOLIB */
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
default:
|
||||
dev_err(ds->dev, "Unsupported p5_intf_sel %d\n",
|
||||
priv->p5_intf_sel);
|
||||
@@ -2367,8 +2364,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2528,8 +2525,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
* Set priv->p5_intf_sel to the appropriate value if PHY muxing
|
||||
* is detected.
|
||||
*/
|
||||
@ -49,7 +49,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
for_each_child_of_node(dn, mac_np) {
|
||||
if (!of_device_is_compatible(mac_np,
|
||||
"mediatek,eth-mac"))
|
||||
@@ -2400,7 +2395,9 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2561,7 +2556,9 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
switch (interface) {
|
||||
case PHY_INTERFACE_MODE_RGMII:
|
||||
trgint = 0;
|
||||
@@ -2295,6 +2288,12 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2456,6 +2449,12 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2649,11 +2653,10 @@ mt7530_mac_config(struct dsa_switch *ds,
|
||||
@@ -2810,11 +2814,10 @@ mt7530_mac_config(struct dsa_switch *ds,
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static void
|
||||
mt7531_pll_setup(struct mt7530_priv *priv)
|
||||
{
|
||||
@@ -2640,14 +2628,6 @@ static void mt7988_mac_port_get_caps(str
|
||||
@@ -2801,14 +2789,6 @@ static void mt7988_mac_port_get_caps(str
|
||||
}
|
||||
|
||||
static int
|
||||
@ -62,7 +62,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
@@ -2812,8 +2792,6 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2973,8 +2953,6 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
if (priv->p6_interface == state->interface)
|
||||
break;
|
||||
|
||||
@ -71,7 +71,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
if (mt753x_mac_config(ds, port, mode, state) < 0)
|
||||
goto unsupported;
|
||||
|
||||
@@ -3130,11 +3108,6 @@ mt753x_conduit_state_change(struct dsa_s
|
||||
@@ -3291,11 +3269,6 @@ mt753x_conduit_state_change(struct dsa_s
|
||||
mt7530_rmw(priv, MT7530_MFC, CPU_EN | CPU_PORT_MASK, val);
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
static int mt7988_setup(struct dsa_switch *ds)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
@@ -3198,7 +3171,6 @@ const struct mt753x_info mt753x_table[]
|
||||
@@ -3359,7 +3332,6 @@ const struct mt753x_info mt753x_table[]
|
||||
.phy_write_c22 = mt7530_phy_write_c22,
|
||||
.phy_read_c45 = mt7530_phy_read_c45,
|
||||
.phy_write_c45 = mt7530_phy_write_c45,
|
||||
@ -91,7 +91,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
.mac_port_get_caps = mt7530_mac_port_get_caps,
|
||||
.mac_port_config = mt7530_mac_config,
|
||||
},
|
||||
@@ -3210,7 +3182,6 @@ const struct mt753x_info mt753x_table[]
|
||||
@@ -3371,7 +3343,6 @@ const struct mt753x_info mt753x_table[]
|
||||
.phy_write_c22 = mt7530_phy_write_c22,
|
||||
.phy_read_c45 = mt7530_phy_read_c45,
|
||||
.phy_write_c45 = mt7530_phy_write_c45,
|
||||
@ -99,7 +99,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
.mac_port_get_caps = mt7530_mac_port_get_caps,
|
||||
.mac_port_config = mt7530_mac_config,
|
||||
},
|
||||
@@ -3222,7 +3193,6 @@ const struct mt753x_info mt753x_table[]
|
||||
@@ -3383,7 +3354,6 @@ const struct mt753x_info mt753x_table[]
|
||||
.phy_write_c22 = mt7531_ind_c22_phy_write,
|
||||
.phy_read_c45 = mt7531_ind_c45_phy_read,
|
||||
.phy_write_c45 = mt7531_ind_c45_phy_write,
|
||||
@ -107,7 +107,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
.cpu_port_config = mt7531_cpu_port_config,
|
||||
.mac_port_get_caps = mt7531_mac_port_get_caps,
|
||||
.mac_port_config = mt7531_mac_config,
|
||||
@@ -3235,7 +3205,6 @@ const struct mt753x_info mt753x_table[]
|
||||
@@ -3396,7 +3366,6 @@ const struct mt753x_info mt753x_table[]
|
||||
.phy_write_c22 = mt7531_ind_c22_phy_write,
|
||||
.phy_read_c45 = mt7531_ind_c45_phy_read,
|
||||
.phy_write_c45 = mt7531_ind_c45_phy_write,
|
||||
@ -115,7 +115,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
.cpu_port_config = mt7988_cpu_port_config,
|
||||
.mac_port_get_caps = mt7988_mac_port_get_caps,
|
||||
.mac_port_config = mt7988_mac_config,
|
||||
@@ -3265,9 +3234,8 @@ mt7530_probe_common(struct mt7530_priv *
|
||||
@@ -3426,9 +3395,8 @@ mt7530_probe_common(struct mt7530_priv *
|
||||
/* Sanity check if these required device operations are filled
|
||||
* properly.
|
||||
*/
|
||||
@ -129,7 +129,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -724,8 +724,6 @@ struct mt753x_pcs {
|
||||
@@ -729,8 +729,6 @@ struct mt753x_pcs {
|
||||
* @phy_write_c22: Holding the way writing PHY port using C22
|
||||
* @phy_read_c45: Holding the way reading PHY port using C45
|
||||
* @phy_write_c45: Holding the way writing PHY port using C45
|
||||
@ -138,7 +138,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
* @phy_mode_supported: Check if the PHY type is being supported on a certain
|
||||
* port
|
||||
* @mac_port_validate: Holding the way to set addition validate type for a
|
||||
@@ -746,7 +744,6 @@ struct mt753x_info {
|
||||
@@ -751,7 +749,6 @@ struct mt753x_info {
|
||||
int regnum);
|
||||
int (*phy_write_c45)(struct mt7530_priv *priv, int port, int devad,
|
||||
int regnum, u16 val);
|
||||
|
||||
@ -25,7 +25,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2613,7 +2613,7 @@ static void mt7988_mac_port_get_caps(str
|
||||
@@ -2774,7 +2774,7 @@ static void mt7988_mac_port_get_caps(str
|
||||
|
||||
switch (port) {
|
||||
/* Ports which are connected to switch PHYs. There is no MII pinout. */
|
||||
|
||||
@ -27,7 +27,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2609,8 +2609,6 @@ static void mt7531_mac_port_get_caps(str
|
||||
@@ -2770,8 +2770,6 @@ static void mt7531_mac_port_get_caps(str
|
||||
static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port,
|
||||
struct phylink_config *config)
|
||||
{
|
||||
|
||||
@ -33,7 +33,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2692,17 +2692,6 @@ static bool mt753x_is_mac_port(u32 port)
|
||||
@@ -2853,17 +2853,6 @@ static bool mt753x_is_mac_port(u32 port)
|
||||
}
|
||||
|
||||
static int
|
||||
@ -51,7 +51,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
@@ -2742,6 +2731,9 @@ mt753x_mac_config(struct dsa_switch *ds,
|
||||
@@ -2903,6 +2892,9 @@ mt753x_mac_config(struct dsa_switch *ds,
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
|
||||
@ -61,7 +61,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
return priv->info->mac_port_config(ds, port, mode, state->interface);
|
||||
}
|
||||
|
||||
@@ -3205,7 +3197,6 @@ const struct mt753x_info mt753x_table[]
|
||||
@@ -3366,7 +3358,6 @@ const struct mt753x_info mt753x_table[]
|
||||
.phy_write_c45 = mt7531_ind_c45_phy_write,
|
||||
.cpu_port_config = mt7988_cpu_port_config,
|
||||
.mac_port_get_caps = mt7988_mac_port_get_caps,
|
||||
@ -69,7 +69,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
},
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(mt753x_table);
|
||||
@@ -3233,8 +3224,7 @@ mt7530_probe_common(struct mt7530_priv *
|
||||
@@ -3394,8 +3385,7 @@ mt7530_probe_common(struct mt7530_priv *
|
||||
* properly.
|
||||
*/
|
||||
if (!priv->info->sw_setup || !priv->info->phy_read_c22 ||
|
||||
|
||||
@ -20,7 +20,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2091,7 +2091,7 @@ mt7530_setup_irq(struct mt7530_priv *pri
|
||||
@@ -2252,7 +2252,7 @@ mt7530_setup_irq(struct mt7530_priv *pri
|
||||
}
|
||||
|
||||
/* This register must be set for MT7530 to properly fire interrupts */
|
||||
|
||||
@ -22,7 +22,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2487,14 +2487,12 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
@@ -2648,14 +2648,12 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
val = mt7530_read(priv, MT7531_TOP_SIG_SR);
|
||||
priv->p5_sgmii = !!(val & PAD_DUAL_SGMII_EN);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2623,7 +2623,7 @@ static void mt7988_mac_port_get_caps(str
|
||||
@@ -2784,7 +2784,7 @@ static void mt7988_mac_port_get_caps(str
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
@@ -2633,22 +2633,14 @@ mt7530_mac_config(struct dsa_switch *ds,
|
||||
@@ -2794,22 +2794,14 @@ mt7530_mac_config(struct dsa_switch *ds,
|
||||
mt7530_setup_port5(priv->ds, interface);
|
||||
else if (port == 6)
|
||||
mt7530_setup_port6(priv->ds, interface);
|
||||
@ -71,7 +71,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
val = mt7530_read(priv, MT7531_CLKGEN_CTRL);
|
||||
val |= GP_CLK_EN;
|
||||
val &= ~GP_MODE_MASK;
|
||||
@@ -2676,20 +2668,14 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
@@ -2837,20 +2829,14 @@ static int mt7531_rgmii_setup(struct mt7
|
||||
case PHY_INTERFACE_MODE_RGMII_ID:
|
||||
break;
|
||||
default:
|
||||
@ -95,7 +95,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
@@ -2697,42 +2683,21 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
@@ -2858,42 +2844,21 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
struct phy_device *phydev;
|
||||
struct dsa_port *dp;
|
||||
|
||||
@ -143,7 +143,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
}
|
||||
|
||||
static struct phylink_pcs *
|
||||
@@ -2761,17 +2726,11 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2922,17 +2887,11 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
u32 mcr_cur, mcr_new;
|
||||
|
||||
switch (port) {
|
||||
@ -162,7 +162,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
if (priv->p5_intf_sel != P5_DISABLED)
|
||||
priv->p5_interface = state->interface;
|
||||
@@ -2780,16 +2739,10 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2941,16 +2900,10 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
if (priv->p6_interface == state->interface)
|
||||
break;
|
||||
|
||||
@ -180,7 +180,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
}
|
||||
|
||||
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
|
||||
@@ -2872,7 +2825,6 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
@@ -3033,7 +2986,6 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
phy_interface_t interface;
|
||||
int speed;
|
||||
@ -188,7 +188,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
switch (port) {
|
||||
case 5:
|
||||
@@ -2897,9 +2849,8 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
@@ -3058,9 +3010,8 @@ mt7531_cpu_port_config(struct dsa_switch
|
||||
else
|
||||
speed = SPEED_1000;
|
||||
|
||||
@ -202,7 +202,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mt753x_phylink_mac_link_up(ds, port, MLO_AN_FIXED, interface, NULL,
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -750,9 +750,9 @@ struct mt753x_info {
|
||||
@@ -755,9 +755,9 @@ struct mt753x_info {
|
||||
void (*mac_port_validate)(struct dsa_switch *ds, int port,
|
||||
phy_interface_t interface,
|
||||
unsigned long *supported);
|
||||
|
||||
@ -57,8 +57,8 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1002,18 +1002,10 @@ mt753x_trap_frames(struct mt7530_priv *p
|
||||
MT753X_BPDU_CPU_ONLY);
|
||||
@@ -1163,18 +1163,10 @@ mt753x_trap_frames(struct mt7530_priv *p
|
||||
MT753X_BPDU_CPU_ONLY);
|
||||
}
|
||||
|
||||
-static int
|
||||
@ -77,7 +77,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
/* Enable Mediatek header mode on the cpu port */
|
||||
mt7530_write(priv, MT7530_PVC_P(port),
|
||||
@@ -1039,8 +1031,6 @@ mt753x_cpu_port_enable(struct dsa_switch
|
||||
@@ -1200,8 +1192,6 @@ mt753x_cpu_port_enable(struct dsa_switch
|
||||
/* Set to fallback mode for independent VLAN learning */
|
||||
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK,
|
||||
MT7530_PORT_FALLBACK_MODE);
|
||||
@ -86,7 +86,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -2297,8 +2287,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2458,8 +2448,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
val |= MHWTRAP_MANUAL;
|
||||
mt7530_write(priv, MT7530_MHWTRAP, val);
|
||||
|
||||
@ -95,7 +95,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mt753x_trap_frames(priv);
|
||||
|
||||
/* Enable and reset MIB counters */
|
||||
@@ -2313,9 +2301,7 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2474,9 +2462,7 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
mt7530_set(priv, MT7530_PSC_P(i), SA_DIS);
|
||||
|
||||
if (dsa_is_cpu_port(ds, i)) {
|
||||
@ -106,7 +106,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
} else {
|
||||
mt7530_port_disable(ds, i);
|
||||
|
||||
@@ -2419,9 +2405,7 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
@@ -2580,9 +2566,7 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
mt7530_set(priv, MT7531_DBG_CNT(i), MT7531_DIS_CLR);
|
||||
|
||||
if (dsa_is_cpu_port(ds, i)) {
|
||||
@ -117,7 +117,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
} else {
|
||||
mt7530_port_disable(ds, i);
|
||||
|
||||
@@ -2510,10 +2494,6 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
@@ -2671,10 +2655,6 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK,
|
||||
MT7531_GPIO0_INTERRUPT);
|
||||
|
||||
@ -128,7 +128,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
/* Enable PHY core PLL, since phy_device has not yet been created
|
||||
* provided for phy_[read,write]_mmd_indirect is called, we provide
|
||||
* our own mt7531_ind_mmd_phy_[read,write] to complete this
|
||||
@@ -2725,26 +2705,9 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2886,26 +2866,9 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
u32 mcr_cur, mcr_new;
|
||||
|
||||
@ -156,7 +156,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
|
||||
mcr_new = mcr_cur;
|
||||
mcr_new &= ~PMCR_LINK_SETTINGS_MASK;
|
||||
@@ -2780,17 +2743,10 @@ static void mt753x_phylink_mac_link_up(s
|
||||
@@ -2941,17 +2904,10 @@ static void mt753x_phylink_mac_link_up(s
|
||||
|
||||
mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
|
||||
|
||||
@ -176,7 +176,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mcr |= PMCR_FORCE_SPEED_1000;
|
||||
break;
|
||||
case SPEED_100:
|
||||
@@ -2808,6 +2764,7 @@ static void mt753x_phylink_mac_link_up(s
|
||||
@@ -2969,6 +2925,7 @@ static void mt753x_phylink_mac_link_up(s
|
||||
if (mode == MLO_AN_PHY && phydev && phy_init_eee(phydev, false) >= 0) {
|
||||
switch (speed) {
|
||||
case SPEED_1000:
|
||||
@ -184,7 +184,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
mcr |= PMCR_FORCE_EEE1G;
|
||||
break;
|
||||
case SPEED_100:
|
||||
@@ -2819,61 +2776,6 @@ static void mt753x_phylink_mac_link_up(s
|
||||
@@ -2980,61 +2937,6 @@ static void mt753x_phylink_mac_link_up(s
|
||||
mt7530_set(priv, MT7530_PMCR_P(port), mcr);
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
|
||||
struct phylink_config *config)
|
||||
{
|
||||
@@ -3132,7 +3034,6 @@ const struct mt753x_info mt753x_table[]
|
||||
@@ -3293,7 +3195,6 @@ const struct mt753x_info mt753x_table[]
|
||||
.phy_write_c22 = mt7531_ind_c22_phy_write,
|
||||
.phy_read_c45 = mt7531_ind_c45_phy_read,
|
||||
.phy_write_c45 = mt7531_ind_c45_phy_write,
|
||||
@ -254,7 +254,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
.mac_port_get_caps = mt7531_mac_port_get_caps,
|
||||
.mac_port_config = mt7531_mac_config,
|
||||
},
|
||||
@@ -3144,7 +3045,6 @@ const struct mt753x_info mt753x_table[]
|
||||
@@ -3305,7 +3206,6 @@ const struct mt753x_info mt753x_table[]
|
||||
.phy_write_c22 = mt7531_ind_c22_phy_write,
|
||||
.phy_read_c45 = mt7531_ind_c45_phy_read,
|
||||
.phy_write_c45 = mt7531_ind_c45_phy_write,
|
||||
@ -264,7 +264,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
};
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -331,13 +331,6 @@ enum mt7530_vlan_port_acc_frm {
|
||||
@@ -336,13 +336,6 @@ enum mt7530_vlan_port_acc_frm {
|
||||
PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
|
||||
PMCR_FORCE_FDX | PMCR_FORCE_LNK | \
|
||||
PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100)
|
||||
@ -278,7 +278,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
#define MT7530_PMEEECR_P(x) (0x3004 + (x) * 0x100)
|
||||
#define WAKEUP_TIME_1000(x) (((x) & 0xFF) << 24)
|
||||
@@ -744,7 +737,6 @@ struct mt753x_info {
|
||||
@@ -749,7 +742,6 @@ struct mt753x_info {
|
||||
int regnum);
|
||||
int (*phy_write_c45)(struct mt7530_priv *priv, int port, int devad,
|
||||
int regnum, u16 val);
|
||||
@ -286,7 +286,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
void (*mac_port_get_caps)(struct dsa_switch *ds, int port,
|
||||
struct phylink_config *config);
|
||||
void (*mac_port_validate)(struct dsa_switch *ds, int port,
|
||||
@@ -770,7 +762,6 @@ struct mt753x_info {
|
||||
@@ -775,7 +767,6 @@ struct mt753x_info {
|
||||
* @ports: Holding the state among ports
|
||||
* @reg_mutex: The lock for protecting among process accessing
|
||||
* registers
|
||||
@ -294,7 +294,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
* @p5_intf_sel: Holding the current port 5 interface select
|
||||
* @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch
|
||||
* has got SGMII
|
||||
@@ -792,8 +783,6 @@ struct mt7530_priv {
|
||||
@@ -797,8 +788,6 @@ struct mt7530_priv {
|
||||
const struct mt753x_info *info;
|
||||
unsigned int id;
|
||||
bool mcm;
|
||||
|
||||
@ -18,7 +18,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2670,16 +2670,6 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
@@ -2831,16 +2831,6 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static struct phylink_pcs *
|
||||
mt753x_phylink_mac_select_pcs(struct dsa_switch *ds, int port,
|
||||
phy_interface_t interface)
|
||||
@@ -2705,8 +2695,8 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2866,8 +2856,8 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
u32 mcr_cur, mcr_new;
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2848,17 +2848,9 @@ static int
|
||||
@@ -3009,17 +3009,9 @@ static int
|
||||
mt753x_setup(struct dsa_switch *ds)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
@ -40,7 +40,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -2870,6 +2862,14 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
@@ -3031,6 +3023,14 @@ mt753x_setup(struct dsa_switch *ds)
|
||||
if (ret && priv->irq)
|
||||
mt7530_free_irq_common(priv);
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1054,7 +1054,6 @@ mt7530_port_enable(struct dsa_switch *ds
|
||||
@@ -1215,7 +1215,6 @@ mt7530_port_enable(struct dsa_switch *ds
|
||||
priv->ports[port].enable = true;
|
||||
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
|
||||
priv->ports[port].pm);
|
||||
@ -32,7 +32,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
|
||||
@@ -1074,7 +1073,6 @@ mt7530_port_disable(struct dsa_switch *d
|
||||
@@ -1235,7 +1234,6 @@ mt7530_port_disable(struct dsa_switch *d
|
||||
priv->ports[port].enable = false;
|
||||
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK,
|
||||
PCR_MATRIX_CLR);
|
||||
@ -40,7 +40,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
}
|
||||
@@ -2293,6 +2291,12 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2454,6 +2452,12 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
mt7530_mib_reset(ds);
|
||||
|
||||
for (i = 0; i < MT7530_NUM_PORTS; i++) {
|
||||
@ -53,7 +53,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
/* Disable forwarding by default on all ports */
|
||||
mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
|
||||
PCR_MATRIX_CLR);
|
||||
@@ -2395,6 +2399,12 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
@@ -2556,6 +2560,12 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
UNU_FFP_MASK);
|
||||
|
||||
for (i = 0; i < MT7530_NUM_PORTS; i++) {
|
||||
|
||||
@ -45,7 +45,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2703,23 +2703,13 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
@@ -2864,23 +2864,13 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
const struct phylink_link_state *state)
|
||||
{
|
||||
struct mt7530_priv *priv = ds->priv;
|
||||
@ -72,7 +72,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
static void mt753x_phylink_mac_link_down(struct dsa_switch *ds, int port,
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -324,8 +324,6 @@ enum mt7530_vlan_port_acc_frm {
|
||||
@@ -329,8 +329,6 @@ enum mt7530_vlan_port_acc_frm {
|
||||
MT7531_FORCE_DPX | \
|
||||
MT7531_FORCE_RX_FC | \
|
||||
MT7531_FORCE_TX_FC)
|
||||
|
||||
@ -79,7 +79,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2228,6 +2228,12 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2389,6 +2389,12 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2274,8 +2274,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2435,8 +2435,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
|
||||
SYS_CTRL_REG_RST);
|
||||
|
||||
@ -62,7 +62,7 @@ Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
/* Lower Tx driving for TRGMII path */
|
||||
for (i = 0; i < NUM_TRGMII_CTRL; i++)
|
||||
mt7530_write(priv, MT7530_TRGMII_TD_ODT(i),
|
||||
@@ -2291,6 +2289,9 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2452,6 +2450,9 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
val |= MHWTRAP_MANUAL;
|
||||
mt7530_write(priv, MT7530_MHWTRAP, val);
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2228,12 +2228,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
@@ -2389,12 +2389,6 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2505,18 +2505,25 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
@@ -2666,18 +2666,25 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK,
|
||||
MT7531_GPIO0_INTERRUPT);
|
||||
|
||||
@ -82,7 +82,7 @@ Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
/* Setup VLAN ID 0 for VLAN-unaware bridges */
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -616,6 +616,7 @@ enum mt7531_clk_skew {
|
||||
@@ -621,6 +621,7 @@ enum mt7531_clk_skew {
|
||||
#define RG_SYSPLL_DDSFBK_EN BIT(12)
|
||||
#define RG_SYSPLL_BIAS_EN BIT(11)
|
||||
#define RG_SYSPLL_BIAS_LPF_EN BIT(10)
|
||||
@ -0,0 +1,135 @@
|
||||
From 5754b3bdcd872aa229881b8f07f84a8404c7d72a Mon Sep 17 00:00:00 2001
|
||||
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
||||
Date: Fri, 12 Apr 2024 16:15:34 +0100
|
||||
Subject: [PATCH 1/5] net: dsa: mt7530: provide own phylink MAC operations
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Convert mt753x to provide its own phylink MAC operations, thus avoiding
|
||||
the shim layer in DSA's port.c
|
||||
|
||||
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
||||
Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Link: https://lore.kernel.org/r/E1rvIco-006bQu-Fq@rmk-PC.armlinux.org.uk
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 46 +++++++++++++++++++++++++---------------
|
||||
1 file changed, 29 insertions(+), 17 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2850,28 +2850,34 @@ mt7531_mac_config(struct dsa_switch *ds,
|
||||
}
|
||||
|
||||
static struct phylink_pcs *
|
||||
-mt753x_phylink_mac_select_pcs(struct dsa_switch *ds, int port,
|
||||
+mt753x_phylink_mac_select_pcs(struct phylink_config *config,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
+ struct mt7530_priv *priv = dp->ds->priv;
|
||||
|
||||
switch (interface) {
|
||||
case PHY_INTERFACE_MODE_TRGMII:
|
||||
- return &priv->pcs[port].pcs;
|
||||
+ return &priv->pcs[dp->index].pcs;
|
||||
case PHY_INTERFACE_MODE_SGMII:
|
||||
case PHY_INTERFACE_MODE_1000BASEX:
|
||||
case PHY_INTERFACE_MODE_2500BASEX:
|
||||
- return priv->ports[port].sgmii_pcs;
|
||||
+ return priv->ports[dp->index].sgmii_pcs;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
-mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
|
||||
+mt753x_phylink_mac_config(struct phylink_config *config, unsigned int mode,
|
||||
const struct phylink_link_state *state)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
+ struct dsa_switch *ds = dp->ds;
|
||||
+ struct mt7530_priv *priv;
|
||||
+ int port = dp->index;
|
||||
+
|
||||
+ priv = ds->priv;
|
||||
|
||||
if ((port == 5 || port == 6) && priv->info->mac_port_config)
|
||||
priv->info->mac_port_config(ds, port, mode, state->interface);
|
||||
@@ -2881,23 +2887,25 @@ mt753x_phylink_mac_config(struct dsa_swi
|
||||
mt7530_set(priv, MT7530_PMCR_P(port), PMCR_EXT_PHY);
|
||||
}
|
||||
|
||||
-static void mt753x_phylink_mac_link_down(struct dsa_switch *ds, int port,
|
||||
+static void mt753x_phylink_mac_link_down(struct phylink_config *config,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
+ struct mt7530_priv *priv = dp->ds->priv;
|
||||
|
||||
- mt7530_clear(priv, MT7530_PMCR_P(port), PMCR_LINK_SETTINGS_MASK);
|
||||
+ mt7530_clear(priv, MT7530_PMCR_P(dp->index), PMCR_LINK_SETTINGS_MASK);
|
||||
}
|
||||
|
||||
-static void mt753x_phylink_mac_link_up(struct dsa_switch *ds, int port,
|
||||
+static void mt753x_phylink_mac_link_up(struct phylink_config *config,
|
||||
+ struct phy_device *phydev,
|
||||
unsigned int mode,
|
||||
phy_interface_t interface,
|
||||
- struct phy_device *phydev,
|
||||
int speed, int duplex,
|
||||
bool tx_pause, bool rx_pause)
|
||||
{
|
||||
- struct mt7530_priv *priv = ds->priv;
|
||||
+ struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
+ struct mt7530_priv *priv = dp->ds->priv;
|
||||
u32 mcr;
|
||||
|
||||
mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
|
||||
@@ -2932,7 +2940,7 @@ static void mt753x_phylink_mac_link_up(s
|
||||
}
|
||||
}
|
||||
|
||||
- mt7530_set(priv, MT7530_PMCR_P(port), mcr);
|
||||
+ mt7530_set(priv, MT7530_PMCR_P(dp->index), mcr);
|
||||
}
|
||||
|
||||
static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
|
||||
@@ -3152,16 +3160,19 @@ const struct dsa_switch_ops mt7530_switc
|
||||
.port_mirror_add = mt753x_port_mirror_add,
|
||||
.port_mirror_del = mt753x_port_mirror_del,
|
||||
.phylink_get_caps = mt753x_phylink_get_caps,
|
||||
- .phylink_mac_select_pcs = mt753x_phylink_mac_select_pcs,
|
||||
- .phylink_mac_config = mt753x_phylink_mac_config,
|
||||
- .phylink_mac_link_down = mt753x_phylink_mac_link_down,
|
||||
- .phylink_mac_link_up = mt753x_phylink_mac_link_up,
|
||||
.get_mac_eee = mt753x_get_mac_eee,
|
||||
.set_mac_eee = mt753x_set_mac_eee,
|
||||
.master_state_change = mt753x_conduit_state_change,
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(mt7530_switch_ops);
|
||||
|
||||
+static const struct phylink_mac_ops mt753x_phylink_mac_ops = {
|
||||
+ .mac_select_pcs = mt753x_phylink_mac_select_pcs,
|
||||
+ .mac_config = mt753x_phylink_mac_config,
|
||||
+ .mac_link_down = mt753x_phylink_mac_link_down,
|
||||
+ .mac_link_up = mt753x_phylink_mac_link_up,
|
||||
+};
|
||||
+
|
||||
const struct mt753x_info mt753x_table[] = {
|
||||
[ID_MT7621] = {
|
||||
.id = ID_MT7621,
|
||||
@@ -3239,6 +3250,7 @@ mt7530_probe_common(struct mt7530_priv *
|
||||
priv->dev = dev;
|
||||
priv->ds->priv = priv;
|
||||
priv->ds->ops = &mt7530_switch_ops;
|
||||
+ priv->ds->phylink_mac_ops = &mt753x_phylink_mac_ops;
|
||||
mutex_init(&priv->reg_mutex);
|
||||
dev_set_drvdata(dev, priv);
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
From d4097ddef078a113643a6dcde01e99741f852adb Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Sat, 13 Apr 2024 16:01:39 +0300
|
||||
Subject: [PATCH 2/5] net: dsa: mt7530: fix mirroring frames received on local
|
||||
port
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This switch intellectual property provides a bit on the ARL global control
|
||||
register which controls allowing mirroring frames which are received on the
|
||||
local port (monitor port). This bit is unset after reset.
|
||||
|
||||
This ability must be enabled to fully support the port mirroring feature on
|
||||
this switch intellectual property.
|
||||
|
||||
Therefore, this patch fixes the traffic not being reflected on a port,
|
||||
which would be configured like below:
|
||||
|
||||
tc qdisc add dev swp0 clsact
|
||||
|
||||
tc filter add dev swp0 ingress matchall skip_sw \
|
||||
action mirred egress mirror dev swp0
|
||||
|
||||
As a side note, this configuration provides the hairpinning feature for a
|
||||
single port.
|
||||
|
||||
Fixes: 37feab6076aa ("net: dsa: mt7530: add support for port mirroring")
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 6 ++++++
|
||||
drivers/net/dsa/mt7530.h | 4 ++++
|
||||
2 files changed, 10 insertions(+)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -2480,6 +2480,9 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
|
||||
}
|
||||
|
||||
+ /* Allow mirroring frames received on the local port (monitor port). */
|
||||
+ mt7530_set(priv, MT753X_AGC, LOCAL_EN);
|
||||
+
|
||||
/* Setup VLAN ID 0 for VLAN-unaware bridges */
|
||||
ret = mt7530_setup_vlan0(priv);
|
||||
if (ret)
|
||||
@@ -2591,6 +2594,9 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
PVC_EG_TAG(MT7530_VLAN_EG_CONSISTENT));
|
||||
}
|
||||
|
||||
+ /* Allow mirroring frames received on the local port (monitor port). */
|
||||
+ mt7530_set(priv, MT753X_AGC, LOCAL_EN);
|
||||
+
|
||||
/* Flush the FDB table */
|
||||
ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
|
||||
if (ret < 0)
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -32,6 +32,10 @@ enum mt753x_id {
|
||||
#define SYSC_REG_RSTCTRL 0x34
|
||||
#define RESET_MCM BIT(2)
|
||||
|
||||
+/* Register for ARL global control */
|
||||
+#define MT753X_AGC 0xc
|
||||
+#define LOCAL_EN BIT(7)
|
||||
+
|
||||
/* Registers to mac forward control for unknown frames */
|
||||
#define MT7530_MFC 0x10
|
||||
#define BC_FFP(x) (((x) & 0xff) << 24)
|
||||
@ -0,0 +1,49 @@
|
||||
From 019a17a5e76940ea86114838d1d638d4dc8d3750 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Sat, 13 Apr 2024 16:01:40 +0300
|
||||
Subject: [PATCH 3/5] net: dsa: mt7530: fix port mirroring for MT7988 SoC
|
||||
switch
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The "MT7988A Wi-Fi 7 Generation Router Platform: Datasheet (Open Version)
|
||||
v0.1" document shows bits 16 to 18 as the MIRROR_PORT field of the CPU
|
||||
forward control register. Currently, the MT7530 DSA subdriver configures
|
||||
bits 0 to 2 of the CPU forward control register which breaks the port
|
||||
mirroring feature for the MT7988 SoC switch.
|
||||
|
||||
Fix this by using the MT7531_MIRROR_PORT_GET() and MT7531_MIRROR_PORT_SET()
|
||||
macros which utilise the correct bits.
|
||||
|
||||
Fixes: 110c18bfed41 ("net: dsa: mt7530: introduce driver for MT7988 built-in switch")
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Acked-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 10 ++++++----
|
||||
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1883,14 +1883,16 @@ mt7530_port_vlan_del(struct dsa_switch *
|
||||
|
||||
static int mt753x_mirror_port_get(unsigned int id, u32 val)
|
||||
{
|
||||
- return (id == ID_MT7531) ? MT7531_MIRROR_PORT_GET(val) :
|
||||
- MIRROR_PORT(val);
|
||||
+ return (id == ID_MT7531 || id == ID_MT7988) ?
|
||||
+ MT7531_MIRROR_PORT_GET(val) :
|
||||
+ MIRROR_PORT(val);
|
||||
}
|
||||
|
||||
static int mt753x_mirror_port_set(unsigned int id, u32 val)
|
||||
{
|
||||
- return (id == ID_MT7531) ? MT7531_MIRROR_PORT_SET(val) :
|
||||
- MIRROR_PORT(val);
|
||||
+ return (id == ID_MT7531 || id == ID_MT7988) ?
|
||||
+ MT7531_MIRROR_PORT_SET(val) :
|
||||
+ MIRROR_PORT(val);
|
||||
}
|
||||
|
||||
static int mt753x_port_mirror_add(struct dsa_switch *ds, int port,
|
||||
@ -0,0 +1,238 @@
|
||||
From 5053a6cf1d50d785078562470d2a63695a9f3bf2 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Thu, 18 Apr 2024 08:35:30 +0300
|
||||
Subject: [PATCH 4/5] net: dsa: mt7530-mdio: read PHY address of switch from
|
||||
device tree
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Read the PHY address the switch listens on from the reg property of the
|
||||
switch node on the device tree. This change brings support for MT7530
|
||||
switches on boards with such bootstrapping configuration where the switch
|
||||
listens on a different PHY address than the hardcoded PHY address on the
|
||||
driver, 31.
|
||||
|
||||
As described on the "MT7621 Programming Guide v0.4" document, the MT7530
|
||||
switch and its PHYs can be configured to listen on the range of 7-12,
|
||||
15-20, 23-28, and 31 and 0-4 PHY addresses.
|
||||
|
||||
There are operations where the switch PHY registers are used. For the PHY
|
||||
address of the control PHY, transform the MT753X_CTRL_PHY_ADDR constant
|
||||
into a macro and use it. The PHY address for the control PHY is 0 when the
|
||||
switch listens on 31. In any other case, it is one greater than the PHY
|
||||
address the switch listens on.
|
||||
|
||||
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Tested-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530-mdio.c | 28 +++++++++++++-------------
|
||||
drivers/net/dsa/mt7530.c | 37 +++++++++++++++++++++++------------
|
||||
drivers/net/dsa/mt7530.h | 4 +++-
|
||||
3 files changed, 41 insertions(+), 28 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530-mdio.c
|
||||
+++ b/drivers/net/dsa/mt7530-mdio.c
|
||||
@@ -18,7 +18,8 @@
|
||||
static int
|
||||
mt7530_regmap_write(void *context, unsigned int reg, unsigned int val)
|
||||
{
|
||||
- struct mii_bus *bus = context;
|
||||
+ struct mt7530_priv *priv = context;
|
||||
+ struct mii_bus *bus = priv->bus;
|
||||
u16 page, r, lo, hi;
|
||||
int ret;
|
||||
|
||||
@@ -27,36 +28,35 @@ mt7530_regmap_write(void *context, unsig
|
||||
lo = val & 0xffff;
|
||||
hi = val >> 16;
|
||||
|
||||
- /* MT7530 uses 31 as the pseudo port */
|
||||
- ret = bus->write(bus, 0x1f, 0x1f, page);
|
||||
+ ret = bus->write(bus, priv->mdiodev->addr, 0x1f, page);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
- ret = bus->write(bus, 0x1f, r, lo);
|
||||
+ ret = bus->write(bus, priv->mdiodev->addr, r, lo);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
- ret = bus->write(bus, 0x1f, 0x10, hi);
|
||||
+ ret = bus->write(bus, priv->mdiodev->addr, 0x10, hi);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
mt7530_regmap_read(void *context, unsigned int reg, unsigned int *val)
|
||||
{
|
||||
- struct mii_bus *bus = context;
|
||||
+ struct mt7530_priv *priv = context;
|
||||
+ struct mii_bus *bus = priv->bus;
|
||||
u16 page, r, lo, hi;
|
||||
int ret;
|
||||
|
||||
page = (reg >> 6) & 0x3ff;
|
||||
r = (reg >> 2) & 0xf;
|
||||
|
||||
- /* MT7530 uses 31 as the pseudo port */
|
||||
- ret = bus->write(bus, 0x1f, 0x1f, page);
|
||||
+ ret = bus->write(bus, priv->mdiodev->addr, 0x1f, page);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
- lo = bus->read(bus, 0x1f, r);
|
||||
- hi = bus->read(bus, 0x1f, 0x10);
|
||||
+ lo = bus->read(bus, priv->mdiodev->addr, r);
|
||||
+ hi = bus->read(bus, priv->mdiodev->addr, 0x10);
|
||||
|
||||
*val = (hi << 16) | (lo & 0xffff);
|
||||
|
||||
@@ -107,8 +107,7 @@ mt7531_create_sgmii(struct mt7530_priv *
|
||||
mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock;
|
||||
mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
|
||||
|
||||
- regmap = devm_regmap_init(priv->dev,
|
||||
- &mt7530_regmap_bus, priv->bus,
|
||||
+ regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus, priv,
|
||||
mt7531_pcs_config[i]);
|
||||
if (IS_ERR(regmap)) {
|
||||
ret = PTR_ERR(regmap);
|
||||
@@ -153,6 +152,7 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
|
||||
priv->bus = mdiodev->bus;
|
||||
priv->dev = &mdiodev->dev;
|
||||
+ priv->mdiodev = mdiodev;
|
||||
|
||||
ret = mt7530_probe_common(priv);
|
||||
if (ret)
|
||||
@@ -203,8 +203,8 @@ mt7530_probe(struct mdio_device *mdiodev
|
||||
regmap_config->reg_stride = 4;
|
||||
regmap_config->max_register = MT7530_CREV;
|
||||
regmap_config->disable_locking = true;
|
||||
- priv->regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus,
|
||||
- priv->bus, regmap_config);
|
||||
+ priv->regmap = devm_regmap_init(priv->dev, &mt7530_regmap_bus, priv,
|
||||
+ regmap_config);
|
||||
if (IS_ERR(priv->regmap))
|
||||
return PTR_ERR(priv->regmap);
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -86,22 +86,26 @@ core_read_mmd_indirect(struct mt7530_pri
|
||||
int value, ret;
|
||||
|
||||
/* Write the desired MMD Devad */
|
||||
- ret = bus->write(bus, 0, MII_MMD_CTRL, devad);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_CTRL, devad);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the desired MMD register address */
|
||||
- ret = bus->write(bus, 0, MII_MMD_DATA, prtad);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA, prtad);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Select the Function : DATA with no post increment */
|
||||
- ret = bus->write(bus, 0, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Read the content of the MMD's selected register */
|
||||
- value = bus->read(bus, 0, MII_MMD_DATA);
|
||||
+ value = bus->read(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA);
|
||||
|
||||
return value;
|
||||
err:
|
||||
@@ -118,22 +122,26 @@ core_write_mmd_indirect(struct mt7530_pr
|
||||
int ret;
|
||||
|
||||
/* Write the desired MMD Devad */
|
||||
- ret = bus->write(bus, 0, MII_MMD_CTRL, devad);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_CTRL, devad);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the desired MMD register address */
|
||||
- ret = bus->write(bus, 0, MII_MMD_DATA, prtad);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA, prtad);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Select the Function : DATA with no post increment */
|
||||
- ret = bus->write(bus, 0, MII_MMD_CTRL, (devad | MII_MMD_CTRL_NOINCR));
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the data into MMD's selected register */
|
||||
- ret = bus->write(bus, 0, MII_MMD_DATA, data);
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA, data);
|
||||
err:
|
||||
if (ret < 0)
|
||||
dev_err(&bus->dev,
|
||||
@@ -2679,16 +2687,19 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
* phy_[read,write]_mmd_indirect is called, we provide our own
|
||||
* mt7531_ind_mmd_phy_[read,write] to complete this function.
|
||||
*/
|
||||
- val = mt7531_ind_c45_phy_read(priv, MT753X_CTRL_PHY_ADDR,
|
||||
+ val = mt7531_ind_c45_phy_read(priv,
|
||||
+ MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
MDIO_MMD_VEND2, CORE_PLL_GROUP4);
|
||||
val |= MT7531_RG_SYSPLL_DMY2 | MT7531_PHY_PLL_BYPASS_MODE;
|
||||
val &= ~MT7531_PHY_PLL_OFF;
|
||||
- mt7531_ind_c45_phy_write(priv, MT753X_CTRL_PHY_ADDR, MDIO_MMD_VEND2,
|
||||
- CORE_PLL_GROUP4, val);
|
||||
+ mt7531_ind_c45_phy_write(priv,
|
||||
+ MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MDIO_MMD_VEND2, CORE_PLL_GROUP4, val);
|
||||
|
||||
/* Disable EEE advertisement on the switch PHYs. */
|
||||
- for (i = MT753X_CTRL_PHY_ADDR;
|
||||
- i < MT753X_CTRL_PHY_ADDR + MT7530_NUM_PHYS; i++) {
|
||||
+ for (i = MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr);
|
||||
+ i < MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr) + MT7530_NUM_PHYS;
|
||||
+ i++) {
|
||||
mt7531_ind_c45_phy_write(priv, i, MDIO_MMD_AN, MDIO_AN_EEE_ADV,
|
||||
0);
|
||||
}
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -629,7 +629,7 @@ enum mt7531_clk_skew {
|
||||
#define MT7531_PHY_PLL_OFF BIT(5)
|
||||
#define MT7531_PHY_PLL_BYPASS_MODE BIT(4)
|
||||
|
||||
-#define MT753X_CTRL_PHY_ADDR 0
|
||||
+#define MT753X_CTRL_PHY_ADDR(addr) ((addr + 1) & 0x1f)
|
||||
|
||||
#define CORE_PLL_GROUP5 0x404
|
||||
#define RG_LCDDS_PCW_NCPO1(x) ((x) & 0xffff)
|
||||
@@ -778,6 +778,7 @@ struct mt753x_info {
|
||||
* @irq_enable: IRQ enable bits, synced to SYS_INT_EN
|
||||
* @create_sgmii: Pointer to function creating SGMII PCS instance(s)
|
||||
* @active_cpu_ports: Holding the active CPU ports
|
||||
+ * @mdiodev: The pointer to the MDIO device structure
|
||||
*/
|
||||
struct mt7530_priv {
|
||||
struct device *dev;
|
||||
@@ -804,6 +805,7 @@ struct mt7530_priv {
|
||||
u32 irq_enable;
|
||||
int (*create_sgmii)(struct mt7530_priv *priv);
|
||||
u8 active_cpu_ports;
|
||||
+ struct mdio_device *mdiodev;
|
||||
};
|
||||
|
||||
struct mt7530_hw_vlan_entry {
|
||||
@ -0,0 +1,186 @@
|
||||
From 9764a08b3d260f4e7799d34bbfe64463db940d74 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Thu, 18 Apr 2024 08:35:31 +0300
|
||||
Subject: [PATCH 5/5] net: dsa: mt7530: simplify core operations
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The core_rmw() function calls core_read_mmd_indirect() to read the
|
||||
requested register, and then calls core_write_mmd_indirect() to write the
|
||||
requested value to the register. Because Clause 22 is used to access Clause
|
||||
45 registers, some operations on core_write_mmd_indirect() are
|
||||
unnecessarily run. Get rid of core_read_mmd_indirect() and
|
||||
core_write_mmd_indirect(), and run only the necessary operations on
|
||||
core_write() and core_rmw().
|
||||
|
||||
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Tested-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 108 ++++++++++++++++-----------------------
|
||||
1 file changed, 43 insertions(+), 65 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -74,116 +74,94 @@ static const struct mt7530_mib_desc mt75
|
||||
MIB_DESC(1, 0xb8, "RxArlDrop"),
|
||||
};
|
||||
|
||||
-/* Since phy_device has not yet been created and
|
||||
- * phy_{read,write}_mmd_indirect is not available, we provide our own
|
||||
- * core_{read,write}_mmd_indirect with core_{clear,write,set} wrappers
|
||||
- * to complete this function.
|
||||
- */
|
||||
-static int
|
||||
-core_read_mmd_indirect(struct mt7530_priv *priv, int prtad, int devad)
|
||||
+static void
|
||||
+mt7530_mutex_lock(struct mt7530_priv *priv)
|
||||
+{
|
||||
+ if (priv->bus)
|
||||
+ mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+mt7530_mutex_unlock(struct mt7530_priv *priv)
|
||||
+{
|
||||
+ if (priv->bus)
|
||||
+ mutex_unlock(&priv->bus->mdio_lock);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+core_write(struct mt7530_priv *priv, u32 reg, u32 val)
|
||||
{
|
||||
struct mii_bus *bus = priv->bus;
|
||||
- int value, ret;
|
||||
+ int ret;
|
||||
+
|
||||
+ mt7530_mutex_lock(priv);
|
||||
|
||||
/* Write the desired MMD Devad */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_CTRL, devad);
|
||||
+ MII_MMD_CTRL, MDIO_MMD_VEND2);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the desired MMD register address */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_DATA, prtad);
|
||||
+ MII_MMD_DATA, reg);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Select the Function : DATA with no post increment */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
|
||||
+ MII_MMD_CTRL, MDIO_MMD_VEND2 | MII_MMD_CTRL_NOINCR);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
- /* Read the content of the MMD's selected register */
|
||||
- value = bus->read(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_DATA);
|
||||
-
|
||||
- return value;
|
||||
+ /* Write the data into MMD's selected register */
|
||||
+ ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA, val);
|
||||
err:
|
||||
- dev_err(&bus->dev, "failed to read mmd register\n");
|
||||
+ if (ret < 0)
|
||||
+ dev_err(&bus->dev, "failed to write mmd register\n");
|
||||
|
||||
- return ret;
|
||||
+ mt7530_mutex_unlock(priv);
|
||||
}
|
||||
|
||||
-static int
|
||||
-core_write_mmd_indirect(struct mt7530_priv *priv, int prtad,
|
||||
- int devad, u32 data)
|
||||
+static void
|
||||
+core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
|
||||
{
|
||||
struct mii_bus *bus = priv->bus;
|
||||
+ u32 val;
|
||||
int ret;
|
||||
|
||||
+ mt7530_mutex_lock(priv);
|
||||
+
|
||||
/* Write the desired MMD Devad */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_CTRL, devad);
|
||||
+ MII_MMD_CTRL, MDIO_MMD_VEND2);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Write the desired MMD register address */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_DATA, prtad);
|
||||
+ MII_MMD_DATA, reg);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
/* Select the Function : DATA with no post increment */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
|
||||
+ MII_MMD_CTRL, MDIO_MMD_VEND2 | MII_MMD_CTRL_NOINCR);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
+ /* Read the content of the MMD's selected register */
|
||||
+ val = bus->read(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
+ MII_MMD_DATA);
|
||||
+ val &= ~mask;
|
||||
+ val |= set;
|
||||
/* Write the data into MMD's selected register */
|
||||
ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
|
||||
- MII_MMD_DATA, data);
|
||||
+ MII_MMD_DATA, val);
|
||||
err:
|
||||
if (ret < 0)
|
||||
- dev_err(&bus->dev,
|
||||
- "failed to write mmd register\n");
|
||||
- return ret;
|
||||
-}
|
||||
-
|
||||
-static void
|
||||
-mt7530_mutex_lock(struct mt7530_priv *priv)
|
||||
-{
|
||||
- if (priv->bus)
|
||||
- mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
|
||||
-}
|
||||
-
|
||||
-static void
|
||||
-mt7530_mutex_unlock(struct mt7530_priv *priv)
|
||||
-{
|
||||
- if (priv->bus)
|
||||
- mutex_unlock(&priv->bus->mdio_lock);
|
||||
-}
|
||||
-
|
||||
-static void
|
||||
-core_write(struct mt7530_priv *priv, u32 reg, u32 val)
|
||||
-{
|
||||
- mt7530_mutex_lock(priv);
|
||||
-
|
||||
- core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
|
||||
-
|
||||
- mt7530_mutex_unlock(priv);
|
||||
-}
|
||||
-
|
||||
-static void
|
||||
-core_rmw(struct mt7530_priv *priv, u32 reg, u32 mask, u32 set)
|
||||
-{
|
||||
- u32 val;
|
||||
-
|
||||
- mt7530_mutex_lock(priv);
|
||||
-
|
||||
- val = core_read_mmd_indirect(priv, reg, MDIO_MMD_VEND2);
|
||||
- val &= ~mask;
|
||||
- val |= set;
|
||||
- core_write_mmd_indirect(priv, reg, MDIO_MMD_VEND2, val);
|
||||
+ dev_err(&bus->dev, "failed to write mmd register\n");
|
||||
|
||||
mt7530_mutex_unlock(priv);
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
From 856e8954a0a88d1a4d2b43e9002b9249131a156f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Mon, 22 Apr 2024 10:15:08 +0300
|
||||
Subject: [PATCH 01/15] net: dsa: mt7530: disable EEE abilities on failure on
|
||||
MT7531 and MT7988
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The MT7531_FORCE_EEE1G and MT7531_FORCE_EEE100 bits let the
|
||||
PMCR_FORCE_EEE1G and PMCR_FORCE_EEE100 bits determine the 1G/100 EEE
|
||||
abilities of the MAC. If MT7531_FORCE_EEE1G and MT7531_FORCE_EEE100 are
|
||||
unset, the abilities are left to be determined by PHY auto polling.
|
||||
|
||||
The commit 40b5d2f15c09 ("net: dsa: mt7530: Add support for EEE features")
|
||||
made it so that the PMCR_FORCE_EEE1G and PMCR_FORCE_EEE100 bits are set on
|
||||
mt753x_phylink_mac_link_up(). But it did not set the MT7531_FORCE_EEE1G and
|
||||
MT7531_FORCE_EEE100 bits. Because of this, the EEE abilities will be
|
||||
determined by PHY auto polling, regardless of the result of phy_init_eee().
|
||||
|
||||
Define these bits and add them to the MT7531_FORCE_MODE mask which is set
|
||||
in mt7531_setup_common(). With this, there won't be any EEE abilities set
|
||||
when phy_init_eee() returns a negative value.
|
||||
|
||||
Thanks to Russell for explaining when phy_init_eee() could return a
|
||||
negative value below.
|
||||
|
||||
Looking at phy_init_eee(), it could return a negative value when:
|
||||
|
||||
1. phydev->drv is NULL
|
||||
2. if genphy_c45_eee_is_active() returns negative
|
||||
3. if genphy_c45_eee_is_active() returns zero, it returns -EPROTONOSUPPORT
|
||||
4. if phy_set_bits_mmd() fails (e.g. communication error with the PHY)
|
||||
|
||||
If we then look at genphy_c45_eee_is_active(), then:
|
||||
|
||||
genphy_c45_read_eee_adv() and genphy_c45_read_eee_lpa() propagate their
|
||||
non-zero return values, otherwise this function returns zero or positive
|
||||
integer.
|
||||
|
||||
If we then look at genphy_c45_read_eee_adv(), then a failure of
|
||||
phy_read_mmd() would cause a negative value to be returned.
|
||||
|
||||
Looking at genphy_c45_read_eee_lpa(), the same is true.
|
||||
|
||||
So, it can be summarised as:
|
||||
|
||||
- phydev->drv is NULL
|
||||
- there is a communication error accessing the PHY
|
||||
- EEE is not active
|
||||
|
||||
otherwise, it returns zero on success.
|
||||
|
||||
If one wishes to determine whether an error occurred vs EEE not being
|
||||
supported through negotiation for the negotiated speed, if it returns
|
||||
-EPROTONOSUPPORT in the latter case. Other error codes mean either the
|
||||
driver has been unloaded or communication error.
|
||||
|
||||
In conclusion, determining the EEE abilities by PHY auto polling shouldn't
|
||||
result in having any EEE abilities enabled, when one of the last two
|
||||
situations in the summary happens. And it seems that if phydev->drv is
|
||||
NULL, there would be bigger problems with the device than a broken link. So
|
||||
this is not a bugfix.
|
||||
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.h | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -328,11 +328,15 @@ enum mt7530_vlan_port_acc_frm {
|
||||
#define MT7531_FORCE_DPX BIT(29)
|
||||
#define MT7531_FORCE_RX_FC BIT(28)
|
||||
#define MT7531_FORCE_TX_FC BIT(27)
|
||||
+#define MT7531_FORCE_EEE100 BIT(26)
|
||||
+#define MT7531_FORCE_EEE1G BIT(25)
|
||||
#define MT7531_FORCE_MODE (MT7531_FORCE_LNK | \
|
||||
MT7531_FORCE_SPD | \
|
||||
MT7531_FORCE_DPX | \
|
||||
MT7531_FORCE_RX_FC | \
|
||||
- MT7531_FORCE_TX_FC)
|
||||
+ MT7531_FORCE_TX_FC | \
|
||||
+ MT7531_FORCE_EEE100 | \
|
||||
+ MT7531_FORCE_EEE1G)
|
||||
#define PMCR_LINK_SETTINGS_MASK (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \
|
||||
PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \
|
||||
PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
|
||||
@ -0,0 +1,200 @@
|
||||
From 712ad00d2f43814c81a7abfcbc339690a05fb6a0 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Mon, 22 Apr 2024 10:15:09 +0300
|
||||
Subject: [PATCH 02/15] net: dsa: mt7530: refactor MT7530_PMCR_P()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The MT7530_PMCR_P() registers are on MT7530, MT7531, and the switch on the
|
||||
MT7988 SoC. Rename the definition for them to MT753X_PMCR_P(). Bit 15 is
|
||||
for MT7530 only. Add MT7530 prefix to the definition for bit 15.
|
||||
|
||||
Use GENMASK and FIELD_PREP for PMCR_IFG_XMIT().
|
||||
|
||||
Rename PMCR_TX_EN and PMCR_RX_EN to PMCR_MAC_TX_EN and PMCR_MAC_TX_EN to
|
||||
follow the naming on the "MT7621 Giga Switch Programming Guide v0.3",
|
||||
"MT7531 Reference Manual for Development Board v1.0", and "MT7988A Wi-Fi 7
|
||||
Generation Router Platform: Datasheet (Open Version) v0.1" documents.
|
||||
|
||||
These documents show that PMCR_RX_FC_EN is at bit 5. Correct this along
|
||||
with renaming it to PMCR_FORCE_RX_FC_EN, and the same for PMCR_TX_FC_EN.
|
||||
|
||||
Remove PMCR_SPEED_MASK which doesn't have a use.
|
||||
|
||||
Rename the force mode definitions for MT7531 to FORCE_MODE. Add MASK at the
|
||||
end for the mask that includes all force mode definitions.
|
||||
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 24 ++++++++---------
|
||||
drivers/net/dsa/mt7530.h | 58 +++++++++++++++++++++-------------------
|
||||
2 files changed, 42 insertions(+), 40 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -889,7 +889,7 @@ static void mt7530_setup_port5(struct ds
|
||||
val &= ~MHWTRAP_P5_MAC_SEL & ~MHWTRAP_P5_DIS;
|
||||
|
||||
/* Setup the MAC by default for the cpu port */
|
||||
- mt7530_write(priv, MT7530_PMCR_P(5), 0x56300);
|
||||
+ mt7530_write(priv, MT753X_PMCR_P(5), 0x56300);
|
||||
break;
|
||||
case P5_INTF_SEL_GMAC5:
|
||||
/* MT7530_P5_MODE_GMAC: P5 -> External phy or 2nd GMAC */
|
||||
@@ -2435,8 +2435,8 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
/* Clear link settings and enable force mode to force link down
|
||||
* on all ports until they're enabled later.
|
||||
*/
|
||||
- mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
|
||||
- PMCR_FORCE_MODE, PMCR_FORCE_MODE);
|
||||
+ mt7530_rmw(priv, MT753X_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
|
||||
+ MT7530_FORCE_MODE, MT7530_FORCE_MODE);
|
||||
|
||||
/* Disable forwarding by default on all ports */
|
||||
mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
|
||||
@@ -2546,8 +2546,8 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
/* Clear link settings and enable force mode to force link down
|
||||
* on all ports until they're enabled later.
|
||||
*/
|
||||
- mt7530_rmw(priv, MT7530_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
|
||||
- MT7531_FORCE_MODE, MT7531_FORCE_MODE);
|
||||
+ mt7530_rmw(priv, MT753X_PMCR_P(i), PMCR_LINK_SETTINGS_MASK |
|
||||
+ MT7531_FORCE_MODE_MASK, MT7531_FORCE_MODE_MASK);
|
||||
|
||||
/* Disable forwarding by default on all ports */
|
||||
mt7530_rmw(priv, MT7530_PCR_P(i), PCR_MATRIX_MASK,
|
||||
@@ -2630,7 +2630,7 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
|
||||
/* Force link down on all ports before internal reset */
|
||||
for (i = 0; i < MT7530_NUM_PORTS; i++)
|
||||
- mt7530_write(priv, MT7530_PMCR_P(i), MT7531_FORCE_LNK);
|
||||
+ mt7530_write(priv, MT753X_PMCR_P(i), MT7531_FORCE_MODE_LNK);
|
||||
|
||||
/* Reset the switch through internal reset */
|
||||
mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_SW_RST | SYS_CTRL_REG_RST);
|
||||
@@ -2872,7 +2872,7 @@ mt753x_phylink_mac_config(struct phylink
|
||||
|
||||
/* Are we connected to external phy */
|
||||
if (port == 5 && dsa_is_user_port(ds, 5))
|
||||
- mt7530_set(priv, MT7530_PMCR_P(port), PMCR_EXT_PHY);
|
||||
+ mt7530_set(priv, MT753X_PMCR_P(port), PMCR_EXT_PHY);
|
||||
}
|
||||
|
||||
static void mt753x_phylink_mac_link_down(struct phylink_config *config,
|
||||
@@ -2882,7 +2882,7 @@ static void mt753x_phylink_mac_link_down
|
||||
struct dsa_port *dp = dsa_phylink_to_port(config);
|
||||
struct mt7530_priv *priv = dp->ds->priv;
|
||||
|
||||
- mt7530_clear(priv, MT7530_PMCR_P(dp->index), PMCR_LINK_SETTINGS_MASK);
|
||||
+ mt7530_clear(priv, MT753X_PMCR_P(dp->index), PMCR_LINK_SETTINGS_MASK);
|
||||
}
|
||||
|
||||
static void mt753x_phylink_mac_link_up(struct phylink_config *config,
|
||||
@@ -2896,7 +2896,7 @@ static void mt753x_phylink_mac_link_up(s
|
||||
struct mt7530_priv *priv = dp->ds->priv;
|
||||
u32 mcr;
|
||||
|
||||
- mcr = PMCR_RX_EN | PMCR_TX_EN | PMCR_FORCE_LNK;
|
||||
+ mcr = PMCR_MAC_RX_EN | PMCR_MAC_TX_EN | PMCR_FORCE_LNK;
|
||||
|
||||
switch (speed) {
|
||||
case SPEED_1000:
|
||||
@@ -2911,9 +2911,9 @@ static void mt753x_phylink_mac_link_up(s
|
||||
if (duplex == DUPLEX_FULL) {
|
||||
mcr |= PMCR_FORCE_FDX;
|
||||
if (tx_pause)
|
||||
- mcr |= PMCR_TX_FC_EN;
|
||||
+ mcr |= PMCR_FORCE_TX_FC_EN;
|
||||
if (rx_pause)
|
||||
- mcr |= PMCR_RX_FC_EN;
|
||||
+ mcr |= PMCR_FORCE_RX_FC_EN;
|
||||
}
|
||||
|
||||
if (mode == MLO_AN_PHY && phydev && phy_init_eee(phydev, false) >= 0) {
|
||||
@@ -2928,7 +2928,7 @@ static void mt753x_phylink_mac_link_up(s
|
||||
}
|
||||
}
|
||||
|
||||
- mt7530_set(priv, MT7530_PMCR_P(dp->index), mcr);
|
||||
+ mt7530_set(priv, MT753X_PMCR_P(dp->index), mcr);
|
||||
}
|
||||
|
||||
static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -304,44 +304,46 @@ enum mt7530_vlan_port_acc_frm {
|
||||
#define G0_PORT_VID_DEF G0_PORT_VID(0)
|
||||
|
||||
/* Register for port MAC control register */
|
||||
-#define MT7530_PMCR_P(x) (0x3000 + ((x) * 0x100))
|
||||
-#define PMCR_IFG_XMIT(x) (((x) & 0x3) << 18)
|
||||
+#define MT753X_PMCR_P(x) (0x3000 + ((x) * 0x100))
|
||||
+#define PMCR_IFG_XMIT_MASK GENMASK(19, 18)
|
||||
+#define PMCR_IFG_XMIT(x) FIELD_PREP(PMCR_IFG_XMIT_MASK, x)
|
||||
#define PMCR_EXT_PHY BIT(17)
|
||||
#define PMCR_MAC_MODE BIT(16)
|
||||
-#define PMCR_FORCE_MODE BIT(15)
|
||||
-#define PMCR_TX_EN BIT(14)
|
||||
-#define PMCR_RX_EN BIT(13)
|
||||
+#define MT7530_FORCE_MODE BIT(15)
|
||||
+#define PMCR_MAC_TX_EN BIT(14)
|
||||
+#define PMCR_MAC_RX_EN BIT(13)
|
||||
#define PMCR_BACKOFF_EN BIT(9)
|
||||
#define PMCR_BACKPR_EN BIT(8)
|
||||
#define PMCR_FORCE_EEE1G BIT(7)
|
||||
#define PMCR_FORCE_EEE100 BIT(6)
|
||||
-#define PMCR_TX_FC_EN BIT(5)
|
||||
-#define PMCR_RX_FC_EN BIT(4)
|
||||
+#define PMCR_FORCE_RX_FC_EN BIT(5)
|
||||
+#define PMCR_FORCE_TX_FC_EN BIT(4)
|
||||
#define PMCR_FORCE_SPEED_1000 BIT(3)
|
||||
#define PMCR_FORCE_SPEED_100 BIT(2)
|
||||
#define PMCR_FORCE_FDX BIT(1)
|
||||
#define PMCR_FORCE_LNK BIT(0)
|
||||
-#define PMCR_SPEED_MASK (PMCR_FORCE_SPEED_100 | \
|
||||
- PMCR_FORCE_SPEED_1000)
|
||||
-#define MT7531_FORCE_LNK BIT(31)
|
||||
-#define MT7531_FORCE_SPD BIT(30)
|
||||
-#define MT7531_FORCE_DPX BIT(29)
|
||||
-#define MT7531_FORCE_RX_FC BIT(28)
|
||||
-#define MT7531_FORCE_TX_FC BIT(27)
|
||||
-#define MT7531_FORCE_EEE100 BIT(26)
|
||||
-#define MT7531_FORCE_EEE1G BIT(25)
|
||||
-#define MT7531_FORCE_MODE (MT7531_FORCE_LNK | \
|
||||
- MT7531_FORCE_SPD | \
|
||||
- MT7531_FORCE_DPX | \
|
||||
- MT7531_FORCE_RX_FC | \
|
||||
- MT7531_FORCE_TX_FC | \
|
||||
- MT7531_FORCE_EEE100 | \
|
||||
- MT7531_FORCE_EEE1G)
|
||||
-#define PMCR_LINK_SETTINGS_MASK (PMCR_TX_EN | PMCR_FORCE_SPEED_1000 | \
|
||||
- PMCR_RX_EN | PMCR_FORCE_SPEED_100 | \
|
||||
- PMCR_TX_FC_EN | PMCR_RX_FC_EN | \
|
||||
- PMCR_FORCE_FDX | PMCR_FORCE_LNK | \
|
||||
- PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100)
|
||||
+#define MT7531_FORCE_MODE_LNK BIT(31)
|
||||
+#define MT7531_FORCE_MODE_SPD BIT(30)
|
||||
+#define MT7531_FORCE_MODE_DPX BIT(29)
|
||||
+#define MT7531_FORCE_MODE_RX_FC BIT(28)
|
||||
+#define MT7531_FORCE_MODE_TX_FC BIT(27)
|
||||
+#define MT7531_FORCE_MODE_EEE100 BIT(26)
|
||||
+#define MT7531_FORCE_MODE_EEE1G BIT(25)
|
||||
+#define MT7531_FORCE_MODE_MASK (MT7531_FORCE_MODE_LNK | \
|
||||
+ MT7531_FORCE_MODE_SPD | \
|
||||
+ MT7531_FORCE_MODE_DPX | \
|
||||
+ MT7531_FORCE_MODE_RX_FC | \
|
||||
+ MT7531_FORCE_MODE_TX_FC | \
|
||||
+ MT7531_FORCE_MODE_EEE100 | \
|
||||
+ MT7531_FORCE_MODE_EEE1G)
|
||||
+#define PMCR_LINK_SETTINGS_MASK (PMCR_MAC_TX_EN | PMCR_MAC_RX_EN | \
|
||||
+ PMCR_FORCE_EEE1G | \
|
||||
+ PMCR_FORCE_EEE100 | \
|
||||
+ PMCR_FORCE_RX_FC_EN | \
|
||||
+ PMCR_FORCE_TX_FC_EN | \
|
||||
+ PMCR_FORCE_SPEED_1000 | \
|
||||
+ PMCR_FORCE_SPEED_100 | \
|
||||
+ PMCR_FORCE_FDX | PMCR_FORCE_LNK)
|
||||
|
||||
#define MT7530_PMEEECR_P(x) (0x3004 + (x) * 0x100)
|
||||
#define WAKEUP_TIME_1000(x) (((x) & 0xFF) << 24)
|
||||
@ -0,0 +1,185 @@
|
||||
From 875ec5b67ab88e969b171e6e9ea803e3ed759614 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Mon, 22 Apr 2024 10:15:10 +0300
|
||||
Subject: [PATCH 03/15] net: dsa: mt7530: rename p5_intf_sel and use only for
|
||||
MT7530 switch
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The p5_intf_sel pointer is used to store the information of whether PHY
|
||||
muxing is used or not. PHY muxing is a feature specific to port 5 of the
|
||||
MT7530 switch. Do not use it for other switch models.
|
||||
|
||||
Rename the pointer to p5_mode to store the mode the port is being used in.
|
||||
Rename the p5_interface_select enum to mt7530_p5_mode, the string
|
||||
representation to mt7530_p5_mode_str, and the enum elements.
|
||||
|
||||
If PHY muxing is not detected, the default mode, GMAC5, will be used.
|
||||
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 62 +++++++++++++++++-----------------------
|
||||
drivers/net/dsa/mt7530.h | 15 +++++-----
|
||||
2 files changed, 33 insertions(+), 44 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -850,19 +850,15 @@ mt7530_set_ageing_time(struct dsa_switch
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static const char *p5_intf_modes(unsigned int p5_interface)
|
||||
+static const char *mt7530_p5_mode_str(unsigned int mode)
|
||||
{
|
||||
- switch (p5_interface) {
|
||||
- case P5_DISABLED:
|
||||
- return "DISABLED";
|
||||
- case P5_INTF_SEL_PHY_P0:
|
||||
- return "PHY P0";
|
||||
- case P5_INTF_SEL_PHY_P4:
|
||||
- return "PHY P4";
|
||||
- case P5_INTF_SEL_GMAC5:
|
||||
- return "GMAC5";
|
||||
+ switch (mode) {
|
||||
+ case MUX_PHY_P0:
|
||||
+ return "MUX PHY P0";
|
||||
+ case MUX_PHY_P4:
|
||||
+ return "MUX PHY P4";
|
||||
default:
|
||||
- return "unknown";
|
||||
+ return "GMAC5";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -879,23 +875,23 @@ static void mt7530_setup_port5(struct ds
|
||||
val |= MHWTRAP_MANUAL | MHWTRAP_P5_MAC_SEL | MHWTRAP_P5_DIS;
|
||||
val &= ~MHWTRAP_P5_RGMII_MODE & ~MHWTRAP_PHY0_SEL;
|
||||
|
||||
- switch (priv->p5_intf_sel) {
|
||||
- case P5_INTF_SEL_PHY_P0:
|
||||
- /* MT7530_P5_MODE_GPHY_P0: 2nd GMAC -> P5 -> P0 */
|
||||
+ switch (priv->p5_mode) {
|
||||
+ /* MUX_PHY_P0: P0 -> P5 -> SoC MAC */
|
||||
+ case MUX_PHY_P0:
|
||||
val |= MHWTRAP_PHY0_SEL;
|
||||
fallthrough;
|
||||
- case P5_INTF_SEL_PHY_P4:
|
||||
- /* MT7530_P5_MODE_GPHY_P4: 2nd GMAC -> P5 -> P4 */
|
||||
+
|
||||
+ /* MUX_PHY_P4: P4 -> P5 -> SoC MAC */
|
||||
+ case MUX_PHY_P4:
|
||||
val &= ~MHWTRAP_P5_MAC_SEL & ~MHWTRAP_P5_DIS;
|
||||
|
||||
/* Setup the MAC by default for the cpu port */
|
||||
mt7530_write(priv, MT753X_PMCR_P(5), 0x56300);
|
||||
break;
|
||||
- case P5_INTF_SEL_GMAC5:
|
||||
- /* MT7530_P5_MODE_GMAC: P5 -> External phy or 2nd GMAC */
|
||||
- val &= ~MHWTRAP_P5_DIS;
|
||||
- break;
|
||||
+
|
||||
+ /* GMAC5: P5 -> SoC MAC or external PHY */
|
||||
default:
|
||||
+ val &= ~MHWTRAP_P5_DIS;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -923,8 +919,8 @@ static void mt7530_setup_port5(struct ds
|
||||
|
||||
mt7530_write(priv, MT7530_MHWTRAP, val);
|
||||
|
||||
- dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, intf_sel=%s, phy-mode=%s\n",
|
||||
- val, p5_intf_modes(priv->p5_intf_sel), phy_modes(interface));
|
||||
+ dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, mode=%s, phy-mode=%s\n", val,
|
||||
+ mt7530_p5_mode_str(priv->p5_mode), phy_modes(interface));
|
||||
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
}
|
||||
@@ -2467,13 +2463,11 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- /* Setup port 5 */
|
||||
- if (!dsa_is_unused_port(ds, 5)) {
|
||||
- priv->p5_intf_sel = P5_INTF_SEL_GMAC5;
|
||||
- } else {
|
||||
+ /* Check for PHY muxing on port 5 */
|
||||
+ if (dsa_is_unused_port(ds, 5)) {
|
||||
/* Scan the ethernet nodes. Look for GMAC1, lookup the used PHY.
|
||||
- * Set priv->p5_intf_sel to the appropriate value if PHY muxing
|
||||
- * is detected.
|
||||
+ * Set priv->p5_mode to the appropriate value if PHY muxing is
|
||||
+ * detected.
|
||||
*/
|
||||
for_each_child_of_node(dn, mac_np) {
|
||||
if (!of_device_is_compatible(mac_np,
|
||||
@@ -2497,17 +2491,16 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
}
|
||||
id = of_mdio_parse_addr(ds->dev, phy_node);
|
||||
if (id == 0)
|
||||
- priv->p5_intf_sel = P5_INTF_SEL_PHY_P0;
|
||||
+ priv->p5_mode = MUX_PHY_P0;
|
||||
if (id == 4)
|
||||
- priv->p5_intf_sel = P5_INTF_SEL_PHY_P4;
|
||||
+ priv->p5_mode = MUX_PHY_P4;
|
||||
}
|
||||
of_node_put(mac_np);
|
||||
of_node_put(phy_node);
|
||||
break;
|
||||
}
|
||||
|
||||
- if (priv->p5_intf_sel == P5_INTF_SEL_PHY_P0 ||
|
||||
- priv->p5_intf_sel == P5_INTF_SEL_PHY_P4)
|
||||
+ if (priv->p5_mode == MUX_PHY_P0 || priv->p5_mode == MUX_PHY_P4)
|
||||
mt7530_setup_port5(ds, interface);
|
||||
}
|
||||
|
||||
@@ -2645,9 +2638,6 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
MT7531_EXT_P_MDIO_12);
|
||||
}
|
||||
|
||||
- if (!dsa_is_unused_port(ds, 5))
|
||||
- priv->p5_intf_sel = P5_INTF_SEL_GMAC5;
|
||||
-
|
||||
mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK,
|
||||
MT7531_GPIO0_INTERRUPT);
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -708,12 +708,11 @@ struct mt7530_port {
|
||||
struct phylink_pcs *sgmii_pcs;
|
||||
};
|
||||
|
||||
-/* Port 5 interface select definitions */
|
||||
-enum p5_interface_select {
|
||||
- P5_DISABLED,
|
||||
- P5_INTF_SEL_PHY_P0,
|
||||
- P5_INTF_SEL_PHY_P4,
|
||||
- P5_INTF_SEL_GMAC5,
|
||||
+/* Port 5 mode definitions of the MT7530 switch */
|
||||
+enum mt7530_p5_mode {
|
||||
+ GMAC5,
|
||||
+ MUX_PHY_P0,
|
||||
+ MUX_PHY_P4,
|
||||
};
|
||||
|
||||
struct mt7530_priv;
|
||||
@@ -769,7 +768,7 @@ struct mt753x_info {
|
||||
* @ports: Holding the state among ports
|
||||
* @reg_mutex: The lock for protecting among process accessing
|
||||
* registers
|
||||
- * @p5_intf_sel: Holding the current port 5 interface select
|
||||
+ * @p5_mode: Holding the current mode of port 5 of the MT7530 switch
|
||||
* @p5_sgmii: Flag for distinguishing if port 5 of the MT7531 switch
|
||||
* has got SGMII
|
||||
* @irq: IRQ number of the switch
|
||||
@@ -791,7 +790,7 @@ struct mt7530_priv {
|
||||
const struct mt753x_info *info;
|
||||
unsigned int id;
|
||||
bool mcm;
|
||||
- enum p5_interface_select p5_intf_sel;
|
||||
+ enum mt7530_p5_mode p5_mode;
|
||||
bool p5_sgmii;
|
||||
u8 mirror_rx;
|
||||
u8 mirror_tx;
|
||||
@ -0,0 +1,169 @@
|
||||
From 83fe3df057e641cd0e88425e579d7a5a370ca430 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Mon, 22 Apr 2024 10:15:11 +0300
|
||||
Subject: [PATCH 04/15] net: dsa: mt7530: rename mt753x_bpdu_port_fw enum to
|
||||
mt753x_to_cpu_fw
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The mt753x_bpdu_port_fw enum is globally used for manipulating the process
|
||||
of deciding the forwardable ports, specifically concerning the CPU port(s).
|
||||
Therefore, rename it and the values in it to mt753x_to_cpu_fw.
|
||||
|
||||
Change FOLLOW_MFC to SYSTEM_DEFAULT to be on par with the switch documents.
|
||||
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 44 ++++++++++-------------
|
||||
drivers/net/dsa/mt7530.h | 76 ++++++++++++++++++++--------------------
|
||||
2 files changed, 56 insertions(+), 64 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1100,42 +1100,34 @@ mt753x_trap_frames(struct mt7530_priv *p
|
||||
* VLAN-untagged.
|
||||
*/
|
||||
mt7530_rmw(priv, MT753X_BPC,
|
||||
- MT753X_PAE_BPDU_FR | MT753X_PAE_EG_TAG_MASK |
|
||||
- MT753X_PAE_PORT_FW_MASK | MT753X_BPDU_EG_TAG_MASK |
|
||||
- MT753X_BPDU_PORT_FW_MASK,
|
||||
- MT753X_PAE_BPDU_FR |
|
||||
- MT753X_PAE_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
- MT753X_PAE_PORT_FW(MT753X_BPDU_CPU_ONLY) |
|
||||
- MT753X_BPDU_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
- MT753X_BPDU_CPU_ONLY);
|
||||
+ PAE_BPDU_FR | PAE_EG_TAG_MASK | PAE_PORT_FW_MASK |
|
||||
+ BPDU_EG_TAG_MASK | BPDU_PORT_FW_MASK,
|
||||
+ PAE_BPDU_FR | PAE_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
+ PAE_PORT_FW(TO_CPU_FW_CPU_ONLY) |
|
||||
+ BPDU_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
+ TO_CPU_FW_CPU_ONLY);
|
||||
|
||||
/* Trap frames with :01 and :02 MAC DAs to the CPU port(s) and egress
|
||||
* them VLAN-untagged.
|
||||
*/
|
||||
mt7530_rmw(priv, MT753X_RGAC1,
|
||||
- MT753X_R02_BPDU_FR | MT753X_R02_EG_TAG_MASK |
|
||||
- MT753X_R02_PORT_FW_MASK | MT753X_R01_BPDU_FR |
|
||||
- MT753X_R01_EG_TAG_MASK | MT753X_R01_PORT_FW_MASK,
|
||||
- MT753X_R02_BPDU_FR |
|
||||
- MT753X_R02_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
- MT753X_R02_PORT_FW(MT753X_BPDU_CPU_ONLY) |
|
||||
- MT753X_R01_BPDU_FR |
|
||||
- MT753X_R01_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
- MT753X_BPDU_CPU_ONLY);
|
||||
+ R02_BPDU_FR | R02_EG_TAG_MASK | R02_PORT_FW_MASK |
|
||||
+ R01_BPDU_FR | R01_EG_TAG_MASK | R01_PORT_FW_MASK,
|
||||
+ R02_BPDU_FR | R02_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
+ R02_PORT_FW(TO_CPU_FW_CPU_ONLY) | R01_BPDU_FR |
|
||||
+ R01_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
+ TO_CPU_FW_CPU_ONLY);
|
||||
|
||||
/* Trap frames with :03 and :0E MAC DAs to the CPU port(s) and egress
|
||||
* them VLAN-untagged.
|
||||
*/
|
||||
mt7530_rmw(priv, MT753X_RGAC2,
|
||||
- MT753X_R0E_BPDU_FR | MT753X_R0E_EG_TAG_MASK |
|
||||
- MT753X_R0E_PORT_FW_MASK | MT753X_R03_BPDU_FR |
|
||||
- MT753X_R03_EG_TAG_MASK | MT753X_R03_PORT_FW_MASK,
|
||||
- MT753X_R0E_BPDU_FR |
|
||||
- MT753X_R0E_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
- MT753X_R0E_PORT_FW(MT753X_BPDU_CPU_ONLY) |
|
||||
- MT753X_R03_BPDU_FR |
|
||||
- MT753X_R03_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
- MT753X_BPDU_CPU_ONLY);
|
||||
+ R0E_BPDU_FR | R0E_EG_TAG_MASK | R0E_PORT_FW_MASK |
|
||||
+ R03_BPDU_FR | R03_EG_TAG_MASK | R03_PORT_FW_MASK,
|
||||
+ R0E_BPDU_FR | R0E_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
+ R0E_PORT_FW(TO_CPU_FW_CPU_ONLY) | R03_BPDU_FR |
|
||||
+ R03_EG_TAG(MT7530_VLAN_EG_UNTAGGED) |
|
||||
+ TO_CPU_FW_CPU_ONLY);
|
||||
}
|
||||
|
||||
static void
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -67,47 +67,47 @@ enum mt753x_id {
|
||||
#define MT753X_MIRROR_MASK(id) ((((id) == ID_MT7531) || ((id) == ID_MT7988)) ? \
|
||||
MT7531_MIRROR_MASK : MIRROR_MASK)
|
||||
|
||||
-/* Registers for BPDU and PAE frame control*/
|
||||
+/* Register for BPDU and PAE frame control */
|
||||
#define MT753X_BPC 0x24
|
||||
-#define MT753X_PAE_BPDU_FR BIT(25)
|
||||
-#define MT753X_PAE_EG_TAG_MASK GENMASK(24, 22)
|
||||
-#define MT753X_PAE_EG_TAG(x) FIELD_PREP(MT753X_PAE_EG_TAG_MASK, x)
|
||||
-#define MT753X_PAE_PORT_FW_MASK GENMASK(18, 16)
|
||||
-#define MT753X_PAE_PORT_FW(x) FIELD_PREP(MT753X_PAE_PORT_FW_MASK, x)
|
||||
-#define MT753X_BPDU_EG_TAG_MASK GENMASK(8, 6)
|
||||
-#define MT753X_BPDU_EG_TAG(x) FIELD_PREP(MT753X_BPDU_EG_TAG_MASK, x)
|
||||
-#define MT753X_BPDU_PORT_FW_MASK GENMASK(2, 0)
|
||||
+#define PAE_BPDU_FR BIT(25)
|
||||
+#define PAE_EG_TAG_MASK GENMASK(24, 22)
|
||||
+#define PAE_EG_TAG(x) FIELD_PREP(PAE_EG_TAG_MASK, x)
|
||||
+#define PAE_PORT_FW_MASK GENMASK(18, 16)
|
||||
+#define PAE_PORT_FW(x) FIELD_PREP(PAE_PORT_FW_MASK, x)
|
||||
+#define BPDU_EG_TAG_MASK GENMASK(8, 6)
|
||||
+#define BPDU_EG_TAG(x) FIELD_PREP(BPDU_EG_TAG_MASK, x)
|
||||
+#define BPDU_PORT_FW_MASK GENMASK(2, 0)
|
||||
|
||||
-/* Register for :01 and :02 MAC DA frame control */
|
||||
+/* Register for 01-80-C2-00-00-[01,02] MAC DA frame control */
|
||||
#define MT753X_RGAC1 0x28
|
||||
-#define MT753X_R02_BPDU_FR BIT(25)
|
||||
-#define MT753X_R02_EG_TAG_MASK GENMASK(24, 22)
|
||||
-#define MT753X_R02_EG_TAG(x) FIELD_PREP(MT753X_R02_EG_TAG_MASK, x)
|
||||
-#define MT753X_R02_PORT_FW_MASK GENMASK(18, 16)
|
||||
-#define MT753X_R02_PORT_FW(x) FIELD_PREP(MT753X_R02_PORT_FW_MASK, x)
|
||||
-#define MT753X_R01_BPDU_FR BIT(9)
|
||||
-#define MT753X_R01_EG_TAG_MASK GENMASK(8, 6)
|
||||
-#define MT753X_R01_EG_TAG(x) FIELD_PREP(MT753X_R01_EG_TAG_MASK, x)
|
||||
-#define MT753X_R01_PORT_FW_MASK GENMASK(2, 0)
|
||||
+#define R02_BPDU_FR BIT(25)
|
||||
+#define R02_EG_TAG_MASK GENMASK(24, 22)
|
||||
+#define R02_EG_TAG(x) FIELD_PREP(R02_EG_TAG_MASK, x)
|
||||
+#define R02_PORT_FW_MASK GENMASK(18, 16)
|
||||
+#define R02_PORT_FW(x) FIELD_PREP(R02_PORT_FW_MASK, x)
|
||||
+#define R01_BPDU_FR BIT(9)
|
||||
+#define R01_EG_TAG_MASK GENMASK(8, 6)
|
||||
+#define R01_EG_TAG(x) FIELD_PREP(R01_EG_TAG_MASK, x)
|
||||
+#define R01_PORT_FW_MASK GENMASK(2, 0)
|
||||
|
||||
-/* Register for :03 and :0E MAC DA frame control */
|
||||
+/* Register for 01-80-C2-00-00-[03,0E] MAC DA frame control */
|
||||
#define MT753X_RGAC2 0x2c
|
||||
-#define MT753X_R0E_BPDU_FR BIT(25)
|
||||
-#define MT753X_R0E_EG_TAG_MASK GENMASK(24, 22)
|
||||
-#define MT753X_R0E_EG_TAG(x) FIELD_PREP(MT753X_R0E_EG_TAG_MASK, x)
|
||||
-#define MT753X_R0E_PORT_FW_MASK GENMASK(18, 16)
|
||||
-#define MT753X_R0E_PORT_FW(x) FIELD_PREP(MT753X_R0E_PORT_FW_MASK, x)
|
||||
-#define MT753X_R03_BPDU_FR BIT(9)
|
||||
-#define MT753X_R03_EG_TAG_MASK GENMASK(8, 6)
|
||||
-#define MT753X_R03_EG_TAG(x) FIELD_PREP(MT753X_R03_EG_TAG_MASK, x)
|
||||
-#define MT753X_R03_PORT_FW_MASK GENMASK(2, 0)
|
||||
+#define R0E_BPDU_FR BIT(25)
|
||||
+#define R0E_EG_TAG_MASK GENMASK(24, 22)
|
||||
+#define R0E_EG_TAG(x) FIELD_PREP(R0E_EG_TAG_MASK, x)
|
||||
+#define R0E_PORT_FW_MASK GENMASK(18, 16)
|
||||
+#define R0E_PORT_FW(x) FIELD_PREP(R0E_PORT_FW_MASK, x)
|
||||
+#define R03_BPDU_FR BIT(9)
|
||||
+#define R03_EG_TAG_MASK GENMASK(8, 6)
|
||||
+#define R03_EG_TAG(x) FIELD_PREP(R03_EG_TAG_MASK, x)
|
||||
+#define R03_PORT_FW_MASK GENMASK(2, 0)
|
||||
|
||||
-enum mt753x_bpdu_port_fw {
|
||||
- MT753X_BPDU_FOLLOW_MFC,
|
||||
- MT753X_BPDU_CPU_EXCLUDE = 4,
|
||||
- MT753X_BPDU_CPU_INCLUDE = 5,
|
||||
- MT753X_BPDU_CPU_ONLY = 6,
|
||||
- MT753X_BPDU_DROP = 7,
|
||||
+enum mt753x_to_cpu_fw {
|
||||
+ TO_CPU_FW_SYSTEM_DEFAULT,
|
||||
+ TO_CPU_FW_CPU_EXCLUDE = 4,
|
||||
+ TO_CPU_FW_CPU_INCLUDE = 5,
|
||||
+ TO_CPU_FW_CPU_ONLY = 6,
|
||||
+ TO_CPU_FW_DROP = 7,
|
||||
};
|
||||
|
||||
/* Registers for address table access */
|
||||
@ -0,0 +1,201 @@
|
||||
From 1dbc1bdc2869e6d2929235c70d64e393aa5a5fa2 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Mon, 22 Apr 2024 10:15:12 +0300
|
||||
Subject: [PATCH 05/15] net: dsa: mt7530: refactor MT7530_MFC and MT7531_CFC,
|
||||
add MT7531_QRY_FFP
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The MT7530_MFC register is on MT7530, MT7531, and the switch on the MT7988
|
||||
SoC. Rename it to MT753X_MFC. Bit 7 to 0 differs between MT7530 and
|
||||
MT7531/MT7988. Add MT7530 prefix to these definitions, and define the
|
||||
IGMP/MLD Query Frame Flooding Ports mask for MT7531.
|
||||
|
||||
Rename the cases of MIRROR_MASK to MIRROR_PORT_MASK.
|
||||
|
||||
Move mt753x_mirror_port_get() and mt753x_port_mirror_set() to mt7530.h as
|
||||
macros.
|
||||
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 38 ++++++++--------------
|
||||
drivers/net/dsa/mt7530.h | 69 +++++++++++++++++++++++++---------------
|
||||
2 files changed, 57 insertions(+), 50 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -1140,7 +1140,7 @@ mt753x_cpu_port_enable(struct dsa_switch
|
||||
PORT_SPEC_TAG);
|
||||
|
||||
/* Enable flooding on the CPU port */
|
||||
- mt7530_set(priv, MT7530_MFC, BC_FFP(BIT(port)) | UNM_FFP(BIT(port)) |
|
||||
+ mt7530_set(priv, MT753X_MFC, BC_FFP(BIT(port)) | UNM_FFP(BIT(port)) |
|
||||
UNU_FFP(BIT(port)));
|
||||
|
||||
/* Add the CPU port to the CPU port bitmap for MT7531 and the switch on
|
||||
@@ -1304,15 +1304,15 @@ mt7530_port_bridge_flags(struct dsa_swit
|
||||
flags.val & BR_LEARNING ? 0 : SA_DIS);
|
||||
|
||||
if (flags.mask & BR_FLOOD)
|
||||
- mt7530_rmw(priv, MT7530_MFC, UNU_FFP(BIT(port)),
|
||||
+ mt7530_rmw(priv, MT753X_MFC, UNU_FFP(BIT(port)),
|
||||
flags.val & BR_FLOOD ? UNU_FFP(BIT(port)) : 0);
|
||||
|
||||
if (flags.mask & BR_MCAST_FLOOD)
|
||||
- mt7530_rmw(priv, MT7530_MFC, UNM_FFP(BIT(port)),
|
||||
+ mt7530_rmw(priv, MT753X_MFC, UNM_FFP(BIT(port)),
|
||||
flags.val & BR_MCAST_FLOOD ? UNM_FFP(BIT(port)) : 0);
|
||||
|
||||
if (flags.mask & BR_BCAST_FLOOD)
|
||||
- mt7530_rmw(priv, MT7530_MFC, BC_FFP(BIT(port)),
|
||||
+ mt7530_rmw(priv, MT753X_MFC, BC_FFP(BIT(port)),
|
||||
flags.val & BR_BCAST_FLOOD ? BC_FFP(BIT(port)) : 0);
|
||||
|
||||
return 0;
|
||||
@@ -1848,20 +1848,6 @@ mt7530_port_vlan_del(struct dsa_switch *
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int mt753x_mirror_port_get(unsigned int id, u32 val)
|
||||
-{
|
||||
- return (id == ID_MT7531 || id == ID_MT7988) ?
|
||||
- MT7531_MIRROR_PORT_GET(val) :
|
||||
- MIRROR_PORT(val);
|
||||
-}
|
||||
-
|
||||
-static int mt753x_mirror_port_set(unsigned int id, u32 val)
|
||||
-{
|
||||
- return (id == ID_MT7531 || id == ID_MT7988) ?
|
||||
- MT7531_MIRROR_PORT_SET(val) :
|
||||
- MIRROR_PORT(val);
|
||||
-}
|
||||
-
|
||||
static int mt753x_port_mirror_add(struct dsa_switch *ds, int port,
|
||||
struct dsa_mall_mirror_tc_entry *mirror,
|
||||
bool ingress, struct netlink_ext_ack *extack)
|
||||
@@ -1877,14 +1863,14 @@ static int mt753x_port_mirror_add(struct
|
||||
val = mt7530_read(priv, MT753X_MIRROR_REG(priv->id));
|
||||
|
||||
/* MT7530 only supports one monitor port */
|
||||
- monitor_port = mt753x_mirror_port_get(priv->id, val);
|
||||
+ monitor_port = MT753X_MIRROR_PORT_GET(priv->id, val);
|
||||
if (val & MT753X_MIRROR_EN(priv->id) &&
|
||||
monitor_port != mirror->to_local_port)
|
||||
return -EEXIST;
|
||||
|
||||
val |= MT753X_MIRROR_EN(priv->id);
|
||||
- val &= ~MT753X_MIRROR_MASK(priv->id);
|
||||
- val |= mt753x_mirror_port_set(priv->id, mirror->to_local_port);
|
||||
+ val &= ~MT753X_MIRROR_PORT_MASK(priv->id);
|
||||
+ val |= MT753X_MIRROR_PORT_SET(priv->id, mirror->to_local_port);
|
||||
mt7530_write(priv, MT753X_MIRROR_REG(priv->id), val);
|
||||
|
||||
val = mt7530_read(priv, MT7530_PCR_P(port));
|
||||
@@ -2524,7 +2510,7 @@ mt7531_setup_common(struct dsa_switch *d
|
||||
mt7530_mib_reset(ds);
|
||||
|
||||
/* Disable flooding on all ports */
|
||||
- mt7530_clear(priv, MT7530_MFC, BC_FFP_MASK | UNM_FFP_MASK |
|
||||
+ mt7530_clear(priv, MT753X_MFC, BC_FFP_MASK | UNM_FFP_MASK |
|
||||
UNU_FFP_MASK);
|
||||
|
||||
for (i = 0; i < MT7530_NUM_PORTS; i++) {
|
||||
@@ -3086,10 +3072,12 @@ mt753x_conduit_state_change(struct dsa_s
|
||||
else
|
||||
priv->active_cpu_ports &= ~mask;
|
||||
|
||||
- if (priv->active_cpu_ports)
|
||||
- val = CPU_EN | CPU_PORT(__ffs(priv->active_cpu_ports));
|
||||
+ if (priv->active_cpu_ports) {
|
||||
+ val = MT7530_CPU_EN |
|
||||
+ MT7530_CPU_PORT(__ffs(priv->active_cpu_ports));
|
||||
+ }
|
||||
|
||||
- mt7530_rmw(priv, MT7530_MFC, CPU_EN | CPU_PORT_MASK, val);
|
||||
+ mt7530_rmw(priv, MT753X_MFC, MT7530_CPU_EN | MT7530_CPU_PORT_MASK, val);
|
||||
}
|
||||
|
||||
static int mt7988_setup(struct dsa_switch *ds)
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -36,36 +36,55 @@ enum mt753x_id {
|
||||
#define MT753X_AGC 0xc
|
||||
#define LOCAL_EN BIT(7)
|
||||
|
||||
-/* Registers to mac forward control for unknown frames */
|
||||
-#define MT7530_MFC 0x10
|
||||
-#define BC_FFP(x) (((x) & 0xff) << 24)
|
||||
-#define BC_FFP_MASK BC_FFP(~0)
|
||||
-#define UNM_FFP(x) (((x) & 0xff) << 16)
|
||||
-#define UNM_FFP_MASK UNM_FFP(~0)
|
||||
-#define UNU_FFP(x) (((x) & 0xff) << 8)
|
||||
-#define UNU_FFP_MASK UNU_FFP(~0)
|
||||
-#define CPU_EN BIT(7)
|
||||
-#define CPU_PORT_MASK GENMASK(6, 4)
|
||||
-#define CPU_PORT(x) FIELD_PREP(CPU_PORT_MASK, x)
|
||||
-#define MIRROR_EN BIT(3)
|
||||
-#define MIRROR_PORT(x) ((x) & 0x7)
|
||||
-#define MIRROR_MASK 0x7
|
||||
+/* Register for MAC forward control */
|
||||
+#define MT753X_MFC 0x10
|
||||
+#define BC_FFP_MASK GENMASK(31, 24)
|
||||
+#define BC_FFP(x) FIELD_PREP(BC_FFP_MASK, x)
|
||||
+#define UNM_FFP_MASK GENMASK(23, 16)
|
||||
+#define UNM_FFP(x) FIELD_PREP(UNM_FFP_MASK, x)
|
||||
+#define UNU_FFP_MASK GENMASK(15, 8)
|
||||
+#define UNU_FFP(x) FIELD_PREP(UNU_FFP_MASK, x)
|
||||
+#define MT7530_CPU_EN BIT(7)
|
||||
+#define MT7530_CPU_PORT_MASK GENMASK(6, 4)
|
||||
+#define MT7530_CPU_PORT(x) FIELD_PREP(MT7530_CPU_PORT_MASK, x)
|
||||
+#define MT7530_MIRROR_EN BIT(3)
|
||||
+#define MT7530_MIRROR_PORT_MASK GENMASK(2, 0)
|
||||
+#define MT7530_MIRROR_PORT_GET(x) FIELD_GET(MT7530_MIRROR_PORT_MASK, x)
|
||||
+#define MT7530_MIRROR_PORT_SET(x) FIELD_PREP(MT7530_MIRROR_PORT_MASK, x)
|
||||
+#define MT7531_QRY_FFP_MASK GENMASK(7, 0)
|
||||
+#define MT7531_QRY_FFP(x) FIELD_PREP(MT7531_QRY_FFP_MASK, x)
|
||||
|
||||
-/* Registers for CPU forward control */
|
||||
+/* Register for CPU forward control */
|
||||
#define MT7531_CFC 0x4
|
||||
#define MT7531_MIRROR_EN BIT(19)
|
||||
-#define MT7531_MIRROR_MASK (MIRROR_MASK << 16)
|
||||
-#define MT7531_MIRROR_PORT_GET(x) (((x) >> 16) & MIRROR_MASK)
|
||||
-#define MT7531_MIRROR_PORT_SET(x) (((x) & MIRROR_MASK) << 16)
|
||||
+#define MT7531_MIRROR_PORT_MASK GENMASK(18, 16)
|
||||
+#define MT7531_MIRROR_PORT_GET(x) FIELD_GET(MT7531_MIRROR_PORT_MASK, x)
|
||||
+#define MT7531_MIRROR_PORT_SET(x) FIELD_PREP(MT7531_MIRROR_PORT_MASK, x)
|
||||
#define MT7531_CPU_PMAP_MASK GENMASK(7, 0)
|
||||
#define MT7531_CPU_PMAP(x) FIELD_PREP(MT7531_CPU_PMAP_MASK, x)
|
||||
|
||||
-#define MT753X_MIRROR_REG(id) ((((id) == ID_MT7531) || ((id) == ID_MT7988)) ? \
|
||||
- MT7531_CFC : MT7530_MFC)
|
||||
-#define MT753X_MIRROR_EN(id) ((((id) == ID_MT7531) || ((id) == ID_MT7988)) ? \
|
||||
- MT7531_MIRROR_EN : MIRROR_EN)
|
||||
-#define MT753X_MIRROR_MASK(id) ((((id) == ID_MT7531) || ((id) == ID_MT7988)) ? \
|
||||
- MT7531_MIRROR_MASK : MIRROR_MASK)
|
||||
+#define MT753X_MIRROR_REG(id) ((id == ID_MT7531 || \
|
||||
+ id == ID_MT7988) ? \
|
||||
+ MT7531_CFC : MT753X_MFC)
|
||||
+
|
||||
+#define MT753X_MIRROR_EN(id) ((id == ID_MT7531 || \
|
||||
+ id == ID_MT7988) ? \
|
||||
+ MT7531_MIRROR_EN : MT7530_MIRROR_EN)
|
||||
+
|
||||
+#define MT753X_MIRROR_PORT_MASK(id) ((id == ID_MT7531 || \
|
||||
+ id == ID_MT7988) ? \
|
||||
+ MT7531_MIRROR_PORT_MASK : \
|
||||
+ MT7530_MIRROR_PORT_MASK)
|
||||
+
|
||||
+#define MT753X_MIRROR_PORT_GET(id, val) ((id == ID_MT7531 || \
|
||||
+ id == ID_MT7988) ? \
|
||||
+ MT7531_MIRROR_PORT_GET(val) : \
|
||||
+ MT7530_MIRROR_PORT_GET(val))
|
||||
+
|
||||
+#define MT753X_MIRROR_PORT_SET(id, val) ((id == ID_MT7531 || \
|
||||
+ id == ID_MT7988) ? \
|
||||
+ MT7531_MIRROR_PORT_SET(val) : \
|
||||
+ MT7530_MIRROR_PORT_SET(val))
|
||||
|
||||
/* Register for BPDU and PAE frame control */
|
||||
#define MT753X_BPC 0x24
|
||||
@ -0,0 +1,257 @@
|
||||
From 3ccf67597d35c06a7319e407b1c42f78a7966779 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
|
||||
Date: Mon, 22 Apr 2024 10:15:13 +0300
|
||||
Subject: [PATCH 06/15] net: dsa: mt7530: refactor MT7530_HWTRAP and
|
||||
MT7530_MHWTRAP
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The MT7530_HWTRAP and MT7530_MHWTRAP registers are on MT7530 and MT7531.
|
||||
It's called hardware trap on MT7530, software trap on MT7531. That's
|
||||
because some bits of the trap on MT7530 cannot be modified by software
|
||||
whilst all bits of the trap on MT7531 can. Rename the definitions for them
|
||||
to MT753X_TRAP and MT753X_MTRAP. Add MT7530 and MT7531 prefixes to the
|
||||
definitions specific to the switch model.
|
||||
|
||||
Remove the extra parentheses from MT7530_XTAL_40MHZ and MT7530_XTAL_20MHZ.
|
||||
|
||||
Rename MHWTRAP_PHY0_SEL, MHWTRAP_MANUAL, and MHWTRAP_PHY_ACCESS to be on
|
||||
par with the "MT7621 Giga Switch Programming Guide v0.3" document.
|
||||
|
||||
Make an enumaration for the XTAL frequency. Set the data type of the xtal
|
||||
variable on mt7531_pll_setup() to it.
|
||||
|
||||
Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
---
|
||||
drivers/net/dsa/mt7530.c | 59 ++++++++++++++++++++--------------------
|
||||
drivers/net/dsa/mt7530.h | 50 ++++++++++++++++------------------
|
||||
2 files changed, 54 insertions(+), 55 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mt7530.c
|
||||
+++ b/drivers/net/dsa/mt7530.c
|
||||
@@ -403,23 +403,23 @@ mt7530_setup_port6(struct dsa_switch *ds
|
||||
|
||||
mt7530_rmw(priv, MT7530_P6ECR, P6_INTF_MODE_MASK, P6_INTF_MODE(1));
|
||||
|
||||
- xtal = mt7530_read(priv, MT7530_MHWTRAP) & HWTRAP_XTAL_MASK;
|
||||
+ xtal = mt7530_read(priv, MT753X_MTRAP) & MT7530_XTAL_MASK;
|
||||
|
||||
- if (xtal == HWTRAP_XTAL_25MHZ)
|
||||
+ if (xtal == MT7530_XTAL_25MHZ)
|
||||
ssc_delta = 0x57;
|
||||
else
|
||||
ssc_delta = 0x87;
|
||||
|
||||
if (priv->id == ID_MT7621) {
|
||||
/* PLL frequency: 125MHz: 1.0GBit */
|
||||
- if (xtal == HWTRAP_XTAL_40MHZ)
|
||||
+ if (xtal == MT7530_XTAL_40MHZ)
|
||||
ncpo1 = 0x0640;
|
||||
- if (xtal == HWTRAP_XTAL_25MHZ)
|
||||
+ if (xtal == MT7530_XTAL_25MHZ)
|
||||
ncpo1 = 0x0a00;
|
||||
} else { /* PLL frequency: 250MHz: 2.0Gbit */
|
||||
- if (xtal == HWTRAP_XTAL_40MHZ)
|
||||
+ if (xtal == MT7530_XTAL_40MHZ)
|
||||
ncpo1 = 0x0c80;
|
||||
- if (xtal == HWTRAP_XTAL_25MHZ)
|
||||
+ if (xtal == MT7530_XTAL_25MHZ)
|
||||
ncpo1 = 0x1400;
|
||||
}
|
||||
|
||||
@@ -442,19 +442,20 @@ mt7530_setup_port6(struct dsa_switch *ds
|
||||
static void
|
||||
mt7531_pll_setup(struct mt7530_priv *priv)
|
||||
{
|
||||
+ enum mt7531_xtal_fsel xtal;
|
||||
u32 top_sig;
|
||||
u32 hwstrap;
|
||||
- u32 xtal;
|
||||
u32 val;
|
||||
|
||||
val = mt7530_read(priv, MT7531_CREV);
|
||||
top_sig = mt7530_read(priv, MT7531_TOP_SIG_SR);
|
||||
- hwstrap = mt7530_read(priv, MT7531_HWTRAP);
|
||||
+ hwstrap = mt7530_read(priv, MT753X_TRAP);
|
||||
if ((val & CHIP_REV_M) > 0)
|
||||
- xtal = (top_sig & PAD_MCM_SMI_EN) ? HWTRAP_XTAL_FSEL_40MHZ :
|
||||
- HWTRAP_XTAL_FSEL_25MHZ;
|
||||
+ xtal = (top_sig & PAD_MCM_SMI_EN) ? MT7531_XTAL_FSEL_40MHZ :
|
||||
+ MT7531_XTAL_FSEL_25MHZ;
|
||||
else
|
||||
- xtal = hwstrap & HWTRAP_XTAL_FSEL_MASK;
|
||||
+ xtal = (hwstrap & MT7531_XTAL25) ? MT7531_XTAL_FSEL_25MHZ :
|
||||
+ MT7531_XTAL_FSEL_40MHZ;
|
||||
|
||||
/* Step 1 : Disable MT7531 COREPLL */
|
||||
val = mt7530_read(priv, MT7531_PLLGP_EN);
|
||||
@@ -483,13 +484,13 @@ mt7531_pll_setup(struct mt7530_priv *pri
|
||||
usleep_range(25, 35);
|
||||
|
||||
switch (xtal) {
|
||||
- case HWTRAP_XTAL_FSEL_25MHZ:
|
||||
+ case MT7531_XTAL_FSEL_25MHZ:
|
||||
val = mt7530_read(priv, MT7531_PLLGP_CR0);
|
||||
val &= ~RG_COREPLL_SDM_PCW_M;
|
||||
val |= 0x140000 << RG_COREPLL_SDM_PCW_S;
|
||||
mt7530_write(priv, MT7531_PLLGP_CR0, val);
|
||||
break;
|
||||
- case HWTRAP_XTAL_FSEL_40MHZ:
|
||||
+ case MT7531_XTAL_FSEL_40MHZ:
|
||||
val = mt7530_read(priv, MT7531_PLLGP_CR0);
|
||||
val &= ~RG_COREPLL_SDM_PCW_M;
|
||||
val |= 0x190000 << RG_COREPLL_SDM_PCW_S;
|
||||
@@ -870,20 +871,20 @@ static void mt7530_setup_port5(struct ds
|
||||
|
||||
mutex_lock(&priv->reg_mutex);
|
||||
|
||||
- val = mt7530_read(priv, MT7530_MHWTRAP);
|
||||
+ val = mt7530_read(priv, MT753X_MTRAP);
|
||||
|
||||
- val |= MHWTRAP_MANUAL | MHWTRAP_P5_MAC_SEL | MHWTRAP_P5_DIS;
|
||||
- val &= ~MHWTRAP_P5_RGMII_MODE & ~MHWTRAP_PHY0_SEL;
|
||||
+ val |= MT7530_CHG_TRAP | MT7530_P5_MAC_SEL | MT7530_P5_DIS;
|
||||
+ val &= ~MT7530_P5_RGMII_MODE & ~MT7530_P5_PHY0_SEL;
|
||||
|
||||
switch (priv->p5_mode) {
|
||||
/* MUX_PHY_P0: P0 -> P5 -> SoC MAC */
|
||||
case MUX_PHY_P0:
|
||||
- val |= MHWTRAP_PHY0_SEL;
|
||||
+ val |= MT7530_P5_PHY0_SEL;
|
||||
fallthrough;
|
||||
|
||||
/* MUX_PHY_P4: P4 -> P5 -> SoC MAC */
|
||||
case MUX_PHY_P4:
|
||||
- val &= ~MHWTRAP_P5_MAC_SEL & ~MHWTRAP_P5_DIS;
|
||||
+ val &= ~MT7530_P5_MAC_SEL & ~MT7530_P5_DIS;
|
||||
|
||||
/* Setup the MAC by default for the cpu port */
|
||||
mt7530_write(priv, MT753X_PMCR_P(5), 0x56300);
|
||||
@@ -891,13 +892,13 @@ static void mt7530_setup_port5(struct ds
|
||||
|
||||
/* GMAC5: P5 -> SoC MAC or external PHY */
|
||||
default:
|
||||
- val &= ~MHWTRAP_P5_DIS;
|
||||
+ val &= ~MT7530_P5_DIS;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Setup RGMII settings */
|
||||
if (phy_interface_mode_is_rgmii(interface)) {
|
||||
- val |= MHWTRAP_P5_RGMII_MODE;
|
||||
+ val |= MT7530_P5_RGMII_MODE;
|
||||
|
||||
/* P5 RGMII RX Clock Control: delay setting for 1000M */
|
||||
mt7530_write(priv, MT7530_P5RGMIIRXCR, CSR_RGMII_EDGE_ALIGN);
|
||||
@@ -917,7 +918,7 @@ static void mt7530_setup_port5(struct ds
|
||||
P5_IO_CLK_DRV(1) | P5_IO_DATA_DRV(1));
|
||||
}
|
||||
|
||||
- mt7530_write(priv, MT7530_MHWTRAP, val);
|
||||
+ mt7530_write(priv, MT753X_MTRAP, val);
|
||||
|
||||
dev_dbg(ds->dev, "Setup P5, HWTRAP=0x%x, mode=%s, phy-mode=%s\n", val,
|
||||
mt7530_p5_mode_str(priv->p5_mode), phy_modes(interface));
|
||||
@@ -2356,7 +2357,7 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
}
|
||||
|
||||
/* Waiting for MT7530 got to stable */
|
||||
- INIT_MT7530_DUMMY_POLL(&p, priv, MT7530_HWTRAP);
|
||||
+ INIT_MT7530_DUMMY_POLL(&p, priv, MT753X_TRAP);
|
||||
ret = readx_poll_timeout(_mt7530_read, &p, val, val != 0,
|
||||
20, 1000000);
|
||||
if (ret < 0) {
|
||||
@@ -2371,7 +2372,7 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
- if ((val & HWTRAP_XTAL_MASK) == HWTRAP_XTAL_20MHZ) {
|
||||
+ if ((val & MT7530_XTAL_MASK) == MT7530_XTAL_20MHZ) {
|
||||
dev_err(priv->dev,
|
||||
"MT7530 with a 20MHz XTAL is not supported!\n");
|
||||
return -EINVAL;
|
||||
@@ -2392,12 +2393,12 @@ mt7530_setup(struct dsa_switch *ds)
|
||||
RD_TAP_MASK, RD_TAP(16));
|
||||
|
||||
/* Enable port 6 */
|
||||
- val = mt7530_read(priv, MT7530_MHWTRAP);
|
||||
- val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS;
|
||||
- val |= MHWTRAP_MANUAL;
|
||||
- mt7530_write(priv, MT7530_MHWTRAP, val);
|
||||
+ val = mt7530_read(priv, MT753X_MTRAP);
|
||||
+ val &= ~MT7530_P6_DIS & ~MT7530_PHY_INDIRECT_ACCESS;
|
||||
+ val |= MT7530_CHG_TRAP;
|
||||
+ mt7530_write(priv, MT753X_MTRAP, val);
|
||||
|
||||
- if ((val & HWTRAP_XTAL_MASK) == HWTRAP_XTAL_40MHZ)
|
||||
+ if ((val & MT7530_XTAL_MASK) == MT7530_XTAL_40MHZ)
|
||||
mt7530_pll_setup(priv);
|
||||
|
||||
mt753x_trap_frames(priv);
|
||||
@@ -2577,7 +2578,7 @@ mt7531_setup(struct dsa_switch *ds)
|
||||
}
|
||||
|
||||
/* Waiting for MT7530 got to stable */
|
||||
- INIT_MT7530_DUMMY_POLL(&p, priv, MT7530_HWTRAP);
|
||||
+ INIT_MT7530_DUMMY_POLL(&p, priv, MT753X_TRAP);
|
||||
ret = readx_poll_timeout(_mt7530_read, &p, val, val != 0,
|
||||
20, 1000000);
|
||||
if (ret < 0) {
|
||||
--- a/drivers/net/dsa/mt7530.h
|
||||
+++ b/drivers/net/dsa/mt7530.h
|
||||
@@ -495,32 +495,30 @@ enum mt7531_clk_skew {
|
||||
MT7531_CLK_SKEW_REVERSE = 3,
|
||||
};
|
||||
|
||||
-/* Register for hw trap status */
|
||||
-#define MT7530_HWTRAP 0x7800
|
||||
-#define HWTRAP_XTAL_MASK (BIT(10) | BIT(9))
|
||||
-#define HWTRAP_XTAL_25MHZ (BIT(10) | BIT(9))
|
||||
-#define HWTRAP_XTAL_40MHZ (BIT(10))
|
||||
-#define HWTRAP_XTAL_20MHZ (BIT(9))
|
||||
+/* Register for trap status */
|
||||
+#define MT753X_TRAP 0x7800
|
||||
+#define MT7530_XTAL_MASK (BIT(10) | BIT(9))
|
||||
+#define MT7530_XTAL_25MHZ (BIT(10) | BIT(9))
|
||||
+#define MT7530_XTAL_40MHZ BIT(10)
|
||||
+#define MT7530_XTAL_20MHZ BIT(9)
|
||||
+#define MT7531_XTAL25 BIT(7)
|
||||
|
||||
-#define MT7531_HWTRAP 0x7800
|
||||
-#define HWTRAP_XTAL_FSEL_MASK BIT(7)
|
||||
-#define HWTRAP_XTAL_FSEL_25MHZ BIT(7)
|
||||
-#define HWTRAP_XTAL_FSEL_40MHZ 0
|
||||
-/* Unique fields of (M)HWSTRAP for MT7531 */
|
||||
-#define XTAL_FSEL_S 7
|
||||
-#define XTAL_FSEL_M BIT(7)
|
||||
-#define PHY_EN BIT(6)
|
||||
-#define CHG_STRAP BIT(8)
|
||||
+/* Register for trap modification */
|
||||
+#define MT753X_MTRAP 0x7804
|
||||
+#define MT7530_P5_PHY0_SEL BIT(20)
|
||||
+#define MT7530_CHG_TRAP BIT(16)
|
||||
+#define MT7530_P5_MAC_SEL BIT(13)
|
||||
+#define MT7530_P6_DIS BIT(8)
|
||||
+#define MT7530_P5_RGMII_MODE BIT(7)
|
||||
+#define MT7530_P5_DIS BIT(6)
|
||||
+#define MT7530_PHY_INDIRECT_ACCESS BIT(5)
|
||||
+#define MT7531_CHG_STRAP BIT(8)
|
||||
+#define MT7531_PHY_EN BIT(6)
|
||||
|
||||
-/* Register for hw trap modification */
|
||||
-#define MT7530_MHWTRAP 0x7804
|
||||
-#define MHWTRAP_PHY0_SEL BIT(20)
|
||||
-#define MHWTRAP_MANUAL BIT(16)
|
||||
-#define MHWTRAP_P5_MAC_SEL BIT(13)
|
||||
-#define MHWTRAP_P6_DIS BIT(8)
|
||||
-#define MHWTRAP_P5_RGMII_MODE BIT(7)
|
||||
-#define MHWTRAP_P5_DIS BIT(6)
|
||||
-#define MHWTRAP_PHY_ACCESS BIT(5)
|
||||
+enum mt7531_xtal_fsel {
|
||||
+ MT7531_XTAL_FSEL_25MHZ,
|
||||
+ MT7531_XTAL_FSEL_40MHZ,
|
||||
+};
|
||||
|
||||
/* Register for TOP signal control */
|
||||
#define MT7530_TOP_SIG_CTRL 0x7808
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user