2 * OMAP1 Dual-Mode Timers - platform device registration
4 * Contains first level initialization routines which internally
5 * generates timer device information and registers with linux
6 * device model. It also has a low level function to change the timer
9 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
10 * Tarun Kanti DebBarma <tarun.kanti@ti.com>
11 * Thara Gopinath <thara@ti.com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
17 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
18 * kind, whether express or implied; without even the implied warranty
19 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
23 #include <linux/clk.h>
25 #include <linux/err.h>
26 #include <linux/slab.h>
27 #include <linux/platform_device.h>
28 #include <linux/platform_data/dmtimer-omap.h>
30 #include <clocksource/timer-ti-dm.h>
34 #define OMAP1610_GPTIMER1_BASE 0xfffb1400
35 #define OMAP1610_GPTIMER2_BASE 0xfffb1c00
36 #define OMAP1610_GPTIMER3_BASE 0xfffb2400
37 #define OMAP1610_GPTIMER4_BASE 0xfffb2c00
38 #define OMAP1610_GPTIMER5_BASE 0xfffb3400
39 #define OMAP1610_GPTIMER6_BASE 0xfffb3c00
40 #define OMAP1610_GPTIMER7_BASE 0xfffb7400
41 #define OMAP1610_GPTIMER8_BASE 0xfffbd400
43 #define OMAP1_DM_TIMER_COUNT 8
45 static int omap1_dm_timer_set_src(struct platform_device *pdev,
48 int n = (pdev->id - 1) << 1;
51 l = omap_readl(MOD_CONF_CTRL_1) & ~(0x03 << n);
53 omap_writel(l, MOD_CONF_CTRL_1);
58 static int __init omap1_dm_timer_init(void)
62 struct dmtimer_platform_data *pdata;
63 struct platform_device *pdev;
65 if (!cpu_is_omap16xx())
68 for (i = 1; i <= OMAP1_DM_TIMER_COUNT; i++) {
69 struct resource res[2];
74 base = OMAP1610_GPTIMER1_BASE;
75 irq = INT_1610_GPTIMER1;
78 base = OMAP1610_GPTIMER2_BASE;
79 irq = INT_1610_GPTIMER2;
82 base = OMAP1610_GPTIMER3_BASE;
83 irq = INT_1610_GPTIMER3;
86 base = OMAP1610_GPTIMER4_BASE;
87 irq = INT_1610_GPTIMER4;
90 base = OMAP1610_GPTIMER5_BASE;
91 irq = INT_1610_GPTIMER5;
94 base = OMAP1610_GPTIMER6_BASE;
95 irq = INT_1610_GPTIMER6;
98 base = OMAP1610_GPTIMER7_BASE;
99 irq = INT_1610_GPTIMER7;
102 base = OMAP1610_GPTIMER8_BASE;
103 irq = INT_1610_GPTIMER8;
107 * not supposed to reach here.
108 * this is to remove warning.
113 pdev = platform_device_alloc("omap_timer", i);
115 pr_err("%s: Failed to device alloc for dmtimer%d\n",
120 memset(res, 0, 2 * sizeof(struct resource));
122 res[0].end = base + 0x46;
123 res[0].flags = IORESOURCE_MEM;
126 res[1].flags = IORESOURCE_IRQ;
127 ret = platform_device_add_resources(pdev, res,
130 dev_err(&pdev->dev, "%s: Failed to add resources.\n",
135 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
141 pdata->set_timer_src = omap1_dm_timer_set_src;
142 pdata->timer_capability = OMAP_TIMER_ALWON |
143 OMAP_TIMER_NEEDS_RESET | OMAP_TIMER_HAS_DSP_IRQ;
145 ret = platform_device_add_data(pdev, pdata, sizeof(*pdata));
147 dev_err(&pdev->dev, "%s: Failed to add platform data.\n",
152 ret = platform_device_add(pdev);
154 dev_err(&pdev->dev, "%s: Failed to add platform device.\n",
159 dev_dbg(&pdev->dev, " Registered.\n");
168 platform_device_put(pdev);
172 arch_initcall(omap1_dm_timer_init);