From patchwork Tue Jun 26 23:45:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10490325 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 A435460386 for ; Wed, 27 Jun 2018 00:02:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95F081FF13 for ; Wed, 27 Jun 2018 00:02:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87FBA26E54; Wed, 27 Jun 2018 00:02:34 +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 DD2B51FF13 for ; Wed, 27 Jun 2018 00:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753716AbeF0ACc (ORCPT ); Tue, 26 Jun 2018 20:02:32 -0400 Received: from mail-eopbgr00081.outbound.protection.outlook.com ([40.107.0.81]:10426 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753093AbeF0ACb (ORCPT ); Tue, 26 Jun 2018 20:02:31 -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=MV7ZTSi+9Q1t1d0nKgiRperPLgtDE8zgSXqoBrFic6g=; b=Mi102A0ZmTxIfvzE+q2n9sE26xObLqiD1+S/cpw/8tCPjbnPyPxEgMZsnz8Crtt9wNU0ku52YzAy2QVyITphBn5lpkJlg7UhUlUVmduA+04eznf+mp11ppCtUTOhIbhUM95hiFWj0DIc7ry2YUSswSTcDk2GrNcX9634/sRQyTk= 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 AM0PR0402MB3908.eurprd04.prod.outlook.com (2603:10a6:208:f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.22; Wed, 27 Jun 2018 00:02:24 +0000 From: Li Jun To: robh+dt@kernel.org, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, linux@roeck-us.net Cc: a.hajda@samsung.com, jun.li@nxp.com, cw00.choi@samsung.com, shufan_lee@richtek.com, peter.chen@nxp.com, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH v8 01/14] dt-bindings: connector: add properties for typec Date: Wed, 27 Jun 2018 07:45:19 +0800 Message-Id: <1530056732-9640-2-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530056732-9640-1-git-send-email-jun.li@nxp.com> References: <1530056732-9640-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: HK0P153CA0011.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::23) To AM0PR0402MB3908.eurprd04.prod.outlook.com (2603:10a6:208:f::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 914f10f9-ad21-42f3-3097-08d5dbc145c0 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM0PR0402MB3908; X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3908; 3:f6+8FOpJSKRZuoWX1WzUxqSCVt68tG0C5VJifdvRSbW2niEN+boQrn2MJ7wsI50coR0lzqqNomw1OI12HayG36bA/WvmnxvFiWIRoXRpgpkxRJZm1TTc+Uw8BbGGogc/P3i1qTb8Gz5R6dKZxeEtyOeJMRBU9ioJHrrKvt8z24ZidV3QRTckt6pat6q2wUF5HXBwvBmBPnAB7i7J9jJfSK3C7SCmGX/IaGROie7AEuW8C/Vc+P0Kiz/rqD/gihwT; 25:8kiSNyahHwJBfAhyCowJFpKbW32yvMurfwpQljWfP5CB6l0kryUmlB6dSNb/eDKZXlgCBGshx6hzHauamHv73LL4lViwPNq7Zrj9fTXBz8o2wW+qyYl8RvJTvScMgReRaQOEC7fjqZorXXS0nV9ogVxvvxfIwPR+6NHRvqxKflF46akegMnS5rH7cea9T0/YwrJjzU9NJJM8gJFxUZa5pPcg55WxzCrPnnXv8ff2s5Xwqz0mIrRugMZFQMrpqTDRdvfz2by5ozxCkUZCMO0xtISA3EiprZ6QhJTgXFHAG0csAUjtGJlep1Rq2KT73S0y4iCjB6OK0wTajGGJRNgg7w==; 31:2tKJP4OqmXbo2EP2QqQywfoh29RRLnA3JuwSthpl8qYVK9VqV+TN4Snq3L3RRcSQz+AwP/aEFTIXpW5ZE3/4Zlp59d7fjfK7/3BVyqaz3bp+Q8oaPKbmpKFBmbtPzBXytXXnbt26mXrLn7eiFxTGDI8iIUmInrgQwS/ynYFW+xCo3AAcdxYNQxoLO2kiY1MdmLw64wA0kS8AzGwIBomSk6LMBa7sb/Y7seIDTBjfeO4= X-MS-TrafficTypeDiagnostic: AM0PR0402MB3908: X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3908; 20:TGNxL68I8Wj56sNyCxyCeW3qhOUexlTlnYC4X9q3KPKOfvA0woXgkWvBlVR60bpwOe4weuDqUcFrDe1kl3N8CT86F7xUxY9JUgwD0fUcBspN01623ga6MImnvR8XpfDgZsXqP7m/nRTmm+R2o3EVAP9rbfMPdSJikLtIXEN56jxG1EAfJfIFqgV0k63Mb7eN+vVww++uySNo6D4wc66dLhNYlqBmtZXvrRCaKV+oFFxZFSiz6YiZgcTMhcSEyUnoqum02HTXQJoEoukNcmHfR/QXxr+0+Pyo7ZwqmQvSAi3sm8dnqGlNKTXLnd4UrNRQQkrKRVrjKsQ/Ym1/QP++KjmCATxCAmmyUS6ft4y73SeKe3Y1nudKfUNoR/rfXLp2vSsb7kUSPbGI29TJ2ejEaRPvXPN2anrHx/gvRVs5eCMlI5H37iEaDFEb7SA/WURJ921/ylE0CY3Zge19EoESXtUqiFf5Ax/05VqEA3oAX4FRWa0YPVkuLNso2EVFNfso; 4:BuaYGj8aByDgdYpRp8Ac93Ti5CkZzd3hxl7yxdc47vdpHc5FdweFdB5Hs4NJDD1flw+HebKRdGUHUKXXu62HUx9zCcQoUWhylXHdTOEeJHqAd70v+Xy+8pEgHt+lLZRmd3DhfzezaIx0EH8jkj5DD7zpJf2T+ZZKlC0bk5gHI32I1m+rQG5j1VQkvBj61zrLnaZrq9vCY5vqONGJcQzASlWEzRyDImqa3rKb/TSNiqWh4Uz+W7ebqjOvexvhw0xVClvtGj9Kb/bbyeYVCrhpgjxVXHa2/l9Tu0hbfeAuLIAmIHjLhoJy/1C2pw/BaOTy 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)(93006095)(93001095)(10201501046)(3002001)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:AM0PR0402MB3908; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0402MB3908; X-Forefront-PRVS: 0716E70AB6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(136003)(376002)(366004)(39860400002)(396003)(189003)(199004)(2906002)(14444005)(5024004)(7736002)(26005)(6486002)(305945005)(486006)(48376002)(478600001)(86362001)(25786009)(4326008)(16526019)(186003)(36756003)(50466002)(16586007)(68736007)(6512007)(47776003)(51416003)(52116002)(53936002)(3846002)(386003)(6506007)(6116002)(76176011)(316002)(97736004)(50226002)(476003)(2616005)(956004)(6666003)(11346002)(446003)(106356001)(8936002)(81156014)(66066001)(5660300001)(81166006)(8676002)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0402MB3908; 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; AM0PR0402MB3908; 23:7+acnbEkoAh43Xt8ZyvN9bx24tggQd6hQIycFTa?= =?us-ascii?Q?g5ne0gmfY6BanDbfqKCoerMUfjvQomaMBs/AULc+2a4h9B8HTqfFTtKQ84Db?= =?us-ascii?Q?d8HieP5bsU04FV/JUHerJFWRV15SZmsUCCpJHTk/DWl4+ThrVUU1dO3MJ4pt?= =?us-ascii?Q?otJhx6GysR5jAdD5IsP3oOfHN98P2qwWzeID9au5V5j/5HQckpxLDTd5rkNy?= =?us-ascii?Q?eP0DroWdTkY83vC0b5oCSFJq6L7QBWaEnVnGFH05zWq4Xe4oh8Oxx7R3cuBK?= =?us-ascii?Q?U0fjILoV0+7hPdaW+ChJAji76vBDzcM6fj9pxWYbqwuAnN+PJf0ELgire+u4?= =?us-ascii?Q?7M9qfsMEs07UoZ27piLqgAkLlgSxsksCfGDcqykK+hY2WxeFbgdQykCV4KzN?= =?us-ascii?Q?7iqAhNdN8Sk+3BMA76Lod7quo5koax5uS1ZYWVFjI3qc+bq1+uk+5UhAVPk2?= =?us-ascii?Q?CH1jwuAoxSCStFSmvPvubPM21nlAY+zfGuNguZGg916lp/Ynp/q78cntYtR8?= =?us-ascii?Q?vO3u8oGDNy5sWt/YFLFJUn7dakM5kJpF0qbR+DcX6HoShDMjvcm5UjkGznbj?= =?us-ascii?Q?xC00fHDhxiXFMSjI+jOT1lQ6haw2LEDyVs2VBCfT5kCz5P22ujceInnNoywc?= =?us-ascii?Q?egn8qww29tk4ed2ou6nwpW3E5elob0n8u890pb+z90QVrGjgVMwayEHhhT8b?= =?us-ascii?Q?XEfr4ECjXICOSzFRcf2rxotlxFd1MH16vTL4lQSPGWv6swxWZh1TVMP7WCnQ?= =?us-ascii?Q?C/1j4+d30NfekBA9YgzFZnFeSPjwvPnkFX23VNr9dO4ZFAXxwlBZjjnyeyH+?= =?us-ascii?Q?yJQao/t0L+YNg0pOW3mOAAeAgrygers2mr4hpWJjFck+QT87wbhbcjNBaxhy?= =?us-ascii?Q?5f+Msoh+Fn60GmDQLBQdwxMOynIYeFCjoxZmbwihGL9I1r2mY2TEJWNv5IJ2?= =?us-ascii?Q?Y6TMd2E8m31t/sknPh0IOwXWEKQ692mfpksCFqy8RWKEJAIzKZlr0eEIC6+P?= =?us-ascii?Q?4LVgiHtCNO0AnUsZhvM0KbP2HRJ/73R1wYVX1VVSKhipHTEU5EvXRc20AI+7?= =?us-ascii?Q?s+maTyaem6I6GN5PNC8+IQIss1GZdkSD9olWBB9kXNuUnPbI4qd3Vx5wq5w8?= =?us-ascii?Q?Es683xv8Cgj0IR7cPQlnsWWyBCOUSibYsgKA1K83bfRTBuUP6DKVNlR8urnY?= =?us-ascii?Q?mP2XEcc949Z8DYVg=3D?= X-Microsoft-Antispam-Message-Info: NkOu/aAShhO6wAWF+/Xj5DPd6+fnIDKy32SMd4azxGCfGgh8sDbbR7yhmHRSE9LcpjXJKyJiTUa5Pj1H0CHM37Bd+VD3Qo9dlUOWpzpZu9dsl2twtKB/tFAl02pxXAthgsTGOjaBkfACyBPMHO98QaxHCLgBg1Wx1Jcw/metE/N80Vo1f6Rubs5R+KNl9Sqs4DOYlW1AH3XHwhm9YYCJKvEj9IHcFtQdO6oDcSSjwy/EfLvsmeiGsAV8FBZuMVZAjDzetjasQR6/7KnegEp98MvcLAp0qEkedCxIzRINZGg9oIUmwOSj+vtgAVm3aViWQU8TgUUMMXNKB/iTw9PqlanT5ArN+6HznokLLASQvic= X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3908; 6:8+06u3r/xisvwi1hWoL/Ysoe2z2smsU91BgyIVSsBn1dUj1BgNYDpv01wyROMhoB4PKyhvdZtAM2Wla+SUe5lD6aXNpRhiKiODvLot25A/elYkr5+y9zJREtkhNfcxdzp3hA5p6iOIyXexMk+mv8RNrAOBO75jR+AGu4xs2xFt3UeOUggIQVp7JEtnCho1Lhnn0zEnNdMaW5NZLB96CLmXB/+NL68XHE65dVFuysPC94EKRWvuLruoqtOzW/ZGY4U6ABM5evEClqcu4jv6TMuqbjD++/K4Us8eJgWgy9v3seEgRMHnPD76R8yCDMxmU931/oDTv8WrSiVXDq+VhzkX36zs4cjsf7W2nFRC7wNKKrPMzU0ONLGb2m6J2qGrc8bDgTn7IDewI3GlG0ePAJXslSLzc+brG1td3fU7baZdYySyXyfbku0CzakwvKef69WBoi8UDSiTko3U9Uy6LtzQ==; 5:z/65+G8XBKeZxaxB2SO+4+gzkIR2DVLD5PopmqsrqDeaaTPEixctIQZwDOLX/9BfzKwmns+acMMEUDukX3c+N+97z8lU2W+tK1Fq9ZROF89qFq3aRnk3OlhvbNNW4sAzu4TRNtmhI9YA5zM0urhilWdtUVskNEoHqvEyDQcc+dU=; 24:Fz96OfnTl2CH7C6A4sse+EmLlX/nMrlQ8eflgn1Vrd2UqEcZGlmfSoMCgleQ46hUV3CJ7WGFglZX07s2CZSB93n2QM61vUTBPmS1YY4olP8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3908; 7:qaJ6OdrR5PzaXAuVFbZ6+TLmjrSyQvCaIqpqHgL6uGBYC6tfQTI4ju1LCILZxtPnq3L8UAhm/SWVUyyuviayHvaWzi66wlUc2cPCE4Qiaqp6RlB+Q9n9j33FtI+gmXk+nM3y6pWYHj5gNtnAV1QpFoGnD5m+YQRM6hux93eMp/k2yDUzdQiOr3QZp4faQLXZrjo1RmaLXYHam/Ib/5IeLVBZI754lGoRnin/ibrErYr4r3dIy9Tlb+9f0EopMPHk X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2018 00:02:24.2717 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 914f10f9-ad21-42f3-3097-08d5dbc145c0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3908 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. Reviewed-by: Rob Herring 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..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 */