Samsung clock updates v2
Subsystems (3)
Re-based on tree submitted to RMK, so there where some fixups that had to be done. This has only been compile test and thus needs testing. If someone else can test and send me a tested-by:
line for any of the patches in this series then please let me know.
PATCH v2 1/1 ] ARM: S3C64XX: Fixup .reg_src and .reg_div with named initialisers
Change these two fields to have named initialisers as per the review comments from Kyungmin Park.
sed used:
s@\.reg_src\(.*\)=\(.*\){\(.*\),\(.*\),\(.*\)}@.reg_src\1=\2{ .reg =\3, .shift =\4, .size =\5 }@g
--- arch/arm/plat-s3c64xx/s3c6400-clock.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-)
arch/arm/plat-s3c64xx/s3c6400-clock.c +14 -14
@@ -68,7 +68,7 @@ static struct clksrc_clk clk_mout_apll = { .name = "mout_apll", .id = -1, }, - .reg_src = { S3C_CLK_SRC, 0, 1 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 0, .size = 1 }, .sources = &clk_src_apll, };
@@ -92,7 +92,7 @@ static struct clksrc_clk clk_mout_epll = { .name = "mout_epll", .id = -1, }, - .reg_src = { S3C_CLK_SRC, 2, 1 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 2, .size = 1 }, .sources = &clk_src_epll, };
@@ -111,7 +111,7 @@ static struct clksrc_clk clk_mout_mpll = { .name = "mout_mpll", .id = -1, }, - .reg_src = { S3C_CLK_SRC, 1, 1 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 1, .size = 1 }, .sources = &clk_src_mpll, };
@@ -317,7 +317,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_MMC0, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 18, 2 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 18, .size = 2 }, .reg_div = { S3C_CLK_DIV1, 0, 4 }, .sources = &clkset_spi_mmc, }, {
@@ -327,7 +327,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_MMC1, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 20, 2 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 20, .size = 2 }, .reg_div = { S3C_CLK_DIV1, 4, 4 }, .sources = &clkset_spi_mmc, }, {
@@ -337,7 +337,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_MMC2, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 22, 2 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 22, .size = 2 }, .reg_div = { S3C_CLK_DIV1, 8, 4 }, .sources = &clkset_spi_mmc, }, {
@@ -347,7 +347,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_UHOST, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 5, 2 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 5, .size = 2 }, .reg_div = { S3C_CLK_DIV1, 20, 4 }, .sources = &clkset_uhost, }, {
@@ -357,7 +357,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_UART, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 13, 1 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 13, .size = 1 }, .reg_div = { S3C_CLK_DIV2, 16, 4 }, .sources = &clkset_uart, }, {
@@ -368,7 +368,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_SPI0, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 14, 2 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 14, .size = 2 }, .reg_div = { S3C_CLK_DIV2, 0, 4 }, .sources = &clkset_spi_mmc, }, {
@@ -378,7 +378,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_SPI1, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 16, 2 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 16, .size = 2 }, .reg_div = { S3C_CLK_DIV2, 4, 4 }, .sources = &clkset_spi_mmc, }, {
@@ -388,7 +388,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_AUDIO0, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 7, 3 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 7, .size = 3 }, .reg_div = { S3C_CLK_DIV2, 8, 4 }, .sources = &clkset_audio0, }, {
@@ -398,7 +398,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_AUDIO1, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 10, 3 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 10, .size = 3 }, .reg_div = { S3C_CLK_DIV2, 12, 4 }, .sources = &clkset_audio1, }, {
@@ -408,7 +408,7 @@ static struct clksrc_clk clksrcs[] = { .ctrlbit = S3C_CLKCON_SCLK_IRDA, .enable = s3c64xx_sclk_ctrl, }, - .reg_src = { S3C_CLK_SRC, 24, 2 }, + .reg_src = { .reg = S3C_CLK_SRC, .shift = 24, .size = 2 }, .reg_div = { S3C_CLK_DIV2, 20, 4 }, .sources = &clkset_irda, }, {
@@ -419,7 +419,7 @@ static struct clksrc_clk clksrcs[] = { .enable = s3c64xx_sclk_ctrl, }, .reg_div = { S3C_CLK_DIV0, 20, 4 }, - .reg_src = { NULL, 0, 0 }, + .reg_src = { .reg = NULL, .shift = 0, .size = 0 }, .sources = &clkset_camif, }, };
Signature · 1 line
1.5.6.5
PATCH v2 1/1 ] ARM: S3C64XX: Compress s3c6400-clock.c code
In reply to Ben DooksThe individually named clocks are all static to the code and thus can be compressed into a single array and then the array can be referenced. This removes the need for a seperate array of pointers to clocks.
Fix a minor problem of re-initialising the pointers in s3c6400_set_clksrc() as this is also called by the cpufreq code. Move these initialisations to the code that does the registration.
Based on Harald Welte's original clock changes patch.
--- arch/arm/plat-s3c64xx/s3c6400-clock.c | 334 +++++++++++++++------------------ 1 files changed, 154 insertions(+), 180 deletions(-)
arch/arm/plat-s3c64xx/s3c6400-clock.c +154 -180
@@ -259,7 +259,6 @@ static struct clk_sources clkset_uhost = { .nr_sources = ARRAY_SIZE(clkset_uhost_list), }; -/* The peripheral clocks are all controlled via clocksource followed * by an optional divider and gate stage. We currently roll this into * one clock which hides the intermediate clock from the mux.
@@ -358,105 +357,7 @@ static unsigned long s3c64xx_roundrate_clksrc(struct clk *clk,return rate; } -static struct clksrc_clk clk_mmc0 = { - .clk = { - .name ="mmc_bus" , - .id =0 , - .ctrlbit =S3C_CLKCON_SCLK_MMC0 , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_MMC0_SHIFT , - .mask =S3C6400_CLKSRC_MMC0_MASK , - .sources = &clkset_spi_mmc, - .divider_shift =S3C6400_CLKDIV1_MMC0_SHIFT , - .reg_divider =S3C_CLK_DIV1 , -}; - -static struct clksrc_clk clk_mmc1 = { - .clk = { - .name ="mmc_bus" , - .id =1 , - .ctrlbit =S3C_CLKCON_SCLK_MMC1 , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_MMC1_SHIFT , - .mask =S3C6400_CLKSRC_MMC1_MASK , - .sources = &clkset_spi_mmc, - .divider_shift =S3C6400_CLKDIV1_MMC1_SHIFT , - .reg_divider =S3C_CLK_DIV1 , -}; - -static struct clksrc_clk clk_mmc2 = { - .clk = { - .name ="mmc_bus" , - .id =2 , - .ctrlbit =S3C_CLKCON_SCLK_MMC2 , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_MMC2_SHIFT , - .mask =S3C6400_CLKSRC_MMC2_MASK , - .sources = &clkset_spi_mmc, - .divider_shift =S3C6400_CLKDIV1_MMC2_SHIFT , - .reg_divider =S3C_CLK_DIV1 , -}; - -static struct clksrc_clk clk_usbhost = { - .clk = { - .name ="usb-bus-host" , - .id =-1 , - .ctrlbit =S3C_CLKCON_SCLK_UHOST , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_UHOST_SHIFT , - .mask =S3C6400_CLKSRC_UHOST_MASK , - .sources = &clkset_uhost, - .divider_shift =S3C6400_CLKDIV1_UHOST_SHIFT , - .reg_divider =S3C_CLK_DIV1 , -}; - -static struct clksrc_clk clk_uart_uclk1 = { - .clk = { - .name ="uclk1" , - .id =-1 , - .ctrlbit =S3C_CLKCON_SCLK_UART , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_UART_SHIFT , - .mask =S3C6400_CLKSRC_UART_MASK , - .sources = &clkset_uart, - .divider_shift =S3C6400_CLKDIV2_UART_SHIFT , - .reg_divider =S3C_CLK_DIV2 , -}; - -/* Where does UCLK0 come from? */ - -static struct clksrc_clk clk_spi0 = { - .clk = { - .name ="spi-bus" , - .id =0 , - .ctrlbit =S3C_CLKCON_SCLK_SPI0 , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_SPI0_SHIFT , - .mask =S3C6400_CLKSRC_SPI0_MASK , - .sources = &clkset_spi_mmc, - .divider_shift =S3C6400_CLKDIV2_SPI0_SHIFT , - .reg_divider =S3C_CLK_DIV2 , -}; - -static struct clksrc_clk clk_spi1 = { - .clk = { - .name ="spi-bus" , - .id =1 , - .ctrlbit =S3C_CLKCON_SCLK_SPI1 , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_SPI1_SHIFT , - .mask =S3C6400_CLKSRC_SPI1_MASK , - .sources = &clkset_spi_mmc, - .divider_shift =S3C6400_CLKDIV2_SPI1_SHIFT , - .reg_divider =S3C_CLK_DIV2 , -}; +/* clocks that feed other parts of the clock source tree */ static struct clk clk_iis_cd0 = { .name ="iis_cdclk0" ,
@@ -486,20 +387,6 @@ static struct clk_sources clkset_audio0 = { .nr_sources = ARRAY_SIZE(clkset_audio0_list), }; -static struct clksrc_clk clk_audio0 = { - .clk = { - .name ="audio-bus" , - .id =0 , - .ctrlbit =S3C_CLKCON_SCLK_AUDIO0 , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_AUDIO0_SHIFT , - .mask =S3C6400_CLKSRC_AUDIO0_MASK , - .sources = &clkset_audio0, - .divider_shift =S3C6400_CLKDIV2_AUDIO0_SHIFT , - .reg_divider =S3C_CLK_DIV2 , -}; -static struct clk *clkset_audio1_list[] = { [0 ] = &clk_mout_epll.clk, [1 ] = &clk_dout_mpll,
@@ -513,34 +400,6 @@ static struct clk_sources clkset_audio1 = { .nr_sources = ARRAY_SIZE(clkset_audio1_list), }; -static struct clksrc_clk clk_audio1 = { - .clk = { - .name ="audio-bus" , - .id =1 , - .ctrlbit =S3C_CLKCON_SCLK_AUDIO1 , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_AUDIO1_SHIFT , - .mask =S3C6400_CLKSRC_AUDIO1_MASK , - .sources = &clkset_audio1, - .divider_shift =S3C6400_CLKDIV2_AUDIO1_SHIFT , - .reg_divider =S3C_CLK_DIV2 , -}; - -static struct clksrc_clk clk_irda = { - .clk = { - .name ="irda-bus" , - .id =0 , - .ctrlbit =S3C_CLKCON_SCLK_IRDA , - .enable = s3c64xx_sclk_ctrl, - }, - .shift =S3C6400_CLKSRC_IRDA_SHIFT , - .mask =S3C6400_CLKSRC_IRDA_MASK , - .sources = &clkset_irda, - .divider_shift =S3C6400_CLKDIV2_IRDA_SHIFT , - .reg_divider =S3C_CLK_DIV2 , -}; -static struct clk *clkset_camif_list[] = { &clk_h2, };
@@ -550,18 +409,141 @@ static struct clk_sources clkset_camif = { .nr_sources = ARRAY_SIZE(clkset_camif_list), }; -static struct clksrc_clk clk_camif = { - .clk = { - .name ="camera" , - .id =-1 , - .ctrlbit =S3C_CLKCON_SCLK_CAM , - .enable = s3c64xx_sclk_ctrl, +static struct clksrc_clk clksrcs[] = { + { + .clk = { + .name ="mmc_bus" , + .id =0 , + .ctrlbit =S3C_CLKCON_SCLK_MMC0 , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_MMC0_SHIFT , + .mask =S3C6400_CLKSRC_MMC0_MASK , + .sources = &clkset_spi_mmc, + .divider_shift =S3C6400_CLKDIV1_MMC0_SHIFT , + .reg_divider =S3C_CLK_DIV1 , + }, { + .clk = { + .name ="mmc_bus" , + .id =1 , + .ctrlbit =S3C_CLKCON_SCLK_MMC1 , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_MMC1_SHIFT , + .mask =S3C6400_CLKSRC_MMC1_MASK , + .sources = &clkset_spi_mmc, + .divider_shift =S3C6400_CLKDIV1_MMC1_SHIFT , + .reg_divider =S3C_CLK_DIV1 , + }, { + .clk = { + .name ="mmc_bus" , + .id =2 , + .ctrlbit =S3C_CLKCON_SCLK_MMC2 , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_MMC2_SHIFT , + .mask =S3C6400_CLKSRC_MMC2_MASK , + .sources = &clkset_spi_mmc, + .divider_shift =S3C6400_CLKDIV1_MMC2_SHIFT , + .reg_divider =S3C_CLK_DIV1 , + }, { + .clk = { + .name ="usb-bus-host" , + .id =-1 , + .ctrlbit =S3C_CLKCON_SCLK_UHOST , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_UHOST_SHIFT , + .mask =S3C6400_CLKSRC_UHOST_MASK , + .sources = &clkset_uhost, + .divider_shift =S3C6400_CLKDIV1_UHOST_SHIFT , + .reg_divider =S3C_CLK_DIV1 , + }, { + .clk = { + .name ="uclk1" , + .id =-1 , + .ctrlbit =S3C_CLKCON_SCLK_UART , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_UART_SHIFT , + .mask =S3C6400_CLKSRC_UART_MASK , + .sources = &clkset_uart, + .divider_shift =S3C6400_CLKDIV2_UART_SHIFT , + .reg_divider =S3C_CLK_DIV2 , + }, { +/* Where does UCLK0 come from? */ + .clk = { + .name ="spi-bus" , + .id =0 , + .ctrlbit =S3C_CLKCON_SCLK_SPI0 , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_SPI0_SHIFT , + .mask =S3C6400_CLKSRC_SPI0_MASK , + .sources = &clkset_spi_mmc, + .divider_shift =S3C6400_CLKDIV2_SPI0_SHIFT , + .reg_divider =S3C_CLK_DIV2 , + }, { + .clk = { + .name ="spi-bus" , + .id =1 , + .ctrlbit =S3C_CLKCON_SCLK_SPI1 , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_SPI1_SHIFT , + .mask =S3C6400_CLKSRC_SPI1_MASK , + .sources = &clkset_spi_mmc, + .divider_shift =S3C6400_CLKDIV2_SPI1_SHIFT , + .reg_divider =S3C_CLK_DIV2 , + }, { + .clk = { + .name ="audio-bus" , + .id =0 , + .ctrlbit =S3C_CLKCON_SCLK_AUDIO0 , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_AUDIO0_SHIFT , + .mask =S3C6400_CLKSRC_AUDIO0_MASK , + .sources = &clkset_audio0, + .divider_shift =S3C6400_CLKDIV2_AUDIO0_SHIFT , + .reg_divider =S3C_CLK_DIV2 , + }, { + .clk = { + .name ="audio-bus" , + .id =1 , + .ctrlbit =S3C_CLKCON_SCLK_AUDIO1 , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_AUDIO1_SHIFT , + .mask =S3C6400_CLKSRC_AUDIO1_MASK , + .sources = &clkset_audio1, + .divider_shift =S3C6400_CLKDIV2_AUDIO1_SHIFT , + .reg_divider =S3C_CLK_DIV2 , + }, { + .clk = { + .name ="irda-bus" , + .id =0 , + .ctrlbit =S3C_CLKCON_SCLK_IRDA , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =S3C6400_CLKSRC_IRDA_SHIFT , + .mask =S3C6400_CLKSRC_IRDA_MASK , + .sources = &clkset_irda, + .divider_shift =S3C6400_CLKDIV2_IRDA_SHIFT , + .reg_divider =S3C_CLK_DIV2 , + }, { + .clk = { + .name ="camera" , + .id =-1 , + .ctrlbit =S3C_CLKCON_SCLK_CAM , + .enable = s3c64xx_sclk_ctrl, + }, + .shift =0 , + .mask =0 , + .sources = &clkset_camif, + .divider_shift =S3C6400_CLKDIV0_CAM_SHIFT , + .reg_divider =S3C_CLK_DIV0 , }, - .shift =0 , - .mask =0 , - .sources = &clkset_camif, - .divider_shift =S3C6400_CLKDIV0_CAM_SHIFT , - .reg_divider =S3C_CLK_DIV0 , };/* Clock initialisation code */
@@ -570,17 +552,6 @@ static struct clksrc_clk *init_parents[] = { &clk_mout_apll, &clk_mout_epll, &clk_mout_mpll, - &clk_mmc0, - &clk_mmc1, - &clk_mmc2, - &clk_usbhost, - &clk_uart_uclk1, - &clk_spi0, - &clk_spi1, - &clk_audio0, - &clk_audio1, - &clk_irda, - &clk_camif, }; static void __init_or_cpufreq s3c6400_set_clksrc(struct clksrc_clk *clk)
@@ -597,11 +568,6 @@ static void __init_or_cpufreq s3c6400_set_clksrc(struct clksrc_clk *clk)return ; } - clk->clk.get_rate = s3c64xx_getrate_clksrc; - clk->clk.set_rate = s3c64xx_setrate_clksrc; - clk->clk.set_parent = s3c64xx_setparent_clksrc; - clk->clk.round_rate = s3c64xx_roundrate_clksrc; - clk->clk.parent = srcs->sources[clksrc]; printk(KERN_INFO "%s: source is %s (%d), rate is %ld\n",
@@ -668,6 +634,9 @@ void __init_or_cpufreq s3c6400_setup_clocks(void)for (ptr =0 ; ptr <ARRAY_SIZE (init_parents); ptr++)s3c6400_set_clksrc (init_parents[ptr]); + +for (ptr =0 ; ptr <ARRAY_SIZE (clksrcs); ptr++) +s3c6400_set_clksrc (&clksrcs[ptr]); }static struct clk *clks[]__initdata = {
@@ -679,17 +648,6 @@ static struct clk *clks[] __initdata = { &clk_fout_epll, &clk_mout_mpll.clk, &clk_dout_mpll, - &clk_mmc0.clk, - &clk_mmc1.clk, - &clk_mmc2.clk, - &clk_usbhost.clk, - &clk_uart_uclk1.clk, - &clk_spi0.clk, - &clk_spi1.clk, - &clk_audio0.clk, - &clk_audio1.clk, - &clk_irda.clk, - &clk_camif.clk, &clk_arm, };
@@ -722,6 +680,22 @@ void __init s3c6400_register_clocks(unsigned armclk_divlimit) } } +for (ptr =0 ; ptr <ARRAY_SIZE (clksrcs); ptr++) { + clkp = &clksrcs[ptr].clk; + +/* all clksrc clocks have these */ + clkp->get_rate = s3c64xx_getrate_clksrc; + clkp->set_rate = s3c64xx_setrate_clksrc; + clkp->set_parent = s3c64xx_setparent_clksrc; + clkp->round_rate = s3c64xx_roundrate_clksrc; + + ret =s3c24xx_register_clock (clkp); +if (ret <0 ) { +printk (KERN_ERR "Failed to register clock %s (%d)\n" , + clkp->name, ret); + } + } + clk_mpll.parent = &clk_mout_mpll.clk; clk_epll.parent = &clk_mout_epll.clk; }
Signature · 1 line
1.5.6.5
PATCH v2 1/1 ] ARM: S3C64XX: Use new clock-clksrc.c code for clocks.
In reply to Ben DooksMove the s3c6400-clock.c implementation over to use the new common plat-samsung based clock-clksrc.c.
Note, this does not delete the clocks definitions that are now unused in the regs-clock.h to reduce the quantity of change in this commit.
Based on original patches by Harald Welte.
--- arch/arm/plat-s3c64xx/Kconfig | 1 + arch/arm/plat-s3c64xx/s3c6400-clock.c | 241 ++++++--------------------------- 2 files changed, 40 insertions(+), 202 deletions(-)
arch/arm/plat-s3c64xx/Kconfig +1 -0
@@ -15,6 +15,7 @@ config PLAT_S3C64XX select ARM_VIC select NO_IOPORT select ARCH_REQUIRE_GPIOLIB + select SAMSUNG_CLKSRC select S3C_GPIO_TRACK select S3C_GPIO_PULL_UPDOWN select S3C_GPIO_CFG_S3C24XX
arch/arm/plat-s3c64xx/s3c6400-clock.c +39 -202
434 lines not on this page · raw message
Signature · 1 line
1.5.6.5
PATCH v2 1/1 ] ARM: S3C64XX: Remove unused clock definitions from clock header
In reply to Ben DooksFrom: Harald Welte <[email protected]>
Clean out the definitions we are no longer using after the new clock code updates.
--- arch/arm/plat-s3c64xx/include/plat/regs-clock.h | 71 +---------------------- 1 files changed, 1 insertions(+), 70 deletions(-)
arch/arm/plat-s3c64xx/include/plat/regs-clock.h +1 -70
@@ -35,14 +35,6 @@#define S3C_MEM0_GATE S3C_CLKREG(0x3C)/* CLKDIV0 */ -#define S3C6400_CLKDIV0_MFC_MASK (0xf << 28) -#define S3C6400_CLKDIV0_MFC_SHIFT (28) -#define S3C6400_CLKDIV0_JPEG_MASK (0xf << 24) -#define S3C6400_CLKDIV0_JPEG_SHIFT (24) -#define S3C6400_CLKDIV0_CAM_MASK (0xf << 20) -#define S3C6400_CLKDIV0_CAM_SHIFT (20) -#define S3C6400_CLKDIV0_SECURITY_MASK (0x3 << 18) -#define S3C6400_CLKDIV0_SECURITY_SHIFT (18)#define S3C6400_CLKDIV0_PCLK_MASK (0xf << 12)#define S3C6400_CLKDIV0_PCLK_SHIFT (12)#define S3C6400_CLKDIV0_HCLK2_MASK (0x7 << 9)
@@ -51,42 +43,11 @@#define S3C6400_CLKDIV0_HCLK_SHIFT (8)#define S3C6400_CLKDIV0_MPLL_MASK (0x1 << 4)#define S3C6400_CLKDIV0_MPLL_SHIFT (4) +#define S3C6400_CLKDIV0_ARM_MASK (0x7 << 0)#define S3C6410_CLKDIV0_ARM_MASK (0xf << 0)#define S3C6400_CLKDIV0_ARM_SHIFT (0) -/* CLKDIV1 */ -#define S3C6410_CLKDIV1_FIMC_MASK (0xf << 24) -#define S3C6410_CLKDIV1_FIMC_SHIFT (24) -#define S3C6400_CLKDIV1_UHOST_MASK (0xf << 20) -#define S3C6400_CLKDIV1_UHOST_SHIFT (20) -#define S3C6400_CLKDIV1_SCALER_MASK (0xf << 16) -#define S3C6400_CLKDIV1_SCALER_SHIFT (16) -#define S3C6400_CLKDIV1_LCD_MASK (0xf << 12) -#define S3C6400_CLKDIV1_LCD_SHIFT (12) -#define S3C6400_CLKDIV1_MMC2_MASK (0xf << 8) -#define S3C6400_CLKDIV1_MMC2_SHIFT (8) -#define S3C6400_CLKDIV1_MMC1_MASK (0xf << 4) -#define S3C6400_CLKDIV1_MMC1_SHIFT (4) -#define S3C6400_CLKDIV1_MMC0_MASK (0xf << 0) -#define S3C6400_CLKDIV1_MMC0_SHIFT (0) - -/* CLKDIV2 */ -#define S3C6410_CLKDIV2_AUDIO2_MASK (0xf << 24) -#define S3C6410_CLKDIV2_AUDIO2_SHIFT (24) -#define S3C6400_CLKDIV2_IRDA_MASK (0xf << 20) -#define S3C6400_CLKDIV2_IRDA_SHIFT (20) -#define S3C6400_CLKDIV2_UART_MASK (0xf << 16) -#define S3C6400_CLKDIV2_UART_SHIFT (16) -#define S3C6400_CLKDIV2_AUDIO1_MASK (0xf << 12) -#define S3C6400_CLKDIV2_AUDIO1_SHIFT (12) -#define S3C6400_CLKDIV2_AUDIO0_MASK (0xf << 8) -#define S3C6400_CLKDIV2_AUDIO0_SHIFT (8) -#define S3C6400_CLKDIV2_SPI1_MASK (0xf << 4) -#define S3C6400_CLKDIV2_SPI1_SHIFT (4) -#define S3C6400_CLKDIV2_SPI0_MASK (0xf << 0) -#define S3C6400_CLKDIV2_SPI0_SHIFT (0) -/* HCLK GATE Registers */ #define S3C_CLKCON_HCLK_3DSE (1<<31)#define S3C_CLKCON_HCLK_UHOST (1<<29)
@@ -192,34 +153,4 @@#define S3C6400_CLKSRC_EPLL_MOUT_SHIFT (2)#define S3C6400_CLKSRC_MFC (1 << 4) -#define S3C6410_CLKSRC_TV27_MASK (0x1 << 31) -#define S3C6410_CLKSRC_TV27_SHIFT (31) -#define S3C6410_CLKSRC_DAC27_MASK (0x1 << 30) -#define S3C6410_CLKSRC_DAC27_SHIFT (30) -#define S3C6400_CLKSRC_SCALER_MASK (0x3 << 28) -#define S3C6400_CLKSRC_SCALER_SHIFT (28) -#define S3C6400_CLKSRC_LCD_MASK (0x3 << 26) -#define S3C6400_CLKSRC_LCD_SHIFT (26) -#define S3C6400_CLKSRC_IRDA_MASK (0x3 << 24) -#define S3C6400_CLKSRC_IRDA_SHIFT (24) -#define S3C6400_CLKSRC_MMC2_MASK (0x3 << 22) -#define S3C6400_CLKSRC_MMC2_SHIFT (22) -#define S3C6400_CLKSRC_MMC1_MASK (0x3 << 20) -#define S3C6400_CLKSRC_MMC1_SHIFT (20) -#define S3C6400_CLKSRC_MMC0_MASK (0x3 << 18) -#define S3C6400_CLKSRC_MMC0_SHIFT (18) -#define S3C6400_CLKSRC_SPI1_MASK (0x3 << 16) -#define S3C6400_CLKSRC_SPI1_SHIFT (16) -#define S3C6400_CLKSRC_SPI0_MASK (0x3 << 14) -#define S3C6400_CLKSRC_SPI0_SHIFT (14) -#define S3C6400_CLKSRC_UART_MASK (0x1 << 13) -#define S3C6400_CLKSRC_UART_SHIFT (13) -#define S3C6400_CLKSRC_AUDIO1_MASK (0x7 << 10) -#define S3C6400_CLKSRC_AUDIO1_SHIFT (10) -#define S3C6400_CLKSRC_AUDIO0_MASK (0x7 << 7) -#define S3C6400_CLKSRC_AUDIO0_SHIFT (7) -#define S3C6400_CLKSRC_UHOST_MASK (0x3 << 5) -#define S3C6400_CLKSRC_UHOST_SHIFT (5) - -#endif /* _PLAT_REGS_CLOCK_H */
Signature · 1 line
1.5.6.5
PATCH v2 1/1 ] ARM: S3C64XX: Cleanup common init code in s3c6400-clock.c
In reply to Ben DooksRemove the four fields from clksrc_clk.clk which are always the same and init them when the clock is registered. This helps remove the amount of repeated code.
This is a re-work of Harald Welte's clock changes for the latest kernel.
--- arch/arm/plat-s3c64xx/s3c6400-clock.c | 49 +++----------------------------- 1 files changed, 5 insertions(+), 44 deletions(-)
arch/arm/plat-s3c64xx/s3c6400-clock.c +5 -44
@@ -364,10 +364,6 @@ static struct clksrc_clk clk_mmc0 = { .id = 0, .ctrlbit = S3C_CLKCON_SCLK_MMC0, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_MMC0_SHIFT, .mask = S3C6400_CLKSRC_MMC0_MASK,
@@ -382,10 +378,6 @@ static struct clksrc_clk clk_mmc1 = { .id = 1, .ctrlbit = S3C_CLKCON_SCLK_MMC1, .enable = s3c64xx_sclk_ctrl, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .set_parent = s3c64xx_setparent_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_MMC1_SHIFT, .mask = S3C6400_CLKSRC_MMC1_MASK,
@@ -400,10 +392,6 @@ static struct clksrc_clk clk_mmc2 = { .id = 2, .ctrlbit = S3C_CLKCON_SCLK_MMC2, .enable = s3c64xx_sclk_ctrl, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .set_parent = s3c64xx_setparent_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_MMC2_SHIFT, .mask = S3C6400_CLKSRC_MMC2_MASK,
@@ -418,10 +406,6 @@ static struct clksrc_clk clk_usbhost = { .id = -1, .ctrlbit = S3C_CLKCON_SCLK_UHOST, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_UHOST_SHIFT, .mask = S3C6400_CLKSRC_UHOST_MASK,
@@ -436,10 +420,6 @@ static struct clksrc_clk clk_uart_uclk1 = { .id = -1, .ctrlbit = S3C_CLKCON_SCLK_UART, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_UART_SHIFT, .mask = S3C6400_CLKSRC_UART_MASK,
@@ -456,10 +436,6 @@ static struct clksrc_clk clk_spi0 = { .id = 0, .ctrlbit = S3C_CLKCON_SCLK_SPI0, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_SPI0_SHIFT, .mask = S3C6400_CLKSRC_SPI0_MASK,
@@ -474,10 +450,6 @@ static struct clksrc_clk clk_spi1 = { .id = 1, .ctrlbit = S3C_CLKCON_SCLK_SPI1, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_SPI1_SHIFT, .mask = S3C6400_CLKSRC_SPI1_MASK,
@@ -520,10 +492,6 @@ static struct clksrc_clk clk_audio0 = { .id = 0, .ctrlbit = S3C_CLKCON_SCLK_AUDIO0, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_AUDIO0_SHIFT, .mask = S3C6400_CLKSRC_AUDIO0_MASK,
@@ -551,10 +519,6 @@ static struct clksrc_clk clk_audio1 = { .id = 1, .ctrlbit = S3C_CLKCON_SCLK_AUDIO1, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_AUDIO1_SHIFT, .mask = S3C6400_CLKSRC_AUDIO1_MASK,
@@ -569,10 +533,6 @@ static struct clksrc_clk clk_irda = { .id = 0, .ctrlbit = S3C_CLKCON_SCLK_IRDA, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = S3C6400_CLKSRC_IRDA_SHIFT, .mask = S3C6400_CLKSRC_IRDA_MASK,
@@ -596,10 +556,6 @@ static struct clksrc_clk clk_camif = { .id = -1, .ctrlbit = S3C_CLKCON_SCLK_CAM, .enable = s3c64xx_sclk_ctrl, - .set_parent = s3c64xx_setparent_clksrc, - .get_rate = s3c64xx_getrate_clksrc, - .set_rate = s3c64xx_setrate_clksrc, - .round_rate = s3c64xx_roundrate_clksrc, }, .shift = 0, .mask = 0,
@@ -641,6 +597,11 @@ static void __init_or_cpufreq s3c6400_set_clksrc(struct clksrc_clk *clk)return ; } + clk->clk.get_rate = s3c64xx_getrate_clksrc; + clk->clk.set_rate = s3c64xx_setrate_clksrc; + clk->clk.set_parent = s3c64xx_setparent_clksrc; + clk->clk.round_rate = s3c64xx_roundrate_clksrc; + clk->clk.parent = srcs->sources[clksrc]; printk(KERN_INFO "%s: source is %s (%d), rate is %ld\n",
Signature · 1 line
1.5.6.5
PATCH v2 1/1 ] ARM: SAMSUNG: Add core clock implementation for clksrc based clocks
In reply to Ben DooksFrom: Harald Welte <[email protected]>
Add a core for the clksrc clock implementation, which is found in many of the newer Samsung SoCs into plat-samsung.
--- arch/arm/plat-samsung/Kconfig | 5 + arch/arm/plat-samsung/Makefile | 1 + arch/arm/plat-samsung/clock-clksrc.c | 177 +++++++++++++++++++++ arch/arm/plat-samsung/include/plat/clock-clksrc.h | 75 +++++++++ 4 files changed, 258 insertions(+), 0 deletions(-) create mode 100644 arch/arm/plat-samsung/clock-clksrc.c create mode 100644 arch/arm/plat-samsung/include/plat/clock-clksrc.h
arch/arm/plat-samsung/Kconfig +5 -0
@@ -13,5 +13,10 @@ config PLAT_SAMSUNG if PLAT_SAMSUNG +config SAMSUNG_CLKSRC + bool + help + Select the clock code for the clksrc implementation + used by newer systems such as the S3C64XX. endif
arch/arm/plat-samsung/Makefile +1 -0
@@ -9,3 +9,4 @@ obj-m := obj-n := dummy.o obj- := +obj-$(CONFIG_SAMSUNG_CLKSRC) += clock-clksrc.o
arch/arm/plat-samsung/clock-clksrc.c new file +177 -0
177 lines not on this page · raw message
arch/arm/plat-samsung/include/plat/clock-clksrc.h new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
1.5.6.5
PATCH v2 1/1 ] ARM: SAMSUNG: Move <plat/clock.h> to plat-samsung
In reply to Ben DooksMove the <plat/clock.h> header to plat-samsung where it can be used by all the platforms, and readies it for the next round of clock updates where the clock code will be amalgamated.
--- arch/arm/plat-s3c/include/plat/clock.h | 89 ---------------------------- arch/arm/plat-samsung/include/plat/clock.h | 89 ++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 89 deletions(-) delete mode 100644 arch/arm/plat-s3c/include/plat/clock.h create mode 100644 arch/arm/plat-samsung/include/plat/clock.h
arch/arm/plat-s3c/include/plat/clock.h deleted +0 -89
@@ -1,89 +0,0 @@ -/* linux/arch/arm/plat-s3c/include/plat/clock.h -* -* Copyright (c) 2004-2005 Simtec Electronics -* http://www.simtec.co.uk/products/SWLINUX/ -* Written by Ben Dooks, <[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. -*/ - -#include <linux/spinlock.h> - -struct clk { -struct list_head list; -struct module *owner; -struct clk *parent; -const char *name; -int id; -int usage; -unsigned long rate; -unsigned long ctrlbit; - -int (*enable)(struct clk *,int enable); -int (*set_rate)(struct clk *c,unsigned long rate); -unsigned long (*get_rate)(struct clk *c); -unsigned long (*round_rate)(struct clk *c,unsigned long rate); -int (*set_parent)(struct clk *c,struct clk *parent); -}; - -/* other clocks which may be registered by board support */ - -extern struct clk s3c24xx_dclk0; -extern struct clk s3c24xx_dclk1; -extern struct clk s3c24xx_clkout0; -extern struct clk s3c24xx_clkout1; -extern struct clk s3c24xx_uclk; - -extern struct clk clk_usb_bus; - -/* core clock support */ - -extern struct clk clk_f; -extern struct clk clk_h; -extern struct clk clk_p; -extern struct clk clk_mpll; -extern struct clk clk_upll; -extern struct clk clk_epll; -extern struct clk clk_xtal; -extern struct clk clk_ext; - -/* S3C64XX specific clocks */ -extern struct clk clk_h2; -extern struct clk clk_27m; -extern struct clk clk_48m; - -/* exports for arch/arm/mach-s3c2410 -* -* Please DO NOT use these outside of arch/arm/mach-s3c2410 -*/ - -extern spinlock_t clocks_lock; - -extern int s3c2410_clkcon_enable (struct clk *clk,int enable); - -extern int s3c24xx_register_clock (struct clk *clk); -extern int s3c24xx_register_clocks (struct clk **clk,int nr_clks); - -extern int s3c24xx_register_baseclocks (unsigned long xtal); - -extern void s3c64xx_register_clocks (void ); - -extern void s3c24xx_setup_clocks (unsigned long fclk, -unsigned long hclk, -unsigned long pclk); - -extern void s3c2410_setup_clocks (void ); -extern void s3c2412_setup_clocks (void ); -extern void s3c244x_setup_clocks (void ); -extern void s3c2443_setup_clocks (void ); - -/* S3C64XX specific functions and clocks */ - -extern int s3c64xx_sclk_ctrl (struct clk *clk,int enable); - -/* Init for pwm clock code */ - -extern void s3c_pwmclk_init (void ); -
arch/arm/plat-samsung/include/plat/clock.h new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
1.5.6.5
PATCH v2 1/1 ] ARM: SAMSUNG: Reduce size of struct clk.
In reply to Ben DooksReduce the size of struct clk by 12 bytes and make defining clocks with common implementation functions easier by moving the set_rate, get_rate, round_rate and set_parent calls into a new structure called 'struct clk_ops' and using that instead.
This change does make a few clocks larger as they need their own clk_ops, but this is outweighed by the number of clocks with either no ops or having a common set of ops.
Update all the users of this.
--- arch/arm/mach-s3c2412/clock.c | 52 +++++++---- arch/arm/mach-s3c2440/clock.c | 6 +- arch/arm/mach-s3c2442/clock.c | 6 +- arch/arm/mach-s3c2443/clock.c | 88 +++++++++++++------- arch/arm/plat-s3c/clock.c | 31 ++++--- arch/arm/plat-s3c/pwm-clock.c | 94 +++++++++++---------- arch/arm/plat-s3c24xx/clock-dclk.c | 22 +++-- arch/arm/plat-s3c24xx/s3c244x-clock.c | 4 +- arch/arm/plat-s3c64xx/s3c6400-clock.c | 14 ++- arch/arm/plat-s5pc1xx/clock.c | 8 ++- arch/arm/plat-s5pc1xx/s5pc100-clock.c | 126 ++++++++++++---------------- arch/arm/plat-samsung/clock-clksrc.c | 17 ++-- arch/arm/plat-samsung/include/plat/clock.h | 29 ++++++- 13 files changed, 286 insertions(+), 211 deletions(-)
arch/arm/mach-s3c2412/clock.c +33 -19
@@ -124,7 +124,9 @@ static struct clk clk_usysclk = { .name = "usysclk", .id = -1, .parent = &clk_xtal, - .set_parent = s3c2412_setparent_usysclk, + .ops = &(struct clk_ops ) { + .set_parent = s3c2412_setparent_usysclk, + }, };static struct clk clk_mrefclk = {
@@ -199,10 +201,12 @@ static int s3c2412_setrate_usbsrc(struct clk *clk, unsigned long rate)static struct clk clk_usbsrc = { .name ="usbsrc" , .id =-1 , - .get_rate = s3c2412_getrate_usbsrc, - .set_rate = s3c2412_setrate_usbsrc, - .round_rate = s3c2412_roundrate_usbsrc, - .set_parent = s3c2412_setparent_usbsrc, + .ops = &(struct clk_ops ) { + .get_rate = s3c2412_getrate_usbsrc, + .set_rate = s3c2412_setrate_usbsrc, + .round_rate = s3c2412_roundrate_usbsrc, + .set_parent = s3c2412_setparent_usbsrc, + }, };static int s3c2412_setparent_msysclk (struct clk *clk,struct clk *parent)
@@ -225,7 +229,9 @@ static int s3c2412_setparent_msysclk(struct clk *clk, struct clk *parent)static struct clk clk_msysclk = { .name ="msysclk" , .id =-1 , - .set_parent = s3c2412_setparent_msysclk, + .ops = &(struct clk_ops ) { + .set_parent = s3c2412_setparent_msysclk, + }, };static int s3c2412_setparent_armclk (struct clk *clk,struct clk *parent)
@@ -264,7 +270,9 @@ static struct clk clk_armclk = { .name = "armclk", .id = -1, .parent = &clk_msysclk, - .set_parent = s3c2412_setparent_armclk, + .ops = &(struct clk_ops ) { + .set_parent = s3c2412_setparent_armclk, + }, };/* these next clocks have an divider immediately after them,
@@ -337,10 +345,12 @@ static int s3c2412_setrate_uart(struct clk *clk, unsigned long rate)static struct clk clk_uart = { .name ="uartclk" , .id =-1 , - .get_rate = s3c2412_getrate_uart, - .set_rate = s3c2412_setrate_uart, - .set_parent = s3c2412_setparent_uart, - .round_rate = s3c2412_roundrate_clksrc, + .ops = &(struct clk_ops ) { + .get_rate = s3c2412_getrate_uart, + .set_rate = s3c2412_setrate_uart, + .set_parent = s3c2412_setparent_uart, + .round_rate = s3c2412_roundrate_clksrc, + }, };static int s3c2412_setparent_i2s (struct clk *clk,struct clk *parent)
@@ -388,10 +398,12 @@ static int s3c2412_setrate_i2s(struct clk *clk, unsigned long rate)static struct clk clk_i2s = { .name ="i2sclk" , .id =-1 , - .get_rate = s3c2412_getrate_i2s, - .set_rate = s3c2412_setrate_i2s, - .set_parent = s3c2412_setparent_i2s, - .round_rate = s3c2412_roundrate_clksrc, + .ops = &(struct clk_ops ) { + .get_rate = s3c2412_getrate_i2s, + .set_rate = s3c2412_setrate_i2s, + .set_parent = s3c2412_setparent_i2s, + .round_rate = s3c2412_roundrate_clksrc, + }, };static int s3c2412_setparent_cam (struct clk *clk,struct clk *parent)
@@ -438,10 +450,12 @@ static int s3c2412_setrate_cam(struct clk *clk, unsigned long rate)static struct clk clk_cam = { .name ="camif-upll" ,/* same as 2440 name */ .id =-1 , - .get_rate = s3c2412_getrate_cam, - .set_rate = s3c2412_setrate_cam, - .set_parent = s3c2412_setparent_cam, - .round_rate = s3c2412_roundrate_clksrc, + .ops = &(struct clk_ops ) { + .get_rate = s3c2412_getrate_cam, + .set_rate = s3c2412_setrate_cam, + .set_parent = s3c2412_setparent_cam, + .round_rate = s3c2412_roundrate_clksrc, + }, };/* standard clock definitions */
arch/arm/mach-s3c2440/clock.c +4 -2
@@ -98,8 +98,10 @@ static struct clk s3c2440_clk_cam = {static struct clk s3c2440_clk_cam_upll = { .name ="camif-upll" , .id =-1 , - .set_rate = s3c2440_camif_upll_setrate, - .round_rate = s3c2440_camif_upll_round, + .ops = &(struct clk_ops ) { + .set_rate = s3c2440_camif_upll_setrate, + .round_rate = s3c2440_camif_upll_round, + }, };static struct clk s3c2440_clk_ac97 = {
arch/arm/mach-s3c2442/clock.c +4 -2
@@ -109,8 +109,10 @@ static struct clk s3c2442_clk_cam = {static struct clk s3c2442_clk_cam_upll = { .name ="camif-upll" , .id =-1 , - .set_rate = s3c2442_camif_upll_setrate, - .round_rate = s3c2442_camif_upll_round, + .ops = &(struct clk_ops ) { + .set_rate = s3c2442_camif_upll_setrate, + .round_rate = s3c2442_camif_upll_round, + }, };static int s3c2442_clk_add (struct sys_device *sysdev)
arch/arm/mach-s3c2443/clock.c +59 -29
178 lines not on this page · raw message
arch/arm/plat-s3c/clock.c +17 -14
@@ -150,8 +150,8 @@ unsigned long clk_get_rate(struct clk *clk)if (clk->rate !=0 )return clk->rate; -if (clk->get_rate !=NULL ) -return (clk->get_rate)(clk); +if (clk->ops !=NULL && clk->ops->get_rate !=NULL ) +return (clk->ops->get_rate)(clk);if (clk->parent !=NULL )return clk_get_rate (clk->parent);
@@ -161,8 +161,8 @@ unsigned long clk_get_rate(struct clk *clk)long clk_round_rate (struct clk *clk,unsigned long rate) { -if (!IS_ERR (clk) && clk->round_rate) -return (clk->round_rate)(clk, rate); +if (!IS_ERR (clk) && clk->ops && clk->ops->round_rate) +return (clk->ops->round_rate)(clk, rate);return rate; }
@@ -178,13 +178,14 @@ int clk_set_rate(struct clk *clk, unsigned long rate)* the clock may have been made this way by choice. */ -WARN_ON (clk->set_rate ==NULL ); +WARN_ON (clk->ops ==NULL ); +WARN_ON (clk->ops && clk->ops->set_rate ==NULL ); -if (clk->set_rate ==NULL ) +if (clk->ops ==NULL || clk->ops->set_rate ==NULL )return -EINVAL ;spin_lock (&clocks_lock); - ret = (clk->set_rate)(clk, rate); + ret = (clk->ops->set_rate)(clk, rate);spin_unlock (&clocks_lock);return ret;
@@ -204,8 +205,8 @@ int clk_set_parent(struct clk *clk, struct clk *parent)spin_lock (&clocks_lock); -if (clk->set_parent) - ret = (clk->set_parent)(clk, parent); +if (clk->ops && clk->ops->set_parent) + ret = (clk->ops->set_parent)(clk, parent);spin_unlock (&clocks_lock);
@@ -230,6 +231,10 @@ static int clk_default_setrate(struct clk *clk, unsigned long rate)return 0 ; } +static struct clk_ops clk_ops_def_setrate = { + .set_rate = clk_default_setrate, +}; +struct clk clk_xtal = { .name ="xtal" , .id =-1 ,
@@ -251,7 +256,7 @@ struct clk clk_epll = {struct clk clk_mpll = { .name ="mpll" , .id =-1 , - .set_rate = clk_default_setrate, + .ops = &clk_ops_def_setrate, };struct clk clk_upll = {
@@ -267,7 +272,6 @@ struct clk clk_f = { .rate = 0, .parent = &clk_mpll, .ctrlbit = 0, - .set_rate = clk_default_setrate, };struct clk clk_h = {
@@ -276,7 +280,7 @@ struct clk clk_h = { .rate = 0, .parent = NULL, .ctrlbit = 0, - .set_rate = clk_default_setrate, + .ops = &clk_ops_def_setrate, };struct clk clk_p = {
@@ -285,7 +289,7 @@ struct clk clk_p = { .rate = 0, .parent = NULL, .ctrlbit = 0, - .set_rate = clk_default_setrate, + .ops = &clk_ops_def_setrate, };struct clk clk_usb_bus = {
@@ -296,7 +300,6 @@ struct clk clk_usb_bus = { }; -struct clk s3c24xx_uclk = { .name ="uclk" , .id =-1 ,
arch/arm/plat-s3c/pwm-clock.c +48 -46
149 lines not on this page · raw message
arch/arm/plat-s3c24xx/clock-dclk.c +14 -8
@@ -161,14 +161,18 @@ static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent)/* external clock definitions */ +static struct clk_ops dclk_ops = { + .set_parent = s3c24xx_dclk_setparent, + .set_rate = s3c24xx_set_dclk_rate, + .round_rate = s3c24xx_round_dclk_rate, +}; +struct clk s3c24xx_dclk0 = { .name ="dclk0" , .id =-1 , .ctrlbit =S3C2410_DCLKCON_DCLK0EN , .enable = s3c24xx_dclk_enable, - .set_parent = s3c24xx_dclk_setparent, - .set_rate = s3c24xx_set_dclk_rate, - .round_rate = s3c24xx_round_dclk_rate, + .ops = &dclk_ops, };struct clk s3c24xx_dclk1 = {
@@ -176,19 +180,21 @@ struct clk s3c24xx_dclk1 = { .id = -1, .ctrlbit = S3C2410_DCLKCON_DCLK1EN, .enable = s3c24xx_dclk_enable, - .set_parent = s3c24xx_dclk_setparent, - .set_rate = s3c24xx_set_dclk_rate, - .round_rate = s3c24xx_round_dclk_rate, + .ops = &dclk_ops, +}; + +static struct clk_ops clkout_ops = { + .set_parent = s3c24xx_clkout_setparent, };struct clk s3c24xx_clkout0 = { .name ="clkout0" , .id =-1 , - .set_parent = s3c24xx_clkout_setparent, + .ops = &clkout_ops, };struct clk s3c24xx_clkout1 = { .name ="clkout1" , .id =-1 , - .set_parent = s3c24xx_clkout_setparent, + .ops = &clkout_ops, };
arch/arm/plat-s3c24xx/s3c244x-clock.c +3 -1
@@ -68,7 +68,9 @@ static int s3c2440_setparent_armclk(struct clk *clk, struct clk *parent)static struct clk clk_arm = { .name ="armclk" , .id =-1 , - .set_parent = s3c2440_setparent_armclk, + .ops = &(struct clk_ops ) { + .set_parent = s3c2440_setparent_armclk, + }, };static int s3c244x_clk_add (struct sys_device *sysdev)
arch/arm/plat-s3c64xx/s3c6400-clock.c +10 -4
@@ -169,9 +169,11 @@ static struct clk clk_arm = { .name = "armclk", .id = -1, .parent = &clk_mout_apll.clk, - .get_rate = s3c64xx_clk_arm_get_rate, - .set_rate = s3c64xx_clk_arm_set_rate, - .round_rate = s3c64xx_clk_arm_round_rate, + .ops = &(struct clk_ops ) { + .get_rate = s3c64xx_clk_arm_get_rate, + .set_rate = s3c64xx_clk_arm_set_rate, + .round_rate = s3c64xx_clk_arm_round_rate, + }, };static unsigned long s3c64xx_clk_doutmpll_get_rate (struct clk *clk)
@@ -186,11 +188,15 @@ static unsigned long s3c64xx_clk_doutmpll_get_rate(struct clk *clk)return rate; } +static struct clk_ops clk_dout_ops = { + .get_rate = s3c64xx_clk_doutmpll_get_rate, +}; +static struct clk clk_dout_mpll = { .name ="dout_mpll" , .id =-1 , .parent = &clk_mout_mpll.clk, - .get_rate = s3c64xx_clk_doutmpll_get_rate, + .ops = &clk_dout_ops, };static struct clk *clkset_spi_mmc_list[] = {
arch/arm/plat-s5pc1xx/clock.c +6 -2
@@ -70,6 +70,10 @@ static int clk_default_setrate(struct clk *clk, unsigned long rate)return 0 ; } +static struct clk_ops clk_ops_default_setrate = { + .set_rate = clk_default_setrate, +}; +static int clk_dummy_enable (struct clk *clk,int enable) {return 0 ;
@@ -81,8 +85,8 @@ struct clk clk_hd0 = { .rate = 0, .parent = NULL, .ctrlbit = 0, - .set_rate = clk_default_setrate, .enable = clk_dummy_enable, + .ops = &clk_ops_default_setrate, };struct clk clk_pd0 = {
@@ -91,7 +95,7 @@ struct clk clk_pd0 = { .rate = 0, .parent = NULL, .ctrlbit = 0, - .set_rate = clk_default_setrate, + .ops = &clk_ops_default_setrate, .enable = clk_dummy_enable, };
arch/arm/plat-s5pc1xx/s5pc100-clock.c +54 -72
282 lines not on this page · raw message
arch/arm/plat-samsung/clock-clksrc.c +9 -8
@@ -150,20 +150,21 @@ void __init_or_cpufreq s3c_set_clksrc(struct clksrc_clk *clk) clk_get_rate(&clk->clk)); } +static struct clk_ops clksrc_ops = { + .set_parent = s3c_setparent_clksrc, + .get_rate = s3c_getrate_clksrc, + .set_rate = s3c_setrate_clksrc, + .round_rate = s3c_roundrate_clksrc, +}; +void __init s3c_register_clksrc (struct clksrc_clk *clksrc,int size) {int ret;for (; size >0 ; size--, clksrc++) {/* fill in the default functions */ -if (!clksrc->clk.set_parent) - clksrc->clk.set_parent = s3c_setparent_clksrc; -if (!clksrc->clk.get_rate) - clksrc->clk.get_rate = s3c_getrate_clksrc; -if (!clksrc->clk.set_rate) - clksrc->clk.set_rate = s3c_setrate_clksrc; -if (!clksrc->clk.round_rate) - clksrc->clk.round_rate = s3c_roundrate_clksrc; +if (!clksrc->clk.ops) + clksrc->clk.ops = &clksrc_ops;s3c_set_clksrc (clksrc);
arch/arm/plat-samsung/include/plat/clock.h +25 -4
@@ -11,6 +11,30 @@#include <linux/spinlock.h> +struct clk ; + +/** +* struct clk_ops - standard clock operations +* @set_rate: set the clock rate, see clk_set_rate(). +* @get_rate: get the clock rate, see clk_get_rate(). +* @round_rate: round a given clock rate, see clk_round_rate(). +* @set_parent: set the clock's parent, see clk_set_parent(). +* +* Group the common clock implementations together so that we +* don't have to keep setting the same fiels again. We leave +* enable in struct clk. +* +* Adding an extra layer of indirection into the process should +* not be a problem as it is unlikely these operations are going +* to need to be called quickly. +*/ +struct clk_ops { +int (*set_rate)(struct clk *c,unsigned long rate); +unsigned long (*get_rate)(struct clk *c); +unsigned long (*round_rate)(struct clk *c,unsigned long rate); +int (*set_parent)(struct clk *c,struct clk *parent); +}; +struct clk {struct list_head list;struct module *owner;
@@ -21,11 +45,8 @@ struct clk {unsigned long rate;unsigned long ctrlbit; +struct clk_ops *ops;int (*enable)(struct clk *,int enable); -int (*set_rate)(struct clk *c,unsigned long rate); -unsigned long (*get_rate)(struct clk *c); -unsigned long (*round_rate)(struct clk *c,unsigned long rate); -int (*set_parent)(struct clk *c,struct clk *parent); };/* other clocks which may be registered by board support */
Signature · 1 line
1.5.6.5