From patchwork Wed Sep 27 17:53:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 145714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3039100vqu; Wed, 27 Sep 2023 20:05:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFSaOJkIYJoZVFZymVhVCBRWpPEDghEdORW7jjGV2hf2KBUnZUI8lpuYwqeCrtmXR94CUJu X-Received: by 2002:a05:6a20:158b:b0:15c:b7ba:1671 with SMTP id h11-20020a056a20158b00b0015cb7ba1671mr13102pzj.2.1695870330073; Wed, 27 Sep 2023 20:05:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695870330; cv=none; d=google.com; s=arc-20160816; b=X5eTjesFQhiMptA6hzQa7x/t9MKCukOPRfqusMmlNwgZMpvicgaR4iXPEZCTkhk6hL FS1GBm2cQ+T63s/GHHi+vDBQd8SXcqFcox+WrnA3ukwQXuPCXK2Qn0aiDNBQY0DMaE+3 bgyv5nvVEIsdvxVPJm0/cI8QIXPKcxbLRiaKrGp7uioLxwU6uQGDCkQBZqmOhekSXVmT DwzLe9Z8xf3RjjMabhMf2Mu07zKNLJQkRI8rcxp0wdTqoevX1FPtFq207hSIDeYyaKCv fkvfklwyM/+omCugzRHomOB4D9K7l4x6ikroEV+iq139nnk5/ryx5DC4XrJBTPvScPJs j6AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=08TTJK6jIdlF3YGQZqg/ueMGQffH5CXs2rT/Yy540NE=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=j9Afgc3LIANajXuPPlW4DMz5+Ys3G5cPSu8GBZODO7l8R9k97pYAGNk0ICP3k/z8rn oC7jg8kx04yXmkE6DLoib9cCfmSzcIHPqtueczPMFv0ih/ZjB52b2LDTpqjjz4R1Zr7f yhB/b8bCTVs/IkKVGNlRpxj3RVfDohuUotepzMGfTuPyruKT2gjvk1icwPPxJNzD9qLs 7XeF2NzYSA/szsc/mo22us1ukg/KIg5ZtKcC7U1IO4W8dol9gThnB3wLZ2g9m+xOoZAs znTJWbhSEZzqu+RLZHwrKqURiCUetQZeECr1nNOFEttVOu/mIO+O9qRt5Vc3yE0r5+jV bGBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Fo4aXa5b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b130-20020a633488000000b0056952b496efsi17417936pga.366.2023.09.27.20.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 20:05:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Fo4aXa5b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 47A8A80253BC; Wed, 27 Sep 2023 10:59:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjI0R5y (ORCPT + 20 others); Wed, 27 Sep 2023 13:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjI0R5p (ORCPT ); Wed, 27 Sep 2023 13:57:45 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F48C12A; Wed, 27 Sep 2023 10:57:40 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2c124adf469so197985711fa.0; Wed, 27 Sep 2023 10:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837458; x=1696442258; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=08TTJK6jIdlF3YGQZqg/ueMGQffH5CXs2rT/Yy540NE=; b=Fo4aXa5bduEsfH0X1GG2XnvD/W23eQHGKXCgWHjFzeXd7R+FDite+0yC2qRE7dsh3M j3Gt5EzAie5+cJAiaE/BStwMQ7kg4RCH/MCyg3EXJP+xkPgLMJypTDDJ9H4hugp3697J QyVvVGDa5oxwa2w/XcZhVVw/RnB986hedkEuk6g5OwQxyOgTR6fxZEHLsU61HMbjpDrZ VFOx6GJUbES3yNe0vR2GyRXtPTBmZlwgmdbdeSZn1xDG9bW/hhez/qeNSl7nRvl9/klX FJpjfKaIYpvOE3R2fKf+wdIRupyVWmPYXeb1y7z1rkn2qO0fvTehMjMvIXM6+KDEITso yNTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837458; x=1696442258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=08TTJK6jIdlF3YGQZqg/ueMGQffH5CXs2rT/Yy540NE=; b=moISAK70dRA6o6RzErHPK+rcjByX6wfaMPurDDM/aGH0KDaTQHnwu9HEQfuTpuSdOR xzmvZSjkSIXQ37TqFekHpW/dz0nDtrEhcNyD7wV8mNWoO4CIq1q+Ff8DnE0cB/wG1O8Y ZNhvEV/dAvqkdqL93FREz8SlGDWDdjm3LpX3n8H38X31oPtWm9OfvF/VmPDijg8mg8sS tRYueQrmAAA1ZCy4miMNEhmh9Z/CPjjzYFBKz9lVYPgwaLxGlDygCBBRGdIjxZ6ggn3Z uahUO8dCME1eFFypUirI956544PdQA3p3d8bA/+rCNfG0OlrqOnH4l4fV3vnNYem15/C AUpQ== X-Gm-Message-State: AOJu0YwrnGkzU+gs9cAGFfHpefUek6iMWTAD+yD1a2aYx62yJivEOjfW Lna/iif5t38WB5fJ4bJHjkM= X-Received: by 2002:a2e:93cf:0:b0:2bd:1bca:ebee with SMTP id p15-20020a2e93cf000000b002bd1bcaebeemr2559253ljh.19.1695837458077; Wed, 27 Sep 2023 10:57:38 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:37 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: 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: [PATCH v7 05/14] USB: typec: tps6598x: Check for EEPROM present Date: Wed, 27 Sep 2023 13:53:39 -0400 Message-Id: <20230927175348.18041-6-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927175348.18041-1-alkuor@gmail.com> References: <20230927175348.18041-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SORBS_WEB, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:59:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778248927504919935 X-GMAIL-MSGID: 1778248927504919935 From: Abdel Alkuor When an EEPROM is present, tps25750 loads the binary configuration from EEPROM. Hence, all we need to do is wait for the device to switch to APP mode Signed-off-by: Abdel Alkuor --- Changes in v7: - Add driver name to commit subject Changes in v6: - Update eeprom macro to use TPS instead Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 13 +++++++++++++ drivers/usb/typec/tipd/tps6598x.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index f96a9ff07fba..cd22635460d3 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -37,6 +37,7 @@ #define TPS_REG_STATUS 0x1a #define TPS_REG_SYSTEM_CONF 0x28 #define TPS_REG_CTRL_CONF 0x29 +#define TPS_REG_BOOT_STATUS 0x2D #define TPS_REG_POWER_STATUS 0x3f #define TPS_REG_RX_IDENTITY_SOP 0x48 #define TPS_REG_DATA_STATUS 0x5f @@ -910,6 +911,17 @@ static int tps25750_apply_patch(struct tps6598x *tps) { int ret; unsigned long timeout; + u64 status = 0; + + ret = tps6598x_block_read(tps, TPS_REG_BOOT_STATUS, &status, 5); + if (ret) + return ret; + /* + * Nothing to be done if the configuration + * is being loaded from EERPOM + */ + if (status & TPS_BOOT_STATUS_I2C_EEPROM_PRESENT) + goto wait_for_app; ret = tps25750_start_patch_burst_mode(tps); if (ret) { @@ -921,6 +933,7 @@ static int tps25750_apply_patch(struct tps6598x *tps) if (ret) return ret; +wait_for_app: timeout = jiffies + msecs_to_jiffies(1000); do { diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 527857549d69..a80d0929f3ee 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -199,4 +199,7 @@ #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_A BIT(2) #define TPS_DATA_STATUS_DP_SPEC_PIN_ASSIGNMENT_B (BIT(2) | BIT(1)) +/* BOOT STATUS REG*/ +#define TPS_BOOT_STATUS_I2C_EEPROM_PRESENT BIT(3) + #endif /* __TPS6598X_H__ */