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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [m68k/] [mvme16x/] [config.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  arch/m68k/mvme16x/config.c
3
 *
4
 *  Copyright (C) 1995 Richard Hirst [richard@sleepie.demon.co.uk]
5
 *
6
 * Based on:
7
 *
8
 *  linux/amiga/config.c
9
 *
10
 *  Copyright (C) 1993 Hamish Macdonald
11
 *
12
 * This file is subject to the terms and conditions of the GNU General Public
13
 * License.  See the file README.legal in the main directory of this archive
14
 * for more details.
15
 */
16
 
17
#include <linux/types.h>
18
#include <linux/kernel.h>
19
#include <linux/mm.h>
20
#include <linux/tty.h>
21
#include <linux/console.h>
22
#include <linux/linkage.h>
23
#include <linux/init.h>
24
#include <linux/major.h>
25
 
26
#include <asm/bootinfo.h>
27
#include <asm/system.h>
28
#include <asm/pgtable.h>
29
#include <asm/setup.h>
30
#include <asm/irq.h>
31
#include <asm/traps.h>
32
#include <asm/rtc.h>
33
#include <asm/machdep.h>
34
#include <asm/mvme16xhw.h>
35
 
36
extern t_bdid mvme_bdid;
37
 
38
static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE;
39
 
40
extern void mvme16x_process_int (int level, struct pt_regs *regs);
41
extern void mvme16x_init_IRQ (void);
42
extern void mvme16x_free_irq (unsigned int, void *);
43
extern int  mvme16x_get_irq_list (char *);
44
extern void mvme16x_enable_irq (unsigned int);
45
extern void mvme16x_disable_irq (unsigned int);
46
static void mvme16x_get_model(char *model);
47
static int  mvme16x_get_hardware_list(char *buffer);
48
extern int  mvme16x_request_irq(unsigned int irq, void (*handler)(int, void *, struct pt_regs *), unsigned long flags, const char *devname, void *dev_id);
49
extern void mvme16x_sched_init(void (*handler)(int, void *, struct pt_regs *));
50
extern int  mvme16x_keyb_init(void);
51
extern int  mvme16x_kbdrate (struct kbd_repeat *);
52
extern unsigned long mvme16x_gettimeoffset (void);
53
extern void mvme16x_gettod (int *year, int *mon, int *day, int *hour,
54
                           int *min, int *sec);
55
extern int mvme16x_hwclk (int, struct rtc_time *);
56
extern int mvme16x_set_clock_mmss (unsigned long);
57
extern void mvme16x_check_partition (struct gendisk *hd, unsigned int dev);
58
extern void mvme16x_mksound( unsigned int count, unsigned int ticks );
59
extern void mvme16x_reset (void);
60
extern void mvme16x_waitbut(void);
61
 
62
int bcd2int (unsigned char b);
63
 
64
/* Save tick handler routine pointer, will point to do_timer() in
65
 * kernel/sched.c, called via mvme16x_process_int() */
66
 
67
static void (*tick_handler)(int, void *, struct pt_regs *);
68
 
69
 
70
unsigned short mvme16x_config;
71
 
72
 
73
int mvme16x_parse_bootinfo(const struct bi_record *bi)
74
{
75
        if (bi->tag == BI_VME_TYPE || bi->tag == BI_VME_BRDINFO)
76
                return 0;
77
        else
78
                return 1;
79
}
80
 
81
int mvme16x_kbdrate (struct kbd_repeat *k)
82
{
83
        return 0;
84
}
85
 
86
void mvme16x_mksound( unsigned int count, unsigned int ticks )
87
{
88
}
89
 
90
void mvme16x_reset()
91
{
92
        printk ("\r\n\nCalled mvme16x_reset\r\n"
93
                        "\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r");
94
        /* The string of returns is to delay the reset until the whole
95
         * message is output.  Assert reset bit in GCSR */
96
        *(volatile char *)0xfff40107 = 0x80;
97
}
98
 
99
static void mvme16x_get_model(char *model)
100
{
101
    p_bdid p = &mvme_bdid;
102
    char suf[4];
103
 
104
    suf[1] = p->brdsuffix[0];
105
    suf[2] = p->brdsuffix[1];
106
    suf[3] = '\0';
107
    suf[0] = suf[1] ? '-' : '\0';
108
 
109
    sprintf(model, "Motorola MVME%x%s", p->brdno, suf);
110
}
111
 
112
 
113
static int mvme16x_get_hardware_list(char *buffer)
114
{
115
    p_bdid p = &mvme_bdid;
116
    int len = 0;
117
 
118
    if (p->brdno == 0x0162 || p->brdno == 0x0172)
119
    {
120
        unsigned char rev = *(unsigned char *)MVME162_VERSION_REG;
121
 
122
        len += sprintf (buffer+len, "VMEchip2        %spresent\n",
123
                        rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : "");
124
        len += sprintf (buffer+len, "SCSI interface  %spresent\n",
125
                        rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : "");
126
        len += sprintf (buffer+len, "Ethernet i/f    %spresent\n",
127
                        rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : "");
128
    }
129
    else
130
        *buffer = '\0';
131
 
132
    return (len);
133
}
134
 
135
 
136
#define pcc2chip        ((volatile u_char *)0xfff42000)
137
#define PccSCCMICR      0x1d
138
#define PccSCCTICR      0x1e
139
#define PccSCCRICR      0x1f
140
 
141
void __init config_mvme16x(void)
142
{
143
    p_bdid p = &mvme_bdid;
144
    char id[40];
145
 
146
    mach_max_dma_address = 0xffffffff;
147
    mach_sched_init      = mvme16x_sched_init;
148
#ifdef CONFIG_VT
149
    mach_keyb_init       = mvme16x_keyb_init;
150
    mach_kbdrate         = mvme16x_kbdrate;
151
/*  kd_mksound           = mvme16x_mksound; */
152
#endif
153
    mach_init_IRQ        = mvme16x_init_IRQ;
154
    mach_gettimeoffset   = mvme16x_gettimeoffset;
155
    mach_gettod          = mvme16x_gettod;
156
    mach_hwclk           = mvme16x_hwclk;
157
    mach_set_clock_mmss  = mvme16x_set_clock_mmss;
158
    mach_reset           = mvme16x_reset;
159
    mach_free_irq        = mvme16x_free_irq;
160
    mach_process_int     = mvme16x_process_int;
161
    mach_get_irq_list    = mvme16x_get_irq_list;
162
    mach_request_irq     = mvme16x_request_irq;
163
    enable_irq           = mvme16x_enable_irq;
164
    disable_irq          = mvme16x_disable_irq;
165
    mach_get_model       = mvme16x_get_model;
166
    mach_get_hardware_list = mvme16x_get_hardware_list;
167
 
168
    /* Report board revision */
169
 
170
    if (strncmp("BDID", p->bdid, 4))
171
    {
172
        printk ("\n\nBug call .BRD_ID returned garbage - giving up\n\n");
173
        while (1)
174
                ;
175
    }
176
    /* Board type is only set by newer versions of vmelilo/tftplilo */
177
    if (vme_brdtype == 0)
178
        vme_brdtype = p->brdno;
179
 
180
    mvme16x_get_model(id);
181
    printk ("\nBRD_ID: %s   BUG %x.%x %02x/%02x/%02x\n", id, p->rev>>4,
182
                                        p->rev&0xf, p->yr, p->mth, p->day);
183
    if (p->brdno == 0x0162 || p->brdno == 0x172)
184
    {
185
        unsigned char rev = *(unsigned char *)MVME162_VERSION_REG;
186
 
187
        mvme16x_config = rev | MVME16x_CONFIG_GOT_SCCA;
188
 
189
        printk ("MVME%x Hardware status:\n", p->brdno);
190
        printk ("    CPU Type           68%s040\n",
191
                        rev & MVME16x_CONFIG_GOT_FPU ? "" : "LC");
192
        printk ("    CPU clock          %dMHz\n",
193
                        rev & MVME16x_CONFIG_SPEED_32 ? 32 : 25);
194
        printk ("    VMEchip2           %spresent\n",
195
                        rev & MVME16x_CONFIG_NO_VMECHIP2 ? "NOT " : "");
196
        printk ("    SCSI interface     %spresent\n",
197
                        rev & MVME16x_CONFIG_NO_SCSICHIP ? "NOT " : "");
198
        printk ("    Ethernet interface %spresent\n",
199
                        rev & MVME16x_CONFIG_NO_ETHERNET ? "NOT " : "");
200
    }
201
    else
202
    {
203
        mvme16x_config = MVME16x_CONFIG_GOT_LP | MVME16x_CONFIG_GOT_CD2401;
204
 
205
        /* Dont allow any interrupts from the CD2401 until the interrupt */
206
        /* handlers are installed                                        */
207
 
208
        pcc2chip[PccSCCMICR] = 0x10;
209
        pcc2chip[PccSCCTICR] = 0x10;
210
        pcc2chip[PccSCCRICR] = 0x10;
211
    }
212
}
213
 
214
static void mvme16x_abort_int (int irq, void *dev_id, struct pt_regs *fp)
215
{
216
        p_bdid p = &mvme_bdid;
217
        unsigned long *new = (unsigned long *)vectors;
218
        unsigned long *old = (unsigned long *)0xffe00000;
219
        volatile unsigned char uc, *ucp;
220
 
221
        if (p->brdno == 0x0162 || p->brdno == 0x172)
222
        {
223
                ucp = (volatile unsigned char *)0xfff42043;
224
                uc = *ucp | 8;
225
                *ucp = uc;
226
        }
227
        else
228
        {
229
                *(volatile unsigned long *)0xfff40074 = 0x40000000;
230
        }
231
        *(new+4) = *(old+4);            /* Illegal instruction */
232
        *(new+9) = *(old+9);            /* Trace */
233
        *(new+47) = *(old+47);          /* Trap #15 */
234
 
235
        if (p->brdno == 0x0162 || p->brdno == 0x172)
236
                *(new+0x5e) = *(old+0x5e);      /* ABORT switch */
237
        else
238
                *(new+0x6e) = *(old+0x6e);      /* ABORT switch */
239
}
240
 
241
static void mvme16x_timer_int (int irq, void *dev_id, struct pt_regs *fp)
242
{
243
    *(volatile unsigned char *)0xfff4201b |= 8;
244
    tick_handler(irq, dev_id, fp);
245
}
246
 
247
void mvme16x_sched_init (void (*timer_routine)(int, void *, struct pt_regs *))
248
{
249
    p_bdid p = &mvme_bdid;
250
    int irq;
251
 
252
    tick_handler = timer_routine;
253
    /* Using PCCchip2 or MC2 chip tick timer 1 */
254
    *(volatile unsigned long *)0xfff42008 = 0;
255
    *(volatile unsigned long *)0xfff42004 = 10000;      /* 10ms */
256
    *(volatile unsigned char *)0xfff42017 |= 3;
257
    *(volatile unsigned char *)0xfff4201b = 0x16;
258
    if (request_irq(MVME16x_IRQ_TIMER, mvme16x_timer_int, 0,
259
                                "timer", mvme16x_timer_int))
260
        panic ("Couldn't register timer int");
261
 
262
    if (p->brdno == 0x0162 || p->brdno == 0x172)
263
        irq = MVME162_IRQ_ABORT;
264
    else
265
        irq = MVME167_IRQ_ABORT;
266
    if (request_irq(irq, mvme16x_abort_int, 0,
267
                                "abort", mvme16x_abort_int))
268
        panic ("Couldn't register abort int");
269
}
270
 
271
 
272
/* This is always executed with interrupts disabled.  */
273
unsigned long mvme16x_gettimeoffset (void)
274
{
275
    return (*(volatile unsigned long *)0xfff42008);
276
}
277
 
278
extern void mvme16x_gettod (int *year, int *mon, int *day, int *hour,
279
                           int *min, int *sec)
280
{
281
        rtc->ctrl = RTC_READ;
282
        *year = bcd2int (rtc->bcd_year);
283
        *mon = bcd2int (rtc->bcd_mth);
284
        *day = bcd2int (rtc->bcd_dom);
285
        *hour = bcd2int (rtc->bcd_hr);
286
        *min = bcd2int (rtc->bcd_min);
287
        *sec = bcd2int (rtc->bcd_sec);
288
        rtc->ctrl = 0;
289
}
290
 
291
int bcd2int (unsigned char b)
292
{
293
        return ((b>>4)*10 + (b&15));
294
}
295
 
296
int mvme16x_hwclk(int op, struct rtc_time *t)
297
{
298
        return 0;
299
}
300
 
301
int mvme16x_set_clock_mmss (unsigned long nowtime)
302
{
303
        return 0;
304
}
305
 
306
int mvme16x_keyb_init (void)
307
{
308
        return 0;
309
}
310
 

powered by: WebSVN 2.1.0

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