Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6458929rwp; Tue, 18 Jul 2023 00:07:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlGchgbwVaF4T1JuImKVwtOKBXVAhXv9NlVdrmSnDoesZ0PHFjilXJob+RhdmSbF4VikvKGW X-Received: by 2002:a05:6808:1ab1:b0:3a3:eabe:7fc0 with SMTP id bm49-20020a0568081ab100b003a3eabe7fc0mr1790086oib.7.1689664067499; Tue, 18 Jul 2023 00:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689664067; cv=none; d=google.com; s=arc-20160816; b=O2GbOWoi9ea1mT0soecBduQoLyNwh+ye8AQwuPsKJiQxXlsSefCR6ONkRxg9PGmmfi uDpFDEjdTLcEAhzp+6ZpxvTInJUotXaD94+N4iYgXsKNKryh5lDUjRgdrHrJzbaZSoN8 XupwAR7JZFRjTaCQz6wqYyqK7NJzWHywEnrLhWbMInhlYmuQxx8WpfTtxm3Qol91w9rS xY0SmmFQg7XcgaNCJlxcNB02KIysk7YVWxylpiDnJFyzDQFdYKd0PmEoPzv1ExUrAD8G sKnZlT+uZr8utH/UMPdt2HOJYASMWnNeDFRy8+b8lNh2OukX4GFQ3PqoVoI7MXRQKOTc Uo9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xApnMAcH/JoVfVzJ9XWUXSyQ0risnVdCKw+SVT9maDo=; fh=XCRuunfIcC4qfEd8J69TyF5JmLPkbv4obhD0Wh+oe4M=; b=Tw9s7Dl7F6zAXG8CtoRbtxF3ixwHxS7TD4cDqPiIxayeS2L3yRfBOfn8qgwzq4cChc 7DfSavtVU83uxV8yzk7awCoWJDWeKlBQIm3BUE3XTW05svpxPB2vB1ARhedO0ppS6CrP qyj8rWiNP7doNc+CNogEwxGji4quBRSxdJnox0NghWX6ZjSsiUBaWFlHTu5lFnYhWmye umttXuvQU5XoESNlswCIQrzSfqkLbgg7WPdVyeccIpV2eoAKiSfGOsHB4v+MSg6+/+Dc nkdHsHW/cHuq6VtNy2ptC8oCpPtjATVGryzE4muIyYbypdt9mQGf6/9+Kf6mOXbxBHyF i5Yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=N1l9HHlJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g62-20020a636b41000000b0055c7ed70756si1096057pgc.451.2023.07.18.00.07.34; Tue, 18 Jul 2023 00:07:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=N1l9HHlJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231522AbjGRHAb (ORCPT + 99 others); Tue, 18 Jul 2023 03:00:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbjGRHAY (ORCPT ); Tue, 18 Jul 2023 03:00:24 -0400 Received: from mta-64-225.siemens.flowmailer.net (mta-64-225.siemens.flowmailer.net [185.136.64.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8D4C1716 for ; Tue, 18 Jul 2023 00:00:18 -0700 (PDT) Received: by mta-64-225.siemens.flowmailer.net with ESMTPSA id 202307180700163730c5efcd6844d1a2 for ; Tue, 18 Jul 2023 09:00:16 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=michael.haener@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=xApnMAcH/JoVfVzJ9XWUXSyQ0risnVdCKw+SVT9maDo=; b=N1l9HHlJxjNtJjG/rpr8/eS1V1oW7rLeyDyYMHIV5swa7Jea0aHJNunLg2+mLRxIYxYpeB OMXnfmctGvREM/dsG3c+ZZyoJsOjekmQoXM5CjRR96HsEFwzwcfTRlH1Agy/PB3Jny+Arlyz PIEYlLBfcKrH7rGYUsLdUqDvtuIxc=; From: "M. Haener" To: netdev@vger.kernel.org Cc: Michael Haener , linux-kernel@vger.kernel.org, Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Alexander Sverdlin Subject: [PATCH v3 3/3] net: dsa: mv88e632x: Add SERDES ops Date: Tue, 18 Jul 2023 08:59:31 +0200 Message-ID: <20230718065937.10713-4-michael.haener@siemens.com> In-Reply-To: <20230718065937.10713-1-michael.haener@siemens.com> References: <20230718065937.10713-1-michael.haener@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-664519:519-21489:flowmailer X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Haener The 88e632x family has several SERDES 100/1000 blocks. By adding these operations, these functionalities can be used. Signed-off-by: Michael Haener --- Changelog: v3: rebased onto main branch v2: rebased onto Russell Kings series dsa/88e6xxx/phylink drivers/net/dsa/mv88e6xxx/chip.c | 18 ++++++++++++++ drivers/net/dsa/mv88e6xxx/serdes.c | 39 ++++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/serdes.h | 9 +++++++ 3 files changed, 66 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 7e8aaa1383c6..4750db8f7e58 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -4909,10 +4909,19 @@ static const struct mv88e6xxx_ops mv88e6320_ops = { .reset = mv88e6352_g1_reset, .vtu_getnext = mv88e6185_g1_vtu_getnext, .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, + .serdes_get_lane = mv88e6320_serdes_get_lane, + .serdes_read = mv88e6320_serdes_read, + .serdes_write = mv88e6320_serdes_write, + .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, .gpio_ops = &mv88e6352_gpio_ops, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6352_ptp_ops, .phylink_get_caps = mv88e6185_phylink_get_caps, + .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, + .serdes_get_strings = mv88e6352_serdes_get_strings, + .serdes_get_stats = mv88e6352_serdes_get_stats, + .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, + .serdes_get_regs = mv88e6352_serdes_get_regs, }; static const struct mv88e6xxx_ops mv88e6321_ops = { @@ -4955,10 +4964,19 @@ static const struct mv88e6xxx_ops mv88e6321_ops = { .reset = mv88e6352_g1_reset, .vtu_getnext = mv88e6185_g1_vtu_getnext, .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, + .serdes_get_lane = mv88e6320_serdes_get_lane, + .serdes_read = mv88e6320_serdes_read, + .serdes_write = mv88e6320_serdes_write, + .serdes_irq_mapping = mv88e6352_serdes_irq_mapping, .gpio_ops = &mv88e6352_gpio_ops, .avb_ops = &mv88e6352_avb_ops, .ptp_ops = &mv88e6352_ptp_ops, .phylink_get_caps = mv88e6185_phylink_get_caps, + .serdes_get_sset_count = mv88e6352_serdes_get_sset_count, + .serdes_get_strings = mv88e6352_serdes_get_strings, + .serdes_get_stats = mv88e6352_serdes_get_stats, + .serdes_get_regs_len = mv88e6352_serdes_get_regs_len, + .serdes_get_regs = mv88e6352_serdes_get_regs, }; static const struct mv88e6xxx_ops mv88e6341_ops = { diff --git a/drivers/net/dsa/mv88e6xxx/serdes.c b/drivers/net/dsa/mv88e6xxx/serdes.c index b988d47ecbdd..411fe9ac421a 100644 --- a/drivers/net/dsa/mv88e6xxx/serdes.c +++ b/drivers/net/dsa/mv88e6xxx/serdes.c @@ -17,6 +17,45 @@ #include "port.h" #include "serdes.h" +int mv88e6320_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device, + int reg, u16 *val) +{ + return mv88e6xxx_phy_page_read(chip, lane, + MV88E6320_SERDES_PAGE_FIBER, + reg, val); +} + +int mv88e6320_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg, + u16 val) +{ + return mv88e6xxx_phy_page_write(chip, lane, + MV88E6320_SERDES_PAGE_FIBER, + reg, val); +} + +int mv88e6320_serdes_get_lane(struct mv88e6xxx_chip *chip, int port) +{ + u8 cmode = chip->ports[port].cmode; + int lane = -ENODEV; + + switch (port) { + case 0: + if (cmode == MV88E6XXX_PORT_STS_CMODE_100BASEX || + cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX || + cmode == MV88E6XXX_PORT_STS_CMODE_SGMII) + lane = MV88E6320_PORT0_LANE; + break; + case 1: + if (cmode == MV88E6XXX_PORT_STS_CMODE_100BASEX || + cmode == MV88E6XXX_PORT_STS_CMODE_1000BASEX || + cmode == MV88E6XXX_PORT_STS_CMODE_SGMII) + lane = MV88E6320_PORT1_LANE; + break; + } + + return lane; +} + int mv88e6352_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device, int reg, u16 *val) { diff --git a/drivers/net/dsa/mv88e6xxx/serdes.h b/drivers/net/dsa/mv88e6xxx/serdes.h index d3e83c674ef7..9dcc9e581c05 100644 --- a/drivers/net/dsa/mv88e6xxx/serdes.h +++ b/drivers/net/dsa/mv88e6xxx/serdes.h @@ -14,6 +14,10 @@ struct phylink_link_state; +#define MV88E6320_PORT0_LANE 0x0c +#define MV88E6320_PORT1_LANE 0x0d +#define MV88E6320_SERDES_PAGE_FIBER 0x01 + #define MV88E6352_ADDR_SERDES 0x0f #define MV88E6352_SERDES_PAGE_FIBER 0x01 #define MV88E6352_SERDES_IRQ 0x0b @@ -116,14 +120,19 @@ struct phylink_link_state; int mv88e6xxx_pcs_decode_state(struct device *dev, u16 bmsr, u16 lpa, u16 status, struct phylink_link_state *state); +int mv88e6320_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6341_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6390_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6390x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); int mv88e6393x_serdes_get_lane(struct mv88e6xxx_chip *chip, int port); +int mv88e6320_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device, + int reg, u16 *val); int mv88e6352_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device, int reg, u16 *val); int mv88e6390_serdes_read(struct mv88e6xxx_chip *chip, int lane, int device, int reg, u16 *val); +int mv88e6320_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg, + u16 val); int mv88e6352_serdes_write(struct mv88e6xxx_chip *chip, int lane, int reg, u16 val); unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip, -- 2.41.0