xref: /linux/drivers/clk/tegra/clk-tegra124-dfll-fcpu.c (revision bb8727096c86c299080c46258492098cc01741b9)
162a8a094STuomas Tynkkynen /*
262a8a094STuomas Tynkkynen  * Tegra124 DFLL FCPU clock source driver
362a8a094STuomas Tynkkynen  *
4b0dcfb78SPeter De Schrijver  * Copyright (C) 2012-2019 NVIDIA Corporation.  All rights reserved.
562a8a094STuomas Tynkkynen  *
662a8a094STuomas Tynkkynen  * Aleksandr Frid <afrid@nvidia.com>
762a8a094STuomas Tynkkynen  * Paul Walmsley <pwalmsley@nvidia.com>
862a8a094STuomas Tynkkynen  *
962a8a094STuomas Tynkkynen  * This program is free software; you can redistribute it and/or modify
1062a8a094STuomas Tynkkynen  * it under the terms of the GNU General Public License version 2 as
1162a8a094STuomas Tynkkynen  * published by the Free Software Foundation.
1262a8a094STuomas Tynkkynen  *
1362a8a094STuomas Tynkkynen  * This program is distributed in the hope that it will be useful, but WITHOUT
1462a8a094STuomas Tynkkynen  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1562a8a094STuomas Tynkkynen  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
1662a8a094STuomas Tynkkynen  * more details.
1762a8a094STuomas Tynkkynen  *
1862a8a094STuomas Tynkkynen  */
1962a8a094STuomas Tynkkynen 
2062a8a094STuomas Tynkkynen #include <linux/cpu.h>
2162a8a094STuomas Tynkkynen #include <linux/err.h>
2262a8a094STuomas Tynkkynen #include <linux/kernel.h>
2333996b02SPaul Gortmaker #include <linux/init.h>
24b0dcfb78SPeter De Schrijver #include <linux/of_device.h>
2562a8a094STuomas Tynkkynen #include <linux/platform_device.h>
26b3cf8d06SJoseph Lo #include <linux/regulator/consumer.h>
2762a8a094STuomas Tynkkynen #include <soc/tegra/fuse.h>
2862a8a094STuomas Tynkkynen 
2962a8a094STuomas Tynkkynen #include "clk.h"
3062a8a094STuomas Tynkkynen #include "clk-dfll.h"
3162a8a094STuomas Tynkkynen #include "cvb.h"
3262a8a094STuomas Tynkkynen 
33b0dcfb78SPeter De Schrijver struct dfll_fcpu_data {
34b0dcfb78SPeter De Schrijver 	const unsigned long *cpu_max_freq_table;
35b0dcfb78SPeter De Schrijver 	unsigned int cpu_max_freq_table_size;
36b0dcfb78SPeter De Schrijver 	const struct cvb_table *cpu_cvb_tables;
37b0dcfb78SPeter De Schrijver 	unsigned int cpu_cvb_tables_size;
38b0dcfb78SPeter De Schrijver };
39b0dcfb78SPeter De Schrijver 
4062a8a094STuomas Tynkkynen /* Maximum CPU frequency, indexed by CPU speedo id */
41b0dcfb78SPeter De Schrijver static const unsigned long tegra124_cpu_max_freq_table[] = {
4262a8a094STuomas Tynkkynen 	[0] = 2014500000UL,
4362a8a094STuomas Tynkkynen 	[1] = 2320500000UL,
4462a8a094STuomas Tynkkynen 	[2] = 2116500000UL,
4562a8a094STuomas Tynkkynen 	[3] = 2524500000UL,
4662a8a094STuomas Tynkkynen };
4762a8a094STuomas Tynkkynen 
4862a8a094STuomas Tynkkynen static const struct cvb_table tegra124_cpu_cvb_tables[] = {
4962a8a094STuomas Tynkkynen 	{
5062a8a094STuomas Tynkkynen 		.speedo_id = -1,
5162a8a094STuomas Tynkkynen 		.process_id = -1,
5262a8a094STuomas Tynkkynen 		.min_millivolts = 900,
5362a8a094STuomas Tynkkynen 		.max_millivolts = 1260,
5462a8a094STuomas Tynkkynen 		.speedo_scale = 100,
5562a8a094STuomas Tynkkynen 		.voltage_scale = 1000,
56e8f6a68cSThierry Reding 		.entries = {
5762a8a094STuomas Tynkkynen 			{  204000000UL, { 1112619, -29295, 402 } },
5862a8a094STuomas Tynkkynen 			{  306000000UL, { 1150460, -30585, 402 } },
5962a8a094STuomas Tynkkynen 			{  408000000UL, { 1190122, -31865, 402 } },
6062a8a094STuomas Tynkkynen 			{  510000000UL, { 1231606, -33155, 402 } },
6162a8a094STuomas Tynkkynen 			{  612000000UL, { 1274912, -34435, 402 } },
6262a8a094STuomas Tynkkynen 			{  714000000UL, { 1320040, -35725, 402 } },
6362a8a094STuomas Tynkkynen 			{  816000000UL, { 1366990, -37005, 402 } },
6462a8a094STuomas Tynkkynen 			{  918000000UL, { 1415762, -38295, 402 } },
6562a8a094STuomas Tynkkynen 			{ 1020000000UL, { 1466355, -39575, 402 } },
6662a8a094STuomas Tynkkynen 			{ 1122000000UL, { 1518771, -40865, 402 } },
6762a8a094STuomas Tynkkynen 			{ 1224000000UL, { 1573009, -42145, 402 } },
6862a8a094STuomas Tynkkynen 			{ 1326000000UL, { 1629068, -43435, 402 } },
6962a8a094STuomas Tynkkynen 			{ 1428000000UL, { 1686950, -44715, 402 } },
7062a8a094STuomas Tynkkynen 			{ 1530000000UL, { 1746653, -46005, 402 } },
7162a8a094STuomas Tynkkynen 			{ 1632000000UL, { 1808179, -47285, 402 } },
7262a8a094STuomas Tynkkynen 			{ 1734000000UL, { 1871526, -48575, 402 } },
7362a8a094STuomas Tynkkynen 			{ 1836000000UL, { 1936696, -49855, 402 } },
7462a8a094STuomas Tynkkynen 			{ 1938000000UL, { 2003687, -51145, 402 } },
7562a8a094STuomas Tynkkynen 			{ 2014500000UL, { 2054787, -52095, 402 } },
7662a8a094STuomas Tynkkynen 			{ 2116500000UL, { 2124957, -53385, 402 } },
7762a8a094STuomas Tynkkynen 			{ 2218500000UL, { 2196950, -54665, 402 } },
7862a8a094STuomas Tynkkynen 			{ 2320500000UL, { 2270765, -55955, 402 } },
7962a8a094STuomas Tynkkynen 			{ 2422500000UL, { 2346401, -57235, 402 } },
8062a8a094STuomas Tynkkynen 			{ 2524500000UL, { 2437299, -58535, 402 } },
812690e912SThierry Reding 			{          0UL, {       0,      0,   0 } },
8262a8a094STuomas Tynkkynen 		},
8362a8a094STuomas Tynkkynen 		.cpu_dfll_data = {
8462a8a094STuomas Tynkkynen 			.tune0_low = 0x005020ff,
8562a8a094STuomas Tynkkynen 			.tune0_high = 0x005040ff,
8662a8a094STuomas Tynkkynen 			.tune1 = 0x00000060,
8762a8a094STuomas Tynkkynen 		}
8862a8a094STuomas Tynkkynen 	},
8962a8a094STuomas Tynkkynen };
9062a8a094STuomas Tynkkynen 
912b2dbc2fSJoseph Lo static const unsigned long tegra210_cpu_max_freq_table[] = {
922b2dbc2fSJoseph Lo 	[0] = 1912500000UL,
932b2dbc2fSJoseph Lo 	[1] = 1912500000UL,
942b2dbc2fSJoseph Lo 	[2] = 2218500000UL,
952b2dbc2fSJoseph Lo 	[3] = 1785000000UL,
962b2dbc2fSJoseph Lo 	[4] = 1632000000UL,
972b2dbc2fSJoseph Lo 	[5] = 1912500000UL,
982b2dbc2fSJoseph Lo 	[6] = 2014500000UL,
992b2dbc2fSJoseph Lo 	[7] = 1734000000UL,
1002b2dbc2fSJoseph Lo 	[8] = 1683000000UL,
1012b2dbc2fSJoseph Lo 	[9] = 1555500000UL,
1022b2dbc2fSJoseph Lo 	[10] = 1504500000UL,
1032b2dbc2fSJoseph Lo };
1042b2dbc2fSJoseph Lo 
1052b2dbc2fSJoseph Lo #define CPU_CVB_TABLE \
1062b2dbc2fSJoseph Lo 	.speedo_scale = 100,	\
1072b2dbc2fSJoseph Lo 	.voltage_scale = 1000,	\
1082b2dbc2fSJoseph Lo 	.entries = {		\
1092b2dbc2fSJoseph Lo 		{  204000000UL,	{ 1007452, -23865, 370 } }, \
1102b2dbc2fSJoseph Lo 		{  306000000UL,	{ 1052709, -24875, 370 } }, \
1112b2dbc2fSJoseph Lo 		{  408000000UL,	{ 1099069, -25895, 370 } }, \
1122b2dbc2fSJoseph Lo 		{  510000000UL,	{ 1146534, -26905, 370 } }, \
1132b2dbc2fSJoseph Lo 		{  612000000UL,	{ 1195102, -27915, 370 } }, \
1142b2dbc2fSJoseph Lo 		{  714000000UL,	{ 1244773, -28925, 370 } }, \
1152b2dbc2fSJoseph Lo 		{  816000000UL,	{ 1295549, -29935, 370 } }, \
1162b2dbc2fSJoseph Lo 		{  918000000UL,	{ 1347428, -30955, 370 } }, \
1172b2dbc2fSJoseph Lo 		{ 1020000000UL,	{ 1400411, -31965, 370 } }, \
1182b2dbc2fSJoseph Lo 		{ 1122000000UL,	{ 1454497, -32975, 370 } }, \
1192b2dbc2fSJoseph Lo 		{ 1224000000UL,	{ 1509687, -33985, 370 } }, \
1202b2dbc2fSJoseph Lo 		{ 1326000000UL,	{ 1565981, -35005, 370 } }, \
1212b2dbc2fSJoseph Lo 		{ 1428000000UL,	{ 1623379, -36015, 370 } }, \
1222b2dbc2fSJoseph Lo 		{ 1530000000UL,	{ 1681880, -37025, 370 } }, \
1232b2dbc2fSJoseph Lo 		{ 1632000000UL,	{ 1741485, -38035, 370 } }, \
1242b2dbc2fSJoseph Lo 		{ 1734000000UL,	{ 1802194, -39055, 370 } }, \
1252b2dbc2fSJoseph Lo 		{ 1836000000UL,	{ 1864006, -40065, 370 } }, \
1262b2dbc2fSJoseph Lo 		{ 1912500000UL,	{ 1910780, -40815, 370 } }, \
1272b2dbc2fSJoseph Lo 		{ 2014500000UL,	{ 1227000,      0,   0 } }, \
1282b2dbc2fSJoseph Lo 		{ 2218500000UL,	{ 1227000,      0,   0 } }, \
1292b2dbc2fSJoseph Lo 		{          0UL,	{       0,      0,   0 } }, \
1302b2dbc2fSJoseph Lo 	}
1312b2dbc2fSJoseph Lo 
1322b2dbc2fSJoseph Lo #define CPU_CVB_TABLE_XA \
1332b2dbc2fSJoseph Lo 	.speedo_scale = 100,	\
1342b2dbc2fSJoseph Lo 	.voltage_scale = 1000,	\
1352b2dbc2fSJoseph Lo 	.entries = {		\
1362b2dbc2fSJoseph Lo 		{  204000000UL,	{ 1250024, -39785, 565 } }, \
1372b2dbc2fSJoseph Lo 		{  306000000UL,	{ 1297556, -41145, 565 } }, \
1382b2dbc2fSJoseph Lo 		{  408000000UL,	{ 1346718, -42505, 565 } }, \
1392b2dbc2fSJoseph Lo 		{  510000000UL,	{ 1397511, -43855, 565 } }, \
1402b2dbc2fSJoseph Lo 		{  612000000UL,	{ 1449933, -45215, 565 } }, \
1412b2dbc2fSJoseph Lo 		{  714000000UL,	{ 1503986, -46575, 565 } }, \
1422b2dbc2fSJoseph Lo 		{  816000000UL,	{ 1559669, -47935, 565 } }, \
1432b2dbc2fSJoseph Lo 		{  918000000UL,	{ 1616982, -49295, 565 } }, \
1442b2dbc2fSJoseph Lo 		{ 1020000000UL,	{ 1675926, -50645, 565 } }, \
1452b2dbc2fSJoseph Lo 		{ 1122000000UL,	{ 1736500, -52005, 565 } }, \
1462b2dbc2fSJoseph Lo 		{ 1224000000UL,	{ 1798704, -53365, 565 } }, \
1472b2dbc2fSJoseph Lo 		{ 1326000000UL,	{ 1862538, -54725, 565 } }, \
1482b2dbc2fSJoseph Lo 		{ 1428000000UL,	{ 1928003, -56085, 565 } }, \
1492b2dbc2fSJoseph Lo 		{ 1530000000UL,	{ 1995097, -57435, 565 } }, \
1502b2dbc2fSJoseph Lo 		{ 1606500000UL,	{ 2046149, -58445, 565 } }, \
1512b2dbc2fSJoseph Lo 		{ 1632000000UL,	{ 2063822, -58795, 565 } }, \
1522b2dbc2fSJoseph Lo 		{          0UL,	{       0,      0,   0 } }, \
1532b2dbc2fSJoseph Lo 	}
1542b2dbc2fSJoseph Lo 
1552b2dbc2fSJoseph Lo #define CPU_CVB_TABLE_EUCM1 \
1562b2dbc2fSJoseph Lo 	.speedo_scale = 100,	\
1572b2dbc2fSJoseph Lo 	.voltage_scale = 1000,	\
1582b2dbc2fSJoseph Lo 	.entries = {		\
1592b2dbc2fSJoseph Lo 		{  204000000UL,	{  734429, 0, 0 } }, \
1602b2dbc2fSJoseph Lo 		{  306000000UL,	{  768191, 0, 0 } }, \
1612b2dbc2fSJoseph Lo 		{  408000000UL,	{  801953, 0, 0 } }, \
1622b2dbc2fSJoseph Lo 		{  510000000UL,	{  835715, 0, 0 } }, \
1632b2dbc2fSJoseph Lo 		{  612000000UL,	{  869477, 0, 0 } }, \
1642b2dbc2fSJoseph Lo 		{  714000000UL,	{  903239, 0, 0 } }, \
1652b2dbc2fSJoseph Lo 		{  816000000UL,	{  937001, 0, 0 } }, \
1662b2dbc2fSJoseph Lo 		{  918000000UL,	{  970763, 0, 0 } }, \
1672b2dbc2fSJoseph Lo 		{ 1020000000UL,	{ 1004525, 0, 0 } }, \
1682b2dbc2fSJoseph Lo 		{ 1122000000UL,	{ 1038287, 0, 0 } }, \
1692b2dbc2fSJoseph Lo 		{ 1224000000UL,	{ 1072049, 0, 0 } }, \
1702b2dbc2fSJoseph Lo 		{ 1326000000UL,	{ 1105811, 0, 0 } }, \
1712b2dbc2fSJoseph Lo 		{ 1428000000UL,	{ 1130000, 0, 0 } }, \
1722b2dbc2fSJoseph Lo 		{ 1555500000UL,	{ 1130000, 0, 0 } }, \
1732b2dbc2fSJoseph Lo 		{ 1632000000UL,	{ 1170000, 0, 0 } }, \
1742b2dbc2fSJoseph Lo 		{ 1734000000UL,	{ 1227500, 0, 0 } }, \
1752b2dbc2fSJoseph Lo 		{          0UL,	{       0, 0, 0 } }, \
1762b2dbc2fSJoseph Lo 	}
1772b2dbc2fSJoseph Lo 
1782b2dbc2fSJoseph Lo #define CPU_CVB_TABLE_EUCM2 \
1792b2dbc2fSJoseph Lo 	.speedo_scale = 100,	\
1802b2dbc2fSJoseph Lo 	.voltage_scale = 1000,	\
1812b2dbc2fSJoseph Lo 	.entries = {		\
1822b2dbc2fSJoseph Lo 		{  204000000UL,	{  742283, 0, 0 } }, \
1832b2dbc2fSJoseph Lo 		{  306000000UL,	{  776249, 0, 0 } }, \
1842b2dbc2fSJoseph Lo 		{  408000000UL,	{  810215, 0, 0 } }, \
1852b2dbc2fSJoseph Lo 		{  510000000UL,	{  844181, 0, 0 } }, \
1862b2dbc2fSJoseph Lo 		{  612000000UL,	{  878147, 0, 0 } }, \
1872b2dbc2fSJoseph Lo 		{  714000000UL,	{  912113, 0, 0 } }, \
1882b2dbc2fSJoseph Lo 		{  816000000UL,	{  946079, 0, 0 } }, \
1892b2dbc2fSJoseph Lo 		{  918000000UL,	{  980045, 0, 0 } }, \
1902b2dbc2fSJoseph Lo 		{ 1020000000UL,	{ 1014011, 0, 0 } }, \
1912b2dbc2fSJoseph Lo 		{ 1122000000UL,	{ 1047977, 0, 0 } }, \
1922b2dbc2fSJoseph Lo 		{ 1224000000UL,	{ 1081943, 0, 0 } }, \
1932b2dbc2fSJoseph Lo 		{ 1326000000UL,	{ 1090000, 0, 0 } }, \
1942b2dbc2fSJoseph Lo 		{ 1479000000UL,	{ 1090000, 0, 0 } }, \
1952b2dbc2fSJoseph Lo 		{ 1555500000UL,	{ 1162000, 0, 0 } }, \
1962b2dbc2fSJoseph Lo 		{ 1683000000UL,	{ 1195000, 0, 0 } }, \
1972b2dbc2fSJoseph Lo 		{          0UL,	{       0, 0, 0 } }, \
1982b2dbc2fSJoseph Lo 	}
1992b2dbc2fSJoseph Lo 
2002b2dbc2fSJoseph Lo #define CPU_CVB_TABLE_EUCM2_JOINT_RAIL \
2012b2dbc2fSJoseph Lo 	.speedo_scale = 100,	\
2022b2dbc2fSJoseph Lo 	.voltage_scale = 1000,	\
2032b2dbc2fSJoseph Lo 	.entries = {		\
2042b2dbc2fSJoseph Lo 		{  204000000UL,	{  742283, 0, 0 } }, \
2052b2dbc2fSJoseph Lo 		{  306000000UL,	{  776249, 0, 0 } }, \
2062b2dbc2fSJoseph Lo 		{  408000000UL,	{  810215, 0, 0 } }, \
2072b2dbc2fSJoseph Lo 		{  510000000UL,	{  844181, 0, 0 } }, \
2082b2dbc2fSJoseph Lo 		{  612000000UL,	{  878147, 0, 0 } }, \
2092b2dbc2fSJoseph Lo 		{  714000000UL,	{  912113, 0, 0 } }, \
2102b2dbc2fSJoseph Lo 		{  816000000UL,	{  946079, 0, 0 } }, \
2112b2dbc2fSJoseph Lo 		{  918000000UL,	{  980045, 0, 0 } }, \
2122b2dbc2fSJoseph Lo 		{ 1020000000UL,	{ 1014011, 0, 0 } }, \
2132b2dbc2fSJoseph Lo 		{ 1122000000UL,	{ 1047977, 0, 0 } }, \
2142b2dbc2fSJoseph Lo 		{ 1224000000UL,	{ 1081943, 0, 0 } }, \
2152b2dbc2fSJoseph Lo 		{ 1326000000UL,	{ 1090000, 0, 0 } }, \
2162b2dbc2fSJoseph Lo 		{ 1479000000UL,	{ 1090000, 0, 0 } }, \
2172b2dbc2fSJoseph Lo 		{ 1504500000UL,	{ 1120000, 0, 0 } }, \
2182b2dbc2fSJoseph Lo 		{          0UL,	{       0, 0, 0 } }, \
2192b2dbc2fSJoseph Lo 	}
2202b2dbc2fSJoseph Lo 
2212b2dbc2fSJoseph Lo #define CPU_CVB_TABLE_ODN \
2222b2dbc2fSJoseph Lo 	.speedo_scale = 100,	\
2232b2dbc2fSJoseph Lo 	.voltage_scale = 1000,	\
2242b2dbc2fSJoseph Lo 	.entries = {		\
2252b2dbc2fSJoseph Lo 		{  204000000UL,	{  721094, 0, 0 } }, \
2262b2dbc2fSJoseph Lo 		{  306000000UL,	{  754040, 0, 0 } }, \
2272b2dbc2fSJoseph Lo 		{  408000000UL,	{  786986, 0, 0 } }, \
2282b2dbc2fSJoseph Lo 		{  510000000UL,	{  819932, 0, 0 } }, \
2292b2dbc2fSJoseph Lo 		{  612000000UL,	{  852878, 0, 0 } }, \
2302b2dbc2fSJoseph Lo 		{  714000000UL,	{  885824, 0, 0 } }, \
2312b2dbc2fSJoseph Lo 		{  816000000UL,	{  918770, 0, 0 } }, \
2322b2dbc2fSJoseph Lo 		{  918000000UL,	{  915716, 0, 0 } }, \
2332b2dbc2fSJoseph Lo 		{ 1020000000UL,	{  984662, 0, 0 } }, \
2342b2dbc2fSJoseph Lo 		{ 1122000000UL,	{ 1017608, 0, 0 } }, \
2352b2dbc2fSJoseph Lo 		{ 1224000000UL,	{ 1050554, 0, 0 } }, \
2362b2dbc2fSJoseph Lo 		{ 1326000000UL,	{ 1083500, 0, 0 } }, \
2372b2dbc2fSJoseph Lo 		{ 1428000000UL,	{ 1116446, 0, 0 } }, \
2382b2dbc2fSJoseph Lo 		{ 1581000000UL,	{ 1130000, 0, 0 } }, \
2392b2dbc2fSJoseph Lo 		{ 1683000000UL,	{ 1168000, 0, 0 } }, \
2402b2dbc2fSJoseph Lo 		{ 1785000000UL,	{ 1227500, 0, 0 } }, \
2412b2dbc2fSJoseph Lo 		{          0UL,	{       0, 0, 0 } }, \
2422b2dbc2fSJoseph Lo 	}
2432b2dbc2fSJoseph Lo 
244*bb872709SWei Yongjun static struct cvb_table tegra210_cpu_cvb_tables[] = {
2452b2dbc2fSJoseph Lo 	{
2462b2dbc2fSJoseph Lo 		.speedo_id = 10,
2472b2dbc2fSJoseph Lo 		.process_id = 0,
2482b2dbc2fSJoseph Lo 		.min_millivolts = 840,
2492b2dbc2fSJoseph Lo 		.max_millivolts = 1120,
2502b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_EUCM2_JOINT_RAIL,
2512b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
2522b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
2532b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
2542b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
2552b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
2562b2dbc2fSJoseph Lo 		}
2572b2dbc2fSJoseph Lo 	},
2582b2dbc2fSJoseph Lo 	{
2592b2dbc2fSJoseph Lo 		.speedo_id = 10,
2602b2dbc2fSJoseph Lo 		.process_id = 1,
2612b2dbc2fSJoseph Lo 		.min_millivolts = 840,
2622b2dbc2fSJoseph Lo 		.max_millivolts = 1120,
2632b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_EUCM2_JOINT_RAIL,
2642b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
2652b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
2662b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
2672b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
2682b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
2692b2dbc2fSJoseph Lo 		}
2702b2dbc2fSJoseph Lo 	},
2712b2dbc2fSJoseph Lo 	{
2722b2dbc2fSJoseph Lo 		.speedo_id = 9,
2732b2dbc2fSJoseph Lo 		.process_id = 0,
2742b2dbc2fSJoseph Lo 		.min_millivolts = 900,
2752b2dbc2fSJoseph Lo 		.max_millivolts = 1162,
2762b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_EUCM2,
2772b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
2782b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
2792b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
2802b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
2812b2dbc2fSJoseph Lo 		}
2822b2dbc2fSJoseph Lo 	},
2832b2dbc2fSJoseph Lo 	{
2842b2dbc2fSJoseph Lo 		.speedo_id = 9,
2852b2dbc2fSJoseph Lo 		.process_id = 1,
2862b2dbc2fSJoseph Lo 		.min_millivolts = 900,
2872b2dbc2fSJoseph Lo 		.max_millivolts = 1162,
2882b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_EUCM2,
2892b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
2902b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
2912b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
2922b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
2932b2dbc2fSJoseph Lo 		}
2942b2dbc2fSJoseph Lo 	},
2952b2dbc2fSJoseph Lo 	{
2962b2dbc2fSJoseph Lo 		.speedo_id = 8,
2972b2dbc2fSJoseph Lo 		.process_id = 0,
2982b2dbc2fSJoseph Lo 		.min_millivolts = 900,
2992b2dbc2fSJoseph Lo 		.max_millivolts = 1195,
3002b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_EUCM2,
3012b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
3022b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
3032b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
3042b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
3052b2dbc2fSJoseph Lo 		}
3062b2dbc2fSJoseph Lo 	},
3072b2dbc2fSJoseph Lo 	{
3082b2dbc2fSJoseph Lo 		.speedo_id = 8,
3092b2dbc2fSJoseph Lo 		.process_id = 1,
3102b2dbc2fSJoseph Lo 		.min_millivolts = 900,
3112b2dbc2fSJoseph Lo 		.max_millivolts = 1195,
3122b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_EUCM2,
3132b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
3142b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
3152b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
3162b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
3172b2dbc2fSJoseph Lo 		}
3182b2dbc2fSJoseph Lo 	},
3192b2dbc2fSJoseph Lo 	{
3202b2dbc2fSJoseph Lo 		.speedo_id = 7,
3212b2dbc2fSJoseph Lo 		.process_id = 0,
3222b2dbc2fSJoseph Lo 		.min_millivolts = 841,
3232b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
3242b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_EUCM1,
3252b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
3262b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
3272b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
3282b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
3292b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
3302b2dbc2fSJoseph Lo 		}
3312b2dbc2fSJoseph Lo 	},
3322b2dbc2fSJoseph Lo 	{
3332b2dbc2fSJoseph Lo 		.speedo_id = 7,
3342b2dbc2fSJoseph Lo 		.process_id = 1,
3352b2dbc2fSJoseph Lo 		.min_millivolts = 841,
3362b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
3372b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_EUCM1,
3382b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
3392b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
3402b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
3412b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
3422b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
3432b2dbc2fSJoseph Lo 		}
3442b2dbc2fSJoseph Lo 	},
3452b2dbc2fSJoseph Lo 	{
3462b2dbc2fSJoseph Lo 		.speedo_id = 6,
3472b2dbc2fSJoseph Lo 		.process_id = 0,
3482b2dbc2fSJoseph Lo 		.min_millivolts = 870,
3492b2dbc2fSJoseph Lo 		.max_millivolts = 1150,
3502b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
3512b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
3522b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
3532b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
3542b2dbc2fSJoseph Lo 		}
3552b2dbc2fSJoseph Lo 	},
3562b2dbc2fSJoseph Lo 	{
3572b2dbc2fSJoseph Lo 		.speedo_id = 6,
3582b2dbc2fSJoseph Lo 		.process_id = 1,
3592b2dbc2fSJoseph Lo 		.min_millivolts = 870,
3602b2dbc2fSJoseph Lo 		.max_millivolts = 1150,
3612b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
3622b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
3632b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
3642b2dbc2fSJoseph Lo 			.tune1 = 0x25501d0,
3652b2dbc2fSJoseph Lo 		}
3662b2dbc2fSJoseph Lo 	},
3672b2dbc2fSJoseph Lo 	{
3682b2dbc2fSJoseph Lo 		.speedo_id = 5,
3692b2dbc2fSJoseph Lo 		.process_id = 0,
3702b2dbc2fSJoseph Lo 		.min_millivolts = 818,
3712b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
3722b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
3732b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
3742b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
3752b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
3762b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
3772b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
3782b2dbc2fSJoseph Lo 		}
3792b2dbc2fSJoseph Lo 	},
3802b2dbc2fSJoseph Lo 	{
3812b2dbc2fSJoseph Lo 		.speedo_id = 5,
3822b2dbc2fSJoseph Lo 		.process_id = 1,
3832b2dbc2fSJoseph Lo 		.min_millivolts = 818,
3842b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
3852b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
3862b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
3872b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
3882b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
3892b2dbc2fSJoseph Lo 			.tune1 = 0x25501d0,
3902b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
3912b2dbc2fSJoseph Lo 		}
3922b2dbc2fSJoseph Lo 	},
3932b2dbc2fSJoseph Lo 	{
3942b2dbc2fSJoseph Lo 		.speedo_id = 4,
3952b2dbc2fSJoseph Lo 		.process_id = -1,
3962b2dbc2fSJoseph Lo 		.min_millivolts = 918,
3972b2dbc2fSJoseph Lo 		.max_millivolts = 1113,
3982b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_XA,
3992b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4002b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4012b2dbc2fSJoseph Lo 			.tune1 = 0x17711BD,
4022b2dbc2fSJoseph Lo 		}
4032b2dbc2fSJoseph Lo 	},
4042b2dbc2fSJoseph Lo 	{
4052b2dbc2fSJoseph Lo 		.speedo_id = 3,
4062b2dbc2fSJoseph Lo 		.process_id = 0,
4072b2dbc2fSJoseph Lo 		.min_millivolts = 825,
4082b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
4092b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_ODN,
4102b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4112b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4122b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
4132b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
4142b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
4152b2dbc2fSJoseph Lo 		}
4162b2dbc2fSJoseph Lo 	},
4172b2dbc2fSJoseph Lo 	{
4182b2dbc2fSJoseph Lo 		.speedo_id = 3,
4192b2dbc2fSJoseph Lo 		.process_id = 1,
4202b2dbc2fSJoseph Lo 		.min_millivolts = 825,
4212b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
4222b2dbc2fSJoseph Lo 		CPU_CVB_TABLE_ODN,
4232b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4242b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4252b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
4262b2dbc2fSJoseph Lo 			.tune1 = 0x25501d0,
4272b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
4282b2dbc2fSJoseph Lo 		}
4292b2dbc2fSJoseph Lo 	},
4302b2dbc2fSJoseph Lo 	{
4312b2dbc2fSJoseph Lo 		.speedo_id = 2,
4322b2dbc2fSJoseph Lo 		.process_id = 0,
4332b2dbc2fSJoseph Lo 		.min_millivolts = 870,
4342b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
4352b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
4362b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4372b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4382b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
4392b2dbc2fSJoseph Lo 		}
4402b2dbc2fSJoseph Lo 	},
4412b2dbc2fSJoseph Lo 	{
4422b2dbc2fSJoseph Lo 		.speedo_id = 2,
4432b2dbc2fSJoseph Lo 		.process_id = 1,
4442b2dbc2fSJoseph Lo 		.min_millivolts = 870,
4452b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
4462b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
4472b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4482b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4492b2dbc2fSJoseph Lo 			.tune1 = 0x25501d0,
4502b2dbc2fSJoseph Lo 		}
4512b2dbc2fSJoseph Lo 	},
4522b2dbc2fSJoseph Lo 	{
4532b2dbc2fSJoseph Lo 		.speedo_id = 1,
4542b2dbc2fSJoseph Lo 		.process_id = 0,
4552b2dbc2fSJoseph Lo 		.min_millivolts = 837,
4562b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
4572b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
4582b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4592b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4602b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
4612b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
4622b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
4632b2dbc2fSJoseph Lo 		}
4642b2dbc2fSJoseph Lo 	},
4652b2dbc2fSJoseph Lo 	{
4662b2dbc2fSJoseph Lo 		.speedo_id = 1,
4672b2dbc2fSJoseph Lo 		.process_id = 1,
4682b2dbc2fSJoseph Lo 		.min_millivolts = 837,
4692b2dbc2fSJoseph Lo 		.max_millivolts = 1227,
4702b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
4712b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4722b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4732b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
4742b2dbc2fSJoseph Lo 			.tune1 = 0x25501d0,
4752b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
4762b2dbc2fSJoseph Lo 		}
4772b2dbc2fSJoseph Lo 	},
4782b2dbc2fSJoseph Lo 	{
4792b2dbc2fSJoseph Lo 		.speedo_id = 0,
4802b2dbc2fSJoseph Lo 		.process_id = 0,
4812b2dbc2fSJoseph Lo 		.min_millivolts = 850,
4822b2dbc2fSJoseph Lo 		.max_millivolts = 1170,
4832b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
4842b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4852b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4862b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
4872b2dbc2fSJoseph Lo 			.tune1 = 0x20091d9,
4882b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
4892b2dbc2fSJoseph Lo 		}
4902b2dbc2fSJoseph Lo 	},
4912b2dbc2fSJoseph Lo 	{
4922b2dbc2fSJoseph Lo 		.speedo_id = 0,
4932b2dbc2fSJoseph Lo 		.process_id = 1,
4942b2dbc2fSJoseph Lo 		.min_millivolts = 850,
4952b2dbc2fSJoseph Lo 		.max_millivolts = 1170,
4962b2dbc2fSJoseph Lo 		CPU_CVB_TABLE,
4972b2dbc2fSJoseph Lo 		.cpu_dfll_data = {
4982b2dbc2fSJoseph Lo 			.tune0_low = 0xffead0ff,
4992b2dbc2fSJoseph Lo 			.tune0_high = 0xffead0ff,
5002b2dbc2fSJoseph Lo 			.tune1 = 0x25501d0,
5012b2dbc2fSJoseph Lo 			.tune_high_min_millivolts = 864,
5022b2dbc2fSJoseph Lo 		}
5032b2dbc2fSJoseph Lo 	},
5042b2dbc2fSJoseph Lo };
5052b2dbc2fSJoseph Lo 
506b0dcfb78SPeter De Schrijver static const struct dfll_fcpu_data tegra124_dfll_fcpu_data = {
507b0dcfb78SPeter De Schrijver 	.cpu_max_freq_table = tegra124_cpu_max_freq_table,
508b0dcfb78SPeter De Schrijver 	.cpu_max_freq_table_size = ARRAY_SIZE(tegra124_cpu_max_freq_table),
509b0dcfb78SPeter De Schrijver 	.cpu_cvb_tables = tegra124_cpu_cvb_tables,
510b0dcfb78SPeter De Schrijver 	.cpu_cvb_tables_size = ARRAY_SIZE(tegra124_cpu_cvb_tables)
511b0dcfb78SPeter De Schrijver };
512b0dcfb78SPeter De Schrijver 
5132b2dbc2fSJoseph Lo static const struct dfll_fcpu_data tegra210_dfll_fcpu_data = {
5142b2dbc2fSJoseph Lo 	.cpu_max_freq_table = tegra210_cpu_max_freq_table,
5152b2dbc2fSJoseph Lo 	.cpu_max_freq_table_size = ARRAY_SIZE(tegra210_cpu_max_freq_table),
5162b2dbc2fSJoseph Lo 	.cpu_cvb_tables = tegra210_cpu_cvb_tables,
5172b2dbc2fSJoseph Lo 	.cpu_cvb_tables_size = ARRAY_SIZE(tegra210_cpu_cvb_tables),
5182b2dbc2fSJoseph Lo };
5192b2dbc2fSJoseph Lo 
520b0dcfb78SPeter De Schrijver static const struct of_device_id tegra124_dfll_fcpu_of_match[] = {
521b0dcfb78SPeter De Schrijver 	{
522b0dcfb78SPeter De Schrijver 		.compatible = "nvidia,tegra124-dfll",
523b0dcfb78SPeter De Schrijver 		.data = &tegra124_dfll_fcpu_data,
524b0dcfb78SPeter De Schrijver 	},
5252b2dbc2fSJoseph Lo 	{
5262b2dbc2fSJoseph Lo 		.compatible = "nvidia,tegra210-dfll",
5272b2dbc2fSJoseph Lo 		.data = &tegra210_dfll_fcpu_data
5282b2dbc2fSJoseph Lo 	},
529b0dcfb78SPeter De Schrijver 	{ },
530b0dcfb78SPeter De Schrijver };
531b0dcfb78SPeter De Schrijver 
532b3cf8d06SJoseph Lo static void get_alignment_from_dt(struct device *dev,
533b3cf8d06SJoseph Lo 				  struct rail_alignment *align)
534b3cf8d06SJoseph Lo {
535b3cf8d06SJoseph Lo 	if (of_property_read_u32(dev->of_node,
536b3cf8d06SJoseph Lo 				 "nvidia,pwm-voltage-step-microvolts",
537b3cf8d06SJoseph Lo 				 &align->step_uv))
538b3cf8d06SJoseph Lo 		align->step_uv = 0;
539b3cf8d06SJoseph Lo 
540b3cf8d06SJoseph Lo 	if (of_property_read_u32(dev->of_node,
541b3cf8d06SJoseph Lo 				 "nvidia,pwm-min-microvolts",
542b3cf8d06SJoseph Lo 				 &align->offset_uv))
543b3cf8d06SJoseph Lo 		align->offset_uv = 0;
544b3cf8d06SJoseph Lo }
545b3cf8d06SJoseph Lo 
546b3cf8d06SJoseph Lo static int get_alignment_from_regulator(struct device *dev,
547b3cf8d06SJoseph Lo 					 struct rail_alignment *align)
548b3cf8d06SJoseph Lo {
549b3cf8d06SJoseph Lo 	struct regulator *reg = devm_regulator_get(dev, "vdd-cpu");
550b3cf8d06SJoseph Lo 
551b3cf8d06SJoseph Lo 	if (IS_ERR(reg))
552b3cf8d06SJoseph Lo 		return PTR_ERR(reg);
553b3cf8d06SJoseph Lo 
554b3cf8d06SJoseph Lo 	align->offset_uv = regulator_list_voltage(reg, 0);
555b3cf8d06SJoseph Lo 	align->step_uv = regulator_get_linear_step(reg);
556b3cf8d06SJoseph Lo 
557b3cf8d06SJoseph Lo 	devm_regulator_put(reg);
558b3cf8d06SJoseph Lo 
559b3cf8d06SJoseph Lo 	return 0;
560b3cf8d06SJoseph Lo }
561b3cf8d06SJoseph Lo 
56262a8a094STuomas Tynkkynen static int tegra124_dfll_fcpu_probe(struct platform_device *pdev)
56362a8a094STuomas Tynkkynen {
564f7c42d98SThierry Reding 	int process_id, speedo_id, speedo_value, err;
56562a8a094STuomas Tynkkynen 	struct tegra_dfll_soc_data *soc;
566b0dcfb78SPeter De Schrijver 	const struct dfll_fcpu_data *fcpu_data;
567b3cf8d06SJoseph Lo 	struct rail_alignment align;
568b0dcfb78SPeter De Schrijver 
569b0dcfb78SPeter De Schrijver 	fcpu_data = of_device_get_match_data(&pdev->dev);
570b0dcfb78SPeter De Schrijver 	if (!fcpu_data)
571b0dcfb78SPeter De Schrijver 		return -ENODEV;
57262a8a094STuomas Tynkkynen 
57362a8a094STuomas Tynkkynen 	process_id = tegra_sku_info.cpu_process_id;
57462a8a094STuomas Tynkkynen 	speedo_id = tegra_sku_info.cpu_speedo_id;
57562a8a094STuomas Tynkkynen 	speedo_value = tegra_sku_info.cpu_speedo_value;
57662a8a094STuomas Tynkkynen 
577b0dcfb78SPeter De Schrijver 	if (speedo_id >= fcpu_data->cpu_max_freq_table_size) {
57862a8a094STuomas Tynkkynen 		dev_err(&pdev->dev, "unknown max CPU freq for speedo_id=%d\n",
57962a8a094STuomas Tynkkynen 			speedo_id);
58062a8a094STuomas Tynkkynen 		return -ENODEV;
58162a8a094STuomas Tynkkynen 	}
58262a8a094STuomas Tynkkynen 
58362a8a094STuomas Tynkkynen 	soc = devm_kzalloc(&pdev->dev, sizeof(*soc), GFP_KERNEL);
58462a8a094STuomas Tynkkynen 	if (!soc)
58562a8a094STuomas Tynkkynen 		return -ENOMEM;
58662a8a094STuomas Tynkkynen 
58762a8a094STuomas Tynkkynen 	soc->dev = get_cpu_device(0);
58862a8a094STuomas Tynkkynen 	if (!soc->dev) {
58962a8a094STuomas Tynkkynen 		dev_err(&pdev->dev, "no CPU0 device\n");
59062a8a094STuomas Tynkkynen 		return -ENODEV;
59162a8a094STuomas Tynkkynen 	}
59262a8a094STuomas Tynkkynen 
593b3cf8d06SJoseph Lo 	if (of_property_read_bool(pdev->dev.of_node, "nvidia,pwm-to-pmic")) {
594b3cf8d06SJoseph Lo 		get_alignment_from_dt(&pdev->dev, &align);
595b3cf8d06SJoseph Lo 	} else {
596b3cf8d06SJoseph Lo 		err = get_alignment_from_regulator(&pdev->dev, &align);
597b3cf8d06SJoseph Lo 		if (err)
598b3cf8d06SJoseph Lo 			return err;
599b3cf8d06SJoseph Lo 	}
600f7c42d98SThierry Reding 
601b0dcfb78SPeter De Schrijver 	soc->max_freq = fcpu_data->cpu_max_freq_table[speedo_id];
60262a8a094STuomas Tynkkynen 
603b0dcfb78SPeter De Schrijver 	soc->cvb = tegra_cvb_add_opp_table(soc->dev, fcpu_data->cpu_cvb_tables,
604b0dcfb78SPeter De Schrijver 					   fcpu_data->cpu_cvb_tables_size,
605b3cf8d06SJoseph Lo 					   &align, process_id, speedo_id,
606b3cf8d06SJoseph Lo 					   speedo_value, soc->max_freq);
607b3cf8d06SJoseph Lo 	soc->alignment = align;
608b3cf8d06SJoseph Lo 
60927ed2f7eSThierry Reding 	if (IS_ERR(soc->cvb)) {
61027ed2f7eSThierry Reding 		dev_err(&pdev->dev, "couldn't add OPP table: %ld\n",
61127ed2f7eSThierry Reding 			PTR_ERR(soc->cvb));
61227ed2f7eSThierry Reding 		return PTR_ERR(soc->cvb);
61362a8a094STuomas Tynkkynen 	}
61462a8a094STuomas Tynkkynen 
615f7c42d98SThierry Reding 	err = tegra_dfll_register(pdev, soc);
616f7c42d98SThierry Reding 	if (err < 0) {
617f7c42d98SThierry Reding 		tegra_cvb_remove_opp_table(soc->dev, soc->cvb, soc->max_freq);
618f7c42d98SThierry Reding 		return err;
619f7c42d98SThierry Reding 	}
62062a8a094STuomas Tynkkynen 
621f7c42d98SThierry Reding 	return 0;
622f7c42d98SThierry Reding }
623f7c42d98SThierry Reding 
624f7c42d98SThierry Reding static int tegra124_dfll_fcpu_remove(struct platform_device *pdev)
625f7c42d98SThierry Reding {
6261752c9eeSNicolin Chen 	struct tegra_dfll_soc_data *soc;
627f7c42d98SThierry Reding 
6281752c9eeSNicolin Chen 	soc = tegra_dfll_unregister(pdev);
629d39eca54SDan Carpenter 	if (IS_ERR(soc)) {
6301752c9eeSNicolin Chen 		dev_err(&pdev->dev, "failed to unregister DFLL: %ld\n",
6311752c9eeSNicolin Chen 			PTR_ERR(soc));
632d39eca54SDan Carpenter 		return PTR_ERR(soc);
633d39eca54SDan Carpenter 	}
634f7c42d98SThierry Reding 
635f7c42d98SThierry Reding 	tegra_cvb_remove_opp_table(soc->dev, soc->cvb, soc->max_freq);
636f7c42d98SThierry Reding 
637f7c42d98SThierry Reding 	return 0;
63862a8a094STuomas Tynkkynen }
63962a8a094STuomas Tynkkynen 
64062a8a094STuomas Tynkkynen static const struct dev_pm_ops tegra124_dfll_pm_ops = {
64162a8a094STuomas Tynkkynen 	SET_RUNTIME_PM_OPS(tegra_dfll_runtime_suspend,
64262a8a094STuomas Tynkkynen 			   tegra_dfll_runtime_resume, NULL)
64362a8a094STuomas Tynkkynen };
64462a8a094STuomas Tynkkynen 
64562a8a094STuomas Tynkkynen static struct platform_driver tegra124_dfll_fcpu_driver = {
64662a8a094STuomas Tynkkynen 	.probe = tegra124_dfll_fcpu_probe,
647f7c42d98SThierry Reding 	.remove = tegra124_dfll_fcpu_remove,
64862a8a094STuomas Tynkkynen 	.driver = {
64962a8a094STuomas Tynkkynen 		.name = "tegra124-dfll",
65062a8a094STuomas Tynkkynen 		.of_match_table = tegra124_dfll_fcpu_of_match,
65162a8a094STuomas Tynkkynen 		.pm = &tegra124_dfll_pm_ops,
65262a8a094STuomas Tynkkynen 	},
65362a8a094STuomas Tynkkynen };
6546f877e79SWei Yongjun builtin_platform_driver(tegra124_dfll_fcpu_driver);
655