1 /* 2 * linux/arch/sh/kernel/led_se.c 3 * 4 * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com> 5 * 6 * May be copied or modified under the terms of the GNU General Public 7 * License. See linux/COPYING for more information. 8 * 9 * This file contains Solution Engine specific LED code. 10 */ 11 12 #include <linux/config.h> 13 14 #ifdef CONFIG_SH_7751_SOLUTION_ENGINE 15 #include <asm/hitachi_7751se.h> 16 #elif defined(CONFIG_SH_MOBILE_SOLUTION_ENGINE) 17 #include <asm/hitachi_shmse.h> 18 #else 19 #include <asm/hitachi_se.h> 20 #endif 21 mach_led(int position,int value)22static void mach_led(int position, int value) 23 { 24 volatile unsigned short* p = (volatile unsigned short*)PA_LED; 25 26 if (value) { 27 *p |= (1<<8); 28 } else { 29 *p &= ~(1<<8); 30 } 31 } 32 33 #ifdef CONFIG_HEARTBEAT 34 35 #include <linux/sched.h> 36 37 /* Cycle the LED's in the clasic Knightrider/Sun pattern */ heartbeat_se(void)38void heartbeat_se(void) 39 { 40 static unsigned int cnt = 0, period = 0; 41 volatile unsigned short* p = (volatile unsigned short*)PA_LED; 42 static unsigned bit = 0, up = 1; 43 44 cnt += 1; 45 if (cnt < period) { 46 return; 47 } 48 49 cnt = 0; 50 51 /* Go through the points (roughly!): 52 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110 53 */ 54 period = 110 - ( (300<<FSHIFT)/ 55 ((avenrun[0]/5) + (3<<FSHIFT)) ); 56 57 if (up) { 58 if (bit == 7) { 59 bit--; 60 up=0; 61 } else { 62 bit ++; 63 } 64 } else { 65 if (bit == 0) { 66 bit++; 67 up=1; 68 } else { 69 bit--; 70 } 71 } 72 *p = 1<<(bit+8); 73 74 } 75 #endif /* CONFIG_HEARTBEAT */ 76