Detecting ATA/ATAPI  device on 40-pin ATA connector using CY4611B Firmware

Question: In Cy4611B reference design how does the firmware detect if the attached device on 40-pin ATA Bus connector is ATA or ATAPI type?

 

Answer:

The ATA/ATAPI -6  standard defines  a  set of  configuration registers to communicate with ATA or ATAPI  device. The AT2LP  controller  uses  DA2 ,DA1 , DA0 CS#1 and CS#2 signals  to access these  registers. The ATA and ATAPI  register space overlap in address space .During firmware initialization the function detectSCSIvsATA()  reads the  ATAPI_BYTE_COUNT   register  in the following manner

If(readPIO8(ATAPI_BYTE_COUNT_MSB) == 0xeb && readPIO8(ATAPI_BYTE_COUNT_LSB) == 0x14) .

If the resultant value is 0xEB14  it indicates ATAPI compliant SCSI device or else it is ATA device .