1/*-
2 * Copyright (c) 2007, Juniper Networks, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 *    may be used to endorse or promote products derived from this software
15 *    without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD$
30 */
31
32#ifndef _DEV_CFI_VAR_H_
33#define	_DEV_CFI_VAR_H_
34
35struct cfi_region {
36	u_int		r_blocks;
37	u_int		r_blksz;
38};
39
40struct cfi_softc {
41	device_t	sc_dev;
42
43	struct resource	*sc_res;
44	bus_space_handle_t sc_handle;
45	bus_space_tag_t	sc_tag;
46	int		sc_rid;
47
48	u_int		sc_size;	/* Flash size. */
49	u_int		sc_width;	/* Interface width. */
50	u_int		sc_regions;	/* Erase regions. */
51	struct cfi_region *sc_region;	/* Array of region info. */
52
53	u_int		sc_cmdset;
54	u_int		sc_erase_timeout;
55	u_int		sc_write_timeout;
56
57	struct cdev	*sc_nod;
58	struct proc	*sc_opened;	/* Process that has us opened. */
59
60	u_char		*sc_wrbuf;
61	u_int		sc_wrbufsz;
62	u_int		sc_wrofs;
63	u_int		sc_writing;
64};
65
66extern char cfi_driver_name[];
67extern devclass_t cfi_devclass;
68extern devclass_t cfi_diskclass;
69
70int cfi_probe(device_t);
71int cfi_attach(device_t);
72int cfi_detach(device_t);
73
74uint32_t cfi_read(struct cfi_softc *, u_int);
75uint8_t cfi_read_qry(struct cfi_softc *, u_int);
76int cfi_write_block(struct cfi_softc *);
77int cfi_block_start(struct cfi_softc *, u_int);
78int cfi_block_finish(struct cfi_softc *);
79
80#ifdef CFI_SUPPORT_STRATAFLASH
81int	cfi_intel_get_factory_pr(struct cfi_softc *sc, uint64_t *);
82int	cfi_intel_get_oem_pr(struct cfi_softc *sc, uint64_t *);
83int	cfi_intel_set_oem_pr(struct cfi_softc *sc, uint64_t);
84int	cfi_intel_get_plr(struct cfi_softc *sc, uint32_t *);
85int	cfi_intel_set_plr(struct cfi_softc *sc);
86#endif /* CFI_SUPPORT_STRATAFLASH */
87#endif /* _DEV_CFI_VAR_H_ */
88