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 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> |
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; |
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; |
204 uint64_t id; |
205 |
206 if (!ofw_bus_is_compatible(dev, "fsl,sec2.0")) |
207 return (ENXIO); 208 209 sc = device_get_softc(dev); 210 211 sc->sc_rrid = 0; |
212 sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid, 213 RF_ACTIVE); |
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; |
271 sc->sc_rres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rrid, 272 RF_ACTIVE); |
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 |
290 |
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"); |
295 |
296 if (error) 297 goto fail3; 298 } 299 |
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 --- |