From patchwork Thu May 3 00:24:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10376833 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 9A4E160384 for ; Thu, 3 May 2018 00:41:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 889A829137 for ; Thu, 3 May 2018 00:41:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D3E729153; Thu, 3 May 2018 00:41:52 +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 C893229137 for ; Thu, 3 May 2018 00:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751862AbeECAlt (ORCPT ); Wed, 2 May 2018 20:41:49 -0400 Received: from mail-eopbgr10056.outbound.protection.outlook.com ([40.107.1.56]:1220 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751747AbeECAls (ORCPT ); Wed, 2 May 2018 20:41:48 -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=9CKO64UzQKYZsaaBUlagykh2HZM107DLcrNMcWenSI0=; b=WFPxrgJX8ZROfYCI3vUY/RZ1wCpuTLmfg2Ihnh6KKnk3ET8rlgr6dYM6aWcbwa0r5HjZ+UjhfIl/yq4MX14ODg8Hi3CF4NzJ1yoixGpfh+YQQOKwVOPuAO8hU5P3q35d9lu0AelCqlQaFB9xeSpPOV+WC8ShEjesyHtuMDeOwmQ= 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:40 +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 06/14] usb: typec: tcpm: support get typec and pd config from device properties Date: Thu, 3 May 2018 08:24:46 +0800 Message-Id: <1525307094-27402-7-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; DB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W2stIr6QnRvEiwZPtHu+NaCvcd2urUHYaso7UNJeRVwupx2jrq83rJR0zAa4X5ujdi9CjiAbkGKPG6HaBMZQEMhZQVSvgrHThva2oANyvlNb2EvfUlDDF0Uj8HmSfk0eLZ9DUqYRo5i+SIQFjMZhC8y3m2jmIHPbvVCFr/xLVY9/QCbp66hLK4jHhoCyDBjybGl33yT65l1Vz13b3C4jP44QYV3c0ER4kjFu6872z1g9djNnf0q8ivEOJpTIj6iJ1qEFoGkdAChMxZ1gU84s08OrIvCZKCpW2nlZwtOQ7BR2WvrMBtlgdj7CJXiMjH2m7/rjRI3hBb7UARJnoEBPR9UdrI4RRoOOz6VNHBrpmXuFuXNt7; 4:s4zEgboYV40LK40UbiAkjVDFevqXFwYYRkMuU5C4vhvvfPf9g75vGM5vQywljw20FeZY4CWvpzf3YUz59kZmx8AjzJ8ArFHIFEp4prPMP1cugGkN/b9tdWeDtg2I0ezWpwbe7P2PLQrSPlkUgNflhhMCokjV67qPNqv1ssPwyZhicnDjqurgnMd8znqHs10SMDpK1NnMbzKOEtGDfCrb9LATof+AxtBo63mcHof3FDCQakouuX2YkGBpMopbwZ7B4U7JPz//zgtVloETYY4yrdp4cmTf1H1JbVeaJIC6A7PZJubsMlKKY1YCOwphZ8BI 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)(81166006)(8676002)(50226002)(68736007)(81156014)(36756003)(956004)(2616005)(386003)(16586007)(476003)(50466002)(6506007)(59450400001)(6512007)(97736004)(316002)(446003)(39060400002)(52116002)(26005)(76176011)(48376002)(4326008)(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:/IMVHkAsmqseM4VTyXrgnFlRooXb1GKul1iM2dU?= =?us-ascii?Q?c5CLBUr4nG6JSKoT9jmzHPCGm5HzGQrLUXbUgkOFDHAUUykE56PGZxEYl5He?= =?us-ascii?Q?Ab0MkpfiKfoyxbwSz4v6w4eXTb+u2uQOe3OA7l/uFD9+hjN7oDoKsfDHqdC0?= =?us-ascii?Q?MXAXTrhpvlS6xdZEWmQEm+Fa+Nu0WLAbwiYauEJMpSU74PEuewljx265b8ck?= =?us-ascii?Q?ixhPKM7+hrWy3l24Yrfws1vTHDxzZ7FGc8wYqGjQJ+BuRPYPhj0KjoiRblZw?= =?us-ascii?Q?8zHo0XNErsI3phMuib0vvq5sVsOa1NHMvlJcTRqm063dbDLRN0CluC0mMnWE?= =?us-ascii?Q?enDabWO7MC+7iuVjlcrxixOnXvwI2aKBAo30hJl3pfh29ylwzJR9EZLF7djh?= =?us-ascii?Q?f57O8mWZaPS4mE68j7vOQt/JJJpoYBxcPDFKIp88OpMyYFVou+JYEABpS7oD?= =?us-ascii?Q?qowHVchrtipNUMGjFkBI743UO2muod8cQmsoorsbHE1EXv7RgNCAJvqGuDkv?= =?us-ascii?Q?tRhSvZ54rsP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diagnostics: 1; DB3PR0402MB3914; 6:kEqwNymZqkbw3mXMPydVPecuii6Umzc5l212YKehGdD5OZGV10g+EOwXrevFCIFbfpA/1tu6W3u7aKJDb7lO4EV2lueOHxybHz4aab+KDL+dBn145gBwPSGlsyuYOKKBXMSQdhkD13TbP82TiqaXJWZFBi60BECgct/hsq70GzKPA32Qcbv03+LNtxJHZcprAq7UTDxltc3XSsNweiDEOlPQhdZIyqaLNLZcw2ybFlGrnRHlypQ7xSUD290aSOR8QLmjCE/kV8P6aln9DxQjrhCCJEuo08avyY92QuBGv6f/sFrI9gaiz5bjnSm/HRm0a6xGZKDzt+nyBkbUIARH77PZvEXhxGWnztTbAiqkqoqGUh3IIRzZJtX/x7dVLTD3IEPKO42zYdv1ix2MkiSL95lHs9xTpjVuH2V/UtM9DaDIoJrDak8hndsqGBVRdA/wSCNl3afsdAdGLoCAxQPEdQ==; 5:aiGFZ33HHgnL3czb59VowHweANFA3F7NBCYCXZ0D4+PKFYNRcSaoHB1fBgtC9a8zlF8UI9mM2Yku05J+ZeIIdVxMfn5NvpLDF80j8sisQsTD7sP438hiqyJfw+jbKH6qjFRxfNlXL+f/3FR1JZHVXZoNMQPb64VFnZFOHLnxLCw=; 24:Xeeg5d9KR+XTHQJcE5bgYVXVoAgqXm4nqNjZRmRTMLzRHkweqxdEqRK35yHhFqqkqrY+ckzYvGZxWl0bW1oj8lr6KpTGvtkXEyDz65l5fzo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB3PR0402MB3914; 7:AJEVokzdIPwHIxENo7VqXnL58QMbyk72nN/PMKp9Uf4G1Iau3SL3Y2aFFd9SIN7MBnoAp2vIvVmEd2CzVZPUBQes1gIrl/Le5EntYKlcLRaTAot46RFDQDIIqFvwywpG1eZ9meym4qZOjNBa+1RVdfsJnB9zzHximUqmH4EPpUnO5CLAMW5Fp8zMd2EICuzVE01kHD+UREhWDnkE3YkHPjCz5BE0CZa0sJkAgOol6UYgOEozi0tX85ycs4juqOh1 X-MS-Office365-Filtering-Correlation-Id: d91512c3-0ddf-42aa-de55-08d5b08ea5c5 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2018 00:41:40.0063 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d91512c3-0ddf-42aa-de55-08d5b08ea5c5 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 This patch adds support of get typec and power delivery config from firmware description. Signed-off-by: Li Jun --- drivers/usb/typec/tcpm.c | 133 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 111 insertions(+), 22 deletions(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 80b2303..becedcf 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -4240,6 +4241,81 @@ static int tcpm_copy_vdos(u32 *dest_vdo, const u32 *src_vdo, return nr_vdo; } +static int tcpm_fw_get_caps(struct tcpm_port *port, + struct fwnode_handle *fwnode) +{ + const char *cap_str; + int ret; + u32 mw; + + if (!port || !fwnode) + return -EINVAL; + + /* USB data support is optional */ + ret = fwnode_property_read_string(fwnode, "data-role", &cap_str); + if (ret == 0) { + port->typec_caps.data = typec_find_data_type(cap_str); + if (port->typec_caps.data < 0) + return -EINVAL; + } + + ret = fwnode_property_read_string(fwnode, "power-role", &cap_str); + if (ret < 0) + return ret; + + port->typec_caps.type = typec_find_power_type(cap_str); + if (port->typec_caps.type < 0) + return -EINVAL; + port->port_type = port->typec_caps.type; + + if (port->port_type == TYPEC_PORT_SNK) + goto sink; + + /* Get soruce pdos */ + ret = fwnode_property_read_u32_array(fwnode, "source-pdos", + NULL, 0); + if (ret <= 0) + return -EINVAL; + + port->nr_src_pdo = min(ret, PDO_MAX_OBJECTS); + ret = fwnode_property_read_u32_array(fwnode, "source-pdos", + port->src_pdo, port->nr_src_pdo); + if ((ret < 0) || tcpm_validate_caps(port, port->src_pdo, + port->nr_src_pdo)) + return -EINVAL; + + if (port->port_type == TYPEC_PORT_SRC) + return 0; + + /* Get the preferred power role for DRP */ + ret = fwnode_property_read_string(fwnode, "try-power-role", &cap_str); + if (ret < 0) + return ret; + + port->typec_caps.prefer_role = typec_find_preferred_role(cap_str); + if (port->typec_caps.prefer_role < 0) + return -EINVAL; +sink: + /* Get sink pdos */ + ret = fwnode_property_read_u32_array(fwnode, "sink-pdos", + NULL, 0); + if (ret <= 0) + return -EINVAL; + + port->nr_snk_pdo = min(ret, PDO_MAX_OBJECTS); + ret = fwnode_property_read_u32_array(fwnode, "sink-pdos", + port->snk_pdo, port->nr_snk_pdo); + if ((ret < 0) || tcpm_validate_caps(port, port->snk_pdo, + port->nr_snk_pdo)) + return -EINVAL; + + if (fwnode_property_read_u32(fwnode, "op-sink-microwatt", &mw) < 0) + return -EINVAL; + port->operating_snk_mw = mw / 1000; + + return 0; +} + int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, unsigned int nr_pdo) { @@ -4524,12 +4600,36 @@ static int devm_tcpm_psy_register(struct tcpm_port *port) return PTR_ERR_OR_ZERO(port->psy); } +static int tcpm_copy_caps(struct tcpm_port *port, + const struct tcpc_config *tcfg) +{ + if (tcpm_validate_caps(port, tcfg->src_pdo, tcfg->nr_src_pdo) || + tcpm_validate_caps(port, tcfg->snk_pdo, tcfg->nr_snk_pdo)) + return -EINVAL; + + port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcfg->src_pdo, + tcfg->nr_src_pdo); + port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcfg->snk_pdo, + tcfg->nr_snk_pdo); + + port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcfg->snk_vdo, + tcfg->nr_snk_vdo); + + port->operating_snk_mw = tcfg->operating_snk_mw; + + port->typec_caps.prefer_role = tcfg->default_role; + port->typec_caps.type = tcfg->type; + port->typec_caps.data = tcfg->data; + + return 0; +} + struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) { struct tcpm_port *port; int i, err; - if (!dev || !tcpc || !tcpc->config || + if (!dev || !tcpc || !tcpc->get_vbus || !tcpc->set_cc || !tcpc->get_cc || !tcpc->set_polarity || !tcpc->set_vconn || !tcpc->set_vbus || !tcpc->set_pd_rx || !tcpc->set_roles || !tcpc->pd_transmit) @@ -4559,30 +4659,19 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) init_completion(&port->pps_complete); tcpm_debugfs_init(port); - if (tcpm_validate_caps(port, tcpc->config->src_pdo, - tcpc->config->nr_src_pdo) || - tcpm_validate_caps(port, tcpc->config->snk_pdo, - tcpc->config->nr_snk_pdo)) { - err = -EINVAL; + if (tcpc->config) + err = tcpm_copy_caps(port, tcpc->config); + else + err = tcpm_fw_get_caps(port, tcpc->fwnode); + if (err < 0) goto out_destroy_wq; - } - port->nr_src_pdo = tcpm_copy_pdos(port->src_pdo, tcpc->config->src_pdo, - tcpc->config->nr_src_pdo); - port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo, - tcpc->config->nr_snk_pdo); - port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo, - tcpc->config->nr_snk_vdo); - - port->operating_snk_mw = tcpc->config->operating_snk_mw; - if (!tcpc->config->try_role_hw) - port->try_role = tcpc->config->default_role; + + if (!tcpc->config || !tcpc->config->try_role_hw) + port->try_role = port->typec_caps.prefer_role; else port->try_role = TYPEC_NO_PREFERRED_ROLE; port->typec_caps.fwnode = tcpc->fwnode; - port->typec_caps.prefer_role = tcpc->config->default_role; - port->typec_caps.type = tcpc->config->type; - port->typec_caps.data = tcpc->config->data; port->typec_caps.revision = 0x0120; /* Type-C spec release 1.2 */ port->typec_caps.pd_revision = 0x0300; /* USB-PD spec release 3.0 */ port->typec_caps.dr_set = tcpm_dr_set; @@ -4592,7 +4681,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) port->typec_caps.port_type_set = tcpm_port_type_set; port->partner_desc.identity = &port->partner_ident; - port->port_type = tcpc->config->type; + port->port_type = port->typec_caps.type; port->role_sw = usb_role_switch_get(port->dev); if (IS_ERR(port->role_sw)) { @@ -4610,7 +4699,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) goto out_destroy_wq; } - if (tcpc->config->alt_modes) { + if (tcpc->config && tcpc->config->alt_modes) { const struct typec_altmode_desc *paltmode = tcpc->config->alt_modes; i = 0;