cfi_var.h revision 189606
1184251Smarcel/*-
2184251Smarcel * Copyright (c) 2007, Juniper Networks, Inc.
3184251Smarcel * All rights reserved.
4184251Smarcel *
5184251Smarcel * Redistribution and use in source and binary forms, with or without
6184251Smarcel * modification, are permitted provided that the following conditions
7184251Smarcel * are met:
8184251Smarcel * 1. Redistributions of source code must retain the above copyright
9184251Smarcel *    notice, this list of conditions and the following disclaimer.
10184251Smarcel * 2. Redistributions in binary form must reproduce the above copyright
11184251Smarcel *    notice, this list of conditions and the following disclaimer in the
12184251Smarcel *    documentation and/or other materials provided with the distribution.
13184251Smarcel * 3. Neither the name of the author nor the names of any co-contributors
14184251Smarcel *    may be used to endorse or promote products derived from this software
15184251Smarcel *    without specific prior written permission.
16184251Smarcel *
17184251Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18184251Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19184251Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20184251Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21184251Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22184251Smarcel * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23184251Smarcel * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24184251Smarcel * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25184251Smarcel * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26184251Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27184251Smarcel * SUCH DAMAGE.
28184251Smarcel *
29184251Smarcel * $FreeBSD: head/sys/dev/cfi/cfi_var.h 189606 2009-03-09 23:16:02Z sam $
30184251Smarcel */
31184251Smarcel
32184251Smarcel#ifndef _DEV_CFI_VAR_H_
33184251Smarcel#define	_DEV_CFI_VAR_H_
34184251Smarcel
35184251Smarcelstruct cfi_region {
36184251Smarcel	u_int		r_blocks;
37184251Smarcel	u_int		r_blksz;
38184251Smarcel};
39184251Smarcel
40184251Smarcelstruct cfi_softc {
41184251Smarcel	device_t	sc_dev;
42184251Smarcel
43184251Smarcel	struct resource	*sc_res;
44184251Smarcel	bus_space_handle_t sc_handle;
45184251Smarcel	bus_space_tag_t	sc_tag;
46184251Smarcel	int		sc_rid;
47184251Smarcel
48184251Smarcel	u_int		sc_size;	/* Flash size. */
49184251Smarcel	u_int		sc_width;	/* Interface width. */
50184251Smarcel	u_int		sc_regions;	/* Erase regions. */
51184251Smarcel	struct cfi_region *sc_region;	/* Array of region info. */
52184251Smarcel
53184251Smarcel	u_int		sc_cmdset;
54184251Smarcel	u_int		sc_erase_timeout;
55184251Smarcel	u_int		sc_write_timeout;
56184251Smarcel
57184251Smarcel	struct cdev	*sc_nod;
58184251Smarcel	struct proc	*sc_opened;	/* Process that has us opened. */
59184251Smarcel
60184251Smarcel	u_char		*sc_wrbuf;
61184251Smarcel	u_int		sc_wrbufsz;
62184251Smarcel	u_int		sc_wrofs;
63184251Smarcel	u_int		sc_writing;
64184251Smarcel};
65184251Smarcel
66184251Smarcelextern char cfi_driver_name[];
67184251Smarcelextern devclass_t cfi_devclass;
68189606Ssamextern devclass_t cfi_diskclass;
69184251Smarcel
70184251Smarcelint cfi_probe(device_t);
71184251Smarcelint cfi_attach(device_t);
72184251Smarcelint cfi_detach(device_t);
73184251Smarcel
74184251Smarceluint32_t cfi_read(struct cfi_softc *, u_int);
75184251Smarceluint8_t cfi_read_qry(struct cfi_softc *, u_int);
76184251Smarcelint cfi_write_block(struct cfi_softc *);
77189606Ssamint cfi_block_start(struct cfi_softc *, u_int);
78189606Ssamint cfi_block_finish(struct cfi_softc *);
79184251Smarcel
80188156Ssam#ifdef CFI_SUPPORT_STRATAFLASH
81188156Ssamint	cfi_intel_get_factory_pr(struct cfi_softc *sc, uint64_t *);
82188156Ssamint	cfi_intel_get_oem_pr(struct cfi_softc *sc, uint64_t *);
83188156Ssamint	cfi_intel_set_oem_pr(struct cfi_softc *sc, uint64_t);
84188156Ssamint	cfi_intel_get_plr(struct cfi_softc *sc, uint32_t *);
85188156Ssamint	cfi_intel_set_plr(struct cfi_softc *sc);
86188156Ssam#endif /* CFI_SUPPORT_STRATAFLASH */
87184251Smarcel#endif /* _DEV_CFI_VAR_H_ */
88