From d87f82967fc90ca23672451f55eeb2a36f2f36c7 Mon Sep 17 00:00:00 2001
From: Tom Rini <trini@konsulko.com>
Date: Fri, 12 May 2017 22:33:17 -0400
Subject: [PATCH] omap5: Migrate CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC to
 Kconfig

While in theory this value could be used in places outside of "omap5"
(such as OMAP4), we only make use of it today in OMAP5, so place the
Kconfig entry there.  Given that Kconfig lets us provide a default, we
drop CONFIG_DEFAULT_OMAP_RESET_TIME_MAX_USEC entirely.  The contents of
doc/README.omap-reset-time make a good help entry, so adjust them
slightly and delete the file.  Move the comment about range to where we
use the value now, and have Kconfig enforce the upper bound.

Signed-off-by: Tom Rini <trini@konsulko.com>
---
 README                                  |  5 -----
 arch/arm/include/asm/arch-omap5/clock.h |  7 -------
 arch/arm/mach-omap2/omap5/Kconfig       | 17 +++++++++++++++++
 arch/arm/mach-omap2/omap5/hwinit.c      | 13 +++++++------
 configs/cm_t54_defconfig                |  1 +
 configs/omap5_uevm_defconfig            |  1 +
 doc/README.omap-reset-time              | 20 --------------------
 include/configs/cm_t54.h                |  3 ---
 include/configs/omap5_uevm.h            |  3 ---
 scripts/config_whitelist.txt            |  2 --
 10 files changed, 26 insertions(+), 46 deletions(-)
 delete mode 100644 doc/README.omap-reset-time

diff --git a/README b/README
index 2ca0102b57..f4eecd0a0b 100644
--- a/README
+++ b/README
@@ -3708,11 +3708,6 @@ Configuration Settings:
 	If defined, don't allow the -f switch to env set override variable
 	access flags.
 
-- CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC (OMAP only)
-	This is set by OMAP boards for the max time that reset should
-	be asserted. See doc/README.omap-reset-time for details on how
-	the value can be calculated on a given board.
-
 - CONFIG_USE_STDINT
 	If stdint.h is available with your toolchain you can define this
 	option to enable it. You can provide option 'USE_STDINT=1' when
diff --git a/arch/arm/include/asm/arch-omap5/clock.h b/arch/arm/include/asm/arch-omap5/clock.h
index 7ea7199f2b..0c99bbdc93 100644
--- a/arch/arm/include/asm/arch-omap5/clock.h
+++ b/arch/arm/include/asm/arch-omap5/clock.h
@@ -370,13 +370,6 @@
 #define DPLL_NO_LOCK	0
 #define DPLL_LOCK	1
 
-/*
- * MAX value for PRM_RSTTIME[9:0]RSTTIME1 stored is 0x3ff.
- * 0x3ff is in the no of FUNC_32K_CLK cycles. Converting cycles
- * into microsec and passing the value.
- */
-#define CONFIG_DEFAULT_OMAP_RESET_TIME_MAX_USEC	31219
-
 #if defined(CONFIG_DRA7XX)
 #define V_OSCK			20000000	/* Clock output from T2 */
 #else
diff --git a/arch/arm/mach-omap2/omap5/Kconfig b/arch/arm/mach-omap2/omap5/Kconfig
index c89c438305..1a66abdeb2 100644
--- a/arch/arm/mach-omap2/omap5/Kconfig
+++ b/arch/arm/mach-omap2/omap5/Kconfig
@@ -63,6 +63,23 @@ config TI_SECURE_EMIF_PROTECTED_REGION_SIZE
 	  using hardware memory firewalls. This value must be smaller than the
 	  TI_SECURE_EMIF_TOTAL_REGION_SIZE value.
 
+config OMAP_PLATFORM_RESET_TIME_MAX_USEC
+	int "Something"
+	range 0  31219
+	default 31219
+	help
+	  Most OMAPs' provide a way to specify the time for which the reset
+	  should be held low while the voltages and Oscillator outputs
+	  stabilize.
+	  This time is mostly board and PMIC dependent. Hence the boards are
+	  expected to specify a pre-computed time using the above option.
+	  This value can be computed using a summation of the below 3
+	  parameters
+	  1: Time taken by the Osciallator to stop and restart
+	  2: PMIC OTP time
+	  3: Voltage ramp time, which can be derived using the PMIC slew rate
+	     and value of voltage ramp needed.
+
 if TARGET_DRA7XX_EVM || TARGET_AM57XX_EVM
 menu "Voltage Domain OPP selections"
 
diff --git a/arch/arm/mach-omap2/omap5/hwinit.c b/arch/arm/mach-omap2/omap5/hwinit.c
index 839d79d102..afe59e0b58 100644
--- a/arch/arm/mach-omap2/omap5/hwinit.c
+++ b/arch/arm/mach-omap2/omap5/hwinit.c
@@ -414,12 +414,13 @@ void setup_warmreset_time(void)
 {
 	u32 rst_time, rst_val;
 
-#ifndef CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC
-	rst_time = CONFIG_DEFAULT_OMAP_RESET_TIME_MAX_USEC;
-#else
-	rst_time = CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC;
-#endif
-	rst_time = usec_to_32k(rst_time) << RSTTIME1_SHIFT;
+	/*
+	 * MAX value for PRM_RSTTIME[9:0]RSTTIME1 stored is 0x3ff.
+	 * 0x3ff is in the no of FUNC_32K_CLK cycles. Converting cycles
+	 * into microsec and passing the value.
+	 */
+	rst_time = usec_to_32k(CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC)
+		<< RSTTIME1_SHIFT;
 
 	if (rst_time > RSTTIME1_MASK)
 		rst_time = RSTTIME1_MASK;
diff --git a/configs/cm_t54_defconfig b/configs/cm_t54_defconfig
index d7fd995f7a..0afc6a2741 100644
--- a/configs/cm_t54_defconfig
+++ b/configs/cm_t54_defconfig
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_OMAP2PLUS=y
 CONFIG_OMAP54XX=y
 CONFIG_TARGET_CM_T54=y
+CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC=16296
 # CONFIG_SPL_NAND_SUPPORT is not set
 CONFIG_OF_BOARD_SETUP=y
 CONFIG_BOOTDELAY=3
diff --git a/configs/omap5_uevm_defconfig b/configs/omap5_uevm_defconfig
index 865845ee9c..9eefec5cd5 100644
--- a/configs/omap5_uevm_defconfig
+++ b/configs/omap5_uevm_defconfig
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_ARCH_OMAP2PLUS=y
 CONFIG_OMAP54XX=y
 CONFIG_TARGET_OMAP5_UEVM=y
+CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC=16296
 # CONFIG_SPL_NAND_SUPPORT is not set
 CONFIG_ARMV7_LPAE=y
 CONFIG_SYS_CONSOLE_INFO_QUIET=y
diff --git a/doc/README.omap-reset-time b/doc/README.omap-reset-time
deleted file mode 100644
index 0c974bacae..0000000000
--- a/doc/README.omap-reset-time
+++ /dev/null
@@ -1,20 +0,0 @@
-README on how reset time on OMAPs should be calculated
-
-CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC:
-Most OMAPs' provide a way to specify the time for
-which the reset should be held low while the voltages
-and Oscillator outputs stabilize.
-
-This time is mostly board and PMIC dependent. Hence the
-boards are expected to specify a pre-computed time
-using the above option, (the details on how to compute
-the value are given below) without which a default time
-as specified by CONFIG_DEFAULT_OMAP_RESET_TIME_MAX_USEC
-is used.
-
-The value for CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC
-can be computed using a summation of the below 3 parameters
--1- Time taken by the Osciallator to stop and restart
--2- PMIC OTP time
--3- Voltage ramp time, which can be derived using the
-PMIC slew rate and value of voltage ramp needed.
diff --git a/include/configs/cm_t54.h b/include/configs/cm_t54.h
index 477aa07bd8..d7e7c29298 100644
--- a/include/configs/cm_t54.h
+++ b/include/configs/cm_t54.h
@@ -86,9 +86,6 @@
 #define CONFIG_USB_ETHER_ASIX
 #define CONFIG_USB_ETHER_MCS7830
 
-/* Max time to hold reset on this board, see doc/README.omap-reset-time */
-#define CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC	16296
-
 /*
  * Miscellaneous configurable options
  */
diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
index 533bb02c5e..6ac5d506f6 100644
--- a/include/configs/omap5_uevm.h
+++ b/include/configs/omap5_uevm.h
@@ -68,9 +68,6 @@
 
 #define CONSOLEDEV		"ttyO2"
 
-/* Max time to hold reset on this board, see doc/README.omap-reset-time */
-#define CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC	16296
-
 #define CONFIG_SCSI
 #define CONFIG_LIBATA
 #define CONFIG_SCSI_AHCI
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 5febd2a1d7..87719048ca 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -617,7 +617,6 @@ CONFIG_DEEP_SLEEP
 CONFIG_DEFAULT
 CONFIG_DEFAULT_CONSOLE
 CONFIG_DEFAULT_IMMR
-CONFIG_DEFAULT_OMAP_RESET_TIME_MAX_USEC
 CONFIG_DEFAULT_SPI_BUS
 CONFIG_DEFAULT_SPI_CS
 CONFIG_DEFAULT_SPI_MODE
@@ -1999,7 +1998,6 @@ CONFIG_OMAP_EHCI_PHY1_RESET_GPIO
 CONFIG_OMAP_EHCI_PHY2_RESET_GPIO
 CONFIG_OMAP_EHCI_PHY3_RESET_GPIO
 CONFIG_OMAP_GPIO
-CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC
 CONFIG_OMAP_USB2PHY2_HOST
 CONFIG_OMAP_USB3PHY1_HOST
 CONFIG_OMAP_USB_PHY
-- 
2.39.5