Merge branch 'timers/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer code update from Thomas Gleixner:
- armada SoC clocksource overhaul with a trivial merge conflict
- Minor improvements to various SoC clocksource drivers

* 'timers/core' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
clocksource: armada-370-xp: Add detailed clock requirements in devicetree binding
clocksource: armada-370-xp: Get reference fixed-clock by name
clocksource: armada-370-xp: Replace WARN_ON with BUG_ON
clocksource: armada-370-xp: Fix device-tree binding
clocksource: armada-370-xp: Introduce new compatibles
clocksource: armada-370-xp: Use CLOCKSOURCE_OF_DECLARE
clocksource: armada-370-xp: Simplify TIMER_CTRL register access
clocksource: armada-370-xp: Use BIT()
ARM: timer-sp: Set dynamic irq affinity
ARM: nomadik: add dynamic irq flag to the timer
clocksource: sh_cmt: 32-bit control register support
clocksource: em_sti: Convert to devm_* managed helpers

Changed files
+164 -128
Documentation
devicetree
arch
arm
common
mach-mvebu
drivers
include
+31 -5
Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt
··· 2 2 --------------------------------------- 3 3 4 4 Required properties: 5 - - compatible: Should be "marvell,armada-370-xp-timer" 5 + - compatible: Should be either "marvell,armada-370-timer" or 6 + "marvell,armada-xp-timer" as appropriate. 6 7 - interrupts: Should contain the list of Global Timer interrupts and 7 8 then local timer interrupts 8 9 - reg: Should contain location and length for timers register. First 9 10 pair for the Global Timer registers, second pair for the 10 11 local/private timers. 11 - - clocks: clock driving the timer hardware 12 12 13 - Optional properties: 14 - - marvell,timer-25Mhz: Tells whether the Global timer supports the 25 15 - Mhz fixed mode (available on Armada XP and not on Armada 370) 13 + Clocks required for compatible = "marvell,armada-370-timer": 14 + - clocks : Must contain a single entry describing the clock input 15 + 16 + Clocks required for compatible = "marvell,armada-xp-timer": 17 + - clocks : Must contain an entry for each entry in clock-names. 18 + - clock-names : Must include the following entries: 19 + "nbclk" (L2/coherency fabric clock), 20 + "fixed" (Reference 25 MHz fixed-clock). 21 + 22 + Examples: 23 + 24 + - Armada 370: 25 + 26 + timer { 27 + compatible = "marvell,armada-370-timer"; 28 + reg = <0x20300 0x30>, <0x21040 0x30>; 29 + interrupts = <37>, <38>, <39>, <40>, <5>, <6>; 30 + clocks = <&coreclk 2>; 31 + }; 32 + 33 + - Armada XP: 34 + 35 + timer { 36 + compatible = "marvell,armada-xp-timer"; 37 + reg = <0x20300 0x30>, <0x21040 0x30>; 38 + interrupts = <37>, <38>, <39>, <40>, <5>, <6>; 39 + clocks = <&coreclk 2>, <&refclk>; 40 + clock-names = "nbclk", "fixed"; 41 + };
+2 -1
arch/arm/common/timer-sp.c
··· 166 166 } 167 167 168 168 static struct clock_event_device sp804_clockevent = { 169 - .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, 169 + .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT | 170 + CLOCK_EVT_FEAT_DYNIRQ, 170 171 .set_mode = sp804_set_mode, 171 172 .set_next_event = sp804_set_next_event, 172 173 .rating = 300,
+2 -2
arch/arm/mach-mvebu/armada-370-xp.c
··· 18 18 #include <linux/of_address.h> 19 19 #include <linux/of_platform.h> 20 20 #include <linux/io.h> 21 - #include <linux/time-armada-370-xp.h> 21 + #include <linux/clocksource.h> 22 22 #include <linux/dma-mapping.h> 23 23 #include <linux/mbus.h> 24 24 #include <asm/hardware/cache-l2x0.h> ··· 37 37 static void __init armada_370_xp_timer_and_clk_init(void) 38 38 { 39 39 of_clk_init(NULL); 40 - armada_370_xp_timer_init(); 40 + clocksource_of_init(); 41 41 coherency_init(); 42 42 BUG_ON(mvebu_mbus_dt_init()); 43 43 #ifdef CONFIG_CACHE_L2X0
+14 -35
drivers/clocksource/em_sti.c
··· 315 315 { 316 316 struct em_sti_priv *p; 317 317 struct resource *res; 318 - int irq, ret; 318 + int irq; 319 319 320 - p = kzalloc(sizeof(*p), GFP_KERNEL); 320 + p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); 321 321 if (p == NULL) { 322 322 dev_err(&pdev->dev, "failed to allocate driver data\n"); 323 - ret = -ENOMEM; 324 - goto err0; 323 + return -ENOMEM; 325 324 } 326 325 327 326 p->pdev = pdev; 328 327 platform_set_drvdata(pdev, p); 329 328 330 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 331 - if (!res) { 332 - dev_err(&pdev->dev, "failed to get I/O memory\n"); 333 - ret = -EINVAL; 334 - goto err0; 335 - } 336 - 337 329 irq = platform_get_irq(pdev, 0); 338 330 if (irq < 0) { 339 331 dev_err(&pdev->dev, "failed to get irq\n"); 340 - ret = -EINVAL; 341 - goto err0; 332 + return -EINVAL; 342 333 } 343 334 344 335 /* map memory, let base point to the STI instance */ 345 - p->base = ioremap_nocache(res->start, resource_size(res)); 346 - if (p->base == NULL) { 347 - dev_err(&pdev->dev, "failed to remap I/O memory\n"); 348 - ret = -ENXIO; 349 - goto err0; 350 - } 336 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 337 + p->base = devm_ioremap_resource(&pdev->dev, res); 338 + if (IS_ERR(p->base)) 339 + return PTR_ERR(p->base); 351 340 352 341 /* get hold of clock */ 353 - p->clk = clk_get(&pdev->dev, "sclk"); 342 + p->clk = devm_clk_get(&pdev->dev, "sclk"); 354 343 if (IS_ERR(p->clk)) { 355 344 dev_err(&pdev->dev, "cannot get clock\n"); 356 - ret = PTR_ERR(p->clk); 357 - goto err1; 345 + return PTR_ERR(p->clk); 358 346 } 359 347 360 - if (request_irq(irq, em_sti_interrupt, 361 - IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, 362 - dev_name(&pdev->dev), p)) { 348 + if (devm_request_irq(&pdev->dev, irq, em_sti_interrupt, 349 + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, 350 + dev_name(&pdev->dev), p)) { 363 351 dev_err(&pdev->dev, "failed to request low IRQ\n"); 364 - ret = -ENOENT; 365 - goto err2; 352 + return -ENOENT; 366 353 } 367 354 368 355 raw_spin_lock_init(&p->lock); 369 356 em_sti_register_clockevent(p); 370 357 em_sti_register_clocksource(p); 371 358 return 0; 372 - 373 - err2: 374 - clk_put(p->clk); 375 - err1: 376 - iounmap(p->base); 377 - err0: 378 - kfree(p); 379 - return ret; 380 359 } 381 360 382 361 static int em_sti_remove(struct platform_device *pdev)
+2 -1
drivers/clocksource/nomadik-mtu.c
··· 165 165 166 166 static struct clock_event_device nmdk_clkevt = { 167 167 .name = "mtu_1", 168 - .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC, 168 + .features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC | 169 + CLOCK_EVT_FEAT_DYNIRQ, 169 170 .rating = 200, 170 171 .set_mode = nmdk_clkevt_mode, 171 172 .set_next_event = nmdk_clkevt_next,
+36 -14
drivers/clocksource/sh_cmt.c
··· 37 37 38 38 struct sh_cmt_priv { 39 39 void __iomem *mapbase; 40 + void __iomem *mapbase_str; 40 41 struct clk *clk; 41 42 unsigned long width; /* 16 or 32 bit version of hardware block */ 42 43 unsigned long overflow_bit; ··· 80 79 * CMCSR 0xffca0060 16-bit 81 80 * CMCNT 0xffca0064 32-bit 82 81 * CMCOR 0xffca0068 32-bit 82 + * 83 + * "32-bit counter and 32-bit control" as found on r8a73a4 and r8a7790: 84 + * CMSTR 0xffca0500 32-bit 85 + * CMCSR 0xffca0510 32-bit 86 + * CMCNT 0xffca0514 32-bit 87 + * CMCOR 0xffca0518 32-bit 83 88 */ 84 89 85 90 static unsigned long sh_cmt_read16(void __iomem *base, unsigned long offs) ··· 116 109 117 110 static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_priv *p) 118 111 { 119 - struct sh_timer_config *cfg = p->pdev->dev.platform_data; 120 - 121 - return p->read_control(p->mapbase - cfg->channel_offset, 0); 112 + return p->read_control(p->mapbase_str, 0); 122 113 } 123 114 124 115 static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_priv *p) ··· 132 127 static inline void sh_cmt_write_cmstr(struct sh_cmt_priv *p, 133 128 unsigned long value) 134 129 { 135 - struct sh_timer_config *cfg = p->pdev->dev.platform_data; 136 - 137 - p->write_control(p->mapbase - cfg->channel_offset, 0, value); 130 + p->write_control(p->mapbase_str, 0, value); 138 131 } 139 132 140 133 static inline void sh_cmt_write_cmcsr(struct sh_cmt_priv *p, ··· 679 676 static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) 680 677 { 681 678 struct sh_timer_config *cfg = pdev->dev.platform_data; 682 - struct resource *res; 679 + struct resource *res, *res2; 683 680 int irq, ret; 684 681 ret = -ENXIO; 685 682 ··· 697 694 goto err0; 698 695 } 699 696 697 + /* optional resource for the shared timer start/stop register */ 698 + res2 = platform_get_resource(p->pdev, IORESOURCE_MEM, 1); 699 + 700 700 irq = platform_get_irq(p->pdev, 0); 701 701 if (irq < 0) { 702 702 dev_err(&p->pdev->dev, "failed to get irq\n"); ··· 711 705 if (p->mapbase == NULL) { 712 706 dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); 713 707 goto err0; 708 + } 709 + 710 + /* map second resource for CMSTR */ 711 + p->mapbase_str = ioremap_nocache(res2 ? res2->start : 712 + res->start - cfg->channel_offset, 713 + res2 ? resource_size(res2) : 2); 714 + if (p->mapbase_str == NULL) { 715 + dev_err(&p->pdev->dev, "failed to remap I/O second memory\n"); 716 + goto err1; 714 717 } 715 718 716 719 /* request irq using setup_irq() (too early for request_irq()) */ ··· 734 719 if (IS_ERR(p->clk)) { 735 720 dev_err(&p->pdev->dev, "cannot get clock\n"); 736 721 ret = PTR_ERR(p->clk); 737 - goto err1; 722 + goto err2; 738 723 } 739 724 740 - p->read_control = sh_cmt_read16; 741 - p->write_control = sh_cmt_write16; 725 + if (res2 && (resource_size(res2) == 4)) { 726 + /* assume both CMSTR and CMCSR to be 32-bit */ 727 + p->read_control = sh_cmt_read32; 728 + p->write_control = sh_cmt_write32; 729 + } else { 730 + p->read_control = sh_cmt_read16; 731 + p->write_control = sh_cmt_write16; 732 + } 742 733 743 734 if (resource_size(res) == 6) { 744 735 p->width = 16; ··· 773 752 cfg->clocksource_rating); 774 753 if (ret) { 775 754 dev_err(&p->pdev->dev, "registration failed\n"); 776 - goto err2; 755 + goto err3; 777 756 } 778 757 p->cs_enabled = false; 779 758 780 759 ret = setup_irq(irq, &p->irqaction); 781 760 if (ret) { 782 761 dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); 783 - goto err2; 762 + goto err3; 784 763 } 785 764 786 765 platform_set_drvdata(pdev, p); 787 766 788 767 return 0; 789 - err2: 768 + err3: 790 769 clk_put(p->clk); 791 - 770 + err2: 771 + iounmap(p->mapbase_str); 792 772 err1: 793 773 iounmap(p->mapbase); 794 774 err0:
+77 -54
drivers/clocksource/time-armada-370-xp.c
··· 13 13 * 14 14 * Timer 0 is used as free-running clocksource, while timer 1 is 15 15 * used as clock_event_device. 16 + * 17 + * --- 18 + * Clocksource driver for Armada 370 and Armada XP SoC. 19 + * This driver implements one compatible string for each SoC, given 20 + * each has its own characteristics: 21 + * 22 + * * Armada 370 has no 25 MHz fixed timer. 23 + * 24 + * * Armada XP cannot work properly without such 25 MHz fixed timer as 25 + * doing otherwise leads to using a clocksource whose frequency varies 26 + * when doing cpufreq frequency changes. 27 + * 28 + * See Documentation/devicetree/bindings/timer/marvell,armada-370-xp-timer.txt 16 29 */ 17 30 18 31 #include <linux/init.h> ··· 43 30 #include <linux/module.h> 44 31 #include <linux/sched_clock.h> 45 32 #include <linux/percpu.h> 46 - #include <linux/time-armada-370-xp.h> 47 33 48 34 /* 49 35 * Timer block registers. 50 36 */ 51 37 #define TIMER_CTRL_OFF 0x0000 52 - #define TIMER0_EN 0x0001 53 - #define TIMER0_RELOAD_EN 0x0002 54 - #define TIMER0_25MHZ 0x0800 38 + #define TIMER0_EN BIT(0) 39 + #define TIMER0_RELOAD_EN BIT(1) 40 + #define TIMER0_25MHZ BIT(11) 55 41 #define TIMER0_DIV(div) ((div) << 19) 56 - #define TIMER1_EN 0x0004 57 - #define TIMER1_RELOAD_EN 0x0008 58 - #define TIMER1_25MHZ 0x1000 42 + #define TIMER1_EN BIT(2) 43 + #define TIMER1_RELOAD_EN BIT(3) 44 + #define TIMER1_25MHZ BIT(12) 59 45 #define TIMER1_DIV(div) ((div) << 22) 60 46 #define TIMER_EVENTS_STATUS 0x0004 61 47 #define TIMER0_CLR_MASK (~0x1) ··· 84 72 85 73 static struct clock_event_device __percpu *armada_370_xp_evt; 86 74 75 + static void timer_ctrl_clrset(u32 clr, u32 set) 76 + { 77 + writel((readl(timer_base + TIMER_CTRL_OFF) & ~clr) | set, 78 + timer_base + TIMER_CTRL_OFF); 79 + } 80 + 81 + static void local_timer_ctrl_clrset(u32 clr, u32 set) 82 + { 83 + writel((readl(local_base + TIMER_CTRL_OFF) & ~clr) | set, 84 + local_base + TIMER_CTRL_OFF); 85 + } 86 + 87 87 static u32 notrace armada_370_xp_read_sched_clock(void) 88 88 { 89 89 return ~readl(timer_base + TIMER0_VAL_OFF); ··· 108 84 armada_370_xp_clkevt_next_event(unsigned long delta, 109 85 struct clock_event_device *dev) 110 86 { 111 - u32 u; 112 87 /* 113 88 * Clear clockevent timer interrupt. 114 89 */ ··· 121 98 /* 122 99 * Enable the timer. 123 100 */ 124 - u = readl(local_base + TIMER_CTRL_OFF); 125 - u = ((u & ~TIMER0_RELOAD_EN) | TIMER0_EN | 126 - TIMER0_DIV(TIMER_DIVIDER_SHIFT)); 127 - writel(u, local_base + TIMER_CTRL_OFF); 128 - 101 + local_timer_ctrl_clrset(TIMER0_RELOAD_EN, 102 + TIMER0_EN | TIMER0_DIV(TIMER_DIVIDER_SHIFT)); 129 103 return 0; 130 104 } 131 105 ··· 130 110 armada_370_xp_clkevt_mode(enum clock_event_mode mode, 131 111 struct clock_event_device *dev) 132 112 { 133 - u32 u; 134 - 135 113 if (mode == CLOCK_EVT_MODE_PERIODIC) { 136 114 137 115 /* ··· 141 123 /* 142 124 * Enable timer. 143 125 */ 144 - 145 - u = readl(local_base + TIMER_CTRL_OFF); 146 - 147 - writel((u | TIMER0_EN | TIMER0_RELOAD_EN | 148 - TIMER0_DIV(TIMER_DIVIDER_SHIFT)), 149 - local_base + TIMER_CTRL_OFF); 126 + local_timer_ctrl_clrset(0, TIMER0_RELOAD_EN | 127 + TIMER0_EN | 128 + TIMER0_DIV(TIMER_DIVIDER_SHIFT)); 150 129 } else { 151 130 /* 152 131 * Disable timer. 153 132 */ 154 - u = readl(local_base + TIMER_CTRL_OFF); 155 - writel(u & ~TIMER0_EN, local_base + TIMER_CTRL_OFF); 133 + local_timer_ctrl_clrset(TIMER0_EN, 0); 156 134 157 135 /* 158 136 * ACK pending timer interrupt. ··· 177 163 */ 178 164 static int armada_370_xp_timer_setup(struct clock_event_device *evt) 179 165 { 180 - u32 u; 166 + u32 clr = 0, set = 0; 181 167 int cpu = smp_processor_id(); 182 168 183 - u = readl(local_base + TIMER_CTRL_OFF); 184 169 if (timer25Mhz) 185 - writel(u | TIMER0_25MHZ, local_base + TIMER_CTRL_OFF); 170 + set = TIMER0_25MHZ; 186 171 else 187 - writel(u & ~TIMER0_25MHZ, local_base + TIMER_CTRL_OFF); 172 + clr = TIMER0_25MHZ; 173 + local_timer_ctrl_clrset(clr, set); 188 174 189 175 evt->name = "armada_370_xp_per_cpu_tick", 190 176 evt->features = CLOCK_EVT_FEAT_ONESHOT | ··· 231 217 .notifier_call = armada_370_xp_timer_cpu_notify, 232 218 }; 233 219 234 - void __init armada_370_xp_timer_init(void) 220 + static void __init armada_370_xp_timer_common_init(struct device_node *np) 235 221 { 236 - u32 u; 237 - struct device_node *np; 222 + u32 clr = 0, set = 0; 238 223 int res; 239 224 240 - np = of_find_compatible_node(NULL, NULL, "marvell,armada-370-xp-timer"); 241 225 timer_base = of_iomap(np, 0); 242 226 WARN_ON(!timer_base); 243 227 local_base = of_iomap(np, 1); 244 228 245 - if (of_find_property(np, "marvell,timer-25Mhz", NULL)) { 246 - /* The fixed 25MHz timer is available so let's use it */ 247 - u = readl(timer_base + TIMER_CTRL_OFF); 248 - writel(u | TIMER0_25MHZ, 249 - timer_base + TIMER_CTRL_OFF); 250 - timer_clk = 25000000; 251 - } else { 252 - unsigned long rate = 0; 253 - struct clk *clk = of_clk_get(np, 0); 254 - WARN_ON(IS_ERR(clk)); 255 - rate = clk_get_rate(clk); 256 - 257 - u = readl(timer_base + TIMER_CTRL_OFF); 258 - writel(u & ~(TIMER0_25MHZ), 259 - timer_base + TIMER_CTRL_OFF); 260 - 261 - timer_clk = rate / TIMER_DIVIDER; 262 - timer25Mhz = false; 263 - } 229 + if (timer25Mhz) 230 + set = TIMER0_25MHZ; 231 + else 232 + clr = TIMER0_25MHZ; 233 + timer_ctrl_clrset(clr, set); 234 + local_timer_ctrl_clrset(clr, set); 264 235 265 236 /* 266 237 * We use timer 0 as clocksource, and private(local) timer 0 ··· 267 268 writel(0xffffffff, timer_base + TIMER0_VAL_OFF); 268 269 writel(0xffffffff, timer_base + TIMER0_RELOAD_OFF); 269 270 270 - u = readl(timer_base + TIMER_CTRL_OFF); 271 - 272 - writel((u | TIMER0_EN | TIMER0_RELOAD_EN | 273 - TIMER0_DIV(TIMER_DIVIDER_SHIFT)), timer_base + TIMER_CTRL_OFF); 271 + timer_ctrl_clrset(0, TIMER0_EN | TIMER0_RELOAD_EN | 272 + TIMER0_DIV(TIMER_DIVIDER_SHIFT)); 274 273 275 274 clocksource_mmio_init(timer_base + TIMER0_VAL_OFF, 276 275 "armada_370_xp_clocksource", ··· 290 293 if (!res) 291 294 armada_370_xp_timer_setup(this_cpu_ptr(armada_370_xp_evt)); 292 295 } 296 + 297 + static void __init armada_xp_timer_init(struct device_node *np) 298 + { 299 + struct clk *clk = of_clk_get_by_name(np, "fixed"); 300 + 301 + /* The 25Mhz fixed clock is mandatory, and must always be available */ 302 + BUG_ON(IS_ERR(clk)); 303 + timer_clk = clk_get_rate(clk); 304 + 305 + armada_370_xp_timer_common_init(np); 306 + } 307 + CLOCKSOURCE_OF_DECLARE(armada_xp, "marvell,armada-xp-timer", 308 + armada_xp_timer_init); 309 + 310 + static void __init armada_370_timer_init(struct device_node *np) 311 + { 312 + struct clk *clk = of_clk_get(np, 0); 313 + 314 + BUG_ON(IS_ERR(clk)); 315 + timer_clk = clk_get_rate(clk) / TIMER_DIVIDER; 316 + timer25Mhz = false; 317 + 318 + armada_370_xp_timer_common_init(np); 319 + } 320 + CLOCKSOURCE_OF_DECLARE(armada_370, "marvell,armada-370-timer", 321 + armada_370_timer_init);
-16
include/linux/time-armada-370-xp.h
··· 1 - /* 2 - * Marvell Armada 370/XP SoC timer handling. 3 - * 4 - * Copyright (C) 2012 Marvell 5 - * 6 - * Lior Amsalem <alior@marvell.com> 7 - * Gregory CLEMENT <gregory.clement@free-electrons.com> 8 - * Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 9 - * 10 - */ 11 - #ifndef __TIME_ARMADA_370_XPPRCMU_H 12 - #define __TIME_ARMADA_370_XPPRCMU_H 13 - 14 - void armada_370_xp_timer_init(void); 15 - 16 - #endif