From: Erik M. <er...@us...> - 2003-02-13 01:10:58
|
Update of /cvsroot/blob/blob/src/lib In directory sc8-pr-cvs1:/tmp/cvs-serv20927/src/lib Modified Files: Makefile.am led.c Added Files: led-mmap.c led-sa11x0.c Log Message: LED driver modularisation from Kevin O'Neill. --- NEW FILE: led-mmap.c --- /* * led_mmap.c: simple memory mapped LED control functions * * Copyright (C) 2002, 2003 by SOMA Networks Inc. * * $Id: led-mmap.c,v 1.1 2003/02/13 01:10:53 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ident "$Id: led-mmap.c,v 1.1 2003/02/13 01:10:53 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> #include <blob/led.h> #include <blob/init.h> static int led_state; static int led_locked; static void mmap_led_on(void) { volatile u16 *ledp; if(led_locked) return; ledp = (volatile u16 *)LED_ADDR; *ledp = LED_ON; led_state = 1; } static void mmap_led_off(void) { volatile u16 *ledp; if(led_locked) return; ledp = (volatile u16 *)LED_ADDR; *ledp = LED_OFF; led_state = 0; } static void mmap_led_toggle(void) { if(led_state) mmap_led_off(); else mmap_led_on(); return; } static void mmap_led_lock(void) { led_locked = 1; } static void mmap_led_unlock(void) { led_locked = 0; } led_driver_t mmap_led_driver = { led_on: mmap_led_on, led_off: mmap_led_off, led_toggle: mmap_led_toggle, led_lock: mmap_led_lock, led_unlock: mmap_led_unlock, }; --- NEW FILE: led-sa11x0.c --- /* * led-sa11x0.c: simple LED control functions * * Copyright (C) 1999 2001 Erik Mouw (J.A...@it...) * * $Id: led-sa11x0.c,v 1.1 2003/02/13 01:10:53 erikm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * All functions assume that the LED is properly initialised by the code * in ledasm.S. * */ #ident "$Id: led-sa11x0.c,v 1.1 2003/02/13 01:10:53 erikm Exp $" #ifdef HAVE_CONFIG_H # include <blob/config.h> #endif #include <blob/arch.h> #include <blob/sa1100.h> #include <blob/led.h> #include <blob/init.h> static int led_state; static int led_locked; /* TODO: fix this */ static void sa11x0_led_on(void) { if(led_locked) return; GPSR = LED_GPIO; led_state = 1; } /* TODO: fix this */ static void sa11x0_led_off(void) { if(led_locked) return; GPCR = LED_GPIO; led_state = 0; } static void sa11x0_led_toggle(void) { if(led_state) sa11x0_led_off(); else sa11x0_led_on(); return; } static void sa11x0_led_lock(void) { led_locked = 1; } static void sa11x0_led_unlock(void) { led_locked = 0; } led_driver_t sa11x0_gpio_led_driver = { led_on: sa11x0_led_on, led_off: sa11x0_led_off, led_toggle: sa11x0_led_toggle, led_lock: sa11x0_led_lock, led_unlock: sa11x0_led_unlock, }; Index: Makefile.am =================================================================== RCS file: /cvsroot/blob/blob/src/lib/Makefile.am,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Makefile.am 4 Jan 2003 02:11:43 -0000 1.23 +++ Makefile.am 13 Feb 2003 01:10:53 -0000 1.24 @@ -51,18 +51,23 @@ util.c EXTRA_libblob_a_SOURCES = \ + led-mmap.c \ + led-sa11x0.c \ reboot-pxa.c \ reboot-sa11x0.c \ serial-pxa.c \ serial-sa11x0.c + libblob_a_DEPENDENCIES = \ @BLOB_REBOOT_DRIVER_OBJS@ \ - @BLOB_SERIAL_DRIVER_OBJS@ + @BLOB_SERIAL_DRIVER_OBJS@ \ + @BLOB_LED_DRIVER_OBJS@ libblob_a_LIBADD = \ @BLOB_REBOOT_DRIVER_OBJS@ \ - @BLOB_SERIAL_DRIVER_OBJS@ + @BLOB_SERIAL_DRIVER_OBJS@ \ + @BLOB_LED_DRIVER_OBJS@ INCLUDES += \ -I${top_builddir}/include \ Index: led.c =================================================================== RCS file: /cvsroot/blob/blob/src/lib/led.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- led.c 26 Nov 2002 18:43:43 -0000 1.7 +++ led.c 13 Feb 2003 01:10:53 -0000 1.8 @@ -1,17 +1,9 @@ -/*------------------------------------------------------------------------- - * Filename: led.c - * Version: $Id$ - * Copyright: Copyright (C) 1999, Erik Mouw - * Author: Erik Mouw <J.A...@it...> - * Description: - * Created at: Mon Aug 16 15:39:12 1999 - * Modified by: Erik Mouw <J.A...@it...> - * Modified at: Mon Aug 16 16:55:21 1999 - *-----------------------------------------------------------------------*/ /* * led.c: simple LED control functions * - * Copyright (C) 1999 2001 Erik Mouw (J.A...@it...) + * Copyright (C) 2002, 2003 by SOMA Networks Inc. + * + * $Id$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,84 +20,67 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -/* - * All functions assume that the LED is properly initialised by the code - * in ledasm.S. - * - */ #ident "$Id$" #ifdef HAVE_CONFIG_H # include <blob/config.h> -#endif +#endif -#include <blob/arch.h> -#include <blob/sa1100.h> +#include <blob/debug.h> #include <blob/led.h> -#include <blob/init.h> - - - -static int led_state; -static int led_locked; - - +#include <blob/types.h> +led_driver_t *led_driver; -void led_init(void) +int led_init(void) { - led_unlock(); - led_on(); -} - - + if (led_driver == NULL){ + deprintf("No LED driver defined in arch specific file\n"); + return -1; + } -/* TODO: fix this */ -void led_on(void) -{ - if(led_locked) - return; + led_driver->led_unlock(); + led_driver->led_on(); - GPSR = LED_GPIO; - led_state = 1; + return 0; } - - -/* TODO: fix this */ -void led_off(void) +int led_on(void) { - if(led_locked) - return; + if (led_driver == NULL){ + deprintf("No LED driver defined in arch specific file\n"); + return -1; + } - GPCR = LED_GPIO; - led_state = 0; + led_driver->led_on(); + + return 0; } +int led_off(void) +{ + if (led_driver == NULL){ + deprintf("No LED driver defined in arch specific file\n"); + return -1; + } + led_driver->led_off(); + return 0; +} void led_toggle(void) { - if(led_state) - led_off(); - else - led_on(); + led_driver->led_toggle(); } - - - void led_lock(void) { - led_locked = 1; + led_driver->led_lock(); } - - - void led_unlock(void) { - led_locked = 0; + led_driver->led_unlock(); } |