Commit f98984cb194bb34dbe1db9429d3b51133af30d07

Authored by Heiko Schocher
1 parent 3e66c07800

IDE: - make ide_inb () and ide_outb () "weak", so boards can

define there own I/O functions.
          (Needed for the pcs440ep board).
        - The default I/O Functions are again 8 Bit accesses.
        - Added CONFIG_CMD_IDE for the pcs440ep Board.

Signed-off-by: Heiko Schocher <hs@denx.de>

Showing 5 changed files with 49 additions and 44 deletions Side-by-side Diff

board/pcs440ep/pcs440ep.c
... ... @@ -30,6 +30,7 @@
30 30 #include <spd_sdram.h>
31 31 #include <status_led.h>
32 32 #include <sha1.h>
  33 +#include <asm/io.h>
33 34  
34 35 DECLARE_GLOBAL_DATA_PTR;
35 36  
... ... @@ -865,6 +866,29 @@
865 866 " -p calculate the SHA1 sum from the U-Boot image in flash and print\n"
866 867 " -c check the U-Boot image in flash\n"
867 868 );
  869 +#endif
  870 +
  871 +#if defined (CONFIG_CMD_IDE)
  872 +/* These addresses need to be shifted one place to the left
  873 + * ( bus per_addr 20 -30 is connectsd on CF bus A10-A0)
  874 + * These values are shifted
  875 + */
  876 +extern ulong *ide_bus_offset;
  877 +void inline ide_outb(int dev, int port, unsigned char val)
  878 +{
  879 + debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
  880 + dev, port, val, (ATA_CURR_BASE(dev)+port));
  881 +
  882 + out_be16((u16 *)(ATA_CURR_BASE(dev)+(port << 1)), val);
  883 +}
  884 +unsigned char inline ide_inb(int dev, int port)
  885 +{
  886 + uchar val;
  887 + val = in_be16((u16 *)(ATA_CURR_BASE(dev)+(port << 1)));
  888 + debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
  889 + dev, port, (ATA_CURR_BASE(dev)+port), val);
  890 + return (val);
  891 +}
868 892 #endif
869 893  
870 894 #ifdef CONFIG_IDE_PREINIT
... ... @@ -31,6 +31,7 @@
31 31 #include <command.h>
32 32 #include <image.h>
33 33 #include <asm/byteorder.h>
  34 +#include <asm/io.h>
34 35  
35 36 #if defined(CONFIG_IDE_8xx_DIRECT) || defined(CONFIG_IDE_PCMCIA)
36 37 # include <pcmcia.h>
... ... @@ -128,8 +129,6 @@
128 129 };
129 130  
130 131  
131   -#define ATA_CURR_BASE(dev) (CFG_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
132   -
133 132 #ifndef CONFIG_AMIGAONEG3SE
134 133 static int ide_bus_ok[CFG_IDE_MAXBUS];
135 134 #else
... ... @@ -172,8 +171,8 @@
172 171  
173 172 #define IDE_SPIN_UP_TIME_OUT 5000 /* 5 sec spin-up timeout */
174 173  
175   -static void __inline__ ide_outb(int dev, int port, unsigned char val);
176   -static unsigned char __inline__ ide_inb(int dev, int port);
  174 +void inline ide_outb(int dev, int port, unsigned char val);
  175 +unsigned char inline ide_inb(int dev, int port);
177 176 static void input_data(int dev, ulong *sect_buf, int words);
178 177 static void output_data(int dev, ulong *sect_buf, int words);
179 178 static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
180 179  
181 180  
182 181  
183 182  
184 183  
185 184  
... ... @@ -805,45 +804,27 @@
805 804  
806 805 /* ------------------------------------------------------------------------- */
807 806  
808   -#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA)
809   -static void __inline__
810   -ide_outb(int dev, int port, unsigned char val)
  807 +void inline
  808 +__ide_outb(int dev, int port, unsigned char val)
811 809 {
812 810 debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
813   - dev, port, val, (ATA_CURR_BASE(dev)+port));
814   -
815   - /* Ensure I/O operations complete */
816   - EIEIO;
817   - *((u16 *)(ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port))) = val;
  811 + dev, port, val, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
  812 + outb(val, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
818 813 }
819   -#else /* ! __PPC__ */
820   -static void __inline__
821   -ide_outb(int dev, int port, unsigned char val)
822   -{
823   - outb(val, ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port));
824   -}
825   -#endif /* __PPC__ */
  814 +void inline ide_outb (int dev, int port, unsigned char val)
  815 + __attribute__((weak, alias("__ide_outb")));
826 816  
827   -
828   -#if defined(__PPC__) || defined(CONFIG_PXA_PCMCIA)
829   -static unsigned char __inline__
830   -ide_inb(int dev, int port)
  817 +unsigned char inline
  818 +__ide_inb(int dev, int port)
831 819 {
832 820 uchar val;
833   - /* Ensure I/O operations complete */
834   - EIEIO;
835   - val = *((u16 *)(ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
  821 + val = inb((ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)));
836 822 debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
837   - dev, port, (ATA_CURR_BASE(dev)+port), val);
838   - return (val);
  823 + dev, port, (ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port)), val);
  824 + return val;
839 825 }
840   -#else /* ! __PPC__ */
841   -static unsigned char __inline__
842   -ide_inb(int dev, int port)
843   -{
844   - return inb(ATA_CURR_BASE(dev)+CFG_ATA_PORT_ADDR(port));
845   -}
846   -#endif /* __PPC__ */
  826 +unsigned char inline ide_inb(int dev, int port)
  827 + __attribute__((weak, alias("__ide_inb")));
847 828  
848 829 #ifdef __PPC__
849 830 # ifdef CONFIG_AMIGAONEG3SE
include/asm-ppc/io.h
... ... @@ -13,6 +13,9 @@
13 13 #define SIO_CONFIG_RA 0x398
14 14 #define SIO_CONFIG_RD 0x399
15 15  
  16 +#ifndef _IO_BASE
  17 +#define _IO_BASE 0
  18 +#endif
16 19  
17 20 #define readb(addr) in_8((volatile u8 *)(addr))
18 21 #define writeb(b,addr) out_8((volatile u8 *)(addr), (b))
include/configs/pcs440ep.h
... ... @@ -266,7 +266,10 @@
266 266 #define CONFIG_CMD_DIAG
267 267 #define CONFIG_CMD_EEPROM
268 268 #define CONFIG_CMD_ELF
  269 +#define CONFIG_CMD_EXT2
  270 +#define CONFIG_CMD_FAT
269 271 #define CONFIG_CMD_I2C
  272 +#define CONFIG_CMD_IDE
270 273 #define CONFIG_CMD_IRQ
271 274 #define CONFIG_CMD_MII
272 275 #define CONFIG_CMD_NET
273 276  
274 277  
... ... @@ -274,12 +277,10 @@
274 277 #define CONFIG_CMD_PCI
275 278 #define CONFIG_CMD_PING
276 279 #define CONFIG_CMD_REGINFO
  280 +#define CONFIG_CMD_REISER
277 281 #define CONFIG_CMD_SDRAM
278   -#define CONFIG_CMD_EXT2
279   -#define CONFIG_CMD_FAT
280 282 #define CONFIG_CMD_USB
281 283  
282   -
283 284 #define CONFIG_SUPPORT_VFAT
284 285  
285 286 /*
... ... @@ -487,12 +488,6 @@
487 488  
488 489 /* Offset for alternate registers */
489 490 #define CFG_ATA_ALT_OFFSET (0x0000)
490   -
491   -/* These addresses need to be shifted one place to the left
492   - * ( bus per_addr 20 -30 is connectsd on CF bus A10-A0)
493   - * These values are shifted
494   - */
495   -#define CFG_ATA_PORT_ADDR(port) ((port) << 1)
496 491  
497 492 #endif /* __CONFIG_H */
... ... @@ -26,6 +26,8 @@
26 26  
27 27 #define IDE_BUS(dev) (dev >> 1)
28 28  
  29 +#define ATA_CURR_BASE(dev) (CFG_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
  30 +
29 31 #ifdef CONFIG_IDE_LED
30 32  
31 33 /*