ARMSYS44B0开发板IDE接口挂接硬盘的参考
44b0x-p板Linux下ide硬盘成功挂接
1.确定IDE寄存器地址填充:
根据硬件设计有以下对应:
CS0 CS1 DA2 DA1 DA0
ADDR2 ADDR1 ADDR3 ADDR4 ADDR5 地址 功能 对应定义
1 0 1 0 1 0x0400001c Alternate status IDE_CTRL
0 1 0 0 0 0x04000002 Data IDE_DATA_OFFSET
0 1 0 1 0 0x04000022 Error IDE_ERROR_OFFSET
0 1 0 0 1 0x04000012 Sector Count IDE_NSECTOR_OFFSET
0 1 0 1 1 0x04000032 Sector Number IDE_SECTOR_OFFSET
0 1 1 0 0 0x0400000A Cylinder Low IDE_LCYL_OFFSET
0 1 1 1 0 0x0400002A Cylinder High IDE_HCYL_OFFSET
0 1 1 0 1 0x0400001A Device/Head IDE_SELECT_OFFSET
0 1 1 1 1 0x0400003A Status IDE_STATUS_OFFSET
p板IDE中断为EINT1.
2. 修改ide.h
//-----------------------ide.h---------------------?óè?μ?include/asm-armnommu/??????
/*
* linux/include/asm-arm/ide.h
*
* Copyright (C) 1994-1996 Linus Torvalds & authors
*/
/*
* This file contains the i386 architecture specific IDE code.
*/
#ifndef __ASMARMNOMMU_IDE_H
#define __ASMARMNOMMU_IDE_H
#ifdef __KERNEL__
#ifndef MAX_HWIFS
#define MAX_HWIFS 1
#endif
#define ide__sti() __sti()
#include <asm/arch/hardware.h>//ìá1?S3C44B0X?????÷μ??·
#include <asm/arch/irqs.h> //ìá1??D??o???
#include <linux/ide.h> //ìá1?1?óúó2?ìμ?ò?D?êy?Y?á11??ò?
#define IDE_BASE 0x04000000//ó2?ì?????÷?aê?μ??·
#define IDE_CTRL 0x0400001c//
#define IDE_IRQ S3C44B0X_INTERRUPT_EINT1 //ê1ó?μ?ía2??D??o?
//μ??·????,?a???ú??μ?ó2?tóD1??μ,óDμ???????ê?1,?òμ?ó2?té?ê?2
#define IDE_DATA_OFFSET (0)
#define IDE_ERROR_OFFSET (1)
#define IDE_NSECTOR_OFFSET (2)
#define IDE_SECTOR_OFFSET (3)
#define IDE_LCYL_OFFSET (4)
#define IDE_HCYL_OFFSET (5)
#define IDE_SELECT_OFFSET (6)
#define IDE_STATUS_OFFSET (7)
#define IDE_CONTROL_OFFSET (8)
/*----------------------------------------------------------*/
static __inline__ int ide_default_irq(ide_ioreg_t base)
{
return IDE_IRQ;
}
static __inline__ ide_ioreg_t ide_default_io_base(int index)
{
return IDE_BASE;
}
/*----------------------------------------------------------*/
/*
* Set up a hw structure for a specified data port, control port and IRQ.
* This should follow whatever the default interface uses.
*/
static __inline__ void ide_init_hwif_ports(
hw_regs_t *hw,
ide_ioreg_t data_port,
ide_ioreg_t ctrl_port,
int *irq)
{
ide_ioreg_t reg = data_port;
printk("ide_init_hwif_ports\n");//??μ?ìáê?£?è??ò???aμàuClinuxμ?è·?üμ??aà?á?
hw->io_ports[IDE_DATA_OFFSET] = 0x04000002;
hw->io_ports[IDE_ERROR_OFFSET] = 0x04000022;
hw->io_ports[IDE_NSECTOR_OFFSET] = 0x04000012;
hw->io_ports[IDE_SECTOR_OFFSET] = 0x04000032;
hw->io_ports[IDE_LCYL_OFFSET] = 0x0400000A;
hw->io_ports[IDE_HCYL_OFFSET] = 0x0400002A;
hw->io_ports[IDE_SELECT_OFFSET] = 0x0400001A;
hw->io_ports[IDE_STATUS_OFFSET] = 0x0400003A;
hw->io_ports[IDE_CONTROL_OFFSET] = 0x0400001c;
}
/*----------------------------------------------------------*/
/*
* This registers the standard ports for this architecture with the IDE
* driver.
*/
static __inline__ void ide_init_default_hwifs(void)
{
hw_regs_t hw;
printk("ide_init_default_hwifs\n");
//--------------------------------------------------------
//(*(volatile unsigned short *)0x0A200000)|=0x0040; // Set IDE Reset to High
outl( inl(S3C44B0X_PCONG)|0x0c, S3C44B0X_PCONG);
outl( inl(S3C44B0X_PUPG) &0xfd, S3C44B0X_PUPG);
outl((inl(S3C44B0X_EXTINT) &0xffffff8f) | 0x00000040, S3C44B0X_EXTINT);
outl(inl(S3C44B0X_INTMSK) &( ~( 1 << 24 ) ),S3C44B0X_INTMSK );
//--------------------------------------------------------
ide_init_hwif_ports(&hw,IDE_BASE,IDE_CTRL, NULL);
hw.irq = IDE_IRQ;
ide_register_hw(&hw, NULL);
}
/*----------------------------------------------------------*/
#define __ide_mm_insw(port,addr,count) do { } while(0)
#define __ide_mm_insl(port,addr,count) do { } while(0)
#define __ide_mm_outsw(port,addr,count) do { } while(0)
#define __ide_mm_outsl(port,addr,count) do { } while(0)
#endif /* __KERNEL__ */
#endif /* __ASMARM_IDE_H */
//-------------------------end of ide.h-----------------------------------
3.移植.
在make menuconfig 后选择IDE相关选项:
A.选择IDE硬盘驱动
ATA/IDE/MFM/RLL support
Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
Include IDE/ATA-2 DISK support //选择支持IDE硬盘
B.选择文件系统支持
File systems
DOS FAT fssupport
MSDOS fs support
VFAT(Windows-95)fs support
C.选择分区支持
File systems
Partition Types
Advanced partition selection
PC BIOS (MSDOS partition tables) support
D.定义设备文件
改动 uClinux/vendors/Samsung/44b0x/下的makefile 文件内容,加入:
\
hda,b,3,0 hdb,b,3,64 \
hda1,b,3,1 hda2,b,3,2 hda3,b,3,3 hda4,b,3,4\
hda5,b,3,5 hda6,b,3,6 hda7,b,3,7 hda8,b,3,8\
hdb1,b,3,65 hdb2,b,3,66 hdb3,b,3,67 hdb4,b,3,68\
hdb5,b,3,69 hdb6,b,3,70 hdb7,b,3,71 hdb8,b,3,72\
\
然后编译即可.
附记:我挂接的是512M电子盘,2.5寸,44针接口.超过此大小的存贮介质在uClinux系统解压时就有问题,估计是要修改p板的BIOS文件.
==================================
作者:wuqiqi
S3C44B0X 挂接硬盘注意的问题
在S3C44B0X上的UCLINUX挂接硬盘,搞了很久,读回来的硬盘信息就是不对,读得的磁头数竟然有63个,所以UCLINUX就没有继续往下面走,百思不得其解,总以为是总线的3.3V电压与硬盘的5V电压不匹配造成数据传输错误.后来加了74LS245做数据线缓冲,故障依旧.又看了很久的ATA协议英文资料,还是没有找到办法.无意间发现挂接硬盘的BANK数据总线为8位模式,恍然大悟.原来在访问硬盘数据寄存器的时候是16位的,而其他寄存器是8位的,因此能正确执行命令,但是数据访问就不正确了.在一文中也没有特别指出数据总线为16位,数据总线的初始化也是在BOOTLOADER里完成的,所以之前一直没有注意这个问题.现在终于一切搞定了.现提醒各位,希望不要走我的弯路.