2015-07-16 01:55:57 -07:00
/*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation version 2.
*/
# include <linux/kernel.h>
2016-02-26 09:35:05 -08:00
# include <linux/clk.h>
2015-07-16 01:55:57 -07:00
# include <linux/clk-provider.h>
# include <linux/clk/ti.h>
2016-02-26 09:35:05 -08:00
# include <linux/of_platform.h>
2017-08-24 15:41:37 +03:00
# include <dt-bindings/clock/dm814.h>
2015-07-16 01:55:57 -07:00
2015-07-27 14:11:17 +10:00
# include "clock.h"
2017-08-24 15:41:37 +03:00
static const struct omap_clkctrl_reg_data dm814_default_clkctrl_regs [ ] __initconst = {
{ DM814_USB_OTG_HS_CLKCTRL , NULL , CLKF_SW_SUP , " pll260dcoclkldo " } ,
{ 0 } ,
} ;
static const struct omap_clkctrl_reg_data dm814_alwon_clkctrl_regs [ ] __initconst = {
{ DM814_UART1_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk10_ck " } ,
{ DM814_UART2_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk10_ck " } ,
{ DM814_UART3_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk10_ck " } ,
{ DM814_GPIO1_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk6_ck " } ,
{ DM814_GPIO2_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk6_ck " } ,
{ DM814_I2C1_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk10_ck " } ,
{ DM814_I2C2_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk10_ck " } ,
{ DM814_WD_TIMER_CLKCTRL , NULL , CLKF_SW_SUP | CLKF_NO_IDLEST , " sysclk18_ck " } ,
{ DM814_MCSPI1_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk10_ck " } ,
{ DM814_GPMC_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk6_ck " } ,
{ DM814_CPGMAC0_CLKCTRL , NULL , CLKF_SW_SUP , " cpsw_125mhz_gclk " } ,
{ DM814_MPU_CLKCTRL , NULL , CLKF_SW_SUP , " mpu_ck " } ,
{ DM814_RTC_CLKCTRL , NULL , CLKF_SW_SUP | CLKF_NO_IDLEST , " sysclk18_ck " } ,
{ DM814_TPCC_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk4_ck " } ,
{ DM814_TPTC0_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk4_ck " } ,
{ DM814_TPTC1_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk4_ck " } ,
{ DM814_TPTC2_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk4_ck " } ,
{ DM814_TPTC3_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk4_ck " } ,
{ DM814_MMC1_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk8_ck " } ,
{ DM814_MMC2_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk8_ck " } ,
{ DM814_MMC3_CLKCTRL , NULL , CLKF_SW_SUP , " sysclk8_ck " } ,
{ 0 } ,
} ;
const struct omap_clkctrl_data dm814_clkctrl_data [ ] __initconst = {
{ 0x48180500 , dm814_default_clkctrl_regs } ,
{ 0x48181400 , dm814_alwon_clkctrl_regs } ,
{ 0 } ,
} ;
2015-07-16 01:55:57 -07:00
static struct ti_dt_clk dm814_clks [ ] = {
DT_CLK ( NULL , " timer_sys_ck " , " devosc_ck " ) ,
{ . node_name = NULL } ,
} ;
2016-02-26 09:35:05 -08:00
static bool timer_clocks_initialized ;
2016-03-01 10:51:42 -08:00
static int __init dm814x_adpll_early_init ( void )
2016-02-26 09:35:05 -08:00
{
struct device_node * np ;
if ( ! timer_clocks_initialized )
return - ENODEV ;
np = of_find_node_by_name ( NULL , " pllss " ) ;
if ( ! np ) {
pr_err ( " Could not find node for plls \n " ) ;
return - ENODEV ;
}
of_platform_populate ( np , NULL , NULL , NULL ) ;
return 0 ;
}
core_initcall ( dm814x_adpll_early_init ) ;
static const char * const init_clocks [ ] = {
" pll040clkout " , /* MPU 481c5040.adpll.clkout */
" pll290clkout " , /* DDR 481c5290.adpll.clkout */
} ;
2016-03-01 10:51:42 -08:00
static int __init dm814x_adpll_enable_init_clocks ( void )
2016-02-26 09:35:05 -08:00
{
int i , err ;
if ( ! timer_clocks_initialized )
return - ENODEV ;
for ( i = 0 ; i < ARRAY_SIZE ( init_clocks ) ; i + + ) {
struct clk * clock ;
clock = clk_get ( NULL , init_clocks [ i ] ) ;
if ( WARN ( IS_ERR ( clock ) , " could not find init clock %s \n " ,
init_clocks [ i ] ) )
continue ;
err = clk_prepare_enable ( clock ) ;
if ( WARN ( err , " could not enable init clock %s \n " ,
init_clocks [ i ] ) )
continue ;
}
return 0 ;
}
postcore_initcall ( dm814x_adpll_enable_init_clocks ) ;
2015-07-16 01:55:57 -07:00
int __init dm814x_dt_clk_init ( void )
{
ti_dt_clocks_register ( dm814_clks ) ;
omap2_clk_disable_autoidle_all ( ) ;
2017-08-24 15:29:36 +03:00
ti_clk_add_aliases ( ) ;
2015-07-16 01:55:57 -07:00
omap2_clk_enable_init_clocks ( NULL , 0 ) ;
2016-02-26 09:35:05 -08:00
timer_clocks_initialized = true ;
2015-07-16 01:55:57 -07:00
return 0 ;
}