base-files: define yes/no as valid boolean options
[openwrt/staging/lynxis/omap.git] / target / linux / mvebu / patches-3.10 / 0046-bus-mvebu-mbus-Add-new-API-for-the-PCIe-memory-and-I.patch
1 From c9646c891dbd07061a9ff5e061f9f9e54c571349 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Tue, 9 Jul 2013 10:41:53 -0300
4 Subject: [PATCH 046/203] bus: mvebu-mbus: Add new API for the PCIe memory and
5 IO aperture
6
7 We add two optional properties to the MBus DT binding, to encode
8 the PCIe memory and IO aperture. This allows such information to
9 be retrieved by -for instance- the pci driver to allocate the
10 MBus decoding windows.
11
12 Correspondingly, and in order to retrieve this information,
13 we add two new APIs.
14
15 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
16 Tested-by: Andrew Lunn <andrew@lunn.ch>
17 Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
18 ---
19 drivers/bus/mvebu-mbus.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
20 include/linux/mbus.h | 4 ++++
21 2 files changed, 53 insertions(+)
22
23 --- a/drivers/bus/mvebu-mbus.c
24 +++ b/drivers/bus/mvebu-mbus.c
25 @@ -142,6 +142,8 @@ struct mvebu_mbus_state {
26 struct dentry *debugfs_root;
27 struct dentry *debugfs_sdram;
28 struct dentry *debugfs_devs;
29 + struct resource pcie_mem_aperture;
30 + struct resource pcie_io_aperture;
31 const struct mvebu_mbus_soc_data *soc;
32 int hw_io_coherency;
33 };
34 @@ -821,6 +823,20 @@ int mvebu_mbus_del_window(phys_addr_t ba
35 return 0;
36 }
37
38 +void mvebu_mbus_get_pcie_mem_aperture(struct resource *res)
39 +{
40 + if (!res)
41 + return;
42 + *res = mbus_state.pcie_mem_aperture;
43 +}
44 +
45 +void mvebu_mbus_get_pcie_io_aperture(struct resource *res)
46 +{
47 + if (!res)
48 + return;
49 + *res = mbus_state.pcie_io_aperture;
50 +}
51 +
52 static __init int mvebu_mbus_debugfs_init(void)
53 {
54 struct mvebu_mbus_state *s = &mbus_state;
55 @@ -1023,6 +1039,35 @@ static int __init mbus_dt_setup(struct m
56 return 0;
57 }
58
59 +static void __init mvebu_mbus_get_pcie_resources(struct device_node *np,
60 + struct resource *mem,
61 + struct resource *io)
62 +{
63 + u32 reg[2];
64 + int ret;
65 +
66 + /*
67 + * These are optional, so we clear them and they'll
68 + * be zero if they are missing from the DT.
69 + */
70 + memset(mem, 0, sizeof(struct resource));
71 + memset(io, 0, sizeof(struct resource));
72 +
73 + ret = of_property_read_u32_array(np, "pcie-mem-aperture", reg, ARRAY_SIZE(reg));
74 + if (!ret) {
75 + mem->start = reg[0];
76 + mem->end = mem->start + reg[1];
77 + mem->flags = IORESOURCE_MEM;
78 + }
79 +
80 + ret = of_property_read_u32_array(np, "pcie-io-aperture", reg, ARRAY_SIZE(reg));
81 + if (!ret) {
82 + io->start = reg[0];
83 + io->end = io->start + reg[1];
84 + io->flags = IORESOURCE_IO;
85 + }
86 +}
87 +
88 int __init mvebu_mbus_dt_init(void)
89 {
90 struct resource mbuswins_res, sdramwins_res;
91 @@ -1062,6 +1107,10 @@ int __init mvebu_mbus_dt_init(void)
92 return -EINVAL;
93 }
94
95 + /* Get optional pcie-{mem,io}-aperture properties */
96 + mvebu_mbus_get_pcie_resources(np, &mbus_state.pcie_mem_aperture,
97 + &mbus_state.pcie_io_aperture);
98 +
99 ret = mvebu_mbus_common_init(&mbus_state,
100 mbuswins_res.start,
101 resource_size(&mbuswins_res),
102 --- a/include/linux/mbus.h
103 +++ b/include/linux/mbus.h
104 @@ -11,6 +11,8 @@
105 #ifndef __LINUX_MBUS_H
106 #define __LINUX_MBUS_H
107
108 +struct resource;
109 +
110 struct mbus_dram_target_info
111 {
112 /*
113 @@ -59,6 +61,8 @@ static inline const struct mbus_dram_tar
114 }
115 #endif
116
117 +void mvebu_mbus_get_pcie_mem_aperture(struct resource *res);
118 +void mvebu_mbus_get_pcie_io_aperture(struct resource *res);
119 int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base,
120 size_t size, phys_addr_t remap,
121 unsigned int flags);