Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  linux/arch/arm/mach-omap1/clock_data.c
0004  *
0005  *  Copyright (C) 2004 - 2005, 2009-2010 Nokia Corporation
0006  *  Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
0007  *  Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
0008  *
0009  * To do:
0010  * - Clocks that are only available on some chips should be marked with the
0011  *   chips that they are present on.
0012  */
0013 
0014 #include <linux/kernel.h>
0015 #include <linux/io.h>
0016 #include <linux/clk.h>
0017 #include <linux/clkdev.h>
0018 #include <linux/clk-provider.h>
0019 #include <linux/cpufreq.h>
0020 #include <linux/delay.h>
0021 #include <linux/soc/ti/omap1-io.h>
0022 
0023 #include <asm/mach-types.h>  /* for machine_is_* */
0024 
0025 #include "soc.h"
0026 #include "hardware.h"
0027 #include "usb.h"   /* for OTG_BASE */
0028 #include "iomap.h"
0029 #include "clock.h"
0030 #include "sram.h"
0031 
0032 /* Some ARM_IDLECT1 bit shifts - used in struct arm_idlect1_clk */
0033 #define IDL_CLKOUT_ARM_SHIFT            12
0034 #define IDLTIM_ARM_SHIFT            9
0035 #define IDLAPI_ARM_SHIFT            8
0036 #define IDLIF_ARM_SHIFT             6
0037 #define IDLLB_ARM_SHIFT             4   /* undocumented? */
0038 #define OMAP1510_IDLLCD_ARM_SHIFT       3   /* undocumented? */
0039 #define IDLPER_ARM_SHIFT            2
0040 #define IDLXORP_ARM_SHIFT           1
0041 #define IDLWDT_ARM_SHIFT            0
0042 
0043 /* Some MOD_CONF_CTRL_0 bit shifts - used in struct clk.enable_bit */
0044 #define CONF_MOD_UART3_CLK_MODE_R       31
0045 #define CONF_MOD_UART2_CLK_MODE_R       30
0046 #define CONF_MOD_UART1_CLK_MODE_R       29
0047 #define CONF_MOD_MMC_SD_CLK_REQ_R       23
0048 #define CONF_MOD_MCBSP3_AUXON           20
0049 
0050 /* Some MOD_CONF_CTRL_1 bit shifts - used in struct clk.enable_bit */
0051 #define CONF_MOD_SOSSI_CLK_EN_R         16
0052 
0053 /* Some OTG_SYSCON_2-specific bit fields */
0054 #define OTG_SYSCON_2_UHOST_EN_SHIFT     8
0055 
0056 /* Some SOFT_REQ_REG bit fields - used in struct clk.enable_bit */
0057 #define SOFT_MMC2_DPLL_REQ_SHIFT    13
0058 #define SOFT_MMC_DPLL_REQ_SHIFT     12
0059 #define SOFT_UART3_DPLL_REQ_SHIFT   11
0060 #define SOFT_UART2_DPLL_REQ_SHIFT   10
0061 #define SOFT_UART1_DPLL_REQ_SHIFT   9
0062 #define SOFT_USB_OTG_DPLL_REQ_SHIFT 8
0063 #define SOFT_CAM_DPLL_REQ_SHIFT     7
0064 #define SOFT_COM_MCKO_REQ_SHIFT     6
0065 #define SOFT_PERIPH_REQ_SHIFT       5   /* sys_ck gate for UART2 ? */
0066 #define USB_REQ_EN_SHIFT        4
0067 #define SOFT_USB_REQ_SHIFT      3   /* sys_ck gate for USB host? */
0068 #define SOFT_SDW_REQ_SHIFT      2   /* sys_ck gate for Bluetooth? */
0069 #define SOFT_COM_REQ_SHIFT      1   /* sys_ck gate for com proc? */
0070 #define SOFT_DPLL_REQ_SHIFT     0
0071 
0072 /*
0073  * Omap1 clocks
0074  */
0075 
0076 static struct omap1_clk ck_ref = {
0077     .hw.init    = CLK_HW_INIT_NO_PARENT("ck_ref", &omap1_clk_rate_ops, 0),
0078     .rate       = 12000000,
0079 };
0080 
0081 static struct omap1_clk ck_dpll1 = {
0082     .hw.init    = CLK_HW_INIT("ck_dpll1", "ck_ref", &omap1_clk_rate_ops,
0083                       /*
0084                        * force recursive refresh of rates of the clock
0085                        * and its children when clk_get_rate() is called
0086                        */
0087                       CLK_GET_RATE_NOCACHE),
0088 };
0089 
0090 /*
0091  * FIXME: This clock seems to be necessary but no-one has asked for its
0092  * activation.  [ FIX: SoSSI, SSR ]
0093  */
0094 static struct arm_idlect1_clk ck_dpll1out = {
0095     .clk = {
0096         .hw.init    = CLK_HW_INIT("ck_dpll1out", "ck_dpll1", &omap1_clk_gate_ops, 0),
0097         .ops        = &clkops_generic,
0098         .flags      = CLOCK_IDLE_CONTROL | ENABLE_REG_32BIT,
0099         .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0100         .enable_bit = EN_CKOUT_ARM,
0101     },
0102     .idlect_shift   = IDL_CLKOUT_ARM_SHIFT,
0103 };
0104 
0105 static struct omap1_clk sossi_ck = {
0106     .hw.init    = CLK_HW_INIT("ck_sossi", "ck_dpll1out", &omap1_clk_full_ops, 0),
0107     .ops        = &clkops_generic,
0108     .flags      = CLOCK_NO_IDLE_PARENT | ENABLE_REG_32BIT,
0109     .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1),
0110     .enable_bit = CONF_MOD_SOSSI_CLK_EN_R,
0111     .recalc     = &omap1_sossi_recalc,
0112     .round_rate = &omap1_round_sossi_rate,
0113     .set_rate   = &omap1_set_sossi_rate,
0114 };
0115 
0116 static struct omap1_clk arm_ck = {
0117     .hw.init    = CLK_HW_INIT("arm_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
0118     .rate_offset    = CKCTL_ARMDIV_OFFSET,
0119     .recalc     = &omap1_ckctl_recalc,
0120     .round_rate = omap1_clk_round_rate_ckctl_arm,
0121     .set_rate   = omap1_clk_set_rate_ckctl_arm,
0122 };
0123 
0124 static struct arm_idlect1_clk armper_ck = {
0125     .clk = {
0126         .hw.init    = CLK_HW_INIT("armper_ck", "ck_dpll1", &omap1_clk_full_ops,
0127                           CLK_IS_CRITICAL),
0128         .ops        = &clkops_generic,
0129         .flags      = CLOCK_IDLE_CONTROL,
0130         .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0131         .enable_bit = EN_PERCK,
0132         .rate_offset    = CKCTL_PERDIV_OFFSET,
0133         .recalc     = &omap1_ckctl_recalc,
0134         .round_rate = omap1_clk_round_rate_ckctl_arm,
0135         .set_rate   = omap1_clk_set_rate_ckctl_arm,
0136     },
0137     .idlect_shift   = IDLPER_ARM_SHIFT,
0138 };
0139 
0140 /*
0141  * FIXME: This clock seems to be necessary but no-one has asked for its
0142  * activation.  [ GPIO code for 1510 ]
0143  */
0144 static struct omap1_clk arm_gpio_ck = {
0145     .hw.init    = CLK_HW_INIT("ick", "ck_dpll1", &omap1_clk_gate_ops, CLK_IS_CRITICAL),
0146     .ops        = &clkops_generic,
0147     .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0148     .enable_bit = EN_GPIOCK,
0149 };
0150 
0151 static struct arm_idlect1_clk armxor_ck = {
0152     .clk = {
0153         .hw.init    = CLK_HW_INIT("armxor_ck", "ck_ref", &omap1_clk_gate_ops,
0154                           CLK_IS_CRITICAL),
0155         .ops        = &clkops_generic,
0156         .flags      = CLOCK_IDLE_CONTROL,
0157         .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0158         .enable_bit = EN_XORPCK,
0159     },
0160     .idlect_shift   = IDLXORP_ARM_SHIFT,
0161 };
0162 
0163 static struct arm_idlect1_clk armtim_ck = {
0164     .clk = {
0165         .hw.init    = CLK_HW_INIT("armtim_ck", "ck_ref", &omap1_clk_gate_ops,
0166                           CLK_IS_CRITICAL),
0167         .ops        = &clkops_generic,
0168         .flags      = CLOCK_IDLE_CONTROL,
0169         .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0170         .enable_bit = EN_TIMCK,
0171     },
0172     .idlect_shift   = IDLTIM_ARM_SHIFT,
0173 };
0174 
0175 static struct arm_idlect1_clk armwdt_ck = {
0176     .clk = {
0177         .hw.init    = CLK_HW_INIT("armwdt_ck", "ck_ref", &omap1_clk_full_ops, 0),
0178         .ops        = &clkops_generic,
0179         .flags      = CLOCK_IDLE_CONTROL,
0180         .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0181         .enable_bit = EN_WDTCK,
0182         .fixed_div  = 14,
0183         .recalc     = &omap_fixed_divisor_recalc,
0184     },
0185     .idlect_shift   = IDLWDT_ARM_SHIFT,
0186 };
0187 
0188 static struct omap1_clk arminth_ck16xx = {
0189     .hw.init    = CLK_HW_INIT("arminth_ck", "arm_ck", &omap1_clk_null_ops, 0),
0190     /* Note: On 16xx the frequency can be divided by 2 by programming
0191      * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
0192      *
0193      * 1510 version is in TC clocks.
0194      */
0195 };
0196 
0197 static struct omap1_clk dsp_ck = {
0198     .hw.init    = CLK_HW_INIT("dsp_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
0199     .ops        = &clkops_generic,
0200     .enable_reg = OMAP1_IO_ADDRESS(ARM_CKCTL),
0201     .enable_bit = EN_DSPCK,
0202     .rate_offset    = CKCTL_DSPDIV_OFFSET,
0203     .recalc     = &omap1_ckctl_recalc,
0204     .round_rate = omap1_clk_round_rate_ckctl_arm,
0205     .set_rate   = omap1_clk_set_rate_ckctl_arm,
0206 };
0207 
0208 static struct omap1_clk dspmmu_ck = {
0209     .hw.init    = CLK_HW_INIT("dspmmu_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
0210     .rate_offset    = CKCTL_DSPMMUDIV_OFFSET,
0211     .recalc     = &omap1_ckctl_recalc,
0212     .round_rate = omap1_clk_round_rate_ckctl_arm,
0213     .set_rate   = omap1_clk_set_rate_ckctl_arm,
0214 };
0215 
0216 static struct omap1_clk dspper_ck = {
0217     .hw.init    = CLK_HW_INIT("dspper_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
0218     .ops        = &clkops_dspck,
0219     .enable_reg = DSP_IDLECT2,
0220     .enable_bit = EN_PERCK,
0221     .rate_offset    = CKCTL_PERDIV_OFFSET,
0222     .recalc     = &omap1_ckctl_recalc_dsp_domain,
0223     .round_rate = omap1_clk_round_rate_ckctl_arm,
0224     .set_rate   = &omap1_clk_set_rate_dsp_domain,
0225 };
0226 
0227 static struct omap1_clk dspxor_ck = {
0228     .hw.init    = CLK_HW_INIT("dspxor_ck", "ck_ref", &omap1_clk_gate_ops, 0),
0229     .ops        = &clkops_dspck,
0230     .enable_reg = DSP_IDLECT2,
0231     .enable_bit = EN_XORPCK,
0232 };
0233 
0234 static struct omap1_clk dsptim_ck = {
0235     .hw.init    = CLK_HW_INIT("dsptim_ck", "ck_ref", &omap1_clk_gate_ops, 0),
0236     .ops        = &clkops_dspck,
0237     .enable_reg = DSP_IDLECT2,
0238     .enable_bit = EN_DSPTIMCK,
0239 };
0240 
0241 static struct arm_idlect1_clk tc_ck = {
0242     .clk = {
0243         .hw.init    = CLK_HW_INIT("tc_ck", "ck_dpll1", &omap1_clk_rate_ops, 0),
0244         .flags      = CLOCK_IDLE_CONTROL,
0245         .rate_offset    = CKCTL_TCDIV_OFFSET,
0246         .recalc     = &omap1_ckctl_recalc,
0247         .round_rate = omap1_clk_round_rate_ckctl_arm,
0248         .set_rate   = omap1_clk_set_rate_ckctl_arm,
0249     },
0250     .idlect_shift   = IDLIF_ARM_SHIFT,
0251 };
0252 
0253 static struct omap1_clk arminth_ck1510 = {
0254     .hw.init    = CLK_HW_INIT("arminth_ck", "tc_ck", &omap1_clk_null_ops, 0),
0255     /* Note: On 1510 the frequency follows TC_CK
0256      *
0257      * 16xx version is in MPU clocks.
0258      */
0259 };
0260 
0261 static struct omap1_clk tipb_ck = {
0262     /* No-idle controlled by "tc_ck" */
0263     .hw.init    = CLK_HW_INIT("tipb_ck", "tc_ck", &omap1_clk_null_ops, 0),
0264 };
0265 
0266 static struct omap1_clk l3_ocpi_ck = {
0267     /* No-idle controlled by "tc_ck" */
0268     .hw.init    = CLK_HW_INIT("l3_ocpi_ck", "tc_ck", &omap1_clk_gate_ops, 0),
0269     .ops        = &clkops_generic,
0270     .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
0271     .enable_bit = EN_OCPI_CK,
0272 };
0273 
0274 static struct omap1_clk tc1_ck = {
0275     .hw.init    = CLK_HW_INIT("tc1_ck", "tc_ck", &omap1_clk_gate_ops, 0),
0276     .ops        = &clkops_generic,
0277     .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
0278     .enable_bit = EN_TC1_CK,
0279 };
0280 
0281 /*
0282  * FIXME: This clock seems to be necessary but no-one has asked for its
0283  * activation.  [ pm.c (SRAM), CCP, Camera ]
0284  */
0285 
0286 static struct omap1_clk tc2_ck = {
0287     .hw.init    = CLK_HW_INIT("tc2_ck", "tc_ck", &omap1_clk_gate_ops, CLK_IS_CRITICAL),
0288     .ops        = &clkops_generic,
0289     .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3),
0290     .enable_bit = EN_TC2_CK,
0291 };
0292 
0293 static struct omap1_clk dma_ck = {
0294     /* No-idle controlled by "tc_ck" */
0295     .hw.init    = CLK_HW_INIT("dma_ck", "tc_ck", &omap1_clk_null_ops, 0),
0296 };
0297 
0298 static struct omap1_clk dma_lcdfree_ck = {
0299     .hw.init    = CLK_HW_INIT("dma_lcdfree_ck", "tc_ck", &omap1_clk_null_ops, 0),
0300 };
0301 
0302 static struct arm_idlect1_clk api_ck = {
0303     .clk = {
0304         .hw.init    = CLK_HW_INIT("api_ck", "tc_ck", &omap1_clk_gate_ops, 0),
0305         .ops        = &clkops_generic,
0306         .flags      = CLOCK_IDLE_CONTROL,
0307         .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0308         .enable_bit = EN_APICK,
0309     },
0310     .idlect_shift   = IDLAPI_ARM_SHIFT,
0311 };
0312 
0313 static struct arm_idlect1_clk lb_ck = {
0314     .clk = {
0315         .hw.init    = CLK_HW_INIT("lb_ck", "tc_ck", &omap1_clk_gate_ops, 0),
0316         .ops        = &clkops_generic,
0317         .flags      = CLOCK_IDLE_CONTROL,
0318         .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0319         .enable_bit = EN_LBCK,
0320     },
0321     .idlect_shift   = IDLLB_ARM_SHIFT,
0322 };
0323 
0324 static struct omap1_clk rhea1_ck = {
0325     .hw.init    = CLK_HW_INIT("rhea1_ck", "tc_ck", &omap1_clk_null_ops, 0),
0326 };
0327 
0328 static struct omap1_clk rhea2_ck = {
0329     .hw.init    = CLK_HW_INIT("rhea2_ck", "tc_ck", &omap1_clk_null_ops, 0),
0330 };
0331 
0332 static struct omap1_clk lcd_ck_16xx = {
0333     .hw.init    = CLK_HW_INIT("lcd_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
0334     .ops        = &clkops_generic,
0335     .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0336     .enable_bit = EN_LCDCK,
0337     .rate_offset    = CKCTL_LCDDIV_OFFSET,
0338     .recalc     = &omap1_ckctl_recalc,
0339     .round_rate = omap1_clk_round_rate_ckctl_arm,
0340     .set_rate   = omap1_clk_set_rate_ckctl_arm,
0341 };
0342 
0343 static struct arm_idlect1_clk lcd_ck_1510 = {
0344     .clk = {
0345         .hw.init    = CLK_HW_INIT("lcd_ck", "ck_dpll1", &omap1_clk_full_ops, 0),
0346         .ops        = &clkops_generic,
0347         .flags      = CLOCK_IDLE_CONTROL,
0348         .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2),
0349         .enable_bit = EN_LCDCK,
0350         .rate_offset    = CKCTL_LCDDIV_OFFSET,
0351         .recalc     = &omap1_ckctl_recalc,
0352         .round_rate = omap1_clk_round_rate_ckctl_arm,
0353         .set_rate   = omap1_clk_set_rate_ckctl_arm,
0354     },
0355     .idlect_shift   = OMAP1510_IDLLCD_ARM_SHIFT,
0356 };
0357 
0358 
0359 /*
0360  * XXX The enable_bit here is misused - it simply switches between 12MHz
0361  * and 48MHz.  Reimplement with clk_mux.
0362  *
0363  * XXX does this need SYSC register handling?
0364  */
0365 static struct omap1_clk uart1_1510 = {
0366     /* Direct from ULPD, no real parent */
0367     .hw.init    = CLK_HW_INIT("uart1_ck", "armper_ck", &omap1_clk_full_ops, 0),
0368     .flags      = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
0369     .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
0370     .enable_bit = CONF_MOD_UART1_CLK_MODE_R,
0371     .round_rate = &omap1_round_uart_rate,
0372     .set_rate   = &omap1_set_uart_rate,
0373     .recalc     = &omap1_uart_recalc,
0374 };
0375 
0376 /*
0377  * XXX The enable_bit here is misused - it simply switches between 12MHz
0378  * and 48MHz.  Reimplement with clk_mux.
0379  *
0380  * XXX SYSC register handling does not belong in the clock framework
0381  */
0382 static struct uart_clk uart1_16xx = {
0383     .clk    = {
0384         .ops        = &clkops_uart_16xx,
0385         /* Direct from ULPD, no real parent */
0386         .hw.init    = CLK_HW_INIT("uart1_ck", "armper_ck", &omap1_clk_full_ops, 0),
0387         .rate       = 48000000,
0388         .flags      = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
0389         .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
0390         .enable_bit = CONF_MOD_UART1_CLK_MODE_R,
0391     },
0392     .sysc_addr  = 0xfffb0054,
0393 };
0394 
0395 /*
0396  * XXX The enable_bit here is misused - it simply switches between 12MHz
0397  * and 48MHz.  Reimplement with clk_mux.
0398  *
0399  * XXX does this need SYSC register handling?
0400  */
0401 static struct omap1_clk uart2_ck = {
0402     /* Direct from ULPD, no real parent */
0403     .hw.init    = CLK_HW_INIT("uart2_ck", "armper_ck", &omap1_clk_full_ops, 0),
0404     .flags      = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
0405     .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
0406     .enable_bit = CONF_MOD_UART2_CLK_MODE_R,
0407     .round_rate = &omap1_round_uart_rate,
0408     .set_rate   = &omap1_set_uart_rate,
0409     .recalc     = &omap1_uart_recalc,
0410 };
0411 
0412 /*
0413  * XXX The enable_bit here is misused - it simply switches between 12MHz
0414  * and 48MHz.  Reimplement with clk_mux.
0415  *
0416  * XXX does this need SYSC register handling?
0417  */
0418 static struct omap1_clk uart3_1510 = {
0419     /* Direct from ULPD, no real parent */
0420     .hw.init    = CLK_HW_INIT("uart3_ck", "armper_ck", &omap1_clk_full_ops, 0),
0421     .flags      = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
0422     .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
0423     .enable_bit = CONF_MOD_UART3_CLK_MODE_R,
0424     .round_rate = &omap1_round_uart_rate,
0425     .set_rate   = &omap1_set_uart_rate,
0426     .recalc     = &omap1_uart_recalc,
0427 };
0428 
0429 /*
0430  * XXX The enable_bit here is misused - it simply switches between 12MHz
0431  * and 48MHz.  Reimplement with clk_mux.
0432  *
0433  * XXX SYSC register handling does not belong in the clock framework
0434  */
0435 static struct uart_clk uart3_16xx = {
0436     .clk    = {
0437         .ops        = &clkops_uart_16xx,
0438         /* Direct from ULPD, no real parent */
0439         .hw.init    = CLK_HW_INIT("uart3_ck", "armper_ck", &omap1_clk_full_ops, 0),
0440         .rate       = 48000000,
0441         .flags      = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
0442         .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
0443         .enable_bit = CONF_MOD_UART3_CLK_MODE_R,
0444     },
0445     .sysc_addr  = 0xfffb9854,
0446 };
0447 
0448 static struct omap1_clk usb_clko = {    /* 6 MHz output on W4_USB_CLKO */
0449     .ops        = &clkops_generic,
0450     /* Direct from ULPD, no parent */
0451     .hw.init    = CLK_HW_INIT_NO_PARENT("usb_clko", &omap1_clk_full_ops, 0),
0452     .rate       = 6000000,
0453     .flags      = ENABLE_REG_32BIT,
0454     .enable_reg = OMAP1_IO_ADDRESS(ULPD_CLOCK_CTRL),
0455     .enable_bit = USB_MCLK_EN_BIT,
0456 };
0457 
0458 static struct omap1_clk usb_hhc_ck1510 = {
0459     .ops        = &clkops_generic,
0460     /* Direct from ULPD, no parent */
0461     .hw.init    = CLK_HW_INIT_NO_PARENT("usb_hhc_ck", &omap1_clk_full_ops, 0),
0462     .rate       = 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
0463     .flags      = ENABLE_REG_32BIT,
0464     .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
0465     .enable_bit = USB_HOST_HHC_UHOST_EN,
0466 };
0467 
0468 static struct omap1_clk usb_hhc_ck16xx = {
0469     .ops        = &clkops_generic,
0470     /* Direct from ULPD, no parent */
0471     .hw.init    = CLK_HW_INIT_NO_PARENT("usb_hhc_ck", &omap1_clk_full_ops, 0),
0472     .rate       = 48000000,
0473     /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
0474     .flags      = ENABLE_REG_32BIT,
0475     .enable_reg = OMAP1_IO_ADDRESS(OTG_BASE + 0x08), /* OTG_SYSCON_2 */
0476     .enable_bit = OTG_SYSCON_2_UHOST_EN_SHIFT
0477 };
0478 
0479 static struct omap1_clk usb_dc_ck = {
0480     .ops        = &clkops_generic,
0481     /* Direct from ULPD, no parent */
0482     .hw.init    = CLK_HW_INIT_NO_PARENT("usb_dc_ck", &omap1_clk_full_ops, 0),
0483     .rate       = 48000000,
0484     .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
0485     .enable_bit = SOFT_USB_OTG_DPLL_REQ_SHIFT,
0486 };
0487 
0488 static struct omap1_clk uart1_7xx = {
0489     .ops        = &clkops_generic,
0490     /* Direct from ULPD, no parent */
0491     .hw.init    = CLK_HW_INIT_NO_PARENT("uart1_ck", &omap1_clk_full_ops, 0),
0492     .rate       = 12000000,
0493     .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
0494     .enable_bit = 9,
0495 };
0496 
0497 static struct omap1_clk uart2_7xx = {
0498     .ops        = &clkops_generic,
0499     /* Direct from ULPD, no parent */
0500     .hw.init    = CLK_HW_INIT_NO_PARENT("uart2_ck", &omap1_clk_full_ops, 0),
0501     .rate       = 12000000,
0502     .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
0503     .enable_bit = 11,
0504 };
0505 
0506 static struct omap1_clk mclk_1510 = {
0507     .ops        = &clkops_generic,
0508     /* Direct from ULPD, no parent. May be enabled by ext hardware. */
0509     .hw.init    = CLK_HW_INIT_NO_PARENT("mclk", &omap1_clk_full_ops, 0),
0510     .rate       = 12000000,
0511     .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
0512     .enable_bit = SOFT_COM_MCKO_REQ_SHIFT,
0513 };
0514 
0515 static struct omap1_clk mclk_16xx = {
0516     .ops        = &clkops_generic,
0517     /* Direct from ULPD, no parent. May be enabled by ext hardware. */
0518     .hw.init    = CLK_HW_INIT_NO_PARENT("mclk", &omap1_clk_full_ops, 0),
0519     .enable_reg = OMAP1_IO_ADDRESS(COM_CLK_DIV_CTRL_SEL),
0520     .enable_bit = COM_ULPD_PLL_CLK_REQ,
0521     .set_rate   = &omap1_set_ext_clk_rate,
0522     .round_rate = &omap1_round_ext_clk_rate,
0523     .init       = &omap1_init_ext_clk,
0524 };
0525 
0526 static struct omap1_clk bclk_1510 = {
0527     /* Direct from ULPD, no parent. May be enabled by ext hardware. */
0528     .hw.init    = CLK_HW_INIT_NO_PARENT("bclk", &omap1_clk_rate_ops, 0),
0529     .rate       = 12000000,
0530 };
0531 
0532 static struct omap1_clk bclk_16xx = {
0533     .ops        = &clkops_generic,
0534     /* Direct from ULPD, no parent. May be enabled by ext hardware. */
0535     .hw.init    = CLK_HW_INIT_NO_PARENT("bclk", &omap1_clk_full_ops, 0),
0536     .enable_reg = OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL),
0537     .enable_bit = SWD_ULPD_PLL_CLK_REQ,
0538     .set_rate   = &omap1_set_ext_clk_rate,
0539     .round_rate = &omap1_round_ext_clk_rate,
0540     .init       = &omap1_init_ext_clk,
0541 };
0542 
0543 static struct omap1_clk mmc1_ck = {
0544     .ops        = &clkops_generic,
0545     /* Functional clock is direct from ULPD, interface clock is ARMPER */
0546     .hw.init    = CLK_HW_INIT("mmc1_ck", "armper_ck", &omap1_clk_full_ops, 0),
0547     .rate       = 48000000,
0548     .flags      = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
0549     .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
0550     .enable_bit = CONF_MOD_MMC_SD_CLK_REQ_R,
0551 };
0552 
0553 /*
0554  * XXX MOD_CONF_CTRL_0 bit 20 is defined in the 1510 TRM as
0555  * CONF_MOD_MCBSP3_AUXON ??
0556  */
0557 static struct omap1_clk mmc2_ck = {
0558     .ops        = &clkops_generic,
0559     /* Functional clock is direct from ULPD, interface clock is ARMPER */
0560     .hw.init    = CLK_HW_INIT("mmc2_ck", "armper_ck", &omap1_clk_full_ops, 0),
0561     .rate       = 48000000,
0562     .flags      = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
0563     .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0),
0564     .enable_bit = 20,
0565 };
0566 
0567 static struct omap1_clk mmc3_ck = {
0568     .ops        = &clkops_generic,
0569     /* Functional clock is direct from ULPD, interface clock is ARMPER */
0570     .hw.init    = CLK_HW_INIT("mmc3_ck", "armper_ck", &omap1_clk_full_ops, 0),
0571     .rate       = 48000000,
0572     .flags      = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
0573     .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG),
0574     .enable_bit = SOFT_MMC_DPLL_REQ_SHIFT,
0575 };
0576 
0577 static struct omap1_clk virtual_ck_mpu = {
0578     /* Is smarter alias for arm_ck */
0579     .hw.init    = CLK_HW_INIT("mpu", "arm_ck", &omap1_clk_rate_ops, 0),
0580     .recalc     = &followparent_recalc,
0581     .set_rate   = &omap1_select_table_rate,
0582     .round_rate = &omap1_round_to_table_rate,
0583 };
0584 
0585 /* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK
0586 remains active during MPU idle whenever this is enabled */
0587 static struct omap1_clk i2c_fck = {
0588     .hw.init    = CLK_HW_INIT("i2c_fck", "armxor_ck", &omap1_clk_gate_ops, 0),
0589     .flags      = CLOCK_NO_IDLE_PARENT,
0590 };
0591 
0592 static struct omap1_clk i2c_ick = {
0593     .hw.init    = CLK_HW_INIT("i2c_ick", "armper_ck", &omap1_clk_gate_ops, 0),
0594     .flags      = CLOCK_NO_IDLE_PARENT,
0595 };
0596 
0597 /*
0598  * clkdev integration
0599  */
0600 
0601 static struct omap_clk omap_clks[] = {
0602     /* non-ULPD clocks */
0603     CLK(NULL,   "ck_ref",   &ck_ref.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
0604     CLK(NULL,   "ck_dpll1", &ck_dpll1.hw,   CK_16XX | CK_1510 | CK_310 | CK_7XX),
0605     /* CK_GEN1 clocks */
0606     CLK(NULL,   "ck_dpll1out",  &ck_dpll1out.clk.hw, CK_16XX),
0607     CLK(NULL,   "ck_sossi", &sossi_ck.hw,   CK_16XX),
0608     CLK(NULL,   "arm_ck",   &arm_ck.hw, CK_16XX | CK_1510 | CK_310),
0609     CLK(NULL,   "armper_ck",    &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
0610     CLK("omap_gpio.0", "ick",   &arm_gpio_ck.hw, CK_1510 | CK_310),
0611     CLK(NULL,   "armxor_ck",    &armxor_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
0612     CLK(NULL,   "armtim_ck",    &armtim_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
0613     CLK("omap_wdt", "fck",      &armwdt_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
0614     CLK("omap_wdt", "ick",      &armper_ck.clk.hw, CK_16XX),
0615     CLK("omap_wdt", "ick",      &dummy_ck.hw,   CK_1510 | CK_310),
0616     CLK(NULL,   "arminth_ck",   &arminth_ck1510.hw, CK_1510 | CK_310),
0617     CLK(NULL,   "arminth_ck",   &arminth_ck16xx.hw, CK_16XX),
0618     /* CK_GEN2 clocks */
0619     CLK(NULL,   "dsp_ck",   &dsp_ck.hw, CK_16XX | CK_1510 | CK_310),
0620     CLK(NULL,   "dspmmu_ck",    &dspmmu_ck.hw,  CK_16XX | CK_1510 | CK_310),
0621     CLK(NULL,   "dspper_ck",    &dspper_ck.hw,  CK_16XX | CK_1510 | CK_310),
0622     CLK(NULL,   "dspxor_ck",    &dspxor_ck.hw,  CK_16XX | CK_1510 | CK_310),
0623     CLK(NULL,   "dsptim_ck",    &dsptim_ck.hw,  CK_16XX | CK_1510 | CK_310),
0624     /* CK_GEN3 clocks */
0625     CLK(NULL,   "tc_ck",    &tc_ck.clk.hw,  CK_16XX | CK_1510 | CK_310 | CK_7XX),
0626     CLK(NULL,   "tipb_ck",  &tipb_ck.hw,    CK_1510 | CK_310),
0627     CLK(NULL,   "l3_ocpi_ck",   &l3_ocpi_ck.hw, CK_16XX | CK_7XX),
0628     CLK(NULL,   "tc1_ck",   &tc1_ck.hw, CK_16XX),
0629     CLK(NULL,   "tc2_ck",   &tc2_ck.hw, CK_16XX),
0630     CLK(NULL,   "dma_ck",   &dma_ck.hw, CK_16XX | CK_1510 | CK_310),
0631     CLK(NULL,   "dma_lcdfree_ck", &dma_lcdfree_ck.hw, CK_16XX),
0632     CLK(NULL,   "api_ck",   &api_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
0633     CLK(NULL,   "lb_ck",    &lb_ck.clk.hw,  CK_1510 | CK_310),
0634     CLK(NULL,   "rhea1_ck", &rhea1_ck.hw,   CK_16XX),
0635     CLK(NULL,   "rhea2_ck", &rhea2_ck.hw,   CK_16XX),
0636     CLK(NULL,   "lcd_ck",   &lcd_ck_16xx.hw, CK_16XX | CK_7XX),
0637     CLK(NULL,   "lcd_ck",   &lcd_ck_1510.clk.hw, CK_1510 | CK_310),
0638     /* ULPD clocks */
0639     CLK(NULL,   "uart1_ck", &uart1_1510.hw, CK_1510 | CK_310),
0640     CLK(NULL,   "uart1_ck", &uart1_16xx.clk.hw, CK_16XX),
0641     CLK(NULL,   "uart1_ck", &uart1_7xx.hw,  CK_7XX),
0642     CLK(NULL,   "uart2_ck", &uart2_ck.hw,   CK_16XX | CK_1510 | CK_310),
0643     CLK(NULL,   "uart2_ck", &uart2_7xx.hw,  CK_7XX),
0644     CLK(NULL,   "uart3_ck", &uart3_1510.hw, CK_1510 | CK_310),
0645     CLK(NULL,   "uart3_ck", &uart3_16xx.clk.hw, CK_16XX),
0646     CLK(NULL,   "usb_clko", &usb_clko.hw,   CK_16XX | CK_1510 | CK_310),
0647     CLK(NULL,   "usb_hhc_ck",   &usb_hhc_ck1510.hw, CK_1510 | CK_310),
0648     CLK(NULL,   "usb_hhc_ck",   &usb_hhc_ck16xx.hw, CK_16XX),
0649     CLK(NULL,   "usb_dc_ck",    &usb_dc_ck.hw,  CK_16XX | CK_7XX),
0650     CLK(NULL,   "mclk",     &mclk_1510.hw,  CK_1510 | CK_310),
0651     CLK(NULL,   "mclk",     &mclk_16xx.hw,  CK_16XX),
0652     CLK(NULL,   "bclk",     &bclk_1510.hw,  CK_1510 | CK_310),
0653     CLK(NULL,   "bclk",     &bclk_16xx.hw,  CK_16XX),
0654     CLK("mmci-omap.0", "fck",   &mmc1_ck.hw,    CK_16XX | CK_1510 | CK_310),
0655     CLK("mmci-omap.0", "fck",   &mmc3_ck.hw,    CK_7XX),
0656     CLK("mmci-omap.0", "ick",   &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX),
0657     CLK("mmci-omap.1", "fck",   &mmc2_ck.hw,    CK_16XX),
0658     CLK("mmci-omap.1", "ick",   &armper_ck.clk.hw, CK_16XX),
0659     /* Virtual clocks */
0660     CLK(NULL,   "mpu",      &virtual_ck_mpu.hw, CK_16XX | CK_1510 | CK_310),
0661     CLK("omap_i2c.1", "fck",    &i2c_fck.hw,    CK_16XX | CK_1510 | CK_310 | CK_7XX),
0662     CLK("omap_i2c.1", "ick",    &i2c_ick.hw,    CK_16XX),
0663     CLK("omap_i2c.1", "ick",    &dummy_ck.hw,   CK_1510 | CK_310 | CK_7XX),
0664     CLK("omap1_spi100k.1", "fck",   &dummy_ck.hw,   CK_7XX),
0665     CLK("omap1_spi100k.1", "ick",   &dummy_ck.hw,   CK_7XX),
0666     CLK("omap1_spi100k.2", "fck",   &dummy_ck.hw,   CK_7XX),
0667     CLK("omap1_spi100k.2", "ick",   &dummy_ck.hw,   CK_7XX),
0668     CLK("omap_uwire", "fck",    &armxor_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
0669     CLK("omap-mcbsp.1", "ick",  &dspper_ck.hw,  CK_16XX),
0670     CLK("omap-mcbsp.1", "ick",  &dummy_ck.hw,   CK_1510 | CK_310),
0671     CLK("omap-mcbsp.2", "ick",  &armper_ck.clk.hw, CK_16XX),
0672     CLK("omap-mcbsp.2", "ick",  &dummy_ck.hw,   CK_1510 | CK_310),
0673     CLK("omap-mcbsp.3", "ick",  &dspper_ck.hw,  CK_16XX),
0674     CLK("omap-mcbsp.3", "ick",  &dummy_ck.hw,   CK_1510 | CK_310),
0675     CLK("omap-mcbsp.1", "fck",  &dspxor_ck.hw,  CK_16XX | CK_1510 | CK_310),
0676     CLK("omap-mcbsp.2", "fck",  &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310),
0677     CLK("omap-mcbsp.3", "fck",  &dspxor_ck.hw,  CK_16XX | CK_1510 | CK_310),
0678 };
0679 
0680 /*
0681  * init
0682  */
0683 
0684 static void __init omap1_show_rates(void)
0685 {
0686     pr_notice("Clocking rate (xtal/DPLL1/MPU): %ld.%01ld/%ld.%01ld/%ld.%01ld MHz\n",
0687           ck_ref.rate / 1000000, (ck_ref.rate / 100000) % 10,
0688           ck_dpll1.rate / 1000000, (ck_dpll1.rate / 100000) % 10,
0689           arm_ck.rate / 1000000, (arm_ck.rate / 100000) % 10);
0690 }
0691 
0692 u32 cpu_mask;
0693 
0694 int __init omap1_clk_init(void)
0695 {
0696     struct omap_clk *c;
0697     u32 reg;
0698 
0699 #ifdef CONFIG_DEBUG_LL
0700     /* Make sure UART clocks are enabled early */
0701     if (cpu_is_omap16xx())
0702         omap_writel(omap_readl(MOD_CONF_CTRL_0) |
0703                 CONF_MOD_UART1_CLK_MODE_R |
0704                 CONF_MOD_UART3_CLK_MODE_R, MOD_CONF_CTRL_0);
0705 #endif
0706 
0707     /* USB_REQ_EN will be disabled later if necessary (usb_dc_ck) */
0708     reg = omap_readw(SOFT_REQ_REG) & (1 << 4);
0709     omap_writew(reg, SOFT_REQ_REG);
0710     if (!cpu_is_omap15xx())
0711         omap_writew(0, SOFT_REQ_REG2);
0712 
0713     /* By default all idlect1 clocks are allowed to idle */
0714     arm_idlect1_mask = ~0;
0715 
0716     cpu_mask = 0;
0717     if (cpu_is_omap1710())
0718         cpu_mask |= CK_1710;
0719     if (cpu_is_omap16xx())
0720         cpu_mask |= CK_16XX;
0721     if (cpu_is_omap1510())
0722         cpu_mask |= CK_1510;
0723     if (cpu_is_omap7xx())
0724         cpu_mask |= CK_7XX;
0725     if (cpu_is_omap310())
0726         cpu_mask |= CK_310;
0727 
0728     /* Pointers to these clocks are needed by code in clock.c */
0729     api_ck_p = &api_ck.clk;
0730     ck_dpll1_p = &ck_dpll1;
0731     ck_ref_p = &ck_ref;
0732 
0733     if (cpu_is_omap7xx())
0734         ck_ref.rate = 13000000;
0735 
0736     pr_info("Clocks: ARM_SYSST: 0x%04x DPLL_CTL: 0x%04x ARM_CKCTL: 0x%04x\n",
0737         omap_readw(ARM_SYSST), omap_readw(DPLL_CTL),
0738         omap_readw(ARM_CKCTL));
0739 
0740     /* We want to be in synchronous scalable mode */
0741     omap_writew(0x1000, ARM_SYSST);
0742 
0743 
0744     /*
0745      * Initially use the values set by bootloader. Determine PLL rate and
0746      * recalculate dependent clocks as if kernel had changed PLL or
0747      * divisors. See also omap1_clk_late_init() that can reprogram dpll1
0748      * after the SRAM is initialized.
0749      */
0750     {
0751         unsigned pll_ctl_val = omap_readw(DPLL_CTL);
0752 
0753         ck_dpll1.rate = ck_ref.rate; /* Base xtal rate */
0754         if (pll_ctl_val & 0x10) {
0755             /* PLL enabled, apply multiplier and divisor */
0756             if (pll_ctl_val & 0xf80)
0757                 ck_dpll1.rate *= (pll_ctl_val & 0xf80) >> 7;
0758             ck_dpll1.rate /= ((pll_ctl_val & 0x60) >> 5) + 1;
0759         } else {
0760             /* PLL disabled, apply bypass divisor */
0761             switch (pll_ctl_val & 0xc) {
0762             case 0:
0763                 break;
0764             case 0x4:
0765                 ck_dpll1.rate /= 2;
0766                 break;
0767             default:
0768                 ck_dpll1.rate /= 4;
0769                 break;
0770             }
0771         }
0772     }
0773 
0774     if (machine_is_omap_perseus2() || machine_is_omap_fsample()) {
0775         /* Select slicer output as OMAP input clock */
0776         omap_writew(omap_readw(OMAP7XX_PCC_UPLD_CTRL) & ~0x1,
0777                 OMAP7XX_PCC_UPLD_CTRL);
0778     }
0779 
0780     /* Amstrad Delta wants BCLK high when inactive */
0781     if (machine_is_ams_delta())
0782         omap_writel(omap_readl(ULPD_CLOCK_CTRL) |
0783                 (1 << SDW_MCLK_INV_BIT),
0784                 ULPD_CLOCK_CTRL);
0785 
0786     /* Turn off DSP and ARM_TIMXO. Make sure ARM_INTHCK is not divided */
0787     /* (on 730, bit 13 must not be cleared) */
0788     if (cpu_is_omap7xx())
0789         omap_writew(omap_readw(ARM_CKCTL) & 0x2fff, ARM_CKCTL);
0790     else
0791         omap_writew(omap_readw(ARM_CKCTL) & 0x0fff, ARM_CKCTL);
0792 
0793     /* Put DSP/MPUI into reset until needed */
0794     omap_writew(0, ARM_RSTCT1);
0795     omap_writew(1, ARM_RSTCT2);
0796     omap_writew(0x400, ARM_IDLECT1);
0797 
0798     /*
0799      * According to OMAP5910 Erratum SYS_DMA_1, bit DMACK_REQ (bit 8)
0800      * of the ARM_IDLECT2 register must be set to zero. The power-on
0801      * default value of this bit is one.
0802      */
0803     omap_writew(0x0000, ARM_IDLECT2);   /* Turn LCD clock off also */
0804 
0805     for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++) {
0806         if (!(c->cpu & cpu_mask))
0807             continue;
0808 
0809         if (c->lk.clk_hw->init) { /* NULL if provider already registered */
0810             const struct clk_init_data *init = c->lk.clk_hw->init;
0811             const char *name = c->lk.clk_hw->init->name;
0812             int err;
0813 
0814             err = clk_hw_register(NULL, c->lk.clk_hw);
0815             if (err < 0) {
0816                 pr_err("failed to register clock \"%s\"! (%d)\n", name, err);
0817                 /* may be tried again, restore init data */
0818                 c->lk.clk_hw->init = init;
0819                 continue;
0820             }
0821         }
0822 
0823         clk_hw_register_clkdev(c->lk.clk_hw, c->lk.con_id, c->lk.dev_id);
0824     }
0825 
0826     omap1_show_rates();
0827 
0828     return 0;
0829 }
0830 
0831 #define OMAP1_DPLL1_SANE_VALUE  60000000
0832 
0833 void __init omap1_clk_late_init(void)
0834 {
0835     unsigned long rate = ck_dpll1.rate;
0836 
0837     /* Find the highest supported frequency and enable it */
0838     if (omap1_select_table_rate(&virtual_ck_mpu, ~0, arm_ck.rate)) {
0839         pr_err("System frequencies not set, using default. Check your config.\n");
0840         /*
0841          * Reprogramming the DPLL is tricky, it must be done from SRAM.
0842          */
0843         omap_sram_reprogram_clock(0x2290, 0x0005);
0844         ck_dpll1.rate = OMAP1_DPLL1_SANE_VALUE;
0845     }
0846     propagate_rate(&ck_dpll1);
0847     omap1_show_rates();
0848     loops_per_jiffy = cpufreq_scale(loops_per_jiffy, rate, ck_dpll1.rate);
0849 }