PageRenderTime 16ms CodeModel.GetById 9ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/arch/sh/boards/mpc1211/led.c

https://bitbucket.org/evzijst/gittest
C | 64 lines | 42 code | 11 blank | 11 comment | 11 complexity | aca6e023bf37e0721ec9f2429aad4f64 MD5 | raw file
 1/*
 2 * linux/arch/sh/kernel/led_mpc1211.c
 3 *
 4 * Copyright (C) 2001  Saito.K & Jeanne
 5 *
 6 * This file contains Interface MPC-1211 specific LED code.
 7 */
 8
 9#include <linux/config.h>
10
11static void mach_led(int position, int value)
12{
13	volatile unsigned char* p = (volatile unsigned char*)0xa2000000;
14
15	if (value) {
16		*p |= 1;
17	} else {
18		*p &= ~1;
19	}
20}
21
22#ifdef CONFIG_HEARTBEAT
23
24#include <linux/sched.h>
25
26/* Cycle the LED's in the clasic Knightrider/Sun pattern */
27void heartbeat_mpc1211(void)
28{
29	static unsigned int cnt = 0, period = 0;
30	volatile unsigned char* p = (volatile unsigned char*)0xa2000000;
31	static unsigned bit = 0, up = 1;
32
33	cnt += 1;
34	if (cnt < period) {
35		return;
36	}
37
38	cnt = 0;
39
40	/* Go through the points (roughly!):
41	 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
42	 */
43	period = 110 - ( (300<<FSHIFT)/
44			 ((avenrun[0]/5) + (3<<FSHIFT)) );
45
46	if (up) {
47		if (bit == 7) {
48			bit--;
49			up=0;
50		} else {
51			bit ++;
52		}
53	} else {
54		if (bit == 0) {
55			bit++;
56			up=1;
57		} else {
58			bit--;
59		}
60	}
61	*p = 1<<bit;
62
63}
64#endif /* CONFIG_HEARTBEAT */