Received: by 2002:a17:90a:bc8d:0:0:0:0 with SMTP id x13csp2402987pjr; Tue, 19 May 2020 14:27:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2PifRLbK5dPGcvor6SrQAmq/MbkcziEvxEAlBJq9u1Gp6cfouM5IhCfGMfOSnySmXw8Ah X-Received: by 2002:a50:a624:: with SMTP id d33mr740636edc.58.1589923628402; Tue, 19 May 2020 14:27:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589923628; cv=none; d=google.com; s=arc-20160816; b=oFU3h00TFsfE72PL4lY8RTYJTUrhk87PjdRK3Rkoszgp/m8hNdxtVt25253JdIPzdy 3syQTFk2mwsBJEIuBt/7BtagxCO/IuFMzyYAz0oZfekW/mU6uEj3A51eY4zftu1WUWm1 ONMpvZ4VQsu7nW5+S5cpiAzAWDsOj+SSh70YiGJJ85Po2BKOUbHqtAy6Upokglsh8pG1 h/hTp+m56FxZUeZY0y/q7YpfZH7yOeV+G0Jl5pozyj6qlqShr3FWyCn3u8C0c4uHVPg1 aMTbxj2q29Qfeslh4Doa1m0rSbx9yibychRIarTydBemlSyW8xq8Bzh0I3/jugF52amN vvHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=o3KSSDG5U8XIkvIC/T+e4P2nWgbVDIFyY94f1xpjme8=; b=pT1KwH+ZqxOmmYkgTAX7LNUugRm5qk50D7BLpPjQs/aM/WRQErbBTWxyBszqLRqD81 z2DAvcqhBVX+AMVxYa0YIRtFPunGgH91NnYawTWcbnIH+KGSS3isYNiMp1rxsXOOycM0 opOUvyD/fvN6FiEvOnA1E5VpY3YI62NfbKHKBZYbkeYqGlEYBceNTpzqy6bXFYnKiwfR Y/uYGiooh436STUjStXpOZzeK/YGPaI8HtjJajh52OVuAfFsnHQPD3UchtKvk2GO66IQ 3LlrHWa18QK7TMs09pKspAXGBHMdaSuR/tzwyffwtcyUabRI1jjNrApVGEinkarc2I4U NBag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si649956eju.20.2020.05.19.14.26.44; Tue, 19 May 2020 14:27:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726304AbgESVYw (ORCPT + 99 others); Tue, 19 May 2020 17:24:52 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:57650 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbgESVYw (ORCPT ); Tue, 19 May 2020 17:24:52 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 10FDB2A03F5 Subject: Re: [PATCH v2 2/2] platform/chrome: typec: Register Type C switches To: Prashant Malani , linux-kernel@vger.kernel.org Cc: heikki.krogerus@linux.intel.com, Heikki Krogerus , Benson Leung , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Guenter Roeck , Rob Herring References: <20200518071707.161843-1-pmalani@chromium.org> <20200518071707.161843-2-pmalani@chromium.org> From: Enric Balletbo i Serra Message-ID: Date: Tue, 19 May 2020 23:24:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200518071707.161843-2-pmalani@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Prashant, Thank you for the patch. On 18/5/20 9:17, 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 > Reviewed-by: Heikki Krogerus For my own reference: Acked-by: Enric Balletbo i Serra Patch 1/2 still needs a review from Rob, I'll wait for that before queue the patches. Thanks, Enric > --- > > Changes in v2: > - Changed dev_info prints to dev_dbg. > > 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 66b8d21092af..6e79f917314b 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_dbg(dev, "Mux handle not found.\n"); > + goto mux_err; > + } > + > + port->ori_sw = fwnode_typec_switch_get(fwnode); > + if (IS_ERR(port->ori_sw)) { > + dev_dbg(dev, "Orientation switch handle not found.\n"); > + goto ori_sw_err; > + } > + > + port->role_sw = fwnode_usb_role_switch_get(fwnode); > + if (IS_ERR(port->role_sw)) { > + dev_dbg(dev, "USB role switch handle not found.\n"); > + 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_dbg(dev, "No switch control for port %d\n", > + port_num); > } > > return 0; >