File: tyne-c.c

package info (click to toggle)
kernel-source-2.0.32 2.0.32-5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 29,648 kB
  • ctags: 86,850
  • sloc: ansic: 542,141; asm: 26,201; makefile: 3,423; sh: 1,195; perl: 727; tcl: 408; cpp: 277; lisp: 211; awk: 134
file content (122 lines) | stat: -rw-r--r-- 2,371 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * Deskstation Tyne specific C parts
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1994, 1995 by Ralf Baechle
 */
#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <asm/bootinfo.h>
#include <asm/cachectl.h>
#include <asm/dma.h>
#include <asm/io.h>

/*
 * How to access the FDC's registers.
 */
unsigned char deskstation_tyne_fd_inb(unsigned int port)
{
	return inb_p(port);
}

void deskstation_tyne_fd_outb(unsigned char value, unsigned int port)
{
	outb_p(value, port);
}

/*
 * How to access the floppy DMA functions.
 */
void deskstation_tyne_fd_enable_dma(void)
{
	enable_dma(FLOPPY_DMA);
}

void deskstation_tyne_fd_disable_dma(void)
{
	disable_dma(FLOPPY_DMA);
}

int deskstation_tyne_fd_request_dma(void)
{
	return request_dma(FLOPPY_DMA, "floppy");
}

void deskstation_tyne_fd_free_dma(void)
{
	free_dma(FLOPPY_DMA);
}

void deskstation_tyne_fd_clear_dma_ff(void)
{
	clear_dma_ff(FLOPPY_DMA);
}

int deskstation_tyne_fd_set_dma_mode(char mode)
{
	return set_dma_mode(FLOPPY_DMA, mode);
}

void deskstation_tyne_fd_set_dma_addr(unsigned int a)
{
	set_dma_addr(FLOPPY_DMA, addr);
}

void deskstation_tyne_fd_set_dma_count(unsigned int count)
{
	set_dma_count(FLOPPY_DMA, count);
}

int deskstation_tyne_fd_get_dma_residue(void)
{
	return get_dma_residue(FLOPPY_DMA);
}

void deskstation_tyne_fd_enable_irq(void)
{
	enable_irq(FLOPPY_IRQ);
}

void deskstation_tyne_fd_disable_irq(void)
{
	disable_irq(FLOPPY_IRQ);
}

void deskstation_tyne_fd_cacheflush(unsigned char *addr, unsigned int)
{
	sys_cacheflush((void *)addr, size, DCACHE);
}


/*
 * Tiny Tyne DMA buffer allocator
 *
 * Untested for a long time and changed again and again ...
 * Sorry, but no hardware to test ...
 */
static unsigned long allocated;

/*
 * Not very sophisticated, but should suffice for now...
 */
unsigned long deskstation_tyne_dma_alloc(size_t size)
{
	unsigned long ret = allocated;
	allocated += size;
	if (allocated > boot_info.dma_cache_size)
		ret = -1;
	return ret;
}

void deskstation_tyne_dma_init(void)
{
	if (boot_info.machtype != MACH_DESKSTATION_TYNE)
		return;
	allocated = 0;
	printk ("Deskstation Tyne DMA (%luk) buffer initialized.\n",
	        boot_info.dma_cache_size >> 10);
}