[U-Boot] [PATCH] cmd_ide: Convert to [read,write][b,w]

Signed-off-by: Marek Vasut marek.vasut@gmail.com --- common/cmd_ide.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 093ca9f..9c4b250 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -161,8 +161,8 @@ static uchar ide_wait (int dev, ulong t);
#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, ulong *sect_buf, int words); +static void input_data(int dev, uint16_t *sect_buf, int words); +static void output_data(int dev, uint16_t *sect_buf, int words); static void ident_cpy (unsigned char *dest, unsigned char *src, unsigned int len);
#ifndef CONFIG_SYS_ATA_PORT_ADDR @@ -526,7 +526,7 @@ __ide_outb(int dev, int port, unsigned char val) { debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n", dev, port, val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); - outb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); + writeb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); } void ide_outb (int dev, int port, unsigned char val) __attribute__((weak, alias("__ide_outb"))); @@ -535,7 +535,7 @@ unsigned char inline __ide_inb(int dev, int port) { uchar val; - val = inb((ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); + val = readb((ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port))); debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n", dev, port, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)), val); return val; @@ -937,9 +937,11 @@ output_data(int dev, ulong *sect_buf, int words) } #else /* ! __PPC__ */ static void -output_data(int dev, ulong *sect_buf, int words) +output_data(int dev, uint16_t *sect_buf, int words) { - outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words<<1); + int i; + for (i = 0; i < (words << 1); i++) + writew(sect_buf[i], ATA_CURR_BASE(dev)+ATA_DATA_REG); } #endif /* __PPC__ */
@@ -995,9 +997,11 @@ input_data(int dev, ulong *sect_buf, int words) } #else /* ! __PPC__ */ static void -input_data(int dev, ulong *sect_buf, int words) +input_data(int dev, uint16_t *sect_buf, int words) { - insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1); + int i; + for (i = 0; i < (words << 1); i++) + sect_buf[i] = readw(ATA_CURR_BASE(dev)+ATA_DATA_REG); }
#endif /* __PPC__ */ @@ -1115,7 +1119,7 @@ static void ide_ident (block_dev_desc_t *dev_desc) return; #endif
- input_swap_data (device, iobuf, ATA_SECTORWORDS); + input_swap_data (device, (uint16_t *)iobuf, ATA_SECTORWORDS);
ident_cpy ((unsigned char*)dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision)); ident_cpy ((unsigned char*)dev_desc->vendor, iop->model, sizeof(dev_desc->vendor));

Dear Marek Vasut,
In message 1277320683-2057-1-git-send-email-marek.vasut@gmail.com you wrote:
Signed-off-by: Marek Vasut marek.vasut@gmail.com
common/cmd_ide.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
I don't see the big advantage of this patch yet.
#ifndef CONFIG_SYS_ATA_PORT_ADDR @@ -526,7 +526,7 @@ __ide_outb(int dev, int port, unsigned char val) { debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n", dev, port, val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
- outb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
- writeb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
So we replace outb() => writeb(), but the function where this is used is still __ide_outb() ?
The __ide_outb() => outb() mapping looks more logical to me.
-output_data(int dev, ulong *sect_buf, int words) +output_data(int dev, uint16_t *sect_buf, int words) {
- outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words<<1);
- int i;
- for (i = 0; i < (words << 1); i++)
writew(sect_buf[i], ATA_CURR_BASE(dev)+ATA_DATA_REG);
And here the code size is growing, too.
What are the exact advantages of your version?
Best regards,
Wolfgang Denk

Dne St 23. června 2010 22:51:28 Wolfgang Denk napsal(a):
Dear Marek Vasut,
In message 1277320683-2057-1-git-send-email-marek.vasut@gmail.com you wrote:
Signed-off-by: Marek Vasut marek.vasut@gmail.com
common/cmd_ide.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
I don't see the big advantage of this patch yet.
It won't compile at least on ARM. Same case as with the dm9000 ethernet adapter.
#ifndef CONFIG_SYS_ATA_PORT_ADDR
@@ -526,7 +526,7 @@ __ide_outb(int dev, int port, unsigned char val)
{
debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
dev, port, val,
(ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
- outb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
- writeb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
So we replace outb() => writeb(), but the function where this is used is still __ide_outb() ?
The __ide_outb() => outb() mapping looks more logical to me.
See above.
-output_data(int dev, ulong *sect_buf, int words) +output_data(int dev, uint16_t *sect_buf, int words)
{
- outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words<<1);
- int i;
- for (i = 0; i < (words << 1); i++)
writew(sect_buf[i], ATA_CURR_BASE(dev)+ATA_DATA_REG);
And here the code size is growing, too.
Possibly, I was unsure if there is some implementation of writesw/readsw elsewhere then on PPC.
What are the exact advantages of your version?
That it actually compiles and works on other architectures than ppc.
Best regards,
Wolfgang Denk
Cheers

Dne Čt 24. června 2010 02:36:00 Marek Vasut napsal(a):
Dne St 23. června 2010 22:51:28 Wolfgang Denk napsal(a):
Dear Marek Vasut,
In message 1277320683-2057-1-git-send-email-marek.vasut@gmail.com you
wrote:
Signed-off-by: Marek Vasut marek.vasut@gmail.com
common/cmd_ide.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
I don't see the big advantage of this patch yet.
It won't compile at least on ARM. Same case as with the dm9000 ethernet adapter.
#ifndef CONFIG_SYS_ATA_PORT_ADDR
@@ -526,7 +526,7 @@ __ide_outb(int dev, int port, unsigned char val)
{
debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
dev, port, val,
(ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
- outb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
- writeb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
So we replace outb() => writeb(), but the function where this is used is still __ide_outb() ?
The __ide_outb() => outb() mapping looks more logical to me.
See above.
-output_data(int dev, ulong *sect_buf, int words) +output_data(int dev, uint16_t *sect_buf, int words)
{
- outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words<<1);
- int i;
- for (i = 0; i < (words << 1); i++)
writew(sect_buf[i], ATA_CURR_BASE(dev)+ATA_DATA_REG);
And here the code size is growing, too.
Possibly, I was unsure if there is some implementation of writesw/readsw elsewhere then on PPC.
What are the exact advantages of your version?
That it actually compiles and works on other architectures than ppc.
Best regards,
Wolfgang Denk
Cheers
Any updates ?

Le 01/07/2010 02:09, Marek Vasut a écrit :
common/cmd_ide.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
I don't see the big advantage of this patch yet.
It won't compile at least on ARM. Same case as with the dm9000 ethernet adapter.
What are the exact advantages of your version?
That it actually compiles and works on other architectures than ppc.
Any updates ?
Actually I've compiled cmd_ide.c for ARM -- I just sent a patchset for this. Required me to #define __io in my board's config, and also to #define CONFIG_IDE_SWAP_IO, a new configuration option which replaces the complex conditionals on __PPC__ et al.
Amicalement,

Dne Čt 1. července 2010 02:44:01 Albert ARIBAUD napsal(a):
Le 01/07/2010 02:09, Marek Vasut a écrit :
common/cmd_ide.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
I don't see the big advantage of this patch yet.
It won't compile at least on ARM. Same case as with the dm9000 ethernet adapter.
What are the exact advantages of your version?
That it actually compiles and works on other architectures than ppc.
Any updates ?
Actually I've compiled cmd_ide.c for ARM -- I just sent a patchset for this. Required me to #define __io in my board's config,
Are you really supposed to #define __io in your config ?! I doubt that.
and also to #define CONFIG_IDE_SWAP_IO, a new configuration option which replaces the complex conditionals on __PPC__ et al.
Amicalement,

Dne Čt 1. července 2010 05:33:46 Marek Vasut napsal(a):
Dne Čt 1. července 2010 02:44:01 Albert ARIBAUD napsal(a):
Le 01/07/2010 02:09, Marek Vasut a écrit :
common/cmd_ide.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
I don't see the big advantage of this patch yet.
It won't compile at least on ARM. Same case as with the dm9000 ethernet adapter.
What are the exact advantages of your version?
That it actually compiles and works on other architectures than ppc.
Any updates ?
Actually I've compiled cmd_ide.c for ARM -- I just sent a patchset for this. Required me to #define __io in my board's config,
Are you really supposed to #define __io in your config ?! I doubt that.
Bump? After some discussion with Wolfgang, we figured that'd be the easiest temporary solution actually. But after I tried this approach, I git this problem:
u-boot-pxa/arch/arm/lib/eabi_compat.o -L /usr/lib/gcc/arm-linux-gnueabi/4.4.4 - lgcc -Map u-boot.map -o u-boot common/libcommon.a(cmd_ide.o): In function `output_data': /home/marex/PalmLD/u-boot-pxa/common/cmd_ide.c:904: undefined reference to `__raw_writesw' common/libcommon.a(cmd_ide.o): In function `input_data': /home/marex/PalmLD/u-boot-pxa/common/cmd_ide.c:962: undefined reference to `__raw_readsw' /home/marex/PalmLD/u-boot-pxa/common/cmd_ide.c:962: undefined reference to `__raw_readsw' make: *** [u-boot] Error 1
So arm is missing the implementation of __raw_reads[bwl] etc.
and also to #define CONFIG_IDE_SWAP_IO, a new configuration option which replaces the complex conditionals on __PPC__ et al.
Amicalement,
participants (3)
-
Albert ARIBAUD
-
Marek Vasut
-
Wolfgang Denk