x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / mn10300 / unit-asb2364 / leds.c
blob1ff830c372b31c081a08b2e03aaafbe65fad7938
1 /* leds.c: ASB2364 peripheral 7seg LEDs x4 support
3 * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/kernel.h>
13 #include <linux/param.h>
14 #include <linux/init.h>
16 #include <asm/io.h>
17 #include <asm/processor.h>
18 #include <asm/intctl-regs.h>
19 #include <asm/rtc-regs.h>
20 #include <unit/leds.h>
22 #if MN10300_USE_7SEGLEDS
23 static const u8 asb2364_led_hex_tbl[16] = {
24 0x80, 0xf2, 0x48, 0x60, 0x32, 0x24, 0x04, 0xf0,
25 0x00, 0x20, 0x10, 0x06, 0x8c, 0x42, 0x0c, 0x1c
28 static const u32 asb2364_led_chase_tbl[6] = {
29 ~0x02020202, /* top - segA */
30 ~0x04040404, /* right top - segB */
31 ~0x08080808, /* right bottom - segC */
32 ~0x10101010, /* bottom - segD */
33 ~0x20202020, /* left bottom - segE */
34 ~0x40404040, /* left top - segF */
37 static unsigned asb2364_led_chase;
39 void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points)
41 u32 leds;
43 leds = asb2364_led_hex_tbl[(val/1000) % 10];
44 leds <<= 8;
45 leds |= asb2364_led_hex_tbl[(val/100) % 10];
46 leds <<= 8;
47 leds |= asb2364_led_hex_tbl[(val/10) % 10];
48 leds <<= 8;
49 leds |= asb2364_led_hex_tbl[val % 10];
50 leds |= points^0x01010101;
52 ASB2364_7SEGLEDS = leds;
55 void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points)
57 u32 leds;
59 leds = asb2364_led_hex_tbl[(val/1000) % 10];
60 leds <<= 8;
61 leds |= asb2364_led_hex_tbl[(val/100) % 10];
62 leds <<= 8;
63 leds |= asb2364_led_hex_tbl[(val/10) % 10];
64 leds <<= 8;
65 leds |= asb2364_led_hex_tbl[val % 10];
66 leds |= points^0x01010101;
68 ASB2364_7SEGLEDS = leds;
71 /* display triple horizontal bar and exception code */
72 void peripheral_leds_display_exception(enum exception_code code)
74 u32 leds;
76 leds = asb2364_led_hex_tbl[(code/0x100) % 0x10];
77 leds <<= 8;
78 leds |= asb2364_led_hex_tbl[(code/0x10) % 0x10];
79 leds <<= 8;
80 leds |= asb2364_led_hex_tbl[code % 0x10];
81 leds |= 0x6d010101;
83 ASB2364_7SEGLEDS = leds;
86 void peripheral_leds_led_chase(void)
88 ASB2364_7SEGLEDS = asb2364_led_chase_tbl[asb2364_led_chase];
89 asb2364_led_chase++;
90 if (asb2364_led_chase >= 6)
91 asb2364_led_chase = 0;
93 #else /* MN10300_USE_7SEGLEDS */
94 void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points) { }
95 void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points) { }
96 void peripheral_leds_display_exception(enum exception_code code) { }
97 void peripheral_leds_led_chase(void) { }
98 #endif /* MN10300_USE_7SEGLEDS */