Commit 8a8477d7 authored by Nicolas Pitre's avatar Nicolas Pitre Committed by Russell King

[ARM PATCH] 1838/1: Lubbock leds and macro namespace cleanup

Patch from Nicolas Pitre

Too many macro with too generic names.  Let's remove unneeded code and
redundant/unused macros.  This also prevent namespace clash with upcoming 
patches.
parent bcbcfdfa
...@@ -7,12 +7,10 @@ ...@@ -7,12 +7,10 @@
* *
* Original (leds-footbridge.c) by Russell King * Original (leds-footbridge.c) by Russell King
* *
* See leds.h for bit definitions. The first version defines D28 on the * Major surgery on April 2004 by Nicolas Pitre for less global
* Lubbock dev board as the heartbeat, and D27 as the Sys_busy led. * namespace collision. Mostly adapted the Mainstone version.
* There's plenty more if you're interested in adding them :)
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -22,6 +20,21 @@ ...@@ -22,6 +20,21 @@
#include "leds.h" #include "leds.h"
/*
* 8 discrete leds available for general use:
*
* Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays
* so be sure to not monkey with them here.
*/
#define D28 (1 << 0)
#define D27 (1 << 1)
#define D26 (1 << 2)
#define D25 (1 << 3)
#define D24 (1 << 4)
#define D23 (1 << 5)
#define D22 (1 << 6)
#define D21 (1 << 7)
#define LED_STATE_ENABLED 1 #define LED_STATE_ENABLED 1
#define LED_STATE_CLAIMED 2 #define LED_STATE_CLAIMED 2
...@@ -37,7 +50,7 @@ void lubbock_leds_event(led_event_t evt) ...@@ -37,7 +50,7 @@ void lubbock_leds_event(led_event_t evt)
switch (evt) { switch (evt) {
case led_start: case led_start:
hw_led_state = HEARTBEAT_LED | SYS_BUSY_LED; hw_led_state = 0;
led_state = LED_STATE_ENABLED; led_state = LED_STATE_ENABLED;
break; break;
...@@ -47,30 +60,27 @@ void lubbock_leds_event(led_event_t evt) ...@@ -47,30 +60,27 @@ void lubbock_leds_event(led_event_t evt)
case led_claim: case led_claim:
led_state |= LED_STATE_CLAIMED; led_state |= LED_STATE_CLAIMED;
hw_led_state = HEARTBEAT_LED | SYS_BUSY_LED; hw_led_state = 0;
break; break;
case led_release: case led_release:
led_state &= ~LED_STATE_CLAIMED; led_state &= ~LED_STATE_CLAIMED;
hw_led_state = HEARTBEAT_LED | SYS_BUSY_LED; hw_led_state = 0;
break; break;
#ifdef CONFIG_LEDS_TIMER #ifdef CONFIG_LEDS_TIMER
case led_timer: case led_timer:
if (!(led_state & LED_STATE_CLAIMED)) hw_led_state ^= D26;
hw_led_state ^= HEARTBEAT_LED;
break; break;
#endif #endif
#ifdef CONFIG_LEDS_CPU #ifdef CONFIG_LEDS_CPU
case led_idle_start: case led_idle_start:
if (!(led_state & LED_STATE_CLAIMED)) hw_led_state &= ~D27;
hw_led_state |= SYS_BUSY_LED;
break; break;
case led_idle_end: case led_idle_end:
if (!(led_state & LED_STATE_CLAIMED)) hw_led_state |= D27;
hw_led_state &= ~SYS_BUSY_LED;
break; break;
#endif #endif
...@@ -78,29 +88,27 @@ void lubbock_leds_event(led_event_t evt) ...@@ -78,29 +88,27 @@ void lubbock_leds_event(led_event_t evt)
break; break;
case led_green_on: case led_green_on:
if (led_state & LED_STATE_CLAIMED) hw_led_state |= D21;;
hw_led_state &= ~HEARTBEAT_LED;
break; break;
case led_green_off: case led_green_off:
if (led_state & LED_STATE_CLAIMED) hw_led_state &= ~D21;
hw_led_state |= HEARTBEAT_LED;
break; break;
case led_amber_on: case led_amber_on:
hw_led_state |= D22;;
break; break;
case led_amber_off: case led_amber_off:
hw_led_state &= ~D22;
break; break;
case led_red_on: case led_red_on:
if (led_state & LED_STATE_CLAIMED) hw_led_state |= D23;;
hw_led_state &= ~SYS_BUSY_LED;
break; break;
case led_red_off: case led_red_off:
if (led_state & LED_STATE_CLAIMED) hw_led_state &= ~D23;
hw_led_state |= SYS_BUSY_LED;
break; break;
default: default:
...@@ -108,27 +116,9 @@ void lubbock_leds_event(led_event_t evt) ...@@ -108,27 +116,9 @@ void lubbock_leds_event(led_event_t evt)
} }
if (led_state & LED_STATE_ENABLED) if (led_state & LED_STATE_ENABLED)
{ LUB_DISC_BLNK_LED = (LUB_DISC_BLNK_LED | 0xff) & ~hw_led_state;
switch (hw_led_state) { else
case 0: // all on LUB_DISC_BLNK_LED |= 0xff;
HEARTBEAT_LED_ON;
SYS_BUSY_LED_ON;
break;
case 1: // turn off heartbeat, status on:
HEARTBEAT_LED_OFF;
SYS_BUSY_LED_ON;
break;
case 2: // status off, heartbeat on:
HEARTBEAT_LED_ON;
SYS_BUSY_LED_OFF;
break;
case 3: // turn them both off...
HEARTBEAT_LED_OFF;
SYS_BUSY_LED_OFF;
break;
default:
break;
}
}
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -10,11 +10,10 @@ ...@@ -10,11 +10,10 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#define LUBBOCK_FPGA_PHYS PXA_CS2_PHYS
#define LUBBOCK_FPGA_VIRT (0xf0000000) /* phys 0x08000000 */
#define LUBBOCK_ETH_PHYS PXA_CS3_PHYS #define LUBBOCK_ETH_PHYS PXA_CS3_PHYS
#define LUBBOCK_ETH_VIRT (0xf1000000)
#define LUBBOCK_FPGA_PHYS PXA_CS2_PHYS
#define LUBBOCK_FPGA_VIRT (0xf0000000)
#define LUB_P2V(x) ((x) - LUBBOCK_FPGA_PHYS + LUBBOCK_FPGA_VIRT) #define LUB_P2V(x) ((x) - LUBBOCK_FPGA_PHYS + LUBBOCK_FPGA_VIRT)
#define LUB_V2P(x) ((x) - LUBBOCK_FPGA_VIRT + LUBBOCK_FPGA_PHYS) #define LUB_V2P(x) ((x) - LUBBOCK_FPGA_VIRT + LUBBOCK_FPGA_PHYS)
...@@ -24,89 +23,15 @@ ...@@ -24,89 +23,15 @@
# define __LUB_REG(x) LUB_P2V(x) # define __LUB_REG(x) LUB_P2V(x)
#endif #endif
/* board level registers in the CPLD: (offsets from CPLD_BASE) */
#define WHOAMI 0 // card ID's (see programmers manual)
#define HEX_LED 0x10 // R/W access to 8 7 segment displays
#define DISC_BLNK_LED 0x40 // R/W [15-8] enables for hex leds, [7-0] discrete LEDs
#define CONF_SWITCHES 0x50 // RO [1] flash wrt prot, [0] 0= boot from rom, 1= flash
#define USER_SWITCHES 0x60 // RO [15-8] dip switches, [7-0] 2 hex encoding switches
#define MISC_WR 0x80 // R/W various system controls -see manual
#define MISC_RD 0x90 // RO various system status bits -see manual
//#define LUB_IRQ_MASK_EN 0xC0 // R/W 0= mask, 1= enable of TS, codec, ethernet, USB, SA1111, and card det. irq's
//#define LUB_IRQ_SET_CLR 0xD0 // R/W 1= set, 0 = clear IRQ's from TS, codec, etc...
//#define LUB_GP 0x100 // R/W [15-0] 16 bits of general purpose I/o for hacking
/* FPGA register physical addresses */
#define _LUB_WHOAMI (LUBBOCK_FPGA_PHYS + 0x000)
#define _LUB_HEXLED (LUBBOCK_FPGA_PHYS + 0x010)
#define _LUB_DISC_BLNK_LED (LUBBOCK_FPGA_PHYS + 0x040)
#define _LUB_CONF_SWITCHES (LUBBOCK_FPGA_PHYS + 0x050)
#define _LUB_USER_SWITCHES (LUBBOCK_FPGA_PHYS + 0x060)
#define _LUB_MISC_WR (LUBBOCK_FPGA_PHYS + 0x080)
#define _LUB_MISC_RD (LUBBOCK_FPGA_PHYS + 0x090)
#define _LUB_IRQ_MASK_EN (LUBBOCK_FPGA_PHYS + 0x0C0)
#define _LUB_IRQ_SET_CLR (LUBBOCK_FPGA_PHYS + 0x0D0)
#define _LUB_GP (LUBBOCK_FPGA_PHYS + 0x100)
/* FPGA register virtual addresses */ /* FPGA register virtual addresses */
#define LUB_WHOAMI __LUB_REG(_LUB_WHOAMI) #define LUB_WHOAMI __LUB_REG(LUBBOCK_FPGA_PHYS + 0x000)
#define LUB_HEXLED __LUB_REG(_LUB_HEXLED) #define LUB_HEXLED __LUB_REG(LUBBOCK_FPGA_PHYS + 0x010)
#define LUB_DISC_BLNK_LED __LUB_REG(_LUB_DISC_BLNK_LED) #define LUB_DISC_BLNK_LED __LUB_REG(LUBBOCK_FPGA_PHYS + 0x040)
#define LUB_CONF_SWITCHES __LUB_REG(_LUB_CONF_SWITCHES) #define LUB_CONF_SWITCHES __LUB_REG(LUBBOCK_FPGA_PHYS + 0x050)
#define LUB_USER_SWITCHES __LUB_REG(_LUB_USER_SWITCHES) #define LUB_USER_SWITCHES __LUB_REG(LUBBOCK_FPGA_PHYS + 0x060)
#define LUB_MISC_WR __LUB_REG(_LUB_MISC_WR) #define LUB_MISC_WR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
#define LUB_MISC_RD __LUB_REG(_LUB_MISC_RD) #define LUB_MISC_RD __LUB_REG(LUBBOCK_FPGA_PHYS + 0x090)
#define LUB_IRQ_MASK_EN __LUB_REG(_LUB_IRQ_MASK_EN) #define LUB_IRQ_MASK_EN __LUB_REG(LUBBOCK_FPGA_PHYS + 0x0c0)
#define LUB_IRQ_SET_CLR __LUB_REG(_LUB_IRQ_SET_CLR) #define LUB_IRQ_SET_CLR __LUB_REG(LUBBOCK_FPGA_PHYS + 0x0d0)
#define LUB_GP __LUB_REG(_LUB_GP) #define LUB_GP __LUB_REG(LUBBOCK_FPGA_PHYS + 0x100)
/* GPIOs */
#define GPIO_LUBBOCK_IRQ 0
#define IRQ_GPIO_LUBBOCK_IRQ IRQ_GPIO0
/*
* LED macros
*/
#define LEDS_BASE LUB_DISC_BLNK_LED
// 8 discrete leds available for general use:
#define D28 0x1
#define D27 0x2
#define D26 0x4
#define D25 0x8
#define D24 0x10
#define D23 0x20
#define D22 0x40
#define D21 0x80
/* Note: bits [15-8] are used to enable/blank the 8 7 segment hex displays so
* be sure to not monkey with them here.
*/
#define HEARTBEAT_LED D28
#define SYS_BUSY_LED D27
#define HEXLEDS_BASE LUB_HEXLED
#define HEARTBEAT_LED_ON (LEDS_BASE &= ~HEARTBEAT_LED)
#define HEARTBEAT_LED_OFF (LEDS_BASE |= HEARTBEAT_LED)
#define SYS_BUSY_LED_OFF (LEDS_BASE |= SYS_BUSY_LED)
#define SYS_BUSY_LED_ON (LEDS_BASE &= ~SYS_BUSY_LED)
// use x = D26-D21 for these, please...
#define DISCRETE_LED_ON(x) (LEDS_BASE &= ~(x))
#define DISCRETE_LED_OFF(x) (LEDS_BASE |= (x))
#ifndef __ASSEMBLY__
//extern int hexled_val = 0;
#endif
#define BUMP_COUNTER (HEXLEDS_BASE = hexled_val++)
#define DEC_COUNTER (HEXLEDS_BASE = hexled_val--)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment