Я пишу фиктивный драйвер PHY как LKM. Это драйвер платформы, и я не могу вызвать тест драйвера, поскольку это зависит от совместимой строки. Как я могу заставить мой драйвер вызывать датчик на моей машине, на которой работает Ubuntu 18.04, версия ядра - 5.3.0-40-generi c. Моя машина X86. Я устанавливаю этот phy драйвер на мой компьютер с архитектурой X86.
Вот мой код:
static int phy_platform_probe(struct platform_device *pdev) {
struct custom_port_phy_platform_local *lp;
int ret;
printk(KERN_ALERT "abc..phy_platform_probe..Invoked\r\n");
lp = devm_kzalloc(&pdev->dev,sizeof(struct custom_port_phy_platform_local),GFP_KERNEL);
if (!lp) {
dev_err(&(pdev->dev),"Failed to allocatate platform_local\n");
return -ENOMEM;
}
platform_set_drvdata(pdev, lp);
lp->dev = &pdev->dev;
ret = custom_port_phy_mdio_setup(lp, pdev->dev.of_node);
if (ret < 0) {
dev_err(&(pdev->dev),"Failed to setup MDIO bus\n");
return ret;
}
return 0;
}
static int phy_platform_remove(struct platform_device *pdev) {
struct custom_port_phy_platform_local *lp = platform_get_drvdata(pdev);
dev_info(&pdev->dev,"%s Enter\n",__func__);
custom_port_phy_mdio_teardown(lp);
return 0;
}
static struct phy_driver custom_phy_driver = {
.phy_id = 0x00000002,
.phy_id_mask = 0xffffffff,
.name = "custom_port_phy",
};
static struct platform_driver custom_phy_platform_driver = {
.probe = phy_platform_probe,
.remove = phy_platform_remove,
#if 1
.driver = {
.name = "custom_port_phy"
.of_match_table = port_phy_of_match,
}
#endif
};
#if 1
/* Match table for of_platform binding */
static struct of_device_id port_phy_of_match[] = {
{ .compatible = "custom,custom-port-phy", },
{},
};
#endif
static int __init phy_init(void)
{
int ret = 0;
printk(KERN_ALERT "abc >>> phy_driver_register started\r\n");
ret = phy_driver_register(&custom_phy_driver, THIS_MODULE);
printk(KERN_ALERT "abc >>> phy_driver_register END\r\n");
if(ret < 0) {
printk(KERN_ALERT "custom phy driver registration failed\r\n");
return ret;
}
ret = platform_driver_register(&custom_phy_platform_driver);
if(ret < 0) {
phy_driver_unregister(&custom_phy_driver);
printk("%s: Failed to register as Platform Driver\r\n", __func__);
return ret;
}
return ret;
}
static void __exit phy_exit(void)
{
pr_info("Goodbye phy_driver .\n");
phy_driver_unregister(&custom_phy_driver);
platform_driver_unregister(&custom_phy_platform_driver);
}
module_init(phy_init);
module_exit(phy_exit);
MODULE_LICENSE("GPL");
Мой код не выполняет проверку, поскольку не может найти совместимый флаг.
Как я могу заставить его работать на моей машине? Я знаю, мне нужен файл DTB. Даже если у меня есть файл dtb, как мне его предоставить и как так написать?