cregit-Linux how code gets into the kernel

Release 4.11 arch/avr32/kernel/time.c

/*
 * Copyright (C) 2004-2007 Atmel Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#include <linux/clk.h>
#include <linux/clockchips.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/time.h>
#include <linux/cpu.h>

#include <asm/sysreg.h>

#include <mach/pm.h>


static bool disable_cpu_idle_poll;


static u64 read_cycle_count(struct clocksource *cs) { return (u64)sysreg_read(COUNT); }

Contributors

PersonTokensPropCommitsCommitProp
Håvard Skinnemoen1365.00%125.00%
Magnus Damm420.00%125.00%
Thomas Gleixner210.00%125.00%
David Brownell15.00%125.00%
Total20100.00%4100.00%

/* * The architectural cycle count registers are a fine clocksource unless * the system idle loop use sleep states like "idle": the CPU cycles * measured by COUNT (and COMPARE) don't happen during sleep states. * Their duration also changes if cpufreq changes the CPU clock rate. * So we rate the clocksource using COUNT as very low quality. */ static struct clocksource counter = { .name = "avr32_counter", .rating = 50, .read = read_cycle_count, .mask = CLOCKSOURCE_MASK(32), .flags = CLOCK_SOURCE_IS_CONTINUOUS, };
static irqreturn_t timer_interrupt(int irq, void *dev_id) { struct clock_event_device *evdev = dev_id; if (unlikely(!(intc_get_pending(0) & 1))) return IRQ_NONE; /* * Disable the interrupt until the clockevent subsystem * reprograms it. */ sysreg_write(COMPARE, 0); evdev->event_handler(evdev); return IRQ_HANDLED; }

Contributors

PersonTokensPropCommitsCommitProp
David Brownell2850.00%133.33%
Nikolaus Voss1832.14%133.33%
Hans-Christian Noren Egtvedt1017.86%133.33%
Total56100.00%3100.00%

static struct irqaction timer_irqaction = { .handler = timer_interrupt, /* Oprofile uses the same irq as the timer, so allow it to be shared */ .flags = IRQF_TIMER | IRQF_SHARED, .name = "avr32_comparator", };
static int comparator_next_event(unsigned long delta, struct clock_event_device *evdev) { unsigned long flags; raw_local_irq_save(flags); /* The time to read COUNT then update COMPARE must be less * than the min_delta_ns value for this clockevent source. */ sysreg_write(COMPARE, (sysreg_read(COUNT) + delta) ? : 1); raw_local_irq_restore(flags); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
David Brownell2142.00%133.33%
Håvard Skinnemoen1836.00%133.33%
Hans-Christian Noren Egtvedt1122.00%133.33%
Total50100.00%3100.00%


static int comparator_shutdown(struct clock_event_device *evdev) { pr_debug("%s: %s\n", __func__, evdev->name); sysreg_write(COMPARE, 0); if (disable_cpu_idle_poll) { disable_cpu_idle_poll = false; /* * Only disable idle poll if we have forced that * in a previous call. */ cpu_idle_poll_ctrl(false); } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Viresh Kumar2552.08%133.33%
David Brownell1327.08%133.33%
Håvard Skinnemoen1020.83%133.33%
Total48100.00%3100.00%


static int comparator_set_oneshot(struct clock_event_device *evdev) { pr_debug("%s: %s\n", __func__, evdev->name); disable_cpu_idle_poll = true; /* * If we're using the COUNT and COMPARE registers we * need to force idle poll. */ cpu_idle_poll_ctrl(true); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Viresh Kumar2262.86%125.00%
Håvard Skinnemoen514.29%125.00%
David Brownell514.29%125.00%
Thomas Gleixner38.57%125.00%
Total35100.00%4100.00%

static struct clock_event_device comparator = { .name = "avr32_comparator", .features = CLOCK_EVT_FEAT_ONESHOT, .shift = 16, .rating = 50, .set_next_event = comparator_next_event, .set_state_shutdown = comparator_shutdown, .set_state_oneshot = comparator_set_oneshot, .tick_resume = comparator_set_oneshot, };
void read_persistent_clock(struct timespec *ts) { ts->tv_sec = mktime(2007, 1, 1, 0, 0, 0); ts->tv_nsec = 0; }

Contributors

PersonTokensPropCommitsCommitProp
David Brownell1440.00%125.00%
Håvard Skinnemoen1028.57%125.00%
John Stultz1028.57%125.00%
Peter Hüwe12.86%125.00%
Total35100.00%4100.00%


void __init time_init(void) { unsigned long counter_hz; int ret; /* figure rate for counter */ counter_hz = clk_get_rate(boot_cpu_data.clk); ret = clocksource_register_hz(&counter, counter_hz); if (ret) pr_debug("timer: could not register clocksource: %d\n", ret); /* setup COMPARE clockevent */ comparator.mult = div_sc(counter_hz, NSEC_PER_SEC, comparator.shift); comparator.max_delta_ns = clockevent_delta2ns((u32)~0, &comparator); comparator.min_delta_ns = clockevent_delta2ns(50, &comparator) + 1; comparator.cpumask = cpumask_of(0); sysreg_write(COMPARE, 0); timer_irqaction.dev_id = &comparator; ret = setup_irq(0, &timer_irqaction); if (ret) pr_debug("timer: could not request IRQ 0: %d\n", ret); else { clockevents_register_device(&comparator); pr_info("%s: irq 0, %lu.%03lu MHz\n", comparator.name, ((counter_hz + 500) / 1000) / 1000, ((counter_hz + 500) / 1000) % 1000); } }

Contributors

PersonTokensPropCommitsCommitProp
David Brownell11866.29%116.67%
Håvard Skinnemoen3117.42%116.67%
John Stultz179.55%233.33%
Rusty Russell95.06%116.67%
Hans-Christian Noren Egtvedt31.69%116.67%
Total178100.00%6100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
David Brownell24643.54%212.50%
Håvard Skinnemoen14024.78%318.75%
Viresh Kumar6311.15%16.25%
Hans-Christian Noren Egtvedt457.96%16.25%
John Stultz274.78%212.50%
Nikolaus Voss203.54%16.25%
Thomas Gleixner101.77%318.75%
Rusty Russell91.59%16.25%
Magnus Damm40.71%16.25%
Peter Hüwe10.18%16.25%
Total565100.00%16100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.