2 * Clock tree for CSR SiRFprimaII
4 * Copyright (c) 2011 - 2014 Cambridge Silicon Radio Limited, a CSR plc group
7 * Licensed under GPLv2 or later.
10 #include <linux/module.h>
11 #include <linux/bitops.h>
13 #include <linux/clk.h>
14 #include <linux/clkdev.h>
15 #include <linux/clk-provider.h>
16 #include <linux/of_address.h>
17 #include <linux/syscore_ops.h>
20 #include "clk-common.c"
22 static struct clk_dmn clk_mmc01
= {
23 .regofs
= SIRFSOC_CLKC_MMC_CFG
,
26 .init
= &clk_mmc01_init
,
30 static struct clk_dmn clk_mmc23
= {
31 .regofs
= SIRFSOC_CLKC_MMC_CFG
,
34 .init
= &clk_mmc23_init
,
38 static struct clk_dmn clk_mmc45
= {
39 .regofs
= SIRFSOC_CLKC_MMC_CFG
,
42 .init
= &clk_mmc45_init
,
46 static struct clk_init_data clk_nand_init
= {
49 .parent_names
= std_clk_io_parents
,
50 .num_parents
= ARRAY_SIZE(std_clk_io_parents
),
53 static struct clk_std clk_nand
= {
56 .init
= &clk_nand_init
,
60 enum prima2_clk_index
{
61 /* 0 1 2 3 4 5 6 7 8 9 */
62 rtc
, osc
, pll1
, pll2
, pll3
, mem
, sys
, security
, dsp
, gps
,
63 mf
, io
, cpu
, uart0
, uart1
, uart2
, tsc
, i2c0
, i2c1
, spi0
,
64 spi1
, pwmc
, efuse
, pulse
, dmac0
, dmac1
, nand
, audio
, usp0
, usp1
,
65 usp2
, vip
, gfx
, mm
, lcd
, vpp
, mmc01
, mmc23
, mmc45
, usbpll
,
66 usb0
, usb1
, cphif
, maxclk
,
69 static __initdata
struct clk_hw
*prima2_clk_hw_array
[maxclk
] = {
115 static struct clk
*prima2_clks
[maxclk
];
117 static void __init
prima2_clk_init(struct device_node
*np
)
119 struct device_node
*rscnp
;
122 rscnp
= of_find_compatible_node(NULL
, NULL
, "sirf,prima2-rsc");
123 sirfsoc_rsc_vbase
= of_iomap(rscnp
, 0);
124 if (!sirfsoc_rsc_vbase
)
125 panic("unable to map rsc registers\n");
128 sirfsoc_clk_vbase
= of_iomap(np
, 0);
129 if (!sirfsoc_clk_vbase
)
130 panic("unable to map clkc registers\n");
132 /* These are always available (RTC and 26MHz OSC)*/
133 prima2_clks
[rtc
] = clk_register_fixed_rate(NULL
, "rtc", NULL
,
135 prima2_clks
[osc
] = clk_register_fixed_rate(NULL
, "osc", NULL
,
136 CLK_IS_ROOT
, 26000000);
138 for (i
= pll1
; i
< maxclk
; i
++) {
139 prima2_clks
[i
] = clk_register(NULL
, prima2_clk_hw_array
[i
]);
140 BUG_ON(!prima2_clks
[i
]);
142 clk_register_clkdev(prima2_clks
[cpu
], NULL
, "cpu");
143 clk_register_clkdev(prima2_clks
[io
], NULL
, "io");
144 clk_register_clkdev(prima2_clks
[mem
], NULL
, "mem");
145 clk_register_clkdev(prima2_clks
[mem
], NULL
, "osc");
147 clk_data
.clks
= prima2_clks
;
148 clk_data
.clk_num
= maxclk
;
150 of_clk_add_provider(np
, of_clk_src_onecell_get
, &clk_data
);
152 CLK_OF_DECLARE(prima2_clk
, "sirf,prima2-clkc", prima2_clk_init
);