1 // SPDX-License-Identifier: GPL-2.0
3 * PLL clock driver for TI Davinci SoCs
7 * Based on arch/arm/mach-davinci/clock.c
8 * Copyright (C) 2006-2007 Texas Instruments.
9 * Copyright (C) 2008-2009 Deep Root Systems, LLC
12 #include <linux/clk-provider.h>
13 #include <linux/clk.h>
14 #include <linux/clk/davinci.h>
15 #include <linux/delay.h>
16 #include <linux/err.h>
18 #include <linux/kernel.h>
19 #include <linux/mfd/syscon.h>
20 #include <linux/notifier.h>
22 #include <linux/platform_device.h>
23 #include <linux/property.h>
24 #include <linux/regmap.h>
25 #include <linux/slab.h>
26 #include <linux/types.h>
30 #define MAX_NAME_SIZE 20
31 #define OSCIN_CLK_NAME "oscin"
36 #define PLLSECCTL 0x108
59 #define PLLCTL_PLLEN BIT(0)
60 #define PLLCTL_PLLPWRDN BIT(1)
61 #define PLLCTL_PLLRST BIT(3)
62 #define PLLCTL_PLLDIS BIT(4)
63 #define PLLCTL_PLLENSRC BIT(5)
64 #define PLLCTL_CLKMODE BIT(8)
66 /* shared by most *DIV registers */
67 #define DIV_RATIO_SHIFT 0
68 #define DIV_RATIO_WIDTH 5
69 #define DIV_ENABLE_SHIFT 15
71 #define PLLCMD_GOSET BIT(0)
72 #define PLLSTAT_GOSTAT BIT(0)
74 #define CKEN_OBSCLK_SHIFT 1
75 #define CKEN_AUXEN_SHIFT 0
78 * OMAP-L138 system reference guide recommends a wait for 4 OSCIN/CLKIN
79 * cycles to ensure that the PLLC has switched to bypass mode. Delay of 1us
80 * ensures we are good for all > 4MHz OSCIN/CLKIN inputs. Typically the input
81 * is ~25MHz. Units are micro seconds.
83 #define PLL_BYPASS_TIME 1
85 /* From OMAP-L138 datasheet table 6-4. Units are micro seconds */
86 #define PLL_RESET_TIME 1
89 * From OMAP-L138 datasheet table 6-4; assuming prediv = 1, sqrt(pllm) = 4
90 * Units are micro seconds.
92 #define PLL_LOCK_TIME 20
95 * struct davinci_pll_clk - Main PLL clock (aka PLLOUT)
96 * @hw: clk_hw for the pll
97 * @base: Base memory address
98 * @pllm_min: The minimum allowable PLLM[PLLM] value
99 * @pllm_max: The maximum allowable PLLM[PLLM] value
100 * @pllm_mask: Bitmask for PLLM[PLLM] value
102 struct davinci_pll_clk {
110 #define to_davinci_pll_clk(_hw) \
111 container_of((_hw), struct davinci_pll_clk, hw)
113 static unsigned long davinci_pll_recalc_rate(struct clk_hw *hw,
114 unsigned long parent_rate)
116 struct davinci_pll_clk *pll = to_davinci_pll_clk(hw);
117 unsigned long rate = parent_rate;
120 mult = readl(pll->base + PLLM) & pll->pllm_mask;
126 static int davinci_pll_determine_rate(struct clk_hw *hw,
127 struct clk_rate_request *req)
129 struct davinci_pll_clk *pll = to_davinci_pll_clk(hw);
130 struct clk_hw *parent = req->best_parent_hw;
131 unsigned long parent_rate = req->best_parent_rate;
132 unsigned long rate = req->rate;
133 unsigned long best_rate, r;
136 /* there is a limited range of valid outputs (see datasheet) */
137 if (rate < req->min_rate)
140 rate = min(rate, req->max_rate);
141 mult = rate / parent_rate;
142 best_rate = parent_rate * mult;
144 /* easy case when there is no PREDIV */
145 if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
146 if (best_rate < req->min_rate)
149 if (mult < pll->pllm_min || mult > pll->pllm_max)
152 req->rate = best_rate;
157 /* see if the PREDIV clock can help us */
160 for (mult = pll->pllm_min; mult <= pll->pllm_max; mult++) {
161 parent_rate = clk_hw_round_rate(parent, rate / mult);
162 r = parent_rate * mult;
163 if (r < req->min_rate)
165 if (r > rate || r > req->max_rate)
169 req->rate = best_rate;
170 req->best_parent_rate = parent_rate;
171 if (best_rate == rate)
179 static int davinci_pll_set_rate(struct clk_hw *hw, unsigned long rate,
180 unsigned long parent_rate)
182 struct davinci_pll_clk *pll = to_davinci_pll_clk(hw);
185 mult = rate / parent_rate;
186 writel(mult - 1, pll->base + PLLM);
191 #ifdef CONFIG_DEBUG_FS
192 static void davinci_pll_debug_init(struct clk_hw *hw, struct dentry *dentry);
194 #define davinci_pll_debug_init NULL
197 static const struct clk_ops davinci_pll_ops = {
198 .recalc_rate = davinci_pll_recalc_rate,
199 .determine_rate = davinci_pll_determine_rate,
200 .set_rate = davinci_pll_set_rate,
201 .debug_init = davinci_pll_debug_init,
204 /* PLLM works differently on DM365 */
205 static unsigned long dm365_pll_recalc_rate(struct clk_hw *hw,
206 unsigned long parent_rate)
208 struct davinci_pll_clk *pll = to_davinci_pll_clk(hw);
209 unsigned long rate = parent_rate;
212 mult = readl(pll->base + PLLM) & pll->pllm_mask;
218 static const struct clk_ops dm365_pll_ops = {
219 .recalc_rate = dm365_pll_recalc_rate,
220 .debug_init = davinci_pll_debug_init,
224 * davinci_pll_div_register - common *DIV clock implementation
225 * @dev: The PLL platform device or NULL
226 * @name: the clock name
227 * @parent_name: the parent clock name
228 * @reg: the *DIV register
229 * @fixed: if true, the divider is a fixed value
230 * @flags: bitmap of CLK_* flags from clock-provider.h
232 static struct clk *davinci_pll_div_register(struct device *dev,
234 const char *parent_name,
236 bool fixed, u32 flags)
238 const char * const *parent_names = parent_name ? &parent_name : NULL;
239 int num_parents = parent_name ? 1 : 0;
240 const struct clk_ops *divider_ops = &clk_divider_ops;
241 struct clk_gate *gate;
242 struct clk_divider *divider;
246 gate = kzalloc(sizeof(*gate), GFP_KERNEL);
248 return ERR_PTR(-ENOMEM);
251 gate->bit_idx = DIV_ENABLE_SHIFT;
253 divider = kzalloc(sizeof(*divider), GFP_KERNEL);
260 divider->shift = DIV_RATIO_SHIFT;
261 divider->width = DIV_RATIO_WIDTH;
264 divider->flags |= CLK_DIVIDER_READ_ONLY;
265 divider_ops = &clk_divider_ro_ops;
268 clk = clk_register_composite(dev, name, parent_names, num_parents,
269 NULL, NULL, ÷r->hw, divider_ops,
270 &gate->hw, &clk_gate_ops, flags);
273 goto err_free_divider;
286 struct davinci_pllen_clk {
291 #define to_davinci_pllen_clk(_hw) \
292 container_of((_hw), struct davinci_pllen_clk, hw)
294 static const struct clk_ops davinci_pllen_ops = {
295 /* this clocks just uses the clock notification feature */
299 * The PLL has to be switched into bypass mode while we are chaning the rate,
300 * so we do that on the PLLEN clock since it is the end of the line. This will
301 * switch to bypass before any of the parent clocks (PREDIV, PLL, POSTDIV) are
302 * changed and will switch back to the PLL after the changes have been made.
304 static int davinci_pllen_rate_change(struct notifier_block *nb,
305 unsigned long flags, void *data)
307 struct clk_notifier_data *cnd = data;
308 struct clk_hw *hw = __clk_get_hw(cnd->clk);
309 struct davinci_pllen_clk *pll = to_davinci_pllen_clk(hw);
312 ctrl = readl(pll->base + PLLCTL);
314 if (flags == PRE_RATE_CHANGE) {
315 /* Switch the PLL to bypass mode */
316 ctrl &= ~(PLLCTL_PLLENSRC | PLLCTL_PLLEN);
317 writel(ctrl, pll->base + PLLCTL);
319 udelay(PLL_BYPASS_TIME);
321 /* Reset and enable PLL */
322 ctrl &= ~(PLLCTL_PLLRST | PLLCTL_PLLDIS);
323 writel(ctrl, pll->base + PLLCTL);
325 udelay(PLL_RESET_TIME);
327 /* Bring PLL out of reset */
328 ctrl |= PLLCTL_PLLRST;
329 writel(ctrl, pll->base + PLLCTL);
331 udelay(PLL_LOCK_TIME);
333 /* Remove PLL from bypass mode */
334 ctrl |= PLLCTL_PLLEN;
335 writel(ctrl, pll->base + PLLCTL);
341 static struct notifier_block davinci_pllen_notifier = {
342 .notifier_call = davinci_pllen_rate_change,
346 * davinci_pll_clk_register - Register a PLL clock
347 * @dev: The PLL platform device or NULL
348 * @info: The device-specific clock info
349 * @parent_name: The parent clock name
350 * @base: The PLL's memory region
351 * @cfgchip: CFGCHIP syscon regmap for info->unlock_reg or NULL
353 * This creates a series of clocks that represent the PLL.
355 * OSCIN > [PREDIV >] PLL > [POSTDIV >] PLLEN
357 * - OSCIN is the parent clock (on secondary PLL, may come from primary PLL)
358 * - PREDIV and POSTDIV are optional (depends on the PLL controller)
359 * - PLL is the PLL output (aka PLLOUT)
360 * - PLLEN is the bypass multiplexer
362 * Returns: The PLLOUT clock or a negative error code.
364 struct clk *davinci_pll_clk_register(struct device *dev,
365 const struct davinci_pll_clk_info *info,
366 const char *parent_name,
368 struct regmap *cfgchip)
370 char prediv_name[MAX_NAME_SIZE];
371 char pllout_name[MAX_NAME_SIZE];
372 char postdiv_name[MAX_NAME_SIZE];
373 char pllen_name[MAX_NAME_SIZE];
374 struct clk_init_data init;
375 struct davinci_pll_clk *pllout;
376 struct davinci_pllen_clk *pllen;
377 struct clk *oscin_clk = NULL;
378 struct clk *prediv_clk = NULL;
379 struct clk *pllout_clk;
380 struct clk *postdiv_clk = NULL;
381 struct clk *pllen_clk;
384 if (info->flags & PLL_HAS_CLKMODE) {
386 * If a PLL has PLLCTL[CLKMODE], then it is the primary PLL.
387 * We register a clock named "oscin" that serves as the internal
388 * "input clock" domain shared by both PLLs (if there are 2)
389 * and will be the parent clock to the AUXCLK, SYSCLKBP and
390 * OBSCLK domains. NB: The various TRMs use "OSCIN" to mean
391 * a number of different things. In this driver we use it to
392 * mean the signal after the PLLCTL[CLKMODE] switch.
394 oscin_clk = clk_register_fixed_factor(dev, OSCIN_CLK_NAME,
395 parent_name, 0, 1, 1);
396 if (IS_ERR(oscin_clk))
399 parent_name = OSCIN_CLK_NAME;
402 if (info->flags & PLL_HAS_PREDIV) {
403 bool fixed = info->flags & PLL_PREDIV_FIXED_DIV;
406 snprintf(prediv_name, MAX_NAME_SIZE, "%s_prediv", info->name);
408 if (info->flags & PLL_PREDIV_ALWAYS_ENABLED)
409 flags |= CLK_IS_CRITICAL;
411 /* Some? DM355 chips don't correctly report the PREDIV value */
412 if (info->flags & PLL_PREDIV_FIXED8)
413 prediv_clk = clk_register_fixed_factor(dev, prediv_name,
414 parent_name, flags, 1, 8);
416 prediv_clk = davinci_pll_div_register(dev, prediv_name,
417 parent_name, base + PREDIV, fixed, flags);
418 if (IS_ERR(prediv_clk)) {
419 ret = PTR_ERR(prediv_clk);
420 goto err_unregister_oscin;
423 parent_name = prediv_name;
426 /* Unlock writing to PLL registers */
427 if (info->unlock_reg) {
428 if (IS_ERR_OR_NULL(cfgchip))
429 dev_warn(dev, "Failed to get CFGCHIP (%ld)\n",
432 regmap_write_bits(cfgchip, info->unlock_reg,
433 info->unlock_mask, 0);
436 pllout = kzalloc(sizeof(*pllout), GFP_KERNEL);
439 goto err_unregister_prediv;
442 snprintf(pllout_name, MAX_NAME_SIZE, "%s_pllout", info->name);
444 init.name = pllout_name;
445 if (info->flags & PLL_PLLM_2X)
446 init.ops = &dm365_pll_ops;
448 init.ops = &davinci_pll_ops;
449 init.parent_names = &parent_name;
450 init.num_parents = 1;
453 if (info->flags & PLL_HAS_PREDIV)
454 init.flags |= CLK_SET_RATE_PARENT;
456 pllout->hw.init = &init;
458 pllout->pllm_mask = info->pllm_mask;
459 pllout->pllm_min = info->pllm_min;
460 pllout->pllm_max = info->pllm_max;
462 pllout_clk = clk_register(dev, &pllout->hw);
463 if (IS_ERR(pllout_clk)) {
464 ret = PTR_ERR(pllout_clk);
465 goto err_free_pllout;
468 clk_hw_set_rate_range(&pllout->hw, info->pllout_min_rate,
469 info->pllout_max_rate);
471 parent_name = pllout_name;
473 if (info->flags & PLL_HAS_POSTDIV) {
474 bool fixed = info->flags & PLL_POSTDIV_FIXED_DIV;
475 u32 flags = CLK_SET_RATE_PARENT;
477 snprintf(postdiv_name, MAX_NAME_SIZE, "%s_postdiv", info->name);
479 if (info->flags & PLL_POSTDIV_ALWAYS_ENABLED)
480 flags |= CLK_IS_CRITICAL;
482 postdiv_clk = davinci_pll_div_register(dev, postdiv_name,
483 parent_name, base + POSTDIV, fixed, flags);
484 if (IS_ERR(postdiv_clk)) {
485 ret = PTR_ERR(postdiv_clk);
486 goto err_unregister_pllout;
489 parent_name = postdiv_name;
492 pllen = kzalloc(sizeof(*pllen), GFP_KERNEL);
495 goto err_unregister_postdiv;
498 snprintf(pllen_name, MAX_NAME_SIZE, "%s_pllen", info->name);
500 init.name = pllen_name;
501 init.ops = &davinci_pllen_ops;
502 init.parent_names = &parent_name;
503 init.num_parents = 1;
504 init.flags = CLK_SET_RATE_PARENT;
506 pllen->hw.init = &init;
509 pllen_clk = clk_register(dev, &pllen->hw);
510 if (IS_ERR(pllen_clk)) {
511 ret = PTR_ERR(pllen_clk);
515 clk_notifier_register(pllen_clk, &davinci_pllen_notifier);
521 err_unregister_postdiv:
522 clk_unregister(postdiv_clk);
523 err_unregister_pllout:
524 clk_unregister(pllout_clk);
527 err_unregister_prediv:
528 clk_unregister(prediv_clk);
529 err_unregister_oscin:
530 clk_unregister(oscin_clk);
536 * davinci_pll_auxclk_register - Register bypass clock (AUXCLK)
537 * @dev: The PLL platform device or NULL
538 * @name: The clock name
539 * @base: The PLL memory region
541 struct clk *davinci_pll_auxclk_register(struct device *dev,
545 return clk_register_gate(dev, name, OSCIN_CLK_NAME, 0, base + CKEN,
546 CKEN_AUXEN_SHIFT, 0, NULL);
550 * davinci_pll_sysclkbp_clk_register - Register bypass divider clock (SYSCLKBP)
551 * @dev: The PLL platform device or NULL
552 * @name: The clock name
553 * @base: The PLL memory region
555 struct clk *davinci_pll_sysclkbp_clk_register(struct device *dev,
559 return clk_register_divider(dev, name, OSCIN_CLK_NAME, 0, base + BPDIV,
560 DIV_RATIO_SHIFT, DIV_RATIO_WIDTH,
561 CLK_DIVIDER_READ_ONLY, NULL);
565 * davinci_pll_obsclk_register - Register oscillator divider clock (OBSCLK)
566 * @dev: The PLL platform device or NULL
567 * @info: The clock info
568 * @base: The PLL memory region
571 davinci_pll_obsclk_register(struct device *dev,
572 const struct davinci_pll_obsclk_info *info,
576 struct clk_gate *gate;
577 struct clk_divider *divider;
582 mux = kzalloc(sizeof(*mux), GFP_KERNEL);
584 return ERR_PTR(-ENOMEM);
586 mux->reg = base + OCSEL;
587 mux->table = info->table;
588 mux->mask = info->ocsrc_mask;
590 gate = kzalloc(sizeof(*gate), GFP_KERNEL);
596 gate->reg = base + CKEN;
597 gate->bit_idx = CKEN_OBSCLK_SHIFT;
599 divider = kzalloc(sizeof(*divider), GFP_KERNEL);
605 divider->reg = base + OSCDIV;
606 divider->shift = DIV_RATIO_SHIFT;
607 divider->width = DIV_RATIO_WIDTH;
609 /* make sure divider is enabled just in case bootloader disabled it */
610 oscdiv = readl(base + OSCDIV);
611 oscdiv |= BIT(DIV_ENABLE_SHIFT);
612 writel(oscdiv, base + OSCDIV);
614 clk = clk_register_composite(dev, info->name, info->parent_names,
616 &mux->hw, &clk_mux_ops,
617 ÷r->hw, &clk_divider_ops,
618 &gate->hw, &clk_gate_ops, 0);
622 goto err_free_divider;
637 /* The PLL SYSCLKn clocks have a mechanism for synchronizing rate changes. */
638 static int davinci_pll_sysclk_rate_change(struct notifier_block *nb,
639 unsigned long flags, void *data)
641 struct clk_notifier_data *cnd = data;
642 struct clk_hw *hw = __clk_get_hw(clk_get_parent(cnd->clk));
643 struct davinci_pllen_clk *pll = to_davinci_pllen_clk(hw);
647 case POST_RATE_CHANGE:
648 /* apply the changes */
649 pllcmd = readl(pll->base + PLLCMD);
650 pllcmd |= PLLCMD_GOSET;
651 writel(pllcmd, pll->base + PLLCMD);
653 case PRE_RATE_CHANGE:
654 /* Wait until for outstanding changes to take effect */
656 pllstat = readl(pll->base + PLLSTAT);
657 } while (pllstat & PLLSTAT_GOSTAT);
664 static struct notifier_block davinci_pll_sysclk_notifier = {
665 .notifier_call = davinci_pll_sysclk_rate_change,
669 * davinci_pll_sysclk_register - Register divider clocks (SYSCLKn)
670 * @dev: The PLL platform device or NULL
671 * @info: The clock info
672 * @base: The PLL memory region
675 davinci_pll_sysclk_register(struct device *dev,
676 const struct davinci_pll_sysclk_info *info,
679 const struct clk_ops *divider_ops = &clk_divider_ops;
680 struct clk_gate *gate;
681 struct clk_divider *divider;
687 /* PLLDIVn registers are not entirely consecutive */
689 reg = PLLDIV1 + 4 * (info->id - 1);
691 reg = PLLDIV4 + 4 * (info->id - 4);
693 gate = kzalloc(sizeof(*gate), GFP_KERNEL);
695 return ERR_PTR(-ENOMEM);
697 gate->reg = base + reg;
698 gate->bit_idx = DIV_ENABLE_SHIFT;
700 divider = kzalloc(sizeof(*divider), GFP_KERNEL);
706 divider->reg = base + reg;
707 divider->shift = DIV_RATIO_SHIFT;
708 divider->width = info->ratio_width;
711 if (info->flags & SYSCLK_FIXED_DIV) {
712 divider->flags |= CLK_DIVIDER_READ_ONLY;
713 divider_ops = &clk_divider_ro_ops;
716 /* Only the ARM clock can change the parent PLL rate */
717 if (info->flags & SYSCLK_ARM_RATE)
718 flags |= CLK_SET_RATE_PARENT;
720 if (info->flags & SYSCLK_ALWAYS_ENABLED)
721 flags |= CLK_IS_CRITICAL;
723 clk = clk_register_composite(dev, info->name, &info->parent_name, 1,
724 NULL, NULL, ÷r->hw, divider_ops,
725 &gate->hw, &clk_gate_ops, flags);
728 goto err_free_divider;
731 clk_notifier_register(clk, &davinci_pll_sysclk_notifier);
743 int of_davinci_pll_init(struct device *dev, struct device_node *node,
744 const struct davinci_pll_clk_info *info,
745 const struct davinci_pll_obsclk_info *obsclk_info,
746 const struct davinci_pll_sysclk_info **div_info,
749 struct regmap *cfgchip)
751 struct device_node *child;
752 const char *parent_name;
755 if (info->flags & PLL_HAS_CLKMODE)
756 parent_name = of_clk_get_parent_name(node, 0);
758 parent_name = OSCIN_CLK_NAME;
760 clk = davinci_pll_clk_register(dev, info, parent_name, base, cfgchip);
762 dev_err(dev, "failed to register %s\n", info->name);
766 child = of_get_child_by_name(node, "pllout");
767 if (of_device_is_available(child))
768 of_clk_add_provider(child, of_clk_src_simple_get, clk);
771 child = of_get_child_by_name(node, "sysclk");
772 if (of_device_is_available(child)) {
773 struct clk_onecell_data *clk_data;
775 int n_clks = max_sysclk_id + 1;
778 clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL);
784 clks = kmalloc_array(n_clks, sizeof(*clks), GFP_KERNEL);
791 clk_data->clks = clks;
792 clk_data->clk_num = n_clks;
794 for (i = 0; i < n_clks; i++)
795 clks[i] = ERR_PTR(-ENOENT);
797 for (; *div_info; div_info++) {
798 clk = davinci_pll_sysclk_register(dev, *div_info, base);
800 dev_warn(dev, "failed to register %s (%ld)\n",
801 (*div_info)->name, PTR_ERR(clk));
803 clks[(*div_info)->id] = clk;
805 of_clk_add_provider(child, of_clk_src_onecell_get, clk_data);
809 child = of_get_child_by_name(node, "auxclk");
810 if (of_device_is_available(child)) {
811 char child_name[MAX_NAME_SIZE];
813 snprintf(child_name, MAX_NAME_SIZE, "%s_auxclk", info->name);
815 clk = davinci_pll_auxclk_register(dev, child_name, base);
817 dev_warn(dev, "failed to register %s (%ld)\n",
818 child_name, PTR_ERR(clk));
820 of_clk_add_provider(child, of_clk_src_simple_get, clk);
824 child = of_get_child_by_name(node, "obsclk");
825 if (of_device_is_available(child)) {
827 clk = davinci_pll_obsclk_register(dev, obsclk_info, base);
829 clk = ERR_PTR(-EINVAL);
832 dev_warn(dev, "failed to register obsclk (%ld)\n",
835 of_clk_add_provider(child, of_clk_src_simple_get, clk);
842 /* needed in early boot for clocksource/clockevent */
843 #ifdef CONFIG_ARCH_DAVINCI_DA850
844 CLK_OF_DECLARE(da850_pll0, "ti,da850-pll0", of_da850_pll0_init);
847 static const struct of_device_id davinci_pll_of_match[] = {
848 #ifdef CONFIG_ARCH_DAVINCI_DA850
849 { .compatible = "ti,da850-pll1", .data = of_da850_pll1_init },
854 static const struct platform_device_id davinci_pll_id_table[] = {
855 #ifdef CONFIG_ARCH_DAVINCI_DA830
856 { .name = "da830-pll", .driver_data = (kernel_ulong_t)da830_pll_init },
858 #ifdef CONFIG_ARCH_DAVINCI_DA850
859 { .name = "da850-pll0", .driver_data = (kernel_ulong_t)da850_pll0_init },
860 { .name = "da850-pll1", .driver_data = (kernel_ulong_t)da850_pll1_init },
865 typedef int (*davinci_pll_init)(struct device *dev, void __iomem *base,
866 struct regmap *cfgchip);
868 static int davinci_pll_probe(struct platform_device *pdev)
870 struct device *dev = &pdev->dev;
871 davinci_pll_init pll_init = NULL;
872 struct regmap *cfgchip;
875 pll_init = device_get_match_data(dev);
876 if (!pll_init && pdev->id_entry)
877 pll_init = (void *)pdev->id_entry->driver_data;
880 dev_err(dev, "unable to find driver data\n");
884 cfgchip = syscon_regmap_lookup_by_compatible("ti,da830-cfgchip");
886 base = devm_platform_ioremap_resource(pdev, 0);
888 return PTR_ERR(base);
890 return pll_init(dev, base, cfgchip);
893 static struct platform_driver davinci_pll_driver = {
894 .probe = davinci_pll_probe,
896 .name = "davinci-pll-clk",
897 .of_match_table = davinci_pll_of_match,
899 .id_table = davinci_pll_id_table,
902 static int __init davinci_pll_driver_init(void)
904 return platform_driver_register(&davinci_pll_driver);
907 /* has to be postcore_initcall because PSC devices depend on PLL parent clocks */
908 postcore_initcall(davinci_pll_driver_init);
910 #ifdef CONFIG_DEBUG_FS
911 #include <linux/debugfs.h>
913 #define DEBUG_REG(n) \
919 static const struct debugfs_reg32 davinci_pll_regs[] = {
923 DEBUG_REG(PLLSECCTL),
947 static void davinci_pll_debug_init(struct clk_hw *hw, struct dentry *dentry)
949 struct davinci_pll_clk *pll = to_davinci_pll_clk(hw);
950 struct debugfs_regset32 *regset;
952 regset = kzalloc(sizeof(*regset), GFP_KERNEL);
956 regset->regs = davinci_pll_regs;
957 regset->nregs = ARRAY_SIZE(davinci_pll_regs);
958 regset->base = pll->base;
960 debugfs_create_regset32("registers", 0400, dentry, regset);