[x-loader][PATCH RFC 00/13] Remove and move duplicated code

42 views
Skip to first unread message

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:12 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
Hello,

This is an attempt to remove the duplicated code present in diferents boards,
the idea is move common functions to cpu/omap3/sys_info.c file, like u-boot.

As this moves a lot of code must be really tested for all OMAP3 boards, I've
tested on IGEP0020, IGEP0030, OMAP3EVM and BEAGLEBOARD booting from SDCARD.

I don't have tested yet booting from flash device.

If someone would like to test can pull the patches from:
URL: git://git.igep.es/pub/scm/x-loader.git
Branch: for-next

I'm waiting for your comments.

Cheers,

Enric Balletbo i Serra (13):
igep00x0: Remove dummy and unnused functions
OMAP3: Move get_device_type() function to not duplicate code
OMAP3: Move get_cpu_type() function to not duplicate code
OMAP3: Move get_cpu_id() function to not duplicate code
OMAP3: Move get_cpu_family() function to not duplicate code
OMAP3: Move get_cpu_rev() function to not duplicate code
OMAP3: Move print_cpuinfo() function to not duplicate code
OMAP3: Move get_sysboot_value() function to not duplicate code
OMAP3: Move sr32() function to not duplicate code
OMAP3: Move wait_on_value() function to not duplicate code
OMAP3: Move get_sys_clkin_sel() function to not duplicate code
OMAP3: Move secure_unlock() function to not duplicate code
OMAP3: Move try_unlock_memory() function to not duplicate code

board/igep00x0/igep00x0.c | 291 -------------------------------
board/omap3430labrador/omap3430sdp.c | 129 --------------
board/omap3430sdp/omap3430sdp.c | 129 --------------
board/omap3530beagle/omap3530beagle.c | 138 ---------------
board/omap3evm/omap3evm.c | 138 ---------------
board/overo/overo.c | 285 ------------------------------
cpu/omap3/Makefile | 2 +-
cpu/omap3/sys_info.c | 309 +++++++++++++++++++++++++++++++++
include/asm/arch-omap3/sys_proto.h | 5 +
9 files changed, 315 insertions(+), 1111 deletions(-)
create mode 100644 cpu/omap3/sys_info.c

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:13 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The abort() is a dummy function that is not being used, and the
get_sysboot_value() function is not being used on IGEP boards, so it's
safe to remove these functions.

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---
board/igep00x0/igep00x0.c | 16 ----------------
1 files changed, 0 insertions(+), 16 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index f8de400..b794abb 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -94,16 +94,6 @@ u32 get_device_type(void)
return mode >>= 8;
}

-/************************************************
- * get_sysboot_value(void) - return SYS_BOOT[4:0]
- ************************************************/
-u32 get_sysboot_value(void)
-{
- int mode;
- mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
- return mode;
-}
-
/*************************************************************
* Routine: get_mem_type(void) - returns the kind of memory connected
* to GPMC that we are trying to boot form. Uses SYS BOOT settings.
@@ -971,9 +961,3 @@ void raise(void)
{
}

-/******************************************************************************
- * Dummy function to handle errors for EABI incompatibility
- *****************************************************************************/
-void abort(void)
-{
-}
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:14 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The get_device_type() function is implemented by various boards, this
patch moves this function to a common place to not duplicate code.

board/omap3530beagle/omap3530beagle.c:97:u32 get_device_type(void)
board/igep00x0/igep00x0.c :90:u32 get_device_type(void)
board/omap3430sdp/omap3430sdp.c :82:u32 get_device_type(void)
board/omap3evm/omap3evm.c :84:u32 get_device_type(void)
board/omap3430labrador/omap3430sdp.c :79:u32 get_device_type(void)
board/overo/overo.c :105:u32 get_device_type(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 10 ---------
board/omap3430labrador/omap3430sdp.c | 10 ---------
board/omap3430sdp/omap3430sdp.c | 10 ---------
board/omap3530beagle/omap3530beagle.c | 10 ---------
board/omap3evm/omap3evm.c | 10 ---------
board/overo/overo.c | 10 ---------
cpu/omap3/Makefile | 2 +-
cpu/omap3/sys_info.c | 35 +++++++++++++++++++++++++++++++++
8 files changed, 36 insertions(+), 61 deletions(-)
create mode 100644 cpu/omap3/sys_info.c

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index b794abb..1666337 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -85,16 +85,6 @@ void udelay (unsigned long usecs) {
}

/*************************************************************
- * get_device_type(): tell if GP/HS/EMU/TST
- *************************************************************/
-u32 get_device_type(void)
-{
- int mode;
- mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
- return mode >>= 8;
-}
-
-/*************************************************************


* Routine: get_mem_type(void) - returns the kind of memory connected
* to GPMC that we are trying to boot form. Uses SYS BOOT settings.

*************************************************************/
diff --git a/board/omap3430labrador/omap3430sdp.c b/board/omap3430labrador/omap3430sdp.c
index 89d9ff1..0312d66 100644
--- a/board/omap3430labrador/omap3430sdp.c
+++ b/board/omap3430labrador/omap3430sdp.c
@@ -73,16 +73,6 @@ int board_init (void)
return 0;
}

-/*************************************************************
- * get_device_type(): tell if GP/HS/EMU/TST
- *************************************************************/
-u32 get_device_type(void)
-{
- int mode;
- mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
- return(mode >>= 8);
-}
-
/******************************************
* get_cpu_rev(void) - extract version info
******************************************/
diff --git a/board/omap3430sdp/omap3430sdp.c b/board/omap3430sdp/omap3430sdp.c
index 6ed62bc..7cb45bb 100644
--- a/board/omap3430sdp/omap3430sdp.c
+++ b/board/omap3430sdp/omap3430sdp.c
@@ -76,16 +76,6 @@ int board_init (void)
return 0;
}

-/*************************************************************
- * get_device_type(): tell if GP/HS/EMU/TST
- *************************************************************/
-u32 get_device_type(void)
-{
- int mode;
- mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
- return(mode >>= 8);
-}
-
/******************************************
* get_cpu_rev(void) - extract version info
******************************************/
diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
index 15943f5..0402a57 100644
--- a/board/omap3530beagle/omap3530beagle.c
+++ b/board/omap3530beagle/omap3530beagle.c
@@ -91,16 +91,6 @@ int board_init(void)
return 0;
}

-/*************************************************************
- * get_device_type(): tell if GP/HS/EMU/TST
- *************************************************************/
-u32 get_device_type(void)
-{
- int mode;
- mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
- return mode >>= 8;
-}
-
/************************************************


* get_sysboot_value(void) - return SYS_BOOT[4:0]

************************************************/
diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c
index 16c1f70..4f1fedd 100644
--- a/board/omap3evm/omap3evm.c
+++ b/board/omap3evm/omap3evm.c
@@ -78,16 +78,6 @@ int board_init (void)
return 0;
}

-/*************************************************************
- * get_device_type(): tell if GP/HS/EMU/TST
- *************************************************************/
-u32 get_device_type(void)
-{
- int mode;
- mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
- return(mode >>= 8);
-}
-
/************************************************


* get_sysboot_value(void) - return SYS_BOOT[4:0]

************************************************/
diff --git a/board/overo/overo.c b/board/overo/overo.c
index b2c536a..b942c5b 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -99,16 +99,6 @@ int board_init(void)
return 0;
}

-/*************************************************************
- * get_device_type(): tell if GP/HS/EMU/TST
- *************************************************************/
-u32 get_device_type(void)
-{
- int mode;
- mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
- return mode >>= 8;
-}
-
/************************************************


* get_sysboot_value(void) - return SYS_BOOT[4:0]

************************************************/
diff --git a/cpu/omap3/Makefile b/cpu/omap3/Makefile
index 678619c..eba6987 100644
--- a/cpu/omap3/Makefile
+++ b/cpu/omap3/Makefile
@@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(CPU).a

START = start.o
-COBJS = cpu.o mmc.o gpio.o
+COBJS = cpu.o mmc.o gpio.o sys_info.o

SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
new file mode 100644
index 0000000..f6cb65f
--- /dev/null
+++ b/cpu/omap3/sys_info.c
@@ -0,0 +1,35 @@
+/*
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/bits.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/arch/sys_info.h>
+
+/*
+ * get_device_type(): tell if GP/HS/EMU/TST
+ */
+u32 get_device_type(void)
+{
+ int mode;
+ mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
+ return mode >>= 8;
+}
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:15 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The get_cpu_type() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/igep00x0/igep00x0.c :99:u32 get_cpu_type(void)
board/overo/overo.c :164:u32 get_cpu_type(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 8 --------
board/overo/overo.c | 8 --------
cpu/omap3/sys_info.c | 8 ++++++++
3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index 1666337..b9a1dcd 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -94,14 +94,6 @@ u32 get_mem_type(void)
}

/******************************************
- * get_cpu_type(void) - extract cpu info
- ******************************************/
-u32 get_cpu_type(void)
-{
- return __raw_readl(CONTROL_OMAP_STATUS);
-}
-
-/******************************************
* get_cpu_id(void) - extract cpu id
* returns 0 for ES1.0, cpuid otherwise


******************************************/
diff --git a/board/overo/overo.c b/board/overo/overo.c

index b942c5b..b157b0e 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -159,14 +159,6 @@ u32 get_mem_type(void)
}

/******************************************
- * get_cpu_type(void) - extract cpu info
- ******************************************/
-u32 get_cpu_type(void)
-{
- return __raw_readl(CONTROL_OMAP_STATUS);
-}
-
-/******************************************
* get_cpu_id(void) - extract cpu id
* returns 0 for ES1.0, cpuid otherwise
******************************************/
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index f6cb65f..49ee4d5 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -33,3 +33,11 @@ u32 get_device_type(void)


mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);

return mode >>= 8;
}
+

+/*
+ * get_cpu_type(): extract cpu info
+ */
+u32 get_cpu_type(void)
+{
+ return __raw_readl(CONTROL_OMAP_STATUS);
+}
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:16 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The get_cpu_id() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/igep00x0/igep00x0.c :100:u32 get_cpu_id(void)
board/overo/overo.c :165:u32 get_cpu_id(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 23 -----------------------
board/overo/overo.c | 23 -----------------------
cpu/omap3/sys_info.c | 23 +++++++++++++++++++++++
3 files changed, 23 insertions(+), 46 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index b9a1dcd..bb45637 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -93,29 +93,6 @@ u32 get_mem_type(void)
return GPMC_ONENAND;
}

-/******************************************
- * get_cpu_id(void) - extract cpu id
- * returns 0 for ES1.0, cpuid otherwise
- ******************************************/
-u32 get_cpu_id(void)
-{
- u32 cpuid = 0;
-
- /*
- * On ES1.0 the IDCODE register is not exposed on L4
- * so using CPU ID to differentiate between ES1.0 and > ES1.0.
- */
- __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
- if ((cpuid & 0xf) == 0x0) {
- return 0;
- } else {
- /* Decode the IDs on > ES1.0 */
- cpuid = __raw_readl(CONTROL_IDCODE);
- }
-
- return cpuid;
-}
-
/*****************************************************************
* sr32 - clear & set a value in a bit range for a 32 bit address
*****************************************************************/
diff --git a/board/overo/overo.c b/board/overo/overo.c
index b157b0e..165c503 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -159,29 +159,6 @@ u32 get_mem_type(void)
}

/******************************************
- * get_cpu_id(void) - extract cpu id
- * returns 0 for ES1.0, cpuid otherwise
- ******************************************/
-u32 get_cpu_id(void)
-{
- u32 cpuid = 0;
-
- /*
- * On ES1.0 the IDCODE register is not exposed on L4
- * so using CPU ID to differentiate between ES1.0 and > ES1.0.
- */
- __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
- if ((cpuid & 0xf) == 0x0) {
- return 0;
- } else {
- /* Decode the IDs on > ES1.0 */
- cpuid = __raw_readl(CONTROL_IDCODE);
- }
-
- return cpuid;
-}
-
-/******************************************
* get_cpu_family(void) - extract cpu info
******************************************/
u32 get_cpu_family(void)
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index 49ee4d5..8422b4e 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -41,3 +41,26 @@ u32 get_cpu_type(void)
{
return __raw_readl(CONTROL_OMAP_STATUS);
}
+
+/*
+ * get_cpu_id(): extract cpu id
+ * returns 0 for ES1.0, cpuid otherwise
+ */
+u32 get_cpu_id(void)
+{
+ u32 cpuid = 0;
+
+ /*
+ * On ES1.0 the IDCODE register is not exposed on L4
+ * so using CPU ID to differentiate between ES1.0 and > ES1.0.
+ */
+ __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
+ if ((cpuid & 0xf) == 0x0) {
+ return 0;
+ } else {
+ /* Decode the IDs on > ES1.0 */
+ cpuid = __raw_readl(CONTROL_IDCODE);
+ }
+
+ return cpuid;
+}
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:17 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The get_cpu_family() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/igep00x0/igep00x0.c :129:u32 get_cpu_family(void)
board/overo/overo.c :164:u32 get_cpu_family(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 30 ------------------------------
board/overo/overo.c | 30 ------------------------------
cpu/omap3/sys_info.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 30 insertions(+), 60 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index bb45637..ab90606 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -124,36 +124,6 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
}

/******************************************
- * get_cpu_family(void) - extract cpu info
- ******************************************/
-u32 get_cpu_family(void)
-{
- u16 hawkeye;
- u32 cpu_family;
- u32 cpuid = get_cpu_id();
-
- if (cpuid == 0)
- return CPU_OMAP34XX;
-
- hawkeye = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
- switch (hawkeye) {
- case HAWKEYE_OMAP34XX:
- cpu_family = CPU_OMAP34XX;
- break;
- case HAWKEYE_AM35XX:
- cpu_family = CPU_AM35XX;
- break;
- case HAWKEYE_OMAP36XX:
- cpu_family = CPU_OMAP36XX;
- break;
- default:
- cpu_family = CPU_OMAP34XX;
- }
-
- return cpu_family;
-}
-
-/******************************************


* get_cpu_rev(void) - extract version info
******************************************/

u32 get_cpu_rev(void)
diff --git a/board/overo/overo.c b/board/overo/overo.c
index 165c503..bd03b55 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -159,36 +159,6 @@ u32 get_mem_type(void)
}

/******************************************
- * get_cpu_family(void) - extract cpu info
- ******************************************/
-u32 get_cpu_family(void)
-{
- u16 hawkeye;
- u32 cpu_family;
- u32 cpuid = get_cpu_id();
-
- if (cpuid == 0)
- return CPU_OMAP34XX;
-
- hawkeye = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
- switch (hawkeye) {
- case HAWKEYE_OMAP34XX:
- cpu_family = CPU_OMAP34XX;
- break;
- case HAWKEYE_AM35XX:
- cpu_family = CPU_AM35XX;
- break;
- case HAWKEYE_OMAP36XX:
- cpu_family = CPU_OMAP36XX;
- break;
- default:
- cpu_family = CPU_OMAP34XX;
- }
-
- return cpu_family;
-}
-
-/******************************************


* get_cpu_rev(void) - extract version info
******************************************/

u32 get_cpu_rev(void)
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index 8422b4e..ef18d60 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -64,3 +64,33 @@ u32 get_cpu_id(void)

return cpuid;
}
+
+/*
+ * get_cpu_family(void): extract cpu info
+ */
+u32 get_cpu_family(void)
+{
+ u16 hawkeye;
+ u32 cpu_family;
+ u32 cpuid = get_cpu_id();
+
+ if (cpuid == 0)
+ return CPU_OMAP34XX;
+
+ hawkeye = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
+ switch (hawkeye) {
+ case HAWKEYE_OMAP34XX:
+ cpu_family = CPU_OMAP34XX;
+ break;
+ case HAWKEYE_AM35XX:
+ cpu_family = CPU_AM35XX;
+ break;
+ case HAWKEYE_OMAP36XX:
+ cpu_family = CPU_OMAP36XX;
+ break;
+ default:
+ cpu_family = CPU_OMAP34XX;
+ }
+
+ return cpu_family;
+}
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:18 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The get_cpu_rev() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/omap3530beagle/omap3530beagle.c :159:u32 get_cpu_rev(void)
board/igep00x0/igep00x0.c :129:u32 get_cpu_rev(void)
board/omap3430sdp/omap3430sdp.c :82:u32 get_cpu_rev(void)
board/omap3evm/omap3evm.c :135:u32 get_cpu_rev(void)
board/omap3430labrador/omap3430sdp.c :79:u32 get_cpu_rev(void)
board/overo/overo.c :164:u32 get_cpu_rev(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 13 -------------
board/omap3430labrador/omap3430sdp.c | 18 ------------------
board/omap3430sdp/omap3430sdp.c | 18 ------------------
board/omap3530beagle/omap3530beagle.c | 18 ------------------
board/omap3evm/omap3evm.c | 18 ------------------
board/overo/overo.c | 13 -------------
cpu/omap3/sys_info.c | 13 +++++++++++++
7 files changed, 13 insertions(+), 98 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index ab90606..a876da3 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -124,19 +124,6 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
}

/******************************************
- * get_cpu_rev(void) - extract version info
- ******************************************/
-u32 get_cpu_rev(void)
-{


- u32 cpuid = get_cpu_id();
-
- if (cpuid == 0)

- return CPU_3XX_ES10;
- else
- return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
-}
-
-/******************************************
* Print CPU information
******************************************/
int print_cpuinfo (void)
diff --git a/board/omap3430labrador/omap3430sdp.c b/board/omap3430labrador/omap3430sdp.c
index 0312d66..7fcaec1 100644
--- a/board/omap3430labrador/omap3430sdp.c
+++ b/board/omap3430labrador/omap3430sdp.c
@@ -74,24 +74,6 @@ int board_init (void)
}

/******************************************
- * get_cpu_rev(void) - extract version info
- ******************************************/
-u32 get_cpu_rev(void)
-{
- u32 cpuid=0;
- /* On ES1.0 the IDCODE register is not exposed on L4


- * so using CPU ID to differentiate

- * between ES2.0 and ES1.0.


- */
- __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r" (cpuid));

- if((cpuid & 0xf) == 0x0)
- return CPU_3430_ES1;
- else
- return CPU_3430_ES2;
-
-}
-
-/******************************************
* cpu_is_3410(void) - returns true for 3410
******************************************/
u32 cpu_is_3410(void)
diff --git a/board/omap3430sdp/omap3430sdp.c b/board/omap3430sdp/omap3430sdp.c
index 7cb45bb..a0b0d0e 100644
--- a/board/omap3430sdp/omap3430sdp.c
+++ b/board/omap3430sdp/omap3430sdp.c
@@ -77,24 +77,6 @@ int board_init (void)
}

/******************************************
- * get_cpu_rev(void) - extract version info
- ******************************************/
-u32 get_cpu_rev(void)
-{
- u32 cpuid=0;
- /* On ES1.0 the IDCODE register is not exposed on L4


- * so using CPU ID to differentiate

- * between ES2.0 and ES1.0.


- */
- __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r" (cpuid));

- if((cpuid & 0xf) == 0x0)
- return CPU_3430_ES1;
- else
- return CPU_3430_ES2;
-
-}
-
-/******************************************
* cpu_is_3410(void) - returns true for 3410
******************************************/
u32 cpu_is_3410(void)
diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
index 0402a57..a564e4a 100644
--- a/board/omap3530beagle/omap3530beagle.c
+++ b/board/omap3530beagle/omap3530beagle.c
@@ -154,24 +154,6 @@ u32 get_mem_type(void)
}

/******************************************
- * get_cpu_rev(void) - extract version info
- ******************************************/
-u32 get_cpu_rev(void)


-{
- u32 cpuid = 0;

- /* On ES1.0 the IDCODE register is not exposed on L4


- * so using CPU ID to differentiate

- * between ES2.0 and ES1.0.


- */
- __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r" (cpuid));
- if ((cpuid & 0xf) == 0x0)

- return CPU_3430_ES1;
- else
- return CPU_3430_ES2;
-
-}
-
-/******************************************
* cpu_is_3410(void) - returns true for 3410
******************************************/
u32 cpu_is_3410(void)
diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c
index 4f1fedd..c225ac1 100644
--- a/board/omap3evm/omap3evm.c
+++ b/board/omap3evm/omap3evm.c
@@ -130,24 +130,6 @@ u32 get_mem_type(void)
}

/******************************************
- * get_cpu_rev(void) - extract version info
- ******************************************/
-u32 get_cpu_rev(void)
-{
- u32 cpuid=0;
- /* On ES1.0 the IDCODE register is not exposed on L4


- * so using CPU ID to differentiate

- * between ES2.0 and ES1.0.


- */
- __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r" (cpuid));

- if((cpuid & 0xf) == 0x0)
- return CPU_3430_ES1;
- else
- return CPU_3430_ES2;
-
-}
-
-/******************************************
* cpu_is_3410(void) - returns true for 3410
******************************************/
u32 cpu_is_3410(void)
diff --git a/board/overo/overo.c b/board/overo/overo.c
index bd03b55..b3a73e6 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -159,19 +159,6 @@ u32 get_mem_type(void)
}

/******************************************
- * get_cpu_rev(void) - extract version info
- ******************************************/
-u32 get_cpu_rev(void)
-{


- u32 cpuid = get_cpu_id();
-
- if (cpuid == 0)

- return CPU_3XX_ES10;
- else
- return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
-}
-
-/******************************************
* Print CPU information
******************************************/
int print_cpuinfo (void)
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index ef18d60..9fd9c71 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -94,3 +94,16 @@ u32 get_cpu_family(void)

return cpu_family;
}
+
+/*
+ * get_cpu_rev(void): extract version info
+ */
+u32 get_cpu_rev(void)
+{


+ u32 cpuid = get_cpu_id();
+
+ if (cpuid == 0)

+ return CPU_3XX_ES10;
+ else
+ return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
+}
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:19 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The print_cpuinfo() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/igep00x0/igep00x0.c :129:int print_cpuinfo(void)
board/overo/overo.c :164:int print_cpuinfo(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 91 ---------------------------------------------
board/overo/overo.c | 91 ---------------------------------------------
cpu/omap3/sys_info.c | 91 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 91 insertions(+), 182 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index a876da3..64cc023 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -60,16 +60,6 @@ extern dpll_param *get_per_dpll_param(void);
#define __raw_readw(a) (*(volatile unsigned short *)(a))
#define __raw_writew(v, a) (*(volatile unsigned short *)(a) = (v))

-static char *rev_s[CPU_3XX_MAX_REV] = {
- "1.0",
- "2.0",
- "2.1",
- "3.0",
- "3.1",
- "UNKNOWN",
- "UNKNOWN",
- "3.1.2"};
-
/*******************************************************
* Routine: delay
* Description: spinning delay to use before udelay works
@@ -123,87 +113,6 @@ u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
} while (1);
}

-/******************************************
- * Print CPU information
- ******************************************/
-int print_cpuinfo (void)
-{
- char *cpu_family_s, *cpu_s, *sec_s;
-
- switch (get_cpu_family()) {
- case CPU_OMAP34XX:
- cpu_family_s = "OMAP";
- switch (get_cpu_type()) {
- case OMAP3503:
- cpu_s = "3503";
- break;
- case OMAP3515:
- cpu_s = "3515";
- break;
- case OMAP3525:
- cpu_s = "3525";
- break;
- case OMAP3530:
- cpu_s = "3530";
- break;
- default:
- cpu_s = "35XX";
- break;
- }
- break;
- case CPU_AM35XX:
- cpu_family_s = "AM";
- switch (get_cpu_type()) {
- case AM3505:
- cpu_s = "3505";
- break;
- case AM3517:
- cpu_s = "3517";
- break;
- default:
- cpu_s = "35XX";
- break;
- }
- break;
- case CPU_OMAP36XX:
- cpu_family_s = "OMAP";
- switch (get_cpu_type()) {
- case OMAP3730:
- cpu_s = "3630/3730";
- break;
- default:
- cpu_s = "36XX/37XX";
- break;
- }
- break;
- default:
- cpu_family_s = "OMAP";
- cpu_s = "35XX";
- }
-
- switch (get_device_type()) {
- case TST_DEVICE:
- sec_s = "TST";
- break;
- case EMU_DEVICE:
- sec_s = "EMU";
- break;
- case HS_DEVICE:
- sec_s = "HS";
- break;
- case GP_DEVICE:
- sec_s = "GP";
- break;
- default:
- sec_s = "?";
- }
-
- printf("%s%s-%s ES%s\n",
- cpu_family_s, cpu_s, sec_s, rev_s[get_cpu_rev()]);
-
- return 0;
-}
-
/*************************************************************
* get_sys_clk_speed - determine reference oscillator speed
* based on known 32kHz clock and gptimer.
diff --git a/board/overo/overo.c b/board/overo/overo.c
index b3a73e6..d09b594 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -66,16 +66,6 @@ extern dpll_param *get_per_dpll_param();
#define __raw_readw(a) (*(volatile unsigned short *)(a))
#define __raw_writew(v, a) (*(volatile unsigned short *)(a) = (v))

-static char *rev_s[CPU_3XX_MAX_REV] = {
- "1.0",
- "2.0",
- "2.1",
- "3.0",
- "3.1",
- "UNKNOWN",
- "UNKNOWN",
- "3.1.2"};
-
/*******************************************************
* Routine: delay
* Description: spinning delay to use before udelay works
@@ -159,87 +149,6 @@ u32 get_mem_type(void)
}

/******************************************
- * Print CPU information
- ******************************************/
-int print_cpuinfo (void)
-{
- char *cpu_family_s, *cpu_s, *sec_s;
-
- switch (get_cpu_family()) {
- case CPU_OMAP34XX:
- cpu_family_s = "OMAP";
- switch (get_cpu_type()) {
- case OMAP3503:
- cpu_s = "3503";
- break;
- case OMAP3515:
- cpu_s = "3515";
- break;
- case OMAP3525:
- cpu_s = "3525";
- break;
- case OMAP3530:
- cpu_s = "3530";
- break;
- default:
- cpu_s = "35XX";
- break;
- }
- break;
- case CPU_AM35XX:
- cpu_family_s = "AM";
- switch (get_cpu_type()) {
- case AM3505:
- cpu_s = "3505";
- break;
- case AM3517:
- cpu_s = "3517";
- break;
- default:
- cpu_s = "35XX";
- break;
- }
- break;
- case CPU_OMAP36XX:
- cpu_family_s = "OMAP";
- switch (get_cpu_type()) {
- case OMAP3730:
- cpu_s = "3630/3730";
- break;
- default:
- cpu_s = "36XX/37XX";
- break;
- }
- break;
- default:
- cpu_family_s = "OMAP";
- cpu_s = "35XX";
- }
-
- switch (get_device_type()) {
- case TST_DEVICE:
- sec_s = "TST";
- break;
- case EMU_DEVICE:
- sec_s = "EMU";
- break;
- case HS_DEVICE:
- sec_s = "HS";
- break;
- case GP_DEVICE:
- sec_s = "GP";
- break;
- default:
- sec_s = "?";
- }
-
- printf("%s%s-%s ES%s\n",
- cpu_family_s, cpu_s, sec_s, rev_s[get_cpu_rev()]);
-
- return 0;


-}
-
-/******************************************
* cpu_is_3410(void) - returns true for 3410
******************************************/
u32 cpu_is_3410(void)

diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index 9fd9c71..56b6c4d 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -24,6 +24,16 @@
#include <asm/arch/sys_proto.h>
#include <asm/arch/sys_info.h>

+static char *rev_s[CPU_3XX_MAX_REV] = {
+ "1.0",
+ "2.0",
+ "2.1",
+ "3.0",
+ "3.1",
+ "UNKNOWN",
+ "UNKNOWN",
+ "3.1.2"};
+
/*


* get_device_type(): tell if GP/HS/EMU/TST

*/
@@ -107,3 +117,84 @@ u32 get_cpu_rev(void)
else


return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
}
+

+/*
+ * print_cpuinfo(void): print CPU information
+ */
+int print_cpuinfo(void)
+{
+ char *cpu_family_s, *cpu_s, *sec_s;
+
+ switch (get_cpu_family()) {
+ case CPU_OMAP34XX:
+ cpu_family_s = "OMAP";
+ switch (get_cpu_type()) {
+ case OMAP3503:
+ cpu_s = "3503";
+ break;
+ case OMAP3515:
+ cpu_s = "3515";
+ break;
+ case OMAP3525:
+ cpu_s = "3525";
+ break;
+ case OMAP3530:
+ cpu_s = "3530";
+ break;
+ default:
+ cpu_s = "35XX";
+ break;
+ }
+ break;
+ case CPU_AM35XX:
+ cpu_family_s = "AM";
+ switch (get_cpu_type()) {
+ case AM3505:
+ cpu_s = "3505";
+ break;
+ case AM3517:
+ cpu_s = "3517";
+ break;
+ default:
+ cpu_s = "35XX";
+ break;
+ }
+ break;
+ case CPU_OMAP36XX:
+ cpu_family_s = "OMAP";
+ switch (get_cpu_type()) {
+ case OMAP3730:
+ cpu_s = "3630/3730";
+ break;
+ default:
+ cpu_s = "36XX/37XX";
+ break;
+ }
+ break;
+ default:
+ cpu_family_s = "OMAP";
+ cpu_s = "35XX";
+ }
+
+ switch (get_device_type()) {
+ case TST_DEVICE:
+ sec_s = "TST";
+ break;
+ case EMU_DEVICE:
+ sec_s = "EMU";
+ break;
+ case HS_DEVICE:
+ sec_s = "HS";
+ break;
+ case GP_DEVICE:
+ sec_s = "GP";
+ break;
+ default:
+ sec_s = "?";
+ }
+
+ printf("%s%s-%s ES%s\n",
+ cpu_family_s, cpu_s, sec_s, rev_s[get_cpu_rev()]);
+
+ return 0;
+}
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:20 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The get_sysboot_value() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/omap3530beagle/omap3530beagle.c :97:u32 get_sysboot_value(void)
board/omap3evm/omap3evm.c :84:u32 get_sysboot_value(void)
board/overo/overo.c :95:u32 get_sysboot_value(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/omap3530beagle/omap3530beagle.c | 10 ----------
board/omap3evm/omap3evm.c | 9 ---------
board/overo/overo.c | 10 ----------
cpu/omap3/sys_info.c | 10 ++++++++++
4 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
index a564e4a..b8656f5 100644
--- a/board/omap3530beagle/omap3530beagle.c
+++ b/board/omap3530beagle/omap3530beagle.c


@@ -91,16 +91,6 @@ int board_init(void)
return 0;
}

-/************************************************

- * get_sysboot_value(void) - return SYS_BOOT[4:0]
- ************************************************/
-u32 get_sysboot_value(void)
-{
- int mode;


- mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
- return mode;
-}
-
/*************************************************************

* Routine: get_mem_type(void) - returns the kind of memory connected
* to GPMC that we are trying to boot form. Uses SYS BOOT settings.

diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c
index c225ac1..27aed09 100644
--- a/board/omap3evm/omap3evm.c
+++ b/board/omap3evm/omap3evm.c
@@ -78,15 +78,6 @@ int board_init (void)
return 0;
}

-/************************************************
- * get_sysboot_value(void) - return SYS_BOOT[4:0]
- ************************************************/
-u32 get_sysboot_value(void)
-{
- int mode;


- mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
- return mode;
-}

/*************************************************************
* Routine: get_mem_type(void) - returns the kind of memory connected
* to GPMC that we are trying to boot form. Uses SYS BOOT settings.

diff --git a/board/overo/overo.c b/board/overo/overo.c
index d09b594..0beda9b 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -89,16 +89,6 @@ int board_init(void)
return 0;
}

-/************************************************
- * get_sysboot_value(void) - return SYS_BOOT[4:0]
- ************************************************/
-u32 get_sysboot_value(void)
-{
- int mode;


- mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
- return mode;
-}
-
/*************************************************************

* Routine: get_mem_type(void) - returns the kind of memory connected
* to GPMC that we are trying to boot form. Uses SYS BOOT settings.

diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index 56b6c4d..87d4c15 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -198,3 +198,13 @@ int print_cpuinfo(void)

return 0;
}
+
+/*
+ * get_sysboot_value(void): return SYS_BOOT[4:0]
+ */
+u32 get_sysboot_value(void)
+{
+ int mode;
+ mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
+ return mode;
+}
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:21 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The sr32() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/omap3530beagle/omap3530beagle.c:215:void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
board/igep00x0/igep00x0.c :89:void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
board/omap3430sdp/omap3430sdp.c :103:void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
board/omap3evm/omap3evm.c :147:void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
board/omap3430labrador/omap3430sdp.c :100:void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
board/overo/overo.c :206:void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 13 -------------
board/omap3430labrador/omap3430sdp.c | 13 -------------
board/omap3430sdp/omap3430sdp.c | 13 -------------
board/omap3530beagle/omap3530beagle.c | 13 -------------
board/omap3evm/omap3evm.c | 13 -------------


board/overo/overo.c | 13 -------------
cpu/omap3/sys_info.c | 13 +++++++++++++

7 files changed, 13 insertions(+), 78 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index 64cc023..f1c1829 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -83,19 +83,6 @@ u32 get_mem_type(void)
return GPMC_ONENAND;
}

-/*****************************************************************
- * sr32 - clear & set a value in a bit range for a 32 bit address
- *****************************************************************/
-void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
-{
- u32 tmp, msk = 0;
- msk = 1 << num_bits;
- --msk;
- tmp = __raw_readl(addr) & ~(msk << start_bit);
- tmp |= value << start_bit;
- __raw_writel(tmp, addr);
-}
-
/*********************************************************************
* wait_on_value() - common routine to allow waiting for changes in
* volatile regs.
diff --git a/board/omap3430labrador/omap3430sdp.c b/board/omap3430labrador/omap3430sdp.c
index 7fcaec1..300deb1 100644
--- a/board/omap3430labrador/omap3430sdp.c
+++ b/board/omap3430labrador/omap3430sdp.c
@@ -94,19 +94,6 @@ u32 cpu_is_3410(void)
}
}

-/*****************************************************************
- * sr32 - clear & set a value in a bit range for a 32 bit address
- *****************************************************************/
-void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
-{
- u32 tmp, msk = 0;
- msk = 1 << num_bits;
- --msk;
- tmp = __raw_readl(addr) & ~(msk << start_bit);
- tmp |= value << start_bit;
- __raw_writel(tmp, addr);
-}
-
/*********************************************************************
* wait_on_value() - common routine to allow waiting for changes in
* volatile regs.
diff --git a/board/omap3430sdp/omap3430sdp.c b/board/omap3430sdp/omap3430sdp.c
index a0b0d0e..bfa61dc 100644
--- a/board/omap3430sdp/omap3430sdp.c
+++ b/board/omap3430sdp/omap3430sdp.c
@@ -97,19 +97,6 @@ u32 cpu_is_3410(void)
}
}

-/*****************************************************************
- * sr32 - clear & set a value in a bit range for a 32 bit address
- *****************************************************************/
-void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
-{
- u32 tmp, msk = 0;
- msk = 1 << num_bits;
- --msk;
- tmp = __raw_readl(addr) & ~(msk << start_bit);
- tmp |= value << start_bit;
- __raw_writel(tmp, addr);
-}
-
/*********************************************************************
* wait_on_value() - common routine to allow waiting for changes in
* volatile regs.
diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
index b8656f5..5659f3b 100644
--- a/board/omap3530beagle/omap3530beagle.c
+++ b/board/omap3530beagle/omap3530beagle.c
@@ -209,19 +209,6 @@ int beagle_revision(void)
return rev;
}

-/*****************************************************************
- * sr32 - clear & set a value in a bit range for a 32 bit address
- *****************************************************************/
-void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
-{
- u32 tmp, msk = 0;
- msk = 1 << num_bits;
- --msk;
- tmp = __raw_readl(addr) & ~(msk << start_bit);
- tmp |= value << start_bit;
- __raw_writel(tmp, addr);
-}
-
/*********************************************************************
* wait_on_value() - common routine to allow waiting for changes in
* volatile regs.
diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c
index 27aed09..4265da1 100644
--- a/board/omap3evm/omap3evm.c
+++ b/board/omap3evm/omap3evm.c
@@ -141,19 +141,6 @@ u32 cpu_is_3410(void)
}
}

-/*****************************************************************
- * sr32 - clear & set a value in a bit range for a 32 bit address
- *****************************************************************/
-void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
-{
- u32 tmp, msk = 0;
- msk = 1 << num_bits;
- --msk;
- tmp = __raw_readl(addr) & ~(msk << start_bit);
- tmp |= value << start_bit;
- __raw_writel(tmp, addr);
-}
-
/*********************************************************************
* wait_on_value() - common routine to allow waiting for changes in
* volatile regs.
diff --git a/board/overo/overo.c b/board/overo/overo.c
index 0beda9b..3b61335 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -200,19 +200,6 @@ int get_board_revision(void)
return revision;
}

-/*****************************************************************
- * sr32 - clear & set a value in a bit range for a 32 bit address
- *****************************************************************/
-void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
-{
- u32 tmp, msk = 0;
- msk = 1 << num_bits;
- --msk;
- tmp = __raw_readl(addr) & ~(msk << start_bit);
- tmp |= value << start_bit;
- __raw_writel(tmp, addr);
-}
-
/*********************************************************************
* wait_on_value() - common routine to allow waiting for changes in
* volatile regs.
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index 87d4c15..bcf5f8e 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -35,6 +35,19 @@ static char *rev_s[CPU_3XX_MAX_REV] = {
"3.1.2"};

/*
+ * sr32: clear & set a value in a bit range for a 32 bit address
+ */
+void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
+{
+ u32 tmp, msk = 0;
+ msk = 1 << num_bits;
+ --msk;
+ tmp = __raw_readl(addr) & ~(msk << start_bit);
+ tmp |= value << start_bit;
+ __raw_writel(tmp, addr);
+}
+
+/*


* get_device_type(): tell if GP/HS/EMU/TST
*/

u32 get_device_type(void)
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:22 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The wait_on_value() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/omap3530beagle/omap3530beagle.c :216:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
board/igep00x0/igep00x0.c :90:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
board/omap3430sdp/omap3430sdp.c :104:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
board/omap3evm/omap3evm.c :148:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
board/omap3430labrador/omap3430sdp.c :101:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
board/overo/overo.c :207:u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 17 -----------------
board/omap3430labrador/omap3430sdp.c | 17 -----------------
board/omap3430sdp/omap3430sdp.c | 17 -----------------
board/omap3530beagle/omap3530beagle.c | 17 -----------------
board/omap3evm/omap3evm.c | 17 -----------------
board/overo/overo.c | 17 -----------------
cpu/omap3/sys_info.c | 17 +++++++++++++++++
7 files changed, 17 insertions(+), 102 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index f1c1829..0b2ce5e 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -83,23 +83,6 @@ u32 get_mem_type(void)
return GPMC_ONENAND;
}

-/*********************************************************************
- * wait_on_value() - common routine to allow waiting for changes in
- * volatile regs.
- *********************************************************************/
-u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
-{
- u32 i = 0, val;
- do {
- ++i;
- val = __raw_readl(read_addr) & read_bit_mask;
- if (val == match_value)
- return 1;
- if (i == bound)
- return 0;
- } while (1);


-}
-
/*************************************************************
* get_sys_clk_speed - determine reference oscillator speed
* based on known 32kHz clock and gptimer.

diff --git a/board/omap3430labrador/omap3430sdp.c b/board/omap3430labrador/omap3430sdp.c
index 300deb1..79d0dce 100644
--- a/board/omap3430labrador/omap3430sdp.c
+++ b/board/omap3430labrador/omap3430sdp.c
@@ -94,23 +94,6 @@ u32 cpu_is_3410(void)
}
}

-/*********************************************************************
- * wait_on_value() - common routine to allow waiting for changes in
- * volatile regs.
- *********************************************************************/
-u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
-{
- u32 i = 0, val;
- do {
- ++i;
- val = __raw_readl(read_addr) & read_bit_mask;
- if (val == match_value)
- return (1);
- if (i == bound)
- return (0);
- } while (1);
-}
-
#ifdef CFG_3430SDRAM_DDR
/*********************************************************************
* config_3430sdram_ddr() - Init DDR on 3430SDP dev board.
diff --git a/board/omap3430sdp/omap3430sdp.c b/board/omap3430sdp/omap3430sdp.c
index bfa61dc..bb6070e 100644
--- a/board/omap3430sdp/omap3430sdp.c
+++ b/board/omap3430sdp/omap3430sdp.c
@@ -97,23 +97,6 @@ u32 cpu_is_3410(void)
}
}

-/*********************************************************************
- * wait_on_value() - common routine to allow waiting for changes in
- * volatile regs.
- *********************************************************************/
-u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
-{
- u32 i = 0, val;
- do {
- ++i;
- val = __raw_readl(read_addr) & read_bit_mask;
- if (val == match_value)
- return (1);
- if (i == bound)
- return (0);
- } while (1);
-}
-
#ifdef CFG_3430SDRAM_DDR
/*********************************************************************
* config_3430sdram_ddr() - Init DDR on 3430SDP dev board.
diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
index 5659f3b..5a97d96 100644
--- a/board/omap3530beagle/omap3530beagle.c
+++ b/board/omap3530beagle/omap3530beagle.c
@@ -209,23 +209,6 @@ int beagle_revision(void)
return rev;
}

-/*********************************************************************
- * wait_on_value() - common routine to allow waiting for changes in
- * volatile regs.
- *********************************************************************/
-u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
-{
- u32 i = 0, val;
- do {
- ++i;
- val = __raw_readl(read_addr) & read_bit_mask;
- if (val == match_value)
- return 1;
- if (i == bound)
- return 0;
- } while (1);
-}
-
#ifdef CFG_3430SDRAM_DDR

#define MICRON_DDR 0
diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c
index 4265da1..5071046 100644
--- a/board/omap3evm/omap3evm.c
+++ b/board/omap3evm/omap3evm.c
@@ -141,23 +141,6 @@ u32 cpu_is_3410(void)
}
}

-/*********************************************************************
- * wait_on_value() - common routine to allow waiting for changes in
- * volatile regs.
- *********************************************************************/
-u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
-{
- u32 i = 0, val;
- do {
- ++i;
- val = __raw_readl(read_addr) & read_bit_mask;
- if (val == match_value)
- return (1);
- if (i == bound)
- return (0);
- } while (1);
-}
-
#ifdef CFG_3430SDRAM_DDR
/*********************************************************************
* config_3430sdram_ddr() - Init DDR on 3430SDP dev board.
diff --git a/board/overo/overo.c b/board/overo/overo.c
index 3b61335..e7ac7a6 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -200,23 +200,6 @@ int get_board_revision(void)
return revision;
}

-/*********************************************************************
- * wait_on_value() - common routine to allow waiting for changes in
- * volatile regs.
- *********************************************************************/
-u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
-{
- u32 i = 0, val;
- do {
- ++i;
- val = __raw_readl(read_addr) & read_bit_mask;
- if (val == match_value)
- return 1;
- if (i == bound)
- return 0;
- } while (1);
-}
-
#ifdef CFG_3430SDRAM_DDR
/*********************************************************************
* config_3430sdram_ddr() - Init DDR on 3430SDP dev board.
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index bcf5f8e..d6568a9 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -48,6 +48,23 @@ void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
}

/*
+ * wait_on_value(): common routine to allow waiting for changes in
+ * volatile regs.
+ */
+u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
+{
+ u32 i = 0, val;
+ do {
+ ++i;
+ val = __raw_readl(read_addr) & read_bit_mask;
+ if (val == match_value)
+ return 1;
+ if (i == bound)
+ return 0;
+ } while (1);

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:23 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The get_sys_clkin_sel() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/omap3530beagle/omap3530beagle.c :398:void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
board/igep00x0/igep00x0.c :142:void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
board/omap3430sdp/omap3430sdp.c :194:void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
board/omap3evm/omap3evm.c :246:void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
board/omap3430labrador/omap3430sdp.c :191:void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
board/overo/overo.c :349:void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 19 -------------------
board/omap3430labrador/omap3430sdp.c | 19 -------------------
board/omap3430sdp/omap3430sdp.c | 19 -------------------
board/omap3530beagle/omap3530beagle.c | 19 -------------------
board/omap3evm/omap3evm.c | 19 -------------------
board/overo/overo.c | 19 -------------------
cpu/omap3/sys_info.c | 19 +++++++++++++++++++
include/asm/arch-omap3/sys_proto.h | 2 ++
8 files changed, 21 insertions(+), 114 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index 0b2ce5e..a9c02dd 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -135,25 +135,6 @@ u32 get_osc_clk_speed(void)
}

/******************************************************************************
- * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
- * -- input oscillator clock frequency.
- *
- *****************************************************************************/
-void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
-{
- if (osc_clk == S38_4M)
- *sys_clkin_sel = 4;
- else if (osc_clk == S26M)
- *sys_clkin_sel = 3;
- else if (osc_clk == S19_2M)
- *sys_clkin_sel = 2;
- else if (osc_clk == S13M)
- *sys_clkin_sel = 1;
- else if (osc_clk == S12M)
- *sys_clkin_sel = 0;
-}
-
-/******************************************************************************
* prcm_init() - inits clocks for PRCM as defined in clocks.h
* -- called from SRAM, or Flash (using temp SRAM stack).
*****************************************************************************/
diff --git a/board/omap3430labrador/omap3430sdp.c b/board/omap3430labrador/omap3430sdp.c
index 79d0dce..991a34f 100644
--- a/board/omap3430labrador/omap3430sdp.c
+++ b/board/omap3430labrador/omap3430sdp.c
@@ -184,25 +184,6 @@ u32 get_osc_clk_speed(void)
}

/******************************************************************************
- * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
- * -- input oscillator clock frequency.
- *
- *****************************************************************************/
-void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
-{
- if(osc_clk == S38_4M)
- *sys_clkin_sel= 4;
- else if(osc_clk == S26M)
- *sys_clkin_sel = 3;
- else if(osc_clk == S19_2M)
- *sys_clkin_sel = 2;
- else if(osc_clk == S13M)
- *sys_clkin_sel = 1;
- else if(osc_clk == S12M)
- *sys_clkin_sel = 0;
-}
-
-/******************************************************************************
* prcm_init() - inits clocks for PRCM as defined in clocks.h
* -- called from SRAM, or Flash (using temp SRAM stack).
*****************************************************************************/
diff --git a/board/omap3430sdp/omap3430sdp.c b/board/omap3430sdp/omap3430sdp.c
index bb6070e..859ce1e 100644
--- a/board/omap3430sdp/omap3430sdp.c
+++ b/board/omap3430sdp/omap3430sdp.c
@@ -187,25 +187,6 @@ u32 get_osc_clk_speed(void)
}

/******************************************************************************
- * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
- * -- input oscillator clock frequency.
- *
- *****************************************************************************/
-void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
-{
- if(osc_clk == S38_4M)
- *sys_clkin_sel= 4;
- else if(osc_clk == S26M)
- *sys_clkin_sel = 3;
- else if(osc_clk == S19_2M)
- *sys_clkin_sel = 2;
- else if(osc_clk == S13M)
- *sys_clkin_sel = 1;
- else if(osc_clk == S12M)
- *sys_clkin_sel = 0;
-}
-
-/******************************************************************************
* prcm_init() - inits clocks for PRCM as defined in clocks.h
* -- called from SRAM, or Flash (using temp SRAM stack).
*****************************************************************************/
diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
index 5a97d96..e3105bd 100644
--- a/board/omap3530beagle/omap3530beagle.c
+++ b/board/omap3530beagle/omap3530beagle.c
@@ -391,25 +391,6 @@ u32 get_osc_clk_speed(void)
}

/******************************************************************************
- * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
- * -- input oscillator clock frequency.
- *
- *****************************************************************************/
-void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
-{
- if (osc_clk == S38_4M)
- *sys_clkin_sel = 4;
- else if (osc_clk == S26M)
- *sys_clkin_sel = 3;
- else if (osc_clk == S19_2M)
- *sys_clkin_sel = 2;
- else if (osc_clk == S13M)
- *sys_clkin_sel = 1;
- else if (osc_clk == S12M)
- *sys_clkin_sel = 0;
-}
-
-/******************************************************************************
* prcm_init() - inits clocks for PRCM as defined in clocks.h
* -- called from SRAM, or Flash (using temp SRAM stack).
*****************************************************************************/
diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c
index 5071046..2180594 100644
--- a/board/omap3evm/omap3evm.c
+++ b/board/omap3evm/omap3evm.c
@@ -239,25 +239,6 @@ u32 get_osc_clk_speed(void)
}

/******************************************************************************
- * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
- * -- input oscillator clock frequency.
- *
- *****************************************************************************/
-void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
-{
- if(osc_clk == S38_4M)
- *sys_clkin_sel= 4;
- else if(osc_clk == S26M)
- *sys_clkin_sel = 3;
- else if(osc_clk == S19_2M)
- *sys_clkin_sel = 2;
- else if(osc_clk == S13M)
- *sys_clkin_sel = 1;
- else if(osc_clk == S12M)
- *sys_clkin_sel = 0;
-}
-
-/******************************************************************************
* prcm_init() - inits clocks for PRCM as defined in clocks.h
* -- called from SRAM, or Flash (using temp SRAM stack).
*****************************************************************************/
diff --git a/board/overo/overo.c b/board/overo/overo.c
index e7ac7a6..d852986 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -342,25 +342,6 @@ u32 get_osc_clk_speed(void)
}

/******************************************************************************
- * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
- * -- input oscillator clock frequency.
- *
- *****************************************************************************/
-void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
-{
- if (osc_clk == S38_4M)
- *sys_clkin_sel = 4;
- else if (osc_clk == S26M)
- *sys_clkin_sel = 3;
- else if (osc_clk == S19_2M)
- *sys_clkin_sel = 2;
- else if (osc_clk == S13M)
- *sys_clkin_sel = 1;
- else if (osc_clk == S12M)
- *sys_clkin_sel = 0;
-}
-
-/******************************************************************************
* prcm_init() - inits clocks for PRCM as defined in clocks.h
* -- called from SRAM, or Flash (using temp SRAM stack).
*****************************************************************************/
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index d6568a9..77b25a5 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -21,6 +21,7 @@
#include <common.h>
#include <asm/io.h>
#include <asm/arch/bits.h>
+#include <asm/arch/clocks.h>
#include <asm/arch/sys_proto.h>
#include <asm/arch/sys_info.h>

@@ -238,3 +239,21 @@ u32 get_sysboot_value(void)


mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);

return mode;
}
+
+/*
+ * get_sys_clkin_sel(): returns the sys_clkin_sel field value based on
+ * input oscillator clock frequency.
+ */
+void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
+{
+ if (osc_clk == S38_4M)
+ *sys_clkin_sel = 4;
+ else if (osc_clk == S26M)
+ *sys_clkin_sel = 3;
+ else if (osc_clk == S19_2M)
+ *sys_clkin_sel = 2;
+ else if (osc_clk == S13M)
+ *sys_clkin_sel = 1;
+ else if (osc_clk == S12M)
+ *sys_clkin_sel = 0;
+}
diff --git a/include/asm/arch-omap3/sys_proto.h b/include/asm/arch-omap3/sys_proto.h
index 7ac53a2..8b40822 100644
--- a/include/asm/arch-omap3/sys_proto.h
+++ b/include/asm/arch-omap3/sys_proto.h
@@ -52,6 +52,8 @@ u32 running_in_flash(void);
u32 running_from_internal_boot(void);
u32 get_device_type(void);

+void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel);
+
void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value);
u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound);
void sdelay(unsigned long loops);
--
1.7.0.4

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:24 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The secure_unlock() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/omap3530beagle/omap3530beagle.c :527:void secure_unlock(void)
board/igep00x0/igep00x0.c :271:void secure_unlock(void)
board/omap3430sdp/omap3430sdp.c :314:void secure_unlock(void)
board/omap3evm/omap3evm.c :359:void secure_unlock(void)
board/omap3430labrador/omap3430sdp.c :316:void secure_unlock(void)
board/overo/overo.c :478:void secure_unlock(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 34 ---------------------------------
board/omap3430labrador/omap3430sdp.c | 34 ---------------------------------
board/omap3430sdp/omap3430sdp.c | 34 ---------------------------------
board/omap3530beagle/omap3530beagle.c | 34 ---------------------------------
board/omap3evm/omap3evm.c | 34 ---------------------------------
board/overo/overo.c | 34 ---------------------------------
cpu/omap3/sys_info.c | 33 ++++++++++++++++++++++++++++++++
include/asm/arch-omap3/sys_proto.h | 2 +
8 files changed, 35 insertions(+), 204 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index a9c02dd..8c99923 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -263,40 +263,6 @@ void prcm_init(void)
delay(5000);
}

-/*****************************************
- * Routine: secure_unlock
- * Description: Setup security registers for access
- * (GP Device only)
- *****************************************/
-void secure_unlock(void)
-{
- /* Permission values for registers -Full fledged permissions to all */
-#define UNLOCK_1 0xFFFFFFFF
-#define UNLOCK_2 0x00000000
-#define UNLOCK_3 0x0000FFFF
- /* Protection Module Register Target APE (PM_RT) */
- __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
- __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
- __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
-
- __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
-
- /* IVA Changes */
- __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
-}
-
/**********************************************************
* Routine: try_unlock_sram()
* Description: If chip is GP type, unlock the SRAM for
diff --git a/board/omap3430labrador/omap3430sdp.c b/board/omap3430labrador/omap3430sdp.c
index 991a34f..2c42168 100644
--- a/board/omap3430labrador/omap3430sdp.c
+++ b/board/omap3430labrador/omap3430sdp.c
@@ -308,40 +308,6 @@ void prcm_init(void)
delay(5000);
}

-/*****************************************
- * Routine: secure_unlock
- * Description: Setup security registers for access
- * (GP Device only)
- *****************************************/
-void secure_unlock(void)
-{
- /* Permission values for registers -Full fledged permissions to all */
- #define UNLOCK_1 0xFFFFFFFF
- #define UNLOCK_2 0x00000000
- #define UNLOCK_3 0x0000FFFF
- /* Protection Module Register Target APE (PM_RT)*/
- __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
- __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
- __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
-
- __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
-
- /* IVA Changes */
- __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
-}
-
/**********************************************************
* Routine: try_unlock_sram()
* Description: If chip is GP type, unlock the SRAM for
diff --git a/board/omap3430sdp/omap3430sdp.c b/board/omap3430sdp/omap3430sdp.c
index 859ce1e..fe3f8e1 100644
--- a/board/omap3430sdp/omap3430sdp.c
+++ b/board/omap3430sdp/omap3430sdp.c
@@ -306,40 +306,6 @@ void prcm_init(void)
delay(5000);
}

-/*****************************************
- * Routine: secure_unlock
- * Description: Setup security registers for access
- * (GP Device only)
- *****************************************/
-void secure_unlock(void)
-{
- /* Permission values for registers -Full fledged permissions to all */
- #define UNLOCK_1 0xFFFFFFFF
- #define UNLOCK_2 0x00000000
- #define UNLOCK_3 0x0000FFFF
- /* Protection Module Register Target APE (PM_RT)*/
- __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
- __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
- __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
-
- __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
-
- /* IVA Changes */
- __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
-}
-
/**********************************************************
* Routine: try_unlock_sram()
* Description: If chip is GP type, unlock the SRAM for
diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
index e3105bd..c861b21 100644
--- a/board/omap3530beagle/omap3530beagle.c
+++ b/board/omap3530beagle/omap3530beagle.c
@@ -519,40 +519,6 @@ void prcm_init(void)
delay(5000);
}

-/*****************************************
- * Routine: secure_unlock
- * Description: Setup security registers for access
- * (GP Device only)
- *****************************************/
-void secure_unlock(void)
-{
- /* Permission values for registers -Full fledged permissions to all */
-#define UNLOCK_1 0xFFFFFFFF
-#define UNLOCK_2 0x00000000
-#define UNLOCK_3 0x0000FFFF
- /* Protection Module Register Target APE (PM_RT) */
- __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
- __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
- __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
-
- __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
-
- /* IVA Changes */
- __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
-}
-
/**********************************************************
* Routine: try_unlock_sram()
* Description: If chip is GP type, unlock the SRAM for
diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c
index 2180594..164c211 100644
--- a/board/omap3evm/omap3evm.c
+++ b/board/omap3evm/omap3evm.c
@@ -351,40 +351,6 @@ void prcm_init(void)
delay(5000);
}

-/*****************************************
- * Routine: secure_unlock
- * Description: Setup security registers for access
- * (GP Device only)
- *****************************************/
-void secure_unlock(void)
-{
- /* Permission values for registers -Full fledged permissions to all */
- #define UNLOCK_1 0xFFFFFFFF
- #define UNLOCK_2 0x00000000
- #define UNLOCK_3 0x0000FFFF
- /* Protection Module Register Target APE (PM_RT)*/
- __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
- __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
- __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
-
- __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
-
- /* IVA Changes */
- __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
-}
-
/**********************************************************
* Routine: try_unlock_sram()
* Description: If chip is GP type, unlock the SRAM for
diff --git a/board/overo/overo.c b/board/overo/overo.c
index d852986..1c8102b 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -470,40 +470,6 @@ void prcm_init(void)
delay(5000);
}

-/*****************************************
- * Routine: secure_unlock
- * Description: Setup security registers for access
- * (GP Device only)
- *****************************************/
-void secure_unlock(void)
-{
- /* Permission values for registers -Full fledged permissions to all */
- #define UNLOCK_1 0xFFFFFFFF
- #define UNLOCK_2 0x00000000
- #define UNLOCK_3 0x0000FFFF
- /* Protection Module Register Target APE (PM_RT)*/
- __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
- __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
- __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
-
- __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
- __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
-
- /* IVA Changes */
- __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
- __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
-
- __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
-}
-
/**********************************************************
* Routine: try_unlock_sram()
* Description: If chip is GP type, unlock the SRAM for
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index 77b25a5..09bd823 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -257,3 +257,36 @@ void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)


else if (osc_clk == S12M)

*sys_clkin_sel = 0;
}
+
+/*
+ * secure_unlock(void): setup security registers for access
+ * (GP Device only)
+ */
+void secure_unlock(void)
+{
+ /* Permission values for registers -Full fledged permissions to all */
+ #define UNLOCK_1 0xFFFFFFFF
+ #define UNLOCK_2 0x00000000
+ #define UNLOCK_3 0x0000FFFF
+ /* Protection Module Register Target APE (PM_RT)*/
+ __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
+ __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
+ __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
+ __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
+
+ __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
+ __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
+ __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
+
+ __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
+ __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
+ __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
+ __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
+
+ /* IVA Changes */
+ __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
+ __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
+ __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
+
+ __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */


+}
diff --git a/include/asm/arch-omap3/sys_proto.h b/include/asm/arch-omap3/sys_proto.h

index 8b40822..7e768fa 100644
--- a/include/asm/arch-omap3/sys_proto.h
+++ b/include/asm/arch-omap3/sys_proto.h
@@ -54,6 +54,8 @@ u32 get_device_type(void);

void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel);

+void secure_unlock(void);

Enric Balletbo i Serra

unread,
May 25, 2011, 9:12:25 AM5/25/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
The try_unlock_memory() function is implemented by various boards, this

patch moves this function to a common place to not duplicate code.

board/omap3530beagle/omap3530beagle.c :527:void try_unlock_memory(void)
board/igep00x0/igep00x0.c :271:void try_unlock_memory(void)
board/omap3430sdp/omap3430sdp.c :314:void try_unlock_memory(void)
board/omap3evm/omap3evm.c :359:void try_unlock_memory(void)
board/omap3430labrador/omap3430sdp.c :316:void try_unlock_memory(void)
board/overo/overo.c :478:void try_unlock_memory(void)

Signed-off-by: Enric Balletbo i Serra <ebal...@gmail.com>
---

board/igep00x0/igep00x0.c | 17 -----------------


board/omap3430labrador/omap3430sdp.c | 18 ------------------
board/omap3430sdp/omap3430sdp.c | 18 ------------------

board/omap3530beagle/omap3530beagle.c | 17 -----------------
board/omap3evm/omap3evm.c | 18 ------------------


board/overo/overo.c | 17 -----------------
cpu/omap3/sys_info.c | 17 +++++++++++++++++

include/asm/arch-omap3/sys_proto.h | 1 +
8 files changed, 18 insertions(+), 105 deletions(-)

diff --git a/board/igep00x0/igep00x0.c b/board/igep00x0/igep00x0.c
index 8c99923..5550741 100644
--- a/board/igep00x0/igep00x0.c
+++ b/board/igep00x0/igep00x0.c
@@ -263,23 +263,6 @@ void prcm_init(void)
delay(5000);
}

-/**********************************************************
- * Routine: try_unlock_sram()
- * Description: If chip is GP type, unlock the SRAM for
- * general use.
- ***********************************************************/
-void try_unlock_memory(void)


-{
- int mode;
-

- /* if GP device unlock device SRAM for general use */
- /* secure code breaks for Secure/Emulation device - HS/E/T */
- mode = get_device_type();
- if (mode == GP_DEVICE)
- secure_unlock();
- return;
-}
-
/*********************************************************************
* config_sdram_m65kx002am() - 2 dice of 2Gb, DDR x32 I/O, 4KB page
*********************************************************************/
diff --git a/board/omap3430labrador/omap3430sdp.c b/board/omap3430labrador/omap3430sdp.c
index 2c42168..522de06 100644
--- a/board/omap3430labrador/omap3430sdp.c
+++ b/board/omap3430labrador/omap3430sdp.c
@@ -309,24 +309,6 @@ void prcm_init(void)
}

/**********************************************************
- * Routine: try_unlock_sram()
- * Description: If chip is GP type, unlock the SRAM for
- * general use.
- ***********************************************************/
-void try_unlock_memory(void)


-{
- int mode;
-

- /* if GP device unlock device SRAM for general use */
- /* secure code breaks for Secure/Emulation device - HS/E/T*/
- mode = get_device_type();
- if (mode == GP_DEVICE) {
- secure_unlock();
- }
- return;
-}
-
-/**********************************************************
* Routine: s_init
* Description: Does early system init of muxing and clocks.
* - Called at time when only stack is available.
diff --git a/board/omap3430sdp/omap3430sdp.c b/board/omap3430sdp/omap3430sdp.c
index fe3f8e1..d8a2c1b 100644
--- a/board/omap3430sdp/omap3430sdp.c
+++ b/board/omap3430sdp/omap3430sdp.c
@@ -307,24 +307,6 @@ void prcm_init(void)
}

/**********************************************************
- * Routine: try_unlock_sram()
- * Description: If chip is GP type, unlock the SRAM for
- * general use.
- ***********************************************************/
-void try_unlock_memory(void)


-{
- int mode;
-

- /* if GP device unlock device SRAM for general use */
- /* secure code breaks for Secure/Emulation device - HS/E/T*/
- mode = get_device_type();
- if (mode == GP_DEVICE) {
- secure_unlock();
- }
- return;
-}
-
-/**********************************************************
* Routine: s_init
* Description: Does early system init of muxing and clocks.
* - Called at time when only stack is available.
diff --git a/board/omap3530beagle/omap3530beagle.c b/board/omap3530beagle/omap3530beagle.c
index c861b21..c85bebf 100644
--- a/board/omap3530beagle/omap3530beagle.c
+++ b/board/omap3530beagle/omap3530beagle.c
@@ -520,23 +520,6 @@ void prcm_init(void)
}

/**********************************************************
- * Routine: try_unlock_sram()
- * Description: If chip is GP type, unlock the SRAM for
- * general use.
- ***********************************************************/
-void try_unlock_memory(void)


-{
- int mode;
-

- /* if GP device unlock device SRAM for general use */
- /* secure code breaks for Secure/Emulation device - HS/E/T */
- mode = get_device_type();
- if (mode == GP_DEVICE)
- secure_unlock();
- return;
-}
-
-/**********************************************************
* Routine: s_init
* Description: Does early system init of muxing and clocks.
* - Called at time when only stack is available.
diff --git a/board/omap3evm/omap3evm.c b/board/omap3evm/omap3evm.c
index 164c211..6048964 100644
--- a/board/omap3evm/omap3evm.c
+++ b/board/omap3evm/omap3evm.c
@@ -352,24 +352,6 @@ void prcm_init(void)
}

/**********************************************************
- * Routine: try_unlock_sram()
- * Description: If chip is GP type, unlock the SRAM for
- * general use.
- ***********************************************************/
-void try_unlock_memory(void)


-{
- int mode;
-

- /* if GP device unlock device SRAM for general use */
- /* secure code breaks for Secure/Emulation device - HS/E/T*/
- mode = get_device_type();
- if (mode == GP_DEVICE) {
- secure_unlock();
- }
- return;
-}
-
-/**********************************************************
* Routine: s_init
* Description: Does early system init of muxing and clocks.
* - Called at time when only stack is available.
diff --git a/board/overo/overo.c b/board/overo/overo.c
index 1c8102b..413fe43 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -471,23 +471,6 @@ void prcm_init(void)
}

/**********************************************************
- * Routine: try_unlock_sram()
- * Description: If chip is GP type, unlock the SRAM for
- * general use.
- ***********************************************************/
-void try_unlock_memory(void)


-{
- int mode;
-

- /* if GP device unlock device SRAM for general use */
- /* secure code breaks for Secure/Emulation device - HS/E/T*/
- mode = get_device_type();
- if (mode == GP_DEVICE)
- secure_unlock();
- return;
-}
-
-/**********************************************************
* Routine: s_init
* Description: Does early system init of muxing and clocks.
* - Called at time when only stack is available.
diff --git a/cpu/omap3/sys_info.c b/cpu/omap3/sys_info.c
index 09bd823..0d592e9 100644
--- a/cpu/omap3/sys_info.c
+++ b/cpu/omap3/sys_info.c
@@ -290,3 +290,20 @@ void secure_unlock(void)



__raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
}
+

+/*
+ * try_unlock_memory(void): If chip is GP type, unlock the SRAM for
+ * general use.
+ */
+void try_unlock_memory(void)


+{
+ int mode;
+

+ /* if GP device unlock device SRAM for general use */
+ /* secure code breaks for Secure/Emulation device - HS/E/T*/
+ mode = get_device_type();
+ if (mode == GP_DEVICE) {
+ secure_unlock();
+ }
+ return;


+}
diff --git a/include/asm/arch-omap3/sys_proto.h b/include/asm/arch-omap3/sys_proto.h

index 7e768fa..8622d9f 100644
--- a/include/asm/arch-omap3/sys_proto.h
+++ b/include/asm/arch-omap3/sys_proto.h
@@ -55,6 +55,7 @@ u32 get_device_type(void);


void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel);

void secure_unlock(void);
+void try_unlock_memory(void);



void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value);
u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound);

--
1.7.0.4

Gadiyar, Anand

unread,
Jul 14, 2011, 8:15:29 AM7/14/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra
Enric Balletbo i Serra wrote:
> Hello,
>
> This is an attempt to remove the duplicated code present in diferents boards,
> the idea is move common functions to cpu/omap3/sys_info.c file, like u-boot.
>
> As this moves a lot of code must be really tested for all OMAP3 boards, I've
> tested on IGEP0020, IGEP0030, OMAP3EVM and BEAGLEBOARD booting from SDCARD.
>
> I don't have tested yet booting from flash device.
>
> If someone would like to test can pull the patches from:
> URL: git://git.igep.es/pub/scm/x-loader.git
> Branch: for-next
>
> I'm waiting for your comments.

I haven't seen any comments yet, so I've applied this series too.

That ought to clear out all patches sent to the list so far.
If I've missed any, please let me know.

I've only tested on my pandaboard so far. I'll try and test some
other boards when I get a chance.

I'd like to tag a new release if all is well with the patches
pushed so far. How does 1.5.1 sound?

Thanks,
Anand

Ricardo Salveti

unread,
Jul 15, 2011, 1:34:58 AM7/15/11
to x-lo...@googlegroups.com, Enric Balletbo i Serra

Guess the only remaining useful patch is the "[PATCH v2][RFC] Beagle
Rev C5 support" sent by Koen.

After applying this patch I'm fine for a 1.5.1 release :-)

Thanks!
--
Ricardo Salveti de Araujo

Reply all
Reply to author
Forward
0 new messages