net: dsa: microchip: DSA Driver support for LAN937x
Subsystems (6)
v15 cover net: dsa: microchip: DSA Driver support for LAN937x
LAN937x is a Multi-Port 100BASE-T1 Ethernet Physical Layer switch compliant with the IEEE 802.3bw-2015 specification. The device provides 100 Mbit/s transmit and receive capability over a single Unshielded Twisted Pair (UTP) cable. LAN937x is successive revision of KSZ series switch.
This series of patches provide the DSA driver support for Microchip LAN937X switch through MII/RMII interface. The RGMII interface support will be added in the follow up series. LAN937x uses the most of functionality of KSZ9477.
The LAN937x switch series family consists of following SKUs:
LAN9370:
- 4 T1 Phys
- 1 RGMII port
LAN9371:
- 3 T1 Phys & 1 TX Phy
- 2 RGMII ports
LAN9372:
- 5 T1 Phys & 1 TX Phy
- 2 RGMII ports
LAN9373:
- 5 T1 Phys
- 2 RGMII
- 1 SGMII port
LAN9374:
- 6 T1 Phys
- 2 RGMII ports
Changes in v15:
- fixed compilation issue.
- Updated the phylink_mac_link_up to check only for 10/100/1000 speed.
Changes in v14:
- Updated the patch series to latest ksz code refactoring.
- RGMII register configuration is removed from the series. It will be added in the follow up patch series.
Changes in v13:
- Fixed the compilation issue in patch 5 and 6
Changes in v12:
- Removed the reduntant spi indirect enable in lan937x_init
- Used the ksz_port_stp_state_set function
- Apply rgmii internal delay only if it is rgmii port
- Set the bit for 100baseTx in phylink_get_caps
- Moved the ethtool related API from patch 5 to 7
- Moved lan_alu_entry struct in lan937x_dev.h from patch 5 to 9
- Moved lan_vlan_entry in lan937x_dev.h from patch 5 to 10
- Used the ksz_get_stats64 function for get_stats64 hook
- Splitted the patch 5. one for port configuration, spi driver, phy read & write and mtu configuration.
- Updated the indentation in ethernet-controller.yaml
- lan937x.yaml: Removed the blank lines, updated the ethernet handle to macb0. Added the rgmii internal delay only for the ports.
Changes in v11:
- Tagged as RFC to get the feedback for the subpatches 1/10, 5/10 and 6/10
Changes in v10:
- dsa.yaml: dropped moving mdio properties to dsa.yaml as per the feedback
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/#24787466
- microchip,lan937x.yaml: Naming convention changes in the example
- lan937x_main.c: Moving configurations from lan937x_reset_switch() to setup()
- lan937x_main.c: helper function has been introduced for lan937x_internal_phy_read & write
- lan937x_dev.h: lan_alu_struct struct data type changes
- lan937x_main.c: lan937x_get_stats64 make non blocking
- lan937x_main.c: modified lan937x_port_mirror_add to include extack
Changes in v9:
- lan937x_main.c: of_node_put() correction in lan937x_parse_dt_rgmii_delay
- lan937x_dev.c: removed the interface checks from lan937x_apply_rgmii_delay.
- changes in ethernet-controller.yaml and dsa.yaml
Changes in v8:
- lan937x_dev.c: fixed lan937x_r_mib_pkt warning in the sub patches
- lan937x_main.c: phylink_autoneg_inband() check removed in lan937x_phylink_mac_link_up()
- lan937x_main.c: made legacy_pre_march2020 = false as this is non-legacy driver and indentation correction in lan937x_phylink_mac_link_up()
- removed unnecessary parenthesis in lan937x_get_strings()
Changes in v7:
- microchip,lan937x.yaml: *-internal-delay-ps enum values & commit messages corrections
- lan937x_main.c: removed phylink_validate() and added phylink_get_caps()
- lan937x_main.c: added support for ethtool standard stats (get_eth_*_stats
and get_stats64)
- lan937x_main.c: removed unnecessary PVID read from lan937x_port_vlan_del()
- integrated the changes of ksz9477 multi bridging support to lan937x dev and tested both multi bridging and STP
- lan937x_port_vlan_del - dummy pvid read removed
Changes in v6:
- microchip_t1.c: There was new merge done in the net-next tree for microchip_1.c after the v5 submission. Hence rebased it for v6.
Changes in v5:
- microchip,lan937x.yaml: Added mdio properties detail
- microchip,lan937x.yaml: *-internal-delay-ps added under port node
- lan937x_dev.c: changed devm_mdiobus_alloc from of_mdiobus_register as suggested by Vladimir
- lan937x_dev.c: added dev_info for rgmii internal delay & error message to user in case of out of range values
- lan937x_dev.c: return -EOPNOTSUPP for C45 regnum values for lan937x_sw_mdio_read & write operations
- return from function with out storing in a variable
- lan937x_main.c: Added vlan_enable info in vlan_filtering API
- lan937x_main.c: lan937x_port_vlan_del: removed unintended PVID write
Changes in v4:
- tag_ksz.c: cpu_to_be16 to put_unaligned_be16
- correct spacing in comments
- tag_ksz.c: NETIF_F_HW_CSUM fix is integrated
- lan937x_dev.c: mdio_np is removed from global and handled locally
- lan937x_dev.c: unused functions removed lan937x_cfg32 & lan937x_port_cfg32
- lan937x_dev.c: lan937x_is_internal_100BTX_phy_port function name changes
- lan937x_dev.c: RGMII internal delay handling for MAC. Delay values are retrieved from DTS and updated
- lan937x_dev.c: corrected mutex operations for few dev variables
- microchip,lan937x.yaml: introduced rx-internal-delay-ps & tx-internal-delay-ps for RGMII internal delay
- lan937x_dev.c: Unnecessary mutex_lock has been removed
- lan937x_main.c: PHY_INTERFACE_MODE_NA handling for lan937x_phylink_validate
- lan937x_main.c: PORT_MIRROR_SNIFFER check in right place
- lan937x_main.c: memset is used instead of writing 0's individually in lan937x_port_fdb_add function
- lan937x_main.c: Removed \n from NL_SET_ERR_MSG_MOD calls
Changes in v3:
- Removed settings of cnt_ptr to zero and the memset() added a cleanup patch which moves this into ksz_init_mib_timer().
- Used ret everywhere instead of rc
- microchip,lan937x.yaml: Remove mdio compatible
- microchip_t1.c: Renaming standard phy registers
- tag_ksz.c: LAN937X_TAIL_TAG_OVERRIDE renaming LAN937X_TAIL_TAG_BLOCKING_OVERRIDE
- tag_ksz.c: Changed Ingress and Egress naming convention based on Host
- tag_ksz.c: converted to skb_mac_header(skb) from (is_link_local_ether_addr(hdr->h_dest))
- lan937x_dev.c: Removed BCAST Storm protection settings since we have Tc commands for them
- lan937x_dev.c: Flow control setting in lan937x_port_setup function
- lan937x_dev.c: RGMII internal delay added only for cpu port,
- lan937x_dev.c: of_get_compatible_child(node, "microchip,lan937x-mdio") to of_get_child_by_name(node, "mdio");
- lan937x_dev.c:lan937x_get_interface API: returned PHY_INTERFACE_MODE_INTERNAL instead of PHY_INTERFACE_MODE_NA
- lan937x_main.c: Removed compat interface implementation in lan937x_config_cpu_port() API & dev_info corrected as well
- lan937x_main.c: deleted ds->configure_vlan_while_not_filtering = true
- lan937x_main.c: Added explanation for lan937x_setup lines
- lan937x_main.c: FR_MAX_SIZE correction in lan937x_get_max_mtu API
- lan937x_main.c: removed lan937x_port_bridge_flags dummy functions
- lan937x_spi.c - mdiobus_unregister to be added to spi_remove function
- lan937x_main.c: phy link layer changes
- lan937x_main.c: port mirroring: sniff port selection limiting to one port
- lan937x_main.c: Changed to global vlan filtering
- lan937x_main.c: vlan_table array to structure
- lan937x_main.c -Use extack instead of reporting errors to Console
- lan937x_main.c - Remove cpu_port addition in vlan_add api
- lan937x_main.c - removed pvid resetting
Changes in v2:
- return check for register read/writes
- dt compatible compatible check is added against chip id value
- lan937x_internal_t1_tx_phy_write() is renamed to lan937x_internal_phy_write()
- lan937x_is_internal_tx_phy_port is renamed to lan937x_is_internal_100BTX_phy_port as it is 100Base-Tx phy
- Return value for lan937x_internal_phy_write() is -EOPNOTSUPP in case of failures
- Return value for lan937x_internal_phy_read() is 0xffff for non existent phy
- cpu_port checking is removed from lan937x_port_stp_state_set()
- lan937x_phy_link_validate: 100baseT_Full to 100baseT1_Full
- T1 Phy driver is moved to drivers/net/phy/microchip_t1.c
- Tx phy driver support will be added later
- Legacy switch checkings in dts file are removed.
- tag_ksz.c: Re-used ksz9477_rcv for lan937x_rcv
- tag_ksz.c: Xmit() & rcv() Comments are corrected w.r.to host
- net/dsa/Kconfig: Family skew numbers altered in ascending order
- microchip,lan937x.yaml: eth is replaced with ethernet
- microchip,lan937x.yaml: spi1 is replaced with spi
- microchip,lan937x.yaml: cpu labelling is removed
- microchip,lan937x.yaml: port@x value will match the reg value now
Arun Ramadoss (10):
net: dsa: microchip: generic access to ksz9477 static and reserved
table
net: dsa: microchip: add DSA support for microchip LAN937x
net: dsa: microchip: lan937x: add dsa_tag_protocol
net: dsa: microchip: lan937x: add phy read and write support
net: dsa: microchip: lan937x: register mdio-bus
net: dsa: microchip: lan937x: add MTU and fast_age support
net: dsa: microchip: lan937x: add phylink_get_caps support
net: dsa: microchip: lan937x: add phylink_mac_link_up support
net: dsa: microchip: lan937x: add phylink_mac_config support
net: dsa: microchip: add LAN937x in the ksz spi probe
Prasanna Vengateshan (3):
dt-bindings: net: make internal-delay-ps based on phy-mode
dt-bindings: net: dsa: dt bindings for microchip lan937x
net: dsa: tag_ksz: add tag handling for Microchip LAN937x
.../bindings/net/dsa/microchip,lan937x.yaml | 192 +++++++ .../bindings/net/ethernet-controller.yaml | 35 +- MAINTAINERS | 1 + drivers/net/dsa/microchip/Kconfig | 2 +- drivers/net/dsa/microchip/Makefile | 1 + drivers/net/dsa/microchip/ksz9477.c | 27 +- drivers/net/dsa/microchip/ksz9477_reg.h | 3 - drivers/net/dsa/microchip/ksz_common.c | 105 ++++ drivers/net/dsa/microchip/ksz_common.h | 20 + drivers/net/dsa/microchip/ksz_spi.c | 26 + drivers/net/dsa/microchip/lan937x.h | 27 + drivers/net/dsa/microchip/lan937x_main.c | 484 ++++++++++++++++++ drivers/net/dsa/microchip/lan937x_reg.h | 180 +++++++ include/net/dsa.h | 2 + net/dsa/Kconfig | 4 +- net/dsa/tag_ksz.c | 59 +++ 16 files changed, 1143 insertions(+), 25 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml create mode 100644 drivers/net/dsa/microchip/lan937x.h create mode 100644 drivers/net/dsa/microchip/lan937x_main.c create mode 100644 drivers/net/dsa/microchip/lan937x_reg.h
base-commit: dbdd9a28e1406ab8218a69e60f10a168b968c81d
Signature · 1 line
2.36.1
PATCH v15 1/13 dt-bindings: net: make internal-delay-ps based on phy-mode
From: Prasanna Vengateshan <[email protected]>
*-internal-delay-ps properties would be applicable only for RGMII interface modes.
It is changed as per the request.
Ran dt_binding_check to confirm nothing is broken.
--- .../bindings/net/ethernet-controller.yaml | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/net/ethernet-controller.yaml +23 -12
@@ -133,12 +133,6 @@ properties: and is useful for determining certain configuration settings such as flow control thresholds. - rx-internal-delay-ps: - description: | - RGMII Receive Clock Delay defined in pico seconds. - This is used for controllers that have configurable RX internal delays. - If this property is present then the MAC applies the RX delay. - sfp: $ref: /schemas/types.yaml#/definitions/phandle description:
@@ -150,12 +144,6 @@ properties: The size of the controller\'s transmit fifo in bytes. This is used for components that can have configurable fifo sizes. - tx-internal-delay-ps: - description: | - RGMII Transmit Clock Delay defined in pico seconds. - This is used for controllers that have configurable TX internal delays. - If this property is present then the MAC applies the TX delay. - managed: description: Specifies the PHY management type. If auto is set and fixed-link
@@ -232,6 +220,29 @@ properties: required: - speed +allOf: + - if: + properties: + phy-mode: + contains: + enum: + - rgmii + - rgmii-rxid + - rgmii-txid + - rgmii-id + then: + properties: + rx-internal-delay-ps: + description: + RGMII Receive Clock Delay defined in pico seconds.This is used for + controllers that have configurable RX internal delays. If this + property is present then the MAC applies the RX delay. + tx-internal-delay-ps: + description: + RGMII Transmit Clock Delay defined in pico seconds.This is used for + controllers that have configurable TX internal delays. If this + property is present then the MAC applies the TX delay. + additionalProperties: true ...
Signature · 1 line
2.36.1
PATCH v15 2/13 dt-bindings: net: dsa: dt bindings for microchip lan937x
In reply to Arun RamadossFrom: Prasanna Vengateshan <[email protected]>
Documentation in .yaml format and updates to the MAINTAINERS Also 'make dt_binding_check' is passed.
RGMII internal delay values for the mac is retrieved from rx-internal-delay-ps & tx-internal-delay-ps as per the feedback from v3 patch series.
https://lore.kernel.org/netdev/20210802121550.gqgbipqdvp5x76ii@skbuf/
It supports only the delay value of 0ns and 2ns.
--- .../bindings/net/dsa/microchip,lan937x.yaml | 192 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 193 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml
Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml new file +192 -0
@@ -0,0 +1,192 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/microchip,lan937x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LAN937x Ethernet Switch Series Tree Bindings + +maintainers: + - [email protected] + +allOf: + - $ref: dsa.yaml# + +properties: + compatible: + enum: + - microchip,lan9370 + - microchip,lan9371 + - microchip,lan9372 + - microchip,lan9373 + - microchip,lan9374 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 50000000 + + reset-gpios: + description: Optional gpio specifier for a reset line + maxItems: 1 + + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + +patternProperties: + "^(ethernet-)?ports$": + patternProperties: + "^(ethernet-)?port@[0-9]+$": + allOf: + - if: + properties: + phy-mode: + contains: + enum: + - rgmii + - rgmii-id + - rgmii-txid + - rgmii-rxid + then: + properties: + rx-internal-delay-ps: + enum: [0, 2000] + default: 0 + tx-internal-delay-ps: + enum: [0, 2000] + default: 0 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + macb0 { + #address-cells = <1>; + #size-cells = <0>; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + spi { + #address-cells = <1>; + #size-cells = <0>; + + lan9374: switch@0 { + compatible = "microchip,lan9374"; + reg = <0>; + spi-max-frequency = <44000000>; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + phy-mode = "internal"; + phy-handle = <&t1phy0>; + }; + + port@1 { + reg = <1>; + label = "lan2"; + phy-mode = "internal"; + phy-handle = <&t1phy1>; + }; + + port@2 { + reg = <2>; + label = "lan4"; + phy-mode = "internal"; + phy-handle = <&t1phy2>; + }; + + port@3 { + reg = <3>; + label = "lan6"; + phy-mode = "internal"; + phy-handle = <&t1phy3>; + }; + + port@4 { + reg = <4>; + phy-mode = "rgmii"; + tx-internal-delay-ps = <2000>; + rx-internal-delay-ps = <2000>; + ethernet = <&macb0>; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + port@5 { + reg = <5>; + label = "lan7"; + phy-mode = "rgmii"; + tx-internal-delay-ps = <2000>; + rx-internal-delay-ps = <2000>; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + + port@6 { + reg = <6>; + label = "lan5"; + phy-mode = "internal"; + phy-handle = <&t1phy6>; + }; + + port@7 { + reg = <7>; + label = "lan3"; + phy-mode = "internal"; + phy-handle = <&t1phy7>; + }; + }; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + t1phy0: ethernet-phy@0{ + reg = <0x0>; + }; + + t1phy1: ethernet-phy@1{ + reg = <0x1>; + }; + + t1phy2: ethernet-phy@2{ + reg = <0x2>; + }; + + t1phy3: ethernet-phy@3{ + reg = <0x3>; + }; + + t1phy6: ethernet-phy@6{ + reg = <0x6>; + }; + + t1phy7: ethernet-phy@7{ + reg = <0x7>; + }; + }; + }; + };
MAINTAINERS +1 -0
@@ -13104,6 +13104,7 @@ M: [email protected] L: [email protected] S: Maintained F: Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml +F: Documentation/devicetree/bindings/net/dsa/microchip,lan937x.yaml F: drivers/net/dsa/microchip/* F: include/linux/platform_data/microchip-ksz.h F: net/dsa/tag_ksz.c
Signature · 1 line
2.36.1
PATCH v15 3/13 net: dsa: tag_ksz: add tag handling for Microchip LAN937x
In reply to Arun RamadossFrom: Prasanna Vengateshan <[email protected]>
The Microchip LAN937X switches have a tagging protocol which is very similar to KSZ tagging. So that the implementation is added to tag_ksz.c and reused common APIs
--- include/net/dsa.h | 2 ++ net/dsa/Kconfig | 4 ++-- net/dsa/tag_ksz.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-)
include/net/dsa.h +2 -0
@@ -54,6 +54,7 @@ struct phylink_link_state;#define DSA_TAG_PROTO_RTL8_4_VALUE 24#define DSA_TAG_PROTO_RTL8_4T_VALUE 25#define DSA_TAG_PROTO_RZN1_A5PSW_VALUE 26 +#define DSA_TAG_PROTO_LAN937X_VALUE 27enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -83,6 +84,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_RTL8_4 =DSA_TAG_PROTO_RTL8_4_VALUE ,DSA_TAG_PROTO_RTL8_4T =DSA_TAG_PROTO_RTL8_4T_VALUE ,DSA_TAG_PROTO_RZN1_A5PSW =DSA_TAG_PROTO_RZN1_A5PSW_VALUE , + DSA_TAG_PROTO_LAN937X = DSA_TAG_PROTO_LAN937X_VALUE, };struct dsa_switch ;
net/dsa/Kconfig +2 -2
@@ -87,10 +87,10 @@ config NET_DSA_TAG_MTK Mediatek switches. config NET_DSA_TAG_KSZ - tristate "Tag driver for Microchip 8795/9477/9893 families of switches" + tristate "Tag driver for Microchip 8795/937x/9477/9893 families of switches" help Say Y if you want to enable support for tagging frames for the - Microchip 8795/9477/9893 families of switches. + Microchip 8795/937x/9477/9893 families of switches. config NET_DSA_TAG_OCELOT tristate "Tag driver for Ocelot family of switches, using NPI port"
net/dsa/tag_ksz.c +59 -0
69 lines not on this page · raw message
Signature · 1 line
2.36.1
PATCH v15 4/13 net: dsa: microchip: generic access to ksz9477 static and reserved table
In reply to Arun RamadossThe ksz9477 and lan937x has few difference in the static and reserved table register 0x041C. For the ksz9477 if the bit 0 is 1 - read operation and 0 - write operation. But for lan937x bit 1:0 used for selecting the read/write operation, 01 - write and 10 - read. To use ksz9477 mdb add/del and enable_stp_addr for the lan937x, masks & shifts are introduced for ksz9477 & lan937x in ksz_common.c. Then updated the function with masks & shifts based on the switch instead of hard coding it.
--- drivers/net/dsa/microchip/ksz9477.c | 27 ++++++++++++++----- drivers/net/dsa/microchip/ksz9477_reg.h | 3 --- drivers/net/dsa/microchip/ksz_common.c | 35 +++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 3 +++ 4 files changed, 58 insertions(+), 10 deletions(-)
drivers/net/dsa/microchip/ksz9477.c +20 -7
@@ -644,11 +644,16 @@ int ksz9477_mdb_add(struct ksz_device *dev, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db) { u32 static_table[4]; +const u8 *shifts; +const u32 *masks;u32 data;int index;u32 mac_hi, mac_lo;int err =0 ; + shifts = dev->info->shifts; + masks = dev->info->masks; + mac_hi = ((mdb->addr[0 ] <<8 ) | mdb->addr[1 ]); mac_lo = ((mdb->addr[2 ] <<24 ) | (mdb->addr[3 ] <<16 )); mac_lo |= ((mdb->addr[4 ] <<8 ) | mdb->addr[5 ]);
@@ -657,8 +662,8 @@ int ksz9477_mdb_add(struct ksz_device *dev, int port,for (index =0 ; index < dev->info->num_statics; index++) {/* find empty slot first */ - data = (index <<ALU_STAT_INDEX_S ) | -ALU_STAT_READ |ALU_STAT_START ; + data = (index << shifts[ALU_STAT_INDEX ]) | + masks[ALU_STAT_READ ] |ALU_STAT_START ;ksz_write32 (dev,REG_SW_ALU_STAT_CTRL__4 , data);/* wait to be finished */
@@ -702,7 +707,7 @@ int ksz9477_mdb_add(struct ksz_device *dev, int port,ksz9477_write_table (dev, static_table); - data = (index <<ALU_STAT_INDEX_S ) |ALU_STAT_START ; + data = (index << shifts[ALU_STAT_INDEX ]) |ALU_STAT_START ;ksz_write32 (dev,REG_SW_ALU_STAT_CTRL__4 , data);/* wait to be finished */
@@ -718,11 +723,16 @@ int ksz9477_mdb_del(struct ksz_device *dev, int port, const struct switchdev_obj_port_mdb *mdb, struct dsa_db db) { u32 static_table[4]; +const u8 *shifts; +const u32 *masks;u32 data;int index;int ret =0 ;u32 mac_hi, mac_lo; + shifts = dev->info->shifts; + masks = dev->info->masks; + mac_hi = ((mdb->addr[0 ] <<8 ) | mdb->addr[1 ]); mac_lo = ((mdb->addr[2 ] <<24 ) | (mdb->addr[3 ] <<16 )); mac_lo |= ((mdb->addr[4 ] <<8 ) | mdb->addr[5 ]);
@@ -731,8 +741,8 @@ int ksz9477_mdb_del(struct ksz_device *dev, int port,for (index =0 ; index < dev->info->num_statics; index++) {/* find empty slot first */ - data = (index <<ALU_STAT_INDEX_S ) | -ALU_STAT_READ |ALU_STAT_START ; + data = (index << shifts[ALU_STAT_INDEX ]) | + masks[ALU_STAT_READ ] |ALU_STAT_START ;ksz_write32 (dev,REG_SW_ALU_STAT_CTRL__4 , data);/* wait to be finished */
@@ -774,7 +784,7 @@ int ksz9477_mdb_del(struct ksz_device *dev, int port,ksz9477_write_table (dev, static_table); - data = (index <<ALU_STAT_INDEX_S ) |ALU_STAT_START ; + data = (index << shifts[ALU_STAT_INDEX ]) |ALU_STAT_START ;ksz_write32 (dev,REG_SW_ALU_STAT_CTRL__4 , data);/* wait to be finished */
@@ -1230,9 +1240,12 @@ void ksz9477_config_cpu_port(struct dsa_switch *ds)int ksz9477_enable_stp_addr (struct ksz_device *dev) { +const u32 *masks;u32 data;int ret; + masks = dev->info->masks; +/* Enable Reserved multicast table */ ksz_cfg (dev,REG_SW_LUE_CTRL_0 ,SW_RESV_MCAST_ENABLE , true);
@@ -1242,7 +1255,7 @@ int ksz9477_enable_stp_addr(struct ksz_device *dev)if (ret <0 )return ret; - data =ALU_STAT_START |ALU_RESV_MCAST_ADDR ; + data =ALU_STAT_START |ALU_RESV_MCAST_ADDR | masks[ALU_STAT_WRITE ]; ret =ksz_write32 (dev,REG_SW_ALU_STAT_CTRL__4 , data);if (ret <0 )
drivers/net/dsa/microchip/ksz9477_reg.h +0 -3
@@ -419,12 +419,9 @@#define REG_SW_ALU_STAT_CTRL__4 0x041C -#define ALU_STAT_INDEX_M (BIT(4) - 1) -#define ALU_STAT_INDEX_S 16#define ALU_RESV_MCAST_INDEX_M (BIT(6) - 1)#define ALU_STAT_START BIT(7)#define ALU_RESV_MCAST_ADDR BIT(1) -#define ALU_STAT_READ BIT(0)#define REG_SW_ALU_VAL_A 0x0420
drivers/net/dsa/microchip/ksz_common.c +35 -0
@@ -314,7 +314,24 @@ static const u16 ksz9477_regs[] = { [S_START_CTRL] = 0x0300, [S_BROADCAST_CTRL] = 0x0332, [S_MULTICAST_CTRL] = 0x0331, +}; + +static const u32 ksz9477_masks[] = { + [ALU_STAT_WRITE ] =0 , + [ALU_STAT_READ ] =1 , +}; + +static const u8 ksz9477_shifts[] = { + [ALU_STAT_INDEX ] =16 , +}; + +static const u32 lan937x_masks[] = { + [ALU_STAT_WRITE ] =1 , + [ALU_STAT_READ ] =2 , +}; +static const u8 lan937x_shifts[] = { + [ALU_STAT_INDEX ] =8 , };const struct ksz_chip_data ksz_switch_chips[] = {
@@ -432,6 +449,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = ksz9477_masks, + .shifts = ksz9477_shifts, .supports_mii = {false, false, false, false, false, true, false}, .supports_rmii = {false, false, false, false,
@@ -456,6 +475,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = ksz9477_masks, + .shifts = ksz9477_shifts, .supports_mii = {false, false, false, false, false, true, true}, .supports_rmii = {false, false, false, false,
@@ -479,6 +500,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = ksz9477_masks, + .shifts = ksz9477_shifts, .supports_mii = {false, false, true}, .supports_rmii = {false, false, true}, .supports_rgmii = {false, false, true},
@@ -499,6 +522,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = ksz9477_masks, + .shifts = ksz9477_shifts, .supports_mii = {false, false, false, false, false, true, true}, .supports_rmii = {false, false, false, false,
@@ -521,6 +546,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = lan937x_masks, + .shifts = lan937x_shifts, .supports_mii = {false, false, false, false, true}, .supports_rmii = {false, false, false, false, true}, .supports_rgmii = {false, false, false, false, true},
@@ -539,6 +566,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = lan937x_masks, + .shifts = lan937x_shifts, .supports_mii = {false, false, false, false, true, true}, .supports_rmii = {false, false, false, false, true, true}, .supports_rgmii = {false, false, false, false, true, true},
@@ -557,6 +586,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = lan937x_masks, + .shifts = lan937x_shifts, .supports_mii = {false, false, false, false, true, true, false, false}, .supports_rmii = {false, false, false, false,
@@ -579,6 +610,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = lan937x_masks, + .shifts = lan937x_shifts, .supports_mii = {false, false, false, false, true, true, false, false}, .supports_rmii = {false, false, false, false,
@@ -601,6 +634,8 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz9477_regs, + .masks = lan937x_masks, + .shifts = lan937x_shifts, .supports_mii = {false, false, false, false, true, true, false, false}, .supports_rmii = {false, false, false, false,
drivers/net/dsa/microchip/ksz_common.h +3 -0
@@ -191,6 +191,8 @@ enum ksz_masks {DYNAMIC_MAC_TABLE_FID ,DYNAMIC_MAC_TABLE_SRC_PORT ,DYNAMIC_MAC_TABLE_TIMESTAMP , +ALU_STAT_WRITE , + ALU_STAT_READ, }; enum ksz_shifts {
@@ -203,6 +205,7 @@ enum ksz_shifts {DYNAMIC_MAC_FID ,DYNAMIC_MAC_TIMESTAMP ,DYNAMIC_MAC_SRC_PORT , + ALU_STAT_INDEX, }; struct alu_struct {
Signature · 1 line
2.36.1
PATCH v15 5/13 net: dsa: microchip: add DSA support for microchip LAN937x
In reply to Arun RamadossBasic DSA driver support for lan937x and the device will be configured through SPI interface.
It adds the lan937x_dev_ops in ksz_common.c file and tries to reuse the functionality of ksz9477 series switch.
drivers/net/dsa/microchip/ path is already part of MAINTAINERS & the new files come under this path. Hence no update needed to the MAINTAINERS
--- drivers/net/dsa/microchip/Kconfig | 2 +- drivers/net/dsa/microchip/Makefile | 1 + drivers/net/dsa/microchip/ksz_common.c | 34 +++++ drivers/net/dsa/microchip/lan937x.h | 15 +++ drivers/net/dsa/microchip/lan937x_main.c | 154 +++++++++++++++++++++++ drivers/net/dsa/microchip/lan937x_reg.h | 128 +++++++++++++++++++ 6 files changed, 333 insertions(+), 1 deletion(-) create mode 100644 drivers/net/dsa/microchip/lan937x.h create mode 100644 drivers/net/dsa/microchip/lan937x_main.c create mode 100644 drivers/net/dsa/microchip/lan937x_reg.h
drivers/net/dsa/microchip/Kconfig +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only menuconfig NET_DSA_MICROCHIP_KSZ_COMMON - tristate "Microchip KSZ8795/KSZ9477 series switch support" + tristate "Microchip KSZ8795/KSZ9477/LAN937x series switch support" depends on NET_DSA select NET_DSA_TAG_KSZ help
drivers/net/dsa/microchip/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_switch.o ksz_switch-objs := ksz_common.o ksz_switch-objs += ksz9477.o ksz_switch-objs += ksz8795.o +ksz_switch-objs += lan937x_main.o obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_I2C) += ksz9477_i2c.o obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_SPI) += ksz_spi.o obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ8863_SMI) += ksz8863_smi.o
drivers/net/dsa/microchip/ksz_common.c +34 -0
@@ -23,6 +23,7 @@#include "ksz_common.h" #include "ksz8.h" #include "ksz9477.h" +#include "lan937x.h" #define MIB_COUNTER_NUM 0x20
@@ -201,6 +202,34 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .exit = ksz9477_switch_exit, }; +static const struct ksz_dev_ops lan937x_dev_ops = { + .setup = lan937x_setup, + .get_port_addr = ksz9477_get_port_addr, + .cfg_port_member = ksz9477_cfg_port_member, + .port_setup = lan937x_port_setup, + .r_mib_cnt = ksz9477_r_mib_cnt, + .r_mib_pkt = ksz9477_r_mib_pkt, + .r_mib_stat64 = ksz_r_mib_stats64, + .freeze_mib = ksz9477_freeze_mib, + .port_init_cnt = ksz9477_port_init_cnt, + .vlan_filtering = ksz9477_port_vlan_filtering, + .vlan_add = ksz9477_port_vlan_add, + .vlan_del = ksz9477_port_vlan_del, + .mirror_add = ksz9477_port_mirror_add, + .mirror_del = ksz9477_port_mirror_del, + .fdb_dump = ksz9477_fdb_dump, + .fdb_add = ksz9477_fdb_add, + .fdb_del = ksz9477_fdb_del, + .mdb_add = ksz9477_mdb_add, + .mdb_del = ksz9477_mdb_del, + .max_mtu = ksz9477_max_mtu, + .config_cpu_port = lan937x_config_cpu_port, + .enable_stp_addr = ksz9477_enable_stp_addr, + .reset = lan937x_reset_switch, + .init = lan937x_switch_init, + .exit = lan937x_switch_exit, +}; +static const u16 ksz8795_regs[] = { [REG_IND_CTRL_0 ] =0x6E , [REG_IND_DATA_8 ] =0x70 ,
@@ -542,6 +571,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x10, /* can be configured as cpu port */ .port_cnt = 5, /* total physical port count */ + .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM,
@@ -562,6 +592,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 6, /* total physical port count */ + .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM,
@@ -582,6 +613,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 8, /* total physical port count */ + .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM,
@@ -606,6 +638,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x38, /* can be configured as cpu port */ .port_cnt = 5, /* total physical port count */ + .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM,
@@ -630,6 +663,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 8, /* total physical port count */ + .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM,
drivers/net/dsa/microchip/lan937x.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Microchip lan937x dev ops headers +* Copyright (C) 2019-2022 Microchip Technology Inc. +*/ + +#ifndef __LAN937X_CFG_H +#define __LAN937X_CFG_H + +int lan937x_reset_switch (struct ksz_device *dev); +int lan937x_setup (struct dsa_switch *ds); +void lan937x_port_setup (struct ksz_device *dev,int port,bool cpu_port); +void lan937x_config_cpu_port (struct dsa_switch *ds); +int lan937x_switch_init (struct ksz_device *dev); +void lan937x_switch_exit (struct ksz_device *dev); +#endif
drivers/net/dsa/microchip/lan937x_main.c new file +154 -0
154 lines not on this page · raw message
drivers/net/dsa/microchip/lan937x_reg.h new file +128 -0
128 lines not on this page · raw message
Signature · 1 line
2.36.1
PATCH v15 6/13 net: dsa: microchip: lan937x: add dsa_tag_protocol
In reply to Arun RamadossThis patch update the ksz_get_tag_protocol to return LAN937x specific tag if the chip id matches one of LAN937x series switch
--- drivers/net/dsa/microchip/ksz_common.c | 3 +++ drivers/net/dsa/microchip/ksz_common.h | 9 +++++++++ 2 files changed, 12 insertions(+)
drivers/net/dsa/microchip/ksz_common.c +3 -0
@@ -1254,6 +1254,9 @@ static enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds, dev->chip_id == KSZ9567_CHIP_ID) proto =DSA_TAG_PROTO_KSZ9477 ; +if (is_lan937x (dev)) + proto =DSA_TAG_PROTO_LAN937X_VALUE ; +return proto; }
drivers/net/dsa/microchip/ksz_common.h +9 -0
@@ -403,6 +403,15 @@ static inline void ksz_regmap_unlock(void *__mtx)mutex_unlock (mtx); } +static inline int is_lan937x (struct ksz_device *dev) +{ +return dev->chip_id ==LAN9370_CHIP_ID || + dev->chip_id ==LAN9371_CHIP_ID || + dev->chip_id ==LAN9372_CHIP_ID || + dev->chip_id ==LAN9373_CHIP_ID || + dev->chip_id ==LAN9374_CHIP_ID ; +} +/* STP State Defines */ #define PORT_TX_ENABLE BIT(2)#define PORT_RX_ENABLE BIT(1)
Signature · 1 line
2.36.1
PATCH v15 7/13 net: dsa: microchip: lan937x: add phy read and write support
In reply to Arun RamadossThis patch add support for the writing and reading of the phy registers. LAN937x uses the Vphy indirect addressing method for accessing the phys.
--- drivers/net/dsa/microchip/ksz_common.c | 2 + drivers/net/dsa/microchip/lan937x.h | 2 + drivers/net/dsa/microchip/lan937x_main.c | 116 +++++++++++++++++++++++ drivers/net/dsa/microchip/lan937x_reg.h | 36 +++++++ 4 files changed, 156 insertions(+)
drivers/net/dsa/microchip/ksz_common.c +2 -0
@@ -207,6 +207,8 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .get_port_addr = ksz9477_get_port_addr, .cfg_port_member = ksz9477_cfg_port_member, .port_setup = lan937x_port_setup, + .r_phy = lan937x_r_phy, + .w_phy = lan937x_w_phy, .r_mib_cnt = ksz9477_r_mib_cnt, .r_mib_pkt = ksz9477_r_mib_pkt, .r_mib_stat64 = ksz_r_mib_stats64,
drivers/net/dsa/microchip/lan937x.h +2 -0
@@ -12,4 +12,6 @@ void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port);void lan937x_config_cpu_port (struct dsa_switch *ds);int lan937x_switch_init (struct ksz_device *dev);void lan937x_switch_exit (struct ksz_device *dev); +void lan937x_r_phy (struct ksz_device *dev,u16 addr,u16 reg,u16 *data); +void lan937x_w_phy (struct ksz_device *dev,u16 addr,u16 reg,u16 val);#endif
drivers/net/dsa/microchip/lan937x_main.c +116 -0
128 lines not on this page · raw message
drivers/net/dsa/microchip/lan937x_reg.h +36 -0
@@ -8,6 +8,12 @@#define PORT_CTRL_ADDR (port, addr) ((addr) | (((port) + 1) << 12))/* 0 - Operation */ +#define REG_GLOBAL_CTRL_0 0x0007 + +#define SW_PHY_REG_BLOCK BIT(7) +#define SW_FAST_MODE BIT(3) +#define SW_FAST_MODE_OVERRIDE BIT(2) +#define REG_SW_INT_STATUS__4 0x0010#define REG_SW_INT_MASK__4 0x0014
@@ -82,6 +88,33 @@#define ALU_V_USE_FID BIT(30)#define ALU_V_PORT_MAP 0xFF +/* 7 - VPhy */ +#define REG_VPHY_IND_ADDR__2 0x075C +#define REG_VPHY_IND_DATA__2 0x0760 + +#define REG_VPHY_IND_CTRL__2 0x0768 + +#define VPHY_IND_WRITE BIT(1) +#define VPHY_IND_BUSY BIT(0) + +#define REG_VPHY_SPECIAL_CTRL__2 0x077C +#define VPHY_SMI_INDIRECT_ENABLE BIT(15) +#define VPHY_SW_LOOPBACK BIT(14) +#define VPHY_MDIO_INTERNAL_ENABLE BIT(13) +#define VPHY_SPI_INDIRECT_ENABLE BIT(12) +#define VPHY_PORT_MODE_M 0x3 +#define VPHY_PORT_MODE_S 8 +#define VPHY_MODE_RGMII 0 +#define VPHY_MODE_MII_PHY 1 +#define VPHY_MODE_SGMII 2 +#define VPHY_MODE_RMII_PHY 3 +#define VPHY_SW_COLLISION_TEST BIT(7) +#define VPHY_SPEED_DUPLEX_STAT_M 0x7 +#define VPHY_SPEED_DUPLEX_STAT_S 2 +#define VPHY_SPEED_1000 BIT(4) +#define VPHY_SPEED_100 BIT(3) +#define VPHY_FULL_DUPLEX BIT(2) +/* Port Registers */ /* 0 - Operation */
@@ -94,6 +127,9 @@#define PORT_TAIL_TAG_ENABLE BIT(2)#define PORT_QUEUE_SPLIT_ENABLE 0x3 +/* 1 - Phy */ +#define REG_PORT_T1_PHY_CTRL_BASE 0x0100 +/* 3 - xMII */ #define REG_PORT_XMII_CTRL_0 0x0300#define PORT_SGMII_SEL BIT(7)
Signature · 1 line
2.36.1
PATCH v15 8/13 net: dsa: microchip: lan937x: register mdio-bus
In reply to Arun RamadossThis patch register mdio-bus for the lan937x series switch. mdio read and write uses the vphy for accessing the phy register.
--- drivers/net/dsa/microchip/lan937x_main.c | 74 ++++++++++++++++++++++++ 1 file changed, 74 insertions(+)
drivers/net/dsa/microchip/lan937x_main.c +74 -0
@@ -7,6 +7,7 @@#include <linux/iopoll.h> #include <linux/phy.h> #include <linux/of_net.h> +#include <linux/of_mdio.h> #include <linux/if_bridge.h> #include <linux/math.h> #include <net/dsa.h>
@@ -136,6 +137,73 @@ void lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val)lan937x_internal_phy_write (dev, addr, reg, val); } +static int lan937x_sw_mdio_read (struct mii_bus *bus,int addr,int regnum) +{ +struct ksz_device *dev = bus->priv; +u16 val; +int ret; + +if (regnum &MII_ADDR_C45 ) +return -EOPNOTSUPP ; + + ret =lan937x_internal_phy_read (dev, addr, regnum, &val); +if (ret <0 ) +return ret; + +return val; +} + +static int lan937x_sw_mdio_write (struct mii_bus *bus,int addr,int regnum, +u16 val) +{ +struct ksz_device *dev = bus->priv; + +if (regnum &MII_ADDR_C45 ) +return -EOPNOTSUPP ; + +return lan937x_internal_phy_write (dev, addr, regnum, val); +} + +static int lan937x_mdio_register (struct ksz_device *dev) +{ +struct dsa_switch *ds = dev->ds; +struct device_node *mdio_np; +struct mii_bus *bus; +int ret; + + mdio_np =of_get_child_by_name (dev->dev->of_node,"mdio" ); +if (!mdio_np) { +dev_err (ds->dev,"no MDIO bus node\n" ); +return -ENODEV ; + } + + bus =devm_mdiobus_alloc (ds->dev); +if (!bus) { +of_node_put (mdio_np); +return -ENOMEM ; + } + + bus->priv = dev; + bus->read = lan937x_sw_mdio_read; + bus->write = lan937x_sw_mdio_write; + bus->name ="lan937x slave smi" ; +snprintf (bus->id,MII_BUS_ID_SIZE ,"SMI-%d" , ds->index); + bus->parent = ds->dev; + bus->phy_mask = ~ds->phys_mii_mask; + + ds->slave_mii_bus = bus; + + ret =devm_of_mdiobus_register (ds->dev, bus, mdio_np); +if (ret) { +dev_err (ds->dev,"unable to register MDIO bus %s\n" , + bus->id); + } + +of_node_put (mdio_np); + +return ret; +} +int lan937x_reset_switch (struct ksz_device *dev) {u32 data32;
@@ -228,6 +296,12 @@ int lan937x_setup(struct dsa_switch *ds)return ret; } + ret =lan937x_mdio_register (dev); +if (ret <0 ) { +dev_err (dev->dev,"failed to register the mdio" ); +return ret; + } +/* The VLAN aware is a global setting. Mixed vlan * filterings are not supported. */
Signature · 1 line
2.36.1
PATCH v15 9/13 net: dsa: microchip: lan937x: add MTU and fast_age support
In reply to Arun RamadossThis patch add the support for port_max_mtu, port_change_mtu and port_fast_age dsa functionality.
--- drivers/net/dsa/microchip/ksz_common.c | 2 ++ drivers/net/dsa/microchip/lan937x.h | 1 + drivers/net/dsa/microchip/lan937x_main.c | 28 ++++++++++++++++++++++++ drivers/net/dsa/microchip/lan937x_reg.h | 5 +++++ 4 files changed, 36 insertions(+)
drivers/net/dsa/microchip/ksz_common.c +2 -0
@@ -206,6 +206,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .setup = lan937x_setup, .get_port_addr = ksz9477_get_port_addr, .cfg_port_member = ksz9477_cfg_port_member, + .flush_dyn_mac_table = ksz9477_flush_dyn_mac_table, .port_setup = lan937x_port_setup, .r_phy = lan937x_r_phy, .w_phy = lan937x_w_phy,
@@ -224,6 +225,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .fdb_del = ksz9477_fdb_del, .mdb_add = ksz9477_mdb_add, .mdb_del = ksz9477_mdb_del, + .change_mtu = lan937x_change_mtu, .max_mtu = ksz9477_max_mtu, .config_cpu_port = lan937x_config_cpu_port, .enable_stp_addr = ksz9477_enable_stp_addr,
drivers/net/dsa/microchip/lan937x.h +1 -0
@@ -14,4 +14,5 @@ int lan937x_switch_init(struct ksz_device *dev);void lan937x_switch_exit (struct ksz_device *dev);void lan937x_r_phy (struct ksz_device *dev,u16 addr,u16 reg,u16 *data);void lan937x_w_phy (struct ksz_device *dev,u16 addr,u16 reg,u16 val); +int lan937x_change_mtu (struct ksz_device *dev,int port,int new_mtu);#endif
drivers/net/dsa/microchip/lan937x_main.c +28 -0
@@ -9,6 +9,7 @@#include <linux/of_net.h> #include <linux/of_mdio.h> #include <linux/if_bridge.h> +#include <linux/if_vlan.h> #include <linux/math.h> #include <net/dsa.h> #include <net/switchdev.h>
@@ -284,6 +285,33 @@ void lan937x_config_cpu_port(struct dsa_switch *ds) } } +int lan937x_change_mtu (struct ksz_device *dev,int port,int new_mtu) +{ +struct dsa_switch *ds = dev->ds; +int ret; + + new_mtu +=VLAN_ETH_HLEN +ETH_FCS_LEN ; + +if (dsa_is_cpu_port (ds, port)) + new_mtu +=LAN937X_TAG_LEN ; + +if (new_mtu >=FR_MIN_SIZE ) + ret =lan937x_port_cfg (dev, port,REG_PORT_MAC_CTRL_0 , +PORT_JUMBO_PACKET , true); +else + ret =lan937x_port_cfg (dev, port,REG_PORT_MAC_CTRL_0 , +PORT_JUMBO_PACKET , false); +if (ret <0 ) { +dev_err (ds->dev,"failed to enable jumbo\n" ); +return ret; + } + +/* Write the frame size in PORT_MAX_FR_SIZE register */ +ksz_pwrite16 (dev, port,PORT_MAX_FR_SIZE , new_mtu); + +return 0 ; +} +int lan937x_setup (struct dsa_switch *ds) {struct ksz_device *dev = ds->priv;
drivers/net/dsa/microchip/lan937x_reg.h +5 -0
@@ -149,6 +149,9 @@#define PORT_BACK_PRESSURE BIT(3)#define PORT_PASS_ALL BIT(0) +#define PORT_MAX_FR_SIZE 0x404 +#define FR_MIN_SIZE 1522 +/* 8 - Classification and Policing */ #define REG_PORT_MRI_PRIO_CTRL 0x0801#define PORT_HIGHEST_PRIO BIT(7)
@@ -161,4 +164,6 @@#define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL +#define LAN937X_TAG_LEN 2 +#endif
Signature · 1 line
2.36.1
PATCH v15 10/13 net: dsa: microchip: lan937x: add phylink_get_caps support
In reply to Arun RamadossThe internal phy of the LAN937x are capable of 100Mbps Full duplex. The xMII port of switch is capable of 10Mbps Full & Half Duplex, 100Mbps Full & Half Duplex and 1000Mbps Half duplex. xMII port also supports Tx and Rx Flow control.
--- drivers/net/dsa/microchip/ksz_common.c | 1 + drivers/net/dsa/microchip/lan937x.h | 2 ++ drivers/net/dsa/microchip/lan937x_main.c | 12 ++++++++++++ 3 files changed, 15 insertions(+)
drivers/net/dsa/microchip/ksz_common.c +1 -0
@@ -220,6 +220,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .vlan_del = ksz9477_port_vlan_del, .mirror_add = ksz9477_port_mirror_add, .mirror_del = ksz9477_port_mirror_del, + .get_caps = lan937x_phylink_get_caps, .fdb_dump = ksz9477_fdb_dump, .fdb_add = ksz9477_fdb_add, .fdb_del = ksz9477_fdb_del,
drivers/net/dsa/microchip/lan937x.h +2 -0
@@ -15,4 +15,6 @@ void lan937x_switch_exit(struct ksz_device *dev);void lan937x_r_phy (struct ksz_device *dev,u16 addr,u16 reg,u16 *data);void lan937x_w_phy (struct ksz_device *dev,u16 addr,u16 reg,u16 val);int lan937x_change_mtu (struct ksz_device *dev,int port,int new_mtu); +void lan937x_phylink_get_caps (struct ksz_device *dev,int port, +struct phylink_config *config);#endif
drivers/net/dsa/microchip/lan937x_main.c +12 -0
@@ -312,6 +312,18 @@ int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu)return 0 ; } +void lan937x_phylink_get_caps (struct ksz_device *dev,int port, +struct phylink_config *config) +{ + config->mac_capabilities =MAC_100FD ; + +if (dev->info->supports_rgmii[port]) { +/* MII/RMII/RGMII ports */ + config->mac_capabilities |=MAC_ASYM_PAUSE |MAC_SYM_PAUSE | +MAC_100HD |MAC_10 |MAC_1000FD ; + } +} +int lan937x_setup (struct dsa_switch *ds) {struct ksz_device *dev = ds->priv;
Signature · 1 line
2.36.1
PATCH v15 11/13 net: dsa: microchip: lan937x: add phylink_mac_link_up support
In reply to Arun RamadossThis patch add support for phylink_mac_link_up. It configures the mac for the speed, flow control and duplex mode.
--- drivers/net/dsa/microchip/ksz_common.c | 16 +++++++++ drivers/net/dsa/microchip/ksz_common.h | 5 +++ drivers/net/dsa/microchip/lan937x.h | 4 +++ drivers/net/dsa/microchip/lan937x_main.c | 46 ++++++++++++++++++++++++ drivers/net/dsa/microchip/lan937x_reg.h | 11 ++++++ 5 files changed, 82 insertions(+)
drivers/net/dsa/microchip/ksz_common.c +16 -0
@@ -221,6 +221,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .mirror_add = ksz9477_port_mirror_add, .mirror_del = ksz9477_port_mirror_del, .get_caps = lan937x_phylink_get_caps, + .phylink_mac_link_up = lan937x_phylink_mac_link_up, .fdb_dump = ksz9477_fdb_dump, .fdb_add = ksz9477_fdb_add, .fdb_del = ksz9477_fdb_del,
@@ -1340,6 +1341,20 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)return dev->dev_ops->max_mtu (dev, port); } +static void ksz_phylink_mac_link_up (struct dsa_switch *ds,int port, +unsigned int mode, +phy_interface_t interface, +struct phy_device *phydev,int speed, +int duplex,bool tx_pause,bool rx_pause) +{ +struct ksz_device *dev = ds->priv; + +if (dev->dev_ops->phylink_mac_link_up) + dev->dev_ops->phylink_mac_link_up (dev, port, mode, interface, + phydev, speed, duplex, + tx_pause, rx_pause); +} +static int ksz_switch_detect (struct ksz_device *dev) {u8 id1, id2;
@@ -1413,6 +1428,7 @@ static const struct dsa_switch_ops ksz_switch_ops = { .phy_read = ksz_phy_read16, .phy_write = ksz_phy_write16, .phylink_get_caps = ksz_phylink_get_caps, + .phylink_mac_link_up = ksz_phylink_mac_link_up, .phylink_mac_link_down = ksz_mac_link_down, .port_enable = ksz_enable_port, .get_strings = ksz_get_strings,
drivers/net/dsa/microchip/ksz_common.h +5 -0
@@ -271,6 +271,11 @@ struct ksz_dev_ops {int (*max_mtu)(struct ksz_device *dev,int port);void (*freeze_mib)(struct ksz_device *dev,int port,bool freeze);void (*port_init_cnt)(struct ksz_device *dev,int port); +void (*phylink_mac_link_up)(struct ksz_device *dev,int port, +unsigned int mode, +phy_interface_t interface, +struct phy_device *phydev,int speed, +int duplex,bool tx_pause,bool rx_pause);void (*config_cpu_port)(struct dsa_switch *ds);int (*enable_stp_addr)(struct ksz_device *dev);int (*reset)(struct ksz_device *dev);
drivers/net/dsa/microchip/lan937x.h +4 -0
@@ -17,4 +17,8 @@ void lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);int lan937x_change_mtu (struct ksz_device *dev,int port,int new_mtu);void lan937x_phylink_get_caps (struct ksz_device *dev,int port,struct phylink_config *config); +void lan937x_phylink_mac_link_up (struct ksz_device *dev,int port, +unsigned int mode,phy_interface_t interface, +struct phy_device *phydev,int speed, +int duplex,bool tx_pause,bool rx_pause);#endif
drivers/net/dsa/microchip/lan937x_main.c +46 -0
58 lines not on this page · raw message
drivers/net/dsa/microchip/lan937x_reg.h +11 -0
@@ -139,6 +139,17 @@#define PORT_MII_RX_FLOW_CTRL BIT(3)#define PORT_GRXC_ENABLE BIT(0) +#define REG_PORT_XMII_CTRL_1 0x0301 +#define PORT_MII_NOT_1GBIT BIT(6) +#define PORT_MII_SEL_EDGE BIT(5) +#define PORT_RGMII_ID_IG_ENABLE BIT(4) +#define PORT_RGMII_ID_EG_ENABLE BIT(3) +#define PORT_MII_MAC_MODE BIT(2) +#define PORT_MII_SEL_M 0x3 +#define PORT_RGMII_SEL 0x0 +#define PORT_RMII_SEL 0x1 +#define PORT_MII_SEL 0x2 +/* 4 - MAC */ #define REG_PORT_MAC_CTRL_0 0x0400#define PORT_CHECK_LENGTH BIT(2)
Signature · 1 line
2.36.1
PATCH v15 12/13 net: dsa: microchip: lan937x: add phylink_mac_config support
In reply to Arun RamadossThis patch add support for phylink_mac_config dsa hook. It configures the mac for MII/RMII modes. The RGMII mode will be added in the future patches.
--- drivers/net/dsa/microchip/ksz_common.c | 12 +++++ drivers/net/dsa/microchip/ksz_common.h | 3 ++ drivers/net/dsa/microchip/lan937x.h | 3 ++ drivers/net/dsa/microchip/lan937x_main.c | 58 +++++++++++++++++++++++- 4 files changed, 74 insertions(+), 2 deletions(-)
drivers/net/dsa/microchip/ksz_common.c +12 -0
@@ -221,6 +221,7 @@ static const struct ksz_dev_ops lan937x_dev_ops = { .mirror_add = ksz9477_port_mirror_add, .mirror_del = ksz9477_port_mirror_del, .get_caps = lan937x_phylink_get_caps, + .phylink_mac_config = lan937x_phylink_mac_config, .phylink_mac_link_up = lan937x_phylink_mac_link_up, .fdb_dump = ksz9477_fdb_dump, .fdb_add = ksz9477_fdb_add,
@@ -1341,6 +1342,16 @@ static int ksz_max_mtu(struct dsa_switch *ds, int port)return dev->dev_ops->max_mtu (dev, port); } +static void ksz_phylink_mac_config (struct dsa_switch *ds,int port, +unsigned int mode, +const struct phylink_link_state *state) +{ +struct ksz_device *dev = ds->priv; + +if (dev->dev_ops->phylink_mac_config) + dev->dev_ops->phylink_mac_config (dev, port, mode, state); +} + static void ksz_phylink_mac_link_up(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface,
@@ -1428,6 +1439,7 @@ static const struct dsa_switch_ops ksz_switch_ops = { .phy_read = ksz_phy_read16, .phy_write = ksz_phy_write16, .phylink_get_caps = ksz_phylink_get_caps, + .phylink_mac_config = ksz_phylink_mac_config, .phylink_mac_link_up = ksz_phylink_mac_link_up, .phylink_mac_link_down = ksz_mac_link_down, .port_enable = ksz_enable_port,
drivers/net/dsa/microchip/ksz_common.h +3 -0
@@ -271,6 +271,9 @@ struct ksz_dev_ops {int (*max_mtu)(struct ksz_device *dev,int port);void (*freeze_mib)(struct ksz_device *dev,int port,bool freeze);void (*port_init_cnt)(struct ksz_device *dev,int port); +void (*phylink_mac_config)(struct ksz_device *dev,int port, +unsigned int mode, +const struct phylink_link_state *state); void (*phylink_mac_link_up)(struct ksz_device *dev, int port, unsigned int mode, phy_interface_t interface,
drivers/net/dsa/microchip/lan937x.h +3 -0
@@ -21,4 +21,7 @@ void lan937x_phylink_mac_link_up(struct ksz_device *dev, int port, unsigned int mode, phy_interface_t interface, struct phy_device *phydev, int speed, int duplex, bool tx_pause, bool rx_pause); +void lan937x_phylink_mac_config (struct ksz_device *dev,int port, +unsigned int mode, +const struct phylink_link_state *state);#endif
drivers/net/dsa/microchip/lan937x_main.c +56 -2
77 lines not on this page · raw message
Signature · 1 line
2.36.1
PATCH v15 13/13 net: dsa: microchip: add LAN937x in the ksz spi probe
In reply to Arun RamadossThis patch add the LAN937x part support in the existing ksz_spi_probe.
--- drivers/net/dsa/microchip/ksz_spi.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/net/dsa/microchip/ksz_spi.c +26 -0
@@ -166,6 +166,26 @@ static const struct of_device_id ksz_dt_ids[] = { .compatible = "microchip,ksz9567", .data = &ksz_switch_chips[KSZ9567] }, + { + .compatible = "microchip,lan9370", + .data = &ksz_switch_chips[LAN9370 ] + }, + { + .compatible = "microchip,lan9371", + .data = &ksz_switch_chips[LAN9371 ] + }, + { + .compatible = "microchip,lan9372", + .data = &ksz_switch_chips[LAN9372 ] + }, + { + .compatible = "microchip,lan9373", + .data = &ksz_switch_chips[LAN9373 ] + }, + { + .compatible = "microchip,lan9374", + .data = &ksz_switch_chips[LAN9374 ] + }, {}, };MODULE_DEVICE_TABLE (of, ksz_dt_ids);
@@ -182,6 +202,11 @@ static const struct spi_device_id ksz_spi_ids[] = { { "ksz9563" }, { "ksz8563" }, { "ksz9567" }, + { "lan9370" }, + { "lan9371" }, + { "lan9372" }, + { "lan9373" }, + { "lan9374" }, { }, };MODULE_DEVICE_TABLE (spi, ksz_spi_ids);
@@ -206,6 +231,7 @@ MODULE_ALIAS("spi:ksz9893");MODULE_ALIAS ("spi:ksz9563" );MODULE_ALIAS ("spi:ksz8563" );MODULE_ALIAS ("spi:ksz9567" ); +MODULE_ALIAS ("spi:lan937x" );MODULE_AUTHOR ("Tristram Ha <[email protected]>" );MODULE_DESCRIPTION ("Microchip ksz Series Switch SPI Driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.36.1
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 11 lines · On Fri, 1 Jul 2022 20:16:39 +0530 you wrote:
LAN937x is a Multi-Port 100BASE-T1 Ethernet Physical Layer switch compliant with the IEEE 802.3bw-2015 specification. The device provides 100 Mbit/s transmit and receive capability over a single Unshielded Twisted Pair (UTP) cable. LAN937x is successive revision of KSZ series switch.
This series of patches provide the DSA driver support for Microchip LAN937X switch through MII/RMII interface. The RGMII interface support will be added in the follow up series. LAN937x uses the most of functionality of KSZ9477.[...]
Here is the summary with links:
- [net-next,v15,01/13] dt-bindings: net: make internal-delay-ps based on phy-mode
https://git.kernel.org/netdev/net-next/c/528f7f1fadf1 - [net-next,v15,02/13] dt-bindings: net: dsa: dt bindings for microchip lan937x https://git.kernel.org/netdev/net-next/c/8926d94e5c50 - [net-next,v15,03/13] net: dsa: tag_ksz: add tag handling for Microchip LAN937x https://git.kernel.org/netdev/net-next/c/092f875131dc - [net-next,v15,04/13] net: dsa: microchip: generic access to ksz9477 static and reserved table https://git.kernel.org/netdev/net-next/c/457c182af597 - [net-next,v15,05/13] net: dsa: microchip: add DSA support for microchip LAN937x https://git.kernel.org/netdev/net-next/c/55ab6ffaf378 - [net-next,v15,06/13] net: dsa: microchip: lan937x: add dsa_tag_protocol https://git.kernel.org/netdev/net-next/c/99b16df0cd52 - [net-next,v15,07/13] net: dsa: microchip: lan937x: add phy read and write support https://git.kernel.org/netdev/net-next/c/ffaf1de2f62d - [net-next,v15,08/13] net: dsa: microchip: lan937x: register mdio-bus https://git.kernel.org/netdev/net-next/c/a50b35366c64 - [net-next,v15,09/13] net: dsa: microchip: lan937x: add MTU and fast_age support https://git.kernel.org/netdev/net-next/c/ab8823688f9e - [net-next,v15,10/13] net: dsa: microchip: lan937x: add phylink_get_caps support https://git.kernel.org/netdev/net-next/c/c14e878d4a4f - [net-next,v15,11/13] net: dsa: microchip: lan937x: add phylink_mac_link_up support https://git.kernel.org/netdev/net-next/c/f597d3ad75b8 - [net-next,v15,12/13] net: dsa: microchip: lan937x: add phylink_mac_config support https://git.kernel.org/netdev/net-next/c/a0cb1aa43825 - [net-next,v15,13/13] net: dsa: microchip: add LAN937x in the ksz spi probe https://git.kernel.org/netdev/net-next/c/c8fac9d0aa5a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html