Deleted Added
full compact
sec.c (194101) sec.c (209908)
1/*-
2 * Copyright (C) 2008-2009 Semihalf, Piotr Ziecik
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

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

24 */
25
26/*
27 * Freescale integrated Security Engine (SEC) driver. Currently SEC 2.0 and
28 * 3.0 are supported.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 2008-2009 Semihalf, Piotr Ziecik
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

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

24 */
25
26/*
27 * Freescale integrated Security Engine (SEC) driver. Currently SEC 2.0 and
28 * 3.0 are supported.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/sec/sec.c 194101 2009-06-13 08:57:04Z raj $");
32__FBSDID("$FreeBSD: head/sys/dev/sec/sec.c 209908 2010-07-11 21:08:29Z raj $");
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bus.h>
37#include <sys/endian.h>
38#include <sys/kernel.h>
39#include <sys/lock.h>
40#include <sys/malloc.h>
41#include <sys/mbuf.h>
42#include <sys/module.h>
43#include <sys/mutex.h>
44#include <sys/random.h>
45#include <sys/rman.h>
46
47#include <machine/bus.h>
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bus.h>
37#include <sys/endian.h>
38#include <sys/kernel.h>
39#include <sys/lock.h>
40#include <sys/malloc.h>
41#include <sys/mbuf.h>
42#include <sys/module.h>
43#include <sys/mutex.h>
44#include <sys/random.h>
45#include <sys/rman.h>
46
47#include <machine/bus.h>
48#include <machine/ocpbus.h>
49#include <machine/resource.h>
50
51#include <opencrypto/cryptodev.h>
52#include "cryptodev_if.h"
53
48#include <machine/resource.h>
49
50#include <opencrypto/cryptodev.h>
51#include "cryptodev_if.h"
52
53#include <dev/ofw/ofw_bus_subr.h>
54#include <dev/sec/sec.h>
55
56static int sec_probe(device_t dev);
57static int sec_attach(device_t dev);
58static int sec_detach(device_t dev);
59static int sec_suspend(device_t dev);
60static int sec_resume(device_t dev);
61static int sec_shutdown(device_t dev);

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

148};
149static driver_t sec_driver = {
150 "sec",
151 sec_methods,
152 sizeof(struct sec_softc),
153};
154
155static devclass_t sec_devclass;
54#include <dev/sec/sec.h>
55
56static int sec_probe(device_t dev);
57static int sec_attach(device_t dev);
58static int sec_detach(device_t dev);
59static int sec_suspend(device_t dev);
60static int sec_resume(device_t dev);
61static int sec_shutdown(device_t dev);

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

148};
149static driver_t sec_driver = {
150 "sec",
151 sec_methods,
152 sizeof(struct sec_softc),
153};
154
155static devclass_t sec_devclass;
156DRIVER_MODULE(sec, ocpbus, sec_driver, sec_devclass, 0, 0);
156DRIVER_MODULE(sec, simplebus, sec_driver, sec_devclass, 0, 0);
157MODULE_DEPEND(sec, crypto, 1, 1, 1);
158
159static struct sec_eu_methods sec_eus[] = {
160 {
161 sec_aesu_newsession,
162 sec_aesu_make_desc,
163 },
164 {

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

196
197 return (desc->sd_ptr_dmem[n].dma_vaddr);
198}
199
200static int
201sec_probe(device_t dev)
202{
203 struct sec_softc *sc;
157MODULE_DEPEND(sec, crypto, 1, 1, 1);
158
159static struct sec_eu_methods sec_eus[] = {
160 {
161 sec_aesu_newsession,
162 sec_aesu_make_desc,
163 },
164 {

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

196
197 return (desc->sd_ptr_dmem[n].dma_vaddr);
198}
199
200static int
201sec_probe(device_t dev)
202{
203 struct sec_softc *sc;
204 device_t parent;
205 uintptr_t devtype;
206 uint64_t id;
204 uint64_t id;
207 int error;
208
205
209 parent = device_get_parent(dev);
210 error = BUS_READ_IVAR(parent, dev, OCPBUS_IVAR_DEVTYPE, &devtype);
211 if (error)
212 return (error);
213
214 if (devtype != OCPBUS_DEVTYPE_SEC)
206 if (!ofw_bus_is_compatible(dev, "fsl,sec2.0"))
215 return (ENXIO);
216
217 sc = device_get_softc(dev);
218
219 sc->sc_rrid = 0;
207 return (ENXIO);
208
209 sc = device_get_softc(dev);
210
211 sc->sc_rrid = 0;
220 sc->sc_rres = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->sc_rrid,
221 0ul, ~0ul, SEC_IO_SIZE, RF_ACTIVE);
212 sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid,
213 RF_ACTIVE);
222
223 if (sc->sc_rres == NULL)
224 return (ENXIO);
225
226 sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
227 sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
228
229 id = SEC_READ(sc, SEC_ID);

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

271 "SEC Controller lock", MTX_DEF);
272 mtx_init(&sc->sc_descriptors_lock, device_get_nameunit(dev),
273 "SEC Descriptors lock", MTX_DEF);
274 mtx_init(&sc->sc_sessions_lock, device_get_nameunit(dev),
275 "SEC Sessions lock", MTX_DEF);
276
277 /* Allocate I/O memory for SEC registers */
278 sc->sc_rrid = 0;
214
215 if (sc->sc_rres == NULL)
216 return (ENXIO);
217
218 sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
219 sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
220
221 id = SEC_READ(sc, SEC_ID);

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

263 "SEC Controller lock", MTX_DEF);
264 mtx_init(&sc->sc_descriptors_lock, device_get_nameunit(dev),
265 "SEC Descriptors lock", MTX_DEF);
266 mtx_init(&sc->sc_sessions_lock, device_get_nameunit(dev),
267 "SEC Sessions lock", MTX_DEF);
268
269 /* Allocate I/O memory for SEC registers */
270 sc->sc_rrid = 0;
279 sc->sc_rres = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->sc_rrid,
280 0ul, ~0ul, SEC_IO_SIZE, RF_ACTIVE);
271 sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid,
272 RF_ACTIVE);
281
282 if (sc->sc_rres == NULL) {
283 device_printf(dev, "could not allocate I/O memory!\n");
284 goto fail1;
285 }
286
287 sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
288 sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
289
290 /* Setup interrupts */
291 sc->sc_pri_irid = 0;
292 error = sec_setup_intr(sc, &sc->sc_pri_ires, &sc->sc_pri_ihand,
293 &sc->sc_pri_irid, sec_primary_intr, "primary");
294
295 if (error)
296 goto fail2;
297
273
274 if (sc->sc_rres == NULL) {
275 device_printf(dev, "could not allocate I/O memory!\n");
276 goto fail1;
277 }
278
279 sc->sc_bas.bsh = rman_get_bushandle(sc->sc_rres);
280 sc->sc_bas.bst = rman_get_bustag(sc->sc_rres);
281
282 /* Setup interrupts */
283 sc->sc_pri_irid = 0;
284 error = sec_setup_intr(sc, &sc->sc_pri_ires, &sc->sc_pri_ihand,
285 &sc->sc_pri_irid, sec_primary_intr, "primary");
286
287 if (error)
288 goto fail2;
289
298 sc->sc_sec_irid = 1;
299 error = sec_setup_intr(sc, &sc->sc_sec_ires, &sc->sc_sec_ihand,
300 &sc->sc_sec_irid, sec_secondary_intr, "secondary");
301
290
302 if (error)
303 goto fail3;
291 if (sc->sc_version == 3) {
292 sc->sc_sec_irid = 1;
293 error = sec_setup_intr(sc, &sc->sc_sec_ires, &sc->sc_sec_ihand,
294 &sc->sc_sec_irid, sec_secondary_intr, "secondary");
304
295
296 if (error)
297 goto fail3;
298 }
299
305 /* Alloc DMA memory for descriptors and link tables */
306 error = sec_alloc_dma_mem(sc, &(sc->sc_desc_dmem),
307 SEC_DESCRIPTORS * sizeof(struct sec_hw_desc));
308
309 if (error)
310 goto fail4;
311
312 error = sec_alloc_dma_mem(sc, &(sc->sc_lt_dmem),

--- 1565 unchanged lines hidden ---
300 /* Alloc DMA memory for descriptors and link tables */
301 error = sec_alloc_dma_mem(sc, &(sc->sc_desc_dmem),
302 SEC_DESCRIPTORS * sizeof(struct sec_hw_desc));
303
304 if (error)
305 goto fail4;
306
307 error = sec_alloc_dma_mem(sc, &(sc->sc_lt_dmem),

--- 1565 unchanged lines hidden ---