Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fsl-soc.c
Go to the documentation of this file.
1 /*
2  * Freescale SOC support functions
3  *
4  * Author: Scott Wood <[email protected]>
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 
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 }