Path: blob/master/arch/mn10300/unit-asb2305/leds.c
10819 views
/* ASB2305 Peripheral 7-segment LEDs x4 support1*2* Copyright (C) 2007 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 Licence7* as published by the Free Software Foundation; either version8* 2 of the Licence, or (at your option) any later version.9*/10#include <linux/kernel.h>11#include <linux/param.h>12#include <linux/init.h>13#include <asm/io.h>14#include <asm/processor.h>15#include <asm/intctl-regs.h>16#include <asm/rtc-regs.h>17#include <unit/leds.h>1819static const u8 asb2305_led_hex_tbl[16] = {200x80, 0xf2, 0x48, 0x60, 0x32, 0x24, 0x04, 0xf0,210x00, 0x20, 0x10, 0x06, 0x8c, 0x42, 0x0c, 0x1c22};2324static const u32 asb2305_led_chase_tbl[6] = {25~0x02020202, /* top - segA */26~0x04040404, /* right top - segB */27~0x08080808, /* right bottom - segC */28~0x10101010, /* bottom - segD */29~0x20202020, /* left bottom - segE */30~0x40404040, /* left top - segF */31};3233static unsigned asb2305_led_chase;3435void peripheral_leds7x4_display_dec(unsigned int val, unsigned int points)36{37u32 leds;3839leds = asb2305_led_hex_tbl[(val/1000) % 10];40leds <<= 8;41leds |= asb2305_led_hex_tbl[(val/100) % 10];42leds <<= 8;43leds |= asb2305_led_hex_tbl[(val/10) % 10];44leds <<= 8;45leds |= asb2305_led_hex_tbl[val % 10];46leds |= points^0x01010101;4748ASB2305_7SEGLEDS = leds;49}5051void peripheral_leds7x4_display_hex(unsigned int val, unsigned int points)52{53u32 leds;5455leds = asb2305_led_hex_tbl[(val/1000) % 10];56leds <<= 8;57leds |= asb2305_led_hex_tbl[(val/100) % 10];58leds <<= 8;59leds |= asb2305_led_hex_tbl[(val/10) % 10];60leds <<= 8;61leds |= asb2305_led_hex_tbl[val % 10];62leds |= points^0x01010101;6364ASB2305_7SEGLEDS = leds;65}6667void peripheral_leds_display_exception(enum exception_code code)68{69u32 leds;7071leds = asb2305_led_hex_tbl[(code/0x100) % 0x10];72leds <<= 8;73leds |= asb2305_led_hex_tbl[(code/0x10) % 0x10];74leds <<= 8;75leds |= asb2305_led_hex_tbl[code % 0x10];76leds |= 0x6d010101;7778ASB2305_7SEGLEDS = leds;79}8081void peripheral_leds7x4_display_minssecs(unsigned int time, unsigned int points)82{83u32 leds;8485leds = asb2305_led_hex_tbl[(time/600) % 6];86leds <<= 8;87leds |= asb2305_led_hex_tbl[(time/60) % 10];88leds <<= 8;89leds |= asb2305_led_hex_tbl[(time/10) % 6];90leds <<= 8;91leds |= asb2305_led_hex_tbl[time % 10];92leds |= points^0x01010101;9394ASB2305_7SEGLEDS = leds;95}9697void peripheral_leds7x4_display_rtc(void)98{99unsigned int clock;100u8 mins, secs;101102mins = RTMCR;103secs = RTSCR;104105clock = ((mins & 0xf0) >> 4);106clock *= 10;107clock += (mins & 0x0f);108clock *= 6;109110clock += ((secs & 0xf0) >> 4);111clock *= 10;112clock += (secs & 0x0f);113114peripheral_leds7x4_display_minssecs(clock, 0);115}116117void peripheral_leds_led_chase(void)118{119ASB2305_7SEGLEDS = asb2305_led_chase_tbl[asb2305_led_chase];120asb2305_led_chase++;121if (asb2305_led_chase >= 6)122asb2305_led_chase = 0;123}124125126