aspeed-g6: move patches from internal repo
So that patches shared between NPIs can be reused if they share the same
Aspeed CPU.
Google-Bug-Id: 259299803
Signed-off-by: Nan Zhou <nanzhou@google.com>
Change-Id: Id4824b46082f6ef0e407697e75c6b8cd12b0a6a0
diff --git a/recipes-kernel/linux/files/0001-net-ftgmac100-Support-for-fixed-PHYs.patch b/recipes-kernel/linux/files/0001-net-ftgmac100-Support-for-fixed-PHYs.patch
new file mode 100644
index 0000000..1ce5a53
--- /dev/null
+++ b/recipes-kernel/linux/files/0001-net-ftgmac100-Support-for-fixed-PHYs.patch
@@ -0,0 +1,120 @@
+From efd1628a922224349e7849fbc11c6f3655fb75dd Mon Sep 17 00:00:00 2001
+From: Tom Tung <tomtung@google.com>
+Date: Sun, 17 Apr 2022 15:15:17 +0800
+Subject: [PATCH] net: ftgmac100: Support for fixed PHYs
+
+Port https://lore.kernel.org/all/20210327004920.388957-1-wak@google.com/
+to linux code for Aspeed.
+
+I will upstream this and keep this as a temporary solution for Aspeed-g6
+once it passes the internal review.
+
+Tested:
+With dts change: go/fbmcl/9074.
+The testing gBMC has been up for more than 14 hours and the free memory
+still has 7xxxxx bytes.
+
+Also, we can ssh to ${MACHINE}-nfd01 after applying this change.
+
+Patch Tracking Bug: b/233663692
+Upstream info / review: N/A, but will update a patch to upstream for
+review soon.
+Upstream-Status: Pending [Haven't submitted patch to upstream yet]
+Justification: The plan is to get internal review and then update it to
+upstream for another review.
+
+Signed-off-by: Tom Tung <tomtung@google.com>
+Change-Id: Ia238a5c67e9d8f557ec9402655f01969652569fd
+---
+ drivers/net/ethernet/faraday/ftgmac100.c | 45 +++++++++++++++++++-----
+ 1 file changed, 37 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
+index c96d4bf4d5e3..a0648635cc99 100644
+--- a/drivers/net/ethernet/faraday/ftgmac100.c
++++ b/drivers/net/ethernet/faraday/ftgmac100.c
+@@ -86,6 +86,7 @@ struct ftgmac100 {
+ struct ncsi_dev *ndev;
+ struct napi_struct napi;
+ struct work_struct reset_task;
++ struct device_node *phy_dn;
+ struct mii_bus *mii_bus;
+ struct clk *clk;
+
+@@ -1882,16 +1883,36 @@ static int ftgmac100_probe(struct platform_device *pdev)
+ * PHYs.
+ */
+ priv->use_ncsi = false;
+- err = ftgmac100_setup_mdio(netdev);
+- if (err)
+- goto err_setup_mdio;
+
+- err = ftgmac100_mii_probe(netdev);
+- if (err) {
+- dev_err(priv->dev, "MII probe failed!\n");
+- goto err_ncsi_dev;
+- }
++ if (of_phy_is_fixed_link(np)) {
++ err = of_phy_register_fixed_link(np);
++ if (err)
++ goto err_setup_mdio;
+
++ priv->phy_dn = of_node_get(np);
++ if (priv->phy_dn && priv->netdev) {
++ priv->netdev->phydev =
++ of_phy_connect(netdev, priv->phy_dn,
++ &ftgmac100_adjust_link,
++ 0, 0);
++ if (!priv->phy_dn) {
++ dev_err(&pdev->dev,
++ "could not connect to phy %pOF\n",
++ priv->phy_dn);
++ return -ENODEV;
++ }
++ }
++ } else {
++ err = ftgmac100_setup_mdio(netdev);
++ if (err)
++ goto err_setup_mdio;
++
++ err = ftgmac100_mii_probe(netdev);
++ if (err) {
++ dev_err(priv->dev, "MII probe failed!\n");
++ goto err_ncsi_dev;
++ }
++ }
+ }
+
+ if (priv->is_aspeed) {
+@@ -1945,6 +1966,9 @@ static int ftgmac100_probe(struct platform_device *pdev)
+ ncsi_unregister_dev(priv->ndev);
+ ftgmac100_destroy_mdio(netdev);
+ err_setup_mdio:
++ of_node_put(priv->phy_dn);
++ if (of_phy_is_fixed_link(np))
++ of_phy_deregister_fixed_link(np);
+ iounmap(priv->base);
+ err_ioremap:
+ release_resource(priv->res);
+@@ -1958,6 +1982,7 @@ static int ftgmac100_remove(struct platform_device *pdev)
+ {
+ struct net_device *netdev;
+ struct ftgmac100 *priv;
++ struct device_node *np = pdev->dev.of_node;
+
+ netdev = platform_get_drvdata(pdev);
+ priv = netdev_priv(netdev);
+@@ -1966,6 +1991,10 @@ static int ftgmac100_remove(struct platform_device *pdev)
+ ncsi_unregister_dev(priv->ndev);
+ unregister_netdev(netdev);
+
++ of_node_put(priv->phy_dn);
++ if (of_phy_is_fixed_link(np))
++ of_phy_deregister_fixed_link(np);
++
+ clk_disable_unprepare(priv->rclk);
+ clk_disable_unprepare(priv->clk);
+
+--
+2.36.1.124.g0e6072fb45-goog
+
diff --git a/recipes-kernel/linux/files/0002-kernel-Ensure-only-3-byte-read-command-can-be-sent.patch b/recipes-kernel/linux/files/0002-kernel-Ensure-only-3-byte-read-command-can-be-sent.patch
new file mode 100644
index 0000000..b4cdac9
--- /dev/null
+++ b/recipes-kernel/linux/files/0002-kernel-Ensure-only-3-byte-read-command-can-be-sent.patch
@@ -0,0 +1,48 @@
+From a75a1ed032e1bf2adc6691ab8d9e043281a6126e Mon Sep 17 00:00:00 2001
+From: Tom Tung <tomtung@google.com>
+Date: Tue, 8 Feb 2022 16:57:04 +0800
+Subject: [PATCH 2/2] kernel: Ensure only 3 byte read command can be sent
+
+Patch Tracking Bug: b/232026313
+Upstream info / review: N/A
+Upstream-Status: Inappropriate [configuration]
+Justification: This patch probably cannot be upstreamed since it
+makes BMC use 3-byte read command with 4-byte address.
+
+Aspeed-g6 needs this because Hoth doesn't support 4-byte read
+command and our flash chip supports 3-byte read command with
+4-byte addresses.
+
+Signed-off-by: Tom Tung <tomtung@google.com>
+---
+ drivers/mtd/spi-nor/controllers/aspeed-smc.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/mtd/spi-nor/controllers/aspeed-smc.c b/drivers/mtd/spi-nor/controllers/aspeed-smc.c
+index c421fad4b3f5..e62868d4ddce 100644
+--- a/drivers/mtd/spi-nor/controllers/aspeed-smc.c
++++ b/drivers/mtd/spi-nor/controllers/aspeed-smc.c
+@@ -853,6 +853,9 @@ static void aspeed_smc_chip_set_4b(struct aspeed_smc_chip *chip)
+ u32 reg;
+
+ reg = readl(controller->regs + CE_CONTROL_REG);
++ // Ensure the 4th bit of FMC04 is set to zero so that 3 byte read
++ // command will be sent.
++ reg &= 0xffffffef;
+ reg |= 1 << chip->cs;
+ writel(reg, controller->regs + CE_CONTROL_REG);
+ }
+@@ -1032,8 +1035,8 @@ static u32 aspeed_smc_default_read(struct aspeed_smc_chip *chip)
+ */
+ u32 ctl_mask = chip->controller->info == &spi_2400_info ?
+ CONTROL_IO_ADDRESS_4B : 0;
+- u8 cmd = chip->nor.addr_width == 4 ? SPINOR_OP_READ_4B :
+- SPINOR_OP_READ;
++ // Ensure sending out 3 byte read command.
++ u8 cmd = SPINOR_OP_READ;
+
+ /*
+ * Use the "read command" mode to customize the opcode. In
+--
+2.35.0.263.gb82422642f-goog
+
diff --git a/recipes-kernel/linux/linux-gbmc.inc b/recipes-kernel/linux/linux-gbmc.inc
index 3112e05..70ef3e1 100644
--- a/recipes-kernel/linux/linux-gbmc.inc
+++ b/recipes-kernel/linux/linux-gbmc.inc
@@ -15,3 +15,9 @@
SRC_URI += "file://defconfig"
SRC_URI:append:dev = " file://dev.cfg"
SRC_URI:append:npcm7xx = " file://npcm7xx.cfg"
+
+SRC_URI:append:aspeed-g6 = " \
+ file://0001-net-ftgmac100-Support-for-fixed-PHYs.patch \
+ file://0002-kernel-Ensure-only-3-byte-read-command-can-be-sent.patch \
+"
+