Introduce ICSSG based ethernet Driver
MD Danish Anwar
reviewerv7 cover Introduce ICSSG based ethernet Driver
The Programmable Real-time Unit and Industrial Communication Subsystem Gigabit (PRU_ICSSG) is a low-latency microcontroller subsystem in the TI SoCs. This subsystem is provided for the use cases like the implementation of custom peripheral interfaces, offloading of tasks from the other processor cores of the SoC, etc.
The subsystem includes many accelerators for data processing like multiplier and multiplier-accumulator. It also has peripherals like UART, MII/RGMII, MDIO, etc. Every ICSSG core includes two 32-bit load/store RISC CPU cores called PRUs.
The above features allow it to be used for implementing custom firmware based peripherals like ethernet.
This series adds the YAML documentation and the driver with basic EMAC support for TI AM654 Silicon Rev 2 SoC with the PRU_ICSSG Sub-system. running dual-EMAC firmware.
This currently supports basic EMAC with 1Gbps and 100Mbps link. 10M and half-duplex modes are not yet supported because they require the support of an IEP, which will be added later.
Advanced features like switch-dev and timestamping will be added later.
This series depends on a patch series [1] which is yet to be merged. The seires
[1] is posted to SoC tree, has already been reviewed and is ready to be merged. Currently I am posting this series as RFC to get it reviewed. Once [1] is merged, this series can also be merged.
This is the v7 of the patch series [v1]. This version of the patchset addresses the comments made on [v6] of the series.
Changes from v6 to v7 :
*) Added RB tag of Rob in patch 1 of this series. *) Addressed Simon's comment on patch 2 of the series. *) Rebased patchset on next-20230428 linux-next.
Changes from v5 to v6 :
*) Added RB tag of Andrew Lunn in patch 2 of this series. *) Addressed Rob's comment on patch 1 of the series. *) Rebased patchset on next-20230421 linux-next.
Changes from v4 to v5 :
*) Re-arranged properties section in ti,icssg-prueth.yaml file. *) Added requirement for minimum one ethernet port.
*) Fixed some minor formatting errors as asked by Krzysztof. *) Dropped SGMII mode from enum mii_mode as SGMII mode is not currently
supported by the driver.
*) Added switch-case block to handle different phy modes by ICSSG driver.
Changes from v3 to v4 :
*) Addressed Krzysztof's comments and fixed dt_binding_check errors in
patch 1/2.
*) Added interrupt-extended property in ethernet-ports properties section. *) Fixed comments in file icssg_switch_map.h according to the Linux coding
style in patch 2/2. Added Documentation of structures in patch 2/2.
Changes from v2 to v3 :
*) Addressed Rob and Krzysztof's comments on patch 1 of this series.
Fixed indentation. Removed description and pinctrl section from ti,icssg-prueth.yaml file.
*) Addressed Krzysztof, Paolo, Randy, Andrew and Christophe's comments on
patch 2 of this seires.
*) Fixed blanklines in Kconfig and Makefile. Changed structures to const
as suggested by Krzysztof.
*) Fixed while loop logic in emac_tx_complete_packets() API as suggested
by Paolo. Previously in the loop's last iteration 'budget' was 0 and napi_consume_skb would wrongly assume the caller is not in NAPI context Now, budget won't be zero in last iteration of loop.
*) Removed inline functions addr_to_da1() and addr_to_da0() as asked by
Andrew.
*) Added dev_err_probe() instead of dev_err() as suggested by Christophe. *) In ti,icssg-prueth.yaml file, in the patternProperties section of
ethernet-ports, kept the port name as "port" instead of "ethernet-port" as all other drivers were using "port". Will change it if is compulsory to use "ethernet-port".
[1] https://lore.kernel.org/all/[email protected]/
[v1] https://lore.kernel.org/all/[email protected]/
[v2] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/all/[email protected]/
[v4] https://lore.kernel.org/all/[email protected]/
[v5] https://lore.kernel.org/all/[email protected]/
[v6] https://lore.kernel.org/all/[email protected]/
Thanks and Regards,
Md Danish Anwar
MD Danish Anwar (1):
dt-bindings: net: Add ICSSG Ethernet
Roger Quadros (1):
net: ti: icssg-prueth: Add ICSSG ethernet driver
.../bindings/net/ti,icssg-prueth.yaml | 184 ++ drivers/net/ethernet/ti/Kconfig | 13 + drivers/net/ethernet/ti/Makefile | 2 + drivers/net/ethernet/ti/icssg_classifier.c | 369 ++++ drivers/net/ethernet/ti/icssg_config.c | 449 ++++ drivers/net/ethernet/ti/icssg_config.h | 200 ++ drivers/net/ethernet/ti/icssg_ethtool.c | 326 +++ drivers/net/ethernet/ti/icssg_mii_cfg.c | 104 + drivers/net/ethernet/ti/icssg_mii_rt.h | 150 ++ drivers/net/ethernet/ti/icssg_prueth.c | 1866 +++++++++++++++++ drivers/net/ethernet/ti/icssg_prueth.h | 248 +++ drivers/net/ethernet/ti/icssg_switch_map.h | 234 +++ 12 files changed, 4145 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml create mode 100644 drivers/net/ethernet/ti/icssg_classifier.c create mode 100644 drivers/net/ethernet/ti/icssg_config.c create mode 100644 drivers/net/ethernet/ti/icssg_config.h create mode 100644 drivers/net/ethernet/ti/icssg_ethtool.c create mode 100644 drivers/net/ethernet/ti/icssg_mii_cfg.c create mode 100644 drivers/net/ethernet/ti/icssg_mii_rt.h create mode 100644 drivers/net/ethernet/ti/icssg_prueth.c create mode 100644 drivers/net/ethernet/ti/icssg_prueth.h create mode 100644 drivers/net/ethernet/ti/icssg_switch_map.h
Signature · 1 line
2.34.1
MD Danish Anwar
reviewerRFC PATCH v7 1/2 dt-bindings: net: Add ICSSG Ethernet
Add a YAML binding document for the ICSSG Programmable real time unit based Ethernet hardware. The ICSSG driver uses the PRU and PRUSS consumer APIs to interface the PRUs and load/run the firmware for supporting ethernet functionality.
--- .../bindings/net/ti,icssg-prueth.yaml | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml
Documentation/devicetree/bindings/net/ti,icssg-prueth.yaml new file +184 -0
@@ -0,0 +1,184 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/ti,icssg-prueth.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ICSSG PRUSS Ethernet + +maintainers: + - Md Danish Anwar <[email protected]> + +description: + Ethernet based on the Programmable Real-Time Unit and Industrial + Communication Subsystem. + +allOf: + - $ref: /schemas/remoteproc/ti,pru-consumer.yaml# + +properties: + compatible: + enum: + - ti,am654-icssg-prueth # for AM65x SoC family + + sram: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to MSMC SRAM node + + dmas: + maxItems: 10 + + dma-names: + items: + - const: tx0-0 + - const: tx0-1 + - const: tx0-2 + - const: tx0-3 + - const: tx1-0 + - const: tx1-1 + - const: tx1-2 + - const: tx1-3 + - const: rx0 + - const: rx1 + + ti,mii-g-rt: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to MII_G_RT module's syscon regmap. + + ti,mii-rt: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to MII_RT module's syscon regmap + + interrupts: + maxItems: 2 + description: + Interrupt specifiers to TX timestamp IRQ. + + interrupt-names: + items: + - const: tx_ts0 + - const: tx_ts1 + + ethernet-ports: + type: object + additionalProperties: false + + properties: + '#address-cells': + const: 1 + '#size-cells': + const: 0 + + patternProperties: + ^port@[0-1]$: + type: object + description: ICSSG PRUETH external ports + $ref: ethernet-controller.yaml# + unevaluatedProperties: false + + properties: + reg: + items: + - enum: [0, 1] + description: ICSSG PRUETH port number + + interrupts: + maxItems: 1 + + ti,syscon-rgmii-delay: + items: + - items: + - description: phandle to system controller node + - description: The offset to ICSSG control register + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + phandle to system controller node and register offset + to ICSSG control register for RGMII transmit delay + + required: + - reg + anyOf: + - required: + - port@0 + - required: + - port@1 + +required: + - compatible + - sram + - dmas + - dma-names + - ethernet-ports + - ti,mii-g-rt + - interrupts + - interrupt-names + +unevaluatedProperties: false + +examples: + - | + /* Example k3-am654 base board SR2.0, dual-emac */ + pruss2_eth: ethernet { + compatible = "ti,am654-icssg-prueth"; + pinctrl-names = "default"; + pinctrl-0 = <&icssg2_rgmii_pins_default>; + sram = <&msmc_ram>; + + ti,prus = <&pru2_0>, <&rtu2_0>, <&tx_pru2_0>, + <&pru2_1>, <&rtu2_1>, <&tx_pru2_1>; + firmware-name = "ti-pruss/am65x-pru0-prueth-fw.elf", + "ti-pruss/am65x-rtu0-prueth-fw.elf", + "ti-pruss/am65x-txpru0-prueth-fw.elf", + "ti-pruss/am65x-pru1-prueth-fw.elf", + "ti-pruss/am65x-rtu1-prueth-fw.elf", + "ti-pruss/am65x-txpru1-prueth-fw.elf"; + ti,pruss-gp-mux-sel = <2>, /* MII mode */ + <2>, + <2>, + <2>, /* MII mode */ + <2>, + <2>; + dmas = <&main_udmap 0xc300>, /* egress slice 0 */ + <&main_udmap 0xc301>, /* egress slice 0 */ + <&main_udmap 0xc302>, /* egress slice 0 */ + <&main_udmap 0xc303>, /* egress slice 0 */ + <&main_udmap 0xc304>, /* egress slice 1 */ + <&main_udmap 0xc305>, /* egress slice 1 */ + <&main_udmap 0xc306>, /* egress slice 1 */ + <&main_udmap 0xc307>, /* egress slice 1 */ + <&main_udmap 0x4300>, /* ingress slice 0 */ + <&main_udmap 0x4301>; /* ingress slice 1 */ + dma-names = "tx0-0", "tx0-1", "tx0-2", "tx0-3", + "tx1-0", "tx1-1", "tx1-2", "tx1-3", + "rx0", "rx1"; + ti,mii-g-rt = <&icssg2_mii_g_rt>; + interrupt-parent = <&icssg2_intc>; + interrupts = <24 0 2>, <25 1 3>; + interrupt-names = "tx_ts0", "tx_ts1"; + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + pruss2_emac0: port@0 { + reg = <0>; + phy-handle = <&pruss2_eth0_phy>; + phy-mode = "rgmii-id"; + interrupts-extended = <&icssg2_intc 24>; + ti,syscon-rgmii-delay = <&scm_conf 0x4120>; + /* Filled in by bootloader */ + local-mac-address = [00 00 00 00 00 00]; + }; + + pruss2_emac1: port@1 { + reg = <1>; + phy-handle = <&pruss2_eth1_phy>; + phy-mode = "rgmii-id"; + interrupts-extended = <&icssg2_intc 25>; + ti,syscon-rgmii-delay = <&scm_conf 0x4124>; + /* Filled in by bootloader */ + local-mac-address = [00 00 00 00 00 00]; + }; + }; + };
Signature · 1 line
2.34.1
MD Danish Anwar
reviewerRFC PATCH v7 2/2 net: ti: icssg-prueth: Add ICSSG ethernet driver
In reply to MD Danish AnwarFrom: Roger Quadros <[email protected]>
This is the Ethernet driver for TI AM654 Silicon rev. 2 with the ICSSG PRU Sub-system running dual-EMAC firmware.
The Programmable Real-time Unit and Industrial Communication Subsystem Gigabit (PRU_ICSSG) is a low-latency microcontroller subsystem in the TI SoCs. This subsystem is provided for the use cases like implementation of custom peripheral interfaces, offloading of tasks from the other processor cores of the SoC, etc.
Every ICSSG core has two Programmable Real-Time Unit(PRUs), two auxiliary Real-Time Transfer Unit (RT_PRUs), and
two Transmit Real-Time Transfer Units (TX_PRUs). Each one of these runs its own firmware. Every ICSSG core has two MII ports connect to these PRUs and also a MDIO port.
The cores can run different firmwares to support different protocols and features like switch-dev, timestamping, etc.
It uses System DMA to transfer and receive packets and shared memory register emulation between the firmware and driver for control and configuration.
This patch adds support for basic EMAC functionality with 1Gbps and 100Mbps link speed. 10M and half duplex mode are not supported currently as they require IEP, the support for which will be added later. Support for switch-dev, timestamp, etc. will be added later by subsequent patch series.
--- drivers/net/ethernet/ti/Kconfig | 13 + drivers/net/ethernet/ti/Makefile | 2 + drivers/net/ethernet/ti/icssg_classifier.c | 369 ++++ drivers/net/ethernet/ti/icssg_config.c | 449 +++++ drivers/net/ethernet/ti/icssg_config.h | 200 +++ drivers/net/ethernet/ti/icssg_ethtool.c | 326 ++++ drivers/net/ethernet/ti/icssg_mii_cfg.c | 104 ++ drivers/net/ethernet/ti/icssg_mii_rt.h | 150 ++ drivers/net/ethernet/ti/icssg_prueth.c | 1866 ++++++++++++++++++++ drivers/net/ethernet/ti/icssg_prueth.h | 248 +++ drivers/net/ethernet/ti/icssg_switch_map.h | 234 +++ 11 files changed, 3961 insertions(+) create mode 100644 drivers/net/ethernet/ti/icssg_classifier.c create mode 100644 drivers/net/ethernet/ti/icssg_config.c create mode 100644 drivers/net/ethernet/ti/icssg_config.h create mode 100644 drivers/net/ethernet/ti/icssg_ethtool.c create mode 100644 drivers/net/ethernet/ti/icssg_mii_cfg.c create mode 100644 drivers/net/ethernet/ti/icssg_mii_rt.h create mode 100644 drivers/net/ethernet/ti/icssg_prueth.c create mode 100644 drivers/net/ethernet/ti/icssg_prueth.h create mode 100644 drivers/net/ethernet/ti/icssg_switch_map.h
drivers/net/ethernet/ti/Kconfig +13 -0
@@ -183,4 +183,17 @@ config CPMAC help TI AR7 CPMAC Ethernet support +config TI_ICSSG_PRUETH + tristate "TI Gigabit PRU Ethernet driver" + select PHYLIB + depends on PRU_REMOTEPROC + depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER + help + Support dual Gigabit Ethernet ports over the ICSSG PRU Subsystem. + This subsystem is available starting with the AM65 platform. + + This driver requires firmware binaries which will run on the PRUs + to support the Ethernet operation. Currently, it supports Ethernet + with 1G and 100M link speed. + endif # NET_VENDOR_TI
drivers/net/ethernet/ti/Makefile +2 -0
@@ -28,3 +28,5 @@ obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o k3-cppi-desc-pool.o am65-cpsw-qos.o ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += am65-cpsw-switchdev.o obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o +obj-$(CONFIG_TI_ICSSG_PRUETH) += icssg-prueth.o +icssg-prueth-y := icssg_prueth.o icssg_classifier.o icssg_ethtool.o icssg_config.o k3-cppi-desc-pool.o icssg_mii_cfg.o
drivers/net/ethernet/ti/icssg_classifier.c new file +369 -0
369 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_config.c new file +449 -0
449 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_config.h new file +200 -0
200 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_ethtool.c new file +326 -0
326 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_mii_cfg.c new file +104 -0
104 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_mii_rt.h new file +150 -0
150 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_prueth.c new file +1866 -0
1,380 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_prueth.h new file +248 -0
248 lines not on this page · raw message
drivers/net/ethernet/ti/icssg_switch_map.h new file +234 -0
234 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
kernel test robot
build botRe: [RFC PATCH v7 2/2] net: ti: icssg-prueth: Add ICSSG ethernet driver
kernel test robot noticed the following build errors:
Hi MD,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on robh/for-next]
[also build test ERROR on krzk-dt/for-next linus/master v6.4-rc2 next-20230515] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/MD-Danish-Anwar/dt-bindings-net-Add-ICSSG-Ethernet/20230502-141903 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20230502061650.2716736-3-danishanwar%40ti.com patch subject: [RFC PATCH v7 2/2] net: ti: icssg-prueth: Add ICSSG ethernet driver config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230516/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/a262c00285104f1bc48e47b0b3df0d2f43c7f353
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review MD-Danish-Anwar/dt-bindings-net-Add-ICSSG-Ethernet/20230502-141903 git checkout a262c00285104f1bc48e47b0b3df0d2f43c7f353
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
drivers/net/ethernet/ti/icssg_prueth.c: In function 'prueth_netdev_init':
>> drivers/net/ethernet/ti/icssg_prueth.c:1327:15: error: implicit declaration of function 'pruss_request_mem_region'; did you mean 'devm_request_mem_region'? [-Werror=implicit-function-declaration]
1327 | ret = pruss_request_mem_region(prueth->pruss,
| ^~~~~~~~~~~~~~~~~~~~~~~~
| devm_request_mem_region
>> drivers/net/ethernet/ti/icssg_prueth.c:1412:9: error: implicit declaration of function 'pruss_release_mem_region'; did you mean 'devm_release_mem_region'? [-Werror=implicit-function-declaration]
1412 | pruss_release_mem_region(prueth->pruss, &emac->dram);
| ^~~~~~~~~~~~~~~~~~~~~~~~
| devm_release_mem_region
drivers/net/ethernet/ti/icssg_prueth.c: In function 'prueth_probe':
>> drivers/net/ethernet/ti/icssg_prueth.c:1603:17: error: implicit declaration of function 'pruss_get'; did you mean 'css_get'? [-Werror=implicit-function-declaration]
1603 | pruss = pruss_get(eth0_node ?
| ^~~~~~~~~
| css_get
drivers/net/ethernet/ti/icssg_prueth.c:1603:15: warning: assignment to 'struct pruss *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
1603 | pruss = pruss_get(eth0_node ?
| ^
>> drivers/net/ethernet/ti/icssg_prueth.c:1617:17: error: implicit declaration of function 'pruss_put'; did you mean 'css_put'? [-Werror=implicit-function-declaration]
1617 | pruss_put(prueth->pruss);
| ^~~~~~~~~
| css_put
cc1: some warnings being treated as errors
--
drivers/net/ethernet/ti/icssg_config.c: In function 'icssg_config':
>> drivers/net/ethernet/ti/icssg_config.c:348:9: error: implicit declaration of function 'pruss_cfg_gpimode' [-Werror=implicit-function-declaration]
348 | pruss_cfg_gpimode(prueth->pruss, prueth->pru_id[slice],
| ^~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/ti/icssg_config.c:349:27: error: 'PRUSS_GPI_MODE_MII' undeclared (first use in this function)
349 | PRUSS_GPI_MODE_MII);
| ^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/ti/icssg_config.c:349:27: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/net/ethernet/ti/icssg_config.c:352:9: error: implicit declaration of function 'pruss_cfg_xfr_enable' [-Werror=implicit-function-declaration]
352 | pruss_cfg_xfr_enable(prueth->pruss, PRU_TYPE_PRU, true);
| ^~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/ti/icssg_config.c:352:45: error: 'PRU_TYPE_PRU' undeclared (first use in this function); did you mean 'IRQ_TYPE_PROBE'?
352 | pruss_cfg_xfr_enable(prueth->pruss, PRU_TYPE_PRU, true);
| ^~~~~~~~~~~~
| IRQ_TYPE_PROBE
drivers/net/ethernet/ti/icssg_config.c:353:45: error: 'PRU_TYPE_RTU' undeclared (first use in this function)
353 | pruss_cfg_xfr_enable(prueth->pruss, PRU_TYPE_RTU, true);
| ^~~~~~~~~~~~cc1: some warnings being treated as errors
vim +1327 drivers/net/ethernet/ti/icssg_prueth.c
1293
1294 static int prueth_netdev_init(struct prueth *prueth,
1295 struct device_node *eth_node)
1296 {
1297 int ret, num_tx_chn = PRUETH_MAX_TX_QUEUES;
1298 struct prueth_emac *emac;
1299 struct net_device *ndev;
1300 enum prueth_port port;
1301 enum prueth_mac mac;
1302
1303 port = prueth_node_port(eth_node);
1304 if (port < 0)
1305 return -EINVAL;
1306
1307 mac = prueth_node_mac(eth_node);
1308 if (mac < 0)
1309 return -EINVAL;
1310
1311 ndev = alloc_etherdev_mq(sizeof(*emac), num_tx_chn);
1312 if (!ndev)
1313 return -ENOMEM;
1314
1315 emac = netdev_priv(ndev);
1316 prueth->emac[mac] = emac;
1317 emac->prueth = prueth;
1318 emac->ndev = ndev;
1319 emac->port_id = port;
1320 emac->cmd_wq = create_singlethread_workqueue("icssg_cmd_wq");
1321 if (!emac->cmd_wq) {
1322 ret = -ENOMEM;
1323 goto free_ndev;
1324 }
1325 INIT_WORK(&emac->rx_mode_work, emac_ndo_set_rx_mode_work);
1326
> 1327 ret = pruss_request_mem_region(prueth->pruss,
1328 port == PRUETH_PORT_MII0 ?
1329 PRUSS_MEM_DRAM0 : PRUSS_MEM_DRAM1,
1330 &emac->dram);
1331 if (ret) {
1332 dev_err(prueth->dev, "unable to get DRAM: %d\n", ret);
1333 ret = -ENOMEM;
1334 goto free_wq;
1335 }
1336
1337 emac->tx_ch_num = 1;
1338
1339 SET_NETDEV_DEV(ndev, prueth->dev);
1340 spin_lock_init(&emac->lock);
1341 mutex_init(&emac->cmd_lock);
1342
1343 emac->phy_node = of_parse_phandle(eth_node, "phy-handle", 0);
1344 if (!emac->phy_node && !of_phy_is_fixed_link(eth_node)) {
1345 dev_err(prueth->dev, "couldn't find phy-handle\n");
1346 ret = -ENODEV;
1347 goto free;
1348 } else if (of_phy_is_fixed_link(eth_node)) {
1349 ret = of_phy_register_fixed_link(eth_node);
1350 if (ret) {
1351 ret = dev_err_probe(prueth->dev, ret,
1352 "failed to register fixed-link phy\n");
1353 goto free;
1354 }
1355
1356 emac->phy_node = eth_node;
1357 }
1358
1359 ret = of_get_phy_mode(eth_node, &emac->phy_if);
1360 if (ret) {
1361 dev_err(prueth->dev, "could not get phy-mode property\n");
1362 goto free;
1363 }
1364
1365 if (emac->phy_if != PHY_INTERFACE_MODE_MII &&
1366 !phy_interface_mode_is_rgmii(emac->phy_if)) {
1367 dev_err(prueth->dev, "PHY mode unsupported %s\n", phy_modes(emac->phy_if));
1368 ret = -EINVAL;
1369 goto free;
1370 }
1371
1372 /* AM65 SR2.0 has TX Internal delay always enabled by hardware
1373 * and it is not possible to disable TX Internal delay. The below
1374 * switch case block describes how we handle different phy modes
1375 * based on hardware restriction.
1376 */
1377 switch (emac->phy_if) {
1378 case PHY_INTERFACE_MODE_RGMII_ID:
1379 emac->phy_if = PHY_INTERFACE_MODE_RGMII_RXID;
1380 break;
1381 case PHY_INTERFACE_MODE_RGMII_TXID:
1382 emac->phy_if = PHY_INTERFACE_MODE_RGMII;
1383 break;
1384 case PHY_INTERFACE_MODE_RGMII:
1385 case PHY_INTERFACE_MODE_RGMII_RXID:
1386 dev_err(prueth->dev, "RGMII mode without TX delay is not supported");
1387 return -EINVAL;
1388 default:
1389 break;
1390 }
1391
1392 /* get mac address from DT and set private and netdev addr */
1393 ret = of_get_ethdev_address(eth_node, ndev);
1394 if (!is_valid_ether_addr(ndev->dev_addr)) {
1395 eth_hw_addr_random(ndev);
1396 dev_warn(prueth->dev, "port %d: using random MAC addr: %pM\n",
1397 port, ndev->dev_addr);
1398 }
1399 ether_addr_copy(emac->mac_addr, ndev->dev_addr);
1400
1401 ndev->netdev_ops = &emac_netdev_ops;
1402 ndev->ethtool_ops = &icssg_ethtool_ops;
1403 ndev->hw_features = NETIF_F_SG;
1404 ndev->features = ndev->hw_features;
1405
1406 netif_napi_add(ndev, &emac->napi_rx,
1407 emac_napi_rx_poll);
1408
1409 return 0;
1410
1411 free:
> 1412 pruss_release_mem_region(prueth->pruss, &emac->dram); 1413 free_wq:
1414 destroy_workqueue(emac->cmd_wq);
1415 free_ndev:
1416 free_netdev(ndev);
1417 prueth->emac[mac] = NULL;
1418
1419 return ret;
1420 }
1421
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests