From patchwork Thu Mar 30 10:48:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Khandelwal X-Patchwork-Id: 77109 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1052736vqo; Thu, 30 Mar 2023 04:27:19 -0700 (PDT) X-Google-Smtp-Source: AKy350Y6BD2o/diNW9jek6Ifz7sidLYSLeKLb30/i9Q8+jgOm/mlcpEW4OwvltmvoklQlKHQQtZC X-Received: by 2002:a17:907:7b8d:b0:946:c265:7931 with SMTP id ne13-20020a1709077b8d00b00946c2657931mr13024073ejc.59.1680175638944; Thu, 30 Mar 2023 04:27:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680175638; cv=none; d=google.com; s=arc-20160816; b=WgV3ms1G6AV3Ugt4zsewh19lyqOf9376NpykbqV9w0ItFghDYLM/das/lvRrcgtF1k 0kPFc9GWbc7ITTh/+gCuGRJBSXUB8xx/2NedF8iW7/L5lZg5UzKvGvnwC6Y/vyvTZ+Xt oc3qtvCFNTsya/qmM6WeRloP1objgQfXf2aQbkoL66oPOwXYbMQqek/FAwd5AbKlUXCD fwHpMrO90V2mMCxoV3Pof/FwPatdd0wE9Ie3MULpmXaf+xbnQdTttO86lXM+e6RNikFQ 2HhJbwehsOfDWB4OUEYRDHQEmxfIHQ/NkYnzqv2A9+YoUVMtyq4EixHnHRkKdZXzT2g5 et5Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=QntkwyvpiTiQVZf7WFfyAD7G7qW76JaBvGJTdEkY3nI=; b=0F75Yu9d+1qzkGnmk4Cd81l+co7It5bb7PfVUtlNy66Yt0YQGa/FLgX92WQ3Bizas3 Nc5Xg0QKOSMMQyv//2Ev5Wo2P4a60rxoHUVk8UQe57efWxdGJbuhxGT/OFQ0UXH3LyzG v0QrEvF1fkL1EIEJbln6V0XvdQdV76OJXwV8YAEMN3wZKoCoUTGbUuSLyxRpllvSAboV sWzC4/sjkXN4PCnZKBmZ2a5wCRU3e+eKvdaDTdmW4zageiK41TyKi4qg/2i13SWq3CO4 mloFDPAmj6YiaYIPGx2+n+SC+p5Bgud2rP9sHYIAKDwHs8E/mSwcVLPxRIDJd1myUNBr xTBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jExnIkiN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m23-20020a1709066d1700b0092627d03e39si30803662ejr.657.2023.03.30.04.26.54; Thu, 30 Mar 2023 04:27:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jExnIkiN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbjC3KuO (ORCPT + 99 others); Thu, 30 Mar 2023 06:50:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230423AbjC3Ktx (ORCPT ); Thu, 30 Mar 2023 06:49:53 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EB8D93C0; Thu, 30 Mar 2023 03:49:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680173356; x=1711709356; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Pg3OR5f2IuuZ6wVtG+jyKyGmKCMM/ZwdMBOOfAhqvnU=; b=jExnIkiNm1JhEinKnS9Fece3xk+R+DV6vHfNF6mt8g2/YLtaxv6+lBv5 BUHxRRDDreHJ1jdHNgAyhp08MM6DGJA3RLeEI72ucXfuhYLa34u9A+88+ dnagWW1nyiyqGv4UH/opxWV7LQl3u8dqP8UFvhyUDs29I88EiaPfObv6W 8pKwdBybenMtpb99/dXaDm9+MrIqx4X/IUyrgelPLRaqIi+26V63FouML sfAZwEi6h/HHOUJmUAxZax8J5XVfblw83TVpeccqgIBf7rMScP0DXGtAI C6valaRQ1fhpbzCCG/OuRGe+jeCkoU4xGNQOWipqO6ZNhIiY5t3CmWS2g w==; X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="406097336" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="406097336" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 03:49:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="1014391203" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="1014391203" Received: from unknown (HELO rajath-NUC10i7FNH..) ([10.223.165.88]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 03:49:13 -0700 From: Rajat Khandelwal To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Rajat Khandelwal Subject: [PATCH] usb: typec: intel_pmc_mux: Expose IOM port status to debugfs Date: Thu, 30 Mar 2023 16:18:21 +0530 Message-Id: <20230330104821.773053-1-rajat.khandelwal@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761790780556595044?= X-GMAIL-MSGID: =?utf-8?q?1761791850390503794?= IOM status has a crucial role during debugging to check the current state of the type-C port. There are ways to fetch the status, but all those require the IOM port status offset, which could change with platform. Make a debugfs directory for intel_pmc_mux and expose the status under it per port basis. Signed-off-by: Rajat Khandelwal Reviewed-by: Heikki Krogerus --- drivers/usb/typec/mux/intel_pmc_mux.c | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 34e4188a40ff..c99d20888f5d 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -145,6 +146,8 @@ struct pmc_usb { u32 iom_port_status_offset; }; +static struct dentry *pmc_mux_debugfs_root; + static void update_port_status(struct pmc_usb_port *port) { u8 port_num; @@ -639,6 +642,39 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc) return 0; } +static int port_iom_status_show(struct seq_file *s, void *unused) +{ + struct pmc_usb_port *port = s->private; + + update_port_status(port); + seq_printf(s, "0x%08x\n", port->iom_status); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(port_iom_status); + +static void pmc_mux_port_debugfs_init(struct pmc_usb_port *port) +{ + struct dentry *debugfs_dir; + char name[6]; + + snprintf(name, sizeof(name), "port%d", port->usb3_port - 1); + + debugfs_dir = debugfs_create_dir(name, pmc_mux_debugfs_root); + debugfs_create_file("iom_status", 0400, debugfs_dir, port, + &port_iom_status_fops); +} + +static void pmc_mux_debugfs_init(void) +{ + pmc_mux_debugfs_root = debugfs_create_dir("intel_pmc_mux", NULL); +} + +static void pmc_mux_debugfs_exit(void) +{ + debugfs_remove_recursive(pmc_mux_debugfs_root); +} + static int pmc_usb_probe(struct platform_device *pdev) { struct fwnode_handle *fwnode = NULL; @@ -674,6 +710,8 @@ static int pmc_usb_probe(struct platform_device *pdev) if (ret) return ret; + pmc_mux_debugfs_init(); + /* * For every physical USB connector (USB2 and USB3 combo) there is a * child ACPI device node under the PMC mux ACPI device object. @@ -688,6 +726,8 @@ static int pmc_usb_probe(struct platform_device *pdev) fwnode_handle_put(fwnode); goto err_remove_ports; } + + pmc_mux_port_debugfs_init(&pmc->port[i]); } platform_set_drvdata(pdev, pmc); @@ -703,6 +743,8 @@ static int pmc_usb_probe(struct platform_device *pdev) acpi_dev_put(pmc->iom_adev); + pmc_mux_debugfs_exit(); + return ret; } @@ -719,6 +761,8 @@ static int pmc_usb_remove(struct platform_device *pdev) acpi_dev_put(pmc->iom_adev); + pmc_mux_debugfs_exit(); + return 0; }