From patchwork Thu Apr 1 21:21:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12179589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3539C433ED for ; Thu, 1 Apr 2021 21:29:25 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23890610FB for ; Thu, 1 Apr 2021 21:29:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23890610FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wkafC8+zEKSbSil+EC1whGSWjTG3vWEF7fxkmEl+SHc=; b=AdiF1r6XDyyHHsfTud4ZVrlR6t lQbhELNgMkPhtVzDgrsGO6r1vjF6VhsOpRE70lQUAmAxosqJ53twtBnT7khtjNhECma3R7Nmm/Xml +LU5NPNt7Ebp0g1LSQx8Dm9jaoglIvzJs8Hq2K0xLFR0Cdz1tIxDki9p/68BqlEL/Xs63nK8hfk+i WDyvI7P5s+OWgbPu8uAlBXC93MVGw9AsgC4XR1n7KuqziikcJVAz+d+h0QuD/mfaAqYu8Vmd0j5te yP9ZM3HlMkgE/B4BWohPwFKfplv/vWlD9abxCgIgeb/S3OZ+wxwiKMGzKmrOSBc4KndNcQW2UaaLj hkdZ3rog==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lS4qA-00B3Rl-DA; Thu, 01 Apr 2021 21:26:58 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lS4lI-00B35K-SD; Thu, 01 Apr 2021 21:22:51 +0000 Received: by mail-pg1-x529.google.com with SMTP id p12so65758pgj.10; Thu, 01 Apr 2021 14:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7XSm6/qzn9duNJgtAGMhBBSTeeaC2tU96ijTiVyfrw0=; b=FVZIRLrnc8G1Hy9rQgixadd2ErSk6SMttyrJQOLWi/5XMq0Cg0ILEkiaulBE+VmFta Fk/v9tsh1o+JslU3jZLly0kNadXbLPSOEuhPDchDCfF+8S5gru2p8WWxbqKKCL8Gn+UN 7FTawmIMsHV9y6QvGzuoqMw+dmO3NqCLTSZNV46hrnIU7GNJRRiaetP8xcmF7yWVCD6T BtD9+rKJJfw6+FGl6YLL7PGUiU4bxKuj6k6AwDo4c69CS6Q1oqvQCG69vvDwrXFUKHVX 9EVIsc5TM7AhBkKvC7+IudUmfss4KwzGldZ4MYRIQXDY2Hjs9e/xfVzPRoH8Sla8lgzy 6cxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7XSm6/qzn9duNJgtAGMhBBSTeeaC2tU96ijTiVyfrw0=; b=XGuLp/jthk/w2/95ygmvnV8cKpU4GNKmC/OowaqJZ7Ghafi/h2WQyZBJJV+sQkC4+3 /wQxSXcxItFhXietbPaynUp+YIWfcusdtgSTMZfhT8RVZg4tObN4UxWi0G2iytgoCvCP r435wtYK3e4Lo7hRKEukY+S5trzsvXB+ySCsJkdsYXfHWk6qXsLlexR3Y0lQ77OEm7GW lEXb+kCsn2s0hIrX/WkHU160pYsKOenstkf4dCVQ7+KPzaXDhE7yiCgrSNaGeVWTieUX lH2DpVCWpqaZAWmb55TBysxlmg2bUQvg07+uX8vInOtwsOm9CLChipPIoyjjEtZMDGVK 1JwQ== X-Gm-Message-State: AOAM533iOp8fKLW5x8qkrP261UemQQWJLwcPy/mejTqsyVVl7aFYJnrE XO+VfPI30ITTculKPOKi9MU= X-Google-Smtp-Source: ABdhPJyfsLCcva5kpJAf0m0l/d1Xo7b+YAYAci8o03yqPZmVUlbZ1wQvQH2IXG+wFsRbemPv1EzAqw== X-Received: by 2002:a63:78cc:: with SMTP id t195mr9011398pgc.196.1617312115571; Thu, 01 Apr 2021 14:21:55 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id q5sm5926707pfk.219.2021.04.01.14.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 14:21:55 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , Jim Quinlan , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 1/6] PCI: brcmstb: Check return value of clk_prepare_enable() Date: Thu, 1 Apr 2021 17:21:41 -0400 Message-Id: <20210401212148.47033-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210401212148.47033-1-jim2101024@gmail.com> References: <20210401212148.47033-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_222249_681785_9D8C65CA X-CRM114-Status: GOOD ( 12.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Check for failure of clk_prepare_enable() on device resume. Signed-off-by: Jim Quinlan Acked-by: Florian Fainelli Fixes: 8195b7417018 ("PCI: brcmstb: Add suspend and resume pm_ops") --- drivers/pci/controller/pcie-brcmstb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index e330e6811f0b..4ce1f3a60574 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1161,7 +1161,9 @@ static int brcm_pcie_resume(struct device *dev) int ret; base = pcie->base; - clk_prepare_enable(pcie->clk); + ret = clk_prepare_enable(pcie->clk); + if (ret) + return ret; ret = brcm_phy_start(pcie); if (ret) From patchwork Thu Apr 1 21:21:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12179607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C0F8C433B4 for ; Thu, 1 Apr 2021 21:33:40 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 87443610F7 for ; Thu, 1 Apr 2021 21:33:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87443610F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3sVP3rgP53xgnZmeE0lO3GQXbU93wG6xfV+E7oX+0uM=; b=fXeyeTMKlhL3pZuo0a1V4X58m4 1cNlZiDjKH6/aOpWAbPHSEFl0/7Ii4bKkxl6Kgcrsqq95GMTKOiJLKJ9Oxx7manaCkXVKUpQF8o9B SDiQmgI0rjxheAHuPUVPlfXdRpYqQK+NaDpdPzxlqnAUHMyw+ISj17oLwcdQb9r7UMjNnwBQqGSa+ 2Qj3B6pfC6b6b6g3VNz0aQxR74Yic1Ap4yabufkROSRi6jmngqbZiwrUbkUrRiv0v0dw7/6gktYAJ QTANNsxPXh/Isk+v6WlYwtrSrCx9FJc2Yp8F/a324pyEophSVSGZ3rb5GD2O7uTC4+4WJkAzszgPJ eW6D5hEw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lS4sk-00B44J-CU; Thu, 01 Apr 2021 21:29:38 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lS4lL-00B35N-DM; Thu, 01 Apr 2021 21:22:54 +0000 Received: by mail-pg1-x52f.google.com with SMTP id f3so2416808pgv.0; Thu, 01 Apr 2021 14:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OE1GPy2uIOsC5BPQ8KNKWKnU0bskwsFqEC7/aDazAJ8=; b=d+F70zzCcRNcUn6JgGk0dSebsptHa6texPhBSXUtvlhJNc9/RqncITqT/RF4S6A5wh 1ORnJwgArYHIZYIo0oGV9o1b6gtHa5+/hHzyhmn4f9tUaXQTtda2eJxz1EHPkbzGT6HK D+r5sp2WJGG5yh4IL3Gxhpo7EsxQmFxqANDNcZN7NGQq5aun+pduy7sWbcb1VR/CACfW GsOSZMCt3eOPHuM5VPYXuB5nomnJ0XPVhQzguRUvLLI43TDhxt9Jr6m+02X3RE2AF4OE x+6mWuMY7B0vGvCKDb2qOdAIKXCfBQAFXVPaEgl1L301MvyevGDK/ea2Br23UR3EPId9 Kguw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OE1GPy2uIOsC5BPQ8KNKWKnU0bskwsFqEC7/aDazAJ8=; b=L+Bk/RKjEFC1dUNDDjOO9qh3b5JP2ZvnEwvju5RnVj2U+CMr5x+JQcPVfSARlR5SSP yKC99Zl21yCf6+2WW9EcMaq1leWHEBqTFvJ9acoNacGT47FeV6867SL/y3cP9IhB+a7N IKvetmHWGf63O4Y1e1J1bp0R+fYOlXIujcosuYNi6Jd0lkjHqcBIALjQtAZFJc+C2lAK bnq61lwPQmRbM3uJ209PpML6azpB4mxCtG4tuI7YIxNQ9Prf+WBRFcWaXx53wQ9Eva2J TVuqmhYgO6KcsfLmpBNeQosEccQvRL39RKhxe5eZrYKIwldMsj3NN4OOljIDKmgklfHM w74w== X-Gm-Message-State: AOAM532gKiURmB0672sMpAcrHgzB4/Xghr9b/Xj25T/q+e9I5P+2da0h iOCgRYdsVBYbImL5hTzBUoE= X-Google-Smtp-Source: ABdhPJxIQxjnKwL2oIoNRT4BO7QMOaNJKDHKvahHfGc+telOcRy17DZ4zmM6/qQz0RXjvNGz8uIUag== X-Received: by 2002:a62:5a83:0:b029:222:c9de:5c65 with SMTP id o125-20020a625a830000b0290222c9de5c65mr9304697pfb.23.1617312117974; Thu, 01 Apr 2021 14:21:57 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id q5sm5926707pfk.219.2021.04.01.14.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 14:21:57 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Bjorn Helgaas , Rob Herring , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 2/6] dt-bindings: PCI: Add bindings for Brcmstb endpoint device voltage regulators Date: Thu, 1 Apr 2021 17:21:42 -0400 Message-Id: <20210401212148.47033-3-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210401212148.47033-1-jim2101024@gmail.com> References: <20210401212148.47033-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_222249_691431_33F2FA34 X-CRM114-Status: GOOD ( 11.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Similar to the regulator bindings found in "rockchip-pcie-host.txt", this allows optional regulators to be attached and controlled by the PCIe RC driver. That being said, this driver searches in the DT subnode (the EP node, eg pci@0,0) for the regulator property. The use of a regulator property in the pcie EP subnode such as "vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml file at https://github.com/devicetree-org/dt-schema/pull/54 Signed-off-by: Jim Quinlan --- Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index f90557f6deb8..f2caa5b3b281 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -64,6 +64,9 @@ properties: aspm-no-l0s: true + vpcie12v-supply: true + vpcie3v3-supply: true + brcm,scb-sizes: description: u64 giving the 64bit PCIe memory viewport size of a memory controller. There may be up to @@ -156,5 +159,6 @@ examples: <0x42000000 0x1 0x80000000 0x3 0x00000000 0x0 0x80000000>; brcm,enable-ssc; brcm,scb-sizes = <0x0000000080000000 0x0000000080000000>; + vpcie12v-supply = <&vreg12>; }; }; From patchwork Thu Apr 1 21:21:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12179593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16411C433ED for ; Thu, 1 Apr 2021 21:30:19 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A9BDE61105 for ; Thu, 1 Apr 2021 21:30:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9BDE61105 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=N5CAbR/Ije/yf7QswIUw8BkEg7/W8KMrMN4BoGoZ79g=; b=BR0A9DZkmP2zgphCDhIYRkZOlI wzNGWsBD302aFRNDaBvntbQMyU8NcnH5cwqSlJo6JbBxMMk6mlaUinUtHNh1nWOeScaEWgDf5P9tk ktbLSVxyoQyjQI6hCBtZTrG0KhJVCJqg1qvZ7wp7sM2+z3IPf+YGnSJlxh/hymUCbBFIFDjF4BIOg JMGumf/wvy4X9hl5+KUWBCqTt0u5uqO3uuqzOXXvvhVaK4wgfX6tnjjln0bW3tMY6n3nLjVSdwOZS c1cVFNiDE8PmeYBruN9VtrTmlxbMRlEoOZP75pruzh3Q/Wj5J7qxBfbjxC/iw04suQoCeQNsyU5EG w2VCPgYQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lS4rn-00B3hx-AZ; Thu, 01 Apr 2021 21:28:39 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lS4lN-00B35Q-OP; Thu, 01 Apr 2021 21:22:53 +0000 Received: by mail-pf1-x435.google.com with SMTP id s11so2356723pfm.1; Thu, 01 Apr 2021 14:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8VnZEjn3FMdva8ipBLV073OJdSwGTGi+Qmw1GQKtSJk=; b=rqKnVniAJqaznlfyFZnoH63rR6cVFwpgQ1QdlN2GJJEUGkszt41VRZqO4rpJeSuS5W ulfVwYfHvp8XURH5eqZdXRk3HjvyAmp8qq3bJ134fXnzYTTtscawCWC+iF+uCpSQq89a 7bW6bFpsWlfi63s1qgjE0H7ml3Y/BX9AFUA/0lQa0EGHhXKLZp8OCrL8X/Fvj+OpRhay d8f4T1l7t7sDxVP0p4nHlV1Vhc3gElYaA9PN8KVvin04fuQM3P6l9OTxU70AZWusuLfE 7/3vfT1uuQBVsMGt7v8BuPnU1bO9Rg9jgyDouparceLhXtuvpk6SUpfvnPtYgLP2LB0t MpVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8VnZEjn3FMdva8ipBLV073OJdSwGTGi+Qmw1GQKtSJk=; b=nJ2AjuI9mBcRgMJLZl4PgdNgjdaSbaoRA2znlgibM2qUI5r+crmEWSgjL76xz0oXV4 nLGqaFO0plRpWPl15gLwQ5C3ZqSYfS/6mzZhM6uacg29dSx82II2qHqTZST2u13jHT1P ywFbgXYG+Bv/8320mYDUrPX1xnl5+0bg+ngmoUveM4TyBwClC9Z0GTf/QE9/UPUXo1I/ dnkOM53VoYCORslTqQCEV1XSxQnaXIvJAXmgcTz6tvNIJ9q6f/NZnTbZjPnUdVg7k9Iv XiRoL8TXXG3/R6Yz2tZNWF8UPgq+dGFerLeqfAhvYjAdq1pNImP4R4kbtslB05/tsKQo qIZg== X-Gm-Message-State: AOAM532MF3SJeRM71RbjPqlvbFvub3wLueGeWjTDhI9QtOo9XxHVuMAv pcY+BvMnPSTvukHJZwEi7y7fcMdnAvM= X-Google-Smtp-Source: ABdhPJwgmmrtZmxhTHaTcSUUdrBWSClYS0FE/GSnCuAlxz39mj1gVVrWBKV+9SHfDMvk4TEKO0KzZQ== X-Received: by 2002:a05:6a00:b86:b029:207:8ac9:85de with SMTP id g6-20020a056a000b86b02902078ac985demr9011916pfj.66.1617312120361; Thu, 01 Apr 2021 14:22:00 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id q5sm5926707pfk.219.2021.04.01.14.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 14:22:00 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 3/6] PCI: brcmstb: Add control of slot0 device voltage regulators Date: Thu, 1 Apr 2021 17:21:43 -0400 Message-Id: <20210401212148.47033-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210401212148.47033-1-jim2101024@gmail.com> References: <20210401212148.47033-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_222249_681783_8579615F X-CRM114-Status: GOOD ( 23.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This Broadcom STB has one port and connects directly to one device, be it a switch or an endpoint. We want to be able to turn on/off any regulators for that device. Control of regulators is needed because of the chicken-and-egg situation: although the regulator is "owned" by the device and would be best handled by its driver, the device cannot be discovered and probed unless its regulator is already turned on. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 83 +++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 4ce1f3a60574..1b0de0c7da60 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -169,6 +170,7 @@ #define SSC_STATUS_SSC_MASK 0x400 #define SSC_STATUS_PLL_LOCK_MASK 0x800 #define PCIE_BRCM_MAX_MEMC 3 +#define PCIE_BRCM_MAX_EP_REGULATORS 4 #define IDX_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_INDEX]) #define DATA_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_DATA]) @@ -192,6 +194,11 @@ static inline void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val); +static const char * const supplies[] = { + "vpcie12v-supply", + "vpcie3v3-supply", +}; + enum { RGR1_SW_INIT_1, EXT_CFG_INDEX, @@ -295,8 +302,27 @@ struct brcm_pcie { u32 hw_rev; void (*perst_set)(struct brcm_pcie *pcie, u32 val); void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); + struct regulator_bulk_data supplies[PCIE_BRCM_MAX_EP_REGULATORS]; + unsigned int num_supplies; }; +static int brcm_set_regulators(struct brcm_pcie *pcie, bool on) +{ + struct device *dev = pcie->dev; + int ret; + + if (!pcie->num_supplies) + return 0; + if (on) + ret = regulator_bulk_enable(pcie->num_supplies, pcie->supplies); + else + ret = regulator_bulk_disable(pcie->num_supplies, pcie->supplies); + if (ret) + dev_err(dev, "failed to %s EP regulators\n", + on ? "enable" : "disable"); + return ret; +} + /* * This is to convert the size of the inbound "BAR" region to the * non-linear values of PCIE_X_MISC_RC_BAR[123]_CONFIG_LO.SIZE @@ -1112,9 +1138,10 @@ static inline int brcm_phy_start(struct brcm_pcie *pcie) return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0; } -static inline int brcm_phy_stop(struct brcm_pcie *pcie) +static inline void brcm_phy_stop(struct brcm_pcie *pcie) { - return pcie->rescal ? brcm_phy_cntl(pcie, 0) : 0; + if (pcie->rescal) + brcm_phy_cntl(pcie, 0); } static void brcm_pcie_turn_off(struct brcm_pcie *pcie) @@ -1141,16 +1168,45 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie) pcie->bridge_sw_init_set(pcie, 1); } +static int brcm_pcie_get_regulators(struct brcm_pcie *pcie) +{ + struct device_node *np = pcie->np; + struct property *pp; + const unsigned int ns = ARRAY_SIZE(supplies); + unsigned int i; + int ret = 0; + + /* Look for specific pcie regulators in the RC DT node. */ + for_each_property_of_node(np, pp) { + for (i = 0; i < ns; i++) + if (strcmp(supplies[i], pp->name) == 0) + break; + if (i >= ns) + continue; + + if (pcie->num_supplies < PCIE_BRCM_MAX_EP_REGULATORS) + pcie->supplies[pcie->num_supplies++].supply + = supplies[i]; + else + dev_warn(pcie->dev, "No room for supply %s\n", + supplies[i]); + } + + if (pcie->num_supplies) + ret = devm_regulator_bulk_get(pcie->dev, pcie->num_supplies, + pcie->supplies); + return ret; +} + static int brcm_pcie_suspend(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); - int ret; brcm_pcie_turn_off(pcie); - ret = brcm_phy_stop(pcie); + brcm_phy_stop(pcie); clk_disable_unprepare(pcie->clk); - return ret; + return brcm_set_regulators(pcie, false); } static int brcm_pcie_resume(struct device *dev) @@ -1165,6 +1221,10 @@ static int brcm_pcie_resume(struct device *dev) if (ret) return ret; + ret = brcm_set_regulators(pcie, true); + if (ret) + return ret; + ret = brcm_phy_start(pcie); if (ret) goto err; @@ -1201,6 +1261,7 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) brcm_phy_stop(pcie); reset_control_assert(pcie->rescal); clk_disable_unprepare(pcie->clk); + brcm_set_regulators(pcie, false); } static int brcm_pcie_remove(struct platform_device *pdev) @@ -1291,6 +1352,18 @@ static int brcm_pcie_probe(struct platform_device *pdev) return ret; } + ret = brcm_pcie_get_regulators(pcie); + if (ret) { + pcie->num_supplies = 0; + if (ret != -EPROBE_DEFER) + dev_err(pcie->dev, "failed to get regulators (err=%d)\n", ret); + goto fail; + } + + ret = brcm_set_regulators(pcie, true); + if (ret) + goto fail; + ret = brcm_pcie_setup(pcie); if (ret) goto fail; From patchwork Thu Apr 1 21:21:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12179599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C88D2C433ED for ; Thu, 1 Apr 2021 21:32:12 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CE23610FB for ; Thu, 1 Apr 2021 21:32:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CE23610FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=c5+oO3EGoE3ZGWwXTK2yjMA8du7ua7c0s0X+3Ok+4wk=; b=ikNyzz/dCL5v7JyNnq+pOgVc7F e0lgJs9ni6/Kr7315PeQwYDpqHl4Yf2e7/4i3Abw71sg3qYMTCGeuj8J8+C2cDnHhbM/ylYu+BBDe 0CSSHkaSZZXK+0LD/AjoPPWvFMpA6YJGplfVlJ/aUUiUAkYKiKlCNLLajnChD1EBHqQ0H3riShc/u EpEkVv0rFIBtH+x/S4bU9lfSYorllXwAPx5oj+IXavcmQOEAbYr5C77mQXhzqeQxkpgKt0Y0QuPI3 2+jpUce9aDMt9cMExUKBwX4wy11+VxBr1isQw0kxb3a84gNXgVwxfR31zEX0RnieiPB3fO3s/Z94X 1GrU7nUA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lS4sH-00B3sj-CD; Thu, 01 Apr 2021 21:29:11 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lS4lQ-00B35R-1b; Thu, 01 Apr 2021 21:22:53 +0000 Received: by mail-pf1-x433.google.com with SMTP id m11so2323290pfc.11; Thu, 01 Apr 2021 14:22:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3Svmj4M57E9UEJUPztxJxLaD+qDYLkSPzt9oL2QtC44=; b=QdAOl64swAv8QPAkhS3LmoBMm77A/m1F7ZHnm2l6hl7zkTCmQRw6maRV9rcYq2IQYS SDu+c5Ia41SWN6rSBDaNecTwacaO+Pq9gHj+ium+lNYkeyUi1Pa4c7ff6LrA8/qJWaHk MTXBeFEmdYgSWt2MzNBAj5utjpdWkdVtqlj4HrFWm4NdYESeDlxCx4eNMS3J0hU0fc+L lR6YldvvVtve8TN2mJ//NKZ4zSHIUrF6pqjG08HFHz4491EgU9U+OBLy4hhOLEDL2O8w wYcHFxaWkSM04kEfVEJk9SncgCAO0nj6LoYJ7s3jvM3bkkO8dmx95pQdycDKCxAKTlNh lc0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3Svmj4M57E9UEJUPztxJxLaD+qDYLkSPzt9oL2QtC44=; b=BY9BdmCj8pt0LnC5wltCt2XUtvSqpcTYVlw1u4v35T+Y61K+PfnHvNlwBXn8HWTgwT QNefdbADXUO6Jy/Np0HGZD3JR11rSJYMkk1AERX8ZJ9JAQGRDTCL6Tid3P5rk1HGQ6+m 3HSCbL01lxI/hUXVp25o8Ss+l5fn+CysaH2RPM9Qk8prkSBLUNiXUnz85dd4mH7eoy/W oDGfOrwJtrzhIP3QiG8gTZEnrATRzpmvhHu0x2yzH52irBG/6AVZRgL/9qKPItTYpfo9 3q/nwHxHOcmHn8HosG0sqC/qdhOVU4f7Da3fA/a/0aNSinYAqiMIfZ8xzA64GGr6uBR9 gUUQ== X-Gm-Message-State: AOAM5313Uuku03G6A1TpWyi2l7fFPSKLb9UpGnH6wvbD1ELBzEghaZdV 1eATojhLOCCCLtW0+eGDiDk= X-Google-Smtp-Source: ABdhPJwi3QBpg+AUACKEeirWBOo7RVmBvkFoAwhc7TIv+cKY68bgc16eXAS34emUMg33TpkYzsMKDQ== X-Received: by 2002:aa7:9478:0:b029:1fd:1fc1:bdfe with SMTP id t24-20020aa794780000b02901fd1fc1bdfemr9225842pfq.57.1617312122653; Thu, 01 Apr 2021 14:22:02 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id q5sm5926707pfk.219.2021.04.01.14.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 14:22:02 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 4/6] PCI: brcmstb: Do not turn off regulators if EP can wake up Date: Thu, 1 Apr 2021 17:21:44 -0400 Message-Id: <20210401212148.47033-5-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210401212148.47033-1-jim2101024@gmail.com> References: <20210401212148.47033-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_222249_689928_0F72E341 X-CRM114-Status: GOOD ( 19.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If any downstream device may wake up during S2/S3 suspend, we do not want to turn off its power when suspending. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 58 +++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 1b0de0c7da60..4c79aff66de7 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -193,6 +193,7 @@ static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, static inline void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val); +static bool brcm_pcie_link_up(struct brcm_pcie *pcie); static const char * const supplies[] = { "vpcie12v-supply", @@ -304,22 +305,65 @@ struct brcm_pcie { void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); struct regulator_bulk_data supplies[PCIE_BRCM_MAX_EP_REGULATORS]; unsigned int num_supplies; + bool ep_wakeup_capable; }; -static int brcm_set_regulators(struct brcm_pcie *pcie, bool on) +static int pci_dev_may_wakeup(struct pci_dev *dev, void *data) { + bool *ret = data; + + if (device_may_wakeup(&dev->dev)) { + *ret = true; + dev_dbg(&dev->dev, "disable cancelled for wake-up device\n"); + } + return (int) *ret; +} + +enum { + TURN_OFF, /* Turn regulators off, unless an EP is wakeup-capable */ + TURN_OFF_ALWAYS, /* Turn regulators off, no exceptions */ + TURN_ON, /* Turn regulators on, unless pcie->ep_wakeup_capable */ +}; + +static int brcm_set_regulators(struct brcm_pcie *pcie, int how) +{ + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); struct device *dev = pcie->dev; int ret; if (!pcie->num_supplies) return 0; - if (on) + if (how == TURN_ON) { + if (pcie->ep_wakeup_capable) { + /* + * We are resuming from a suspend. In the + * previous suspend we did not disable the power + * supplies, so there is no need to enable them + * (and falsely increase their usage count). + */ + pcie->ep_wakeup_capable = false; + return 0; + } + } else if (how == TURN_OFF) { + /* + * If at least one device on this bus is enabled as a + * wake-up source, do not turn off regulators. + */ + pcie->ep_wakeup_capable = false; + if (bridge->bus && brcm_pcie_link_up(pcie)) { + pci_walk_bus(bridge->bus, pci_dev_may_wakeup, &pcie->ep_wakeup_capable); + if (pcie->ep_wakeup_capable) + return 0; + } + } + + if (how == TURN_ON) ret = regulator_bulk_enable(pcie->num_supplies, pcie->supplies); else ret = regulator_bulk_disable(pcie->num_supplies, pcie->supplies); if (ret) dev_err(dev, "failed to %s EP regulators\n", - on ? "enable" : "disable"); + how == TURN_ON ? "enable" : "disable"); return ret; } @@ -1206,7 +1250,7 @@ static int brcm_pcie_suspend(struct device *dev) brcm_phy_stop(pcie); clk_disable_unprepare(pcie->clk); - return brcm_set_regulators(pcie, false); + return brcm_set_regulators(pcie, TURN_OFF); } static int brcm_pcie_resume(struct device *dev) @@ -1221,7 +1265,7 @@ static int brcm_pcie_resume(struct device *dev) if (ret) return ret; - ret = brcm_set_regulators(pcie, true); + ret = brcm_set_regulators(pcie, TURN_ON); if (ret) return ret; @@ -1261,7 +1305,7 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) brcm_phy_stop(pcie); reset_control_assert(pcie->rescal); clk_disable_unprepare(pcie->clk); - brcm_set_regulators(pcie, false); + brcm_set_regulators(pcie, TURN_OFF_ALWAYS); } static int brcm_pcie_remove(struct platform_device *pdev) @@ -1360,7 +1404,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) goto fail; } - ret = brcm_set_regulators(pcie, true); + ret = brcm_set_regulators(pcie, TURN_ON); if (ret) goto fail; From patchwork Thu Apr 1 21:21:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12179597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 945A7C433ED for ; Thu, 1 Apr 2021 21:31:20 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 070EC610FB for ; Thu, 1 Apr 2021 21:31:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 070EC610FB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Jr3ljCn/5i4Q7iKKjrNTpusWWUNAnyKYUAsu+jqkyxI=; b=fE/NWgX04Zho/VCChr/+5sRS+7 psLsiZmUz161+ad5mFK7tXIoLqS7LaZTj8F/xra7WY0pY1gCcAzzLjN61fWyAe+sHqDqVOX3SNVXh zPOdbWNEYJ/KWbXJf9WsoHmjwPcdjKrFDZS7tXm/c8r/Dm3J2+bnomTObgFBEPi2IWPrz7acSj2gv ai5lc14CjrS8tR+AI9PnNqsCNJ4GmVL5d9Ih3Irv37/Oa4WA0RKNUsR08n7NroLBqTWVrsVSs6DhZ RxooPZkFtlP3lBgYi3R29Ne+EYhM/WEtZ5iApqJFhH1j+GkUPpoY7kZH7KJg1USqul+BpcHESws4x 10UJsk/g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lS4s0-00B3mz-WF; Thu, 01 Apr 2021 21:28:53 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lS4lS-00B35V-9u; Thu, 01 Apr 2021 21:22:51 +0000 Received: by mail-pg1-x52e.google.com with SMTP id l76so2374602pga.6; Thu, 01 Apr 2021 14:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kSGfeqiI16h1xdk+kDjbKZZ2Zy2FnQRhOpc1dRiQ3Hc=; b=TyACpHVWPpmn4rVcyPdd2oD+YnXPljjxNqIQMypgJj1OzC2p1DEKTcULKOs8oO7d5j 3Zl7zcTZwdQkdVDKuhV0OqsolRYB983JEXRhlyaWPIP9e1uW81Vl8yv9nHO6SBiDDrGp 8fjhQ0G6TED/SftetqoBCQ/Wnt9WuC/bVamjwvpKUVpyWMbD56Ue6IBYLX1tRVnyhmCU kegFFPShHoTCNIXHeFkIjyyQYLeP2dx02DYvA7iYJr/NC1q5qV7c1IPPbVsklEjZTEb9 V9x08uQsyJWH/ZUPtd25IeMALZ8/GHoT+08WEfqu+isMVCZN0vzNRyGfug4LonsXvZJv 2rUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kSGfeqiI16h1xdk+kDjbKZZ2Zy2FnQRhOpc1dRiQ3Hc=; b=PMbdvIhDElWApCuxsELnH6jF9N0QPnxvs8wtf5hnKjXrkTt8HBLdWJHW2RmF4QTvQF eRDkg/z0Nl0q2rgVEhra5B+VxG+Vj1fuD6pJHiccOLnD1QpU1EWT62yMkuh5DidYn75A Yw5bPMWSUmEDn0zFu3xt0BA0mawWdY6l9P6KpDOpab335EMG7lhpYSHorMrOcyYKLAA4 RDseAVlcvhepTO1LCfChFJXu+3TpYyDW0uPjOBlG1f+8zu9u46JwzY7WjCJO1XxdklRn vx3dxRzIe5StBh8nu2N23jnY6GfXhx8D+Lqdbdtvko4Vuing8FQ+R9kdQzqapy6G0RPG Svaw== X-Gm-Message-State: AOAM530IRmNMkSMz2eCL3dBWVQpGnbTBbcqheghKUwBFcDoGTF39MQoy h6jbaIxjmueLtB9NDK2yiys= X-Google-Smtp-Source: ABdhPJzZR0MBN1IIOC3WlT4nfpVaoCry/gQUJ5AcabN0UPPKheKks8+k5P9sS4p57f3qyjkkVffmVA== X-Received: by 2002:aa7:8d4c:0:b029:21c:104b:f6cb with SMTP id s12-20020aa78d4c0000b029021c104bf6cbmr9063700pfe.26.1617312124937; Thu, 01 Apr 2021 14:22:04 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id q5sm5926707pfk.219.2021.04.01.14.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 14:22:04 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 5/6] PCI: brcmstb: Give 7216 SOCs their own config type Date: Thu, 1 Apr 2021 17:21:45 -0400 Message-Id: <20210401212148.47033-6-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210401212148.47033-1-jim2101024@gmail.com> References: <20210401212148.47033-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_222249_682451_A8A2732C X-CRM114-Status: GOOD ( 11.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This distinction is required for an imminent commit. Signed-off-by: Jim Quinlan Acked-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 4c79aff66de7..44128df33785 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -265,6 +265,13 @@ static const struct pcie_cfg_data bcm2711_cfg = { .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, }; +static const struct pcie_cfg_data bcm7216_cfg = { + .offsets = pcie_offset_bcm7278, + .type = BCM7278, + .perst_set = brcm_pcie_perst_set_7278, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278, +}; + struct brcm_msi { struct device *dev; void __iomem *base; @@ -1325,7 +1332,7 @@ static const struct of_device_id brcm_pcie_match[] = { { .compatible = "brcm,bcm4908-pcie", .data = &bcm4908_cfg }, { .compatible = "brcm,bcm7211-pcie", .data = &generic_cfg }, { .compatible = "brcm,bcm7278-pcie", .data = &bcm7278_cfg }, - { .compatible = "brcm,bcm7216-pcie", .data = &bcm7278_cfg }, + { .compatible = "brcm,bcm7216-pcie", .data = &bcm7216_cfg }, { .compatible = "brcm,bcm7445-pcie", .data = &generic_cfg }, {}, }; From patchwork Thu Apr 1 21:21:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12179595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 240CDC433B4 for ; Thu, 1 Apr 2021 21:30:19 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9829B61106 for ; Thu, 1 Apr 2021 21:30:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9829B61106 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RSWY03wkXlGEXsxiVgYS020GqK0ZIWK9pU9Hntp1AMI=; b=RkyKJkMvXnL5T+VsjVNJNYgj/P h8ohiVDQ6pqwgIdWR2ojg6uIfDbAD3P+3HVZFl78ElJ+nvg/KhI4got6ecn4z9ckoDSLHBmfAAvnF GMg3YwGoZPlOilns3XcT3Zos+cq1Buh1az7Fm7l1cty5ylGBqCRrZ7qB1OCN9GnWkxeTNfgJmHy9g fb0TaXpVgfcqP+oxxAaUwt4vFkw1oDFXBPYblUWFx5P92BGW9ULXAS2QO8SL3fIOMemz3jUUDQakU NmG80MIzPV88SH+Hv48skH4/jlOLwtI26ud/L6k03lhpz9abUFe7ma2+0ERzgpMAvRQlUzUwhso+y 3QATUKhA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lS4r6-00B3YL-CU; Thu, 01 Apr 2021 21:28:13 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lS4lU-00B36F-P8; Thu, 01 Apr 2021 21:22:53 +0000 Received: by mail-pl1-x636.google.com with SMTP id d8so1627030plh.11; Thu, 01 Apr 2021 14:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9phU48RwJquj1HVaVVeNhbqrrN2jUhNbS5Biccg8yro=; b=mf05s/dF++HwMxbOidTLOvztf9Kpc4EiadrDa5AtEPTVx8J0angukRCUMwXd14G84t 4xawu3d07CQrZ7qdTbZRXj2/NxPGRrRLwOOh/B+E19gy5BCRZwje0Nzjib9LnmKO2csh ahDdHznUPTguLAACsTUG34OMHkceHz0YjVVxUHwCG4730RPIkBbA+LB0Z/JONaCLGxQt vjk2FEFB7iBFpkJKl/yVV6FBsM98+3dt/HmGCFzrzu4oBz+4byk9WG7uIssc2mgTAosX lQ/zVx6XuzgoACZmsgwIGLcS8feinE0tdmWSR4F3vDseVAa9fLkhpAUKJXQLM8w6Dot2 vKoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9phU48RwJquj1HVaVVeNhbqrrN2jUhNbS5Biccg8yro=; b=T68mae2q5N/sQUwUlGITGiEhUfCvnK/0fJxgd/eUuqaMQcBC8t9qr/BHA3+yIJxgkG ya9S8QoekW+ti58M7BfbMFNdz9LDoLMqsl5JaaH271gMHa2euB9JFwVS4brXHBcLmqlg MTMj+HA37erqfQIxY7wVCJ8uGlpne9uqOQvdyb2H4+kKzWrOBPX0ANRD1x8ewNHcVbZf MKW56EM3plO5tH+qXnumg+07+7XW1S6/9t/ZOM0h7bYG9ewnB/8mo47wRAahyKk1zEIW U3RnT8yN85dEWsI+C4FhxnB7ZG2jsiSJP+LaVwgsyCFEL51+OM7a1MqmoEs5JHSc0rmY /3FA== X-Gm-Message-State: AOAM533oHeq3aqKsgu6WU/2uW5tXWxoFw066auX8JQWweR4fv5JKBYlQ lWwZvZ8jOMs750dztGPwpX2t9p0JDuM= X-Google-Smtp-Source: ABdhPJzUHdMagnBlhKn7JuKQcxF83/2LF3hu3PoZB4IHWdEjl6OlL4MufW0ramrPBv1MZWu4Aaswbw== X-Received: by 2002:a17:90b:a01:: with SMTP id gg1mr10770520pjb.22.1617312127478; Thu, 01 Apr 2021 14:22:07 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id q5sm5926707pfk.219.2021.04.01.14.22.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Apr 2021 14:22:06 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Lorenzo Pieralisi , Bjorn Helgaas , Florian Fainelli , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v4 6/6] PCI: brcmstb: Add panic/die handler to RC driver Date: Thu, 1 Apr 2021 17:21:46 -0400 Message-Id: <20210401212148.47033-7-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210401212148.47033-1-jim2101024@gmail.com> References: <20210401212148.47033-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210401_222249_688935_36DA02B7 X-CRM114-Status: GOOD ( 19.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Whereas most PCIe HW returns 0xffffffff on illegal accesses and the like, by default Broadcom's STB PCIe controller effects an abort. This simple handler determines if the PCIe controller was the cause of the abort and if so, prints out diagnostic info. Example output: brcm-pcie 8b20000.pcie: Error: Mem Acc: 32bit, Read, @0x38000000 brcm-pcie 8b20000.pcie: Type: TO=0 Abt=0 UnspReq=1 AccDsble=0 BadAddr=0 Signed-off-by: Jim Quinlan Acked-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 122 ++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 44128df33785..73a12c62b94e 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -12,11 +12,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -186,6 +188,39 @@ #define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_PWRDN_MASK 0x1 #define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_PWRDN_SHIFT 0x0 +/* Error report regiseters */ +#define PCIE_OUTB_ERR_TREAT 0x6000 +#define PCIE_OUTB_ERR_TREAT_CONFIG_MASK 0x1 +#define PCIE_OUTB_ERR_TREAT_MEM_MASK 0x2 +#define PCIE_OUTB_ERR_VALID 0x6004 +#define PCIE_OUTB_ERR_CLEAR 0x6008 +#define PCIE_OUTB_ERR_ACC_INFO 0x600c +#define PCIE_OUTB_ERR_ACC_INFO_CFG_ERR_MASK 0x01 +#define PCIE_OUTB_ERR_ACC_INFO_MEM_ERR_MASK 0x02 +#define PCIE_OUTB_ERR_ACC_INFO_TYPE_64_MASK 0x04 +#define PCIE_OUTB_ERR_ACC_INFO_DIR_WRITE_MASK 0x10 +#define PCIE_OUTB_ERR_ACC_INFO_BYTE_LANES_MASK 0xff00 +#define PCIE_OUTB_ERR_ACC_ADDR 0x6010 +#define PCIE_OUTB_ERR_ACC_ADDR_BUS_MASK 0xff00000 +#define PCIE_OUTB_ERR_ACC_ADDR_DEV_MASK 0xf8000 +#define PCIE_OUTB_ERR_ACC_ADDR_FUNC_MASK 0x7000 +#define PCIE_OUTB_ERR_ACC_ADDR_REG_MASK 0xfff +#define PCIE_OUTB_ERR_CFG_CAUSE 0x6014 +#define PCIE_OUTB_ERR_CFG_CAUSE_TIMEOUT_MASK 0x40 +#define PCIE_OUTB_ERR_CFG_CAUSE_ABORT_MASK 0x20 +#define PCIE_OUTB_ERR_CFG_CAUSE_UNSUPP_REQ_MASK 0x10 +#define PCIE_OUTB_ERR_CFG_CAUSE_ACC_TIMEOUT_MASK 0x4 +#define PCIE_OUTB_ERR_CFG_CAUSE_ACC_DISABLED_MASK 0x2 +#define PCIE_OUTB_ERR_CFG_CAUSE_ACC_64BIT__MASK 0x1 +#define PCIE_OUTB_ERR_MEM_ADDR_LO 0x6018 +#define PCIE_OUTB_ERR_MEM_ADDR_HI 0x601c +#define PCIE_OUTB_ERR_MEM_CAUSE 0x6020 +#define PCIE_OUTB_ERR_MEM_CAUSE_TIMEOUT_MASK 0x40 +#define PCIE_OUTB_ERR_MEM_CAUSE_ABORT_MASK 0x20 +#define PCIE_OUTB_ERR_MEM_CAUSE_UNSUPP_REQ_MASK 0x10 +#define PCIE_OUTB_ERR_MEM_CAUSE_ACC_DISABLED_MASK 0x2 +#define PCIE_OUTB_ERR_MEM_CAUSE_BAD_ADDR_MASK 0x1 + /* Forward declarations */ struct brcm_pcie; static inline void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val); @@ -223,6 +258,7 @@ struct pcie_cfg_data { const enum pcie_type type; void (*perst_set)(struct brcm_pcie *pcie, u32 val); void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); + const bool has_err_report; }; static const int pcie_offsets[] = { @@ -270,6 +306,7 @@ static const struct pcie_cfg_data bcm7216_cfg = { .type = BCM7278, .perst_set = brcm_pcie_perst_set_7278, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278, + .has_err_report = true, }; struct brcm_msi { @@ -313,8 +350,87 @@ struct brcm_pcie { struct regulator_bulk_data supplies[PCIE_BRCM_MAX_EP_REGULATORS]; unsigned int num_supplies; bool ep_wakeup_capable; + bool has_err_report; + struct notifier_block die_notifier; }; +/* Dump out PCIe errors on die or panic */ +static int dump_pcie_error(struct notifier_block *self, unsigned long v, void *p) +{ + const struct brcm_pcie *pcie = container_of(self, struct brcm_pcie, die_notifier); + void __iomem *base = pcie->base; + int i, is_cfg_err, is_mem_err, lanes; + char *width_str, *direction_str, lanes_str[9]; + u32 info; + + if (readl(base + PCIE_OUTB_ERR_VALID) == 0) + return NOTIFY_DONE; + info = readl(base + PCIE_OUTB_ERR_ACC_INFO); + + + is_cfg_err = !!(info & PCIE_OUTB_ERR_ACC_INFO_CFG_ERR_MASK); + is_mem_err = !!(info & PCIE_OUTB_ERR_ACC_INFO_MEM_ERR_MASK); + width_str = (info & PCIE_OUTB_ERR_ACC_INFO_TYPE_64_MASK) ? "64bit" : "32bit"; + direction_str = (info & PCIE_OUTB_ERR_ACC_INFO_DIR_WRITE_MASK) ? "Write" : "Read"; + lanes = FIELD_GET(PCIE_OUTB_ERR_ACC_INFO_BYTE_LANES_MASK, info); + for (i = 0, lanes_str[8] = 0; i < 8; i++) + lanes_str[i] = (lanes & (1 << i)) ? '1' : '0'; + + if (is_cfg_err) { + u32 cfg_addr = readl(base + PCIE_OUTB_ERR_ACC_ADDR); + u32 cause = readl(base + PCIE_OUTB_ERR_CFG_CAUSE); + int bus = FIELD_GET(PCIE_OUTB_ERR_ACC_ADDR_BUS_MASK, cfg_addr); + int dev = FIELD_GET(PCIE_OUTB_ERR_ACC_ADDR_DEV_MASK, cfg_addr); + int func = FIELD_GET(PCIE_OUTB_ERR_ACC_ADDR_FUNC_MASK, cfg_addr); + int reg = FIELD_GET(PCIE_OUTB_ERR_ACC_ADDR_REG_MASK, cfg_addr); + + dev_err(pcie->dev, "Error: CFG Acc, %s, %s, Bus=%d, Dev=%d, Fun=%d, Reg=0x%x, lanes=%s\n", + width_str, direction_str, bus, dev, func, reg, lanes_str); + dev_err(pcie->dev, " Type: TO=%d Abt=%d UnsupReq=%d AccTO=%d AccDsbld=%d Acc64bit=%d\n", + !!(cause & PCIE_OUTB_ERR_CFG_CAUSE_TIMEOUT_MASK), + !!(cause & PCIE_OUTB_ERR_CFG_CAUSE_ABORT_MASK), + !!(cause & PCIE_OUTB_ERR_CFG_CAUSE_UNSUPP_REQ_MASK), + !!(cause & PCIE_OUTB_ERR_CFG_CAUSE_ACC_TIMEOUT_MASK), + !!(cause & PCIE_OUTB_ERR_CFG_CAUSE_ACC_DISABLED_MASK), + !!(cause & PCIE_OUTB_ERR_CFG_CAUSE_ACC_64BIT__MASK)); + } + + if (is_mem_err) { + u32 cause = readl(base + PCIE_OUTB_ERR_MEM_CAUSE); + u32 lo = readl(base + PCIE_OUTB_ERR_MEM_ADDR_LO); + u32 hi = readl(base + PCIE_OUTB_ERR_MEM_ADDR_HI); + u64 addr = ((u64)hi << 32) | (u64)lo; + + dev_err(pcie->dev, "Error: Mem Acc, %s, %s, @0x%llx, lanes=%s\n", + width_str, direction_str, addr, lanes_str); + dev_err(pcie->dev, " Type: TO=%d Abt=%d UnsupReq=%d AccDsble=%d BadAddr=%d\n", + !!(cause & PCIE_OUTB_ERR_MEM_CAUSE_TIMEOUT_MASK), + !!(cause & PCIE_OUTB_ERR_MEM_CAUSE_ABORT_MASK), + !!(cause & PCIE_OUTB_ERR_MEM_CAUSE_UNSUPP_REQ_MASK), + !!(cause & PCIE_OUTB_ERR_MEM_CAUSE_ACC_DISABLED_MASK), + !!(cause & PCIE_OUTB_ERR_MEM_CAUSE_BAD_ADDR_MASK)); + } + + /* Clear the error */ + writel(1, base + PCIE_OUTB_ERR_CLEAR); + + return NOTIFY_DONE; +} + +static void brcm_register_die_notifiers(struct brcm_pcie *pcie) +{ + pcie->die_notifier.notifier_call = dump_pcie_error; + register_die_notifier(&pcie->die_notifier); + atomic_notifier_chain_register(&panic_notifier_list, &pcie->die_notifier); +} + +static void brcm_unregister_die_notifiers(struct brcm_pcie *pcie) +{ + unregister_die_notifier(&pcie->die_notifier); + atomic_notifier_chain_unregister(&panic_notifier_list, &pcie->die_notifier); + pcie->die_notifier.notifier_call = NULL; +} + static int pci_dev_may_wakeup(struct pci_dev *dev, void *data) { bool *ret = data; @@ -1321,6 +1437,8 @@ static int brcm_pcie_remove(struct platform_device *pdev) struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); pci_stop_root_bus(bridge->bus); + if (pcie->has_err_report) + brcm_unregister_die_notifiers(pcie); pci_remove_root_bus(bridge->bus); __brcm_pcie_remove(pcie); @@ -1360,6 +1478,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->np = np; pcie->reg_offsets = data->offsets; pcie->type = data->type; + pcie->has_err_report = data->has_err_report; pcie->perst_set = data->perst_set; pcie->bridge_sw_init_set = data->bridge_sw_init_set; @@ -1439,6 +1558,9 @@ static int brcm_pcie_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pcie); + if (pcie->has_err_report) + brcm_register_die_notifiers(pcie); + return pci_host_probe(bridge); fail: __brcm_pcie_remove(pcie);