18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Interface to the 93C46/56 serial EEPROM that is used to store BIOS 38c2ecf20Sopenharmony_ci * settings for the aic7xxx based adaptec SCSI controllers. It can 48c2ecf20Sopenharmony_ci * also be used for 93C26 and 93C06 serial EEPROMS. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (c) 1994, 1995, 2000 Justin T. Gibbs. 78c2ecf20Sopenharmony_ci * All rights reserved. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 108c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 118c2ecf20Sopenharmony_ci * are met: 128c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 138c2ecf20Sopenharmony_ci * notice, this list of conditions, and the following disclaimer, 148c2ecf20Sopenharmony_ci * without modification. 158c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer 168c2ecf20Sopenharmony_ci * substantially similar to the "NO WARRANTY" disclaimer below 178c2ecf20Sopenharmony_ci * ("Disclaimer") and any redistribution must be conditioned upon 188c2ecf20Sopenharmony_ci * including a substantially similar Disclaimer requirement for further 198c2ecf20Sopenharmony_ci * binary redistribution. 208c2ecf20Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names 218c2ecf20Sopenharmony_ci * of any contributors may be used to endorse or promote products derived 228c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 258c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 268c2ecf20Sopenharmony_ci * Software Foundation. 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * NO WARRANTY 298c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 308c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 318c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 328c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 338c2ecf20Sopenharmony_ci * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 348c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 358c2ecf20Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 368c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 378c2ecf20Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 388c2ecf20Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 398c2ecf20Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGES. 408c2ecf20Sopenharmony_ci * 418c2ecf20Sopenharmony_ci * $Id: //depot/aic7xxx/aic7xxx/aic7xxx_93cx6.h#12 $ 428c2ecf20Sopenharmony_ci * 438c2ecf20Sopenharmony_ci * $FreeBSD$ 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_ci#ifndef _AIC7XXX_93CX6_H_ 468c2ecf20Sopenharmony_ci#define _AIC7XXX_93CX6_H_ 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_citypedef enum { 498c2ecf20Sopenharmony_ci C46 = 6, 508c2ecf20Sopenharmony_ci C56_66 = 8 518c2ecf20Sopenharmony_ci} seeprom_chip_t; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_cistruct seeprom_descriptor { 548c2ecf20Sopenharmony_ci struct ahc_softc *sd_ahc; 558c2ecf20Sopenharmony_ci u_int sd_control_offset; 568c2ecf20Sopenharmony_ci u_int sd_status_offset; 578c2ecf20Sopenharmony_ci u_int sd_dataout_offset; 588c2ecf20Sopenharmony_ci seeprom_chip_t sd_chip; 598c2ecf20Sopenharmony_ci uint16_t sd_MS; 608c2ecf20Sopenharmony_ci uint16_t sd_RDY; 618c2ecf20Sopenharmony_ci uint16_t sd_CS; 628c2ecf20Sopenharmony_ci uint16_t sd_CK; 638c2ecf20Sopenharmony_ci uint16_t sd_DO; 648c2ecf20Sopenharmony_ci uint16_t sd_DI; 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* 688c2ecf20Sopenharmony_ci * This function will read count 16-bit words from the serial EEPROM and 698c2ecf20Sopenharmony_ci * return their value in buf. The port address of the aic7xxx serial EEPROM 708c2ecf20Sopenharmony_ci * control register is passed in as offset. The following parameters are 718c2ecf20Sopenharmony_ci * also passed in: 728c2ecf20Sopenharmony_ci * 738c2ecf20Sopenharmony_ci * CS - Chip select 748c2ecf20Sopenharmony_ci * CK - Clock 758c2ecf20Sopenharmony_ci * DO - Data out 768c2ecf20Sopenharmony_ci * DI - Data in 778c2ecf20Sopenharmony_ci * RDY - SEEPROM ready 788c2ecf20Sopenharmony_ci * MS - Memory port mode select 798c2ecf20Sopenharmony_ci * 808c2ecf20Sopenharmony_ci * A failed read attempt returns 0, and a successful read returns 1. 818c2ecf20Sopenharmony_ci */ 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci#define SEEPROM_INB(sd) \ 848c2ecf20Sopenharmony_ci ahc_inb(sd->sd_ahc, sd->sd_control_offset) 858c2ecf20Sopenharmony_ci#define SEEPROM_OUTB(sd, value) \ 868c2ecf20Sopenharmony_cido { \ 878c2ecf20Sopenharmony_ci ahc_outb(sd->sd_ahc, sd->sd_control_offset, value); \ 888c2ecf20Sopenharmony_ci ahc_flush_device_writes(sd->sd_ahc); \ 898c2ecf20Sopenharmony_ci} while(0) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define SEEPROM_STATUS_INB(sd) \ 928c2ecf20Sopenharmony_ci ahc_inb(sd->sd_ahc, sd->sd_status_offset) 938c2ecf20Sopenharmony_ci#define SEEPROM_DATA_INB(sd) \ 948c2ecf20Sopenharmony_ci ahc_inb(sd->sd_ahc, sd->sd_dataout_offset) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciint ahc_read_seeprom(struct seeprom_descriptor *sd, uint16_t *buf, 978c2ecf20Sopenharmony_ci u_int start_addr, u_int count); 988c2ecf20Sopenharmony_ciint ahc_write_seeprom(struct seeprom_descriptor *sd, uint16_t *buf, 998c2ecf20Sopenharmony_ci u_int start_addr, u_int count); 1008c2ecf20Sopenharmony_ciint ahc_verify_cksum(struct seeprom_config *sc); 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#endif /* _AIC7XXX_93CX6_H_ */ 103