bus: mvebu-mbus: Add new API for window creation
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fri, 26 Jul 2013 13:17:39 +0000 (10:17 -0300)
committerJason Cooper <jason@lakedaemon.net>
Tue, 6 Aug 2013 14:10:01 +0000 (14:10 +0000)
We add an API to create MBus address decoding windows from the target
ID and attribute. This function will be used later and deprecate the
current name based scheme.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
drivers/bus/mvebu-mbus.c
include/linux/mbus.h

index 33c6947eebecb5069c156003563548efaa4c3b6b..827468abb236a62396799fb94a3eff3482a9c786 100644 (file)
@@ -748,6 +748,22 @@ static const struct of_device_id of_mvebu_mbus_ids[] = {
 /*
  * Public API of the driver
  */
+int mvebu_mbus_add_window_remap_by_id(unsigned int target,
+                                     unsigned int attribute,
+                                     phys_addr_t base, size_t size,
+                                     phys_addr_t remap)
+{
+       struct mvebu_mbus_state *s = &mbus_state;
+
+       if (!mvebu_mbus_window_conflicts(s, base, size, target, attribute)) {
+               pr_err("cannot add window '%x:%x', conflicts with another window\n",
+                      target, attribute);
+               return -EINVAL;
+       }
+
+       return mvebu_mbus_alloc_window(s, base, size, remap, target, attribute);
+}
+
 int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base,
                                      size_t size, phys_addr_t remap,
                                      unsigned int flags)
@@ -776,14 +792,8 @@ int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base,
        else if (flags == MVEBU_MBUS_PCI_WA)
                attr |= 0x28;
 
-       if (!mvebu_mbus_window_conflicts(s, base, size, target, attr)) {
-               pr_err("cannot add window '%s', conflicts with another window\n",
-                      devname);
-               return -EINVAL;
-       }
-
-       return mvebu_mbus_alloc_window(s, base, size, remap, target, attr);
-
+       return mvebu_mbus_add_window_remap_by_id(target, attr, base,
+                                                size, remap);
 }
 
 int mvebu_mbus_add_window(const char *devname, phys_addr_t base, size_t size)
@@ -792,6 +802,13 @@ int mvebu_mbus_add_window(const char *devname, phys_addr_t base, size_t size)
                                                 MVEBU_MBUS_NO_REMAP, 0);
 }
 
+int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
+                               phys_addr_t base, size_t size)
+{
+       return mvebu_mbus_add_window_remap_by_id(target, attribute, base,
+                                                size, MVEBU_MBUS_NO_REMAP);
+}
+
 int mvebu_mbus_del_window(phys_addr_t base, size_t size)
 {
        int win;
index dba482e31a130e2e29690bf0c63e36b1e88e6aa8..9245b663e720af5ea266c459a4b321929879f38a 100644 (file)
@@ -62,8 +62,14 @@ static inline const struct mbus_dram_target_info *mv_mbus_dram_info(void)
 int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base,
                                      size_t size, phys_addr_t remap,
                                      unsigned int flags);
+int mvebu_mbus_add_window_remap_by_id(unsigned int target,
+                                     unsigned int attribute,
+                                     phys_addr_t base, size_t size,
+                                     phys_addr_t remap);
 int mvebu_mbus_add_window(const char *devname, phys_addr_t base,
                          size_t size);
+int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute,
+                               phys_addr_t base, size_t size);
 int mvebu_mbus_del_window(phys_addr_t base, size_t size);
 int mvebu_mbus_init(const char *soc, phys_addr_t mbus_phys_base,
                    size_t mbus_size, phys_addr_t sdram_phys_base,