#include <linux/device.h>
#include <linux/irqdomain.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/pci.h>
static void tc9564_function_remove(struct pci_dev *pdev)
{
of_platform_depopulate(&pdev->dev);
pci_clear_master(pdev);
pci_disable_device(pdev);
}
static int
tc9564_function_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct device *dev = &pdev->dev;
struct device_node *np;
int ret;
np = dev_of_node(dev);
if (!np)
return dev_err_probe(dev, -EINVAL, "no devicetree node\n");
ret = pci_enable_device(pdev);
if (ret)
return dev_err_probe(dev, ret, "failed to enable device\n");
pci_set_master(pdev);
ret = of_platform_default_populate(np, NULL, dev);
if (ret)
goto err_depopulate;
return 0;
err_depopulate:
tc9564_function_remove(pdev);
return dev_err_probe(dev, ret, "failed to populate platform bus\n");
}
static const struct pci_device_id tc9564_function_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA, 0x0220), },
{ },
};
MODULE_DEVICE_TABLE(pci, tc9564_function_id_table);
static struct pci_driver tc9564_function_driver = {
.name = KBUILD_MODNAME,
.id_table = tc9564_function_id_table,
.probe = tc9564_function_probe,
.remove = tc9564_function_remove,
};
module_pci_driver(tc9564_function_driver);
MODULE_DESCRIPTION("Toshiba TC9564 PCIe Embedded Function Driver");
MODULE_LICENSE("GPL"