mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-17 20:51:39 +00:00
change all versions of input_data() and output_data() to global weak aliases
This changes input_data() and friends from static function to global symbols under weak alias, to enable board specific overrides (and therefore get rid of board-specific code in cmd_ide.c) Also declare ide_bus_offset in the header file, so other files can use ATA_CURR_BASE as well. Signed-off-by: Pavel Herrmann <morpheus.ibis@gmail.com>
This commit is contained in:
parent
e4148c1165
commit
f5b82c0f9c
5 changed files with 48 additions and 23 deletions
|
@ -30,7 +30,6 @@
|
||||||
#include <ide.h>
|
#include <ide.h>
|
||||||
#include <pci.h>
|
#include <pci.h>
|
||||||
|
|
||||||
extern ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS];
|
|
||||||
int cpci_hd_type;
|
int cpci_hd_type;
|
||||||
|
|
||||||
int ata_device(int dev)
|
int ata_device(int dev)
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#define IT8212_PCI_IdeBusSkewCONTROL 0x4c
|
#define IT8212_PCI_IdeBusSkewCONTROL 0x4c
|
||||||
#define IT8212_PCI_IdeDrivingCURRENT 0x42
|
#define IT8212_PCI_IdeDrivingCURRENT 0x42
|
||||||
|
|
||||||
extern ulong ide_bus_offset[CONFIG_SYS_IDE_MAXBUS];
|
|
||||||
extern struct pci_controller hose;
|
extern struct pci_controller hose;
|
||||||
|
|
||||||
int ide_preinit (void)
|
int ide_preinit (void)
|
||||||
|
|
|
@ -672,7 +672,6 @@ U_BOOT_CMD(
|
||||||
* ( bus per_addr 20 -30 is connectsd on CF bus A10-A0)
|
* ( bus per_addr 20 -30 is connectsd on CF bus A10-A0)
|
||||||
* These values are shifted
|
* These values are shifted
|
||||||
*/
|
*/
|
||||||
extern ulong *ide_bus_offset;
|
|
||||||
void inline ide_outb(int dev, int port, unsigned char val)
|
void inline ide_outb(int dev, int port, unsigned char val)
|
||||||
{
|
{
|
||||||
debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
|
debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
|
||||||
|
|
|
@ -109,8 +109,6 @@ static uchar ide_wait (int dev, ulong t);
|
||||||
|
|
||||||
#define IDE_SPIN_UP_TIME_OUT 5000 /* 5 sec spin-up timeout */
|
#define IDE_SPIN_UP_TIME_OUT 5000 /* 5 sec spin-up timeout */
|
||||||
|
|
||||||
static void input_data(int dev, ulong *sect_buf, int words);
|
|
||||||
static void output_data(int dev, const ulong *sect_buf, int words);
|
|
||||||
static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
|
static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
|
||||||
|
|
||||||
#ifndef CONFIG_SYS_ATA_PORT_ADDR
|
#ifndef CONFIG_SYS_ATA_PORT_ADDR
|
||||||
|
@ -483,12 +481,24 @@ block_dev_desc_t *ide_get_dev(int dev)
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void ide_input_swap_data(int dev, ulong *sect_buf, int words)
|
||||||
|
__attribute__ ((weak, alias("__ide_input_swap_data")));
|
||||||
|
|
||||||
|
void ide_input_data(int dev, ulong *sect_buf, int words)
|
||||||
|
__attribute__ ((weak, alias("__ide_input_data")));
|
||||||
|
|
||||||
|
void ide_output_data(int dev, const ulong *sect_buf, int words)
|
||||||
|
__attribute__ ((weak, alias("__ide_output_data")));
|
||||||
|
|
||||||
/* We only need to swap data if we are running on a big endian cpu. */
|
/* We only need to swap data if we are running on a big endian cpu. */
|
||||||
/* But Au1x00 cpu:s already swaps data in big endian mode! */
|
/* But Au1x00 cpu:s already swaps data in big endian mode! */
|
||||||
#if defined(__LITTLE_ENDIAN) || defined(CONFIG_SOC_AU1X00)
|
#if defined(__LITTLE_ENDIAN) || defined(CONFIG_SOC_AU1X00)
|
||||||
#define input_swap_data(x,y,z) input_data(x,y,z)
|
void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
|
||||||
|
{
|
||||||
|
ide_input_data(dev, sect_buf, words);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
static void input_swap_data(int dev, ulong *sect_buf, int words)
|
void __ide_input_swap_data(int dev, ulong *sect_buf, int words)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_CPC45)
|
#if defined(CONFIG_CPC45)
|
||||||
uchar i;
|
uchar i;
|
||||||
|
@ -531,7 +541,7 @@ static void input_swap_data(int dev, ulong *sect_buf, int words)
|
||||||
|
|
||||||
|
|
||||||
#if defined(CONFIG_IDE_SWAP_IO)
|
#if defined(CONFIG_IDE_SWAP_IO)
|
||||||
static void output_data(int dev, const ulong *sect_buf, int words)
|
void __ide_output_data(int dev, const ulong *sect_buf, int words)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_CPC45)
|
#if defined(CONFIG_CPC45)
|
||||||
uchar *dbuf;
|
uchar *dbuf;
|
||||||
|
@ -574,7 +584,7 @@ static void output_data(int dev, const ulong *sect_buf, int words)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else /* ! CONFIG_IDE_SWAP_IO */
|
#else /* ! CONFIG_IDE_SWAP_IO */
|
||||||
static void output_data(int dev, const ulong *sect_buf, int words)
|
void __ide_output_data(int dev, const ulong *sect_buf, int words)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_IDE_AHB)
|
#if defined(CONFIG_IDE_AHB)
|
||||||
ide_write_data(dev, sect_buf, words);
|
ide_write_data(dev, sect_buf, words);
|
||||||
|
@ -585,7 +595,7 @@ static void output_data(int dev, const ulong *sect_buf, int words)
|
||||||
#endif /* CONFIG_IDE_SWAP_IO */
|
#endif /* CONFIG_IDE_SWAP_IO */
|
||||||
|
|
||||||
#if defined(CONFIG_IDE_SWAP_IO)
|
#if defined(CONFIG_IDE_SWAP_IO)
|
||||||
static void input_data(int dev, ulong *sect_buf, int words)
|
void __ide_input_data(int dev, ulong *sect_buf, int words)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_CPC45)
|
#if defined(CONFIG_CPC45)
|
||||||
uchar *dbuf;
|
uchar *dbuf;
|
||||||
|
@ -634,7 +644,7 @@ static void input_data(int dev, ulong *sect_buf, int words)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else /* ! CONFIG_IDE_SWAP_IO */
|
#else /* ! CONFIG_IDE_SWAP_IO */
|
||||||
static void input_data(int dev, ulong *sect_buf, int words)
|
void __ide_input_data(int dev, ulong *sect_buf, int words)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_IDE_AHB)
|
#if defined(CONFIG_IDE_AHB)
|
||||||
ide_read_data(dev, sect_buf, words);
|
ide_read_data(dev, sect_buf, words);
|
||||||
|
@ -744,7 +754,7 @@ static void ide_ident(block_dev_desc_t *dev_desc)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
input_swap_data(device, (ulong *)&iop, ATA_SECTORWORDS);
|
ide_input_swap_data(device, (ulong *)&iop, ATA_SECTORWORDS);
|
||||||
|
|
||||||
ident_cpy((unsigned char *) dev_desc->revision, iop.fw_rev,
|
ident_cpy((unsigned char *) dev_desc->revision, iop.fw_rev,
|
||||||
sizeof(dev_desc->revision));
|
sizeof(dev_desc->revision));
|
||||||
|
@ -1006,7 +1016,7 @@ ulong ide_read(int device, lbaint_t blknr, ulong blkcnt, void *buffer)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
input_data(device, buffer, ATA_SECTORWORDS);
|
ide_input_data(device, buffer, ATA_SECTORWORDS);
|
||||||
(void) ide_inb(device, ATA_STATUS); /* clear IRQ */
|
(void) ide_inb(device, ATA_STATUS); /* clear IRQ */
|
||||||
|
|
||||||
++n;
|
++n;
|
||||||
|
@ -1099,7 +1109,7 @@ ulong ide_write(int device, lbaint_t blknr, ulong blkcnt, const void *buffer)
|
||||||
goto WR_OUT;
|
goto WR_OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
output_data(device, buffer, ATA_SECTORWORDS);
|
ide_output_data(device, buffer, ATA_SECTORWORDS);
|
||||||
c = ide_inb(device, ATA_STATUS); /* clear IRQ */
|
c = ide_inb(device, ATA_STATUS); /* clear IRQ */
|
||||||
++n;
|
++n;
|
||||||
++blknr;
|
++blknr;
|
||||||
|
@ -1232,10 +1242,17 @@ int ide_device_present(int dev)
|
||||||
* ATAPI Support
|
* ATAPI Support
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
|
||||||
|
__attribute__ ((weak, alias("__ide_input_data_shorts")));
|
||||||
|
|
||||||
|
void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
|
||||||
|
__attribute__ ((weak, alias("__ide_output_data_shorts")));
|
||||||
|
|
||||||
|
|
||||||
#if defined(CONFIG_IDE_SWAP_IO)
|
#if defined(CONFIG_IDE_SWAP_IO)
|
||||||
/* since ATAPI may use commands with not 4 bytes alligned length
|
/* since ATAPI may use commands with not 4 bytes alligned length
|
||||||
* we have our own transfer functions, 2 bytes alligned */
|
* we have our own transfer functions, 2 bytes alligned */
|
||||||
static void output_data_shorts(int dev, ushort *sect_buf, int shorts)
|
void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_CPC45)
|
#if defined(CONFIG_CPC45)
|
||||||
uchar *dbuf;
|
uchar *dbuf;
|
||||||
|
@ -1267,7 +1284,7 @@ static void output_data_shorts(int dev, ushort *sect_buf, int shorts)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void input_data_shorts(int dev, ushort *sect_buf, int shorts)
|
void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_CPC45)
|
#if defined(CONFIG_CPC45)
|
||||||
uchar *dbuf;
|
uchar *dbuf;
|
||||||
|
@ -1300,12 +1317,12 @@ static void input_data_shorts(int dev, ushort *sect_buf, int shorts)
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* ! CONFIG_IDE_SWAP_IO */
|
#else /* ! CONFIG_IDE_SWAP_IO */
|
||||||
static void output_data_shorts(int dev, ushort *sect_buf, int shorts)
|
void __ide_output_data_shorts(int dev, ushort *sect_buf, int shorts)
|
||||||
{
|
{
|
||||||
outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
|
outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void input_data_shorts(int dev, ushort *sect_buf, int shorts)
|
void __ide_input_data_shorts(int dev, ushort *sect_buf, int shorts)
|
||||||
{
|
{
|
||||||
insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
|
insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
|
||||||
}
|
}
|
||||||
|
@ -1384,7 +1401,7 @@ unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write command block */
|
/* write command block */
|
||||||
output_data_shorts(device, (unsigned short *) ccb, ccblen / 2);
|
ide_output_data_shorts(device, (unsigned short *) ccb, ccblen / 2);
|
||||||
|
|
||||||
/* ATAPI Command written wait for completition */
|
/* ATAPI Command written wait for completition */
|
||||||
udelay(5000); /* device must set bsy */
|
udelay(5000); /* device must set bsy */
|
||||||
|
@ -1435,12 +1452,12 @@ unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen,
|
||||||
/* ok now decide if it is an in or output */
|
/* ok now decide if it is an in or output */
|
||||||
if ((ide_inb(device, ATA_SECT_CNT) & 0x02) == 0) {
|
if ((ide_inb(device, ATA_SECT_CNT) & 0x02) == 0) {
|
||||||
debug("Write to device\n");
|
debug("Write to device\n");
|
||||||
output_data_shorts(device, (unsigned short *) buffer,
|
ide_output_data_shorts(device,
|
||||||
n);
|
(unsigned short *) buffer, n);
|
||||||
} else {
|
} else {
|
||||||
debug("Read from device @ %p shorts %d\n", buffer, n);
|
debug("Read from device @ %p shorts %d\n", buffer, n);
|
||||||
input_data_shorts(device, (unsigned short *) buffer,
|
ide_input_data_shorts(device,
|
||||||
n);
|
(unsigned short *) buffer, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
udelay(5000); /* seems that some CD ROMs need this... */
|
udelay(5000); /* seems that some CD ROMs need this... */
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS))
|
#define IDE_BUS(dev) (dev / (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS))
|
||||||
|
|
||||||
#define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
|
#define ATA_CURR_BASE(dev) (CONFIG_SYS_ATA_BASE_ADDR+ide_bus_offset[IDE_BUS(dev)])
|
||||||
|
extern ulong ide_bus_offset[];
|
||||||
|
|
||||||
#ifdef CONFIG_IDE_LED
|
#ifdef CONFIG_IDE_LED
|
||||||
|
|
||||||
|
@ -72,4 +73,14 @@ void ide_write_register(int dev, unsigned int port, unsigned char val);
|
||||||
void ide_read_data(int dev, ulong *sect_buf, int words);
|
void ide_read_data(int dev, ulong *sect_buf, int words);
|
||||||
void ide_write_data(int dev, ulong *sect_buf, int words);
|
void ide_write_data(int dev, ulong *sect_buf, int words);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I/O function overrides
|
||||||
|
*/
|
||||||
|
void ide_input_swap_data(int dev, ulong *sect_buf, int words);
|
||||||
|
void ide_input_data(int dev, ulong *sect_buf, int words);
|
||||||
|
void ide_output_data(int dev, const ulong *sect_buf, int words);
|
||||||
|
void ide_input_data_shorts(int dev, ushort *sect_buf, int shorts);
|
||||||
|
void ide_output_data_shorts(int dev, ushort *sect_buf, int shorts);
|
||||||
|
|
||||||
#endif /* _IDE_H */
|
#endif /* _IDE_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue