From patchwork Fri Jun 17 20:33:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12885986 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD67DC43334 for ; Fri, 17 Jun 2022 20:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383410AbiFQUhi (ORCPT ); Fri, 17 Jun 2022 16:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382807AbiFQUfr (ORCPT ); Fri, 17 Jun 2022 16:35:47 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150041.outbound.protection.outlook.com [40.107.15.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5B9A5F25B; Fri, 17 Jun 2022 13:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V1wGcaXNGKWZxByN3dQZ3tlnbVt4mCWYnlOgiG96zEZo38dXRAuEtAwHHV6ndVZsLeKMRBT0CJZsjQc/t4fe+gPmldg+EXDqxa7nxLFUrWKbKELGWOx4F/vBof/CtfzZn9/D8D+V3OmUpvqZ6Gj6p9D/jPwU58Vr55Hw9UacgBl47uKvbaTMJeGFQ/5zya7wXvH0YSBqlm/lnwzol+RyZY3HdCywB2u3ONKg6W320odpThodLrALTuPnaJndaSyjcbvaaTCCvJ1V7W0K74OPRw5D7R5W0BicLrPkKnhUlIvG32doFNUaSaL4gnkFtl6VvjbHvd9kEU1q7cUSlfWm5Q== 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=CADaDmRzmKOMdy31UT6TFsHjJE6WK1kWCCSE8NrVWmo=; b=lUY/937sbn4kiPn//Gt0JvMTQ7hjR6N2Et7Ma3uEQeciLS4uXcF2trFHG2DPmd6AAJqwvpM4oBrRVP1djpUo0eUmmpz1Ac29akINqQbb/wJVvAWG535vBxwmDQKeJAfdGMiTb1bPqLo7rJV0X8s1bTIKNjmio2Epep4xmgnzQ77krYsVfJMCCoBWv+wKvAnaV+OjLw4cuMcEFhSzJWbRpClk/1ceL+hIU1+5LxVMpUVC+UHQJFyzULg7LlPBcXKYXZtANw8KknS49//89dQ2CyfOwvB+ypcVI7PBWKy6WoRQ6bLY30VoplEsSwzamzHsn0ZVo2xfY0KV01XfpwLVhQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CADaDmRzmKOMdy31UT6TFsHjJE6WK1kWCCSE8NrVWmo=; b=dqqayYS+DAuUUIzfL0WSVc7nDzVZt6bwmYPS6/6iYF817GIp4X+mxEFI/wn2bdk6ZPn8WTdKWw0V3n4TWQnDsq/Y5efidZXIeRjDSfje138w+pZwjWIXvxGx2l937/dtJQDjXy2eQINfnF+8DlgD6broxKdyAbCq4qe8yPyRP1xdSfjrudtXvUvj5qt/BDUFI9CkHgn/2Bk4wCvOjwsdwh9TxKWRVzxJhit2IRLyMNfj0nlNN06aHiYe9fg9GgbfdIADeA517/APOe0wJyhuGHfv1Kel5Ky+cRGUshKmB5xePJglIJyU+N7pBuusqzwNNlVGKfBW5eq1iWxRCvk6lQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from VI1PR03MB4973.eurprd03.prod.outlook.com (2603:10a6:803:c5::12) by AS8PR03MB6838.eurprd03.prod.outlook.com (2603:10a6:20b:29b::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.16; Fri, 17 Jun 2022 20:34:17 +0000 Received: from VI1PR03MB4973.eurprd03.prod.outlook.com ([fe80::d18f:e481:f1fa:3e8d]) by VI1PR03MB4973.eurprd03.prod.outlook.com ([fe80::d18f:e481:f1fa:3e8d%7]) with mapi id 15.20.5353.016; Fri, 17 Jun 2022 20:34:17 +0000 From: Sean Anderson To: "David S . Miller" , Jakub Kicinski , Madalin Bucur , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Paolo Abeni , Russell King , Eric Dumazet , Sean Anderson Subject: [PATCH net-next 22/28] net: fman: memac: Add serdes support Date: Fri, 17 Jun 2022 16:33:06 -0400 Message-Id: <20220617203312.3799646-23-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220617203312.3799646-1-sean.anderson@seco.com> References: <20220617203312.3799646-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0384.namprd13.prod.outlook.com (2603:10b6:208:2c0::29) To VI1PR03MB4973.eurprd03.prod.outlook.com (2603:10a6:803:c5::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f2d721bb-1c6c-458b-8289-08da50a0c041 X-MS-TrafficTypeDiagnostic: AS8PR03MB6838:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lFPUA0rzSgBchrganU6/BQWrFy9A9cxfDsvLrC6HqTpg7F2z3c0UoETlm7G5psEZxVGqx/NPtGdgu0i814W0WzTTtzlHkNiSgvfH4HXKSztUCie4zLUj3pEqORn7qZR0tgMHHLBk/hFKaHq8yUMucGk+2iIiI/XUOGB8uU7belhJjYJCgWVVZ0cqOkIoBQLVtezZlCcH0+vLVpYY1PbWC6/OT6o1jww8uwLEpb9p8Q+kxymRge2a21zFawIjFpJJEwI3efhvEOBswfAOZx8NfcuJt/9JhXo/eUz7s2Q17IWxfsgVcqTAGdAk8XVC1ZksP7umk5ORuf8coe9r3k0C00q+91m+5bthJQP0Cm7hiYcvN+cgMijX0Liyj7YoIL+6h6kIDVxO9Y68ZlZ5MRjoiD3YUwCrjGh3N1tARS2qcXgqyMflLQaGzdi8ZeiVBFM9CRpVMpfyZN1jd6Wtg5dWJcIrAaHnj8Xi4If5fcJXZyRY6vCQFh0rBtzZpbrDqXo6/AzmUuclKGtpdT+0qnHTGDplXr5iLus2LBcWlj27pQGrm0oiFlpOhuHDlK3Yubp9TQZD4F6ijr63FurPhBkQ1qo3md/5ItbftnDHPVSHwrOzFr1gOUbvEN/UtQhiOvrwJLm7zlKsga2jmingD8LxcskFS9tKo5GIyjxMha4lSdZokBypK7hFu0YfjhcFWCRcsbrvV+v5hk8EUAJUcdV4ww== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR03MB4973.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(366004)(44832011)(2616005)(38100700002)(38350700002)(8936002)(52116002)(26005)(316002)(36756003)(6512007)(2906002)(4326008)(66476007)(6486002)(66556008)(6506007)(5660300002)(107886003)(83380400001)(8676002)(86362001)(186003)(66946007)(6666004)(1076003)(54906003)(110136005)(498600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GiBal5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HCGpTFTTgaeszu83JkMNAjcMgxnQfmYdgVSq5dkF3b9Vxdure3MCP2TRCwwA1tcAA7EI/E5fpanQY09pzAvDcSycpnryLB2qhYQColty9AzmsaHJq7K8iclpESvBZ3+pyVWV/H2OxECo6ww7G1w4h6zKEX3qUPNyATQac2a0QTEYZmUSoXm/hD5KqfR4Hq/88BILTC8geRKxrE9eAiSpxjwEKUDL4YYhEfb3IklLbn/DHYsG/XzPRGkFZU88y/LWWOOY81Vghwy7zhAnJfkrs2Y3ME4nQh+5cB/dTyDuS7QgdhKqNJHr6ZAiNi1BvH3A6M+Xr9qq8qDt7nvyrzluLHwpPeQyj0CatcEZQPsZzT1sf8OVXkwqNHAys7qIa53cQp4st6PzC10AA0LIG3yXARngiY79Y9e5N7/GAUIob3n7N/OTtnwTQURyrDa9VszZJsB+9PbXJUoyaZQVybVt+WpU0RfQvFL3cmLWjwj7uwYFU8rJM1VfqwkUXTaO6KNdij8oHJwGDx9ISr5sjvawo8AmKdTFCKIsYvpkLfmUuSX4WlhvvutKOYA06ntOl2gHagHcvLzug4Y3/lrE3AC0z6Owf6bJi5QYTDUx3BiueDC+YOApuHOA2q29YbdKvORplvt8fkKp63qVMVefEreS0D7xfCu+7Y+9ERIJN/O/snScmQNuUQM= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2d721bb-1c6c-458b-8289-08da50a0c041 X-MS-Exchange-CrossTenant-AuthSource: VI1PR03MB4973.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 20:34:17.8104 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Kadab4utTRs3nEB9e44iA2upMTMWKAgmT6xn/oQT2eYnnNC/UVA6S0PEy/wxQWmRLZ4hUlTxvQfwVBnQCXiiwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6838 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds support for using a serdes which has to be configured. This is primarly in preparation for the next commit, which will then change the serdes mode dynamically. Signed-off-by: Sean Anderson --- .../net/ethernet/freescale/fman/fman_memac.c | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c index 4d4c235d5dbc..5598a74ec559 100644 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c @@ -13,6 +13,7 @@ #include #include #include +#include #include /* PCS registers */ @@ -324,6 +325,7 @@ struct fman_mac { void *fm; struct fman_rev_info fm_rev_info; bool basex_if; + struct phy *serdes; struct phy_device *pcsphy; bool allmulti_enabled; }; @@ -1206,17 +1208,55 @@ int memac_initialization(struct mac_device *mac_dev, } } + memac->serdes = devm_of_phy_get(mac_dev->dev, mac_node, "serdes"); + if (PTR_ERR(memac->serdes) == -ENODEV) { + memac->serdes = NULL; + } else if (IS_ERR(memac->serdes)) { + err = PTR_ERR(memac->serdes); + dev_err_probe(mac_dev->dev, err, "could not get serdes\n"); + goto _return_fm_mac_free; + } else { + err = phy_init(memac->serdes); + if (err) { + dev_err_probe(mac_dev->dev, err, + "could not initialize serdes\n"); + goto _return_fm_mac_free; + } + + err = phy_power_on(memac->serdes); + if (err) { + dev_err_probe(mac_dev->dev, err, + "could not power on serdes\n"); + goto _return_phy_exit; + } + + if (memac->phy_if == PHY_INTERFACE_MODE_SGMII || + memac->phy_if == PHY_INTERFACE_MODE_1000BASEX || + memac->phy_if == PHY_INTERFACE_MODE_2500BASEX || + memac->phy_if == PHY_INTERFACE_MODE_QSGMII || + memac->phy_if == PHY_INTERFACE_MODE_XGMII) { + err = phy_set_mode_ext(memac->serdes, PHY_MODE_ETHERNET, + memac->phy_if); + if (err) { + dev_err_probe(mac_dev->dev, err, + "could not set serdes mode to %s\n", + phy_modes(memac->phy_if)); + goto _return_phy_power_off; + } + } + } + if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) { struct phy_device *phy; err = of_phy_register_fixed_link(mac_node); if (err) - goto _return_fm_mac_free; + goto _return_phy_power_off; fixed_link = kzalloc(sizeof(*fixed_link), GFP_KERNEL); if (!fixed_link) { err = -ENOMEM; - goto _return_fm_mac_free; + goto _return_phy_power_off; } mac_dev->phy_node = of_node_get(mac_node); @@ -1245,6 +1285,10 @@ int memac_initialization(struct mac_device *mac_dev, goto _return; +_return_phy_power_off: + phy_power_off(memac->serdes); +_return_phy_exit: + phy_exit(memac->serdes); _return_fixed_link_free: kfree(fixed_link); _return_fm_mac_free: