Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp4075361rdh; Fri, 29 Sep 2023 10:15:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/QaHEh6oaKos34NHgtz8mgIeplj622lPXzGSDsQHzDmzHaQMFUXKWvE3jZME9tFnQr0w9 X-Received: by 2002:a05:6a20:1613:b0:160:6577:c527 with SMTP id l19-20020a056a20161300b001606577c527mr5418466pzj.52.1696007719992; Fri, 29 Sep 2023 10:15:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696007719; cv=none; d=google.com; s=arc-20160816; b=WObfaBiV8ds++tS1M3yPeJW2qnVKkGwhGMOnl2xfuKctbqTgxngWnXv8S8WsIBZDS/ amT6/bF5bktwOCnZ3YyWm69cF5JGrQa5trktlX49a/uG+pz5uHnYFeGf2/mqg41PYoEs 2MIpsQuodwye4fCm7JTcD4bfQLBXPc8v7tnR9bXl6oEu1BL8EYfokAH+WwMvAbqS5e5m Z50OeASsnbBPOYULYiibuuckRMTaa9dbRNN9hzbvE3CLZJcpRFGOMcn0cAwHKub0HO0a as/KmNWg7OVIhgM6seLdsh20+EhK6XL0POcBUW+GgdJ9TnSuHzAmoQEDj94GfDKBMcbm 0XZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yN2E7MQMCZ0ePiGEOEioEa8WG7WL2Z6XoVLmcr7JWQQ=; fh=4FTxD8y/AkqrxGSds7He/tgcu1K8JroTMbxcGH2DVaw=; b=f9vu3Fxu/tFNtWv3bbw1Dvw6u8PxqMOAtsAzkkmJ/jbXTUkW0UPr7nypjNm7tHavnr cI3Cceolv4gzFlZrvqcrAGNTZrYi/OsM2/F/F5hTahXhlhz7l1hNTY4nV8n5arYidVo7 klHENwrToExM5JCtgkSV4QpGKlKhHf4XSaZEVcEKdJp0GCJgbyJlmUpkDVyCroM6qsMM FlhHXRpTdIDp02eLRb5dz4nhEaN++pdF1+pRx7PvmJQHiWG3eSELcgRcf0CwZL4ONkeK RxW8TdHCReDiLy3qmjQZEqFiSVKoYRgCKbBdSSIAqv9syn71xiuVHV6U4lPjd0Qq5bNX 3Wtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g6yYQ+Ie; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i184-20020a6387c1000000b005859d13f276si2225692pge.569.2023.09.29.10.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 10:15:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=g6yYQ+Ie; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3C55782D66C6; Fri, 29 Sep 2023 01:52:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232519AbjI2IwT (ORCPT + 99 others); Fri, 29 Sep 2023 04:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbjI2IwQ (ORCPT ); Fri, 29 Sep 2023 04:52:16 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF6794; Fri, 29 Sep 2023 01:52:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695977535; x=1727513535; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=bxjnnMTEfiYHjMl/VzP/xRuB60mcYj1DgtGGuQgN3Hs=; b=g6yYQ+Iefg22lv5yGHgMwWGzRMjvI85SNfTiVUlqSYX70uBMLUwP/Vh0 06ryHpQmtlJBdNo2TAh+FP95WQBE09de2GZOgKCax3C7hItnN2oV9NNmr qXOBSEjSmd4a/vGhLBGYagZaErbmFgPuiTZQv5xQrQ0/L3jpDQABLqRVc rOLCvyg/D6p9KBTrLoHgqCQDo9tFcHWf9uRMiBdIXmstY+5ofgRsTuD5w JiAEuPqBgJ44uLaV0R2LrsV3wfSSl+RjFnA0dIri8k/4tdbgrGfXkAHtp 9RvkgIRf2/37epaYcWdhmhPYJvQs9k8jcml6aIFxy3U6E3vO4TSX4MDCe A==; X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="863667" X-IronPort-AV: E=Sophos;i="6.03,186,1694761200"; d="scan'208";a="863667" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2023 01:52:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="743396335" X-IronPort-AV: E=Sophos;i="6.03,186,1694761200"; d="scan'208";a="743396335" Received: from kuha.fi.intel.com ([10.237.72.185]) by orsmga007.jf.intel.com with SMTP; 29 Sep 2023 01:52:09 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Fri, 29 Sep 2023 11:52:09 +0300 Date: Fri, 29 Sep 2023 11:52:09 +0300 From: Heikki Krogerus To: Abdel Alkuor Cc: krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ryan.eleceng@gmail.com, robh+dt@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, Abdel Alkuor Subject: Re: [PATCH v7 02/14] USB: typec: tsp6598x: Add cmd timeout and response delay Message-ID: References: <20230927175348.18041-1-alkuor@gmail.com> <20230927175348.18041-3-alkuor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230927175348.18041-3-alkuor@gmail.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 29 Sep 2023 01:52:33 -0700 (PDT) On Wed, Sep 27, 2023 at 01:53:36PM -0400, Abdel Alkuor wrote: > From: Abdel Alkuor > > Some commands in tps25750 take longer than 1 second > to complete, and some responses need some delay before > the result becomes available. > > Signed-off-by: Abdel Alkuor Reviewed-by: Heikki Krogerus > --- > Changes in v7: > - Add driver name to commit subject > Changes in v6: > - Use tps6598x_exec_cmd as a wrapper > Changes in v5: > - Incorporating tps25750 into tps6598x driver > > drivers/usb/typec/tipd/core.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c > index 37b56ce75f39..32420c61660d 100644 > --- a/drivers/usb/typec/tipd/core.c > +++ b/drivers/usb/typec/tipd/core.c > @@ -282,9 +282,10 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) > power_supply_changed(tps->psy); > } > > -static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, > +static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, > size_t in_len, u8 *in_data, > - size_t out_len, u8 *out_data) > + size_t out_len, u8 *out_data, > + u32 cmd_timeout_ms, u32 res_delay_ms) > { > unsigned long timeout; > u32 val; > @@ -307,8 +308,7 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, > if (ret < 0) > return ret; > > - /* XXX: Using 1s for now, but it may not be enough for every command. */ > - timeout = jiffies + msecs_to_jiffies(1000); > + timeout = jiffies + msecs_to_jiffies(cmd_timeout_ms); > > do { > ret = tps6598x_read32(tps, TPS_REG_CMD1, &val); > @@ -321,6 +321,9 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, > return -ETIMEDOUT; > } while (val); > > + /* some commands require delay for the result to be available */ > + mdelay(res_delay_ms); > + > if (out_len) { > ret = tps6598x_block_read(tps, TPS_REG_DATA1, > out_data, out_len); > @@ -345,6 +348,14 @@ static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, > return 0; > } > > +static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, > + size_t in_len, u8 *in_data, > + size_t out_len, u8 *out_data) > +{ > + return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data, > + out_len, out_data, 1000, 0); > +} > + > static int tps6598x_dr_set(struct typec_port *port, enum typec_data_role role) > { > const char *cmd = (role == TYPEC_DEVICE) ? "SWUF" : "SWDF"; > -- > 2.34.1 -- heikki