[PATCH 07/17] Staging: ipack: Provide physical memory regions to IPack devices.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jens Taprogge <jens.taprogge@xxxxxxxxxxxx>

This will allow us to use the regular ioremop functions.

Signed-off-by: Jens Taprogge <jens.taprogge@xxxxxxxxxxxx>
Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@xxxxxxxxxx>
---
 drivers/staging/ipack/bridges/tpci200.c |   22 ++++++++++++++++++++++
 drivers/staging/ipack/ipack.h           |    6 ++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
index 84e1c27..8428e3b 100644
--- a/drivers/staging/ipack/bridges/tpci200.c
+++ b/drivers/staging/ipack/bridges/tpci200.c
@@ -28,6 +28,20 @@ static const u16 tpci200_status_error[] = {
 	TPCI200_D_ERROR,
 };
 
+static const size_t tpci200_space_size[IPACK_SPACE_COUNT] = {
+	[IPACK_IO_SPACE]  = TPCI200_IO_SPACE_SIZE,
+	[IPACK_ID_SPACE]  = TPCI200_ID_SPACE_SIZE,
+	[IPACK_INT_SPACE] = TPCI200_INT_SPACE_SIZE,
+	[IPACK_MEM_SPACE] = TPCI200_MEM8_SPACE_SIZE,
+};
+
+static const size_t tpci200_space_interval[IPACK_SPACE_COUNT] = {
+	[IPACK_IO_SPACE]  = TPCI200_IO_SPACE_INTERVAL,
+	[IPACK_ID_SPACE]  = TPCI200_ID_SPACE_INTERVAL,
+	[IPACK_INT_SPACE] = TPCI200_INT_SPACE_INTERVAL,
+	[IPACK_MEM_SPACE] = TPCI200_MEM8_SPACE_INTERVAL,
+};
+
 static struct tpci200_board *check_slot(struct ipack_device *dev)
 {
 	struct tpci200_board *tpci200;
@@ -642,6 +656,7 @@ static void tpci200_release_device(struct ipack_device *dev)
 
 static int tpci200_create_device(struct tpci200_board *tpci200, int i)
 {
+	enum ipack_space space;
 	struct ipack_device *dev =
 		kzalloc(sizeof(struct ipack_device), GFP_KERNEL);
 	if (!dev)
@@ -649,6 +664,13 @@ static int tpci200_create_device(struct tpci200_board *tpci200, int i)
 	dev->slot = i;
 	dev->bus = tpci200->info->ipack_bus;
 	dev->release = tpci200_release_device;
+
+	for (space = 0; space < IPACK_SPACE_COUNT; space++) {
+		dev->region[space].start =
+			tpci200->mod_mem[space]
+			+ tpci200_space_interval[space] * i;
+		dev->region[space].size = tpci200_space_size[space];
+	}
 	return ipack_device_register(dev);
 }
 
diff --git a/drivers/staging/ipack/ipack.h b/drivers/staging/ipack/ipack.h
index a842eea..43d152a 100644
--- a/drivers/staging/ipack/ipack.h
+++ b/drivers/staging/ipack/ipack.h
@@ -82,6 +82,7 @@ struct ipack_device {
 	struct ipack_addr_space mem_space;
 	struct device dev;
 	void (*release) (struct ipack_device *dev);
+	struct ipack_region      region[IPACK_SPACE_COUNT];
 	u8                      *id;
 	size_t			 id_avail;
 	u32			 id_vendor;
@@ -195,8 +196,9 @@ void ipack_driver_unregister(struct ipack_driver *edrv);
  *
  *	Register a new IPack device ("module" in IndustryPack jargon). The call
  *	is done by the carrier driver.  The carrier should populate the fields
- *	bus and slot of @dev prior to calling this function.  The rest of the
- *	fields will be allocated and populated during registration.
+ *	bus and slot as well as the region array of @dev prior to calling this
+ *	function.  The rest of the fields will be allocated and populated
+ *	during registration.
  *
  *	Return zero on success or error code on failure.
  */
-- 
1.7.10.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux