Path: blob/master/arch/mn10300/unit-asb2364/leds.c
10817 views
/* leds.c: ASB2364 peripheral 7seg LEDs x4 support1*2* Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.3* Written by David Howells ([email protected])4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License7* as published by the Free Software Foundation; either version8* 2 of the License, or (at your option) any later version.9*/1011#include <linux/kernel.h>12#include <linux/param.h>13#include <linux/init.h>1415#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>2021#if MN10300_USE_7SEGLEDS22static const u8 asb2364_led_hex_tbl[16] = {230x80, 0xf2, 0x48, 0x60, 0x32, 0x24, 0x04, 0xf0,240x00, 0x20, 0x10, 0x06, 0x8c, 0x42, 0x0c, 0x1c25};2627static const u32 asb2364_led_chase_tbl[6] = {28~0x02020202, /* top - segA */29~0x04040404, /* right top - segB */30~0x08080808, /* right bottom - segC */31~0x10101010, /* bottom - segD */32~0x20202020, /* left bottom - segE */33~0x40404040, /* left top - segF */34};3536static unsigned asb2364_led_chase;3738void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points)39{40u32 leds;4142leds = asb2364_led_hex_tbl[(val/1000) % 10];43leds <<= 8;44leds |= asb2364_led_hex_tbl[(val/100) % 10];45leds <<= 8;46leds |= asb2364_led_hex_tbl[(val/10) % 10];47leds <<= 8;48leds |= asb2364_led_hex_tbl[val % 10];49leds |= points^0x01010101;5051ASB2364_7SEGLEDS = leds;52}5354void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points)55{56u32 leds;5758leds = asb2364_led_hex_tbl[(val/1000) % 10];59leds <<= 8;60leds |= asb2364_led_hex_tbl[(val/100) % 10];61leds <<= 8;62leds |= asb2364_led_hex_tbl[(val/10) % 10];63leds <<= 8;64leds |= asb2364_led_hex_tbl[val % 10];65leds |= points^0x01010101;6667ASB2364_7SEGLEDS = leds;68}6970/* display triple horizontal bar and exception code */71void peripheral_leds_display_exception(enum exception_code code)72{73u32 leds;7475leds = asb2364_led_hex_tbl[(code/0x100) % 0x10];76leds <<= 8;77leds |= asb2364_led_hex_tbl[(code/0x10) % 0x10];78leds <<= 8;79leds |= asb2364_led_hex_tbl[code % 0x10];80leds |= 0x6d010101;8182ASB2364_7SEGLEDS = leds;83}8485void peripheral_leds_led_chase(void)86{87ASB2364_7SEGLEDS = asb2364_led_chase_tbl[asb2364_led_chase];88asb2364_led_chase++;89if (asb2364_led_chase >= 6)90asb2364_led_chase = 0;91}92#else /* MN10300_USE_7SEGLEDS */93void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points) { }94void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points) { }95void peripheral_leds_display_exception(enum exception_code code) { }96void peripheral_leds_led_chase(void) { }97#endif /* MN10300_USE_7SEGLEDS */9899100