mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stanimir Varbanov <svarbanov@suse.de>
To: James Quinlan <james.quinlan@broadcom.com>,
	Stanimir Varbanov <svarbanov@suse.de>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-rpi-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Jim Quinlan <jim2101024@gmail.com>,
	Nicolas Saenz Julienne <nsaenz@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	kw@linux.com, Philipp Zabel <p.zabel@pengutronix.de>,
	Andrea della Porta <andrea.porta@suse.com>,
	Phil Elwell <phil@raspberrypi.com>,
	Jonathan Bell <jonathan@raspberrypi.com>
Subject: Re: [PATCH v4 08/10] PCI: brcmstb: Adjust PHY PLL setup to use a 54MHz input refclk
Date: Tue, 10 Dec 2024 15:42:21 +0200	[thread overview]
Message-ID: <f9f49030-0518-4e30-91a7-3c088c31180b@suse.de> (raw)
In-Reply-To: <4bbdf9ed-f429-411b-8f5f-e51857f0f9d0@broadcom.com>

Hi Jim

On 12/10/24 12:52 AM, James Quinlan wrote:
> On 10/25/24 08:45, Stanimir Varbanov wrote:
>> The default input reference clock for the PHY PLL is 100Mhz, except for
>> some devices where it is 54Mhz like bcm2712C1 and bcm2712D0.
>>
>> To implement this adjustments introduce a new .post_setup op in
>> pcie_cfg_data and call it at the end of brcm_pcie_setup function.
>>
>> The bcm2712 .post_setup callback implements the required MDIO writes that
>> switch the PLL refclk and also change PHY PM clock period.
>>
>> Without this RPi5 PCIex1 is unable to enumerate endpoint devices on
>> the expansion connector.
>>
>> Signed-off-by: Stanimir Varbanov <svarbanov@suse.de>
>> ---
>> v3 -> v4:
>>   - Improved patch description (Florian)
>>
>>   drivers/pci/controller/pcie-brcmstb.c | 42 +++++++++++++++++++++++++++
>>   1 file changed, 42 insertions(+)
>>
>> diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/
>> controller/pcie-brcmstb.c
>> index d970a76aa9ef..2571dcc14560 100644
>> --- a/drivers/pci/controller/pcie-brcmstb.c
>> +++ b/drivers/pci/controller/pcie-brcmstb.c
>> @@ -55,6 +55,10 @@
>>   #define PCIE_RC_DL_MDIO_WR_DATA                0x1104
>>   #define PCIE_RC_DL_MDIO_RD_DATA                0x1108
>>   +#define PCIE_RC_PL_PHY_CTL_15                0x184c
>> +#define  PCIE_RC_PL_PHY_CTL_15_DIS_PLL_PD_MASK        0x400000
>> +#define  PCIE_RC_PL_PHY_CTL_15_PM_CLK_PERIOD_MASK    0xff
>> +
>>   #define PCIE_MISC_MISC_CTRL                0x4008
>>   #define  PCIE_MISC_MISC_CTRL_PCIE_RCB_64B_MODE_MASK    0x80
>>   #define  PCIE_MISC_MISC_CTRL_PCIE_RCB_MPS_MODE_MASK    0x400
>> @@ -251,6 +255,7 @@ struct pcie_cfg_data {
>>       u8 num_inbound_wins;
>>       int (*perst_set)(struct brcm_pcie *pcie, u32 val);
>>       int (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val);
>> +    int (*post_setup)(struct brcm_pcie *pcie);
>>   };
>>     struct subdev_regulators {
>> @@ -826,6 +831,36 @@ static int brcm_pcie_perst_set_generic(struct
>> brcm_pcie *pcie, u32 val)
>>       return 0;
>>   }
>>   +static int brcm_pcie_post_setup_bcm2712(struct brcm_pcie *pcie)
>> +{
>> +    const u16 data[] = { 0x50b9, 0xbda1, 0x0094, 0x97b4, 0x5030,
>> 0x5030, 0x0007 };
>> +    const u8 regs[] = { 0x16, 0x17, 0x18, 0x19, 0x1b, 0x1c, 0x1e };
>> +    int ret, i;
>> +    u32 tmp;
>> +
>> +    /* Allow a 54MHz (xosc) refclk source */
>> +    ret = brcm_pcie_mdio_write(pcie->base, MDIO_PORT0,
>> SET_ADDR_OFFSET, 0x1600);
>> +    if (ret < 0)
>> +        return ret;
>> +
>> +    for (i = 0; i < ARRAY_SIZE(regs); i++) {
>> +        ret = brcm_pcie_mdio_write(pcie->base, MDIO_PORT0, regs[i],
>> data[i]);
>> +        if (ret < 0)
>> +            return ret;
>> +    }
>> +
>> +    usleep_range(100, 200);
>> +
>> +    /* Fix for L1SS errata */
>> +    tmp = readl(pcie->base + PCIE_RC_PL_PHY_CTL_15);
>> +    tmp &= ~PCIE_RC_PL_PHY_CTL_15_PM_CLK_PERIOD_MASK;
>> +    /* PM clock period is 18.52ns (round down) */
>> +    tmp |= 0x12;
>> +    writel(tmp, pcie->base + PCIE_RC_PL_PHY_CTL_15);
> 
> Hi Stan,
> 
> Can you please say more about where this errata came from?  I asked the
> 7712 PCIe HW folks and they said that there best guess was that it was a
> old workaround for a particular Broadcom Wifi endpoint.  Do you know its
> origin?

Unfortunately, I don't know the details. See the comments on previous
series version [1]. My observation shows that MDIO writes are
implemented in RPi platform firmware only for pcie2 (where RP1 south
bridge is connected) but not for pcie1 expansion connector.

~Stan

[1] https://www.spinics.net/lists/linux-pci/msg160842.html


  reply	other threads:[~2024-12-10 13:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 12:45 [PATCH v4 00/10] Add PCIe support for bcm2712 Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 01/10] dt-bindings: interrupt-controller: Add bcm2712 MSI-X DT bindings Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 02/10] dt-bindings: PCI: brcmstb: Update bindings for PCIe on bcm2712 Stanimir Varbanov
2024-10-25 21:55   ` Rob Herring
2024-10-25 12:45 ` [PATCH v4 03/10] irqchip: Add Broadcom bcm2712 MSI-X interrupt controller Stanimir Varbanov
2024-10-28 20:06   ` Thomas Gleixner
2024-11-01 13:15     ` Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 04/10] PCI: brcmstb: Reuse config structure Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 05/10] PCI: brcmstb: Expand inbound window size up to 64GB Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 06/10] PCI: brcmstb: Enable external MSI-X if available Stanimir Varbanov
2024-11-10  9:41   ` Stanimir Varbanov
2024-12-11 20:01   ` James Quinlan
2024-12-18 14:54     ` Stanimir Varbanov
2024-12-18 16:20       ` Jim Quinlan
2024-10-25 12:45 ` [PATCH v4 07/10] PCI: brcmstb: Add bcm2712 support Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 08/10] PCI: brcmstb: Adjust PHY PLL setup to use a 54MHz input refclk Stanimir Varbanov
2024-10-25 22:08   ` Florian Fainelli
2024-12-09 22:52   ` James Quinlan
2024-12-10 13:42     ` Stanimir Varbanov [this message]
2024-12-11 19:39       ` James Quinlan
2024-12-11 20:54         ` Jonathan Bell
2024-12-12 13:48           ` Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 09/10] arm64: dts: broadcom: bcm2712: Add PCIe DT nodes Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 10/10] arm64: dts: broadcom: bcm2712-rpi-5-b: Enable " Stanimir Varbanov
2024-12-23 16:35 ` [PATCH v4 00/10] Add PCIe support for bcm2712 Olivier Benjamin
2025-01-21 15:01   ` Stanimir Varbanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f9f49030-0518-4e30-91a7-3c088c31180b@suse.de \
    --to=svarbanov@suse.de \
    --cc=andrea.porta@suse.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=james.quinlan@broadcom.com \
    --cc=jim2101024@gmail.com \
    --cc=jonathan@raspberrypi.com \
    --cc=krzk+dt@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=lpieralisi@kernel.org \
    --cc=nsaenz@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=phil@raspberrypi.com \
    --cc=robh@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®