使用设备树给dm9000网卡、触摸屏指定中断

  1. 给dm9000网卡指定中断
/*bank4*/
srom-cs4@20000000 {
		compatible = "simple-bus";
		#address-cells = <1>;
		#size-cells = <1>;
		reg = <0x20000000 0x8000000>;//起始地址  128M
		ranges;

		ethernet@20000000 {
			compatible = "davicom,dm9000";
			reg = <0x20000000 0x2 0x20000004 0x2>;
			interrupt-parent = <&gpf>;
			interrupts = <7 IRQ_TYPE_EDGE_RISING>;
			local-mac-address = [00 00 de ad be ef];
			davicom,no-eeprom;
		};
	};

仿照设备树–按键中断程序,在原驱动程序中添加

#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_platform.h>



static int dm9000drv_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;		
	struct device_node *dp_node = dev->of_node;
	struct resource		*res;
	int i;

	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
	if (res) {
		irq = res->start;//获得中断号
		printk("get dm9000 irq %d\n", irq);
	}
	else {
		printk("can not get irq res for dm9000\n");
		return -1;
	}
	return dm9000c_init();//调用原驱动程序的初始化函数
}

static int dm9000drv_remove(struct platform_device *pdev)
{
	dm9000c_exit();//调用原驱动程序的退出函数
	return 0;
}

static const struct of_device_id of_match_dm9000[] = {
	{ .compatible = "davicom,dm9000", .data = NULL },
	{ /* sentinel */ }
};

struct platform_driver dm9000_drv = {
	.probe		= dm9000drv_probe,
	.remove		= dm9000drv_remove,
	.driver		= {
		.name	= "dm9000",
		.of_match_table = of_match_dm9000, /* 能支持哪些来自于dts的platform_device */
	}
};

static int dm9000drv_init(void)
{
	platform_driver_register(&dm9000_drv);
	return 0;
}

static void dm9000drv_exit(void)
{
	platform_driver_unregister(&dm9000_drv);
}
module_init(dm9000drv_init);
module_exit(dm9000drv_exit);

2.给触摸屏指定中断

jz2440ts@5800000 {
		compatible = "jz2440,ts";
		reg = <0x58000000 0x100>;
		reg-names = "adc_ts_physical";
		interrupts = <1 31 9 3>, <1 31 10 3>;
		interrupt-names = "int_ts", "int_adc_s";
		clocks = <&clocks PCLK_ADC>;
		clock-names = "adc";
	};

interrupts = <1 31 9 3>, <1 31 10 3>;
子中断控制器-1
上一级中断控制器-31
中断控制器-9
触发类型-3

s3c_ts.c

static int s3cts_drv_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;		
	struct device_node *dp_node = dev->of_node;
	struct resource		*res;
	int i;

	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
	if (res) {
		irq_tc = res->start;//9
		printk("get touchscreen's tc irq %d\n", irq_tc);
	}
	else {
		printk("can not get irq res for touchscreen's tc\n");
		return -1;
	}

	res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
	if (res) {
		irq_adc = res->start;//10
		printk("get touchscreen's adc irq %d\n", irq_adc);
	}
	else {
		printk("can not get irq res for touchscreen's adc\n");
		return -1;
	}
	return s3c_ts_init();
}

static int s3cts_drv_remove(struct platform_device *pdev)
{
	s3c_ts_exit();
	return 0;
}

static const struct of_device_id of_match_s3cts[] = {
	{ .compatible = "jz2440,ts", .data = NULL },
	{ /* sentinel */ }
};

struct platform_driver s3cts_drv = {
	.probe		= s3cts_drv_probe,
	.remove		= s3cts_drv_remove,
	.driver		= {
		.name	= "s3c_ts",
		.of_match_table = of_match_s3cts, /* 能支持哪些来自于dts的platform_device */
	}
};


static int s3cts_drv_init(void)
{
	platform_driver_register(&s3cts_drv);
	return 0;
}

static void s3cts_drv_exit(void)
{
	platform_driver_unregister(&s3cts_drv);
}
module_init(s3cts_drv_init);
module_exit(s3cts_drv_exit);

s3c2440中断控制器
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值