4ebb3f3216d26e7895d1850423c9d0a20dcf8628
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0038-bus-mvebu-mbus-Add-new-API-for-window-creation.patch
1 From 93b6bd1bf81cffd3e5739478c4434bf25458ec7d Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Fri, 5 Jul 2013 14:54:16 +0200
4 Subject: [PATCH 038/203] bus: mvebu-mbus: Add new API for window creation
5
6 We add an API to create MBus address decoding windows from the target
7 ID and attribute. This function will be used later and deprecate the
8 current name based scheme.
9
10 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
11 Tested-by: Andrew Lunn <andrew@lunn.ch>
12 Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
13 ---
14  drivers/bus/mvebu-mbus.c | 33 +++++++++++++++++++++++++--------
15  include/linux/mbus.h     |  6 ++++++
16  2 files changed, 31 insertions(+), 8 deletions(-)
17
18 --- a/drivers/bus/mvebu-mbus.c
19 +++ b/drivers/bus/mvebu-mbus.c
20 @@ -748,6 +748,22 @@ static const struct of_device_id of_mveb
21  /*
22   * Public API of the driver
23   */
24 +int mvebu_mbus_add_window_remap_by_id(unsigned int target,
25 +                                     unsigned int attribute,
26 +                                     phys_addr_t base, size_t size,
27 +                                     phys_addr_t remap)
28 +{
29 +       struct mvebu_mbus_state *s = &mbus_state;
30 +
31 +       if (!mvebu_mbus_window_conflicts(s, base, size, target, attribute)) {
32 +               pr_err("cannot add window '%x:%x', conflicts with another window\n",
33 +                      target, attribute);
34 +               return -EINVAL;
35 +       }
36 +
37 +       return mvebu_mbus_alloc_window(s, base, size, remap, target, attribute);
38 +}
39 +
40  int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base,
41                                       size_t size, phys_addr_t remap,
42                                       unsigned int flags)
43 @@ -776,14 +792,8 @@ int mvebu_mbus_add_window_remap_flags(co
44         else if (flags == MVEBU_MBUS_PCI_WA)
45                 attr |= 0x28;
46  
47 -       if (!mvebu_mbus_window_conflicts(s, base, size, target, attr)) {
48 -               pr_err("cannot add window '%s', conflicts with another window\n",
49 -                      devname);
50 -               return -EINVAL;
51 -       }
52 -
53 -       return mvebu_mbus_alloc_window(s, base, size, remap, target, attr);
54 -
55 +       return mvebu_mbus_add_window_remap_by_id(target, attr, base,
56 +                                                size, remap);
57  }
58  
59  int mvebu_mbus_add_window(const char *devname, phys_addr_t base, size_t size)
60 @@ -792,6 +802,13 @@ int mvebu_mbus_add_window(const char *de
61                                                  MVEBU_MBUS_NO_REMAP, 0);
62  }
63  
64 +int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
65 +                               phys_addr_t base, size_t size)
66 +{
67 +       return mvebu_mbus_add_window_remap_by_id(target, attribute, base,
68 +                                                size, MVEBU_MBUS_NO_REMAP);
69 +}
70 +
71  int mvebu_mbus_del_window(phys_addr_t base, size_t size)
72  {
73         int win;
74 --- a/include/linux/mbus.h
75 +++ b/include/linux/mbus.h
76 @@ -62,8 +62,14 @@ static inline const struct mbus_dram_tar
77  int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base,
78                                       size_t size, phys_addr_t remap,
79                                       unsigned int flags);
80 +int mvebu_mbus_add_window_remap_by_id(unsigned int target,
81 +                                     unsigned int attribute,
82 +                                     phys_addr_t base, size_t size,
83 +                                     phys_addr_t remap);
84  int mvebu_mbus_add_window(const char *devname, phys_addr_t base,
85                           size_t size);
86 +int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
87 +                               phys_addr_t base, size_t size);
88  int mvebu_mbus_del_window(phys_addr_t base, size_t size);
89  int mvebu_mbus_init(const char *soc, phys_addr_t mbus_phys_base,
90                     size_t mbus_size, phys_addr_t sdram_phys_base,