Blackfin IDE Driver There is no specific knowledge of the IDE (Integrated Drive Electronics (hard drives!))-bus needed to understand how the interface works. Any good search-engine can lead to more than enough sites which provide you with the needed technical info. Some Terminology -------- IDE (Integrated Drive Electronics (hard drives!)) Integrated Drive Electronics, meaning that each drive has a built-in controller, which is why an “IDE (Integrated Drive Electronics (hard drives!)) interface card” is not a “controller card”. ATA (Advanced Technology Attachment (hard drives!)) AT (the old IBM 286 computer) Attachment Interface, a draft American National Standard for connecting hard drives to PCs. This is the official name for “IDE (Integrated Drive Electronics (hard drives!))”. ATA (Advanced Technology Attachment (hard drives!)) defines the physical, electrical, transport, and command protocols for the internal attachment of storage devices. ATAPI (Advanced Technology Attachment Packet Interface (hard drives!)) (AT Attachment Packet Interface) device: A device implementing the Packet Command feature set CFA The CompactFlash Association that created the specification for compact flash memory that uses the ATA (Advanced Technology Attachment (hard drives!)) interface. DMA (Direct Memory Access) Direct Memory Access. A means of data transfer between device and host memory without host processor intervention. master In ATA (Advanced Technology Attachment (hard drives!))-1, Device 0 has also been referred to as the master. Newer specifications, including this documentation, the term Device 0 is used. PIO Programmed Input/Output data transfer: PIO data transfers are performed by the host processor utilizing PIO register accesses to the Data register. slave In ATA (Advanced Technology Attachment (hard drives!))-1, Device 1 has also been referred to as the slave. Newer specifications, including this documentation, the term Device 1 is used. The latest standards define some enhancements, known as the ATA (Advanced Technology Attachment (hard drives!))-6 spec (specification), which grew out of vendor-specific “Enhanced IDE (Integrated Drive Electronics (hard drives!))” (EIDE) implementations. The IDE (Integrated Drive Electronics (hard drives!))-bus is based on the old MFM-, RLL- and ESDI-harddisks. The idea rose to integrate the controller in the PC with the onboard controller of the harddisk and to attach the result to the harddisk. The only signals needed for the resulting board would be the same signals as those after decoding the complete ISA-bus. These signals together nowadays are the IDE (Integrated Drive Electronics (hard drives!))-bus. The signals we need for the interface are: 16 data bits, D0..D15 3 address lines, A0..A2 2 Register block - select lines, CS0 and CS1 2 Read/write lines, IOW (In other words) and IOR 1 Interrupt strobe INTRQ There is one other strobe but is not needed for the functioning of the interface itself: DASP. The function of this line is to blink a LED when the HD is executing a command. There are more lines on the IDE (Integrated Drive Electronics (hard drives!))-bus but they are only needed for the extended DMA (Direct Memory Access) Modes. The IDE (Integrated Drive Electronics (hard drives!))-HD has two blocks of eight registers each: the “Command Block Registers” and the “Control Block Registers”. Register , CS0 , CS1 , A2 , A1 , A0 , Blackfin , A9 , A5 , A4 , A3 , A2 , A1 , , Offset , AMS0 , AMS1 , AMS2 , AMS3 Data Register(Read and Write) , 0 , 1 , 0 , 0 , 0 , , 0 , 1 , 0 , 0 , 0 , 0 , , 0x20 , 0x20000020 , 0x20100020 , 0x20200020 , 0x20300020 Error register (Read) , 0 , 1 , 0 , 0 , 1 , , 0 , 1 , 0 , 0 , 0 , 1 , , 0x22 , 0x20000022 , 0x20100022 , 0x20200022 , 0x20300022 Sector count register (Read and Write) , 0 , 1 , 0 , 1 , 0 , , 0 , 1 , 0 , 0 , 1 , 0 , , 0x24 , 0x20000024 , 0x20100024 , 0x20200024 , 0x20300024 Sector number register (Read and Write) , 0 , 1 , 0 , 1 , 1 , , 0 , 1 , 0 , 0 , 1 , 1 , , 0x26 , 0x20000026 , 0x20100026 , 0x20200026 , 0x20300026 Cylinder Low register (Read and Write) , 0 , 1 , 1 , 0 , 0 , , 0 , 1 , 0 , 1 , 0 , 0 , , 0x28 , 0x20000028 , 0x20100028 , 0x20200028 , 0x20300028 Cylinder HIGH register (Read and Write) , 0 , 1 , 1 , 0 , 1 , , 0 , 1 , 0 , 1 , 0 , 1 , , 0x2A , 0x2000002A , 0x2010002A , 0x2020002A , 0x2030002A Select Card/Head register (Read and Write) , 0 , 1 , 1 , 1 , 0 , , 0 , 1 , 0 , 1 , 1 , 0 , , 0x2C , 0x2000002C , 0x2010002C , 0x2020002C , 0x2030002C Status register (Read) , 0 , 1 , 1 , 1 , 1 , , 0 , 1 , 0 , 1 , 1 , 1 , , 0x2E , 0x2000002E , 0x2010002E , 0x2020002E , 0x2030002E Alt Status register (Read) , 1 , 0 , 1 , 1 , 0 , , 0 , 0 , 1 , 1 , 1 , 0 , , 0x1C , 0x2000001C , 0x2010001C , 0x2020001C , 0x2030001C Feature register (Write) , 0 , 1 , 0 , 0 , 1 , , 0 , 1 , 0 , 0 , 0 , 1 , , 0x22 , 0x20000022 , 0x20100023 , 0x20200024 , 0x20300025 Command register (Write) , 0 , 1 , 1 , 1 , 1 , , 0 , 1 , 0 , 1 , 1 , 1 , , 0x2E , 0x2000002E , 0x2010002E , 0x2020002E , 0x2030002E Device Control Register (Write) , 1 , 0 , 1 , 1 , 0 , , 0 , 0 , 1 , 1 , 1 , 0 , , 0x1C , 0x2000001C , 0x2010001C , 0x2020001C , 0x2030001C The first block is chosen by negating CS0, the second by negating CS1. Applying the right value to the addresslines A0..2 chooses the correct register within each block. Reading from or writing to a register is done by negating IOR or IOW (In other words). The IDE (Integrated Drive Electronics (hard drives!)) bus is, as said before, 16 bits wide but some of the registers are only 8 bits wide. Example Interfacing a CF Card in True IDE Mode A CompactFlash Storage Card can be operated in True IDE (Integrated Drive Electronics (hard drives!)) Mode that is electrically compatible with an IDE (Integrated Drive Electronics (hard drives!)) disk drive. The CompactFlash Storage Cards on-card intelligent controller manages interface protocols, data storage and retrieval as well as Error Correcting Code (ECC), defect handling and diagnostics, power management and clock control. Once the CompactFlash Storage Card has been configured by the host, it appears to the host as a standard ATA (Advanced Technology Attachment (hard drives!)) (IDE (Integrated Drive Electronics (hard drives!))) disk drive. For further details refer to the CF and ATA (Advanced Technology Attachment (hard drives!))-4 specification. Blackfin , , HDD A1 , → , A0 A2 , → , A1 A3 , → , A2 A4 + AMSx , → , /CS0 A5 + AMSx , → , /CS1 /ARE , → , /IOR /AWE , → , /IOW (In other words) PFx , ← , /INTRQ /RESET , → , /RESET D[0..15] , ↔ , D[0..15] For CF Cards in TRUE IDE (Integrated Drive Electronics (hard drives!)) MODE only VCC , ← , /REG VCC , ← , /WE GND , ← , /ATA (Advanced Technology Attachment (hard drives!))_SEL Blackfin's IO Voltage is limited to 3.3 Volt only ! If you're connecting a 5 Volt Drive use level shifters between 3.3V and 5V IOs A more complex implementation can be found here: cf-ide-nand http://blackfin.uclinux.org/frs/?group_id=7 Configuring the kernel for IDE ATA support The driver documented here is deprecated. It exists in 2008R1 and older only. It has been replaced by thePATA Platformdriver for the realIDE (Integrated Drive Electronics (hard drives!))channel, and theBlackfin CF/PCMCIAdriver for the CF in PC Card IO mode. Enable the appropriate kernel options. IDE (Integrated Drive Electronics (hard drives!))/ATA (Advanced Technology Attachment (hard drives!))-2 Disk is only needed for IDE (Integrated Drive Electronics (hard drives!)) drives while IDE (Integrated Drive Electronics (hard drives!))/ATAPI (Advanced Technology Attachment Packet Interface (hard drives!)) CDROM is only needed for IDE (Integrated Drive Electronics (hard drives!)) cd/dvd drives. Device Drivers ---> ATA/ATAPI/MFM/RLL support ---> <*> ATA/ATAPI/MFM/RLL support <*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support <*> Include IDE/ATA-2 DISK support <*> Include IDE/ATAPI CDROM support --- IDE chipset support/bugfixes <*> generic/default IDE chipset support [*] IDE support on Blackfin CPU Blackfin specific configuration IDE Settings For CF card in TRUE IDE mode <*> IDE support on Blackfin CPU IDE Interface Address Mapping (see help) (16-bit mapping for multimode CF Interface) ---> (0x2031C020) IDE register base address (0x2031C01C) IDE register alternate address (54) IDE IRQ_PFx number (13) Blackfin A[x] used as CF A0 (0x20311802) Address for enabling CF TRUE IDE MODE (ATASEL) (0x20311800) Address for disabling CF TRUE IDE MODE (ATASEL) For IDE Disk EBIU Configuration Blackfin Processor Options ---> EBIU_AMBCTL Control ---> (0x7BB0) Bank 0 (0x7BB0) Bank 1 (0xFFC3) Bank 2 (0xFFC3) Bank 3 Enable maximum wait states (0xFFC3) for the memory bank theIDE (Integrated Drive Electronics (hard drives!))drive is connected to. Adjusting System Clock Speed This part is optional. Tweak according to your needs. Depending on the connected drives PIO mode support, System ClockSCLK (System Clock)must not exceed maximumIDE (Integrated Drive Electronics (hard drives!))timing requirements Enabling file system support Enabling File System support for file systems commonly used on CF Cards Enabling Native Language Support Testing the IDE interface Kernel Start A configured kernel should print messages as following Linux version 2.6.12.1 (hennerich@linux) (gcc version 3.4.4) #69 Sun Oct 23 11:5 Blackfin support (C) 2004 Analog Devices, Inc. ADSP-BF537 Rev. 0.2 uClinux/BF537 Blackfin uClinux support by blackfin.uclinux.org Processor Speed: 500 MHz core clock and 100 Mhz System Clock Board Memory: 64MB Memory map: text = 0x001000-0x0ed400 data = 0x0fa8dc-0x11d9b8 bss = 0x11d9c0-0x12c284 rootfs = 0x3b00000-0x3f00000 stack = 0x0fc000-0x0fe000 Command line: 'root=/dev/mtdblock0 rw' Instruction Cache Enabled Data Cache Enabled (write-through) Hardware Trace Enabled Built 1 zonelists Kernel command line: root=/dev/mtdblock0 rw Configuring Blackfin Priority Driven Interrupts PID hash table entries: 256 (order: 8, 4096 bytes) Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) Physical pages: 3b00 Memory available: 58624k/64533k RAM, (49k init code, 945k kernel code, 198k dat) Blackfin Scratchpad data SRAM: 4 KB Blackfin DATA_A SRAM: 16 KB Blackfin DATA_B SRAM: 16 KB Security Framework v1.0.0 initialized Capability LSM initialized Mount-cache hash table entries: 512 NET: Registered protocol family 16 Blackfin DMA Controller for BF533 stamp_init(): registering device resources NTFS driver 2.1.22 [Flags: R/O]. Real Time Clock Driver v1.10e BlackFin BF533 serial driver version 2.00 With DMA Support io scheduler noop registered io scheduler cfq registered RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2 ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx Blackfin IDE interrupt setup: flag PF11, irq 35 ide0: Blackfin generic IDE interface hda: SanDisk SDCFH-512, CFA DISK drive ide0 at 0x20300020-0x20300027,0x2020001c on irq 35 hda: max request size: 128KiB hda: 1000944 sectors (512 MB) w/1KiB Cache, CHS=993/16/63 hda: cache flushes not supported hda: hda1 uclinux[mtd]: RAM probe address=0x3b00000 size=0x400000 Creating 1 MTD partitions on "RAM": 0x00000000-0x00400000 : "EXT2fs" uclinux[mtd0]: set EXT2fs to be root filesystem NET: Registered protocol family 2 IP: routing cache hash table of 512 buckets, 4Kbytes TCP established hash table entries: 2048 (order: 2, 16384 bytes) TCP bind hash table entries: 2048 (order: 1, 8192 bytes) TCP: Hash tables configured (established 2048 bind 2048) NET: Registered protocol family 1 NET: Registered protocol family 17 VFS: Mounted root (ext2 filesystem). Freeing unused kernel memory: 48k freed (0xee000 - 0xf9000) ttyS0 at irq = 18 is a builtin BlackFin UART dma_alloc_init: dma_page @ 0x000f6000 - 256 pages at 0x03f00000 bfin_change_speed: baud = 57600, cval = 0x13 Welcome to: ____ _ _ / __| ||_| _ _ _ _| | | | _ ____ _ _ \ \/ / | | | | | | || | _ \| | | | \ / | |_| | |__| || | | | | |_| | / \ | ___\____|_||_|_| |_|\____|/_/\_\ |_| For further information see: http://www.uclinux.org/ http://blackfin.uclinux.org/ BusyBox v1.00 (2005.10.22-09:09+0000) Built-in shell (msh) Enter 'help' for a list of built-in commands. root:~> Make sure the start up messages include this section: ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx BlackfinIDE (Integrated Drive Electronics (hard drives!))interrupt setup: flag PF11, irq 35 ide0: Blackfin genericIDE (Integrated Drive Electronics (hard drives!))interface hda: SanDisk SDCFH-512, CFA DISK drive ide0 at 0x20300020-0x20300027,0x2020001c on irq 35 hda: max request size: 128KiB hda: 1000944 sectors (512MB (Megabyte)) w/1KiB Cache, CHS=993/16/63 hda: cache flushes not supported hda: hda1 Mounting the IDE device root:~> mount /dev/hda1 /mnt hda: hda1 VFS: Can't find an ext2 filesystem on dev hda1. hda: hda1 root:~> Display drive content root:~> cd mnt root:/mnt> ls -al images/ drwxr-xr-x 2 0 0 8192 . drwxr-xr-x 4 0 0 16384 .. -rwxr-xr-x 1 0 0 228942800 tardum~1.gz -rwxr-xr-x 1 0 0 205595524 uclinu~1.gz root:/mnt> Simple throughput test 228942800 bytes / 44.24s / (1024*1024) = 4.935 MB (Megabyte)/s root:/mnt> time cat images/tardum~1.gz > /dev/null real 0m 44.24s user 0m 0.35s sys 0m 28.26s root:/mnt> Displaying Drive Information The hdparm utility can be used to control various IDE (Integrated Drive Electronics (hard drives!)) features on a running system. A hdparm derivative can be found in busybox root:~> hdparm -i /dev/hda /dev/hda: Model=SanDisk SDCFH-512, FwRev=HDX 2.27, SerialNo=012017H1305T3518 Config={ HardSect NotMFM Removeable DTR>10Mbs nonMagnetic } RawCHS=993/16/63, TrkSize=0, SectSize=576, ECCbytes=4 BuffType=DualPort, BuffSize=1kB, MaxMultSect=1, MultSect=off CurCHS=993/16/63, CurSects=1000944, LBA=yes, LBAsects=1000944 IORDY=no, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4 DMA modes: mdma0 mdma1 *mdma2 AdvancedPM=no Drive conforms to: device does not report version: * signifies the current active mode root:~> Checking for filesystem support root:/proc> cat filesystems nodev sysfs nodev rootfs nodev bdev nodev proc nodev sockfs nodev pipefs nodev futexfs nodev eventpollfs nodev devpts ext2 nodev ramfs msdos vfat ntfs root:/proc> Checking disk space root:/proc> df Filesystem 1k-blocks Used Available Use% Mounted on /dev/mtdblock0 3579 1877 1498 56% / /dev/hda1 500176 439720 60456 88% /mnt Validating data integrity root:/proc> while [ 1 ]; md5sum /mnt/images/tardum~1.gz ; done 543b4b991ca7eef667582608d809029f /mnt/images/tardum~1.gz 543b4b991ca7eef667582608d809029f /mnt/images/tardum~1.gz 543b4b991ca7eef667582608d809029f /mnt/images/tardum~1.gz 543b4b991ca7eef667582608d809029f /mnt/images/tardum~1.gz 543b4b991ca7eef667582608d809029f /mnt/images/tardum~1.gz 543b4b991ca7eef667582608d809029f /mnt/images/tardum~1.gz 543b4b991ca7eef667582608d809029f /mnt/images/tardum~1.gz 543b4b991ca7eef667582608d809029f /mnt/images/tardum~1.gz