Linux-2.6.12-rc2
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / sh / drivers / pci / dma-dreamcast.c
1 /*
2 * arch/sh/pci/dma-dreamcast.c
3 *
4 * PCI DMA support for the Sega Dreamcast
5 *
6 * Copyright (C) 2001, 2002 M. R. Brown
7 * Copyright (C) 2002, 2003 Paul Mundt
8 *
9 * This file originally bore the message (with enclosed-$):
10 * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
11 * Dreamcast PCI: Supports SEGA Broadband Adaptor only.
12 *
13 * This file is subject to the terms and conditions of the GNU General Public
14 * License. See the file "COPYING" in the main directory of this archive
15 * for more details.
16 */
17
18 #include <linux/config.h>
19 #include <linux/sched.h>
20 #include <linux/kernel.h>
21 #include <linux/param.h>
22 #include <linux/interrupt.h>
23 #include <linux/init.h>
24 #include <linux/irq.h>
25 #include <linux/pci.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/device.h>
28
29 #include <asm/io.h>
30 #include <asm/irq.h>
31 #include <asm/mach/pci.h>
32
33 static int gapspci_dma_used = 0;
34
35 void *dreamcast_consistent_alloc(struct device *dev, size_t size,
36 dma_addr_t *dma_handle, int flag)
37 {
38 unsigned long buf;
39
40 if (dev && dev->bus != &pci_bus_type)
41 return NULL;
42
43 if (gapspci_dma_used + size > GAPSPCI_DMA_SIZE)
44 return ERR_PTR(-EINVAL);
45
46 buf = GAPSPCI_DMA_BASE + gapspci_dma_used;
47
48 gapspci_dma_used = PAGE_ALIGN(gapspci_dma_used+size);
49
50 *dma_handle = (dma_addr_t)buf;
51
52 buf = P2SEGADDR(buf);
53
54 /* Flush the dcache before we hand off the buffer */
55 dma_cache_wback_inv((void *)buf, size);
56
57 return (void *)buf;
58 }
59
60 int dreamcast_consistent_free(struct device *dev, size_t size,
61 void *vaddr, dma_addr_t dma_handle)
62 {
63 if (dev && dev->bus != &pci_bus_type)
64 return -EINVAL;
65
66 /* XXX */
67 gapspci_dma_used = 0;
68
69 return 0;
70 }
71