Can not get PATA to work for Compact Flash with 2.6.28 kernel

Lixin Yao Lixin.Yao at HSTX.com
Tue Feb 3 09:00:31 EST 2009


I redefined io functions in libata-sff.c, byte operations are converted
to 16bit word operations. Maybe I should ask for HW changes in new
revisions of the board.

These are the changes I had to make in drivers/ata/libata-sff.c.
TR5000V2 is my board config define.

#if defined(CONFIG_TR5000V2)

#define ioread8(X) ide_inb(X)
#define iowrite8(X, Y) ide_outb(X, Y)
#define ioread16_rep(X, Y, Z) ide_read16_rep(X, Y, Z)
#define iowrite16_rep(X, Y, Z) ide_write16_rep(X, Y, Z)

static void inline ide_outb (u8 val, void __iomem *addr)
{
   asm("eieio");
   *(ushort *)addr = val;
   asm("eieio");
   asm("sync");
}

static unsigned char inline ide_inb(void __iomem *addr)
{
   ushort data16;
   data16 = *(volatile ushort *)(addr);
   asm("eieio"); 
   asm("sync");
   return data16;
}


static void ide_read16_rep(void __iomem *addr, void *dst, unsigned long
ulcount)
{
   const volatile u16 __iomem *port = addr;
   void *buf = dst;
   long count = ulcount;
   u16 *tbuf = buf;
   u16 tmp;

   if (unlikely(count <= 0))
      return;
   asm volatile("sync");
   do {
      tmp = *port;
      eieio();
      *tbuf++ = tmp>>8 | tmp<<8;
   } while (--count != 0);
   asm volatile("twi 0,%0,0; isync" : : "r" (tmp));
}

static void ide_write16_rep(void __iomem *addr, const void *src,
unsigned long ulcount)
{
   volatile u16 __iomem *port = addr;
   const void *buf = src;
   long count = ulcount;   
   const u16 *tbuf = buf;

   if (unlikely(count <= 0))
      return;
   asm volatile("sync");
   do {
      *port = *tbuf<<8 | *tbuf>>8;
      tbuf++;
   } while (--count != 0);
   asm volatile("sync");
}
#endif 


I can mount DOS FS now.

>mknod /dev/sda1 b 8 1
>mount -t msdos /dev/sda1 /mnt

Thanks.

Lixin

-----Original Message-----
From: Steven A. Falco [mailto:sfalco at harris.com] 
Sent: Monday, February 02, 2009 4:52 PM
To: Lixin Yao
Cc: Aaron Pace; linuxppc-dev at ozlabs.org
Subject: Re: Can not get PATA to work for Compact Flash with 2.6.28
kernel

Lixin Yao wrote:
> Steven/Aaron,
> 
> I found the problem. On my board, the CF is on a 16 bit interface on
bus
> of MPC8248. The HW is connected in Big Endian format. PPC Bit D0 is
> connected to CF Bit D15, and PPC D1 to CF Bit D14, till PPC D0 to CF
> D15. I had to swap the bytes in u-boot. I forgot to do it in Kernel. 
> 
> After making the change, CF is detected. But I can not access /dev/hda
> or any scsi/sda devices under /dev. 
> 

How did you swap the bytes?  The CF will be accessed both in byte mode
and in 16-bit mode.  So this is tricky to do in software.  When we
wired our CF, we deliberately swapped the bytes in hardware.  So the
processor bus MSB goes to pin 6 of the CF.

	Steve




More information about the Linuxppc-dev mailing list