| Akira Takeuchi | 368dd5a | 2010-10-27 17:28:55 +0100 | [diff] [blame] | 1 | /* leds.c: ASB2364 peripheral 7seg LEDs x4 support | 
|  | 2 | * | 
|  | 3 | * Copyright (C) 2002 Red Hat, Inc. All Rights Reserved. | 
|  | 4 | * Written by David Howells (dhowells@redhat.com) | 
|  | 5 | * | 
|  | 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. | 
|  | 10 | */ | 
|  | 11 |  | 
|  | 12 | #include <linux/kernel.h> | 
|  | 13 | #include <linux/param.h> | 
|  | 14 | #include <linux/init.h> | 
|  | 15 |  | 
|  | 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> | 
|  | 21 |  | 
|  | 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 | 
|  | 26 | }; | 
|  | 27 |  | 
|  | 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 */ | 
|  | 35 | }; | 
|  | 36 |  | 
|  | 37 | static unsigned asb2364_led_chase; | 
|  | 38 |  | 
|  | 39 | void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points) | 
|  | 40 | { | 
|  | 41 | u32 leds; | 
|  | 42 |  | 
|  | 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; | 
|  | 51 |  | 
|  | 52 | ASB2364_7SEGLEDS = leds; | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points) | 
|  | 56 | { | 
|  | 57 | u32 leds; | 
|  | 58 |  | 
|  | 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; | 
|  | 67 |  | 
|  | 68 | ASB2364_7SEGLEDS = leds; | 
|  | 69 | } | 
|  | 70 |  | 
|  | 71 | /* display triple horizontal bar and exception code */ | 
|  | 72 | void peripheral_leds_display_exception(enum exception_code code) | 
|  | 73 | { | 
|  | 74 | u32 leds; | 
|  | 75 |  | 
|  | 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; | 
|  | 82 |  | 
|  | 83 | ASB2364_7SEGLEDS = leds; | 
|  | 84 | } | 
|  | 85 |  | 
|  | 86 | void peripheral_leds_led_chase(void) | 
|  | 87 | { | 
|  | 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; | 
|  | 92 | } | 
|  | 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 */ |