diff mbox

[RFC,3/3] OMAP3: omap_device: Add support to associate a device with an initiator

Message ID 1300705823-12784-4-git-send-email-rnayak@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rajendra Nayak March 21, 2011, 11:10 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index 9bbda9a..0cd05d2 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -662,6 +662,60 @@  int omap_device_shutdown(struct platform_device *pdev)
 	return ret;
 }
 
+static int omap_device_add_initiator_user(struct platform_device *pdev,
+					  u8 init_id)
+{
+	int i;
+	struct omap_device *od;
+
+	od = _find_by_pdev(pdev);
+
+	if (od->_state != OMAP_DEVICE_STATE_ENABLED)
+		return -EINVAL;
+
+	for (i = 0; i < od->hwmods_cnt; i++)
+		omap_hwmod_add_initiator_user(od->hwmods[i], init_id);
+
+	return 0;
+}
+
+inline int omap_device_add_mpu_user(struct platform_device *pdev)
+{
+	return omap_device_add_initiator_user(pdev, OMAP_INIT_MPU);
+}
+
+inline int omap_device_add_iva_user(struct platform_device *pdev)
+{
+	return omap_device_add_initiator_user(pdev, OMAP_INIT_IVA);
+}
+
+static int omap_device_del_initiator_user(struct platform_device *pdev,
+					  u8 init_id)
+{
+	int i;
+	struct omap_device *od;
+
+	od = _find_by_pdev(pdev);
+
+	if (od->_state == OMAP_DEVICE_STATE_ENABLED)
+		return -EINVAL;
+
+	for (i = 0; i < od->hwmods_cnt; i++)
+		omap_hwmod_del_initiator_user(od->hwmods[i], init_id);
+
+	return 0;
+}
+
+inline int omap_device_del_mpu_user(struct platform_device *pdev)
+{
+	return omap_device_del_initiator_user(pdev, OMAP_INIT_MPU);
+}
+
+inline int omap_device_del_iva_user(struct platform_device *pdev)
+{
+	return omap_device_del_initiator_user(pdev, OMAP_INIT_IVA);
+}
+
 /**
  * omap_device_align_pm_lat - activate/deactivate device to match wakeup lat lim
  * @od: struct omap_device *