From patchwork Fri Dec 1 17:10:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?K=C3=B6ry_Maincent?= X-Patchwork-Id: 172576 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp1278596vqy; Fri, 1 Dec 2023 09:12:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFeUNIZh0AHN1pfICmPGwVi7/zqjSPnANS2tKjE6fRf9ndzEFT3FUMSMhQojh+vFYJl6IE0 X-Received: by 2002:a05:6a20:158e:b0:18b:cdd5:10c1 with SMTP id h14-20020a056a20158e00b0018bcdd510c1mr37848870pzj.26.1701450727610; Fri, 01 Dec 2023 09:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701450727; cv=none; d=google.com; s=arc-20160816; b=UJnpZIjaxQGDi2ajacYUuG+D0FjQ90uvbekaIRwFqa/G+zKdvETwPd4wW0UKZtkdQ6 yHeP3ttWgNtsH5iyWW3xiX/iBtzuSMWvCOfC7LRFxwwumqSU8Vt1Vjz1VCB5Ab6lzI3U h72x+tKCo0A15GeiVXrmmrgazrjC0AkfkVLIpv4MUIKchXiogtO9TZCtzYsk3ggspOYJ YqJVu44+VAM2gVTUUiTmWkfdB+Ydc5wjVGAJBBeIu0WhbPu2ZvyrR7thRtJcpAiXqJEK sFWYXpnq42EgJ+agD32+gPxv2+Yc6/qElVplSEQVXIAWyQooosAGXCdzhEGRL141zePW gayQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Ur2t+3CZiMiWT1hOhnWzj0bjmB7HlBaMOY5SSeNEDOo=; fh=/uDJtwnpikhDHchW+BU5DaWKtgJ2QqyhTe++6ujbTY0=; b=nLGU3KK1VwWKitFlngltLdTlGwAamczQRAvPt8uS5jeK51/Ism8NJdqDPMTq5UJ4ma SyROsYPLH2dtBTRC41G5p90nuXTgTKqIvStLe9aetFZ5H8TYsybvA3H0KjIhumqnNPKm q70FNwAmlKXZp3VI6vTmDgYl+Sj8iS8y8mAwAuCULnix7N5/9MEjWLvZzOLWuv8o8eEI hkewJYdzzg8U7KP6B2CdddSav78EuRhZgq1iHDcIUp519j+6LtSnc0/h9LSKM9MPr+rV VlqgrZOthT/dnpoO6QflSOGjD4XbNFgCp8g80Lb/92EJrbpt1+1+wCEmP6sblRKF8zGO EccA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=batvedLs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id e15-20020a056a001a8f00b006c2cb9a884fsi3672875pfv.293.2023.12.01.09.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 09:12:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=batvedLs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 0E56081A206C; Fri, 1 Dec 2023 09:12:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229468AbjLARLi (ORCPT + 99 others); Fri, 1 Dec 2023 12:11:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378756AbjLARLe (ORCPT ); Fri, 1 Dec 2023 12:11:34 -0500 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43C0512A; Fri, 1 Dec 2023 09:11:40 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0D09224000E; Fri, 1 Dec 2023 17:11:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701450699; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ur2t+3CZiMiWT1hOhnWzj0bjmB7HlBaMOY5SSeNEDOo=; b=batvedLsMF+5fFUDJk5QtEjk/H8hKHD/llMaQBCVFZhull78N3CCJprss0L8pDO1cqAKi1 4DutMhREiyzj6QIZSNiM6+3JGp702YL9mccLtkS/4ElKXpilRgyovFSC/2RG5JC1OUmjHs EU3RglutAdeqN4VR7Ydon7bo3j2g8lnz/N0GaJ4Us06A/dW63Wh4RMol3R3H5ieG1tsN2V n6qPRNi/zKGynERo0aoC+UlLdmQlHQXJMZaV4BE64coFUdwqBcckbhpyVaJnv/QdyoM/0w 9zjw30JplhtyaDLbpiD0zcSoL6rrpZybuvj/NQmWlNTScOeCDZwE2yPPbsBvyA== From: Kory Maincent Date: Fri, 01 Dec 2023 18:10:25 +0100 Subject: [PATCH net-next v2 3/8] net: pse-pd: Introduce PSE types enumeration MIME-Version: 1.0 Message-Id: <20231201-feature_poe-v2-3-56d8cac607fa@bootlin.com> References: <20231201-feature_poe-v2-0-56d8cac607fa@bootlin.com> In-Reply-To: <20231201-feature_poe-v2-0-56d8cac607fa@bootlin.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Luis Chamberlain , Russ Weight , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oleksij Rempel Cc: Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devicetree@vger.kernel.org, Dent Project , Kory Maincent X-Mailer: b4 0.12.4 X-GND-Sasl: kory.maincent@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 01 Dec 2023 09:12:02 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784100398245206728 X-GMAIL-MSGID: 1784100398245206728 Introduce an enumeration to define PSE types (C33 or PoDL), utilizing a bitfield for potential future support of both types. Include 'pse_get_types' helper for external access to PSE type info. Sponsored-by: Dent Project Signed-off-by: Kory Maincent --- Changes in v2: - Rename PSE_POE to PSE_C33 to have naming consistency. - Use "static inline" instead of simple static in the header --- drivers/net/pse-pd/pse_core.c | 9 +++++++++ drivers/net/pse-pd/pse_regulator.c | 1 + include/linux/pse-pd/pse.h | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c index 146b81f08a89..2959c94f7798 100644 --- a/drivers/net/pse-pd/pse_core.c +++ b/drivers/net/pse-pd/pse_core.c @@ -312,3 +312,12 @@ int pse_ethtool_set_config(struct pse_control *psec, return err; } EXPORT_SYMBOL_GPL(pse_ethtool_set_config); + +u32 pse_get_types(struct pse_control *psec) +{ + if (!psec->pcdev) + return PSE_UNKNOWN; + else + return psec->pcdev->types; +} +EXPORT_SYMBOL_GPL(pse_get_types); diff --git a/drivers/net/pse-pd/pse_regulator.c b/drivers/net/pse-pd/pse_regulator.c index 1dedf4de296e..e34ab8526067 100644 --- a/drivers/net/pse-pd/pse_regulator.c +++ b/drivers/net/pse-pd/pse_regulator.c @@ -116,6 +116,7 @@ pse_reg_probe(struct platform_device *pdev) priv->pcdev.owner = THIS_MODULE; priv->pcdev.ops = &pse_reg_ops; priv->pcdev.dev = dev; + priv->pcdev.types = PSE_PODL; ret = devm_pse_controller_register(dev, &priv->pcdev); if (ret) { dev_err(dev, "failed to register PSE controller (%pe)\n", diff --git a/include/linux/pse-pd/pse.h b/include/linux/pse-pd/pse.h index be4e5754eb24..4a0ae3097bb2 100644 --- a/include/linux/pse-pd/pse.h +++ b/include/linux/pse-pd/pse.h @@ -44,6 +44,19 @@ struct pse_control_status { enum ethtool_c33_pse_pw_d_status c33_pw_status; }; +/** + * enum - Types of PSE controller. + * + * @PSE_UNKNOWN: Type of PSE controller is unknown + * @PSE_PODL: PSE controller which support PoDL + * @PSE_C33: PSE controller which support Clause 33 (PoE) + */ +enum { + PSE_UNKNOWN = BIT(0), + PSE_PODL = BIT(1), + PSE_C33 = BIT(2), +}; + /** * struct pse_controller_ops - PSE controller driver callbacks * @@ -77,6 +90,7 @@ struct pse_control; * device tree to id as given to the PSE control ops * @nr_lines: number of PSE controls in this controller device * @lock: Mutex for serialization access to the PSE controller + * @types: types of the PSE controller */ struct pse_controller_dev { const struct pse_controller_ops *ops; @@ -89,6 +103,7 @@ struct pse_controller_dev { const struct of_phandle_args *pse_spec); unsigned int nr_lines; struct mutex lock; + u32 types; }; #if IS_ENABLED(CONFIG_PSE_CONTROLLER) @@ -108,6 +123,8 @@ int pse_ethtool_set_config(struct pse_control *psec, struct netlink_ext_ack *extack, const struct pse_control_config *config); +u32 pse_get_types(struct pse_control *psec); + #else static inline struct pse_control *of_pse_control_get(struct device_node *node) @@ -133,6 +150,11 @@ static inline int pse_ethtool_set_config(struct pse_control *psec, return -ENOTSUPP; } +static inline u32 pse_get_types(struct pse_control *psec) +{ + return PSE_UNKNOWN; +} + #endif #endif