Skip to contentSkip to conversation

dm: pci: Add an inline API to test if a device is on a PCI bus

PATCH New Bin Meng 2 participants 11 messages Sep 11, 2015 – Sep 17, 2015

Subsystems (3)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH v5 1/4 dm: pci: Add an inline API to test if a device is on a PCI bus

Introduce device_is_on_pci_bus() which can be utilized by driver to test if a device is on a PCI bus.

---

Changes in v5:
- Move the inline API from include/pci.h to include/dm/device.h to resolve the cyclic dependency

Changes in v3: None
Changes in v2:
- New patch to add an inline API to test if a device is on a PCI bus

 drivers/pci/pci-uclass.c |  4 ++--
 include/dm/device.h      | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/pci/pci-uclass.c +2 -2
index ea70853..0756bbe 100644
@@ -238,7 +238,7 @@ int dm_pci_write_config(struct udevice *dev, int offset, unsigned long value,
 {
 	struct udevice *bus;
 
-	for (bus = dev; device_get_uclass_id(bus->parent) == UCLASS_PCI;)
+	for (bus = dev; device_is_on_pci_bus(bus);)
 		bus = bus->parent;
 	return pci_bus_write_config(bus, pci_get_bdf(dev), offset, value, size);
 }
@@ -303,7 +303,7 @@ int dm_pci_read_config(struct udevice *dev, int offset, unsigned long *valuep,
 {
 	struct udevice *bus;
 
-	for (bus = dev; device_get_uclass_id(bus->parent) == UCLASS_PCI;)
+	for (bus = dev; device_is_on_pci_bus(bus);)
 		bus = bus->parent;
 	return pci_bus_read_config(bus, pci_get_bdf(dev), offset, valuep,
 				   size);
include/dm/device.h +11 -0
index a239be6..8519612 100644
@@ -485,6 +485,17 @@ bool device_is_last_sibling(struct udevice *dev);
  */
 int device_set_name(struct udevice *dev, const char *name);
 
+/**
+ * device_is_on_pci_bus - Test if a device is on a PCI bus
+ *
+ * @dev:	device to test
+ * @return:	true if it is on a PCI bus, false otherwise
+ */
+static inline bool device_is_on_pci_bus(struct udevice *dev)
+{
+	return device_get_uclass_id(dev->parent) == UCLASS_PCI;
+}
+
 /* device resource management */
 typedef void (*dr_release_t)(struct udevice *dev, void *res);
 typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
Signature · 1 line
1.8.2.1
author
#1 lore raw

PATCH v5 2/4 net: designware: Add support to PCI designware devices

The Designware ethernet controller is also seen on PCI bus, e.g. on Intel Quark SoC. Add this support in the DM version driver.

---

Changes in v5:
- Wrap PCI device support with CONFIG_DM_PCI

Changes in v3:
- Change to use dm_pci_read_config32()

Changes in v2:
- Change to use device_is_on_pci_bus()

 drivers/net/designware.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
drivers/net/designware.c +42 -0
index ae78d21..6433896 100644
@@ -14,6 +14,7 @@
 #include <errno.h>
 #include <miiphy.h>
 #include <malloc.h>
+#include <pci.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <asm/io.h>
@@ -558,6 +559,22 @@ static int designware_eth_write_hwaddr(struct udevice *dev)
 	return _dw_write_hwaddr(priv, pdata->enetaddr);
 }
 
+static int designware_eth_bind(struct udevice *dev)
+{
+#ifdef CONFIG_DM_PCI
+	static int num_cards;
+	char name[20];
+
+	/* Create a unique device name for PCI type devices */
+	if (device_is_on_pci_bus(dev)) {
+		sprintf(name, "eth_designware#%u", num_cards++);
+		device_set_name(dev, name);
+	}
+#endif
+
+	return 0;
+}
+
 static int designware_eth_probe(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -565,6 +582,23 @@ static int designware_eth_probe(struct udevice *dev)
 	u32 iobase = pdata->iobase;
 	int ret;
 
+#ifdef CONFIG_DM_PCI
+	/*
+	 * If we are on PCI bus, either directly attached to a PCI root port,
+	 * or via a PCI bridge, fill in platdata before we probe the hardware.
+	 */
+	if (device_is_on_pci_bus(dev)) {
+		pci_dev_t bdf = pci_get_bdf(dev);
+
+		dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
+		iobase &= PCI_BASE_ADDRESS_MEM_MASK;
+		iobase = pci_mem_to_phys(bdf, iobase);
+
+		pdata->iobase = iobase;
+		pdata->phy_interface = PHY_INTERFACE_MODE_RMII;
+	}
+#endif
+
 	debug("%s, iobase=%x, priv=%p\n", __func__, iobase, priv);
 	priv->mac_regs_p = (struct eth_mac_regs *)iobase;
 	priv->dma_regs_p = (struct eth_dma_regs *)(iobase + DW_DMA_BASE_OFFSET);
@@ -617,10 +651,18 @@ U_BOOT_DRIVER(eth_designware) = {
 	.id	= UCLASS_ETH,
 	.of_match = designware_eth_ids,
 	.ofdata_to_platdata = designware_eth_ofdata_to_platdata,
+	.bind	= designware_eth_bind,
 	.probe	= designware_eth_probe,
 	.ops	= &designware_eth_ops,
 	.priv_auto_alloc_size = sizeof(struct dw_eth_dev),
 	.platdata_auto_alloc_size = sizeof(struct eth_pdata),
 	.flags = DM_FLAG_ALLOC_PRIV_DMA,
 };
+
+static struct pci_device_id supported[] = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_EMAC) },
+	{ }
+};
+
+U_BOOT_PCI_DEVICE(eth_designware, supported);
 #endif
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH v5 2/4 net: designware: Add support to PCI designware devices

Quoted 10 lines · Bin Meng

The Designware ethernet controller is also seen on PCI bus, e.g. on Intel Quark SoC. Add this support in the DM version driver.

---

Changes in v5:
- Wrap PCI device support with CONFIG_DM_PCI

Quoted 8 lines

Changes in v3:
- Change to use dm_pci_read_config32()

Changes in v2:
- Change to use device_is_on_pci_bus()

 drivers/net/designware.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Please see below.

Quoted 65 lines
drivers/net/designware.c +35 -0
index ae78d21..6433896 100644
@@ -14,6 +14,7 @@
 #include <errno.h>
 #include <miiphy.h>
 #include <malloc.h>
+#include <pci.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <asm/io.h>
@@ -558,6 +559,22 @@ static int designware_eth_write_hwaddr(struct udevice *dev)
        return _dw_write_hwaddr(priv, pdata->enetaddr);
 }
 
+static int designware_eth_bind(struct udevice *dev)
+{
+#ifdef CONFIG_DM_PCI
+       static int num_cards;
+       char name[20];
+
+       /* Create a unique device name for PCI type devices */
+       if (device_is_on_pci_bus(dev)) {
+               sprintf(name, "eth_designware#%u", num_cards++);
+               device_set_name(dev, name);
+       }
+#endif
+
+       return 0;
+}
+
 static int designware_eth_probe(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -565,6 +582,23 @@ static int designware_eth_probe(struct udevice *dev)
        u32 iobase = pdata->iobase;
        int ret;
 
+#ifdef CONFIG_DM_PCI
+       /*
+        * If we are on PCI bus, either directly attached to a PCI root port,
+        * or via a PCI bridge, fill in platdata before we probe the hardware.
+        */
+       if (device_is_on_pci_bus(dev)) {
+               pci_dev_t bdf = pci_get_bdf(dev);
+
+               dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
+               iobase &= PCI_BASE_ADDRESS_MEM_MASK;
+               iobase = pci_mem_to_phys(bdf, iobase);
+
+               pdata->iobase = iobase;
+               pdata->phy_interface = PHY_INTERFACE_MODE_RMII;
+       }
+#endif
+
        debug("%s, iobase=%x, priv=%p\n", __func__, iobase, priv);
        priv->mac_regs_p = (struct eth_mac_regs *)iobase;
        priv->dma_regs_p = (struct eth_dma_regs *)(iobase + DW_DMA_BASE_OFFSET);
@@ -617,10 +651,18 @@ U_BOOT_DRIVER(eth_designware) = {
        .id     = UCLASS_ETH,
        .of_match = designware_eth_ids,
        .ofdata_to_platdata = designware_eth_ofdata_to_platdata,
+       .bind   = designware_eth_bind,

drivers/net/designware.c U_BOOT_DRIVER(eth_designware) = { · line 664

Quoted 10 lines
drivers/net/designware.c +4 -0
        .probe  = designware_eth_probe,
        .ops    = &designware_eth_ops,
        .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
        .platdata_auto_alloc_size = sizeof(struct eth_pdata),
        .flags = DM_FLAG_ALLOC_PRIV_DMA,
 };
+
+static struct pci_device_id supported[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_EMAC) },
+       { }

Rather than ending up with a table of these device IDs, should this go in the device tree?

Quoted 7 lines
drivers/net/designware.c +3 -1
+};
+
+U_BOOT_PCI_DEVICE(eth_designware, supported);
 #endif
--

1.8.2.1

Regards,
Simon

author
#3 lore raw

PATCH v5 2/4 net: designware: Add support to PCI designware devices

Hi Simon,

Quoted 94 lines · Simon Glass
Quoted 10 lines · Bin Meng

The Designware ethernet controller is also seen on PCI bus, e.g. on Intel Quark SoC. Add this support in the DM version driver.

---

Changes in v5:
- Wrap PCI device support with CONFIG_DM_PCI

Quoted 8 lines

Changes in v3:
- Change to use dm_pci_read_config32()

Changes in v2:
- Change to use device_is_on_pci_bus()

 drivers/net/designware.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Please see below.

Quoted 70 lines
drivers/net/designware.c +35 -0
index ae78d21..6433896 100644
@@ -14,6 +14,7 @@
 #include <errno.h>
 #include <miiphy.h>
 #include <malloc.h>
+#include <pci.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <asm/io.h>
@@ -558,6 +559,22 @@ static int designware_eth_write_hwaddr(struct udevice *dev)
        return _dw_write_hwaddr(priv, pdata->enetaddr);
 }
 
+static int designware_eth_bind(struct udevice *dev)
+{
+#ifdef CONFIG_DM_PCI
+       static int num_cards;
+       char name[20];
+
+       /* Create a unique device name for PCI type devices */
+       if (device_is_on_pci_bus(dev)) {
+               sprintf(name, "eth_designware#%u", num_cards++);
+               device_set_name(dev, name);
+       }
+#endif
+
+       return 0;
+}
+
 static int designware_eth_probe(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -565,6 +582,23 @@ static int designware_eth_probe(struct udevice *dev)
        u32 iobase = pdata->iobase;
        int ret;
 
+#ifdef CONFIG_DM_PCI
+       /*
+        * If we are on PCI bus, either directly attached to a PCI root port,
+        * or via a PCI bridge, fill in platdata before we probe the hardware.
+        */
+       if (device_is_on_pci_bus(dev)) {
+               pci_dev_t bdf = pci_get_bdf(dev);
+
+               dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
+               iobase &= PCI_BASE_ADDRESS_MEM_MASK;
+               iobase = pci_mem_to_phys(bdf, iobase);
+
+               pdata->iobase = iobase;
+               pdata->phy_interface = PHY_INTERFACE_MODE_RMII;
+       }
+#endif
+
        debug("%s, iobase=%x, priv=%p\n", __func__, iobase, priv);
        priv->mac_regs_p = (struct eth_mac_regs *)iobase;
        priv->dma_regs_p = (struct eth_dma_regs *)(iobase + DW_DMA_BASE_OFFSET);
@@ -617,10 +651,18 @@ U_BOOT_DRIVER(eth_designware) = {
        .id     = UCLASS_ETH,
        .of_match = designware_eth_ids,
        .ofdata_to_platdata = designware_eth_ofdata_to_platdata,
+       .bind   = designware_eth_bind,
        .probe  = designware_eth_probe,
        .ops    = &designware_eth_ops,
        .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
        .platdata_auto_alloc_size = sizeof(struct eth_pdata),
        .flags = DM_FLAG_ALLOC_PRIV_DMA,
Quoted 8 lines

drivers/net/designware.c U_BOOT_DRIVER(eth_designware) = { · line 664

Quoted 5 lines
drivers/net/designware.c +4 -0
 };
+
+static struct pci_device_id supported[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_EMAC) },
+       { }

Rather than ending up with a table of these device IDs, should this go in the device tree?

I am OK for either way. In fact compared to the widely available PCI NS16550 devices from many chipset vendors, there are just two or three PCI variants of designware ethernet devices so far (seen from linux driver). I guess putting a device ID table here is not that bad.

Quoted 6 lines

drivers/net/designware.c U_BOOT_DRIVER(eth_designware) = {

Quoted 6 lines
drivers/net/designware.c +3 -1
+};
+
+U_BOOT_PCI_DEVICE(eth_designware, supported);
 #endif
--

Regards,
Bin

#4 lore raw

PATCH v5 2/4 net: designware: Add support to PCI designware devices

Quoted 106 lines · Bin Meng

Hi Simon,

Quoted 94 lines · Simon Glass
Quoted 10 lines · Bin Meng

The Designware ethernet controller is also seen on PCI bus, e.g. on Intel Quark SoC. Add this support in the DM version driver.

---

Changes in v5:
- Wrap PCI device support with CONFIG_DM_PCI

Quoted 8 lines

Changes in v3:
- Change to use dm_pci_read_config32()

Changes in v2:
- Change to use device_is_on_pci_bus()

 drivers/net/designware.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Please see below.

Quoted 70 lines
drivers/net/designware.c +35 -0
index ae78d21..6433896 100644
@@ -14,6 +14,7 @@
 #include <errno.h>
 #include <miiphy.h>
 #include <malloc.h>
+#include <pci.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <asm/io.h>
@@ -558,6 +559,22 @@ static int designware_eth_write_hwaddr(struct udevice *dev)
        return _dw_write_hwaddr(priv, pdata->enetaddr);
 }
 
+static int designware_eth_bind(struct udevice *dev)
+{
+#ifdef CONFIG_DM_PCI
+       static int num_cards;
+       char name[20];
+
+       /* Create a unique device name for PCI type devices */
+       if (device_is_on_pci_bus(dev)) {
+               sprintf(name, "eth_designware#%u", num_cards++);
+               device_set_name(dev, name);
+       }
+#endif
+
+       return 0;
+}
+
 static int designware_eth_probe(struct udevice *dev)
 {
        struct eth_pdata *pdata = dev_get_platdata(dev);
@@ -565,6 +582,23 @@ static int designware_eth_probe(struct udevice *dev)
        u32 iobase = pdata->iobase;
        int ret;
 
+#ifdef CONFIG_DM_PCI
+       /*
+        * If we are on PCI bus, either directly attached to a PCI root port,
+        * or via a PCI bridge, fill in platdata before we probe the hardware.
+        */
+       if (device_is_on_pci_bus(dev)) {
+               pci_dev_t bdf = pci_get_bdf(dev);
+
+               dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase);
+               iobase &= PCI_BASE_ADDRESS_MEM_MASK;
+               iobase = pci_mem_to_phys(bdf, iobase);
+
+               pdata->iobase = iobase;
+               pdata->phy_interface = PHY_INTERFACE_MODE_RMII;
+       }
+#endif
+
        debug("%s, iobase=%x, priv=%p\n", __func__, iobase, priv);
        priv->mac_regs_p = (struct eth_mac_regs *)iobase;
        priv->dma_regs_p = (struct eth_dma_regs *)(iobase + DW_DMA_BASE_OFFSET);
@@ -617,10 +651,18 @@ U_BOOT_DRIVER(eth_designware) = {
        .id     = UCLASS_ETH,
        .of_match = designware_eth_ids,
        .ofdata_to_platdata = designware_eth_ofdata_to_platdata,
+       .bind   = designware_eth_bind,
        .probe  = designware_eth_probe,
        .ops    = &designware_eth_ops,
        .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
        .platdata_auto_alloc_size = sizeof(struct eth_pdata),
        .flags = DM_FLAG_ALLOC_PRIV_DMA,
Quoted 8 lines

drivers/net/designware.c U_BOOT_DRIVER(eth_designware) = { · line 664

Quoted 5 lines
drivers/net/designware.c +4 -0
 };
+
+static struct pci_device_id supported[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_EMAC) },
+       { }

Rather than ending up with a table of these device IDs, should this go in the device tree?

Quoted 4 lines

I am OK for either way. In fact compared to the widely available PCI NS16550 devices from many chipset vendors, there are just two or three PCI variants of designware ethernet devices so far (seen from linux driver). I guess putting a device ID table here is not that bad.

OK let's revisit it if needed.

Applied to u-boot-x86, thanks!

author
#5 lore raw

PATCH v5 3/4 x86: Convert to use driver model eth on quark/galileo

In reply to Bin Meng

Convert to use DM version of Designware ethernet driver on Intel quark/galileo.

---

Changes in v5: None
Changes in v3: None
Changes in v2: None

 arch/x86/cpu/quark/quark.c | 19 -------------------
 configs/galileo_defconfig  |  2 +-
 2 files changed, 1 insertion(+), 20 deletions(-)
arch/x86/cpu/quark/quark.c +0 -19
index 637c370..caa3875 100644
@@ -6,8 +6,6 @@
 
 #include <common.h>
 #include <mmc.h>
-#include <netdev.h>
-#include <phy.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/pci.h>
@@ -231,23 +229,6 @@ int cpu_mmc_init(bd_t *bis)
 			    ARRAY_SIZE(mmc_supported));
 }
 
-int cpu_eth_init(bd_t *bis)
-{
-	u32 base;
-	int ret0, ret1;
-
-	qrk_pci_read_config_dword(QUARK_EMAC0, PCI_BASE_ADDRESS_0, &base);
-	ret0 = designware_initialize(base, PHY_INTERFACE_MODE_RMII);
-
-	qrk_pci_read_config_dword(QUARK_EMAC1, PCI_BASE_ADDRESS_0, &base);
-	ret1 = designware_initialize(base, PHY_INTERFACE_MODE_RMII);
-
-	if (ret0 < 0 && ret1 < 0)
-		return -1;
-	else
-		return 0;
-}
-
 void cpu_irq_init(void)
 {
 	struct quark_rcba *rcba;
configs/galileo_defconfig +1 -1
index d05154e..9623986 100644
@@ -12,7 +12,7 @@ CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_CMD_BOOTSTAGE=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPI_FLASH=y
-CONFIG_NETDEVICES=y
+CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_DM_PCI=y
 CONFIG_DM_RTC=y
Signature · 1 line
1.8.2.1
#6 lore raw

PATCH v5 3/4 x86: Convert to use driver model eth on quark/galileo

Quoted 8 lines · Bin Meng

Convert to use DM version of Designware ethernet driver on Intel quark/galileo.

---

Quoted 7 lines

Changes in v5: None
Changes in v3: None
Changes in v2: None

 arch/x86/cpu/quark/quark.c | 19 -------------------
 configs/galileo_defconfig  |  2 +-
 2 files changed, 1 insertion(+), 20 deletions(-)

Applied to u-boot-x86, thanks!

author
#7 lore raw

PATCH v5 4/4 x86: quark: Add PCIe/USB static register programming after memory init

In reply to Bin Meng

This adds static register programming for PCIe and USB after memory init as required by Quark firmware writer guide. Although not doing this did not cause any malfunction, just do it for safety.

---

Changes in v5: None
Changes in v3: None
Changes in v2:
- New patch to add PCIe/USB static register programming after memory init

 arch/x86/cpu/quark/quark.c              | 64 +++++++++++++++++++++++++++++++++
 arch/x86/include/asm/arch-quark/quark.h | 22 ++++++++++++
 include/configs/galileo.h               |  1 +
 3 files changed, 87 insertions(+)
arch/x86/cpu/quark/quark.c +64 -0
index caa3875..934250b 100644
@@ -223,6 +223,53 @@ void reset_cpu(ulong addr)
 	x86_full_reset();
 }
 
+static void quark_pcie_init(void)
+{
+	u32 val;
+
+	/* PCIe upstream non-posted & posted request size */
+	qrk_pci_write_config_dword(QUARK_PCIE0, PCIE_RP_CCFG,
+				   CCFG_UPRS | CCFG_UNRS);
+	qrk_pci_write_config_dword(QUARK_PCIE1, PCIE_RP_CCFG,
+				   CCFG_UPRS | CCFG_UNRS);
+
+	/* PCIe packet fast transmit mode (IPF) */
+	qrk_pci_write_config_dword(QUARK_PCIE0, PCIE_RP_MPC2, MPC2_IPF);
+	qrk_pci_write_config_dword(QUARK_PCIE1, PCIE_RP_MPC2, MPC2_IPF);
+
+	/* PCIe message bus idle counter (SBIC) */
+	qrk_pci_read_config_dword(QUARK_PCIE0, PCIE_RP_MBC, &val);
+	val |= MBC_SBIC;
+	qrk_pci_write_config_dword(QUARK_PCIE0, PCIE_RP_MBC, val);
+	qrk_pci_read_config_dword(QUARK_PCIE1, PCIE_RP_MBC, &val);
+	val |= MBC_SBIC;
+	qrk_pci_write_config_dword(QUARK_PCIE1, PCIE_RP_MBC, val);
+}
+
+static void quark_usb_init(void)
+{
+	u32 bar;
+
+	/* Change USB EHCI packet buffer OUT/IN threshold */
+	qrk_pci_read_config_dword(QUARK_USB_EHCI, PCI_BASE_ADDRESS_0, &bar);
+	writel((0x7f << 16) | 0x7f, bar + EHCI_INSNREG01);
+
+	/* Disable USB device interrupts */
+	qrk_pci_read_config_dword(QUARK_USB_DEVICE, PCI_BASE_ADDRESS_0, &bar);
+	writel(0x7f, bar + USBD_INT_MASK);
+	writel((0xf << 16) | 0xf, bar + USBD_EP_INT_MASK);
+	writel((0xf << 16) | 0xf, bar + USBD_EP_INT_STS);
+}
+
+int arch_early_init_r(void)
+{
+	quark_pcie_init();
+
+	quark_usb_init();
+
+	return 0;
+}
+
 int cpu_mmc_init(bd_t *bis)
 {
 	return pci_mmc_init("Quark SDHCI", mmc_supported,
@@ -256,3 +303,20 @@ int arch_misc_init(void)
 {
 	return pirq_init();
 }
+
+void board_final_cleanup(void)
+{
+	struct quark_rcba *rcba;
+	u32 base, val;
+
+	qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_RCBA, &base);
+	base &= ~MEM_BAR_EN;
+	rcba = (struct quark_rcba *)base;
+
+	/* Initialize 'Component ID' to zero */
+	val = readl(&rcba->esd);
+	val &= ~0xff0000;
+	writel(val, &rcba->esd);
+
+	return;
+}
arch/x86/include/asm/arch-quark/quark.h +22 -0
index 5d81976..eb3afbf 100644
@@ -88,6 +88,20 @@
 /* 64KiB of RMU binary in flash */
 #define RMU_BINARY_SIZE		0x10000
 
+/* PCIe Root Port Configuration Registers */
+
+#define PCIE_RP_CCFG		0xd0
+#define CCFG_UPRS		(1 << 14)
+#define CCFG_UNRS		(1 << 15)
+#define CCFG_UNSD		(1 << 23)
+#define CCFG_UPSD		(1 << 24)
+
+#define PCIE_RP_MPC2		0xd4
+#define MPC2_IPF		(1 << 11)
+
+#define PCIE_RP_MBC		0xf4
+#define MBC_SBIC		(3 << 16)
+
 /* Legacy Bridge PCI Configuration Registers */
 #define LB_GBA			0x44
 #define LB_PM1BLK		0x48
@@ -100,6 +114,14 @@
 #define LB_BC			0xd8
 #define LB_RCBA			0xf0
 
+/* USB EHCI memory-mapped registers */
+#define EHCI_INSNREG01		0x94
+
+/* USB device memory-mapped registers */
+#define USBD_INT_MASK		0x410
+#define USBD_EP_INT_STS		0x414
+#define USBD_EP_INT_MASK	0x418
+
 #ifndef __ASSEMBLY__
 
 /* Root Complex Register Block */
include/configs/galileo.h +1 -0
index b7ec279..ba6c8f1 100644
@@ -15,6 +15,7 @@
 
 #define CONFIG_SYS_MONITOR_LEN		(1 << 20)
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_ARCH_EARLY_INIT_R
 #define CONFIG_ARCH_MISC_INIT
 
 /* ns16550 UART is memory-mapped in Quark SoC */
Signature · 1 line
1.8.2.1
#8 lore raw

PATCH v5 4/4 x86: quark: Add PCIe/USB static register programming after memory init

Quoted 14 lines · Bin Meng

This adds static register programming for PCIe and USB after memory init as required by Quark firmware writer guide. Although not doing this did not cause any malfunction, just do it for safety.

---

Changes in v5: None
Changes in v3: None
Changes in v2:
- New patch to add PCIe/USB static register programming after memory init

Quoted 4 lines
 arch/x86/cpu/quark/quark.c              | 64 +++++++++++++++++++++++++++++++++
 arch/x86/include/asm/arch-quark/quark.h | 22 ++++++++++++
 include/configs/galileo.h               |  1 +
 3 files changed, 87 insertions(+)

Applied to u-boot-x86, thanks!

#9 lore raw

PATCH v5 1/4 dm: pci: Add an inline API to test if a device is on a PCI bus

In reply to Bin Meng
Quoted 11 lines · Bin Meng

Introduce device_is_on_pci_bus() which can be utilized by driver to test if a device is on a PCI bus.

---

Changes in v5:
- Move the inline API from include/pci.h to include/dm/device.h to resolve the cyclic dependency

Quoted 7 lines

Changes in v3: None
Changes in v2:
- New patch to add an inline API to test if a device is on a PCI bus

 drivers/pci/pci-uclass.c |  4 ++--
 include/dm/device.h      | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
#10 lore raw

PATCH v5 1/4 dm: pci: Add an inline API to test if a device is on a PCI bus

Quoted 16 lines · Simon Glass
Quoted 15 lines · Bin Meng

Introduce device_is_on_pci_bus() which can be utilized by driver to test if a device is on a PCI bus.

---

Changes in v5:
- Move the inline API from include/pci.h to include/dm/device.h to resolve the cyclic dependency

Changes in v3: None
Changes in v2:
- New patch to add an inline API to test if a device is on a PCI bus

Quoted 5 lines
Quoted 3 lines
 drivers/pci/pci-uclass.c |  4 ++--
 include/dm/device.h      | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

Applied to u-boot-x86, thanks!