pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils u-boot-rockpro64-ayufan: backport PCIe fixes ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/9e9e05f079cf
branches:  trunk
changeset: 456391:9e9e05f079cf
user:      tnn <tnn%pkgsrc.org@localhost>
date:      Tue Jul 27 20:47:34 2021 +0000

description:
u-boot-rockpro64-ayufan: backport PCIe fixes from sysutils/u-boot-rockpro64

diffstat:

 sysutils/u-boot-rockpro64-ayufan/Makefile                                |    7 +-
 sysutils/u-boot/distinfo-2020.01.2014                                    |    4 +-
 sysutils/u-boot/patches-2020.01.2014/patch-arch_arm_lib_interrupts__64.c |   33 +
 sysutils/u-boot/patches-2020.01.2014/patch-drivers_pci_pcie__rockchip.c  |  271 ++++++++++
 4 files changed, 311 insertions(+), 4 deletions(-)

diffs (truncated from 347 to 300 lines):

diff -r 9b5c3e2724be -r 9e9e05f079cf sysutils/u-boot-rockpro64-ayufan/Makefile
--- a/sysutils/u-boot-rockpro64-ayufan/Makefile Tue Jul 27 19:39:38 2021 +0000
+++ b/sysutils/u-boot-rockpro64-ayufan/Makefile Tue Jul 27 20:47:34 2021 +0000
@@ -1,5 +1,6 @@
-# $NetBSD: Makefile,v 1.5 2021/07/27 15:29:08 tnn Exp $
+# $NetBSD: Makefile,v 1.6 2021/07/27 20:47:35 tnn Exp $
 
+PKGREVISION=           1
 UBOOT_TARGET=          rockpro64
 UBOOT_CONFIG=          rockpro64-rk3399_defconfig
 UBOOT_BIN=             idbloader.img rksd_loader.img rkspi_loader.img u-boot.itb
@@ -11,8 +12,8 @@
 # If updating this package, make sure SPI boot still works.
 # It is broken in mainline 2021.07 as well as in ayufan 2021.07.
 # Until verified fixed keep this version as-is.
-UBOOT_VERSION=  2020.01.2014
-MASTER_SITES=   ${MASTER_SITE_GITHUB:=ayufan-rock64/}
+UBOOT_VERSION= 2020.01.2014
+MASTER_SITES=  ${MASTER_SITE_GITHUB:=ayufan-rock64/}
 GITHUB_PROJECT=        linux-mainline-u-boot
 GITHUB_TAG=    2020.01-ayufan-2014-gff2cdd38
 DISTNAME=      u-boot-rockpro64-ayufan-${GITHUB_TAG}
diff -r 9b5c3e2724be -r 9e9e05f079cf sysutils/u-boot/distinfo-2020.01.2014
--- a/sysutils/u-boot/distinfo-2020.01.2014     Tue Jul 27 19:39:38 2021 +0000
+++ b/sysutils/u-boot/distinfo-2020.01.2014     Tue Jul 27 20:47:34 2021 +0000
@@ -1,6 +1,8 @@
-$NetBSD: distinfo-2020.01.2014,v 1.1 2021/04/18 07:30:28 mrg Exp $
+$NetBSD: distinfo-2020.01.2014,v 1.2 2021/07/27 20:47:34 tnn Exp $
 
 SHA1 (u-boot-rockpro64-ayufan-2020.01-ayufan-2014-gff2cdd38.tar.gz) = 4636aaa91912081708ad69c610b8bfa545c200c7
 RMD160 (u-boot-rockpro64-ayufan-2020.01-ayufan-2014-gff2cdd38.tar.gz) = 7c32af7ca2411712e6960bce453bbf1fe1dc3445
 SHA512 (u-boot-rockpro64-ayufan-2020.01-ayufan-2014-gff2cdd38.tar.gz) = 
938bb081805b1acfb75479115c3e38406b3753f60f13e663dc2a26921380b5c3fbd2adb477e2a83d28bab551294ae697fde72994514f55ed5e36894a29d4502b
 Size (u-boot-rockpro64-ayufan-2020.01-ayufan-2014-gff2cdd38.tar.gz) = 18847179 bytes
+SHA1 (patch-arch_arm_lib_interrupts__64.c) = 5f24ae8c358bd03383c121fec27fa983765b994f
+SHA1 (patch-drivers_pci_pcie__rockchip.c) = e216698695adcc7e842de9f4e63c36ecf46924d1
diff -r 9b5c3e2724be -r 9e9e05f079cf sysutils/u-boot/patches-2020.01.2014/patch-arch_arm_lib_interrupts__64.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/u-boot/patches-2020.01.2014/patch-arch_arm_lib_interrupts__64.c  Tue Jul 27 20:47:34 2021 +0000
@@ -0,0 +1,33 @@
+$NetBSD: patch-arch_arm_lib_interrupts__64.c,v 1.1 2021/07/27 20:47:35 tnn Exp $
+
+backport PCIe fixes from sysutils/u-boot-rockpro64
+
+--- arch/arm/lib/interrupts_64.c.orig  2020-04-15 17:13:47.000000000 +0000
++++ arch/arm/lib/interrupts_64.c
+@@ -107,11 +107,26 @@ void do_bad_error(struct pt_regs *pt_reg
+       panic("Resetting CPU ...\n");
+ }
+ 
++#ifdef CONFIG_ROCKCHIP_RK3399
++extern volatile int rockchip_pcie_expect_data_abort;
++extern volatile int rockchip_pcie_got_data_abort;
++#endif
+ /*
+  * do_sync handles the Synchronous Abort exception.
+  */
+ void do_sync(struct pt_regs *pt_regs, unsigned int esr)
+ {
++#ifdef CONFIG_ROCKCHIP_RK3399
++      if ((esr >> 26) == 0x25 && rockchip_pcie_expect_data_abort) {
++              /*
++               * Data Abort taken without a change in Exception level.
++               * This happens when probing nonexistent PCI-e devices.
++               */
++              rockchip_pcie_got_data_abort = 1;
++              pt_regs->elr += 4; /* skip faulting insn */
++              return;
++      }
++#endif
+       efi_restore_gd();
+       printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
+       show_regs(pt_regs);
diff -r 9b5c3e2724be -r 9e9e05f079cf sysutils/u-boot/patches-2020.01.2014/patch-drivers_pci_pcie__rockchip.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/u-boot/patches-2020.01.2014/patch-drivers_pci_pcie__rockchip.c   Tue Jul 27 20:47:34 2021 +0000
@@ -0,0 +1,271 @@
+$NetBSD: patch-drivers_pci_pcie__rockchip.c,v 1.1 2021/07/27 20:47:35 tnn Exp $
+
+backport PCIe fixes from sysutils/u-boot-rockpro64
+
+--- drivers/pci/pcie_rockchip.c.orig   2020-04-15 17:13:47.000000000 +0000
++++ drivers/pci/pcie_rockchip.c
+@@ -171,8 +171,11 @@ enum of_gpio_flags {
+ 
+ #define RC_REGION_0_ADDR_TRANS_H              0x00000000
+ #define RC_REGION_0_ADDR_TRANS_L              0x00000000
+-#define RC_REGION_0_PASS_BITS                 (25 - 1)
++#define RC_REGION_0_PASS_BITS                 (20 - 1)
+ #define MAX_AXI_WRAPPER_REGION_NUM            33
++#define PCIE_ATR_HDR_CFG_TYPE0                        0xa
++#define PCIE_ATR_HDR_CFG_TYPE1                        0xb
++#define PCIE_ATR_HDR_RID                      BIT(23)
+ 
+ #define PCI_CLASS_BRIDGE_PCI          0x0604
+ 
+@@ -359,42 +362,64 @@ static int rockchip_pcie_wr_own_conf(voi
+     return 0;
+ }
+ 
+-static int rockchip_pcie_rd_other_conf(void *priv, int where,
++static void rockchip_pcie_write(struct pcie_rockchip *rockchip, u32 val, u32 reg);
++volatile int rockchip_pcie_expect_data_abort;
++volatile int rockchip_pcie_got_data_abort;
++
++static int rockchip_pcie_rd_other_conf(void *priv, pci_dev_t d, int where,
+                                        int size, u32 *val)
+ {
+     u32 busdev;
+     struct pcie_rockchip *rockchip = (struct pcie_rockchip *)priv;
+ 
+-    /*
+-     * BDF = 01:00:00
+-     * end-to-end support, no hierarchy....
+-     */
+-    busdev = PCIE_ECAM_ADDR(1, 0, 0, where);
++    busdev = PCIE_ECAM_ADDR(0, PCI_DEV(d), PCI_FUNC(d), where);
++    rockchip_pcie_write(rockchip,
++      (PCI_BUS(d) << 20) | RC_REGION_0_PASS_BITS,
++      PCIE_CORE_OB_REGION_ADDR0);
++    rockchip_pcie_write(rockchip,
++      PCIE_ATR_HDR_RID | (PCI_BUS(d) > (rockchip->first_busno  + 1) ? PCIE_ATR_HDR_CFG_TYPE1 : PCIE_ATR_HDR_CFG_TYPE0),
++      PCIE_CORE_OB_REGION_DESC0);
++    dsb();
++    rockchip_pcie_got_data_abort = 0;
++    rockchip_pcie_expect_data_abort = 1;
+ 
+       if (size == 4) {
+         *val = readl(rockchip->axi_base + busdev);
++            if (rockchip_pcie_got_data_abort) {
++                *val = 0xFFFFFFFFUL;
++            }
+       } else if (size == 2) {
+         *val = readw(rockchip->axi_base + busdev);
++            if (rockchip_pcie_got_data_abort) {
++                *val = 0xFFFF;
++            }
+     } else if (size == 1) {
+         *val = readb(rockchip->axi_base + busdev);
++            if (rockchip_pcie_got_data_abort) {
++                *val = 0xFF;
++            }
+     } else {
+         *val = 0;
+         return -1;
+     }
++    dsb();
++    rockchip_pcie_expect_data_abort = 0;
+     return 0;
+ }
+ 
+-static int rockchip_pcie_wr_other_conf(void *priv, int where, int size, u32 val)
++static int rockchip_pcie_wr_other_conf(void *priv, pci_dev_t d, int where, int size, u32 val)
+ {
+     struct pcie_rockchip *rockchip = (struct pcie_rockchip *)priv;
+     u32 busdev;
+ 
+-    /*
+-     * BDF = 01:00:00
+-     * end-to-end support, no hierarchy....
+-     */
+-    busdev = PCIE_ECAM_ADDR(1, 0, 0, where);
+-
++    busdev = PCIE_ECAM_ADDR(0, PCI_DEV(d), PCI_FUNC(d), where);
++    rockchip_pcie_write(rockchip,
++      (PCI_BUS(d) << 20) | RC_REGION_0_PASS_BITS,
++      PCIE_CORE_OB_REGION_ADDR0);
++    rockchip_pcie_write(rockchip,
++      PCIE_ATR_HDR_RID | (PCI_BUS(d) > (rockchip->first_busno  + 1) ? PCIE_ATR_HDR_CFG_TYPE1 : PCIE_ATR_HDR_CFG_TYPE0),
++      PCIE_CORE_OB_REGION_DESC0);
++    dsb();
+     if (size == 4)
+         writel(val, rockchip->axi_base + busdev);
+     else if (size == 2)
+@@ -403,7 +428,7 @@ static int rockchip_pcie_wr_other_conf(v
+         writeb(val, rockchip->axi_base + busdev);
+     else
+         return -1;
+-
++    dsb();
+     return 0;
+ }
+ 
+@@ -436,7 +461,7 @@ static int pcie_rockchip_read_config(str
+         if(ret < 0)
+             return ret;
+       } else {
+-        ret = rockchip_pcie_rd_other_conf(pcie, offset, size1, (u32 *)valuep);
++        ret = rockchip_pcie_rd_other_conf(pcie, bdf, offset, size1, (u32 *)valuep);
+         if(ret < 0)
+                       return ret;
+       }
+@@ -470,7 +495,7 @@ static int pcie_rockchip_write_config(st
+         if(ret < 0)
+             return ret;
+       } else {
+-        ret = rockchip_pcie_wr_other_conf(pcie, offset, size1, value);
++        ret = rockchip_pcie_wr_other_conf(pcie, bdf, offset, size1, value);
+         if(ret < 0)
+             return ret;
+       }
+@@ -496,8 +521,9 @@ static int config_link(struct udevice *d
+       u64 msix_table_addr = 0x0;
+       bool is_msi = false, is_msix = false;
+       u32 cmd;
++      pci_dev_t odev = PCI_BUS(rockchip->first_busno + 1) | PCI_DEV(0) | PCI_FUNC(0);
+ 
+-      rockchip_pcie_rd_other_conf((void *)rockchip, PCI_CLASS_REVISION, 4, &value);
++      rockchip_pcie_rd_other_conf((void *)rockchip, odev, PCI_CLASS_REVISION, 4, &value);
+       if ((value & (0xffff << 16)) !=
+         (PCI_CLASS_MSC | PCI_SUBCLASS_NVME)) {
+         debug("PCIe: device's classe code & revision ID = 0x%x\n",
+@@ -506,8 +532,8 @@ static int config_link(struct udevice *d
+         return -EINVAL;
+     }
+ 
+-    rockchip_pcie_rd_other_conf((void *)rockchip, PCI_VENDOR_ID, 2, &value);
+-    rockchip_pcie_rd_other_conf((void *)rockchip, PCI_DEVICE_ID, 2, &value);
++    rockchip_pcie_rd_other_conf((void *)rockchip, odev, PCI_VENDOR_ID, 2, &value);
++    rockchip_pcie_rd_other_conf((void *)rockchip, odev, PCI_DEVICE_ID, 2, &value);
+ 
+     rockchip_pcie_wr_own_conf((void *)rockchip, PCI_PRIMARY_BUS, 4, 0x0);
+     rockchip_pcie_wr_own_conf((void *)rockchip, PCI_BRIDGE_CONTROL, 2, 0x0);
+@@ -516,7 +542,7 @@ static int config_link(struct udevice *d
+     /* only support 64bit non-prefetchable 16k mem region: BAR0 + BAR1
+      * clear BAR1 for upper 32bit, no need to wr all 1s to see the size
+      */
+-    rockchip_pcie_wr_other_conf((void *)rockchip, PCI_BASE_ADDRESS_1, 4, 0x0);
++    rockchip_pcie_wr_other_conf((void *)rockchip, odev, PCI_BASE_ADDRESS_1, 4, 0x0);
+ 
+     /* clear CCC and enable retrain link */
+     rockchip_pcie_rd_own_conf((void *)rockchip, PCI_LNKCTL, 2, &value);
+@@ -542,22 +568,22 @@ static int config_link(struct udevice *d
+     /* clear some enable bits for error */
+     rockchip_pcie_wr_own_conf((void *)rockchip, PCI_BRIDGE_CONTROL, 2, 0x0);
+     /* write EP's command register, disable EP */
+-    rockchip_pcie_wr_other_conf((void *)rockchip, PCI_COMMAND, 2, 0x0);
++    rockchip_pcie_wr_other_conf((void *)rockchip, odev, PCI_COMMAND, 2, 0x0);
+ 
+       for (i = 0; i < rockchip->bus.region_count; i++) {
+         if (rockchip->bus.regions[i].flags == PCI_REGION_MEM) {
+             /* configre BAR0 */
+-                      rockchip_pcie_wr_other_conf((void *)rockchip, PCI_BASE_ADDRESS_0, 4,
++            rockchip_pcie_wr_other_conf((void *)rockchip, odev, PCI_BASE_ADDRESS_0, 4,
+                                         rockchip->bus.regions[i].bus_start);
+             /* configre BAR1 */
+-            rockchip_pcie_wr_other_conf((void *)rockchip, PCI_BASE_ADDRESS_1,
++            rockchip_pcie_wr_other_conf((void *)rockchip, odev, PCI_BASE_ADDRESS_1,
+                                   4, 0x0);
+             break;
+         }
+     }
+ 
+       /* write EP's command register */
+-    rockchip_pcie_wr_other_conf((void *)rockchip, PCI_COMMAND, 2, 0x0);
++    rockchip_pcie_wr_other_conf((void *)rockchip, odev, PCI_COMMAND, 2, 0x0);
+ 
+     /* write RC's IO base and limit including upper */
+     rockchip_pcie_wr_own_conf((void *)rockchip, PCI_IO_BASE_UPPER16, 4, 0xffff);
+@@ -583,11 +609,11 @@ static int config_link(struct udevice *d
+     rockchip_pcie_wr_own_conf((void *)rockchip, 0x104, 4, 0x0);
+ 
+     value = 0;
+-    rockchip_pcie_rd_other_conf((void *)rockchip, 0x34, 1, &pointer);
++    rockchip_pcie_rd_other_conf((void *)rockchip, odev, 0x34, 1, &pointer);
+     debug("PCIe: cap pointer = 0x%x\n", pointer);
+ 
+     for (;;) {
+-        rockchip_pcie_rd_other_conf((void *)rockchip, pointer, 2, &next_pointer);
++        rockchip_pcie_rd_other_conf((void *)rockchip, odev, pointer, 2, &next_pointer);
+         if ((next_pointer & 0xff) == PCI_CAP_ID_MSI) {
+             is_msi = true;
+             break;
+@@ -602,18 +628,18 @@ static int config_link(struct udevice *d
+     }
+     if (is_msi) {
+         debug("PCIe: msi cap pointer = 0x%x\n", pointer);
+-        rockchip_pcie_rd_other_conf((void *)rockchip, pointer + 2, 2, &value);
++        rockchip_pcie_rd_other_conf((void *)rockchip, odev, pointer + 2, 2, &value);
+         value |= 0x1;
+-        rockchip_pcie_wr_other_conf((void *)rockchip, pointer + 2, 2, value);
+-        rockchip_pcie_wr_other_conf((void *)rockchip, pointer + 4, 4,
++        rockchip_pcie_wr_other_conf((void *)rockchip, odev, pointer + 2, 2, value);
++        rockchip_pcie_wr_other_conf((void *)rockchip, odev, pointer + 4, 4,
+                               rockchip->bus.msi_base);
+-        rockchip_pcie_wr_other_conf((void *)rockchip, pointer + 8, 4, 0x0);
++        rockchip_pcie_wr_other_conf((void *)rockchip, odev, pointer + 8, 4, 0x0);
+     } else if (is_msix) {
+         debug("PCIe: msi-x cap pointer = 0x%x\n", pointer);
+-        rockchip_pcie_rd_other_conf((void *)rockchip, pointer + 2, 2, &value);
++        rockchip_pcie_rd_other_conf((void *)rockchip, odev, pointer + 2, 2, &value);
+         debug("PCIe: msi-x table size = %d\n", value & 0x7ff);
+         table_size = value & 0x7ff;
+-        rockchip_pcie_rd_other_conf((void *)rockchip, pointer + 8, 2, &value);
++        rockchip_pcie_rd_other_conf((void *)rockchip, odev, pointer + 8, 2, &value);
+         debug("PCIe: msi-x BIR = 0x%x\n", value & 0x7);
+         debug("PCIe: msi-x table offset = 0x%x\n", value & 0xfffffff8);
+ 
+@@ -634,20 +660,20 @@ static int config_link(struct udevice *d
+             writel(i,         msix_table_addr + i * 0x8);
+             writel(0x0,               msix_table_addr + i * 0xc);



Home | Main Index | Thread Index | Old Index