From patchwork Fri Sep 29 14:30:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 148939 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp438566vqb; Thu, 5 Oct 2023 10:03:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGZ1mktACE4lG7SLWIJqr2cwGK2iNJKrbkZzt77fwGWpEZ4fsdCrFlFQr7anf0/YQk8O3J X-Received: by 2002:a17:903:11d2:b0:1c7:2697:ec0a with SMTP id q18-20020a17090311d200b001c72697ec0amr6040171plh.30.1696525412976; Thu, 05 Oct 2023 10:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525412; cv=none; d=google.com; s=arc-20160816; b=MQnDIZ5X2BnCcUbdAu+4zm9s6bZpHXV+oLd+iP9onAbFFpCAnGkr3BPeZnE8LlLHW9 M41hOVF17qp4ZdQVjuRbRupF7DHOat8El+5U8fm87mE6p2fz4dB/uE4PU8h25lm8FxHL DwHIFQ56WqtyEBR5QKeu/IeYPjT0fOebWYUxZxnS7UXaSE+6K0cgXK6rMo0RZTwt1fzx R9QzDk9WEeoCWkl75F44s4wql/XmSezapyhSpij4UG2v5pvE3KauHZ0bTSvtc1QQGZiH 6dz9QlkEEqbfpcdglFkKrsUuaIDH5tEONnyb/BrimTwnNc6N2uK79pqt0jktWkCd5Xdy pdLA== 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=a4cA+mZWyPkCkV/BDJlpA7F0WPLb7gs/FrHfljohURs=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=z53E7w9yRMdLwbYG4mX8A8bXOiOKVV1kC3dbK0g/R8cjA0u0Zh3faht8dM/++X8DAy J5/gKCLocq4KMw/mh3NrY55h9Z6qTupqQ5nF3xGEotFWqrBXu+RQuNQucD68sMaGN5kI mdzlYxotXPWZ4yh+YrVcmcbEAS3w8s0RbUd/tPmziWfpv7X7EYdNmiiWiPRTXbGn61R0 rmvKZC7T3XwW60Ai2fNl6PT93/lx2nfj4LAXcuLtyCnJCrI86Z/Wrkb4Fk7txIYwQML2 vzR5uwyamHLJK+NYp6k+fHgiGZXvthcYK3maIuYUrCjePpzA6hcPGNTYZjC2yNht6cBw TVUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HY3sGX96; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id o17-20020a170903301100b001c39b8b1d77si1721251pla.149.2023.10.05.10.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:03:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HY3sGX96; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id DCBE58020D8C; Fri, 29 Sep 2023 07:33:45 -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 S233772AbjI2OdJ (ORCPT + 20 others); Fri, 29 Sep 2023 10:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233583AbjI2Oc0 (ORCPT ); Fri, 29 Sep 2023 10:32:26 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E870610FB; Fri, 29 Sep 2023 07:32:21 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-9ad8d47ef2fso1850782166b.1; Fri, 29 Sep 2023 07:32:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695997940; x=1696602740; 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=a4cA+mZWyPkCkV/BDJlpA7F0WPLb7gs/FrHfljohURs=; b=HY3sGX96P4QoQ4faJEt8f8sREXCBNcb6H5QDd4jkeCbRPGKC8e8gR+YKoszoSqkJdd 1NqhZsZk4rEGNQzhxPdRBmDTWZcgiRkXm2hPs8Bgkm+XY/VqB30yRzcMf1pqMy+qCGmK eVbuAjtP1+PJdU3h6W/Io6UtSQqpWxQ4aaVxz1XJDNwyM69bKFOIl2hHbZ0OEJQtomYJ zN7hTlV7zeyac3PbJ0YiSW7CmfTKDXMk1C5xY3fFrnJaK9Un4eImw3Vc5Zjihq1p0XAK ksGwULld/DgwyXewtD5vdDpoUUJdx+c9NTr2ykn10ASZ7z/NjWnLSXgVipOShyvWUQ0p 7gWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695997940; x=1696602740; 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=a4cA+mZWyPkCkV/BDJlpA7F0WPLb7gs/FrHfljohURs=; b=KBQ1nwwIY9Y9CmkPUbTM8uRJPYOjWrYKvhTZ1sMiejkJRd+RbJGNIyIaYOrFmH4w/k TcB2jkghbQO034Dpyxpvv+Fy/rvTfJJHHKCvpNrNcA/lFUZ8liKZjAdfyI35ZgnDkCDC aTjy1RENWhloh+VKK9hExznqjHSuMXElChHByQ1Xha5aGlE0BYgG6qSPDBCdlRbCBXDu zHYpU5sQPtGCXGKFoohU0V9BL1cDiu4WdoATJZkEKR3VXZEO9SOgxg7rHmOhnJJzvmla BytBQ6urxtxrNjZUlGnRBi0ZpkBIwpscWZDq+32RQF4hFuyPktbfr1qvnyTULgpVZM91 R3sw== X-Gm-Message-State: AOJu0Yx8B56DuEe4wSiPoXiLQjLRW+wwwL3qzznsZbS73IF9fzFr40Gi roFqxwDpRkVYzriJQIiApEI6E6OIx0gg3CbkPuM= X-Received: by 2002:a17:906:854b:b0:9ae:54c3:c627 with SMTP id h11-20020a170906854b00b009ae54c3c627mr3503943ejy.71.1695997940123; Fri, 29 Sep 2023 07:32:20 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id a7-20020a170906670700b0099293cdbc98sm12660105ejp.145.2023.09.29.07.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 07:32:19 -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 v8 13/14] USB: typec: tps6598x: Add power status trace for tps25750 Date: Fri, 29 Sep 2023 10:30:54 -0400 Message-Id: <20230929143055.31360-14-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929143055.31360-1-alkuor@gmail.com> References: <20230929143055.31360-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 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 07:33:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778935831438145614 X-GMAIL-MSGID: 1778935831438145614 From: Abdel Alkuor tps25750 power status register is a subset of tps6598x power status register. Signed-off-by: Abdel Alkuor --- Changes in v8: - Change tps->cb to tps->data Changes in v7: - Add driver name to commit subject Changes in v6: - Add trace power status to tipd data factory Changes in v5: - Incorporating tps25750 into tps6598x driver drivers/usb/typec/tipd/core.c | 8 +++++++- drivers/usb/typec/tipd/tps6598x.h | 19 ++++++++++++++++++ drivers/usb/typec/tipd/trace.h | 33 +++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 9df8da8f5d4b..c7bec4464b8e 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -109,6 +109,7 @@ struct tps6598x; struct tipd_data { irq_handler_t irq_handler; int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); + void (*trace_power_status)(u16 status); }; struct tps6598x { @@ -499,7 +500,9 @@ static bool tps6598x_read_power_status(struct tps6598x *tps) return false; } tps->pwr_status = pwr_status; - trace_tps6598x_power_status(pwr_status); + + if (tps->data->trace_power_status) + tps->data->trace_power_status(pwr_status); return true; } @@ -1170,16 +1173,19 @@ tps25750_register_port(struct tps6598x *tps, struct fwnode_handle *fwnode) static const struct tipd_data cd321x_data = { .irq_handler = cd321x_interrupt, .register_port = tps6598x_register_port, + .trace_power_status = trace_tps6598x_power_status, }; static const struct tipd_data tps6598x_data = { .irq_handler = tps6598x_interrupt, .register_port = tps6598x_register_port, + .trace_power_status = trace_tps6598x_power_status, }; static const struct tipd_data tps25750_data = { .irq_handler = tps25750_interrupt, .register_port = tps25750_register_port, + .trace_power_status = trace_tps25750_power_status, }; static const struct of_device_id tps6598x_of_match[] = { diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index f86b5e96efba..01609bf509e4 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),