1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
252650505SPaul Walmsley /*
352650505SPaul Walmsley * linux/arch/arm/mach-omap1/clock_data.c
452650505SPaul Walmsley *
551c19541SPaul Walmsley * Copyright (C) 2004 - 2005, 2009-2010 Nokia Corporation
652650505SPaul Walmsley * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
752650505SPaul Walmsley * Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
852650505SPaul Walmsley *
9fb2fc920SPaul Walmsley * To do:
10fb2fc920SPaul Walmsley * - Clocks that are only available on some chips should be marked with the
11fb2fc920SPaul Walmsley * chips that they are present on.
1252650505SPaul Walmsley */
1352650505SPaul Walmsley
1452650505SPaul Walmsley #include <linux/kernel.h>
152c799cefSTony Lindgren #include <linux/io.h>
1652650505SPaul Walmsley #include <linux/clk.h>
17*c73b9099SJanusz Krzysztofik #include <linux/clkdev.h>
18*c73b9099SJanusz Krzysztofik #include <linux/clk-provider.h>
196560ee07SJanusz Krzysztofik #include <linux/cpufreq.h>
206560ee07SJanusz Krzysztofik #include <linux/delay.h>
217e0a9e62SArnd Bergmann #include <linux/soc/ti/omap1-io.h>
2252650505SPaul Walmsley
2352650505SPaul Walmsley #include <asm/mach-types.h> /* for machine_is_* */
2452650505SPaul Walmsley
25e4c060dbSTony Lindgren #include "soc.h"
267e0a9e62SArnd Bergmann #include "hardware.h"
27e8e77e97SArnd Bergmann #include "usb.h" /* for OTG_BASE */
282e3ee9f4STony Lindgren #include "iomap.h"
2952650505SPaul Walmsley #include "clock.h"
30bf027ca1STony Lindgren #include "sram.h"
3152650505SPaul Walmsley
32fb2fc920SPaul Walmsley /* Some ARM_IDLECT1 bit shifts - used in struct arm_idlect1_clk */
33fb2fc920SPaul Walmsley #define IDL_CLKOUT_ARM_SHIFT 12
34fb2fc920SPaul Walmsley #define IDLTIM_ARM_SHIFT 9
35fb2fc920SPaul Walmsley #define IDLAPI_ARM_SHIFT 8
36fb2fc920SPaul Walmsley #define IDLIF_ARM_SHIFT 6
37fb2fc920SPaul Walmsley #define IDLLB_ARM_SHIFT 4 /* undocumented? */
38fb2fc920SPaul Walmsley #define OMAP1510_IDLLCD_ARM_SHIFT 3 /* undocumented? */
39fb2fc920SPaul Walmsley #define IDLPER_ARM_SHIFT 2
40fb2fc920SPaul Walmsley #define IDLXORP_ARM_SHIFT 1
41fb2fc920SPaul Walmsley #define IDLWDT_ARM_SHIFT 0
42fb2fc920SPaul Walmsley
43fb2fc920SPaul Walmsley /* Some MOD_CONF_CTRL_0 bit shifts - used in struct clk.enable_bit */
44fb2fc920SPaul Walmsley #define CONF_MOD_UART3_CLK_MODE_R 31
45fb2fc920SPaul Walmsley #define CONF_MOD_UART2_CLK_MODE_R 30
46fb2fc920SPaul Walmsley #define CONF_MOD_UART1_CLK_MODE_R 29
47fb2fc920SPaul Walmsley #define CONF_MOD_MMC_SD_CLK_REQ_R 23
48fb2fc920SPaul Walmsley #define CONF_MOD_MCBSP3_AUXON 20
49fb2fc920SPaul Walmsley
50fb2fc920SPaul Walmsley /* Some MOD_CONF_CTRL_1 bit shifts - used in struct clk.enable_bit */
51fb2fc920SPaul Walmsley #define CONF_MOD_SOSSI_CLK_EN_R 16
52fb2fc920SPaul Walmsley
53fb2fc920SPaul Walmsley /* Some OTG_SYSCON_2-specific bit fields */
54fb2fc920SPaul Walmsley #define OTG_SYSCON_2_UHOST_EN_SHIFT 8
55fb2fc920SPaul Walmsley
56fb2fc920SPaul Walmsley /* Some SOFT_REQ_REG bit fields - used in struct clk.enable_bit */
57fb2fc920SPaul Walmsley #define SOFT_MMC2_DPLL_REQ_SHIFT 13
58fb2fc920SPaul Walmsley #define SOFT_MMC_DPLL_REQ_SHIFT 12
59fb2fc920SPaul Walmsley #define SOFT_UART3_DPLL_REQ_SHIFT 11
60fb2fc920SPaul Walmsley #define SOFT_UART2_DPLL_REQ_SHIFT 10
61fb2fc920SPaul Walmsley #define SOFT_UART1_DPLL_REQ_SHIFT 9
62fb2fc920SPaul Walmsley #define SOFT_USB_OTG_DPLL_REQ_SHIFT 8
63fb2fc920SPaul Walmsley #define SOFT_CAM_DPLL_REQ_SHIFT 7
64fb2fc920SPaul Walmsley #define SOFT_COM_MCKO_REQ_SHIFT 6
65fb2fc920SPaul Walmsley #define SOFT_PERIPH_REQ_SHIFT 5 /* sys_ck gate for UART2 ? */
66fb2fc920SPaul Walmsley #define USB_REQ_EN_SHIFT 4
67fb2fc920SPaul Walmsley #define SOFT_USB_REQ_SHIFT 3 /* sys_ck gate for USB host? */
68fb2fc920SPaul Walmsley #define SOFT_SDW_REQ_SHIFT 2 /* sys_ck gate for Bluetooth? */
69fb2fc920SPaul Walmsley #define SOFT_COM_REQ_SHIFT 1 /* sys_ck gate for com proc? */
70fb2fc920SPaul Walmsley #define SOFT_DPLL_REQ_SHIFT 0
71fb2fc920SPaul Walmsley
72fb2fc920SPaul Walmsley /*
7352650505SPaul Walmsley * Omap1 clocks
74fb2fc920SPaul Walmsley */
7552650505SPaul Walmsley
76*c73b9099SJanusz Krzysztofik static struct omap1_clk ck_ref = {
77*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("ck_ref", &omap1_clk_rate_ops, 0),
7852650505SPaul Walmsley .rate = 12000000,
7952650505SPaul Walmsley };
8052650505SPaul Walmsley
81*c73b9099SJanusz Krzysztofik static struct omap1_clk ck_dpll1 = {
82*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("ck_dpll1", "ck_ref", &omap1_clk_rate_ops,
83*c73b9099SJanusz Krzysztofik /*
84*c73b9099SJanusz Krzysztofik * force recursive refresh of rates of the clock
85*c73b9099SJanusz Krzysztofik * and its children when clk_get_rate() is called
86*c73b9099SJanusz Krzysztofik */
87*c73b9099SJanusz Krzysztofik CLK_GET_RATE_NOCACHE),
8852650505SPaul Walmsley };
8952650505SPaul Walmsley
9052650505SPaul Walmsley /*
9152650505SPaul Walmsley * FIXME: This clock seems to be necessary but no-one has asked for its
9252650505SPaul Walmsley * activation. [ FIX: SoSSI, SSR ]
9352650505SPaul Walmsley */
9452650505SPaul Walmsley static struct arm_idlect1_clk ck_dpll1out = {
9552650505SPaul Walmsley .clk = {
96*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("ck_dpll1out", "ck_dpll1", &omap1_clk_gate_ops, 0),
9752650505SPaul Walmsley .ops = &clkops_generic,
98e9bdc3d4SJanusz Krzysztofik .flags = CLOCK_IDLE_CONTROL | ENABLE_REG_32BIT,
9952650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
10052650505SPaul Walmsley .enable_bit = EN_CKOUT_ARM,
10152650505SPaul Walmsley },
102fb2fc920SPaul Walmsley .idlect_shift = IDL_CLKOUT_ARM_SHIFT,
10352650505SPaul Walmsley };
10452650505SPaul Walmsley
105*c73b9099SJanusz Krzysztofik static struct omap1_clk sossi_ck = {
106*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("ck_sossi", "ck_dpll1out", &omap1_clk_full_ops, 0),
10752650505SPaul Walmsley .ops = &clkops_generic,
10852650505SPaul Walmsley .flags = CLOCK_NO_IDLE_PARENT | ENABLE_REG_32BIT,
10952650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1),
110fb2fc920SPaul Walmsley .enable_bit = CONF_MOD_SOSSI_CLK_EN_R,
11152650505SPaul Walmsley .recalc = &omap1_sossi_recalc,
112*c73b9099SJanusz Krzysztofik .round_rate = &omap1_round_sossi_rate,
11352650505SPaul Walmsley .set_rate = &omap1_set_sossi_rate,
11452650505SPaul Walmsley };
11552650505SPaul Walmsley
116*c73b9099SJanusz Krzysztofik static struct omap1_clk arm_ck = {
117*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("arm_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
11852650505SPaul Walmsley .rate_offset = CKCTL_ARMDIV_OFFSET,
11952650505SPaul Walmsley .recalc = &omap1_ckctl_recalc,
12052650505SPaul Walmsley .round_rate = omap1_clk_round_rate_ckctl_arm,
12152650505SPaul Walmsley .set_rate = omap1_clk_set_rate_ckctl_arm,
12252650505SPaul Walmsley };
12352650505SPaul Walmsley
12452650505SPaul Walmsley static struct arm_idlect1_clk armper_ck = {
12552650505SPaul Walmsley .clk = {
126*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("armper_ck", "ck_dpll1", &omap1_clk_full_ops,
127*c73b9099SJanusz Krzysztofik CLK_IS_CRITICAL),
12852650505SPaul Walmsley .ops = &clkops_generic,
12952650505SPaul Walmsley .flags = CLOCK_IDLE_CONTROL,
13052650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
13152650505SPaul Walmsley .enable_bit = EN_PERCK,
13252650505SPaul Walmsley .rate_offset = CKCTL_PERDIV_OFFSET,
13352650505SPaul Walmsley .recalc = &omap1_ckctl_recalc,
13452650505SPaul Walmsley .round_rate = omap1_clk_round_rate_ckctl_arm,
13552650505SPaul Walmsley .set_rate = omap1_clk_set_rate_ckctl_arm,
13652650505SPaul Walmsley },
137fb2fc920SPaul Walmsley .idlect_shift = IDLPER_ARM_SHIFT,
13852650505SPaul Walmsley };
13952650505SPaul Walmsley
14052650505SPaul Walmsley /*
14152650505SPaul Walmsley * FIXME: This clock seems to be necessary but no-one has asked for its
14252650505SPaul Walmsley * activation. [ GPIO code for 1510 ]
14352650505SPaul Walmsley */
144*c73b9099SJanusz Krzysztofik static struct omap1_clk arm_gpio_ck = {
145*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("ick", "ck_dpll1", &omap1_clk_gate_ops, CLK_IS_CRITICAL),
14652650505SPaul Walmsley .ops = &clkops_generic,
14752650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
14852650505SPaul Walmsley .enable_bit = EN_GPIOCK,
14952650505SPaul Walmsley };
15052650505SPaul Walmsley
15152650505SPaul Walmsley static struct arm_idlect1_clk armxor_ck = {
15252650505SPaul Walmsley .clk = {
153*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("armxor_ck", "ck_ref", &omap1_clk_gate_ops,
154*c73b9099SJanusz Krzysztofik CLK_IS_CRITICAL),
15552650505SPaul Walmsley .ops = &clkops_generic,
15652650505SPaul Walmsley .flags = CLOCK_IDLE_CONTROL,
15752650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
15852650505SPaul Walmsley .enable_bit = EN_XORPCK,
15952650505SPaul Walmsley },
160fb2fc920SPaul Walmsley .idlect_shift = IDLXORP_ARM_SHIFT,
16152650505SPaul Walmsley };
16252650505SPaul Walmsley
16352650505SPaul Walmsley static struct arm_idlect1_clk armtim_ck = {
16452650505SPaul Walmsley .clk = {
165*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("armtim_ck", "ck_ref", &omap1_clk_gate_ops,
166*c73b9099SJanusz Krzysztofik CLK_IS_CRITICAL),
16752650505SPaul Walmsley .ops = &clkops_generic,
16852650505SPaul Walmsley .flags = CLOCK_IDLE_CONTROL,
16952650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
17052650505SPaul Walmsley .enable_bit = EN_TIMCK,
17152650505SPaul Walmsley },
172fb2fc920SPaul Walmsley .idlect_shift = IDLTIM_ARM_SHIFT,
17352650505SPaul Walmsley };
17452650505SPaul Walmsley
17552650505SPaul Walmsley static struct arm_idlect1_clk armwdt_ck = {
17652650505SPaul Walmsley .clk = {
177*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("armwdt_ck", "ck_ref", &omap1_clk_full_ops, 0),
17852650505SPaul Walmsley .ops = &clkops_generic,
17952650505SPaul Walmsley .flags = CLOCK_IDLE_CONTROL,
18052650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
18152650505SPaul Walmsley .enable_bit = EN_WDTCK,
1820dfc242fSPaul Walmsley .fixed_div = 14,
1830dfc242fSPaul Walmsley .recalc = &omap_fixed_divisor_recalc,
18452650505SPaul Walmsley },
185fb2fc920SPaul Walmsley .idlect_shift = IDLWDT_ARM_SHIFT,
18652650505SPaul Walmsley };
18752650505SPaul Walmsley
188*c73b9099SJanusz Krzysztofik static struct omap1_clk arminth_ck16xx = {
189*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("arminth_ck", "arm_ck", &omap1_clk_null_ops, 0),
19052650505SPaul Walmsley /* Note: On 16xx the frequency can be divided by 2 by programming
19152650505SPaul Walmsley * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
19252650505SPaul Walmsley *
19352650505SPaul Walmsley * 1510 version is in TC clocks.
19452650505SPaul Walmsley */
19552650505SPaul Walmsley };
19652650505SPaul Walmsley
197*c73b9099SJanusz Krzysztofik static struct omap1_clk dsp_ck = {
198*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("dsp_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
19952650505SPaul Walmsley .ops = &clkops_generic,
20052650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_CKCTL),
20152650505SPaul Walmsley .enable_bit = EN_DSPCK,
20252650505SPaul Walmsley .rate_offset = CKCTL_DSPDIV_OFFSET,
20352650505SPaul Walmsley .recalc = &omap1_ckctl_recalc,
20452650505SPaul Walmsley .round_rate = omap1_clk_round_rate_ckctl_arm,
20552650505SPaul Walmsley .set_rate = omap1_clk_set_rate_ckctl_arm,
20652650505SPaul Walmsley };
20752650505SPaul Walmsley
208*c73b9099SJanusz Krzysztofik static struct omap1_clk dspmmu_ck = {
209*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("dspmmu_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
21052650505SPaul Walmsley .rate_offset = CKCTL_DSPMMUDIV_OFFSET,
21152650505SPaul Walmsley .recalc = &omap1_ckctl_recalc,
21252650505SPaul Walmsley .round_rate = omap1_clk_round_rate_ckctl_arm,
21352650505SPaul Walmsley .set_rate = omap1_clk_set_rate_ckctl_arm,
21452650505SPaul Walmsley };
21552650505SPaul Walmsley
216*c73b9099SJanusz Krzysztofik static struct omap1_clk dspper_ck = {
217*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("dspper_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
21852650505SPaul Walmsley .ops = &clkops_dspck,
21952650505SPaul Walmsley .enable_reg = DSP_IDLECT2,
22052650505SPaul Walmsley .enable_bit = EN_PERCK,
22152650505SPaul Walmsley .rate_offset = CKCTL_PERDIV_OFFSET,
22252650505SPaul Walmsley .recalc = &omap1_ckctl_recalc_dsp_domain,
22352650505SPaul Walmsley .round_rate = omap1_clk_round_rate_ckctl_arm,
22452650505SPaul Walmsley .set_rate = &omap1_clk_set_rate_dsp_domain,
22552650505SPaul Walmsley };
22652650505SPaul Walmsley
227*c73b9099SJanusz Krzysztofik static struct omap1_clk dspxor_ck = {
228*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("dspxor_ck", "ck_ref", &omap1_clk_gate_ops, 0),
22952650505SPaul Walmsley .ops = &clkops_dspck,
23052650505SPaul Walmsley .enable_reg = DSP_IDLECT2,
23152650505SPaul Walmsley .enable_bit = EN_XORPCK,
23252650505SPaul Walmsley };
23352650505SPaul Walmsley
234*c73b9099SJanusz Krzysztofik static struct omap1_clk dsptim_ck = {
235*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("dsptim_ck", "ck_ref", &omap1_clk_gate_ops, 0),
23652650505SPaul Walmsley .ops = &clkops_dspck,
23752650505SPaul Walmsley .enable_reg = DSP_IDLECT2,
23852650505SPaul Walmsley .enable_bit = EN_DSPTIMCK,
23952650505SPaul Walmsley };
24052650505SPaul Walmsley
24152650505SPaul Walmsley static struct arm_idlect1_clk tc_ck = {
24252650505SPaul Walmsley .clk = {
243*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("tc_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
24452650505SPaul Walmsley .flags = CLOCK_IDLE_CONTROL,
24552650505SPaul Walmsley .rate_offset = CKCTL_TCDIV_OFFSET,
24652650505SPaul Walmsley .recalc = &omap1_ckctl_recalc,
24752650505SPaul Walmsley .round_rate = omap1_clk_round_rate_ckctl_arm,
24852650505SPaul Walmsley .set_rate = omap1_clk_set_rate_ckctl_arm,
24952650505SPaul Walmsley },
250fb2fc920SPaul Walmsley .idlect_shift = IDLIF_ARM_SHIFT,
25152650505SPaul Walmsley };
25252650505SPaul Walmsley
253*c73b9099SJanusz Krzysztofik static struct omap1_clk arminth_ck1510 = {
254*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("arminth_ck", "tc_ck", &omap1_clk_null_ops, 0),
25552650505SPaul Walmsley /* Note: On 1510 the frequency follows TC_CK
25652650505SPaul Walmsley *
25752650505SPaul Walmsley * 16xx version is in MPU clocks.
25852650505SPaul Walmsley */
25952650505SPaul Walmsley };
26052650505SPaul Walmsley
261*c73b9099SJanusz Krzysztofik static struct omap1_clk tipb_ck = {
26252650505SPaul Walmsley /* No-idle controlled by "tc_ck" */
263*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("tipb_ck", "tc_ck", &omap1_clk_null_ops, 0),
26452650505SPaul Walmsley };
26552650505SPaul Walmsley
266*c73b9099SJanusz Krzysztofik static struct omap1_clk l3_ocpi_ck = {
26752650505SPaul Walmsley /* No-idle controlled by "tc_ck" */
268*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("l3_ocpi_ck", "tc_ck", &omap1_clk_gate_ops, 0),
26952650505SPaul Walmsley .ops = &clkops_generic,
27052650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
27152650505SPaul Walmsley .enable_bit = EN_OCPI_CK,
27252650505SPaul Walmsley };
27352650505SPaul Walmsley
274*c73b9099SJanusz Krzysztofik static struct omap1_clk tc1_ck = {
275*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("tc1_ck", "tc_ck", &omap1_clk_gate_ops, 0),
27652650505SPaul Walmsley .ops = &clkops_generic,
27752650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
27852650505SPaul Walmsley .enable_bit = EN_TC1_CK,
27952650505SPaul Walmsley };
28052650505SPaul Walmsley
28152650505SPaul Walmsley /*
28252650505SPaul Walmsley * FIXME: This clock seems to be necessary but no-one has asked for its
28352650505SPaul Walmsley * activation. [ pm.c (SRAM), CCP, Camera ]
28452650505SPaul Walmsley */
285*c73b9099SJanusz Krzysztofik
286*c73b9099SJanusz Krzysztofik static struct omap1_clk tc2_ck = {
287*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("tc2_ck", "tc_ck", &omap1_clk_gate_ops, CLK_IS_CRITICAL),
28852650505SPaul Walmsley .ops = &clkops_generic,
28952650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
29052650505SPaul Walmsley .enable_bit = EN_TC2_CK,
29152650505SPaul Walmsley };
29252650505SPaul Walmsley
293*c73b9099SJanusz Krzysztofik static struct omap1_clk dma_ck = {
29452650505SPaul Walmsley /* No-idle controlled by "tc_ck" */
295*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("dma_ck", "tc_ck", &omap1_clk_null_ops, 0),
29652650505SPaul Walmsley };
29752650505SPaul Walmsley
298*c73b9099SJanusz Krzysztofik static struct omap1_clk dma_lcdfree_ck = {
299*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("dma_lcdfree_ck", "tc_ck", &omap1_clk_null_ops, 0),
30052650505SPaul Walmsley };
30152650505SPaul Walmsley
30252650505SPaul Walmsley static struct arm_idlect1_clk api_ck = {
30352650505SPaul Walmsley .clk = {
304*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("api_ck", "tc_ck", &omap1_clk_gate_ops, 0),
30552650505SPaul Walmsley .ops = &clkops_generic,
30652650505SPaul Walmsley .flags = CLOCK_IDLE_CONTROL,
30752650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
30852650505SPaul Walmsley .enable_bit = EN_APICK,
30952650505SPaul Walmsley },
310fb2fc920SPaul Walmsley .idlect_shift = IDLAPI_ARM_SHIFT,
31152650505SPaul Walmsley };
31252650505SPaul Walmsley
31352650505SPaul Walmsley static struct arm_idlect1_clk lb_ck = {
31452650505SPaul Walmsley .clk = {
315*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("lb_ck", "tc_ck", &omap1_clk_gate_ops, 0),
31652650505SPaul Walmsley .ops = &clkops_generic,
31752650505SPaul Walmsley .flags = CLOCK_IDLE_CONTROL,
31852650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
31952650505SPaul Walmsley .enable_bit = EN_LBCK,
32052650505SPaul Walmsley },
321fb2fc920SPaul Walmsley .idlect_shift = IDLLB_ARM_SHIFT,
32252650505SPaul Walmsley };
32352650505SPaul Walmsley
324*c73b9099SJanusz Krzysztofik static struct omap1_clk rhea1_ck = {
325*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("rhea1_ck", "tc_ck", &omap1_clk_null_ops, 0),
32652650505SPaul Walmsley };
32752650505SPaul Walmsley
328*c73b9099SJanusz Krzysztofik static struct omap1_clk rhea2_ck = {
329*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("rhea2_ck", "tc_ck", &omap1_clk_null_ops, 0),
33052650505SPaul Walmsley };
33152650505SPaul Walmsley
332*c73b9099SJanusz Krzysztofik static struct omap1_clk lcd_ck_16xx = {
333*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("lcd_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
33452650505SPaul Walmsley .ops = &clkops_generic,
33552650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
33652650505SPaul Walmsley .enable_bit = EN_LCDCK,
33752650505SPaul Walmsley .rate_offset = CKCTL_LCDDIV_OFFSET,
33852650505SPaul Walmsley .recalc = &omap1_ckctl_recalc,
33952650505SPaul Walmsley .round_rate = omap1_clk_round_rate_ckctl_arm,
34052650505SPaul Walmsley .set_rate = omap1_clk_set_rate_ckctl_arm,
34152650505SPaul Walmsley };
34252650505SPaul Walmsley
34352650505SPaul Walmsley static struct arm_idlect1_clk lcd_ck_1510 = {
34452650505SPaul Walmsley .clk = {
345*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("lcd_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
34652650505SPaul Walmsley .ops = &clkops_generic,
34752650505SPaul Walmsley .flags = CLOCK_IDLE_CONTROL,
34852650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
34952650505SPaul Walmsley .enable_bit = EN_LCDCK,
35052650505SPaul Walmsley .rate_offset = CKCTL_LCDDIV_OFFSET,
35152650505SPaul Walmsley .recalc = &omap1_ckctl_recalc,
35252650505SPaul Walmsley .round_rate = omap1_clk_round_rate_ckctl_arm,
35352650505SPaul Walmsley .set_rate = omap1_clk_set_rate_ckctl_arm,
35452650505SPaul Walmsley },
355fb2fc920SPaul Walmsley .idlect_shift = OMAP1510_IDLLCD_ARM_SHIFT,
35652650505SPaul Walmsley };
35752650505SPaul Walmsley
358*c73b9099SJanusz Krzysztofik
359fb2fc920SPaul Walmsley /*
360fb2fc920SPaul Walmsley * XXX The enable_bit here is misused - it simply switches between 12MHz
361*c73b9099SJanusz Krzysztofik * and 48MHz. Reimplement with clk_mux.
362fb2fc920SPaul Walmsley *
363fb2fc920SPaul Walmsley * XXX does this need SYSC register handling?
364fb2fc920SPaul Walmsley */
365*c73b9099SJanusz Krzysztofik static struct omap1_clk uart1_1510 = {
36652650505SPaul Walmsley /* Direct from ULPD, no real parent */
367*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("uart1_ck", "armper_ck", &omap1_clk_full_ops, 0),
36852650505SPaul Walmsley .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
36952650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
370fb2fc920SPaul Walmsley .enable_bit = CONF_MOD_UART1_CLK_MODE_R,
371*c73b9099SJanusz Krzysztofik .round_rate = &omap1_round_uart_rate,
37252650505SPaul Walmsley .set_rate = &omap1_set_uart_rate,
37352650505SPaul Walmsley .recalc = &omap1_uart_recalc,
37452650505SPaul Walmsley };
37552650505SPaul Walmsley
376fb2fc920SPaul Walmsley /*
377fb2fc920SPaul Walmsley * XXX The enable_bit here is misused - it simply switches between 12MHz
378*c73b9099SJanusz Krzysztofik * and 48MHz. Reimplement with clk_mux.
379fb2fc920SPaul Walmsley *
380fb2fc920SPaul Walmsley * XXX SYSC register handling does not belong in the clock framework
381fb2fc920SPaul Walmsley */
38252650505SPaul Walmsley static struct uart_clk uart1_16xx = {
38352650505SPaul Walmsley .clk = {
384fb2fc920SPaul Walmsley .ops = &clkops_uart_16xx,
38552650505SPaul Walmsley /* Direct from ULPD, no real parent */
386*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("uart1_ck", "armper_ck", &omap1_clk_full_ops, 0),
38752650505SPaul Walmsley .rate = 48000000,
38851c19541SPaul Walmsley .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
38952650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
390fb2fc920SPaul Walmsley .enable_bit = CONF_MOD_UART1_CLK_MODE_R,
39152650505SPaul Walmsley },
39252650505SPaul Walmsley .sysc_addr = 0xfffb0054,
39352650505SPaul Walmsley };
39452650505SPaul Walmsley
395fb2fc920SPaul Walmsley /*
396fb2fc920SPaul Walmsley * XXX The enable_bit here is misused - it simply switches between 12MHz
397*c73b9099SJanusz Krzysztofik * and 48MHz. Reimplement with clk_mux.
398fb2fc920SPaul Walmsley *
399fb2fc920SPaul Walmsley * XXX does this need SYSC register handling?
400fb2fc920SPaul Walmsley */
401*c73b9099SJanusz Krzysztofik static struct omap1_clk uart2_ck = {
40252650505SPaul Walmsley /* Direct from ULPD, no real parent */
403*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("uart2_ck", "armper_ck", &omap1_clk_full_ops, 0),
40452650505SPaul Walmsley .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
40552650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
406fb2fc920SPaul Walmsley .enable_bit = CONF_MOD_UART2_CLK_MODE_R,
407*c73b9099SJanusz Krzysztofik .round_rate = &omap1_round_uart_rate,
40852650505SPaul Walmsley .set_rate = &omap1_set_uart_rate,
40952650505SPaul Walmsley .recalc = &omap1_uart_recalc,
41052650505SPaul Walmsley };
41152650505SPaul Walmsley
412fb2fc920SPaul Walmsley /*
413fb2fc920SPaul Walmsley * XXX The enable_bit here is misused - it simply switches between 12MHz
414*c73b9099SJanusz Krzysztofik * and 48MHz. Reimplement with clk_mux.
415fb2fc920SPaul Walmsley *
416fb2fc920SPaul Walmsley * XXX does this need SYSC register handling?
417fb2fc920SPaul Walmsley */
418*c73b9099SJanusz Krzysztofik static struct omap1_clk uart3_1510 = {
41952650505SPaul Walmsley /* Direct from ULPD, no real parent */
420*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("uart3_ck", "armper_ck", &omap1_clk_full_ops, 0),
42152650505SPaul Walmsley .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
42252650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
423fb2fc920SPaul Walmsley .enable_bit = CONF_MOD_UART3_CLK_MODE_R,
424*c73b9099SJanusz Krzysztofik .round_rate = &omap1_round_uart_rate,
42552650505SPaul Walmsley .set_rate = &omap1_set_uart_rate,
42652650505SPaul Walmsley .recalc = &omap1_uart_recalc,
42752650505SPaul Walmsley };
42852650505SPaul Walmsley
429fb2fc920SPaul Walmsley /*
430fb2fc920SPaul Walmsley * XXX The enable_bit here is misused - it simply switches between 12MHz
431*c73b9099SJanusz Krzysztofik * and 48MHz. Reimplement with clk_mux.
432fb2fc920SPaul Walmsley *
433fb2fc920SPaul Walmsley * XXX SYSC register handling does not belong in the clock framework
434fb2fc920SPaul Walmsley */
43552650505SPaul Walmsley static struct uart_clk uart3_16xx = {
43652650505SPaul Walmsley .clk = {
437fb2fc920SPaul Walmsley .ops = &clkops_uart_16xx,
43852650505SPaul Walmsley /* Direct from ULPD, no real parent */
439*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("uart3_ck", "armper_ck", &omap1_clk_full_ops, 0),
44052650505SPaul Walmsley .rate = 48000000,
44151c19541SPaul Walmsley .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
44252650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
443fb2fc920SPaul Walmsley .enable_bit = CONF_MOD_UART3_CLK_MODE_R,
44452650505SPaul Walmsley },
44552650505SPaul Walmsley .sysc_addr = 0xfffb9854,
44652650505SPaul Walmsley };
44752650505SPaul Walmsley
448*c73b9099SJanusz Krzysztofik static struct omap1_clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */
44952650505SPaul Walmsley .ops = &clkops_generic,
45052650505SPaul Walmsley /* Direct from ULPD, no parent */
451*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("usb_clko", &omap1_clk_full_ops, 0),
45252650505SPaul Walmsley .rate = 6000000,
45351c19541SPaul Walmsley .flags = ENABLE_REG_32BIT,
45452650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(ULPD_CLOCK_CTRL),
45552650505SPaul Walmsley .enable_bit = USB_MCLK_EN_BIT,
45652650505SPaul Walmsley };
45752650505SPaul Walmsley
458*c73b9099SJanusz Krzysztofik static struct omap1_clk usb_hhc_ck1510 = {
45952650505SPaul Walmsley .ops = &clkops_generic,
46052650505SPaul Walmsley /* Direct from ULPD, no parent */
461*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("usb_hhc_ck", &omap1_clk_full_ops, 0),
46252650505SPaul Walmsley .rate = 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
46351c19541SPaul Walmsley .flags = ENABLE_REG_32BIT,
46452650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
46552650505SPaul Walmsley .enable_bit = USB_HOST_HHC_UHOST_EN,
46652650505SPaul Walmsley };
46752650505SPaul Walmsley
468*c73b9099SJanusz Krzysztofik static struct omap1_clk usb_hhc_ck16xx = {
46952650505SPaul Walmsley .ops = &clkops_generic,
47052650505SPaul Walmsley /* Direct from ULPD, no parent */
471*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("usb_hhc_ck", &omap1_clk_full_ops, 0),
47252650505SPaul Walmsley .rate = 48000000,
47352650505SPaul Walmsley /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
47451c19541SPaul Walmsley .flags = ENABLE_REG_32BIT,
47552650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(OTG_BASE + 0x08), /* OTG_SYSCON_2 */
476fb2fc920SPaul Walmsley .enable_bit = OTG_SYSCON_2_UHOST_EN_SHIFT
47752650505SPaul Walmsley };
47852650505SPaul Walmsley
479*c73b9099SJanusz Krzysztofik static struct omap1_clk usb_dc_ck = {
48052650505SPaul Walmsley .ops = &clkops_generic,
48152650505SPaul Walmsley /* Direct from ULPD, no parent */
482*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("usb_dc_ck", &omap1_clk_full_ops, 0),
48352650505SPaul Walmsley .rate = 48000000,
48452650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
485fb2fc920SPaul Walmsley .enable_bit = SOFT_USB_OTG_DPLL_REQ_SHIFT,
48652650505SPaul Walmsley };
48752650505SPaul Walmsley
488*c73b9099SJanusz Krzysztofik static struct omap1_clk uart1_7xx = {
4898b8fbd39SCory Maccarrone .ops = &clkops_generic,
4908b8fbd39SCory Maccarrone /* Direct from ULPD, no parent */
491*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("uart1_ck", &omap1_clk_full_ops, 0),
4928b8fbd39SCory Maccarrone .rate = 12000000,
4938b8fbd39SCory Maccarrone .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
4948b8fbd39SCory Maccarrone .enable_bit = 9,
4958b8fbd39SCory Maccarrone };
4968b8fbd39SCory Maccarrone
497*c73b9099SJanusz Krzysztofik static struct omap1_clk uart2_7xx = {
4988b8fbd39SCory Maccarrone .ops = &clkops_generic,
4998b8fbd39SCory Maccarrone /* Direct from ULPD, no parent */
500*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("uart2_ck", &omap1_clk_full_ops, 0),
5018b8fbd39SCory Maccarrone .rate = 12000000,
5028b8fbd39SCory Maccarrone .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
5038b8fbd39SCory Maccarrone .enable_bit = 11,
5048b8fbd39SCory Maccarrone };
5058b8fbd39SCory Maccarrone
506*c73b9099SJanusz Krzysztofik static struct omap1_clk mclk_1510 = {
50752650505SPaul Walmsley .ops = &clkops_generic,
50852650505SPaul Walmsley /* Direct from ULPD, no parent. May be enabled by ext hardware. */
509*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("mclk", &omap1_clk_full_ops, 0),
51052650505SPaul Walmsley .rate = 12000000,
51152650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
512fb2fc920SPaul Walmsley .enable_bit = SOFT_COM_MCKO_REQ_SHIFT,
51352650505SPaul Walmsley };
51452650505SPaul Walmsley
515*c73b9099SJanusz Krzysztofik static struct omap1_clk mclk_16xx = {
51652650505SPaul Walmsley .ops = &clkops_generic,
51752650505SPaul Walmsley /* Direct from ULPD, no parent. May be enabled by ext hardware. */
518*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("mclk", &omap1_clk_full_ops, 0),
51952650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(COM_CLK_DIV_CTRL_SEL),
52052650505SPaul Walmsley .enable_bit = COM_ULPD_PLL_CLK_REQ,
52152650505SPaul Walmsley .set_rate = &omap1_set_ext_clk_rate,
52252650505SPaul Walmsley .round_rate = &omap1_round_ext_clk_rate,
52352650505SPaul Walmsley .init = &omap1_init_ext_clk,
52452650505SPaul Walmsley };
52552650505SPaul Walmsley
526*c73b9099SJanusz Krzysztofik static struct omap1_clk bclk_1510 = {
52752650505SPaul Walmsley /* Direct from ULPD, no parent. May be enabled by ext hardware. */
528*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("bclk", &omap1_clk_rate_ops, 0),
52952650505SPaul Walmsley .rate = 12000000,
53052650505SPaul Walmsley };
53152650505SPaul Walmsley
532*c73b9099SJanusz Krzysztofik static struct omap1_clk bclk_16xx = {
53352650505SPaul Walmsley .ops = &clkops_generic,
53452650505SPaul Walmsley /* Direct from ULPD, no parent. May be enabled by ext hardware. */
535*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT_NO_PARENT("bclk", &omap1_clk_full_ops, 0),
53652650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL),
53752650505SPaul Walmsley .enable_bit = SWD_ULPD_PLL_CLK_REQ,
53852650505SPaul Walmsley .set_rate = &omap1_set_ext_clk_rate,
53952650505SPaul Walmsley .round_rate = &omap1_round_ext_clk_rate,
54052650505SPaul Walmsley .init = &omap1_init_ext_clk,
54152650505SPaul Walmsley };
54252650505SPaul Walmsley
543*c73b9099SJanusz Krzysztofik static struct omap1_clk mmc1_ck = {
54452650505SPaul Walmsley .ops = &clkops_generic,
54552650505SPaul Walmsley /* Functional clock is direct from ULPD, interface clock is ARMPER */
546*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("mmc1_ck", "armper_ck", &omap1_clk_full_ops, 0),
54752650505SPaul Walmsley .rate = 48000000,
54851c19541SPaul Walmsley .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
54952650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
550fb2fc920SPaul Walmsley .enable_bit = CONF_MOD_MMC_SD_CLK_REQ_R,
55152650505SPaul Walmsley };
55252650505SPaul Walmsley
553fb2fc920SPaul Walmsley /*
554fb2fc920SPaul Walmsley * XXX MOD_CONF_CTRL_0 bit 20 is defined in the 1510 TRM as
555fb2fc920SPaul Walmsley * CONF_MOD_MCBSP3_AUXON ??
556fb2fc920SPaul Walmsley */
557*c73b9099SJanusz Krzysztofik static struct omap1_clk mmc2_ck = {
55852650505SPaul Walmsley .ops = &clkops_generic,
55952650505SPaul Walmsley /* Functional clock is direct from ULPD, interface clock is ARMPER */
560*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("mmc2_ck", "armper_ck", &omap1_clk_full_ops, 0),
56152650505SPaul Walmsley .rate = 48000000,
56251c19541SPaul Walmsley .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
56352650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
56452650505SPaul Walmsley .enable_bit = 20,
56552650505SPaul Walmsley };
56652650505SPaul Walmsley
567*c73b9099SJanusz Krzysztofik static struct omap1_clk mmc3_ck = {
56852650505SPaul Walmsley .ops = &clkops_generic,
56952650505SPaul Walmsley /* Functional clock is direct from ULPD, interface clock is ARMPER */
570*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("mmc3_ck", "armper_ck", &omap1_clk_full_ops, 0),
57152650505SPaul Walmsley .rate = 48000000,
57251c19541SPaul Walmsley .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
57352650505SPaul Walmsley .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
574fb2fc920SPaul Walmsley .enable_bit = SOFT_MMC_DPLL_REQ_SHIFT,
57552650505SPaul Walmsley };
57652650505SPaul Walmsley
577*c73b9099SJanusz Krzysztofik static struct omap1_clk virtual_ck_mpu = {
578*c73b9099SJanusz Krzysztofik /* Is smarter alias for arm_ck */
579*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("mpu", "arm_ck", &omap1_clk_rate_ops, 0),
58052650505SPaul Walmsley .recalc = &followparent_recalc,
58152650505SPaul Walmsley .set_rate = &omap1_select_table_rate,
58252650505SPaul Walmsley .round_rate = &omap1_round_to_table_rate,
58352650505SPaul Walmsley };
58452650505SPaul Walmsley
58552650505SPaul Walmsley /* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK
58652650505SPaul Walmsley remains active during MPU idle whenever this is enabled */
587*c73b9099SJanusz Krzysztofik static struct omap1_clk i2c_fck = {
588*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("i2c_fck", "armxor_ck", &omap1_clk_gate_ops, 0),
58952650505SPaul Walmsley .flags = CLOCK_NO_IDLE_PARENT,
59052650505SPaul Walmsley };
59152650505SPaul Walmsley
592*c73b9099SJanusz Krzysztofik static struct omap1_clk i2c_ick = {
593*c73b9099SJanusz Krzysztofik .hw.init = CLK_HW_INIT("i2c_ick", "armper_ck", &omap1_clk_gate_ops, 0),
59452650505SPaul Walmsley .flags = CLOCK_NO_IDLE_PARENT,
59552650505SPaul Walmsley };
59652650505SPaul Walmsley
59752650505SPaul Walmsley /*
59852650505SPaul Walmsley * clkdev integration
59952650505SPaul Walmsley */
60052650505SPaul Walmsley
60152650505SPaul Walmsley static struct omap_clk omap_clks[] = {
60252650505SPaul Walmsley /* non-ULPD clocks */
603*c73b9099SJanusz Krzysztofik CLK(NULL, "ck_ref", &ck_ref.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
604*c73b9099SJanusz Krzysztofik CLK(NULL, "ck_dpll1", &ck_dpll1.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
60552650505SPaul Walmsley /* CK_GEN1 clocks */
606*c73b9099SJanusz Krzysztofik CLK(NULL, "ck_dpll1out", &ck_dpll1out.clk.hw, CK_16XX),
607*c73b9099SJanusz Krzysztofik CLK(NULL, "ck_sossi", &sossi_ck.hw, CK_16XX),
608*c73b9099SJanusz Krzysztofik CLK(NULL, "arm_ck", &arm_ck.hw, CK_16XX | CK_1510 | CK_310),
609*c73b9099SJanusz Krzysztofik CLK(NULL, "armper_ck", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
610*c73b9099SJanusz Krzysztofik CLK("omap_gpio.0", "ick", &arm_gpio_ck.hw, CK_1510 | CK_310),
611*c73b9099SJanusz Krzysztofik CLK(NULL, "armxor_ck", &armxor_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
612*c73b9099SJanusz Krzysztofik CLK(NULL, "armtim_ck", &armtim_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
613*c73b9099SJanusz Krzysztofik CLK("omap_wdt", "fck", &armwdt_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
614*c73b9099SJanusz Krzysztofik CLK("omap_wdt", "ick", &armper_ck.clk.hw, CK_16XX),
615*c73b9099SJanusz Krzysztofik CLK("omap_wdt", "ick", &dummy_ck.hw, CK_1510 | CK_310),
616*c73b9099SJanusz Krzysztofik CLK(NULL, "arminth_ck", &arminth_ck1510.hw, CK_1510 | CK_310),
617*c73b9099SJanusz Krzysztofik CLK(NULL, "arminth_ck", &arminth_ck16xx.hw, CK_16XX),
61852650505SPaul Walmsley /* CK_GEN2 clocks */
619*c73b9099SJanusz Krzysztofik CLK(NULL, "dsp_ck", &dsp_ck.hw, CK_16XX | CK_1510 | CK_310),
620*c73b9099SJanusz Krzysztofik CLK(NULL, "dspmmu_ck", &dspmmu_ck.hw, CK_16XX | CK_1510 | CK_310),
621*c73b9099SJanusz Krzysztofik CLK(NULL, "dspper_ck", &dspper_ck.hw, CK_16XX | CK_1510 | CK_310),
622*c73b9099SJanusz Krzysztofik CLK(NULL, "dspxor_ck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310),
623*c73b9099SJanusz Krzysztofik CLK(NULL, "dsptim_ck", &dsptim_ck.hw, CK_16XX | CK_1510 | CK_310),
62452650505SPaul Walmsley /* CK_GEN3 clocks */
625*c73b9099SJanusz Krzysztofik CLK(NULL, "tc_ck", &tc_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
626*c73b9099SJanusz Krzysztofik CLK(NULL, "tipb_ck", &tipb_ck.hw, CK_1510 | CK_310),
627*c73b9099SJanusz Krzysztofik CLK(NULL, "l3_ocpi_ck", &l3_ocpi_ck.hw, CK_16XX | CK_7XX),
628*c73b9099SJanusz Krzysztofik CLK(NULL, "tc1_ck", &tc1_ck.hw, CK_16XX),
629*c73b9099SJanusz Krzysztofik CLK(NULL, "tc2_ck", &tc2_ck.hw, CK_16XX),
630*c73b9099SJanusz Krzysztofik CLK(NULL, "dma_ck", &dma_ck.hw, CK_16XX | CK_1510 | CK_310),
631*c73b9099SJanusz Krzysztofik CLK(NULL, "dma_lcdfree_ck", &dma_lcdfree_ck.hw, CK_16XX),
632*c73b9099SJanusz Krzysztofik CLK(NULL, "api_ck", &api_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
633*c73b9099SJanusz Krzysztofik CLK(NULL, "lb_ck", &lb_ck.clk.hw, CK_1510 | CK_310),
634*c73b9099SJanusz Krzysztofik CLK(NULL, "rhea1_ck", &rhea1_ck.hw, CK_16XX),
635*c73b9099SJanusz Krzysztofik CLK(NULL, "rhea2_ck", &rhea2_ck.hw, CK_16XX),
636*c73b9099SJanusz Krzysztofik CLK(NULL, "lcd_ck", &lcd_ck_16xx.hw, CK_16XX | CK_7XX),
637*c73b9099SJanusz Krzysztofik CLK(NULL, "lcd_ck", &lcd_ck_1510.clk.hw, CK_1510 | CK_310),
63852650505SPaul Walmsley /* ULPD clocks */
639*c73b9099SJanusz Krzysztofik CLK(NULL, "uart1_ck", &uart1_1510.hw, CK_1510 | CK_310),
640*c73b9099SJanusz Krzysztofik CLK(NULL, "uart1_ck", &uart1_16xx.clk.hw, CK_16XX),
641*c73b9099SJanusz Krzysztofik CLK(NULL, "uart1_ck", &uart1_7xx.hw, CK_7XX),
642*c73b9099SJanusz Krzysztofik CLK(NULL, "uart2_ck", &uart2_ck.hw, CK_16XX | CK_1510 | CK_310),
643*c73b9099SJanusz Krzysztofik CLK(NULL, "uart2_ck", &uart2_7xx.hw, CK_7XX),
644*c73b9099SJanusz Krzysztofik CLK(NULL, "uart3_ck", &uart3_1510.hw, CK_1510 | CK_310),
645*c73b9099SJanusz Krzysztofik CLK(NULL, "uart3_ck", &uart3_16xx.clk.hw, CK_16XX),
646*c73b9099SJanusz Krzysztofik CLK(NULL, "usb_clko", &usb_clko.hw, CK_16XX | CK_1510 | CK_310),
647*c73b9099SJanusz Krzysztofik CLK(NULL, "usb_hhc_ck", &usb_hhc_ck1510.hw, CK_1510 | CK_310),
648*c73b9099SJanusz Krzysztofik CLK(NULL, "usb_hhc_ck", &usb_hhc_ck16xx.hw, CK_16XX),
649*c73b9099SJanusz Krzysztofik CLK(NULL, "usb_dc_ck", &usb_dc_ck.hw, CK_16XX | CK_7XX),
650*c73b9099SJanusz Krzysztofik CLK(NULL, "mclk", &mclk_1510.hw, CK_1510 | CK_310),
651*c73b9099SJanusz Krzysztofik CLK(NULL, "mclk", &mclk_16xx.hw, CK_16XX),
652*c73b9099SJanusz Krzysztofik CLK(NULL, "bclk", &bclk_1510.hw, CK_1510 | CK_310),
653*c73b9099SJanusz Krzysztofik CLK(NULL, "bclk", &bclk_16xx.hw, CK_16XX),
654*c73b9099SJanusz Krzysztofik CLK("mmci-omap.0", "fck", &mmc1_ck.hw, CK_16XX | CK_1510 | CK_310),
655*c73b9099SJanusz Krzysztofik CLK("mmci-omap.0", "fck", &mmc3_ck.hw, CK_7XX),
656*c73b9099SJanusz Krzysztofik CLK("mmci-omap.0", "ick", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
657*c73b9099SJanusz Krzysztofik CLK("mmci-omap.1", "fck", &mmc2_ck.hw, CK_16XX),
658*c73b9099SJanusz Krzysztofik CLK("mmci-omap.1", "ick", &armper_ck.clk.hw, CK_16XX),
65952650505SPaul Walmsley /* Virtual clocks */
660*c73b9099SJanusz Krzysztofik CLK(NULL, "mpu", &virtual_ck_mpu.hw, CK_16XX | CK_1510 | CK_310),
661*c73b9099SJanusz Krzysztofik CLK("omap_i2c.1", "fck", &i2c_fck.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
662*c73b9099SJanusz Krzysztofik CLK("omap_i2c.1", "ick", &i2c_ick.hw, CK_16XX),
663*c73b9099SJanusz Krzysztofik CLK("omap_i2c.1", "ick", &dummy_ck.hw, CK_1510 | CK_310 | CK_7XX),
664*c73b9099SJanusz Krzysztofik CLK("omap1_spi100k.1", "fck", &dummy_ck.hw, CK_7XX),
665*c73b9099SJanusz Krzysztofik CLK("omap1_spi100k.1", "ick", &dummy_ck.hw, CK_7XX),
666*c73b9099SJanusz Krzysztofik CLK("omap1_spi100k.2", "fck", &dummy_ck.hw, CK_7XX),
667*c73b9099SJanusz Krzysztofik CLK("omap1_spi100k.2", "ick", &dummy_ck.hw, CK_7XX),
668*c73b9099SJanusz Krzysztofik CLK("omap_uwire", "fck", &armxor_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
669*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.1", "ick", &dspper_ck.hw, CK_16XX),
670*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.1", "ick", &dummy_ck.hw, CK_1510 | CK_310),
671*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.2", "ick", &armper_ck.clk.hw, CK_16XX),
672*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.2", "ick", &dummy_ck.hw, CK_1510 | CK_310),
673*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.3", "ick", &dspper_ck.hw, CK_16XX),
674*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.3", "ick", &dummy_ck.hw, CK_1510 | CK_310),
675*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.1", "fck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310),
676*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.2", "fck", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
677*c73b9099SJanusz Krzysztofik CLK("omap-mcbsp.3", "fck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310),
67852650505SPaul Walmsley };
67952650505SPaul Walmsley
68052650505SPaul Walmsley /*
68152650505SPaul Walmsley * init
68252650505SPaul Walmsley */
68352650505SPaul Walmsley
omap1_show_rates(void)684e9b7086bSTony Lindgren static void __init omap1_show_rates(void)
685e9b7086bSTony Lindgren {
6867852ec05SPaul Walmsley pr_notice("Clocking rate (xtal/DPLL1/MPU): %ld.%01ld/%ld.%01ld/%ld.%01ld MHz\n",
687e9b7086bSTony Lindgren ck_ref.rate / 1000000, (ck_ref.rate / 100000) % 10,
688e9b7086bSTony Lindgren ck_dpll1.rate / 1000000, (ck_dpll1.rate / 100000) % 10,
689e9b7086bSTony Lindgren arm_ck.rate / 1000000, (arm_ck.rate / 100000) % 10);
690e9b7086bSTony Lindgren }
691e9b7086bSTony Lindgren
69224ce2705SJanusz Krzysztofik u32 cpu_mask;
69324ce2705SJanusz Krzysztofik
omap1_clk_init(void)69452650505SPaul Walmsley int __init omap1_clk_init(void)
69552650505SPaul Walmsley {
69652650505SPaul Walmsley struct omap_clk *c;
69724ce2705SJanusz Krzysztofik u32 reg;
69852650505SPaul Walmsley
69952650505SPaul Walmsley #ifdef CONFIG_DEBUG_LL
70034c86239SJanusz Krzysztofik /* Make sure UART clocks are enabled early */
70134c86239SJanusz Krzysztofik if (cpu_is_omap16xx())
70234c86239SJanusz Krzysztofik omap_writel(omap_readl(MOD_CONF_CTRL_0) |
70334c86239SJanusz Krzysztofik CONF_MOD_UART1_CLK_MODE_R |
70434c86239SJanusz Krzysztofik CONF_MOD_UART3_CLK_MODE_R, MOD_CONF_CTRL_0);
70552650505SPaul Walmsley #endif
70652650505SPaul Walmsley
70752650505SPaul Walmsley /* USB_REQ_EN will be disabled later if necessary (usb_dc_ck) */
70852650505SPaul Walmsley reg = omap_readw(SOFT_REQ_REG) & (1 << 4);
70952650505SPaul Walmsley omap_writew(reg, SOFT_REQ_REG);
71052650505SPaul Walmsley if (!cpu_is_omap15xx())
71152650505SPaul Walmsley omap_writew(0, SOFT_REQ_REG2);
71252650505SPaul Walmsley
71352650505SPaul Walmsley /* By default all idlect1 clocks are allowed to idle */
71452650505SPaul Walmsley arm_idlect1_mask = ~0;
71552650505SPaul Walmsley
71652650505SPaul Walmsley cpu_mask = 0;
71724ce2705SJanusz Krzysztofik if (cpu_is_omap1710())
71824ce2705SJanusz Krzysztofik cpu_mask |= CK_1710;
71952650505SPaul Walmsley if (cpu_is_omap16xx())
72052650505SPaul Walmsley cpu_mask |= CK_16XX;
72152650505SPaul Walmsley if (cpu_is_omap1510())
72252650505SPaul Walmsley cpu_mask |= CK_1510;
72352650505SPaul Walmsley if (cpu_is_omap310())
72452650505SPaul Walmsley cpu_mask |= CK_310;
72552650505SPaul Walmsley
72652650505SPaul Walmsley /* Pointers to these clocks are needed by code in clock.c */
727*c73b9099SJanusz Krzysztofik api_ck_p = &api_ck.clk;
728*c73b9099SJanusz Krzysztofik ck_dpll1_p = &ck_dpll1;
729*c73b9099SJanusz Krzysztofik ck_ref_p = &ck_ref;
73052650505SPaul Walmsley
7317852ec05SPaul Walmsley pr_info("Clocks: ARM_SYSST: 0x%04x DPLL_CTL: 0x%04x ARM_CKCTL: 0x%04x\n",
7327852ec05SPaul Walmsley omap_readw(ARM_SYSST), omap_readw(DPLL_CTL),
73352650505SPaul Walmsley omap_readw(ARM_CKCTL));
73452650505SPaul Walmsley
735ec8f1282SJulia Lawall /* We want to be in synchronous scalable mode */
73652650505SPaul Walmsley omap_writew(0x1000, ARM_SYSST);
73752650505SPaul Walmsley
738e9b7086bSTony Lindgren
739e9b7086bSTony Lindgren /*
740e9b7086bSTony Lindgren * Initially use the values set by bootloader. Determine PLL rate and
741e9b7086bSTony Lindgren * recalculate dependent clocks as if kernel had changed PLL or
742e9b7086bSTony Lindgren * divisors. See also omap1_clk_late_init() that can reprogram dpll1
743e9b7086bSTony Lindgren * after the SRAM is initialized.
74452650505SPaul Walmsley */
74552650505SPaul Walmsley {
74652650505SPaul Walmsley unsigned pll_ctl_val = omap_readw(DPLL_CTL);
74752650505SPaul Walmsley
74852650505SPaul Walmsley ck_dpll1.rate = ck_ref.rate; /* Base xtal rate */
74952650505SPaul Walmsley if (pll_ctl_val & 0x10) {
75052650505SPaul Walmsley /* PLL enabled, apply multiplier and divisor */
75152650505SPaul Walmsley if (pll_ctl_val & 0xf80)
75252650505SPaul Walmsley ck_dpll1.rate *= (pll_ctl_val & 0xf80) >> 7;
75352650505SPaul Walmsley ck_dpll1.rate /= ((pll_ctl_val & 0x60) >> 5) + 1;
75452650505SPaul Walmsley } else {
75552650505SPaul Walmsley /* PLL disabled, apply bypass divisor */
75652650505SPaul Walmsley switch (pll_ctl_val & 0xc) {
75752650505SPaul Walmsley case 0:
75852650505SPaul Walmsley break;
75952650505SPaul Walmsley case 0x4:
76052650505SPaul Walmsley ck_dpll1.rate /= 2;
76152650505SPaul Walmsley break;
76252650505SPaul Walmsley default:
76352650505SPaul Walmsley ck_dpll1.rate /= 4;
76452650505SPaul Walmsley break;
76552650505SPaul Walmsley }
76652650505SPaul Walmsley }
76752650505SPaul Walmsley }
768*c73b9099SJanusz Krzysztofik
76952650505SPaul Walmsley /* Amstrad Delta wants BCLK high when inactive */
77052650505SPaul Walmsley if (machine_is_ams_delta())
77152650505SPaul Walmsley omap_writel(omap_readl(ULPD_CLOCK_CTRL) |
77252650505SPaul Walmsley (1 << SDW_MCLK_INV_BIT),
77352650505SPaul Walmsley ULPD_CLOCK_CTRL);
77452650505SPaul Walmsley
77552650505SPaul Walmsley /* Turn off DSP and ARM_TIMXO. Make sure ARM_INTHCK is not divided */
77652650505SPaul Walmsley omap_writew(omap_readw(ARM_CKCTL) & 0x0fff, ARM_CKCTL);
77752650505SPaul Walmsley
77852650505SPaul Walmsley /* Put DSP/MPUI into reset until needed */
77952650505SPaul Walmsley omap_writew(0, ARM_RSTCT1);
78052650505SPaul Walmsley omap_writew(1, ARM_RSTCT2);
78152650505SPaul Walmsley omap_writew(0x400, ARM_IDLECT1);
78252650505SPaul Walmsley
78352650505SPaul Walmsley /*
78452650505SPaul Walmsley * According to OMAP5910 Erratum SYS_DMA_1, bit DMACK_REQ (bit 8)
78552650505SPaul Walmsley * of the ARM_IDLECT2 register must be set to zero. The power-on
78652650505SPaul Walmsley * default value of this bit is one.
78752650505SPaul Walmsley */
78852650505SPaul Walmsley omap_writew(0x0000, ARM_IDLECT2); /* Turn LCD clock off also */
78952650505SPaul Walmsley
790*c73b9099SJanusz Krzysztofik for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++) {
791*c73b9099SJanusz Krzysztofik if (!(c->cpu & cpu_mask))
792*c73b9099SJanusz Krzysztofik continue;
79352650505SPaul Walmsley
794*c73b9099SJanusz Krzysztofik if (c->lk.clk_hw->init) { /* NULL if provider already registered */
795*c73b9099SJanusz Krzysztofik const struct clk_init_data *init = c->lk.clk_hw->init;
796*c73b9099SJanusz Krzysztofik const char *name = c->lk.clk_hw->init->name;
797*c73b9099SJanusz Krzysztofik int err;
798*c73b9099SJanusz Krzysztofik
799*c73b9099SJanusz Krzysztofik err = clk_hw_register(NULL, c->lk.clk_hw);
800*c73b9099SJanusz Krzysztofik if (err < 0) {
801*c73b9099SJanusz Krzysztofik pr_err("failed to register clock \"%s\"! (%d)\n", name, err);
802*c73b9099SJanusz Krzysztofik /* may be tried again, restore init data */
803*c73b9099SJanusz Krzysztofik c->lk.clk_hw->init = init;
804*c73b9099SJanusz Krzysztofik continue;
805*c73b9099SJanusz Krzysztofik }
806*c73b9099SJanusz Krzysztofik }
807*c73b9099SJanusz Krzysztofik
808*c73b9099SJanusz Krzysztofik clk_hw_register_clkdev(c->lk.clk_hw, c->lk.con_id, c->lk.dev_id);
809*c73b9099SJanusz Krzysztofik }
810*c73b9099SJanusz Krzysztofik
811*c73b9099SJanusz Krzysztofik omap1_show_rates();
81252650505SPaul Walmsley
81352650505SPaul Walmsley return 0;
81452650505SPaul Walmsley }
815e9b7086bSTony Lindgren
816e9b7086bSTony Lindgren #define OMAP1_DPLL1_SANE_VALUE 60000000
817e9b7086bSTony Lindgren
omap1_clk_late_init(void)818e9b7086bSTony Lindgren void __init omap1_clk_late_init(void)
819e9b7086bSTony Lindgren {
8206560ee07SJanusz Krzysztofik unsigned long rate = ck_dpll1.rate;
8216560ee07SJanusz Krzysztofik
822e9b7086bSTony Lindgren /* Find the highest supported frequency and enable it */
823*c73b9099SJanusz Krzysztofik if (omap1_select_table_rate(&virtual_ck_mpu, ~0, arm_ck.rate)) {
824e9b7086bSTony Lindgren pr_err("System frequencies not set, using default. Check your config.\n");
825f9e5908fSJanusz Krzysztofik /*
826f9e5908fSJanusz Krzysztofik * Reprogramming the DPLL is tricky, it must be done from SRAM.
827f9e5908fSJanusz Krzysztofik */
828f9e5908fSJanusz Krzysztofik omap_sram_reprogram_clock(0x2290, 0x0005);
829e9b7086bSTony Lindgren ck_dpll1.rate = OMAP1_DPLL1_SANE_VALUE;
830e9b7086bSTony Lindgren }
831e9b7086bSTony Lindgren propagate_rate(&ck_dpll1);
832e9b7086bSTony Lindgren omap1_show_rates();
8336560ee07SJanusz Krzysztofik loops_per_jiffy = cpufreq_scale(loops_per_jiffy, rate, ck_dpll1.rate);
834e9b7086bSTony Lindgren }
835