From patchwork Sun Sep 17 15:26:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 141312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2514856vqi; Mon, 18 Sep 2023 01:54:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHROJ3XrwBoFBW9Z6bxqmeTcGh32Wlmz+wND9LcX7LTgaQ1t4jJwNRba3hMOhJm5/Fa5CwC X-Received: by 2002:a05:6a20:6a1a:b0:13d:a903:88e6 with SMTP id p26-20020a056a206a1a00b0013da90388e6mr7815977pzk.48.1695027279303; Mon, 18 Sep 2023 01:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695027279; cv=none; d=google.com; s=arc-20160816; b=X9ytVPZmxX4Tl6Pt945QptFILjpVbdh3CgCGx8B+on8Xu9LvkBGFNJPl36rAHPzdRq SA1j+aCyXc5mTUCrpk1d6TV7dUyw6f4Aj9PsHPjI7hgJDoO/Zic3nhMb9UgrB47J6k1q 1P1LTFHSjMHhCLrQXdUGD18132/SaP7wWmVZv9fQZBb12qtKKdEMzmw+bstItpBnbECe 3L2FnsmcKz29qV+NubWLnZlYCDBUjbxcqfZ3td0cboUvYig8k0Z4JqG3V1k73D13yDvr 6Pq9JcDBm8gaAbrOsDP/cKW3Zb9Ln/w6oPsXUAqyZz4WFe+6L1kYxsYSAr8rnAOpLdSN zrNQ== 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=48igqbWoZ6rl5cAwQg8BttYETGq1bFuqrgNpEHB1dVg=; fh=1TLHXZLxbVW/pzxFCwcQN1QIszWWCFgsgFdloZrlyPk=; b=E8NL9N0bGLQsBQQ6L+QBee45CjZ9xBuikFhIP9eCoG+m7e8ydf1gRsMPD7t3JYg1JG oDgX36K4eEZ494k2cHqI7Ezv8Gh4uNMf0UK/shU26xU7z47YKd8QQOQrW/qmiX/gzPA+ 3Ate4DkNStfBeM5+uMPeCp1t+fk1Y42J797LDKlrCpINHOgTcqZwT4INS2gzQiVuXiQm oClcd4hxEPBHR5OEUudMLRUIVf7U3lAfXIgmYSYHWi8wCX7tMQZIpaTUSQZnIb4RpRC7 Jul0kan4HZ7IKtSY1EuFztqpuoSSJV2b7K33sxtPTeD4rjn+tDgNO+B0+3Y0z0RI4Tzj 3Eog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hh7O0bMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e19-20020a056a001a9300b0068fe9c452acsi7795458pfv.376.2023.09.18.01.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 01:54:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=hh7O0bMG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 3033582296B1; Sun, 17 Sep 2023 08:32:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237459AbjIQP2T (ORCPT + 29 others); Sun, 17 Sep 2023 11:28:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235011AbjIQP15 (ORCPT ); Sun, 17 Sep 2023 11:27:57 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB079186; Sun, 17 Sep 2023 08:27:51 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-401da71b83cso42177515e9.2; Sun, 17 Sep 2023 08:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694964470; x=1695569270; 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=48igqbWoZ6rl5cAwQg8BttYETGq1bFuqrgNpEHB1dVg=; b=hh7O0bMGsG7deqbwcqrweZ32uH7xxvfLtPuXaA1Ju+ViyXjwTOhDGbc6AcUCdyucIx 7b/bZFB0XRfK1SQusqoJgpzRehr7D6rGxVM7z+4dbGih1RChnDewY2yRV9UpZ+f1nNTH 2fdEHXB9PrZ+X4xZlZN20HdzcJodes17K+p1ghw1KzqBNRtT/f2JTjOHPFQ6Q7l5xGPC 44OmMeXNGumz1CUf4o0ExrlEVLwn67jKS46amBqhMhEAnOaM0yfS9E7ySryUNJZy+0R3 L5JJw88C3Mbd49eI45/BnqogbK6u0aHJHJcwUtmbE/IGudSV7KC84Nd9QSAyaUEq44V5 WkYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694964470; x=1695569270; 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=48igqbWoZ6rl5cAwQg8BttYETGq1bFuqrgNpEHB1dVg=; b=RsEuClIP2GyX6XhHfiQ3Fp9eW3HPgzsNfkl9KLp49TaEdMxuB+C2XUdnqtPlqFZzVh 7QiC8fbiARNQ5nycFSYTD5mTlX4o+MiPc0c3GjNU/ASKLm4i8vTKZ60LBt4SEt6c2g95 8KL4kkY+/+o+E2hxL8+JEAumsMNAlI2IcF0teecrWPsOdyowQMo+2+URhnxm3i81HzX9 oDiXWlDQNeC4KxGGAxm4U3gfNqHQm7kAQ1OEUtEp8Y61BQUoAUkVzu26nvDgcqQ0panv GTFhg2QcjQr0W+BT6CIHZt9dVRJmELz24jiJm8+h4dx3VMK3a7p6mwNdu+yZHkz0dqZT zLUQ== X-Gm-Message-State: AOJu0Yy0pJkpLeLDJDwdv1JX4aHhHz74u25yZ9gbxdO4EIhEBjdPub4Z mVzb4q4MxUvCJZL7KuXCRJM= X-Received: by 2002:a05:600c:144:b0:401:b504:b6a0 with SMTP id w4-20020a05600c014400b00401b504b6a0mr6937162wmm.3.1694964470280; Sun, 17 Sep 2023 08:27:50 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:27:49 -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 Subject: [PATCH v5 13/15] USB: typec: Add power status trace for tps25750 Date: Sun, 17 Sep 2023 11:26:37 -0400 Message-Id: <20230917152639.21443-14-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 agentk.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 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:32:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777364924338877393 X-GMAIL-MSGID: 1777364924338877393 From: Abdel Alkuor tps25750 power status register is a subset of tps6598x power status register. Signed-off-by: Abdel Alkuor --- drivers/usb/typec/tipd/core.c | 6 +++++- drivers/usb/typec/tipd/tps6598x.h | 19 ++++++++++++++++++ drivers/usb/typec/tipd/trace.h | 33 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 8d6cb67898a5..dd3c76b57aaa 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -484,7 +484,11 @@ static bool tps6598x_read_power_status(struct tps6598x *tps) return false; } tps->pwr_status = pwr_status; - trace_tps6598x_power_status(pwr_status); + + if (tps->is_tps25750) + trace_tps25750_power_status(pwr_status); + else + trace_tps6598x_power_status(pwr_status); return true; } diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 0344b65cd55a..bab6b0f026fc 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -161,6 +161,25 @@ #define TPS_POWER_STATUS_BC12_STATUS_CDP 2 #define TPS_POWER_STATUS_BC12_STATUS_DCP 3 +/* TPS25750_REG_POWER_STATUS bits */ +#define TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS_MASK GENMASK(7, 4) +#define TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS(p) \ + TPS_FIELD_GET(TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS_MASK, (p)) +#define TPS25750_POWER_STATUS_CHARGER_ADVERTISE_STATUS_MASK GENMASK(9, 8) +#define TPS25750_POWER_STATUS_CHARGER_ADVERTISE_STATUS(p) \ + TPS_FIELD_GET(TPS25750_POWER_STATUS_CHARGER_ADVERTISE_STATUS_MASK, (p)) + +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DISABLED 0 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_IN_PROGRESS 1 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_NONE 2 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_SPD 3 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_CPD 4 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_DPD 5 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_1_DCP 6 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_2_DCP 7 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_3_DCP 8 +#define TPS25750_POWER_STATUS_CHARGER_DET_STATUS_1_2V_DCP 9 + /* TPS_REG_DATA_STATUS bits */ #define TPS_DATA_STATUS_DATA_CONNECTION BIT(0) #define TPS_DATA_STATUS_UPSIDE_DOWN BIT(1) diff --git a/drivers/usb/typec/tipd/trace.h b/drivers/usb/typec/tipd/trace.h index 28725234a2d8..739b0a2a867d 100644 --- a/drivers/usb/typec/tipd/trace.h +++ b/drivers/usb/typec/tipd/trace.h @@ -166,6 +166,19 @@ { TPS_POWER_STATUS_BC12_STATUS_CDP, "cdp" }, \ { TPS_POWER_STATUS_BC12_STATUS_SDP, "sdp" }) +#define show_tps25750_power_status_charger_detect_status(power_status) \ + __print_symbolic(TPS25750_POWER_STATUS_CHARGER_DETECT_STATUS(power_status), \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DISABLED, "disabled"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_IN_PROGRESS, "in progress"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_NONE, "none"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_SPD, "spd"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_CPD, "cpd"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_BC_1_2_DPD, "dpd"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_1_DCP, "divider 1 dcp"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_2_DCP, "divider 2 dcp"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_DIV_3_DCP, "divider 3 dpc"}, \ + { TPS25750_POWER_STATUS_CHARGER_DET_STATUS_1_2V_DCP, "1.2V dpc"}) + #define TPS_DATA_STATUS_FLAGS_MASK (GENMASK(31, 0) ^ (TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK | \ TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK | \ TPS_DATA_STATUS_TBT_CABLE_GEN_MASK)) @@ -299,6 +312,26 @@ TRACE_EVENT(tps6598x_power_status, ) ); +TRACE_EVENT(tps25750_power_status, + TP_PROTO(u16 power_status), + TP_ARGS(power_status), + + TP_STRUCT__entry( + __field(u16, power_status) + ), + + TP_fast_assign( + __entry->power_status = power_status; + ), + + TP_printk("conn: %d, pwr-role: %s, typec: %s, charger detect: %s", + !!TPS_POWER_STATUS_CONNECTION(__entry->power_status), + show_power_status_source_sink(__entry->power_status), + show_power_status_typec_status(__entry->power_status), + show_tps25750_power_status_charger_detect_status(__entry->power_status) + ) +); + TRACE_EVENT(tps6598x_data_status, TP_PROTO(u32 data_status), TP_ARGS(data_status),