这个芯片名字是叫TPS65930,但是驱动的名字却是TWL4030,估计是同一个芯片,前后代的关系吧。
这是一个MFD芯片,multi-function device(多功能设备),集合了ldo,audio,gpio,usb phy, clock, vibrator, adc,thermal detect 等功能于一体的芯片。
这是一个MFD芯片,multi-function device(多功能设备),集合了ldo,audio,gpio,usb phy, clock, vibrator, adc,thermal detect 等功能于一体的芯片。
下面是一个twl4030 usb部分的驱动分析。
1.init()/exit()
static int __init twl4030_usb_init(void)
{
return platform_driver_register(&twl4030_usb_driver);
}
subsys_initcall(twl4030_usb_init); //这里用了subsys_initcall().
static void __exit twl4030_usb_exit(void)
{
platform_driver_unregister(&twl4030_usb_driver);
}
module_exit(twl4030_usb_exit);
struct twl4030_usb_driver :
static struct platform_driver twl4030_usb_driver = {
.probe = twl4030_usb_probe,
.remove = __exit_p(twl4030_usb_remove),
.driver = {
.name = "twl4030_usb", //驱动名
.owner = THIS_MODULE,
},
};
2. twl4030_usb_probe():
static int __devinit twl4030_usb_probe(struct platform_device *pdev)
{
struct twl4030_usb_data *pdata = pdev->dev.platform_data; //这个platform_data 来自board-omap3evm.c
struct twl4030_usb *twl;
int status, err;
if (!pdata) {
dev_dbg(&pdev->dev, "platform_data not available\n");
return -EINVAL;
}
twl = kzalloc(sizeof *twl, GFP_KERNEL);
if (!twl)
return -ENOMEM;
twl->dev = &pdev->dev;
twl->irq = platform_get_irq(pdev, 0); //获取中断
twl->otg.dev = twl->dev;
twl->otg.label = "twl4030";
twl->otg.set_host = twl4030_set_host;
twl->otg.set_peripheral = twl4030_set_peripheral;
twl->otg.set_suspend