1983016ddf9c4b0bc8c4404b9aa03915067bb7ec
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0037-memory-mvebu-devbus-Remove-address-decoding-window-w.patch
1 From 9760aafa716292050a96d71a4bd7bd4e66053975 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Tue, 21 May 2013 10:24:48 -0300
4 Subject: [PATCH 037/203] memory: mvebu-devbus: Remove address decoding window
5  workaround
6
7 Now that mbus device tree binding has been introduced, remove the address
8 decoding window management from this driver.
9 A suitable 'ranges' entry should be added to the devbus-compatible node in
10 the device tree, as described by the mbus binding documentation.
11
12 Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
14 Tested-by: Andrew Lunn <andrew@lunn.ch>
15 Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
16 ---
17  drivers/memory/mvebu-devbus.c | 64 ++-----------------------------------------
18  1 file changed, 2 insertions(+), 62 deletions(-)
19
20 --- a/drivers/memory/mvebu-devbus.c
21 +++ b/drivers/memory/mvebu-devbus.c
22 @@ -208,16 +208,11 @@ static int mvebu_devbus_probe(struct pla
23  {
24         struct device *dev = &pdev->dev;
25         struct device_node *node = pdev->dev.of_node;
26 -       struct device_node *parent;
27         struct devbus *devbus;
28         struct resource *res;
29         struct clk *clk;
30         unsigned long rate;
31 -       const __be32 *ranges;
32 -       int err, cs;
33 -       int addr_cells, p_addr_cells, size_cells;
34 -       int ranges_len, tuple_len;
35 -       u32 base, size;
36 +       int err;
37  
38         devbus = devm_kzalloc(&pdev->dev, sizeof(struct devbus), GFP_KERNEL);
39         if (!devbus)
40 @@ -248,68 +243,13 @@ static int mvebu_devbus_probe(struct pla
41                 return err;
42  
43         /*
44 -        * Allocate an address window for this device.
45 -        * If the device probing fails, then we won't be able to
46 -        * remove the allocated address decoding window.
47 -        *
48 -        * FIXME: This is only a temporary hack! We need to do this here
49 -        * because we still don't have device tree bindings for mbus.
50 -        * Once that support is added, we will declare these address windows
51 -        * statically in the device tree, and remove the window configuration
52 -        * from here.
53 -        */
54 -
55 -       /*
56 -        * Get the CS to choose the window string.
57 -        * This is a bit hacky, but it will be removed once the
58 -        * address windows are declared in the device tree.
59 -        */
60 -       cs = (((unsigned long)devbus->base) % 0x400) / 8;
61 -
62 -       /*
63 -        * Parse 'ranges' property to obtain a (base,size) window tuple.
64 -        * This will be removed once the address windows
65 -        * are declared in the device tree.
66 -        */
67 -       parent = of_get_parent(node);
68 -       if (!parent)
69 -               return -EINVAL;
70 -
71 -       p_addr_cells = of_n_addr_cells(parent);
72 -       of_node_put(parent);
73 -
74 -       addr_cells = of_n_addr_cells(node);
75 -       size_cells = of_n_size_cells(node);
76 -       tuple_len = (p_addr_cells + addr_cells + size_cells) * sizeof(__be32);
77 -
78 -       ranges = of_get_property(node, "ranges", &ranges_len);
79 -       if (ranges == NULL || ranges_len != tuple_len)
80 -               return -EINVAL;
81 -
82 -       base = of_translate_address(node, ranges + addr_cells);
83 -       if (base == OF_BAD_ADDR)
84 -               return -EINVAL;
85 -       size = of_read_number(ranges + addr_cells + p_addr_cells, size_cells);
86 -
87 -       /*
88 -        * Create an mbus address windows.
89 -        * FIXME: Remove this, together with the above code, once the
90 -        * address windows are declared in the device tree.
91 -        */
92 -       err = mvebu_mbus_add_window(devbus_wins[cs], base, size);
93 -       if (err < 0)
94 -               return err;
95 -
96 -       /*
97          * We need to create a child device explicitly from here to
98          * guarantee that the child will be probed after the timing
99          * parameters for the bus are written.
100          */
101         err = of_platform_populate(node, NULL, NULL, dev);
102 -       if (err < 0) {
103 -               mvebu_mbus_del_window(base, size);
104 +       if (err < 0)
105                 return err;
106 -       }
107  
108         return 0;
109  }