2017-07-09 37 views
0

我试图在Linux中使用新的串行设备总线(使用内核4.11rc6)编写带有伴随GPIO驱动程序的MFD驱动程序。未探测到Linux serdev mfd驱动程序

我的qemu下为ARM设备上运行,我已经修改arch/arm/boot/dts/versatile-ab.dts使UART2写着:

uart2: [email protected] { 
    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/[email protected]/fcd16999/compatible读取ev,fcd16999和子节点fcd16999-gpio/compatibleev,fcd16999-gpio

仍然调用这两个设备的初始化函数,但不调用它们的探测函数。我在这里错过了很明显的东西吗兼容的标志匹配和设备树被加载,所以它应该只是工作,对不对?

下面的文件。

驱动器/ 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); 
+0

您错过了显示UART驱动程序(探头和初始部件)。最好在Github上或类似的地方使用回购,并分享链接。 – 0andriy

+0

我从来没有想过这件事,但我没有触及那部分。我认为这应该是好的,因为它是默认的qemu arm driver。 – evading

回答

0

事实证明,我需要在内核中启用了SERIAL_DEV_CTRL_TTYPORT选项来获得它来探测。