mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-20 15:58:37 +07:00
dfd10e7ae6
New core SoC-specific changes. New platforms: * Introduction of a vendor, Hisilicon, and one of their SoCs with some random numerical product name. * Introduction of EFM32, embedded platform from Silicon Labs (ARMv7m, i.e. !MMU). * Marvell Berlin series of SoCs, which include the one in Chromecast. * MOXA platform support, ARM9-based platform used mostly in industrial products * Support for Freescale's i.MX50 SoC. Other work: * Renesas work for new platforms and drivers, and conversion over to more multiplatform-friendly device registration schemes. * SMP support for Allwinner sunxi platforms. * ... plus a bunch of other stuff across various platforms. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJS4VggAAoJEIwa5zzehBx3YkEP/j/Vp83zPcPijb8CNLUGJ9rK RTOW9hlLbwCGAcIi/32XVjup1ylTzQuwKpH2R6Sf2GRcmXI1HbCCyDSGKWq+eK9C vDRoWiU9DVRmXuaC7R1dscLS1qSobVoI80bOstblZW65799z48IllD7rJA1BzDIg vUy4knY9hO39DK7sJymXTBJepWxXJHMaYmr15xuxbaR3Qsp8zisqyzMwLqVfBwFB FyPr2PfxU8HJOoWhIsVo+679pmb9tHD6our0HG/lHSuPcRO/3UwN+VD87SwfpjNx P7qiRFkIoMooiTRmjwPPNbMZBJHl6vBR1RWHmws5s9aay1DDhdvQURxKx4bNaN/A UzwiestopISLChd9jqjxTbngl1mvLaL9JwBjRVAkXG4vJJFrhwqvmcMrlszA3ueR 2Th/NBk0b2s8ncAuT7bFe4i/H7es8aI/D2weF3FxRGgpan/B0T0UDAKO+rrMYZ0q 1ZoqlgMQZ0o1l7B5v90h0QQo/GMmin1xzyAChmsl8xbOHh5YfWVFGwLzVbYeZ/YJ yf3CcgQjAA8UV3f1J3nZeqM84o8qqtKUmUjsqWIgT2DnxOoM3pGckrmQ4OvhLccd etROW2nr8EqmoL7shheeHPANoDsTT1XSs0xbWo4ZBpGW5rTIFVoLEGyqa48tw5qA pkH1KwpwEXTrw6MXP5L1 =pgLW -----END PGP SIGNATURE----- Merge tag 'soc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc Pull ARM SoC platform changes from Olof Johansson: "New core SoC-specific changes. New platforms: * Introduction of a vendor, Hisilicon, and one of their SoCs with some random numerical product name. * Introduction of EFM32, embedded platform from Silicon Labs (ARMv7m, i.e. !MMU). * Marvell Berlin series of SoCs, which include the one in Chromecast. * MOXA platform support, ARM9-based platform used mostly in industrial products * Support for Freescale's i.MX50 SoC. Other work: * Renesas work for new platforms and drivers, and conversion over to more multiplatform-friendly device registration schemes. * SMP support for Allwinner sunxi platforms. * ... plus a bunch of other stuff across various platforms" * tag 'soc-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (201 commits) ARM: tegra: fix tegra_powergate_sequence_power_up() inline ARM: msm_defconfig: Update for multi-platform ARM: msm: Move MSM's DT based hardware to multi-platform support ARM: msm: Only build timer.c if required ARM: msm: Only build clock.c on proc_comm based platforms ARM: ux500: Enable system suspend with WFI support ARM: ux500: turn on PRINTK_TIME in u8500_defconfig ARM: shmobile: r8a7790: Fix I2C controller names ARM: msm: Simplify ARCH_MSM_DT config ARM: msm: Add support for MSM8974 SoC ARM: sunxi: select ARM_PSCI MAINTAINERS: Update Allwinner sunXi maintainer files ARM: sunxi: Select RESET_CONTROLLER ARM: imx: improve the comment of CCM lpm SW workaround ARM: imx: improve status check of clock gate ARM: imx: add necessary interface for pfd ARM: imx_v6_v7_defconfig: Select CONFIG_REGULATOR_PFUZE100 ARM: imx_v6_v7_defconfig: Select MX35 and MX50 device tree support ARM: imx: Add cpu frequency scaling support ARM i.MX35: Add devicetree support. ...
227 lines
5.0 KiB
C
227 lines
5.0 KiB
C
/*
|
|
* arch/arm/plat-orion/time.c
|
|
*
|
|
* Marvell Orion SoC timer handling.
|
|
*
|
|
* This file is licensed under the terms of the GNU General Public
|
|
* License version 2. This program is licensed "as is" without any
|
|
* warranty of any kind, whether express or implied.
|
|
*
|
|
* Timer 0 is used as free-running clocksource, while timer 1 is
|
|
* used as clock_event_device.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/clockchips.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/sched_clock.h>
|
|
#include <plat/time.h>
|
|
|
|
/*
|
|
* MBus bridge block registers.
|
|
*/
|
|
#define BRIDGE_CAUSE_OFF 0x0110
|
|
#define BRIDGE_MASK_OFF 0x0114
|
|
#define BRIDGE_INT_TIMER0 0x0002
|
|
#define BRIDGE_INT_TIMER1 0x0004
|
|
|
|
|
|
/*
|
|
* Timer block registers.
|
|
*/
|
|
#define TIMER_CTRL_OFF 0x0000
|
|
#define TIMER0_EN 0x0001
|
|
#define TIMER0_RELOAD_EN 0x0002
|
|
#define TIMER1_EN 0x0004
|
|
#define TIMER1_RELOAD_EN 0x0008
|
|
#define TIMER0_RELOAD_OFF 0x0010
|
|
#define TIMER0_VAL_OFF 0x0014
|
|
#define TIMER1_RELOAD_OFF 0x0018
|
|
#define TIMER1_VAL_OFF 0x001c
|
|
|
|
|
|
/*
|
|
* SoC-specific data.
|
|
*/
|
|
static void __iomem *bridge_base;
|
|
static u32 bridge_timer1_clr_mask;
|
|
static void __iomem *timer_base;
|
|
|
|
|
|
/*
|
|
* Number of timer ticks per jiffy.
|
|
*/
|
|
static u32 ticks_per_jiffy;
|
|
|
|
|
|
/*
|
|
* Orion's sched_clock implementation. It has a resolution of
|
|
* at least 7.5ns (133MHz TCLK).
|
|
*/
|
|
|
|
static u64 notrace orion_read_sched_clock(void)
|
|
{
|
|
return ~readl(timer_base + TIMER0_VAL_OFF);
|
|
}
|
|
|
|
/*
|
|
* Clockevent handling.
|
|
*/
|
|
static int
|
|
orion_clkevt_next_event(unsigned long delta, struct clock_event_device *dev)
|
|
{
|
|
unsigned long flags;
|
|
u32 u;
|
|
|
|
if (delta == 0)
|
|
return -ETIME;
|
|
|
|
local_irq_save(flags);
|
|
|
|
/*
|
|
* Clear and enable clockevent timer interrupt.
|
|
*/
|
|
writel(bridge_timer1_clr_mask, bridge_base + BRIDGE_CAUSE_OFF);
|
|
|
|
u = readl(bridge_base + BRIDGE_MASK_OFF);
|
|
u |= BRIDGE_INT_TIMER1;
|
|
writel(u, bridge_base + BRIDGE_MASK_OFF);
|
|
|
|
/*
|
|
* Setup new clockevent timer value.
|
|
*/
|
|
writel(delta, timer_base + TIMER1_VAL_OFF);
|
|
|
|
/*
|
|
* Enable the timer.
|
|
*/
|
|
u = readl(timer_base + TIMER_CTRL_OFF);
|
|
u = (u & ~TIMER1_RELOAD_EN) | TIMER1_EN;
|
|
writel(u, timer_base + TIMER_CTRL_OFF);
|
|
|
|
local_irq_restore(flags);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void
|
|
orion_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
|
|
{
|
|
unsigned long flags;
|
|
u32 u;
|
|
|
|
local_irq_save(flags);
|
|
if (mode == CLOCK_EVT_MODE_PERIODIC) {
|
|
/*
|
|
* Setup timer to fire at 1/HZ intervals.
|
|
*/
|
|
writel(ticks_per_jiffy - 1, timer_base + TIMER1_RELOAD_OFF);
|
|
writel(ticks_per_jiffy - 1, timer_base + TIMER1_VAL_OFF);
|
|
|
|
/*
|
|
* Enable timer interrupt.
|
|
*/
|
|
u = readl(bridge_base + BRIDGE_MASK_OFF);
|
|
writel(u | BRIDGE_INT_TIMER1, bridge_base + BRIDGE_MASK_OFF);
|
|
|
|
/*
|
|
* Enable timer.
|
|
*/
|
|
u = readl(timer_base + TIMER_CTRL_OFF);
|
|
writel(u | TIMER1_EN | TIMER1_RELOAD_EN,
|
|
timer_base + TIMER_CTRL_OFF);
|
|
} else {
|
|
/*
|
|
* Disable timer.
|
|
*/
|
|
u = readl(timer_base + TIMER_CTRL_OFF);
|
|
writel(u & ~TIMER1_EN, timer_base + TIMER_CTRL_OFF);
|
|
|
|
/*
|
|
* Disable timer interrupt.
|
|
*/
|
|
u = readl(bridge_base + BRIDGE_MASK_OFF);
|
|
writel(u & ~BRIDGE_INT_TIMER1, bridge_base + BRIDGE_MASK_OFF);
|
|
|
|
/*
|
|
* ACK pending timer interrupt.
|
|
*/
|
|
writel(bridge_timer1_clr_mask, bridge_base + BRIDGE_CAUSE_OFF);
|
|
|
|
}
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
static struct clock_event_device orion_clkevt = {
|
|
.name = "orion_tick",
|
|
.features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
|
|
.rating = 300,
|
|
.set_next_event = orion_clkevt_next_event,
|
|
.set_mode = orion_clkevt_mode,
|
|
};
|
|
|
|
static irqreturn_t orion_timer_interrupt(int irq, void *dev_id)
|
|
{
|
|
/*
|
|
* ACK timer interrupt and call event handler.
|
|
*/
|
|
writel(bridge_timer1_clr_mask, bridge_base + BRIDGE_CAUSE_OFF);
|
|
orion_clkevt.event_handler(&orion_clkevt);
|
|
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static struct irqaction orion_timer_irq = {
|
|
.name = "orion_tick",
|
|
.flags = IRQF_TIMER,
|
|
.handler = orion_timer_interrupt
|
|
};
|
|
|
|
void __init
|
|
orion_time_set_base(void __iomem *_timer_base)
|
|
{
|
|
timer_base = _timer_base;
|
|
}
|
|
|
|
void __init
|
|
orion_time_init(void __iomem *_bridge_base, u32 _bridge_timer1_clr_mask,
|
|
unsigned int irq, unsigned int tclk)
|
|
{
|
|
u32 u;
|
|
|
|
/*
|
|
* Set SoC-specific data.
|
|
*/
|
|
bridge_base = _bridge_base;
|
|
bridge_timer1_clr_mask = _bridge_timer1_clr_mask;
|
|
|
|
ticks_per_jiffy = (tclk + HZ/2) / HZ;
|
|
|
|
/*
|
|
* Set scale and timer for sched_clock.
|
|
*/
|
|
sched_clock_register(orion_read_sched_clock, 32, tclk);
|
|
|
|
/*
|
|
* Setup free-running clocksource timer (interrupts
|
|
* disabled).
|
|
*/
|
|
writel(0xffffffff, timer_base + TIMER0_VAL_OFF);
|
|
writel(0xffffffff, timer_base + TIMER0_RELOAD_OFF);
|
|
u = readl(bridge_base + BRIDGE_MASK_OFF);
|
|
writel(u & ~BRIDGE_INT_TIMER0, bridge_base + BRIDGE_MASK_OFF);
|
|
u = readl(timer_base + TIMER_CTRL_OFF);
|
|
writel(u | TIMER0_EN | TIMER0_RELOAD_EN, timer_base + TIMER_CTRL_OFF);
|
|
clocksource_mmio_init(timer_base + TIMER0_VAL_OFF, "orion_clocksource",
|
|
tclk, 300, 32, clocksource_mmio_readl_down);
|
|
|
|
/*
|
|
* Setup clockevent timer (interrupt-driven).
|
|
*/
|
|
setup_irq(irq, &orion_timer_irq);
|
|
orion_clkevt.cpumask = cpumask_of(0);
|
|
clockevents_config_and_register(&orion_clkevt, tclk, 1, 0xfffffffe);
|
|
}
|