Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/sh/boards/se/73180/led.c |
| 3 | * |
| 4 | * Derived from arch/sh/boards/se/770x/led.c |
| 5 | * |
| 6 | * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com> |
| 7 | * |
| 8 | * May be copied or modified under the terms of the GNU General Public |
| 9 | * License. See linux/COPYING for more information. |
| 10 | * |
| 11 | * This file contains Solution Engine specific LED code. |
| 12 | */ |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/sched.h> |
| 15 | #include <asm/mach/se73180.h> |
| 16 | |
| 17 | static void |
| 18 | mach_led(int position, int value) |
| 19 | { |
| 20 | volatile unsigned short *p = (volatile unsigned short *) PA_LED; |
| 21 | |
| 22 | if (value) { |
| 23 | *p |= (1 << LED_SHIFT); |
| 24 | } else { |
| 25 | *p &= ~(1 << LED_SHIFT); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /* Cycle the LED's in the clasic Knightrider/Sun pattern */ |
| 30 | void |
| 31 | heartbeat_73180se(void) |
| 32 | { |
| 33 | static unsigned int cnt = 0, period = 0; |
| 34 | volatile unsigned short *p = (volatile unsigned short *) PA_LED; |
| 35 | static unsigned bit = 0, up = 1; |
| 36 | |
| 37 | cnt += 1; |
| 38 | if (cnt < period) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | cnt = 0; |
| 43 | |
| 44 | /* Go through the points (roughly!): |
| 45 | * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110 |
| 46 | */ |
| 47 | period = 110 - ((300 << FSHIFT) / ((avenrun[0] / 5) + (3 << FSHIFT))); |
| 48 | |
| 49 | if (up) { |
| 50 | if (bit == 7) { |
| 51 | bit--; |
| 52 | up = 0; |
| 53 | } else { |
| 54 | bit++; |
| 55 | } |
| 56 | } else { |
| 57 | if (bit == 0) { |
| 58 | bit++; |
| 59 | up = 1; |
| 60 | } else { |
| 61 | bit--; |
| 62 | } |
| 63 | } |
| 64 | *p = 1 << (bit + LED_SHIFT); |
| 65 | |
| 66 | } |