From patchwork Mon Oct 19 09:03:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 11843871 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 1D5AD17CA for ; Mon, 19 Oct 2020 09:10:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CA35D222E7 for ; Mon, 19 Oct 2020 09:10:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="QV1BtBSh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728064AbgJSJKN (ORCPT ); Mon, 19 Oct 2020 05:10:13 -0400 Received: from mail-eopbgr60076.outbound.protection.outlook.com ([40.107.6.76]:14403 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727235AbgJSJKN (ORCPT ); Mon, 19 Oct 2020 05:10:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YA0Dme/QLItciHa17FJGYNxkZ+wQUfdNsf0z/12n5vD6EFjx+ov3xgmofsXWPGz6fiBjPRPcjKgB+6IRsEJ1dFH9dw1xhk6WZ6gAbKS7hQVynJL8FFlR/V8dUEcXiNe8VNJ5KzshF7wxkxwGfMj+vo59SR7KLt0HWeEVeEHuJH3sqFqJsL1+c++uFWGf8YWm2O4m6Et7hKk7DOeTsw42ktq7+AJVnb7dbYhxZqo5Dd0TlfM6mpqg22limIkYSQMcjEfYpw3PWM+An7iSIWmot59LscKH3cG7lZrfSqk3w6wwhDqOZo1fcaYOXbuGn2LLNqBjwYqmAZOSGhbVDX1psw== 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=Beg3QnEiQRH+PfPlHy6n1+tg6XtXGaljM3uvHLxni7Q=; b=TowTO32es+PEtkhNQFjiQ3EEYZQ0cp5OxflCqJWEWPc3YV+vBiaN76Smwst6w5+KSV5F2OL3iRFUirQf0EPBFW72Hld7zc012R2R4PcDxCllTlKbmAaEZ13vw15QJnBxPVmrE5bWmnd5vVnw2FvKag76+BQ7/bgtw3WAcd0pTd7wfIrlS74bePmQNbNTnQYinr/LepkDoS+fnQsVTDp7wP2b6up3nn1wbb9Ya88rhmqTjzzkFz8D6h/jUBmNdLR+LpdJsMyAwpwsxyh3yte10dz6jcgfWklNY6hNL6MIbcAXaKFTWD0H8zfe9euMFJY6saireQvkBHU0xJALVxboSw== 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=Beg3QnEiQRH+PfPlHy6n1+tg6XtXGaljM3uvHLxni7Q=; b=QV1BtBShuB54m2Z87LT/m5+j+8He0OMrXo51CeI78XAY/FsI/LZf+MZ9RUdm7glKOdWHtddUrnrQG6yJ+/fNiSwbXY5716ujwiYddsDNARNDcu6hpYyA2GG0YS/MYC5l4iIveFfgBHKPVnoK90xtuMFv1r9xkTusqE/a/6L3kLw= 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 DB8PR04MB6523.eurprd04.prod.outlook.com (2603:10a6:10:10f::26) by DB6PR0401MB2342.eurprd04.prod.outlook.com (2603:10a6:4:4e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.25; Mon, 19 Oct 2020 09:10:09 +0000 Received: from DB8PR04MB6523.eurprd04.prod.outlook.com ([fe80::35e9:2f0b:112b:28c3]) by DB8PR04MB6523.eurprd04.prod.outlook.com ([fe80::35e9:2f0b:112b:28c3%6]) with mapi id 15.20.3477.028; Mon, 19 Oct 2020 09:10:09 +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 v4 1/4] dt-bindings: usb: add documentation for typec switch simple driver Date: Mon, 19 Oct 2020 17:03:12 +0800 Message-Id: <1603098195-9923-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: SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::32) To DB8PR04MB6523.eurprd04.prod.outlook.com (2603:10a6:10:10f::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3477.21 via Frontend Transport; Mon, 19 Oct 2020 09:10:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 749526a9-3135-4111-dd38-08d8740ec6d6 X-MS-TrafficTypeDiagnostic: DB6PR0401MB2342: 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: x59XFxft0RLCOuTdtKWM38+HjOtOAaY8VN8Dfu5x3JDN1/I0VP39f56LKu3lpfthvZbTU3Q2s1HIXN7YrMPEEROzotB1JDkeuJxz/q4ugWP9Ftnu+vM9EAlsM3YzbTDd/J5GsvlPRW+UTdqZCd7IbcybZEoiKQNcwGddn1XoMnY56HUdtSbmCAixcm9R8qNH2T/ukuF4Uh8i7qoKxzG1O/qlTtMZP40dVKNRwEtPAVK5lQOlmBT7ebPYEYikNLWsVloukgh7W4oQNtBu90doDRdrxy/7vKIW25s0/l22ljzCsEoba0uk1qgQ+gWMpNEWERmy3mJrExaXUid94Pj+9pC7oJbbYJriFpqINdvZIYELM2EspZJ7+aPsEFo1iPiQGKe60/MGnlUaYFT7EvJMcwcJ2cWzAok2PZamzMO0Cko0gx2SVV4irfxNvh6RLfL11vLqbAuX2up9neGkOB2FpA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB6523.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(376002)(136003)(39860400002)(6666004)(8936002)(66556008)(7416002)(316002)(5660300002)(6512007)(4326008)(36756003)(66476007)(66946007)(8676002)(52116002)(69590400008)(478600001)(2616005)(956004)(2906002)(16526019)(26005)(86362001)(186003)(966005)(6506007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: zMwt+A8xrSL/nUJXlabP6dLyoc/a7Z6Cj4+1pZFdDmb0x00Xmj+WcZcuh19EE025Rx+Vx75V6uLv1f+c7YiouVlqizXVKGxLk1d60Lr024g8aa0RCJDM7TeVjKSozy+lmghSy4bTxWH+8FBwDNxkoGD+VNGmPT2y3HSHRfkV2WzhV3XUi4OS00qYem+0QXO1U0jl67YlBlWnNf4oz313jtpi7S/6SOSicLwlB8JMtuwzH1LGoFft6YP+f84bAjHZhhxFvv1dZBg/U2Ws7SWJ0bChcJ86RKgDoMFMLaSnqqEvhKQpcfaiy0RNBvPL6iXmAu2LuhSahJyCg+FP3s5K5cYfwk0Fxz06JrIxvB0LvoMfSV9NRLq8e1CGuwgzwp8lwaCfNaR/lvIaSJPXdkUNveNA3+/Ud0RlsBV2Kg0LBKRVmRy5Nu7Krd3ao4GPczETxgjD5nY/EiPQtvFDEQl1DXD6NWdU5ymrbUUeZMoZTthOGghPeDl2m8OYC07CtFwYHs/ZtT+NKz9hNDNrzbRvYyOK07hJCXH3VSI0d9OcGBZf8dSc6peTA26LELRfVOVskos2kxh/5IBofiNImChxbZWb+qV6sOzC4BhgJn2IclMOKSguzKtQOMoOhH4VCI6m/sXGvkgkUq2IgMp3VRafqQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 749526a9-3135-4111-dd38-08d8740ec6d6 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6523.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2020 09:10:09.4195 (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: RnyDjWWiRZsE2UjMQ5/vfNSjtrhBLg2EweyI+5yRfBYsIazu4i0GGahvq4vY5HKo X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2342 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 --- 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. previsou 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 Mon Oct 19 09:03:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 11843873 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 25A8361C for ; Mon, 19 Oct 2020 09:10:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC3D822282 for ; Mon, 19 Oct 2020 09:10:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="TNDG3SQ1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730163AbgJSJKS (ORCPT ); Mon, 19 Oct 2020 05:10:18 -0400 Received: from mail-eopbgr60080.outbound.protection.outlook.com ([40.107.6.80]:54046 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727235AbgJSJKR (ORCPT ); Mon, 19 Oct 2020 05:10:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ABwRcc45yPPI+VwO6fBF9FamM+d5kAUz9zqSv1o3z/8pSi1Y/dYlPnxpQSlLfg1JNoJauCm2oGpscn1k17el7DcZNta1hj1ejLLkg94RJpqoxN7DFvdCTiUg9PlDtnzOOolbyypV28AsPfT6eD1iHv8UegAc3GRWOJ4OocgS0nolpN4mgF+eixIA62NKmpUJbhe3rKjT5FHX7vde57CVWmi17UESdrjXiv2cyythcXDBcIJXg+oEMDrTfKCtiad3+jXCzxRX4xSDgj8WRUVlltR/wkG6p6rlV7D1CKMa400pqgXs6g0A1eSboppxa5gAIkYc3FQs7LTmrn3uEWBhSg== 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=S8vk+XZTydaeDCsS2UPxVDpzAulijz2e5lZz4PBh4t0=; b=UXKFfzAl6uhRWoJ4Ywso0XO1TD4ipkE9MPNfOZ8LZg7BPGlV/EpB7AKkI6FvzdMWvUAMcAwBOT4JGFm62gPunOxTXMf/u4cSeynB5/HFFsf0tDqyhbrJHWZi34QnTKTbWlRAOzadww14PsNVAdJv7rzUAM4EKTaT2069TVhyvhoY5cdbXFCnnvL6j3ru4Jb+M+WuD1LHMVmJffJp6pOu5FEu6DeXQcN4oLMnBOT+8ooep2PXxWj3R96kfr+z1hK+0U+v4W9rgtt99MzUYvU7R6B0JzqiYoWexj0MIYBkXkIW+speABuBjbclMgTwh0RQnDDnplxRWA2i0Ir/MHD7JQ== 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=S8vk+XZTydaeDCsS2UPxVDpzAulijz2e5lZz4PBh4t0=; b=TNDG3SQ15hkfsbdJl3Miluq8J8b9hHRtgk360t7MFw+Wp54CxdskhpzfVb1NDJFrAbo6zX/ab7iaTGKYkfHBePMDCfxyN3jhFAcEUUggUoaiw5RxJwTumPgOZDygEgmOgtVinqAF+dEeyGzY2mOa+MHzMsHMc6iyGSHmEbjYa7c= 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 DB8PR04MB6523.eurprd04.prod.outlook.com (2603:10a6:10:10f::26) by DB6PR0401MB2342.eurprd04.prod.outlook.com (2603:10a6:4:4e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.25; Mon, 19 Oct 2020 09:10:14 +0000 Received: from DB8PR04MB6523.eurprd04.prod.outlook.com ([fe80::35e9:2f0b:112b:28c3]) by DB8PR04MB6523.eurprd04.prod.outlook.com ([fe80::35e9:2f0b:112b:28c3%6]) with mapi id 15.20.3477.028; Mon, 19 Oct 2020 09:10:14 +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 v4 2/4] device property: Add fwnode_is_compatible() and device_is_compatible() helpers Date: Mon, 19 Oct 2020 17:03:13 +0800 Message-Id: <1603098195-9923-2-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1603098195-9923-1-git-send-email-jun.li@nxp.com> References: <1603098195-9923-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::32) To DB8PR04MB6523.eurprd04.prod.outlook.com (2603:10a6:10:10f::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3477.21 via Frontend Transport; Mon, 19 Oct 2020 09:10:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a0fc9a30-67a9-4ee7-b3c6-08d8740ec9df X-MS-TrafficTypeDiagnostic: DB6PR0401MB2342: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8MHKoJB1vn8NInQ0kWxqicpKgziSC/YhTut5awpBjzhViqZAa2TL4BycbYXSf59agJK7hSspqpe4wuEng2XkLkvF6hi3gk0dDHyzprg3y8z+wgqYy3JO3IkqarT7kbpv2xbkNFDn5F7lUgkQDS+xoEKSxwWrTZfvgD/Z372XVST8OXXAEsMcuoQYjeGgjgJzvBe78SBqcEYwOTV/LEmaYg7wydGOuZMr6RZQkzxKaOJP7pakYl7cposll/cUqZsBWh2SGmnDD4pm/o0bFoT/G2DhzFQWOmdTJHoOTUEZJ3L/MLi4Mkna+HRPdoldoGSjiZyTqOWW9HMBfyKOnTXSsZo9dLFvp+HhKq4yENbc1/cP7FYqmTF/r/zbmod0jV1G X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB6523.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(376002)(136003)(39860400002)(6666004)(8936002)(66556008)(7416002)(316002)(5660300002)(6512007)(4326008)(36756003)(66476007)(66946007)(8676002)(52116002)(69590400008)(478600001)(2616005)(956004)(2906002)(16526019)(26005)(86362001)(186003)(6506007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hsJNo2lcV4q78InLOqmNIaUZzuG21vduZwqovAJBd5NWeVHDotMbgheluC7IUoJrRzy/zwjFG8CWNM+E+rdz75q/GraP4rarqkGNTDdokILaq+tc3uMHOunTWja4PYVkCHm8dvUsZCTxdel29WLaIpoRi6nl92qTsAur+4+PAcihcgKvpmIjRG1baDaxwDzGkODPpdO07qDNf9ufkRmqxUxR0kLldlpY/SHHE5DBMldxasqjy6IpA+Bgg6OHCjA2ZuTzE2OjmfuYTggW1r5yQ0f8PIX/x6isgOXdL9nzzsp7MRz13+ARGc8/e4dlSFKlHO8GGyAMP3AeitT9ISrkz9lZ+8l9de+Z3C5IAEZDwwqMku3U97gf7uDq1MkOOGfeigCRagjNZffBNZFqd7jT8Ry6DTaGFp+UhKoaoxE2N6NHVtsPO60xK7d//5aZTb1JiDY1N7b/HZ+icZ1c3hi34EHoSGLDPZ3DarCgI0g7v+I/xKr2NiL40tvtxIqnz316GLndl0+w+Qkya7bTYNV5oweKlvHe3Gsngtr9KTuKE6ihVBW+1CpDNRD/vUXrsoRjYDI47mTPGHL3QLW1S1SPEoKFRxZDOoaOj+EaB2fWex5pBlRboV+KeYx6AomTffIqGqNZ3pw7gPdlMUAYjFutQA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0fc9a30-67a9-4ee7-b3c6-08d8740ec9df X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6523.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2020 09:10:14.0279 (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: Aizlz1/1E+71E1Wl39rA2AdfLKDA3nMKQDYSo3CO8F27OS+QXv4NFrwv+WIE2KeG X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2342 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 --- New patch for v4. drivers/base/property.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/property.h | 3 +++ 2 files changed, 38 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index d58aa98..32e3a3e 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1184,3 +1184,38 @@ 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..4a84325 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -418,6 +418,9 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode, int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode, struct fwnode_endpoint *endpoint); +int fwnode_is_compatible(struct fwnode_handle *fwnode, const char *compat); +int device_is_compatible(struct device *dev, const char *compat); + /* -------------------------------------------------------------------------- */ /* Software fwnode support - when HW description is incomplete or missing */ From patchwork Mon Oct 19 09:03:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 11843875 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 BA2B661C for ; Mon, 19 Oct 2020 09:10:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EE4422269 for ; Mon, 19 Oct 2020 09:10:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Su9bFa/v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730174AbgJSJKW (ORCPT ); Mon, 19 Oct 2020 05:10:22 -0400 Received: from mail-eopbgr60067.outbound.protection.outlook.com ([40.107.6.67]:33899 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727235AbgJSJKW (ORCPT ); Mon, 19 Oct 2020 05:10:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=az/VMl3vR2FvXPjBOY3oyoEdUMLUQ3QwVWQB0JdZrJHlIh1fdZ804FkZwvbwReEbw9R6SFaSON3oh9IUzKfT1msdzFBmo+1f4/eDDPpBl/GGR/t7x/l5P9LOSC+z0TKrk2uNDvFWGSzN7SG9ACrW0G0v6Gx8Fco4CJOp+Z5TEeHxjs0ujdsLY3WVuZ2CaYegwwcGVO22tsRgrMGVM3UlnGpnplGrDTdYN/7/zBAyIaQh/jApAeNfvR43HqPCuCINqf+ukotezOpprB/husGMRPTu6GghohufmkCDWFhIZ5ytgGhOuiftmEPg/AzvXYPzfiDK8xF5XRGsbN+6/mq/1w== 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=UGAZF7j1tY7ekCQx4t0zenYMGcEWBf86Hpcd54jlhRQ=; b=MH+K5gmzLuYJcM7Nj4ms2kGywr2vOye1J48wLoNVDBgMD9Zv+wzfOGCs5djIUKvGkwNA9rA/vlXrAM8Nz44m4A5+jwLe7lzC8zeJVT9mvXxJWPjgo60PTyx3SeH67UUkPQnxd7NWpuBMY47/3EN02MW75DzUU96ysFRO4ypglo4JxVxjpxnV2eDPE+KFo6MbiH+MQ3T2o7K9vG4Qfvz379CJ5Ak93svs9S/82x4oZJf9s4xTkWLCbwNiyl3rt5yNJECTMIxV1xfVwdUky11ConoAACoC2O5pt+Uoo9edLr0P0PSrRWBD3ZcafMfoL0fK17NPs6M4armg/cRx3KM1MQ== 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=UGAZF7j1tY7ekCQx4t0zenYMGcEWBf86Hpcd54jlhRQ=; b=Su9bFa/vFYvCYlh/laDCLpAOni3KRc6G4VkkB7ZEwBr1tIf/R6cwZsDnrIeZbF3xQnwEL3fE059Kew6TWTJkmymjdgyTu6MmXoMfglAO3pCA5+gwzVU1sWj2gFBx/dWSBP4wAMQCsBCPa79uN2bVhD+PKHRKpArGeS86Z/TwSl4= 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 DB8PR04MB6523.eurprd04.prod.outlook.com (2603:10a6:10:10f::26) by DB6PR0401MB2342.eurprd04.prod.outlook.com (2603:10a6:4:4e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.25; Mon, 19 Oct 2020 09:10:19 +0000 Received: from DB8PR04MB6523.eurprd04.prod.outlook.com ([fe80::35e9:2f0b:112b:28c3]) by DB8PR04MB6523.eurprd04.prod.outlook.com ([fe80::35e9:2f0b:112b:28c3%6]) with mapi id 15.20.3477.028; Mon, 19 Oct 2020 09:10:19 +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 v4 3/4] usb: typec: mux: add "compatible" property for switch match Date: Mon, 19 Oct 2020 17:03:14 +0800 Message-Id: <1603098195-9923-3-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1603098195-9923-1-git-send-email-jun.li@nxp.com> References: <1603098195-9923-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::32) To DB8PR04MB6523.eurprd04.prod.outlook.com (2603:10a6:10:10f::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3477.21 via Frontend Transport; Mon, 19 Oct 2020 09:10:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 203fa0a9-84f8-4bfa-8eb7-08d8740ecca9 X-MS-TrafficTypeDiagnostic: DB6PR0401MB2342: 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: lvE/WysMZaa+42AbIlcoumOJMgeugmFQWTcXtn1FDIZ9gVbl8tfZxe1YATk+E2waazs2n1kSyPAEiy4bWhXpgWa5BH13dr1yXffzoxzrCncdNo86yl2mdtK3Iy/1d39b3AUCs93JDrUEzr8EID5ccOP9kqaWkZNGaKeeazSh7IYTXVc1QsRuuZLVIeuFGdzJOWtGAJYuEZ7HE0k0i2crd93bBxvP7o/xyKWdSRF7gFmSeFrEhJR9sW45QaZuFey0tZO2QQ1u2o7+mdnBLQVTQQnGmCBwjVWecmL19H7puvrKS/EP2nO+LxTVK4T/pwxyJW+4VM0knTWvRE36wrLWSj0yn7Q1jC8ruZEFkElgPNPAeCesJJhBq2Ful9UKx9RI X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB6523.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(376002)(136003)(39860400002)(8936002)(66556008)(7416002)(316002)(5660300002)(6512007)(4326008)(36756003)(66476007)(66946007)(8676002)(52116002)(69590400008)(478600001)(83380400001)(2616005)(956004)(2906002)(16526019)(26005)(86362001)(186003)(6506007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: uItvPlkJMKGwt4B0/GPIbJFgWH9dmeIe7pv9TyjYLAZjinyaZFaaY9Ath+2LBVUMxbtrBeMLKDeYzCTzyAqsFzZ52BzM01Sw1bOQ/UqEo2FN6ZNiFv6uvnbGXigKImpGaBGxsmsw6SbZ7zzYPxosciSpSBGlL0nxaapcp6fKrq0j8peXaAgHYX7/z/iMDnvJtp+HTZpojk7ul3QUU7AtqgTEi4rw89axccQYKfcDM3InDwGI8T1E2msgjAuL0XgRB34Yr42cvhKzn4XugLkjmdmOWZn65ZpoerOv4w++6RYoTEhYWHE1Ua5pCLUkxFDvmnQYqi690vWMz8kcFe87aad6gizlYMPNs658tJv5ysuGfTEnSjBKRUND8tCsoqpjN+4QH+e4NxEUDBRp9ald2VY0WKB1IMVrIJzz/RqlwGQYjfbr+twISsq/WUwqVCXVgQzOeDvndk6DjxZVgHV7Svq25T0rNKuenrwRFwrIlqnyzNfyIL9tWnqpCFTL2AvaO2t7340iiumQDWxfLKmN0e3bKxTgc3zQpkXgMD3xveue4W61N46+9qDyms0wPYKIe3vg05C/oplcWldD0LOkgHDItFVZC3qT3JBVwsOTX0UWDJAw3dhuqv1SzOZqGSVQUvJwiNX1+qcWL0y1baIDiQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 203fa0a9-84f8-4bfa-8eb7-08d8740ecca9 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6523.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2020 09:10:18.8491 (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: z3kt1nJokTAMb1tZbATuFU8SElyGk05rWj0N9uTJ9vW1YZWSpgWW9lZ6lmpbPXvD X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2342 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 --- 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 Mon Oct 19 09:03:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 11843877 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 C184317C9 for ; Mon, 19 Oct 2020 09:10:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9ABE2222E7 for ; Mon, 19 Oct 2020 09:10:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="slm7LAp9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730182AbgJSJK2 (ORCPT ); Mon, 19 Oct 2020 05:10:28 -0400 Received: from mail-eopbgr60057.outbound.protection.outlook.com ([40.107.6.57]:40419 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727235AbgJSJK2 (ORCPT ); Mon, 19 Oct 2020 05:10:28 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B8iUYvXgctU2xLsIkeuL9KyzJRtgaRIpaV/6Pibb1+jD6nxaf1RfpkJoyc1QYNrReWWkzv5Czo/Bn0OkDlJpteg510v29oVwy/T9SqRm/GVqqsppEiD+/c8CEQzcxucL5uUwE/j7azk4CDX6bAYOYhPd7hpctVneVh1JxkHl0TeH92wVBArxhRsT1E8wmdXvctQgam8l2C9jFfAJsyR4ZVMaJtlQKN23NM3CrqURmQ/PwPm9jt4OR6Q+M293qXFufMvabuRlRUwuyXVBPLFHN9lCGllFQkO35A6NEzg15H8Skt+Y5xxYbpapG7kK+rQtNYxOCx2RyYCzQAYu5HSZcQ== 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=gE74sv2IBt9Pcd3zUMCOek8sUliOPbaudik6Ly20dPM=; b=i0PWKQYH9piEjVjiwKEruimfa6HD7zcqt94orXtMU65mKaOUIPbOUxUK7LtHtTYN4NIBpNcHLbIvsVJY/Xaq8WDN3G7mMswmyM863WSiAJMxegvtjrYwZgXp936WUAaDRQRQasdfJ1reWGYSmm1RmclMdX8qfTQ1LNCC6mX+G5/EizmMQNai0bETteeAGcmhYTgy5bX1Ay9vXOMHL5fpw8yEOmSgNc9tKHAu6MnH6XBrn2hKFEWi18s98n+2xCC8OnvQHUPpZXjmfIzarlU8gzNwA614UIzTIr4f1+jnjyfV2sBPskF4Od6WN8QYvWXDbfXXNoCuLLnWQIiUVn0noQ== 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=gE74sv2IBt9Pcd3zUMCOek8sUliOPbaudik6Ly20dPM=; b=slm7LAp9IG+VmAYVm0DnFdP0+e7R5zHea2Mf9SM5K1sufSMgFzFChzqiNdmoYsDr2Fd87aODMMq8otpvO7n180B3/nqfmGLjNy7kAYiyxLo52L4gW5NySzJBB5GJHHtK5tBGr3wex5QSFe1Bic7iUdIFit9nFjm2iBYVOjgIYJ4= 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 DB8PR04MB6523.eurprd04.prod.outlook.com (2603:10a6:10:10f::26) by DB6PR0401MB2342.eurprd04.prod.outlook.com (2603:10a6:4:4e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.25; Mon, 19 Oct 2020 09:10:24 +0000 Received: from DB8PR04MB6523.eurprd04.prod.outlook.com ([fe80::35e9:2f0b:112b:28c3]) by DB8PR04MB6523.eurprd04.prod.outlook.com ([fe80::35e9:2f0b:112b:28c3%6]) with mapi id 15.20.3477.028; Mon, 19 Oct 2020 09:10:23 +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 v4 4/4] usb: typec: mux: add typec switch simple driver Date: Mon, 19 Oct 2020 17:03:15 +0800 Message-Id: <1603098195-9923-4-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1603098195-9923-1-git-send-email-jun.li@nxp.com> References: <1603098195-9923-1-git-send-email-jun.li@nxp.com> X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::32) To DB8PR04MB6523.eurprd04.prod.outlook.com (2603:10a6:10:10f::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR01CA0128.apcprd01.prod.exchangelabs.com (2603:1096:4:40::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3477.21 via Frontend Transport; Mon, 19 Oct 2020 09:10:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d2871977-9f76-48ae-767f-08d8740ecf76 X-MS-TrafficTypeDiagnostic: DB6PR0401MB2342: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1107; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f/qyj7/36WZUz9mZfx4D0V6WMOwHIpWFbTYux1xJ38FmjlJ7MqzwzjySpPHNX0EHZ9FWkEe8UYMQgakioUiEmcrtrNibHHiuutwRDwt18n5LY9YUCqkuVQQs6RWtA8LJXNt9YGtpUpjEuuTQGeWMGDQoV97p1A5zMs9dtYckE/TLy5Df9xpxVU4msJgCkzf9T1Rwsb39002h5z/ivywJOfLcTrkbaybGtAV7p945yOAWgm4BEW8ljouWHka5voGUeZ+vfr0YucFy11InX4A2UmEIawpvK3hJkiKW7TQHvz/euEqiCev3keIS7IJPsjJZ35qBzCdYGsL2SWGr0sgMJVUbVUzrDCP6RBWktivp1Rz6TMWLS469IzmgVe1F99f8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR04MB6523.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(396003)(366004)(376002)(136003)(39860400002)(6666004)(8936002)(66556008)(7416002)(316002)(5660300002)(6512007)(4326008)(36756003)(66476007)(66946007)(8676002)(52116002)(69590400008)(478600001)(83380400001)(2616005)(956004)(2906002)(16526019)(26005)(86362001)(186003)(6506007)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZMpREL/HTILtHMSVJicr1xuy/oSFjID5qVuQb8ULbU5tPPHn+aNWAbPIMse2OOkApzunC0X9QRugEJqOqA3TKDV+F26CPeZAXkjSPvWyF4bacaZKSzmsqzQAqiG6yoWkSft1mOzQB46R8cWIRhlj8/3KjPHPEkDyNlY/h0THLXABqxXVmwRbquRiv4E6hUOeUfcA9WyXmYSe2Zqq6scuDrLlDyLoRyMHkHg677bweOtFxZiJnhegzjzi1+bXskOIlHxqcrnw7ZgftHp2IdwGFMx7mrMISXWUV3hk2qxgwlMmaQnDjOECJsz3dduaMiknsI9JvE+djpsW0wyUiE5n2gQq4yckk1UFDTokBnZLUXE+zew8p5vv9/eQElRScBZWS3YrY5Uky4qaGUjMumH8hwuhzfkC5A1OEcyv+otTXWA/PoVbmkE2qjR4df0V8ORuVB8mmA+WTQ6v69H3oPJnbvMtnBuqWUynkiYbqs5vAzXflKJ40BwFSPdsZJOjcVP7XYqbg+NRgrKUczBtIbyAfAiP3E6BMkuYANdiANxslU26QShNOVDPwRGGo2zCFkh92NrqLgYP4Dkr3UXTb8mNDJhjvPTLuY1X0h1eaRQvLw9b1gEfuUXqsnLhmpij76zf75NI8yRiAwmeIZ5Nea7hKQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2871977-9f76-48ae-767f-08d8740ecf76 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6523.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2020 09:10:23.5884 (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: f1uIZHW+XBgGkg2JdkQ+D0t7Iq7ILC8YMLdvJ6uo3m2XQjvHo/Eh4ZUn+brU08pj X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2342 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 --- 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 | 6 ++ drivers/usb/typec/mux/Makefile | 1 + drivers/usb/typec/mux/switch-simple.c | 110 ++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) diff --git a/drivers/usb/typec/mux/Kconfig b/drivers/usb/typec/mux/Kconfig index a4dbd11..2942588 100644 --- a/drivers/usb/typec/mux/Kconfig +++ b/drivers/usb/typec/mux/Kconfig @@ -17,5 +17,11 @@ config TYPEC_MUX_INTEL_PMC Driver for USB muxes controlled by Intel PMC FW. Intel PMC FW can 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. 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..98f4b49 --- /dev/null +++ b/drivers/usb/typec/mux/switch-simple.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0 +/** + * switch-simple.c - typec switch simple control. + * + * Copyright 2020 NXP + * Author: Jun Li + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct typec_switch_simple { + struct typec_switch *sw; + struct mutex lock; + 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); + + mutex_lock(&typec_sw->lock); + + switch (orientation) { + case TYPEC_ORIENTATION_NORMAL: + if (typec_sw->sel_gpio) + gpiod_set_value_cansleep(typec_sw->sel_gpio, 1); + break; + case TYPEC_ORIENTATION_REVERSE: + if (typec_sw->sel_gpio) + gpiod_set_value_cansleep(typec_sw->sel_gpio, 0); + break; + case TYPEC_ORIENTATION_NONE: + break; + } + + mutex_unlock(&typec_sw->lock); + + return 0; +} + +static int typec_switch_simple_probe(struct platform_device *pdev) +{ + struct typec_switch_simple *typec_sw; + struct device *dev = &pdev->dev; + struct typec_switch_desc sw_desc; + + 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; + mutex_init(&typec_sw->lock); + + /* 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 ");