OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [i960/] [kernel/] [bios32.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1623 jcastillo
/*
2
 * Copyright (C) 1999   Keith Adams     <kma@cse.ogi.edu>
3
 *                      Oregon Graduate Institute
4
 *
5
 * Bios and PCI stuff.
6
 */
7
 
8
#include <linux/pci.h>
9
#include <linux/bios32.h>
10
#include <linux/config.h>
11
#include <linux/kernel.h>
12
#include <asm/system.h>
13
 
14
unsigned long bios32_init(unsigned long memory_start, unsigned long memory_end)
15
{
16
        return memory_start;
17
}
18
 
19
unsigned long pcibios_init(unsigned long memory_start, unsigned long memory_end)
20
{
21
        return memory_start;
22
}
23
 
24
unsigned long pcibios_fixup(unsigned long memory_start, unsigned long memory_end)
25
{
26
        return memory_start;
27
}
28
 
29
#ifdef CONFIG_MON960
30
 
31
#include <asm/mon960.h>
32
 
33
/*
34
 * mon960 system calls for pci management
35
 */
36
extern int mon960_pcibios_present(void* info);
37
extern int mon960_pcibios_find_device(int vendor, int dev, int idx, void* loc);
38
extern int mon960_pcibios_find_class(int class, int idx, void* dev);
39
 
40
int pcibios_present(void)
41
{
42
        return 1;
43
}
44
 
45
int pcibios_find_device(unsigned short vendor, unsigned short dev,
46
                        unsigned short index, unsigned char* bus,
47
                        unsigned char* dev_fn)
48
{
49
        pci_dev_info    loc;
50
        int             status;
51
 
52
        if ((status=mon960_pcibios_find_device(vendor, dev, index, &loc)))
53
                return -1;
54
 
55
        printk("PCI device found: %x, %x, %x\n", loc.bus, loc.dev, loc.fn);
56
        *bus = loc.bus;
57
        *dev_fn = loc.dev;
58
        return 0;
59
}
60
 
61
int pcibios_find_class(unsigned int class, unsigned short idx,
62
                       unsigned char* bus, unsigned char* dev_fn)
63
{
64
        pci_dev_info    loc;
65
        int             status;
66
 
67
        if ((status=mon960_pcibios_find_class(class, idx, &loc)))
68
                return -1;
69
 
70
        *bus = loc.bus;
71
        *dev_fn = loc.dev;
72
        return 0;
73
}
74
 
75
#define CONFIG_RDWR(op,sz,type) \
76
int pcibios_ ## op ## _config_ ## sz(unsigned char bus, unsigned char fn, \
77
                                unsigned char offset, type val) \
78
{       \
79
        return mon960_pcibios_ ## op ## _config_ ## sz(bus, fn, 0, offset, val); \
80
}
81
 
82
CONFIG_RDWR(read,byte,unsigned char*);
83
CONFIG_RDWR(read,word,unsigned short*);
84
CONFIG_RDWR(read,dword,unsigned int*);
85
CONFIG_RDWR(write,byte,unsigned char);
86
CONFIG_RDWR(write,word,unsigned short);
87
CONFIG_RDWR(write,dword,unsigned int);
88
 
89
#endif  /* CONFIG_MON960 */
90
 
91
/*
92
 * Dealing with the ATU. We just do all accesses translated; checking
93
 * whether we can directly use the address might not be any faster.
94
 */
95
 
96
/* external address = (local address & 0x03ffffff) | ATU_OMWVR */
97
#define OIOW_BASE       0x90000000UL    /* outbound I/O space window */
98
#define ATU_OIOWVR      ((unsigned long*) 0x125c)       /* I/O window val */
99
 
100
/* Set up ATU, return local address to use */
101
static unsigned long program_atu(unsigned long pciaddr)
102
{
103
        unsigned long retval;
104
        unsigned long pci_hibits = pciaddr & 0xfc000000;
105
        *ATU_OIOWVR = pci_hibits;
106
        retval = (pciaddr & 0x03ffffff) | OIOW_BASE;
107
        return retval;
108
}
109
 
110
/* Note that we synchronize ATU access with the ipl.
111
 *
112
 * XXX: diddling the ipl every time seems to be a performance problem. Is
113
 * there any way to use the i960 hardware in just one memory op, instead of
114
 * two?
115
 */
116
 
117
#define READ_OP(type,name)      \
118
type name(char* addr)   \
119
{       \
120
        volatile type *local_addr;      \
121
        type retval;    \
122
        unsigned long oldatu = *ATU_OIOWVR;     \
123
        local_addr = (volatile type*)   \
124
                program_atu((unsigned long)addr);       \
125
        retval = *local_addr;   \
126
        *ATU_OIOWVR = oldatu;   \
127
        return retval;  \
128
}
129
READ_OP(unsigned char,readb)
130
READ_OP(unsigned short,readw)
131
READ_OP(unsigned int,readl)
132
#undef READ_OP
133
 
134
#define WRITE_OP(type,name)     \
135
type name(type val, char* addr) \
136
{       \
137
        volatile type *local_addr;      \
138
        type retval;    \
139
        unsigned long oldatu = *ATU_OIOWVR;     \
140
        local_addr = (volatile type*)   \
141
                program_atu((unsigned long)addr);       \
142
        retval = *local_addr = val;     \
143
        *ATU_OIOWVR = oldatu;   \
144
        return retval;  \
145
}
146
WRITE_OP(unsigned char,writeb)
147
WRITE_OP(unsigned short,writew)
148
WRITE_OP(unsigned int,writel)
149
#undef WRITE_OP

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.