// SPDX-License-Identifier: GPL-2.0-only /* * Clock event driver for the CS5535/CS5536 * * Copyright (C) 2006, Advanced Micro Devices, Inc. * Copyright (C) 2007 Andres Salomon <[email protected]> * Copyright (C) 2009 Andres Salomon <[email protected]> * * The MFGPTs are documented in AMD Geode CS5536 Companion Device Data Book. */ #include <linux/kernel.h> #include <linux/irq.h> #include <linux/interrupt.h> #include <linux/module.h> #include <linux/cs5535.h> #include <linux/clockchips.h> #define DRV_NAME … static int timer_irq; module_param_hw_named(irq, timer_irq, int, irq, 0644); MODULE_PARM_DESC(…) …; /* * We are using the 32.768kHz input clock - it's the only one that has the * ranges we find desirable. The following table lists the suitable * divisors and the associated Hz, minimum interval and the maximum interval: * * Divisor Hz Min Delta (s) Max Delta (s) * 1 32768 .00048828125 2.000 * 2 16384 .0009765625 4.000 * 4 8192 .001953125 8.000 * 8 4096 .00390625 16.000 * 16 2048 .0078125 32.000 * 32 1024 .015625 64.000 * 64 512 .03125 128.000 * 128 256 .0625 256.000 * 256 128 .125 512.000 */ static struct cs5535_mfgpt_timer *cs5535_event_clock; /* Selected from the table above */ #define MFGPT_DIVISOR … #define MFGPT_SCALE … #define MFGPT_HZ … #define MFGPT_PERIODIC … /* * The MFGPT timers on the CS5536 provide us with suitable timers to use * as clock event sources - not as good as a HPET or APIC, but certainly * better than the PIT. This isn't a general purpose MFGPT driver, but * a simplified one designed specifically to act as a clock event source. * For full details about the MFGPT, please consult the CS5536 data sheet. */ static void disable_timer(struct cs5535_mfgpt_timer *timer) { … } static void start_timer(struct cs5535_mfgpt_timer *timer, uint16_t delta) { … } static int mfgpt_shutdown(struct clock_event_device *evt) { … } static int mfgpt_set_periodic(struct clock_event_device *evt) { … } static int mfgpt_next_event(unsigned long delta, struct clock_event_device *evt) { … } static struct clock_event_device cs5535_clockevent = …; static irqreturn_t mfgpt_tick(int irq, void *dev_id) { … } static int __init cs5535_mfgpt_init(void) { … } module_init(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;