From patchwork Mon May 28 02:52:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10429703 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 0AD9D60362 for ; Mon, 28 May 2018 03:09:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDF4D28AF4 for ; Mon, 28 May 2018 03:09:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E154E28AF7; Mon, 28 May 2018 03:09: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 49FDC28AF4 for ; Mon, 28 May 2018 03:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753129AbeE1DJR (ORCPT ); Sun, 27 May 2018 23:09:17 -0400 Received: from mail-eopbgr00077.outbound.protection.outlook.com ([40.107.0.77]:13063 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753114AbeE1DJP (ORCPT ); Sun, 27 May 2018 23:09: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:X-MS-Exchange-SenderADCheck; bh=gq2NiSUEPEGA+WwCbtQN7Pw+9thCFWrkdEWTaEqWr3k=; b=uOHbmdGOXRrNJy8ng8VX8CPrqJKX6D1CEFo9vwD79qJcqXodJp4b11uqWHzfPE21c1ew6l/n3GSMEz9D4qqoDCbIaC38vKWHmAt6ynjC+VC24Cqk6HLLJWAuqsOaVU1nFjEy1tX8g6JJAPdjCUorBXqMEH1iQOZE4J/i7II1px0= Received: from b47624-OptiPlex-7040.ap.freescale.net (92.121.68.129) by VI1PR0402MB3919.eurprd04.prod.outlook.com (2603:10a6:803:22::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.797.11; Mon, 28 May 2018 03:09:07 +0000 From: Li Jun To: robh+dt@kernel.org, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, linux@roeck-us.net Cc: cw00.choi@samsung.com, a.hajda@samsung.com, shufan_lee@richtek.com, peter.chen@nxp.com, garsilva@embeddedor.com, gsomlo@gmail.com, jun.li@nxp.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH v6 01/15] dt-bindings: connector: add properties for typec Date: Mon, 28 May 2018 10:52:33 +0800 Message-Id: <1527475967-15201-2-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527475967-15201-1-git-send-email-jun.li@nxp.com> References: <1527475967-15201-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: HK2PR0302CA0015.apcprd03.prod.outlook.com (2603:1096:202::25) To VI1PR0402MB3919.eurprd04.prod.outlook.com (2603:10a6:803:22::32) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3919; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3919; 3:vodz10saYSiEQUMnUVF2hf24VsgP2ykKHE34gdCp+aLyo4fefSspbb9JEX/Q1yEu/Dudc9hVWIlL7or2cNPOeFENpfi6ey4G8tpC0L7PPjQ2lfDo2RsW4pjg3u+QHfEF8cKB3i8LRcb/uTZq9tCXnLfR0Z8nLdiGjfSsr6qY84R/Hc9NX/k4r5MVVEFIn4tp7H043rYlJf/40OZDYye2gheBIZz2tPwHqpha/i2XJyXjEBZ1TPN+Y/NSygTKfSCT; 25:H8+yYw3vnCwaiW4voIyABq3E2KOuRVHA1abrwsUUzShUeJPRWTplAgCKvKv4DYXonwQQKmRwEt5nd2gTYoCJHNFFfcBaFEBzLfHgXxHWB2+JfpoNxcWEb0QA8ot3/aiGNLK8nwz37rdXqdnF2KVKRMUwG8Reo+6zMiUj3o6r5W3zxzUZWtjXVKqZofJZlEXbRVJD6ddo1Yxr1TdFEW80VThlQpmrXOyoi9cfh7myd4e8X8v9tUTNn5zSUvDHt4OVtTOaJlcNmrmkA7KIEhW7znlhWwZ3w+zS8ivWjV88hYF0X7OpODCesY8vGfhX1rmKoYV2QGTxMVxJOIW016RlHA==; 31:c4S1ihNOPchhhW8fkg29OchCZEY9evgGHCCBNpNpF4fk8gYH3Xjzn4rLUh0fq9/nVtCV/LfoUtJRxzvCCUZWe0GB9aQuA3WoxjfLQ7+ZIBpwdc49NErpRtGTeHrXlFESTOWxJo9Mgxc3OE/BKqCrsN9/O/+tsujpWHpIiB5Ela008ABRa1it4l38zPfYHgnajjEE79LhSgmCrbPYih6VdDIyW5MF3BnSap2UoTf+8iY= X-MS-TrafficTypeDiagnostic: VI1PR0402MB3919: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jun.li@nxp.com; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3919; 20:pgw3Prkk0KQkOdZQdpW4M7BSVmTSxhBi9E3emUKxJEKqdlg9ZH55FYvbBBXC1adQdqNaNHtqiC0Ft/KE0+avbLvFb/6bkD54XtSdmGFHWSGytOj3e+VVKPghjFxlMD0xncpPMoZavu0PkQvYjIy9HUlFQQybhdndDVw8OUHSnN8/7/41iTaL6BfHSLn9DQdQfdWH+bSFI8V7iw8WavAxeZjLUA89AKleMx65uZsfgvoV2ETUpubIAUJVYefank2Wg/7iDqmjbYUjKJ0ZmL6GUEXhMsR4WketBrmmJCln+VRWKD2VCVQ0td6xJbJ2/y/CsKNNNj6VRxxSIMpkChyynl6KCopn7eQgV/8xLo28p6WrJbd4PVm6f1h/QPmq/hmQRZhFR0u1ar28UyqsWrV9Aa2J5EQQa5Rxyxx3HMxsCGkwewHqeXaGc33Ammpp8RZK1PvQQW+j38ZigXHQ1HI9Ry6R9ByPWbemFUWs5DgIq/fdiDkKsqtGxXUHbIc13SoA; 4:qWAwfJ400PHKDHZiAT1p+Ru4EQoBXyhcV4eRrFKnp9xbkmtlcCTUporjUbd7JTTAVScmWGzAz4qXg+/8Eao2BG9axdIxYFZsEpY11oyoYaXM6oDmdadkSIud90Gbwbb9YMOwslDDKrUaFp5M5uQjhc/wNbpLHA/wtPUzcdbCRuEf/fgA1eCc6253139RuDTpVF64jobJxs8DNG0KQz/i2x9fsSGh3ME13qvhcfkN8GSO7QLVKPAb7rZKoGiTPRuRc/ytT8nzvW+ZV4vpA1Ddq5xN2tVGUpTFxXuyxGWerwxpD1XbxFPkn/OFwfStmXQb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR0402MB3919; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB3919; X-Forefront-PRVS: 06860EDC7B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(396003)(39860400002)(366004)(346002)(376002)(199004)(189003)(6506007)(8676002)(16526019)(305945005)(26005)(7736002)(386003)(486006)(446003)(48376002)(11346002)(956004)(2616005)(2906002)(66066001)(81156014)(186003)(3846002)(81166006)(478600001)(8936002)(50466002)(6486002)(5660300001)(6116002)(6666003)(7416002)(36756003)(50226002)(47776003)(39060400002)(476003)(86362001)(106356001)(68736007)(5890100001)(53936002)(51416003)(105586002)(59450400001)(16586007)(316002)(4326008)(6512007)(76176011)(97736004)(25786009)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3919; H:b47624-OptiPlex-7040.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0402MB3919; 23:1b9beqz0sl8vJgr9bP3Mm4U6zylg6UVO2fdcmDU?= =?us-ascii?Q?6A0roCzLyKAFqUOuhkvsfdp7ZL50RS402GAE5pqc9PNWyTBcrn83Peu6Debu?= =?us-ascii?Q?uf5MXLAcVAnS56fkcN4fFOs6I0pqBy9pNss9fBQK2y13JYtfHpSkXmVXPeNz?= =?us-ascii?Q?T4RlNzWNwfli8a4AHHbinbtXaMdver1Gj6/4M7QwHMG6t2OprQcPaGbDg1lD?= =?us-ascii?Q?odUfaZ6KdtWusodxIGRH9tlGqLaUvJFJ8JPWG/2munHfUqLAD67n47W0fHy1?= =?us-ascii?Q?gBZv3jZwL8kxNDrC+TkZts8RqSg/Dms66ougOzMBxOlmdITbK+pKikSjWbh0?= =?us-ascii?Q?y2oJciw8pUXRqPVwn4NW9ToSHG1H+Dug9kktMEUGgr3SJwS/SRGH1QV9kt5p?= =?us-ascii?Q?+136zqM+ZLAOyJ9vKLSE/Y+c3jbSfNKwvZ5ktbgZhhD3Si3oMJqcV+LEO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muTUwjaIbwyEJVa1JkmM1w394OYRIQwilrA5dXCe9mz33QCsvuSZvvmclaMWXBty75Ic1zJebadoRshNvuvY8pUa/6Mv9AxZlZjzQbQzcFWsB4LXb/NTZOSBdXBYyaP5cYBdR6U62dj4Ta9DmXPJRKE01dSHpTS0k3mpJ9dwSo1EQG1BjoT0AfMv1+gnDGQJjYrouZjneb7ms6RS2 X-MS-Office365-Filtering-Correlation-Id: e83b5e0c-9ec9-437a-058c-08d5c44863b6 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2018 03:09:07.6261 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e83b5e0c-9ec9-437a-058c-08d5c44863b6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3919 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 bindings supported by current typec driver, so user can pass all those properties via dt. Signed-off-by: Li Jun Reviewed-by: Rob Herring --- .../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..8855bfc 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 */