Skip to content

Commit

Permalink
[ARM] 3360/1: S3C2440 - add set rate methods and camera clock
Browse files Browse the repository at this point in the history
Patch from Ben Dooks

Add set_rate methods for the extra clocks on the S3C2440
and add the camera UPLL clock source

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Ben Dooks authored and Russell King committed Mar 21, 2006
1 parent 6e8908e commit e44c039
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions arch/arm/mach-s3c2410/s3c2440-clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,62 @@

/* S3C2440 extended clock support */

static unsigned long s3c2440_camif_upll_round(struct clk *clk,
unsigned long rate)
{
unsigned long parent_rate = clk_get_rate(clk->parent);
int div;

if (rate > parent_rate)
return parent_rate;

/* note, we remove the +/- 1 calculations for the divisor */

div = (parent_rate / rate) / 2;

if (div < 1)
div = 1;
else if (div > 16)
div = 16;

return parent_rate / (div * 2);
}

static int s3c2440_camif_upll_setrate(struct clk *clk, unsigned long rate)
{
unsigned long parent_rate = clk_get_rate(clk->parent);
unsigned long camdivn = __raw_readl(S3C2440_CAMDIVN);

rate = s3c2440_camif_upll_round(clk, rate);

camdivn &= ~(S3C2440_CAMDIVN_CAMCLK_SEL | S3C2440_CAMDIVN_CAMCLK_MASK);

if (rate != parent_rate) {
camdivn |= S3C2440_CAMDIVN_CAMCLK_SEL;
camdivn |= (((parent_rate / rate) / 2) - 1);
}

__raw_writel(camdivn, S3C2440_CAMDIVN);

return 0;
}

/* Extra S3C2440 clocks */

static struct clk s3c2440_clk_cam = {
.name = "camif",
.id = -1,
.enable = s3c24xx_clkcon_enable,
.ctrlbit = S3C2440_CLKCON_CAMERA,
};

static struct clk s3c2440_clk_cam_upll = {
.name = "camif-upll",
.id = -1,
.set_rate = s3c2440_camif_upll_setrate,
.round_rate = s3c2440_camif_upll_round,
};

static struct clk s3c2440_clk_ac97 = {
.name = "ac97",
.id = -1,
Expand All @@ -78,9 +127,11 @@ static int s3c2440_clk_add(struct sys_device *sysdev)

s3c2440_clk_cam.parent = clk_h;
s3c2440_clk_ac97.parent = clk_p;
s3c2440_clk_cam_upll.parent = clk_upll;

s3c24xx_register_clock(&s3c2440_clk_ac97);
s3c24xx_register_clock(&s3c2440_clk_cam);
s3c24xx_register_clock(&s3c2440_clk_cam_upll);

clk_disable(&s3c2440_clk_ac97);
clk_disable(&s3c2440_clk_cam);
Expand Down

0 comments on commit e44c039

Please sign in to comment.