Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 1 | /* |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 2 | * This file is part of the flashrom project. |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 3 | * |
Uwe Hermann | d22a1d4 | 2007-09-09 20:21:05 +0000 | [diff] [blame] | 4 | * Copyright (C) 2003 Niki W. Waibel <niki.waibel@gmx.net> |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 5 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 10 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 15 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 21 | #include <stdio.h> |
| 22 | #include <unistd.h> |
| 23 | #include "flash.h" |
| 24 | #include "msys_doc.h" |
| 25 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 26 | static int doc_wait(volatile uint8_t *bios, int timeout); |
| 27 | static uint8_t doc_read_chipid(volatile uint8_t *bios); |
| 28 | static uint8_t doc_read_docstatus(volatile uint8_t *bios); |
| 29 | static uint8_t doc_read_cdsncontrol(volatile uint8_t *bios); |
| 30 | static void doc_write_cdsncontrol(volatile uint8_t *bios, uint8_t data); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 31 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 32 | int probe_md2802(struct flashchip *flash) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 33 | { |
Stefan Reinauer | ce53297 | 2007-05-23 17:20:56 +0000 | [diff] [blame] | 34 | volatile uint8_t *bios = flash->virtual_memory; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 35 | uint8_t chipid; |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 36 | #ifndef MSYSTEMS_DOC_NO_55AA_CHECKING |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 37 | uint8_t id_0x55, id_0xAA; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 38 | #endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */ |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 39 | int i, toggle_a, toggle_b; |
| 40 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 41 | printf_debug("%s:\n", __FUNCTION__); |
| 42 | printf_debug("%s: *******************************\n", __FUNCTION__); |
| 43 | printf_debug("%s: * THIS IS A PRE ALPHA VERSION *\n", __FUNCTION__); |
| 44 | printf_debug("%s: * IN THE DEVELOPEMENT *********\n", __FUNCTION__); |
| 45 | printf_debug("%s: * PROCESS RIGHT NOW. **********\n", __FUNCTION__); |
| 46 | printf_debug("%s: *******************************\n", __FUNCTION__); |
| 47 | printf_debug("%s: * IF YOU ARE NOT A DEVELOPER **\n", __FUNCTION__); |
| 48 | printf_debug("%s: * THEN DO NOT TRY TO READ OR **\n", __FUNCTION__); |
| 49 | printf_debug("%s: * WRITE TO THIS DEVICE ********\n", __FUNCTION__); |
| 50 | printf_debug("%s: *******************************\n", __FUNCTION__); |
| 51 | printf_debug("%s:\n", __FUNCTION__); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 52 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 53 | printf_debug("%s: switching off reset mode ...\n", __FUNCTION__); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 54 | doc_write(0x85, bios, DOCControl); |
| 55 | doc_write(0x85, bios, DOCControl); |
| 56 | doc_read_4nop(bios); |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 57 | if (doc_wait(bios, 5000)) |
| 58 | return (-1); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 59 | printf("%s: switching off reset mode ... done\n", __FUNCTION__); |
| 60 | printf("%s:\n", __FUNCTION__); |
| 61 | |
| 62 | printf("%s: switching off write protection ...\n", __FUNCTION__); |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 63 | doc_write_cdsncontrol(bios, doc_read_cdsncontrol(bios) & (~0x08)); |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 64 | printf("%s: switching off write protection ... done\n", __FUNCTION__); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 65 | printf("%s:\n", __FUNCTION__); |
| 66 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 67 | chipid = doc_read_chipid(bios); |
| 68 | #ifndef MSYSTEMS_DOC_NO_55AA_CHECKING |
| 69 | id_0x55 = doc_read(bios, IPL_0x0000); |
| 70 | id_0xAA = doc_read(bios, IPL_0x0001); |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 71 | #endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */ |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 72 | printf("%s: IPL_0x0000: 0x%02x\n", __FUNCTION__, id_0x55); |
| 73 | printf("%s: IPL_0x0001: 0x%02x\n", __FUNCTION__, id_0xAA); |
| 74 | printf("%s: IPL_0x0002: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 75 | doc_read(bios, IPL_0x0002)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 76 | printf("%s: IPL_0x0003: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 77 | doc_read(bios, IPL_0x0003)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 78 | printf("%s:\n", __FUNCTION__); |
| 79 | printf("%s: ChipID: 0x%02x\n", __FUNCTION__, chipid); |
| 80 | printf("%s: DOCStatus: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 81 | doc_read_docstatus(bios)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 82 | printf("%s: FloorSelect: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 83 | doc_read(bios, FloorSelect)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 84 | printf("%s: CDSNControl: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 85 | doc_read_cdsncontrol(bios)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 86 | printf("%s: CDSNDeviceSelect: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 87 | doc_read(bios, CDSNDeviceSelect)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 88 | printf("%s: ECCConfiguration: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 89 | doc_read(bios, ECCConfiguration)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 90 | printf("%s: CDSNSlowIO: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 91 | doc_read(bios, CDSNSlowIO)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 92 | printf("%s: ECCSyndrome0: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 93 | doc_read(bios, ECCSyndrome0)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 94 | printf("%s: ECCSyndrome1: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 95 | doc_read(bios, ECCSyndrome1)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 96 | printf("%s: ECCSyndrome2: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 97 | doc_read(bios, ECCSyndrome2)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 98 | printf("%s: ECCSyndrome3: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 99 | doc_read(bios, ECCSyndrome3)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 100 | printf("%s: ECCSyndrome4: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 101 | doc_read(bios, ECCSyndrome4)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 102 | printf("%s: ECCSyndrome5: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 103 | doc_read(bios, ECCSyndrome5)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 104 | printf("%s: AliasResolution: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 105 | doc_read(bios, AliasResolution)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 106 | printf("%s: ConfigurationInput: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 107 | doc_read(bios, ConfigurationInput)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 108 | printf("%s: ReadPipelineInitialization: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 109 | doc_read(bios, ReadPipelineInitialization)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 110 | printf("%s: LastDataRead: 0x%02x\n", __FUNCTION__, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 111 | doc_read(bios, LastDataRead)); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 112 | printf("%s:\n", __FUNCTION__); |
| 113 | |
| 114 | printf("%s: checking ECCConfiguration toggle bit\n", __FUNCTION__); |
| 115 | printf("%s:", __FUNCTION__); |
| 116 | toggle_a = toggle_b = 0; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 117 | for (i = 0; i < 10; i++) { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 118 | uint8_t toggle = doc_toggle(bios); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 119 | |
| 120 | printf(" 0x%02x", toggle); |
| 121 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 122 | if (i % 2) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 123 | toggle_a += toggle; |
| 124 | else |
| 125 | toggle_b += toggle; |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 126 | } /* for(i=0; i<10; i++) */ |
| 127 | printf("\n%s: toggle result: %d/%d\n", __FUNCTION__, toggle_a, |
| 128 | toggle_b); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 129 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 130 | if (chipid == flash->model_id && ((toggle_a == 5 && toggle_b == 0) |
| 131 | || (toggle_a == 0 && toggle_b == 5)) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 132 | #ifndef MSYSTEMS_DOC_NO_55AA_CHECKING |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 133 | && id_0x55 == 0x55 && id_0xAA == 0xaa |
| 134 | #endif /* !MSYSTEMS_DOC_NO_55AA_CHECKING */ |
| 135 | ) { |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 136 | return 1; |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 139 | return 0; |
| 140 | } |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 141 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 142 | int read_md2802(struct flashchip *flash, uint8_t *buf) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 143 | { |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 144 | return 0; |
| 145 | } |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 146 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 147 | int erase_md2802(struct flashchip *flash) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 148 | { |
Stefan Reinauer | ce53297 | 2007-05-23 17:20:56 +0000 | [diff] [blame] | 149 | volatile uint8_t *bios = flash->virtual_memory; |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 150 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 151 | return 1; |
| 152 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 153 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 154 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 155 | *(volatile uint8_t *)(bios + 0x5555) = 0x80; |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 156 | |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 157 | *(volatile uint8_t *)(bios + 0x5555) = 0xAA; |
| 158 | *(volatile uint8_t *)(bios + 0x2AAA) = 0x55; |
| 159 | *(volatile uint8_t *)(bios + 0x5555) = 0x10; |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 160 | } |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 161 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 162 | int write_md2802(struct flashchip *flash, uint8_t *buf) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 163 | { |
| 164 | int i; |
Uwe Hermann | a7e0548 | 2007-05-09 10:17:44 +0000 | [diff] [blame] | 165 | int total_size = flash->total_size * 1024; |
| 166 | int page_size = flash->page_size; |
Stefan Reinauer | ce53297 | 2007-05-23 17:20:56 +0000 | [diff] [blame] | 167 | volatile uint8_t *bios = flash->virtual_memory; |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 168 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 169 | return (1); |
| 170 | erase_md2802(flash); |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 171 | if (*bios != (uint8_t) 0xff) { |
Uwe Hermann | a502dce | 2007-10-17 23:55:15 +0000 | [diff] [blame^] | 172 | printf("ERASE FAILED!\n"); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 173 | return -1; |
| 174 | } |
Uwe Hermann | a502dce | 2007-10-17 23:55:15 +0000 | [diff] [blame^] | 175 | printf("Programming page: "); |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 176 | for (i = 0; i < total_size / page_size; i++) { |
| 177 | printf("%04d at address: 0x%08x", i, i * page_size); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 178 | //write_page_md2802(bios, buf + i * page_size, bios + i * page_size, page_size); |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 179 | printf |
| 180 | ("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 181 | } |
| 182 | printf("\n"); |
| 183 | //protect_md2802(bios); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 184 | |
Ronald G. Minnich | e66bdb3 | 2004-04-13 19:10:48 +0000 | [diff] [blame] | 185 | return 0; |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 186 | } /* int write_md2802(struct flashchip *flash, uint8_t *buf) */ |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 187 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 188 | /* |
| 189 | wait timeout msec for doc to become ready |
| 190 | return: |
| 191 | 0: ready |
| 192 | -1: timeout expired |
| 193 | */ |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 194 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 195 | static int doc_wait(volatile uint8_t *bios, int timeout) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 196 | { |
| 197 | int i = 20; |
| 198 | |
| 199 | doc_read_4nop(bios); |
| 200 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 201 | while (_doc_busy(bios) && (i != 0)) { |
| 202 | usleep(timeout * 1000 / 20); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 203 | i--; |
| 204 | } |
| 205 | |
| 206 | doc_read_2nop(bios); |
| 207 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 208 | if (_doc_busy(bios)) { |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 209 | doc_read_2nop(bios); |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 210 | return (-1); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 213 | return 0; |
| 214 | } |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 215 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 216 | static uint8_t doc_read_docstatus(volatile uint8_t *bios) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 217 | { |
| 218 | doc_read(bios, CDSNSlowIO); |
| 219 | doc_read_2nop(bios); |
| 220 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 221 | return (doc_read(bios, _DOCStatus)); |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 222 | } |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 223 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 224 | static uint8_t doc_read_chipid(volatile uint8_t *bios) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 225 | { |
| 226 | doc_read(bios, CDSNSlowIO); |
| 227 | doc_read_2nop(bios); |
| 228 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 229 | return (doc_read(bios, _ChipID)); |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 230 | } |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 231 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 232 | static uint8_t doc_read_cdsncontrol(volatile uint8_t *bios) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 233 | { |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 234 | uint8_t value; |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 235 | |
| 236 | /* the delays might be necessary when reading the busy bit, |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 237 | but because a read to this reg reads the busy bit |
| 238 | anyway we better do this delays... */ |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 239 | doc_read_4nop(bios); |
| 240 | value = doc_read(bios, _CDSNControl); |
| 241 | doc_read_2nop(bios); |
| 242 | |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 243 | return value; |
| 244 | } |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 245 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 246 | static void doc_write_cdsncontrol(volatile uint8_t *bios, uint8_t data) |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 247 | { |
| 248 | doc_write(data, bios, _CDSNControl); |
| 249 | doc_read_4nop(bios); |
Uwe Hermann | ffec5f3 | 2007-08-23 16:08:21 +0000 | [diff] [blame] | 250 | } |