summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/linux-hierofalcon/412-3-styx-linux-tracking.git-427c918b150e5f9c25ea36b3d640e511a08abb5f.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/linux/linux-hierofalcon/412-3-styx-linux-tracking.git-427c918b150e5f9c25ea36b3d640e511a08abb5f.patch')
-rw-r--r--recipes-kernel/linux/linux-hierofalcon/412-3-styx-linux-tracking.git-427c918b150e5f9c25ea36b3d640e511a08abb5f.patch211
1 files changed, 211 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-hierofalcon/412-3-styx-linux-tracking.git-427c918b150e5f9c25ea36b3d640e511a08abb5f.patch b/recipes-kernel/linux/linux-hierofalcon/412-3-styx-linux-tracking.git-427c918b150e5f9c25ea36b3d640e511a08abb5f.patch
new file mode 100644
index 0000000..b32044d
--- /dev/null
+++ b/recipes-kernel/linux/linux-hierofalcon/412-3-styx-linux-tracking.git-427c918b150e5f9c25ea36b3d640e511a08abb5f.patch
@@ -0,0 +1,211 @@
1From 8c969157c0ac60d23ff2102ca0b5a893cedf2fad Mon Sep 17 00:00:00 2001
2From: Adrian Calianu <adrian.calianu@enea.com>
3Date: Mon, 10 Aug 2015 17:53:12 +0200
4Subject: [PATCH] Subject: [PATCH] pci-host-generic
5
6Ported from 3.19 kernel:
7
8From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
9Date: Tue, 20 Jan 2015 19:30:58 -0600
10
11Signed-off-by: Adrian Calianu <adrian.calianu@enea.com>
12---
13 drivers/pci/host/Kconfig | 2 +-
14 drivers/pci/host/pci-host-generic.c | 97 ++++++++++++++++++++++++++++++++-----
15 2 files changed, 87 insertions(+), 12 deletions(-)
16
17diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig
18index 1dfb567..aeca260 100644
19--- a/drivers/pci/host/Kconfig
20+++ b/drivers/pci/host/Kconfig
21@@ -53,7 +53,7 @@ config PCI_RCAR_GEN2_PCIE
22
23 config PCI_HOST_GENERIC
24 bool "Generic PCI host controller"
25- depends on ARM && OF
26+ depends on (ARM || ARM64) && OF
27 help
28 Say Y here if you want to support a simple generic PCI host
29 controller, such as the one emulated by kvmtool.
30diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
31index ba46e58..01931e8 100644
32--- a/drivers/pci/host/pci-host-generic.c
33+++ b/drivers/pci/host/pci-host-generic.c
34@@ -44,12 +44,21 @@ struct gen_pci {
35 struct list_head resources;
36 };
37
38+#ifdef CONFIG_ARM64
39+#define bus_to_gen_pci(b) \
40+ ((struct gen_pci *)b->sysdata)
41+#else
42+#define bus_to_gen_pci(b) \
43+ ((struct gen_pci *) \
44+ (((struct pci_sys_data *) \
45+ (bus->sysdata))->private_data))
46+#endif
47+
48 static void __iomem *gen_pci_map_cfg_bus_cam(struct pci_bus *bus,
49 unsigned int devfn,
50 int where)
51 {
52- struct pci_sys_data *sys = bus->sysdata;
53- struct gen_pci *pci = sys->private_data;
54+ struct gen_pci *pci = bus_to_gen_pci(bus);
55 resource_size_t idx = bus->number - pci->cfg.bus_range->start;
56
57 return pci->cfg.win[idx] + ((devfn << 8) | where);
58@@ -64,8 +73,7 @@ static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
59 unsigned int devfn,
60 int where)
61 {
62- struct pci_sys_data *sys = bus->sysdata;
63- struct gen_pci *pci = sys->private_data;
64+ struct gen_pci *pci = bus_to_gen_pci(bus);
65 resource_size_t idx = bus->number - pci->cfg.bus_range->start;
66
67 return pci->cfg.win[idx] + ((devfn << 12) | where);
68@@ -94,6 +102,13 @@ MODULE_DEVICE_TABLE(of, gen_pci_of_match);
69
70 static void gen_pci_release_of_pci_ranges(struct gen_pci *pci)
71 {
72+ struct pci_host_bridge_window *win;
73+
74+ list_for_each_entry(win, &pci->resources, list)
75+ /* Release only requested resources */
76+ if (win->res->parent)
77+ release_resource(win->res);
78+
79 pci_free_resource_list(&pci->resources);
80 }
81
82@@ -117,11 +132,6 @@ static int gen_pci_parse_request_of_pci_ranges(struct gen_pci *pci)
83 case IORESOURCE_IO:
84 parent = &ioport_resource;
85 err = pci_remap_iospace(res, iobase);
86- if (err) {
87- dev_warn(dev, "error %d: failed to map resource %pR\n",
88- err, res);
89- continue;
90- }
91 break;
92 case IORESOURCE_MEM:
93 parent = &iomem_resource;
94@@ -129,11 +139,20 @@ static int gen_pci_parse_request_of_pci_ranges(struct gen_pci *pci)
95 break;
96 case IORESOURCE_BUS:
97 pci->cfg.bus_range = res;
98+ continue;
99 default:
100+ err = -EINVAL;
101 continue;
102 }
103
104- err = devm_request_resource(dev, parent, res);
105+ if (err) {
106+ dev_warn(dev,
107+ "error %d: failed to add resource %pR\n", err,
108+ res);
109+ continue;
110+ }
111+
112+ err = request_resource(parent, res);
113 if (err)
114 goto out_release_res;
115 }
116@@ -198,12 +217,51 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
117 return 0;
118 }
119
120+#ifndef CONFIG_ARM64
121 static int gen_pci_setup(int nr, struct pci_sys_data *sys)
122 {
123 struct gen_pci *pci = sys->private_data;
124 list_splice_init(&pci->resources, &sys->resources);
125 return 1;
126 }
127+#endif
128+
129+#ifdef CONFIG_ARM64
130+struct pci_bus *gen_scan_root_bus(struct device *parent, int bus,
131+ struct pci_ops *ops, void *sysdata,
132+ struct list_head *resources)
133+{
134+ struct pci_host_bridge_window *window;
135+ bool found = false;
136+ struct pci_bus *b;
137+ int max;
138+
139+ list_for_each_entry(window, resources, list)
140+ if (window->res->flags & IORESOURCE_BUS) {
141+ found = true;
142+ break;
143+ }
144+
145+ b = pci_create_root_bus(parent, bus, ops, sysdata, resources);
146+ if (!b)
147+ return NULL;
148+
149+ if (!found) {
150+ dev_info(&b->dev,
151+ "No busn resource found for root bus, will use [bus %02x-ff]\n",
152+ bus);
153+ pci_bus_insert_busn_res(b, bus, 255);
154+ }
155+
156+ max = pci_scan_child_bus(b);
157+
158+ if (!found)
159+ pci_bus_update_busn_res_end(b, max);
160+
161+ pci_bus_add_devices(b);
162+ return b;
163+}
164+#endif
165
166 static int gen_pci_probe(struct platform_device *pdev)
167 {
168@@ -214,6 +272,7 @@ static int gen_pci_probe(struct platform_device *pdev)
169 struct device *dev = &pdev->dev;
170 struct device_node *np = dev->of_node;
171 struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL);
172+#ifndef CONFIG_ARM64
173 struct hw_pci hw = {
174 .nr_controllers = 1,
175 .private_data = (void **)&pci,
176@@ -221,6 +280,9 @@ static int gen_pci_probe(struct platform_device *pdev)
177 .map_irq = of_irq_parse_and_map_pci,
178 .ops = &gen_pci_ops,
179 };
180+#else
181+ struct pci_bus *bus;
182+#endif
183
184 if (!pci)
185 return -ENOMEM;
186@@ -257,8 +319,21 @@ static int gen_pci_probe(struct platform_device *pdev)
187 gen_pci_release_of_pci_ranges(pci);
188 return err;
189 }
190-
191+#ifdef CONFIG_ARM64
192+ bus = gen_scan_root_bus(&pdev->dev, pci->cfg.bus_range->start,
193+ &gen_pci_ops, pci, &pci->resources);
194+ if (!bus) {
195+ dev_err(&pdev->dev, "failed to enable PCIe ports\n");
196+ return -ENODEV;
197+ }
198+
199+ if (!pci_has_flag(PCI_PROBE_ONLY)) {
200+ pci_bus_size_bridges(bus);
201+ pci_bus_assign_resources(bus);
202+ }
203+#else
204 pci_common_init_dev(dev, &hw);
205+#endif /* CONFIG_ARM64 */
206 return 0;
207 }
208
209--
2101.9.1
211