Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 123867
b: refs/heads/master
c: 9d325f2
h: refs/heads/master
i:
  123865: 6c50714
  123863: 82208ad
v: v3
  • Loading branch information
Ben Dooks committed Dec 16, 2008
1 parent 85b17a8 commit 2c55f56
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 35 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b09bcdd4c2f52b54115895c4d62ad82918f71431
refs/heads/master: 9d325f23416d1525401d43442bafca2bb254ab74
1 change: 1 addition & 0 deletions trunk/arch/arm/mach-s3c2412/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,5 +767,6 @@ int __init s3c2412_baseclk_add(void)
s3c2412_clkcon_enable(clkp, 0);
}

s3c_pwmclk_init();
return 0;
}
2 changes: 2 additions & 0 deletions trunk/arch/arm/mach-s3c2443/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,4 +1107,6 @@ void __init s3c2443_init_clocks(int xtal)

(clkp->enable)(clkp, 0);
}

s3c_pwmclk_init();
}
5 changes: 5 additions & 0 deletions trunk/arch/arm/plat-s3c/include/plat/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ 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);

28 changes: 15 additions & 13 deletions trunk/arch/arm/plat-s3c/pwm-clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,16 @@ static __init int clk_pwm_tin_register(struct clk *pwm)
return clk_set_parent(pwm, parent);
}

static __init int s3c24xx_pwmclk_init(void)
/**
* s3c_pwmclk_init() - initialise pwm clocks
*
* Initialise and register the clocks which provide the inputs for the
* pwm timer blocks.
*
* Note, this call is required by the time core, so must be called after
* the base clocks are added and before any of the initcalls are run.
*/
__init void s3c_pwmclk_init(void)
{
struct clk *clk_timers;
unsigned int clk;
Expand All @@ -416,46 +425,39 @@ static __init int s3c24xx_pwmclk_init(void)
clk_timers = clk_get(NULL, "timers");
if (IS_ERR(clk_timers)) {
printk(KERN_ERR "%s: no parent clock\n", __func__);
return -EINVAL;
return;
}

for (clk = 0; clk < ARRAY_SIZE(clk_timer_scaler); clk++) {
clk_timer_scaler[clk].parent = clk_timers;
ret = s3c24xx_register_clock(&clk_timer_scaler[clk]);
if (ret < 0) {
printk(KERN_ERR "error adding pwm scaler%d clock\n", clk);
goto err;
return;
}
}

for (clk = 0; clk < ARRAY_SIZE(clk_timer_tclk); clk++) {
ret = s3c24xx_register_clock(&clk_timer_tclk[clk]);
if (ret < 0) {
printk(KERN_ERR "error adding pww tclk%d\n", clk);
goto err;
return;
}
}

for (clk = 0; clk < ARRAY_SIZE(clk_timer_tdiv); clk++) {
ret = clk_pwm_tdiv_register(clk);
if (ret < 0) {
printk(KERN_ERR "error adding pwm%d tdiv clock\n", clk);
goto err;
return;
}
}

for (clk = 0; clk < ARRAY_SIZE(clk_tin); clk++) {
ret = clk_pwm_tin_register(&clk_tin[clk]);
if (ret < 0) {
printk(KERN_ERR "error adding pwm%d tin clock\n", clk);
goto err;
return;
}
}

return 0;

err:
return ret;
}

arch_initcall(s3c24xx_pwmclk_init);
66 changes: 45 additions & 21 deletions trunk/arch/arm/plat-s3c/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/platform_device.h>

#include <asm/system.h>
#include <asm/leds.h>
Expand Down Expand Up @@ -147,6 +148,10 @@ static struct irqaction s3c2410_timer_irq = {
machine_is_anubis() || \
machine_is_osiris())

static struct clk *tin;
static struct clk *tdiv;
static struct clk *timerclk;

/*
* Set up timer interrupt, and return the current time in seconds.
*
Expand All @@ -162,24 +167,20 @@ static void s3c2410_timer_setup (void)

tcnt = TICK_MAX; /* default value for tcnt */

/* read the current timer configuration bits */

tcon = __raw_readl(S3C2410_TCON);
tcfg1 = __raw_readl(S3C2410_TCFG1);
tcfg0 = __raw_readl(S3C2410_TCFG0);

/* configure the system for whichever machine is in use */

if (use_tclk1_12()) {
/* timer is at 12MHz, scaler is 1 */
timer_usec_ticks = timer_mask_usec_ticks(1, 12000000);
tcnt = 12000000 / HZ;

tcfg1 = __raw_readl(S3C2410_TCFG1);
tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK;
tcfg1 |= S3C2410_TCFG1_MUX4_TCLK1;
__raw_writel(tcfg1, S3C2410_TCFG1);
} else {
unsigned long pclk;
struct clk *clk;
struct clk *tscaler;

/* for the h1940 (and others), we use the pclk from the core
* to generate the timer values. since values around 50 to
Expand All @@ -190,29 +191,25 @@ static void s3c2410_timer_setup (void)
* (8.45 ticks per usec)
*/

/* this is used as default if no other timer can be found */

clk = clk_get(NULL, "timers");
if (IS_ERR(clk))
panic("failed to get clock for system timer");

clk_enable(clk);

pclk = clk_get_rate(clk);
pclk = clk_get_rate(timerclk);

/* configure clock tick */

timer_usec_ticks = timer_mask_usec_ticks(6, pclk);

tcfg1 &= ~S3C2410_TCFG1_MUX4_MASK;
tcfg1 |= S3C2410_TCFG1_MUX4_DIV2;
tscaler = clk_get_parent(tdiv);

tcfg0 &= ~S3C2410_TCFG_PRESCALER1_MASK;
tcfg0 |= ((6 - 1) / 2) << S3C2410_TCFG_PRESCALER1_SHIFT;
clk_set_rate(tscaler, pclk / 3);
clk_set_rate(tdiv, pclk / 6);
clk_set_parent(tin, tdiv);

tcnt = (pclk / 6) / HZ;
tcnt = clk_get_rate(tin) / HZ;
}

tcon = __raw_readl(S3C2410_TCON);
tcfg0 = __raw_readl(S3C2410_TCFG0);
tcfg1 = __raw_readl(S3C2410_TCFG1);

/* timers reload after counting zero, so reduce the count by 1 */

tcnt--;
Expand Down Expand Up @@ -248,8 +245,35 @@ static void s3c2410_timer_setup (void)
__raw_writel(tcon, S3C2410_TCON);
}

static void __init s3c2410_timer_resources(void)
{
struct platform_device tmpdev;

tmpdev.dev.bus = &platform_bus_type;
tmpdev.id = 4;

timerclk = clk_get(NULL, "timers");
if (IS_ERR(timerclk))
panic("failed to get clock for system timer");

clk_enable(timerclk);

if (!use_tclk1_12()) {
tin = clk_get(&tmpdev.dev, "pwm-tin");
if (IS_ERR(tin))
panic("failed to get pwm-tin clock for system timer");

tdiv = clk_get(&tmpdev.dev, "pwm-tdiv");
if (IS_ERR(tdiv))
panic("failed to get pwm-tdiv clock for system timer");
}

clk_enable(tin);
}

static void __init s3c2410_timer_init(void)
{
s3c2410_timer_resources();
s3c2410_timer_setup();
setup_irq(IRQ_TIMER4, &s3c2410_timer_irq);
}
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/arm/plat-s3c24xx/s3c2410-clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,6 @@ int __init s3c2410_baseclk_add(void)
(clkslow & S3C2410_CLKSLOW_MPLL_OFF) ? "off" : "on",
(clkslow & S3C2410_CLKSLOW_UCLK_OFF) ? "off" : "on");

s3c_pwmclk_init();
return 0;
}
2 changes: 2 additions & 0 deletions trunk/arch/arm/plat-s3c64xx/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,6 @@ void s3c64xx_register_clocks(void)

(clkp->enable)(clkp, 0);
}

s3c_pwmclk_init();
}

0 comments on commit 2c55f56

Please sign in to comment.