From patchwork Mon Nov 23 14:01:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 331586 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 16ED9C2D0E4 for ; Mon, 23 Nov 2020 14:09:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9572120732 for ; Mon, 23 Nov 2020 14:09:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="YurncW6P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729858AbgKWOIy (ORCPT ); Mon, 23 Nov 2020 09:08:54 -0500 Received: from mail-vi1eur05on2073.outbound.protection.outlook.com ([40.107.21.73]:8513 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729111AbgKWOIx (ORCPT ); Mon, 23 Nov 2020 09:08:53 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NhWFtNa+hmOZLtnZ1G+rb/A0g6D5L6YDw8VvNWojJ2InjfQQiX7xTK0Q/EQIeLp5Y0BNMEfL2EoGvZ5vWywnHCQbknC2Bc72XjF7u3K/P+Ro7ZCynAP5zxeAPDfEKjD+NIdVm6MOmR0BCSD1CsuB97mNNOunDSxBds+10F6LRAn8uh/eM88PoGeF/4KGcmpK1G/f3xruWPh40mI6KSk8DkyLu6EiB6Rx1w8hrjnfpHe4rDdCS9TgMKnuE4XPrBRAtbj+zPNEl+P1MAJuR+zz0zMrHgM6FMlxNjLzZzbzenG6ssrpc6BP5cTdpscWyn5XDOwvHj+bo7gtGJv12TVRtw== 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=tvjPCHPIKqLJYXalimTUpBZ/ZbP6H6NE4aqt3/1bTRM=; b=U+I6CzYXU7l+UoAXiEnuXx3aanOhmtoWsjvKSAYAxLOeR6TkPaMgmelcWKAH8h8RQdjjcJlS4HHD0VD6Vhyzcb4X7iJGRPVaRJt2m28RCyj3939+CExTwYPpVj1AUJQLbi7H3Tgzeb4gEpVsRz1cTj928TpyiBm3iqtIwL/b0oLz1AUJRNdOmvho2+NmYDU5Bf4gzc0wtfm29Smkqd7Hbx0k8w8mrcQY/SsTwfTPkxXxk+23t2L7bqp04bOs3fov0+06EiuGWJCMVl9mPf91g2164td79cCcBfpAy+Ys/pbhP9ByF4BErVsO1jt3kuyn1AzMh+NC4mwJBf9fQJP5nw== 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=tvjPCHPIKqLJYXalimTUpBZ/ZbP6H6NE4aqt3/1bTRM=; b=YurncW6P6GpySbwLSSStCWS7b0eEA+gqZZmF+CAPvRFdkFTD3EBwWG8gVVZtO9AaD7FLxXiQgiOxg5UHI3MHsxt4srn7plVT5LgJKISHg5PyIllm3o/EpQC5yVbezN0iREJXaE0WzCGjG2iSN/OU5AKqSurwr18DJBfMelqdKbU= Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none; linux.intel.com; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) by VI1PR0402MB3760.eurprd04.prod.outlook.com (2603:10a6:803:23::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Mon, 23 Nov 2020 14:08:49 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6%7]) with mapi id 15.20.3589.028; Mon, 23 Nov 2020 14:08:49 +0000 From: Li Jun To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, rafael@kernel.org Cc: gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com, hdegoede@redhat.com, lee.jones@linaro.org, mika.westerberg@linux.intel.com, dmitry.torokhov@gmail.com, prabhakar.mahadev-lad.rj@bp.renesas.com, laurent.pinchart+renesas@ideasonboard.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com, peter.chen@nxp.com Subject: [PATCH v6 1/6] dt-bindings: usb: add documentation for typec switch simple driver Date: Mon, 23 Nov 2020 22:01:31 +0800 Message-Id: <1606140096-1382-1-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) To VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 14:08:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f70fbdc3-2b91-4866-f5c4-08d88fb94c95 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3760: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SlyBArFZGi3e1P2Z/JIlFvuJ+jMGSWTIn84GdbeWVWsdnp+hoEhHrWI6ei0V3RzHn0/boOkW+MCwBpu1hR8Od4tfUEuW0J/syEVWJCP2TfQouH0jE9I/6Wh/gNBOx9kDTCzYCh/PoCJs6OWIQE/NYioLIzIu0bNqrl07hiu/r3QWcwnrSHZIjz0Ep6IZhfX0AyXAsZupruMzxC06n/1HXKIYITSkE62lxXhWP7U+LFsmpWRprk79/SSfAT3DjKBj3gJcyuL8pghsS6QblQU3RR9AF9f6K/XAWYHJvGWfFxN132WA+lYV58ximiwFwDnz4Wln7G57hh5+NV2hUsKxrUaGhpWhm925wFuYAx7Dob468d1SsXdWRvPrQJxssllW5MeU4arXmb2hKNfka16BIhIOqaLXSgvejoRVNq3gbkRyJ/OiGB+Be/iHbv8G41rysi0elSiniMQ3C1Q5OWm64Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6528.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(396003)(136003)(376002)(366004)(4326008)(186003)(16526019)(26005)(36756003)(86362001)(69590400008)(6666004)(2906002)(66556008)(6512007)(66946007)(478600001)(7416002)(2616005)(8936002)(956004)(966005)(316002)(52116002)(66476007)(6486002)(8676002)(6506007)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: CQpUQycvXexQwG1CvA/sLgWLoQ1008IQr1koKI1vPVV7J7fV2h6v+N3IM48tzWXBqUKVOI/QmBrI5qigBLVAusbkv49M+SF+lf0vO9i9xr93MP0Wz8QM7yXF4Qz85+wSJeMchrnnfUizHugMpYatuDA0GMglqCwvVuRZ//s0C24lpynwDd3gIArvbu+SopLBD0qJsGFrkAPPK/7C3gp+KLhJElQSLM5eRlVbsDzX3+IOJiJwP3vJUQS7rBzPt0ENROT/TF9418D5Chp9pa4pRJY46wDXjasasrp76brsSFRYKtDE4C13SRCjOmT1Cn18lD+q9AKwqVlLxPr5fjFwL6AHEHMZdkUO9v/vpTFOXLuwel6bx8JyyMT4PdJHebJurYb4kbTI6OZsTkJ4X89qf45+sHvQVGb9ARnNUDQaGcltK52cHYPUNanEs5ZJPioK2lIXYoKBI0wrVNpDqpZR9ZYYr/QqgI0HUBYWNM/+LS3ppagLIwLJBFNpAApH8oAkVxQLYjzbSG8kKbY+UzXqVVo4YAApmahLLKFKvu+o6bnnoJXYqYmBF9dv8wBLp4h6RGoTtEmRn9Ric2zDzrXS4+KYYMYUZuyRgtd0mtY4mnhUUfqJ6rWFGlAUq0fszjUwwmxBgo5kANGhlqMFvZdXs/7+zJvMIuo1Bx+NCLQFDySStF6hQCc3QJAnTwmE38m0CAU4E/GTqS6Yq4jZ/38bclqCtGWCp6d+DCvCCdaylvxYuBb9B8XYJGI5vvNujWmszToTqX7wa4CiUKIwnE3lcoWX08bw1xuJ7e4OEOK1VM4FAwYQkPmv3f0Vzyi60OfWjdTs4BVoMb97BZo2X0PSmtUzCcpW7tFrmPuCRDrKyJT80sypJN0psNEz71Ty4LBMFWUenYYTuZrnGmKeboHCKA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f70fbdc3-2b91-4866-f5c4-08d88fb94c95 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2020 14:08:49.2561 (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: T9lhvYYumLyEmwV/rWF78SN45LjODU3XnU4ZmgmYl1iMvwCoXVycflZTwFlpDuxQ X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3760 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some platforms need a simple driver to do some controls according to typec orientation, this can be extended to be a generic driver with compatible with "typec-orientation-switch". Signed-off-by: Li Jun --- changes for v6: - Use general mux bindings for typec switch, one typec switch may have 1 or 2 GPIOs for channel selection, if 1 GPIO, only can be used to select cc1 or cc2; if 2 GPIOs, the second GPIO can be used to deselect both channels or keep normal operations. - Add one more connection to usb controller. No changes for v5. changes on v4: - Use compatible instead of bool property for switch matching. - Change switch GPIO to be switch simple. - Change the active channel selection GPIO to be optional. previous discussion: http://patchwork.ozlabs.org/patch/1054342/ .../bindings/usb/typec-switch-simple.yaml | 122 +++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml b/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml new file mode 100644 index 0000000..030ade5 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml @@ -0,0 +1,122 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/usb/typec-switch-simple.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Typec Orientation Switch Simple Solution Bindings + +maintainers: + - Li Jun + +description: |- + USB SuperSpeed (SS) lanes routing to which side of typec connector is + decided by orientation, this maybe achieved by some simple control like + GPIO toggle. + +properties: + compatible: + const: typec-orientation-switch + + '#mux-control-cells': + const: 0 + + switch-gpios: + description: | + GPIO specifiers to select the target channel of mux. + The first GPIO is for cc1 and cc2 selection, the GPIO flag use + GPIO_ACTIVE_HIGH if GPIO physical state high is for cc1; or use + GPIO_ACTIVE_LOW if GPIO physical state low is for cc1. + The second gpio is to deselect any channles by places all channels + in high-impedance state to reduce current consumption, the gpio flag + use GPIO_ACTIVE_HIGH if GPIO physical state high is for + high-impedance state (so low for normal operations); or Use + GPIO_ACTIVE_LOW if GPIO physical state low is for high-impedance + state(so high for normal operations). + minItems: 1 + maxItems: 2 + + idle-state: + description: -| + For TYPEC_ORIENTATION_NONE by deselect both channels if supported. + const: 2 + + # Standard properties described in + # Documentation/devicetree/bindings/mux/mux-controller.txt + + port: + type: object + additionalProperties: false + description: -| + Connection to the remote endpoint using OF graph bindings that model + SS data bus to typec connector. + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + endpoint@0: + type: object + description: Endpoint connected to typec connector. + additionalProperties: false + + properties: + reg: + const: 0 + remote-endpoint: true + + required: + - remote-endpoint + + endpoint@1: + type: object + description: Endpoint connected to usb controller. + additionalProperties: false + + properties: + reg: + const: 1 + remote-endpoint: true + + required: + - remote-endpoint + + required: + - endpoint@0 + +required: + - compatible + - port + +additionalProperties: false + +examples: + - | + #include + typec_switch: mux-controller { + compatible = "typec-orientation-switch"; + #mux-control-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ss_sel>; + switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>, + <&gpio2 20 GPIO_ACTIVE_HIGH>; + idle-state = <2>; + + port { + #address-cells = <1>; + #size-cells = <0>; + + usb3_orien_sel: endpoint@0 { + reg = <0>; + remote-endpoint = <&typec_con_ss>; + }; + + usb3_con_data: endpoint@1 { + reg = <1>; + remote-endpoint = <&dwc3_0>; + }; + }; + }; From patchwork Mon Nov 23 14:01:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 330790 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 913A1C388F9 for ; Mon, 23 Nov 2020 14:09:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FED52080A for ; Mon, 23 Nov 2020 14:09:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="eIqk8lMd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729897AbgKWOI7 (ORCPT ); Mon, 23 Nov 2020 09:08:59 -0500 Received: from mail-vi1eur05on2088.outbound.protection.outlook.com ([40.107.21.88]:4001 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729111AbgKWOI7 (ORCPT ); Mon, 23 Nov 2020 09:08:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TNae8u0t+XRx3AYWdfC2THD5i1/bd5k2XmIBdl9OxnPrIGQG9OGFiJSFfKS+/37jG/QCSpAd4/l+hSi8LiiURtr5xxNqhaGJqR0h41hqQBBtwuWIJOlxf2nDcqMNhuoj0hgxQYgzaGbWyxMjC8i3PqxwljqFuK1KgtjZt/wDCEbGAv+GP9TcF0rpTRZi7+WHKAqeuONsNRJ+Wd5tUcUoDAICnJp8aI59hY8eLUeW51wmiT5H5uj/zVY9YBCiu1VRIIUQtTUM2l1aINUN/bvb8uchPWoH5CyMIMXwp12T0f4tZfAwY61NymZpwqHYd4GKF665gbvVRORUVD1DJY3pVA== 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=iKxA2olZIxrO9Jii9rIBwEOXLwjmbAGvddS6MgKU5/A=; b=QL3AJLupj4+Sl/KpySebzX5WvTVywSZvj8hLe/lQ6Jt3lz3eBCZ0TK7NvRBoZbQsxSKB2X2oWGShOwzjAWcUAdAMSyb8OUsTt+4Zy+sw8aDBXbasYbu9Un6jGbTmYmg2UJ4Sb6IyAXWW963GhGKoTb51sjBE2eYaKC//DM7YcIjOvhWbKD8LrJSfVRshy0sMxepMBN/bi/0NAyxThYSVMq4dqoBaN85PME1OqSK4jcdMI8CusE7NW3oMGV0HU84UwNljHFrt5FcL84CI73joJdle/k1RSOWzQ+3nJIj76smtiQKWS5cd9qi1AaErouyEWvuopkg6g6GBQQrwgNWjoQ== 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=iKxA2olZIxrO9Jii9rIBwEOXLwjmbAGvddS6MgKU5/A=; b=eIqk8lMdqsxeHvB9E/hDQnzRsYeh3nUpZU+7xSWrQNMUmCmkCrf/VXnJG+bD2FS4QOKXt5oqNO2+4Tf+jjgsHe7p0+6Pg1iFCPCjjXa6bKBZ62DH6C48S9UnMZ+tL2RSXZlA6P9qOIcfEjt6sTwNjXbIdwrr4fIUvJVplO6H4ns= Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none; linux.intel.com; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) by VI1PR0402MB3760.eurprd04.prod.outlook.com (2603:10a6:803:23::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Mon, 23 Nov 2020 14:08:53 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6%7]) with mapi id 15.20.3589.028; Mon, 23 Nov 2020 14:08:53 +0000 From: Li Jun To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, rafael@kernel.org Cc: gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com, hdegoede@redhat.com, lee.jones@linaro.org, mika.westerberg@linux.intel.com, dmitry.torokhov@gmail.com, prabhakar.mahadev-lad.rj@bp.renesas.com, laurent.pinchart+renesas@ideasonboard.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com, peter.chen@nxp.com Subject: [PATCH v6 2/6] device property: Add fwnode_is_compatible() and device_is_compatible() helpers Date: Mon, 23 Nov 2020 22:01:32 +0800 Message-Id: <1606140096-1382-2-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606140096-1382-1-git-send-email-jun.li@nxp.com> References: <1606140096-1382-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) To VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 14:08:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c2253203-4d0f-462d-c398-08d88fb94f53 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3760: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:499; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d4Kr9fJ9w1rLCEXJCotPJQoTde48G5roeZ87aOqogrZ6EYiy9lM0HL9XlBrHSKJzw7cZR0sKMXZOasL+EKtBn66m3OATUXtNygDF693nuozhQPmNl3h/X8IOU9BjIW/d87pD89Cze1PVi4fIy8iekIWOSE8fs0L+RYx1ZpxsJnW1rYyMfjZ1UywOMAeILLXWh8zmRg4GR1kE9Yd2VGzhmICGxjLiyH1iFha7B09hqwPjZVvLvHJUKBaTn0U+EomWllvX+KFnYhjvj0DiRzVsZzh4zri8QL0BdxxirZVDkqWHxriMME3f+yVxMsKTri/kdfq3xxo31lepQ/Y1AP0Ag/Yay5dBxWj0XKUn6OEmqldryFMXIfyNbqWvUEOLcs7G X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6528.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(396003)(136003)(376002)(366004)(4326008)(186003)(16526019)(26005)(36756003)(86362001)(69590400008)(6666004)(2906002)(66556008)(6512007)(66946007)(478600001)(7416002)(2616005)(8936002)(956004)(316002)(52116002)(66476007)(6486002)(8676002)(6506007)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: itove1DVrv7uGjU4RNv0BsuqPCjcLCQDRDV0WDsobJkGdghS+1ijRMewAnH3TldNHAX8zNmYTyEO38StmsKGZ5kRnh6QlSScmVXnqCwW1EiqVvf4+siRqlY3/00VY0MsTyyZmYQ5CorTE34uUqQ50pXcW4CQnlfMKir8hL4Y5AGIz1F7CRvy0pZcW3nISOcnSGBSirvK/7AY7cujvgJDduOlnYHZ0x7S3A8FrgokM7bv7sHyIdb7Utupe5WOwcE4W6laJ6PBXlHE1zxInrGrw/nvFe+1jUL2e7W4YVcJjGXOfs5g7kIOb6xtsru4edYk9LNBNmBQIJhh7g/nEkbWK0oqAL7yw0FkoGXA5wMrPAOejuJC3NTKgcG5T4cyO9sTZaNFMiLor4zTa1tXD49RK8ifo7HEqcT1GM0J+YkjsTufS2JvWbIkiZF4xQVuUPixVF82mC9nGjFoYCml1SJVKnl2xz5R6covB+QEDvSoSqh7+73nVqowBjzZ/NAf/ULogsv3jKrx3mk4qo+dWokVsnmCnUuIDQL9+Y+rIzDRlnVF2VvNw7xc6Em8H8vWEpjWHKrOHygTZrbX9Zm0WhBSx7EZLyOUXE5llbG3ZFDg0wxA1DlGJG0tH4sShyrN54lWA21V5KzROTPxZ+n2LGPBOqZ0bWK+tHrF1k/JAhIi7CR5xNKdVeHASaPKBbnV0eOEQCJARAC1UQOfM2OCRdBIMhkviTWq0T/H7bHMeGpclH4vNIGsNXua1+Aub/3i7GLq+PKLgjvqTkpvu/iSUQULiX9t8XKyE4anECv+/CHmTJy/OKKsDwZo3luLMJgugW+QLD2CSleqScAt9EWRqiV8MlHM8dPP52tvppizf4MTKsCt5J+Fc00Q2nuKrDBE4mOTFI5dMQoP+ILdQosEi5LH+g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2253203-4d0f-462d-c398-08d88fb94f53 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2020 14:08:53.7335 (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: +ijKQNeEumOb+OXw4DWCwG23crvDtlxUozo9LY/HPP6/uiodHcpQL8iD36eoLyb8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3760 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Heikki Krogerus Since there are also some ACPI platforms where the "compatible" property is used, introducing a generic helper function fwnode_is_compatible() that can be used with DT, ACPI and swnodes, and a wrapper function device_is_compatible() with it. The function calls of_device_is_comaptible() with OF nodes, and with ACPI and swnodes it matches the given string against the "compatible" string property array. Signed-off-by: Heikki Krogerus Signed-off-by: Li Jun --- drivers/base/property.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 41 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index d58aa98..d1c1f30 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1184,3 +1184,42 @@ const void *device_get_match_data(struct device *dev) return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); } EXPORT_SYMBOL_GPL(device_get_match_data); + +/** + * fwnode_is_compatible - Check does fwnode have the given compatible string + * @fwnode: fwnode with the "compatible" property + * @compat: The compatible string + * + * Match the compatible strings of @fwnode against @compat. + * + * Returns positive value on match, and 0 when no matching compatible + * string is found. + */ +int fwnode_is_compatible(struct fwnode_handle *fwnode, const char *compat) +{ + int ret; + + if (is_of_node(fwnode)) + return of_device_is_compatible(to_of_node(fwnode), compat); + + ret = fwnode_property_match_string(fwnode, "compatible", compat); + + return ret < 0 ? 0 : 1; +} +EXPORT_SYMBOL_GPL(fwnode_is_compatible); + +/** + * device_is_compatible - Check does a device have the given compatible string + * @dev: Device with the "compatible" property + * @compat: The compatible string + * + * Match the compatible strings of @dev against @compat. + * + * Returns positive value on match, and 0 when no matching compatible + * string is found. + */ +int device_is_compatible(struct device *dev, const char *compat) +{ + return fwnode_is_compatible(dev_fwnode(dev), compat); +} +EXPORT_SYMBOL_GPL(device_is_compatible); diff --git a/include/linux/property.h b/include/linux/property.h index 9f805c4..42c1d99 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -48,6 +48,7 @@ int device_property_read_string(struct device *dev, const char *propname, const char **val); int device_property_match_string(struct device *dev, const char *propname, const char *string); +int device_is_compatible(struct device *dev, const char *compat); bool fwnode_device_is_available(const struct fwnode_handle *fwnode); bool fwnode_property_present(const struct fwnode_handle *fwnode, @@ -117,6 +118,7 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); void fwnode_handle_put(struct fwnode_handle *fwnode); int fwnode_irq_get(struct fwnode_handle *fwnode, unsigned int index); +int fwnode_is_compatible(struct fwnode_handle *fwnode, const char *compat); unsigned int device_get_child_node_count(struct device *dev); From patchwork Mon Nov 23 14:01:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 331585 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 074AAC6379D for ; Mon, 23 Nov 2020 14:09:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B168F2075A for ; Mon, 23 Nov 2020 14:09:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="gWoqastO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729111AbgKWOJC (ORCPT ); Mon, 23 Nov 2020 09:09:02 -0500 Received: from mail-vi1eur05on2088.outbound.protection.outlook.com ([40.107.21.88]:4001 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729204AbgKWOJC (ORCPT ); Mon, 23 Nov 2020 09:09:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h/IK5kCvkO508CxQzvP5uvOflJDJzQy0BIuPy6cdbo4qSkJLcYUO+ehW7Iyd+SjOdK9p1khyaH/RXVQ+VPOVyTrzXLLPqEVNxzgZftZbjUpSYmJ4StJenQI9HlWOg0njzUcFE5pQN5FRNQm4lrndmwINof9gSQflANL3KnyV7pZ6vQZzKACGadhyLiBQWF5Mpaw0qdN/Xwmo506tzU+WgMhlg/LIRhqSAa2+WjHuavRyUB0VcsOLG9J7lT8bNGz+24LDdwL37zDNW/3ajp14TSPhM/uuv5xjmHFJF5wx4akZIHQnZYntguY3dpsFTRfU1JV8lUiVzxJXLelflXSytQ== 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=qd6JWnJqQg35ArpxYz6B9la1kP+S+kzVwUQWP8efgik=; b=nId6dY2NJoFU2X/N44cVqixwvQKjAyZN8PlrC377n/hMQleT7vSqTyH2/0Ne88NssriONbcbP3R6B5ySJmCbmgnujCtCwg9Fn1Jsga4U+BO8Z4hGLWXMzdeTdF4UdE9OPSWdetfJL3R3suc+G6DmTxVJ//ijmIC6A/2qGms9qUgStZQg25rm6BedX7p/evf/nElC/omnB4dHgLDONt1h5YeUN3oaRDqt5uLHKKxwvUoiMxNksaC+JvOPUtBqmWnFbGxbV2+dxsou5b5upQsZkgOTgMXfYKupF8aTwtgzfM8CnLbI2fodVninfpuDlnP2XBLvUcEZlvAlbSUwcLsX1A== 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=qd6JWnJqQg35ArpxYz6B9la1kP+S+kzVwUQWP8efgik=; b=gWoqastOiPMYcDeK6mG6qGpVMCCPRfQ8CJTvFTR/8x4aE0lDyjQreQTkiahwjlRKK0kaOEPwaey0jvwvwNneLQbJPDuv5zVYJNL4CNBV4KxmdORdXUNUG32DuKXhqBgHjyjf7a0XOlkXAkHcPkY8UGqCakAUb6JzegTCNrBA8jU= Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none; linux.intel.com; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) by VI1PR0402MB3760.eurprd04.prod.outlook.com (2603:10a6:803:23::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Mon, 23 Nov 2020 14:08:58 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6%7]) with mapi id 15.20.3589.028; Mon, 23 Nov 2020 14:08:58 +0000 From: Li Jun To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, rafael@kernel.org Cc: gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com, hdegoede@redhat.com, lee.jones@linaro.org, mika.westerberg@linux.intel.com, dmitry.torokhov@gmail.com, prabhakar.mahadev-lad.rj@bp.renesas.com, laurent.pinchart+renesas@ideasonboard.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com, peter.chen@nxp.com Subject: [PATCH v6 3/6] usb: typec: mux: add "compatible" property for switch match Date: Mon, 23 Nov 2020 22:01:33 +0800 Message-Id: <1606140096-1382-3-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606140096-1382-1-git-send-email-jun.li@nxp.com> References: <1606140096-1382-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) To VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 14:08:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a69eb107-4813-4e18-a872-08d88fb951fe X-MS-TrafficTypeDiagnostic: VI1PR0402MB3760: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:334; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N1rHQoeSm/WCqstH8ZshkhqevQeEVLYfzrCg00XCdTXhCrbPQY/tXR8d8TDB7ww7aIAJLyKVFffbai0hgBbapdhlQsFjkXMc11/lUXVaH0Udx2OVtI30GDwNdbXI7yWT+EcYPX7Bl6uuLx70aIV0ZtrJZluXNm0orvoE/kIJJBMoZaM5zv1BCpwWjLNyzOUjNbRHVmOUHuswnyscy1DbV2UGnRnC/n5wGHHVtKURcG2E7ieuvblegshuYTvm/8KbKm3P2M10xv0MwAd1wmEdkrUDnLPltcUc8FNpnZR2y0v7RpIccBI7U6l8FwTXwYi31Ss0yTLzOSIHLOUCaxeZ9zehaqBJ8SWc4chVldqlwgGTYHZjQtIPEagzujvbIwV7 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6528.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(396003)(136003)(376002)(366004)(4326008)(186003)(16526019)(83380400001)(26005)(36756003)(86362001)(69590400008)(6666004)(2906002)(66556008)(6512007)(66946007)(478600001)(7416002)(2616005)(8936002)(956004)(316002)(52116002)(66476007)(6486002)(8676002)(6506007)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: yqSzNA5idMGzd67mCUMSr1lcvjTYi6fV0iw1TnC0MhO1qarJOPWUTCnWa/yiZErlqSywqVRAFC6mKN4MXX4ilXaMhDJOaa4WvnK8rirnD3VxFfoGt9H4H4rMsgwnclJVU+fdwpMXdDxkonqWPTdTgfNsG92dP11OS6C8LZhbQvojuOQW/LvmDue1GZ8ZfQDi1wuXhSMhskMst5xs+e6hOfvQAKAJmSMOTJJ4ET+Wexvaumq9nA5ErTL1xPL7tXg0fq3iMUJRWJ63SNL+jfc+3P2bOH/dCfgr+kB2DkZnnFLqUbWpO3eQYhfQOxZAZvxJNPnE1nztc6UHOpiy1Z+oeq7gTevOha7RyvP7PNcBhp2+2x/68qutU6uir6xYpSuKswszFax5tRcpw+RJyEVuMyD9XqwIEoATLXQeAYfYJNl/5befbvapLLzE6JNiMfde6P3PSgspPNmqIp6/G5HzMUB1/VqexOb4ucpOGHF1SaFwdmNjY3xudD4ZXoPgnwTQIlaxtMRTw4ElVSMNuByzRJiKYPyU8KP0XHp6tZVEFR4RSdmYWFKXektveFzrLTjy4g7DJtSm6ahCmtqA0Cs5WdxyTpyotGve/Gt3HjieM0PRz67f+WeyF/KL+ZcMe9QU0oEy5evMyIewQPzeMHfPwRg1v2cYoAim/tOaxH2XC5hKFJUfH8nV6TF8+jPMhS4rNiP9h8A+7g/MYSsEMn2/okcItxFRYxlg/5hUZ9FPvt3jVqmsaZRBG0maiT90bN9GHJE2acjn8Q+W7LNCerOF2TW7MpluGbBnB5jv4eQ+cn4XYr/RRVuGCOb+IkkQFbhT79ckThaAyAw+tpRZtZCyriK67qRwMqRfYixqLVzAgUKkSevNGnmOfFEArjNAn2iKha4BD5+yGZssE/K96DXAwQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a69eb107-4813-4e18-a872-08d88fb951fe X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2020 14:08:58.3748 (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: qw6mLqFkNzfKcqCRKeNrPnGRolNrPKJmIjprfs3Fme9Et1NB7D4RPKV3Ydael+GH X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3760 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org For those need a dedicated typec switch simple solution driver, use compatible property for matching. Acked-by: Heikki Krogerus Signed-off-by: Li Jun --- drivers/usb/typec/mux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index 52ad277..3da17d1 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -39,7 +39,8 @@ static void *typec_switch_match(struct device_connection *con, int ep, { struct device *dev; - if (con->id && !fwnode_property_present(con->fwnode, con->id)) + if (con->id && !fwnode_is_compatible(con->fwnode, con->id) && + !fwnode_property_present(con->fwnode, con->id)) return NULL; dev = class_find_device(&typec_mux_class, NULL, con->fwnode, @@ -61,8 +62,8 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode) { struct typec_switch *sw; - sw = fwnode_connection_find_match(fwnode, "orientation-switch", NULL, - typec_switch_match); + sw = fwnode_connection_find_match(fwnode, "typec-orientation-switch", + NULL, typec_switch_match); if (!IS_ERR_OR_NULL(sw)) WARN_ON(!try_module_get(sw->dev.parent->driver->owner)); From patchwork Mon Nov 23 14:01:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 330788 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 55112C64E69 for ; Mon, 23 Nov 2020 14:09:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E4A32075A for ; Mon, 23 Nov 2020 14:09:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="GwBmge4n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730000AbgKWOJH (ORCPT ); Mon, 23 Nov 2020 09:09:07 -0500 Received: from mail-vi1eur05on2081.outbound.protection.outlook.com ([40.107.21.81]:56064 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729204AbgKWOJG (ORCPT ); Mon, 23 Nov 2020 09:09:06 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y13X9PCq7KKAo+VbQxNv8316a7XFWPNZ8F1OLgIfp5BEFjfKDZZfcmA7GUIBhkXnpXpTxUfg3VxMhmMQBIK/Co27BzfB+TTSHH6pdzOSB5as/1WLwmANVqBtT1cHp1NAdNP/tYpwdVHKnVO9S+FTxAi/6BwxIZ0B9wPP1Ea8NB3pT43QHnE/Xy91SspuPAZcrWVwSV2mcUnVPml/mO2qCFRskpOBU57yiz6lJsSgNiDug++pUO80WNxZVTZAVpTPzzp0yWEQTH8kxyglqAU0xhMyAPnKZlhH9Ypq9taQZuhakXtkZIh2oLSuaDSmSrh05s1AKFtOrPXZMw8Tp4gMKg== 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=7as96nAltumeTfk60IfWdz+fqlULvx32CtbZSPCOPlE=; b=MTJvIUTT1CjSNEO7+VHiB9IgGcIXOQdmMJYeApyzCuDGMB6RlxZYSmsqUfnvSAbU53/gnK8Wk1n0/iMKdD9CQP3UqnE8c9CnWfit73UVW1UIt1IwAJCTYZKMFyZIZVu4EutKidr2p05W5o6YvLaJQXl0Z9gEr+y63dvfv+VyZDXvudA4vjAFJPNFXrgJopNgMidTnWHmMi49ZebRvU+a192ZMUn1sm/SA0rM4BT19Nbm8FOVGC4yDTCS8vk07Ij3HK7Pmy2/Epyj+WZNtNb2mPJQJYQidVAYIVDkZ6W4otdh/Ur5TalTBXxbm5Yl5z+K/FQ9dji69mClI2WzD6dNSg== 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=7as96nAltumeTfk60IfWdz+fqlULvx32CtbZSPCOPlE=; b=GwBmge4nl5GepSczkkUaL+dhmUb7IzNV4UeMhWXrslaoK7hj9l5TU0ZTXF2W2Q1F1sp9r73zuD5xRfv6KydEZiPX3kqt4zcbhzcSgGDFtpHmwfUwi48GqAusNE1J92Qd1NhzO2wKe2u4BxLhh44UNhlOM7swrp5ZEKmf1CTDUFQ= Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none; linux.intel.com; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) by VI1PR0402MB3760.eurprd04.prod.outlook.com (2603:10a6:803:23::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Mon, 23 Nov 2020 14:09:03 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6%7]) with mapi id 15.20.3589.028; Mon, 23 Nov 2020 14:09:03 +0000 From: Li Jun To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, rafael@kernel.org Cc: gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com, hdegoede@redhat.com, lee.jones@linaro.org, mika.westerberg@linux.intel.com, dmitry.torokhov@gmail.com, prabhakar.mahadev-lad.rj@bp.renesas.com, laurent.pinchart+renesas@ideasonboard.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com, peter.chen@nxp.com Subject: [PATCH v6 4/6] usb: typec: mux: use fwnode's dev for driver module user count Date: Mon, 23 Nov 2020 22:01:34 +0800 Message-Id: <1606140096-1382-4-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606140096-1382-1-git-send-email-jun.li@nxp.com> References: <1606140096-1382-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) To VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 14:08:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 7909f32f-6504-4954-41c3-08d88fb954c2 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3760: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aySgnACvSx6NQsmrmLtruz/DVbG+1eQ6Aja6N6MntEhxB2TaPai3K/X4/JF6Wq7MSwXqm1ZtwMHKR4T3K3OTdXEjDVEcmiISL+9bTN4rDqbY3HrGrbznliS/4+OsRqG4r4tZOTHAJxDcVMvvY7vLX+0J+QFDLMyzvcQE35UyevbUn/HFnercDIkYufuVRvhEGsscfLgctvXKGwyNqhe4411S0T0zHsugHJ6HTpNbl/wVXRetjzL0zTXJ/vpztlN5t/YefjJ+neQYnczXC2IGFIU9/LdpDYk3tH7sVK6I/mpz7huUc1UAyi182dEW4V/C2/ugcdDpxchFxMEhaw3MYGQ845XzEM2hGe7uUyy2sXnt7H6ovQD6w2ig/cWLjqHG X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6528.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(396003)(136003)(376002)(366004)(4326008)(186003)(16526019)(83380400001)(26005)(36756003)(86362001)(69590400008)(6666004)(2906002)(66556008)(6512007)(66946007)(478600001)(7416002)(2616005)(8936002)(956004)(316002)(52116002)(66476007)(6486002)(8676002)(6506007)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: i9RGt8egEELZCVAeMQNifHIe51+CAGC/z1rDdPx9bv3x9V2P3uDqlLimZMchSivV7LzlNaaEpqo/qXSMpHfiT2zj0m6NfChLOXJcBOb7ASfM4EymXH7RK2B+I9dli01NG4D1STZw2nWP8VzWdVLy9ygeHhcAcBQcY+MF1Aa3q3SXDWEn5kLx2R/wBR1KDDxb8sah7O6fLoiSfqmPHkMv/ApOCWrfIzwal5p1Rp+4IOG3bW+L79dqvE+YOlGVqzjM6VgZFQuMUlGbttfwaVs9vH+tDzjOBeA1KcNh2EdL4m2p2T/PSJPHAI55YISaspAQ6BezPlEpNo5YmxlkkBMXfHYDDp9ZkzyDbdnF+avwHpGM/ST99A3NoRJnnTcwSDDHnXiFJxQrmgejaatrt3X5W0mIgKL/fALikiMfsjbzMGzjSnP5bxZ0Zn/le60nmxV+2czK9YmNwn4cqcoFOduIMSI90fT65ehtEL5YOu7NdxoNbDNhIeRmuB+jCMGB//0bHqgTpUmMxlYJXIZwX8sIWTJ3Flw22glypHmkg9K8Mmd03rgazNFbqIx8q9aeNYK5EkY3b+8pUiArL7OyuBdEYPhEyWLQ2w88ZJ/EdxZAMxiLxNLmPG1aNaFrESsM5ouJ1BlDqr3EB1RRu3jglwsgOGNNRuG4jLrSYtZ+A2Mw80GCKab9V7nnQWEUGg5Kqcpxj6VZgEnEig7ClANforfjHvjxaEC+lhUxlcFUXI073axX9MAc2q8ccJK5Nyrtfjm7xceU7a0e0UF8Muqp5BDPvM/F1c+DLvyzwALFPDK9JKxWWMGrbjD6AZpxRR5G+xFgP3z0h7Zo3RgaMX5HTVf28PLGu8Rd7s6OQm9aqaWK3nPrBFn1Q7jJTTKZmf3WlnPn5cYkkFKJ+DUhlkmWVt6E3A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7909f32f-6504-4954-41c3-08d88fb954c2 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2020 14:09:02.9971 (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: 0xBI3k6eDbBfPvfqyHwhyJqmykKGChJ+VraPk2+7/aAmNJydLlLi5/8vFUVoHAF9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3760 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org As the typec switch provider driver's dev may not the parent of typec_switch dev(may be the switch's parent's parent), but we use the typec switch provider driver dev's fwnode anyway, so change to use fwnode's dev to get driver's user count. Signed-off-by: Li Jun Acked-by: Heikki Krogerus --- New patch for v6. drivers/usb/typec/mux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index 3da17d1..0219aa4 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -65,7 +65,7 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode) sw = fwnode_connection_find_match(fwnode, "typec-orientation-switch", NULL, typec_switch_match); if (!IS_ERR_OR_NULL(sw)) - WARN_ON(!try_module_get(sw->dev.parent->driver->owner)); + WARN_ON(!try_module_get(dev_fwnode(&sw->dev)->dev->driver->owner)); return sw; } @@ -80,7 +80,7 @@ EXPORT_SYMBOL_GPL(fwnode_typec_switch_get); void typec_switch_put(struct typec_switch *sw) { if (!IS_ERR_OR_NULL(sw)) { - module_put(sw->dev.parent->driver->owner); + module_put(dev_fwnode(&sw->dev)->dev->driver->owner); put_device(&sw->dev); } } From patchwork Mon Nov 23 14:01:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 330789 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 E55BBC64E75 for ; Mon, 23 Nov 2020 14:09:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8475E2080A for ; Mon, 23 Nov 2020 14:09:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="q/psueN1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730352AbgKWOJM (ORCPT ); Mon, 23 Nov 2020 09:09:12 -0500 Received: from mail-vi1eur05on2066.outbound.protection.outlook.com ([40.107.21.66]:60993 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730077AbgKWOJM (ORCPT ); Mon, 23 Nov 2020 09:09:12 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nb26eYQDG0h8PHA0i2qKfgdRPEVQ3eJZ6jzd3VgrGBkT48kUTdSsudWf5VkNkHvDBD7p6cNxHVRu5BJukOciNfkrisjArp6su9jF+0lgNTfmuQxVIyavKeJFIyq8OchIKeJxJjJ4QHc7szXdcLD5EwpXYMchiLK7H1Bu1zcg5mug3N+8PIk1keKXZH0VhRlaZljs5SQJl6tAJ0EXe5GChSyGS3UkyB7QNldA+kH5G0ZNKZM0bMLdfo7HWVK6gjSAXWu/T8RMtnsPsH59KNm63wJdlfR6FyuhQ7wOzsMZvgl2h4IOAlRGj40Fe51DBw+DuvXNGusRAXSNCWZEp42e6g== 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=IjAeAgCr9DAzbj24obIXr3nxzSsrHHpHtmmyA/ZiAag=; b=ehPJ0aThu/7vfSsc+gPb6x9AH+EANfaAJYPtZBZkvcFyeYGHeFXI1PPYYvEcqHezz/7PqfmFL487igtlEQ264rcRHNBxhDL2UH4tn59R7Lrd0EetzD/jNeAlaO5lYsxCUnWQPe1UjsnRq3IcctXAXtR3Hr/lOLtH5Eeewzv/oBqKQRoE4txCfmm8CH+GEvZToXT8to59HHOv61TSy+rzuJAWgp/0esJmdAu403DDJBzLjaVwztaoLo8yzg2WeRIc8izz+mMSOZwVdV7cRbp4UbJmQF5SpeLL1Iq7+0LoPo6V06fFUSt7bZpfsayhAb0oLTLutLFXbdsJ+33lQp5Bzw== 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=IjAeAgCr9DAzbj24obIXr3nxzSsrHHpHtmmyA/ZiAag=; b=q/psueN1bXVPN4NhPvvWnY7/UGcPqxEpQy7jUcP7xwl//FKz7l14fAPb/qTa07xS605nBIX/zCYF5ofbxlvG9XvWTdZBpXh6xd0BAX6WtkASrzMTtP7I0R81zy929Vc+L2sASj5JkXW/Ne41iA+pL1P9dyGsBmscA1kPFp6BPYw= Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none; linux.intel.com; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) by VI1PR0402MB3760.eurprd04.prod.outlook.com (2603:10a6:803:23::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.22; Mon, 23 Nov 2020 14:09:07 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6%7]) with mapi id 15.20.3589.028; Mon, 23 Nov 2020 14:09:07 +0000 From: Li Jun To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, rafael@kernel.org Cc: gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com, hdegoede@redhat.com, lee.jones@linaro.org, mika.westerberg@linux.intel.com, dmitry.torokhov@gmail.com, prabhakar.mahadev-lad.rj@bp.renesas.com, laurent.pinchart+renesas@ideasonboard.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com, peter.chen@nxp.com Subject: [PATCH v6 5/6] usb: typec: mux: add typec switch via general mux control Date: Mon, 23 Nov 2020 22:01:35 +0800 Message-Id: <1606140096-1382-5-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606140096-1382-1-git-send-email-jun.li@nxp.com> References: <1606140096-1382-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) To VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 14:09:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 36fb68ba-b925-41c6-6a74-08d88fb95783 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3760: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GIztky3/dNvWt6U1jDz7STeIjMXt/1l+VYskMeEzuJGR2ZE5uSeSpkSHtx9zU5MFkw6rmhMxa1xuaQL301el6FDG1mQ3LUELqrQOQGemJX0qZUom3a9/LF7H6ziQ0n0R1LAe2haMfLqm12P3s8+zY90IdGc+MmDAlNV0Hvkn7m4HC1j9/iZ6PrTr13fn7RDDls0SJYLIk4Co4qNsMqo/ZCgQoQYt8MSPwstYohaABcGXzF0FZ0UOQ7BIgcdCic8yk10gap/yOLGZyE/kui6iVJUL0psRtbcGPcPjI9SEFVellu3+J0l4Zu9AsXaXlEZziejRtpetXIlNWjLtaKaYJqGXth2LdXjTE1u4bWrpqJWTuLfFF8pAR4BLkRiSENAH X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6528.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(396003)(136003)(376002)(366004)(4326008)(186003)(16526019)(83380400001)(26005)(36756003)(86362001)(69590400008)(6666004)(2906002)(66556008)(6512007)(66946007)(478600001)(7416002)(2616005)(8936002)(956004)(316002)(52116002)(66476007)(6486002)(8676002)(6506007)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ISODz5JpFdNOpRdJG61AZppUeeeO9yfoNiM0EERe9cSU88V3CzIIOL0dsVXEKaOsaoQDsp4SSTAJyr7zi9SyCHUeeVHU8vQ99+VyjQ+9OuFvx2akKXEsUpgUZ1091jr1IE2N5h9EOaX4uq3Wk5LmCXny+acXjt+swZigxFY52iiJzEUyVgIG43ahXsJIdC4p4jyD2f4x/OWksqE5n/nEhIfgv4Fs16MCIFxNPJPJMU+xeWUvg5vKDDhy2lsaksk3r+SwrutKclg9ALSfF2xedmyoO9pnn/3eUChDlE5qEi4uOM4OmNDmW8nlnN3ybsifE1qwXCClE7E5MTmmkT0WkgK6YpcycrClLmOJsrHeKF+7nbhnT/why7Q5DPzKURbEFZwGGccCIfJVNrH6uyAwDh18sXhfNIdPwuYR1BKEBwuJj/PolCbVTkHTp/0Re1aubSKeYZt/xh/2ux+XVAESdoC2ipjvLVVQOoAIpfPHiQqcwuCiarO/zibHOPIuQ3BulzVuYmrXolJN/xym48hPmuFTeOi0VsLLJyKQylpLUIVzEhjr5YGORi+VlUra4zhrMwc8CLDdaV43+J/sPYkWGYdndTk5HcoYzjRUnfUtfBg3c7iEEuUvfi+kK4HNcrMNjbv/ROy79VPGwRy64vUMsNQkPEFgESuxpkaP8c3KWd2CIfF5NkedPVIGN3Jclqt2Q6xlYMwYqw0+Gz0wiJCp42cJkObI010lHX+lOKcRoC0CjybTqpTA0obw2eqlgQV5eaAZQ0deyfYY2XKJgopZ/nFQpzFCnDQEQv2fG6A39UizwVpgm/RSu/Jwq0IeuunYSYBpWfSMYcJPFoRaKeF0VtFn92+LBbDqcuV00Tnr/LJIr7Lhn1xvVZAe8OzJblMqnwCHmPySii+zjFzZE7B5BQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36fb68ba-b925-41c6-6a74-08d88fb95783 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2020 14:09:07.4776 (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: +dlleas4Ri9NlaWVngehRyuIlKZ4XkofZaSUhc7Nh881bugMi+BGYdxSNmb41rmW X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3760 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The general mux controller can be easily extended to support various mux selection, this especially fits typec orientation switch block with a dedicated driver. Signed-off-by: Li Jun --- New patch for v6. drivers/usb/typec/bus.h | 1 + drivers/usb/typec/mux.c | 44 ++++++++++++++++++++++++++++++++++++++++--- include/linux/usb/typec_mux.h | 7 +------ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/drivers/usb/typec/bus.h b/drivers/usb/typec/bus.h index 8ba8112..235ee82 100644 --- a/drivers/usb/typec/bus.h +++ b/drivers/usb/typec/bus.h @@ -38,6 +38,7 @@ extern struct class typec_mux_class; struct typec_switch { struct device dev; typec_switch_set_fn_t set; + struct mux_control *mux_ctrl; }; struct typec_mux { diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index 0219aa4..afc4537 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "bus.h" @@ -42,10 +43,8 @@ static void *typec_switch_match(struct device_connection *con, int ep, if (con->id && !fwnode_is_compatible(con->fwnode, con->id) && !fwnode_property_present(con->fwnode, con->id)) return NULL; - dev = class_find_device(&typec_mux_class, NULL, con->fwnode, switch_fwnode_match); - return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER); } @@ -71,6 +70,19 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode) } EXPORT_SYMBOL_GPL(fwnode_typec_switch_get); +struct typec_switch *typec_switch_get(struct device *dev) +{ + struct mux_control *typec_mc = mux_control_get(dev->parent, + "mux-typec-switch"); + struct typec_switch *sw = fwnode_typec_switch_get(dev_fwnode(dev)); + + if (!IS_ERR_OR_NULL(sw) && !IS_ERR_OR_NULL(typec_mc)) + sw->mux_ctrl = typec_mc; + + return sw; +} +EXPORT_SYMBOL_GPL(typec_switch_get); + /** * typec_put_switch - Release USB Type-C orientation switch * @sw: USB Type-C orientation switch @@ -142,13 +154,39 @@ typec_switch_register(struct device *parent, } EXPORT_SYMBOL_GPL(typec_switch_register); +static int typec_switch_mux_ctrl(struct mux_control *sw_mux, + enum typec_orientation orientation) +{ + int ret = 0; + + if (!sw_mux) + return -EINVAL; + + switch (orientation) { + case TYPEC_ORIENTATION_NORMAL: + ret = mux_control_select(sw_mux, 1); + break; + case TYPEC_ORIENTATION_REVERSE: + ret = mux_control_select(sw_mux, 0); + break; + case TYPEC_ORIENTATION_NONE: + ret = mux_control_deselect(sw_mux); + break; + } + + return ret; +} + int typec_switch_set(struct typec_switch *sw, enum typec_orientation orientation) { if (IS_ERR_OR_NULL(sw)) return 0; - return sw->set(sw, orientation); + if (sw->mux_ctrl) + return typec_switch_mux_ctrl(sw->mux_ctrl, orientation); + else + return sw->set(sw, orientation); } EXPORT_SYMBOL_GPL(typec_switch_set); diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index a9d9957..e2ea141 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h @@ -26,15 +26,10 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode); void typec_switch_put(struct typec_switch *sw); int typec_switch_set(struct typec_switch *sw, enum typec_orientation orientation); - -static inline struct typec_switch *typec_switch_get(struct device *dev) -{ - return fwnode_typec_switch_get(dev_fwnode(dev)); -} - struct typec_switch * typec_switch_register(struct device *parent, const struct typec_switch_desc *desc); +struct typec_switch *typec_switch_get(struct device *dev); void typec_switch_unregister(struct typec_switch *sw); void typec_switch_set_drvdata(struct typec_switch *sw, void *data); From patchwork Mon Nov 23 14:01:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 331584 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 9C54FC2D0E4 for ; Mon, 23 Nov 2020 14:09:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52EB42075A for ; Mon, 23 Nov 2020 14:09:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="ANtLkP4j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730457AbgKWOJS (ORCPT ); Mon, 23 Nov 2020 09:09:18 -0500 Received: from mail-eopbgr40087.outbound.protection.outlook.com ([40.107.4.87]:5240 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730406AbgKWOJR (ORCPT ); Mon, 23 Nov 2020 09:09:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IzEJKJIv8ifY5KmJiTeBIZfsJrkqc+GxfcYcIVrslpmaMQkO5+SWFNPOsYboAC9LsvSdrM/XylpaAcAUaw/ePoOby46tR6a92tu/pbUqxJ8hGgH+sqTrLXFacFDO2sOHuVQ6CSqq4QpVBXobTJ/a5dnTBNp3I6t7x2eC6SPuESyaICSv7yOW6onRqvPJxRMrg8ef0/UJXt6dJqGMXDhAIZJo8bRM4C75dgDGS6WwQqYGvx/Cd5jZF9xEJ012PXjAJxgyYENJ/S1JxaPUKs7Rk3eZFxu6W82MaSDnwZTT+6DzNvShtK6fcjCs0mtki7FiI2kDm1Amxu5gi+KwOUiuYQ== 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=ewEsDJwYkMeMWryd/64pEBAIx0NxOSiiHoDu3fGyrCs=; b=fuzOLrECcLjXc/VXxhmr7+Yy52MBPkWXSq0AyaNJOiRrOt2MgZxV8C9PMp0XikWGY6kwgT94b1rMONtNRNYYsEctO6UaIu9Oow51J8/Fx+Mo8bxslYvkD1HBRphmI5Fj8ka/2f4w+Sc05GP+SPO7+tYsIcreyOWhtZkOEJC2WnY83eAq0k0ufGvN+xpgBluzG9i7dSkq1UApLGGsCr3gXqMr9bQNCutuIZiR3ZfVnslvsfMaL0K8MjrJCzaxUHbmzWujH+/ocrvF9D5dDkP9v7tPZFGb3uScnlcdlUIwVW3L4Hd85R15NeqdmoCqStX2JiFWkV76TO5wBIDG16zElQ== 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=ewEsDJwYkMeMWryd/64pEBAIx0NxOSiiHoDu3fGyrCs=; b=ANtLkP4jvmfDvpM59x3DjxAt1kCuXNg2SBxzf9857/l5S6vr7641c4la+8ip48PLqwaJ3Fu3ovjcqMZKV41N/c9w+SepNtEdyoqgkOPUiD9l0THjdD2eVRxUzf9xQcojlQaE3zjEuOXodDeGj2q6jFkIH6/S8wyjXfNmnP6O+SI= Authentication-Results: linux.intel.com; dkim=none (message not signed) header.d=none; linux.intel.com; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) by VI1PR04MB5759.eurprd04.prod.outlook.com (2603:10a6:803:de::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3589.29; Mon, 23 Nov 2020 14:09:12 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::b035:d158:c99c:57c6%7]) with mapi id 15.20.3589.028; Mon, 23 Nov 2020 14:09:12 +0000 From: Li Jun To: heikki.krogerus@linux.intel.com, robh+dt@kernel.org, rafael@kernel.org Cc: gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com, hdegoede@redhat.com, lee.jones@linaro.org, mika.westerberg@linux.intel.com, dmitry.torokhov@gmail.com, prabhakar.mahadev-lad.rj@bp.renesas.com, laurent.pinchart+renesas@ideasonboard.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com, peter.chen@nxp.com Subject: [PATCH v6 6/6] usb: typec: mux: add typec switch simple driver Date: Mon, 23 Nov 2020 22:01:36 +0800 Message-Id: <1606140096-1382-6-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606140096-1382-1-git-send-email-jun.li@nxp.com> References: <1606140096-1382-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) To VE1PR04MB6528.eurprd04.prod.outlook.com (2603:10a6:803:127::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR06CA0164.apcprd06.prod.outlook.com (2603:1096:1:1e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3589.20 via Frontend Transport; Mon, 23 Nov 2020 14:09:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 950c2f62-f283-4f97-3992-08d88fb95a2f X-MS-TrafficTypeDiagnostic: VI1PR04MB5759: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yOjqrvJNLW8r78qop2vRBfkAp/zGPRJ/CdysTOllYnfkmpvi/WGDLvR78YiLvoy5Q0NRsg5vJCU3RUXSvRijO51QXuX46Nr5dWDICRusk8CWyJ0StqIlPhumCaYO+fONaAkrNDzInAdvTJG4UNqbqfDCFb1hu1F2MCzOAaERpBYh0w1heMt5pVoBoPqdIaXIv4Du45VZHp4WHaUdPx7JVscLAN9ZglbLlGziOeqACltEzJcCOF/hv8EYN3fqqlsBtwBxfdE8iPWQmVeaaDrifMExtTSqDi1JOiiH8qLY16tALAd1PVKVpSAsna/XdUbCq5APIf0vwetGWim55z00t3GItpiLo+sOr4Dti9AKswb+XmNO6D4b1zNfpKmExJ4U X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6528.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(136003)(376002)(39860400002)(396003)(86362001)(8676002)(4326008)(26005)(69590400008)(16526019)(6666004)(186003)(6512007)(36756003)(2906002)(83380400001)(52116002)(956004)(316002)(2616005)(8936002)(6506007)(478600001)(7416002)(5660300002)(66946007)(66556008)(66476007)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: d4fxjbXr8KfR5hcj9yzY/+eZiVTJkG+XCgg421Secx6uneFtG2LGIblf650+us+Lfo8LYYUh1d1E7YGvslpbb3s64bSi1VggCsGuQ9aikPpSf8t0XXmaLmdP3iQTYljNA6mx8NteJPat57uLGSJzuz1Re2ugPEUMUq71IC2usrLLGZOtwSi6gtdEFreKuaZZmZi2gTfdBDrr6jDKUyH/Wvat44TZrOcl1O+5BDad4UKrm5jDyAaxL9qFYUNCLPOOn0YJw8nf7T9xSYZXXBKkDuzsEo5WwFTpi3SUA/wy4CRJX0ufhiqw/AOlxSTM9T7SBs2jzxncEjoIdi15KersXjr3ss3V/ikTJLMiV/wSgrsYRYMDZFWIiPU8ME+HsTxKEUz7i6e5aiEuG3LDe4ptVh/8lMt0Jiup1Bhe7Zm+Unkz8B+duJfI5xn1oPJxXx3A9+mw2wxz2ZfvZ/E5oVO8Mwrxhx1t7z+xfMzGd+CNKGmrVlSzQoXs5VaP48OIf0ToCjkQXZAia1o7TUgVz6Ah2TyguLB6irBgRFFF71PgKA6afLq+YmTW1bgevVY5iVtnXporx3fQYxesh9/SNDABTZTlSOJRvYKuAMwBwTBnL38fD4JG8CAMcWqxWBvGZkLFX3SGggZ48aGayUpB81BEGNF6IEj8FiNG45cJ9qZvNbhJD+0Kj2jcXLG7GScz1ProrTCsCflZ+V017C2v3jB0C9iUYIBa7n39pii9DFIyby4y/Pth4BnfTJts+BYe5FdDSJwHu0OoLZ4sY3j6XPauXJx94ZEG9fZiQlqKG7TaI0kqm2UtX0wFVWmROz6LFREYXp7BvZLDXofcO7qVdDQSK5TBms7qHi0swDDnFWTRwiMZNZUfdXHejnsZfyAjqXFXMC+L2eYpUUBtZWC8PfVQpQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 950c2f62-f283-4f97-3992-08d88fb95a2f X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2020 14:09:12.0979 (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: fLujDGNK+cuKp+PenSZqbHcBcHTmZ+UkZT3ZmnGHKDntxfCrxksAb0k/mcbkCQff X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5759 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org This patch adds a simple typec switch driver for cases which only needs some simple operations but a dedicated driver is required, current driver only supports GPIO toggle to switch the super speed active channel according to typec orientation. Signed-off-by: Li Jun Acked-by: Heikki Krogerus --- Changes for v6: - Use general mux control for typec switch, currently only support max 2 GPIOs to control one typec switch with 3 states: orientation normal(cc1), reverse(cc2), none(deselected both channels). Changes for v5: - A few changes address Andy's comment, remove gpio check as it's optional, add module name for Kconfig, use correct header files, and other minor changes. - Remove the mutex lock as it's not required currently. Changes for v4: - Change driver name to be switch simple from switch GPIO, to make it generic for possible extention. - Use compatiable "typec-orientation-switch" instead of bool property for switch matching. - Make acitve channel selection GPIO to be optional. - Remove Andy's R-b tag since the driver changes a lot. Change for v3: - Remove file name in driver description. - Add Andy Shevchenko's Reviewed-by tag. Changes for v2: - Use the correct head files for gpio api and of_device_id: #include #include - Add driver dependency on GPIOLIB drivers/usb/typec/mux/Kconfig | 10 +++ drivers/usb/typec/mux/Makefile | 1 + drivers/usb/typec/mux/switch-simple.c | 126 ++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) diff --git a/drivers/usb/typec/mux/Kconfig b/drivers/usb/typec/mux/Kconfig index a4dbd11..11320d7 100644 --- a/drivers/usb/typec/mux/Kconfig +++ b/drivers/usb/typec/mux/Kconfig @@ -18,4 +18,14 @@ config TYPEC_MUX_INTEL_PMC control the USB role switch and also the multiplexer/demultiplexer switches used with USB Type-C Alternate Modes. +config TYPEC_SWITCH_SIMPLE + tristate "Type-C orientation switch simple driver" + depends on GPIOLIB + help + Say Y or M if your system need a simple driver for typec switch + control, like use GPIO to select active channel. + + To compile this driver as a module, choose M here: the + module will be called switch-simple. + endmenu diff --git a/drivers/usb/typec/mux/Makefile b/drivers/usb/typec/mux/Makefile index 280a6f5..712d0ad 100644 --- a/drivers/usb/typec/mux/Makefile +++ b/drivers/usb/typec/mux/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_TYPEC_MUX_PI3USB30532) += pi3usb30532.o obj-$(CONFIG_TYPEC_MUX_INTEL_PMC) += intel_pmc_mux.o +obj-$(CONFIG_TYPEC_SWITCH_SIMPLE) += switch-simple.o diff --git a/drivers/usb/typec/mux/switch-simple.c b/drivers/usb/typec/mux/switch-simple.c new file mode 100644 index 0000000..4671169 --- /dev/null +++ b/drivers/usb/typec/mux/switch-simple.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Type-C switch simple control driver + * + * Copyright 2020 NXP + * Author: Jun Li + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct typec_switch_simple { + struct typec_switch *sw; + struct mux_control *mux; + struct gpio_descs *switch_gpios; +}; + +static int typec_switch_simple_mux_set(struct mux_control *mux, int state) +{ + struct typec_switch_simple *typec_ss = mux_chip_priv(mux->chip); + DECLARE_BITMAP(values, BITS_PER_TYPE(state)); + + values[0] = state; + gpiod_set_array_value_cansleep(typec_ss->switch_gpios->ndescs, + typec_ss->switch_gpios->desc, + typec_ss->switch_gpios->info, + values); + + return 0; +} + +static const struct mux_control_ops typec_switch_mux_ops = { + .set = typec_switch_simple_mux_set, +}; + +static int typec_switch_simple_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct mux_chip *mux_chip; + struct typec_switch_desc sw_desc; + struct typec_switch_simple *typec_ss; + int idle_state; + int pins; + int ret; + + pins = gpiod_count(dev, "switch"); + mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*typec_ss)); + if (IS_ERR(mux_chip)) + return PTR_ERR(mux_chip); + + typec_ss = mux_chip_priv(mux_chip); + mux_chip->ops = &typec_switch_mux_ops; + + /* Get the super speed active channel selection GPIO */ + typec_ss->switch_gpios = devm_gpiod_get_array_optional(dev, + "switch", GPIOD_OUT_LOW); + if (IS_ERR(typec_ss->switch_gpios)) + return PTR_ERR(typec_ss->switch_gpios); + + if (pins) { + WARN_ON(pins != typec_ss->switch_gpios->ndescs || pins > 2); + mux_chip->mux->states = pins + 1; + } + + ret = device_property_read_u32(dev, "idle-state", (u32 *)&idle_state); + if (ret >= 0 && idle_state != MUX_IDLE_AS_IS) { + if (idle_state < 0 || idle_state >= mux_chip->mux->states) { + dev_err(dev, "invalid idle-state %u\n", idle_state); + return -EINVAL; + } + mux_chip->mux->idle_state = idle_state; + } + + ret = devm_mux_chip_register(dev, mux_chip); + if (ret < 0) + return ret; + + platform_set_drvdata(pdev, typec_ss); + sw_desc.drvdata = typec_ss; + sw_desc.fwnode = dev->fwnode; + + typec_ss->sw = typec_switch_register(&mux_chip->dev, &sw_desc); + if (IS_ERR(typec_ss->sw)) { + dev_err(dev, "Error registering typec switch: %ld\n", + PTR_ERR(typec_ss->sw)); + return PTR_ERR(typec_ss->sw); + } + + return 0; +} + +static int typec_switch_simple_remove(struct platform_device *pdev) +{ + struct typec_switch_simple *typec_ss = platform_get_drvdata(pdev); + + typec_switch_unregister(typec_ss->sw); + + return 0; +} + +static const struct of_device_id of_typec_switch_simple_match[] = { + { .compatible = "typec-orientation-switch" }, + { /* Sentinel */ } +}; +MODULE_DEVICE_TABLE(of, of_typec_switch_simple_match); + +static struct platform_driver typec_switch_simple_driver = { + .probe = typec_switch_simple_probe, + .remove = typec_switch_simple_remove, + .driver = { + .name = "typec-switch-simple", + .of_match_table = of_typec_switch_simple_match, + }, +}; + +module_platform_driver(typec_switch_simple_driver); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("TypeC Orientation Switch Simple driver"); +MODULE_AUTHOR("Jun Li ");