Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0c5c4dc authored by Tony Truong's avatar Tony Truong
Browse files

msm: pcie: register PCI driver with framework for root port



Register root port with PCI driver framework so that
it will get probe during PCI enumeration. This provides
the root port the option to configure its pci_dev.

Change-Id: Ia52bb2e4230fe9b8d3431022d89125e113463a80
Signed-off-by: default avatarTony Truong <truong@codeaurora.org>
parent 2ce74b94
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ Required properties:
  - perst-gpio: PERST GPIO specified by PCIe spec.
  - wake-gpio: WAKE GPIO specified by PCIe spec.
  - phy-status-offset: Offset from PCIe PHY base to check if PCIe PHY is up.
  - pcie_rc<PCIe index>: PCI node is a sub-node of PCIe controller node.
    node. This node holds root complex specific configurations and properties.
  - <supply-name>-supply: phandle to the regulator device tree node.
    Refer to the schematics for the corresponding voltage regulators.
    vreg-1.8-supply: phandle to the analog supply for the PCIe controller.
@@ -128,6 +130,17 @@ Optional Properties:
  - reset-names: reset signal name strings sorted in the same order as the resets
    property.

=================
Root Complex node
=================

Root complex are defined as subnodes of the PCIe controller node.

Required properties:
- reg: Array (5-cell PCI resource) of <u32>. First cell is devfn, which is
  determined by pci bus topology. Assign the other cells 0 since they are not
  used.

Example:

	pcie0: qcom,pcie@fc520000 {
@@ -304,4 +317,8 @@ Example:
		qcom,msm-bus,vectors-KBps =
				<45 512 0 0>,
				<45 512 500 800>;

		pcie_rc0: pcie_rc0 {
			reg = <0x0 0x0 0x0 0x0 0x0>;
		};
	};
+43 −0
Original line number Diff line number Diff line
@@ -649,6 +649,11 @@ struct msm_pcie_dev_t {
	struct msm_pcie_device_info   pcidev_table[MAX_DEVICE_NUM];
};

struct msm_root_dev_t {
	struct msm_pcie_dev_t *pcie_dev;
	struct pci_dev *pci_dev;
};

/* debug mask sys interface */
static int msm_pcie_debug_mask;
module_param_named(debug_mask, msm_pcie_debug_mask,
@@ -6333,6 +6338,40 @@ static int msm_pcie_remove(struct platform_device *pdev)
	return ret;
}


int msm_pci_probe(struct pci_dev *pci_dev,
		  const struct pci_device_id *device_id)
{
	struct msm_pcie_dev_t *pcie_dev = PCIE_BUS_PRIV_DATA(pci_dev->bus);
	struct msm_root_dev_t *root_dev;

	PCIE_DBG(pcie_dev, "PCIe: RC%d: PCI Probe\n", pcie_dev->rc_idx);

	if (!pci_dev->dev.of_node)
		return -ENODEV;

	root_dev = devm_kzalloc(&pci_dev->dev, sizeof(*root_dev), GFP_KERNEL);
	if (!root_dev)
		return -ENOMEM;

	root_dev->pcie_dev = pcie_dev;
	root_dev->pci_dev = pci_dev;
	dev_set_drvdata(&pci_dev->dev, root_dev);

	return 0;
}

static struct pci_device_id msm_pci_device_id[] = {
	{PCI_DEVICE(0x17cb, 0x0108)},
	{0},
};

static struct pci_driver msm_pci_driver = {
	.name = "pci-msm-rc",
	.id_table = msm_pci_device_id,
	.probe = msm_pci_probe,
};

static const struct of_device_id msm_pcie_match[] = {
	{	.compatible = "qcom,pci-msm",
	},
@@ -6416,6 +6455,10 @@ static int __init pcie_init(void)

	msm_pcie_debugfs_init();

	ret = pci_register_driver(&msm_pci_driver);
	if (ret)
		return ret;

	ret = platform_driver_register(&msm_pcie_driver);

	return ret;