Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 1 | /* |
| 2 | * flash_rom.c: Turnning on Flash Write Enable for SiS 630/950 M/Bs, |
| 3 | * use this program before loading DoC drivers. |
| 4 | * |
| 5 | * |
| 6 | * Copyright 2000 Silicon Integrated System Corporation |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 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. |
| 17 | * |
| 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., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 21 | * |
| 22 | * |
| 23 | * Reference: |
| 24 | * 1. SiS 630 Specification |
| 25 | * 2. SiS 950 Specification |
| 26 | * |
| 27 | * $Id$ |
| 28 | */ |
| 29 | |
| 30 | #include <errno.h> |
| 31 | #include <fcntl.h> |
| 32 | #include <sys/mman.h> |
| 33 | #include <sys/io.h> |
| 34 | #include <unistd.h> |
| 35 | #include <stdio.h> |
| 36 | |
| 37 | main() |
| 38 | { |
| 39 | char b; |
| 40 | |
| 41 | /* get io privilege access PCI configuration space */ |
| 42 | if (iopl(3) != 0) { |
| 43 | perror("Can not set io priviliage"); |
| 44 | exit(1); |
| 45 | } |
| 46 | |
| 47 | /* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630 */ |
| 48 | outl(0x80000840, 0x0cf8); |
| 49 | b = inb(0x0cfc) | 0x0b; |
| 50 | outb(b, 0xcfc); |
| 51 | /* Flash write enable on SiS 540/630 */ |
| 52 | outl(0x80000845, 0x0cf8); |
| 53 | b = inb(0x0cfd) | 0x40; |
| 54 | outb(b, 0xcfd); |
| 55 | |
| 56 | /* The same thing on SiS 950 SuperIO side */ |
| 57 | outb(0x87, 0x2e); |
| 58 | outb(0x01, 0x2e); |
| 59 | outb(0x55, 0x2e); |
| 60 | outb(0x55, 0x2e); |
| 61 | |
| 62 | if (inb(0x2f) != 0x87) { |
| 63 | printf("Can not access SiS 950\n"); |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | outb(0x24, 0x2e); |
| 68 | b = inb(0x2f) | 0xfc; |
| 69 | outb(0x24, 0x2e); |
| 70 | outb(b, 0x2f); |
| 71 | |
| 72 | outb(0x02, 0x2e); |
| 73 | outb(0x02, 0x2f); |
| 74 | } |