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
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/clk.h>
17 #include <linux/clkdev.h>
18 #include <linux/clk-provider.h>
19 #include <linux/mfd/dbx500-prcmu.h>
22 /* Clock definitions for ab8500 */
23 static int ab8500_reg_clks(struct device
*dev
)
28 const char *intclk_parents
[] = {"ab8500_sysclk", "ulpclk"};
29 u16 intclk_reg_sel
[] = {0 , AB8500_SYSULPCLKCTRL1
};
30 u8 intclk_reg_mask
[] = {0 , AB8500_SYSULPCLKCTRL1_SYSULPCLKINTSEL_MASK
};
31 u8 intclk_reg_bits
[] = {
33 (1 << AB8500_SYSULPCLKCTRL1_SYSULPCLKINTSEL_SHIFT
)
36 dev_info(dev
, "register clocks for ab850x\n");
39 ret
= ab8500_sysctrl_set(AB8500_SWATCTRL
, AB8500_SWATCTRL_SWATENABLE
);
44 clk
= clk_reg_prcmu_gate("ab8500_sysclk", NULL
, PRCMU_SYSCLK
,
46 clk_register_clkdev(clk
, "sysclk", "ab8500-usb.0");
47 clk_register_clkdev(clk
, "sysclk", "ab-iddet.0");
48 clk_register_clkdev(clk
, "sysclk", "snd-soc-mop500.0");
49 clk_register_clkdev(clk
, "sysclk", "shrm_bus");
52 clk
= clk_reg_sysctrl_gate(dev
, "ab8500_sysclk2", "ab8500_sysclk",
53 AB8500_SYSULPCLKCTRL1
, AB8500_SYSULPCLKCTRL1_SYSCLKBUF2REQ
,
54 AB8500_SYSULPCLKCTRL1_SYSCLKBUF2REQ
, 0, 0);
55 clk_register_clkdev(clk
, "sysclk", "0-0070");
58 clk
= clk_reg_sysctrl_gate(dev
, "ab8500_sysclk3", "ab8500_sysclk",
59 AB8500_SYSULPCLKCTRL1
, AB8500_SYSULPCLKCTRL1_SYSCLKBUF3REQ
,
60 AB8500_SYSULPCLKCTRL1_SYSCLKBUF3REQ
, 0, 0);
61 clk_register_clkdev(clk
, "sysclk", "cg1960_core.0");
64 clk
= clk_reg_sysctrl_gate(dev
, "ab8500_sysclk4", "ab8500_sysclk",
65 AB8500_SYSULPCLKCTRL1
, AB8500_SYSULPCLKCTRL1_SYSCLKBUF4REQ
,
66 AB8500_SYSULPCLKCTRL1_SYSCLKBUF4REQ
, 0, 0);
69 clk
= clk_reg_sysctrl_gate_fixed_rate(dev
, "ulpclk", NULL
,
70 AB8500_SYSULPCLKCTRL1
, AB8500_SYSULPCLKCTRL1_ULPCLKREQ
,
71 AB8500_SYSULPCLKCTRL1_ULPCLKREQ
,
72 38400000, 9000, CLK_IS_ROOT
);
73 clk_register_clkdev(clk
, "ulpclk", "snd-soc-mop500.0");
76 clk
= clk_reg_sysctrl_set_parent(dev
, "intclk", intclk_parents
, 2,
77 intclk_reg_sel
, intclk_reg_mask
, intclk_reg_bits
, 0);
78 clk_register_clkdev(clk
, "intclk", "snd-soc-mop500.0");
79 clk_register_clkdev(clk
, NULL
, "ab8500-pwm.1");
82 clk
= clk_reg_sysctrl_gate(dev
, "audioclk", "intclk",
83 AB8500_SYSULPCLKCTRL1
, AB8500_SYSULPCLKCTRL1_AUDIOCLKENA
,
84 AB8500_SYSULPCLKCTRL1_AUDIOCLKENA
, 0, 0);
85 clk_register_clkdev(clk
, "audioclk", "ab8500-codec.0");
90 /* Clock definitions for ab8540 */
91 static int ab8540_reg_clks(struct device
*dev
)
96 /* Clock definitions for ab9540 */
97 static int ab9540_reg_clks(struct device
*dev
)
102 static int abx500_clk_probe(struct platform_device
*pdev
)
104 struct ab8500
*parent
= dev_get_drvdata(pdev
->dev
.parent
);
107 if (is_ab8500(parent
) || is_ab8505(parent
)) {
108 ret
= ab8500_reg_clks(&pdev
->dev
);
109 } else if (is_ab8540(parent
)) {
110 ret
= ab8540_reg_clks(&pdev
->dev
);
111 } else if (is_ab9540(parent
)) {
112 ret
= ab9540_reg_clks(&pdev
->dev
);
114 dev_err(&pdev
->dev
, "non supported plf id\n");
121 static struct platform_driver abx500_clk_driver
= {
123 .name
= "abx500-clk",
125 .probe
= abx500_clk_probe
,
128 static int __init
abx500_clk_init(void)
130 return platform_driver_register(&abx500_clk_driver
);
133 arch_initcall(abx500_clk_init
);
135 MODULE_AUTHOR("Ulf Hansson <ulf.hansson@linaro.org");
136 MODULE_DESCRIPTION("ABX500 clk driver");
137 MODULE_LICENSE("GPL v2");