1 /* $NetBSD: smc93cx6var.h,v 1.4 1997/04/10 02:48:42 cgd Exp $ */ 2 3 /* 4 * Interface to the 93C46 serial EEPROM that is used to store BIOS 5 * settings for the aic7xxx based adaptec SCSI controllers. It can 6 * also be used for 93C26 and 93C06 serial EEPROMS. 7 * 8 * Copyright (c) 1994, 1995 Justin T. Gibbs. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice immediately at the beginning of the file, without modification, 16 * this list of conditions, and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. Absolutely no warranty of function or purpose is made by the author 21 * Justin T. Gibbs. 22 * 4. Modifications may be freely made to this file if the above conditions 23 * are met. 24 * 25 * from Id: 93cx6.h,v 1.3 1996/05/30 07:19:55 gibbs Exp 26 */ 27 28 #include <sys/param.h> 29 #if !defined(__NetBSD__) 30 #include <sys/systm.h> 31 #endif 32 33 struct seeprom_descriptor { 34 #if defined(__FreeBSD__) 35 u_long sd_iobase; 36 #elif defined(__NetBSD__) 37 bus_space_tag_t sd_st; 38 bus_space_handle_t sd_sh; 39 bus_size_t sd_offset; 40 #endif 41 u_int16_t sd_MS; 42 u_int16_t sd_RDY; 43 u_int16_t sd_CS; 44 u_int16_t sd_CK; 45 u_int16_t sd_DO; 46 u_int16_t sd_DI; 47 }; 48 49 /* 50 * This function will read count 16-bit words from the serial EEPROM and 51 * return their value in buf. The port address of the aic7xxx serial EEPROM 52 * control register is passed in as offset. The following parameters are 53 * also passed in: 54 * 55 * CS - Chip select 56 * CK - Clock 57 * DO - Data out 58 * DI - Data in 59 * RDY - SEEPROM ready 60 * MS - Memory port mode select 61 * 62 * A failed read attempt returns 0, and a successful read returns 1. 63 */ 64 65 #if defined(__FreeBSD__) 66 #define SEEPROM_INB(sd) inb(sd->sd_iobase) 67 #define SEEPROM_OUTB(sd, value) outb(sd->sd_iobase, value) 68 #elif defined(__NetBSD__) 69 #define SEEPROM_INB(sd) \ 70 bus_space_read_1(sd->sd_st, sd->sd_sh, sd->sd_offset) 71 #define SEEPROM_OUTB(sd, value) \ 72 bus_space_write_1(sd->sd_st, sd->sd_sh, sd->sd_offset, value) 73 #endif 74 75 #if defined(__FreeBSD__) 76 int read_seeprom __P((struct seeprom_descriptor *sd, 77 u_int16_t *buf, u_int start_addr, int count)); 78 #elif defined(__NetBSD__) 79 int read_seeprom __P((struct seeprom_descriptor *sd, 80 u_int16_t *buf, bus_size_t start_addr, bus_size_t count)); 81 #endif 82