aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap_hwmod.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2017-10-10 17:27:33 -0400
committerTony Lindgren <tony@atomide.com>2017-10-10 17:27:33 -0400
commit9cffb1a0504ddc7b291cf882002ee4a794eb3fec (patch)
tree91c96c05b1084ba3423b0e6974565d39b70a4cbf /arch/arm/mach-omap2/omap_hwmod.c
parentc2b84a9bb3414cabaa039b8860a694464a0bad06 (diff)
ARM: OMAP2+: Drop legacy struct omap_hwmod_addr_space
With all of mach-omap2 booting now in device tree only mode, we can get the module IO range from device tree and just drop the legacy hwmod struct omap_hwmod_addr_space. Cc: Lokesh Vutla <lokeshvutla@ti.com> Cc: Paul Walmsley <paul@pwsan.com> Cc: Tero Kristo <t-kristo@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c253
1 files changed, 13 insertions, 240 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 29b6c85f6ce8..104256a5f0f7 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1102,82 +1102,6 @@ static int _omap4_wait_target_disable(struct omap_hwmod *oh)
1102} 1102}
1103 1103
1104/** 1104/**
1105 * _count_ocp_if_addr_spaces - count the number of address space entries for @oh
1106 * @oh: struct omap_hwmod *oh
1107 *
1108 * Count and return the number of address space ranges associated with
1109 * the hwmod @oh. Used to allocate struct resource data. Returns 0
1110 * if @oh is NULL.
1111 */
1112static int _count_ocp_if_addr_spaces(struct omap_hwmod_ocp_if *os)
1113{
1114 struct omap_hwmod_addr_space *mem;
1115 int i = 0;
1116
1117 if (!os || !os->addr)
1118 return 0;
1119
1120 do {
1121 mem = &os->addr[i++];
1122 } while (mem->pa_start != mem->pa_end);
1123
1124 return i-1;
1125}
1126
1127/**
1128 * _get_addr_space_by_name - fetch address space start & end by name
1129 * @oh: struct omap_hwmod * to operate on
1130 * @name: pointer to the name of the address space to fetch (optional)
1131 * @pa_start: pointer to a u32 to store the starting address to
1132 * @pa_end: pointer to a u32 to store the ending address to
1133 *
1134 * Retrieve address space start and end addresses for the IP block
1135 * pointed to by @oh. The data will be filled into the addresses
1136 * pointed to by @pa_start and @pa_end. When @name is non-null, the
1137 * address space data associated with the named entry will be
1138 * returned. If @name is null, the first matching entry will be
1139 * returned. Data order is not meaningful in hwmod data, so callers
1140 * are strongly encouraged to use a non-null @name whenever possible
1141 * to avoid unpredictable effects if hwmod data is later added that
1142 * causes data ordering to change. Returns 0 upon success or a
1143 * negative error code upon error.
1144 */
1145static int _get_addr_space_by_name(struct omap_hwmod *oh, const char *name,
1146 u32 *pa_start, u32 *pa_end)
1147{
1148 int j;
1149 struct omap_hwmod_ocp_if *os;
1150 bool found = false;
1151
1152 list_for_each_entry(os, &oh->slave_ports, node) {
1153
1154 if (!os->addr)
1155 return -ENOENT;
1156
1157 j = 0;
1158 while (os->addr[j].pa_start != os->addr[j].pa_end) {
1159 if (name == os->addr[j].name ||
1160 !strcmp(name, os->addr[j].name)) {
1161 found = true;
1162 break;
1163 }
1164 j++;
1165 }
1166
1167 if (found)
1168 break;
1169 }
1170
1171 if (!found)
1172 return -ENOENT;
1173
1174 *pa_start = os->addr[j].pa_start;
1175 *pa_end = os->addr[j].pa_end;
1176
1177 return 0;
1178}
1179
1180/**
1181 * _save_mpu_port_index - find and save the index to @oh's MPU port 1105 * _save_mpu_port_index - find and save the index to @oh's MPU port
1182 * @oh: struct omap_hwmod * 1106 * @oh: struct omap_hwmod *
1183 * 1107 *
@@ -1228,32 +1152,6 @@ static struct omap_hwmod_ocp_if *_find_mpu_rt_port(struct omap_hwmod *oh)
1228}; 1152};
1229 1153
1230/** 1154/**
1231 * _find_mpu_rt_addr_space - return MPU register target address space for @oh
1232 * @oh: struct omap_hwmod *
1233 *
1234 * Returns a pointer to the struct omap_hwmod_addr_space record representing
1235 * the register target MPU address space; or returns NULL upon error.
1236 */
1237static struct omap_hwmod_addr_space * __init _find_mpu_rt_addr_space(struct omap_hwmod *oh)
1238{
1239 struct omap_hwmod_ocp_if *os;
1240 struct omap_hwmod_addr_space *mem;
1241 int found = 0, i = 0;
1242
1243 os = _find_mpu_rt_port(oh);
1244 if (!os || !os->addr)
1245 return NULL;
1246
1247 do {
1248 mem = &os->addr[i++];
1249 if (mem->flags & ADDR_TYPE_RT)
1250 found = 1;
1251 } while (!found && mem->pa_start != mem->pa_end);
1252
1253 return (found) ? mem : NULL;
1254}
1255
1256/**
1257 * _enable_sysc - try to bring a module out of idle via OCP_SYSCONFIG 1155 * _enable_sysc - try to bring a module out of idle via OCP_SYSCONFIG
1258 * @oh: struct omap_hwmod * 1156 * @oh: struct omap_hwmod *
1259 * 1157 *
@@ -2349,7 +2247,6 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
2349static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, 2247static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data,
2350 int index, struct device_node *np) 2248 int index, struct device_node *np)
2351{ 2249{
2352 struct omap_hwmod_addr_space *mem;
2353 void __iomem *va_start = NULL; 2250 void __iomem *va_start = NULL;
2354 struct resource res; 2251 struct resource res;
2355 int error; 2252 int error;
@@ -2367,35 +2264,22 @@ static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data,
2367 if (oh->_int_flags & _HWMOD_NO_MPU_PORT) 2264 if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
2368 return -ENXIO; 2265 return -ENXIO;
2369 2266
2370 mem = _find_mpu_rt_addr_space(oh); 2267 if (!np) {
2371 if (!mem) { 2268 pr_err("omap_hwmod: %s: no dt node\n", oh->name);
2372 pr_debug("omap_hwmod: %s: no MPU register target found\n", 2269 return -ENXIO;
2373 oh->name);
2374
2375 /* Extract the IO space from device tree blob */
2376 if (!np) {
2377 pr_err("omap_hwmod: %s: no dt node\n", oh->name);
2378 return -ENXIO;
2379 }
2380
2381 /* Do we have a dts range for the interconnect target module? */
2382 error = omap_hwmod_parse_module_range(oh, np, &res);
2383 if (!error)
2384 va_start = ioremap(res.start, resource_size(&res));
2385
2386 /* No ranges, rely on device reg entry */
2387 if (!va_start)
2388 va_start = of_iomap(np, index + oh->mpu_rt_idx);
2389 } else {
2390 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start);
2391 } 2270 }
2392 2271
2272 /* Do we have a dts range for the interconnect target module? */
2273 error = omap_hwmod_parse_module_range(oh, np, &res);
2274 if (!error)
2275 va_start = ioremap(res.start, resource_size(&res));
2276
2277 /* No ranges, rely on device reg entry */
2278 if (!va_start)
2279 va_start = of_iomap(np, index + oh->mpu_rt_idx);
2393 if (!va_start) { 2280 if (!va_start) {
2394 if (mem) 2281 pr_err("omap_hwmod: %s: Missing dt reg%i for %pOF\n",
2395 pr_err("omap_hwmod: %s: Could not ioremap\n", oh->name); 2282 oh->name, index, np);
2396 else
2397 pr_err("omap_hwmod: %s: Missing dt reg%i for %pOF\n",
2398 oh->name, index, np);
2399 return -ENXIO; 2283 return -ENXIO;
2400 } 2284 }
2401 2285
@@ -3300,117 +3184,6 @@ int omap_hwmod_shutdown(struct omap_hwmod *oh)
3300 */ 3184 */
3301 3185
3302/** 3186/**
3303 * omap_hwmod_count_resources - count number of struct resources needed by hwmod
3304 * @oh: struct omap_hwmod *
3305 * @flags: Type of resources to include when counting (IRQ/DMA/MEM)
3306 *
3307 * Count the number of struct resource array elements necessary to
3308 * contain omap_hwmod @oh resources. Intended to be called by code
3309 * that registers omap_devices. Intended to be used to determine the
3310 * size of a dynamically-allocated struct resource array, before
3311 * calling omap_hwmod_fill_resources(). Returns the number of struct
3312 * resource array elements needed.
3313 *
3314 * XXX This code is not optimized. It could attempt to merge adjacent
3315 * resource IDs.
3316 *
3317 */
3318int omap_hwmod_count_resources(struct omap_hwmod *oh, unsigned long flags)
3319{
3320 int ret = 0;
3321
3322 if (flags & IORESOURCE_MEM) {
3323 struct omap_hwmod_ocp_if *os;
3324
3325 list_for_each_entry(os, &oh->slave_ports, node)
3326 ret += _count_ocp_if_addr_spaces(os);
3327 }
3328
3329 return ret;
3330}
3331
3332/**
3333 * omap_hwmod_fill_resources - fill struct resource array with hwmod data
3334 * @oh: struct omap_hwmod *
3335 * @res: pointer to the first element of an array of struct resource to fill
3336 *
3337 * Fill the struct resource array @res with resource data from the
3338 * omap_hwmod @oh. Intended to be called by code that registers
3339 * omap_devices. See also omap_hwmod_count_resources(). Returns the
3340 * number of array elements filled.
3341 */
3342int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res)
3343{
3344 struct omap_hwmod_ocp_if *os;
3345 int j, addr_cnt;
3346 int r = 0;
3347
3348 /* For each memory area, fill in array.*/
3349
3350 list_for_each_entry(os, &oh->slave_ports, node) {
3351 addr_cnt = _count_ocp_if_addr_spaces(os);
3352
3353 for (j = 0; j < addr_cnt; j++) {
3354 (res + r)->name = (os->addr + j)->name;
3355 (res + r)->start = (os->addr + j)->pa_start;
3356 (res + r)->end = (os->addr + j)->pa_end;
3357 (res + r)->flags = IORESOURCE_MEM;
3358 r++;
3359 }
3360 }
3361
3362 return r;
3363}
3364
3365/**
3366 * omap_hwmod_get_resource_byname - fetch IP block integration data by name
3367 * @oh: struct omap_hwmod * to operate on
3368 * @type: one of the IORESOURCE_* constants from include/linux/ioport.h
3369 * @name: pointer to the name of the data to fetch (optional)
3370 * @rsrc: pointer to a struct resource, allocated by the caller
3371 *
3372 * Retrieve MPU IRQ, SDMA request line, or address space start/end
3373 * data for the IP block pointed to by @oh. The data will be filled
3374 * into a struct resource record pointed to by @rsrc. The struct
3375 * resource must be allocated by the caller. When @name is non-null,
3376 * the data associated with the matching entry in the IRQ/SDMA/address
3377 * space hwmod data arrays will be returned. If @name is null, the
3378 * first array entry will be returned. Data order is not meaningful
3379 * in hwmod data, so callers are strongly encouraged to use a non-null
3380 * @name whenever possible to avoid unpredictable effects if hwmod
3381 * data is later added that causes data ordering to change. This
3382 * function is only intended for use by OMAP core code. Device
3383 * drivers should not call this function - the appropriate bus-related
3384 * data accessor functions should be used instead. Returns 0 upon
3385 * success or a negative error code upon error.
3386 */
3387int omap_hwmod_get_resource_byname(struct omap_hwmod *oh, unsigned int type,
3388 const char *name, struct resource *rsrc)
3389{
3390 int r;
3391 u32 pa_start, pa_end;
3392
3393 if (!oh || !rsrc)
3394 return -EINVAL;
3395
3396 if (type == IORESOURCE_MEM) {
3397 r = _get_addr_space_by_name(oh, name, &pa_start, &pa_end);
3398 if (r)
3399 return r;
3400
3401 rsrc->start = pa_start;
3402 rsrc->end = pa_end;
3403 } else {
3404 return -EINVAL;
3405 }
3406
3407 rsrc->flags = type;
3408 rsrc->name = name;
3409
3410 return 0;
3411}
3412
3413/**
3414 * omap_hwmod_get_pwrdm - return pointer to this module's main powerdomain 3187 * omap_hwmod_get_pwrdm - return pointer to this module's main powerdomain
3415 * @oh: struct omap_hwmod * 3188 * @oh: struct omap_hwmod *
3416 * 3189 *