summaryrefslogtreecommitdiff
path: root/release/src/linux/linux/arch/mips/jazz/floppy-jazz.c
blob: 906ba72cfcbb416f98223e922de9efda8c8c69ac (plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
 * 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.
 *
 * Low-level floppy stuff for Jazz family machines.
 *
 * Copyright (C) 1998 by Ralf Baechle
 */
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/linkage.h>
#include <linux/types.h>
#include <linux/mm.h>
#include <asm/addrspace.h>
#include <asm/jazz.h>
#include <asm/jazzdma.h>
#include <asm/keyboard.h>
#include <asm/pgtable.h>
#include <asm/floppy.h>

static unsigned char jazz_fd_inb(unsigned int port)
{
	unsigned char c;

	c = *(volatile unsigned char *) port;
	udelay(1);

	return c;
}

static void jazz_fd_outb(unsigned char value, unsigned int port)
{
	*(volatile unsigned char *) port = value;
}

/*
 * How to access the floppy DMA functions.
 */
static void jazz_fd_enable_dma(int channel)
{
	vdma_enable(JAZZ_FLOPPY_DMA);
}

static void jazz_fd_disable_dma(int channel)
{
	vdma_disable(JAZZ_FLOPPY_DMA);
}

static int jazz_fd_request_dma(int channel)
{
	return 0;
}

static void jazz_fd_free_dma(int channel)
{
}

static void jazz_fd_clear_dma_ff(int channel)
{
}

static void jazz_fd_set_dma_mode(int channel, char mode)
{
	vdma_set_mode(JAZZ_FLOPPY_DMA, mode);
}

static void jazz_fd_set_dma_addr(int channel, unsigned int a)
{
	vdma_set_addr(JAZZ_FLOPPY_DMA, vdma_phys2log(PHYSADDR(a)));
}

static void jazz_fd_set_dma_count(int channel, unsigned int count)
{
	vdma_set_count(JAZZ_FLOPPY_DMA, count);
}

static int jazz_fd_get_dma_residue(int channel)
{
	return vdma_get_residue(JAZZ_FLOPPY_DMA);
}

static void jazz_fd_enable_irq(int irq)
{
}

static void jazz_fd_disable_irq(int irq)
{
}

static unsigned long jazz_fd_getfdaddr1(void)
{
	return JAZZ_FDC_BASE;
}

static unsigned long jazz_fd_dma_mem_alloc(unsigned long size)
{
	unsigned long mem;

	mem = __get_dma_pages(GFP_KERNEL, get_order(size));
	if(!mem)
		return 0;
	vdma_alloc(PHYSADDR(mem), size);	

	return mem;
}

static void jazz_fd_dma_mem_free(unsigned long addr,
                                        unsigned long size)
{
	vdma_free(vdma_phys2log(PHYSADDR(addr)));
	free_pages(addr, get_order(size));
}

static unsigned long jazz_fd_drive_type(unsigned long n)
{
	if (n == 0)
		return 4;	/* 3,5", 1.44mb */

	return 0;
}

struct fd_ops jazz_fd_ops = {
	/*
	 * How to access the floppy controller's ports
	 */
	jazz_fd_inb,
	jazz_fd_outb,
	/*
	 * How to access the floppy DMA functions.
	 */
	jazz_fd_enable_dma,
	jazz_fd_disable_dma,
	jazz_fd_request_dma,
	jazz_fd_free_dma,
	jazz_fd_clear_dma_ff,
	jazz_fd_set_dma_mode,
	jazz_fd_set_dma_addr,
	jazz_fd_set_dma_count,
	jazz_fd_get_dma_residue,
	jazz_fd_enable_irq,
	jazz_fd_disable_irq,
	jazz_fd_getfdaddr1,
	jazz_fd_dma_mem_alloc,
	jazz_fd_dma_mem_free,
	jazz_fd_drive_type
};