From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Stefan Roese <sr@denx.de>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] [POWERPC] 4xx: Add endpoint support to 4xx PCIe driver
Date: Thu, 10 Apr 2008 19:27:29 +1000 [thread overview]
Message-ID: <1207819649.6958.3.camel@pasglop> (raw)
In-Reply-To: <1207149149-17107-1-git-send-email-sr@denx.de>
On Wed, 2008-04-02 at 17:12 +0200, Stefan Roese wrote:
../..
Overall looks good, just a few things:
In general, while I have nothing against the idea of reading the HW
setup left by uboot, I wonder if it wouldn't be best to have this file
capable of fully configuring it in either mode based on DT properties
instead. The PCI node in endpoint mode would be called something
different, such as "pci-endpoint" and would contain some kind of
"endpoint-mode" property, maybe ? That way people using other
bootloaders or even booting of straight flash kernels can still use
this.
> +
> + out_le32(mbase + PCI_BASE_ADDRESS_0, RES_TO_U32_LOW(res->start));
> + out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(res->start));
> + }
>
> /* Enable inbound mapping */
> out_le32(mbase + PECFG_PIMEN, 0x1);
>
> - out_le32(mbase + PCI_BASE_ADDRESS_0, RES_TO_U32_LOW(res->start));
> - out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(res->start));
> -
does it work properly to setup the BARs before enabling the inbound
mapping ?
> * OMRs are already reset, also disable PIMs
> @@ -1531,14 +1569,26 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
> * and device IDs into it. Those are the same bogus one that the
> * initial code in arch/ppc add. We might want to change that.
> */
> - out_le16(mbase + 0x200, 0xaaa0 + port->index);
> - out_le16(mbase + 0x202, 0xbed0 + port->index);
> + if (!port->endpoint) {
> + out_le16(mbase + 0x200, 0xaaa0 + port->index);
> + out_le16(mbase + 0x202, 0xbed0 + port->index);
>
We should probably setup the config space IDs based on some device-tree
properties no ?
> - /* Set Class Code to PCI-PCI bridge and Revision Id to 1 */
> - out_le32(mbase + 0x208, 0x06040001);
> + /* Set Class Code to PCI-PCI bridge and Revision Id to 1 */
> + out_le32(mbase + 0x208, 0x06040001);
> +
> + printk(KERN_INFO "PCIE%d: successfully set as root-complex\n",
> + port->index);
> + } else {
> + out_le16(mbase + 0x200, 0xeee0 + port->index);
> + out_le16(mbase + 0x202, 0xfed0 + port->index);
> +
> + /* Set Class Code to Processor/PPC */
> + out_le32(mbase + 0x208, 0x0b200001);
> +
> + printk(KERN_INFO "PCIE%d: successfully set as endpoint\n",
> + port->index);
> + }
>
> - printk(KERN_INFO "PCIE%d: successfully set as root-complex\n",
> - port->index);
> return;
> fail:
> if (hose)
> @@ -1586,8 +1636,17 @@ static void __init ppc4xx_probe_pciex_bridge(struct device_node *np)
> }
> port->sdr_base = *pval;
>
> - /* XXX Currently, we only support root complex mode */
> - port->endpoint = 0;
> + /* Check whether the PCIe port is already configured as root-complex
> + * or as endpoint. This has been done previously in U-Boot and can
> + * be configured there dynamically by setting the "pcie_mode"
> + * environment variable (reboot necessary of course). Here an example:
> + *
> + * pcie_mode = 'RP:RP:EP'
> + *
> + * Port 0 & 1 are configured as root-complex and port 2 as endpoint.
> + * This mode will now be used in the Linux driver too.
> + */
> + port->endpoint = is_endpoint(port);
>
> /* Fetch config space registers address */
> if (of_address_to_resource(np, 0, &port->cfg_space)) {
> --
> 1.5.4.5
>
next prev parent reply other threads:[~2008-04-10 9:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-02 15:12 [PATCH] [POWERPC] 4xx: Add endpoint support to 4xx PCIe driver Stefan Roese
2008-04-02 15:16 ` Stefan Roese
2008-04-10 9:27 ` Benjamin Herrenschmidt [this message]
2008-04-10 10:21 ` Stefan Roese
2008-04-10 10:35 ` Benjamin Herrenschmidt
2008-04-10 11:59 ` Stefan Roese
2008-04-10 12:23 ` Benjamin Herrenschmidt
2008-04-10 13:37 ` Stefan Roese
2008-04-10 21:58 ` Benjamin Herrenschmidt
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=1207819649.6958.3.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=sr@denx.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;
as well as URLs for NNTP newsgroup(s).