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
469869d
Documentation
arch
block
certs
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
Kconfig
Makefile
acpi_pm.c
arc_timer.c
arm_arch_timer.c
arm_global_timer.c
armv7m_systick.c
asm9260_timer.c
bcm2835_timer.c
bcm_kona_timer.c
cadence_ttc_timer.c
clksrc-dbx500-prcmu.c
clksrc_st_lpc.c
clps711x-timer.c
cs5535-clockevt.c
dummy_timer.c
dw_apb_timer.c
dw_apb_timer_of.c
em_sti.c
exynos_mct.c
fsl_ftm_timer.c
h8300_timer16.c
h8300_timer8.c
h8300_tpu.c
i8253.c
jcore-pit.c
meson6_timer.c
metag_generic.c
mips-gic-timer.c
mmio.c
mps2-timer.c
mtk_timer.c
mxs_timer.c
nomadik-mtu.c
numachip.c
owl-timer.c
pxa_timer.c
qcom-timer.c
renesas-ostm.c
rockchip_timer.c
samsung_pwm_timer.c
scx200_hrt.c
sh_cmt.c
sh_mtu2.c
sh_tmu.c
sun4i_timer.c
tango_xtal.c
tcb_clksrc.c
tegra20_timer.c
time-armada-370-xp.c
time-efm32.c
time-lpc32xx.c
time-orion.c
time-pistachio.c
timer-atlas7.c
timer-atmel-pit.c
timer-atmel-st.c
timer-digicolor.c
timer-fttmr010.c
timer-imx-gpt.c
timer-imx-tpm.c
timer-integrator-ap.c
timer-keystone.c
timer-nps.c
timer-of.c
timer-of.h
timer-oxnas-rps.c
timer-prima2.c
timer-probe.c
timer-sp.h
timer-sp804.c
timer-stm32.c
timer-sun5i.c
timer-ti-32k.c
timer-u300.c
versatile.c
vf_pit_timer.c
vt8500_timer.c
zevio-timer.c
connector
cpufreq
cpuidle
crypto
dax
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fmc
fpga
fsi
gpio
gpu
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
ide
idle
iio
infiniband
input
iommu
ipack
irqchip
isdn
leds
lguest
lightnvm
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
mux
net
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
oprofile
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh
sn
soc
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb
uwb
vfio
vhost
video
virt
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
drivers
/
clocksource
/
timer-of.c
Copy path
Blame
Blame
Latest commit
Rob Herring
and
Daniel Lezcano
clocksource: Convert to using %pOF instead of full_name
Aug 31, 2017
469869d
·
Aug 31, 2017
History
History
178 lines (149 loc) · 4.18 KB
Breadcrumbs
linux
/
drivers
/
clocksource
/
timer-of.c
Top
File metadata and controls
Code
Blame
178 lines (149 loc) · 4.18 KB
Raw
/* * Copyright (c) 2017, Linaro Ltd. All rights reserved. * * Author: Daniel Lezcano <daniel.lezcano@linaro.org> * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>. */ #include <linux/clk.h> #include <linux/interrupt.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/slab.h> #include "timer-of.h" static __init void timer_irq_exit(struct of_timer_irq *of_irq) { struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); struct clock_event_device *clkevt = &to->clkevt; of_irq->percpu ? free_percpu_irq(of_irq->irq, clkevt) : free_irq(of_irq->irq, clkevt); } static __init int timer_irq_init(struct device_node *np, struct of_timer_irq *of_irq) { int ret; struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); struct clock_event_device *clkevt = &to->clkevt; if (of_irq->name) { of_irq->irq = ret = of_irq_get_byname(np, of_irq->name); if (ret < 0) { pr_err("Failed to get interrupt %s for %s\n", of_irq->name, np->full_name); return ret; } } else { of_irq->irq = irq_of_parse_and_map(np, of_irq->index); } if (!of_irq->irq) { pr_err("Failed to map interrupt for %pOF\n", np); return -EINVAL; } ret = of_irq->percpu ? request_percpu_irq(of_irq->irq, of_irq->handler, np->full_name, clkevt) : request_irq(of_irq->irq, of_irq->handler, of_irq->flags ? of_irq->flags : IRQF_TIMER, np->full_name, clkevt); if (ret) { pr_err("Failed to request irq %d for %pOF\n", of_irq->irq, np); return ret; } clkevt->irq = of_irq->irq; return 0; } static __init void timer_clk_exit(struct of_timer_clk *of_clk) { of_clk->rate = 0; clk_disable_unprepare(of_clk->clk); clk_put(of_clk->clk); } static __init int timer_clk_init(struct device_node *np, struct of_timer_clk *of_clk) { int ret; of_clk->clk = of_clk->name ? of_clk_get_by_name(np, of_clk->name) : of_clk_get(np, of_clk->index); if (IS_ERR(of_clk->clk)) { pr_err("Failed to get clock for %pOF\n", np); return PTR_ERR(of_clk->clk); } ret = clk_prepare_enable(of_clk->clk); if (ret) { pr_err("Failed for enable clock for %pOF\n", np); goto out_clk_put; } of_clk->rate = clk_get_rate(of_clk->clk); if (!of_clk->rate) { ret = -EINVAL; pr_err("Failed to get clock rate for %pOF\n", np); goto out_clk_disable; } of_clk->period = DIV_ROUND_UP(of_clk->rate, HZ); out: return ret; out_clk_disable: clk_disable_unprepare(of_clk->clk); out_clk_put: clk_put(of_clk->clk); goto out; } static __init void timer_base_exit(struct of_timer_base *of_base) { iounmap(of_base->base); } static __init int timer_base_init(struct device_node *np, struct of_timer_base *of_base) { const char *name = of_base->name ? of_base->name : np->full_name; of_base->base = of_io_request_and_map(np, of_base->index, name); if (!of_base->base) { pr_err("Failed to iomap (%s)\n", name); return -ENXIO; } return 0; } int __init timer_of_init(struct device_node *np, struct timer_of *to) { int ret = -EINVAL; int flags = 0; if (to->flags & TIMER_OF_BASE) { ret = timer_base_init(np, &to->of_base); if (ret) goto out_fail; flags |= TIMER_OF_BASE; } if (to->flags & TIMER_OF_CLOCK) { ret = timer_clk_init(np, &to->of_clk); if (ret) goto out_fail; flags |= TIMER_OF_CLOCK; } if (to->flags & TIMER_OF_IRQ) { ret = timer_irq_init(np, &to->of_irq); if (ret) goto out_fail; flags |= TIMER_OF_IRQ; } if (!to->clkevt.name) to->clkevt.name = np->name; return ret; out_fail: if (flags & TIMER_OF_IRQ) timer_irq_exit(&to->of_irq); if (flags & TIMER_OF_CLOCK) timer_clk_exit(&to->of_clk); if (flags & TIMER_OF_BASE) timer_base_exit(&to->of_base); return ret; }
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
You can’t perform that action at this time.