How to write Platform Devices and Drivers with FPGA via GPMC

5,385 views
5,208 views

Published on

How to write Platform Devices and Drivers with FPGA via GPMC

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,385
On SlideShare
0
From Embeds
0
Number of Embeds
1,512
Actions
Shares
0
Downloads
43
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

How to write Platform Devices and Drivers with FPGA via GPMC

  1. 1. How to write Platform Devices and Drivers with FPGA via GPMC Bo-Yi Wu 2011.06.15 http://blog.wu-boy.com
  2. 2. What’s GPMC <ul><li>全名 General-Purpose Memory Controller </li></ul><ul><li>the device unified memory controller (UMC) dedicated to interfacing external memory devices. </li></ul><ul><ul><li>NAND Flash </li></ul></ul><ul><ul><li>NOR Flash </li></ul></ul><ul><ul><li>FPGA (*) </li></ul></ul><ul><li>如果要更深入研究,請參考 TI 線上 Documentation </li></ul>
  3. 3. 寫 GPMC Drive 跟 FPGA 溝通前
  4. 4. 必須先瞭解什麼是 Platform Devices 和 Platform Drivers
  5. 5. 撰寫 Driver Model 事先預備 Porting Drivers to New Driver Model <ul><li>Driver Binding </li></ul><ul><li>Bus Types </li></ul><ul><li>Device Classes </li></ul><ul><li>Basic Device Structure </li></ul><ul><li>Managed Device Resource </li></ul><ul><li>Device Drivers </li></ul><ul><li>Device Interfaces </li></ul><ul><li>Platform Devices and Drivers </li></ul>
  6. 6. Platform 架構 <ul><li>參考 <linux/platform_device.h> 來瞭解 driver model 如何跟 platform bus 溝通 </li></ul><ul><li>用在 system-on-chip processors 或者是一些 &quot;legacy&quot; PC interconnects </li></ul>
  7. 7. Platform devices <ul><li>請指定一個名稱用來 Driver Binding ,以及定義該 Devices 需要用到的 addresses 和 IRQs. </li></ul>struct platform_device { const char *name; u32 id; struct device dev; u32 num_resources; struct resource *resource; };
  8. 8. Platform drivers <ul><li>Platform drivers 走 Driver Model 標準規範,提供 probe 及 remove method ,它們提供 power 管理及關閉提醒等標準 </li></ul>
  9. 9. struct platform_driver { int (*probe)(struct platform_device *); int (*remove)(struct platform_device *); void (*shutdown)(struct platform_device *); int (*suspend)(struct platform_device *, pm_message_t state); int (*suspend_late)(struct platform_device *, pm_message_t state); int (*resume_early)(struct platform_device *); int (*resume)(struct platform_device *); struct device_driver driver; };
  10. 10. <ul><li>Probe 用來偵測特定 Hardware 是否存在,及使用該裝置資源 (clocks 和 device platform_data) </li></ul><ul><li>透過底下函式來註冊 Driver </li></ul><ul><ul><li>int platform_driver_register(struct platform_driver *drv); </li></ul></ul><ul><li>過去 Legacy Driver 並不會完全遵守標準 driver model ,這些 driver 會去註冊自己的 platform device ,而不是讓系統來完成註冊 </li></ul>
  11. 11. 裝置初始化 <ul><li>在大多數的 Platform 設備都必須先註冊 Platform Device </li></ul><ul><ul><li>定義 platform_data, resource, 共有多少個 resource 等等 </li></ul></ul><ul><ul><li>platform_device_register </li></ul></ul><ul><ul><li>platform_add_devices </li></ul></ul>
  12. 12. Device Naming 和 Driver Binding <ul><li>platform_device.dev.bus_id 是一個 device id 分為兩個 component: </li></ul><ul><ul><li>platform_device.name 用來跟 Driver match </li></ul></ul><ul><ul><li>platform_device.id 裝置編號順序 ( 例如假設有支援多個 NAND 或 NOR Flash) ,如果設定為 -1 表示為獨一無二的裝置 </li></ul></ul>
  13. 13. Driver binding <ul><li>在 Driver Core 裡面透過 probe 自動匹對 </li></ul><ul><ul><li>利用 Device Name and ID 去 match </li></ul></ul><ul><ul><ul><li>name/id: gpmc_bus.1 或 gpmc_bus </li></ul></ul></ul>
  14. 14. board-omap3evm GPMC Device Init Match Driver name GPMC Driver Init GPMC Address IRQ GPMC Clock and Chip Select Define
  15. 15. GPMC support functions <ul><li>gpmc_cs_read_reg </li></ul><ul><li>gpmc_cs_write_reg </li></ul><ul><li>Please referrer arch/arm/mach-omap2/gpmc.c </li></ul>
  16. 16. GPMC Address Mapping
  17. 17. <ul><li>Supported Devices </li></ul><ul><ul><li>.GPMC_CONFIG1_i[11:10] </li></ul></ul><ul><li>Access Size Adaptation and Device Width </li></ul><ul><ul><li>.GPMC_CONFIG1_i[13:12] </li></ul></ul>
  18. 18. Timing Setting
  19. 19. 上面兩張設定如果設定正確,就可以正確看到波形,如果設定錯誤,請準備接收 Kernel Panic
  20. 20. 結論 <ul><li>Platform Device 和 Platform Driver 區別? </li></ul><ul><li>GPMC Config_[1-7] 設定方式及規範 </li></ul><ul><li>實際參考 NAND Driver 程式 </li></ul>

×