linux-old/arch/sh/stboards/led.c
<<
>>
Prefs
   1/*
   2 * linux/arch/sh/stboards/led.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 ST40STB1 HARP and compatible code.
  10 */
  11
  12#include <linux/config.h>
  13#include <asm/io.h>
  14#include "harp.h"
  15
  16/* Harp: Flash LD10 (front pannel) connected to EPLD (IC8) */
  17/* Overdrive: Flash LD1 (front panel) connected to EPLD (IC4) */
  18/* Works for HARP and overdrive */
  19static void mach_led(int position, int value)
  20{
  21        if (value) {
  22                ctrl_outl(EPLD_LED_ON, EPLD_LED);
  23        } else {
  24                ctrl_outl(EPLD_LED_OFF, EPLD_LED);
  25        }
  26}
  27
  28#ifdef CONFIG_HEARTBEAT
  29
  30#include <linux/sched.h>
  31
  32/* acts like an actual heart beat -- ie thump-thump-pause... */
  33void heartbeat_harp(void)
  34{
  35        static unsigned cnt = 0, period = 0, dist = 0;
  36
  37        if (cnt == 0 || cnt == dist)
  38                mach_led( -1, 1);
  39        else if (cnt == 7 || cnt == dist+7)
  40                mach_led( -1, 0);
  41
  42        if (++cnt > period) {
  43                cnt = 0;
  44                /* The hyperbolic function below modifies the heartbeat period
  45                 * length in dependency of the current (5min) load. It goes
  46                 * through the points f(0)=126, f(1)=86, f(5)=51,
  47                 * f(inf)->30. */
  48                period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
  49                dist = period / 4;
  50        }
  51}
  52#endif
  53
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.