Kukjin Kim | c4aaa29 | 2012-12-28 16:29:10 -0800 | [diff] [blame] | 1 | /* |
Jaecheol Lee | a125a17 | 2012-01-07 20:18:35 +0900 | [diff] [blame] | 2 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. |
| 3 | * http://www.samsung.com |
| 4 | * |
| 5 | * EXYNOS - CPUFreq support |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | enum cpufreq_level_index { |
| 13 | L0, L1, L2, L3, L4, |
| 14 | L5, L6, L7, L8, L9, |
| 15 | L10, L11, L12, L13, L14, |
| 16 | L15, L16, L17, L18, L19, |
| 17 | L20, |
| 18 | }; |
| 19 | |
Jonghwan Choi | be1f7c8 | 2014-05-17 08:19:30 +0900 | [diff] [blame] | 20 | enum exynos_soc_type { |
| 21 | EXYNOS_SOC_4210, |
| 22 | EXYNOS_SOC_4212, |
| 23 | EXYNOS_SOC_4412, |
| 24 | EXYNOS_SOC_5250, |
| 25 | }; |
| 26 | |
Jonghwan Choi | 9d0554f | 2012-12-23 15:57:42 -0800 | [diff] [blame] | 27 | #define APLL_FREQ(f, a0, a1, a2, a3, a4, a5, a6, a7, b0, b1, b2, m, p, s) \ |
| 28 | { \ |
| 29 | .freq = (f) * 1000, \ |
| 30 | .clk_div_cpu0 = ((a0) | (a1) << 4 | (a2) << 8 | (a3) << 12 | \ |
| 31 | (a4) << 16 | (a5) << 20 | (a6) << 24 | (a7) << 28), \ |
| 32 | .clk_div_cpu1 = (b0 << 0 | b1 << 4 | b2 << 8), \ |
| 33 | .mps = ((m) << 16 | (p) << 8 | (s)), \ |
| 34 | } |
| 35 | |
| 36 | struct apll_freq { |
| 37 | unsigned int freq; |
| 38 | u32 clk_div_cpu0; |
| 39 | u32 clk_div_cpu1; |
| 40 | u32 mps; |
| 41 | }; |
| 42 | |
Jaecheol Lee | a125a17 | 2012-01-07 20:18:35 +0900 | [diff] [blame] | 43 | struct exynos_dvfs_info { |
Jonghwan Choi | be1f7c8 | 2014-05-17 08:19:30 +0900 | [diff] [blame] | 44 | enum exynos_soc_type type; |
Chanwoo Choi | e5eaa44 | 2014-04-18 11:20:33 +0900 | [diff] [blame] | 45 | struct device *dev; |
Jaecheol Lee | a125a17 | 2012-01-07 20:18:35 +0900 | [diff] [blame] | 46 | unsigned long mpll_freq_khz; |
| 47 | unsigned int pll_safe_idx; |
Jaecheol Lee | a125a17 | 2012-01-07 20:18:35 +0900 | [diff] [blame] | 48 | struct clk *cpu_clk; |
| 49 | unsigned int *volt_table; |
| 50 | struct cpufreq_frequency_table *freq_table; |
| 51 | void (*set_freq)(unsigned int, unsigned int); |
| 52 | bool (*need_apll_change)(unsigned int, unsigned int); |
Tomasz Figa | 4c8d819 | 2014-05-26 06:26:03 +0900 | [diff] [blame] | 53 | void __iomem *cmu_regs; |
Jaecheol Lee | a125a17 | 2012-01-07 20:18:35 +0900 | [diff] [blame] | 54 | }; |
| 55 | |
Bartlomiej Zolnierkiewicz | 45e1208 | 2013-08-09 14:04:55 +0200 | [diff] [blame] | 56 | #ifdef CONFIG_ARM_EXYNOS4210_CPUFREQ |
Jaecheol Lee | a125a17 | 2012-01-07 20:18:35 +0900 | [diff] [blame] | 57 | extern int exynos4210_cpufreq_init(struct exynos_dvfs_info *); |
Bartlomiej Zolnierkiewicz | 45e1208 | 2013-08-09 14:04:55 +0200 | [diff] [blame] | 58 | #else |
| 59 | static inline int exynos4210_cpufreq_init(struct exynos_dvfs_info *info) |
| 60 | { |
| 61 | return -EOPNOTSUPP; |
| 62 | } |
| 63 | #endif |
| 64 | #ifdef CONFIG_ARM_EXYNOS4X12_CPUFREQ |
Jaecheol Lee | a35c505 | 2012-03-10 02:59:22 -0800 | [diff] [blame] | 65 | extern int exynos4x12_cpufreq_init(struct exynos_dvfs_info *); |
Bartlomiej Zolnierkiewicz | 45e1208 | 2013-08-09 14:04:55 +0200 | [diff] [blame] | 66 | #else |
| 67 | static inline int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info) |
| 68 | { |
| 69 | return -EOPNOTSUPP; |
| 70 | } |
| 71 | #endif |
| 72 | #ifdef CONFIG_ARM_EXYNOS5250_CPUFREQ |
Jaecheol Lee | 562a6cb | 2012-03-10 03:00:02 -0800 | [diff] [blame] | 73 | extern int exynos5250_cpufreq_init(struct exynos_dvfs_info *); |
Bartlomiej Zolnierkiewicz | 45e1208 | 2013-08-09 14:04:55 +0200 | [diff] [blame] | 74 | #else |
| 75 | static inline int exynos5250_cpufreq_init(struct exynos_dvfs_info *info) |
| 76 | { |
| 77 | return -EOPNOTSUPP; |
| 78 | } |
| 79 | #endif |
Kukjin Kim | df3e9c0 | 2013-12-19 04:21:34 +0900 | [diff] [blame] | 80 | |
Tomasz Figa | 4c8d819 | 2014-05-26 06:26:03 +0900 | [diff] [blame] | 81 | #define EXYNOS4_CLKSRC_CPU 0x14200 |
| 82 | #define EXYNOS4_CLKMUX_STATCPU 0x14400 |
Kukjin Kim | df3e9c0 | 2013-12-19 04:21:34 +0900 | [diff] [blame] | 83 | |
Tomasz Figa | 4c8d819 | 2014-05-26 06:26:03 +0900 | [diff] [blame] | 84 | #define EXYNOS4_CLKDIV_CPU 0x14500 |
| 85 | #define EXYNOS4_CLKDIV_CPU1 0x14504 |
| 86 | #define EXYNOS4_CLKDIV_STATCPU 0x14600 |
| 87 | #define EXYNOS4_CLKDIV_STATCPU1 0x14604 |
Kukjin Kim | df3e9c0 | 2013-12-19 04:21:34 +0900 | [diff] [blame] | 88 | |
| 89 | #define EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT (16) |
| 90 | #define EXYNOS4_CLKMUX_STATCPU_MUXCORE_MASK (0x7 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT) |
| 91 | |
Tomasz Figa | 4c8d819 | 2014-05-26 06:26:03 +0900 | [diff] [blame] | 92 | #define EXYNOS5_APLL_LOCK 0x00000 |
| 93 | #define EXYNOS5_APLL_CON0 0x00100 |
| 94 | #define EXYNOS5_CLKMUX_STATCPU 0x00400 |
| 95 | #define EXYNOS5_CLKDIV_CPU0 0x00500 |
| 96 | #define EXYNOS5_CLKDIV_CPU1 0x00504 |
| 97 | #define EXYNOS5_CLKDIV_STATCPU0 0x00600 |
| 98 | #define EXYNOS5_CLKDIV_STATCPU1 0x00604 |