From patchwork Thu May 3 00:24:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10376823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51A0760384 for ; Thu, 3 May 2018 00:41:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4088B29137 for ; Thu, 3 May 2018 00:41:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34F2229159; Thu, 3 May 2018 00:41:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DBC629137 for ; Thu, 3 May 2018 00:41:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751770AbeECAlQ (ORCPT ); Wed, 2 May 2018 20:41:16 -0400 Received: from mail-eopbgr10067.outbound.protection.outlook.com ([40.107.1.67]:11698 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751745AbeECAlP (ORCPT ); Wed, 2 May 2018 20:41:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kkxd/KYHG2z1KSqTukvUpuURP5IkIq8GQsU8K1r+nb8=; b=RBAs4gZx7j1/f0+9s6zl+wg3IW6F/4wEahawOrCyoJAtQNWkVr8ZE6dlE9iFQuNfG9FuvmNcBXVeGBkWWG+p9L88FvOJHYrLLZOvk+I5TWF0hdvrKzWxMDEy6TCuZzQe+SH/CNjiudMGTkoDd0p1dgVAt/tL9JA690EO7Jyu0LM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jun.li@nxp.com; Received: from b47624-OptiPlex-7040.ap.freescale.net (92.121.68.129) by DB3PR0402MB3914.eurprd04.prod.outlook.com (2603:10a6:8:f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.24; Thu, 3 May 2018 00:41:06 +0000 From: Li Jun To: robh+dt@kernel.org, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, linux@roeck-us.net Cc: jun.li@nxp.com, a.hajda@samsung.com, cw00.choi@samsung.com, shufan_lee@richtek.com, peter.chen@nxp.com, gsomlo@gmail.com, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH v5 01/14] dt-bindings: connector: add properties for typec Date: Thu, 3 May 2018 08:24:41 +0800 Message-Id: <1525307094-27402-2-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525307094-27402-1-git-send-email-jun.li@nxp.com> References: <1525307094-27402-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: OSAPR01CA0012.jpnprd01.prod.outlook.com (2603:1096:603:2a::24) To DB3PR0402MB3914.eurprd04.prod.outlook.com (2603:10a6:8:f::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0402MB3914; X-Microsoft-Exchange-Diagnostics: 1; DB3PR0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Bd75A2SAhK86fpEmyrIJcLLXJvEBM+9Z/onnus7oeg9smHDzWrECxjKQEmP+nFoTkyhY5DLblaDUr50xdPhrFeB0Ap7RbGwdin4WVSahfttqAzK6ryrUMQbgfJDYU4LmyATrJB1i5RrNrMOUw3qvlsuzibXaEqHJUVlEPyAsVJbZJgAg3kczSkWf/94sRJPVw/CBoz+7o4AbNfcEXWeawYzProBDIaQ+AoOvL44ql3R4V/2ccP8RlizC+T3ooGFlwjQyGsW+eLgRLUYhAQQksF/DoyxjFSeUvAsbjr/vTBYLx0mv27SyYONUeUqvQASjELcZARUFEXPf6fV8wcvqkp2oHZc/VJ07yXKD80+Cq50GIbhsJWnm; 4:zDEwotel4hfdL1pPU0a3qerB5gLRB401HcNRdn1Hgr3nIHAorZGh0QbHqClwbLqI+7MxFVwI83Ep1ggSF+ShZAAI4Jyli8XxQVPWXM5LLax8zGncrO8eC+6abn7Iqh1otINrY5+z6DNLLgxE8XjzCTzIAGQN6pwfkvhHExyuWSa/4OVcsGl4ShKrUCSZ7qda2XvmX3zZdF+1vPbfxOjpD4JXgaxYxswrxotkxNs4/h94uCUwPPtlb/Gd/I+tpZehHcEz0UXbNAi7dP4CUOCI05h8MOluFnZdmQGLUbG0yhxgWSF/UOL5qjgdnUw91wPj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(6055026)(6041310)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:DB3PR0402MB3914; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0402MB3914; X-Forefront-PRVS: 066153096A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(376002)(39860400002)(346002)(366004)(189003)(199004)(7416002)(47776003)(7736002)(8936002)(66066001)(305945005)(106356001)(2906002)(5660300001)(6486002)(105586002)(6116002)(3846002)(6666003)(81166006)(8676002)(50226002)(68736007)(81156014)(36756003)(956004)(2616005)(386003)(16586007)(476003)(50466002)(6506007)(59450400001)(6512007)(97736004)(316002)(446003)(39060400002)(52116002)(26005)(76176011)(48376002)(4326008)(5890100001)(11346002)(486006)(16526019)(86362001)(51416003)(53936002)(186003)(478600001)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0402MB3914; H:b47624-OptiPlex-7040.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB3PR0402MB3914; 23:5AAXgWYQf+wNOpfhwXtVFDJ23QPZum/ygescoGi?= =?us-ascii?Q?lSs4qfN78rmwLSIDXMYbgjapuDq/Z8tHQ3zIdhh+kTugwlDGsHsF8pXKvrDE?= =?us-ascii?Q?7H4gfTfYhMkLr6XkzlKzxYuXLUF/3b0mM9TZciO71PBPUHeE5BIqyTZ930bz?= =?us-ascii?Q?cpibyLVa/ukSng3PdrOeNer/47mNzfBhGJjMPixx0ev1WfjEuv1G0n9l7zBv?= =?us-ascii?Q?y74DOEq9PLsm3viU9zHvK1y9lAuIF86aV2OtI/V6gbW+hK8B5f1BmeH/ymlh?= =?us-ascii?Q?VGaWBkE5lbdV20jGnLsW3I15cEEpIPbKc5xupTVhgO78Z8IOYhifUKySOkVR?= =?us-ascii?Q?bA9UeCxdvgC8HZXjLAVEB8R9MF7ruAYLpsCxD0AcxEhvYj96KreHWVbOEW1n?= =?us-ascii?Q?Jl+qeu3J+fWNqJCX2/rAwY1ZdH3bj1M9Ra/B6ZMcXUZ3O9DS0Cx1RV5iQ5co?= =?us-ascii?Q?Zbi1c7QGEfr1zX0FkoAthD9ku8xm6k+YPBssLlHTV+Xcn3tc0r2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vHlkBhoTNAnGmUkV+RwYv2Oaz25/7fv+eYRseUGkKCEa/84KivHkL5uJUjj4SNhc+HSMQF5mGA2R5axNlXHsTl5NZKXPmwk78YPmLe157f/7HXQ3RVzGBFWXiyF3hTsFb X-MS-Office365-Filtering-Correlation-Id: 2893d871-83c9-47b7-b98a-08d5b08e918d X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2018 00:41:06.0840 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2893d871-83c9-47b7-b98a-08d5b08e918d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3914 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add bingdings supported by current typec driver, so user can pass all those properties via dt. Signed-off-by: Li Jun --- .../bindings/connector/usb-connector.txt | 44 +++++++++++++++ include/dt-bindings/usb/pd.h | 62 ++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/Documentation/devicetree/bindings/connector/usb-connector.txt b/Documentation/devicetree/bindings/connector/usb-connector.txt index e1463f1..4b19de6d0 100644 --- a/Documentation/devicetree/bindings/connector/usb-connector.txt +++ b/Documentation/devicetree/bindings/connector/usb-connector.txt @@ -15,6 +15,33 @@ Optional properties: - type: size of the connector, should be specified in case of USB-A, USB-B non-fullsize connectors: "mini", "micro". +Optional properties for usb-c-connector: +- power-role: should be one of "source", "sink" or "dual"(DRP) if typec + connector has power support. +- try-power-role: preferred power role if "dual"(DRP) can support Try.SNK + or Try.SRC, should be "sink" for Try.SNK or "source" for Try.SRC. +- data-role: should be one of "host", "device", "dual"(DRD) if typec + connector supports USB data. + +Required properties for usb-c-connector with power delivery support: +- source-pdos: An array of u32 with each entry providing supported power + source data object(PDO), the detailed bit definitions of PDO can be found + in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.2 + Source_Capabilities Message, the order of each entry(PDO) should follow + the PD spec chapter 6.4.1. Required for power source and power dual role. + User can specify the source PDO array via PDO_FIXED/BATT/VAR() defined in + dt-bindings/usb/pd.h. +- sink-pdos: An array of u32 with each entry providing supported power + sink data object(PDO), the detailed bit definitions of PDO can be found + in "Universal Serial Bus Power Delivery Specification" chapter 6.4.1.3 + Sink Capabilities Message, the order of each entry(PDO) should follow + the PD spec chapter 6.4.1. Required for power sink and power dual role. + User can specify the sink PDO array via PDO_FIXED/BATT/VAR() defined in + dt-bindings/usb/pd.h. +- op-sink-microwatt: Sink required operating power in microwatt, if source + can't offer the power, Capability Mismatch is set, required for power + sink and power dual role. + Required nodes: - any data bus to the connector should be modeled using the OF graph bindings specified in bindings/graph.txt, unless the bus is between parent node and @@ -73,3 +100,20 @@ ccic: s2mm005@33 { }; }; }; + +3. USB-C connector attached to a typec port controller(ptn5110), which has +power delivery support and enables drp. + +typec: ptn5110@50 { + ... + usb_con: connector { + compatible = "usb-c-connector"; + label = "USB-C"; + power-role = "dual"; + try-power-role = "sink"; + source-pdos = ; + sink-pdos = ; + op-sink-microwatt = <10000000>; + }; +}; diff --git a/include/dt-bindings/usb/pd.h b/include/dt-bindings/usb/pd.h new file mode 100644 index 0000000..7b7a92f --- /dev/null +++ b/include/dt-bindings/usb/pd.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_POWER_DELIVERY_H +#define __DT_POWER_DELIVERY_H + +/* Power delivery Power Data Object definitions */ +#define PDO_TYPE_FIXED 0 +#define PDO_TYPE_BATT 1 +#define PDO_TYPE_VAR 2 +#define PDO_TYPE_APDO 3 + +#define PDO_TYPE_SHIFT 30 +#define PDO_TYPE_MASK 0x3 + +#define PDO_TYPE(t) ((t) << PDO_TYPE_SHIFT) + +#define PDO_VOLT_MASK 0x3ff +#define PDO_CURR_MASK 0x3ff +#define PDO_PWR_MASK 0x3ff + +#define PDO_FIXED_DUAL_ROLE (1 << 29) /* Power role swap supported */ +#define PDO_FIXED_SUSPEND (1 << 28) /* USB Suspend supported (Source) */ +#define PDO_FIXED_HIGHER_CAP (1 << 28) /* Requires more than vSafe5V (Sink) */ +#define PDO_FIXED_EXTPOWER (1 << 27) /* Externally powered */ +#define PDO_FIXED_USB_COMM (1 << 26) /* USB communications capable */ +#define PDO_FIXED_DATA_SWAP (1 << 25) /* Data role swap supported */ +#define PDO_FIXED_VOLT_SHIFT 10 /* 50mV units */ +#define PDO_FIXED_CURR_SHIFT 0 /* 10mA units */ + +#define PDO_FIXED_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT) +#define PDO_FIXED_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT) + +#define PDO_FIXED(mv, ma, flags) \ + (PDO_TYPE(PDO_TYPE_FIXED) | (flags) | \ + PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma)) + +#define VSAFE5V 5000 /* mv units */ + +#define PDO_BATT_MAX_VOLT_SHIFT 20 /* 50mV units */ +#define PDO_BATT_MIN_VOLT_SHIFT 10 /* 50mV units */ +#define PDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */ + +#define PDO_BATT_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT) +#define PDO_BATT_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT) +#define PDO_BATT_MAX_POWER(mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT) + +#define PDO_BATT(min_mv, max_mv, max_mw) \ + (PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) | \ + PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw)) + +#define PDO_VAR_MAX_VOLT_SHIFT 20 /* 50mV units */ +#define PDO_VAR_MIN_VOLT_SHIFT 10 /* 50mV units */ +#define PDO_VAR_MAX_CURR_SHIFT 0 /* 10mA units */ + +#define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) +#define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT) +#define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT) + +#define PDO_VAR(min_mv, max_mv, max_ma) \ + (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) | \ + PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma)) + + #endif /* __DT_POWER_DELIVERY_H */