2 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
3 * Andreas Heppel <aheppel@sysgo.de>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * Initialisation of the PCI-to-ISA bridge and disabling the BIOS
26 * write protection (for flash) in function 0 of the chip.
27 * Enabling function 1 (IDE controller of the chip.
31 #define CONFIG_ISA_IO 0xFE000000
35 #include <device/pci.h>
36 #include <device/pci_ids.h>
37 #include <console/console.h>
40 void initialise_pic(void);
41 void initialise_dma(void);
44 w83c553_init(struct device *dev)
46 printk_info("Configure W83C553F ISA Bridge (Function 0)\n");
50 * Set ISA memory space NOT SURE ABOUT THIS???
52 reg8 = pci_read_config8(dev, W83C553F_IPADCR);
53 /* 16 MB ISA memory space */
54 reg8 |= (W83C553F_IPADCR_IPATOM4 | W83C553F_IPADCR_IPATOM5 | W83C553F_IPADCR_IPATOM6 | W83C553F_IPADCR_IPATOM7);
55 reg8 &= ~W83C553F_IPADCR_MBE512;
56 pci_write_config8(dev, W83C553F_IPADCR, reg8);
59 * Chip select: switch off BIOS write protection
61 reg8 = pci_read_config8(dev, W83C553F_CSCR);
62 reg8 |= W83C553F_CSCR_UBIOSCSE;
63 reg8 &= ~W83C553F_CSCR_BIOSWP;
64 pci_write_config8(dev, W83C553F_CSCR, reg8);
69 reg8 = W83C553F_ATSCR_P92E | W83C553F_ATSCR_KRCEE;
70 pci_write_config8(dev, W83C553F_CSCR, reg8);
73 * Route IDE interrupts to IRQ 14 & 15 on 8259.
75 pci_write_config8(dev, W83C553F_IDEIRCR, 0x90);
76 pci_write_config16(dev, W83C553F_PCIIRCR, 0xABEF);
79 * Initialise ISA interrupt controller
84 * Initialise DMA controller
89 printk_info("W83C553F configuration complete\n");
92 void initialise_pic(void)
94 outb(W83C553F_PIC1_ICW1, 0x11); /* start init sequence, ICW4 needed */
95 outb(W83C553F_PIC1_ICW2, 0x08); /* base address 00001 */
96 outb(W83C553F_PIC1_ICW3, 0x04); /* slave on IRQ2 */
97 outb(W83C553F_PIC1_ICW4, 0x01); /* x86 mode */
98 outb(W83C553F_PIC1_OCW1, 0xfb); /* enable IRQ 2 */
99 outb(W83C553F_PIC1_ELC, 0xf8); /* all IRQ's edge sensitive */
101 outb(W83C553F_PIC2_ICW1, 0x11); /* start init sequence, ICW4 needed */
102 outb(W83C553F_PIC2_ICW2, 0x08); /* base address 00001 */
103 outb(W83C553F_PIC2_ICW3, 0x02); /* slave ID 2 */
104 outb(W83C553F_PIC2_ICW4, 0x01); /* x86 mode */
105 outb(W83C553F_PIC2_OCW1, 0xff); /* disable all IRQ's */
106 outb(W83C553F_PIC2_ELC, 0xde); /* all IRQ's edge sensitive */
108 outb(W83C553F_TMR1_CMOD, 0x74);
110 outb(W83C553F_PIC2_OCW1, 0x20);
111 outb(W83C553F_PIC1_OCW1, 0x20);
113 outb(W83C553F_PIC2_OCW1, 0x2b);
114 outb(W83C553F_PIC1_OCW1, 0x2b);
117 void initialise_dma(void)
119 unsigned int channel;
120 unsigned int rvalue1, rvalue2;
122 /* perform a H/W reset of the devices */
124 outb(W83C553F_DMA1 + W83C553F_DMA1_MC, 0x00);
125 outw(W83C553F_DMA2 + W83C553F_DMA2_MC, 0x0000);
127 /* initialise all channels to a sane state */
129 for (channel = 0; channel < 4; channel++) {
131 * dependent upon the channel, setup the specifics:
135 * autoinitialize-disable
141 rvalue1 = (W83C553F_MODE_TM_DEMAND|W83C553F_MODE_CH0SEL|W83C553F_MODE_TT_VERIFY);
142 rvalue2 = (W83C553F_MODE_TM_CASCADE|W83C553F_MODE_CH0SEL);
145 rvalue1 = (W83C553F_MODE_TM_DEMAND|W83C553F_MODE_CH1SEL|W83C553F_MODE_TT_VERIFY);
146 rvalue2 = (W83C553F_MODE_TM_DEMAND|W83C553F_MODE_CH1SEL|W83C553F_MODE_TT_VERIFY);
149 rvalue1 = (W83C553F_MODE_TM_DEMAND|W83C553F_MODE_CH2SEL|W83C553F_MODE_TT_VERIFY);
150 rvalue2 = (W83C553F_MODE_TM_DEMAND|W83C553F_MODE_CH2SEL|W83C553F_MODE_TT_VERIFY);
153 rvalue1 = (W83C553F_MODE_TM_DEMAND|W83C553F_MODE_CH3SEL|W83C553F_MODE_TT_VERIFY);
154 rvalue2 = (W83C553F_MODE_TM_DEMAND|W83C553F_MODE_CH3SEL|W83C553F_MODE_TT_VERIFY);
162 /* write to write mode registers */
164 outb(W83C553F_DMA1 + W83C553F_DMA1_WM, rvalue1 & 0xFF);
165 outw(W83C553F_DMA2 + W83C553F_DMA2_WM, rvalue2 & 0x00FF);
168 /* enable all channels */
170 outb(W83C553F_DMA1 + W83C553F_DMA1_CM, 0x00);
171 outw(W83C553F_DMA2 + W83C553F_DMA2_CM, 0x0000);
173 * initialize the global DMA configuration
178 * channel group enable
181 outb(W83C553F_DMA1 + W83C553F_DMA1_CS, 0x00);
182 outw(W83C553F_DMA2 + W83C553F_DMA2_CS, 0x0000);
185 struct device_operations w83c553_ops = {
186 .read_resources = pci_dev_read_resources,
187 .set_resources = pci_dev_set_resources,
188 .enable_resources = pci_dev_enable_resources,
189 .init = w83c553_init,
193 struct pci_driver w83c553f_pci_driver __pci_driver = {
196 .device = PCI_DEVICE_ID_WINBOND_83C553,
197 .vendor = PCI_VENDOR_ID_WINBOND,