Original ata_piix driver is using the IDE framework, not
real SATA framework. This patch makes the ata_piix driver
use the new SATA framework, so
- remove the duplicated command stuff
- remove the CONFIG_CMD_IDE define in the sc520_cdp.h
- add the CONFIG_CMD_SATA define to sc520_cdp.h

Signed-off-by: Dave Liu <[EMAIL PROTECTED]>
---
 drivers/block/ata_piix.c    |  161 +++++++------------------------------------
 include/configs/sc520_cdp.h |   26 +-------
 include/sata.h              |    4 +-
 3 files changed, 28 insertions(+), 163 deletions(-)

diff --git a/drivers/block/ata_piix.c b/drivers/block/ata_piix.c
index bf44e3d..db3922e 100644
--- a/drivers/block/ata_piix.c
+++ b/drivers/block/ata_piix.c
@@ -37,6 +37,9 @@
 
 #ifdef CFG_ATA_PIIX            /*ata_piix driver */
 
+extern block_dev_desc_t sata_dev_desc[CFG_SATA_MAX_DEVICE];
+extern int curr_device;
+
 #define DEBUG_SATA 0           /*For debug prints set DEBUG_SATA to 1 */
 
 #define SATA_DECL
@@ -144,19 +147,15 @@ sata_bus_probe (int port_no)
 }
 
 int
-init_sata (void)
+init_sata (int dev)
 {
+       static int done = 0;
        u8 i, rv = 0;
 
-       for (i = 0; i < CFG_SATA_MAXDEVICES; i++) {
-               sata_dev_desc[i].type = DEV_TYPE_UNKNOWN;
-               sata_dev_desc[i].if_type = IF_TYPE_IDE;
-               sata_dev_desc[i].dev = i;
-               sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
-               sata_dev_desc[i].blksz = 0;
-               sata_dev_desc[i].lba = 0;
-               sata_dev_desc[i].block_read = sata_read;
-       }
+       if (!done)
+               done = 1;
+       else
+               return 0;
 
        rv = pci_sata_init ();
        if (rv == 1) {
@@ -207,8 +206,8 @@ init_sata (void)
                                dev_print (&sata_dev_desc[devno]);
                                /* initialize partition type */
                                init_part (&sata_dev_desc[devno]);
-                               if (curr_dev < 0)
-                                       curr_dev =
+                               if (curr_device < 0)
+                                       curr_device =
                                            i * CFG_SATA_DEVS_PER_BUS + j;
                        }
                }
@@ -231,13 +230,13 @@ sata_outb (unsigned char val, unsigned long ioaddr)
 static void
 output_data (struct sata_ioports *ioaddr, ulong * sect_buf, int words)
 {
-//     outsw (ioaddr->data_addr, sect_buf, words << 1);
+       outsw (ioaddr->data_addr, sect_buf, words << 1);
 }
 
 static int
 input_data (struct sata_ioports *ioaddr, ulong * sect_buf, int words)
 {
-//     insw (ioaddr->data_addr, sect_buf, words << 1);
+       insw (ioaddr->data_addr, sect_buf, words << 1);
        return 0;
 }
 
@@ -753,134 +752,24 @@ sata_write (int device, ulong blknr,lbaint_t blkcnt, 
void * buff)
        return n;
 }
 
-block_dev_desc_t *sata_get_dev (int dev);
-
-block_dev_desc_t *
-sata_get_dev (int dev)
+int sata_low_level_read(int dev, u32 blknr, u32 blkcnt, void *buffer)
 {
-       return ((block_dev_desc_t *) & sata_dev_desc[dev]);
+       return sata_read(dev, blknr, blkcnt, buffer);
 }
 
-int
-do_sata (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+int sata_low_level_write(int dev, u32 blknr, u32 blkcnt, void *buffer)
 {
+       return sata_write(dev, blknr, blkcnt, buffer);
+}
 
-       switch (argc) {
-       case 0:
-       case 1:
-               printf ("Usage:\n%s\n", cmdtp->usage);
-               return 1;
-       case 2:
-               if (strncmp (argv[1], "init", 4) == 0) {
-                       int rcode = 0;
-
-                       rcode = init_sata ();
-                       if (rcode)
-                               printf ("Sata initialization Failed\n");
-                       return rcode;
-               } else if (strncmp (argv[1], "inf", 3) == 0) {
-                       int i;
-
-                       putc ('\n');
-                       for (i = 0; i < CFG_SATA_MAXDEVICES; ++i) {
-                               /*List only known devices */
-                               if (sata_dev_desc[i].type ==
-                                   DEV_TYPE_UNKNOWN)
-                                       continue;
-                               printf ("sata dev %d: ", i);
-                               dev_print (&sata_dev_desc[i]);
-                       }
-                       return 0;
-               }
-               printf ("Usage:\n%s\n", cmdtp->usage);
-               return 1;
-       case 3:
-               if (strcmp (argv[1], "dev") == 0) {
-                       int dev = (int) simple_strtoul (argv[2], NULL, 10);
-
-                       if (dev >= CFG_SATA_MAXDEVICES) {
-                               printf ("\nSata dev %d not available\n",
-                                       dev);
-                               return 1;
-                       }
-                       printf ("\nSATA dev %d: ", dev);
-                       dev_print (&sata_dev_desc[dev]);
-                       if (sata_dev_desc[dev].type == DEV_TYPE_UNKNOWN)
-                               return 1;
-                       curr_dev = dev;
-                       return 0;
-               } else if (strcmp (argv[1], "part") == 0) {
-                       int dev = (int) simple_strtoul (argv[2], NULL, 10);
-
-                       if (dev >= CFG_SATA_MAXDEVICES) {
-                               printf ("\nSata dev %d not available\n",
-                                       dev);
-                               return 1;
-                       }
-                       PRINTF ("\nSATA dev %d: ", dev);
-                       if (sata_dev_desc[dev].part_type !=
-                           PART_TYPE_UNKNOWN) {
-                               print_part (&sata_dev_desc[dev]);
-                       } else {
-                               printf ("\nSata dev %d partition type "
-                                       "unknown\n", dev);
-                               return 1;
-                       }
-                       return 0;
-               }
-               printf ("Usage:\n%s\n", cmdtp->usage);
-               return 1;
-       default:
-               if (argc < 5) {
-                       printf ("Usage:\n%s\n", cmdtp->usage);
-                       return 1;
-               }
-               if (strcmp (argv[1], "read") == 0) {
-                       ulong addr = simple_strtoul (argv[2], NULL, 16);
-                       ulong cnt = simple_strtoul (argv[4], NULL, 16);
-                       ulong n;
-                       lbaint_t blk = simple_strtoul (argv[3], NULL, 16);
-
-                       memset ((int *) addr, 0, cnt * 512);
-                       printf ("\nSATA read: dev %d blk # %ld,"
-                               "count %ld ... ", curr_dev, blk, cnt);
-                       n = sata_read (curr_dev, blk, cnt, (ulong *) addr);
-                       /* flush cache after read */
-                       flush_cache (addr, cnt * 512);
-                       printf ("%ld blocks read: %s\n", n,
-                               (n == cnt) ? "OK" : "ERR");
-                       if (n == cnt)
-                               return 1;
-                       else
-                               return 0;
-               } else if (strcmp (argv[1], "write") == 0) {
-                       ulong addr = simple_strtoul (argv[2], NULL, 16);
-                       ulong cnt = simple_strtoul (argv[4], NULL, 16);
-                       ulong n;
-                       lbaint_t blk = simple_strtoul (argv[3], NULL, 16);
-
-                       printf ("\nSata write: dev %d blk # %ld,"
-                               "count %ld ... ", curr_dev, blk, cnt);
-                       n = sata_write (curr_dev, blk, cnt, (ulong *) addr);
-                       printf ("%ld blocks written: %s\n", n,
-                               (n == cnt) ? "OK" : "ERR");
-                       if (n == cnt)
-                               return 1;
-                       else
-                               return 0;
-               } else {
-                       printf ("Usage:\n%s\n", cmdtp->usage);
-                       return 1;
-               }
-       }                       /*End OF SWITCH */
+int sata_low_level_init(int dev)
+{
+       return init_sata(dev);
 }
 
-U_BOOT_CMD (sata, 5, 1, do_sata,
-           "sata init\n"
-           "sata info\n"
-           "sata part device\n"
-           "sata dev device\n"
-           "sata read  addr blk# cnt\n"
-           "sata write  addr blk# cnt\n", "cmd for init,rw and dev-info\n");
+int sata_low_level_scan(int dev)
+{
+       return 0;
+}
 
 #endif
diff --git a/include/configs/sc520_cdp.h b/include/configs/sc520_cdp.h
index 58d656c..4df461d 100644
--- a/include/configs/sc520_cdp.h
+++ b/include/configs/sc520_cdp.h
@@ -81,8 +81,8 @@
 #include <config_cmd_default.h>
 
 #define CONFIG_CMD_PCI
+#define CONFIG_CMD_SATA
 #define CONFIG_CMD_JFFS2
-#define CONFIG_CMD_IDE
 #define CONFIG_CMD_NET
 #define CONFIG_CMD_EEPROM
 
@@ -173,36 +173,14 @@
 #define PCNET_HAS_PROM         1
 
 /************************************************************
- * IDE/ATA stuff
- ************************************************************/
-#define CFG_IDE_MAXBUS         1   /* max. 2 IDE busses        */
-#define CFG_IDE_MAXDEVICE      (CFG_IDE_MAXBUS*2) /* max. 2 drives per IDE bus 
*/
-
-#define CFG_ATA_IDE0_OFFSET    0x01F0  /* ide0 offste */
-/*#define CFG_ATA_IDE1_OFFSET  0x0170  /###* ide1 offset */
-#define CFG_ATA_DATA_OFFSET    0       /* data reg offset      */
-#define CFG_ATA_REG_OFFSET     0       /* reg offset */
-#define CFG_ATA_ALT_OFFSET     0x200   /* alternate register offset */
-#define CFG_ATA_BASE_ADDR       0
-
-#undef CONFIG_IDE_LED                  /* no led for ide supported     */
-#undef  CONFIG_IDE_RESET               /* reset for ide unsupported... */
-#undef  CONFIG_IDE_RESET_ROUTINE       /* no special reset function */
-
-/************************************************************
 *SATA/Native Stuff
 ************************************************************/
 #define CFG_SATA_MAXBUS         2       /*Max Sata buses supported */
 #define CFG_SATA_DEVS_PER_BUS   2      /*Max no. of devices per bus/port */
-#define CFG_SATA_MAXDEVICES     (CFG_SATA_MAXBUS* CFG_SATA_DEVS_PER_BUS)
+#define CFG_SATA_MAX_DEVICE     (CFG_SATA_MAXBUS* CFG_SATA_DEVS_PER_BUS)
 #define CFG_ATA_PIIX            1       /*Supports ata_piix driver */
 
 /************************************************************
- * ATAPI support (experimental)
- ************************************************************/
-#define CONFIG_ATAPI                   /* enable ATAPI Support */
-
-/************************************************************
  * DISK Partition support
  ************************************************************/
 #define CONFIG_DOS_PARTITION
diff --git a/include/sata.h b/include/sata.h
index bb1acb3..ed2e4d5 100644
--- a/include/sata.h
+++ b/include/sata.h
@@ -82,11 +82,9 @@ void msleep (int count);
 /************DRIVER SPECIFIC DEFINITIONS AND DECLARATIONS**************/
 
 #ifdef DRV_DECL                        /*Driver specific declaration */
-int init_sata (void);
+int init_sata (int dev);
 #endif
 
 #ifdef DRV_DECL                        /*Defines Driver Specific variables */
 struct sata_port port[CFG_SATA_MAXBUS];
-block_dev_desc_t sata_dev_desc[CFG_SATA_MAXDEVICES];
-int curr_dev = -1;
 #endif
-- 
1.5.4.rc4




-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
U-Boot-Users mailing list
U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users

Reply via email to