1/*- 2 * Copyright (c) 1997 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: ppb_1284.c,v 1.4 1998/08/03 19:14:31 msmith Exp $ |
27 * 28 */ 29 30#include "opt_debug_1284.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34 --- 67 unchanged lines hidden (view full) --- 102int 103nibble_1284_inbyte(struct ppb_device *dev, char *buffer) 104{ 105 char nibble[2]; 106 int i, error; 107 108 for (i = 0; i < 2; i++) { 109 /* ready to take data (nAUTO low) */ |
110 ppb_wctr(dev, AUTOFEED & ~(STROBE | SELECTIN)); |
111 112 if ((error = do_1284_wait(dev, nACK, 0))) 113 return (error); 114 115 /* read nibble */ 116 nibble[i] = ppb_rstr(dev); 117 |
118 /* ack, not ready for another nibble */ |
119 ppb_wctr(dev, 0 & ~(AUTOFEED | STROBE | SELECTIN)); |
120 121 /* wait ack from peripherial */ 122 if ((error = do_1284_wait(dev, nACK, nACK))) 123 return (error); 124 } 125 126 *buffer = ((nibble2char(nibble[1]) << 4) & 0xf0) | 127 (nibble2char(nibble[0]) & 0x0f); 128 |
129 return (0); 130} 131 132/* 133 * nibble_1284_sync() 134 */ 135void 136nibble_1284_sync(struct ppb_device *dev) --- 10 unchanged lines hidden (view full) --- 147 do_1284_wait(dev, nACK, nACK); 148 149 ppb_wctr(dev, (ctr & ~AUTOFEED) | SELECTIN); 150 151 return; 152} 153 154/* |
155 * ppb_1284_negociate() |
156 * 157 * Normal nibble mode or request device id mode (see ppb_1284.h) 158 */ 159int |
160ppb_1284_negociate(struct ppb_device *dev, int mode) |
161{ |
162 int error; |
163 int phase = 0; |
164 |
165 ppb_wctr(dev, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); 166 DELAY(1); |
167 168 ppb_wdtr(dev, mode); |
169 DELAY(1); |
170 |
171 ppb_wctr(dev, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN)); |
172 |
173 if ((error = do_1284_wait(dev, nACK | PERROR | SELECT | nFAULT, 174 PERROR | SELECT | nFAULT))) 175 goto error; |
176 |
177 phase = 1; 178 179 ppb_wctr(dev, (nINIT | STROBE | AUTOFEED) & ~SELECTIN); |
180 DELAY(5); 181 |
182 ppb_wctr(dev, nINIT & ~(SELECTIN | AUTOFEED | STROBE)); |
183 |
184#if 0 /* not respected by most devices */ 185 if ((error = do_1284_wait(dev, nACK, nACK))) 186 goto error; 187 188 if (mode == 0) 189 if ((error = do_1284_wait(dev, SELECT, 0))) 190 goto error; 191 else 192 if ((error = do_1284_wait(dev, SELECT, SELECT))) 193 goto error; 194#endif 195 |
196 return (0); |
197 198error: 199 if (bootverbose) 200 printf("%s: status=0x%x %d\n", __FUNCTION__, ppb_rstr(dev), phase); 201 202 return (error); |
203} |
204 205int 206ppb_1284_terminate(struct ppb_device *dev, int how) 207{ 208 int error; 209 210 switch (how) { 211 case VALID_STATE: 212 213 ppb_wctr(dev, SELECTIN & ~(STROBE | AUTOFEED)); 214 215 if ((error = do_1284_wait(dev, nACK | nBUSY | nFAULT, nFAULT))) 216 return (error); 217 218 ppb_wctr(dev, (SELECTIN | AUTOFEED) & ~STROBE); 219 220 if ((error = do_1284_wait(dev, nACK, nACK))) 221 return (error); 222 223 ppb_wctr(dev, SELECTIN & ~(STROBE | AUTOFEED)); 224 break; 225 226 default: 227 return (EINVAL); 228 } 229 230 return (0); 231} |