Deleted Added
full compact
cfi_core.c (193936) cfi_core.c (233553)
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>
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 193936 2009-06-10 17:41:24Z imp $");
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>
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>
39#include <sys/kernel.h>
40#include <sys/malloc.h>
41#include <sys/module.h>
42#include <sys/rman.h>
43#include <sys/sysctl.h>
44
45#include <machine/bus.h>
46
47#include <dev/cfi/cfi_reg.h>
48#include <dev/cfi/cfi_var.h>
49
50extern struct cdevsw cfi_cdevsw;
51
52char cfi_driver_name[] = "cfi";
53devclass_t cfi_devclass;
54devclass_t cfi_diskclass;
55
56uint32_t
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
57cfi_read(struct cfi_softc *sc, u_int ofs)
58cfi_read_raw(struct cfi_softc *sc, u_int ofs)
58{
59 uint32_t val;
60
61 ofs &= ~(sc->sc_width - 1);
62 switch (sc->sc_width) {
63 case 1:
64 val = bus_space_read_1(sc->sc_tag, sc->sc_handle, ofs);
65 break;

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

71 break;
72 default:
73 val = ~0;
74 break;
75 }
76 return (val);
77}
78
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
79static void
80cfi_write(struct cfi_softc *sc, u_int ofs, u_int val)
81{
82
83 ofs &= ~(sc->sc_width - 1);
84 switch (sc->sc_width) {
85 case 1:
86 bus_space_write_1(sc->sc_tag, sc->sc_handle, ofs, val);
87 break;
88 case 2:
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:
89 bus_space_write_2(sc->sc_tag, sc->sc_handle, ofs, val);
116 bus_space_write_2(sc->sc_tag, sc->sc_handle, ofs, htole16(val));
90 break;
91 case 4:
117 break;
118 case 4:
92 bus_space_write_4(sc->sc_tag, sc->sc_handle, ofs, val);
119 bus_space_write_4(sc->sc_tag, sc->sc_handle, ofs, htole32(val));
93 break;
94 }
95}
96
97uint8_t
98cfi_read_qry(struct cfi_softc *sc, u_int ofs)
99{
100 uint8_t val;

--- 487 unchanged lines hidden ---
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 ---