From patchwork Wed Jul 31 22:28:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749287 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67EA916D4FF for ; Wed, 31 Jul 2024 22:28:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464919; cv=none; b=qDRN6cEc1lNHexcXEtrxncKIfseCnuUkHcV3a/BcOU/SMpptvrQGGLGTfLy2BtC4qzMBccr1ryLyDiY9tndPfwimIPeGUPyQtj3AOiJqOTFzzueeEF3ndQfpyXLottiKvAoXT+Fisy3NgHoA4VVGh+Vryou1OGv2uVqQEJTS6Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464919; c=relaxed/simple; bh=xOGWNuaAupIgwPdS/rgbsjpjtqFXk6aLgk37BeHc+W8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=imgjcrgGUeIBMIHQQC1sIoHP9zN0Dd+0GqoSUPTxm01ZQeOPf6UsMrrKc6uvXzh+ISMhRHS30lKCvYihu5crAGyNP9Yov3+9CKwbGNYzpCu4QDU8R+jGXrw2S8dIIrnG1JPqx+88iEYundedQrYNQwIzpk3G6FPKKEynbNh5MB8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=DcfzGJv2; arc=none smtp.client-ip=209.85.160.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="DcfzGJv2" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-44fffca4fb7so26244231cf.1 for ; Wed, 31 Jul 2024 15:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464916; x=1723069716; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=b8cbkrXOvR65c0gzParSa3KyQFx/V1Yolb4QWEqbLeU=; b=DcfzGJv2t5cjo2d/zEOlWrQFvfvyOeBRtZqIE1mlPnGStKWv6fKIVgIdRgJt8A7/Tg s6XfO1X1q+9LUP0BZvCdnJUNN1Wj44F4QqHCnGKF6Rm/UV45KJmZ/iJ0au+ZyAJjRtZO 5g8dwXbfGvSWFcklB+l0k/axfboqnNeFn/b/c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464916; x=1723069716; h=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=b8cbkrXOvR65c0gzParSa3KyQFx/V1Yolb4QWEqbLeU=; b=hg46e9CnQU3vgB5dx81AQXg/WeND8DsLXA63w+Nf+3gpIVqkfklreEygWJ3gPxU1qe jK9nrM37t+LOjeWnr0AnCAFPZGCyHRLoOdyPipkiybVdWY4BM0ALyN7Iipvo3oO/GHLd lcM2B9G5Cx5Qgdy3HNeHobaXjSz/weOIRkC0Mif4wIXR1oSBu2TToTfcLEcx3N+R+zS7 Xnqvwtbe4LpmRqkReNnyGOEPjf/QO8zQdrc3TkQ6tkXzu+Fs6N21BDUy8DCXFt2BRfhQ NIC2E1uwSt9shJylOESmJYx90uqk8uD8NiVvyc1QNuL//d6f/POQxLNznNkH2ZXFzG6x rPJA== X-Gm-Message-State: AOJu0Yzp6QdfS7cef26HCHw2pjA+CgG1AJYEigONK840qbkJwHXIdsDr WYPAco35UFlCmr60SdhJXDzWV+5LGVMyYiObA4I1830VUJxuNmss3KDkHyOWbfXOikrdaqxKbr0 IcpsQEsNy712AlT1fbRQ8IAJJ7eDNzOtKBcobPC7GNE+SoD440e8nunPy+oaUk4/p0VjJaK24WA bRmZyopkTna9ZE7rYxAohuxQzDTXFM9asM69d9C6/BGiityw== X-Google-Smtp-Source: AGHT+IEZ5zlpgTPjR0UxwHUMdNEmwri4DDnsPSxdW+UrsEfbtq1R2jA2OMG2gatPXhIqCCj0RHIJBQ== X-Received: by 2002:a05:622a:548c:b0:44f:dcd2:613a with SMTP id d75a77b69052e-45167d0eaabmr7880061cf.41.1722464915714; Wed, 31 Jul 2024 15:28:35 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:35 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE), linux-rpi-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 v5 01/12] dt-bindings: PCI: Cleanup of brcmstb YAML and add 7712 SoC Date: Wed, 31 Jul 2024 18:28:15 -0400 Message-Id: <20240731222831.14895-2-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: o Change order of the compatible strings to be alphabetical o Use "maxItems" where needed. o Change maintainer: Nicolas has not been active for a while. It also makes sense for a Broadcom employee to be the maintainer as many of the details are privy to Broadcom. Signed-off-by: Jim Quinlan Reviewed-by: Florian Fainelli --- .../devicetree/bindings/pci/brcm,stb-pcie.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 11f8ea33240c..7d2552192153 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# title: Brcmstb PCIe Host Controller maintainers: - - Nicolas Saenz Julienne + - Jim Quinlan properties: compatible: @@ -16,11 +16,11 @@ properties: - brcm,bcm2711-pcie # The Raspberry Pi 4 - brcm,bcm4908-pcie - brcm,bcm7211-pcie # Broadcom STB version of RPi4 - - brcm,bcm7278-pcie # Broadcom 7278 Arm - brcm,bcm7216-pcie # Broadcom 7216 Arm - - brcm,bcm7445-pcie # Broadcom 7445 Arm + - brcm,bcm7278-pcie # Broadcom 7278 Arm - brcm,bcm7425-pcie # Broadcom 7425 MIPs - brcm,bcm7435-pcie # Broadcom 7435 MIPs + - brcm,bcm7445-pcie # Broadcom 7445 Arm reg: maxItems: 1 @@ -95,6 +95,12 @@ properties: minItems: 1 maxItems: 3 + resets: + maxItems: 1 + + reset-names: + maxItems: 1 + required: - compatible - reg @@ -118,8 +124,7 @@ allOf: then: properties: resets: - items: - - description: reset controller handling the PERST# signal + maxItems: 1 reset-names: items: @@ -136,8 +141,7 @@ allOf: then: properties: resets: - items: - - description: phandle pointing to the RESCAL reset controller + maxItems: 1 reset-names: items: From patchwork Wed Jul 31 22:28:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749288 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA44216D9D8 for ; Wed, 31 Jul 2024 22:28:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464920; cv=none; b=ks4de31z5G9Z8ZuPmnnaWgeNi3D1NWpGwDt7jF9J1LE0Inib3ksPa2cL1lb4vOqLlt3f/BBxsyp6j/tJyr49/mzA6hcMkpbImUy4AwycYsWVXfsdImcmswgfn9QqNEBvZ/W1elsqw/6lu330ymROFxylgp7Y0e650D2Jk8nad8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464920; c=relaxed/simple; bh=mAoM+jm0P713mKZxMhykPOMr8VcVpW3lJ0JPpibSWzM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=q+TDZ9DZUkmlgDpzlLZ3aIW9pA2rWiv3RQf4WRhKNj+VCX/qv1R5jqh6SJ1XPGWfx8n6hue2V7QV7Vnlg2PWS8RgB3rE0KU4nxgXgYdrYoP9brqdv8qC7bi2f4gsySiwSSTLIeLNHmsx6Qa230aNXIMHP4ZTFQf2PNBPk6wKBpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=RXeyd7CV; arc=none smtp.client-ip=209.85.210.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="RXeyd7CV" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-70968db52d0so714435a34.3 for ; Wed, 31 Jul 2024 15:28:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464917; x=1723069717; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=MEzSqlnsH2j9tRB5+9ly7frUJhXv2tJmhe1jZ23vhJ0=; b=RXeyd7CVF82M+8IeZtSpbzFhBrQKqFvVlxy9Mt4trRy1ahUJugA0vBwBxA+MKjbCIa N3hv3utV370A59jTjbrn0Mlt+IeHJQTQhBvXgIh/fizqbJO4kB2FAYcVA+/jSnNvRLeM tuJOKgIIXoo1+vsjtMXVSMJZCFLZQWDBXifQY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464917; x=1723069717; h=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=MEzSqlnsH2j9tRB5+9ly7frUJhXv2tJmhe1jZ23vhJ0=; b=SF+lIg7/3MP2Zp08hlfXZ8JfuLikLgojTLnJlmXzGuWw1uq6L5yg6+ow/Sh9NMUglE L/45dn+59SAQ0j3zSzCRI2kT19uTaclH04O2BXQs5I5fQqGZslw5qD07Pz0BUSW/6jhu NX2D02hFf4hchu2H81WiFt3XLEWwsWMcCaj+TwuV30I7hBxCJSB3whYQUImS7i7Gza2q xkKHKMNzSgP8erMgpAvXJRUdcqTleY5kBptpdSnj2i9QsYsPMcGIN++xTJSEPL3Eu96C ahOM8Zb4Lg4NMYWOeapZKqG3EKyn0hDsrDhRgTPRrBIB8s/Z1CfLC07zClbtSxqBDt5q N0MA== X-Gm-Message-State: AOJu0Ywo1k6pJVVX5hExfeIFsZt+Ftla2GKkr6VbA7E+LXh3kKXY/9fo BdEd1Tu2SeBbBP2mJp8ZBhbE9SZtQAsuYyqERm5STxaFxL8hXaFtr0g9yZCSTsbO8ILEXcEsPFV xoZ8S4N+MN7s3DwNfV7U3FYjyChrfXKDP07wgabTT93MDj2xVJnNvWkfuUVoZjPlhi/Jmr9b/nS o3sooJMzMzN/EPdY6vz5JQj0NZQKAA9nQc7szuZ6aqbmonnw== X-Google-Smtp-Source: AGHT+IHhsa4xXStr5djydA447oqZ0eywB6dQmFgO7T5029BQXALrAgyEhVKlX9qDw4OJNWb9FlBZHQ== X-Received: by 2002:a05:6830:dc2:b0:709:441a:351b with SMTP id 46e09a7af769-7096b7da64cmr506886a34.8.1722464917301; Wed, 31 Jul 2024 15:28:37 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:36 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE), linux-rpi-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 v5 02/12] dt-bindings: PCI: brcmstb: Add 7712 SoC description Date: Wed, 31 Jul 2024 18:28:16 -0400 Message-Id: <20240731222831.14895-3-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Add description for the 7712 SoC, a Broadcom STB sibling chip of the RPi 5. The 7712 uses three reset controllers: rescal, for phy reset calibration; bridge, for the bridge between the PCIe bus and the memory bus; and swinit, which is a "soft" initialization of the PCIe HW. Signed-off-by: Jim Quinlan Reviewed-by: Florian Fainelli Reviewed-by: Krzysztof Kozlowski --- .../bindings/pci/brcm,stb-pcie.yaml | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 7d2552192153..0925c520195a 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -21,6 +21,7 @@ properties: - brcm,bcm7425-pcie # Broadcom 7425 MIPs - brcm,bcm7435-pcie # Broadcom 7435 MIPs - brcm,bcm7445-pcie # Broadcom 7445 Arm + - brcm,bcm7712-pcie # Broadcom STB sibling of Rpi 5 reg: maxItems: 1 @@ -96,10 +97,12 @@ properties: maxItems: 3 resets: - maxItems: 1 + minItems: 1 + maxItems: 3 reset-names: - maxItems: 1 + minItems: 1 + maxItems: 3 required: - compatible @@ -151,6 +154,27 @@ allOf: - resets - reset-names + - if: + properties: + compatible: + contains: + const: brcm,bcm7712-pcie + then: + properties: + resets: + minItems: 3 + maxItems: 3 + + reset-names: + items: + - const: rescal + - const: bridge + - const: swinit + + required: + - resets + - reset-names + unevaluatedProperties: false examples: From patchwork Wed Jul 31 22:28:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749289 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3129416DC2E for ; Wed, 31 Jul 2024 22:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464921; cv=none; b=IdEoc98sLbVymVIqPEXq+P0aERR7EfA8yVu536IXiZwhRrCvlNGikqS+9FT8PSQDxRrCnPJovM11o1knKmfIkZYDJfxBsRiO586Vwl53EK/sfRz9MRsezDrpmY7HjQL+Kf2s3RzBR4Xl6LLHz47fdjI5Fq4l58PosTU1VOxcg9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464921; c=relaxed/simple; bh=tXTAjZtcWhewtsJ5mnN9e2cBSHCNX3dQ2tHxYaPUuhA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Z1/Gyfs6deYvnMk+NSizRW4v8IHVgaYNlRy62XzkXYLGXdEhOuSqjWosIIneTOuGOsEIJNoRgqZ45uY1p9i5RZrssmscM13lAY3gzz22KjWjOllTDvq2jIQ19KX3B91a3Lj/KXZopBXc4pNw8iOg3Hkz5KhEziCTvm4J6D0bBuY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=hruA2eJ+; arc=none smtp.client-ip=209.85.210.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="hruA2eJ+" Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-7093b53f315so2306087a34.2 for ; Wed, 31 Jul 2024 15:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464919; x=1723069719; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=J83Zv5BEREvIAUqofWicGKSSTCWUlV2zoywp7ximAEQ=; b=hruA2eJ+kRepZRi+HwCoZdNH6HaXyhU+vNCyXqnWvpQ5cT1C3a1OtG6BjgeRblHmjL Hw8PSNAKBIm4emrjNcMKw/kHY6qv6eE6xJ174TWfy+4NWQjHADrxHYJCczEQ5nV7O7fp X7ILbI6rqPp4u7A+le2dh+JqvryGxO1t4ObBA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464919; x=1723069719; h=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=J83Zv5BEREvIAUqofWicGKSSTCWUlV2zoywp7ximAEQ=; b=FMFODrqfof+Sq2cYUgZUhFlSaYl0Y9bSa3+15ZVQs+PQ5z69bejDvmno0ul9PIQAH8 0hoTSMn8cdQ96nsAWndj1bKpyVWFwkWnIfA/RlnZv3KFN+FKV63yUulMQivs7RNtlNd5 6qycNZDG8PLBCiJV8d8hni17pxBbRmBE5qKHs15ClsVT3ToLENIugZG74qAZY3wBdp0o jg2KRekyBOh8x9HyqjwNCT+Xfps9JCa9QFN9gIVmUitQ2KCc0O/PKYczG801XrRyBnjp c8nXkO+rCtZPbQaBxrnVxUeFMRuBc2td1xR0djnTkde9pcrB8A7xkCkyLbcRS+dj3sv7 ZmIw== X-Gm-Message-State: AOJu0YwjgFfToN+RYsR9N49+OXWtc2+TuRliwWYdp77Y0x3p4iCdaq95 Wohb5XEJ0KXkRSQalvPzyEES9Zqp0owFR++cUSJDVPBkvEOrPzLJW/Gf33Vqlgy+pHFjALgkAi9 9Bh1CTWeOLudIDkgzVPWLfrCDPIb+EVgIPqetLhYLkVdCvA5q3NWI3sGwfzyuu8++LMr9oELePM etpyxzG9SE5Jwo+GPRC37f94BO4ZEuVXDPVmpC+r8EHKZBYA== X-Google-Smtp-Source: AGHT+IHIP5WdHy/ihYegTa0DgMvLcOxm3pAjIV58KNh8m6EZyfzcAcqiHesM2kvbR33Jn8f0UeLyNA== X-Received: by 2002:a05:6830:6c0e:b0:709:44dc:dde7 with SMTP id 46e09a7af769-7096b8054afmr717661a34.9.1722464918795; Wed, 31 Jul 2024 15:28:38 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:38 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Philipp Zabel , 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 v5 03/12] PCI: brcmstb: Use common error handling code in brcm_pcie_probe() Date: Wed, 31 Jul 2024 18:28:17 -0400 Message-Id: <20240731222831.14895-4-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: o Move the clk_prepare_enable() below the resource allocations. o Move the clk_prepare_enable() out of __brcm_pcie_remove() but add it to the end of brcm_pcie_remove(). o Add a jump target (clk_disable_unprepare) so that a bit of exception handling can be better reused at the end of this function implementation. o Use dev_err_probe() where it makes sense. Signed-off-by: Jim Quinlan Reviewed-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index c08683febdd4..7595e7009192 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1473,7 +1473,6 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) dev_err(pcie->dev, "Could not stop phy\n"); if (reset_control_rearm(pcie->rescal)) dev_err(pcie->dev, "Could not rearm rescal reset\n"); - clk_disable_unprepare(pcie->clk); } static void brcm_pcie_remove(struct platform_device *pdev) @@ -1484,6 +1483,7 @@ static void brcm_pcie_remove(struct platform_device *pdev) pci_stop_root_bus(bridge->bus); pci_remove_root_bus(bridge->bus); __brcm_pcie_remove(pcie); + clk_disable_unprepare(pcie->clk); } static const int pcie_offsets[] = { @@ -1613,31 +1613,26 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->ssc = of_property_read_bool(np, "brcm,enable-ssc"); - ret = clk_prepare_enable(pcie->clk); - if (ret) { - dev_err(&pdev->dev, "could not enable clock\n"); - return ret; - } pcie->rescal = devm_reset_control_get_optional_shared(&pdev->dev, "rescal"); - if (IS_ERR(pcie->rescal)) { - clk_disable_unprepare(pcie->clk); + if (IS_ERR(pcie->rescal)) return PTR_ERR(pcie->rescal); - } + pcie->perst_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "perst"); - if (IS_ERR(pcie->perst_reset)) { - clk_disable_unprepare(pcie->clk); + if (IS_ERR(pcie->perst_reset)) return PTR_ERR(pcie->perst_reset); - } - ret = reset_control_reset(pcie->rescal); + ret = clk_prepare_enable(pcie->clk); if (ret) - dev_err(&pdev->dev, "failed to deassert 'rescal'\n"); + return dev_err_probe(&pdev->dev, ret, "could not enable clock\n"); + + ret = reset_control_reset(pcie->rescal); + if (dev_err_probe(&pdev->dev, ret, "failed to deassert 'rescal'\n")) + goto clk_disable_unprepare; ret = brcm_phy_start(pcie); if (ret) { reset_control_rearm(pcie->rescal); - clk_disable_unprepare(pcie->clk); - return ret; + goto clk_disable_unprepare; } ret = brcm_pcie_setup(pcie); @@ -1654,10 +1649,8 @@ static int brcm_pcie_probe(struct platform_device *pdev) msi_np = of_parse_phandle(pcie->np, "msi-parent", 0); if (pci_msi_enabled() && msi_np == pcie->np) { ret = brcm_pcie_enable_msi(pcie); - if (ret) { - dev_err(pcie->dev, "probe of internal MSI failed"); + if (dev_err_probe(pcie->dev, ret, "probe of internal MSI failed")) goto fail; - } } bridge->ops = pcie->type == BCM7425 ? &brcm7425_pcie_ops : &brcm_pcie_ops; @@ -1678,6 +1671,9 @@ static int brcm_pcie_probe(struct platform_device *pdev) fail: __brcm_pcie_remove(pcie); +clk_disable_unprepare: + clk_disable_unprepare(pcie->clk); + return ret; } From patchwork Wed Jul 31 22:28:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749290 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 075BB16E875 for ; Wed, 31 Jul 2024 22:28:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464923; cv=none; b=OoIas69+MBS9ZVFkJwC/GCS5GTpA5Z+UOAUhkNeUeSSe1uj77BbIspou+3uGJtKSGkfoEulmQ35jNJz0XCkjVSCTTPug0W8MoGQbsPA5l0pDVCSTZsT/L7XVTSMCQDkCOnVSmcg9SOKbl7RQAQgNw+F2McRQ6msptJbOQ6q2A7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464923; c=relaxed/simple; bh=XABkIvkgFRWEK75ywChcUI9iJgm62PnlqcP6SvDCSlo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=m1NCaMU2rHGREZ85MUqI85rNNudCd/4mP6HSWLLJoKXI7iE1fhfe9RAX1OLv5Z1KS7yr3atlIfaHwfFYWG2O4It0BSFkN/0lpDX1vIkQz900IVBMl6fvTKVriisLDsCpsY//ON7se9iwNmqNc82zv1Bws9c1LFjTmQ14gxTGMUs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=OgdIVUvz; arc=none smtp.client-ip=209.85.160.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="OgdIVUvz" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-44ff7bdb5a6so31924511cf.3 for ; Wed, 31 Jul 2024 15:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464920; x=1723069720; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=WKU/C7t+A6Qxg3BQxfQdxyrXxjr78aUecg8SreaTGI0=; b=OgdIVUvzdU2pYRGnMoDJ0qGRxCUD0uOwAWzxPu3546VAp+QQPAd3fLp/rDuWAepoe9 7qMeUI2cVt79bcp3gVNpONehYCHaF8JpFj877JgzoIiwFw1mumeP/WP3SY+CUnjL0MZl yZiDm3yPabrfn/WxyM6ik8zN3KcX8p6JzJCXs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464920; x=1723069720; h=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=WKU/C7t+A6Qxg3BQxfQdxyrXxjr78aUecg8SreaTGI0=; b=oer/gjetJaQLPMacHs0B/Tosg7HYhDQy/kWMNppbv8fFEenrU9t7+/i64wxdQlXkaD o5qmC3uEsQy2FM+lvSr0s6ZNv37iQbOapJQDVUFrGMSIx0bc05BQu5yFH5LjhIP4QOVG 0rIIZEhHw8JUwcnKaCSI+wkQh8q7naP0q9cnrYP58kuXEcjiXj+S2KmxKXw7KwQn4Kot NZ175Gk2UxoItrwPnul1lKJAVInZeYklaO5CQLgFtynBkaUWky1b1P7hfqEHIbjDsk45 L1M6C6Rk3JPKLebANGDlC0hOv7BNJGRMi/FytINq/J7BiqvzhgnuCU4Lz8SmswvI6Vcq gbxQ== X-Gm-Message-State: AOJu0YzPSj+W/JDRxFnuvAnLUjIv5dp/5rRXZoNWzv8+vHYkepeRVV4r 5Khqt1o6aSt76hwInFY9lQ0v9TI0wY/VpjSi9uFHhh68Kbhfb+MRjqFx4PZJcrLJJc27xT/THdF Vt2bFkiQtv6q9YSaVuhikK1WArqz53CD4mt1VvNqcxhQn1Q+sH+A31qfCEYe4/JbtpI8MbkLP7k y9LW9bWQZYJTfg/9KW5sSx1yCv8KjhH6tcxkwx4mswimOhzw== X-Google-Smtp-Source: AGHT+IH5WIAKBTNzHOk2cOY6cbJUFfh9InV6VDCil+I8iLVSY6sNMvSKIX+eU+Wup3PUxdLc/xIMzQ== X-Received: by 2002:ac8:7f8d:0:b0:445:2e9:330e with SMTP id d75a77b69052e-4514f9a2ea4mr8919321cf.37.1722464920281; Wed, 31 Jul 2024 15:28:40 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:39 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Philipp Zabel , 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 v5 04/12] PCI: brcmstb: Use bridge reset if available Date: Wed, 31 Jul 2024 18:28:18 -0400 Message-Id: <20240731222831.14895-5-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The 7712 SOC has a bridge reset which can be described in the device tree. Use it if present. Otherwise, continue to use the legacy method to reset the bridge. Signed-off-by: Jim Quinlan Reviewed-by: Florian Fainelli Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/pcie-brcmstb.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 7595e7009192..4d68fe318178 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -265,6 +265,7 @@ struct brcm_pcie { enum pcie_type type; struct reset_control *rescal; struct reset_control *perst_reset; + struct reset_control *bridge_reset; int num_memc; u64 memc_size[PCIE_BRCM_MAX_MEMC]; u32 hw_rev; @@ -732,12 +733,19 @@ static void __iomem *brcm7425_pcie_map_bus(struct pci_bus *bus, static void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val) { - u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK; - u32 shift = RGR1_SW_INIT_1_INIT_GENERIC_SHIFT; + if (val) + reset_control_assert(pcie->bridge_reset); + else + reset_control_deassert(pcie->bridge_reset); - tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); - tmp = (tmp & ~mask) | ((val << shift) & mask); - writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); + if (!pcie->bridge_reset) { + u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK; + u32 shift = RGR1_SW_INIT_1_INIT_GENERIC_SHIFT; + + tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); + tmp = (tmp & ~mask) | ((val << shift) & mask); + writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); + } } static void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val) @@ -1621,10 +1629,16 @@ static int brcm_pcie_probe(struct platform_device *pdev) if (IS_ERR(pcie->perst_reset)) return PTR_ERR(pcie->perst_reset); + pcie->bridge_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "bridge"); + if (IS_ERR(pcie->bridge_reset)) + return PTR_ERR(pcie->bridge_reset); + ret = clk_prepare_enable(pcie->clk); if (ret) return dev_err_probe(&pdev->dev, ret, "could not enable clock\n"); + pcie->bridge_sw_init_set(pcie, 0); + ret = reset_control_reset(pcie->rescal); if (dev_err_probe(&pdev->dev, ret, "failed to deassert 'rescal'\n")) goto clk_disable_unprepare; From patchwork Wed Jul 31 22:28:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749291 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6055216E89E for ; Wed, 31 Jul 2024 22:28:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464924; cv=none; b=MWPnfUO1slC9iy6ndoEenD7GMXSPcbwTPqNcxPP4hk9WwPL8UkrIrtLFLEnV/V7d8dXjz1ciIKfud85hb1AQswZBYd/RLiMxkrcVrjR2TbUo2pJ/ZPuqaASny30dH02c5xZwJ2mKQ3Pu/ysVjGC35xNLRkgEdsUxyztWyx9f6Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464924; c=relaxed/simple; bh=ohxTxIMDhY1ATcgdpM1JyttNCDtL0q2lDi0qmnU6oPc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=RFYcwRPSKcMES6BTqotocAgtW1gJxFIRxNiAEf8/Kxc8y21kkDhwH28/GpJP/IOi1rYjedq/tXM7UT4Gvhzibc5FhEdmHfCy+ARo6eYhA0TFJc5GWJ0y50hkva7iFcbB+0HOuC75xbKKwpowJl6dR2ASTZ9IGhAjPYzcrdQJJ/U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=gekSnrla; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="gekSnrla" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-44fdcd7a622so31050101cf.0 for ; Wed, 31 Jul 2024 15:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464922; x=1723069722; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=BvkPsLOG5fUE2ytDC/96EogS/1H6a6HtgvVDjzytUG8=; b=gekSnrlaIcBasVelXAtPu0R+aEG5i5alx1+igVCPdMmZxNeQr95zRQy8HeESR51x+C 4oRS8Lnh1Jf5aiK5+a8HZuc1kK/+0Tom0vyCTrwg64zF+xO5COMFIEltT5WJi6qsJOV7 QQjT36VRLsRepI7Y7bz2SykaE2q//W+4lqPew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464922; x=1723069722; h=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=BvkPsLOG5fUE2ytDC/96EogS/1H6a6HtgvVDjzytUG8=; b=kV0VwcZZXNVM29s9uU0cnskf2SgohTJgdzBWDhbN3eSgyOBd7AGnkVLhG3l2yUq264 B2svhYlWmaqAZp8ub+OWOnv6EoumBQ66XFac0iXGv0vqBgGb/dsa8Dk2oHK5GgOjIBPc zcRDBfxQjPkjwxSvxizL1xVB5TkmUBkOLHHI/gPxZywZg0YPVaIl6qslDs0asISigui9 hkerv6ix+Ctr+FNStlKsVzpmjAZryhxgG2TSr0P2ABimqPWmp18nMO/FmFlt+5k6127A o4CvGFD5aQzbIxV1xztBPD1wwl8N7hToxzg2ERV7qOctZJPdZjGQv3z2R2OpbNufQVUj EmYw== X-Gm-Message-State: AOJu0YxJyXZ0zXqCdU7fW6X2MSEv6ctlD6AdJ418wneGrKCHsno+R4vk 63eU9Z269cfAuJX5sOBmUgXV+JZaVErfhVY7qfT67jjyel73jBsEWCQQmDxTLaDXNT7rq26nWRW /W/9/narQuDnEAwZnXK2O+kWvQtzf/EcI2DLgZ3BSR+yGuh+c0pnEA+cCuY4PoREMnKBUvNAcYm 6QOU3I3s2XtdyBaIZ1X/4ggYRVbO5iNNRfMatTsy2jHe3JQg== X-Google-Smtp-Source: AGHT+IFBtq3zfvlVDpCsnHiydXJF3wP25FYPP/JkCKWE8phEA2Y4P9A5CFNfuo6bGZRLAirUY+0/bA== X-Received: by 2002:ac8:7f87:0:b0:447:e542:ab00 with SMTP id d75a77b69052e-451567a84b4mr8510471cf.50.1722464921783; Wed, 31 Jul 2024 15:28:41 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:41 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Philipp Zabel , 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 v5 05/12] PCI: brcmstb: Use swinit reset if available Date: Wed, 31 Jul 2024 18:28:19 -0400 Message-Id: <20240731222831.14895-6-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The 7712 SOC adds a software init reset device for the PCIe HW. If found in the DT node, use it. Signed-off-by: Jim Quinlan Reviewed-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 4d68fe318178..948fd4d176bc 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -266,6 +266,7 @@ struct brcm_pcie { struct reset_control *rescal; struct reset_control *perst_reset; struct reset_control *bridge_reset; + struct reset_control *swinit_reset; int num_memc; u64 memc_size[PCIE_BRCM_MAX_MEMC]; u32 hw_rev; @@ -1633,12 +1634,30 @@ static int brcm_pcie_probe(struct platform_device *pdev) if (IS_ERR(pcie->bridge_reset)) return PTR_ERR(pcie->bridge_reset); + pcie->swinit_reset = devm_reset_control_get_optional_exclusive(&pdev->dev, "swinit"); + if (IS_ERR(pcie->swinit_reset)) + return PTR_ERR(pcie->swinit_reset); + ret = clk_prepare_enable(pcie->clk); if (ret) return dev_err_probe(&pdev->dev, ret, "could not enable clock\n"); pcie->bridge_sw_init_set(pcie, 0); + if (pcie->swinit_reset) { + ret = reset_control_assert(pcie->swinit_reset); + if (dev_err_probe(&pdev->dev, ret, "could not assert reset 'swinit'\n")) + goto clk_disable_unprepare; + + /* HW team recommends 1us for proper sync and propagation of reset */ + udelay(1); + + ret = reset_control_deassert(pcie->swinit_reset); + if (dev_err_probe(&pdev->dev, ret, + "could not de-assert reset 'swinit' after asserting\n")) + goto clk_disable_unprepare; + } + ret = reset_control_reset(pcie->rescal); if (dev_err_probe(&pdev->dev, ret, "failed to deassert 'rescal'\n")) goto clk_disable_unprepare; From patchwork Wed Jul 31 22:28:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749292 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1336816EB79 for ; Wed, 31 Jul 2024 22:28:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464926; cv=none; b=oQdYAVA4upse7PpPv9fQ7oWCaqy0dMFweURlFD6VZvBRQ52Y4B5XGPmtRj0CB1EFG+GgunyRjkEv43MBGELuLrs8AEoxxcCM054yeM1duOfhmcP3DDpep/wqWVnkEVFH8hmSRl/nBPNErF7d6vuYc0syfflScdHX5/hqV8ZPXQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464926; c=relaxed/simple; bh=s1fh7f0lmM/Iaphg/fT8tq7g+OZlQdDIO9Songz0MXU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=jAduLfV7Cy157+W4SLUwyfxOJYcshNbfIO82CSmlWfO0YC93nCwJknwR1amljO3r6aaTxSBd23Po05cZfneo81LoZmjoWAT1paM/wjHKV1OPx9Nu6vNdQtMN1P5+SVDzCYUROQfLp121qYDXkLBItIpSFbHWYbY8d2rL4440BIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=ZY+mXoHr; arc=none smtp.client-ip=209.85.160.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="ZY+mXoHr" Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-44fea2d40adso39106481cf.0 for ; Wed, 31 Jul 2024 15:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464923; x=1723069723; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=MXnrW2wZh+02qVnTjCR225qdcoHcBT0cTq9H5uoC8Ts=; b=ZY+mXoHrSXeHp0GzmeIWzokvVKBtogAdmHRqfq6lCVUqTG1v+zC+D6E3CeBVvQDl0v uN24Ejydde1Kr5nYfNtbl6wbzTp8+wBA0H95LxFFnaPnTZYf35gEI//x/2bSY3BwpEYH E7UNKWgy3ppdtBKID0QvdswtxX7+gH+1YxYu4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464923; x=1723069723; h=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=MXnrW2wZh+02qVnTjCR225qdcoHcBT0cTq9H5uoC8Ts=; b=WP5y8WmdddQvtQydU3YVbN2nYwlB6BoUwUvRQrIvMn/NqGlHyuZjw22EdqdtCl3QYs igDRbtmPWAJSHXpm582RhBCh53Sc34U+fPs/hrRSgrNM/tB3UCg8UHbt54BKHcLF7Cre o4dnXfHx4/2tjs6dXn0r826CIcnkCN36r3WBqPR0JhD0H8u2XV8Xmp5bD24J24E21ok5 1xkndDjIt0qQ0PAsmMApyeXOV6CDEYsqgxrHW5oYxP84H8NOhqGqylV9nThYf7JuFP9+ MfwVmv+iqgdFrZjk4EWHXrYK4jh5ObG+SlFfWrubzLvxl82vvRfVosFSYaHPmo6ER7XC A1DQ== X-Gm-Message-State: AOJu0YzFKDnnCGl1UYVXY6nTt/qDNYHXPKkQDCOco1mB0ZSMAZyupXDt eWclqGnCwgH6jt30K0Wn1NgFvJcjMQgXxfzUuWMHLZiXffbCjm4lYpN68Y2Ch8KRpEsLRyqDuij W0rOFN/jzNJxwLrg6gFDEMtsPiwOdECQAeruz+LG1DAa8wQDNxVaYFNRb8+wCX8XqA/AmxkulFa bjOrfGhAirBEc9mu5DOuh7+cz0aP9yrxl+QT0nq7uPVdNCBQ== X-Google-Smtp-Source: AGHT+IGpqHg8M4yPN3SsdyZANWJHE4R2f7s83hYUJdBqpCyFA+T5oHK7zAIU12me/Z/Bj/nc/ABqzQ== X-Received: by 2002:ac8:7dc6:0:b0:44f:fb58:8c3e with SMTP id d75a77b69052e-4514f9b69b1mr8004891cf.46.1722464923324; Wed, 31 Jul 2024 15:28:43 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:42 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , 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), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 06/12] PCI: brcmstb: PCI: brcmstb: Make HARD_DEBUG, INTR2_CPU_BASE offsets SoC-specific Date: Wed, 31 Jul 2024 18:28:20 -0400 Message-Id: <20240731222831.14895-7-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Do prepatory work for the 7712 SoC, which is introduced in a future commit. Our HW design has changed two register offsets for the 7712, where previously it was a common value for all Broadcom SOCs with PCIe cores. Specifically, the two offsets are to the registers HARD_DEBUG and INTR2_CPU_BASE. Signed-off-by: Jim Quinlan Reviewed-by: Stanimir Varbanov Reviewed-by: Florian Fainelli Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/pcie-brcmstb.c | 39 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 948fd4d176bc..9fa1500b8eee 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -122,7 +122,6 @@ #define PCIE_MEM_WIN0_LIMIT_HI(win) \ PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8) -#define PCIE_MISC_HARD_PCIE_HARD_DEBUG 0x4204 #define PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2 #define PCIE_MISC_HARD_PCIE_HARD_DEBUG_L1SS_ENABLE_MASK 0x200000 #define PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x08000000 @@ -131,9 +130,9 @@ (PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK | \ PCIE_MISC_HARD_PCIE_HARD_DEBUG_L1SS_ENABLE_MASK) -#define PCIE_INTR2_CPU_BASE 0x4300 #define PCIE_MSI_INTR2_BASE 0x4500 -/* Offsets from PCIE_INTR2_CPU_BASE and PCIE_MSI_INTR2_BASE */ + +/* Offsets from INTR2_CPU and MSI_INTR2 BASE offsets */ #define MSI_INT_STATUS 0x0 #define MSI_INT_CLR 0x8 #define MSI_INT_MASK_SET 0x10 @@ -184,9 +183,11 @@ #define SSC_STATUS_PLL_LOCK_MASK 0x800 #define PCIE_BRCM_MAX_MEMC 3 -#define IDX_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_INDEX]) -#define DATA_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_DATA]) -#define PCIE_RGR1_SW_INIT_1(pcie) (pcie->reg_offsets[RGR1_SW_INIT_1]) +#define IDX_ADDR(pcie) ((pcie)->reg_offsets[EXT_CFG_INDEX]) +#define DATA_ADDR(pcie) ((pcie)->reg_offsets[EXT_CFG_DATA]) +#define PCIE_RGR1_SW_INIT_1(pcie) ((pcie)->reg_offsets[RGR1_SW_INIT_1]) +#define HARD_DEBUG(pcie) ((pcie)->reg_offsets[PCIE_HARD_DEBUG]) +#define INTR2_CPU_BASE(pcie) ((pcie)->reg_offsets[PCIE_INTR2_CPU_BASE]) /* Rescal registers */ #define PCIE_DVT_PMU_PCIE_PHY_CTRL 0xc700 @@ -205,6 +206,8 @@ enum { RGR1_SW_INIT_1, EXT_CFG_INDEX, EXT_CFG_DATA, + PCIE_HARD_DEBUG, + PCIE_INTR2_CPU_BASE, }; enum { @@ -651,7 +654,7 @@ static int brcm_pcie_enable_msi(struct brcm_pcie *pcie) BUILD_BUG_ON(BRCM_INT_PCI_MSI_LEGACY_NR > BRCM_INT_PCI_MSI_NR); if (msi->legacy) { - msi->intr_base = msi->base + PCIE_INTR2_CPU_BASE; + msi->intr_base = msi->base + INTR2_CPU_BASE(pcie); msi->nr = BRCM_INT_PCI_MSI_LEGACY_NR; msi->legacy_shift = 24; } else { @@ -898,12 +901,12 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) /* Take the bridge out of reset */ pcie->bridge_sw_init_set(pcie, 0); - tmp = readl(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + tmp = readl(base + HARD_DEBUG(pcie)); if (is_bmips(pcie)) tmp &= ~PCIE_BMIPS_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK; else tmp &= ~PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK; - writel(tmp, base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + writel(tmp, base + HARD_DEBUG(pcie)); /* Wait for SerDes to be stable */ usleep_range(100, 200); @@ -1072,7 +1075,7 @@ static void brcm_config_clkreq(struct brcm_pcie *pcie) } /* Start out assuming safe mode (both mode bits cleared) */ - clkreq_cntl = readl(pcie->base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + clkreq_cntl = readl(pcie->base + HARD_DEBUG(pcie)); clkreq_cntl &= ~PCIE_CLKREQ_MASK; if (strcmp(mode, "no-l1ss") == 0) { @@ -1115,7 +1118,7 @@ static void brcm_config_clkreq(struct brcm_pcie *pcie) dev_err(pcie->dev, err_msg); mode = "safe"; } - writel(clkreq_cntl, pcie->base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + writel(clkreq_cntl, pcie->base + HARD_DEBUG(pcie)); dev_info(pcie->dev, "clkreq-mode set to %s\n", mode); } @@ -1337,9 +1340,9 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie) writel(tmp, base + PCIE_MISC_PCIE_CTRL); /* Turn off SerDes */ - tmp = readl(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + tmp = readl(base + HARD_DEBUG(pcie)); u32p_replace_bits(&tmp, 1, PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK); - writel(tmp, base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + writel(tmp, base + HARD_DEBUG(pcie)); /* Shutdown PCIe bridge */ pcie->bridge_sw_init_set(pcie, 1); @@ -1425,9 +1428,9 @@ static int brcm_pcie_resume_noirq(struct device *dev) pcie->bridge_sw_init_set(pcie, 0); /* SERDES_IDDQ = 0 */ - tmp = readl(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + tmp = readl(base + HARD_DEBUG(pcie)); u32p_replace_bits(&tmp, 0, PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK); - writel(tmp, base + PCIE_MISC_HARD_PCIE_HARD_DEBUG); + writel(tmp, base + HARD_DEBUG(pcie)); /* wait for serdes to be stable */ udelay(100); @@ -1499,12 +1502,16 @@ static const int pcie_offsets[] = { [RGR1_SW_INIT_1] = 0x9210, [EXT_CFG_INDEX] = 0x9000, [EXT_CFG_DATA] = 0x9004, + [PCIE_HARD_DEBUG] = 0x4204, + [PCIE_INTR2_CPU_BASE] = 0x4300, }; static const int pcie_offsets_bmips_7425[] = { [RGR1_SW_INIT_1] = 0x8010, [EXT_CFG_INDEX] = 0x8300, [EXT_CFG_DATA] = 0x8304, + [PCIE_HARD_DEBUG] = 0x4204, + [PCIE_INTR2_CPU_BASE] = 0x4300, }; static const struct pcie_cfg_data generic_cfg = { @@ -1539,6 +1546,8 @@ static const int pcie_offset_bcm7278[] = { [RGR1_SW_INIT_1] = 0xc010, [EXT_CFG_INDEX] = 0x9000, [EXT_CFG_DATA] = 0x9004, + [PCIE_HARD_DEBUG] = 0x4204, + [PCIE_INTR2_CPU_BASE] = 0x4300, }; static const struct pcie_cfg_data bcm7278_cfg = { From patchwork Wed Jul 31 22:28:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749293 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AE1F16EBFA for ; Wed, 31 Jul 2024 22:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464927; cv=none; b=mN22yvM48DEC3cgZ5ojBwnZZomhdbn3nAt0Zssfk5pS7qSjieS2KS/VrGuAVo2DPKVKr/TNm04YfENvIxhYYMiD1xiEE8RcTTsvjlgm8pE8Y025bP9VDUUZMIpOr9z8zVJEFnRVQkCRcnyrP0vaxdRC3E7rj3v6TziwYOhuRFAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464927; c=relaxed/simple; bh=Axler9r52aj1s9GK2m+ZS5HEzmaURax/pBU9GtjX+YU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Ql074CbaxRBHlzrAy9WNuTFjTtD7RN7ov7IdHM4hzhVeD5Ndtgof3Uk+BNaOe7w0LqT58kyMvRZDtloTC9JaSxk2kFEArCAANOEWRqBc6vWvoJ7Gkl6icWr7kSEdJVp9jmUtCnWlTnvK4DJfY+lOfuYIGDkDE9Z+PjUfST21kVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=ZIjnoSEW; arc=none smtp.client-ip=209.85.160.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="ZIjnoSEW" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-44ff7cc5432so43084661cf.3 for ; Wed, 31 Jul 2024 15:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464925; x=1723069725; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=tJc8HBYFIKOYZ9CyZ9IbVGyaBM2QRYS+Mj0ZBsZxAaw=; b=ZIjnoSEWyf8tibkylAARjhWmCx8QJN0arOi04w4k8lPCPag3vBA9raSgQbIynXI8u+ vqN6zYudvWciuWdwGOiyOd+IE2REt1anYcJ43VYlGxCDeOnKkAo/XicBXbkqqdvizaTR I0u3SbRybEN38mDfYbo96LaaR9LuHiD7bk4mQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464925; x=1723069725; h=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=tJc8HBYFIKOYZ9CyZ9IbVGyaBM2QRYS+Mj0ZBsZxAaw=; b=jRHmEhRfRQbz6AybKYx4ZvplHdjFbsf7OMEy560uy+RoMOz5HWEUzt5MWzxbvd0ELi +B+APCsJegd6O0BYsbE0JGRUMpI/Keb3UnGMG4W4ExUIOktCiBpN9/qVyyRIr0F+iNvU CF72WcGRCWtGFzkDXfiiW57B9CnzeUvz12i6J09nENNJ8KGScBVs2xg2BkeTlzJOpdlU Wje+sh+KTo5C4mr7dYP3oVFgkJXyH+OyLNKxv7LzQxwlSVmM7T1e7+luZzB4gGMQjtZ2 FMVt4lZCk5fCfzzoV3jo/2NADF1TUhoCRC81M1OYweOuy11g2PKt9hPsn2/S0DCpt3NJ NHQA== X-Gm-Message-State: AOJu0Yw6RRNT1BzGLA6yiH1T5/UKs8r0qTnPy22Ii4arzAUBwWUj4xXP QjXDvBs4mWE4M++WBhiqpK2mn6QvnTHFDK3kPEMAlmU0GLhvERF/xlhudqELC/zCJ7Rf/yk/u8x XmroEwQG+jzDtyRAKTjUVGzsNd1b3/FpD8Z7TaEVQxX9dSdeTMBE3Xd2n5pd3DW9F/++i98wkrH YyWhnHkAfYqdAO+3OEDTYNfyFt/p0oM56nGO0S0g7g7J0pgg== X-Google-Smtp-Source: AGHT+IGWS8XJqJxSeAH/l9U2iSnwykrx+/R/UPoZ2dJMSXMMtQONEAADXPeWL2Ey1+sfyHjCoQX+JQ== X-Received: by 2002:a05:622a:1922:b0:44d:6627:4b16 with SMTP id d75a77b69052e-4514f9bdc74mr7720561cf.1.1722464924732; Wed, 31 Jul 2024 15:28:44 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:44 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , 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), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 07/12] PCI: brcmstb: Remove two unused constants from driver Date: Wed, 31 Jul 2024 18:28:21 -0400 Message-Id: <20240731222831.14895-8-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Remove two constants in the driver which are no longer used: RGR1_SW_INIT_1_INIT_MASK and RGR1_SW_INIT_1_INIT_SHIFT. Signed-off-by: Jim Quinlan Reviewed-by: Stanimir Varbanov Reviewed-by: Florian Fainelli Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/pcie-brcmstb.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 9fa1500b8eee..1ae66c639186 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -210,11 +210,6 @@ enum { PCIE_INTR2_CPU_BASE, }; -enum { - RGR1_SW_INIT_1_INIT_MASK, - RGR1_SW_INIT_1_INIT_SHIFT, -}; - enum pcie_type { GENERIC, BCM7425, From patchwork Wed Jul 31 22:28:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749294 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47E6216EBFA for ; Wed, 31 Jul 2024 22:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464929; cv=none; b=iQfuseS2b8cIlwSqroRvcubnozAUwsqI+vAKSvDagVCusJcc6s8m5HKDcETy80iJmLhLAsf1Fh4jdKhkEMYxK6zu+NTg20ckc7xlLpBPDHKDzs0HVOpgPsQMuMbpkVcOqrfDcn2PeJ/grqmKrQpLXLqXM/8XXZ/r7d/7MBxD3w0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464929; c=relaxed/simple; bh=y4hjFNKfNrZAXib/tvA7NVNsQrFiOMDnP+KgXAPJWNE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=Fqp6KmoZ43JuzH9w9h7yNj5omMonrx2hw3J5iFn5rid5xYBGlEfvi3nFRxiUudZNccNx7aO5MMXmm4za6m8rkwo1m6oTCb4pkHmleN9OONMQ4UBsudoW74o6k7rWnCjZpVlusRi+ADZSG5UJ119eBBwmbeAXPM01+6wVCR5l+YQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=fYK4yan/; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="fYK4yan/" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-450059a25b9so13716921cf.0 for ; Wed, 31 Jul 2024 15:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464926; x=1723069726; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Bv0ulUw6sT8Iayb14UqZxCz07Sx/8FXvzTyd8OjlUtI=; b=fYK4yan/eHVFlukjIxgLOOy6nlVRU2tBavQ6Hbdgj8gY6M4ZF9tbOXWDzsU50irc6N m940ekCSz0EjaxX2xU4ZuiQCXAsR+l15TxqofhTYew+lsqYdyz3QY/FPo/+VGOI0jMxW EVIWXHqBVjNY9YWH11Y3//guLyK4qcF71w2uE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464926; x=1723069726; h=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=Bv0ulUw6sT8Iayb14UqZxCz07Sx/8FXvzTyd8OjlUtI=; b=Q712efg4qKhAS4M6nNbBXhIG+9xh2QCoYzkr1MLbmRM5v6v/jnTXJ+YaNi2VlZRcGi m1swiz6qgJhoPlozgP72VX+TJuvxtjJZicdt5gHDa1jtrgoqlH+c2SJSbb1yqdFDu/Pn ADUe3GTTtRpNTlTS5hwYU3gn5Fdkj7RPJ5sd69TLnhPxgCC/I424yYxDTQKex8/y0mzg RUaOGeSDriKl5lSj9BumAToDjc/L8SSoIWJpVoux1eDylUp5ZM36fA0PeWkfPTFjfV92 W9lB8b11aMKWBZVuvFB2OsuE7XbquHRJMkUn76sAMKSmpZNQwCrHQYNbw7uhzcuBzZVU l1zQ== X-Gm-Message-State: AOJu0YyCuEVRtCqk0AWMRr0CEGTsJ1xurmt+FrBlfdZrJQNLD5LqewpM 4kwxMyKHoGmPZRUKx2U0jqIIeSNm1xADAHgqNacwpEJAqKUHNOBWcKHZ5mSgpbw9fmpu+LfEozy eHdKl92TwI9FHqcq+FLGRCOaDwKYqvWrW6HmsmNtLHCorK5qQUIq8Y8+cOVZWvIWHlZkIVRqREv DN3NDRVFUnURaUE4gyPY3IOT3wO7UA4q5eZdDIED+qwdeLgw== X-Google-Smtp-Source: AGHT+IEc1bug40GUkbPlSsJIRank943JPZR+j1XlzEMEL1N3IsMC7w+8rJGmsbIu3BEy1N2Ib6H+1A== X-Received: by 2002:a05:622a:587:b0:446:5b56:989 with SMTP id d75a77b69052e-4517ee9eb96mr12185401cf.6.1722464926160; Wed, 31 Jul 2024 15:28:46 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:45 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , 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), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 08/12] PCI: brcmstb: Don't conflate the reset rescal with phy ctrl Date: Wed, 31 Jul 2024 18:28:22 -0400 Message-Id: <20240731222831.14895-9-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Add a "has_phy" field indicating that the internal phy has SW control that requires configuration. Some previous chips only required the firing of the "rescal" reset controller. This change requires us to give the 7216 SoC its own cfg_data structure. Signed-off-by: Jim Quinlan Reviewed-by: Stanimir Varbanov Reviewed-by: Florian Fainelli Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/pcie-brcmstb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 1ae66c639186..4659208ae8da 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -222,6 +222,7 @@ enum pcie_type { struct pcie_cfg_data { const int *offsets; const enum pcie_type type; + const bool has_phy; void (*perst_set)(struct brcm_pcie *pcie, u32 val); void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); }; @@ -272,6 +273,7 @@ struct brcm_pcie { void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); struct subdev_regulators *sr; bool ep_wakeup_capable; + bool has_phy; }; static inline bool is_bmips(const struct brcm_pcie *pcie) @@ -1311,12 +1313,12 @@ static int brcm_phy_cntl(struct brcm_pcie *pcie, const int start) static inline int brcm_phy_start(struct brcm_pcie *pcie) { - return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0; + return pcie->has_phy ? brcm_phy_cntl(pcie, 1) : 0; } static inline int brcm_phy_stop(struct brcm_pcie *pcie) { - return pcie->rescal ? brcm_phy_cntl(pcie, 0) : 0; + return pcie->has_phy ? brcm_phy_cntl(pcie, 0) : 0; } static void brcm_pcie_turn_off(struct brcm_pcie *pcie) @@ -1559,12 +1561,20 @@ 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, + .has_phy = true, +}; + static const struct of_device_id brcm_pcie_match[] = { { .compatible = "brcm,bcm2711-pcie", .data = &bcm2711_cfg }, { .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 }, { .compatible = "brcm,bcm7435-pcie", .data = &bcm7435_cfg }, { .compatible = "brcm,bcm7425-pcie", .data = &bcm7425_cfg }, @@ -1612,6 +1622,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->type = data->type; pcie->perst_set = data->perst_set; pcie->bridge_sw_init_set = data->bridge_sw_init_set; + pcie->has_phy = data->has_phy; pcie->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(pcie->base)) From patchwork Wed Jul 31 22:28:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749295 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C86816FF39 for ; Wed, 31 Jul 2024 22:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464931; cv=none; b=RY3vaXd3G+9yKOcGYEElv6jz2c2yHc43mXSunqHXC+bdEyeYWQfl2yfmSYCWDV0qiYl2IRaJGdXGtVYZ4zS7jo4MwPP+YW5Nlrt+g0ooHk+xkQc85xXxZw1QKrsjinWEdAjDOcewWXC7iKCdq9cGm98f2qRCTRVqougufUgKBA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464931; c=relaxed/simple; bh=50hNICu5I0cQ1dc8e6sKALzLgxa4Aa4k1WXKXjZo4o8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=FRpm685WtnQvlhS5Rr104oLWY1ath5a3IvkjglIEn4fJviKow0BpDW5MIetxHcVzMn1Uc1X4tTtYpRxetkimQNrxVIKoUwMuVHRXxXrjGO6Q3UF8S8rhkfu+gd4ZEHCxjwNFicT/GiVlJ0Kf8umPwPcdm8wkiDSu+nbq0NSEtEk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=TbfFuTwI; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="TbfFuTwI" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-44ff9281e93so35337361cf.2 for ; Wed, 31 Jul 2024 15:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464928; x=1723069728; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=5pfZmRNKdTMWf2ZqvAr4Qq8R0KQvMMl+ZjRL68UJXeA=; b=TbfFuTwIcFZ8aXqpry3bIst/7IwaYoLavYxeh4K69qOdKMUfweGDUmkYh83p2sk5wM SB1BWY1ym5vN5pyt0o/ZMDXyDwUv0lJtBiRPqn62oSYzhUD3wCPzueuhO/OTMClZ4uEQ 4U1XDKboymrJM41KTUvUVNsQ9JjJ0KLTA0b9I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464928; x=1723069728; h=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=5pfZmRNKdTMWf2ZqvAr4Qq8R0KQvMMl+ZjRL68UJXeA=; b=rEuFtE/a7ESVL0g/jPRct0ViNpaRuppoga7i7q8Zpv1J5uYv9CfFEJj4MDGaSNyY5Q MVJmvYbre1aIEhGCZcECcRyYSPczxjRz7HxhvZ8qLCO7ohBu8X+kQJAb26joaIzD/be5 12L7EhyOlkY3/Veo+OPuNzsY3NO3mA96mkz9EIbgdlZnbbMkf8s8/f/PhnKv7gWpS2ct PYj+s1QWJnKf44uXydhplETPN7JpxgEAwjMkqfcAGZMZ2vdu2AWMOrchK30nBB1ots0e ZMWjeGlP9rhL2PPn+widMO+R0OfVnfn/I5VieLGJMQBCSggaNP1u8ijkknqX+jNtgvaE 2p5w== X-Gm-Message-State: AOJu0YyzbjqIvzntIONZ3TE+NA53pEfMdDtaM5Vf/fMZewPbpizb5k5M /2+4CdMB4jAjSJhYGJ1jftOOiSehOz38fO56TS5Wc/R41jxM5hY3nZXdf12zqnqAuAGXSxeYIKd c1WeGeRzpDscz7OjfA0ylIndcg4B79UdYlviYqT+6wLw9n0cQD5cmWoTc+4xr2b7vBo+ZKpNBX0 42Ccy24sScbMVlPLezyx9R8bv60UEKJeRCYhebDkZYKD7JtQ== X-Google-Smtp-Source: AGHT+IHBBkmfHuYFGI148IzJz1GuxHa/aa+gI22Rh/rpjLFTRKmigH5kniWSfAx/Gc1Jo5Fg2Wy6fQ== X-Received: by 2002:ac8:7dc6:0:b0:44f:fb58:8c3e with SMTP id d75a77b69052e-4514f9b69b1mr8006651cf.46.1722464927837; Wed, 31 Jul 2024 15:28:47 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:47 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , 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), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 09/12] PCI: brcmstb: Refactor for chips with many regular inbound windows Date: Wed, 31 Jul 2024 18:28:23 -0400 Message-Id: <20240731222831.14895-10-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Provide support for new chips with multiple inbound windows while keeping the legacy support for the older chips. In existing chips there are three inbound windows with fixed purposes: the first was for mapping SoC internal registers, the second was for memory, and the third was for memory but with the endian swapped. Typically, only one window was used. Complicating the inbound window usage was the fact that the PCIe HW would do a baroque internal mapping of system memory, and concatenate the regions of multiple memory controllers. Newer chips such as the 7712 and Cable Modem SOCs take a step forward and drop the internal mapping while providing for multiple inbound windows. This works in concert with the dma-ranges property, where each provided range becomes an inbound window. Signed-off-by: Jim Quinlan Reviewed-by: Florian Fainelli Reviewed-by: Stanimir Varbanov --- drivers/pci/controller/pcie-brcmstb.c | 228 ++++++++++++++++++++------ 1 file changed, 177 insertions(+), 51 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 4659208ae8da..0ecca3d9576f 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -75,15 +75,19 @@ #define PCIE_MEM_WIN0_HI(win) \ PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 8) +/* + * NOTE: You may see the term "BAR" in a number of register names used by + * this driver. The term is an artifact of when the HW core was an + * endpoint device (EP). Now it is a root complex (RC) and anywhere a + * register has the term "BAR" it is related to an inbound window. + */ + +#define PCIE_BRCM_MAX_INBOUND_WINS 16 #define PCIE_MISC_RC_BAR1_CONFIG_LO 0x402c #define PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK 0x1f -#define PCIE_MISC_RC_BAR2_CONFIG_LO 0x4034 -#define PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK 0x1f -#define PCIE_MISC_RC_BAR2_CONFIG_HI 0x4038 +#define PCIE_MISC_RC_BAR4_CONFIG_LO 0x40d4 -#define PCIE_MISC_RC_BAR3_CONFIG_LO 0x403c -#define PCIE_MISC_RC_BAR3_CONFIG_LO_SIZE_MASK 0x1f #define PCIE_MISC_MSI_BAR_CONFIG_LO 0x4044 #define PCIE_MISC_MSI_BAR_CONFIG_HI 0x4048 @@ -130,6 +134,10 @@ (PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK | \ PCIE_MISC_HARD_PCIE_HARD_DEBUG_L1SS_ENABLE_MASK) +#define PCIE_MISC_UBUS_BAR1_CONFIG_REMAP 0x40ac +#define PCIE_MISC_UBUS_BAR1_CONFIG_REMAP_ACCESS_EN_MASK BIT(0) +#define PCIE_MISC_UBUS_BAR4_CONFIG_REMAP 0x410c + #define PCIE_MSI_INTR2_BASE 0x4500 /* Offsets from INTR2_CPU and MSI_INTR2 BASE offsets */ @@ -217,12 +225,20 @@ enum pcie_type { BCM4908, BCM7278, BCM2711, + BCM7712, +}; + +struct inbound_win { + u64 size; + u64 pci_offset; + u64 cpu_addr; }; struct pcie_cfg_data { const int *offsets; const enum pcie_type type; const bool has_phy; + unsigned int num_inbound_wins; void (*perst_set)(struct brcm_pcie *pcie, u32 val); void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); }; @@ -274,6 +290,7 @@ struct brcm_pcie { struct subdev_regulators *sr; bool ep_wakeup_capable; bool has_phy; + int num_inbound_wins; }; static inline bool is_bmips(const struct brcm_pcie *pcie) @@ -789,23 +806,61 @@ static void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val) writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); } -static int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie, - u64 *rc_bar2_size, - u64 *rc_bar2_offset) +static inline void set_bar(struct inbound_win *b, int *count, u64 size, + u64 cpu_addr, u64 pci_offset) +{ + b->size = size; + b->cpu_addr = cpu_addr; + b->pci_offset = pci_offset; + (*count)++; +} + +static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie, + struct inbound_win inbound_wins[]) { struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); + u64 pci_offset, cpu_addr, size = 0, tot_size = 0; struct resource_entry *entry; struct device *dev = pcie->dev; u64 lowest_pcie_addr = ~(u64)0; - int ret, i = 0; - u64 size = 0; + int ret, i = 0, n = 0; + + /* + * The HW registers (and PCIe) use order-1 numbering for BARs. As + * such, we have inbound_wins[0] unused and BAR1 starts at inbound_wins[1]. + */ + struct inbound_win *b_begin = &inbound_wins[1]; + struct inbound_win *b = b_begin; + + /* + * STB chips beside 7712 disable the first inbound window default. + * Rather being mapped to system memory it is mapped to the + * internal registers of the SoC. This feature is deprecated, has + * security considerations, and is not implemented in our modern + * SoCs. + */ + if (pcie->type != BCM7712) + set_bar(b++, &n, 0, 0, 0); resource_list_for_each_entry(entry, &bridge->dma_ranges) { u64 pcie_beg = entry->res->start - entry->offset; + u64 cpu_beg = entry->res->start; - size += entry->res->end - entry->res->start + 1; + size = resource_size(entry->res); + tot_size += size; if (pcie_beg < lowest_pcie_addr) lowest_pcie_addr = pcie_beg; + /* + * 7712 and newer chips may have many BARs, with each + * offering a non-overlapping viewport to system memory. + * That being said, each BARs size must still be a power of + * two. + */ + if (pcie->type == BCM7712) + set_bar(b++, &n, size, cpu_beg, pcie_beg); + + if (n > pcie->num_inbound_wins) + break; } if (lowest_pcie_addr == ~(u64)0) { @@ -813,13 +868,20 @@ static int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie, return -EINVAL; } + /* + * 7712 and newer chips do not have an internal memory mapping system + * that enables multiple memory controllers. As such, it can return + * now w/o doing special configuration. + */ + if (pcie->type == BCM7712) + return n; + ret = of_property_read_variable_u64_array(pcie->np, "brcm,scb-sizes", pcie->memc_size, 1, PCIE_BRCM_MAX_MEMC); - if (ret <= 0) { /* Make an educated guess */ pcie->num_memc = 1; - pcie->memc_size[0] = 1ULL << fls64(size - 1); + pcie->memc_size[0] = 1ULL << fls64(tot_size - 1); } else { pcie->num_memc = ret; } @@ -828,10 +890,15 @@ static int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie, for (i = 0, size = 0; i < pcie->num_memc; i++) size += pcie->memc_size[i]; - /* System memory starts at this address in PCIe-space */ - *rc_bar2_offset = lowest_pcie_addr; - /* The sum of all memc views must also be a power of 2 */ - *rc_bar2_size = 1ULL << fls64(size - 1); + /* Our HW mandates that the window size must be a power of 2 */ + size = 1ULL << fls64(size - 1); + + /* + * For STB chips, the BAR2 cpu_addr is hardwired to the start + * of system memory, so we set it to 0. + */ + cpu_addr = 0; + pci_offset = lowest_pcie_addr; /* * We validate the inbound memory view even though we should trust @@ -866,25 +933,90 @@ static int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie, * outbound memory @ 3GB). So instead it will start at the 1x * multiple of its size */ - if (!*rc_bar2_size || (*rc_bar2_offset & (*rc_bar2_size - 1)) || - (*rc_bar2_offset < SZ_4G && *rc_bar2_offset > SZ_2G)) { - dev_err(dev, "Invalid rc_bar2_offset/size: size 0x%llx, off 0x%llx\n", - *rc_bar2_size, *rc_bar2_offset); + if (!size || (pci_offset & (size - 1)) || + (pci_offset < SZ_4G && pci_offset > SZ_2G)) { + dev_err(dev, "Invalid inbound_win2_offset/size: size 0x%llx, off 0x%llx\n", + size, pci_offset); return -EINVAL; } - return 0; + /* Enable inbound window 2, the main inbound window for STB chips */ + set_bar(b++, &n, size, cpu_addr, pci_offset); + + /* + * Disable inbound window 3. On some chips presents the same + * window as #2 but the data appears in a settable endianness. + */ + set_bar(b++, &n, 0, 0, 0); + + return n; +} + +static u32 brcm_bar_reg_offset(int bar) +{ + if (bar <= 3) + return PCIE_MISC_RC_BAR1_CONFIG_LO + 8 * (bar - 1); + else + return PCIE_MISC_RC_BAR4_CONFIG_LO + 8 * (bar - 4); +} + +static u32 brcm_ubus_reg_offset(int bar) +{ + if (bar <= 3) + return PCIE_MISC_UBUS_BAR1_CONFIG_REMAP + 8 * (bar - 1); + else + return PCIE_MISC_UBUS_BAR4_CONFIG_REMAP + 8 * (bar - 4); +} + +static void set_inbound_win_registers(struct brcm_pcie *pcie, + const struct inbound_win *inbound_wins, + int num_inbound_wins) +{ + void __iomem *base = pcie->base; + int i; + + for (i = 1; i <= num_inbound_wins; i++) { + u64 pci_offset = inbound_wins[i].pci_offset; + u64 cpu_addr = inbound_wins[i].cpu_addr; + u64 size = inbound_wins[i].size; + u32 reg_offset = brcm_bar_reg_offset(i); + u32 tmp = lower_32_bits(pci_offset); + + u32p_replace_bits(&tmp, brcm_pcie_encode_ibar_size(size), + PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK); + + /* Write low */ + writel(tmp, base + reg_offset); + /* Write high */ + writel(upper_32_bits(pci_offset), base + reg_offset + 4); + + /* + * Most STB chips: + * Do nothing. + * 7712: + * All of their BARs need to be set. + */ + if (pcie->type == BCM7712) { + /* BUS remap register settings */ + reg_offset = brcm_ubus_reg_offset(i); + tmp = lower_32_bits(cpu_addr) & ~0xfff; + tmp |= PCIE_MISC_UBUS_BAR1_CONFIG_REMAP_ACCESS_EN_MASK; + writel(tmp, base + reg_offset); + tmp = upper_32_bits(cpu_addr); + writel(tmp, base + reg_offset + 4); + } + } } static int brcm_pcie_setup(struct brcm_pcie *pcie) { - u64 rc_bar2_offset, rc_bar2_size; + struct inbound_win inbound_wins[PCIE_BRCM_MAX_INBOUND_WINS]; void __iomem *base = pcie->base; struct pci_host_bridge *bridge; struct resource_entry *entry; u32 tmp, burst, aspm_support; - int num_out_wins = 0; - int ret, memc; + int num_out_wins = 0, num_rc_bars = 0; + int memc; /* Reset the bridge */ pcie->bridge_sw_init_set(pcie, 1); @@ -933,17 +1065,16 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) u32p_replace_bits(&tmp, 1, PCIE_MISC_MISC_CTRL_PCIE_RCB_64B_MODE_MASK); writel(tmp, base + PCIE_MISC_MISC_CTRL); - ret = brcm_pcie_get_rc_bar2_size_and_offset(pcie, &rc_bar2_size, - &rc_bar2_offset); - if (ret) - return ret; + num_rc_bars = brcm_pcie_get_inbound_wins(pcie, inbound_wins); + if (num_rc_bars < 0) + return num_rc_bars; + + set_inbound_win_registers(pcie, inbound_wins, num_rc_bars); - tmp = lower_32_bits(rc_bar2_offset); - u32p_replace_bits(&tmp, brcm_pcie_encode_ibar_size(rc_bar2_size), - PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK); - writel(tmp, base + PCIE_MISC_RC_BAR2_CONFIG_LO); - writel(upper_32_bits(rc_bar2_offset), - base + PCIE_MISC_RC_BAR2_CONFIG_HI); + if (!brcm_pcie_rc_mode(pcie)) { + dev_err(pcie->dev, "PCIe RC controller misconfigured as Endpoint\n"); + return -EINVAL; + } tmp = readl(base + PCIE_MISC_MISC_CTRL); for (memc = 0; memc < pcie->num_memc; memc++) { @@ -965,25 +1096,12 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) * 4GB or when the inbound area is smaller than 4GB (taking into * account the rounding-up we're forced to perform). */ - if (rc_bar2_offset >= SZ_4G || (rc_bar2_size + rc_bar2_offset) < SZ_4G) + if (inbound_wins[2].pci_offset >= SZ_4G || + (inbound_wins[2].size + inbound_wins[2].pci_offset) < SZ_4G) pcie->msi_target_addr = BRCM_MSI_TARGET_ADDR_LT_4GB; else pcie->msi_target_addr = BRCM_MSI_TARGET_ADDR_GT_4GB; - if (!brcm_pcie_rc_mode(pcie)) { - dev_err(pcie->dev, "PCIe RC controller misconfigured as Endpoint\n"); - return -EINVAL; - } - - /* disable the PCIe->GISB memory window (RC_BAR1) */ - tmp = readl(base + PCIE_MISC_RC_BAR1_CONFIG_LO); - tmp &= ~PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK; - writel(tmp, base + PCIE_MISC_RC_BAR1_CONFIG_LO); - - /* disable the PCIe->SCB memory window (RC_BAR3) */ - tmp = readl(base + PCIE_MISC_RC_BAR3_CONFIG_LO); - tmp &= ~PCIE_MISC_RC_BAR3_CONFIG_LO_SIZE_MASK; - writel(tmp, base + PCIE_MISC_RC_BAR3_CONFIG_LO); /* Don't advertise L0s capability if 'aspm-no-l0s' */ aspm_support = PCIE_LINK_STATE_L1; @@ -1034,7 +1152,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) num_out_wins++; } - /* PCIe->SCB endian mode for BAR */ + /* PCIe->SCB endian mode for inbound window */ tmp = readl(base + PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1); u32p_replace_bits(&tmp, PCIE_RC_CFG_VENDOR_SPCIFIC_REG1_LITTLE_ENDIAN, PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK); @@ -1516,6 +1634,7 @@ static const struct pcie_cfg_data generic_cfg = { .type = GENERIC, .perst_set = brcm_pcie_perst_set_generic, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, + .num_inbound_wins = 3, }; static const struct pcie_cfg_data bcm7425_cfg = { @@ -1523,6 +1642,7 @@ static const struct pcie_cfg_data bcm7425_cfg = { .type = BCM7425, .perst_set = brcm_pcie_perst_set_generic, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, + .num_inbound_wins = 3, }; static const struct pcie_cfg_data bcm7435_cfg = { @@ -1530,6 +1650,7 @@ static const struct pcie_cfg_data bcm7435_cfg = { .type = BCM7435, .perst_set = brcm_pcie_perst_set_generic, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, + .num_inbound_wins = 3, }; static const struct pcie_cfg_data bcm4908_cfg = { @@ -1537,6 +1658,7 @@ static const struct pcie_cfg_data bcm4908_cfg = { .type = BCM4908, .perst_set = brcm_pcie_perst_set_4908, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, + .num_inbound_wins = 3, }; static const int pcie_offset_bcm7278[] = { @@ -1552,6 +1674,7 @@ static const struct pcie_cfg_data bcm7278_cfg = { .type = BCM7278, .perst_set = brcm_pcie_perst_set_7278, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278, + .num_inbound_wins = 3, }; static const struct pcie_cfg_data bcm2711_cfg = { @@ -1559,6 +1682,7 @@ static const struct pcie_cfg_data bcm2711_cfg = { .type = BCM2711, .perst_set = brcm_pcie_perst_set_generic, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, + .num_inbound_wins = 3, }; static const struct pcie_cfg_data bcm7216_cfg = { @@ -1567,6 +1691,7 @@ static const struct pcie_cfg_data bcm7216_cfg = { .perst_set = brcm_pcie_perst_set_7278, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278, .has_phy = true, + .num_inbound_wins = 3, }; static const struct of_device_id brcm_pcie_match[] = { @@ -1623,6 +1748,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->perst_set = data->perst_set; pcie->bridge_sw_init_set = data->bridge_sw_init_set; pcie->has_phy = data->has_phy; + pcie->num_inbound_wins = data->num_inbound_wins; pcie->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(pcie->base)) From patchwork Wed Jul 31 22:28:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749296 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84210171E7C for ; Wed, 31 Jul 2024 22:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464933; cv=none; b=kGHBAY1gWhUGEBGXKCsiEXRVwUT9CoReeDVVWPXqmMTtT1NRWejR5L8Qv/5niq2FOlM7cpC4sxmBS9N13zj3VbPw7tP2opLfSuXrbn0+FBIf0kkmOCJNMnRwT0Yxn2XFrV/gSQYpO7OYkfk3nd+ppB8lAi3ASdyULP9M2ONGFsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464933; c=relaxed/simple; bh=m8Yb5XC7EBKDcQqhey6p9ZpidQ1IqDx4NiWP2Ahl+bY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=mbFjYB8Or2lnCrd3XqVPZGn9r5t8t+1plfoEuTppPpHFYlVwX7Nsr34q2XEwoSepYcSTrmgd7wUNHLcM7g/3OT4DkIipwamueZPHajMZvknarsBUacT3G9DRAY4rj1XPNnxS/cby+2Czp6z+dUz7k5BDYo44CoNtez4tsUdZE2M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=IBpxp6Ix; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="IBpxp6Ix" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-44fdcd7a622so31050531cf.0 for ; Wed, 31 Jul 2024 15:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464929; x=1723069729; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=5hMN9hd5R2EuxrKDlmPrY0rWJepmZzVZcJJrxjFbWRw=; b=IBpxp6IxzOPulOg8KOf23BKPUNZW8C5mbRmh1zFpxjq+4kMapy74N9x1L6VsAoVzMq xw6iXbD2S1JQp8OGnEc4mcR1XVw2DqClGCfjchyU67oAbdIxkh/W5z6m3CrtkJ2aisT0 33g/v9Ui06SnE9U/xjuH3ijJuIB+t9uyh+geY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464929; x=1723069729; h=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=5hMN9hd5R2EuxrKDlmPrY0rWJepmZzVZcJJrxjFbWRw=; b=Iup0iWBYPERbczH4/3Cn/4BnxOnqrJuP/MJSVvIN+epYWpeTF3WnorvnDvTsgE3XKY urfBW7TIUYIJfFsnVq7vLPF7fHw8B61hpyik5INZThiP2eXhzCmdTOM8xbOs4XST1Efw lC3RqhF+GCNk1QQj7prIG1vX96bvgBi+RGNpeHUDmMHK5afa+TIGr8EOLtkJ1Bb1a9SC wfSua0VDcPbIPZ/IaNSBmdbDIcfPbV+w6PxQZq83ezOO+Zx+hHsUTEjSy3qLiR15fCvI I4v44SS6ZLFXkO28lcgWai13KjRojGEmv8EVBz/WlirJYuOnMH0vtheHXMvfNXA5RmEE h9CQ== X-Gm-Message-State: AOJu0YxYcOQggVHfAP/VaUrJADNuxP9zEODfNEVSMvIVWjWYajWEgwy7 fM1BK3/Sh1EFNwUL8WY3p9p26ZjB9vv/yOI0DAkunty8/uFwYGzLUJ1RNS9yduq6cDls0w0sug7 zdlDD/ltELbmWHpoIgp4B7j5WpYljVG5W32MQ6e3lvIbBPYhHALgc08+GQ6tG11CFBAqVipohGn Gl+VV9kk5y955jmOslkaf5YPoF2JRHX4ISH217hfFs5qgViA== X-Google-Smtp-Source: AGHT+IHb4s3V73+ztQ4zJoX+XZ9jOaCR5frA7+yF6G8XoMSBIJbRurH1mjZU8SRenbvMvCHRsNTPoQ== X-Received: by 2002:ac8:5914:0:b0:447:e046:8482 with SMTP id d75a77b69052e-4514f98bdb3mr7983191cf.23.1722464929441; Wed, 31 Jul 2024 15:28:49 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:48 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Philipp Zabel , 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 v5 10/12] PCI: brcmstb: Check return value of all reset_control_xxx calls Date: Wed, 31 Jul 2024 18:28:24 -0400 Message-Id: <20240731222831.14895-11-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Always check the return value for invocations of reset_control_xxx() and propagate the error to the next level. Although the current functions in reset-brcmstb.c cannot fail, this may someday change. Signed-off-by: Jim Quinlan Reviewed-by: Stanimir Varbanov Reviewed-by: Florian Fainelli Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/pcie-brcmstb.c | 102 ++++++++++++++++++-------- 1 file changed, 73 insertions(+), 29 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 0ecca3d9576f..c4ceb1823a79 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -239,8 +239,8 @@ struct pcie_cfg_data { const enum pcie_type type; const bool has_phy; unsigned int num_inbound_wins; - void (*perst_set)(struct brcm_pcie *pcie, u32 val); - void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); + int (*perst_set)(struct brcm_pcie *pcie, u32 val); + int (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); }; struct subdev_regulators { @@ -285,8 +285,8 @@ struct brcm_pcie { int num_memc; u64 memc_size[PCIE_BRCM_MAX_MEMC]; u32 hw_rev; - void (*perst_set)(struct brcm_pcie *pcie, u32 val); - void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); + int (*perst_set)(struct brcm_pcie *pcie, u32 val); + int (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); struct subdev_regulators *sr; bool ep_wakeup_capable; bool has_phy; @@ -749,12 +749,18 @@ static void __iomem *brcm7425_pcie_map_bus(struct pci_bus *bus, return base + DATA_ADDR(pcie); } -static void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val) +static int brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val) { + int ret = 0; + if (val) - reset_control_assert(pcie->bridge_reset); + ret = reset_control_assert(pcie->bridge_reset); else - reset_control_deassert(pcie->bridge_reset); + ret = reset_control_deassert(pcie->bridge_reset); + + if (ret) + dev_err(pcie->dev, "failed to %s 'bridge' reset, err=%d\n", + val ? "assert" : "deassert", ret); if (!pcie->bridge_reset) { u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK; @@ -764,9 +770,11 @@ static void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val tmp = (tmp & ~mask) | ((val << shift) & mask); writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); } + + return ret; } -static void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val) +static int brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val) { u32 tmp, mask = RGR1_SW_INIT_1_INIT_7278_MASK; u32 shift = RGR1_SW_INIT_1_INIT_7278_SHIFT; @@ -774,20 +782,29 @@ static void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val) tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); tmp = (tmp & ~mask) | ((val << shift) & mask); writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); + + return 0; } -static void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val) +static int brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val) { + int ret; + if (WARN_ONCE(!pcie->perst_reset, "missing PERST# reset controller\n")) - return; + return -EINVAL; if (val) - reset_control_assert(pcie->perst_reset); + ret = reset_control_assert(pcie->perst_reset); else - reset_control_deassert(pcie->perst_reset); + ret = reset_control_deassert(pcie->perst_reset); + + if (ret) + dev_err(pcie->dev, "failed to %s 'perst' reset, err=%d\n", + val ? "assert" : "deassert", ret); + return ret; } -static void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val) +static int brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val) { u32 tmp; @@ -795,15 +812,19 @@ static void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val) tmp = readl(pcie->base + PCIE_MISC_PCIE_CTRL); u32p_replace_bits(&tmp, !val, PCIE_MISC_PCIE_CTRL_PCIE_PERSTB_MASK); writel(tmp, pcie->base + PCIE_MISC_PCIE_CTRL); + + return 0; } -static void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val) +static int brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val) { u32 tmp; tmp = readl(pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); u32p_replace_bits(&tmp, val, PCIE_RGR1_SW_INIT_1_PERST_MASK); writel(tmp, pcie->base + PCIE_RGR1_SW_INIT_1(pcie)); + + return 0; } static inline void set_bar(struct inbound_win *b, int *count, u64 size, @@ -1016,19 +1037,28 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) struct resource_entry *entry; u32 tmp, burst, aspm_support; int num_out_wins = 0, num_rc_bars = 0; - int memc; + int memc, ret; /* Reset the bridge */ - pcie->bridge_sw_init_set(pcie, 1); + ret = pcie->bridge_sw_init_set(pcie, 1); + if (ret) + return ret; /* Ensure that PERST# is asserted; some bootloaders may deassert it. */ - if (pcie->type == BCM2711) - pcie->perst_set(pcie, 1); + if (pcie->type == BCM2711) { + ret = pcie->perst_set(pcie, 1); + if (ret) { + pcie->bridge_sw_init_set(pcie, 0); + return ret; + } + } usleep_range(100, 200); /* Take the bridge out of reset */ - pcie->bridge_sw_init_set(pcie, 0); + ret = pcie->bridge_sw_init_set(pcie, 0); + if (ret) + return ret; tmp = readl(base + HARD_DEBUG(pcie)); if (is_bmips(pcie)) @@ -1247,7 +1277,9 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie) int ret, i; /* Unassert the fundamental reset */ - pcie->perst_set(pcie, 0); + ret = pcie->perst_set(pcie, 0); + if (ret) + return ret; /* * Wait for 100ms after PERST# deassertion; see PCIe CEM specification @@ -1439,15 +1471,17 @@ static inline int brcm_phy_stop(struct brcm_pcie *pcie) return pcie->has_phy ? brcm_phy_cntl(pcie, 0) : 0; } -static void brcm_pcie_turn_off(struct brcm_pcie *pcie) +static int brcm_pcie_turn_off(struct brcm_pcie *pcie) { void __iomem *base = pcie->base; - int tmp; + int tmp, ret; if (brcm_pcie_link_up(pcie)) brcm_pcie_enter_l23(pcie); /* Assert fundamental reset */ - pcie->perst_set(pcie, 1); + ret = pcie->perst_set(pcie, 1); + if (ret) + return ret; /* Deassert request for L23 in case it was asserted */ tmp = readl(base + PCIE_MISC_PCIE_CTRL); @@ -1460,7 +1494,9 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie) writel(tmp, base + HARD_DEBUG(pcie)); /* Shutdown PCIe bridge */ - pcie->bridge_sw_init_set(pcie, 1); + ret = pcie->bridge_sw_init_set(pcie, 1); + + return ret; } static int pci_dev_may_wakeup(struct pci_dev *dev, void *data) @@ -1478,9 +1514,12 @@ static int brcm_pcie_suspend_noirq(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); - int ret; + int ret, rret; + + ret = brcm_pcie_turn_off(pcie); + if (ret) + return ret; - brcm_pcie_turn_off(pcie); /* * If brcm_phy_stop() returns an error, just dev_err(). If we * return the error it will cause the suspend to fail and this is a @@ -1509,7 +1548,10 @@ static int brcm_pcie_suspend_noirq(struct device *dev) pcie->sr->supplies); if (ret) { dev_err(dev, "Could not turn off regulators\n"); - reset_control_reset(pcie->rescal); + rret = reset_control_reset(pcie->rescal); + if (rret) + dev_err(dev, "failed to reset 'rascal' controller ret=%d\n", + rret); return ret; } } @@ -1524,7 +1566,7 @@ static int brcm_pcie_resume_noirq(struct device *dev) struct brcm_pcie *pcie = dev_get_drvdata(dev); void __iomem *base; u32 tmp; - int ret; + int ret, rret; base = pcie->base; ret = clk_prepare_enable(pcie->clk); @@ -1586,7 +1628,9 @@ static int brcm_pcie_resume_noirq(struct device *dev) if (pcie->sr) regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies); err_reset: - reset_control_rearm(pcie->rescal); + rret = reset_control_rearm(pcie->rescal); + if (rret) + dev_err(pcie->dev, "failed to rearm 'rescal' reset, err=%d\n", rret); err_disable_clk: clk_disable_unprepare(pcie->clk); return ret; From patchwork Wed Jul 31 22:28:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749297 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33122183CA4 for ; Wed, 31 Jul 2024 22:28:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464934; cv=none; b=j+9Z6D+wMFJZ3VbTlWP/g8JwrQ3YpVDK82ZGx9ekMVnTJqX7v1acdKJSQTEjw1JWQI2ORDnTMUd2IDK0vs2Fxa1Zj+gPA39eElTq3JDDs0HXvfLKe2xEOfLoBHxD87u0woa6EhRyqLgrioeXKckVTtLJrYFHFesuSGHrbECrLFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464934; c=relaxed/simple; bh=KnEfs6HZv31jHNJ3+N/UsBfCm6ko0napd6s47uUx07M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=lXFwctF2n2wVbrpVjQO1O2mhOLUUboFPwitMW0gF3Zr90xIrDqCtasB0i5b2du9ERG8mfdsscAkLGuNd1w+XwsF/rQKHosytarkvgfGU1Y7KGiVeMijyO9ix1UO1IlWB2/iL7SjaJChAv8iXiRvAfEexDPdgFUc5JeviJ23Ek20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=JkB8hIVv; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="JkB8hIVv" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7a1d0ad7113so429539785a.2 for ; Wed, 31 Jul 2024 15:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464932; x=1723069732; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=YZm55XuvS5TsIWPd2I5O2BqV2wZK6adjRKLxKY6gWyA=; b=JkB8hIVvwyT2BCgpRZc7VEgGdcV5Ucj5w2rK79mf9A1xpl2cYHZJlBYRwv0dmwC/Gw QNT2Ex3OrzzBDn5JKBMakJQ8d0B1l5A5I/rZ5Qr5oB+PhOWP6t7OeWOvrxJzCvWNfyM3 gZzPBH36XxF+e284IbyFxq7pxkRCYqKuo3POM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464932; x=1723069732; h=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=YZm55XuvS5TsIWPd2I5O2BqV2wZK6adjRKLxKY6gWyA=; b=qhvBnLWLamM+cO3kysd1hkA0uAy+aC1dHpJURAjHdqZFb+D6uU4l4wbR5lyp4H9ZJN iJZg16mvc6b/tqKFxowqDUAy/FsqRzhdcI+1+3/Hwjvk2aKoUMZCpR/DaBxixyBmPns3 9S0gpQDorxI8cby1yiGINeMvSCet609Ne6Jt0Wmj5103k9zIY2TrCbuEIgj2m6IXarOF uNMLh2wKf29F/aLZtoyu/tmq1UgTLqUw6gDKz3Jwry95vOaJHiuEEtK+kCA3tStUmAmj H90O5RPqcagInfopwhrdb+uv69eeAKuuHovUR37plsapxUWYCa9VeWGlGFIRq2y7tRDG 8ffw== X-Gm-Message-State: AOJu0YwEyu6oJbnHjvUgEiwWmJy4qXLBXjTSRk9UGEwjdf4vYcEv/pY0 cdtt20aPfzBHW3kDrzVA1vcOkEGsAfFV6kf6kpAqpMb0pgxIZ8m7QO9i90QxB0cOwzVKvOrRtT/ bRfhV58URG7DPVlf9rEZR/aqf4JtnShV89GaPY3NK63EHbzJ9+FJj+2WTlaHIzTIFA3SVOlsYHF 0mCBKMJWFbtnQCFn7KG6FwQbaI2bHQQDKp8dTC7Qy8vfwi0A== X-Google-Smtp-Source: AGHT+IEndjov11wcEzjulUpPn9DsM2Y3SCKwPkMcrsPJUtiLRsQRjQ/eaIW0tsU5qan9kt+FiHASmw== X-Received: by 2002:a05:620a:450b:b0:7a2:d63:4cc6 with SMTP id af79cd13be357-7a30c67f324mr66945185a.39.1722464931517; Wed, 31 Jul 2024 15:28:51 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:50 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , 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), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 11/12] PCI: brcmstb: Change field name from 'type' to 'soc_base' Date: Wed, 31 Jul 2024 18:28:25 -0400 Message-Id: <20240731222831.14895-12-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The 'type' field used in the driver to discern SoC differences is confusing; change it to the more apt 'soc_base'. The 'base' is because some SoCs have the same characteristics as previous SoCs so it is convenient to classify them in the same group. Signed-off-by: Jim Quinlan Reviewed-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 42 +++++++++++++-------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index c4ceb1823a79..4623b70f9ad8 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -218,7 +218,7 @@ enum { PCIE_INTR2_CPU_BASE, }; -enum pcie_type { +enum pcie_soc_base { GENERIC, BCM7425, BCM7435, @@ -236,7 +236,7 @@ struct inbound_win { struct pcie_cfg_data { const int *offsets; - const enum pcie_type type; + const enum pcie_soc_base soc_base; const bool has_phy; unsigned int num_inbound_wins; int (*perst_set)(struct brcm_pcie *pcie, u32 val); @@ -277,7 +277,7 @@ struct brcm_pcie { u64 msi_target_addr; struct brcm_msi *msi; const int *reg_offsets; - enum pcie_type type; + enum pcie_soc_base soc_base; struct reset_control *rescal; struct reset_control *perst_reset; struct reset_control *bridge_reset; @@ -295,7 +295,7 @@ struct brcm_pcie { static inline bool is_bmips(const struct brcm_pcie *pcie) { - return pcie->type == BCM7435 || pcie->type == BCM7425; + return pcie->soc_base == BCM7435 || pcie->soc_base == BCM7425; } /* @@ -860,7 +860,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie, * security considerations, and is not implemented in our modern * SoCs. */ - if (pcie->type != BCM7712) + if (pcie->soc_base != BCM7712) set_bar(b++, &n, 0, 0, 0); resource_list_for_each_entry(entry, &bridge->dma_ranges) { @@ -877,7 +877,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie, * That being said, each BARs size must still be a power of * two. */ - if (pcie->type == BCM7712) + if (pcie->soc_base == BCM7712) set_bar(b++, &n, size, cpu_beg, pcie_beg); if (n > pcie->num_inbound_wins) @@ -894,7 +894,7 @@ static int brcm_pcie_get_inbound_wins(struct brcm_pcie *pcie, * that enables multiple memory controllers. As such, it can return * now w/o doing special configuration. */ - if (pcie->type == BCM7712) + if (pcie->soc_base == BCM7712) return n; ret = of_property_read_variable_u64_array(pcie->np, "brcm,scb-sizes", pcie->memc_size, 1, @@ -1017,7 +1017,7 @@ static void set_inbound_win_registers(struct brcm_pcie *pcie, * 7712: * All of their BARs need to be set. */ - if (pcie->type == BCM7712) { + if (pcie->soc_base == BCM7712) { /* BUS remap register settings */ reg_offset = brcm_ubus_reg_offset(i); tmp = lower_32_bits(cpu_addr) & ~0xfff; @@ -1045,7 +1045,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) return ret; /* Ensure that PERST# is asserted; some bootloaders may deassert it. */ - if (pcie->type == BCM2711) { + if (pcie->soc_base == BCM2711) { ret = pcie->perst_set(pcie, 1); if (ret) { pcie->bridge_sw_init_set(pcie, 0); @@ -1076,9 +1076,9 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) */ if (is_bmips(pcie)) burst = 0x1; /* 256 bytes */ - else if (pcie->type == BCM2711) + else if (pcie->soc_base == BCM2711) burst = 0x0; /* 128 bytes */ - else if (pcie->type == BCM7278) + else if (pcie->soc_base == BCM7278) burst = 0x3; /* 512 bytes */ else burst = 0x2; /* 512 bytes */ @@ -1675,7 +1675,7 @@ static const int pcie_offsets_bmips_7425[] = { static const struct pcie_cfg_data generic_cfg = { .offsets = pcie_offsets, - .type = GENERIC, + .soc_base = GENERIC, .perst_set = brcm_pcie_perst_set_generic, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, .num_inbound_wins = 3, @@ -1683,7 +1683,7 @@ static const struct pcie_cfg_data generic_cfg = { static const struct pcie_cfg_data bcm7425_cfg = { .offsets = pcie_offsets_bmips_7425, - .type = BCM7425, + .soc_base = BCM7425, .perst_set = brcm_pcie_perst_set_generic, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, .num_inbound_wins = 3, @@ -1691,7 +1691,7 @@ static const struct pcie_cfg_data bcm7425_cfg = { static const struct pcie_cfg_data bcm7435_cfg = { .offsets = pcie_offsets, - .type = BCM7435, + .soc_base = BCM7435, .perst_set = brcm_pcie_perst_set_generic, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, .num_inbound_wins = 3, @@ -1699,7 +1699,7 @@ static const struct pcie_cfg_data bcm7435_cfg = { static const struct pcie_cfg_data bcm4908_cfg = { .offsets = pcie_offsets, - .type = BCM4908, + .soc_base = BCM4908, .perst_set = brcm_pcie_perst_set_4908, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, .num_inbound_wins = 3, @@ -1715,7 +1715,7 @@ static const int pcie_offset_bcm7278[] = { static const struct pcie_cfg_data bcm7278_cfg = { .offsets = pcie_offset_bcm7278, - .type = BCM7278, + .soc_base = BCM7278, .perst_set = brcm_pcie_perst_set_7278, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278, .num_inbound_wins = 3, @@ -1723,7 +1723,7 @@ static const struct pcie_cfg_data bcm7278_cfg = { static const struct pcie_cfg_data bcm2711_cfg = { .offsets = pcie_offsets, - .type = BCM2711, + .soc_base = BCM2711, .perst_set = brcm_pcie_perst_set_generic, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, .num_inbound_wins = 3, @@ -1731,7 +1731,7 @@ static const struct pcie_cfg_data bcm2711_cfg = { static const struct pcie_cfg_data bcm7216_cfg = { .offsets = pcie_offset_bcm7278, - .type = BCM7278, + .soc_base = BCM7278, .perst_set = brcm_pcie_perst_set_7278, .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278, .has_phy = true, @@ -1788,7 +1788,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->dev = &pdev->dev; pcie->np = np; pcie->reg_offsets = data->offsets; - pcie->type = data->type; + pcie->soc_base = data->soc_base; pcie->perst_set = data->perst_set; pcie->bridge_sw_init_set = data->bridge_sw_init_set; pcie->has_phy = data->has_phy; @@ -1858,7 +1858,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) goto fail; pcie->hw_rev = readl(pcie->base + PCIE_MISC_REVISION); - if (pcie->type == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) { + if (pcie->soc_base == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) { dev_err(pcie->dev, "hardware revision with unsupported PERST# setup\n"); ret = -ENODEV; goto fail; @@ -1871,7 +1871,7 @@ static int brcm_pcie_probe(struct platform_device *pdev) goto fail; } - bridge->ops = pcie->type == BCM7425 ? &brcm7425_pcie_ops : &brcm_pcie_ops; + bridge->ops = pcie->soc_base == BCM7425 ? &brcm7425_pcie_ops : &brcm_pcie_ops; bridge->sysdata = pcie; platform_set_drvdata(pdev, pcie); From patchwork Wed Jul 31 22:28:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13749298 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C8B0183CBA for ; Wed, 31 Jul 2024 22:28:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464936; cv=none; b=J2rIREDvnL7zs2xVlakRiFAOGo5bkUdvYhCl2ktow/S62nfzB83Yt0vdmTTSnwob3Ihq8k9tJs4fEE4a071MZmjSdmIh0uJznVqa1FOCG0RsmCDksTtYpBlP848BzYsU/hQooTkyhG9q89zkxIOVHUTsKoW3wSRygCGg5oO0W1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722464936; c=relaxed/simple; bh=vMmafbjGGptgOc928LWw3HzijtKQn7umoBI3Z8nrrhU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=kgmGweyjDiBWFM7h8EY6Hh3fHkVQCPTdtIDY1Z6yHVK7EC9xB4pPhemWv7cuArVSJkdUVoJ7/QCtxuQS34ftYHrRHIVw4UaOgUOeJH3e1ulRsDjWT/M0d6wxeyeyQQDLRhyrX2ydCfabbzSPJJ9aP6M92Wm3LotpfCoFG7wF6LU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=P4Nt85ZW; arc=none smtp.client-ip=209.85.210.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="P4Nt85ZW" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-70944dc8dc6so3221136a34.3 for ; Wed, 31 Jul 2024 15:28:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1722464933; x=1723069733; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=48kNXVxTxIS1qqb8DRwWYkv7S1xxdo30DtPId8NrWW4=; b=P4Nt85ZWFaJw34g5bso1bpAimKBVe4hcNGUKvo/9+HYteosKysA5dquwMKR3TlFTzn BScVbS5K1Cs0rNo0iKKhvLlV8+AfeLGTsHzraNshYzlDOStnOw32ttJ7Xlj1AGQVTsyv oLf/odzRidX6mkfPmUDZL86/BOTqKTCPNcVjw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722464933; x=1723069733; h=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=48kNXVxTxIS1qqb8DRwWYkv7S1xxdo30DtPId8NrWW4=; b=g8wgXDmPxMUyd1Q/1oS49LjEJVtGgC+ObaEmkxT4fEaR8io9Qg3Fffqbuf26sescjD kJUE5OBtkege5rL8ey9RC/NE5sFOUiU21OctrjXYdKwjWPKqTTts7sswpddpbNGZKnzg 7FKRKkchql3MmI1JmfbN8xkBqzX7kwSV2VyAr527JR/hbOjzhYzyie0x9KfXRl7L+BuO Yt5oqYTnQSxk1eyzDUIKgA5Ae8aOJPTurZlqjDQQdlG85h9JtuKTymuZlfFZLmZyvuVz ue6Fc9m1M7ZRvsKuczxeYK4QDgpZD1+A+spR0DEWTi8UXzN2qYnF56qtIG7Gt+PhTe/M OkFw== X-Gm-Message-State: AOJu0YxCciOzXuCfF7yc5Nc1e/ogqR2YcJ39a5lSP0AgElT78Br9p7sX R7E60ERm9fTbvrB1IYLANC60j8TnmygcYaeD5ZoNH7CXJguSPtNOc1MCz5Lsns042b7dwhxsKhR FuBqosk3psBa7OKyZ/qzVl+KEXgNW88/r9R2phxtptPr74bezTBOxwG5lyp5yCzT1PzAoCGOQIs PXhHB68yWqIn4aS9Uus7RwAdY2tD1oL5QqXnUEk5CEcN9hZw== X-Google-Smtp-Source: AGHT+IG0HTaGPAQVkMi4hiaQmCdPYjlys/O4jVp+HDfUjEJVYYKtUw47a6LfeJvzWSfPWDUXJnJ9nw== X-Received: by 2002:a05:6830:2a8d:b0:704:3fea:5354 with SMTP id 46e09a7af769-7096b80ab4fmr546436a34.10.1722464933013; Wed, 31 Jul 2024 15:28:53 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-44fe8416c80sm62359181cf.96.2024.07.31.15.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 15:28:52 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , Manivannan Sadhasivam , Krzysztof Kozlowski , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , 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), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 12/12] PCI: brcmstb: Enable 7712 SOCs Date: Wed, 31 Jul 2024 18:28:26 -0400 Message-Id: <20240731222831.14895-13-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240731222831.14895-1-james.quinlan@broadcom.com> References: <20240731222831.14895-1-james.quinlan@broadcom.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The Broadcom STB 7712 is the sibling chip of the RPi 5 (2712). It has one PCIe controller with a single port, supports gen2 and one lane only. The current revision of the chip is "C0" or "C1". Signed-off-by: Jim Quinlan Reviewed-by: Stanimir Varbanov Reviewed-by: Florian Fainelli Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/pcie-brcmstb.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 4623b70f9ad8..44b323a13357 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1202,6 +1202,10 @@ static void brcm_extend_rbus_timeout(struct brcm_pcie *pcie) const unsigned int REG_OFFSET = PCIE_RGR1_SW_INIT_1(pcie) - 8; u32 timeout_us = 4000000; /* 4 seconds, our setting for L1SS */ + /* 7712 does not have this (RGR1) timer */ + if (pcie->soc_base == BCM7712) + return; + /* Each unit in timeout register is 1/216,000,000 seconds */ writel(216 * timeout_us, pcie->base + REG_OFFSET); } @@ -1673,6 +1677,13 @@ static const int pcie_offsets_bmips_7425[] = { [PCIE_INTR2_CPU_BASE] = 0x4300, }; +static const int pcie_offset_bcm7712[] = { + [EXT_CFG_INDEX] = 0x9000, + [EXT_CFG_DATA] = 0x9004, + [PCIE_HARD_DEBUG] = 0x4304, + [PCIE_INTR2_CPU_BASE] = 0x4400, +}; + static const struct pcie_cfg_data generic_cfg = { .offsets = pcie_offsets, .soc_base = GENERIC, @@ -1738,6 +1749,14 @@ static const struct pcie_cfg_data bcm7216_cfg = { .num_inbound_wins = 3, }; +static const struct pcie_cfg_data bcm7712_cfg = { + .offsets = pcie_offset_bcm7712, + .perst_set = brcm_pcie_perst_set_7278, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, + .soc_base = BCM7712, + .num_inbound_wins = 10, +}; + static const struct of_device_id brcm_pcie_match[] = { { .compatible = "brcm,bcm2711-pcie", .data = &bcm2711_cfg }, { .compatible = "brcm,bcm4908-pcie", .data = &bcm4908_cfg }, @@ -1747,6 +1766,7 @@ static const struct of_device_id brcm_pcie_match[] = { { .compatible = "brcm,bcm7445-pcie", .data = &generic_cfg }, { .compatible = "brcm,bcm7435-pcie", .data = &bcm7435_cfg }, { .compatible = "brcm,bcm7425-pcie", .data = &bcm7425_cfg }, + { .compatible = "brcm,bcm7712-pcie", .data = &bcm7712_cfg }, {}, };