From patchwork Wed Sep 27 17:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abdel Alkuor X-Patchwork-Id: 145544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2842936vqu; Wed, 27 Sep 2023 12:09:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKD3LIAKv79DXyPYnbgtNNLJn6Qsbchp999vjHpMF4an1CJNpjM3a4eo6w4Y88Nt/KMm0B X-Received: by 2002:a17:902:ab54:b0:1c6:2866:5aeb with SMTP id ij20-20020a170902ab5400b001c628665aebmr8083040plb.9.1695841771463; Wed, 27 Sep 2023 12:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695841771; cv=none; d=google.com; s=arc-20160816; b=tZwTY3+XNS783WoHZL9ffnBS3EjWcrvpFP83xp5EL14vtaWbHlRBLqysaL47NQzgCm RNIRBcxgiSeLu3menAASe4f3u/3QFgejIVPnYZpliUlbSXwWhu3roxVJ7XAm1+fjs1oA kH+6klev1217qI1+4a1oFuVDuVUwFuX1yx1us2e5Ynrh8DwZifAMjXYy550isJ2ykwTy WxLlzyWkOw4BuqrbeCTpMCA6gmv6L+MrEdyjR6g/sbceR0IVyRCyqpmwCf43lYaii8ac uvYZmV2Bb1YTZx5KF+HFowtPrvmO4LbLD/ijkoQ+7gKwPOUWegEQIli99eJjiAoaTOlw YpHQ== 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=voe1AQlyJ66tuR3HAig5V+hgG3HWnfF9e7gj5LZdSfU=; fh=NDkcCmflgZsGSiSjskszThji4SYIrQ1hJIxt3Zy9sPE=; b=n1ddyKlJepfcUbAACkpxtg3jaeluoWWxZqr+bA5LRPUtuleVzNN1xYjLP6TT/1jvUm DIwbmXh8Hp0KQu2O1eGVKlPNZPFgCjmh6l4JZhFipGkAOI2Ziz7PBCqjjMX5yQ7pIFi1 1kp3VS4hvp8/5DGpBuA4BAkOlrWhJFDWuz0XkHmpkqlf6cqX9viJsB0KLPdQkUdwsl1a bmhKt3gD/w/47fdSss6We6euJCYRQvQbjPZ4xrzVL/+AXH1Cmm2HEBrkoeUlt7PhK/k/ Q8niSAFiVmHjTS6BHKTfqqtxd9HUUNcjwNzPufDmkZL1j/gBrb8ds7TUEzrCcnY/mTXV 5eFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a1FlIBvM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x12-20020a1709028ecc00b001b87bd2f7b0si15217051plo.402.2023.09.27.12.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:09:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=a1FlIBvM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 174B280B6C2A; Wed, 27 Sep 2023 10:58:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229847AbjI0R6a (ORCPT + 20 others); Wed, 27 Sep 2023 13:58:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229842AbjI0R6J (ORCPT ); Wed, 27 Sep 2023 13:58:09 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCBB11B7; Wed, 27 Sep 2023 10:57:54 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-98377c5d53eso1443260366b.0; Wed, 27 Sep 2023 10:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695837473; x=1696442273; 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=voe1AQlyJ66tuR3HAig5V+hgG3HWnfF9e7gj5LZdSfU=; b=a1FlIBvM/6x5sT3UzeDHPHDXv3f8hkhuaTz1C6YKhY6SzdRTVXHfAQZ/mnZY82vQ29 t6ev6qo6H5kmjxunJNoMS1xsJoRwAFf29uEfCd562rAHGp2hs2YVkhiefi9Z+DgKwvFT H0TAH4w3Z6bTdfsEZhKfhCuZ/OW/rh8Tsx+gCCAqKVpf/Kbt+RvGsEP6GOPNX4CuFj97 NOFGEsgd1T+a1ez1Yfn/ypfASyqAx4uejtAZgA8UOI72/M5aIbTTIazn0/NCvKx15lTc M5s+r1k6TTOq7r7anI2374fIUrs2wQt5n82ATForzCFkfg6LfQeGT82+yuFDgH8oAQv2 YdVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695837473; x=1696442273; 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=voe1AQlyJ66tuR3HAig5V+hgG3HWnfF9e7gj5LZdSfU=; b=BZenB/wKrhv0CcF6bWZPVCifHEXWhixN/xPIXNuB9kLMhZkgldfULABHgXGSM7ck0z 9ICoPOaeBl2fYjH4lrfwWPXKPrjQBHQJgVJGqX/2TAqbVmHLmDXaDQFPTR3XdBd4nRR5 vH9+LEvrPEoA3lIx/y4j6goHZehcGvzskbMVgtZK64PHeQJhWZnaGt7cMnHLIy8JjgDG 5BJzjMMg3z2o0IuEpWeb8THRASM8EB+n8/ecLQBV7210KTNscMF3f+TemffGsQJpnW+a 1KX4KsPl+701lNn9F58+FaIpG07L2V4mEE7/iC/VlFADCMA/b5UKggi0i5EX1W8wrp6u DSgw== X-Gm-Message-State: AOJu0Yw2eoymZSxgit1rTDQx9DCi8ue5XUD8wQgYXSkY6Ztfgdf6h0BZ zZ175pIFQf+TNa92bQr+Kyc= X-Received: by 2002:a17:907:75d6:b0:99e:f3b:2f78 with SMTP id jl22-20020a17090775d600b0099e0f3b2f78mr2249383ejc.67.1695837473153; Wed, 27 Sep 2023 10:57:53 -0700 (PDT) Received: from primary.. ([212.34.12.50]) by smtp.gmail.com with ESMTPSA id d4-20020a170906370400b0099bd8c1f67esm9654593ejc.109.2023.09.27.10.57.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:57:52 -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 13/14] USB: typec: tps6598x: Add power status trace for tps25750 Date: Wed, 27 Sep 2023 13:53:47 -0400 Message-Id: <20230927175348.18041-14-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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:58:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778218980983912371 X-GMAIL-MSGID: 1778218980983912371 From: Abdel Alkuor tps25750 power status register is a subset of tps6598x power status register. Signed-off-by: Abdel Alkuor --- 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 deb2b756fec4..c9c30de6e77a 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -108,6 +108,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 { @@ -498,7 +499,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; } @@ -1169,16 +1172,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 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),