Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'stmmac-jh7100'

Cristian Ciocaltea says:

====================
StarFive DWMAC support for JH7100

This is just a subset of the initial patch series [1] adding networking
support for StarFive JH7100 SoC.

[1]: https://lore.kernel.org/lkml/20231218214451.2345691-1-cristian.ciocaltea@collabora.com/

Changes in v4:
- Rebased series onto next-20240125
- Added R-b tag from Rob in PATCH 1
- v3:
https://lore.kernel.org/lkml/20231222101001.2541758-1-cristian.ciocaltea@collabora.com/

Changes in v3:
- Optimized jh7110 resets & reset-names properties (Rob)
- Added R-b tag from Jacob in PATCH 1
- v2:
https://lore.kernel.org/lkml/20231220002824.2462655-1-cristian.ciocaltea@collabora.com/

Changes in v2:
- Add the missing binding patch (Conor)
- v1:
https://lore.kernel.org/lkml/20231219231040.2459358-1-cristian.ciocaltea@collabora.com/
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+88 -33
+7 -4
Documentation/devicetree/bindings/net/snps,dwmac.yaml
··· 95 95 - snps,dwmac-5.20 96 96 - snps,dwxgmac 97 97 - snps,dwxgmac-2.10 98 + - starfive,jh7100-dwmac 98 99 - starfive,jh7110-dwmac 99 100 100 101 reg: ··· 145 144 - description: AHB reset 146 145 147 146 reset-names: 148 - minItems: 1 149 - items: 150 - - const: stmmaceth 151 - - const: ahb 147 + oneOf: 148 + - items: 149 + - enum: [stmmaceth, ahb] 150 + - items: 151 + - const: stmmaceth 152 + - const: ahb 152 153 153 154 power-domains: 154 155 maxItems: 1
+50 -22
Documentation/devicetree/bindings/net/starfive,jh7110-dwmac.yaml
··· 16 16 compatible: 17 17 contains: 18 18 enum: 19 + - starfive,jh7100-dwmac 19 20 - starfive,jh7110-dwmac 20 21 required: 21 22 - compatible 22 23 23 24 properties: 24 25 compatible: 25 - items: 26 - - enum: 27 - - starfive,jh7110-dwmac 28 - - const: snps,dwmac-5.20 26 + oneOf: 27 + - items: 28 + - const: starfive,jh7100-dwmac 29 + - const: snps,dwmac 30 + - items: 31 + - const: starfive,jh7110-dwmac 32 + - const: snps,dwmac-5.20 29 33 30 34 reg: 31 35 maxItems: 1 ··· 49 45 - const: ptp_ref 50 46 - const: tx 51 47 - const: gtx 52 - 53 - interrupts: 54 - minItems: 3 55 - maxItems: 3 56 - 57 - interrupt-names: 58 - minItems: 3 59 - maxItems: 3 60 - 61 - resets: 62 - items: 63 - - description: MAC Reset signal. 64 - - description: AHB Reset signal. 65 - 66 - reset-names: 67 - items: 68 - - const: stmmaceth 69 - - const: ahb 70 48 71 49 starfive,tx-use-rgmii-clk: 72 50 description: ··· 79 93 80 94 allOf: 81 95 - $ref: snps,dwmac.yaml# 96 + 97 + - if: 98 + properties: 99 + compatible: 100 + contains: 101 + const: starfive,jh7100-dwmac 102 + then: 103 + properties: 104 + interrupts: 105 + minItems: 2 106 + maxItems: 2 107 + 108 + interrupt-names: 109 + minItems: 2 110 + maxItems: 2 111 + 112 + resets: 113 + maxItems: 1 114 + 115 + reset-names: 116 + const: ahb 117 + 118 + - if: 119 + properties: 120 + compatible: 121 + contains: 122 + const: starfive,jh7110-dwmac 123 + then: 124 + properties: 125 + interrupts: 126 + minItems: 3 127 + maxItems: 3 128 + 129 + interrupt-names: 130 + minItems: 3 131 + maxItems: 3 132 + 133 + resets: 134 + minItems: 2 135 + 136 + reset-names: 137 + minItems: 2 82 138 83 139 unevaluatedProperties: false 84 140
+3 -3
drivers/net/ethernet/stmicro/stmmac/Kconfig
··· 165 165 help 166 166 Support for ethernet controllers on StarFive RISC-V SoCs 167 167 168 - This selects the StarFive platform specific glue layer support for 169 - the stmmac device driver. This driver is used for StarFive JH7110 170 - ethernet controller. 168 + This selects the StarFive platform specific glue layer support 169 + for the stmmac device driver. This driver is used for the 170 + StarFive JH7100 and JH7110 ethernet controllers. 171 171 172 172 config DWMAC_STI 173 173 tristate "STi GMAC support"
+28 -4
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
··· 15 15 16 16 #include "stmmac_platform.h" 17 17 18 - #define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 19 - #define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 20 - #define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U 18 + #define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 19 + #define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 20 + #define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U 21 + 22 + #define JH7100_SYSMAIN_REGISTER49_DLYCHAIN 0xc8 23 + 24 + struct starfive_dwmac_data { 25 + unsigned int gtxclk_dlychain; 26 + }; 21 27 22 28 struct starfive_dwmac { 23 29 struct device *dev; 24 30 struct clk *clk_tx; 31 + const struct starfive_dwmac_data *data; 25 32 }; 26 33 27 34 static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) ··· 74 67 75 68 case PHY_INTERFACE_MODE_RGMII: 76 69 case PHY_INTERFACE_MODE_RGMII_ID: 70 + case PHY_INTERFACE_MODE_RGMII_RXID: 71 + case PHY_INTERFACE_MODE_RGMII_TXID: 77 72 mode = STARFIVE_DWMAC_PHY_INFT_RGMII; 78 73 break; 79 74 ··· 97 88 mode << args[1]); 98 89 if (err) 99 90 return dev_err_probe(dwmac->dev, err, "error setting phy mode\n"); 91 + 92 + if (dwmac->data) { 93 + err = regmap_write(regmap, JH7100_SYSMAIN_REGISTER49_DLYCHAIN, 94 + dwmac->data->gtxclk_dlychain); 95 + if (err) 96 + return dev_err_probe(dwmac->dev, err, 97 + "error selecting gtxclk delay chain\n"); 98 + } 100 99 101 100 return 0; 102 101 } ··· 130 113 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); 131 114 if (!dwmac) 132 115 return -ENOMEM; 116 + 117 + dwmac->data = device_get_match_data(&pdev->dev); 133 118 134 119 dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx"); 135 120 if (IS_ERR(dwmac->clk_tx)) ··· 163 144 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); 164 145 } 165 146 147 + static const struct starfive_dwmac_data jh7100_data = { 148 + .gtxclk_dlychain = 4, 149 + }; 150 + 166 151 static const struct of_device_id starfive_dwmac_match[] = { 167 - { .compatible = "starfive,jh7110-dwmac" }, 152 + { .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data }, 153 + { .compatible = "starfive,jh7110-dwmac" }, 168 154 { /* sentinel */ } 169 155 }; 170 156 MODULE_DEVICE_TABLE(of, starfive_dwmac_match);