我正在尝试使用Linux中的新串行设备总线(使用内核4.11rc6)编写一个带有GPIO驱动程序的MFD驱动程序。
我在qemu下运行arm设备,并修改了arch/arm/boot/dts/versatile-ab.dts
,使uart2读取:
uart2: uart@101f3000 {
compatible = "arm,pl011", "arm,primecell";
reg = <0x101f3000 0x1000>;
interrupts = <14>;
clocks = <&xtal24mhz>, <&pclk>;
clock-names = "uartclk", "apb_pclk";
fcd16999 {
compatible = "ev,fcd16999";
fcd16999gpio: fcd16999-gpio {
compatible = "ev,fcd16999-gpio";
};
};
};
/proc/device-tree/amba/uart@101f3000/fcd16999/compatible
读取ev,fcd16999
,子节点fcd16999-gpio/compatible
为ev,fcd16999-gpio
。仍然会调用两个设备的init函数,但不会调用它们的探测函数。我是不是遗漏了一些显而易见的东西?兼容标志匹配,设备树被加载,所以它应该正常工作,对吧?
文件如下。
驱动程序/mfd/fcd16999.c
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/mfd/core.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/serdev.h>
#include <linux/slab.h>
/*#include <linux/mfd/tps6507x.h>*/
static const struct mfd_cell fcd16999_devs[] = {
{
.name = "fcd16999-gpio",
.of_compatible = "ev,fcd16999-gpio",
},
/*
{
.name = "fcd16999-adc",
},
{
.name = "fcd16999-thermometer",
},
*/
};
static int fcd16999_serdev_probe(struct serdev_device *serdev)
{
dev_warn(&serdev->dev, "fcd16999_serdev_probe\n");
return devm_mfd_add_devices(&serdev->dev, 1, fcd16999_devs,
ARRAY_SIZE(fcd16999_devs), NULL, 0, NULL);
}
void fcd16999_serdev_remove(struct serdev_device *serdev)
{
dev_warn(&serdev->dev, "fcd16999_serdev_remove\n");
}
static const struct of_device_id fcd16999_of_match[] = {
{.compatible = "ev,fcd16999", },
{},
};
MODULE_DEVICE_TABLE(of, fcd16999_of_match);
static struct serdev_device_driver fcd16999_driver = {
.driver = {
.name = "fcd16999",
.of_match_table = of_match_ptr(fcd16999_of_match),
},
.probe = fcd16999_serdev_probe,
.remove = fcd16999_serdev_remove,
};
static int __init fcd16999_serdev_init(void)
{
int ret = 101;
printk("Hello from fcd16999!\n");
ret = serdev_device_driver_register(&fcd16999_driver);
printk("serdev_device_driver_register returned %d\n", ret);
return ret;
}
/* init early so consumer devices can complete system boot */
subsys_initcall(fcd16999_serdev_init);
static void __exit fcd16999_serdev_exit(void)
{
printk("Goodbye from fcd16999!\n");
serdev_device_driver_unregister(&fcd16999_driver);
}
module_exit(fcd16999_serdev_exit);
驱动程序/gpio/gpio-fcd16999.c
#include <linux/bitops.h>
#include <linux/gpio.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
/* #include <linux/mfd/stmpe.h> */
static int fcd16999_gpio_probe(struct platform_device *pdev)
{
printk("Hellow, fcd16999\n");
dev_warn(&pdev->dev, "fcd16999_gpio probing...\n");
return 0;
}
static struct platform_driver fcd16999_gpio_driver = {
.driver = {
.suppress_bind_attrs = true,
.name = "fcd16999-gpio",
},
.probe = fcd16999_gpio_probe,
};
static int __init fcd16999_gpio_init(void)
{
printk("Init Hellow, gpio-fcd16999\n");
return platform_driver_register(&fcd16999_gpio_driver);
}
subsys_initcall(fcd16999_gpio_init);
static void __exit fcd16999_gpio_exit(void)
{
printk("Goodbye from gpio-fcd16999!\n");
platform_driver_unregister(&fcd16999_gpio_driver);
}
module_exit(fcd16999_gpio_exit);
最佳答案
结果是,我需要在内核中启用SERIAL DEV to CTRL TTYPORT选项才能让它进行探测。
关于linux - 未探究Linux serdev mfd驱动程序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44994111/