Deleted Added
full compact
imx_gpio.c (274670) imx_gpio.c (277968)
1/*-
2 * Copyright (c) 2012, 2013 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Oleksandr Rybalko under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

27 * SUCH DAMAGE.
28 */
29
30/*
31 * Freescale i.MX515 GPIO driver.
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2012, 2013 The FreeBSD Foundation
3 * All rights reserved.
4 *
5 * This software was developed by Oleksandr Rybalko under sponsorship
6 * from the FreeBSD Foundation.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

27 * SUCH DAMAGE.
28 */
29
30/*
31 * Freescale i.MX515 GPIO driver.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/arm/freescale/imx/imx_gpio.c 274670 2014-11-18 17:22:08Z loos $");
35__FBSDID("$FreeBSD: head/sys/arm/freescale/imx/imx_gpio.c 277968 2015-01-31 12:17:07Z loos $");
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>
40
41#include <sys/kernel.h>
42#include <sys/module.h>
43#include <sys/rman.h>

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

384 struct imx51_gpio_softc *sc;
385 int i, irq;
386
387 sc = device_get_softc(dev);
388 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
389
390 if (bus_alloc_resources(dev, imx_gpio_spec, sc->sc_res)) {
391 device_printf(dev, "could not allocate resources\n");
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/bus.h>
40
41#include <sys/kernel.h>
42#include <sys/module.h>
43#include <sys/rman.h>

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

384 struct imx51_gpio_softc *sc;
385 int i, irq;
386
387 sc = device_get_softc(dev);
388 mtx_init(&sc->sc_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
389
390 if (bus_alloc_resources(dev, imx_gpio_spec, sc->sc_res)) {
391 device_printf(dev, "could not allocate resources\n");
392 bus_release_resources(dev, imx_gpio_spec, sc->sc_res);
393 mtx_destroy(&sc->sc_mtx);
392 return (ENXIO);
393 }
394
395 sc->dev = dev;
396 sc->gpio_npins = NGPIO;
397 sc->sc_l_irq = 2;
398 sc->sc_iot = rman_get_bustag(sc->sc_res[0]);
399 sc->sc_ioh = rman_get_bushandle(sc->sc_res[0]);

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

406 sc->sc_l_irq = 10;
407 }
408
409 for (irq = 1; irq <= sc->sc_l_irq; irq ++) {
410 if ((bus_setup_intr(dev, sc->sc_res[irq], INTR_TYPE_MISC,
411 imx51_gpio_intr, NULL, sc, &sc->gpio_ih[irq]))) {
412 device_printf(dev,
413 "WARNING: unable to register interrupt handler\n");
394 return (ENXIO);
395 }
396
397 sc->dev = dev;
398 sc->gpio_npins = NGPIO;
399 sc->sc_l_irq = 2;
400 sc->sc_iot = rman_get_bustag(sc->sc_res[0]);
401 sc->sc_ioh = rman_get_bushandle(sc->sc_res[0]);

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

408 sc->sc_l_irq = 10;
409 }
410
411 for (irq = 1; irq <= sc->sc_l_irq; irq ++) {
412 if ((bus_setup_intr(dev, sc->sc_res[irq], INTR_TYPE_MISC,
413 imx51_gpio_intr, NULL, sc, &sc->gpio_ih[irq]))) {
414 device_printf(dev,
415 "WARNING: unable to register interrupt handler\n");
416 imx51_gpio_detach(dev);
414 return (ENXIO);
415 }
416 }
417
418 for (i = 0; i < sc->gpio_npins; i++) {
419 sc->gpio_pins[i].gp_pin = i;
420 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
421 sc->gpio_pins[i].gp_flags =

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

429 device_add_child(dev, "gpiobus", -1);
430
431 return (bus_generic_attach(dev));
432}
433
434static int
435imx51_gpio_detach(device_t dev)
436{
417 return (ENXIO);
418 }
419 }
420
421 for (i = 0; i < sc->gpio_npins; i++) {
422 sc->gpio_pins[i].gp_pin = i;
423 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
424 sc->gpio_pins[i].gp_flags =

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

432 device_add_child(dev, "gpiobus", -1);
433
434 return (bus_generic_attach(dev));
435}
436
437static int
438imx51_gpio_detach(device_t dev)
439{
440 int irq;
437 struct imx51_gpio_softc *sc;
438
439 sc = device_get_softc(dev);
440
441 KASSERT(mtx_initialized(&sc->sc_mtx), ("gpio mutex not initialized"));
442
443 bus_generic_detach(dev);
441 struct imx51_gpio_softc *sc;
442
443 sc = device_get_softc(dev);
444
445 KASSERT(mtx_initialized(&sc->sc_mtx), ("gpio mutex not initialized"));
446
447 bus_generic_detach(dev);
444
445 if (sc->sc_res[3])
446 bus_release_resources(dev, imx_gpio0irq_spec, &sc->sc_res[3]);
447
448 if (sc->sc_res[0])
449 bus_release_resources(dev, imx_gpio_spec, sc->sc_res);
450
448 for (irq = 1; irq <= sc->sc_l_irq; irq ++) {
449 if (sc->gpio_ih[irq])
450 bus_teardown_intr(dev, sc->sc_res[irq], sc->gpio_ih[irq]);
451 }
452 bus_release_resources(dev, imx_gpio0irq_spec, &sc->sc_res[3]);
453 bus_release_resources(dev, imx_gpio_spec, sc->sc_res);
451 mtx_destroy(&sc->sc_mtx);
452
453 return(0);
454}
455
456static device_method_t imx51_gpio_methods[] = {
457 DEVMETHOD(device_probe, imx51_gpio_probe),
458 DEVMETHOD(device_attach, imx51_gpio_attach),

--- 23 unchanged lines hidden ---
454 mtx_destroy(&sc->sc_mtx);
455
456 return(0);
457}
458
459static device_method_t imx51_gpio_methods[] = {
460 DEVMETHOD(device_probe, imx51_gpio_probe),
461 DEVMETHOD(device_attach, imx51_gpio_attach),

--- 23 unchanged lines hidden ---