Deleted Added
full compact
ar71xx_gpio.c (213239) ar71xx_gpio.c (213286)
1/*-
2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3 * Copyright (c) 2009, Luiz Otavio O Souza.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

26 * SUCH DAMAGE.
27 */
28
29/*
30 * GPIO driver for AR71xx
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
3 * Copyright (c) 2009, Luiz Otavio O Souza.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

26 * SUCH DAMAGE.
27 */
28
29/*
30 * GPIO driver for AR71xx
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/mips/atheros/ar71xx_gpio.c 213239 2010-09-28 03:31:34Z gonzo $");
34__FBSDID("$FreeBSD: head/sys/mips/atheros/ar71xx_gpio.c 213286 2010-09-29 23:06:41Z gonzo $");
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/bus.h>
39
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/rman.h>

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

370 if ((bus_setup_intr(dev, sc->gpio_irq_res, INTR_TYPE_MISC,
371 ar71xx_gpio_filter, ar71xx_gpio_intr, sc, &sc->gpio_ih))) {
372 device_printf(dev,
373 "WARNING: unable to register interrupt handler\n");
374 return (ENXIO);
375 }
376
377 sc->dev = dev;
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/bus.h>
39
40#include <sys/kernel.h>
41#include <sys/module.h>
42#include <sys/rman.h>

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

370 if ((bus_setup_intr(dev, sc->gpio_irq_res, INTR_TYPE_MISC,
371 ar71xx_gpio_filter, ar71xx_gpio_intr, sc, &sc->gpio_ih))) {
372 device_printf(dev,
373 "WARNING: unable to register interrupt handler\n");
374 return (ENXIO);
375 }
376
377 sc->dev = dev;
378 ar71xx_gpio_function_enable(sc, GPIO_SPI_CS1_EN);
379 ar71xx_gpio_function_enable(sc, GPIO_SPI_CS2_EN);
378 ar71xx_gpio_function_enable(sc, GPIO_FUNC_SPI_CS1_EN);
379 ar71xx_gpio_function_enable(sc, GPIO_FUNC_SPI_CS2_EN);
380 /* Configure all pins as input */
381 /* disable interrupts for all pins */
382 GPIO_WRITE(sc, AR71XX_GPIO_INT_MASK, 0);
383 pinp = ar71xx_gpio_pins;
384 i = 0;
385 while (pinp->name) {
386 strncpy(sc->gpio_pins[i].gp_name, pinp->name, GPIOMAXNAME);
387 sc->gpio_pins[i].gp_pin = pinp->pin;

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

401
402static int
403ar71xx_gpio_detach(device_t dev)
404{
405 struct ar71xx_gpio_softc *sc = device_get_softc(dev);
406
407 KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized"));
408
380 /* Configure all pins as input */
381 /* disable interrupts for all pins */
382 GPIO_WRITE(sc, AR71XX_GPIO_INT_MASK, 0);
383 pinp = ar71xx_gpio_pins;
384 i = 0;
385 while (pinp->name) {
386 strncpy(sc->gpio_pins[i].gp_name, pinp->name, GPIOMAXNAME);
387 sc->gpio_pins[i].gp_pin = pinp->pin;

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

401
402static int
403ar71xx_gpio_detach(device_t dev)
404{
405 struct ar71xx_gpio_softc *sc = device_get_softc(dev);
406
407 KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized"));
408
409 ar71xx_gpio_function_disable(sc, GPIO_SPI_CS1_EN);
410 ar71xx_gpio_function_disable(sc, GPIO_SPI_CS2_EN);
409 ar71xx_gpio_function_disable(sc, GPIO_FUNC_SPI_CS1_EN);
410 ar71xx_gpio_function_disable(sc, GPIO_FUNC_SPI_CS2_EN);
411 bus_generic_detach(dev);
412
413 if (sc->gpio_mem_res)
414 bus_release_resource(dev, SYS_RES_MEMORY, sc->gpio_mem_rid,
415 sc->gpio_mem_res);
416
417 mtx_destroy(&sc->gpio_mtx);
418

--- 28 unchanged lines hidden ---
411 bus_generic_detach(dev);
412
413 if (sc->gpio_mem_res)
414 bus_release_resource(dev, SYS_RES_MEMORY, sc->gpio_mem_rid,
415 sc->gpio_mem_res);
416
417 mtx_destroy(&sc->gpio_mtx);
418

--- 28 unchanged lines hidden ---