Deleted Added
full compact
exynos5_pad.c (274670) exynos5_pad.c (277968)
1/*-
2 * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com>
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 */
26
27/*
28 * Samsung Exynos 5 Pad Control
29 * Chapter 4, Exynos 5 Dual User's Manual Public Rev 1.00
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com>
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 */
26
27/*
28 * Samsung Exynos 5 Pad Control
29 * Chapter 4, Exynos 5 Dual User's Manual Public Rev 1.00
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/arm/samsung/exynos/exynos5_pad.c 274670 2014-11-18 17:22:08Z loos $");
33__FBSDID("$FreeBSD: head/sys/arm/samsung/exynos/exynos5_pad.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#include <sys/kernel.h>
39#include <sys/module.h>
40#include <sys/malloc.h>
41#include <sys/rman.h>

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

504 case EXYNOS5420:
505 sc->pad_spec = pad_spec_5420;
506 sc->gpio_map = gpio_map_5420;
507 sc->interrupt_table = interrupt_table_5420;
508 sc->gpio_npins = 232;
509 sc->nports = 5;
510 break;
511 default:
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/bus.h>
38#include <sys/kernel.h>
39#include <sys/module.h>
40#include <sys/malloc.h>
41#include <sys/rman.h>

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

504 case EXYNOS5420:
505 sc->pad_spec = pad_spec_5420;
506 sc->gpio_map = gpio_map_5420;
507 sc->interrupt_table = interrupt_table_5420;
508 sc->gpio_npins = 232;
509 sc->nports = 5;
510 break;
511 default:
512 return (-1);
512 goto fail;
513 };
514
515 if (bus_alloc_resources(dev, sc->pad_spec, sc->res)) {
516 device_printf(dev, "could not allocate resources\n");
513 };
514
515 if (bus_alloc_resources(dev, sc->pad_spec, sc->res)) {
516 device_printf(dev, "could not allocate resources\n");
517 return (ENXIO);
517 goto fail;
518 }
519
520 /* Memory interface */
521
522 for (i = 0; i < sc->nports; i++) {
523 sc->bst[i] = rman_get_bustag(sc->res[i]);
524 sc->bsh[i] = rman_get_bushandle(sc->res[i]);
525 };
526
527 sc->dev = dev;
528
529 gpio_sc = sc;
530
531 for (i = 0; i < sc->nports; i++) {
532 if ((bus_setup_intr(dev, sc->res[sc->nports + i],
533 INTR_TYPE_BIO | INTR_MPSAFE, port_intr,
534 NULL, sc, &sc->gpio_ih[i]))) {
535 device_printf(dev,
536 "ERROR: Unable to register interrupt handler\n");
518 }
519
520 /* Memory interface */
521
522 for (i = 0; i < sc->nports; i++) {
523 sc->bst[i] = rman_get_bustag(sc->res[i]);
524 sc->bsh[i] = rman_get_bushandle(sc->res[i]);
525 };
526
527 sc->dev = dev;
528
529 gpio_sc = sc;
530
531 for (i = 0; i < sc->nports; i++) {
532 if ((bus_setup_intr(dev, sc->res[sc->nports + i],
533 INTR_TYPE_BIO | INTR_MPSAFE, port_intr,
534 NULL, sc, &sc->gpio_ih[i]))) {
535 device_printf(dev,
536 "ERROR: Unable to register interrupt handler\n");
537 return (ENXIO);
537 goto fail;
538 }
538 }
539 };
539 }
540
541 for (i = 0; i < sc->gpio_npins; i++) {
542 sc->gpio_pins[i].gp_pin = i;
543 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
544
545 if (get_bank(sc, i, &bank, &pin_shift) != 0)
546 continue;
547

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

558 snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
559 "pad%d.%d", device_get_unit(dev), i);
560 }
561
562 device_add_child(dev, "gpioc", -1);
563 device_add_child(dev, "gpiobus", -1);
564
565 return (bus_generic_attach(dev));
540
541 for (i = 0; i < sc->gpio_npins; i++) {
542 sc->gpio_pins[i].gp_pin = i;
543 sc->gpio_pins[i].gp_caps = DEFAULT_CAPS;
544
545 if (get_bank(sc, i, &bank, &pin_shift) != 0)
546 continue;
547

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

558 snprintf(sc->gpio_pins[i].gp_name, GPIOMAXNAME,
559 "pad%d.%d", device_get_unit(dev), i);
560 }
561
562 device_add_child(dev, "gpioc", -1);
563 device_add_child(dev, "gpiobus", -1);
564
565 return (bus_generic_attach(dev));
566
567fail:
568 for (i = 0; i < sc->nports; i++) {
569 if (sc->gpio_ih[i])
570 bus_teardown_intr(dev, sc->res[sc->nports + i],
571 sc->gpio_ih[i]);
572 }
573 bus_release_resources(dev, sc->pad_spec, sc->res);
574 mtx_destroy(&sc->sc_mtx);
575
576 return (ENXIO);
566}
567
568static int
569pad_pin_max(device_t dev, int *maxpin)
570{
571 struct pad_softc *sc;
572
573 sc = device_get_softc(dev);

--- 255 unchanged lines hidden ---
577}
578
579static int
580pad_pin_max(device_t dev, int *maxpin)
581{
582 struct pad_softc *sc;
583
584 sc = device_get_softc(dev);

--- 255 unchanged lines hidden ---