Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
f3a186f
Documentation
arch
alpha
arc
arm
boot
common
configs
crypto
firmware
include
kernel
kvm
lib
mach-alpine
mach-artpec
mach-asm9260
mach-at91
mach-axxia
mach-bcm
mach-berlin
mach-clps711x
mach-cns3xxx
mach-davinci
mach-digicolor
mach-dove
mach-ebsa110
mach-efm32
mach-ep93xx
mach-exynos
mach-footbridge
mach-gemini
mach-highbank
mach-hisi
mach-imx
devices
3ds_debugboard.c
3ds_debugboard.h
Kconfig
Makefile
Makefile.boot
anatop.c
avic.c
board-mx31lilly.h
board-mx31lite.h
board-mx31moboard.h
common.h
cpu-imx25.c
cpu-imx27.c
cpu-imx31.c
cpu-imx35.c
cpu-imx5.c
cpu.c
cpuidle-imx5.c
cpuidle-imx6q.c
cpuidle-imx6sl.c
cpuidle-imx6sx.c
cpuidle.h
crmregs-imx3.h
devices-imx1.h
devices-imx21.h
devices-imx27.h
devices-imx31.h
devices-imx35.h
ehci-imx27.c
ehci-imx31.c
ehci-imx35.c
ehci.h
epit.c
eukrea-baseboards.h
gpc.c
hardware.h
headsmp.S
hotplug.c
iim.h
imx1-dt.c
imx27-dt.c
imx31-dt.c
imx35-dt.c
iomux-imx31.c
iomux-mx1.h
iomux-mx21.h
iomux-mx27.h
iomux-mx2x.h
iomux-mx3.h
iomux-mx35.h
iomux-v1.c
iomux-v1.h
iomux-v3.c
iomux-v3.h
irq-common.c
irq-common.h
mach-apf9328.c
mach-armadillo5x0.c
mach-bug.c
mach-imx25.c
mach-imx27_visstrim_m10.c
mach-imx50.c
mach-imx51.c
mach-imx53.c
mach-imx6q.c
mach-imx6sl.c
mach-imx6sx.c
mach-imx6ul.c
mach-imx7d.c
mach-kzm_arm11_01.c
mach-ls1021a.c
mach-mx21ads.c
mach-mx27_3ds.c
mach-mx27ads.c
mach-mx31_3ds.c
mach-mx31ads.c
mach-mx31lilly.c
mach-mx31lite.c
mach-mx31moboard.c
mach-mx35_3ds.c
mach-pca100.c
mach-pcm037.c
mach-pcm037_eet.c
mach-pcm043.c
mach-qong.c
mach-scb9328.c
mach-vf610.c
mach-vpr200.c
mm-imx1.c
mm-imx21.c
mm-imx27.c
mm-imx3.c
mmdc.c
mx1.h
mx21.h
mx27.h
mx2x.h
mx31.h
mx31lilly-db.c
mx31lite-db.c
mx31moboard-devboard.c
mx31moboard-marxbot.c
mx31moboard-smartbot.c
mx35.h
mx3x.h
mxc.h
pcm037.h
platsmp.c
pm-imx25.c
pm-imx27.c
pm-imx3.c
pm-imx5.c
pm-imx6.c
src.c
ssi-fiq-ksym.c
ssi-fiq.S
suspend-imx53.S
suspend-imx6.S
system.c
tzic.c
ulpi.h
mach-integrator
mach-iop13xx
mach-iop32x
mach-iop33x
mach-ixp4xx
mach-keystone
mach-ks8695
mach-lpc18xx
mach-lpc32xx
mach-mediatek
mach-meson
mach-mmp
mach-moxart
mach-mv78xx0
mach-mvebu
mach-mxs
mach-netx
mach-nomadik
mach-nspire
mach-omap1
mach-omap2
mach-orion5x
mach-picoxcell
mach-prima2
mach-pxa
mach-qcom
mach-realview
mach-rockchip
mach-rpc
mach-s3c24xx
mach-s3c64xx
mach-s5pv210
mach-sa1100
mach-shmobile
mach-socfpga
mach-spear
mach-sti
mach-stm32
mach-sunxi
mach-tango
mach-tegra
mach-u300
mach-uniphier
mach-ux500
mach-versatile
mach-vexpress
mach-vt8500
mach-w90x900
mach-zx
mach-zynq
mm
net
nwfpe
oprofile
plat-iop
plat-omap
plat-orion
plat-pxa
plat-samsung
plat-versatile
probes
tools
vdso
vfp
xen
Kconfig
Kconfig-nommu
Kconfig.debug
Makefile
arm64
avr32
blackfin
c6x
cris
frv
h8300
hexagon
ia64
m32r
m68k
metag
microblaze
mips
mn10300
nios2
openrisc
parisc
powerpc
s390
score
sh
sparc
tile
um
unicore32
x86
xtensa
.gitignore
Kconfig
block
certs
crypto
drivers
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.get_maintainer.ignore
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
arch
/
arm
/
mach-imx
/
epit.c
Copy path
Blame
Blame
Latest commit
History
History
228 lines (181 loc) · 5.37 KB
Breadcrumbs
linux
/
arch
/
arm
/
mach-imx
/
epit.c
Top
File metadata and controls
Code
Blame
228 lines (181 loc) · 5.37 KB
Raw
/* * linux/arch/arm/plat-mxc/epit.c * * Copyright (C) 2010 Sascha Hauer <s.hauer@pengutronix.de> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ #define EPITCR 0x00 #define EPITSR 0x04 #define EPITLR 0x08 #define EPITCMPR 0x0c #define EPITCNR 0x10 #define EPITCR_EN (1 << 0) #define EPITCR_ENMOD (1 << 1) #define EPITCR_OCIEN (1 << 2) #define EPITCR_RLD (1 << 3) #define EPITCR_PRESC(x) (((x) & 0xfff) << 4) #define EPITCR_SWR (1 << 16) #define EPITCR_IOVW (1 << 17) #define EPITCR_DBGEN (1 << 18) #define EPITCR_WAITEN (1 << 19) #define EPITCR_RES (1 << 20) #define EPITCR_STOPEN (1 << 21) #define EPITCR_OM_DISCON (0 << 22) #define EPITCR_OM_TOGGLE (1 << 22) #define EPITCR_OM_CLEAR (2 << 22) #define EPITCR_OM_SET (3 << 22) #define EPITCR_CLKSRC_OFF (0 << 24) #define EPITCR_CLKSRC_PERIPHERAL (1 << 24) #define EPITCR_CLKSRC_REF_HIGH (1 << 24) #define EPITCR_CLKSRC_REF_LOW (3 << 24) #define EPITSR_OCIF (1 << 0) #include <linux/interrupt.h> #include <linux/irq.h> #include <linux/clockchips.h> #include <linux/clk.h> #include <linux/err.h> #include <asm/mach/time.h> #include "common.h" #include "hardware.h" static struct clock_event_device clockevent_epit; static void __iomem *timer_base; static inline void epit_irq_disable(void) { u32 val; val = imx_readl(timer_base + EPITCR); val &= ~EPITCR_OCIEN; imx_writel(val, timer_base + EPITCR); } static inline void epit_irq_enable(void) { u32 val; val = imx_readl(timer_base + EPITCR); val |= EPITCR_OCIEN; imx_writel(val, timer_base + EPITCR); } static void epit_irq_acknowledge(void) { imx_writel(EPITSR_OCIF, timer_base + EPITSR); } static int __init epit_clocksource_init(struct clk *timer_clk) { unsigned int c = clk_get_rate(timer_clk); return clocksource_mmio_init(timer_base + EPITCNR, "epit", c, 200, 32, clocksource_mmio_readl_down); } /* clock event */ static int epit_set_next_event(unsigned long evt, struct clock_event_device *unused) { unsigned long tcmp; tcmp = imx_readl(timer_base + EPITCNR); imx_writel(tcmp - evt, timer_base + EPITCMPR); return 0; } /* Left event sources disabled, no more interrupts appear */ static int epit_shutdown(struct clock_event_device *evt) { unsigned long flags; /* * The timer interrupt generation is disabled at least * for enough time to call epit_set_next_event() */ local_irq_save(flags); /* Disable interrupt in GPT module */ epit_irq_disable(); /* Clear pending interrupt */ epit_irq_acknowledge(); local_irq_restore(flags); return 0; } static int epit_set_oneshot(struct clock_event_device *evt) { unsigned long flags; /* * The timer interrupt generation is disabled at least * for enough time to call epit_set_next_event() */ local_irq_save(flags); /* Disable interrupt in GPT module */ epit_irq_disable(); /* Clear pending interrupt, only while switching mode */ if (!clockevent_state_oneshot(evt)) epit_irq_acknowledge(); /* * Do not put overhead of interrupt enable/disable into * epit_set_next_event(), the core has about 4 minutes * to call epit_set_next_event() or shutdown clock after * mode switching */ epit_irq_enable(); local_irq_restore(flags); return 0; } /* * IRQ handler for the timer */ static irqreturn_t epit_timer_interrupt(int irq, void *dev_id) { struct clock_event_device *evt = &clockevent_epit; epit_irq_acknowledge(); evt->event_handler(evt); return IRQ_HANDLED; } static struct irqaction epit_timer_irq = { .name = "i.MX EPIT Timer Tick", .flags = IRQF_TIMER | IRQF_IRQPOLL, .handler = epit_timer_interrupt, }; static struct clock_event_device clockevent_epit = { .name = "epit", .features = CLOCK_EVT_FEAT_ONESHOT, .set_state_shutdown = epit_shutdown, .tick_resume = epit_shutdown, .set_state_oneshot = epit_set_oneshot, .set_next_event = epit_set_next_event, .rating = 200, }; static int __init epit_clockevent_init(struct clk *timer_clk) { clockevent_epit.cpumask = cpumask_of(0); clockevents_config_and_register(&clockevent_epit, clk_get_rate(timer_clk), 0x800, 0xfffffffe); return 0; } void __init epit_timer_init(void __iomem *base, int irq) { struct clk *timer_clk; timer_clk = clk_get_sys("imx-epit.0", NULL); if (IS_ERR(timer_clk)) { pr_err("i.MX epit: unable to get clk\n"); return; } clk_prepare_enable(timer_clk); timer_base = base; /* * Initialise to a known state (all timers off, and timing reset) */ imx_writel(0x0, timer_base + EPITCR); imx_writel(0xffffffff, timer_base + EPITLR); imx_writel(EPITCR_EN | EPITCR_CLKSRC_REF_HIGH | EPITCR_WAITEN, timer_base + EPITCR); /* init and register the timer to the framework */ epit_clocksource_init(timer_clk); epit_clockevent_init(timer_clk); /* Make irqs happen */ setup_irq(irq, &epit_timer_irq); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
You can’t perform that action at this time.