Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EFDCC433DB for ; Fri, 22 Jan 2021 15:46:36 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0299D20702 for ; Fri, 22 Jan 2021 15:46:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0299D20702 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vPTI9TUM5595CEcWph74Dlvn0yyZglAC9FyRa1lSzyk=; b=loZ1vqd4Av/E/iP2gLzFJJ5C3 5ha5gYnSn96LO9V856CwTZjHcSh0+WzdhXQS07UQSNBtumFJOjV32JcuIO7pwPyxqMkFro9Uht5p8 IdnmEi4u4heCk+/bexD0q/fREto9ppFLh2JNKKsEVB0Z2sOSAgnZvRhjADbq8wSt5y1yfS1QJ9AHx ENa26YdSriLf7MHvlTMcmIaZWT6nfBGF5LHo8hjWI8ff52w5o3OOzIqxjm8HXQTdqo0aEe1ui8owg bZBOflEHXZ1QOdJGFpCqL+ZK2mJB4E+OoFcdYXFzeCTpx12kfkz+cBvpUJsomq+dpLKJZDvkvHSc3 VDC2geERw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2yc2-0005cg-89; Fri, 22 Jan 2021 15:44:38 +0000 Received: from mail-he1eur04on061e.outbound.protection.outlook.com ([2a01:111:f400:fe0d::61e] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l2ybx-0005ab-7F for linux-arm-kernel@lists.infradead.org; Fri, 22 Jan 2021 15:44:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VbRoIfNeim54e4fyb/qfpwxTkNZ3+VRpsiEjgJvSGdG4P0MSPwkA47xZDTpmPSJaTMC8m6F/yQhjh84LrYSk5gRSpmzbpBOv9PEW2ksP6dkNI16dpeiyetMGr3oUmQRKAh05jBzJnRkp706tmiAJYpziFXQFWqTrGmpp2zprkFu2bf5qhsoRbiQ9gsKJswzu/AZDewDn9iEOD3CI/k6yU/Nl9Z3g4rH1NBHTs75YzH6CZwF2HMAYtqi/lPi7WnD/7NKMm17hutj818TMZHxjn3r62+WgewbIXSPDZ2VLkwqoNETxZ9aZYvYlCY3PBRlRrGXGF6Z11nOfNw3FCjjtuw== 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-SenderADCheck; bh=iJ2smfaUneArAo4LdK1zXMSBOITFv94TpLE+4NmDJgE=; b=Tr4ogXHhef/4jaVR9pzRIlOuR5KChajh6JtXNxUkkIDLqYBDohbCALnJGd6LTkJrzZKXU3AaOT1k9of4JK4VdLQvKVDQjqZtOIO5o0nnMGVmxzYFb2LazvUSO/8bQAtez8OD7g811ZXVNr0h1MgKOGiZjungMxWJEWFwS/iskiUhUTVEQ1CFVuCBNMKzkn65VZ9VJAwZxhQcRhBkkoM6SGuLNL5Hn8AotsImg/iv2ZfVDg6w631CGa/VO4jn8MmIUBwENTORd80xkSqWgmv08ZhTw/ErokLNBrQgbbJvLBaOgQ1QpRWMq9PQab2k4AnADstbfr4oDMAIdRRYPSjtdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iJ2smfaUneArAo4LdK1zXMSBOITFv94TpLE+4NmDJgE=; b=MopWTBgRkl5yCsc2o/1byESl5EAOLwjFP3Keuw6lrpnbcJ21ye0Wu+K03FE92DWYVWOVfqPG73qBXvz3WZikpac2iB7f1oPsa8UiROmOp2tW20TAZhrfPnOpzstRlL2tt1ZL3+q43TvqpBsx1VGVCVj9uopSySblhmSgcvMxONs= Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) by AM0PR0402MB3443.eurprd04.prod.outlook.com (2603:10a6:208:1b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Fri, 22 Jan 2021 15:44:16 +0000 Received: from AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42]) by AM0PR04MB5636.eurprd04.prod.outlook.com ([fe80::e90e:b1d6:18a2:2d42%5]) with mapi id 15.20.3784.015; Fri, 22 Jan 2021 15:44:16 +0000 From: Calvin Johnson To: Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Cristi Sovaiala , Florin Laurentiu Chiculita , Ioana Ciornei , Madalin Bucur , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap Subject: [net-next PATCH v4 05/15] net: phy: Introduce fwnode_get_phy_id() Date: Fri, 22 Jan 2021 21:12:50 +0530 Message-Id: <20210122154300.7628-6-calvin.johnson@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210122154300.7628-1-calvin.johnson@oss.nxp.com> References: <20210122154300.7628-1-calvin.johnson@oss.nxp.com> X-Originating-IP: [14.142.151.118] X-ClientProxiedBy: SG2PR06CA0117.apcprd06.prod.outlook.com (2603:1096:1:1d::19) To AM0PR04MB5636.eurprd04.prod.outlook.com (2603:10a6:208:130::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv03152.swis.in-blr01.nxp.com (14.142.151.118) by SG2PR06CA0117.apcprd06.prod.outlook.com (2603:1096:1:1d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Fri, 22 Jan 2021 15:44:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4e049d92-9a23-47e9-413b-08d8beec931e X-MS-TrafficTypeDiagnostic: AM0PR0402MB3443: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uGhNar0+3+Hu9OA5+J0K25Ax4xRXdjOcylSjpNEH59l+ElY9jSGcXHrS3/qlA5q5wDtovyM91LRWIRenvf66dRh29QMs3y3TrUJjcuYUNLqbEdaRaxMmmvYmn49QQ5vC3gihs1FhIctXW5hRvw0jMrCXiwKM0axDpwuohznJ+tGjl9kK4yy+5uiHd9aKRXJpaLrRuPZRKaR0/CuBJC0qxjfMWMLiNOVq4P++o/WbbjLwBVejV6vBDKcXUYAg8oq73dVpeMClHUb6QWnbTTRPU8yPt3KR1wbkUecDC++PhYni0E8Y+4IK6Wg+dSJ9Efgb5hwYqoheC8xipmfcAuptPFD4af9jYnXN34nXrWE1NWvspo8m/UtLjGHtrJpqwIsKS7vOsQYdBQa3CfGs2KX7XH9M4aHagIM2Zq5eLqlOIVdUdawLglHe3Ca8FdnC4E4CepaRK7i0a5jTFYy91fhnxg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5636.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(136003)(396003)(39850400004)(366004)(2906002)(6506007)(921005)(6512007)(6666004)(186003)(5660300002)(1006002)(16526019)(52116002)(54906003)(956004)(55236004)(8676002)(66556008)(8936002)(66476007)(2616005)(66946007)(1076003)(478600001)(26005)(110136005)(86362001)(316002)(7416002)(4326008)(6486002)(44832011)(110426009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?+6P6wZqMBeZIe9KWsOi0Muxreb/tWPy7zXa/K9yNyxh6EoIi9mo0FTzhY/Xl?= =?us-ascii?Q?vGnTL1enYQUxMv80Q8y5qyNwrHBij2urqMpaZ7cykOc/+fzlz1g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TajPpsTsn5scvqufqUbJ0YCiHUnJT1xKxURB8sYDiPLpJFX9MQRM?= =?us-ascii?Q?JFBuTSeeXEqZnpq2GX+DpnOuOyF6IFiFDZfi4Heyysc5FN0nkKBiiBbIpFOO?= =?us-ascii?Q?rvFvn7ZH?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e049d92-9a23-47e9-413b-08d8beec931e X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5636.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2021 15:44:16.5676 (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: kpSzEIF3cCBE/r/V7i4Y4sivPpIw1S6oy+YHLVrjbwIIzvc+ikG721OpNtVugzb0eFIVF2gX+NWJ+vvCO/dydQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3443 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210122_104433_293094_CFA16154 X-CRM114-Status: GOOD ( 17.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Calvin Johnson , Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux.cj@gmail.com, Jakub Kicinski , Heiner Kallweit , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Laurentiu Tudor Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Extract phy_id from compatible string. This will be used by fwnode_mdiobus_register_phy() to create phy device using the phy_id. Signed-off-by: Calvin Johnson --- Changes in v4: None Changes in v3: - Use traditional comparison pattern - Use GENMASK Changes in v2: None drivers/net/phy/phy_device.c | 21 +++++++++++++++++++++ include/linux/phy.h | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 66e779cd905a..6ebb67a19e69 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -846,6 +846,27 @@ static int get_phy_c22_id(struct mii_bus *bus, int addr, u32 *phy_id) return 0; } +/* Extract the phy ID from the compatible string of the form + * ethernet-phy-idAAAA.BBBB. + */ +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) +{ + unsigned int upper, lower; + const char *cp; + int ret; + + ret = fwnode_property_read_string(fwnode, "compatible", &cp); + if (ret) + return ret; + + if (sscanf(cp, "ethernet-phy-id%4x.%4x", &upper, &lower) != 2) + return -EINVAL; + + *phy_id = ((upper & GENMASK(15, 0)) << 16) | (lower & GENMASK(15, 0)); + return 0; +} +EXPORT_SYMBOL(fwnode_get_phy_id); + /** * get_phy_device - reads the specified PHY device and returns its @phy_device * struct diff --git a/include/linux/phy.h b/include/linux/phy.h index dee7064ea4eb..957ce3c9b058 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1349,6 +1349,7 @@ struct phy_device *phy_device_create(struct mii_bus *bus, int addr, u32 phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids); #if IS_ENABLED(CONFIG_PHYLIB) +int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id); struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode); struct phy_device *fwnode_phy_find_device(struct fwnode_handle *phy_fwnode); struct phy_device *device_phy_find_device(struct device *dev); @@ -1357,6 +1358,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45); int phy_device_register(struct phy_device *phy); void phy_device_free(struct phy_device *phydev); #else +static inline int fwnode_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id) +{ + return 0; +} static inline struct mdio_device *fwnode_mdio_find_device(struct fwnode_handle *fwnode) { -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel