PM / Domains: Remove pm_genpd_poweron() API
[linux/fpc-iii.git] / arch / mn10300 / unit-asb2305 / leds.c
blob6f8de99540263a2f68a52d3fab69ed5db1eb3b81
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>
14 #include <asm/io.h>
15 #include <asm/processor.h>
16 #include <asm/intctl-regs.h>
17 #include <asm/rtc-regs.h>
18 #include <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)
38 u32 leds;
40 leds = asb2305_led_hex_tbl[(val/1000) % 10];
41 leds <<= 8;
42 leds |= asb2305_led_hex_tbl[(val/100) % 10];
43 leds <<= 8;
44 leds |= asb2305_led_hex_tbl[(val/10) % 10];
45 leds <<= 8;
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)
54 u32 leds;
56 leds = asb2305_led_hex_tbl[(val/1000) % 10];
57 leds <<= 8;
58 leds |= asb2305_led_hex_tbl[(val/100) % 10];
59 leds <<= 8;
60 leds |= asb2305_led_hex_tbl[(val/10) % 10];
61 leds <<= 8;
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)
70 u32 leds;
72 leds = asb2305_led_hex_tbl[(code/0x100) % 0x10];
73 leds <<= 8;
74 leds |= asb2305_led_hex_tbl[(code/0x10) % 0x10];
75 leds <<= 8;
76 leds |= asb2305_led_hex_tbl[code % 0x10];
77 leds |= 0x6d010101;
79 ASB2305_7SEGLEDS = leds;
82 void peripheral_leds7x4_display_minssecs(unsigned int time, unsigned int points)
84 u32 leds;
86 leds = asb2305_led_hex_tbl[(time/600) % 6];
87 leds <<= 8;
88 leds |= asb2305_led_hex_tbl[(time/60) % 10];
89 leds <<= 8;
90 leds |= asb2305_led_hex_tbl[(time/10) % 6];
91 leds <<= 8;
92 leds |= asb2305_led_hex_tbl[time % 10];
93 leds |= points^0x01010101;
95 ASB2305_7SEGLEDS = leds;
98 void peripheral_leds7x4_display_rtc(void)
100 unsigned int clock;
101 u8 mins, secs;
103 mins = RTMCR;
104 secs = RTSCR;
106 clock = ((mins & 0xf0) >> 4);
107 clock *= 10;
108 clock += (mins & 0x0f);
109 clock *= 6;
111 clock += ((secs & 0xf0) >> 4);
112 clock *= 10;
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];
121 asb2305_led_chase++;
122 if (asb2305_led_chase >= 6)
123 asb2305_led_chase = 0;