From patchwork Thu Aug 17 15:06:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13356684 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11D54C30633 for ; Thu, 17 Aug 2023 15:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+CIUjJz5X6YmwGYl6Y60LBuGO6z6FXymx6vfdnK6xy4=; b=x1MCayfKvE9LNh wHasFqiQsiLOfVYw1Dhp6wARxqhQealngbxPdzAg2NwDX4nz05KvF/g1/Xax7LzFRuE4sGs1sVV0K oWMNS2VcYpVKVdmBGrzlGGtIPigeJE68Xw8vyl7489MCZcuP9qx8f/yA6LP/Kt1BS0nEPDPnJb52b lZG0a1UjN1f2DiCz8FmnSQ/rj0wFASTPqbt/7nYgW9M0lk3XnkozRgTD12bsHLqP3NRX1X9Kosd7s il7MgXS0YA22H++xG5PlWiWtzChfkrQ+TIfGqi2EY/Vui88m8MQzv07tN3zF0znf3uCNl26lFok4w UiWFtWfoDsdtWBWO43/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qWeaf-006dh3-2T; Thu, 17 Aug 2023 15:07:13 +0000 Received: from mail-db8eur05on2060b.outbound.protection.outlook.com ([2a01:111:f400:7e1a::60b] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qWeac-006deG-32 for linux-phy@lists.infradead.org; Thu, 17 Aug 2023 15:07:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DuAn7Z5k3N+SFy630s3FdWQEPNOuB9/TxCRYOm7va+54BpTW39XzoCXesHg3jvacnx5eD8kJAkQKuiuT0t23A3vM2Y8JA7zhRx8rYe0tvEXa63OmOska9Q5118kt6oZMjpO8i071tpipKqfi3CJZ+CY+Ce1K3sWg12hykjkjB02yxDLpqEZ9PNUN2Ij4UKggAVeGe6MvEHIWevHsBmalQLs4tcodoP6jtrBTCsip/Rkh8cGe16Wghjcby87r1WhBUt+tDTdxJYRLap/bcjySIND+Wq4XlrmFRZ1Nlb/Srb0LMzhgsOJ2gJny2l2MkqGYiSTBMnzlt+6M67zZelvM7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bUIQl1HEDGGbIBVkR3je1gD+kRiyoXmAxMUQgb9O/QM=; b=fZjN582XAiynSELAaSaEIPtH6ToRfYDdlLYm8prnbc0JFTTDO7xvsiwIWe9pojQwZ8cqDjKfUpjGAC/8ahGl+zeRrNYa20yZLb88AbGCmub5cisvoCC7UWv2P2nCCdqm65tgm3U7tgTpcrVihJMmoEjKGEW2zUV+j7oL3nVz/bVMhb+DlKxJ8pg6zfkMXWVa8s0yAXqGu9g9vt9t1K+Zv+rvmydW6cCoQi6ER2DQZotdEZ1e94YNx38AUVku9Kw5nURZ6zI8UAUOjUcsYSySomVWLCdToCaZQAgBhuta2SOzsBY9wwYT6m9GWQg5K30T6nwj6gJZLODHjOAJhH/gWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bUIQl1HEDGGbIBVkR3je1gD+kRiyoXmAxMUQgb9O/QM=; b=B1FYcm4wdwtPXwUUUVtenitnuCK4FCqpneRe2k7vXdvVDw2WFCJX3kzq7Bol6cISnPEOfd74kJPk0j7vu1qlUPz+sqCwyxqPOw/6WA4tFmNBcPYUP46QBQNwmAQmOS9C+M5kixMAlKR0b4OCwH2BaFL8W/XClybZ5FY5S39P4jc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by PAXPR04MB9469.eurprd04.prod.outlook.com (2603:10a6:102:2b4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Thu, 17 Aug 2023 15:07:00 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::d4ed:20a0:8c0a:d9cf%7]) with mapi id 15.20.6678.031; Thu, 17 Aug 2023 15:07:00 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: "Russell King (Oracle)" , Heiner Kallweit , Andrew Lunn , Florian Fainelli , Madalin Bucur , Ioana Ciornei , Camelia Groza , Li Yang , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sean Anderson , Maxime Chevallier , Vinod Koul , Kishon Vijay Abraham I Subject: [RFC PATCH net-next 3/8] phy: xgkr: add configuration interface for copper backplane Ethernet PHYs Date: Thu, 17 Aug 2023 18:06:39 +0300 Message-Id: <20230817150644.3605105-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230817150644.3605105-1-vladimir.oltean@nxp.com> References: <20230817150644.3605105-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR02CA0137.eurprd02.prod.outlook.com (2603:10a6:20b:28c::34) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB9469:EE_ X-MS-Office365-Filtering-Correlation-Id: 6422474e-6aae-486d-6e48-08db9f339b6b X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /e9CEaOMzYZkfHs4Tmm93zliZRfjXzx9FXOyKDuy0l8LcakWgH1vx9VFkYk1E7xmVN5H300yW5+kkbKKJiUxIO06Cm2Qx2Mnj90NOIeFQqytJhkb5/rVMRss1qLVVYJQrkvp85FlA76tIdRCyVV5jQE0k5dFmrg9i5HVn5D3Vb1khlKn2MLzZ2+TMWXnVmoEWhAOcZZoVMev2JM9FqMsjfZ63LTF5/pNqAn4iy1RIrvh6892UTnOZngVrxDt+EjkQJIPWcib7+/mj16e5Ep8cvbzYBPdBI3IrqwKshzPVJvkKPUP5VoCUFt3S9+NfDnNaO+uomGJ/bnQNT9IdwnTIxkmFZ+02CR3t0veMu34nCzqCgZ+boj9igx//9qbS0bWV5Gz188/UTNhr4ivf22pQxYrHUtsRz1fb0OdyqufXmJVi7roxctQ5P81lMKjHr50eIt3A8MFcnTvsXcu95ZGLazeZUsXGOE40xlKW0/o0dg++OZvA/Oub7opqJ46aCiZq1u5/H/qWfNFF0FdtDjxJLv6Id2wD4QxG6HReprGVEFWXWR4bNOR7uJPwsISj/K/hHA6/+68ucIcn6b9j2thbwfbDve6J2HZ5amxcfhcaVcm9BlLqHSXHKmq+CR6a6N5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(376002)(136003)(346002)(39860400002)(396003)(186009)(451199024)(1800799009)(2906002)(83380400001)(66899024)(26005)(86362001)(7416002)(478600001)(6506007)(36756003)(6666004)(2616005)(1076003)(6486002)(6512007)(52116002)(44832011)(5660300002)(41300700001)(316002)(54906003)(66946007)(66476007)(66556008)(4326008)(8676002)(8936002)(38350700002)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GYJq0N6DTqR18eS6E4g/09VmJoVa1AKYTjELMeAJ8TYWVSFUh3gSxOt1+jrsxAkBKuDUXkwiVHmW+khTTJmUtb2TM12/Y2EnRKU1v9uwKbLU/wGS6x55U2bYpFOPhelTYEtM+zrhwVGG4odOndO4MfL7uxN7AHQ1nNvmBC5a6Updi1EBcp0eazENH6a5+AZ5p16n3VetNSYKc+/rfztXhQACMSZvBf/l/lbc+s8E3wzctxIf6pHMFMzZ4G+HfJ/y0dgkcq5RuQctTM5pIMNUfLFoSXRFjXDISe3LS0lmBJckxmhWWKDB0EMqkIewpN/P5t83v/s5jzM1u4ub/GhOdTIQI3pbJAuJ/76DGbVX2OSqgk1yUg/PqT4BCttFVBMet9nU98pf4+e3/KNK3l/xrzvWVXzOc3VrCw4hE3k9cpgXDPcoYLD7aae1NCAVAJE07LDwzD09PlJ/n8G5dsWR+EWcQW8oPkAzktE5jMUQukz0tbxnpwCkPxAIelGU1gSfK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mYswtsVARlro3cDtcplSbU+wDLztxQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6422474e-6aae-486d-6e48-08db9f339b6b X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2023 15:07:00.5095 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DynSEa7MX++75CKUqv3EWMAenL8h9GP3lIWygOkb0y0LJfn5AsfrxFU2ImqK4Jnu7RxGhvrgW4owVHglK1X8/w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9469 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230817_080710_982563_59D9E773 X-CRM114-Status: GOOD ( 22.06 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org In Layerscape and QorIQ SoCs, compliance with the backplane Ethernet protocol is bolted on top of the SerDes lanes using an external IP core, that is modeled as an Ethernet PHY. This means that dynamic tuning of the electrical equalization parameters of the link needs to be communicated with the consumer of the generic PHY. Create a small layer of glue API between a networking PHY (dealing with the AN/LT logic for backplanes) and a generic PHY by extending the phy_configure() API with a new struct phy_configure_opts_xgkr. There are 2 directions of interest. In the "local TX training", the generic PHY consumer gets requests over the wire from the link partner regarding changes we should make to our TX equalization. In the "remote TX training" direction, the generic PHY is the producer of requests, based on its RX status, and the generic PHY consumer polls for these requests until we are happy. Each request is also sent (externally to the generic PHY layer) to the link partner board, for it to adjust its TX equalization. Signed-off-by: Vladimir Oltean --- include/linux/phy/phy-xgkr.h | 165 +++++++++++++++++++++++++++++++++++ include/linux/phy/phy.h | 4 + 2 files changed, 169 insertions(+) create mode 100644 include/linux/phy/phy-xgkr.h diff --git a/include/linux/phy/phy-xgkr.h b/include/linux/phy/phy-xgkr.h new file mode 100644 index 000000000000..8accfb1002a0 --- /dev/null +++ b/include/linux/phy/phy-xgkr.h @@ -0,0 +1,165 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2023 NXP + */ + +#ifndef __PHY_XGKR_H_ +#define __PHY_XGKR_H_ + +struct phy; + +enum coef_status { + COEF_STAT_NOT_UPDATED = 0, + COEF_STAT_UPDATED = 1, + COEF_STAT_MIN = 2, + COEF_STAT_MAX = 3, +}; + +enum coef_update { + COEF_UPD_HOLD = 0, + COEF_UPD_INC = 1, + COEF_UPD_DEC = 2, +}; + +struct c72_coef_update { + enum coef_update com1; + enum coef_update coz; + enum coef_update cop1; + bool preset; + bool init; +}; + +struct c72_coef_status { + enum coef_status com1; + enum coef_status coz; + enum coef_status cop1; +}; + +enum xgkr_phy_configure_type { + XGKR_CONFIGURE_LOCAL_TX, + XGKR_CONFIGURE_REMOTE_TX, + XGKR_CONFIGURE_LT_DONE, +}; + +/* Adjust PHY TX equalization in response to a C72 coefficient + * update request from the link partner + */ +struct xgkr_phy_configure_local_tx { + /* input to PHY */ + struct c72_coef_update update; + /* output from PHY */ + struct c72_coef_status status; +}; + +/* Query the PHY RX quality in order to compute a C72 coefficient update + * request to the link partner to improve that. Optional callback to see + * how the link partner reacted to the update request (which is echoed back + * unmodified). The coefficient status is only valid if there was no error + * during its propagation. + */ +struct xgkr_phy_configure_remote_tx { + /* output from PHY */ + bool rx_ready; + struct c72_coef_update update; + /* input to PHY */ + void (*cb)(void *cb_priv, int err, struct c72_coef_update update, + struct c72_coef_status status); + void *cb_priv; +}; + +/** + * struct phy_configure_opts_xgkr - 10GBase-KR configuration + * + * This structure is used to represent the configuration state of a + * 10GBase-KR Ethernet Copper Backplane PHY. + */ +struct phy_configure_opts_xgkr { + enum xgkr_phy_configure_type type; + union { + struct xgkr_phy_configure_local_tx local_tx; + struct xgkr_phy_configure_remote_tx remote_tx; + }; +}; + +/* Some helpers */ +static inline enum coef_update coef_update_opposite(enum coef_update update) +{ + switch (update) { + case COEF_UPD_INC: + return COEF_UPD_DEC; + case COEF_UPD_DEC: + return COEF_UPD_INC; + default: + return COEF_UPD_HOLD; + } +} + +static inline void coef_update_clamp(enum coef_update *update, + enum coef_status status) +{ + if (*update == COEF_UPD_INC && status == COEF_STAT_MAX) + *update = COEF_UPD_HOLD; + if (*update == COEF_UPD_DEC && status == COEF_STAT_MIN) + *update = COEF_UPD_HOLD; +} + +static inline bool coef_update_is_all_hold(const struct c72_coef_update *update) +{ + return update->coz == COEF_UPD_HOLD && + update->com1 == COEF_UPD_HOLD && + update->cop1 == COEF_UPD_HOLD; +} + +#define C72_COEF_UPDATE_BUFSIZ 64 +#define C72_COEF_STATUS_BUFSIZ 64 + +static inline const char *coef_update_to_string(enum coef_update coef) +{ + switch (coef) { + case COEF_UPD_HOLD: + return "HOLD"; + case COEF_UPD_INC: + return "INC"; + case COEF_UPD_DEC: + return "DEC"; + default: + return "unknown"; + } +} + +static inline const char *coef_status_to_string(enum coef_status coef) +{ + switch (coef) { + case COEF_STAT_NOT_UPDATED: + return "NOT_UPDATED"; + case COEF_STAT_UPDATED: + return "UPDATED"; + case COEF_STAT_MIN: + return "MIN"; + case COEF_STAT_MAX: + return "MAX"; + default: + return "unknown"; + } +} + +static void inline c72_coef_update_print(const struct c72_coef_update *update, + char buf[C72_COEF_UPDATE_BUFSIZ]) +{ + sprintf(buf, "INIT %d, PRESET %d, C(-1) %s, C(0) %s, C(+1) %s", + update->init, update->preset, + coef_update_to_string(update->com1), + coef_update_to_string(update->coz), + coef_update_to_string(update->cop1)); +} + +static inline void c72_coef_status_print(const struct c72_coef_status *status, + char buf[C72_COEF_STATUS_BUFSIZ]) +{ + sprintf(buf, "C(-1) %s, C(0) %s, C(+1) %s", + coef_status_to_string(status->com1), + coef_status_to_string(status->coz), + coef_status_to_string(status->cop1)); +} + +#endif /* __PHY_XGKR_H_ */ diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 7e10761303fc..8ef7de7d2a90 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -19,6 +19,7 @@ #include #include #include +#include struct phy; @@ -61,11 +62,14 @@ enum phy_media { * the DisplayPort protocol. * @lvds: Configuration set applicable for phys supporting * the LVDS phy mode. + * @xgkr: Configuration set applicable for phys supporting + * the 10GBase-KR phy mode. */ union phy_configure_opts { struct phy_configure_opts_mipi_dphy mipi_dphy; struct phy_configure_opts_dp dp; struct phy_configure_opts_lvds lvds; + struct phy_configure_opts_xgkr xgkr; }; /**