platform模型驱动中断和内存资源使用步骤

IO 内存资源使用步骤

/* io memory */
 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 if (!res) {
  dev_err(&pdev->dev, "failed to get io memory region\n");
  ret = -EINVAL;
  goto err_clk_disable;
 }

 /* request mem region */
 res = request_mem_region(res->start,res->end - res->start + 1, pdev->name);
 if (!res) {
  dev_err(&pdev->dev, "failed to request io memory region\n");
  ret = -EINVAL;
  goto err_clk_disable;
 }

 /* ioremap for register block */
 dsim.reg_base = (unsigned int) ioremap(res->start,res->end - res->start + 1);
 if (!dsim.reg_base) {
  dev_err(&pdev->dev, "failed to remap io region\n");
  ret = -EINVAL;
  goto err_clk_disable;

 

中断资源使用步骤

res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 if (!res) {
  dev_err(&pdev->dev, "failed to request dsim irq resource\n");
  ret = -EINVAL;
  goto err_clk_disable;
 }
 /* dsim.irq = res->start; */

 /* clear interrupt */
 /* int_stat = readl(dsim.reg_base + S5P_DSIM_INTSRC); */
 int_stat = 0xffffffff;
 writel(int_stat, dsim.reg_base + S5P_DSIM_INTSRC);

 /* enable interrupts */
 int_stat = readl(dsim.reg_base + S5P_DSIM_INTMSK);

 int_stat &= ~((0x01<<S5P_DSIM_INT_BTA) | (0x01<<S5P_DSIM_INT_RX_TIMEOUT) |
  (0x01<<S5P_DSIM_INT_BTA_TIMEOUT) | (0x01 << S5P_DSIM_INT_RX_DONE) |
  (0x01<<S5P_DSIM_INT_RX_TE) | (0x01<<S5P_DSIM_INT_RX_ACK) |
  (0x01<<S5P_DSIM_INT_RX_ECC_ERR) | (0x01<<S5P_DSIM_IMT_RX_CRC_ERR) |
  (0x01<<S5P_DSIM_INT_SFR_FIFO_EMPTY));

 writel(int_stat, dsim.reg_base + S5P_DSIM_INTMSK);
 ret = request_irq(res->start, (void *)s5p_dsim_isr, IRQF_DISABLED, pdev->name, &dsim);
 if (ret != 0) {
  dev_err(&pdev->dev, "failed to request dsim irq\n");
  ret = -EINVAL;
  goto err_clk_disable;
 }

 

 

你可能感兴趣的:(platform模型驱动中断和内存资源使用步骤)