octeon_gpio.c (274670) | octeon_gpio.c (277968) |
---|---|
1/*- 2 * Copyright (c) 2011, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 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 --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 */ 27 28/* 29 * GPIO driver for Cavium Octeon 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2011, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 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 --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 */ 27 28/* 29 * GPIO driver for Cavium Octeon 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/mips/cavium/octeon_gpio.c 274670 2014-11-18 17:22:08Z loos $"); | 33__FBSDID("$FreeBSD: head/sys/mips/cavium/octeon_gpio.c 277968 2015-01-31 12:17:07Z loos $"); |
34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/bus.h> 38 39#include <sys/kernel.h> 40#include <sys/module.h> 41#include <sys/rman.h> --- 336 unchanged lines hidden (view full) --- 378 mtx_init(&sc->gpio_mtx, device_get_nameunit(dev), NULL, MTX_DEF); 379 380 for ( i = 0; i < OCTEON_GPIO_IRQS; i++) { 381 if ((sc->gpio_irq_res[i] = bus_alloc_resource(dev, 382 SYS_RES_IRQ, &sc->gpio_irq_rid[i], 383 OCTEON_IRQ_GPIO0 + i, OCTEON_IRQ_GPIO0 + i, 1, 384 RF_SHAREABLE | RF_ACTIVE)) == NULL) { 385 device_printf(dev, "unable to allocate IRQ resource\n"); | 34 35#include <sys/param.h> 36#include <sys/systm.h> 37#include <sys/bus.h> 38 39#include <sys/kernel.h> 40#include <sys/module.h> 41#include <sys/rman.h> --- 336 unchanged lines hidden (view full) --- 378 mtx_init(&sc->gpio_mtx, device_get_nameunit(dev), NULL, MTX_DEF); 379 380 for ( i = 0; i < OCTEON_GPIO_IRQS; i++) { 381 if ((sc->gpio_irq_res[i] = bus_alloc_resource(dev, 382 SYS_RES_IRQ, &sc->gpio_irq_rid[i], 383 OCTEON_IRQ_GPIO0 + i, OCTEON_IRQ_GPIO0 + i, 1, 384 RF_SHAREABLE | RF_ACTIVE)) == NULL) { 385 device_printf(dev, "unable to allocate IRQ resource\n"); |
386 octeon_gpio_detach(dev); |
|
386 return (ENXIO); 387 } 388 389 sc->gpio_intr_cookies[i] = sc; 390 if ((bus_setup_intr(dev, sc->gpio_irq_res[i], INTR_TYPE_MISC, 391 octeon_gpio_filter, octeon_gpio_intr, 392 &(sc->gpio_intr_cookies[i]), &sc->gpio_ih[i]))) { 393 device_printf(dev, 394 "WARNING: unable to register interrupt handler\n"); | 387 return (ENXIO); 388 } 389 390 sc->gpio_intr_cookies[i] = sc; 391 if ((bus_setup_intr(dev, sc->gpio_irq_res[i], INTR_TYPE_MISC, 392 octeon_gpio_filter, octeon_gpio_intr, 393 &(sc->gpio_intr_cookies[i]), &sc->gpio_ih[i]))) { 394 device_printf(dev, 395 "WARNING: unable to register interrupt handler\n"); |
396 octeon_gpio_detach(dev); |
|
395 return (ENXIO); 396 } 397 } 398 399 sc->dev = dev; 400 /* Configure all pins as input */ 401 /* disable interrupts for all pins */ 402 pinp = octeon_gpio_pins; --- 40 unchanged lines hidden (view full) --- 443octeon_gpio_detach(device_t dev) 444{ 445 struct octeon_gpio_softc *sc = device_get_softc(dev); 446 int i; 447 448 KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized")); 449 450 for ( i = 0; i < OCTEON_GPIO_IRQS; i++) { | 397 return (ENXIO); 398 } 399 } 400 401 sc->dev = dev; 402 /* Configure all pins as input */ 403 /* disable interrupts for all pins */ 404 pinp = octeon_gpio_pins; --- 40 unchanged lines hidden (view full) --- 445octeon_gpio_detach(device_t dev) 446{ 447 struct octeon_gpio_softc *sc = device_get_softc(dev); 448 int i; 449 450 KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized")); 451 452 for ( i = 0; i < OCTEON_GPIO_IRQS; i++) { |
451 bus_release_resource(dev, SYS_RES_IRQ, 452 sc->gpio_irq_rid[i], sc->gpio_irq_res[i]); | 453 if (sc->gpio_ih[i]) 454 bus_teardown_intr(dev, sc->gpio_irq_res[i], 455 sc->gpio_ih[i]); 456 if (sc->gpio_irq_res[i]) 457 bus_release_resource(dev, SYS_RES_IRQ, 458 sc->gpio_irq_rid[i], sc->gpio_irq_res[i]); |
453 } 454 bus_generic_detach(dev); | 459 } 460 bus_generic_detach(dev); |
455 | |
456 mtx_destroy(&sc->gpio_mtx); 457 458 return(0); 459} 460 461static device_method_t octeon_gpio_methods[] = { 462 DEVMETHOD(device_identify, octeon_gpio_identify), 463 DEVMETHOD(device_probe, octeon_gpio_probe), --- 23 unchanged lines hidden --- | 461 mtx_destroy(&sc->gpio_mtx); 462 463 return(0); 464} 465 466static device_method_t octeon_gpio_methods[] = { 467 DEVMETHOD(device_identify, octeon_gpio_identify), 468 DEVMETHOD(device_probe, octeon_gpio_probe), --- 23 unchanged lines hidden --- |