Deleted Added
full compact
rt305x_gpio.c (274670) rt305x_gpio.c (277968)
1/*-
2 * Copyright (c) 2010-2011, Aleksandr Rybalko <ray@ddteam.net>
3 * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
4 * Copyright (c) 2009, Luiz Otavio O Souza.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

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

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

27 * SUCH DAMAGE.
28 */
29
30/*
31 * GPIO driver for RT305X SoC.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/mips/rt305x/rt305x_gpio.c 274670 2014-11-18 17:22:08Z loos $");
35__FBSDID("$FreeBSD: head/sys/mips/rt305x/rt305x_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>

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

425}
426
427#define DAP1350_RESET_GPIO 10
428
429static int
430rt305x_gpio_attach(device_t dev)
431{
432 struct rt305x_gpio_softc *sc = device_get_softc(dev);
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>

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

425}
426
427#define DAP1350_RESET_GPIO 10
428
429static int
430rt305x_gpio_attach(device_t dev)
431{
432 struct rt305x_gpio_softc *sc = device_get_softc(dev);
433 int error = 0, i;
433 int i;
434 uint64_t avlpins = 0;
435 sc->reset_gpio = DAP1350_RESET_GPIO;
436
437 KASSERT((device_get_unit(dev) == 0),
438 ("rt305x_gpio_gpio: Only one gpio module supported"));
439
440 mtx_init(&sc->gpio_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
441
442 /* Map control/status registers. */
443 sc->gpio_mem_rid = 0;
444 sc->gpio_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
445 &sc->gpio_mem_rid, RF_ACTIVE);
446
447 if (sc->gpio_mem_res == NULL) {
448 device_printf(dev, "couldn't map memory\n");
434 uint64_t avlpins = 0;
435 sc->reset_gpio = DAP1350_RESET_GPIO;
436
437 KASSERT((device_get_unit(dev) == 0),
438 ("rt305x_gpio_gpio: Only one gpio module supported"));
439
440 mtx_init(&sc->gpio_mtx, device_get_nameunit(dev), NULL, MTX_DEF);
441
442 /* Map control/status registers. */
443 sc->gpio_mem_rid = 0;
444 sc->gpio_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
445 &sc->gpio_mem_rid, RF_ACTIVE);
446
447 if (sc->gpio_mem_res == NULL) {
448 device_printf(dev, "couldn't map memory\n");
449 error = ENXIO;
450 rt305x_gpio_detach(dev);
449 rt305x_gpio_detach(dev);
451 return(error);
450 return (ENXIO);
452 }
453
454 if ((sc->gpio_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
455 &sc->gpio_irq_rid, RF_SHAREABLE | RF_ACTIVE)) == NULL) {
456 device_printf(dev, "unable to allocate IRQ resource\n");
451 }
452
453 if ((sc->gpio_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
454 &sc->gpio_irq_rid, RF_SHAREABLE | RF_ACTIVE)) == NULL) {
455 device_printf(dev, "unable to allocate IRQ resource\n");
456 rt305x_gpio_detach(dev);
457 return (ENXIO);
458 }
459
460 if ((bus_setup_intr(dev, sc->gpio_irq_res, INTR_TYPE_MISC,
461 /* rt305x_gpio_filter, */
462 rt305x_gpio_intr, NULL, sc, &sc->gpio_ih))) {
463 device_printf(dev,
464 "WARNING: unable to register interrupt handler\n");
457 return (ENXIO);
458 }
459
460 if ((bus_setup_intr(dev, sc->gpio_irq_res, INTR_TYPE_MISC,
461 /* rt305x_gpio_filter, */
462 rt305x_gpio_intr, NULL, sc, &sc->gpio_ih))) {
463 device_printf(dev,
464 "WARNING: unable to register interrupt handler\n");
465 rt305x_gpio_detach(dev);
465 return (ENXIO);
466 }
467
468 sc->dev = dev;
469 avlpins = rt305x_gpio_init(dev);
470
471 /* Configure all pins as input */
472 /* disable interrupts for all pins */

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

510static int
511rt305x_gpio_detach(device_t dev)
512{
513 struct rt305x_gpio_softc *sc = device_get_softc(dev);
514
515 KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized"));
516
517 bus_generic_detach(dev);
466 return (ENXIO);
467 }
468
469 sc->dev = dev;
470 avlpins = rt305x_gpio_init(dev);
471
472 /* Configure all pins as input */
473 /* disable interrupts for all pins */

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

511static int
512rt305x_gpio_detach(device_t dev)
513{
514 struct rt305x_gpio_softc *sc = device_get_softc(dev);
515
516 KASSERT(mtx_initialized(&sc->gpio_mtx), ("gpio mutex not initialized"));
517
518 bus_generic_detach(dev);
518
519 if (sc->gpio_ih)
520 bus_teardown_intr(dev, sc->gpio_irq_res, sc->gpio_ih);
521 if (sc->gpio_irq_res)
522 bus_release_resource(dev, SYS_RES_IRQ, sc->gpio_irq_rid,
523 sc->gpio_irq_res);
519 if (sc->gpio_mem_res)
520 bus_release_resource(dev, SYS_RES_MEMORY, sc->gpio_mem_rid,
521 sc->gpio_mem_res);
524 if (sc->gpio_mem_res)
525 bus_release_resource(dev, SYS_RES_MEMORY, sc->gpio_mem_rid,
526 sc->gpio_mem_res);
522
523 mtx_destroy(&sc->gpio_mtx);
524
525 return(0);
526}
527
528#ifdef notyet
529static struct resource *
530rt305x_gpio_alloc_resource(device_t bus, device_t child, int type, int *rid,

--- 77 unchanged lines hidden ---
527 mtx_destroy(&sc->gpio_mtx);
528
529 return(0);
530}
531
532#ifdef notyet
533static struct resource *
534rt305x_gpio_alloc_resource(device_t bus, device_t child, int type, int *rid,

--- 77 unchanged lines hidden ---