1. 程式人生 > >Itop4412開發板emmc驅動移植(裝置樹)

Itop4412開發板emmc驅動移植(裝置樹)

硬體裝置:itop4412開發板 核心版本linux-3.8.1

裝置樹方式減少了裝置的冗餘編碼,同時使移植變得更加高效。eMMC作為開發板的基礎,十分重要。

裝置樹用的是核心自帶的smdk4412.dts

vim arch/arm/boot/dts/exynos4412-smdk4412.dts

在裝置樹中新增如下程式碼:

 87                 ldo22_reg: LDO22 {
 88                                 regulator-name = "VMEM_VDD_2.8V";
 89                                 regulator-min-microvolt = <2800000>;
 90                                 regulator-max-microvolt = <2800000>;
 91                                 maxim,ena-gpios = <&gpk0 2 1>;
 92                         };
146         [email protected] {
147         compatible = "samsung,exynos4412-dw-mshc";
148                 reg = <0x12550000 0x1000>;
149                 interrupts = <0 77 0>;
150                 #address-cells = <1>;
151                 #size-cells = <0>;
152                 fifo-depth = <0x80>;
153                 clocks = <&clock 301>, <&clock 149>;
154                 clock-names = "biu", "ciu";
155                 num-slots = <1>;
156                 broken-cd;
157                 non-removable;
158                 card-detect-delay = <200>;
159                 vmmc-supply = <&ldo22_reg>;
160                 clock-frequency = <400000000>;
161                 samsung,dw-mshc-ciu-div = <0>;
162                 samsung,dw-mshc-sdr-timing = <2 3>;
163                 samsung,dw-mshc-ddr-timing = <1 2>;
164                 pinctrl-0 = <&sd4_clk &sd4_cmd &sd4_bus4 &sd4_bus8>;
165                 pinctrl-names = "default";
166                 status = "okay";
167                 bus-width = <8>;
168                 cap-mmc-highspeed;
169         };

在驅動中增加裝置屬性匹配:

vim drivers/mmc/host/dw_mmc-exynos.c

221 static const struct of_device_id dw_mci_exynos_match[] = {
222         { .compatible = "samsung,exynos4412-dw-mshc",},
223         { .compatible = "samsung,exynos5250-dw-mshc",
224                         .data = &exynos5250_drv_data, },
225         {},
226 }; 

make menuconfig 配置emmc核心驅動


編譯燒寫進開發板後啟動會出現錯誤:

mmc1: unrecognised EXT_CSD revision 7 

解決方法:將296行的6改為7

vim drivers/mmc/core/mmc.c

 295 /* amended by cqx:6->7  */
 296                 if (card->ext_csd.rev > 7) {
 297                 pr_err("%s: unrecognised EXT_CSD revision %d\n",
 298                         mmc_hostname(card->host), card->ext_csd.rev);
 299                 err = -EINVAL;
 300                 goto out;
 301         }

重新編譯後燒寫入開發板,啟動列印如下資訊說明emmc驅動移植成功。

mmcblk0: mmc1:0001 4YMD3R 3.64 GiB                                              

mmcblk0boot0: mmc1:0001 4YMD3R partition 1 4.00 MiB                             
mmcblk0boot1: mmc1:0001 4YMD3R partition 2 4.00 MiB                             
 mmcblk0: p1 p2 p3 p4                                                           
 mmcblk0boot1: unknown partition table                                          
 mmcblk0boot0: unknown partition table                                          
mmc0: mmc_rescan_try_freq: trying to init card at 1562500 Hz                    
mmc0: new high speed SD card at address 0260 

使用fdisk -l命令檢視詳細資訊                                                                                                                                  
Disk /dev/mmcblk0: 3909 MB, 3909091328 bytes                                    
226 heads, 33 sectors/track, 1023 cylinders                                     
Units = cylinders of 7458 * 512 = 3818496 bytes                                 
                                                                                
Device Boot      Start         End      Blocks  Id System               
/dev/mmcblk0p1             653        1020     1372272   c Win95 FAT32 (LBA)    
/dev/mmcblk0p2               6         287     1051578  83 Linux                
/dev/mmcblk0p3             288         569     1051578  83 Linux                
/dev/mmcblk0p4             570         652      309507  83 Linux                
                                                                                
Partition table entries are not in disk order                                   
                                                                                
Disk /dev/mmcblk0boot1: 4 MB, 4194304 bytes                                     
4 heads, 16 sectors/track, 128 cylinders                                        
Units = cylinders of 64 * 512 = 32768 bytes                                     
                                                                                
Disk /dev/mmcblk0boot1 doesn't contain a valid partition table                  
                                                                                
Disk /dev/mmcblk0boot0: 4 MB, 4194304 bytes                                     
4 heads, 16 sectors/track, 128 cylinders                                        
Units = cylinders of 64 * 512 = 32768 bytes                                     
                                                                                
Disk /dev/mmcblk0boot0 doesn't contain a valid partition table                  
                                                                                
Disk /dev/mmcblk1: 1992 MB, 1992294400 bytes                                    
4 heads, 16 sectors/track, 60800 cylinders                                      
Units = cylinders of 64 * 512 = 32768 bytes