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> |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 36 | #include <stdlib.h> |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 37 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 38 | int main() |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 39 | { |
| 40 | char b; |
| 41 | |
| 42 | /* get io privilege access PCI configuration space */ |
| 43 | if (iopl(3) != 0) { |
| 44 | perror("Can not set io priviliage"); |
| 45 | exit(1); |
| 46 | } |
| 47 | |
| 48 | /* Enable 0xFFF8000~0xFFFF0000 decoding on SiS 540/630 */ |
| 49 | outl(0x80000840, 0x0cf8); |
| 50 | b = inb(0x0cfc) | 0x0b; |
| 51 | outb(b, 0xcfc); |
| 52 | /* Flash write enable on SiS 540/630 */ |
| 53 | outl(0x80000845, 0x0cf8); |
| 54 | b = inb(0x0cfd) | 0x40; |
| 55 | outb(b, 0xcfd); |
| 56 | |
| 57 | /* The same thing on SiS 950 SuperIO side */ |
| 58 | outb(0x87, 0x2e); |
| 59 | outb(0x01, 0x2e); |
| 60 | outb(0x55, 0x2e); |
| 61 | outb(0x55, 0x2e); |
| 62 | |
| 63 | if (inb(0x2f) != 0x87) { |
| 64 | printf("Can not access SiS 950\n"); |
| 65 | return -1; |
| 66 | } |
| 67 | |
| 68 | outb(0x24, 0x2e); |
| 69 | b = inb(0x2f) | 0xfc; |
| 70 | outb(0x24, 0x2e); |
| 71 | outb(b, 0x2f); |
| 72 | |
| 73 | outb(0x02, 0x2e); |
| 74 | outb(0x02, 0x2f); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 75 | |
| 76 | return(0); |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 77 | } |