aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap_hwmod.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2012-04-19 06:04:29 -0400
committerPaul Walmsley <paul@pwsan.com>2012-04-19 06:04:29 -0400
commit24dbc2130179ebd493a241f6f5972cf6524b933a (patch)
treec5ac665e3ccfb75d2482628845aa84f57daa4438 /arch/arm/mach-omap2/omap_hwmod.c
parent5d95dde7316101656102cb585b73381e4eaadaa7 (diff)
ARM: OMAP2+: hwmod: consolidate finding the MPU port index and storing it
An IP block's MPU interface port only needs to be found once. The result can be cached to speed further lookups. This patch consolidates these two steps into a single function. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: BenoƮt Cousson <b-cousson@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index f74f3af95ca..8cf837d2332 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1008,37 +1008,34 @@ static int _get_addr_space_by_name(struct omap_hwmod *oh, const char *name,
1008} 1008}
1009 1009
1010/** 1010/**
1011 * _find_mpu_port_index - find hwmod OCP slave port ID intended for MPU use 1011 * _save_mpu_port_index - find and save the index to @oh's MPU port
1012 * @oh: struct omap_hwmod * 1012 * @oh: struct omap_hwmod *
1013 * 1013 *
1014 * Returns the array index of the OCP slave port that the MPU 1014 * Determines the array index of the OCP slave port that the MPU uses
1015 * addresses the device on, or -EINVAL upon error or not found. 1015 * to address the device, and saves it into the struct omap_hwmod.
1016 * Intended to be called during hwmod registration only. No return
1017 * value.
1016 */ 1018 */
1017static int __init _find_mpu_port_index(struct omap_hwmod *oh) 1019static void __init _save_mpu_port_index(struct omap_hwmod *oh)
1018{ 1020{
1019 struct omap_hwmod_ocp_if *os; 1021 struct omap_hwmod_ocp_if *os = NULL;
1020 int i = 0; 1022 int i = 0;
1021 int found = 0;
1022 1023
1023 if (!oh) 1024 if (!oh)
1024 return -EINVAL; 1025 return;
1026
1027 oh->_int_flags |= _HWMOD_NO_MPU_PORT;
1025 1028
1026 while (i < oh->slaves_cnt) { 1029 while (i < oh->slaves_cnt) {
1027 os = _fetch_next_ocp_if(NULL, oh->slaves, &i); 1030 os = _fetch_next_ocp_if(NULL, oh->slaves, &i);
1028 if (os->user & OCP_USER_MPU) { 1031 if (os->user & OCP_USER_MPU) {
1029 found = 1; 1032 oh->_mpu_port_index = i - 1;
1033 oh->_int_flags &= ~_HWMOD_NO_MPU_PORT;
1030 break; 1034 break;
1031 } 1035 }
1032 } 1036 }
1033 1037
1034 if (found) 1038 return;
1035 pr_debug("omap_hwmod: %s: MPU OCP slave port ID %d\n",
1036 oh->name, i - 1);
1037 else
1038 pr_debug("omap_hwmod: %s: no MPU OCP slave port found\n",
1039 oh->name);
1040
1041 return (found) ? (i - 1) : -EINVAL;
1042} 1039}
1043 1040
1044/** 1041/**
@@ -1076,7 +1073,7 @@ static struct omap_hwmod_addr_space * __init _find_mpu_rt_addr_space(struct omap
1076 int found = 0, i = 0; 1073 int found = 0, i = 0;
1077 1074
1078 os = _find_mpu_rt_port(oh); 1075 os = _find_mpu_rt_port(oh);
1079 if (!os->addr) 1076 if (!os || !os->addr)
1080 return NULL; 1077 return NULL;
1081 1078
1082 do { 1079 do {
@@ -2213,8 +2210,6 @@ static int __init _setup(struct omap_hwmod *oh, void *data)
2213 */ 2210 */
2214static int __init _register(struct omap_hwmod *oh) 2211static int __init _register(struct omap_hwmod *oh)
2215{ 2212{
2216 int ms_id;
2217
2218 if (!oh || !oh->name || !oh->class || !oh->class->name || 2213 if (!oh || !oh->name || !oh->class || !oh->class->name ||
2219 (oh->_state != _HWMOD_STATE_UNKNOWN)) 2214 (oh->_state != _HWMOD_STATE_UNKNOWN))
2220 return -EINVAL; 2215 return -EINVAL;
@@ -2224,11 +2219,7 @@ static int __init _register(struct omap_hwmod *oh)
2224 if (_lookup(oh->name)) 2219 if (_lookup(oh->name))
2225 return -EEXIST; 2220 return -EEXIST;
2226 2221
2227 ms_id = _find_mpu_port_index(oh); 2222 _save_mpu_port_index(oh);
2228 if (!IS_ERR_VALUE(ms_id))
2229 oh->_mpu_port_index = ms_id;
2230 else
2231 oh->_int_flags |= _HWMOD_NO_MPU_PORT;
2232 2223
2233 list_add_tail(&oh->node, &omap_hwmod_list); 2224 list_add_tail(&oh->node, &omap_hwmod_list);
2234 2225