| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2006-2009 Simtec Electronics |
|---|
| 3 | 4 | * http://armlinux.simtec.co.uk/ |
|---|
| .. | .. |
|---|
| 5 | 6 | * Vincent Sanders <vince@simtec.co.uk> |
|---|
| 6 | 7 | * |
|---|
| 7 | 8 | * S3C2440/S3C2442 CPU Frequency scaling |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 11 | | - * published by the Free Software Foundation. |
|---|
| 12 | 9 | */ |
|---|
| 13 | 10 | |
|---|
| 14 | 11 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 23 | 20 | #include <linux/clk.h> |
|---|
| 24 | 21 | #include <linux/err.h> |
|---|
| 25 | 22 | #include <linux/io.h> |
|---|
| 23 | +#include <linux/soc/samsung/s3c-cpufreq-core.h> |
|---|
| 24 | +#include <linux/soc/samsung/s3c-pm.h> |
|---|
| 26 | 25 | |
|---|
| 27 | 26 | #include <asm/mach/arch.h> |
|---|
| 28 | 27 | #include <asm/mach/map.h> |
|---|
| 29 | 28 | |
|---|
| 30 | | -#include <mach/regs-clock.h> |
|---|
| 29 | +#define S3C2440_CLKDIVN_PDIVN (1<<0) |
|---|
| 30 | +#define S3C2440_CLKDIVN_HDIVN_MASK (3<<1) |
|---|
| 31 | +#define S3C2440_CLKDIVN_HDIVN_1 (0<<1) |
|---|
| 32 | +#define S3C2440_CLKDIVN_HDIVN_2 (1<<1) |
|---|
| 33 | +#define S3C2440_CLKDIVN_HDIVN_4_8 (2<<1) |
|---|
| 34 | +#define S3C2440_CLKDIVN_HDIVN_3_6 (3<<1) |
|---|
| 35 | +#define S3C2440_CLKDIVN_UCLK (1<<3) |
|---|
| 31 | 36 | |
|---|
| 32 | | -#include <plat/cpu.h> |
|---|
| 33 | | -#include <plat/cpu-freq-core.h> |
|---|
| 37 | +#define S3C2440_CAMDIVN_CAMCLK_MASK (0xf<<0) |
|---|
| 38 | +#define S3C2440_CAMDIVN_CAMCLK_SEL (1<<4) |
|---|
| 39 | +#define S3C2440_CAMDIVN_HCLK3_HALF (1<<8) |
|---|
| 40 | +#define S3C2440_CAMDIVN_HCLK4_HALF (1<<9) |
|---|
| 41 | +#define S3C2440_CAMDIVN_DVSEN (1<<12) |
|---|
| 42 | + |
|---|
| 43 | +#define S3C2442_CAMDIVN_CAMCLK_DIV3 (1<<5) |
|---|
| 34 | 44 | |
|---|
| 35 | 45 | static struct clk *xtal; |
|---|
| 36 | 46 | static struct clk *fclk; |
|---|
| .. | .. |
|---|
| 146 | 156 | s3c_freq_dbg("%s: divisors: h=%d, p=%d\n", __func__, |
|---|
| 147 | 157 | cfg->divs.h_divisor, cfg->divs.p_divisor); |
|---|
| 148 | 158 | |
|---|
| 149 | | - clkdiv = __raw_readl(S3C2410_CLKDIVN); |
|---|
| 150 | | - camdiv = __raw_readl(S3C2440_CAMDIVN); |
|---|
| 159 | + clkdiv = s3c24xx_read_clkdivn(); |
|---|
| 160 | + camdiv = s3c2440_read_camdivn(); |
|---|
| 151 | 161 | |
|---|
| 152 | 162 | clkdiv &= ~(S3C2440_CLKDIVN_HDIVN_MASK | S3C2440_CLKDIVN_PDIVN); |
|---|
| 153 | 163 | camdiv &= ~CAMDIVN_HCLK_HALF; |
|---|
| .. | .. |
|---|
| 187 | 197 | * then make a short delay and remove the hclk halving if necessary. |
|---|
| 188 | 198 | */ |
|---|
| 189 | 199 | |
|---|
| 190 | | - __raw_writel(camdiv | CAMDIVN_HCLK_HALF, S3C2440_CAMDIVN); |
|---|
| 191 | | - __raw_writel(clkdiv, S3C2410_CLKDIVN); |
|---|
| 200 | + s3c2440_write_camdivn(camdiv | CAMDIVN_HCLK_HALF); |
|---|
| 201 | + s3c24xx_write_clkdivn(clkdiv); |
|---|
| 192 | 202 | |
|---|
| 193 | 203 | ndelay(20); |
|---|
| 194 | | - __raw_writel(camdiv, S3C2440_CAMDIVN); |
|---|
| 204 | + s3c2440_write_camdivn(camdiv); |
|---|
| 195 | 205 | |
|---|
| 196 | 206 | clk_set_parent(armclk, cfg->divs.dvs ? hclk : fclk); |
|---|
| 197 | 207 | } |
|---|