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
46b3051
Documentation
LICENSES
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
clksrc-dbx500-prcmu.c
clksrc_st_lpc.c
clps711x-timer.c
dummy_timer.c
dw_apb_timer.c
dw_apb_timer_of.c
em_sti.c
exynos_mct.c
h8300_timer16.c
h8300_timer8.c
h8300_tpu.c
hyperv_timer.c
i8253.c
ingenic-ost.c
ingenic-timer.c
jcore-pit.c
mips-gic-timer.c
mmio.c
mps2-timer.c
mxs_timer.c
nomadik-mtu.c
numachip.c
renesas-ostm.c
samsung_pwm_timer.c
scx200_hrt.c
sh_cmt.c
sh_mtu2.c
sh_tmu.c
timer-armada-370-xp.c
timer-atcpit100.c
timer-atlas7.c
timer-atmel-pit.c
timer-atmel-st.c
timer-atmel-tcb.c
timer-cadence-ttc.c
timer-cs5535.c
timer-davinci.c
timer-digicolor.c
timer-efm32.c
timer-fsl-ftm.c
timer-fttmr010.c
timer-gx6605s.c
timer-imx-gpt.c
timer-imx-sysctr.c
timer-imx-tpm.c
timer-integrator-ap.c
timer-ixp4xx.c
timer-keystone.c
timer-lpc32xx.c
timer-mediatek.c
timer-meson6.c
timer-microchip-pit64b.c
timer-milbeaut.c
timer-mp-csky.c
timer-npcm7xx.c
timer-nps.c
timer-of.c
timer-of.h
timer-orion.c
timer-owl.c
timer-oxnas-rps.c
timer-pistachio.c
timer-prima2.c
timer-probe.c
timer-pxa.c
timer-qcom.c
timer-rda.c
timer-riscv.c
timer-rockchip.c
timer-sp.h
timer-sp804.c
timer-sprd.c
timer-stm32.c
timer-sun4i.c
timer-sun5i.c
timer-tango-xtal.c
timer-tegra.c
timer-ti-32k.c
timer-ti-dm.c
timer-u300.c
timer-versatile.c
timer-vf-pit.c
timer-vt8500.c
timer-zevio.c
connector
counter
cpufreq
cpuidle
crypto
dax
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fpga
fsi
gnss
gpio
gpu
greybus
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
i3c
ide
idle
iio
infiniband
input
interconnect
iommu
ipack
irqchip
isdn
leds
lightnvm
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
mux
net
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
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
siox
slimbus
soc
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb
vfio
vhost
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
drivers
/
clocksource
/
timer-ti-32k.c
Blame
Blame
Latest commit
History
History
165 lines (139 loc) · 4.18 KB
Breadcrumbs
linux
/
drivers
/
clocksource
/
timer-ti-32k.c
Top
File metadata and controls
Code
Blame
165 lines (139 loc) · 4.18 KB
Raw
// SPDX-License-Identifier: GPL-2.0-only /** * timer-ti-32k.c - OMAP2 32k Timer Support * * Copyright (C) 2009 Nokia Corporation * * Update to use new clocksource/clockevent layers * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com> * Copyright (C) 2007 MontaVista Software, Inc. * * Original driver: * Copyright (C) 2005 Nokia Corporation * Author: Paul Mundt <paul.mundt@nokia.com> * Juha Yrjölä <juha.yrjola@nokia.com> * OMAP Dual-mode timer framework support by Timo Teras * * Some parts based off of TI's 24xx code: * * Copyright (C) 2004-2009 Texas Instruments, Inc. * * Roughly modelled after the OMAP1 MPU timer code. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com> * * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com */ #include <linux/clk.h> #include <linux/init.h> #include <linux/time.h> #include <linux/sched_clock.h> #include <linux/clocksource.h> #include <linux/of.h> #include <linux/of_address.h> /* * 32KHz clocksource ... always available, on pretty most chips except * OMAP 730 and 1510. Other timers could be used as clocksources, with * higher resolution in free-running counter modes (e.g. 12 MHz xtal), * but systems won't necessarily want to spend resources that way. */ #define OMAP2_32KSYNCNT_REV_OFF 0x0 #define OMAP2_32KSYNCNT_REV_SCHEME (0x3 << 30) #define OMAP2_32KSYNCNT_CR_OFF_LOW 0x10 #define OMAP2_32KSYNCNT_CR_OFF_HIGH 0x30 struct ti_32k { void __iomem *base; void __iomem *counter; struct clocksource cs; }; static inline struct ti_32k *to_ti_32k(struct clocksource *cs) { return container_of(cs, struct ti_32k, cs); } static u64 notrace ti_32k_read_cycles(struct clocksource *cs) { struct ti_32k *ti = to_ti_32k(cs); return (u64)readl_relaxed(ti->counter); } static struct ti_32k ti_32k_timer = { .cs = { .name = "32k_counter", .rating = 250, .read = ti_32k_read_cycles, .mask = CLOCKSOURCE_MASK(32), .flags = CLOCK_SOURCE_IS_CONTINUOUS, }, }; static u64 notrace omap_32k_read_sched_clock(void) { return ti_32k_read_cycles(&ti_32k_timer.cs); } static void __init ti_32k_timer_enable_clock(struct device_node *np, const char *name) { struct clk *clock; int error; clock = of_clk_get_by_name(np->parent, name); if (IS_ERR(clock)) { /* Only some SoCs have a separate interface clock */ if (PTR_ERR(clock) == -EINVAL && !strncmp("ick", name, 3)) return; pr_warn("%s: could not get clock %s %li\n", __func__, name, PTR_ERR(clock)); return; } error = clk_prepare_enable(clock); if (error) { pr_warn("%s: could not enable %s: %i\n", __func__, name, error); return; } } static void __init ti_32k_timer_module_init(struct device_node *np, void __iomem *base) { void __iomem *sysc = base + 4; if (!of_device_is_compatible(np->parent, "ti,sysc")) return; ti_32k_timer_enable_clock(np, "fck"); ti_32k_timer_enable_clock(np, "ick"); /* * Force idle module as wkup domain is active with MPU. * No need to tag the module disabled for ti-sysc probe. */ writel_relaxed(0, sysc); } static int __init ti_32k_timer_init(struct device_node *np) { int ret; ti_32k_timer.base = of_iomap(np, 0); if (!ti_32k_timer.base) { pr_err("Can't ioremap 32k timer base\n"); return -ENXIO; } if (!of_machine_is_compatible("ti,am43")) ti_32k_timer.cs.flags |= CLOCK_SOURCE_SUSPEND_NONSTOP; ti_32k_timer.counter = ti_32k_timer.base; ti_32k_timer_module_init(np, ti_32k_timer.base); /* * 32k sync Counter IP register offsets vary between the highlander * version and the legacy ones. * * The 'SCHEME' bits(30-31) of the revision register is used to identify * the version. */ if (readl_relaxed(ti_32k_timer.base + OMAP2_32KSYNCNT_REV_OFF) & OMAP2_32KSYNCNT_REV_SCHEME) ti_32k_timer.counter += OMAP2_32KSYNCNT_CR_OFF_HIGH; else ti_32k_timer.counter += OMAP2_32KSYNCNT_CR_OFF_LOW; pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n"); ret = clocksource_register_hz(&ti_32k_timer.cs, 32768); if (ret) { pr_err("32k_counter: can't register clocksource\n"); return ret; } sched_clock_register(omap_32k_read_sched_clock, 32, 32768); return 0; } TIMER_OF_DECLARE(ti_32k_timer, "ti,omap-counter32k", ti_32k_timer_init);
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
102
103
104
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
You can’t perform that action at this time.