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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [sh/] [kernel/] [setup_hs7729pci.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* $Id: setup_hs7729pci.c,v 1.1.1.1 2004-04-15 01:17:22 phoenix Exp $
2
 *
3
 * linux/arch/sh/kernel/setup_hs7729pci.c
4
 *
5
 * Copyright (C) 2000  Kazumoto Kojima
6
 *
7
 * Hitachi Semiconductor and Devices HS7729PCI Support.
8
 *
9
 */
10
 
11
#include <linux/config.h>
12
#include <linux/init.h>
13
#include <linux/irq.h>
14
 
15
#include <linux/hdreg.h>
16
#include <linux/ide.h>
17
#include <asm/io.h>
18
#include <asm/hitachi_hs7729pci.h>
19
#include <asm/smc37c93x.h>
20
 
21
static int interrupt_count;
22
static int sevenseg_count;
23
 
24
extern unsigned char aux_device_present;
25
 
26
/*
27
 * Configure the Super I/O chip
28
 */
29
static void __init smsc_config(int index, int data)
30
{
31
        outb_p(index, INDEX_PORT);
32
        outb_p(data, DATA_PORT);
33
}
34
 
35
static void __init init_smsc(void)
36
{
37
        outb_p(CONFIG_ENTER, CONFIG_PORT);
38
        outb_p(CONFIG_ENTER, CONFIG_PORT);
39
 
40
#if defined(CONFIG_BLK_DEV_FD)
41
        /* FDC */
42
        smsc_config(CURRENT_LDN_INDEX, LDN_FDC);
43
        smsc_config(ACTIVATE_INDEX, 0x01);
44
        smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */
45
#endif
46
 
47
#if defined(CONFIG_BLK_DEV_IDE)
48
        /* IDE1 */
49
        smsc_config(CURRENT_LDN_INDEX, LDN_IDE1);
50
        smsc_config(ACTIVATE_INDEX, 0x01);
51
        smsc_config(IRQ_SELECT_INDEX, 14); /* IRQ14 */
52
        smsc_config(IO_BASE_HI_INDEX, 0x01);
53
        smsc_config(IO_BASE_LO_INDEX, 0x70);
54
        smsc_config(0x62, 0x03);
55
        smsc_config(0x63, 0x76);
56
 
57
#if 0
58
#define SMSC_RD(adr) ({ outb(adr, 0x3f0), inb(0x3f1); })
59
 
60
        printk("IDE1 addrs 0x%02x%02x, 0x%02x%02x\n", SMSC_RD(0x60), SMSC_RD(0x61), SMSC_RD(0x62), SMSC_RD(0x63));
61
        printk("IDE1 Reg 0xF0: %02x. IDE1 Reg 0xF1: %02x\n", SMSC_RD(0xf0), SMSC_RD(0xf1));
62
        printk("Power reg: %02x\n", SMSC_RD(0x22));
63
        smsc_config(0x22, 0x3f);
64
        printk("Power reg changed to: %02x\n", SMSC_RD(0x22));
65
#endif         
66
#endif
67
 
68
        /* AUXIO (GPIO): to use IDE1 */
69
        smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO);
70
        smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */
71
        smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */
72
 
73
#if defined(CONFIG_SERIAL)
74
        /* COM1 */
75
        smsc_config(CURRENT_LDN_INDEX, LDN_COM1);
76
        smsc_config(ACTIVATE_INDEX, 0x01);
77
        smsc_config(IO_BASE_HI_INDEX, 0x03);
78
        smsc_config(IO_BASE_LO_INDEX, 0xf8);
79
        smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */
80
 
81
        /* COM2 */
82
        smsc_config(CURRENT_LDN_INDEX, LDN_COM2);
83
        smsc_config(ACTIVATE_INDEX, 0x01);
84
        smsc_config(IO_BASE_HI_INDEX, 0x02);
85
        smsc_config(IO_BASE_LO_INDEX, 0xf8);
86
        smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */
87
#endif
88
 
89
        /* RTC */
90
        smsc_config(CURRENT_LDN_INDEX, LDN_RTC);
91
        smsc_config(ACTIVATE_INDEX, 0x01);
92
        smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */
93
 
94
#if defined(CONFIG_VT)
95
        disable_irq(1);
96
 
97
        /* KBD */
98
        smsc_config(CURRENT_LDN_INDEX, LDN_KBC);
99
        smsc_config(ACTIVATE_INDEX, 0x01);
100
        smsc_config(IRQ_SELECT_INDEX, 1); /* IRQ1 */
101
        smsc_config(IRQ_SELECT_INDEX+2, 12); /* IRQ12 */
102
 
103
        /* Let it probe for PS/2 port. It should find one. */
104
        aux_device_present = 0;
105
#endif
106
 
107
#if defined(CONFIG_PARPORT)
108
        /* PARALLEL */
109
        smsc_config(CURRENT_LDN_INDEX, LDN_PARPORT);
110
        smsc_config(ACTIVATE_INDEX, 0x01);
111
        smsc_config(IO_BASE_HI_INDEX, 0x03);
112
        smsc_config(IO_BASE_LO_INDEX, 0x78);
113
        smsc_config(IRQ_SELECT_INDEX, 5); /* IRQ5 */
114
#endif
115
 
116
        outb_p(CONFIG_EXIT, CONFIG_PORT);
117
}
118
 
119
/*
120
 * Initialize IRQ setting
121
 */
122
void __init init_hs7729pci_IRQ(void)
123
{
124
        /*
125
         * Super I/O (Just mimic PC):
126
         *  0: SD0001
127
         *  1: keyboard
128
         *  3: serial 0
129
         *  4: serial 1
130
         *  5: printer
131
         *  6: floppy
132
         *  8: rtc
133
         * 12: mouse
134
         * 14: ide0
135
         */
136
        ctrl_outw(0x0130, BCR_ILCRA);
137
        ctrl_outw(0x0070, BCR_ILCRB);
138
        ctrl_outw(0x9abc, BCR_ILCRC);
139
        ctrl_outw(0xef84, BCR_ILCRD);
140
        ctrl_outw(0x0506, BCR_ILCRE);
141
        ctrl_outw(0x0002, BCR_ILCRF);
142
        ctrl_outw(0x000d, BCR_ILCRG);
143
 
144
        make_ipr_irq(15, BCR_ILCRA, 3, 0x00); /* IRQ15 */
145
        make_ipr_irq(14, BCR_ILCRA, 2, 0x01); /* IRQ14 */
146
        make_ipr_irq(12, BCR_ILCRA, 1, 0x03); /* IRQ12 */
147
 
148
        make_ipr_irq( 8, BCR_ILCRB, 1, 0x07); /* IRQ8 */
149
 
150
        make_ipr_irq( 6, BCR_ILCRC, 3, 0x09); /* IRQ6 */
151
        make_ipr_irq( 5, BCR_ILCRC, 2, 0x0a); /* IRQ5 */
152
        make_ipr_irq( 4, BCR_ILCRC, 1, 0x0b); /* IRQ4 */
153
        make_ipr_irq( 3, BCR_ILCRC, 0, 0x0c); /* IRQ3 */
154
 
155
        make_ipr_irq( 1, BCR_ILCRD, 3, 0x0e); /* IRQ1 */
156
        make_ipr_irq( 0, BCR_ILCRD, 2, 0x0f); /* PCI_IRQ0 */
157
        make_ipr_irq( 7, BCR_ILCRD, 1, 0x08); /* USB1_IRQ */
158
        make_ipr_irq(11, BCR_ILCRD, 0, 0x04); /* USB2_IRQ */
159
 
160
        make_ipr_irq(10, BCR_ILCRE, 2, 0x05); /* PC_IRQ2 */
161
        make_ipr_irq( 9, BCR_ILCRE, 0, 0x06); /* PC_IRQ1 */
162
 
163
        make_ipr_irq(13, BCR_ILCRF, 0, 0x02); /* SLOT_IRQ5 */
164
 
165
        make_ipr_irq( 2, BCR_ILCRG, 0, 0x0d); /* SLOT_IRQ1 */
166
}
167
 
168
/*
169
 * Initialize the board
170
 */
171
 
172
void __init setup_hs7729pci(void)
173
{
174
        init_smsc();
175
        /* XXX: RTC setting comes here */
176
        interrupt_count = 0;
177
        sevenseg_count = 0;
178
        ctrl_outw(0xffff, PA_LED);
179
        ctrl_outw(0x3f3f, PA_7SEG);
180
}
181
 
182
void debug_interrupt(void)
183
{
184
        ctrl_outw(interrupt_count, PA_LED);
185
        if (interrupt_count == 0xffff)
186
                interrupt_count = 0;
187
        else
188
                interrupt_count++;
189
}
190
 
191
static int sevenseg_data[] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07,
192
                          0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71};
193
 
194
void set_sevenseg(unsigned char val)
195
{
196
        unsigned short data;
197
 
198
        data = sevenseg_data[(val & 0xf0) >> 4] << 8;
199
        data |= sevenseg_data[val & 0x0f];
200
 
201
        ctrl_outw(data, PA_7SEG);
202
}
203
 
204
void debug_sevenseg(void)
205
{
206
        set_sevenseg(sevenseg_count);
207
 
208
        if (sevenseg_count == 0xff)
209
                sevenseg_count = 0;
210
        else
211
                sevenseg_count++;
212
}

powered by: WebSVN 2.1.0

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