手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

基于S3C2440的嵌入式Linux驱动——SPI子系统解读(二)

[日期:2012-08-16] 来源:Linux社区  作者:yj4231 [字体:大 中 小]

至此,在probe函数中, 由spi_bitbang_start调用所引起的一系列函数调用都已讲解完毕。下面总结下整个调用过程:

可以看到,调用spi_bitbang_start以后,spi_master和spi_device都将被注册到内核中。

下面来看下platform driver的其他几个方法。

4.2.3 remove,suspend以及resume方法

  1. static int __exit s3c24xx_spi_remove(struct platform_device *dev)  
  2. {  
  3.     struct s3c24xx_spi *hw = platform_get_drvdata(dev);  
  4.   
  5.     platform_set_drvdata(dev, NULL);  
  6.   
  7.     spi_unregister_master(hw->master);   /*注销spi主控制器*/  
  8.   
  9.     clk_disable(hw->clk);            /*禁止时钟*/  
  10.     clk_put(hw->clk);            /*释放CLK*/  
  11.   
  12.     free_irq(hw->irq, hw);           /*注销IRQ*/  
  13.     iounmap(hw->regs);           /*解除映射*/  
  14.   
  15.     if (hw->set_cs == s3c24xx_spi_gpiocs)  
  16.         gpio_free(hw->pdata->pin_cs); /*释放用于cs的gpio*/  
  17.   
  18.     release_resource(hw->ioarea);  
  19.     kfree(hw->ioarea);                     
  20.   
  21.     spi_master_put(hw->master);      /*减少master引用计数*/  
  22.     return 0;  
  23. }  
  24.   
  25.   
  26. #ifdef CONFIG_PM    /*如果定义了电源管理*/   
  27.   
  28. static int s3c24xx_spi_suspend(struct platform_device *pdev, pm_message_t msg)  
  29. {  
  30.     struct s3c24xx_spi *hw = platform_get_drvdata(pdev);  
  31.   
  32.     if (hw->pdata && hw->pdata->gpio_setup)  
  33.         hw->pdata->gpio_setup(hw->pdata, 0);  
  34.   
  35.     clk_disable(hw->clk);  
  36.     return 0;  
  37. }  
  38.   
  39. static int s3c24xx_spi_resume(struct platform_device *pdev)  
  40. {  
  41.     struct s3c24xx_spi *hw = platform_get_drvdata(pdev);  
  42.   
  43.     s3c24xx_spi_initialsetup(hw);  
  44.     return 0;  
  45. }  
  46.   
  47. #else   
  48. #define s3c24xx_spi_suspend NULL   
  49. #define s3c24xx_spi_resume  NULL   
  50. #endif  

至此,master 驱动的大体结构都已分析完毕,随后第三篇文章将介绍spi设备驱动。

linux
相关资讯       嵌入式Linux  S3C2440 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款