imx6: kernel: backport upstream fix for IMX6DL 800MHz speed grade
[openwrt/openwrt.git] / target / linux / imx6 / patches-3.14 / 0008-ARM-imx-add-speed-grading-check-for-i.mx6-soc.patch
1 From c962a0996335fae7f79e64677f47d4784b86f692 Mon Sep 17 00:00:00 2001
2 From: Anson Huang <b20788@freescale.com>
3 Date: Wed, 12 Feb 2014 17:57:03 +0800
4 Subject: [PATCH] ARM: imx: add speed grading check for i.mx6 soc
5
6 The fuse map of speed_grading[1:0] defines the max speed
7 of ARM, see below the definition:
8
9 2b'11: 1200000000Hz;
10 2b'10: 996000000Hz;
11 2b'01: 852000000Hz; -- i.MX6Q Only, exclusive with 996MHz.
12 2b'00: 792000000Hz;
13
14 Need to remove all illegal setpoints according to fuse
15 map.
16
17 Signed-off-by: Anson Huang <b20788@freescale.com>
18 Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
19 ---
20 arch/arm/mach-imx/mach-imx6q.c | 26 +++++++++++++++++++++++---
21 1 file changed, 23 insertions(+), 3 deletions(-)
22
23 --- a/arch/arm/mach-imx/mach-imx6q.c
24 +++ b/arch/arm/mach-imx/mach-imx6q.c
25 @@ -219,8 +219,10 @@ static void __init imx6q_init_machine(vo
26 #define OCOTP_CFG3 0x440
27 #define OCOTP_CFG3_SPEED_SHIFT 16
28 #define OCOTP_CFG3_SPEED_1P2GHZ 0x3
29 +#define OCOTP_CFG3_SPEED_996MHZ 0x2
30 +#define OCOTP_CFG3_SPEED_852MHZ 0x1
31
32 -static void __init imx6q_opp_check_1p2ghz(struct device *cpu_dev)
33 +static void __init imx6q_opp_check_speed_grading(struct device *cpu_dev)
34 {
35 struct device_node *np;
36 void __iomem *base;
37 @@ -238,11 +240,29 @@ static void __init imx6q_opp_check_1p2gh
38 goto put_node;
39 }
40
41 + /*
42 + * SPEED_GRADING[1:0] defines the max speed of ARM:
43 + * 2b'11: 1200000000Hz;
44 + * 2b'10: 996000000Hz;
45 + * 2b'01: 852000000Hz; -- i.MX6Q Only, exclusive with 996MHz.
46 + * 2b'00: 792000000Hz;
47 + * We need to set the max speed of ARM according to fuse map.
48 + */
49 val = readl_relaxed(base + OCOTP_CFG3);
50 val >>= OCOTP_CFG3_SPEED_SHIFT;
51 - if ((val & 0x3) != OCOTP_CFG3_SPEED_1P2GHZ)
52 + val &= 0x3;
53 +
54 + if (val != OCOTP_CFG3_SPEED_1P2GHZ)
55 if (dev_pm_opp_disable(cpu_dev, 1200000000))
56 pr_warn("failed to disable 1.2 GHz OPP\n");
57 + if (val < OCOTP_CFG3_SPEED_996MHZ)
58 + if (dev_pm_opp_disable(cpu_dev, 996000000))
59 + pr_warn("failed to disable 996 MHz OPP\n");
60 + if (cpu_is_imx6q()) {
61 + if (val != OCOTP_CFG3_SPEED_852MHZ)
62 + if (dev_pm_opp_disable(cpu_dev, 852000000))
63 + pr_warn("failed to disable 852 MHz OPP\n");
64 + }
65
66 put_node:
67 of_node_put(np);
68 @@ -268,7 +288,7 @@ static void __init imx6q_opp_init(void)
69 goto put_node;
70 }
71
72 - imx6q_opp_check_1p2ghz(cpu_dev);
73 + imx6q_opp_check_speed_grading(cpu_dev);
74
75 put_node:
76 of_node_put(np);