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