diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2008-12-08 03:00:45 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2008-12-08 03:00:45 +0000 |
commit | f35bca43d425a2936ce4d49b824d33eb1b734d5f (patch) | |
tree | 94d59888b4cefdceeee74022d56ac2b09f23c02d /sys/powerpc/powermac | |
parent | 2734248c1de9552653b4af39fd65920d61f33784 (diff) | |
download | FreeBSD-src-f35bca43d425a2936ce4d49b824d33eb1b734d5f.zip FreeBSD-src-f35bca43d425a2936ce4d49b824d33eb1b734d5f.tar.gz |
Clean up the mac GPIO interface a little. Also remove bogus copyright
and 3rd license clause.
Submitted by: Marco Trillo
Diffstat (limited to 'sys/powerpc/powermac')
-rw-r--r-- | sys/powerpc/powermac/macgpio.c | 39 | ||||
-rw-r--r-- | sys/powerpc/powermac/macgpiovar.h | 16 |
2 files changed, 29 insertions, 26 deletions
diff --git a/sys/powerpc/powermac/macgpio.c b/sys/powerpc/powermac/macgpio.c index facb390..7dd58a9 100644 --- a/sys/powerpc/powermac/macgpio.c +++ b/sys/powerpc/powermac/macgpio.c @@ -1,5 +1,5 @@ /*- - * Copyright 2002 by Peter Grehan. All rights reserved. + * Copyright 2008 by Nathan Whitehorn. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -9,8 +9,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -51,6 +49,8 @@ #include <dev/ofw/ofw_bus_subr.h> #include <dev/ofw/openfirm.h> +#include <powerpc/powermac/macgpiovar.h> + /* * Macgpio softc */ @@ -62,21 +62,18 @@ struct macgpio_softc { static MALLOC_DEFINE(M_MACGPIO, "macgpio", "macgpio device information"); -static int macgpio_probe(device_t); -static int macgpio_attach(device_t); -static int macgpio_print_child(device_t dev, device_t child); -static void macgpio_probe_nomatch(device_t, device_t); -static struct resource *macgpio_alloc_resource(device_t, device_t, int, int *, - u_long, u_long, u_long, u_int); -static int macgpio_activate_resource(device_t, device_t, int, int, - struct resource *); -static int macgpio_deactivate_resource(device_t, device_t, int, int, - struct resource *); +static int macgpio_probe(device_t); +static int macgpio_attach(device_t); +static int macgpio_print_child(device_t dev, device_t child); +static void macgpio_probe_nomatch(device_t, device_t); +static struct resource *macgpio_alloc_resource(device_t, device_t, int, int *, + u_long, u_long, u_long, u_int); +static int macgpio_activate_resource(device_t, device_t, int, int, + struct resource *); +static int macgpio_deactivate_resource(device_t, device_t, int, int, + struct resource *); static ofw_bus_get_devinfo_t macgpio_get_devinfo; -uint8_t macgpio_read(device_t dev); -void macgpio_write(device_t dev,uint8_t); - /* * Bus interface definition */ @@ -125,7 +122,7 @@ struct macgpio_devinfo { struct ofw_bus_devinfo mdi_obdinfo; struct resource_list mdi_resources; - int gpio_num; + int gpio_num; }; static int @@ -215,8 +212,14 @@ macgpio_print_child(device_t dev, device_t child) dinfo = device_get_ivars(child); retval += bus_print_child_header(dev, child); + + if (dinfo->gpio_num >= GPIO_BASE) + printf(" gpio %d", dinfo->gpio_num - GPIO_BASE); + else if (dinfo->gpio_num >= GPIO_EXTINT_BASE) + printf(" extint-gpio %d", dinfo->gpio_num - GPIO_EXTINT_BASE); + else + printf(" addr 0x%02x", dinfo->gpio_num); /* should not happen */ - printf(" gpio %d",dinfo->gpio_num); resource_list_print_type(&dinfo->mdi_resources, "irq", SYS_RES_IRQ, "%ld"); retval += bus_print_child_footer(dev, child); diff --git a/sys/powerpc/powermac/macgpiovar.h b/sys/powerpc/powermac/macgpiovar.h index 0544bbc..b4f02ea 100644 --- a/sys/powerpc/powermac/macgpiovar.h +++ b/sys/powerpc/powermac/macgpiovar.h @@ -9,8 +9,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -30,13 +28,15 @@ #ifndef _MACIO_MACGPIOVAR_H_ #define _MACIO_MACGPIOVAR_H_ -struct macgpio_devinfo { - struct ofw_bus_devinfo mdi_obdinfo; - struct resource_list mdi_resources; - - int gpio_num; -}; +/* relative offsets into gpio space */ +#define GPIO_EXTINT_BASE 0x08 +#define GPIO_BASE 0x1a +/* gpio bit definitions */ +#define GPIO_DATA 0x01 /* GPIO data */ +#define GPIO_LEVEL_RO 0x02 /* read-only level on pin */ +#define GPIO_DDR_INPUT 0x00 /* use for input */ +#define GPIO_DDR_OUTPUT 0x04 /* use for output */ uint8_t macgpio_read(device_t dev); void macgpio_write(device_t dev,uint8_t); |