1 From 49134da893bc11e833e3d87139c57e3b84e65219 Mon Sep 17 00:00:00 2001
2 From: Stephen Boyd <sboyd@codeaurora.org>
3 Date: Thu, 19 Jun 2014 18:46:31 -0700
4 Subject: [PATCH 167/182] clk: qcom: Add HFPLL driver
6 On some devices (MSM8974 for example), the HFPLLs are
7 instantiated within the Krait processor subsystem as separate
8 register regions. Add a driver for these PLLs so that we can
9 provide HFPLL clocks for use by the system.
11 Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
13 drivers/clk/qcom/Kconfig | 8 ++++
14 drivers/clk/qcom/Makefile | 1 +
15 drivers/clk/qcom/hfpll.c | 110 +++++++++++++++++++++++++++++++++++++++++++++
16 3 files changed, 119 insertions(+)
17 create mode 100644 drivers/clk/qcom/hfpll.c
19 --- a/drivers/clk/qcom/Kconfig
20 +++ b/drivers/clk/qcom/Kconfig
21 @@ -53,3 +53,11 @@ config MSM_MMCC_8974
22 Support for the multimedia clock controller on msm8974 devices.
23 Say Y if you want to support multimedia devices such as display,
24 graphics, video encode/decode, camera, etc.
27 + tristate "High-Frequency PLL (HFPLL) Clock Controller"
28 + depends on COMMON_CLK_QCOM
30 + Support for the high-frequency PLLs present on Qualcomm devices.
31 + Say Y if you want to support CPU frequency scaling on devices
32 + such as MSM8974, APQ8084, etc.
33 --- a/drivers/clk/qcom/Makefile
34 +++ b/drivers/clk/qcom/Makefile
35 @@ -16,3 +16,4 @@ obj-$(CONFIG_MSM_GCC_8960) += gcc-msm896
36 obj-$(CONFIG_MSM_GCC_8974) += gcc-msm8974.o
37 obj-$(CONFIG_MSM_MMCC_8960) += mmcc-msm8960.o
38 obj-$(CONFIG_MSM_MMCC_8974) += mmcc-msm8974.o
39 +obj-$(CONFIG_QCOM_HFPLL) += hfpll.o
41 +++ b/drivers/clk/qcom/hfpll.c
44 + * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
46 + * This program is free software; you can redistribute it and/or modify
47 + * it under the terms of the GNU General Public License version 2 and
48 + * only version 2 as published by the Free Software Foundation.
50 + * This program is distributed in the hope that it will be useful,
51 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
52 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53 + * GNU General Public License for more details.
56 +#include <linux/kernel.h>
57 +#include <linux/init.h>
58 +#include <linux/module.h>
59 +#include <linux/platform_device.h>
60 +#include <linux/of.h>
61 +#include <linux/clk.h>
62 +#include <linux/clk-provider.h>
63 +#include <linux/regmap.h>
65 +#include "clk-regmap.h"
66 +#include "clk-hfpll.h"
68 +static const struct hfpll_data hdata = {
75 + .config_val = 0x430405d,
80 + .user_vco_mask = 0x100000,
81 + .low_vco_max_rate = 1248000000,
82 + .min_rate = 537600000UL,
83 + .max_rate = 2900000000UL,
86 +static const struct of_device_id qcom_hfpll_match_table[] = {
87 + { .compatible = "qcom,hfpll" },
90 +MODULE_DEVICE_TABLE(of, qcom_hfpll_match_table);
92 +static struct regmap_config hfpll_regmap_config = {
96 + .max_register = 0x30,
100 +static int qcom_hfpll_probe(struct platform_device *pdev)
103 + struct resource *res;
104 + struct device *dev = &pdev->dev;
105 + void __iomem *base;
106 + struct regmap *regmap;
107 + struct clk_hfpll *h;
108 + struct clk_init_data init = {
109 + .parent_names = (const char *[]){ "xo" },
111 + .ops = &clk_ops_hfpll,
114 + h = devm_kzalloc(dev, sizeof(*h), GFP_KERNEL);
118 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
119 + base = devm_ioremap_resource(dev, res);
121 + return PTR_ERR(base);
123 + regmap = devm_regmap_init_mmio(&pdev->dev, base, &hfpll_regmap_config);
124 + if (IS_ERR(regmap))
125 + return PTR_ERR(regmap);
127 + if (of_property_read_string_index(dev->of_node, "clock-output-names",
132 + h->clkr.hw.init = &init;
133 + spin_lock_init(&h->lock);
135 + clk = devm_clk_register_regmap(&pdev->dev, &h->clkr);
137 + return PTR_ERR_OR_ZERO(clk);
140 +static struct platform_driver qcom_hfpll_driver = {
141 + .probe = qcom_hfpll_probe,
143 + .name = "qcom-hfpll",
144 + .owner = THIS_MODULE,
145 + .of_match_table = qcom_hfpll_match_table,
148 +module_platform_driver(qcom_hfpll_driver);
150 +MODULE_DESCRIPTION("QCOM HFPLL Clock Driver");
151 +MODULE_LICENSE("GPL v2");
152 +MODULE_ALIAS("platform:qcom-hfpll");