of: MSI: Simplify irqdomain lookup
[linux/fpc-iii.git] / drivers / clk / ux500 / abx500-clk.c
blob222425d08ab6ac3faf05b6385d51c2df1b33713f
1 /*
2 * abx500 clock implementation for ux500 platform.
4 * Copyright (C) 2012 ST-Ericsson SA
5 * Author: Ulf Hansson <ulf.hansson@linaro.org>
7 * License terms: GNU General Public License (GPL) version 2
8 */
10 #include <linux/err.h>
11 #include <linux/module.h>
12 #include <linux/device.h>
13 #include <linux/platform_device.h>
14 #include <linux/mfd/abx500/ab8500.h>
15 #include <linux/mfd/abx500/ab8500-sysctrl.h>
16 #include <linux/clkdev.h>
17 #include <linux/clk-provider.h>
18 #include <linux/mfd/dbx500-prcmu.h>
19 #include "clk.h"
21 /* Clock definitions for ab8500 */
22 static int ab8500_reg_clks(struct device *dev)
24 int ret;
25 struct clk *clk;
27 const char *intclk_parents[] = {"ab8500_sysclk", "ulpclk"};
28 u16 intclk_reg_sel[] = {0 , AB8500_SYSULPCLKCTRL1};
29 u8 intclk_reg_mask[] = {0 , AB8500_SYSULPCLKCTRL1_SYSULPCLKINTSEL_MASK};
30 u8 intclk_reg_bits[] = {
31 0 ,
32 (1 << AB8500_SYSULPCLKCTRL1_SYSULPCLKINTSEL_SHIFT)
35 dev_info(dev, "register clocks for ab850x\n");
37 /* Enable SWAT */
38 ret = ab8500_sysctrl_set(AB8500_SWATCTRL, AB8500_SWATCTRL_SWATENABLE);
39 if (ret)
40 return ret;
42 /* ab8500_sysclk */
43 clk = clk_reg_prcmu_gate("ab8500_sysclk", NULL, PRCMU_SYSCLK,
44 CLK_IS_ROOT);
45 clk_register_clkdev(clk, "sysclk", "ab8500-usb.0");
46 clk_register_clkdev(clk, "sysclk", "ab-iddet.0");
47 clk_register_clkdev(clk, "sysclk", "snd-soc-mop500.0");
48 clk_register_clkdev(clk, "sysclk", "shrm_bus");
50 /* ab8500_sysclk2 */
51 clk = clk_reg_sysctrl_gate(dev , "ab8500_sysclk2", "ab8500_sysclk",
52 AB8500_SYSULPCLKCTRL1, AB8500_SYSULPCLKCTRL1_SYSCLKBUF2REQ,
53 AB8500_SYSULPCLKCTRL1_SYSCLKBUF2REQ, 0, 0);
54 clk_register_clkdev(clk, "sysclk", "0-0070");
56 /* ab8500_sysclk3 */
57 clk = clk_reg_sysctrl_gate(dev , "ab8500_sysclk3", "ab8500_sysclk",
58 AB8500_SYSULPCLKCTRL1, AB8500_SYSULPCLKCTRL1_SYSCLKBUF3REQ,
59 AB8500_SYSULPCLKCTRL1_SYSCLKBUF3REQ, 0, 0);
60 clk_register_clkdev(clk, "sysclk", "cg1960_core.0");
62 /* ab8500_sysclk4 */
63 clk = clk_reg_sysctrl_gate(dev , "ab8500_sysclk4", "ab8500_sysclk",
64 AB8500_SYSULPCLKCTRL1, AB8500_SYSULPCLKCTRL1_SYSCLKBUF4REQ,
65 AB8500_SYSULPCLKCTRL1_SYSCLKBUF4REQ, 0, 0);
67 /* ab_ulpclk */
68 clk = clk_reg_sysctrl_gate_fixed_rate(dev, "ulpclk", NULL,
69 AB8500_SYSULPCLKCTRL1, AB8500_SYSULPCLKCTRL1_ULPCLKREQ,
70 AB8500_SYSULPCLKCTRL1_ULPCLKREQ,
71 38400000, 9000, CLK_IS_ROOT);
72 clk_register_clkdev(clk, "ulpclk", "snd-soc-mop500.0");
74 /* ab8500_intclk */
75 clk = clk_reg_sysctrl_set_parent(dev , "intclk", intclk_parents, 2,
76 intclk_reg_sel, intclk_reg_mask, intclk_reg_bits, 0);
77 clk_register_clkdev(clk, "intclk", "snd-soc-mop500.0");
78 clk_register_clkdev(clk, NULL, "ab8500-pwm.1");
80 /* ab8500_audioclk */
81 clk = clk_reg_sysctrl_gate(dev , "audioclk", "intclk",
82 AB8500_SYSULPCLKCTRL1, AB8500_SYSULPCLKCTRL1_AUDIOCLKENA,
83 AB8500_SYSULPCLKCTRL1_AUDIOCLKENA, 0, 0);
84 clk_register_clkdev(clk, "audioclk", "ab8500-codec.0");
86 return 0;
89 /* Clock definitions for ab8540 */
90 static int ab8540_reg_clks(struct device *dev)
92 return 0;
95 /* Clock definitions for ab9540 */
96 static int ab9540_reg_clks(struct device *dev)
98 return 0;
101 static int abx500_clk_probe(struct platform_device *pdev)
103 struct ab8500 *parent = dev_get_drvdata(pdev->dev.parent);
104 int ret;
106 if (is_ab8500(parent) || is_ab8505(parent)) {
107 ret = ab8500_reg_clks(&pdev->dev);
108 } else if (is_ab8540(parent)) {
109 ret = ab8540_reg_clks(&pdev->dev);
110 } else if (is_ab9540(parent)) {
111 ret = ab9540_reg_clks(&pdev->dev);
112 } else {
113 dev_err(&pdev->dev, "non supported plf id\n");
114 return -ENODEV;
117 return ret;
120 static struct platform_driver abx500_clk_driver = {
121 .driver = {
122 .name = "abx500-clk",
124 .probe = abx500_clk_probe,
127 static int __init abx500_clk_init(void)
129 return platform_driver_register(&abx500_clk_driver);
132 arch_initcall(abx500_clk_init);
134 MODULE_AUTHOR("Ulf Hansson <ulf.hansson@linaro.org");
135 MODULE_DESCRIPTION("ABX500 clk driver");
136 MODULE_LICENSE("GPL v2");