xref: /openbmc/linux/arch/powerpc/boot/fsl-soc.c (revision 293d5b43)
1 /*
2  * Freescale SOC support functions
3  *
4  * Author: Scott Wood <scottwood@freescale.com>
5  *
6  * Copyright (c) 2007 Freescale Semiconductor, Inc.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License version 2 as published
10  * by the Free Software Foundation.
11  */
12 
13 #include "ops.h"
14 #include "types.h"
15 #include "fsl-soc.h"
16 #include "stdio.h"
17 
18 static u32 prop_buf[MAX_PROP_LEN / 4];
19 
20 u32 *fsl_get_immr(void)
21 {
22 	void *soc;
23 	unsigned long ret = 0;
24 
25 	soc = find_node_by_devtype(NULL, "soc");
26 	if (soc) {
27 		int size;
28 		u32 naddr;
29 
30 		size = getprop(soc, "#address-cells", prop_buf, MAX_PROP_LEN);
31 		if (size == 4)
32 			naddr = prop_buf[0];
33 		else
34 			naddr = 2;
35 
36 		if (naddr != 1 && naddr != 2)
37 			goto err;
38 
39 		size = getprop(soc, "ranges", prop_buf, MAX_PROP_LEN);
40 
41 		if (size < 12)
42 			goto err;
43 		if (prop_buf[0] != 0)
44 			goto err;
45 		if (naddr == 2 && prop_buf[1] != 0)
46 			goto err;
47 
48 		if (!dt_xlate_addr(soc, prop_buf + naddr, 8, &ret))
49 			ret = 0;
50 	}
51 
52 err:
53 	if (!ret)
54 		printf("fsl_get_immr: Failed to find immr base\r\n");
55 
56 	return (u32 *)ret;
57 }
58