lkml.org 
[lkml]   [2008]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 20/56] microblaze_v2: heartbeat file
    Date
    From: Michal Simek <monstr@monstr.eu>


    Signed-off-by: Michal Simek <monstr@monstr.eu>
    ---
    arch/microblaze/kernel/heartbeat.c | 37 ++++++++++++++++++++++++++++++++++++
    1 files changed, 37 insertions(+), 0 deletions(-)
    create mode 100644 arch/microblaze/kernel/heartbeat.c

    diff --git a/arch/microblaze/kernel/heartbeat.c b/arch/microblaze/kernel/heartbeat.c
    new file mode 100644
    index 0000000..508b463
    --- /dev/null
    +++ b/arch/microblaze/kernel/heartbeat.c
    @@ -0,0 +1,37 @@
    +/*
    + * arch/microblaze/kernel/heartbeat.c
    + *
    + * This file is subject to the terms and conditions of the GNU General Public
    + * License. See the file "COPYING" in the main directory of this archive
    + * for more details.
    + *
    + * Copyright (C) 2006 Atmark Techno, Inc.
    + */
    +
    +#include <linux/sched.h>
    +#include <asm/page.h>
    +#include <asm/io.h>
    +#include <asm/setup.h>
    +
    +void heartbeat(void)
    +{
    + static unsigned int cnt, period, dist;
    +
    + if (cnt == 0 || cnt == dist)
    + iowrite32(1, CONFIG_HEART_BEAT_ADDRESS);
    + else if (cnt == 7 || cnt == dist + 7)
    + iowrite32(0, CONFIG_HEART_BEAT_ADDRESS);
    +
    + if (++cnt > period) {
    + cnt = 0;
    +
    + /*
    + * The hyperbolic function below modifies the heartbeat period
    + * length in dependency of the current (5min) load. It goes
    + * through the points f(0)=126, f(1)=86, f(5)=51, f(inf)->30.
    + */
    + period = ((672 << FSHIFT) / (5 * avenrun[0] +
    + (7 << FSHIFT))) + 30;
    + dist = period / 4;
    + }
    +}
    --
    1.5.4.GIT


    \
     
     \ /
      Last update: 2008-05-04 15:51    [W:4.057 / U:0.556 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site