From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04809C83000 for ; Wed, 29 Apr 2020 22:25:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB3C120757 for ; Wed, 29 Apr 2020 22:25:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726935AbgD2WZP (ORCPT ); Wed, 29 Apr 2020 18:25:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726481AbgD2WZP (ORCPT ); Wed, 29 Apr 2020 18:25:15 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12B57C03C1AE; Wed, 29 Apr 2020 15:25:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 515CB2A0801 Subject: Re: [PATCH 2/2] platform/chrome: typec: Register Type C switches To: Prashant Malani , linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, twawrzynczak@chromium.org, Benson Leung , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Guenter Roeck , Rob Herring References: <20200422222242.241699-1-pmalani@chromium.org> <20200422222242.241699-2-pmalani@chromium.org> From: Enric Balletbo i Serra Message-ID: <542cfe8f-04a5-8dbb-b498-90254bb4c54e@collabora.com> Date: Thu, 30 Apr 2020 00:25:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200422222242.241699-2-pmalani@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi Prashant, Following my previous comments ... On 23/4/20 0:22, Prashant Malani wrote: > Register Type C mux and switch handles, when provided via firmware > bindings. These will allow the cros-ec-typec driver, and also alternate > mode drivers to configure connected Muxes correctly, according to PD > information retrieved from the Chrome OS EC. > > Signed-off-by: Prashant Malani > --- > drivers/platform/chrome/cros_ec_typec.c | 47 +++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c > index eda57db26f8d..324ead297c4d 100644 > --- a/drivers/platform/chrome/cros_ec_typec.c > +++ b/drivers/platform/chrome/cros_ec_typec.c > @@ -14,6 +14,8 @@ > #include > #include > #include > +#include > +#include > > #define DRV_NAME "cros-ec-typec" > > @@ -25,6 +27,9 @@ struct cros_typec_port { > struct typec_partner *partner; > /* Port partner PD identity info. */ > struct usb_pd_identity p_identity; > + struct typec_switch *ori_sw; > + struct typec_mux *mux; > + struct usb_role_switch *role_sw; > }; > > /* Platform-specific data for the Chrome OS EC Type C controller. */ > @@ -84,6 +89,40 @@ static int cros_typec_parse_port_props(struct typec_capability *cap, > return 0; > } > > +static int cros_typec_get_switch_handles(struct cros_typec_port *port, > + struct fwnode_handle *fwnode, > + struct device *dev) > +{ > + port->mux = fwnode_typec_mux_get(fwnode, NULL); > + if (IS_ERR(port->mux)) { > + dev_info(dev, "Mux handle not found.\n"); Be quiet also here, dev_dbg at most, as you're ignoring the error anyway at the end. > + goto mux_err; > + } > + > + port->ori_sw = fwnode_typec_switch_get(fwnode); > + if (IS_ERR(port->ori_sw)) { > + dev_info(dev, "Orientation switch handle not found.\n"); Same here > + goto ori_sw_err; > + } > + > + port->role_sw = fwnode_usb_role_switch_get(fwnode); > + if (IS_ERR(port->role_sw)) { > + dev_info(dev, "USB role switch handle not found.\n"); And here. > + goto role_sw_err; > + } > + > + return 0; > + > +role_sw_err: > + usb_role_switch_put(port->role_sw); > +ori_sw_err: > + typec_switch_put(port->ori_sw); > +mux_err: > + typec_mux_put(port->mux); > + > + return -ENODEV; > +} > + > static void cros_unregister_ports(struct cros_typec_data *typec) > { > int i; > @@ -91,6 +130,9 @@ static void cros_unregister_ports(struct cros_typec_data *typec) > for (i = 0; i < typec->num_ports; i++) { > if (!typec->ports[i]) > continue; > + usb_role_switch_put(typec->ports[i]->role_sw); > + typec_switch_put(typec->ports[i]->ori_sw); > + typec_mux_put(typec->ports[i]->mux); > typec_unregister_port(typec->ports[i]->port); > } > } > @@ -153,6 +195,11 @@ static int cros_typec_init_ports(struct cros_typec_data *typec) > ret = PTR_ERR(cros_port->port); > goto unregister_ports; > } > + > + ret = cros_typec_get_switch_handles(cros_port, fwnode, dev); > + if (ret) > + dev_info(dev, "No switch control for port %d\n", > + port_num); > } > > return 0; >