/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 2007, Juniper Networks, Inc.4* Copyright (c) 2012-2013, SRI International5* All rights reserved.6*7* Portions of this software were developed by SRI International and the8* University of Cambridge Computer Laboratory under DARPA/AFRL contract9* (FA8750-10-C-0237) ("CTSRD"), as part of the DARPA CRASH research10* programme.11*12* Redistribution and use in source and binary forms, with or without13* modification, are permitted provided that the following conditions14* are met:15* 1. Redistributions of source code must retain the above copyright16* notice, this list of conditions and the following disclaimer.17* 2. Redistributions in binary form must reproduce the above copyright18* notice, this list of conditions and the following disclaimer in the19* documentation and/or other materials provided with the distribution.20* 3. Neither the name of the author nor the names of any co-contributors21* may be used to endorse or promote products derived from this software22* without specific prior written permission.23*24* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR25* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES26* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.27* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,28* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,29* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;30* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED31* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,32* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY33* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF34* SUCH DAMAGE.35*/3637#ifndef _DEV_CFI_VAR_H_38#define _DEV_CFI_VAR_H_3940enum cfi_wait_cmd {41CFI_TIMEOUT_ERASE,42CFI_TIMEOUT_WRITE,43CFI_TIMEOUT_BUFWRITE44};4546struct cfi_region {47u_int r_blocks;48u_int r_blksz;49};5051struct cfi_softc {52device_t sc_dev;5354struct resource *sc_res;55bus_space_handle_t sc_handle;56bus_space_tag_t sc_tag;57int sc_rid;5859u_int sc_size; /* Flash size. */60u_int sc_width; /* Interface width. */61u_int sc_regions; /* Erase regions. */62struct cfi_region *sc_region; /* Array of region info. */6364u_int sc_cmdset;65sbintime_t sc_typical_timeouts[3];66sbintime_t sc_max_timeouts[3];67u_int sc_tto_counts[3];68u_int sc_mto_counts[3];6970u_int sc_maxbuf;7172struct cdev *sc_nod;73struct proc *sc_opened; /* Process that has us opened. */7475u_char *sc_wrbuf;76u_char *sc_wrbufcpy;77u_int sc_wrbufsz;78u_int sc_wrofs;79u_int sc_writing;8081u_int sc_manid;82u_int sc_devid;83};8485extern char cfi_driver_name[];8687int cfi_probe(device_t);88int cfi_attach(device_t);89int cfi_detach(device_t);9091uint32_t cfi_read_raw(struct cfi_softc *, u_int);92uint32_t cfi_read(struct cfi_softc *, u_int);93uint8_t cfi_read_qry(struct cfi_softc *, u_int);94int cfi_write_block(struct cfi_softc *);95int cfi_block_start(struct cfi_softc *, u_int);96int cfi_block_finish(struct cfi_softc *);9798#ifdef CFI_SUPPORT_STRATAFLASH99int cfi_intel_get_factory_pr(struct cfi_softc *sc, uint64_t *);100int cfi_intel_get_oem_pr(struct cfi_softc *sc, uint64_t *);101int cfi_intel_set_oem_pr(struct cfi_softc *sc, uint64_t);102int cfi_intel_get_plr(struct cfi_softc *sc, uint32_t *);103int cfi_intel_set_plr(struct cfi_softc *sc);104#endif /* CFI_SUPPORT_STRATAFLASH */105#endif /* _DEV_CFI_VAR_H_ */106107108