搜索
您的当前位置:首页linux init时初始化中断号

linux init时初始化中断号

来源:乌哈旅游
[    6.535890]<3>[I](3)OF: of_irq_parse_one: dev=/soc/xxx@12300000, index=0
[    6.536771]<3>[W](3)CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.9.118+ #356
[    6.537638]<3>[W](3)Hardware name: ATC Inc. AC8x (DT)
[    6.538266]<3>[W](3)Call trace:
[    6.538658]<3>[W](3)[<ffffff800808bb7c>] dump_backtrace+0x0/0x2c0
[    6.539420]<3>[W](3)[<ffffff800808c36c>] show_stack+0x14/0x1c
[    6.540137]<3>[W](3)[<ffffff80083d6bf8>] dump_stack+0x94/0xb4
[    6.540855]<3>[W](3)[<ffffff80087c3c08>] of_irq_parse_one+0x54/0x174
[    6.541648]<3>[W](3)[<ffffff80087c40d8>] of_irq_count+0x3c/0x68
[    6.542387]<3>[W](3)[<ffffff80087c09fc>] of_device_alloc+0x74/0x198
[    6.543170]<3>[W](3)[<ffffff80087c0b74>] of_platform_device_create_pdata+0x54/0xe8
[    6.544115]<3>[W](3)[<ffffff80087c0ce8>] of_platform_bus_create.part.4+0xc4/0x33c
[    6.545050]<3>[W](3)[<ffffff80087c0e98>] of_platform_bus_create.part.4+0x274/0x33c
[    6.545995]<3>[W](3)[<ffffff80087c10ec>] of_platform_populate+0x94/0xec
[    6.546822]<3>[W](3)[<ffffff8008e8bb54>] of_platform_default_populate_init+0x68/0x74
[    6.547789]<3>[W](3)[<ffffff80080837e0>] do_one_initcall+0x58/0x170
[    6.548572]<3>[W](3)[<ffffff8008e50e70>] kernel_init_freeable+0x1a0/0x25c
[    6.549419]<3>[W](3)[<ffffff8008aa2230>] kernel_init+0x10/0x104
[    6.550158]<3>[W](3)[<ffffff8008083570>] ret_from_fork+0x10/0x20

of_irq_to_resource 将中断资源打包到resource

[    6.776374]<3>[I](3)OF: of_irq_parse_one: dev=/soc/xxx@12300000, index=0
[    6.777254]<3>[W](3)CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.9.118+ #356
[    6.778121]<3>[W](3)Hardware name: ATC Inc. AC8x (DT)
[    6.778749]<3>[W](3)Call trace:
[    6.779142]<3>[W](3)[<ffffff800808bb7c>] dump_backtrace+0x0/0x2c0
[    6.779902]<3>[W](3)[<ffffff800808c36c>] show_stack+0x14/0x1c
[    6.780619]<3>[W](3)[<ffffff80083d6bf8>] dump_stack+0x94/0xb4
[    6.781337]<3>[W](3)[<ffffff80087c3c08>] of_irq_parse_one+0x54/0x174
[    6.782130]<3>[W](3)[<ffffff80087c3f6c>] of_irq_to_resource+0x38/0x104
[    6.782945]<3>[W](3)[<ffffff80087c4084>] of_irq_to_resource_table+0x4c/0x64
[    6.783814]<3>[W](3)[<ffffff80087c0a90>] of_device_alloc+0x108/0x198
[    6.784607]<3>[W](3)[<ffffff80087c0b74>] of_platform_device_create_pdata+0x54/0xe8
[    6.785552]<3>[W](3)[<ffffff80087c0ce8>] of_platform_bus_create.part.4+0xc4/0x33c
[    6.786487]<3>[W](3)[<ffffff80087c0e98>] of_platform_bus_create.part.4+0x274/0x33c
[    6.787432]<3>[W](3)[<ffffff80087c10ec>] of_platform_populate+0x94/0xec
[    6.788258]<3>[W](3)[<ffffff8008e8bb54>] of_platform_default_populate_init+0x68/0x74
[    6.789226]<3>[W](3)[<ffffff80080837e0>] do_one_initcall+0x58/0x170
[    6.790008]<3>[W](3)[<ffffff8008e50e70>] kernel_init_freeable+0x1a0/0x25c
[    6.790855]<3>[W](3)[<ffffff8008aa2230>] kernel_init+0x10/0x104
[    6.791593]<3>[W](3)[<ffffff8008083570>] ret_from_fork+0x10/0x20

获取中断号就可以通过如下方式获取

platform_get_resource(pdev,IORESOURCE_IRQ,idx);

platform_get_irq 也是通过platform_get_resource来实现的

/**
 * platform_get_irq - get an IRQ for a device
 * @dev: platform device
 * @num: IRQ number index
 *
 * Gets an IRQ for a platform device and prints an error message if finding the
 * IRQ fails. Device drivers should check the return value for errors so as to
 * not pass a negative integer value to the request_irq() APIs.
 *
 * For example::
 *
 *		int irq = platform_get_irq(pdev, 0);
 *		if (irq < 0)
 *			return irq;
 *
 * Return: non-zero IRQ number on success, negative error number on failure.
 */
int platform_get_irq(struct platform_device *dev, unsigned int num)
{
	int ret;

	ret = platform_get_irq_optional(dev, num);
	if (ret < 0 && ret != -EPROBE_DEFER)
		dev_err(&dev->dev, "IRQ index %u not found\n", num);

	return ret;
}
EXPORT_SYMBOL_GPL(platform_get_irq);

因篇幅问题不能全部显示,请点此查看更多更全内容

Top