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
f941978
Documentation
LICENSES
arch
block
certs
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
actions
at91
axis
axs10x
bcm
berlin
davinci
h8300
hisilicon
imgtec
imx
ingenic
keystone
loongson1
mediatek
meson
microchip
mmp
mvebu
mxs
nxp
pistachio
pxa
qcom
Kconfig
Makefile
a53-pll.c
apcs-msm8916.c
clk-alpha-pll.c
clk-alpha-pll.h
clk-branch.c
clk-branch.h
clk-pll.c
clk-pll.h
clk-rcg.c
clk-rcg.h
clk-rcg2.c
clk-regmap-divider.c
clk-regmap-divider.h
clk-regmap-mux-div.c
clk-regmap-mux-div.h
clk-regmap-mux.c
clk-regmap-mux.h
clk-regmap.c
clk-regmap.h
clk-rpm.c
clk-smd-rpm.c
clk-spmi-pmic-div.c
common.c
common.h
gcc-apq8084.c
gcc-ipq4019.c
gcc-ipq806x.c
gcc-ipq8074.c
gcc-mdm9615.c
gcc-msm8660.c
gcc-msm8916.c
gcc-msm8960.c
gcc-msm8974.c
gcc-msm8994.c
gcc-msm8996.c
gcc-msm8998.c
gcc-sdm845.c
gdsc.c
gdsc.h
lcc-ipq806x.c
lcc-mdm9615.c
lcc-msm8960.c
mmcc-apq8084.c
mmcc-msm8960.c
mmcc-msm8974.c
mmcc-msm8996.c
reset.c
reset.h
videocc-sdm845.c
renesas
rockchip
samsung
sirf
socfpga
spear
sprd
st
sunxi-ng
sunxi
tegra
ti
uniphier
ux500
versatile
x86
zte
zynq
Kconfig
Makefile
clk-asm9260.c
clk-aspeed.c
clk-axi-clkgen.c
clk-axm5516.c
clk-bulk.c
clk-cdce706.c
clk-cdce925.c
clk-clps711x.c
clk-composite.c
clk-conf.c
clk-cs2000-cp.c
clk-devres.c
clk-divider.c
clk-efm32gg.c
clk-fixed-factor.c
clk-fixed-rate.c
clk-fractional-divider.c
clk-gate.c
clk-gemini.c
clk-gpio.c
clk-hi655x.c
clk-highbank.c
clk-hsdk-pll.c
clk-max77686.c
clk-moxart.c
clk-multiplier.c
clk-mux.c
clk-nomadik.c
clk-npcm7xx.c
clk-nspire.c
clk-oxnas.c
clk-palmas.c
clk-pwm.c
clk-qoriq.c
clk-rk808.c
clk-s2mps11.c
clk-scmi.c
clk-scpi.c
clk-si514.c
clk-si5351.c
clk-si5351.h
clk-si544.c
clk-si570.c
clk-stm32f4.c
clk-stm32h7.c
clk-stm32mp1.c
clk-tango4.c
clk-twl6040.c
clk-u300.c
clk-versaclock5.c
clk-vt8500.c
clk-wm831x.c
clk-xgene.c
clk.c
clk.h
clkdev.c
clocksource
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
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
sn
soc
soundwire
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb
uwb
vfio
vhost
video
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
firmware
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
/
clk
/
qcom
/
common.c
Blame
Blame
Latest commit
History
History
283 lines (231 loc) · 6.48 KB
Breadcrumbs
linux
/
drivers
/
clk
/
qcom
/
common.c
Top
File metadata and controls
Code
Blame
283 lines (231 loc) · 6.48 KB
Raw
// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. */ #include <linux/export.h> #include <linux/module.h> #include <linux/regmap.h> #include <linux/platform_device.h> #include <linux/clk-provider.h> #include <linux/reset-controller.h> #include <linux/of.h> #include "common.h" #include "clk-rcg.h" #include "clk-regmap.h" #include "reset.h" #include "gdsc.h" struct qcom_cc { struct qcom_reset_controller reset; struct clk_regmap **rclks; size_t num_rclks; }; const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate) { if (!f) return NULL; for (; f->freq; f++) if (rate <= f->freq) return f; /* Default to our fastest rate */ return f - 1; } EXPORT_SYMBOL_GPL(qcom_find_freq); const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f, unsigned long rate) { const struct freq_tbl *best = NULL; for ( ; f->freq; f++) { if (rate >= f->freq) best = f; else break; } return best; } EXPORT_SYMBOL_GPL(qcom_find_freq_floor); int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, u8 src) { int i, num_parents = clk_hw_get_num_parents(hw); for (i = 0; i < num_parents; i++) if (src == map[i].src) return i; return -ENOENT; } EXPORT_SYMBOL_GPL(qcom_find_src_index); struct regmap * qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc) { void __iomem *base; struct resource *res; struct device *dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) return ERR_CAST(base); return devm_regmap_init_mmio(dev, base, desc->config); } EXPORT_SYMBOL_GPL(qcom_cc_map); void qcom_pll_set_fsm_mode(struct regmap *map, u32 reg, u8 bias_count, u8 lock_count) { u32 val; u32 mask; /* De-assert reset to FSM */ regmap_update_bits(map, reg, PLL_VOTE_FSM_RESET, 0); /* Program bias count and lock count */ val = bias_count << PLL_BIAS_COUNT_SHIFT | lock_count << PLL_LOCK_COUNT_SHIFT; mask = PLL_BIAS_COUNT_MASK << PLL_BIAS_COUNT_SHIFT; mask |= PLL_LOCK_COUNT_MASK << PLL_LOCK_COUNT_SHIFT; regmap_update_bits(map, reg, mask, val); /* Enable PLL FSM voting */ regmap_update_bits(map, reg, PLL_VOTE_FSM_ENA, PLL_VOTE_FSM_ENA); } EXPORT_SYMBOL_GPL(qcom_pll_set_fsm_mode); static void qcom_cc_gdsc_unregister(void *data) { gdsc_unregister(data); } /* * Backwards compatibility with old DTs. Register a pass-through factor 1/1 * clock to translate 'path' clk into 'name' clk and register the 'path' * clk as a fixed rate clock if it isn't present. */ static int _qcom_cc_register_board_clk(struct device *dev, const char *path, const char *name, unsigned long rate, bool add_factor) { struct device_node *node = NULL; struct device_node *clocks_node; struct clk_fixed_factor *factor; struct clk_fixed_rate *fixed; struct clk_init_data init_data = { }; int ret; clocks_node = of_find_node_by_path("/clocks"); if (clocks_node) { node = of_get_child_by_name(clocks_node, path); of_node_put(clocks_node); } if (!node) { fixed = devm_kzalloc(dev, sizeof(*fixed), GFP_KERNEL); if (!fixed) return -EINVAL; fixed->fixed_rate = rate; fixed->hw.init = &init_data; init_data.name = path; init_data.ops = &clk_fixed_rate_ops; ret = devm_clk_hw_register(dev, &fixed->hw); if (ret) return ret; } of_node_put(node); if (add_factor) { factor = devm_kzalloc(dev, sizeof(*factor), GFP_KERNEL); if (!factor) return -EINVAL; factor->mult = factor->div = 1; factor->hw.init = &init_data; init_data.name = name; init_data.parent_names = &path; init_data.num_parents = 1; init_data.flags = 0; init_data.ops = &clk_fixed_factor_ops; ret = devm_clk_hw_register(dev, &factor->hw); if (ret) return ret; } return 0; } int qcom_cc_register_board_clk(struct device *dev, const char *path, const char *name, unsigned long rate) { bool add_factor = true; /* * TODO: The RPM clock driver currently does not support the xo clock. * When xo is added to the RPM clock driver, we should change this * function to skip registration of xo factor clocks. */ return _qcom_cc_register_board_clk(dev, path, name, rate, add_factor); } EXPORT_SYMBOL_GPL(qcom_cc_register_board_clk); int qcom_cc_register_sleep_clk(struct device *dev) { return _qcom_cc_register_board_clk(dev, "sleep_clk", "sleep_clk_src", 32768, true); } EXPORT_SYMBOL_GPL(qcom_cc_register_sleep_clk); static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec, void *data) { struct qcom_cc *cc = data; unsigned int idx = clkspec->args[0]; if (idx >= cc->num_rclks) { pr_err("%s: invalid index %u\n", __func__, idx); return ERR_PTR(-EINVAL); } return cc->rclks[idx] ? &cc->rclks[idx]->hw : ERR_PTR(-ENOENT); } int qcom_cc_really_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc, struct regmap *regmap) { int i, ret; struct device *dev = &pdev->dev; struct qcom_reset_controller *reset; struct qcom_cc *cc; struct gdsc_desc *scd; size_t num_clks = desc->num_clks; struct clk_regmap **rclks = desc->clks; cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL); if (!cc) return -ENOMEM; reset = &cc->reset; reset->rcdev.of_node = dev->of_node; reset->rcdev.ops = &qcom_reset_ops; reset->rcdev.owner = dev->driver->owner; reset->rcdev.nr_resets = desc->num_resets; reset->regmap = regmap; reset->reset_map = desc->resets; ret = devm_reset_controller_register(dev, &reset->rcdev); if (ret) return ret; if (desc->gdscs && desc->num_gdscs) { scd = devm_kzalloc(dev, sizeof(*scd), GFP_KERNEL); if (!scd) return -ENOMEM; scd->dev = dev; scd->scs = desc->gdscs; scd->num = desc->num_gdscs; ret = gdsc_register(scd, &reset->rcdev, regmap); if (ret) return ret; ret = devm_add_action_or_reset(dev, qcom_cc_gdsc_unregister, scd); if (ret) return ret; } cc->rclks = rclks; cc->num_rclks = num_clks; for (i = 0; i < num_clks; i++) { if (!rclks[i]) continue; ret = devm_clk_register_regmap(dev, rclks[i]); if (ret) return ret; } ret = devm_of_clk_add_hw_provider(dev, qcom_cc_clk_hw_get, cc); if (ret) return ret; return 0; } EXPORT_SYMBOL_GPL(qcom_cc_really_probe); int qcom_cc_probe(struct platform_device *pdev, const struct qcom_cc_desc *desc) { struct regmap *regmap; regmap = qcom_cc_map(pdev, desc); if (IS_ERR(regmap)) return PTR_ERR(regmap); return qcom_cc_really_probe(pdev, desc, regmap); } EXPORT_SYMBOL_GPL(qcom_cc_probe); MODULE_LICENSE("GPL v2");
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
You can’t perform that action at this time.