Skip to contentSkip to conversation

rapidio: add memory mapping driver to RapidIO

PATCH In review [email protected] 1 participant 1 message Mar 28, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 17/24 rapidio: add memory mapping driver to RapidIO

From: Zhang Wei <[email protected]>

The memory mapping driver is used for mapping IO address and system memory address space to RapidIO address space. The driver support IO space allocation, RapidIO space inbound window and outbound window creation. The system can access other RapidIO device by outbound window and can be accessed by other RapidIO device through inbound window.

---

 arch/powerpc/sysdev/fsl_rio.c |    4 
 drivers/rapidio/rio.c         |  362 ++++++++++++++++++++++++++++++++
 include/linux/rio.h           |   39 +++
 include/linux/rio_drv.h       |   41 +++
 4 files changed, 440 insertions(+), 6 deletions(-)
arch/powerpc/sysdev/fsl_rio.c renamed from arch/powerpc/sysdev/fsl_rio.c~rapidio-add-memory-mapping-driver-to-rapidio +3 -1
diff -puN arch/powerpc/sysdev/fsl_rio.c~rapidio-add-memory-mapping-driver-to-rapidio arch/powerpc/sysdev/fsl_rio.c
@@ -1058,6 +1058,7 @@ int fsl_rio_setup(struct of_device *dev)
 	port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
 	port->id = 0;
 	port->index = 0;
+	port->dev = &dev->dev;
 
 	priv = kzalloc(sizeof(struct rio_priv), GFP_KERNEL);
 	if (!priv) {
@@ -1068,8 +1069,9 @@ int fsl_rio_setup(struct of_device *dev)
 
 	INIT_LIST_HEAD(&port->dbells);
 	port->iores.start = law_start;
-	port->iores.end = law_start + law_size;
+	port->iores.end = law_start + law_size - 1;
 	port->iores.flags = IORESOURCE_MEM;
+	port->iores.name = "rio_io_win";
 
 	priv->bellirq = irq_of_parse_and_map(dev->node, 2);
 	priv->txirq = irq_of_parse_and_map(dev->node, 3);
drivers/rapidio/rio.c renamed from drivers/rapidio/rio.c~rapidio-add-memory-mapping-driver-to-rapidio +362 -0

387 lines not on this page · raw message

include/linux/rio.h renamed from include/linux/rio.h~rapidio-add-memory-mapping-driver-to-rapidio +39 -0
diff -puN include/linux/rio.h~rapidio-add-memory-mapping-driver-to-rapidio include/linux/rio.h
@@ -176,6 +176,7 @@ struct rio_mport {
 	struct rio_msg outb_msg[RIO_MAX_MBOX];
 	int host_deviceid;	/* Host device ID */
 	struct rio_ops *ops;	/* maintenance transaction functions */
+	struct rio_mem_ops *mops; /* Memory functions */
 	unsigned char id;	/* port ID, unique among all ports */
 	unsigned char index;	/* port index, unique among all port
 				   interfaces of the same type */
@@ -185,6 +186,7 @@ struct rio_mport {
 				 */
 	enum rio_phy_type phy_type;	/* RapidIO phy type */
 	unsigned char name[40];
+	struct device *dev;
 	void *priv;		/* Master port private data */
 };
 
@@ -319,6 +321,43 @@ struct rio_route_ops {
 			 u16 table, u16 route_destid, u8 * route_port);
 };
 
+/**
+ * Struct for RIO memory definition.
+ * @node: Node in list of memories
+ * @virt: The virtual address for mapped memory accessing.
+ * @owner: The owner id of this memory.
+ * @size: The size of memory space, it should same to iores and riores.
+ * @iores: The resource of local IO region for mapping.
+ * @riores: The resource of mapped RapidIO space region.
+ */
+struct rio_mem {
+	struct list_head node;
+	void *virt;
+	u32 owner;
+	struct rio_dev *dev;
+	resource_size_t size;
+	struct resource iores;
+	struct resource riores;
+};
+
+/**
+ * Struct for RIO memory definition.
+ * @map_inb: The function for mapping inbound memory window.
+ * @map_outb: The function for mapping outbound memory window.
+ * @unmap_inb: The function for unmapping inbound memory window.
+ * @unmap_outb: The function for unmapping outbound memory window.
+ */
+struct rio_mem_ops {
+	int (*map_inb) (struct rio_mport *, resource_size_t lstart,
+			resource_size_t rstart,
+			resource_size_t size, u32 flags);
+	int (*map_outb) (struct rio_mport *, resource_size_t lstart,
+			resource_size_t rstart,
+			resource_size_t size, u16 tid, u32 flags);
+	void (*unmap_inb) (struct rio_mport *, resource_size_t lstart);
+	void (*unmap_outb) (struct rio_mport *, resource_size_t lstart);
+};
+
 /* Architecture and hardware-specific functions */
 extern int rio_init_mports(void);
 extern void rio_register_mport(struct rio_mport *);
include/linux/rio_drv.h renamed from include/linux/rio_drv.h~rapidio-add-memory-mapping-driver-to-rapidio +36 -5

61 lines not on this page · raw message

_