3 * Daniel Engström, Omicron Ceti AB <daniel@omicron.se>.
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 * Based on sc520cdp.c from rolo 1.6:
26 *----------------------------------------------------------------------
28 * Sysgo Real-Time Solutions GmbH
29 * Klein-Winternheim, Germany
30 *----------------------------------------------------------------------
40 /* ALI M5123 Logical device numbers:
53 ************************************************************
54 * Some access primitives for the ALi chip: *
55 ************************************************************
58 static void ali_write(u8 index, u8 value)
60 /* write an arbirary register */
61 outb(index, ALI_INDEX);
62 outb(value, ALI_DATA);
66 static int ali_read(u8 index)
68 outb(index, ALI_INDEX);
74 outb(0x51, ALI_INDEX); \
81 /* Select a logical device */
82 #define ALI_SELDEV(dev) \
86 void ali512x_init(void)
90 ali_write(0x02, 0x01); /* soft reset */
91 ali_write(0x03, 0x03); /* disable access to CIOs */
92 ali_write(0x22, 0x00); /* disable direct powerdown */
93 ali_write(0x23, 0x00); /* disable auto powerdown */
94 ali_write(0x24, 0x00); /* IR 8 is active hi, pin26 is PDIR */
99 void ali512x_set_fdc(int enabled, u16 io, u8 irq, u8 dma_channel)
104 ali_write(0x30, enabled?1:0);
106 ali_write(0x60, io >> 8);
107 ali_write(0x61, io & 0xff);
108 ali_write(0x70, irq);
109 ali_write(0x74, dma_channel);
111 /* AT mode, no drive swap */
112 ali_write(0xf0, 0x08);
113 ali_write(0xf1, 0x00);
114 ali_write(0xf2, 0xff);
115 ali_write(0xf4, 0x00);
121 void ali512x_set_pp(int enabled, u16 io, u8 irq, u8 dma_channel)
126 ali_write(0x30, enabled?1:0);
128 ali_write(0x60, io >> 8);
129 ali_write(0x61, io & 0xff);
130 ali_write(0x70, irq);
131 ali_write(0x74, dma_channel);
133 /* mode: EPP 1.9, ECP FIFO threshold = 7, IRQ active low */
134 ali_write(0xf0, 0xbc);
135 /* 12 MHz, Burst DMA in ECP */
136 ali_write(0xf1, 0x05);
142 void ali512x_set_uart(int enabled, int index, u16 io, u8 irq)
145 ALI_SELDEV(index?5:4);
147 ali_write(0x30, enabled?1:0);
149 ali_write(0x60, io >> 8);
150 ali_write(0x61, io & 0xff);
151 ali_write(0x70, irq);
153 ali_write(0xf0, 0x00);
154 ali_write(0xf1, 0x00);
156 /* huh? write 0xf2 twice - a typo in rolo
157 * or some secret ali errata? Who knows?
160 ali_write(0xf2, 0x00);
162 ali_write(0xf2, 0x0c);
168 void ali512x_set_uart2_irda(int enabled)
173 ali_write(0xf1, enabled?0x48:0x00); /* fullduplex IrDa */
178 void ali512x_set_rtc(int enabled, u16 io, u8 irq)
183 ali_write(0x30, enabled?1:0);
185 ali_write(0x60, io >> 8);
186 ali_write(0x61, io & 0xff);
187 ali_write(0x70, irq);
189 ali_write(0xf0, 0x00);
194 void ali512x_set_kbc(int enabled, u8 kbc_irq, u8 mouse_irq)
199 ali_write(0x30, enabled?1:0);
201 ali_write(0x70, kbc_irq);
202 ali_write(0x72, mouse_irq);
204 ali_write(0xf0, 0x00);
212 * (This descripotsion is base on several incompete sources
213 * since I have not been able to obtain any datasheet for the device
214 * there may be some mis-understandings burried in here.
215 * -- Daniel daniel@omicron.se)
217 * There are 22 CIO pins numbered
222 * 20-24 are dedicated CIO pins, the other 17 are muliplexed with
226 * CIO Pin Function Decription
227 * =======================================================
228 * CIO10 IRQIN1 Interrupt input 1?
229 * CIO11 IRQIN2 Interrupt input 2?
230 * CIO12 IRRX IrDa Receive
231 * CIO13 IRTX IrDa Transmit
232 * CIO14 P21 KBC P21 fucntion
233 * CIO15 P20 KBC P21 fucntion
234 * CIO16 I2C_CLK I2C Clock
235 * CIO17 I2C_DAT I2C Data
244 * CIO30 KBC_CLK Keybaord Clock
245 * CIO31 CS0J General Chip Select decoder CS0J
246 * CIO32 CS1J General Chip Select decoder CS1J
247 * CIO33 ALT_KCLK Alternative Keyboard Clock
248 * CIO34 ALT_KDAT Alternative Keyboard Data
249 * CIO35 ALT_MCLK Alternative Mouse Clock
250 * CIO36 ALT_MDAT Alternative Mouse Data
251 * CIO37 ALT_KBC Alternative KBC select
253 * The CIO use an indirect address scheme.
255 * Reigster 3 in the SIO is used to select the index and data
256 * port addresses where the CIO I/O registers show up.
257 * The function selection registers are accessible under
260 * SIO reigster 3 (CIO Address Selection) bit definitions:
261 * bit 7 CIO index and data registers enabled
262 * bit 1-0 CIO indirect registers port address select
263 * 0 index = 0xE0 data = 0xE1
264 * 1 index = 0xE2 data = 0xE3
265 * 2 index = 0xE4 data = 0xE5
266 * 3 index = 0xEA data = 0xEB
268 * There are three CIO I/O register accessed via CIO index port and CIO data port
269 * 0x01 CIO 10-17 data
270 * 0x02 CIO 20-25 data (bits 7-6 unused)
271 * 0x03 CIO 30-37 data
274 * The pin function is accessed through normal
275 * SIO registers, each register have the same format:
278 * 0 Input/output 1=input
279 * 1 Polarity of signal 1=inverted
281 * 3 Function (normal or special) 1=special
312 #define ALI_CIO_PORT_SEL 0x83
313 #define ALI_CIO_INDEX 0xea
314 #define ALI_CIO_DATA 0xeb
316 void ali512x_set_cio(int enabled)
323 ali_write(0x3, ALI_CIO_PORT_SEL); /* Enable CIO data register */
325 ali_write(0x3, ALI_CIO_PORT_SEL & ~0x80);
330 ali_write(0x30, enabled?1:0);
332 /* set all pins to input to start with */
333 for (i=0xe0;i<0xee;i++) {
337 for (i=0xf5;i<0xfe;i++) {
345 void ali512x_cio_function(int pin, int special, int inv, int input)
350 /* valid pins are 10-17, 20-25 and 30-37 */
351 if (pin >= 10 && pin <= 17) {
353 } else if (pin >= 20 && pin <= 25) {
355 } else if (pin >= 30 && pin <= 37) {
378 ali_write(addr, data);
383 void ali512x_cio_out(int pin, int value)
393 outb(reg, ALI_CIO_INDEX); /* select I/O register */
394 data = inb(ALI_CIO_DATA);
400 outb(data, ALI_CIO_DATA);
403 int ali512x_cio_in(int pin)
409 /* valid pins are 10-17, 20-25 and 30-37 */
414 outb(reg, ALI_CIO_INDEX); /* select I/O register */
415 data = inb(ALI_CIO_DATA);