From patchwork Wed Sep 16 09:11:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 11779405 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB2386CA for ; Wed, 16 Sep 2020 09:11:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D469A2076C for ; Wed, 16 Sep 2020 09:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726369AbgIPJLI (ORCPT ); Wed, 16 Sep 2020 05:11:08 -0400 Received: from mga03.intel.com ([134.134.136.65]:39051 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726301AbgIPJLG (ORCPT ); Wed, 16 Sep 2020 05:11:06 -0400 IronPort-SDR: qS6thsjieS+zjNrg/0uXMmPqzHgcZdHguLhPqaRpi/MzZmHpHltX/VPifKH7vAPQXRhrz+WsW0 fp1nMqjtBbqQ== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="159480576" X-IronPort-AV: E=Sophos;i="5.76,432,1592895600"; d="scan'208";a="159480576" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2020 02:11:06 -0700 IronPort-SDR: ZBgV511JeX9NWbVETHM/VxW0GN8xHKjt8huK9ozZJxraP6RN3ambesIurPR8B+heBxhqQ6OoK6 4vAc4QeibZkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,432,1592895600"; d="scan'208";a="409490850" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 16 Sep 2020 02:11:04 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: "Mani, Rajmohan" , linux-usb@vger.kernel.org, Randy Dunlap Subject: [PATCH 1/3] usb: typec: intel_pmc_mux: Add dependency on ACPI Date: Wed, 16 Sep 2020 12:11:00 +0300 Message-Id: <20200916091102.27118-2-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916091102.27118-1-heikki.krogerus@linux.intel.com> References: <20200916091102.27118-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Since the driver now needs to find the IOM ACPI node, the driver depends on ACPI. Without the dependency set, the driver will only fail to compile when ACPI is not enabled. Fixes: 43d596e32276 ("usb: typec: intel_pmc_mux: Check the port status before connect") Reported-by: Randy Dunlap Signed-off-by: Heikki Krogerus --- drivers/usb/typec/mux/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/typec/mux/Kconfig b/drivers/usb/typec/mux/Kconfig index a4dbd11f8ee26..edead555835e2 100644 --- a/drivers/usb/typec/mux/Kconfig +++ b/drivers/usb/typec/mux/Kconfig @@ -11,6 +11,7 @@ config TYPEC_MUX_PI3USB30532 config TYPEC_MUX_INTEL_PMC tristate "Intel PMC mux control" + depends on ACPI depends on INTEL_SCU_IPC select USB_ROLE_SWITCH help From patchwork Wed Sep 16 09:11:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 11779407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 95C93112E for ; Wed, 16 Sep 2020 09:11:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78C572076C for ; Wed, 16 Sep 2020 09:11:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726472AbgIPJLL (ORCPT ); Wed, 16 Sep 2020 05:11:11 -0400 Received: from mga03.intel.com ([134.134.136.65]:39051 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgIPJLI (ORCPT ); Wed, 16 Sep 2020 05:11:08 -0400 IronPort-SDR: Iwbjh3qp+yU6U21EfaEBuKB0TQf7SdvgFOH9BgCF+iqCmf5RssKW6y1yY2BUjDLqvlJsiNwtyx Zhuw5t2VUmsQ== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="159480581" X-IronPort-AV: E=Sophos;i="5.76,432,1592895600"; d="scan'208";a="159480581" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2020 02:11:08 -0700 IronPort-SDR: PeC6HDa5Fer+0RHrErTXVw6uJh3jFDwRt2RuOh0EIqqu3hRBB3JCxidthdxDROlEne5kXSixpJ pS1V3yHXLyMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,432,1592895600"; d="scan'208";a="409490861" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 16 Sep 2020 02:11:06 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: "Mani, Rajmohan" , linux-usb@vger.kernel.org, Azhar Shaikh , Utkarsh Patel Subject: [PATCH 2/3] usb: typec: intel_pmc_mux: Pass correct USB Type-C port number to SoC Date: Wed, 16 Sep 2020 12:11:01 +0300 Message-Id: <20200916091102.27118-3-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916091102.27118-1-heikki.krogerus@linux.intel.com> References: <20200916091102.27118-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Azhar Shaikh The SoC expects the USB Type-C ports numbers to be starting with 0. If the port number is passed as it is, the IOM status will not be updated. The IOM port status check fails which will eventually lead to PMC IPC communication failure. Fixes: 43d596e32276 ("usb: typec: intel_pmc_mux: Check the port status before connect") Suggested-by: Utkarsh Patel Signed-off-by: Azhar Shaikh Signed-off-by: Heikki Krogerus --- drivers/usb/typec/mux/intel_pmc_mux.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 307830b374ec7..109c1a796e844 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -148,8 +148,13 @@ struct pmc_usb { static void update_port_status(struct pmc_usb_port *port) { + u8 port_num; + + /* SoC expects the USB Type-C port numbers to start with 0 */ + port_num = port->usb3_port - 1; + port->iom_status = readl(port->pmc->iom_base + IOM_PORT_STATUS_OFFSET + - port->usb3_port * sizeof(u32)); + port_num * sizeof(u32)); } static int sbu_orientation(struct pmc_usb_port *port) From patchwork Wed Sep 16 09:11:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heikki Krogerus X-Patchwork-Id: 11779409 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84B45112E for ; Wed, 16 Sep 2020 09:11:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75C442087D for ; Wed, 16 Sep 2020 09:11:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726425AbgIPJLN (ORCPT ); Wed, 16 Sep 2020 05:11:13 -0400 Received: from mga03.intel.com ([134.134.136.65]:39058 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726301AbgIPJLK (ORCPT ); Wed, 16 Sep 2020 05:11:10 -0400 IronPort-SDR: 1HlwM1Tjpws1Vkefrmt8xz+29fT877rJF6Ioej/iqNpT46OawTpAxbFfGh3ah2mI1dCYVmekZB w8Rlqn38gB8g== X-IronPort-AV: E=McAfee;i="6000,8403,9745"; a="159480583" X-IronPort-AV: E=Sophos;i="5.76,432,1592895600"; d="scan'208";a="159480583" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2020 02:11:09 -0700 IronPort-SDR: bQ7tG2RqPdjMfrzy64ppFfKwxmvqeLlbfGjveRx8J/7J2+RcNqt9/NIj5bKDI/iiqWfU86rVVr b/S9h4KYpCPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,432,1592895600"; d="scan'208";a="409490864" Received: from black.fi.intel.com (HELO black.fi.intel.com.) ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 16 Sep 2020 02:11:08 -0700 From: Heikki Krogerus To: Greg Kroah-Hartman Cc: "Mani, Rajmohan" , linux-usb@vger.kernel.org, Madhusudanarao Amara Subject: [PATCH 3/3] usb: typec: intel_pmc_mux: Handle SCU IPC error conditions Date: Wed, 16 Sep 2020 12:11:02 +0300 Message-Id: <20200916091102.27118-4-heikki.krogerus@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916091102.27118-1-heikki.krogerus@linux.intel.com> References: <20200916091102.27118-1-heikki.krogerus@linux.intel.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Madhusudanarao Amara Check and return if there are errors. The response bits are valid only on no errors. Fixes: b7404a29cd3d ("usb: typec: intel_pmc_mux: Definitions for response status bits") Signed-off-by: Madhusudanarao Amara Signed-off-by: Heikki Krogerus --- drivers/usb/typec/mux/intel_pmc_mux.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c index 109c1a796e844..d7f63b74c6b14 100644 --- a/drivers/usb/typec/mux/intel_pmc_mux.c +++ b/drivers/usb/typec/mux/intel_pmc_mux.c @@ -176,13 +176,19 @@ static int hsl_orientation(struct pmc_usb_port *port) static int pmc_usb_command(struct pmc_usb_port *port, u8 *msg, u32 len) { u8 response[4]; + int ret; /* * Error bit will always be 0 with the USBC command. - * Status can be checked from the response message. + * Status can be checked from the response message if the + * function intel_scu_ipc_dev_command succeeds. */ - intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg, len, - response, sizeof(response)); + ret = intel_scu_ipc_dev_command(port->pmc->ipc, PMC_USBC_CMD, 0, msg, + len, response, sizeof(response)); + + if (ret) + return ret; + if (response[2] & PMC_USB_RESP_STATUS_FAILURE) { if (response[2] & PMC_USB_RESP_STATUS_FATAL) return -EIO;