From patchwork Sun Sep 17 15:26:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2247892vqi; Sun, 17 Sep 2023 11:15:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW3ky1Ejn88OeEBRwrDfvpW+GGKDOnhDM5ZusmoDslgy2sQsXCGOzsNpHrtFw6KyoawC76 X-Received: by 2002:a05:6a20:12c4:b0:148:3c72:4878 with SMTP id v4-20020a056a2012c400b001483c724878mr9441877pzg.50.1694974526426; Sun, 17 Sep 2023 11:15:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694974526; cv=none; d=google.com; s=arc-20160816; b=KSUJJ68XMKMdhgUVK+PTjJyTQdZsCw2OqcOeafSw64j05b+sgSXPezNm4m36O1mJH3 WcwqlXM2LE798TMe6guuZYfjlwOtYqC2Hs3lHqdm9e7VrU9SlWCwr0iCenR8psfZnmLd gM73FGnYSBLLCJ79G88ateLKnw/GQRBzdCF0byP1UeVCM/uO0CF+/X+0HP3nc9ItDPTN +T4cRYrNqNGIaZp7zSBKNZG38hFXS9kYa1HEwQwtBTnhawFbBkMaEjQxdMJ6qFDY2SVC d8bzTIdZNj6XMQVvK89kY4JJxCP9YMdPyxqLpCW2lxatWW4y4x+No40LWLTbkLBuW9t5 qM5A== 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=Ca93iTqJpSx/plxX75j5Y8vcvCYToSV9JbO7YLCJdoA=; fh=I0Lzq3m/LIxJ51N7jPTHUv8eE5jJdt/R03iLk7hWxA8=; b=txkvqr7226CLoAQ74+OKxyjuWvNQARAWGxvn6YoLsbBltqHClCT9B99kfccdeABnAT BK9QNc49oPrHgC6PjLeY5oSa2j8NGz6tQxYcjwYWGgmIUGVFh7vr7lzKJUIzfiUEabp8 XITRKXnzyiqGcB3ynfPDoDYFciadg1kRQQZaFlzDofTAFv1wExd8M9wjxiWtKgvxRgnp d8UhiJ7eUz9SoTaDwxsDMzHmy+nuz6PD70dt5uAQeK1pVub6wU24+PK72QpieNXGm75X YiD2tmGUWU7k3S+T9+nEffI9K0zIUq3tpVOEbSacfyWAQ2dNczw7HT+pNQdRhHMdyV18 8sng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="C9/3hplK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id w29-20020a63161d000000b005649d5fc097si4165309pgl.820.2023.09.17.11.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 11:15:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="C9/3hplK"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id C363C81F3785; Sun, 17 Sep 2023 08:29:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236190AbjIQP2E (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233546AbjIQP1a (ORCPT ); Sun, 17 Sep 2023 11:27:30 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56E2418B; Sun, 17 Sep 2023 08:27:25 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-402c46c49f4so39994775e9.1; Sun, 17 Sep 2023 08:27:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964444; x=1695569244; 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=Ca93iTqJpSx/plxX75j5Y8vcvCYToSV9JbO7YLCJdoA=; b=C9/3hplKd8qlo2ppa8L+ohT4dtw+/PX2o77OEcce0LNqarToW3u4OTgl/N7QHhWpPA au5H/ON8jsfQ7H1Od4BCcMHIQn4ELczUAoLhejQjov76N2fUf4gwowcjpy6kAs2Ba8gy sxOsFqvutgEfzaeYDZxpOiwgYdKrwv89wNtnuhMSr+Akq5f3yHxkCG1p6ERmGY3dlAV/ ib95q445tg0zSBRaeBVgpO42zUzqXKZjOq6WXsFLw/TaeT6+V5GcaWwdRSYhzf+K/16q /w0Mq+B1Y9SnrQt5Lni5LAKsBwP3g+ay83e4bJm11JMYR8iqK5n9pmKsicBjCa8qnPx1 BEnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964444; x=1695569244; 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=Ca93iTqJpSx/plxX75j5Y8vcvCYToSV9JbO7YLCJdoA=; b=JAyxkcjSr/+kEKIF0sIn8rUFx5DcZn3ItICYDZPwhY/3aP3rRl4105NIcPCOrnbWDQ Zt97DocdZvIAPyIPGWyZyD62MgHgcUsaaihjOtTjiMfnCryLPu4jLEkLX437hSR2m/05 FxjlZcdXI8/K7xOXFCM2C2eLcSDASe4RDfiBiwe2h/mWPdsqiYnJVbRgZ93BBIfOj98b IRdAZHIa7b7HRRo92yejdJD/9tDnosaqW3uJ4SCjEfzZQsIT+wQVOrkBfQJAD6m8/xfH W24ooRotdtfzp4Nr1ZUUI2LoI/hF1DD9KJ8riuKOrkKY3KNvnbsQWz2Qk8w9+lU36AIJ m21g== X-Gm-Message-State: AOJu0YzlodmFNKaoSD/5BoitusjWkJ9jluOFQyBL5sJGJe1FXHDf+Cu+ OzMj6a/H1CKFdl4FNDv7j80= X-Received: by 2002:a7b:c40d:0:b0:402:cc5c:c98 with SMTP id k13-20020a7bc40d000000b00402cc5c0c98mr5999011wmi.13.1694964443723; Sun, 17 Sep 2023 08:27:23 -0700 (PDT) Received: from localhost.localdomain ([5.45.134.53]) by smtp.gmail.com with ESMTPSA id j23-20020a05600c489700b003fe15ac0934sm7388865wmp.1.2023.09.17.08.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:23 -0700 (PDT) From: Abdel Alkuor To: heikki.krogerus@linux.intel.com, krzysztof.kozlowski+dt@linaro.org, bryan.odonoghue@linaro.org Cc: gregkh@linuxfoundation.org, robh+dt@kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org, linux-kernel@vger.kernel.org, abdelalkuor@geotab.com, Abdel Alkuor Subject: [PATCH v5 03/15] USB: typec: Add patch mode to tps6598x Date: Sun, 17 Sep 2023 11:26:27 -0400 Message-Id: <20230917152639.21443-4-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230917152639.21443-1-alkuor@gmail.com> References: <20230917152639.21443-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:29:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777309608570720008 X-GMAIL-MSGID: 1777309608570720008 TPS25750 has a patch mode indicating the device requires a configuration to get the device into operational mode Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index a8aee4e1aeba..6d2151325fbb 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -68,6 +68,7 @@ enum { TPS_MODE_BOOT, TPS_MODE_BIST, TPS_MODE_DISC, + TPS_MODE_PTCH, }; static const char *const modes[] = { @@ -75,6 +76,7 @@ static const char *const modes[] = { [TPS_MODE_BOOT] = "BOOT", [TPS_MODE_BIST] = "BIST", [TPS_MODE_DISC] = "DISC", + [TPS_MODE_PTCH] = "PTCH", }; /* Unrecognized commands will be replaced with "!CMD" */ @@ -576,7 +578,7 @@ static void tps6598x_poll_work(struct work_struct *work) &tps->wq_poll, msecs_to_jiffies(POLL_INTERVAL)); } -static int tps6598x_check_mode(struct tps6598x *tps) +static int tps6598x_check_mode(struct tps6598x *tps, u8 *curr_mode) { char mode[5] = { }; int ret; @@ -585,8 +587,11 @@ static int tps6598x_check_mode(struct tps6598x *tps) if (ret) return ret; - switch (match_string(modes, ARRAY_SIZE(modes), mode)) { + *curr_mode = match_string(modes, ARRAY_SIZE(modes), mode); + + switch (*curr_mode) { case TPS_MODE_APP: + case TPS_MODE_PTCH: return 0; case TPS_MODE_BOOT: dev_warn(tps->dev, "dead-battery condition\n"); @@ -715,6 +720,7 @@ static int tps6598x_probe(struct i2c_client *client) u32 vid; int ret; u64 mask1; + u8 mode; tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL); if (!tps) @@ -759,7 +765,7 @@ static int tps6598x_probe(struct i2c_client *client) tps->irq_handler = irq_handler; /* Make sure the controller has application firmware running */ - ret = tps6598x_check_mode(tps); + ret = tps6598x_check_mode(tps, &mode); if (ret) return ret;