From patchwork Sat Sep 23 07:39:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 143898 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp165142vqu; Sat, 23 Sep 2023 06:05:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGk71956WtOudSSiMh6IB6uXdeOSLUaxI8EzJeJM5Rri0pUFhacQk63yEO6IhGjz/GnRA6y X-Received: by 2002:a05:6a20:8f06:b0:145:47af:57d8 with SMTP id b6-20020a056a208f0600b0014547af57d8mr2865672pzk.2.1695474334378; Sat, 23 Sep 2023 06:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695474334; cv=none; d=google.com; s=arc-20160816; b=C/o4knZ7M8VDdcDPF/mjShNsG3p5/8HQl0CzbYZ++RPRbbMbuBUtr3A42qyKMRWw6X BpQnfFr2nfzf/NGd0DTwa5Ztl17zWnJvRtRftY8h7OUhiLOkxxoQGp6usNjW0DTuoyVf piaonNwTD5fG8Qkn76toUjpJHSUIkkVKVnEFb6mmW6Ygt2d6G/Pe4vhjbkLK6fnwSAZL ujhHo5Zu2ZsO3FbEd2ekmToG0IkNRaXaLY+q1bUJ8t9zW+hMkyfct28iphhmfLW+g/Ej nQoF4S8EkJkLbSUI+/LzAhG9GKTghI6Y1kR/uQe07nazJ66QjJs0AwufYlv5I7Fpwv6W zy4w== 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=VFRprVF8T6twSRScySzSwWxXFkNe84Dxw0ZjvDU4rH8=; fh=UDTK5wkdLkKA1RzU/KF6Y0FI+lzcfubocuuGO7tFl2w=; b=qx7gyLmFUS8/kRH5XkQlF2ipBkwRDTJb9EFKeqrNgNigqxPRIMdhbLGAF8XLrRDbsI LMq9Au9c9UoEomaKRsCfdjgo8Kc0+O1eP6dEVzw4o1uqtCN3+AC7qzse3oQ+67+Dwd6/ Ak2Y+WEQCyXjfyQbYdLRYpJ2chvNpgqLZ3okC1o87OPRs6FuAAlNNiAzSozdqiKzCx2X 9I9asfWYhff0kGm9ICEfDB1S2yyxSgzRQopSNGad+2XtJUSi2A1nVfyB97Uxcv8smlsd 4UUCFJG0M2z2jIoNPxmcZBu4Z8liPpFXBOi+oTlrcGmqhyugIg5Z0Jf4RMA00V43vmQ1 lE1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XH9XUUVR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id cq23-20020a056a00331700b0068e3b121545si5917836pfb.58.2023.09.23.06.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 06:05:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XH9XUUVR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 CDE41818C78E; Sat, 23 Sep 2023 00:42:05 -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 S230270AbjIWHlw (ORCPT + 29 others); Sat, 23 Sep 2023 03:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbjIWHlk (ORCPT ); Sat, 23 Sep 2023 03:41:40 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13181E5E; Sat, 23 Sep 2023 00:40:58 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-307d20548adso2852253f8f.0; Sat, 23 Sep 2023 00:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695454857; x=1696059657; 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=VFRprVF8T6twSRScySzSwWxXFkNe84Dxw0ZjvDU4rH8=; b=XH9XUUVRxcFpWMUQGiZLjVCumR8xtRY0RJ6pmiEyU2taSxAckChJO2tOMn7GxB9tPH sDNaaldungjOaLiSNuB4xpRsS3btdAfaQcCMPs/6UZeV4YcFLPSORtVZcVS3uILeMadK nYnFcZokQqgWI2qYKje/4iGAFYtgII+W0AslZdWEEpMI/mogSJH3VLtqp4AVQ/qZ4TXQ GlY2HKmdc4G7ke6UUYOCYHlArKEEJSs+L09ljoRAG4ogGVhogTMSUy+2s57u+OgHDA1P /clCjdc66KPXGm11I+vmuy/QdgN8pV8Ku8giAWnqFzwIEXXX7q6mCzpkC3SJ4oSMtddk Hl4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695454857; x=1696059657; 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=VFRprVF8T6twSRScySzSwWxXFkNe84Dxw0ZjvDU4rH8=; b=BzRkas67prZMib2+uC+S6WLtUTvwRvUD6qcHskPbNNC3BZcwwbOwKCXP4WyRuR1fYo Rag3ks8zx1a1v1vYEvh0Pjs+8SV7MjbtCP/9cJJO2wVhzrijQsXmTQ0gRNLDatkMRMXs iuPLv7Xbf1OfjaKqGUH60h14sfUr8i5Xatv0J6ILJVDsHKFUXQ+BLNWga8OHMnqQeCYj VX6ysCFY02p1osyedy731NmIIffs9VwQTDPh/DmysRdCovEIwCc/z42NxRMhItcasHoh EvQ+3RXz0SvvMRCZpfxB/Z8u63nMggVoZD+0nMR3VrQsQ8n73Zkf5PQhcAYdEFp+6Fc/ GgHA== X-Gm-Message-State: AOJu0YzGWUQvZ8UjOzDJxQGPz7/uVEsFAbgnRtcXvJTS5jOpObEJpY2T H9dSZ1RLIV/PQy8FBG2+5SN7y3Q0anmHUpO+myQ= X-Received: by 2002:a5d:4fc9:0:b0:320:7272:8fbe with SMTP id h9-20020a5d4fc9000000b0032072728fbemr1765631wrw.17.1695454857228; Sat, 23 Sep 2023 00:40:57 -0700 (PDT) Received: from primary.. ([213.139.62.222]) by smtp.gmail.com with ESMTPSA id k6-20020adfe3c6000000b003196e992567sm6236955wrm.115.2023.09.23.00.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 00:40:56 -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, linux-kernel@vger.kernel.org, conor+dt@kernel.org, ryan.eleceng@gmail.com, Abdel Alkuor Subject: [PATCH v6 13/14] USB: typec: Add power status trace for tps25750 Date: Sat, 23 Sep 2023 03:39:58 -0400 Message-Id: <20230923073959.86660-14-alkuor@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923073959.86660-1-alkuor@gmail.com> References: <20230923073959.86660-1-alkuor@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=3.0 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_SBL_CSS, 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 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]); Sat, 23 Sep 2023 00:42:05 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777833695914063298 X-GMAIL-MSGID: 1777833695914063298 From: Abdel Alkuor tps25750 power status register is a subset of tps6598x power status register. Signed-off-by: Abdel Alkuor --- 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 a1acf682bde0..e8190f1f57ad 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -111,6 +111,7 @@ struct tipd_data { int (*clear_events)(struct tps6598x *tps, void *events); int (*register_port)(struct tps6598x *tps, struct fwnode_handle *node); void (*trace_irq)(void *events); + void (*trace_power_status)(u16 status); }; struct tps6598x { @@ -501,7 +502,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->cb.trace_power_status) + tps->cb.trace_power_status(pwr_status); return true; } @@ -1146,6 +1149,7 @@ 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 = { @@ -1154,6 +1158,7 @@ static const struct tipd_data tps6598x_data = { .clear_events = tps6598x_clear_events, .register_port = tps6598x_register_port, .trace_irq = tps6598x_trace_irq, + .trace_power_status = trace_tps6598x_power_status, }; static const struct tipd_data tps25750_data = { @@ -1162,6 +1167,7 @@ static const struct tipd_data tps25750_data = { .clear_events = tps25750_clear_events, .register_port = tps25750_register_port, .trace_irq = tps25750_trace_irq, + .trace_power_status = trace_tps25750_power_status, }; static int tps6598x_probe(struct i2c_client *client) 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),