c8e682014c0917ab4c5530416fe05a6198923531
[openwrt/staging/lynxis/omap.git] / target / linux / rb532 / patches-2.6.27 / 005-pata_rb532_cf_4bytes_rw.patch
1 * rename the offset definition to avoid abiguity with the standard ATA
2 IO address
3 * read and write four bytes at once like the original driver does
4 * use writesl() and readsl() which implicitly iterate over the data
5
6 This patch assumes buflen to be a multiple of four, which is true for
7 ATA devices. ATAPI support is not known, though unlikely, as the
8 original driver always transfers 512 Bytes at once.
9
10 Signed-off-by: Phil Sutter <n0-1@freewrt.org>
11 Acked-by: Sergei Shtyltov <sshtylyov@ru.mvista.com>
12 ---
13 drivers/ata/pata_rb532_cf.c | 20 +++++++++-----------
14 1 files changed, 9 insertions(+), 11 deletions(-)
15
16 diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
17 index 7b11f40..b919012 100644
18 --- a/drivers/ata/pata_rb532_cf.c
19 +++ b/drivers/ata/pata_rb532_cf.c
20 @@ -43,7 +43,8 @@
21 #define RB500_CF_REG_BASE 0x0800
22 #define RB500_CF_REG_ERR 0x080D
23 #define RB500_CF_REG_CTRL 0x080E
24 -#define RB500_CF_REG_DATA 0x0C00
25 +/* 32bit buffered data register offset */
26 +#define RB500_CF_REG_DBUF32 0x0C00
27
28 struct rb532_cf_info {
29 void __iomem *iobase;
30 @@ -74,19 +75,16 @@ static void rb532_pata_exec_command(struct ata_port *ap,
31 rb532_pata_finish_io(ap);
32 }
33
34 -static void rb532_pata_data_xfer(struct ata_device *adev, unsigned char *buf,
35 - unsigned int buflen, int write_data)
36 +static void rb532_pata_data_xfer(struct ata_device *adev,
37 + unsigned char *buf, unsigned int buflen, int write_data)
38 {
39 struct ata_port *ap = adev->link->ap;
40 void __iomem *ioaddr = ap->ioaddr.data_addr;
41
42 - if (write_data) {
43 - for (; buflen > 0; buflen--, buf++)
44 - writeb(*buf, ioaddr);
45 - } else {
46 - for (; buflen > 0; buflen--, buf++)
47 - *buf = readb(ioaddr);
48 - }
49 + if (write_data)
50 + writesl(ioaddr, buf, buflen / sizeof(u32));
51 + else
52 + readsl(ioaddr, buf, buflen / sizeof(u32));
53
54 rb532_pata_finish_io(adev->link->ap);
55 }
56 @@ -156,7 +154,7 @@ static void rb532_pata_setup_ports(struct ata_host *ah)
57
58 ata_sff_std_ports(&ap->ioaddr);
59
60 - ap->ioaddr.data_addr = info->iobase + RB500_CF_REG_DATA;
61 + ap->ioaddr.data_addr = info->iobase + RB500_CF_REG_DBUF32;
62 ap->ioaddr.error_addr = info->iobase + RB500_CF_REG_ERR;
63 }
64
65 --
66 1.5.6.4
67
68