summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2024-04-16 15:46:36 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2024-04-16 15:46:36 +0200
commitee11c8219807c2829ca8e96f057ee4dddf79c920 (patch)
treeac88978dc535762ae3990e7c2379b4bf120cf14d /include
parent107f95ee35550b9c37bf205436ebb4bf7b5997b2 (diff)
parent938ae2315a401e49bff348981fabd9231988c421 (diff)
downloadbarebox-ee11c8219807c2829ca8e96f057ee4dddf79c920.tar.gz
barebox-ee11c8219807c2829ca8e96f057ee4dddf79c920.tar.xz
Merge branch 'for-next/pci' into next
Diffstat (limited to 'include')
-rw-r--r--include/linux/pci.h37
-rw-r--r--include/linux/resource_ext.h81
-rw-r--r--include/of.h43
3 files changed, 154 insertions, 7 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index aa29ff5d17..f6511e0095 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -25,6 +25,7 @@
#include <linux/ioport.h>
#include <linux/list.h>
#include <linux/compiler.h>
+#include <linux/resource_ext.h>
#include <driver.h>
#include <errno.h>
#include <io.h>
@@ -139,14 +140,14 @@ enum {
PCI_BUS_RESOURCE_MEM_PREF = 2,
PCI_BUS_RESOURCE_BUSN = 3,
};
+
struct pci_bus {
struct pci_controller *host; /* associated host controller */
- struct device *parent;
- struct pci_bus *parent_bus; /* parent bus */
+ struct pci_dev *self;
+ struct pci_bus *parent; /* Parent bus this bridge is on */
struct list_head node; /* node in list of buses */
struct list_head children; /* list of child buses */
struct list_head devices; /* list of devices on this bus */
- struct resource *resource[PCI_BRIDGE_RESOURCE_NUM];
unsigned char number; /* bus number */
unsigned char primary; /* number of primary bridge */
@@ -184,6 +185,8 @@ struct pci_controller {
unsigned long io_offset;
unsigned long io_map_base;
+ struct list_head windows; /* resource_entry */
+
unsigned int index;
/* Optional access method for writing the bus number */
@@ -277,6 +280,7 @@ int pci_register_device(struct pci_dev *pdev);
extern struct list_head pci_root_buses; /* list of all known PCI buses */
+extern void pci_controller_init(struct pci_controller *hose);
extern void register_pci_controller(struct pci_controller *hose);
int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
@@ -393,4 +397,31 @@ static inline const struct pci_device_id *pci_match_id(const struct pci_device_i
{ return NULL; }
#endif
+/* drivers/pci/bus.c */
+void pci_add_resource_offset(struct list_head *resources, struct resource *res,
+ resource_size_t offset);
+void pci_add_resource(struct list_head *resources, struct resource *res);
+
+struct pci_controller *pci_find_host_bridge(struct pci_bus *bus);
+
+struct pci_bus_region {
+ u64 start;
+ u64 end;
+};
+
+void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
+ struct resource *res);
+void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
+ struct pci_bus_region *region);
+
+/* drivers/pci/of.c */
+#ifdef CONFIG_OFDEVICE
+int of_pci_bridge_init(struct device *dev, struct pci_controller *bridge);
+#else
+static inline int of_pci_bridge_init(struct device *dev, struct pci_controller *bridge)
+{
+ return 0;
+}
+#endif
+
#endif /* LINUX_PCI_H */
diff --git a/include/linux/resource_ext.h b/include/linux/resource_ext.h
new file mode 100644
index 0000000000..ff0339df56
--- /dev/null
+++ b/include/linux/resource_ext.h
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2015, Intel Corporation
+ * Author: Jiang Liu <jiang.liu@linux.intel.com>
+ */
+#ifndef _LINUX_RESOURCE_EXT_H
+#define _LINUX_RESOURCE_EXT_H
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+
+/* Represent resource window for bridge devices */
+struct resource_win {
+ struct resource res; /* In master (CPU) address space */
+ resource_size_t offset; /* Translation offset for bridge */
+};
+
+/*
+ * Common resource list management data structure and interfaces to support
+ * ACPI, PNP and PCI host bridge etc.
+ */
+struct resource_entry {
+ struct list_head node;
+ struct resource *res; /* In master (CPU) address space */
+ resource_size_t offset; /* Translation offset for bridge */
+ struct resource __res; /* Default storage for res */
+};
+
+extern struct resource_entry *
+resource_list_create_entry(struct resource *res, size_t extra_size);
+extern void resource_list_free(struct list_head *head);
+
+static inline void resource_list_add(struct resource_entry *entry,
+ struct list_head *head)
+{
+ list_add(&entry->node, head);
+}
+
+static inline void resource_list_add_tail(struct resource_entry *entry,
+ struct list_head *head)
+{
+ list_add_tail(&entry->node, head);
+}
+
+static inline void resource_list_del(struct resource_entry *entry)
+{
+ list_del(&entry->node);
+}
+
+static inline void resource_list_free_entry(struct resource_entry *entry)
+{
+ kfree(entry);
+}
+
+static inline void
+resource_list_destroy_entry(struct resource_entry *entry)
+{
+ resource_list_del(entry);
+ resource_list_free_entry(entry);
+}
+
+#define resource_list_for_each_entry(entry, list) \
+ list_for_each_entry((entry), (list), node)
+
+#define resource_list_for_each_entry_safe(entry, tmp, list) \
+ list_for_each_entry_safe((entry), (tmp), (list), node)
+
+static inline struct resource_entry *
+resource_list_first_type(struct list_head *list, unsigned long type)
+{
+ struct resource_entry *entry;
+
+ resource_list_for_each_entry(entry, list) {
+ if (resource_type(entry->res) == type)
+ return entry;
+ }
+ return NULL;
+}
+
+#endif /* _LINUX_RESOURCE_EXT_H */
diff --git a/include/of.h b/include/of.h
index 9eef6d7f13..f99cff5cf5 100644
--- a/include/of.h
+++ b/include/of.h
@@ -240,11 +240,22 @@ extern int of_property_read_u32_array(const struct device_node *np,
size_t sz);
extern int of_property_read_u64(const struct device_node *np,
const char *propname, u64 *out_value);
-
+extern int of_property_read_variable_u8_array(const struct device_node *np,
+ const char *propname, u8 *out_values,
+ size_t sz_min, size_t sz_max);
+extern int of_property_read_variable_u16_array(const struct device_node *np,
+ const char *propname, u16 *out_values,
+ size_t sz_min, size_t sz_max);
+extern int of_property_read_variable_u32_array(const struct device_node *np,
+ const char *propname,
+ u32 *out_values,
+ size_t sz_min,
+ size_t sz_max);
extern int of_property_read_variable_u64_array(const struct device_node *np,
const char *propname,
u64 *out_values,
- size_t sz);
+ size_t sz_min,
+ size_t sz_max);
extern int of_property_read_string(struct device_node *np,
const char *propname,
@@ -669,10 +680,34 @@ static inline int of_property_read_u64(const struct device_node *np,
return -ENOSYS;
}
+static inline int of_property_read_variable_u8_array(const struct device_node *np,
+ const char *propname, u8 *out_values,
+ size_t sz_min, size_t sz_max)
+{
+ return -ENOSYS;
+}
+
+static inline int of_property_read_variable_u16_array(const struct device_node *np,
+ const char *propname, u16 *out_values,
+ size_t sz_min, size_t sz_max)
+{
+ return -ENOSYS;
+}
+
+static inline int of_property_read_variable_u32_array(const struct device_node *np,
+ const char *propname,
+ u32 *out_values,
+ size_t sz_min,
+ size_t sz_max)
+{
+ return -ENOSYS;
+}
+
static inline int of_property_read_variable_u64_array(const struct device_node *np,
const char *propname,
u64 *out_values,
- size_t sz)
+ size_t sz_min,
+ size_t sz_max)
{
return -ENOSYS;
}
@@ -1166,7 +1201,7 @@ static inline int of_property_read_u64_array(const struct device_node *np,
u64 *out_values, size_t sz)
{
int ret = of_property_read_variable_u64_array(np, propname, out_values,
- sz);
+ sz, 0);
if (ret >= 0)
return 0;
else