aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2010-07-26 18:34:33 -0400
committerPaul Walmsley <paul@pwsan.com>2010-07-26 18:34:33 -0400
commitdb2a60bf2527209b42e6f512d5892089a835ceaa (patch)
tree98436f3f27ada90324110c6fd3e3256162ec7b34
parent08072acf3a23febd1b676f1d908c6c0b9ddf167c (diff)
OMAP: hwmod/device: add omap_{device,hwmod}_get_mpu_rt_va
Add omap_device_get_mpu_rt_va(). This is intended to be used by device drivers (currently, via a struct platform_data function pointer) to retrieve their corresponding device's virtual base address that the MPU should use to access the device. This is needed because the omap_hwmod code does its own ioremap(), in order to gain access to the module's OCP_SYSCONFIG register. Add omap_hwmod_get_mpu_rt_va(). omap_device_get_mpu_rt_va() calls this function to do the real work. While here, rename struct omap_hwmod._rt_va to struct omap_hwmod._mpu_rt_va, to reinforce that it refers to the MPU's register target virtual address base (as opposed to, for example, the L3's). In the future, this belongs as a function in an omap_bus, so it is not necessary to call this through a platform_data function pointer. The use-case for this function was originally presented by Santosh Shilimkar <santosh.shilimkar@ti.com>. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c33
-rw-r--r--arch/arm/plat-omap/include/plat/omap_device.h2
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h7
-rw-r--r--arch/arm/plat-omap/omap_device.c19
4 files changed, 53 insertions, 8 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index b2c8e8760c80..ec0be6d32232 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * omap_hwmod implementation for OMAP2/3/4 2 * omap_hwmod implementation for OMAP2/3/4
3 * 3 *
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2009-2010 Nokia Corporation
5 * 5 *
6 * Paul Walmsley, Benoît Cousson, Kevin Hilman 6 * Paul Walmsley, Benoît Cousson, Kevin Hilman
7 * 7 *
@@ -1069,12 +1069,12 @@ static int _setup(struct omap_hwmod *oh, void *data)
1069 1069
1070u32 omap_hwmod_readl(struct omap_hwmod *oh, u16 reg_offs) 1070u32 omap_hwmod_readl(struct omap_hwmod *oh, u16 reg_offs)
1071{ 1071{
1072 return __raw_readl(oh->_rt_va + reg_offs); 1072 return __raw_readl(oh->_mpu_rt_va + reg_offs);
1073} 1073}
1074 1074
1075void omap_hwmod_writel(u32 v, struct omap_hwmod *oh, u16 reg_offs) 1075void omap_hwmod_writel(u32 v, struct omap_hwmod *oh, u16 reg_offs)
1076{ 1076{
1077 __raw_writel(v, oh->_rt_va + reg_offs); 1077 __raw_writel(v, oh->_mpu_rt_va + reg_offs);
1078} 1078}
1079 1079
1080int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) 1080int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode)
@@ -1131,7 +1131,7 @@ int omap_hwmod_register(struct omap_hwmod *oh)
1131 ms_id = _find_mpu_port_index(oh); 1131 ms_id = _find_mpu_port_index(oh);
1132 if (!IS_ERR_VALUE(ms_id)) { 1132 if (!IS_ERR_VALUE(ms_id)) {
1133 oh->_mpu_port_index = ms_id; 1133 oh->_mpu_port_index = ms_id;
1134 oh->_rt_va = _find_mpu_rt_base(oh, oh->_mpu_port_index); 1134 oh->_mpu_rt_va = _find_mpu_rt_base(oh, oh->_mpu_port_index);
1135 } else { 1135 } else {
1136 oh->_int_flags |= _HWMOD_NO_MPU_PORT; 1136 oh->_int_flags |= _HWMOD_NO_MPU_PORT;
1137 } 1137 }
@@ -1283,7 +1283,7 @@ int omap_hwmod_unregister(struct omap_hwmod *oh)
1283 pr_debug("omap_hwmod: %s: unregistering\n", oh->name); 1283 pr_debug("omap_hwmod: %s: unregistering\n", oh->name);
1284 1284
1285 mutex_lock(&omap_hwmod_mutex); 1285 mutex_lock(&omap_hwmod_mutex);
1286 iounmap(oh->_rt_va); 1286 iounmap(oh->_mpu_rt_va);
1287 list_del(&oh->node); 1287 list_del(&oh->node);
1288 mutex_unlock(&omap_hwmod_mutex); 1288 mutex_unlock(&omap_hwmod_mutex);
1289 1289
@@ -1544,6 +1544,29 @@ struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh)
1544} 1544}
1545 1545
1546/** 1546/**
1547 * omap_hwmod_get_mpu_rt_va - return the module's base address (for the MPU)
1548 * @oh: struct omap_hwmod *
1549 *
1550 * Returns the virtual address corresponding to the beginning of the
1551 * module's register target, in the address range that is intended to
1552 * be used by the MPU. Returns the virtual address upon success or NULL
1553 * upon error.
1554 */
1555void __iomem *omap_hwmod_get_mpu_rt_va(struct omap_hwmod *oh)
1556{
1557 if (!oh)
1558 return NULL;
1559
1560 if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
1561 return NULL;
1562
1563 if (oh->_state == _HWMOD_STATE_UNKNOWN)
1564 return NULL;
1565
1566 return oh->_mpu_rt_va;
1567}
1568
1569/**
1547 * omap_hwmod_add_initiator_dep - add sleepdep from @init_oh to @oh 1570 * omap_hwmod_add_initiator_dep - add sleepdep from @init_oh to @oh
1548 * @oh: struct omap_hwmod * 1571 * @oh: struct omap_hwmod *
1549 * @init_oh: struct omap_hwmod * (initiator) 1572 * @init_oh: struct omap_hwmod * (initiator)
diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
index 3694b622c4ac..25cd9ac3b095 100644
--- a/arch/arm/plat-omap/include/plat/omap_device.h
+++ b/arch/arm/plat-omap/include/plat/omap_device.h
@@ -101,6 +101,8 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
101int omap_device_register(struct omap_device *od); 101int omap_device_register(struct omap_device *od);
102int omap_early_device_register(struct omap_device *od); 102int omap_early_device_register(struct omap_device *od);
103 103
104void __iomem *omap_device_get_rt_va(struct omap_device *od);
105
104/* OMAP PM interface */ 106/* OMAP PM interface */
105int omap_device_align_pm_lat(struct platform_device *pdev, 107int omap_device_align_pm_lat(struct platform_device *pdev,
106 u32 new_wakeup_lat_limit); 108 u32 new_wakeup_lat_limit);
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index aebfacb3106e..a4e508dfaba2 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * omap_hwmod macros, structures 2 * omap_hwmod macros, structures
3 * 3 *
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2009-2010 Nokia Corporation
5 * Paul Walmsley 5 * Paul Walmsley
6 * 6 *
7 * Created in collaboration with (alphabetical order): Benoît Cousson, 7 * Created in collaboration with (alphabetical order): Benoît Cousson,
@@ -419,7 +419,7 @@ struct omap_hwmod_class {
419 * @slaves: ptr to array of OCP ifs that this hwmod can respond on 419 * @slaves: ptr to array of OCP ifs that this hwmod can respond on
420 * @dev_attr: arbitrary device attributes that can be passed to the driver 420 * @dev_attr: arbitrary device attributes that can be passed to the driver
421 * @_sysc_cache: internal-use hwmod flags 421 * @_sysc_cache: internal-use hwmod flags
422 * @_rt_va: cached register target start address (internal use) 422 * @_mpu_rt_va: cached register target start address (internal use)
423 * @_mpu_port_index: cached MPU register target slave ID (internal use) 423 * @_mpu_port_index: cached MPU register target slave ID (internal use)
424 * @msuspendmux_reg_id: CONTROL_MSUSPENDMUX register ID (1-6) 424 * @msuspendmux_reg_id: CONTROL_MSUSPENDMUX register ID (1-6)
425 * @msuspendmux_shift: CONTROL_MSUSPENDMUX register bit shift 425 * @msuspendmux_shift: CONTROL_MSUSPENDMUX register bit shift
@@ -460,7 +460,7 @@ struct omap_hwmod {
460 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */ 460 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */
461 void *dev_attr; 461 void *dev_attr;
462 u32 _sysc_cache; 462 u32 _sysc_cache;
463 void __iomem *_rt_va; 463 void __iomem *_mpu_rt_va;
464 struct list_head node; 464 struct list_head node;
465 u16 flags; 465 u16 flags;
466 u8 _mpu_port_index; 466 u8 _mpu_port_index;
@@ -507,6 +507,7 @@ int omap_hwmod_count_resources(struct omap_hwmod *oh);
507int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res); 507int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res);
508 508
509struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh); 509struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh);
510void __iomem *omap_hwmod_get_mpu_rt_va(struct omap_hwmod *oh);
510 511
511int omap_hwmod_add_initiator_dep(struct omap_hwmod *oh, 512int omap_hwmod_add_initiator_dep(struct omap_hwmod *oh,
512 struct omap_hwmod *init_oh); 513 struct omap_hwmod *init_oh);
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index f9dec0d32fa4..dee4629b7b47 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -655,6 +655,25 @@ struct powerdomain *omap_device_get_pwrdm(struct omap_device *od)
655 return omap_hwmod_get_pwrdm(od->hwmods[0]); 655 return omap_hwmod_get_pwrdm(od->hwmods[0]);
656} 656}
657 657
658/**
659 * omap_device_get_mpu_rt_va - return the MPU's virtual addr for the hwmod base
660 * @od: struct omap_device *
661 *
662 * Return the MPU's virtual address for the base of the hwmod, from
663 * the ioremap() that the hwmod code does. Only valid if there is one
664 * hwmod associated with this device. Returns NULL if there are zero
665 * or more than one hwmods associated with this omap_device;
666 * otherwise, passes along the return value from
667 * omap_hwmod_get_mpu_rt_va().
668 */
669void __iomem *omap_device_get_rt_va(struct omap_device *od)
670{
671 if (od->hwmods_cnt != 1)
672 return NULL;
673
674 return omap_hwmod_get_mpu_rt_va(od->hwmods[0]);
675}
676
658/* 677/*
659 * Public functions intended for use in omap_device_pm_latency 678 * Public functions intended for use in omap_device_pm_latency
660 * .activate_func and .deactivate_func function pointers 679 * .activate_func and .deactivate_func function pointers