summaryrefslogtreecommitdiff
path: root/linux/arch/arm/mach-omap2/opp43xx_data.c
blob: 303fba2365ac80e5c4cfc15d8f2f624915ae8393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * AM43XX OPP table definitions.
 *
 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
 * kind, whether express or implied; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#include <linux/io.h>
#include <linux/module.h>

#include "control.h"
#include "omap_opp_data.h"
#include "pm.h"
#include "soc.h"

/* From AM437x TRM, SPRUHL7 */
#define AM43XX_DEV_ATTR_OFFSET	0x610

/*
 * Bits [5:0] are OPP Disabled bits,
 * 1 = OPP is disabled and not available,
 * 0 = OPP available.
 */
#define MAX_FREQ_MASK		0x3f
#define MAX_FREQ_SHFT		0

#define EFUSE_OPP_50_300MHZ_BIT		(0x1 << 0)
#define EFUSE_OPP_100_600MHZ_BIT		(0x1 << 2)
#define EFUSE_OPP_120_720MHZ_BIT		(0x1 << 3)
#define EFUSE_OPP_TURBO_800MHZ_BIT		(0x1 << 4)
#define EFUSE_OPP_NITRO_1GHZ_BIT		(0x1 << 5)

static struct omap_opp_def am43xx_es1_0_opp_list[] __initdata = {
	/* MPU OPP1 - OPP50 */
	OPP_INITIALIZER("mpu", false, 300000000, 950000),
	/* MPU OPP2 - OPP100 */
	OPP_INITIALIZER("mpu", false, 600000000, 1100000),
	/* MPU OPP3 - OPP120 */
	OPP_INITIALIZER("mpu", false, 720000000, 1200000),
	/* MPU OPP3 - OPPTurbo */
	OPP_INITIALIZER("mpu", false, 800000000, 1260000),
	/* MPU OPP4 - OPPNitro */
	OPP_INITIALIZER("mpu", false, 1000000000, 1325000),
};

/**
 * am43xx_opp_init() - initialize am43xx opp table
 */
int __init am43xx_opp_init(void)
{
	int r = -ENODEV;
	u32 rev, val, max_freq;

	if (WARN(!soc_is_am43xx(), "Cannot init OPPs: unsupported SoC.\n"))
		return r;

	rev = omap_rev();

	switch (rev) {
	case AM437X_REV_ES1_0:
	case AM437X_REV_ES1_1:
	default:
		/*
		 * First read dev attr reg to detect supported frequency
		 */
		val = omap_ctrl_readl(AM43XX_DEV_ATTR_OFFSET);

		/*
		 * 1 = OPP is disabled and not available,
		 * 0 = OPP available.
		 */
		max_freq = ~val & MAX_FREQ_MASK;

		opp_def_list_enable_opp(am43xx_es1_0_opp_list,
			ARRAY_SIZE(am43xx_es1_0_opp_list),
			"mpu", 300000000,
			(max_freq & EFUSE_OPP_50_300MHZ_BIT) ? true : false);

		opp_def_list_enable_opp(am43xx_es1_0_opp_list,
			ARRAY_SIZE(am43xx_es1_0_opp_list),
			"mpu", 600000000,
			(max_freq & EFUSE_OPP_100_600MHZ_BIT) ? true : false);

		opp_def_list_enable_opp(am43xx_es1_0_opp_list,
			ARRAY_SIZE(am43xx_es1_0_opp_list),
			"mpu", 720000000,
			(max_freq & EFUSE_OPP_120_720MHZ_BIT) ? true : false);

		opp_def_list_enable_opp(am43xx_es1_0_opp_list,
			ARRAY_SIZE(am43xx_es1_0_opp_list),
			"mpu", 800000000,
			(max_freq & EFUSE_OPP_TURBO_800MHZ_BIT) ? true : false);

		opp_def_list_enable_opp(am43xx_es1_0_opp_list,
			ARRAY_SIZE(am43xx_es1_0_opp_list),
			"mpu", 1000000000,
			(max_freq & EFUSE_OPP_NITRO_1GHZ_BIT) ? true : false);

		r = omap_init_opp_table(am43xx_es1_0_opp_list,
					ARRAY_SIZE(am43xx_es1_0_opp_list));
		break;
	}

	return r;
}