Skip to content

Commit

Permalink
Marvell a7020-comexp - add support for common CPU module
Browse files Browse the repository at this point in the history
Signed-off-by: Gil Tabibian <gilt@marvell.com>
Signed-off-by: Alex Doyle <adoyle@cumulusnetworks.com>
  • Loading branch information
gilt-marvell authored and alexdoyle committed Apr 30, 2020
1 parent 5e8299f commit f6429f6
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 12 deletions.
27 changes: 17 additions & 10 deletions machine/marvell/a7020-comexp/kernel/0002-add-a7020-comexp-dts.patch
@@ -1,13 +1,15 @@
From 50ba0ed922447273523c371a948cf977d3f414e0 Mon Sep 17 00:00:00 2001
From e210f9291535e581d577dfc90d9f3b1c7b84e611 Mon Sep 17 00:00:00 2001
From: gilt <gilt@marvell.com>
Date: Mon, 26 Aug 2019 14:58:10 +0300
Subject: [PATCH] add a7020-comexp dts
Subject: [PATCH] From a74e3ab5d785f600c4848eeb8ffaf23daf76adea Mon Sep 17
00:00:00 2001 Subject: [PATCH] From 50ba0ed922447273523c371a948cf977d3f414e0
Mon Sep 17 00:00:00 2001 Subject: [PATCH] add a7020-comexp dts

Change-Id: If4d6e2b704aad1616ad91871282e678eabb400dd
---
arch/arm64/boot/dts/marvell/Makefile | 1 +
.../boot/dts/marvell/armada-7020-comexpress.dts | 136 +++++++++++++++++++++
2 files changed, 137 insertions(+)
.../boot/dts/marvell/armada-7020-comexpress.dts | 141 +++++++++++++++++++++
2 files changed, 142 insertions(+)
create mode 100644 arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts

diff --git a/arch/arm64/boot/dts/marvell/Makefile b/arch/arm64/boot/dts/marvell/Makefile
Expand All @@ -24,10 +26,10 @@ index 55f86c8..da5c1db 100644

diff --git a/arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts b/arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts
new file mode 100644
index 0000000..f077419
index 0000000..de0801f
--- /dev/null
+++ b/arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts
@@ -0,0 +1,136 @@
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2019 Marvell Technology Group Ltd.
Expand Down Expand Up @@ -130,14 +132,19 @@ index 0000000..f077419
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "U-Boot";
+ /* boot - 4MB (dual image of 2M each) */
+ label = "uboot";
+ reg = <0 0x400000>;
+ read-only;
+ };
+ partition@400000 {
+ label = "ENV";
+ partition@400000 {
+ /* uboot-env - 1MB */
+ label = "uboot-env";
+ reg = <0x400000 0x100000>;
+ env_size = <0x10000>;
+ };
+ partition@500000 {
+ /* onie - 30MB */
+ label = "ONIE";
+ reg = <0x500000 0x1e00000>;
+ };
Expand Down Expand Up @@ -165,5 +172,5 @@ index 0000000..f077419
+ broken-cd;
+};
--
2.6.3
2.7.4

@@ -0,0 +1,31 @@
From 7c0c6d40ee361a158eadb703a6fd26e56969fd58 Mon Sep 17 00:00:00 2001
From: Gil Tabibian <gilt@marvell.com>
Date: Fri, 20 Sep 2019 20:06:45 +0530
Subject: [PATCH] dts a7020 rename 10G phy mode to SFI

---
arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts b/arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts
index 7dbe357..dd12d3f 100644
--- a/arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts
+++ b/arch/arm64/boot/dts/marvell/armada-7020-comexpress.dts
@@ -41,13 +41,9 @@
status = "okay";
};

-&cpm_ethernet {
- status = "okay";
-};
-
&cp0_emac0 {
status = "okay";
- phy-mode = "10gbase-kr";
+ phy-mode = "sfi";
};

&cp0_emac2 {
--
2.7.4

@@ -0,0 +1,30 @@
From fd353f58e776986f059752e17cadd3d5279c9f46 Mon Sep 17 00:00:00 2001
From: Stefan Chulski <stefanc@marvell.com>
Date: Thu, 12 Sep 2019 13:57:11 +0300
Subject: [PATCH 3/3] phy: add SFI and XFI mode to PHY mode enum

Change-Id: Ida997f9b4cda3bfc35fb3491ccd34659d868136f
Signed-off-by: Stefan Chulski <stefanc@marvell.com>
Reviewed-on: https://sj1git1.cavium.com/15719
---
include/linux/phy.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 974f009..25c3479 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -144,6 +144,10 @@ static inline const char *phy_modes(phy_interface_t interface)
return "xaui";
case PHY_INTERFACE_MODE_10GKR:
return "10gbase-kr";
+ case PHY_INTERFACE_MODE_SFI:
+ return "sfi";
+ case PHY_INTERFACE_MODE_XFI:
+ return "xfi";
default:
return "unknown";
}
--
2.6.3

@@ -0,0 +1,59 @@
From 309fe90bfda3aa4b482c0013d157d0e5c79c7cd5 Mon Sep 17 00:00:00 2001
From: gilt <gilt@marvell.com>
Date: Mon, 26 Aug 2019 13:43:39 +0300
Subject: [PATCH 4/5] ARM64/PCI: Allow userspace to mmap PCI resources

Change-Id: I87ef6492e4956c77c75470ec010a4f11a9a8bdaf
---
arch/arm64/include/asm/pci.h | 4 ++++
arch/arm64/kernel/pci.c | 19 +++++++++++++++++++
2 files changed, 23 insertions(+)

diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
index b9a7ba9..8a18915 100644
--- a/arch/arm64/include/asm/pci.h
+++ b/arch/arm64/include/asm/pci.h
@@ -31,6 +31,10 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
return -ENODEV;
}

+#define HAVE_PCI_MMAP
+extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
+ enum pci_mmap_state mmap_state,
+ int write_combine);
static inline int pci_proc_domain(struct pci_bus *bus)
{
return 1;
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index 1b3eb67..db6dd98 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -54,6 +54,25 @@ int pcibios_alloc_irq(struct pci_dev *dev)
return 0;
}

+int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
+ enum pci_mmap_state mmap_state, int write_combine)
+{
+ if (mmap_state == pci_mmap_io)
+ return -EINVAL;
+
+ /*
+ * Mark this as IO
+ */
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+ if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
+ vma->vm_end - vma->vm_start,
+ vma->vm_page_prot))
+ return -EAGAIN;
+
+ return 0;
+}
+
/*
* raw_pci_read/write - Platform-specific PCI config space access.
*/
--
2.6.3

2 changes: 1 addition & 1 deletion machine/marvell/a7020-comexp/kernel/config
Expand Up @@ -1639,7 +1639,7 @@ CONFIG_NET_VENDOR_I825XX=y
CONFIG_NET_VENDOR_MARVELL=y
CONFIG_MVMDIO=y
# CONFIG_MVNETA_BM is not set
CONFIG_MVPP2=y
CONFIG_MVPP2=n
CONFIG_MVPP2X=y
# CONFIG_PXA168_ETH is not set
# CONFIG_SKGE is not set
Expand Down
3 changes: 3 additions & 0 deletions machine/marvell/a7020-comexp/kernel/series
@@ -1,2 +1,5 @@
0001-Marvell-support-for-armada7020.patch
0002-add-a7020-comexp-dts.patch
0003-dts-a7020-rename-10G-phy-mode-to-SFI.patch
0004-phy-add-SFI-and-XFI-mode-to-PHY-mode-enum.patch
0005-ARM64-PCI-Allow-userspace-to-mmap-PCI-resources.patch
Binary file not shown.
@@ -0,0 +1,5 @@
#!bin/sh

cp -f /bin/exec_installer /bin/exec_installer_edit
/bin/sed "s/tftp_wrap -g/tftp -g/g" /bin/exec_installer_edit > /bin/exec_installer
rm -f /bin/exec_installer_edit
@@ -0,0 +1,93 @@
# Marvell a7020-comexp - update live machine configuration
#
# set 'onie_machine' & 'onie_platform' at run time by reading deviceID from Marvel PCI

# global variables
onie_mvl_machine_dflt=a7020-comexp

mvl_pci=$(lspci | grep 11ab:8400 | awk '{print $1}')
echo "1" > /sys/bus/pci/devices/0000\:$mvl_pci/enable

bar0_space_address=$(cat /sys/bus/pci/devices/0000\:$mvl_pci/resource | awk '{print $1}' | head -1)
bar2_space_address=$(cat /sys/bus/pci/devices/0000\:$mvl_pci/resource | awk '{print $1}' | head -3 | tail -1)
bar2_mask=$(($bar2_space_address & 0xFFFFFFFF))


# sysfs_pci_write function
# Arguments:
# $1 - base_address
# $2 - offset
# $3 - data
sysfs_pci_write()
{
devmem_width=32
devmem $(($1 + $2)) $devmem_width $3
}


# Create mapping window
# Arguments:
# $1 - deviceId base address
configure_pci_window()
{
sysfs_pci_write $bar0_space_address 0x1308 $bar2_mask
sleep 0.001s
sysfs_pci_write $bar0_space_address 0x130c $(($bar2_mask>>32))
sleep 0.001s
sysfs_pci_write $bar0_space_address 0x1310 $(($bar2_mask+0xFFFFF))
sleep 0.001s
sysfs_pci_write $bar0_space_address 0x1300 0x0
sleep 0.001s
sysfs_pci_write $bar0_space_address 0x1304 0x80000000
sleep 0.001s

# Configure the window map
sysfs_pci_write bar0_space_address 0x1314 $1
sleep 0.001s
}

set_onie_machine()
{
deviceIdBaseAddr=0x1d000000
deviceIdReg=0x4c
configure_pci_window $deviceIdBaseAddr

deviceId=$(devmem $(($bar2_space_address + $deviceIdReg)))
deviceIdMask=$((deviceId & 0xFFFF0))

case "$deviceIdMask" in
# 0x84000
540672)
live_machine=db98cx8540_16cd
;;
# 0x86000
548864)
live_machine=db98cx8580_32cd
;;
#TBD - add support for RD board
#live_machine=rd98cx8580_128c
*)
esac
}

gen_live_config()
{
onie_build_machine=$(cat /etc/machine-build.conf | grep 'onie_build_machine=' | cut -d "=" -f 2)
if [ "$onie_build_machine" = "$onie_mvl_machine_dflt" ]; then
set_onie_machine
fi

# Source build-time machine configuration
. /etc/machine-build.conf
if [ -n "$live_machine" ] ; then
cat<<EOF
# Runtime ONIE Machine
onie_machine=$live_machine
onie_platform=${onie_arch}-marvell_${live_machine}-r${onie_machine_rev}
EOF
fi
}




5 changes: 4 additions & 1 deletion rootconf/default/etc/init.d/gen-config.sh
Expand Up @@ -2,6 +2,8 @@

# Copyright (C) 2017 Curt Brune <curt@cumulusnetworks.com>
# Copyright (C) 2017 david_yang <david_yang@accton.com>
# Copyright (C) 2020 Gil Tabibian <gilt@marvell.com>
# Copyright (C) 2020 Alex Doyle <adoyle@cumulusnetworks.com>
#
# SPDX-License-Identifier: GPL-2.0

Expand Down Expand Up @@ -34,7 +36,8 @@ gen_machine_config()
. $build_conf
. $live_conf
local onie_machine=${onie_machine:-$onie_build_machine}
local onie_platform="${onie_arch}-${onie_machine}-r${onie_machine_rev}"
# if onie_platform has not been set in the sourced files, set it now.
local onie_platform=${onie_platform:-${onie_arch}-${onie_machine}-r${onie_machine_rev}}
cat <<EOF >> $machine_conf
onie_machine=$onie_machine
onie_platform=$onie_platform
Expand Down

0 comments on commit f6429f6

Please sign in to comment.