Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
leds.c
Go to the documentation of this file.
1 /* ASB2303 peripheral 7-segment LEDs x1 support
2  *
3  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells ([email protected])
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public Licence
8  * as published by the Free Software Foundation; either version
9  * 2 of the Licence, or (at your option) any later version.
10  */
11 #include <linux/kernel.h>
12 #include <linux/param.h>
13 #include <linux/init.h>
14 
15 #include <asm/io.h>
16 #include <asm/processor.h>
17 #include <asm/intctl-regs.h>
18 #include <asm/rtc-regs.h>
19 #include <unit/leds.h>
20 
21 #if 0
22 static const u8 asb2303_led_hex_tbl[16] = {
23  0x80, 0xf2, 0x48, 0x60, 0x32, 0x24, 0x04, 0xf0,
24  0x00, 0x20, 0x10, 0x06, 0x8c, 0x42, 0x0c, 0x1c
25 };
26 #endif
27 
28 static const u8 asb2303_led_chase_tbl[6] = {
29  ~0x02, /* top - segA */
30  ~0x04, /* right top - segB */
31  ~0x08, /* right bottom - segC */
32  ~0x10, /* bottom - segD */
33  ~0x20, /* left bottom - segE */
34  ~0x40, /* left top - segF */
35 };
36 
37 static unsigned asb2303_led_chase;
38 
40 {
41  ASB2303_GPIO0DEF = 0x5555; /* configure as an output port */
42  ASB2303_7SEGLEDS = 0x6d; /* triple horizontal bar */
43 }
44 
46 {
47  ASB2303_GPIO0DEF = 0x5555; /* configure as an output port */
48  ASB2303_7SEGLEDS = asb2303_led_chase_tbl[asb2303_led_chase];
49  asb2303_led_chase++;
50  if (asb2303_led_chase >= 6)
51  asb2303_led_chase = 0;
52 }