Fabio Estevam | c53bb60 | 2018-05-22 20:05:04 -0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | // |
| 3 | // Copyright (C) 2000-2001 Deep Blue Solutions |
| 4 | // Copyright (C) 2002 Shane Nay (shane@minirl.com) |
| 5 | // Copyright (C) 2006-2007 Pavel Pisa (ppisa@pikron.com) |
| 6 | // Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de) |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 7 | |
| 8 | #include <linux/interrupt.h> |
| 9 | #include <linux/irq.h> |
| 10 | #include <linux/clockchips.h> |
| 11 | #include <linux/clk.h> |
Sebastian Andrzej Siewior | 1119c84 | 2014-01-22 12:35:44 +0100 | [diff] [blame] | 12 | #include <linux/delay.h> |
Sascha Hauer | 821dc4d | 2012-03-09 09:29:27 +0100 | [diff] [blame] | 13 | #include <linux/err.h> |
Stephen Boyd | 38ff87f | 2013-06-01 23:39:40 -0700 | [diff] [blame] | 14 | #include <linux/sched_clock.h> |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 15 | #include <linux/slab.h> |
Gilles Chanteperdrix | 876292d | 2014-04-05 17:57:45 +0200 | [diff] [blame] | 16 | #include <linux/of.h> |
| 17 | #include <linux/of_address.h> |
| 18 | #include <linux/of_irq.h> |
Shawn Guo | 0931aff | 2015-05-15 11:41:39 +0800 | [diff] [blame] | 19 | #include <soc/imx/timer.h> |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 20 | |
Sascha Hauer | 0f3332c | 2009-12-04 09:34:51 +0100 | [diff] [blame] | 21 | /* |
Shenwei Wang | 65d0a16 | 2015-04-29 16:40:27 -0500 | [diff] [blame] | 22 | * There are 4 versions of the timer hardware on Freescale MXC hardware. |
| 23 | * - MX1/MXL |
| 24 | * - MX21, MX27. |
| 25 | * - MX25, MX31, MX35, MX37, MX51, MX6Q(rev1.0) |
| 26 | * - MX6DL, MX6SX, MX6Q(rev1.1+) |
Sascha Hauer | 0f3332c | 2009-12-04 09:34:51 +0100 | [diff] [blame] | 27 | */ |
| 28 | |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 29 | /* defines common for all i.MX */ |
| 30 | #define MXC_TCTL 0x00 |
Sascha Hauer | 0f3332c | 2009-12-04 09:34:51 +0100 | [diff] [blame] | 31 | #define MXC_TCTL_TEN (1 << 0) /* Enable module */ |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 32 | #define MXC_TPRER 0x04 |
| 33 | |
| 34 | /* MX1, MX21, MX27 */ |
| 35 | #define MX1_2_TCTL_CLK_PCLK1 (1 << 1) |
| 36 | #define MX1_2_TCTL_IRQEN (1 << 4) |
| 37 | #define MX1_2_TCTL_FRR (1 << 8) |
| 38 | #define MX1_2_TCMP 0x08 |
| 39 | #define MX1_2_TCN 0x10 |
| 40 | #define MX1_2_TSTAT 0x14 |
| 41 | |
| 42 | /* MX21, MX27 */ |
| 43 | #define MX2_TSTAT_CAPT (1 << 1) |
| 44 | #define MX2_TSTAT_COMP (1 << 0) |
| 45 | |
Anson Huang | bad3db1 | 2014-09-11 11:29:42 +0800 | [diff] [blame] | 46 | /* MX31, MX35, MX25, MX5, MX6 */ |
Amit Kucheria | 38a66f5 | 2010-04-21 21:34:36 +0300 | [diff] [blame] | 47 | #define V2_TCTL_WAITEN (1 << 3) /* Wait enable mode */ |
| 48 | #define V2_TCTL_CLK_IPG (1 << 6) |
Richard Zhao | 1f152b4 | 2012-05-15 15:34:40 +0800 | [diff] [blame] | 49 | #define V2_TCTL_CLK_PER (2 << 6) |
Anson Huang | bad3db1 | 2014-09-11 11:29:42 +0800 | [diff] [blame] | 50 | #define V2_TCTL_CLK_OSC_DIV8 (5 << 6) |
Amit Kucheria | 38a66f5 | 2010-04-21 21:34:36 +0300 | [diff] [blame] | 51 | #define V2_TCTL_FRR (1 << 9) |
Anson Huang | bad3db1 | 2014-09-11 11:29:42 +0800 | [diff] [blame] | 52 | #define V2_TCTL_24MEN (1 << 10) |
| 53 | #define V2_TPRER_PRE24M 12 |
Amit Kucheria | 38a66f5 | 2010-04-21 21:34:36 +0300 | [diff] [blame] | 54 | #define V2_IR 0x0c |
| 55 | #define V2_TSTAT 0x08 |
| 56 | #define V2_TSTAT_OF1 (1 << 0) |
| 57 | #define V2_TCN 0x24 |
| 58 | #define V2_TCMP 0x10 |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 59 | |
Anson Huang | bad3db1 | 2014-09-11 11:29:42 +0800 | [diff] [blame] | 60 | #define V2_TIMER_RATE_OSC_DIV8 3000000 |
| 61 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 62 | struct imx_timer { |
Shawn Guo | 0931aff | 2015-05-15 11:41:39 +0800 | [diff] [blame] | 63 | enum imx_gpt_type type; |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 64 | void __iomem *base; |
| 65 | int irq; |
| 66 | struct clk *clk_per; |
| 67 | struct clk *clk_ipg; |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 68 | const struct imx_gpt_data *gpt; |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 69 | struct clock_event_device ced; |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | struct imx_gpt_data { |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 73 | int reg_tstat; |
| 74 | int reg_tcn; |
| 75 | int reg_tcmp; |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 76 | void (*gpt_setup_tctl)(struct imx_timer *imxtm); |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 77 | void (*gpt_irq_enable)(struct imx_timer *imxtm); |
| 78 | void (*gpt_irq_disable)(struct imx_timer *imxtm); |
| 79 | void (*gpt_irq_acknowledge)(struct imx_timer *imxtm); |
Shawn Guo | 5ab0475 | 2015-05-22 15:51:41 +0800 | [diff] [blame] | 80 | int (*set_next_event)(unsigned long evt, |
| 81 | struct clock_event_device *ced); |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 82 | }; |
| 83 | |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 84 | static inline struct imx_timer *to_imx_timer(struct clock_event_device *ced) |
| 85 | { |
| 86 | return container_of(ced, struct imx_timer, ced); |
| 87 | } |
| 88 | |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 89 | static void imx1_gpt_irq_disable(struct imx_timer *imxtm) |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 90 | { |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 91 | unsigned int tmp; |
| 92 | |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 93 | tmp = readl_relaxed(imxtm->base + MXC_TCTL); |
| 94 | writel_relaxed(tmp & ~MX1_2_TCTL_IRQEN, imxtm->base + MXC_TCTL); |
| 95 | } |
| 96 | #define imx21_gpt_irq_disable imx1_gpt_irq_disable |
| 97 | |
| 98 | static void imx31_gpt_irq_disable(struct imx_timer *imxtm) |
| 99 | { |
| 100 | writel_relaxed(0, imxtm->base + V2_IR); |
| 101 | } |
| 102 | #define imx6dl_gpt_irq_disable imx31_gpt_irq_disable |
| 103 | |
| 104 | static void imx1_gpt_irq_enable(struct imx_timer *imxtm) |
| 105 | { |
| 106 | unsigned int tmp; |
| 107 | |
| 108 | tmp = readl_relaxed(imxtm->base + MXC_TCTL); |
| 109 | writel_relaxed(tmp | MX1_2_TCTL_IRQEN, imxtm->base + MXC_TCTL); |
| 110 | } |
| 111 | #define imx21_gpt_irq_enable imx1_gpt_irq_enable |
| 112 | |
| 113 | static void imx31_gpt_irq_enable(struct imx_timer *imxtm) |
| 114 | { |
| 115 | writel_relaxed(1<<0, imxtm->base + V2_IR); |
| 116 | } |
| 117 | #define imx6dl_gpt_irq_enable imx31_gpt_irq_enable |
| 118 | |
| 119 | static void imx1_gpt_irq_acknowledge(struct imx_timer *imxtm) |
| 120 | { |
| 121 | writel_relaxed(0, imxtm->base + MX1_2_TSTAT); |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 122 | } |
| 123 | |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 124 | static void imx21_gpt_irq_acknowledge(struct imx_timer *imxtm) |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 125 | { |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 126 | writel_relaxed(MX2_TSTAT_CAPT | MX2_TSTAT_COMP, |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 127 | imxtm->base + MX1_2_TSTAT); |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 128 | } |
| 129 | |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 130 | static void imx31_gpt_irq_acknowledge(struct imx_timer *imxtm) |
| 131 | { |
| 132 | writel_relaxed(V2_TSTAT_OF1, imxtm->base + V2_TSTAT); |
| 133 | } |
| 134 | #define imx6dl_gpt_irq_acknowledge imx31_gpt_irq_acknowledge |
| 135 | |
Russell King | 234b6ced | 2011-05-08 14:09:47 +0100 | [diff] [blame] | 136 | static void __iomem *sched_clock_reg; |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 137 | |
Stephen Boyd | b93767e | 2013-11-15 15:26:12 -0800 | [diff] [blame] | 138 | static u64 notrace mxc_read_sched_clock(void) |
Jan Weitzel | c124bef | 2011-03-17 13:44:30 +0100 | [diff] [blame] | 139 | { |
Shawn Guo | c7770bb | 2015-05-19 18:47:47 +0800 | [diff] [blame] | 140 | return sched_clock_reg ? readl_relaxed(sched_clock_reg) : 0; |
Jan Weitzel | c124bef | 2011-03-17 13:44:30 +0100 | [diff] [blame] | 141 | } |
| 142 | |
Anson Huang | df181e3 | 2018-11-05 01:10:27 +0000 | [diff] [blame] | 143 | #if defined(CONFIG_ARM) |
Sebastian Andrzej Siewior | 1119c84 | 2014-01-22 12:35:44 +0100 | [diff] [blame] | 144 | static struct delay_timer imx_delay_timer; |
| 145 | |
| 146 | static unsigned long imx_read_current_timer(void) |
| 147 | { |
Shawn Guo | c7770bb | 2015-05-19 18:47:47 +0800 | [diff] [blame] | 148 | return readl_relaxed(sched_clock_reg); |
Sebastian Andrzej Siewior | 1119c84 | 2014-01-22 12:35:44 +0100 | [diff] [blame] | 149 | } |
Anson Huang | df181e3 | 2018-11-05 01:10:27 +0000 | [diff] [blame] | 150 | #endif |
Sebastian Andrzej Siewior | 1119c84 | 2014-01-22 12:35:44 +0100 | [diff] [blame] | 151 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 152 | static int __init mxc_clocksource_init(struct imx_timer *imxtm) |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 153 | { |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 154 | unsigned int c = clk_get_rate(imxtm->clk_per); |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 155 | void __iomem *reg = imxtm->base + imxtm->gpt->reg_tcn; |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 156 | |
Anson Huang | df181e3 | 2018-11-05 01:10:27 +0000 | [diff] [blame] | 157 | #if defined(CONFIG_ARM) |
Sebastian Andrzej Siewior | 1119c84 | 2014-01-22 12:35:44 +0100 | [diff] [blame] | 158 | imx_delay_timer.read_current_timer = &imx_read_current_timer; |
| 159 | imx_delay_timer.freq = c; |
| 160 | register_current_timer_delay(&imx_delay_timer); |
Anson Huang | df181e3 | 2018-11-05 01:10:27 +0000 | [diff] [blame] | 161 | #endif |
Sebastian Andrzej Siewior | 1119c84 | 2014-01-22 12:35:44 +0100 | [diff] [blame] | 162 | |
Russell King | 234b6ced | 2011-05-08 14:09:47 +0100 | [diff] [blame] | 163 | sched_clock_reg = reg; |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 164 | |
Stephen Boyd | b93767e | 2013-11-15 15:26:12 -0800 | [diff] [blame] | 165 | sched_clock_register(mxc_read_sched_clock, 32, c); |
Russell King | 234b6ced | 2011-05-08 14:09:47 +0100 | [diff] [blame] | 166 | return clocksource_mmio_init(reg, "mxc_timer1", c, 200, 32, |
| 167 | clocksource_mmio_readl_up); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | /* clock event */ |
| 171 | |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 172 | static int mx1_2_set_next_event(unsigned long evt, |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 173 | struct clock_event_device *ced) |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 174 | { |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 175 | struct imx_timer *imxtm = to_imx_timer(ced); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 176 | unsigned long tcmp; |
| 177 | |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 178 | tcmp = readl_relaxed(imxtm->base + MX1_2_TCN) + evt; |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 179 | |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 180 | writel_relaxed(tcmp, imxtm->base + MX1_2_TCMP); |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 181 | |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 182 | return (int)(tcmp - readl_relaxed(imxtm->base + MX1_2_TCN)) < 0 ? |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 183 | -ETIME : 0; |
| 184 | } |
| 185 | |
Amit Kucheria | 38a66f5 | 2010-04-21 21:34:36 +0300 | [diff] [blame] | 186 | static int v2_set_next_event(unsigned long evt, |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 187 | struct clock_event_device *ced) |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 188 | { |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 189 | struct imx_timer *imxtm = to_imx_timer(ced); |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 190 | unsigned long tcmp; |
| 191 | |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 192 | tcmp = readl_relaxed(imxtm->base + V2_TCN) + evt; |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 193 | |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 194 | writel_relaxed(tcmp, imxtm->base + V2_TCMP); |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 195 | |
Shawn Guo | eea8e32 | 2012-12-06 22:54:41 +0800 | [diff] [blame] | 196 | return evt < 0x7fffffff && |
Shawn Guo | 8995552 | 2015-05-22 22:23:28 +0800 | [diff] [blame] | 197 | (int)(tcmp - readl_relaxed(imxtm->base + V2_TCN)) < 0 ? |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 198 | -ETIME : 0; |
| 199 | } |
| 200 | |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 201 | static int mxc_shutdown(struct clock_event_device *ced) |
| 202 | { |
| 203 | struct imx_timer *imxtm = to_imx_timer(ced); |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 204 | u32 tcn; |
| 205 | |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 206 | /* Disable interrupt in GPT module */ |
| 207 | imxtm->gpt->gpt_irq_disable(imxtm); |
| 208 | |
| 209 | tcn = readl_relaxed(imxtm->base + imxtm->gpt->reg_tcn); |
| 210 | /* Set event time into far-far future */ |
| 211 | writel_relaxed(tcn - 3, imxtm->base + imxtm->gpt->reg_tcmp); |
| 212 | |
| 213 | /* Clear pending interrupt */ |
| 214 | imxtm->gpt->gpt_irq_acknowledge(imxtm); |
| 215 | |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 216 | #ifdef DEBUG |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 217 | printk(KERN_INFO "%s: changing mode\n", __func__); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 218 | #endif /* DEBUG */ |
| 219 | |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 220 | return 0; |
| 221 | } |
| 222 | |
| 223 | static int mxc_set_oneshot(struct clock_event_device *ced) |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 224 | { |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 225 | struct imx_timer *imxtm = to_imx_timer(ced); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 226 | |
| 227 | /* Disable interrupt in GPT module */ |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 228 | imxtm->gpt->gpt_irq_disable(imxtm); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 229 | |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 230 | if (!clockevent_state_oneshot(ced)) { |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 231 | u32 tcn = readl_relaxed(imxtm->base + imxtm->gpt->reg_tcn); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 232 | /* Set event time into far-far future */ |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 233 | writel_relaxed(tcn - 3, imxtm->base + imxtm->gpt->reg_tcmp); |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 234 | |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 235 | /* Clear pending interrupt */ |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 236 | imxtm->gpt->gpt_irq_acknowledge(imxtm); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | #ifdef DEBUG |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 240 | printk(KERN_INFO "%s: changing mode\n", __func__); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 241 | #endif /* DEBUG */ |
| 242 | |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 243 | /* |
| 244 | * Do not put overhead of interrupt enable/disable into |
| 245 | * mxc_set_next_event(), the core has about 4 minutes |
| 246 | * to call mxc_set_next_event() or shutdown clock after |
| 247 | * mode switching |
| 248 | */ |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 249 | imxtm->gpt->gpt_irq_enable(imxtm); |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 250 | |
| 251 | return 0; |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | /* |
| 255 | * IRQ handler for the timer |
| 256 | */ |
| 257 | static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id) |
| 258 | { |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 259 | struct clock_event_device *ced = dev_id; |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 260 | struct imx_timer *imxtm = to_imx_timer(ced); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 261 | uint32_t tstat; |
| 262 | |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 263 | tstat = readl_relaxed(imxtm->base + imxtm->gpt->reg_tstat); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 264 | |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 265 | imxtm->gpt->gpt_irq_acknowledge(imxtm); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 266 | |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 267 | ced->event_handler(ced); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 268 | |
| 269 | return IRQ_HANDLED; |
| 270 | } |
| 271 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 272 | static int __init mxc_clockevent_init(struct imx_timer *imxtm) |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 273 | { |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 274 | struct clock_event_device *ced = &imxtm->ced; |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 275 | |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 276 | ced->name = "mxc_timer1"; |
Lucas Stach | f1c08c9 | 2015-10-14 11:24:17 +0200 | [diff] [blame] | 277 | ced->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_DYNIRQ; |
Viresh Kumar | 26b91f0 | 2015-07-06 15:39:18 +0530 | [diff] [blame] | 278 | ced->set_state_shutdown = mxc_shutdown; |
| 279 | ced->set_state_oneshot = mxc_set_oneshot; |
| 280 | ced->tick_resume = mxc_shutdown; |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 281 | ced->set_next_event = imxtm->gpt->set_next_event; |
| 282 | ced->rating = 200; |
| 283 | ced->cpumask = cpumask_of(0); |
Lucas Stach | f1c08c9 | 2015-10-14 11:24:17 +0200 | [diff] [blame] | 284 | ced->irq = imxtm->irq; |
Shawn Guo | e510d20 | 2015-05-22 16:38:49 +0800 | [diff] [blame] | 285 | clockevents_config_and_register(ced, clk_get_rate(imxtm->clk_per), |
Shawn Guo | 838a2ae | 2013-01-12 11:50:05 +0000 | [diff] [blame] | 286 | 0xff, 0xfffffffe); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 287 | |
afzal mohammed | cc2550b | 2020-02-27 16:29:02 +0530 | [diff] [blame^] | 288 | return request_irq(imxtm->irq, mxc_timer_interrupt, |
| 289 | IRQF_TIMER | IRQF_IRQPOLL, "i.MX Timer Tick", ced); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 290 | } |
| 291 | |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 292 | static void imx1_gpt_setup_tctl(struct imx_timer *imxtm) |
| 293 | { |
| 294 | u32 tctl_val; |
| 295 | |
| 296 | tctl_val = MX1_2_TCTL_FRR | MX1_2_TCTL_CLK_PCLK1 | MXC_TCTL_TEN; |
| 297 | writel_relaxed(tctl_val, imxtm->base + MXC_TCTL); |
| 298 | } |
| 299 | #define imx21_gpt_setup_tctl imx1_gpt_setup_tctl |
| 300 | |
| 301 | static void imx31_gpt_setup_tctl(struct imx_timer *imxtm) |
| 302 | { |
| 303 | u32 tctl_val; |
| 304 | |
| 305 | tctl_val = V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN; |
| 306 | if (clk_get_rate(imxtm->clk_per) == V2_TIMER_RATE_OSC_DIV8) |
| 307 | tctl_val |= V2_TCTL_CLK_OSC_DIV8; |
| 308 | else |
| 309 | tctl_val |= V2_TCTL_CLK_PER; |
| 310 | |
| 311 | writel_relaxed(tctl_val, imxtm->base + MXC_TCTL); |
| 312 | } |
| 313 | |
| 314 | static void imx6dl_gpt_setup_tctl(struct imx_timer *imxtm) |
| 315 | { |
| 316 | u32 tctl_val; |
| 317 | |
| 318 | tctl_val = V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN; |
| 319 | if (clk_get_rate(imxtm->clk_per) == V2_TIMER_RATE_OSC_DIV8) { |
| 320 | tctl_val |= V2_TCTL_CLK_OSC_DIV8; |
| 321 | /* 24 / 8 = 3 MHz */ |
| 322 | writel_relaxed(7 << V2_TPRER_PRE24M, imxtm->base + MXC_TPRER); |
| 323 | tctl_val |= V2_TCTL_24MEN; |
| 324 | } else { |
| 325 | tctl_val |= V2_TCTL_CLK_PER; |
| 326 | } |
| 327 | |
| 328 | writel_relaxed(tctl_val, imxtm->base + MXC_TCTL); |
| 329 | } |
| 330 | |
| 331 | static const struct imx_gpt_data imx1_gpt_data = { |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 332 | .reg_tstat = MX1_2_TSTAT, |
| 333 | .reg_tcn = MX1_2_TCN, |
| 334 | .reg_tcmp = MX1_2_TCMP, |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 335 | .gpt_irq_enable = imx1_gpt_irq_enable, |
| 336 | .gpt_irq_disable = imx1_gpt_irq_disable, |
| 337 | .gpt_irq_acknowledge = imx1_gpt_irq_acknowledge, |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 338 | .gpt_setup_tctl = imx1_gpt_setup_tctl, |
Shawn Guo | 5ab0475 | 2015-05-22 15:51:41 +0800 | [diff] [blame] | 339 | .set_next_event = mx1_2_set_next_event, |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | static const struct imx_gpt_data imx21_gpt_data = { |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 343 | .reg_tstat = MX1_2_TSTAT, |
| 344 | .reg_tcn = MX1_2_TCN, |
| 345 | .reg_tcmp = MX1_2_TCMP, |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 346 | .gpt_irq_enable = imx21_gpt_irq_enable, |
| 347 | .gpt_irq_disable = imx21_gpt_irq_disable, |
| 348 | .gpt_irq_acknowledge = imx21_gpt_irq_acknowledge, |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 349 | .gpt_setup_tctl = imx21_gpt_setup_tctl, |
Shawn Guo | 5ab0475 | 2015-05-22 15:51:41 +0800 | [diff] [blame] | 350 | .set_next_event = mx1_2_set_next_event, |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 351 | }; |
| 352 | |
| 353 | static const struct imx_gpt_data imx31_gpt_data = { |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 354 | .reg_tstat = V2_TSTAT, |
| 355 | .reg_tcn = V2_TCN, |
| 356 | .reg_tcmp = V2_TCMP, |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 357 | .gpt_irq_enable = imx31_gpt_irq_enable, |
| 358 | .gpt_irq_disable = imx31_gpt_irq_disable, |
| 359 | .gpt_irq_acknowledge = imx31_gpt_irq_acknowledge, |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 360 | .gpt_setup_tctl = imx31_gpt_setup_tctl, |
Shawn Guo | 5ab0475 | 2015-05-22 15:51:41 +0800 | [diff] [blame] | 361 | .set_next_event = v2_set_next_event, |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 362 | }; |
| 363 | |
| 364 | static const struct imx_gpt_data imx6dl_gpt_data = { |
Shawn Guo | 24f74ad | 2015-05-22 21:39:55 +0800 | [diff] [blame] | 365 | .reg_tstat = V2_TSTAT, |
| 366 | .reg_tcn = V2_TCN, |
| 367 | .reg_tcmp = V2_TCMP, |
Shawn Guo | db2ae4b | 2015-05-22 22:42:55 +0800 | [diff] [blame] | 368 | .gpt_irq_enable = imx6dl_gpt_irq_enable, |
| 369 | .gpt_irq_disable = imx6dl_gpt_irq_disable, |
| 370 | .gpt_irq_acknowledge = imx6dl_gpt_irq_acknowledge, |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 371 | .gpt_setup_tctl = imx6dl_gpt_setup_tctl, |
Shawn Guo | 5ab0475 | 2015-05-22 15:51:41 +0800 | [diff] [blame] | 372 | .set_next_event = v2_set_next_event, |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 373 | }; |
| 374 | |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 375 | static int __init _mxc_timer_init(struct imx_timer *imxtm) |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 376 | { |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 377 | int ret; |
| 378 | |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 379 | switch (imxtm->type) { |
| 380 | case GPT_TYPE_IMX1: |
| 381 | imxtm->gpt = &imx1_gpt_data; |
| 382 | break; |
| 383 | case GPT_TYPE_IMX21: |
| 384 | imxtm->gpt = &imx21_gpt_data; |
| 385 | break; |
| 386 | case GPT_TYPE_IMX31: |
| 387 | imxtm->gpt = &imx31_gpt_data; |
| 388 | break; |
| 389 | case GPT_TYPE_IMX6DL: |
| 390 | imxtm->gpt = &imx6dl_gpt_data; |
| 391 | break; |
| 392 | default: |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 393 | return -EINVAL; |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 394 | } |
| 395 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 396 | if (IS_ERR(imxtm->clk_per)) { |
Sascha Hauer | 2cfb451 | 2012-05-16 12:29:53 +0200 | [diff] [blame] | 397 | pr_err("i.MX timer: unable to get clk\n"); |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 398 | return PTR_ERR(imxtm->clk_per); |
Sascha Hauer | 821dc4d | 2012-03-09 09:29:27 +0100 | [diff] [blame] | 399 | } |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 400 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 401 | if (!IS_ERR(imxtm->clk_ipg)) |
| 402 | clk_prepare_enable(imxtm->clk_ipg); |
Sascha Hauer | 2cfb451 | 2012-05-16 12:29:53 +0200 | [diff] [blame] | 403 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 404 | clk_prepare_enable(imxtm->clk_per); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 405 | |
| 406 | /* |
| 407 | * Initialise to a known state (all timers off, and timing reset) |
| 408 | */ |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 409 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 410 | writel_relaxed(0, imxtm->base + MXC_TCTL); |
| 411 | writel_relaxed(0, imxtm->base + MXC_TPRER); /* see datasheet note */ |
Sascha Hauer | ec996ba | 2009-02-18 20:58:40 +0100 | [diff] [blame] | 412 | |
Shawn Guo | 9c8694b | 2015-05-15 14:24:41 +0800 | [diff] [blame] | 413 | imxtm->gpt->gpt_setup_tctl(imxtm); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 414 | |
| 415 | /* init and register the timer to the framework */ |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 416 | ret = mxc_clocksource_init(imxtm); |
| 417 | if (ret) |
| 418 | return ret; |
| 419 | |
| 420 | return mxc_clockevent_init(imxtm); |
Juergen Beisert | d0f349f | 2008-07-05 10:02:50 +0200 | [diff] [blame] | 421 | } |
Gilles Chanteperdrix | 876292d | 2014-04-05 17:57:45 +0200 | [diff] [blame] | 422 | |
Shawn Guo | 0931aff | 2015-05-15 11:41:39 +0800 | [diff] [blame] | 423 | void __init mxc_timer_init(unsigned long pbase, int irq, enum imx_gpt_type type) |
Alexander Shiyan | f469675 | 2014-05-27 13:04:46 +0400 | [diff] [blame] | 424 | { |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 425 | struct imx_timer *imxtm; |
Alexander Shiyan | f469675 | 2014-05-27 13:04:46 +0400 | [diff] [blame] | 426 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 427 | imxtm = kzalloc(sizeof(*imxtm), GFP_KERNEL); |
| 428 | BUG_ON(!imxtm); |
Alexander Shiyan | d7f9891 | 2014-05-27 13:04:47 +0400 | [diff] [blame] | 429 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 430 | imxtm->clk_per = clk_get_sys("imx-gpt.0", "per"); |
| 431 | imxtm->clk_ipg = clk_get_sys("imx-gpt.0", "ipg"); |
| 432 | |
| 433 | imxtm->base = ioremap(pbase, SZ_4K); |
| 434 | BUG_ON(!imxtm->base); |
| 435 | |
Shawn Guo | 0931aff | 2015-05-15 11:41:39 +0800 | [diff] [blame] | 436 | imxtm->type = type; |
Guenter Roeck | be3b0f9 | 2015-08-20 03:27:21 -0700 | [diff] [blame] | 437 | imxtm->irq = irq; |
Shawn Guo | 0931aff | 2015-05-15 11:41:39 +0800 | [diff] [blame] | 438 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 439 | _mxc_timer_init(imxtm); |
Alexander Shiyan | f469675 | 2014-05-27 13:04:46 +0400 | [diff] [blame] | 440 | } |
| 441 | |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 442 | static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type type) |
Gilles Chanteperdrix | 876292d | 2014-04-05 17:57:45 +0200 | [diff] [blame] | 443 | { |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 444 | struct imx_timer *imxtm; |
| 445 | static int initialized; |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 446 | int ret; |
Gilles Chanteperdrix | 876292d | 2014-04-05 17:57:45 +0200 | [diff] [blame] | 447 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 448 | /* Support one instance only */ |
| 449 | if (initialized) |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 450 | return 0; |
Alexander Shiyan | fd4959d | 2014-07-13 09:34:00 +0400 | [diff] [blame] | 451 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 452 | imxtm = kzalloc(sizeof(*imxtm), GFP_KERNEL); |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 453 | if (!imxtm) |
| 454 | return -ENOMEM; |
Gilles Chanteperdrix | 876292d | 2014-04-05 17:57:45 +0200 | [diff] [blame] | 455 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 456 | imxtm->base = of_iomap(np, 0); |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 457 | if (!imxtm->base) |
| 458 | return -ENXIO; |
| 459 | |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 460 | imxtm->irq = irq_of_parse_and_map(np, 0); |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 461 | if (imxtm->irq <= 0) |
| 462 | return -EINVAL; |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 463 | |
| 464 | imxtm->clk_ipg = of_clk_get_by_name(np, "ipg"); |
Alexander Shiyan | f469675 | 2014-05-27 13:04:46 +0400 | [diff] [blame] | 465 | |
Anson Huang | bad3db1 | 2014-09-11 11:29:42 +0800 | [diff] [blame] | 466 | /* Try osc_per first, and fall back to per otherwise */ |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 467 | imxtm->clk_per = of_clk_get_by_name(np, "osc_per"); |
| 468 | if (IS_ERR(imxtm->clk_per)) |
| 469 | imxtm->clk_per = of_clk_get_by_name(np, "per"); |
Anson Huang | bad3db1 | 2014-09-11 11:29:42 +0800 | [diff] [blame] | 470 | |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 471 | imxtm->type = type; |
| 472 | |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 473 | ret = _mxc_timer_init(imxtm); |
| 474 | if (ret) |
| 475 | return ret; |
Shawn Guo | 6dd7478 | 2015-05-22 13:53:45 +0800 | [diff] [blame] | 476 | |
| 477 | initialized = 1; |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 478 | |
| 479 | return 0; |
Gilles Chanteperdrix | 876292d | 2014-04-05 17:57:45 +0200 | [diff] [blame] | 480 | } |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 481 | |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 482 | static int __init imx1_timer_init_dt(struct device_node *np) |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 483 | { |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 484 | return mxc_timer_init_dt(np, GPT_TYPE_IMX1); |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 485 | } |
| 486 | |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 487 | static int __init imx21_timer_init_dt(struct device_node *np) |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 488 | { |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 489 | return mxc_timer_init_dt(np, GPT_TYPE_IMX21); |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 490 | } |
| 491 | |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 492 | static int __init imx31_timer_init_dt(struct device_node *np) |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 493 | { |
| 494 | enum imx_gpt_type type = GPT_TYPE_IMX31; |
| 495 | |
| 496 | /* |
| 497 | * We were using the same compatible string for i.MX6Q/D and i.MX6DL/S |
| 498 | * GPT device, while they actually have different programming model. |
| 499 | * This is a workaround to keep the existing i.MX6DL/S DTBs continue |
| 500 | * working with the new kernel. |
| 501 | */ |
| 502 | if (of_machine_is_compatible("fsl,imx6dl")) |
| 503 | type = GPT_TYPE_IMX6DL; |
| 504 | |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 505 | return mxc_timer_init_dt(np, type); |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 506 | } |
| 507 | |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 508 | static int __init imx6dl_timer_init_dt(struct device_node *np) |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 509 | { |
Daniel Lezcano | c11cd41 | 2016-06-06 23:27:05 +0200 | [diff] [blame] | 510 | return mxc_timer_init_dt(np, GPT_TYPE_IMX6DL); |
Shawn Guo | bef11c8 | 2015-05-15 13:38:20 +0800 | [diff] [blame] | 511 | } |
| 512 | |
Daniel Lezcano | 1727339 | 2017-05-26 16:56:11 +0200 | [diff] [blame] | 513 | TIMER_OF_DECLARE(imx1_timer, "fsl,imx1-gpt", imx1_timer_init_dt); |
| 514 | TIMER_OF_DECLARE(imx21_timer, "fsl,imx21-gpt", imx21_timer_init_dt); |
| 515 | TIMER_OF_DECLARE(imx27_timer, "fsl,imx27-gpt", imx21_timer_init_dt); |
| 516 | TIMER_OF_DECLARE(imx31_timer, "fsl,imx31-gpt", imx31_timer_init_dt); |
| 517 | TIMER_OF_DECLARE(imx25_timer, "fsl,imx25-gpt", imx31_timer_init_dt); |
| 518 | TIMER_OF_DECLARE(imx50_timer, "fsl,imx50-gpt", imx31_timer_init_dt); |
| 519 | TIMER_OF_DECLARE(imx51_timer, "fsl,imx51-gpt", imx31_timer_init_dt); |
| 520 | TIMER_OF_DECLARE(imx53_timer, "fsl,imx53-gpt", imx31_timer_init_dt); |
| 521 | TIMER_OF_DECLARE(imx6q_timer, "fsl,imx6q-gpt", imx31_timer_init_dt); |
| 522 | TIMER_OF_DECLARE(imx6dl_timer, "fsl,imx6dl-gpt", imx6dl_timer_init_dt); |
| 523 | TIMER_OF_DECLARE(imx6sl_timer, "fsl,imx6sl-gpt", imx6dl_timer_init_dt); |
| 524 | TIMER_OF_DECLARE(imx6sx_timer, "fsl,imx6sx-gpt", imx6dl_timer_init_dt); |