Deleted Added
sdiff udiff text old ( 255334 ) new ( 255335 )
full compact
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 255334 2013-09-06 23:39:56Z loos $");
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>
43#include <sys/lock.h>
44#include <sys/mutex.h>
45#include <sys/gpio.h>
46
47#include <machine/bus.h>
48#include <machine/resource.h>
49#include <mips/atheros/ar71xxreg.h>
50#include <mips/atheros/ar71xx_setup.h>
51#include <mips/atheros/ar71xx_gpiovar.h>

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

413 (void) ar71xx_gpio_pin_max(dev, &maxpin);
414 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
415 "pinmask", &mask) != 0)
416 mask = 0;
417 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
418 "pinon", &pinon) != 0)
419 pinon = 0;
420 device_printf(dev, "gpio pinmask=0x%x\n", mask);
421 for (i = 0, j = 0; j <= maxpin; j++) {
422 if ((mask & (1 << j)) == 0)
423 continue;
424 snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
425 "pin %d", j);
426 sc->gpio_pins[i].gp_pin = j;
427 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
428 sc->gpio_pins[i].gp_flags = 0;
429 ar71xx_gpio_pin_configure(sc, &sc->gpio_pins[i], DEFAULT_CAPS);
430 i++;
431 }
432 sc->gpio_npins = i;
433 for (i = 0; i < sc->gpio_npins; i++) {
434 j = sc->gpio_pins[i].gp_pin;
435 if ((pinon & (1 << j)) != 0)
436 ar71xx_gpio_pin_set(dev, j, 1);
437 }
438 device_add_child(dev, "gpioc", device_get_unit(dev));
439 device_add_child(dev, "gpiobus", device_get_unit(dev));
440 return (bus_generic_attach(dev));

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

450 ar71xx_gpio_function_disable(sc, GPIO_FUNC_SPI_CS1_EN);
451 ar71xx_gpio_function_disable(sc, GPIO_FUNC_SPI_CS2_EN);
452 bus_generic_detach(dev);
453
454 if (sc->gpio_mem_res)
455 bus_release_resource(dev, SYS_RES_MEMORY, sc->gpio_mem_rid,
456 sc->gpio_mem_res);
457
458 mtx_destroy(&sc->gpio_mtx);
459
460 return(0);
461}
462
463static device_method_t ar71xx_gpio_methods[] = {
464 DEVMETHOD(device_probe, ar71xx_gpio_probe),
465 DEVMETHOD(device_attach, ar71xx_gpio_attach),

--- 22 unchanged lines hidden ---