| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2008 Simtec Electronics |
|---|
| 3 | 4 | * http://armlinux.simtec.co.uk/ |
|---|
| 4 | 5 | * Ben Dooks <ben@simtec.co.uk> |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * S3C2412 CPU Frequency scalling |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 9 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 10 | | - * published by the Free Software Foundation. |
|---|
| 11 | 8 | */ |
|---|
| 12 | 9 | |
|---|
| 13 | 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| .. | .. |
|---|
| 22 | 19 | #include <linux/clk.h> |
|---|
| 23 | 20 | #include <linux/err.h> |
|---|
| 24 | 21 | #include <linux/io.h> |
|---|
| 22 | +#include <linux/soc/samsung/s3c-cpufreq-core.h> |
|---|
| 23 | +#include <linux/soc/samsung/s3c-pm.h> |
|---|
| 25 | 24 | |
|---|
| 26 | 25 | #include <asm/mach/arch.h> |
|---|
| 27 | 26 | #include <asm/mach/map.h> |
|---|
| 28 | 27 | |
|---|
| 29 | | -#include <mach/regs-clock.h> |
|---|
| 30 | | -#include <mach/s3c2412.h> |
|---|
| 31 | | - |
|---|
| 32 | | -#include <plat/cpu.h> |
|---|
| 33 | | -#include <plat/cpu-freq-core.h> |
|---|
| 28 | +#define S3C2412_CLKDIVN_PDIVN (1<<2) |
|---|
| 29 | +#define S3C2412_CLKDIVN_HDIVN_MASK (3<<0) |
|---|
| 30 | +#define S3C2412_CLKDIVN_ARMDIVN (1<<3) |
|---|
| 31 | +#define S3C2412_CLKDIVN_DVSEN (1<<4) |
|---|
| 32 | +#define S3C2412_CLKDIVN_HALFHCLK (1<<5) |
|---|
| 33 | +#define S3C2412_CLKDIVN_USB48DIV (1<<6) |
|---|
| 34 | +#define S3C2412_CLKDIVN_UARTDIV_MASK (15<<8) |
|---|
| 35 | +#define S3C2412_CLKDIVN_UARTDIV_SHIFT (8) |
|---|
| 36 | +#define S3C2412_CLKDIVN_I2SDIV_MASK (15<<12) |
|---|
| 37 | +#define S3C2412_CLKDIVN_I2SDIV_SHIFT (12) |
|---|
| 38 | +#define S3C2412_CLKDIVN_CAMDIV_MASK (15<<16) |
|---|
| 39 | +#define S3C2412_CLKDIVN_CAMDIV_SHIFT (16) |
|---|
| 34 | 40 | |
|---|
| 35 | 41 | /* our clock resources. */ |
|---|
| 36 | 42 | static struct clk *xtal; |
|---|
| .. | .. |
|---|
| 120 | 126 | unsigned long clkdiv; |
|---|
| 121 | 127 | unsigned long olddiv; |
|---|
| 122 | 128 | |
|---|
| 123 | | - olddiv = clkdiv = __raw_readl(S3C2410_CLKDIVN); |
|---|
| 129 | + olddiv = clkdiv = s3c24xx_read_clkdivn(); |
|---|
| 124 | 130 | |
|---|
| 125 | 131 | /* clear off current clock info */ |
|---|
| 126 | 132 | |
|---|
| .. | .. |
|---|
| 137 | 143 | clkdiv |= S3C2412_CLKDIVN_PDIVN; |
|---|
| 138 | 144 | |
|---|
| 139 | 145 | s3c_freq_dbg("%s: div %08lx => %08lx\n", __func__, olddiv, clkdiv); |
|---|
| 140 | | - __raw_writel(clkdiv, S3C2410_CLKDIVN); |
|---|
| 146 | + s3c24xx_write_clkdivn(clkdiv); |
|---|
| 141 | 147 | |
|---|
| 142 | 148 | clk_set_parent(armclk, cfg->divs.dvs ? hclk : fclk); |
|---|
| 143 | | -} |
|---|
| 144 | | - |
|---|
| 145 | | -static void s3c2412_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg) |
|---|
| 146 | | -{ |
|---|
| 147 | | - struct s3c_cpufreq_board *board = cfg->board; |
|---|
| 148 | | - unsigned long refresh; |
|---|
| 149 | | - |
|---|
| 150 | | - s3c_freq_dbg("%s: refresh %u ns, hclk %lu\n", __func__, |
|---|
| 151 | | - board->refresh, cfg->freq.hclk); |
|---|
| 152 | | - |
|---|
| 153 | | - /* Reduce both the refresh time (in ns) and the frequency (in MHz) |
|---|
| 154 | | - * by 10 each to ensure that we do not overflow 32 bit numbers. This |
|---|
| 155 | | - * should work for HCLK up to 133MHz and refresh period up to 30usec. |
|---|
| 156 | | - */ |
|---|
| 157 | | - |
|---|
| 158 | | - refresh = (board->refresh / 10); |
|---|
| 159 | | - refresh *= (cfg->freq.hclk / 100); |
|---|
| 160 | | - refresh /= (1 * 1000 * 1000); /* 10^6 */ |
|---|
| 161 | | - |
|---|
| 162 | | - s3c_freq_dbg("%s: setting refresh 0x%08lx\n", __func__, refresh); |
|---|
| 163 | | - __raw_writel(refresh, S3C2412_REFRESH); |
|---|
| 164 | 149 | } |
|---|
| 165 | 150 | |
|---|
| 166 | 151 | /* set the default cpu frequency information, based on an 200MHz part |
|---|