Deleted Added
sdiff udiff text old ( 193936 ) new ( 233553 )
full compact
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

--- 14 unchanged lines hidden (view full) ---

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
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/cfi/cfi_core.c 233553 2012-03-27 15:13:12Z jchandra $");
32
33#include "opt_cfi.h"
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/bus.h>
38#include <sys/conf.h>
39#include <sys/endian.h>
40#include <sys/kernel.h>
41#include <sys/malloc.h>
42#include <sys/module.h>
43#include <sys/rman.h>
44#include <sys/sysctl.h>
45
46#include <machine/bus.h>
47
48#include <dev/cfi/cfi_reg.h>
49#include <dev/cfi/cfi_var.h>
50
51extern struct cdevsw cfi_cdevsw;
52
53char cfi_driver_name[] = "cfi";
54devclass_t cfi_devclass;
55devclass_t cfi_diskclass;
56
57uint32_t
58cfi_read_raw(struct cfi_softc *sc, u_int ofs)
59{
60 uint32_t val;
61
62 ofs &= ~(sc->sc_width - 1);
63 switch (sc->sc_width) {
64 case 1:
65 val = bus_space_read_1(sc->sc_tag, sc->sc_handle, ofs);
66 break;

--- 5 unchanged lines hidden (view full) ---

72 break;
73 default:
74 val = ~0;
75 break;
76 }
77 return (val);
78}
79
80uint32_t
81cfi_read(struct cfi_softc *sc, u_int ofs)
82{
83 uint32_t val;
84 uint16_t sval;
85
86 ofs &= ~(sc->sc_width - 1);
87 switch (sc->sc_width) {
88 case 1:
89 val = bus_space_read_1(sc->sc_tag, sc->sc_handle, ofs);
90 break;
91 case 2:
92 sval = bus_space_read_2(sc->sc_tag, sc->sc_handle, ofs);
93 val = le16toh(sval);
94 break;
95 case 4:
96 val = bus_space_read_4(sc->sc_tag, sc->sc_handle, ofs);
97 val = le32toh(val);
98 break;
99 default:
100 val = ~0;
101 break;
102 }
103 return (val);
104}
105
106static void
107cfi_write(struct cfi_softc *sc, u_int ofs, u_int val)
108{
109
110 ofs &= ~(sc->sc_width - 1);
111 switch (sc->sc_width) {
112 case 1:
113 bus_space_write_1(sc->sc_tag, sc->sc_handle, ofs, val);
114 break;
115 case 2:
116 bus_space_write_2(sc->sc_tag, sc->sc_handle, ofs, htole16(val));
117 break;
118 case 4:
119 bus_space_write_4(sc->sc_tag, sc->sc_handle, ofs, htole32(val));
120 break;
121 }
122}
123
124uint8_t
125cfi_read_qry(struct cfi_softc *sc, u_int ofs)
126{
127 uint8_t val;

--- 487 unchanged lines hidden ---