Skip to content

Commit d4f07ae

Browse files
Manuel Laussralfbaechle
authored andcommitted
MIPS, IDE: Alchem, au1xxx-ide: Remove pb1200/db1200 header dep
au1xxx-ide uses defines from the pb1200/db1200 headers: get DBDMA ID through platform resource information, hardcode register spacing. The only 2 users of this driver (and the only boards it can really work on realiably) use the same register layout. Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com> Cc: linux-ide@vger.kernel.org To: Linux-MIPS <linux-mips@linux-mips.org> Cc: linux-ide@vger.kernel.org Acked-by: David S. Miller <davem@davemloft.net> Patchwork: https://patchwork.linux-mips.org/patch/2716/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 7517de3 commit d4f07ae

6 files changed

Lines changed: 40 additions & 24 deletions

File tree

‎arch/mips/alchemy/devboards/db1200/platform.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,12 @@ static struct resource db1200_ide_res[] = {
213213
.start = DB1200_IDE_INT,
214214
.end = DB1200_IDE_INT,
215215
.flags = IORESOURCE_IRQ,
216-
}
216+
},
217+
[2] = {
218+
.start = DSCR_CMD0_DMA_REQ1,
219+
.end = DSCR_CMD0_DMA_REQ1,
220+
.flags = IORESOURCE_DMA,
221+
},
217222
};
218223

219224
static u64 ide_dmamask = DMA_BIT_MASK(32);

‎arch/mips/alchemy/devboards/pb1200/platform.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <asm/mach-au1x00/au1xxx.h>
2828
#include <asm/mach-au1x00/au1100_mmc.h>
29+
#include <asm/mach-au1x00/au1xxx_dbdma.h>
2930
#include <asm/mach-db1x00/bcsr.h>
3031

3132
#include "../platform.h"
@@ -115,7 +116,12 @@ static struct resource ide_resources[] = {
115116
.start = IDE_INT,
116117
.end = IDE_INT,
117118
.flags = IORESOURCE_IRQ
118-
}
119+
},
120+
[2] = {
121+
.start = DSCR_CMD0_DMA_REQ1,
122+
.end = DSCR_CMD0_DMA_REQ1,
123+
.flags = IORESOURCE_DMA,
124+
},
119125
};
120126

121127
static u64 ide_dmamask = DMA_BIT_MASK(32);

‎arch/mips/include/asm/mach-au1x00/au1xxx_ide.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ typedef struct {
5858
#endif
5959
int irq;
6060
u32 regbase;
61+
int ddma_id;
6162
} _auide_hwif;
6263

6364
/******************************************************************************/

‎arch/mips/include/asm/mach-db1x00/db1200.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646

4747
#define IDE_PHYS_ADDR 0x18800000
4848
#define IDE_REG_SHIFT 5
49-
#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1
50-
#define IDE_RQSIZE 128
5149

5250
#define DB1200_IDE_PHYS_ADDR IDE_PHYS_ADDR
5351
#define DB1200_IDE_PHYS_LEN (16 << IDE_REG_SHIFT)

‎arch/mips/include/asm/mach-pb1x00/pb1200.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@
7676
#define IDE_REG_SHIFT 5
7777
#define IDE_PHYS_LEN (16 << IDE_REG_SHIFT)
7878
#define IDE_INT PB1200_IDE_INT
79-
#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1
80-
#define IDE_RQSIZE 128
8179

8280
#define NAND_PHYS_ADDR 0x1C000000
8381

‎drivers/ide/au1xxx-ide.c‎

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
#define DRV_NAME "au1200-ide"
4444
#define DRV_AUTHOR "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>"
4545

46+
#ifndef IDE_REG_SHIFT
47+
#define IDE_REG_SHIFT 5
48+
#endif
49+
4650
/* enable the burstmode in the dbdma */
4751
#define IDE_AU1XXX_BURSTMODE 1
4852

@@ -317,10 +321,11 @@ static void auide_ddma_rx_callback(int irq, void *param)
317321
}
318322
#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
319323

320-
static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize, u32 devwidth, u32 flags)
324+
static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize,
325+
u32 devwidth, u32 flags, u32 regbase)
321326
{
322327
dev->dev_id = dev_id;
323-
dev->dev_physaddr = (u32)IDE_PHYS_ADDR;
328+
dev->dev_physaddr = CPHYSADDR(regbase);
324329
dev->dev_intlevel = 0;
325330
dev->dev_intpolarity = 0;
326331
dev->dev_tsize = tsize;
@@ -344,7 +349,7 @@ static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
344349
dbdev_tab_t source_dev_tab, target_dev_tab;
345350
u32 dev_id, tsize, devwidth, flags;
346351

347-
dev_id = IDE_DDMA_REQ;
352+
dev_id = hwif->ddma_id;
348353

349354
tsize = 8; /* 1 */
350355
devwidth = 32; /* 16 */
@@ -356,20 +361,17 @@ static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
356361
#endif
357362

358363
/* setup dev_tab for tx channel */
359-
auide_init_dbdma_dev( &source_dev_tab,
360-
dev_id,
361-
tsize, devwidth, DEV_FLAGS_OUT | flags);
364+
auide_init_dbdma_dev(&source_dev_tab, dev_id, tsize, devwidth,
365+
DEV_FLAGS_OUT | flags, auide->regbase);
362366
auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
363367

364-
auide_init_dbdma_dev( &source_dev_tab,
365-
dev_id,
366-
tsize, devwidth, DEV_FLAGS_IN | flags);
368+
auide_init_dbdma_dev(&source_dev_tab, dev_id, tsize, devwidth,
369+
DEV_FLAGS_IN | flags, auide->regbase);
367370
auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
368371

369372
/* We also need to add a target device for the DMA */
370-
auide_init_dbdma_dev( &target_dev_tab,
371-
(u32)DSCR_CMD0_ALWAYS,
372-
tsize, devwidth, DEV_FLAGS_ANYUSE);
373+
auide_init_dbdma_dev(&target_dev_tab, (u32)DSCR_CMD0_ALWAYS, tsize,
374+
devwidth, DEV_FLAGS_ANYUSE, auide->regbase);
373375
auide->target_dev_id = au1xxx_ddma_add_device(&target_dev_tab);
374376

375377
/* Get a channel for TX */
@@ -411,14 +413,12 @@ static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d)
411413
#endif
412414

413415
/* setup dev_tab for tx channel */
414-
auide_init_dbdma_dev( &source_dev_tab,
415-
(u32)DSCR_CMD0_ALWAYS,
416-
8, 32, DEV_FLAGS_OUT | flags);
416+
auide_init_dbdma_dev(&source_dev_tab, (u32)DSCR_CMD0_ALWAYS, 8, 32,
417+
DEV_FLAGS_OUT | flags, auide->regbase);
417418
auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
418419

419-
auide_init_dbdma_dev( &source_dev_tab,
420-
(u32)DSCR_CMD0_ALWAYS,
421-
8, 32, DEV_FLAGS_IN | flags);
420+
auide_init_dbdma_dev(&source_dev_tab, (u32)DSCR_CMD0_ALWAYS, 8, 32,
421+
DEV_FLAGS_IN | flags, auide->regbase);
422422
auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
423423

424424
/* Get a channel for TX */
@@ -540,6 +540,14 @@ static int au_ide_probe(struct platform_device *dev)
540540
goto out;
541541
}
542542

543+
res = platform_get_resource(dev, IORESOURCE_DMA, 0);
544+
if (!res) {
545+
pr_debug("%s: no DDMA ID resource\n", DRV_NAME);
546+
ret = -ENODEV;
547+
goto out;
548+
}
549+
ahwif->ddma_id = res->start;
550+
543551
memset(&hw, 0, sizeof(hw));
544552
auide_setup_ports(&hw, ahwif);
545553
hw.irq = ahwif->irq;

0 commit comments

Comments
 (0)