blob: ff28d8ad1ed7347dec1928ca0d2bb1ac118d7c47 [file] [log] [blame]
Jonas Aaberg5f5663a2011-09-14 09:10:54 +02001/*
2 * Copyright (C) ST-Ericsson SA 2011
3 *
4 * License Terms: GNU General Public License v2
5 * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson
6 */
7#include <linux/io.h>
Linus Walleijb1e3be062011-10-03 09:30:20 +02008#include <linux/errno.h>
Jonas Aaberg5f5663a2011-09-14 09:10:54 +02009#include <linux/clksrc-dbx500-prcmu.h>
Rob Herringda4a6862013-02-06 21:17:47 -060010#include <linux/clocksource.h>
Lee Jones71de5c42012-03-16 09:53:24 +000011#include <linux/of.h>
Lee Jonesc51423f2012-04-24 10:04:46 +010012#include <linux/of_address.h>
Jonas Aaberg5f5663a2011-09-14 09:10:54 +020013
Arnd Bergmanne657bcf2013-03-21 22:51:12 +010014#include "setup.h"
Jonas Aaberg5f5663a2011-09-14 09:10:54 +020015
Linus Walleij174e7792013-03-19 15:41:55 +010016#include "db8500-regs.h"
Linus Walleij7a4f2602012-09-19 19:31:19 +020017#include "id.h"
18
Tobias Klauser922468c2014-07-01 10:47:48 +020019static const struct of_device_id prcmu_timer_of_match[] __initconst = {
Lee Jonesc51423f2012-04-24 10:04:46 +010020 { .compatible = "stericsson,db8500-prcmu-timer-4", },
21 { },
22};
23
Stephen Warren6bb27d72012-11-08 12:40:59 -070024void __init ux500_timer_init(void)
Jonas Aaberg5f5663a2011-09-14 09:10:54 +020025{
Linus Walleijb1e3be062011-10-03 09:30:20 +020026 void __iomem *prcmu_timer_base;
Lee Jonesc51423f2012-04-24 10:04:46 +010027 void __iomem *tmp_base;
28 struct device_node *np;
Linus Walleijb1e3be062011-10-03 09:30:20 +020029
Linus Walleij8da15e12013-11-19 22:17:06 +010030 if (cpu_is_u8500_family() || cpu_is_ux540_family())
Linus Walleijb1e3be062011-10-03 09:30:20 +020031 prcmu_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE);
Linus Walleij8da15e12013-11-19 22:17:06 +010032 else
Jonas Aaberg5f5663a2011-09-14 09:10:54 +020033 ux500_unknown_soc();
Jonas Aaberg5f5663a2011-09-14 09:10:54 +020034
Lee Jonesac9c0cf2013-11-06 10:05:48 +000035 np = of_find_matching_node(NULL, prcmu_timer_of_match);
36 if (!np)
37 goto dt_fail;
Lee Jonesc51423f2012-04-24 10:04:46 +010038
Lee Jonesac9c0cf2013-11-06 10:05:48 +000039 tmp_base = of_iomap(np, 0);
40 if (!tmp_base)
41 goto dt_fail;
Lee Jonesc51423f2012-04-24 10:04:46 +010042
Lee Jonesac9c0cf2013-11-06 10:05:48 +000043 prcmu_timer_base = tmp_base;
Lee Jonesc51423f2012-04-24 10:04:46 +010044
45dt_fail:
Linus Walleijb1e3be062011-10-03 09:30:20 +020046 clksrc_dbx500_prcmu_init(prcmu_timer_base);
Linus Walleij089b5c92013-11-19 22:37:55 +010047 clocksource_of_init();
Jonas Aaberg5f5663a2011-09-14 09:10:54 +020048}