mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 07:22:33 +00:00
4070e2a64c
This target adds support for the StarFive JH7100 and JH7110 SoCs, based on 6.1, as well as a couple boards equipped with these. Specifications: SoCs: JH7100: - StarFive JH7100 dual-core RISC-V (U74, RC64GC) - additional monitoring (S7) and control (E24) cores - 2Mb L2 cache JH7110: - StarFive JH7110 quad-core RISC-V (U74, RV64GC) - additional monitoring (S7) and control (E24) cores - 2Mb L2 cache Boards: VisionFive1: - JH7100 @ 1GHz - Memory: 8Gb LPDDR4 - 4x USB3.0 - 1x GBit ethernet - AMPak 6236 wifi / bluetooth - audio - powered via USB-C VisionFive2: - JH7110 @ 1.5GHz - Memory: 2/4/8Gb DDR4 - 2x Gbit ethernet - 2x USB3.0 / 2x USB2.0 - eMMC / SDIO - various multimedia input/outputs (MIPI CSI, HDMI, audio) - M.2 key M slot - PoE support - powered via USB-C Installation: Standard SD-card installation via dd-ing the generated image to an SD-card of at least 256Mb. Signed-off-by: Zoltan HERPAI <wigyori@uid0.hu>
94 lines
2.8 KiB
Diff
94 lines
2.8 KiB
Diff
From 20886cd583e8d569d78ea0e723f98384a61ab54b Mon Sep 17 00:00:00 2001
|
|
From: Samin Guo <samin.guo@starfivetech.com>
|
|
Date: Thu, 2 Mar 2023 19:52:37 +0800
|
|
Subject: [PATCH 045/122] net: stmmac: dwmac-starfive: Add phy interface
|
|
settings
|
|
|
|
dwmac supports multiple modess. When working under rmii and rgmii,
|
|
you need to set different phy interfaces.
|
|
|
|
According to the dwmac document, when working in rmii, it needs to be
|
|
set to 0x4, and rgmii needs to be set to 0x1.
|
|
|
|
The phy interface needs to be set in syscon, the format is as follows:
|
|
starfive,syscon: <&syscon, offset, shift>
|
|
|
|
Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
|
|
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|
Signed-off-by: Samin Guo <samin.guo@starfivetech.com>
|
|
---
|
|
.../ethernet/stmicro/stmmac/dwmac-starfive.c | 48 +++++++++++++++++++
|
|
1 file changed, 48 insertions(+)
|
|
|
|
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
|
|
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
|
|
@@ -13,6 +13,10 @@
|
|
|
|
#include "stmmac_platform.h"
|
|
|
|
+#define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1
|
|
+#define STARFIVE_DWMAC_PHY_INFT_RMII 0x4
|
|
+#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U
|
|
+
|
|
struct starfive_dwmac {
|
|
struct device *dev;
|
|
struct clk *clk_tx;
|
|
@@ -46,6 +50,46 @@ static void starfive_dwmac_fix_mac_speed
|
|
dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
|
|
}
|
|
|
|
+static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat)
|
|
+{
|
|
+ struct starfive_dwmac *dwmac = plat_dat->bsp_priv;
|
|
+ struct regmap *regmap;
|
|
+ unsigned int args[2];
|
|
+ unsigned int mode;
|
|
+ int err;
|
|
+
|
|
+ switch (plat_dat->interface) {
|
|
+ case PHY_INTERFACE_MODE_RMII:
|
|
+ mode = STARFIVE_DWMAC_PHY_INFT_RMII;
|
|
+ break;
|
|
+
|
|
+ case PHY_INTERFACE_MODE_RGMII:
|
|
+ case PHY_INTERFACE_MODE_RGMII_ID:
|
|
+ mode = STARFIVE_DWMAC_PHY_INFT_RGMII;
|
|
+ break;
|
|
+
|
|
+ default:
|
|
+ dev_err(dwmac->dev, "unsupported interface %d\n",
|
|
+ plat_dat->interface);
|
|
+ return -EINVAL;
|
|
+ }
|
|
+
|
|
+ regmap = syscon_regmap_lookup_by_phandle_args(dwmac->dev->of_node,
|
|
+ "starfive,syscon",
|
|
+ 2, args);
|
|
+ if (IS_ERR(regmap))
|
|
+ return dev_err_probe(dwmac->dev, PTR_ERR(regmap), "getting the regmap failed\n");
|
|
+
|
|
+ /* args[0]:offset args[1]: shift */
|
|
+ err = regmap_update_bits(regmap, args[0],
|
|
+ STARFIVE_DWMAC_PHY_INFT_FIELD << args[1],
|
|
+ mode << args[1]);
|
|
+ if (err)
|
|
+ return dev_err_probe(dwmac->dev, err, "error setting phy mode\n");
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int starfive_dwmac_probe(struct platform_device *pdev)
|
|
{
|
|
struct plat_stmmacenet_data *plat_dat;
|
|
@@ -91,6 +135,10 @@ static int starfive_dwmac_probe(struct p
|
|
plat_dat->bsp_priv = dwmac;
|
|
plat_dat->dma_cfg->dche = true;
|
|
|
|
+ err = starfive_dwmac_set_mode(plat_dat);
|
|
+ if (err)
|
|
+ return err;
|
|
+
|
|
err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
|
|
if (err) {
|
|
stmmac_remove_config_dt(pdev, plat_dat);
|