Add support for Exynos clock output configuration
cover Add support for Exynos clock output configuration
On all Exynos SoCs there is a dedicated CLKOUT pin that allows many of internal SoC clocks to be output from the SoC. The hardware structure of CLKOUT related clocks looks as follows:
CMU |---> clock0 ---------> | PMU |
| | |
several |---> clock1 ---------> | mux |
muxes | | + |---> CLKOUT
dividers | ... | gate |
and gates | | |
|---> clockN ---------> | |Since the block responsible for handling the pin is PMU, not CMU, a separate driver, that binds to PMU node is required and acquires all input clocks by standard DT clock look-up. This way we don't need any cross-IP block drivers and cross-driver register sharing or nodes for fake devices.
To represent the PMU mux/gate clock, generic composite clock is registered.
Tested on Odroid U3, with HSIC/USB hub using CLKOUT as reference clock, with some additional patches.
Depends on:
[PATCHv4 0/4] Enable usbphy and hsotg for exynos4
(http://thread.gmane.org/gmane.linux.kernel.samsung-soc/30631)
for Exynos4210/4x12 PMU DT nodes.
Tomasz Figa (4):
clk: samsung: exynos4: Add missing DMC clock hierarchy
clk: samsung: exynos4: Add CLKOUT clock hierarchy
clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
ARM: dts: exynos: Update PMU node with CLKOUT related data
.../devicetree/bindings/arm/samsung/pmu.txt | 18 +++ arch/arm/boot/dts/exynos4210.dtsi | 10 ++ arch/arm/boot/dts/exynos4x12.dtsi | 7 + arch/arm/boot/dts/exynos5250.dtsi | 3 + arch/arm/boot/dts/exynos5420.dtsi | 3 + drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-exynos4.c | 156 +++++++++++++++++++++ drivers/clk/samsung/exynos-clkout.c | 107 ++++++++++++++ include/dt-bindings/clock/exynos4.h | 6 + 9 files changed, 311 insertions(+) create mode 100644 drivers/clk/samsung/exynos-clkout.c
Signature · 1 line
1.9.2
RFC PATCH 1/4 clk: samsung: exynos4: Add missing DMC clock hierarchy
This patch adds missing definitions of clocks from DMC clock domain, which are necessary to properly represent CLKOUT clock hierarchy added in further patch.
--- drivers/clk/samsung/clk-exynos4.c | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/clk/samsung/clk-exynos4.c +41 -0
@@ -397,10 +397,15 @@ PNAME(mout_audio2_p4210) = { "cdclk2", "none", "sclk_hdmi24m", "sclk_epll", "sclk_vpll", };PNAME (mout_mixer_p4210 ) = {"sclk_dac" ,"sclk_hdmi" , };PNAME (mout_dac_p4210) = {"sclk_vpll" ,"sclk_hdmiphy" , }; +PNAME (mout_pwi_p4210) = {"xxti" ,"xusbxti" ,"sclk_hdmi24m" ,"sclk_usbphy0" , +"sclk_usbphy1" ,"sclk_hdmiphy" ,"none" , +"sclk_epll" ,"sclk_vpll" };/* Exynos 4x12-specific parent groups */ PNAME (mout_mpll_user_p4x12) = {"fin_pll" ,"sclk_mpll" , };PNAME (mout_core_p4x12) = {"mout_apll" ,"mout_mpll_user_c" , }; +PNAME (mout_gdl_p4x12) = {"mout_mpll_user_l" ,"sclk_apll" , }; +PNAME (mout_gdr_p4x12) = {"mout_mpll_user_r" ,"sclk_apll" , };PNAME (sclk_ampll_p4x12) = {"mout_mpll_user_t" ,"sclk_apll" , };PNAME (group1_p4x12) = {"xxti" ,"xusbxti" ,"sclk_hdmi24m" ,"sclk_usbphy0" ,"none" ,"sclk_hdmiphy" ,"mout_mpll_user_t" ,
@@ -418,6 +423,9 @@ PNAME(aclk_p4412) = { "mout_mpll_user_t", "sclk_apll", };PNAME (mout_user_aclk400_mcuisp_p4x12) = {"fin_pll" ,"div_aclk400_mcuisp" , };PNAME (mout_user_aclk200_p4x12) = {"fin_pll" ,"div_aclk200" , };PNAME (mout_user_aclk266_gps_p4x12) = {"fin_pll" ,"div_aclk266_gps" , }; +PNAME (mout_pwi_p4x12) = {"xxti" ,"xusbxti" ,"sclk_hdmi24m" ,"sclk_usbphy0" , +"none" ,"sclk_hdmiphy" ,"sclk_mpll" , +"sclk_epll" ,"sclk_vpll" };/* fixed rate clocks generated outside the soc */ static struct samsung_fixed_rate_clock exynos4_fixed_rate_ext_clks[]__initdata = {
@@ -451,6 +459,9 @@ static struct samsung_mux_clock exynos4_mux_clks[] __initdata = {MUX (0 ,"mout_onenand1" , mout_onenand1_p,SRC_TOP0 ,0 ,1 ),MUX (CLK_SCLK_EPLL ,"sclk_epll" , mout_epll_p,SRC_TOP0 ,4 ,1 ),MUX (0 ,"mout_onenand" , mout_onenand_p,SRC_TOP0 ,28 ,1 ), + +MUX (0 ,"mout_dmc_bus" , sclk_ampll_p4210,SRC_DMC ,4 ,1 ), + MUX(0, "mout_dphy", sclk_ampll_p4210, SRC_DMC, 8, 1), };/* list of mux clocks supported in exynos4210 soc */
@@ -459,6 +470,10 @@ static struct samsung_mux_clock exynos4210_mux_early[] __initdata = { };static struct samsung_mux_clock exynos4210_mux_clks[]__initdata = { +MUX (0 ,"mout_gdl" , sclk_ampll_p4210,SRC_LEFTBUS ,0 ,1 ), + +MUX (0 ,"mout_gdr" , sclk_ampll_p4210,SRC_RIGHTBUS ,0 ,1 ), +MUX (0 ,"mout_aclk200" , sclk_ampll_p4210,SRC_TOP0 ,12 ,1 ),MUX (0 ,"mout_aclk100" , sclk_ampll_p4210,SRC_TOP0 ,16 ,1 ),MUX (0 ,"mout_aclk160" , sclk_ampll_p4210,SRC_TOP0 ,20 ,1 ),
@@ -503,10 +518,18 @@ static struct samsung_mux_clock exynos4210_mux_clks[] __initdata = {MUX (0 ,"mout_spi0" , group1_p4210,SRC_PERIL1 ,16 ,4 ),MUX (0 ,"mout_spi1" , group1_p4210,SRC_PERIL1 ,20 ,4 ),MUX (0 ,"mout_spi2" , group1_p4210,SRC_PERIL1 ,24 ,4 ), + + MUX(0, "mout_pwi", mout_pwi_p4210, SRC_DMC, 16, 4), };/* list of mux clocks supported in exynos4x12 soc */ static struct samsung_mux_clock exynos4x12_mux_clks[]__initdata = { +MUX (0 ,"mout_mpll_user_l" , mout_mpll_p,SRC_LEFTBUS ,4 ,1 ), +MUX (0 ,"mout_gdl" , mout_gdl_p4x12,SRC_LEFTBUS ,0 ,1 ), + +MUX (0 ,"mout_mpll_user_r" , mout_mpll_p,SRC_RIGHTBUS ,4 ,1 ), +MUX (0 ,"mout_gdr" , mout_gdr_p4x12,SRC_RIGHTBUS ,0 ,1 ), +MUX (CLK_MOUT_MPLL_USER_C ,"mout_mpll_user_c" , mout_mpll_user_p4x12,SRC_CPU ,24 ,1 ), MUX(0, "mout_aclk266_gps", aclk_p4412, SRC_TOP1, 4, 1),
@@ -565,6 +588,8 @@ static struct samsung_mux_clock exynos4x12_mux_clks[] __initdata = {MUX (0 ,"mout_spi0_isp" , group1_p4x12,E4X12_SRC_ISP ,4 ,4 ),MUX (0 ,"mout_spi1_isp" , group1_p4x12,E4X12_SRC_ISP ,8 ,4 ),MUX (0 ,"mout_uart_isp" , group1_p4x12,E4X12_SRC_ISP ,12 ,4 ), +MUX (0 ,"mout_c2c" , sclk_ampll_p4210,SRC_DMC ,0 ,1 ), +MUX (0 ,"mout_pwi" , mout_pwi_p4x12,SRC_DMC ,16 ,4 ),MUX (0 ,"mout_g2d0" , sclk_ampll_p4210,SRC_DMC ,20 ,1 ),MUX (0 ,"mout_g2d1" , sclk_evpll_p,SRC_DMC ,24 ,1 ), MUX(0, "mout_g2d", mout_g2d_p, SRC_DMC, 28, 1),
@@ -572,6 +597,12 @@ static struct samsung_mux_clock exynos4x12_mux_clks[] __initdata = {/* list of divider clocks supported in all exynos4 soc's */ static struct samsung_div_clock exynos4_div_clks[]__initdata = { +DIV (0 ,"div_gdl" ,"mout_gdl" ,DIV_LEFTBUS ,0 ,3 ), +DIV (0 ,"div_gpl" ,"div_gdl" ,DIV_LEFTBUS ,4 ,3 ), + +DIV (0 ,"div_gdr" ,"mout_gdr" ,DIV_RIGHTBUS ,0 ,3 ), +DIV (0 ,"div_gpr" ,"div_gdr" ,DIV_RIGHTBUS ,4 ,3 ), +DIV (0 ,"div_core" ,"mout_core" ,DIV_CPU0 ,0 ,3 ),DIV (0 ,"div_core2" ,"div_core" ,DIV_CPU0 ,28 ,3 ),DIV (0 ,"div_fimc0" ,"mout_fimc0" ,DIV_CAM ,0 ,4 ),
@@ -631,6 +662,14 @@ static struct samsung_div_clock exynos4_div_clks[] __initdata = { CLK_SET_RATE_PARENT, 0),DIV_F (0 ,"div_mmc_pre3" ,"div_mmc3" ,DIV_FSYS2 ,24 ,8 ,CLK_SET_RATE_PARENT ,0 ), + +DIV (0 ,"div_acp" ,"mout_dmc_bus" ,DIV_DMC0 ,0 ,3 ), +DIV (0 ,"div_acp_pclk" ,"div_acp" ,DIV_DMC0 ,4 ,3 ), +DIV (0 ,"div_dphy" ,"mout_dphy" ,DIV_DMC0 ,8 ,3 ), +DIV (0 ,"div_dmc" ,"mout_dmc_bus" ,DIV_DMC0 ,12 ,3 ), +DIV (0 ,"div_dmcd" ,"div_dmc" ,DIV_DMC0 ,16 ,3 ), +DIV (0 ,"div_dmcp" ,"div_dmcd" ,DIV_DMC0 ,20 ,3 ), + DIV(0, "div_pwi", "mout_pwi", DIV_DMC1, 8, 4), };/* list of divider clocks supported in exynos4210 soc */
@@ -671,6 +710,8 @@ static struct samsung_div_clock exynos4x12_div_clks[] __initdata = {DIV_F (CLK_DIV_MCUISP1 ,"div_mcuisp1" ,"div_mcuisp0" ,E4X12_DIV_ISP1 ,8 ,3 ,CLK_GET_RATE_NOCACHE ,0 ),DIV (CLK_SCLK_FIMG2D ,"sclk_fimg2d" ,"mout_g2d" ,DIV_DMC1 ,0 ,4 ), +DIV (0 ,"div_c2c" ,"mout_c2c" ,DIV_DMC1 ,4 ,3 ), + DIV(0, "div_c2c_aclk", "div_c2c", DIV_DMC1, 12, 3), };/* list of gate clocks supported in all exynos4 soc's */
Signature · 1 line
1.9.2
RFC PATCH 2/4 clk: samsung: exynos4: Add CLKOUT clock hierarchy
In reply to Tomasz FigaThis patch adds definitions of clocks that are used to drive clock output signals of particular CMU sub-blocks that are then fed to PMU and handled by Exynos CLKOUT driver added in further patch.
--- drivers/clk/samsung/clk-exynos4.c | 115 ++++++++++++++++++++++++++++++++++++ include/dt-bindings/clock/exynos4.h | 6 ++ 2 files changed, 121 insertions(+)
drivers/clk/samsung/clk-exynos4.c +115 -0
@@ -25,10 +25,12 @@#define DIV_LEFTBUS 0x4500#define GATE_IP_LEFTBUS 0x4800#define E4X12_GATE_IP_IMAGE 0x4930 +#define CLKOUT_CMU_LEFTBUS 0x4a00#define SRC_RIGHTBUS 0x8200#define DIV_RIGHTBUS 0x8500#define GATE_IP_RIGHTBUS 0x8800#define E4X12_GATE_IP_PERIR 0x8960 +#define CLKOUT_CMU_RIGHTBUS 0x8a00#define EPLL_LOCK 0xc010#define VPLL_LOCK 0xc020#define EPLL_CON0 0xc110
@@ -98,6 +100,7 @@#define GATE_IP_PERIL 0xc950#define E4210_GATE_IP_PERIR 0xc960#define GATE_BLOCK 0xc970 +#define CLKOUT_CMU_TOP 0xca00#define E4X12_MPLL_LOCK 0x10008#define E4X12_MPLL_CON0 0x10108#define SRC_DMC 0x10200
@@ -105,6 +108,7 @@#define DIV_DMC0 0x10500#define DIV_DMC1 0x10504#define GATE_IP_DMC 0x10900 +#define CLKOUT_CMU_DMC 0x10a00#define APLL_LOCK 0x14000#define E4210_MPLL_LOCK 0x14008#define APLL_CON0 0x14100
@@ -114,10 +118,12 @@#define DIV_CPU1 0x14504#define GATE_SCLK_CPU 0x14800#define GATE_IP_CPU 0x14900 +#define CLKOUT_CMU_CPU 0x14a00#define E4X12_DIV_ISP0 0x18300#define E4X12_DIV_ISP1 0x18304#define E4X12_GATE_ISP0 0x18800#define E4X12_GATE_ISP1 0x18804 +#define E4X12_CLKOUT_CMU_ISP 0x18a00/* the exynos4 soc type */ enum exynos4_soc {
@@ -400,6 +406,23 @@ PNAME(mout_dac_p4210) = { "sclk_vpll", "sclk_hdmiphy", };PNAME (mout_pwi_p4210) = {"xxti" ,"xusbxti" ,"sclk_hdmi24m" ,"sclk_usbphy0" ,"sclk_usbphy1" ,"sclk_hdmiphy" ,"none" ,"sclk_epll" ,"sclk_vpll" }; +PNAME (clkout_left_p4210) = {"sclk_mpll_div_2" ,"sclk_apll_div_2" , +"div_gdl" ,"div_gpl" }; +PNAME (clkout_right_p4210) = {"sclk_mpll_div_2" ,"sclk_apll_div_2" , +"div_gdr" ,"div_gpr" }; +PNAME (clkout_top_p4210) = {"fout_epll" ,"fout_vpll" ,"sclk_hdmi24m" , +"sclk_usbphy0" ,"sclk_usbphy1" ,"sclk_hdmiphy" , +"cdclk0" ,"cdclk1" ,"cdclk2" ,"spdif_extclk" , +"aclk160" ,"aclk133" ,"aclk200" ,"aclk100" , +"sclk_mfc" ,"sclk_g3d" ,"sclk_g2d" , +"cam_a_pclk" ,"cam_b_pclk" ,"s_rxbyteclkhs0_2l" , +"s_rxbyteclkhs0_4l" }; +PNAME (clkout_dmc_p4210) = {"div_dmcd" ,"div_dmcp" ,"div_acp_pclk" ,"div_dmc" , +"div_dphy" ,"none" ,"div_pwi" }; +PNAME (clkout_cpu_p4210) = {"fout_apll_div_2" ,"none" ,"fout_mpll_div_2" , +"none" ,"arm_clk_div_2" ,"div_corem0" , +"div_corem1" ,"div_corem0" ,"div_atb" , +"div_periph" ,"div_pclk_dbg" ,"div_hpm" };/* Exynos 4x12-specific parent groups */ PNAME (mout_mpll_user_p4x12) = {"fin_pll" ,"sclk_mpll" , };
@@ -426,6 +449,31 @@ PNAME(mout_user_aclk266_gps_p4x12) = {"fin_pll", "div_aclk266_gps", };PNAME (mout_pwi_p4x12) = {"xxti" ,"xusbxti" ,"sclk_hdmi24m" ,"sclk_usbphy0" ,"none" ,"sclk_hdmiphy" ,"sclk_mpll" ,"sclk_epll" ,"sclk_vpll" }; +PNAME (clkout_left_p4x12) = {"sclk_mpll_user_l_div_2" ,"sclk_apll_div_2" , +"div_gdl" ,"div_gpl" }; +PNAME (clkout_right_p4x12) = {"sclk_mpll_user_r_div_2" ,"sclk_apll_div_2" , +"div_gdr" ,"div_gpr" }; +PNAME (clkout_top_p4x12) = {"fout_epll" ,"fout_vpll" ,"sclk_hdmi24m" , +"sclk_usbphy0" ,"none" ,"sclk_hdmiphy" , +"cdclk0" ,"cdclk1" ,"cdclk2" ,"spdif_extclk" , +"aclk160" ,"aclk133" ,"aclk200" ,"aclk100" , +"sclk_mfc" ,"sclk_g3d" ,"aclk400_mcuisp" , +"cam_a_pclk" ,"cam_b_pclk" ,"s_rxbyteclkhs0_2l" , +"s_rxbyteclkhs0_4l" ,"rx_half_byte_clk_csis0" , +"rx_half_byte_clk_csis1" ,"div_jpeg" , +"sclk_pwm_isp" ,"sclk_spi0_isp" , +"sclk_spi1_isp" ,"sclk_uart_isp" , +"sclk_mipihsi" ,"sclk_hdmi" ,"sclk_fimd0" , +"sclk_pcm0" }; +PNAME (clkout_dmc_p4x12) = {"div_dmcd" ,"div_dmcp" ,"aclk_acp" ,"div_acp_pclk" , +"div_dmc" ,"div_dphy" ,"fout_mpll_div_2" , +"div_pwi" ,"none" ,"div_c2c" ,"div_c2c_aclk" }; +PNAME (clkout_cpu_p4x12) = {"fout_apll_div_2" ,"none" ,"none" ,"none" , +"arm_clk_div_2" ,"div_corem0" ,"div_corem1" , +"div_cores" ,"div_atb" ,"div_periph" , +"div_pclk_dbg" ,"div_hpm" }; +PNAME (clkout_isp_p4x12) = {"aclk400_mcuisp" ,"div_mcuisp1" ,"div_isp0" , +"div_isp1" ,"div_mpwm" };/* fixed rate clocks generated outside the soc */ static struct samsung_fixed_rate_clock exynos4_fixed_rate_ext_clks[]__initdata = {
@@ -444,6 +492,24 @@ static struct samsung_fixed_rate_clock exynos4210_fixed_rate_clks[] __initdata = FRATE(0, "sclk_usbphy1", NULL, CLK_IS_ROOT, 48000000), }; +static struct samsung_fixed_factor_clock exynos4_fixed_factor_clks[]__initdata = { +FFACTOR (0 ,"sclk_apll_div_2" ,"sclk_apll" ,1 ,2 ,0 ), +FFACTOR (0 ,"fout_mpll_div_2" ,"fout_mpll" ,1 ,2 ,0 ), +FFACTOR (0 ,"fout_apll_div_2" ,"fout_apll" ,1 ,2 ,0 ), +FFACTOR (0 ,"arm_clk_div_2" ,"arm_clk" ,1 ,2 ,0 ), +}; + +static struct samsung_fixed_factor_clock exynos4210_fixed_factor_clks[]__initdata = { +FFACTOR (0 ,"sclk_mpll_div_2" ,"sclk_mpll" ,1 ,2 ,0 ), +}; + +static struct samsung_fixed_factor_clock exynos4x12_fixed_factor_clks[]__initdata = { +FFACTOR (0 ,"sclk_mpll_user_l_div_2" ,"mout_mpll_user_l" ,1 ,2 ,0 ), +FFACTOR (0 ,"sclk_mpll_user_r_div_2" ,"mout_mpll_user_r" ,1 ,2 ,0 ), +FFACTOR (0 ,"sclk_mpll_user_t_div_2" ,"mout_mpll_user_t" ,1 ,2 ,0 ), +FFACTOR (0 ,"sclk_mpll_user_c_div_2" ,"mout_mpll_user_c" ,1 ,2 ,0 ), +}; +/* list of mux clocks supported in all exynos4 soc's */ static struct samsung_mux_clock exynos4_mux_clks[]__initdata = { MUX_FA(CLK_MOUT_APLL, "mout_apll", mout_apll_p, SRC_CPU, 0, 1,
@@ -471,8 +537,12 @@ static struct samsung_mux_clock exynos4210_mux_early[] __initdata = {static struct samsung_mux_clock exynos4210_mux_clks[]__initdata = {MUX (0 ,"mout_gdl" , sclk_ampll_p4210,SRC_LEFTBUS ,0 ,1 ), +MUX (0 ,"mout_clkout_leftbus" , clkout_left_p4210, +CLKOUT_CMU_LEFTBUS ,0 ,5 ),MUX (0 ,"mout_gdr" , sclk_ampll_p4210,SRC_RIGHTBUS ,0 ,1 ), +MUX (0 ,"mout_clkout_rightbus" , clkout_right_p4210, +CLKOUT_CMU_RIGHTBUS ,0 ,5 ),MUX (0 ,"mout_aclk200" , sclk_ampll_p4210,SRC_TOP0 ,12 ,1 ),MUX (0 ,"mout_aclk100" , sclk_ampll_p4210,SRC_TOP0 ,16 ,1 ),
@@ -518,20 +588,30 @@ static struct samsung_mux_clock exynos4210_mux_clks[] __initdata = { MUX(0, "mout_spi0", group1_p4210, SRC_PERIL1, 16, 4), MUX(0, "mout_spi1", group1_p4210, SRC_PERIL1, 20, 4), MUX(0, "mout_spi2", group1_p4210, SRC_PERIL1, 24, 4), + MUX(0, "mout_clkout_top", clkout_top_p4210, CLKOUT_CMU_TOP, 0, 5), MUX(0, "mout_pwi", mout_pwi_p4210, SRC_DMC, 16, 4), + MUX(0, "mout_clkout_dmc", clkout_dmc_p4210, CLKOUT_CMU_DMC, 0, 5), + + MUX(0, "mout_clkout_cpu", clkout_cpu_p4210, CLKOUT_CMU_CPU, 0, 5), };/* list of mux clocks supported in exynos4x12 soc */ static struct samsung_mux_clock exynos4x12_mux_clks[]__initdata = {MUX (0 ,"mout_mpll_user_l" , mout_mpll_p,SRC_LEFTBUS ,4 ,1 ),MUX (0 ,"mout_gdl" , mout_gdl_p4x12,SRC_LEFTBUS ,0 ,1 ), +MUX (0 ,"mout_clkout_leftbus" , clkout_left_p4x12, +CLKOUT_CMU_LEFTBUS ,0 ,5 ),MUX (0 ,"mout_mpll_user_r" , mout_mpll_p,SRC_RIGHTBUS ,4 ,1 ),MUX (0 ,"mout_gdr" , mout_gdr_p4x12,SRC_RIGHTBUS ,0 ,1 ), +MUX (0 ,"mout_clkout_rightbus" , clkout_right_p4x12, +CLKOUT_CMU_RIGHTBUS ,0 ,5 ),MUX (CLK_MOUT_MPLL_USER_C ,"mout_mpll_user_c" , mout_mpll_user_p4x12,SRC_CPU ,24 ,1 ), +MUX (0 ,"mout_clkout_cpu" , clkout_cpu_p4x12,CLKOUT_CMU_CPU ,0 ,5 ), +MUX (0 ,"mout_aclk266_gps" , aclk_p4412,SRC_TOP1 ,4 ,1 ),MUX (0 ,"mout_aclk400_mcuisp" , aclk_p4412,SRC_TOP1 ,8 ,1 ), MUX(CLK_MOUT_MPLL_USER_T, "mout_mpll_user_t", mout_mpll_user_p4x12,
@@ -584,27 +664,38 @@ static struct samsung_mux_clock exynos4x12_mux_clks[] __initdata = {MUX (0 ,"mout_spi0" , group1_p4x12,SRC_PERIL1 ,16 ,4 ),MUX (0 ,"mout_spi1" , group1_p4x12,SRC_PERIL1 ,20 ,4 ),MUX (0 ,"mout_spi2" , group1_p4x12,SRC_PERIL1 ,24 ,4 ), +MUX (0 ,"mout_clkout_top" , clkout_top_p4x12,CLKOUT_CMU_TOP ,0 ,5 ), +MUX (0 ,"mout_pwm_isp" , group1_p4x12,E4X12_SRC_ISP ,0 ,4 ),MUX (0 ,"mout_spi0_isp" , group1_p4x12,E4X12_SRC_ISP ,4 ,4 ),MUX (0 ,"mout_spi1_isp" , group1_p4x12,E4X12_SRC_ISP ,8 ,4 ),MUX (0 ,"mout_uart_isp" , group1_p4x12,E4X12_SRC_ISP ,12 ,4 ), +MUX (0 ,"mout_clkout_isp" , clkout_isp_p4x12,E4X12_CLKOUT_CMU_ISP ,0 ,5 ), +MUX (0 ,"mout_c2c" , sclk_ampll_p4210,SRC_DMC ,0 ,1 ),MUX (0 ,"mout_pwi" , mout_pwi_p4x12,SRC_DMC ,16 ,4 ),MUX (0 ,"mout_g2d0" , sclk_ampll_p4210,SRC_DMC ,20 ,1 ),MUX (0 ,"mout_g2d1" , sclk_evpll_p,SRC_DMC ,24 ,1 ),MUX (0 ,"mout_g2d" , mout_g2d_p,SRC_DMC ,28 ,1 ), + MUX(0, "mout_clkout_dmc", clkout_dmc_p4x12, CLKOUT_CMU_DMC, 0, 5), };/* list of divider clocks supported in all exynos4 soc's */ static struct samsung_div_clock exynos4_div_clks[]__initdata = {DIV (0 ,"div_gdl" ,"mout_gdl" ,DIV_LEFTBUS ,0 ,3 ),DIV (0 ,"div_gpl" ,"div_gdl" ,DIV_LEFTBUS ,4 ,3 ), +DIV (0 ,"div_clkout_leftbus" ,"mout_clkout_leftbus" , +CLKOUT_CMU_LEFTBUS ,8 ,6 ),DIV (0 ,"div_gdr" ,"mout_gdr" ,DIV_RIGHTBUS ,0 ,3 ),DIV (0 ,"div_gpr" ,"div_gdr" ,DIV_RIGHTBUS ,4 ,3 ), +DIV (0 ,"div_clkout_rightbus" ,"mout_clkout_rightbus" , +CLKOUT_CMU_RIGHTBUS ,8 ,6 ),DIV (0 ,"div_core" ,"mout_core" ,DIV_CPU0 ,0 ,3 ),DIV (0 ,"div_core2" ,"div_core" ,DIV_CPU0 ,28 ,3 ), +DIV (0 ,"div_clkout_cpu" ,"mout_clkout_cpu" ,CLKOUT_CMU_CPU ,8 ,6 ), +DIV (0 ,"div_fimc0" ,"mout_fimc0" ,DIV_CAM ,0 ,4 ),DIV (0 ,"div_fimc1" ,"mout_fimc1" ,DIV_CAM ,4 ,4 ), DIV(0, "div_fimc2", "mout_fimc2", DIV_CAM, 8, 4),
@@ -662,6 +753,7 @@ static struct samsung_div_clock exynos4_div_clks[] __initdata = { CLK_SET_RATE_PARENT, 0),DIV_F (0 ,"div_mmc_pre3" ,"div_mmc3" ,DIV_FSYS2 ,24 ,8 ,CLK_SET_RATE_PARENT ,0 ), +DIV (0 ,"div_clkout_top" ,"mout_clkout_top" ,CLKOUT_CMU_TOP ,8 ,6 ),DIV (0 ,"div_acp" ,"mout_dmc_bus" ,DIV_DMC0 ,0 ,3 ), DIV(0, "div_acp_pclk", "div_acp", DIV_DMC0, 4, 3),
@@ -670,6 +762,7 @@ static struct samsung_div_clock exynos4_div_clks[] __initdata = {DIV (0 ,"div_dmcd" ,"div_dmc" ,DIV_DMC0 ,16 ,3 ),DIV (0 ,"div_dmcp" ,"div_dmcd" ,DIV_DMC0 ,20 ,3 ),DIV (0 ,"div_pwi" ,"mout_pwi" ,DIV_DMC1 ,8 ,4 ), + DIV(0, "div_clkout_dmc", "mout_clkout_dmc", CLKOUT_CMU_DMC, 8, 6), };/* list of divider clocks supported in exynos4210 soc */
@@ -709,6 +802,8 @@ static struct samsung_div_clock exynos4x12_div_clks[] __initdata = { 4, 3, CLK_GET_RATE_NOCACHE, 0),DIV_F (CLK_DIV_MCUISP1 ,"div_mcuisp1" ,"div_mcuisp0" ,E4X12_DIV_ISP1 ,8 ,3 ,CLK_GET_RATE_NOCACHE ,0 ), +DIV (0 ,"div_clkout_isp" ,"mout_clkout_isp" ,E4X12_CLKOUT_CMU_ISP ,8 ,6 ), +DIV (CLK_SCLK_FIMG2D ,"sclk_fimg2d" ,"mout_g2d" ,DIV_DMC1 ,0 ,4 ),DIV (0 ,"div_c2c" ,"mout_c2c" ,DIV_DMC1 ,4 ,3 ), DIV(0, "div_c2c_aclk", "div_c2c", DIV_DMC1, 12, 3),
@@ -893,6 +988,17 @@ static struct samsung_gate_clock exynos4_gate_clks[] __initdata = { 0, 0),GATE (CLK_AC97 ,"ac97" ,"aclk100" ,GATE_IP_PERIL ,27 ,0 ,0 ), + +GATE (CLK_OUT_LEFTBUS ,"clkout_leftbus" ,"div_clkout_leftbus" , +CLKOUT_CMU_LEFTBUS ,16 ,0 ,0 ), +GATE (CLK_OUT_RIGHTBUS ,"clkout_rightbus" ,"div_clkout_rightbus" , +CLKOUT_CMU_RIGHTBUS ,16 ,0 ,0 ), +GATE (CLK_OUT_TOP ,"clkout_top" ,"div_clkout_top" , +CLKOUT_CMU_TOP ,16 ,0 ,0 ), +GATE (CLK_OUT_DMC ,"clkout_dmc" ,"div_clkout_dmc" , +CLKOUT_CMU_DMC ,16 ,0 ,0 ), +GATE (CLK_OUT_CPU ,"clkout_cpu" ,"div_clkout_cpu" , + CLKOUT_CMU_CPU, 16, 0, 0), };/* list of gate clocks supported in exynos4210 soc */
@@ -1042,6 +1148,9 @@ static struct samsung_gate_clock exynos4x12_gate_clks[] __initdata = {GATE (CLK_G2D ,"g2d" ,"aclk200" ,GATE_IP_DMC ,23 ,0 ,0 ),GATE (CLK_TMU_APBIF ,"tmu_apbif" ,"aclk100" ,E4X12_GATE_IP_PERIR ,17 ,0 ,0 ), + +GATE (CLK_OUT_ISP ,"clkout_isp" ,"div_clkout_isp" , + E4X12_CLKOUT_CMU_ISP, 16, 0, 0), }; static struct samsung_clock_alias exynos4_aliases[] __initdata = {
@@ -1270,6 +1379,8 @@ static void __init exynos4_clk_init(struct device_node *np, ARRAY_SIZE(exynos4_div_clks));samsung_clk_register_gate (exynos4_gate_clks,ARRAY_SIZE (exynos4_gate_clks)); +samsung_clk_register_fixed_factor (exynos4_fixed_factor_clks, +ARRAY_SIZE (exynos4_fixed_factor_clks));if (exynos4_soc ==EXYNOS4210 ) { samsung_clk_register_fixed_rate(exynos4210_fixed_rate_clks,
@@ -1282,6 +1393,8 @@ static void __init exynos4_clk_init(struct device_node *np, ARRAY_SIZE(exynos4210_gate_clks));samsung_clk_register_alias (exynos4210_aliases,ARRAY_SIZE (exynos4210_aliases)); +samsung_clk_register_fixed_factor (exynos4210_fixed_factor_clks, +ARRAY_SIZE (exynos4210_fixed_factor_clks)); }else {samsung_clk_register_mux (exynos4x12_mux_clks,ARRAY_SIZE (exynos4x12_mux_clks));
@@ -1291,6 +1404,8 @@ static void __init exynos4_clk_init(struct device_node *np, ARRAY_SIZE(exynos4x12_gate_clks));samsung_clk_register_alias (exynos4x12_aliases,ARRAY_SIZE (exynos4x12_aliases)); +samsung_clk_register_fixed_factor (exynos4x12_fixed_factor_clks, +ARRAY_SIZE (exynos4x12_fixed_factor_clks)); } samsung_clk_register_alias(exynos4_aliases,
include/dt-bindings/clock/exynos4.h +6 -0
@@ -33,6 +33,12 @@#define CLK_MOUT_MPLL_USER_C 18/* Exynos4x12 only */ #define CLK_MOUT_CORE 19#define CLK_MOUT_APLL 20 +#define CLK_OUT_DMC 21 +#define CLK_OUT_TOP 22 +#define CLK_OUT_LEFTBUS 23 +#define CLK_OUT_RIGHTBUS 24 +#define CLK_OUT_CPU 25 +#define CLK_OUT_ISP 26/* gate for special clocks (sclk) */ #define CLK_SCLK_FIMC0 128
Signature · 1 line
1.9.2
RFC PATCH 3/4 clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
In reply to Tomasz FigaThis patch introduces a driver that handles configuration of CLKOUT pin of Exynos SoCs that can be used to output certain clocks from inside of the SoC to a dedicated output pin.
--- .../devicetree/bindings/arm/samsung/pmu.txt | 18 ++++ drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/exynos-clkout.c | 107 +++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 drivers/clk/samsung/exynos-clkout.c
Documentation/devicetree/bindings/arm/samsung/pmu.txt +18 -0
@@ -11,8 +11,26 @@ Properties: - reg : offset and length of the register set. + - #clock-cells : must be zero. + + - clock-names : list of clock names for particular CLKOUT mux inputs in + following format: + "clkoutN", where N is a decimal number corresponding to + CLKOUT mux control bits value for given input, e.g. + "clkout0", "clkout7", "clkout15". + + - clocks : list of phandles and specifiers to all input clocks listed in + clock-names property. + Example : pmu_system_controller: system-controller at 10040000 { compatible = "samsung,exynos5250-pmu", "syscon"; reg = <0x10040000 0x5000>; + #clock-cells = <0>; + clock-names = "clkout0", "clkout1", "clkout2", "clkout3", + "clkout4", "clkout8", "clkout9"; + clocks = <&clock CLK_OUT_DMC>, <&clock CLK_OUT_TOP>, + <&clock CLK_OUT_LEFTBUS>, <&clock CLK_OUT_RIGHTBUS>, + <&clock CLK_OUT_CPU>, <&clock CLK_XXTI>, + <&clock CLK_XUSBXTI>; };
drivers/clk/samsung/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o +obj-$(CONFIG_ARCH_EXYNOS) += exynos-clkout.o obj-$(CONFIG_S3C2410_COMMON_CLK)+= clk-s3c2410.o obj-$(CONFIG_S3C2410_COMMON_DCLK)+= clk-s3c2410-dclk.o obj-$(CONFIG_S3C2412_COMMON_CLK)+= clk-s3c2412.o
drivers/clk/samsung/exynos-clkout.c new file +107 -0
107 lines not on this page · raw message
Signature · 1 line
1.9.2
RFC PATCH 4/4 ARM: dts: exynos: Update PMU node with CLKOUT related data
In reply to Tomasz FigaThis patch extends nodes of PMU system controller on Exynos4210, 4x12, 5250 and 5420 SoCs with newly defined properties used by Exynos CLKOUT driver.
--- arch/arm/boot/dts/exynos4210.dtsi | 10 ++++++++++ arch/arm/boot/dts/exynos4x12.dtsi | 7 +++++++ arch/arm/boot/dts/exynos5250.dtsi | 3 +++ arch/arm/boot/dts/exynos5420.dtsi | 3 +++ 4 files changed, 23 insertions(+)
arch/arm/boot/dts/exynos4210.dtsi +10 -0
@@ -31,6 +31,16 @@ pinctrl2 = &pinctrl_2; }; + pmu_system_controller: system-controller at 10020000 { + #clock-cells = <0>; + clock-names = "clkout0", "clkout1", "clkout2", "clkout3", + "clkout4", "clkout8", "clkout9"; + clocks = <&clock CLK_OUT_DMC>, <&clock CLK_OUT_TOP>, + <&clock CLK_OUT_LEFTBUS>, <&clock CLK_OUT_RIGHTBUS>, + <&clock CLK_OUT_CPU>, <&clock CLK_XXTI>, + <&clock CLK_XUSBXTI>; + }; + sysram at 02020000 { compatible = "mmio-sysram"; reg = <0x02020000 0x20000>;
arch/arm/boot/dts/exynos4x12.dtsi +7 -0
@@ -139,6 +139,13 @@ pmu_system_controller: system-controller at 10020000 { compatible = "samsung,exynos4x12-pmu", "syscon"; + #clock-cells = <0>; + clock-names = "clkout0", "clkout1", "clkout2", "clkout3", + "clkout4", "clkout5", "clkout8", "clkout9"; + clocks = <&clock CLK_OUT_DMC>, <&clock CLK_OUT_TOP>, + <&clock CLK_OUT_LEFTBUS>, <&clock CLK_OUT_RIGHTBUS>, + <&clock CLK_OUT_CPU>, <&clock CLK_OUT_ISP>, + <&clock CLK_XXTI>, <&clock CLK_XUSBXTI>; }; g2d at 10800000 {
arch/arm/boot/dts/exynos5250.dtsi +3 -0
@@ -191,6 +191,9 @@ pmu_system_controller: system-controller at 10040000 { compatible = "samsung,exynos5250-pmu", "syscon"; reg = <0x10040000 0x5000>; + #clock-cells = <0>; + clock-names = "clkout16"; + clocks = <&clock CLK_FIN_PLL>; }; watchdog at 101D0000 {
arch/arm/boot/dts/exynos5420.dtsi +3 -0
@@ -698,6 +698,9 @@ pmu_system_controller: system-controller at 10040000 { compatible = "samsung,exynos5420-pmu", "syscon"; reg = <0x10040000 0x5000>; + #clock-cells = <0>; + clock-names = "clkout16"; + clocks = <&clock CLK_FIN_PLL>; }; tmu_cpu0: tmu at 10060000 {
Signature · 1 line
1.9.2
Re: [PATCH RFC 3/4] clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
In reply to Tomasz Figa[snip]
Quoted 4 lines
drivers/clk/samsung/exynos-clkout.c new file +4
-0+ gate->lock = &clkout_lock; + + mux->reg = reg +EXYNOS_PMU_DEBUG_REG ; + mux->mask =EXYNOS_CLKOUT_MUX_MASK ;
drivers/clk/samsung/exynos-clkout.c line 86
Quoted 10 lines
drivers/clk/samsung/exynos-clkout.c new file +10
-0+ mux->shift =EXYNOS_CLKOUT_MUX_SHIFT ; + mux->lock = &clkout_lock; + + clk =clk_register_composite (NULL ,"clkout" , parent_names, + parent_count, &mux->hw, + &clk_mux_ops,NULL ,NULL , &gate->hw, + &clk_gate_ops,0 ); +if (IS_ERR (clk)) + goto err_unmap; +
Hi Tomasz,
Do we really need a composite clock here? How about registering a mux and a gate separately?
Regards,
Rahul Sharma.
Quoted 29 lines
drivers/clk/samsung/exynos-clkout.c new file +21
-1+of_clk_add_provider (node, of_clk_src_simple_get, clk); + +return ; + +err_unmap: +iounmap (reg); +clks_put: +for (i =0 ; i <EXYNOS_CLKOUT_PARENTS ; ++i) +if (!IS_ERR (parents[i])) +clk_put (parents[i]); +free_gate: +kfree (gate); +free_mux: +kfree (mux); + +pr_err ("%s: failed to register clkout clock\n" , __func__); +} +CLK_OF_DECLARE (exynos4210_clkout,"samsung,exynos4210-pmu" , exynos_clkout_init); +CLK_OF_DECLARE (exynos4412_clkout,"samsung,exynos4x12-pmu" , exynos_clkout_init); +CLK_OF_DECLARE (exynos5250_clkout,"samsung,exynos5250-pmu" , exynos_clkout_init); +CLK_OF_DECLARE (exynos5420_clkout,"samsung,exynos5420-pmu" , exynos_clkout_init); --1.9.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH RFC 3/4] clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
Hi Rahul,
Quoted 18 lines · Rahul Sharma
[snip]
Quoted 4 lines
drivers/clk/samsung/exynos-clkout.c new file +4
-0+ gate->lock = &clkout_lock; + + mux->reg = reg +EXYNOS_PMU_DEBUG_REG ; + mux->mask =EXYNOS_CLKOUT_MUX_MASK ;drivers/clk/samsung/exynos-clkout.c line 86
Quoted 10 lines
drivers/clk/samsung/exynos-clkout.c new file +10
-0+ mux->shift =EXYNOS_CLKOUT_MUX_SHIFT ; + mux->lock = &clkout_lock; + + clk =clk_register_composite (NULL ,"clkout" , parent_names, + parent_count, &mux->hw, + &clk_mux_ops,NULL ,NULL , &gate->hw, + &clk_gate_ops,0 ); +if (IS_ERR (clk)) + goto err_unmap; +Hi Tomasz,
Quoted 2 lines
Do we really need a composite clock here? How about registering a mux and a gate separately?
What's wrong with a composite clock? It simplifies the code as just a single clock needs to be registered. I don't see any drawbacks compared to registering two clocks separately.
Best regards,
Tomasz
Re: [PATCH RFC 3/4] clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
Quoted 21 lines · Tomasz Figa
Hi Rahul,
Quoted 18 lines · Rahul Sharma
[snip]
Quoted 4 lines
drivers/clk/samsung/exynos-clkout.c new file +4
-0+ gate->lock = &clkout_lock; + + mux->reg = reg +EXYNOS_PMU_DEBUG_REG ; + mux->mask =EXYNOS_CLKOUT_MUX_MASK ;drivers/clk/samsung/exynos-clkout.c line 86
Quoted 10 lines
drivers/clk/samsung/exynos-clkout.c new file +10
-0+ mux->shift =EXYNOS_CLKOUT_MUX_SHIFT ; + mux->lock = &clkout_lock; + + clk =clk_register_composite (NULL ,"clkout" , parent_names, + parent_count, &mux->hw, + &clk_mux_ops,NULL ,NULL , &gate->hw, + &clk_gate_ops,0 ); +if (IS_ERR (clk)) + goto err_unmap; +Hi Tomasz,
Quoted 7 lines
Quoted 2 lines
Do we really need a composite clock here? How about registering a mux and a gate separately?
What's wrong with a composite clock? It simplifies the code as just a single clock needs to be registered. I don't see any drawbacks compared to registering two clocks separately.
I always took it as a thumb rule to not to use composite clocks if you can easily represent the block using basic clocks structures.
There can be a problem when drivers using such clocks assume that such clock continue to offer composite functionality for all futures SoCs and write code around it. This is what we faced when fixing drivers during CCF migration.
Quoted 7 lines
Best regards,
Tomasz_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH RFC 3/4] clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
Quoted 30 lines · Rahul Sharma
Quoted 21 lines · Tomasz Figa
Hi Rahul,
Quoted 18 lines · Rahul Sharma
[snip]
Quoted 4 lines
drivers/clk/samsung/exynos-clkout.c new file +4
-0+ gate->lock = &clkout_lock; + + mux->reg = reg +EXYNOS_PMU_DEBUG_REG ; + mux->mask =EXYNOS_CLKOUT_MUX_MASK ;drivers/clk/samsung/exynos-clkout.c line 86
Quoted 10 lines
drivers/clk/samsung/exynos-clkout.c new file +10
-0+ mux->shift =EXYNOS_CLKOUT_MUX_SHIFT ; + mux->lock = &clkout_lock; + + clk =clk_register_composite (NULL ,"clkout" , parent_names, + parent_count, &mux->hw, + &clk_mux_ops,NULL ,NULL , &gate->hw, + &clk_gate_ops,0 ); +if (IS_ERR (clk)) + goto err_unmap; +Hi Tomasz,
Quoted 7 lines
Quoted 2 lines
Do we really need a composite clock here? How about registering a mux and a gate separately?
What's wrong with a composite clock? It simplifies the code as just a single clock needs to be registered. I don't see any drawbacks compared to registering two clocks separately.
Quoted 7 lines
I always took it as a thumb rule to not to use composite clocks if you can easily represent the block using basic clocks structures.
There can be a problem when drivers using such clocks assume that such clock continue to offer composite functionality for all futures SoCs and write code around it. This is what we faced when fixing drivers during CCF migration.
The drivers using CLKOUT need to be designed this way, because they are not Exynos-specific, such as drivers for HSIC hubs or audio codecs. They can't have any Exynos-specific knowledge about clock hierarchy.
So regardless of whether this is implemented using the composite clock or not, consumer device drivers need to be able to use just a single clock to do whatever they need, e.g. gating or rate configuration.
However I can see one problem here with my implementation - it is missing the CLK_SET_RATE_PARENT flag, so dividers of particular CLK_OUTs from CMU blocks could be reconfigured.
Also the driver is missing save and restore of PMU_DEBUG register.
I will fix both in next version.
Best regards,
Tomasz
Re: [PATCH RFC 3/4] clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
In reply to Tomasz FigaQuoting Tomasz Figa (2014-05-15 10:32:30)
Quoted 5 lines
This patch introduces a driver that handles configuration of CLKOUT pin of Exynos SoCs that can be used to output certain clocks from inside of the SoC to a dedicated output pin.
Signed-off-by Tomasz Figa <[email protected]>
Overall implementation looks good to me. Nice solution for exposing these pins to external ICs.
Regards,
Mike
Quoted 166 lines
--- .../devicetree/bindings/arm/samsung/pmu.txt | 18 ++++ drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/exynos-clkout.c | 107 +++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 drivers/clk/samsung/exynos-clkout.cDocumentation/devicetree/bindings/arm/samsung/pmu.txt +18
-0@@ -11,8 +11,26 @@ Properties: - reg : offset and length of the register set. + - #clock-cells : must be zero. + + - clock-names : list of clock names for particular CLKOUT mux inputs in + following format: + "clkoutN", where N is a decimal number corresponding to + CLKOUT mux control bits value for given input, e.g. + "clkout0", "clkout7", "clkout15". + + - clocks : list of phandles and specifiers to all input clocks listed in + clock-names property. + Example : pmu_system_controller: system-controller at 10040000 { compatible = "samsung,exynos5250-pmu", "syscon"; reg = <0x10040000 0x5000>; + #clock-cells = <0>; + clock-names = "clkout0", "clkout1", "clkout2", "clkout3", + "clkout4", "clkout8", "clkout9"; + clocks = <&clock CLK_OUT_DMC>, <&clock CLK_OUT_TOP>, + <&clock CLK_OUT_LEFTBUS>, <&clock CLK_OUT_RIGHTBUS>, + <&clock CLK_OUT_CPU>, <&clock CLK_XXTI>, + <&clock CLK_XUSBXTI>; };drivers/clk/samsung/Makefile +1
-0@@ -8,6 +8,7 @@ obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o +obj-$(CONFIG_ARCH_EXYNOS) += exynos-clkout.o obj-$(CONFIG_S3C2410_COMMON_CLK)+= clk-s3c2410.o obj-$(CONFIG_S3C2410_COMMON_DCLK)+= clk-s3c2410-dclk.o obj-$(CONFIG_S3C2412_COMMON_CLK)+= clk-s3c2412.odrivers/clk/samsung/exynos-clkout.c new file +107
-0@@ -0,0 +1,107 @@ +/* +* Copyright (c) 2014 Samsung Electronics Co., Ltd. +* Author: Tomasz Figa <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* Clock driver for Exynos clock output +*/ + +#include <linux/clk.h> +#include <linux/clkdev.h> +#include <linux/clk-provider.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/syscore_ops.h> + +#define EXYNOS_CLKOUT_PARENTS 32 + +#define EXYNOS_PMU_DEBUG_REG 0xa00 +#define EXYNOS_CLKOUT_DISABLE_SHIFT 0 +#define EXYNOS_CLKOUT_MUX_SHIFT 8 +#define EXYNOS_CLKOUT_MUX_MASK 0x1f + +static DEFINE_SPINLOCK (clkout_lock); + +static void __init exynos_clkout_init (struct device_node *node) +{ +const char *parent_names[EXYNOS_CLKOUT_PARENTS ]; +struct clk *parents[EXYNOS_CLKOUT_PARENTS ]; +struct clk_gate *gate; +struct clk_mux *mux; +int parent_count; +struct clk *clk; +void *reg; +int i; + +/* allocate mux and gate clock structs */ + mux =kzalloc (sizeof (struct clk_mux ),GFP_KERNEL ); +if (!mux) +return ; + + gate =kzalloc (sizeof (struct clk_gate ),GFP_KERNEL ); +if (!gate) + goto free_mux; + + parent_count =0 ; +for (i =0 ; i <EXYNOS_CLKOUT_PARENTS ; ++i) { +char name[] ="clkoutXX" ; + +snprintf (name,sizeof (name),"clkout%d" , i); + parents[i] =of_clk_get_by_name (node, name); +if (IS_ERR (parents[i])) { + parent_names[i] ="none" ; +continue ; + } + + parent_names[i] =__clk_get_name (parents[i]); + parent_count = i +1 ; + } + +if (!parent_count) + goto free_gate; + + reg =of_iomap (node,0 ); +if (!reg) + goto clks_put; + + gate->reg = reg +EXYNOS_PMU_DEBUG_REG ; + gate->bit_idx =EXYNOS_CLKOUT_DISABLE_SHIFT ; + gate->flags =CLK_GATE_SET_TO_DISABLE ; + gate->lock = &clkout_lock; + + mux->reg = reg +EXYNOS_PMU_DEBUG_REG ; + mux->mask =EXYNOS_CLKOUT_MUX_MASK ; + mux->shift =EXYNOS_CLKOUT_MUX_SHIFT ; + mux->lock = &clkout_lock; + + clk =clk_register_composite (NULL ,"clkout" , parent_names, + parent_count, &mux->hw, + &clk_mux_ops,NULL ,NULL , &gate->hw, + &clk_gate_ops,0 ); +if (IS_ERR (clk)) + goto err_unmap; + +of_clk_add_provider (node, of_clk_src_simple_get, clk); + +return ; + +err_unmap: +iounmap (reg); +clks_put: +for (i =0 ; i <EXYNOS_CLKOUT_PARENTS ; ++i) +if (!IS_ERR (parents[i])) +clk_put (parents[i]); +free_gate: +kfree (gate); +free_mux: +kfree (mux); + +pr_err ("%s: failed to register clkout clock\n" , __func__); +} +CLK_OF_DECLARE (exynos4210_clkout,"samsung,exynos4210-pmu" , exynos_clkout_init); +CLK_OF_DECLARE (exynos4412_clkout,"samsung,exynos4x12-pmu" , exynos_clkout_init); +CLK_OF_DECLARE (exynos5250_clkout,"samsung,exynos5250-pmu" , exynos_clkout_init); +CLK_OF_DECLARE (exynos5420_clkout,"samsung,exynos5420-pmu" , exynos_clkout_init);Signature · 1 line
1.9.2
Re: [PATCH RFC 3/4] clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
In reply to Tomasz FigaQuoted 6 lines · Tomasz Figa
This patch introduces a driver that handles configuration of CLKOUT pin of Exynos SoCs that can be used to output certain clocks from inside of the SoC to a dedicated output pin.
Signed-off-by Tomasz Figa <[email protected]>---
Tested the series on Exynos5420-based peach-pit board for audio playback (with an internal patch to set CLK_FIN_PLL as the parent of clkout).
Documentation/devicetree/bindings/arm/samsung/pmu.txt Properties: · line 36
Quoted 12 lines
Example :
pmu_system_controller: system-controller at 10040000 {Documentation/devicetree/bindings/arm/samsung/pmu.txt +7
-0compatible = "samsung,exynos5250-pmu", "syscon"; reg = <0x10040000 0x5000>; + #clock-cells = <0>; + clock-names = "clkout0", "clkout1", "clkout2", "clkout3", + "clkout4", "clkout8", "clkout9"; + clocks = <&clock CLK_OUT_DMC>, <&clock CLK_OUT_TOP>, + <&clock CLK_OUT_LEFTBUS>, <&clock CLK_OUT_RIGHTBUS>, + <&clock CLK_OUT_CPU>, <&clock CLK_XXTI>, + <&clock CLK_XUSBXTI>; };
Adding an usage example in the documentation would be helpful.
Signature · 1 line
Tushar Behera
Re: [PATCH RFC 3/4] clk: samsung: Add driver to control CLKOUT line on Exynos SoCs
Hi Tushar,
Quoted 5 lines · Tushar Behera
Quoted 4 lines · Tomasz Figa
This patch introduces a driver that handles configuration of CLKOUT pin of Exynos SoCs that can be used to output certain clocks from inside of the SoC to a dedicated output pin.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Tomasz Figa <[email protected]>---
Tested the series on Exynos5420-based peach-pit board for audio playback (with an internal patch to set
CLK_FIN_PLLas the parent of clkout).Tested-by Tushar Behera <[email protected]>
Thank you for testing.
Quoted 6 lines
Quoted 6 lines
Example :
pmu_system_controller: system-controller at 10040000 {Documentation/devicetree/bindings/arm/samsung/pmu.txt +2
-0compatible = "samsung,exynos5250-pmu", "syscon"; reg = <0x10040000 0x5000>; + #clock-cells = <0>; + clock-names = "clkout0", "clkout1", "clkout2", "clkout3",
Quoted 8 lines
Documentation/devicetree/bindings/arm/samsung/pmu.txt Properties: · line 36
Quoted 6 lines
Documentation/devicetree/bindings/arm/samsung/pmu.txt +5
-0+ "clkout4", "clkout8", "clkout9"; + clocks = <&clock CLK_OUT_DMC>, <&clock CLK_OUT_TOP>, + <&clock CLK_OUT_LEFTBUS>, <&clock CLK_OUT_RIGHTBUS>, + <&clock CLK_OUT_CPU>, <&clock CLK_XXTI>, + <&clock CLK_XUSBXTI>; };Adding an usage example in the documentation would be helpful.
Right, that's usually a good idea, I don't know why I haven't added one. Thanks.
Best regards,
Tomasz