1 /* ASB2305 Peripheral 7-segment LEDs x4 support
3 * Copyright (C) 2007 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 Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #include <linux/kernel.h>
12 #include <linux/param.h>
13 #include <linux/init.h>
15 #include <asm/processor.h>
16 #include <asm/cpu/intctl-regs.h>
17 #include <asm/cpu/rtc-regs.h>
18 #include <asm/unit/leds.h>
20 static const u8 asb2305_led_hex_tbl[16] = {
21 0x80, 0xf2, 0x48, 0x60, 0x32, 0x24, 0x04, 0xf0,
22 0x00, 0x20, 0x10, 0x06, 0x8c, 0x42, 0x0c, 0x1c
25 static const u32 asb2305_led_chase_tbl[6] = {
26 ~0x02020202, /* top - segA */
27 ~0x04040404, /* right top - segB */
28 ~0x08080808, /* right bottom - segC */
29 ~0x10101010, /* bottom - segD */
30 ~0x20202020, /* left bottom - segE */
31 ~0x40404040, /* left top - segF */
34 static unsigned asb2305_led_chase;
36 void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points)
40 leds = asb2305_led_hex_tbl[(val/1000) % 10];
42 leds |= asb2305_led_hex_tbl[(val/100) % 10];
44 leds |= asb2305_led_hex_tbl[(val/10) % 10];
46 leds |= asb2305_led_hex_tbl[val % 10];
47 leds |= points^0x01010101;
49 ASB2305_7SEGLEDS = leds;
52 void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points)
56 leds = asb2305_led_hex_tbl[(val/1000) % 10];
58 leds |= asb2305_led_hex_tbl[(val/100) % 10];
60 leds |= asb2305_led_hex_tbl[(val/10) % 10];
62 leds |= asb2305_led_hex_tbl[val % 10];
63 leds |= points^0x01010101;
65 ASB2305_7SEGLEDS = leds;
68 void peripheral_leds_display_exception(enum exception_code code)
72 leds = asb2305_led_hex_tbl[(code/0x100) % 0x10];
74 leds |= asb2305_led_hex_tbl[(code/0x10) % 0x10];
76 leds |= asb2305_led_hex_tbl[code % 0x10];
79 ASB2305_7SEGLEDS = leds;
82 void peripheral_leds7x4_display_minssecs(unsigned int time, unsigned int points)
86 leds = asb2305_led_hex_tbl[(time/600) % 6];
88 leds |= asb2305_led_hex_tbl[(time/60) % 10];
90 leds |= asb2305_led_hex_tbl[(time/10) % 6];
92 leds |= asb2305_led_hex_tbl[time % 10];
93 leds |= points^0x01010101;
95 ASB2305_7SEGLEDS = leds;
98 void peripheral_leds7x4_display_rtc(void)
106 clock = ((mins & 0xf0) >> 4);
108 clock += (mins & 0x0f);
111 clock += ((secs & 0xf0) >> 4);
113 clock += (secs & 0x0f);
115 peripheral_leds7x4_display_minssecs(clock, 0);
118 void peripheral_leds_led_chase(void)
120 ASB2305_7SEGLEDS = asb2305_led_chase_tbl[asb2305_led_chase];
122 if (asb2305_led_chase >= 6)
123 asb2305_led_chase = 0;