#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static const struct of_device_id my_pru_of_match[]; static int my_pru_driver_probe(struct platform_device *pdev) { struct device *dev; struct device_node *node = pdev->dev.of_node; const struct of_device_id *match; int ret; struct pruss *pruss; struct rproc *pru0, *pru1; if (!node) return -ENODEV; match = of_match_device(my_pru_of_match, &pdev->dev); if (!match) return -ENODEV; dev = &pdev->dev; pru0 = pru_rproc_get(node, PRUSS_PRU0); if (IS_ERR(pru0)) { ret = PTR_ERR(pru0); if (ret != -EPROBE_DEFER) dev_err(dev, "Unable to get PRU0.\n"); dev_err(dev, "rproc_get_pru0_fail\n"); goto fail; } dev_info(dev, "Got PRU0\n"); pruss = pruss_get(pru0); if (IS_ERR(pruss)) { ret = PTR_ERR(pruss); if (ret != -EPROBE_DEFER) dev_err(dev, "Unable to get pruss handle.\n"); dev_err(dev, "pruss_get failed\n"); goto fail; } dev_info(dev, "Got PRU0 handler\n"); pru1 = pru_rproc_get(node, PRUSS_PRU1); if (IS_ERR(pru1)) { ret = PTR_ERR(pru1); if (ret != -EPROBE_DEFER) dev_err(dev, "Unable to get PRU1.\n"); dev_err(dev, "rproc_get_pru1_fail\n"); goto fail; } dev_info(dev, "Got PRU1\n"); fail: dev_err(dev, "Failed to load driver\n"); return -1; } /* Remove function */ static int my_pru_driver_remove(struct platform_device *pdev) { dev_info(&pdev->dev, "PRU0 remoteproc handle released\n"); return 0; } static const struct of_device_id my_pru_of_match[] = { { .compatible = "daq,daq", }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, my_pru_of_match); static struct platform_driver my_pru_driver = { .driver = { .name = "my_pru_driver", .of_match_table = my_pru_of_match, }, .probe = my_pru_driver_probe, .remove = my_pru_driver_remove, }; module_platform_driver(my_pru_driver); MODULE_AUTHOR("Your Name"); MODULE_DESCRIPTION("My PRU Driver"); MODULE_LICENSE("GPL");