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