cfi_var.h revision 255207
1184610Salfred/*- 2184610Salfred * Copyright (c) 2007, Juniper Networks, Inc. 3184610Salfred * Copyright (c) 2012-2013, SRI International 4184610Salfred * All rights reserved. 5184610Salfred * 6184610Salfred * Portions of this software were developed by SRI International and the 7184610Salfred * University of Cambridge Computer Laboratory under DARPA/AFRL contract 8184610Salfred * (FA8750-10-C-0237) ("CTSRD"), as part of the DARPA CRASH research 9184610Salfred * programme. 10184610Salfred * 11184610Salfred * Redistribution and use in source and binary forms, with or without 12184610Salfred * modification, are permitted provided that the following conditions 13184610Salfred * are met: 14184610Salfred * 1. Redistributions of source code must retain the above copyright 15184610Salfred * notice, this list of conditions and the following disclaimer. 16184610Salfred * 2. Redistributions in binary form must reproduce the above copyright 17184610Salfred * notice, this list of conditions and the following disclaimer in the 18184610Salfred * documentation and/or other materials provided with the distribution. 19184610Salfred * 3. Neither the name of the author nor the names of any co-contributors 20184610Salfred * may be used to endorse or promote products derived from this software 21184610Salfred * without specific prior written permission. 22184610Salfred * 23184610Salfred * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24184610Salfred * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25184610Salfred * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26184610Salfred * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27184610Salfred * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28184610Salfred * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29184610Salfred * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 30184610Salfred * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31184610Salfred * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32184610Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33184610Salfred * SUCH DAMAGE. 34184610Salfred * 35184610Salfred * $FreeBSD: head/sys/dev/cfi/cfi_var.h 255207 2013-09-04 17:19:21Z brooks $ 36184610Salfred */ 37184610Salfred 38184610Salfred#ifndef _DEV_CFI_VAR_H_ 39184610Salfred#define _DEV_CFI_VAR_H_ 40184610Salfred 41184610Salfredenum cfi_wait_cmd { 42184610Salfred CFI_TIMEOUT_ERASE, 43184610Salfred CFI_TIMEOUT_WRITE, 44184610Salfred CFI_TIMEOUT_BUFWRITE 45184610Salfred}; 46184610Salfred 47184610Salfredstruct cfi_region { 48184610Salfred u_int r_blocks; 49184610Salfred u_int r_blksz; 50184610Salfred}; 51184610Salfred 52184610Salfredstruct cfi_softc { 53184610Salfred device_t sc_dev; 54184610Salfred 55184610Salfred struct resource *sc_res; 56184610Salfred bus_space_handle_t sc_handle; 57184610Salfred bus_space_tag_t sc_tag; 58184610Salfred int sc_rid; 59184610Salfred 60184610Salfred u_int sc_size; /* Flash size. */ 61184610Salfred u_int sc_width; /* Interface width. */ 62184610Salfred u_int sc_regions; /* Erase regions. */ 63184610Salfred struct cfi_region *sc_region; /* Array of region info. */ 64184610Salfred 65184610Salfred u_int sc_cmdset; 66184610Salfred sbintime_t sc_typical_timeouts[3]; 67184610Salfred sbintime_t sc_max_timeouts[3]; 68184610Salfred u_int sc_tto_counts[3]; 69184610Salfred u_int sc_mto_counts[3]; 70184610Salfred 71184610Salfred u_int sc_maxbuf; 72184610Salfred 73184610Salfred struct cdev *sc_nod; 74184610Salfred struct proc *sc_opened; /* Process that has us opened. */ 75184610Salfred 76184610Salfred u_char *sc_wrbuf; 77184610Salfred u_char *sc_wrbufcpy; 78184610Salfred u_int sc_wrbufsz; 79184610Salfred u_int sc_wrofs; 80184610Salfred u_int sc_writing; 81184610Salfred}; 82184610Salfred 83184610Salfredextern char cfi_driver_name[]; 84184610Salfredextern devclass_t cfi_devclass; 85184610Salfredextern devclass_t cfi_diskclass; 86184610Salfred 87194677Sthompsaint cfi_probe(device_t); 88194677Sthompsaint cfi_attach(device_t); 89194677Sthompsaint cfi_detach(device_t); 90194677Sthompsa 91194677Sthompsauint32_t cfi_read_raw(struct cfi_softc *, u_int); 92194677Sthompsauint32_t cfi_read(struct cfi_softc *, u_int); 93194677Sthompsauint8_t cfi_read_qry(struct cfi_softc *, u_int); 94194677Sthompsaint cfi_write_block(struct cfi_softc *); 95194677Sthompsaint cfi_block_start(struct cfi_softc *, u_int); 96194677Sthompsaint cfi_block_finish(struct cfi_softc *); 97194677Sthompsa 98194677Sthompsa#ifdef CFI_SUPPORT_STRATAFLASH 99194677Sthompsaint cfi_intel_get_factory_pr(struct cfi_softc *sc, uint64_t *); 100194677Sthompsaint cfi_intel_get_oem_pr(struct cfi_softc *sc, uint64_t *); 101194677Sthompsaint cfi_intel_set_oem_pr(struct cfi_softc *sc, uint64_t); 102194677Sthompsaint cfi_intel_get_plr(struct cfi_softc *sc, uint32_t *); 103194677Sthompsaint cfi_intel_set_plr(struct cfi_softc *sc); 104194677Sthompsa#endif /* CFI_SUPPORT_STRATAFLASH */ 105194677Sthompsa#endif /* _DEV_CFI_VAR_H_ */ 106194677Sthompsa