From patchwork Tue Nov 3 11:40:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 11877245 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C67F5921 for ; Tue, 3 Nov 2020 11:46:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C25C216C4 for ; Tue, 3 Nov 2020 11:46:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="NXk7Gs3i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728072AbgKCLq3 (ORCPT ); Tue, 3 Nov 2020 06:46:29 -0500 Received: from mail-eopbgr40066.outbound.protection.outlook.com ([40.107.4.66]:28642 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727109AbgKCLq1 (ORCPT ); Tue, 3 Nov 2020 06:46:27 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aqaJJy3njJXAEB7/CsWRVAhEJpGsGBvocQEvXob4eZeZS0CcW6+s8BhjwYvlkXSuNFdnaJun2GgfhqWlHKL3B8wR/jeMIxfXY/cFHpEH4Eb9MGwOG+orpExMOLeC+PTxd4kQZTYdUleY2iaoxk3Rm9te3ttdSATHjv50YDekICR6lUZnHxuOdPlztMVNfeyD8IWbjwPtzOqWwgokD9OALqxD9TGX1xgxiD7pDfFIGrl7RxVcIIJ7ylFNfgmaZu2j3cFKJpDhUHvSSXn205QScer/sP93aQY+zECdYjBHN/SyN4EZUD9UIQQiHQcjZg6v7ZBW7qCCZPQNIQAcLY6sIQ== 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=5w5WD8gBwMCmRzhXi8+9zceJ3wKIZEIC8qZhHX4kPC4=; b=lW+1/aWLc6/n+hIR5wReWsnL38RStEOfFjuJVBprY2b2/mya1Q2qfSgt+++G1OOjY62XDjCPJezFhuQj2xmoIO5SAMUoNFFroUEs6NPeNDVGhWoT/S/MBoBJnoUQoGZjO/eYWSqYKjdFvPoZBE1xGaQdJ8ZQoRj6gS8opMYw/iYdFagQvS6CqFDAvzQfCVBZgDUNQA1StSAgYLw9OSTn0Vi4Tt7PJmsm/MyKVC7Lo90bSsKJspCfS6Y5siTbNN/7I8539Phlprkw2RQV5JGjaewKJ9FjkMB5nZcHqxn4sQpZ4GEG2hW23gWKGE7D3DaO85HC2nLVJyE73Q0F1QRaTg== 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=5w5WD8gBwMCmRzhXi8+9zceJ3wKIZEIC8qZhHX4kPC4=; b=NXk7Gs3iNmNKzoC6dZYJqcaLBhqvujpMrx6o5K+xxouO3VXsCFeuaWqc5qH5X/mLkCaw3W43XvoJrGr1Vz0i6kQdeVe3bPNUxX4Mc0Vkg06Zml9q50gm22nD3O5ZzKAzC9jXP9ofnTtDvjCiBLtZqHR+2X1bgYVDKrbyZlkd6W4= 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 VE1PR04MB7278.eurprd04.prod.outlook.com (2603:10a6:800:1b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Tue, 3 Nov 2020 11:46:22 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::852e:24d5:4c9f:5bdf]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::852e:24d5:4c9f:5bdf%6]) with mapi id 15.20.3499.032; Tue, 3 Nov 2020 11:46:22 +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 v5 1/4] dt-bindings: usb: add documentation for typec switch simple driver Date: Tue, 3 Nov 2020 19:40:07 +0800 Message-Id: <1604403610-16577-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: SG2PR01CA0131.apcprd01.prod.exchangelabs.com (2603:1096:4:40::35) 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 SG2PR01CA0131.apcprd01.prod.exchangelabs.com (2603:1096:4:40::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3499.19 via Frontend Transport; Tue, 3 Nov 2020 11:46:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0a7bf8fe-9195-4e49-9d80-08d87fee15f4 X-MS-TrafficTypeDiagnostic: VE1PR04MB7278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: awh9QUksJCvyPhyWGO+mHOhwAzOi6RHn03KSdewpUO5UPmgBzP58RxEMK1BSzlIrLy9cpmeYmYLtN6smah5N/oE1/Hj4fJ+MeaCYfJNQC64eXOP/9nu8KPEZMK6hn70ny06jTi4wLy/nfuU5L3tews1tv3sWZVY+Tm1EQjiZywDtqgS6ryJYpwq2e6nuOnBow366E3JykKxiifSMdUyQSrx5cShMFZO0BZbnDLbcyZYXIVSqAZ2+9H+OK5aLTMVNPW+CBCL/JmRmrCcWBbqA1QGoqk20pYGNsBFiii0A0vT/h6EGQWR5TVVspMiLdZtMrm++uNRSY2oPEfiHH7iQEIT5s3QxJqSVIC7A0wbkpD/oa48+2PJt9nqQF2fXjJczbk8ZgjtpnAl0655qzW28KZlzgL5QDb5B2eUc+XSem3X5B0W1l1lRGdyomkGLPOFLr9RQyYAXf08ofieLSBttaA== 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)(366004)(396003)(136003)(346002)(376002)(39860400002)(69590400008)(26005)(316002)(16526019)(186003)(8936002)(6486002)(6506007)(7416002)(4326008)(6666004)(478600001)(966005)(36756003)(956004)(5660300002)(2906002)(66476007)(2616005)(86362001)(66556008)(52116002)(66946007)(6512007)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: yfKLULPVn3Rhq2LxA4rT7FGtSeZZ2U7H1Ih4B33GNLP3RKIPW1YjRPDsAYmUrejYCeL0D+WaP+qW8eRzmGYZH7Klq5pJXTw9EBE5c+g0p2SYKmRw7ONfCi0C0Mo+A5BoGF7irI+TIGnrv1fba4xnyXLBhNUMH9ZG+93TZ/W4J9npDH9AcQHpqazNRuJvHeQ9AOGi6BBq5HtmWAMrLrL4F5jpF6fp0HiDdfo33VjDQb7RyZ57kHodFH4vouwfID5iOcOyxgYXiKm/1JaoQC1HVQwc6ukgojdmpSV0+f+lVC4Elc86yK299QlnTsg8ON00RvtaasGD7zHkOVFCGE+THQUmGJj5Wf66m9uftwfJJPOf2JqqY27Qsup04WX60qwTmJJj2DLwIQqPhz62T+CwFY+1wkZrWGWFL7L00fHMh0+r5yKSHHIdHxceVt10d5rZEoH2LRNtYvfYb+mCdKi5uUGmLjz7/v0ubHeNb7JGGausqHGnUywLcDWtJMg4pDAuQ3oiqkBnT4xPMkS80wPh0mTZrgfOT7313Fliva2nm4JyVFDGPE5vxtV8l7TSMrEoK4K+QV8ZF1Oc4m9spn/tvXcdHmp4enIaZtWEgY6l159Iz9JEQcWiAs6se9LuiCAk4557Y09R8vhQuhX3QWpKiQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a7bf8fe-9195-4e49-9d80-08d87fee15f4 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 11:46:22.3769 (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: jY7iqcYTD+qL4yOrHU83tm4Ch+qk9L2QCyMpG8z2Go+ckbe89VeBUYoKEpsuZ4bc X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7278 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 --- 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 | 69 ++++++++++++++++++++++ 1 file changed, 69 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..244162d --- /dev/null +++ b/Documentation/devicetree/bindings/usb/typec-switch-simple.yaml @@ -0,0 +1,69 @@ +# 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 + + switch-gpios: + description: | + gpio specifier to switch the super speed active channel, + GPIO_ACTIVE_HIGH: GPIO state high for cc1; + GPIO_ACTIVE_LOW: GPIO state low for cc1. + maxItems: 1 + + port: + type: object + additionalProperties: false + description: -| + Connection to the remote endpoint using OF graph bindings that model SS + data bus to typec connector. + + properties: + endpoint: + type: object + additionalProperties: false + + properties: + remote-endpoint: true + + required: + - remote-endpoint + + required: + - endpoint + +required: + - compatible + - port + +additionalProperties: false + +examples: + - | + #include + ptn36043 { + compatible = "typec-orientation-switch"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ss_sel>; + switch-gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>; + + port { + usb3_data_ss: endpoint { + remote-endpoint = <&typec_con_ss>; + }; + }; + }; From patchwork Tue Nov 3 11:40:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 11877247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CB9092C for ; Tue, 3 Nov 2020 11:46:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B253207BB for ; Tue, 3 Nov 2020 11:46:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="OEBzY/31" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728465AbgKCLqn (ORCPT ); Tue, 3 Nov 2020 06:46:43 -0500 Received: from mail-eopbgr40066.outbound.protection.outlook.com ([40.107.4.66]:28642 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727923AbgKCLqm (ORCPT ); Tue, 3 Nov 2020 06:46:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BxvqnhNrYARpQEi5Ap3EQw31vJY5JBVIBfzE+qnUHfm6rRyVqHJN4B4A3O/tKSnhHpa32sbMbWaSfr83HxoIDYAmv7cv/iOhIiaNZ+iwUfXPdux3I637QjiL30UTas3z8Fouzv9JCoFKMN/cF+eGxNH0ke6xRPnsUQ6l8ALQRzF40mmUE9NKonSlh0Nr5uHqynvUFuhgkEnZwAwS/aSKbbHZtMFehaV3Mr+EKHtZPzs0IyZ3FAEo5IzLYbmhEaDsXzMNmJbnz0g5bUdaFqAWs7u/xnLonXZE3hfVtHwyuY+weKxVdcn3F5y93+1iY5EDFvRIRvrpqSX1o/0cB+hJ5Q== 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=aHglhA++m5WTUnzAra6cRX4kqXFTIwL+B0/ZkuiZyvM=; b=iUpfq1pvgKND3XwYTgHMIvsRYUjScbUSYlubTctorgbpfr2mMw553KDULtErGv0QjuJO8BsqnU2zkcz2bodCxtFkLEDz390SjRvAugyGNufx5I62m9MR+ogV1o+eghKQ4afxZwL8NyAmmM2dFz4LbXGIfvVAMjiDXJq4ff1n/64vkCPqjiDyE9YD6auGeX98q3DW/uUHmMDs6I6GPSnNY2N5x5vSv2M9SBMDdeIA5Flkwf74qr0sLQv0rDCQMmDTsCDUIoujSj3fBdM9x5dtxEJ9wEjMrS8qEXuu+wug0SlDaff7B0qXKkMDjk8+QI+1lnVvyZLg13/brH5ijiiz2g== 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=aHglhA++m5WTUnzAra6cRX4kqXFTIwL+B0/ZkuiZyvM=; b=OEBzY/313E835L5309qVxSKN0Y7+6gkKbtfkXVJhmIlcgyFjpkR+G6sTu03nI2zSX8pWWNarbzK96b28jfgiE7lnzf26XFG5B/N2VTDqjpkO7TWpGfMZxeFIgymla8GkaQMNzwWB1Cehqvp3phKTqZimNqPgZ3oE1EjIgoNXbzA= 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 VE1PR04MB7278.eurprd04.prod.outlook.com (2603:10a6:800:1b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Tue, 3 Nov 2020 11:46:27 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::852e:24d5:4c9f:5bdf]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::852e:24d5:4c9f:5bdf%6]) with mapi id 15.20.3499.032; Tue, 3 Nov 2020 11:46:27 +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 v5 2/4] device property: Add fwnode_is_compatible() and device_is_compatible() helpers Date: Tue, 3 Nov 2020 19:40:08 +0800 Message-Id: <1604403610-16577-2-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604403610-16577-1-git-send-email-jun.li@nxp.com> References: <1604403610-16577-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR01CA0131.apcprd01.prod.exchangelabs.com (2603:1096:4:40::35) 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 SG2PR01CA0131.apcprd01.prod.exchangelabs.com (2603:1096:4:40::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3499.19 via Frontend Transport; Tue, 3 Nov 2020 11:46:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d55c2006-e54e-42e4-bceb-08d87fee18d2 X-MS-TrafficTypeDiagnostic: VE1PR04MB7278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pSUUING/exk2cTDngFXxMW7qTv7xc7Vm64ypCU0jg1vocgj99Jv0uTLO6dc6hkBeQB2/704pdVE7iwizmlTWQ7orjUnjhUOx8Hg2dT5iACrU3fXbNjYMWSinj2OkGMSh508uC39dOhPwvNbHxJdPWDP2i9YTcGer3Hwr0Q0zwlqNWfgRql7HS+i/CBgLr9MjN84GxJiMIGn6CcqRVIEwcZlw/U+b28v0hv3IfDXQ1+QWSJpmYwRDJfkNdk7M/J5PwVKtAHRuuWs+jeyZ7JqAJCQVNOeICJ+AH633hmMbsM2leUY/eVTLdvSlF72ECJKVXkGnUSBsrLKQisTimzk0slYvKohQBLR76ZfC71EYwS3SysjBSEU4hLvOLSi3rHtN 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)(366004)(396003)(136003)(346002)(376002)(39860400002)(69590400008)(26005)(316002)(16526019)(186003)(8936002)(6486002)(6506007)(7416002)(4326008)(6666004)(478600001)(36756003)(956004)(5660300002)(2906002)(66476007)(2616005)(86362001)(66556008)(52116002)(66946007)(6512007)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bZasUjLPjnx8dd55AjGizeN8LO555MOrQfaRGOKu17g9nEap+frncfQQtQnFrMJLnDqxudgfUqOObEK/qHGQ4zF0IdVdWdM86vAphop5V4BMBhjp10IbQ7O5HIw2ZWucxxVDkrtGF65qUUvOtysomK3yTKlMllVdcXHrrNANhFz4gqEOtdOur/JAhi2ueSFrqYhna2VNrKFSPhIkeqvhj6vO/JKrdqpgsMw2hDukwnbn4MaRaipIzQq2GcPBLupzlxlyVmI0RnL1BaqeaXrh3x61BDnRNsCVUVAxqMNDVKSv/R2ns+DqWCqupHVnEsVr8/0Ez+1IFMtKfK+wmvmlg9ST4xeq1EHd7NglgIzi6Y2puOX5g27oioOiVqjIfJVJLqyauhpPTvPr07Ib+eEGRoVl5DJcTRhybBbLwnZbDahJd6UttzukkIS1oJWrT/l+7DKgoC52g79awq7pacWsRE/pLVHx2Y1j0YJAzFakJ2rhbPNdbQ5M7uOc8m2WT4pfbDZMWXbYr9NbH59rqg+pgG7XNDmVQm79/1AvtGJWPi7BI86hTQ6k5u/Uizq69MuO4xd2igh1qwQ3Pv2pm3TZbcCSvB+3HGEcwNGrmnfM6+O1cAFwUDDoIZdOs+txuXT/MbCJe3pb0kecW5/+dI63vA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d55c2006-e54e-42e4-bceb-08d87fee18d2 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 11:46:27.0062 (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: RVTSFIz8SY04f3/en9a0g7FN+uZNIT9rV+cfH33T1xuqvRZ/mBqdevlWOMP+AP5Y X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7278 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 --- change for v5 - A minor change to move the function return valure description to a new paragraph. New patch for v4. 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 Tue Nov 3 11:40:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 11877249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46E7C921 for ; Tue, 3 Nov 2020 11:46:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EEDA2242A for ; Tue, 3 Nov 2020 11:46:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="AgF7SuWm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728727AbgKCLqs (ORCPT ); Tue, 3 Nov 2020 06:46:48 -0500 Received: from mail-eopbgr40066.outbound.protection.outlook.com ([40.107.4.66]:28642 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728687AbgKCLqq (ORCPT ); Tue, 3 Nov 2020 06:46:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c08olgZsOnRm+EkBTfBOI4FA186YZ24wdWmHS1niurjvUuT8hVgwGi6qUEZ87RpYnruoRekSPvBhpHT/ByaYi8b2gefCzp5otj5l7BGFviVV8TquH1qrYfsZM0WZ7Ezq/5MZLWh9eJgRft53Ygb462tyIml/7vraUCug2gV0XAK8A1sFAxhVQgyQCqkGcGWZmTUKoOIUcpEXL7t5m9s9vZr4VrviIJlZB/x3973TeU0wcgjPS42OIClJ1k8CyFaQdicbirJtn3dBdwJOz+EF8px2GsmcZDuYIeuwaK3RIyeA2ZpDhUIYuJIIoEBwTaA3S761uFj/dPbblwgwMruBrA== 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=qYw9QOWipAPRCL7dYJyu98rQ8T8VyjG02b+r45CKa2I=; b=CtWPO21wMBjppC5aTo2kGNftCczHhs16ei4cP+gjKK1sxQxfZzlAnoohMfxy5fEQPKQtbfo6whGBEwxp33NYghwY9TnaUGsrI7sx+GqVw8ajBNslo405ED66jDF4OnKnJL4ztVQg+o8iirD+m9Nrnx7juFX3Qu/IkSrJqxMiJM4yywxD5aRgSWBHJ+iEAKntiPL1WHReJJ9Qr5vhG/mglI16aYb5Df9O2x17kw4IY/MYCmU9Cs5zj8+llQw4GXfHIEwCmANeqo/jbb83uA+NRzVNhE5U26uXQ5KHWa6lQRSO5ECNGDEUoIgxX1OT5QdL7KTIhqH6/lNMWJx8OShi/A== 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=qYw9QOWipAPRCL7dYJyu98rQ8T8VyjG02b+r45CKa2I=; b=AgF7SuWmgDbxmgCW3tcJJFxTksdj0t0APK+cvnuo+bGYkFkyYqxKYmVPYIHTxzYZy6emEA+xnKFuPjNU1zL9jhiZ3jbEFP+SBMB4x5J2FGyWkaKfJteln8uLd19UmnutiJV4X2H/73+4NP7nRfUQOhqnn9KbFmBSDsWpJkMuydE= 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 VE1PR04MB7278.eurprd04.prod.outlook.com (2603:10a6:800:1b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Tue, 3 Nov 2020 11:46:32 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::852e:24d5:4c9f:5bdf]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::852e:24d5:4c9f:5bdf%6]) with mapi id 15.20.3499.032; Tue, 3 Nov 2020 11:46:32 +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 v5 3/4] usb: typec: mux: add "compatible" property for switch match Date: Tue, 3 Nov 2020 19:40:09 +0800 Message-Id: <1604403610-16577-3-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604403610-16577-1-git-send-email-jun.li@nxp.com> References: <1604403610-16577-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR01CA0131.apcprd01.prod.exchangelabs.com (2603:1096:4:40::35) 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 SG2PR01CA0131.apcprd01.prod.exchangelabs.com (2603:1096:4:40::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3499.19 via Frontend Transport; Tue, 3 Nov 2020 11:46:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6cbd9975-693b-43f3-ab4b-08d87fee1b89 X-MS-TrafficTypeDiagnostic: VE1PR04MB7278: 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: EkHFvnwZZ9+9nAT3iseZPyMSqQ3DYKd69w65Fxv2BpeaiBHs/3k8QFavj2Tfhe5hSUjBwEcJrsVZM+cVLzwSoEMiUxiY4R+YxF9Nsr7lyCyadt46ZCZyccwybsajP3zxW+Sv9NOHLL4ZlGtrhIhDWRWUvpDuORI4V5KCSNdLuHsZl51NtgUE/LuudSV7y6tLAWBOGntsOK9fkFo2KO5TWUdtzfjubcEBrCSeuawoGJEdC8GeggT8gmQ1iMcMM7kp1NqRM5HGkdBmDm+6frtrI3CFoJ0Elxf9u2wYNDMfeP0edP26AfBfWNBw413Qa73Mallt+3aIbwaKQYGsr2o7vZMuv93RHfO7nLAi5pijEVcnbaxKToPmCSFKvXcoKSRR 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)(366004)(396003)(136003)(346002)(376002)(39860400002)(69590400008)(26005)(316002)(16526019)(186003)(8936002)(6486002)(6506007)(7416002)(83380400001)(4326008)(6666004)(478600001)(36756003)(956004)(5660300002)(2906002)(66476007)(2616005)(86362001)(66556008)(52116002)(66946007)(6512007)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: quiU8LxRhZVI8IgCJBVukABYQ6O4/r96GOYu9emVjktZ4JY2C27/7q1KEphmrg4ixYjgm/GKNT8bNOEDN6p+G9ks3yK//nUzJLZjsPk+Jd+53RdReFuYMIiSLqXd1qur2P4Rx2ROPY2vhc29p/GilzCLNcBlcHMeKUDrRVurzto5HpAC74KA5FbtO2Bqi6QHh+uifTL3+0N/BAX3b5z0CSA53ovVGHzDSginMIoKm6fWK47NcClUEFIWGMAYozP7mH1SMRJLnsMF2ORkpwLcMmu5nzlQYuBuiI83yFvhRDt16W77VfABUHlga6Orad844Hy2ASGXrkxkuXZ93Gqbe6zh6sVvFXK/8kND3m2Se3E/rTTvVkxA9mmYM7+2/vXUCd4x8Yft/DwgeZ9W9y1bf7Uwn99nGixcdoAxSe33UX22LUN5Nk1u2/d3xyA/6IEPta+tPFNKYrUi6XhATNIGTFBtgKzJdpZAu7L17yws+QpvQlhBFyLLxc8NNohtZQwgwOcXgE/e2juIx5jBrZ0CSnhAe09DG3lJYeonT5SBR+Dbo3SrwAZmyPHLIexTgIqNTEBBv0xHAv7uZtNCE3yDGZz8zBEKnVJnGQ8pZUd2ewevhnvYhxM4JCHNgLlKUq75ppcG1yF7Rd/oL14JaWQRBQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cbd9975-693b-43f3-ab4b-08d87fee1b89 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 11:46:32.0202 (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: CQC7xBjt6WqgLyxaK10/k5odhrhtTEUeWLEsubWAH+Ng7moL6pI9e55sXp5aTD71 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7278 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org For those need a dedicated typec switch simple solution driver, use compatible property for matching. Signed-off-by: Li Jun Acked-by: Heikki Krogerus --- No changes for v5 New patch for v4 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 Tue Nov 3 11:40:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 11877251 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A39992C for ; Tue, 3 Nov 2020 11:46:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 609C7223BF for ; Tue, 3 Nov 2020 11:46:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Dlaw5BL1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728735AbgKCLqx (ORCPT ); Tue, 3 Nov 2020 06:46:53 -0500 Received: from mail-eopbgr40066.outbound.protection.outlook.com ([40.107.4.66]:28642 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727665AbgKCLqw (ORCPT ); Tue, 3 Nov 2020 06:46:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KItynheo1nhAOLjcEsswDYJOHIBizKRKfSehN6ItmIeLrdmDQ5DZULHKgzZrb8zVS2LZSar8oUFu9psvGFfUcMvquutPtINCtoWn7//npeiqclXi3Z+9et2izQQXn1EMijo70fnTILO/OIGVeV6n9CMGMgDW0iwA9spIaMi5seOHxR0jkJLj3WbYNdT85L9oowM203NX3kHOAvPOu/EHUwZaN5ruV9KiWE3Y5zi8MKba1T/DJuFTDq0P7vwVcO4gwbbsH2bu1FAODL4Vh10EuKBDZSCCm1be35Gj4QuNKUqOd21tagHl4uzgHov4Ga4DZAsPK+wu+2juRXIR23Hk1w== 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=U0nmpuMjyAzlYs7St5YcdiLOyI/IWKYRQ2TLTkVahaE=; b=Td74agiEX8Z7Xix4KBBf/cK89ImV/6YFhji0vabK5mzKgDZFSH2vvU2H8mlaCQedXqW7NRaqQxfa7QAX2z1PJjUl1HcLpNspdfCOdguSP1xJEggmGjh4gu+iwMNk+5kh7KWV8WFEv9o809XB0h/MQLuW9u+jZM9wlxQlZr2mEURZvAJFwMsfBt+7o1PP2eaLVsX+cDHlOvLpgZdcoq9cn4qysXIpk0wBC5VHSUw7Gz/Kx7wRSpUN0jXkJs4qXEenzJl5Cciv/NASMSArd5xV3XGlNDJ3YGkV78atgrz+Dyl80OyxaHLM88B0uKTqgsE3BZNCJRbFzwANHr/bh5Ufuw== 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=U0nmpuMjyAzlYs7St5YcdiLOyI/IWKYRQ2TLTkVahaE=; b=Dlaw5BL1Ivq82PsewyQtHcCES/L1h4lhxpkc8RRgYVBDug4rGKq5XUVEgqiw2Ik6Wjzu5f0JFkoXeC1UTEn5P4F4DHdbjIc3mDmv3jV1G7KZU9eWsl0qGG9EgP+cdo2Z+mOCgwdHpL8pSB40vvs86PjomR/Zbzy5ewi/1MS6NrE= 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 VE1PR04MB7278.eurprd04.prod.outlook.com (2603:10a6:800:1b1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Tue, 3 Nov 2020 11:46:36 +0000 Received: from VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::852e:24d5:4c9f:5bdf]) by VE1PR04MB6528.eurprd04.prod.outlook.com ([fe80::852e:24d5:4c9f:5bdf%6]) with mapi id 15.20.3499.032; Tue, 3 Nov 2020 11:46:36 +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 v5 4/4] usb: typec: mux: add typec switch simple driver Date: Tue, 3 Nov 2020 19:40:10 +0800 Message-Id: <1604403610-16577-4-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604403610-16577-1-git-send-email-jun.li@nxp.com> References: <1604403610-16577-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR01CA0131.apcprd01.prod.exchangelabs.com (2603:1096:4:40::35) 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 SG2PR01CA0131.apcprd01.prod.exchangelabs.com (2603:1096:4:40::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3499.19 via Frontend Transport; Tue, 3 Nov 2020 11:46:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 331594b9-e0bc-4c7d-e1b4-08d87fee1e91 X-MS-TrafficTypeDiagnostic: VE1PR04MB7278: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9JI25Quze5J12+NygoKt6BUlzA2F+bo3O/vNburxgfERgXXjLQWS0XlF4e2WCfB454mmar0UW6vn5ZOBbUbDa/Mxv2GiBDbarPWTPg+rkAduJyrZVeCQrpbOc+DGfJ8/QSWJsMHPEq1FdDVoxGANL0nBYRFL8uLdiopWApCRe6OEjxB0+myDJBCcdVU8tatkebwrhc1K0wC1CgtX76m5FmnAGRprO2w6JZxIxZJFWq9Ohkn0CyscNMEfgV2AZUTvbhti6k07MoN3HIhbl43a20qT99Z5hgQFQ/8lF/LX1UYyl3oxJenbyExLqJ3nfD/UNwsIE42TBtc16xxgNMNOiG/P+nCCqU7cHAwKDXoFLkxqaunJjZYxEiNTcLyKBvzy 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)(366004)(396003)(136003)(346002)(376002)(39860400002)(69590400008)(26005)(316002)(16526019)(186003)(8936002)(6486002)(6506007)(7416002)(83380400001)(4326008)(6666004)(478600001)(36756003)(956004)(5660300002)(2906002)(66476007)(2616005)(86362001)(66556008)(52116002)(66946007)(6512007)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: gmDJ+DP1OgLN5lHBDKGDIWTuEkZvNmTfw4SeKNavHWxxI5dzhrOIHr/8ZNWdHJgO4PHPAOye6pVY6HTScuq09Yk7GATca/eMX5zwrS8S4vhIzEBo2pSLY+J11A7hUpVWQyOzC2uX1DG9A/eMo3tqBk4lHEWxRB/qpZ8IDncEdFeHiqUiWJ8FrVhnlMOMKZRKF6wskKLZt0w4GvCgJgd/+W4lHT7mqvhE0az5jDpcm/KC+GsFDvpEJvnd1CZ/omLPV83IsKSPlRKJ0VJPah74RaO0j7UApEMhy/rn+5EIbDP+HFifO4RdPbgwe2+OyvGmo6GsgZFtcYhv9F+24/xb3M9Lm0V8+32FoknkxgaDrCSY6dvRpMIe1RixYFQbO992FwoMeJZLgqk7313Nfs373Hib2VoUUhK8hDVg70muBLxLniZrifRC1fgcIvl4N+dbgGKdn9e7RVQSnRF+vkGbYcWxdNx+7aGDZM7P96B4cLLME4h1zHCJEzxlzl/Tfh0juIy1G9XTVOahZzeuj8b6EYbu3WfojdSZFoHIjMR8cjE0PfN4J9WXXFJbGtQhgc3QivWZ+SJFd37ef6zwY4YLEykHI9klubUFpWklV6ZkrqzZGkfNFDA7vMW+qXy/B8nRi3LKZEnYY2EYBr1Dxd9faw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 331594b9-e0bc-4c7d-e1b4-08d87fee1e91 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6528.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2020 11:46:36.7954 (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: pFYoPh54+QXW3HdMPTo4w9Hr7l+D2kHdb1n8gTTJBSOr/zRkSQaWiv1i4hYPHruk X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB7278 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 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 | 100 ++++++++++++++++++++++++++++++++++ 3 files changed, 111 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..8707703 --- /dev/null +++ b/drivers/usb/typec/mux/switch-simple.c @@ -0,0 +1,100 @@ +// 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 + +struct typec_switch_simple { + struct typec_switch *sw; + struct gpio_desc *sel_gpio; +}; + +static int typec_switch_simple_set(struct typec_switch *sw, + enum typec_orientation orientation) +{ + struct typec_switch_simple *typec_sw = typec_switch_get_drvdata(sw); + + switch (orientation) { + case TYPEC_ORIENTATION_NORMAL: + gpiod_set_value_cansleep(typec_sw->sel_gpio, 1); + break; + case TYPEC_ORIENTATION_REVERSE: + gpiod_set_value_cansleep(typec_sw->sel_gpio, 0); + break; + case TYPEC_ORIENTATION_NONE: + break; + } + + return 0; +} + +static int typec_switch_simple_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct typec_switch_desc sw_desc; + struct typec_switch_simple *typec_sw; + + typec_sw = devm_kzalloc(dev, sizeof(*typec_sw), GFP_KERNEL); + if (!typec_sw) + return -ENOMEM; + + platform_set_drvdata(pdev, typec_sw); + + sw_desc.drvdata = typec_sw; + sw_desc.fwnode = dev->fwnode; + sw_desc.set = typec_switch_simple_set; + + /* Get the super speed active channel selection GPIO */ + typec_sw->sel_gpio = devm_gpiod_get_optional(dev, "switch", GPIOD_OUT_LOW); + if (IS_ERR(typec_sw->sel_gpio)) + return PTR_ERR(typec_sw->sel_gpio); + + typec_sw->sw = typec_switch_register(dev, &sw_desc); + if (IS_ERR(typec_sw->sw)) { + dev_err(dev, "Error registering typec switch: %ld\n", + PTR_ERR(typec_sw->sw)); + return PTR_ERR(typec_sw->sw); + } + + return 0; +} + +static int typec_switch_simple_remove(struct platform_device *pdev) +{ + struct typec_switch_simple *typec_sw = platform_get_drvdata(pdev); + + typec_switch_unregister(typec_sw->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 ");