From patchwork Tue Mar 19 12:53:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 10859537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D088317E0 for ; Tue, 19 Mar 2019 12:53:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B521229674 for ; Tue, 19 Mar 2019 12:53:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A91B02966E; Tue, 19 Mar 2019 12:53:28 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 45F5829671 for ; Tue, 19 Mar 2019 12:53:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726763AbfCSMx1 (ORCPT ); Tue, 19 Mar 2019 08:53:27 -0400 Received: from mga07.intel.com ([134.134.136.100]:60529 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725951AbfCSMx1 (ORCPT ); Tue, 19 Mar 2019 08:53:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2019 05:53:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,497,1544515200"; d="scan'208";a="156332495" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 19 Mar 2019 05:53:25 -0700 From: Heikki Krogerus To: Guenter Roeck Cc: Hans de Goede , linux-usb@vger.kernel.org Subject: [PATCH] usb: typec: wcove: Provide fwnode for the port Date: Tue, 19 Mar 2019 15:53:24 +0300 Message-Id: <20190319125324.7284-1-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 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 By registering a software fwnode for the port, we can supply the connector capabilities to the tcpm using the common USB connector device properties instead of relying on platform data (struct tcpc_config). Signed-off-by: Heikki Krogerus Reviewed-by: Guenter Roeck --- drivers/usb/typec/tcpm/wcove.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c index 423208e19383..53f00ad9aa92 100644 --- a/drivers/usb/typec/tcpm/wcove.c +++ b/drivers/usb/typec/tcpm/wcove.c @@ -587,17 +587,14 @@ static const u32 snk_pdo[] = { PDO_VAR(5000, 12000, 3000), }; -static struct tcpc_config wcove_typec_config = { - .src_pdo = src_pdo, - .nr_src_pdo = ARRAY_SIZE(src_pdo), - .snk_pdo = snk_pdo, - .nr_snk_pdo = ARRAY_SIZE(snk_pdo), - - .operating_snk_mw = 15000, - - .type = TYPEC_PORT_DRP, - .data = TYPEC_PORT_DRD, - .default_role = TYPEC_SINK, +static const struct property_entry wcove_props[] = { + PROPERTY_ENTRY_STRING("data-role", "dual"), + PROPERTY_ENTRY_STRING("power-role", "dual"), + PROPERTY_ENTRY_STRING("try-power-role", "sink"), + PROPERTY_ENTRY_U32_ARRAY("source-pdos", src_pdo), + PROPERTY_ENTRY_U32_ARRAY("sink-pdos", snk_pdo), + PROPERTY_ENTRY_U32("op-sink-microwatt", 15000), + { } }; static int wcove_typec_probe(struct platform_device *pdev) @@ -643,17 +640,22 @@ static int wcove_typec_probe(struct platform_device *pdev) wcove->tcpc.set_roles = wcove_set_roles; wcove->tcpc.pd_transmit = wcove_pd_transmit; - wcove->tcpc.config = &wcove_typec_config; + wcove->tcpc.fwnode = fwnode_create_software_node(wcove_props, NULL); + if (IS_ERR(wcove->tcpc.fwnode)) + return PTR_ERR(wcove->tcpc.fwnode); wcove->tcpm = tcpm_register_port(wcove->dev, &wcove->tcpc); - if (IS_ERR(wcove->tcpm)) + if (IS_ERR(wcove->tcpm)) { + fwnode_remove_software_node(wcove->tcpc.fwnode); return PTR_ERR(wcove->tcpm); + } ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, wcove_typec_irq, IRQF_ONESHOT, "wcove_typec", wcove); if (ret) { tcpm_unregister_port(wcove->tcpm); + fwnode_remove_software_node(wcove->tcpc.fwnode); return ret; } @@ -673,6 +675,7 @@ static int wcove_typec_remove(struct platform_device *pdev) regmap_write(wcove->regmap, USBC_IRQMASK2, val | USBC_IRQMASK2_ALL); tcpm_unregister_port(wcove->tcpm); + fwnode_remove_software_node(wcove->tcpc.fwnode); return 0; }