]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_fdc.c
karo: tx6: factor out PMIC initialization
[karo-tx-uboot.git] / common / cmd_fdc.c
index 9ddc59b7a0d10e4b1518c245f55862938b13cdc4..98b3c4c0014901444291c4bddd9e9282a38bf9ce 100644 (file)
@@ -2,24 +2,7 @@
  * (C) Copyright 2001
  * Denis Peter, MPL AG, d.peter@mpl.ch.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 /*
  * Floppy Disk support
 #define PRINTF(fmt,args...)
 #endif
 
-#ifndef        TRUE
-#define TRUE            1
-#endif
-#ifndef FALSE
-#define FALSE           0
-#endif
-
-
 /*#if defined(CONFIG_CMD_DATE) */
 /*#include <rtc.h> */
 /*#endif */
 
-#if defined(CONFIG_CMD_FDC) || defined(CONFIG_CMD_FDOS)
-
-
 typedef struct {
-       int                                             flags;          /* connected drives ect */
-       unsigned long blnr;                     /* Logical block nr */
-       uchar                                   drive;          /* drive no */
-       uchar                                   cmdlen;         /* cmd length */
-       uchar                                   cmd[16];        /* cmd desc */
-       uchar                                   dma;                    /* if > 0 dma enabled */
-       uchar                                   result[11];/* status information */
-       uchar                                   resultlen; /* lenght of result */
+       int             flags;          /* connected drives ect */
+       unsigned long   blnr;           /* Logical block nr */
+       uchar           drive;          /* drive no */
+       uchar           cmdlen;         /* cmd length */
+       uchar           cmd[16];        /* cmd desc */
+       uchar           dma;            /* if > 0 dma enabled */
+       uchar           result[11];     /* status information */
+       uchar           resultlen;      /* lenght of result */
 } FDC_COMMAND_STRUCT;
+
 /* flags: only the lower 8bit used:
  * bit 0 if set drive 0 is present
  * bit 1 if set drive 1 is present
@@ -75,31 +48,30 @@ typedef struct {
  * bit 7 if set disk in drive 4 is inserted
  */
 
-
 /* cmd indexes */
-#define COMMAND                0
-#define DRIVE                  1
+#define COMMAND                        0
+#define DRIVE                  1
 #define CONFIG0                        1
-#define SPEC_HUTSRT    1
-#define TRACK                  2
+#define SPEC_HUTSRT            1
+#define TRACK                  2
 #define CONFIG1                        2
 #define SPEC_HLT               2
-#define HEAD                           3
+#define HEAD                   3
 #define CONFIG2                        3
-#define SECTOR                         4
-#define SECTOR_SIZE    5
-#define LAST_TRACK     6
-#define GAP                                    7
-#define DTL                                    8
+#define SECTOR                 4
+#define SECTOR_SIZE            5
+#define LAST_TRACK             6
+#define GAP                    7
+#define DTL                    8
 /* result indexes */
-#define STATUS_0                                               0
-#define STATUS_PCN                                     1
-#define STATUS_1                                               1
-#define STATUS_2                                               2
-#define STATUS_TRACK                           3
-#define STATUS_HEAD                                    4
-#define STATUS_SECT                                    5
-#define STATUS_SECT_SIZE               6
+#define STATUS_0               0
+#define STATUS_PCN             1
+#define STATUS_1               1
+#define STATUS_2               2
+#define STATUS_TRACK           3
+#define STATUS_HEAD            4
+#define STATUS_SECT            5
+#define STATUS_SECT_SIZE       6
 
 
 /* Register addresses */
@@ -114,34 +86,34 @@ typedef struct {
 #define FDC_DIR                FDC_BASE + 6    /* Digital Input Register */
 #define FDC_CCR                FDC_BASE + 7    /* Configuration Control */
 /* Commands */
-#define FDC_CMD_SENSE_INT              0x08
-#define FDC_CMD_CONFIGURE              0x13
-#define FDC_CMD_SPECIFY                                0x03
-#define FDC_CMD_RECALIBRATE    0x07
-#define FDC_CMD_READ                                   0x06
-#define FDC_CMD_READ_TRACK             0x02
-#define FDC_CMD_READ_ID                                0x0A
-#define FDC_CMD_DUMP_REG                       0x0E
-#define FDC_CMD_SEEK                                   0x0F
-
-#define FDC_CMD_SENSE_INT_LEN          0x01
-#define FDC_CMD_CONFIGURE_LEN          0x04
-#define FDC_CMD_SPECIFY_LEN                            0x03
-#define FDC_CMD_RECALIBRATE_LEN        0x02
-#define FDC_CMD_READ_LEN                                       0x09
-#define FDC_CMD_READ_TRACK_LEN         0x09
-#define FDC_CMD_READ_ID_LEN                            0x02
-#define FDC_CMD_DUMP_REG_LEN                   0x01
-#define FDC_CMD_SEEK_LEN                                       0x03
-
-#define FDC_FIFO_THR                   0x0C
-#define FDC_FIFO_DIS                   0x00
+#define FDC_CMD_SENSE_INT      0x08
+#define FDC_CMD_CONFIGURE      0x13
+#define FDC_CMD_SPECIFY                0x03
+#define FDC_CMD_RECALIBRATE    0x07
+#define FDC_CMD_READ           0x06
+#define FDC_CMD_READ_TRACK     0x02
+#define FDC_CMD_READ_ID                0x0A
+#define FDC_CMD_DUMP_REG       0x0E
+#define FDC_CMD_SEEK           0x0F
+
+#define FDC_CMD_SENSE_INT_LEN  0x01
+#define FDC_CMD_CONFIGURE_LEN  0x04
+#define FDC_CMD_SPECIFY_LEN    0x03
+#define FDC_CMD_RECALIBRATE_LEN        0x02
+#define FDC_CMD_READ_LEN       0x09
+#define FDC_CMD_READ_TRACK_LEN 0x09
+#define FDC_CMD_READ_ID_LEN    0x02
+#define FDC_CMD_DUMP_REG_LEN   0x01
+#define FDC_CMD_SEEK_LEN       0x03
+
+#define FDC_FIFO_THR           0x0C
+#define FDC_FIFO_DIS           0x00
 #define FDC_IMPLIED_SEEK       0x01
-#define FDC_POLL_DIS                   0x00
-#define FDC_PRE_TRK                            0x00
-#define FDC_CONFIGURE                  FDC_FIFO_THR | (FDC_POLL_DIS<<4) | (FDC_FIFO_DIS<<5) | (FDC_IMPLIED_SEEK << 6)
-#define FDC_MFM_MODE                   0x01 /* MFM enable */
-#define FDC_SKIP_MODE                  0x00 /* skip enable */
+#define FDC_POLL_DIS           0x00
+#define FDC_PRE_TRK            0x00
+#define FDC_CONFIGURE          FDC_FIFO_THR | (FDC_POLL_DIS<<4) | (FDC_FIFO_DIS<<5) | (FDC_IMPLIED_SEEK << 6)
+#define FDC_MFM_MODE           0x01 /* MFM enable */
+#define FDC_SKIP_MODE          0x00 /* skip enable */
 
 #define FDC_TIME_OUT 100000 /* time out */
 #define        FDC_RW_RETRIES          3 /* read write retries */
@@ -150,18 +122,18 @@ typedef struct {
 
 /* Disk structure */
 typedef struct  {
-       unsigned int size;                      /* nr of sectors total */
-       unsigned int sect;                      /* sectors per track */
-       unsigned int head;                      /* nr of heads */
-       unsigned int track;                     /* nr of tracks */
-       unsigned int stretch;           /* !=0 means double track steps */
-       unsigned char   gap;                    /* gap1 size */
-       unsigned char   rate;                   /* data rate. |= 0x40 for perpendicular */
-       unsigned char   spec1;          /* stepping rate, head unload time */
-       unsigned char   fmt_gap;        /* gap2 size */
-       unsigned char hlt;                      /* head load time */
-       unsigned char sect_code; /* Sector Size code */
-       const char      * name;                 /* used only for predefined formats */
+       unsigned int size;      /* nr of sectors total */
+       unsigned int sect;      /* sectors per track */
+       unsigned int head;      /* nr of heads */
+       unsigned int track;     /* nr of tracks */
+       unsigned int stretch;   /* !=0 means double track steps */
+       unsigned char   gap;    /* gap1 size */
+       unsigned char   rate;   /* data rate. |= 0x40 for perpendicular */
+       unsigned char   spec1;  /* stepping rate, head unload time */
+       unsigned char   fmt_gap;/* gap2 size */
+       unsigned char hlt;      /* head load time */
+       unsigned char sect_code;/* Sector Size code */
+       const char      * name; /* used only for predefined formats */
 } FD_GEO_STRUCT;
 
 
@@ -174,42 +146,17 @@ const static FD_GEO_STRUCT floppy_type[2] = {
 static FDC_COMMAND_STRUCT cmd; /* global command struct */
 
 /* If the boot drive number is undefined, we assume it's drive 0             */
-#ifndef CFG_FDC_DRIVE_NUMBER
-#define CFG_FDC_DRIVE_NUMBER 0
+#ifndef CONFIG_SYS_FDC_DRIVE_NUMBER
+#define CONFIG_SYS_FDC_DRIVE_NUMBER 0
 #endif
 
 /* Hardware access */
-#ifndef CFG_ISA_IO_STRIDE
-#define CFG_ISA_IO_STRIDE 1
-#endif
-
-#ifndef CFG_ISA_IO_OFFSET
-#define CFG_ISA_IO_OFFSET 0
+#ifndef CONFIG_SYS_ISA_IO_STRIDE
+#define CONFIG_SYS_ISA_IO_STRIDE 1
 #endif
 
-
-#ifdef CONFIG_AMIGAONEG3SE
-unsigned char INT6_Status;
-
-void fdc_interrupt(void)
-{
-    INT6_Status = 0x80;
-}
-
-/* waits for an interrupt (polling) */
-int wait_for_fdc_int(void)
-{
-       unsigned long timeout;
-       timeout = FDC_TIME_OUT;
-       while(((volatile)INT6_Status & 0x80) == 0) {
-               timeout--;
-               udelay(10);
-               if(timeout == 0) /* timeout occured */
-                       return FALSE;
-       }
-       INT6_Status = 0;
-       return TRUE;
-}
+#ifndef CONFIG_SYS_ISA_IO_OFFSET
+#define CONFIG_SYS_ISA_IO_OFFSET 0
 #endif
 
 /* Supporting Functions */
@@ -217,9 +164,9 @@ int wait_for_fdc_int(void)
 unsigned char read_fdc_reg(unsigned int addr)
 {
        volatile unsigned char *val =
-               (volatile unsigned char *)(CFG_ISA_IO_BASE_ADDRESS +
-                                          (addr * CFG_ISA_IO_STRIDE) +
-                                          CFG_ISA_IO_OFFSET);
+               (volatile unsigned char *)(CONFIG_SYS_ISA_IO_BASE_ADDRESS +
+                                          (addr * CONFIG_SYS_ISA_IO_STRIDE) +
+                                          CONFIG_SYS_ISA_IO_OFFSET);
 
        return val [0];
 }
@@ -228,13 +175,12 @@ unsigned char read_fdc_reg(unsigned int addr)
 void write_fdc_reg(unsigned int addr, unsigned char val)
 {
        volatile unsigned char *tmp =
-               (volatile unsigned char *)(CFG_ISA_IO_BASE_ADDRESS +
-                                          (addr * CFG_ISA_IO_STRIDE) +
-                                          CFG_ISA_IO_OFFSET);
+               (volatile unsigned char *)(CONFIG_SYS_ISA_IO_BASE_ADDRESS +
+                                          (addr * CONFIG_SYS_ISA_IO_STRIDE) +
+                                          CONFIG_SYS_ISA_IO_OFFSET);
        tmp[0]=val;
 }
 
-#ifndef CONFIG_AMIGAONEG3SE
 /* waits for an interrupt (polling) */
 int wait_for_fdc_int(void)
 {
@@ -244,13 +190,11 @@ int wait_for_fdc_int(void)
                timeout--;
                udelay(10);
                if(timeout==0) /* timeout occured */
-                       return FALSE;
+                       return false;
        }
-       return TRUE;
+       return true;
 }
 
-#endif
-
 /* reads a byte from the FIFO of the FDC and checks direction and RQM bit
    of the MSR. returns -1 if timeout, or byte if ok */
 int read_fdc_byte(void)
@@ -276,7 +220,7 @@ int fdc_need_more_output(void)
                        c=(unsigned char)read_fdc_byte();
                        printf("Error: more output: %x\n",c);
        }
-       return TRUE;
+       return true;
 }
 
 
@@ -292,10 +236,10 @@ int write_fdc_byte(unsigned char val)
                udelay(10);
                fdc_need_more_output();
                if(timeout==0) /* timeout occured */
-                       return FALSE;
+                       return false;
        }
        write_fdc_reg(FDC_FIFO,val);
-       return TRUE;
+       return true;
 }
 
 /* sets up all FDC commands and issues it to the FDC. If
@@ -342,7 +286,7 @@ int fdc_issue_cmd(FDC_COMMAND_STRUCT *pCMD,FD_GEO_STRUCT *pFG)
                case FDC_CMD_CONFIGURE:
                        pCMD->cmd[CONFIG0]=0;
                        pCMD->cmd[CONFIG1]=FDC_CONFIGURE; /* FIFO Threshold, Poll, Enable FIFO */
-                       pCMD->cmd[CONFIG2]=FDC_PRE_TRK;         /* Precompensation Track */
+                       pCMD->cmd[CONFIG2]=FDC_PRE_TRK; /* Precompensation Track */
                        pCMD->cmdlen=FDC_CMD_CONFIGURE_LEN;
                        pCMD->resultlen=0;  /* no result */
                        break;
@@ -376,9 +320,9 @@ int fdc_issue_cmd(FDC_COMMAND_STRUCT *pCMD,FD_GEO_STRUCT *pFG)
        }
        for(i=0;i<pCMD->cmdlen;i++) {
                /* PRINTF("write cmd%d = 0x%02X\n",i,pCMD->cmd[i]); */
-               if(write_fdc_byte(pCMD->cmd[i])==FALSE) {
+               if (write_fdc_byte(pCMD->cmd[i]) == false) {
                        PRINTF("Error: timeout while issue cmd%d\n",i);
-                       return FALSE;
+                       return false;
                }
        }
        timeout=FDC_TIME_OUT;
@@ -387,12 +331,12 @@ int fdc_issue_cmd(FDC_COMMAND_STRUCT *pCMD,FD_GEO_STRUCT *pFG)
                        timeout--;
                        if(timeout==0) {
                                PRINTF(" timeout while reading result%d MSR=0x%02X\n",i,read_fdc_reg(FDC_MSR));
-                               return FALSE;
+                               return false;
                        }
                }
                pCMD->result[i]=(unsigned char)read_fdc_byte();
        }
-       return TRUE;
+       return true;
 }
 
 /* selects the drive assigned in the cmd structur and
@@ -423,9 +367,10 @@ void stop_fdc_drive(FDC_COMMAND_STRUCT *pCMD)
 int fdc_recalibrate(FDC_COMMAND_STRUCT *pCMD,FD_GEO_STRUCT *pFG)
 {
        pCMD->cmd[COMMAND]=FDC_CMD_RECALIBRATE;
-       if(fdc_issue_cmd(pCMD,pFG)==FALSE)
-               return FALSE;
-       while(wait_for_fdc_int()!=TRUE);
+       if (fdc_issue_cmd(pCMD, pFG) == false)
+               return false;
+       while (wait_for_fdc_int() != true);
+
        pCMD->cmd[COMMAND]=FDC_CMD_SENSE_INT;
        return(fdc_issue_cmd(pCMD,pFG));
 }
@@ -435,14 +380,14 @@ int fdc_recalibrate(FDC_COMMAND_STRUCT *pCMD,FD_GEO_STRUCT *pFG)
 int fdc_seek(FDC_COMMAND_STRUCT *pCMD,FD_GEO_STRUCT *pFG)
 {
        pCMD->cmd[COMMAND]=FDC_CMD_SEEK;
-       if(fdc_issue_cmd(pCMD,pFG)==FALSE)
-               return FALSE;
-       while(wait_for_fdc_int()!=TRUE);
+       if (fdc_issue_cmd(pCMD, pFG) == false)
+               return false;
+       while (wait_for_fdc_int() != true);
+
        pCMD->cmd[COMMAND]=FDC_CMD_SENSE_INT;
        return(fdc_issue_cmd(pCMD,pFG));
 }
 
-#ifndef CONFIG_AMIGAONEG3SE
 /* terminates current command, by not servicing the FIFO
  * waits for interrupt and fills in the result bytes */
 int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
@@ -454,36 +399,15 @@ int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
        for(i=0;i<7;i++) {
                pCMD->result[i]=(unsigned char)read_fdc_byte();
        }
-       return TRUE;
-}
-#endif
-#ifdef CONFIG_AMIGAONEG3SE
-int fdc_terminate(FDC_COMMAND_STRUCT *pCMD)
-{
-       int i;
-       for(i=0;i<100;i++)
-               udelay(500); /* wait 500usec for fifo overrun */
-       while((INT6_Status&0x80)==0x00); /* wait as long as no int has occured */
-       for(i=0;i<7;i++) {
-               pCMD->result[i]=(unsigned char)read_fdc_byte();
-       }
-       INT6_Status = 0;
-       return TRUE;
+       return true;
 }
 
-#endif
-
-#ifdef CONFIG_AMIGAONEG3SE
-#define disable_interrupts() 0
-#define enable_interrupts() (void)0
-#endif
-
 /* reads data from FDC, seek commands are issued automatic */
 int fdc_read_data(unsigned char *buffer, unsigned long blocks,FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
 {
   /* first seek to start address */
-       unsigned long len,lastblk,readblk,i,timeout,ii,offset;
-       unsigned char pcn,c,retriesrw,retriescal;
+       unsigned long len,readblk,i,timeout,ii,offset;
+       unsigned char c,retriesrw,retriescal;
        unsigned char *bufferw; /* working buffer */
        int sect_size;
        int flags;
@@ -494,35 +418,37 @@ int fdc_read_data(unsigned char *buffer, unsigned long blocks,FDC_COMMAND_STRUCT
        retriesrw=0;
        retriescal=0;
        offset=0;
-       if(fdc_seek(pCMD,pFG)==FALSE) {
+       if (fdc_seek(pCMD, pFG) == false) {
                stop_fdc_drive(pCMD);
-               enable_interrupts();
-               return FALSE;
+               if (flags)
+                       enable_interrupts();
+               return false;
        }
        if((pCMD->result[STATUS_0]&0x20)!=0x20) {
                printf("Seek error Status: %02X\n",pCMD->result[STATUS_0]);
                stop_fdc_drive(pCMD);
-               enable_interrupts();
-               return FALSE;
+               if (flags)
+                       enable_interrupts();
+               return false;
        }
-       pcn=pCMD->result[STATUS_PCN]; /* current track */
        /* now determine the next seek point */
-       lastblk=pCMD->blnr + blocks;
+       /*      lastblk=pCMD->blnr + blocks; */
        /*      readblk=(pFG->head*pFG->sect)-(pCMD->blnr%(pFG->head*pFG->sect)); */
        readblk=pFG->sect-(pCMD->blnr%pFG->sect);
        PRINTF("1st nr of block possible read %ld start %ld\n",readblk,pCMD->blnr);
        if(readblk>blocks) /* is end within 1st track */
                readblk=blocks; /* yes, correct it */
        PRINTF("we read %ld blocks start %ld\n",readblk,pCMD->blnr);
-       bufferw=&buffer[0]; /* setup working buffer */
+       bufferw = &buffer[0]; /* setup working buffer */
        do {
 retryrw:
                len=sect_size * readblk;
                pCMD->cmd[COMMAND]=FDC_CMD_READ;
-               if(fdc_issue_cmd(pCMD,pFG)==FALSE) {
+               if (fdc_issue_cmd(pCMD, pFG) == false) {
                        stop_fdc_drive(pCMD);
-                       enable_interrupts();
-                       return FALSE;
+                       if (flags)
+                               enable_interrupts();
+                       return false;
                }
                for (i=0;i<len;i++) {
                        timeout=FDC_TIME_OUT;
@@ -542,15 +468,17 @@ retryrw:
                                        if(retriesrw++>FDC_RW_RETRIES) {
                                                if (retriescal++>FDC_CAL_RETRIES) {
                                                        stop_fdc_drive(pCMD);
-                                                       enable_interrupts();
-                                                       return FALSE;
+                                                       if (flags)
+                                                               enable_interrupts();
+                                                       return false;
                                                }
                                                else {
                                                        PRINTF(" trying to recalibrate Try %d\n",retriescal);
-                                                       if(fdc_recalibrate(pCMD,pFG)==FALSE) {
+                                                       if (fdc_recalibrate(pCMD, pFG) == false) {
                                                                stop_fdc_drive(pCMD);
-                                                               enable_interrupts();
-                                                               return FALSE;
+                                                               if (flags)
+                                                                       enable_interrupts();
+                                                               return false;
                                                        }
                                                        retriesrw=0;
                                                        goto retrycal;
@@ -562,13 +490,13 @@ retryrw:
                                        } /* else >FDC_RW_RETRIES */
                                }/* if output */
                                timeout--;
-                       }while(TRUE);
+                       } while (true);
                } /* for len */
                /* the last sector of a track or all data has been read,
                 * we need to get the results */
                fdc_terminate(pCMD);
                offset+=(sect_size*readblk); /* set up buffer pointer */
-               bufferw=&buffer[offset];
+               bufferw = &buffer[offset];
                pCMD->blnr+=readblk; /* update current block nr */
                blocks-=readblk; /* update blocks */
                if(blocks==0)
@@ -580,28 +508,24 @@ retryrw:
                        readblk=blocks;
 retrycal:
                /* a seek is necessary */
-               if(fdc_seek(pCMD,pFG)==FALSE) {
+               if (fdc_seek(pCMD, pFG) == false) {
                        stop_fdc_drive(pCMD);
-                       enable_interrupts();
-                       return FALSE;
+                       if (flags)
+                               enable_interrupts();
+                       return false;
                }
                if((pCMD->result[STATUS_0]&0x20)!=0x20) {
                        PRINTF("Seek error Status: %02X\n",pCMD->result[STATUS_0]);
                        stop_fdc_drive(pCMD);
-                       return FALSE;
+                       return false;
                }
-               pcn=pCMD->result[STATUS_PCN]; /* current track */
-       }while(TRUE); /* start over */
+       } while (true); /* start over */
        stop_fdc_drive(pCMD); /* switch off drive */
-       enable_interrupts();
-       return TRUE;
+       if (flags)
+               enable_interrupts();
+       return true;
 }
 
-#ifdef CONFIG_AMIGAONEG3SE
-#undef disable_interrupts()
-#undef enable_interrupts()
-#endif
-
 /* Scan all drives and check if drive is present and disk is inserted */
 int fdc_check_drive(FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
 {
@@ -613,20 +537,20 @@ int fdc_check_drive(FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
                pCMD->drive=drives;
                select_fdc_drive(pCMD);
                pCMD->blnr=0; /* set to the 1st block */
-               if(fdc_recalibrate(pCMD,pFG)==FALSE)
+               if (fdc_recalibrate(pCMD, pFG) == false)
                        continue;
                if((pCMD->result[STATUS_0]&0x10)==0x10)
                        continue;
                /* ok drive connected check for disk */
                state|=(1<<drives);
                pCMD->blnr=pFG->size; /* set to the last block */
-               if(fdc_seek(pCMD,pFG)==FALSE)
+               if (fdc_seek(pCMD, pFG) == false)
                        continue;
                pCMD->blnr=0; /* set to the 1st block */
-               if(fdc_recalibrate(pCMD,pFG)==FALSE)
+               if (fdc_recalibrate(pCMD, pFG) == false)
                        continue;
                pCMD->cmd[COMMAND]=FDC_CMD_READ_ID;
-               if(fdc_issue_cmd(pCMD,pFG)==FALSE)
+               if (fdc_issue_cmd(pCMD, pFG) == false)
                        continue;
                state|=(0x10<<drives);
        }
@@ -638,7 +562,7 @@ int fdc_check_drive(FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
                        ((state&(0x10<<i))==(0x10<<i)) ? pFG->name : "");
        }
        pCMD->flags=state;
-       return TRUE;
+       return true;
 }
 
 
@@ -651,12 +575,7 @@ int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
 {
        int i;
 
-#ifdef CONFIG_AMIGAONEG3SE
-       irq_install_handler(6, (interrupt_handler_t *)fdc_interrupt, NULL);
-       i8259_unmask_irq(6);
-#endif
-
-#ifdef CFG_FDC_HW_INIT
+#ifdef CONFIG_SYS_FDC_HW_INIT
        fdc_hw_init ();
 #endif
        /* first, we reset the FDC via the DOR */
@@ -670,9 +589,9 @@ int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
        write_fdc_reg(FDC_CCR,pFG->rate);
        /* then initialize the DSR */
        write_fdc_reg(FDC_DSR,pFG->rate);
-       if(wait_for_fdc_int()==FALSE) {
+       if (wait_for_fdc_int() == false) {
                        PRINTF("Time Out after writing CCR\n");
-                       return FALSE;
+                       return false;
        }
        /* now issue sense Interrupt and status command
         * assuming only one drive present (drive 0) */
@@ -680,7 +599,7 @@ int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
        for(i=0;i<4;i++) {
                /* issue sense interrupt for all 4 possible drives */
                pCMD->cmd[COMMAND]=FDC_CMD_SENSE_INT;
-               if(fdc_issue_cmd(pCMD,pFG)==FALSE) {
+               if (fdc_issue_cmd(pCMD, pFG) == false) {
                        PRINTF("Sense Interrupt for drive %d failed\n",i);
                }
        }
@@ -688,26 +607,25 @@ int fdc_setup(int drive, FDC_COMMAND_STRUCT *pCMD, FD_GEO_STRUCT *pFG)
        pCMD->drive=drive;
        select_fdc_drive(pCMD);
        pCMD->cmd[COMMAND]=FDC_CMD_CONFIGURE;
-       if(fdc_issue_cmd(pCMD,pFG)==FALSE) {
+       if (fdc_issue_cmd(pCMD, pFG) == false) {
                PRINTF(" configure timeout\n");
                stop_fdc_drive(pCMD);
-               return FALSE;
+               return false;
        }
        /* issue specify command */
        pCMD->cmd[COMMAND]=FDC_CMD_SPECIFY;
-       if(fdc_issue_cmd(pCMD,pFG)==FALSE) {
+       if (fdc_issue_cmd(pCMD, pFG) == false) {
                PRINTF(" specify timeout\n");
                stop_fdc_drive(pCMD);
-               return FALSE;
+               return false;
 
        }
        /* then, we clear the reset in the DOR */
        /* fdc_check_drive(pCMD,pFG);   */
        /*      write_fdc_reg(FDC_DOR,0x04); */
 
-       return TRUE;
+       return true;
 }
-#endif
 
 #if defined(CONFIG_CMD_FDOS)
 
@@ -724,30 +642,30 @@ int fdc_fdos_init (int drive)
        FDC_COMMAND_STRUCT *pCMD = &cmd;
 
        /* setup FDC and scan for drives  */
-       if(fdc_setup(drive,pCMD,pFG)==FALSE) {
+       if (fdc_setup(drive, pCMD, pFG) == false) {
                printf("\n** Error in setup FDC **\n");
-               return FALSE;
+               return false;
        }
-       if(fdc_check_drive(pCMD,pFG)==FALSE) {
+       if (fdc_check_drive(pCMD, pFG) == false) {
                printf("\n** Error in check_drives **\n");
-               return FALSE;
+               return false;
        }
        if((pCMD->flags&(1<<drive))==0) {
                /* drive not available */
                printf("\n** Drive %d not available **\n",drive);
-               return FALSE;
+               return false;
        }
        if((pCMD->flags&(0x10<<drive))==0) {
                /* no disk inserted */
                printf("\n** No disk inserted in drive %d **\n",drive);
-               return FALSE;
+               return false;
        }
        /* ok, we have a valid source */
        pCMD->drive=drive;
 
        /* read first block */
        pCMD->blnr=0;
-       return TRUE;
+       return true;
 }
 /**************************************************************************
 * int fdc_fdos_seek
@@ -778,7 +696,7 @@ int fdc_fdos_read (void *buffer, int len)
 /****************************************************************************
  * main routine do_fdcboot
  */
-int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        FD_GEO_STRUCT *pFG = (FD_GEO_STRUCT *)floppy_type;
        FDC_COMMAND_STRUCT *pCMD = &cmd;
@@ -786,32 +704,32 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        image_header_t *hdr;  /* used for fdc boot */
        unsigned char boot_drive;
        int i,nrofblk;
-       char *ep;
-       int rcode = 0;
+#if defined(CONFIG_FIT)
+       const void *fit_hdr = NULL;
+#endif
 
        switch (argc) {
        case 1:
-               addr = CFG_LOAD_ADDR;
-               boot_drive=CFG_FDC_DRIVE_NUMBER;
+               addr = CONFIG_SYS_LOAD_ADDR;
+               boot_drive=CONFIG_SYS_FDC_DRIVE_NUMBER;
                break;
        case 2:
                addr = simple_strtoul(argv[1], NULL, 16);
-               boot_drive=CFG_FDC_DRIVE_NUMBER;
+               boot_drive=CONFIG_SYS_FDC_DRIVE_NUMBER;
                break;
        case 3:
                addr = simple_strtoul(argv[1], NULL, 16);
                boot_drive=simple_strtoul(argv[2], NULL, 10);
                break;
        default:
-               printf ("Usage:\n%s\n", cmdtp->usage);
-               return 1;
+               return CMD_RET_USAGE;
        }
        /* setup FDC and scan for drives  */
-       if(fdc_setup(boot_drive,pCMD,pFG)==FALSE) {
+       if (fdc_setup(boot_drive, pCMD, pFG) == false) {
                printf("\n** Error in setup FDC **\n");
                return 1;
        }
-       if(fdc_check_drive(pCMD,pFG)==FALSE) {
+       if (fdc_check_drive(pCMD, pFG) == false) {
                printf("\n** Error in check_drives **\n");
                return 1;
        }
@@ -829,26 +747,39 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        pCMD->drive=boot_drive;
        /* read first block */
        pCMD->blnr=0;
-       if(fdc_read_data((unsigned char *)addr,1,pCMD,pFG)==FALSE) {
+       if (fdc_read_data((unsigned char *)addr, 1, pCMD, pFG) == false) {
                printf("\nRead error:");
                for(i=0;i<7;i++)
                        printf("result%d: 0x%02X\n",i,pCMD->result[i]);
                return 1;
        }
-       hdr = (image_header_t *)addr;
-       if (!image_check_magic (hdr)) {
-               printf ("Bad Magic Number\n");
+
+       switch (genimg_get_format ((void *)addr)) {
+       case IMAGE_FORMAT_LEGACY:
+               hdr = (image_header_t *)addr;
+               image_print_contents (hdr);
+
+               imsize = image_get_image_size (hdr);
+               break;
+#if defined(CONFIG_FIT)
+       case IMAGE_FORMAT_FIT:
+               fit_hdr = (const void *)addr;
+               puts ("Fit image detected...\n");
+
+               imsize = fit_get_size (fit_hdr);
+               break;
+#endif
+       default:
+               puts ("** Unknown image type\n");
                return 1;
        }
-       image_print_contents (hdr);
 
-       imsize= image_get_image_size (hdr);
        nrofblk=imsize/512;
        if((imsize%512)>0)
                nrofblk++;
        printf("Loading %ld Bytes (%d blocks) at 0x%08lx..\n",imsize,nrofblk,addr);
        pCMD->blnr=0;
-       if(fdc_read_data((unsigned char *)addr,nrofblk,pCMD,pFG)==FALSE) {
+       if (fdc_read_data((unsigned char *)addr, nrofblk, pCMD, pFG) == false) {
                /* read image block */
                printf("\nRead error:");
                for(i=0;i<7;i++)
@@ -858,39 +789,27 @@ int do_fdcboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        printf("OK %ld Bytes loaded.\n",imsize);
 
        flush_cache (addr, imsize);
-       /* Loading ok, update default load address */
-
-       load_addr = addr;
-       if(image_check_type (hdr, IH_TYPE_KERNEL)) {
-               /* Check if we should attempt an auto-start */
-               if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) {
-                       char *local_args[2];
-                       extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
-
-                       local_args[0] = argv[0];
-                       local_args[1] = NULL;
 
-                       printf ("Automatic boot of image at addr 0x%08lX ...\n", addr);
-
-                       do_bootm (cmdtp, 0, 1, local_args);
-                       rcode ++;
+#if defined(CONFIG_FIT)
+       /* This cannot be done earlier, we need complete FIT image in RAM first */
+       if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) {
+               if (!fit_check_format (fit_hdr)) {
+                       puts ("** Bad FIT image format\n");
+                       return 1;
                }
+               fit_print_contents (fit_hdr);
        }
-       return rcode;
-}
-
-
 #endif
 
+       /* Loading ok, update default load address */
+       load_addr = addr;
 
-/***************************************************/
-
-
-#if defined(CONFIG_CMD_FDC)
+       return bootm_maybe_autostart(cmdtp, argv[0]);
+}
 
 U_BOOT_CMD(
        fdcboot,        3,      1,      do_fdcboot,
-       "fdcboot - boot from floppy device\n",
-       "loadAddr drive\n"
+       "boot from floppy device",
+       "loadAddr drive"
 );
 #endif