1// SPDX-License-Identifier: GPL-2.0
2/*
3 * PCIe host controller driver for Mobiveil PCIe Host controller
4 *
5 * Copyright (c) 2018 Mobiveil Inc.
6 * Copyright 2019 NXP
7 *
8 * Author: Subrahmanya Lingappa <l.subrahmanya@mobiveil.co.in>
9 *	   Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
10 */
11
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/of_pci.h>
16#include <linux/pci.h>
17#include <linux/platform_device.h>
18#include <linux/slab.h>
19
20#include "pcie-mobiveil.h"
21
22static int mobiveil_pcie_probe(struct platform_device *pdev)
23{
24	struct mobiveil_pcie *pcie;
25	struct pci_host_bridge *bridge;
26	struct device *dev = &pdev->dev;
27
28	/* allocate the PCIe port */
29	bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
30	if (!bridge)
31		return -ENOMEM;
32
33	pcie = pci_host_bridge_priv(bridge);
34	pcie->rp.bridge = bridge;
35
36	pcie->pdev = pdev;
37
38	return mobiveil_pcie_host_probe(pcie);
39}
40
41static const struct of_device_id mobiveil_pcie_of_match[] = {
42	{.compatible = "mbvl,gpex40-pcie",},
43	{},
44};
45
46MODULE_DEVICE_TABLE(of, mobiveil_pcie_of_match);
47
48static struct platform_driver mobiveil_pcie_driver = {
49	.probe = mobiveil_pcie_probe,
50	.driver = {
51		.name = "mobiveil-pcie",
52		.of_match_table = mobiveil_pcie_of_match,
53		.suppress_bind_attrs = true,
54	},
55};
56
57builtin_platform_driver(mobiveil_pcie_driver);
58
59MODULE_DESCRIPTION("Mobiveil PCIe host controller driver");
60MODULE_AUTHOR("Subrahmanya Lingappa <l.subrahmanya@mobiveil.co.in>");
61