简介:RK3399平台开发系列讲解(内核入门篇)1.51、platform_get_resource 函数实现细节 设备树中的节点被转换为platform_device后,设备树中的reg属性、interrupts属性也会被转换为“resource”。这时,你可以使用这个函数取出这些资源。 platform_get_resource函数源码如下: 新内核实现 目录:v4.19/drivers/base/platform.c /*...
resource_size_t start; //资源的起始物理地址 resource_size_t end; //资源的结束物理地址 const char *name; //资源的名称 unsigned long flags; //资源的类型,比如MEM,IO,IRQ类型 struct resource *parent, *sibling, *child; //资源链表指针 } 举几个例子 static struct resource snirm_53c710_rsrc[]...
1) alloc platform_device *dev 2) 如果有reg和interrupts的相关属性, 运行of_address_to_resource 和 of_irq_to_resource_table, 加入到dev->resource dev->num_resources = num_reg + num_irq; dev->resource = res; for (i = 0; i < num_reg; i++, res++) { rc = of_address_to_resource(...
int of_address_to_resource(struct device_node *dev, int index, struct resource *r) { const __be32 *addrp; u64 size; unsigned int flags; const char *name = NULL; addrp = of_get_address(dev, index, &size, &flags); if (addrp == NULL) return -EINVAL; /* Get optional "reg-n...
.num_resources = ARRAY_SIZE(s3c_lcd_resource), .resource = s3c_lcd_resource, .dev = { //device实例 .dma_mask = &s3c_device_lcd_dmamask, .coherent_dma_mask = 0xffffffffUL } }; s3c_device_lcd的resource中硬件地址: #define S3C2410_LCDREG(x) ((x) + S3C2410_VA_LCD) ...
res = platform_get_resource(pdev, IORESOURCE_MEM,0); i2c->base = devm_ioremap_resource(&pdev->dev, res);if(IS_ERR(i2c->base))returnPTR_ERR(i2c->base); irq =platform_get_irq(pdev,0);if(irq <0)returnirq; pdata = dev_get_platdata(&pdev->dev);/* hook up driver to tree *...
reg_value&= ~((1<<3) | (1<<4) | (1<<5)); writel(reg_value,&(pGPIOREG->gpj0dat)); } }staticintled_probe(structplatform_device *pdev) {structresource *res_led =NULL;intret = -1;intreg_value =0;/***申请资源***///获取资源res_led = platform_get_resource(pdev, IORESOURCE...
uart0:serial@44e09000{compatible="ti,omap3-uart";ti,hwmods="uart1";clock-frequency=<48000000>;reg=<0x44e090000x2000>;interrupts=<72>;status="disabled";}; platform_driver实例 以samsung.c 串口驱动程序为例: /*兼容匹配表*/staticconststructplatform_device_ids3c24xx_serial_driver_ids[]={{....
reg = <0x50006000 0x4>; //获取地址信息 interrupt-parent = <&gpiof>; interrupts = <9 0>; //获取软中断号71 led = <&gpiof 10 0>; //获取节点信息 }; */ int pdrv_probe(struct platform_device *pdev) { struct resource* res; ...
在上述示例中,该设备节点具有compatible属性来标识设备的兼容性,reg属性用于指定设备的地址范围,interrupt-parent属性指定中断控制器的父节点,interrupts属性指定设备的中断号和触发类型。 在驱动程序中定义platform_driver结构体,并使用of_match_ptr()宏将设备的兼容性标识与驱动程序关联起来。例如: ...