aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap_hwmod.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2011-02-23 02:14:07 -0500
committerPaul Walmsley <paul@pwsan.com>2011-02-28 15:55:08 -0500
commita2debdbd1ad896a410019c9cf30785cad15930fc (patch)
tree5740540fbecde6a9f3efe4accee6c0eb3c38c350 /arch/arm/mach-omap2/omap_hwmod.c
parent48d54f3fd20b435311f295b3bca3570096a2ac83 (diff)
OMAP2+: hwmod: add ability to setup individual hwmods
Add omap_hwmod_setup_one(), which is intended for use early in boot to selectively setup the hwmods needed for system clocksources and clockevents, and any other hwmod that is needed in early boot. omap_hwmod_setup_all() can then be called later in the boot process. The point is to minimize the amount of code that needs to be run early. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: BenoƮt Cousson <b-cousson@ti.com> Cc: Kevin Hilman <khilman@ti.com> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com> Cc: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c62
1 files changed, 55 insertions, 7 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 43aa894174fa..f76f133780c8 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -901,7 +901,7 @@ static struct omap_hwmod *_lookup(const char *name)
901 * @oh: struct omap_hwmod * 901 * @oh: struct omap_hwmod *
902 * @data: not used; pass NULL 902 * @data: not used; pass NULL
903 * 903 *
904 * Called by omap_hwmod_setup_all() (after omap2_clk_init()). 904 * Called by omap_hwmod_setup_*() (after omap2_clk_init()).
905 * Resolves all clock names embedded in the hwmod. Returns 0 on 905 * Resolves all clock names embedded in the hwmod. Returns 0 on
906 * success, or a negative error code on failure. 906 * success, or a negative error code on failure.
907 */ 907 */
@@ -1616,7 +1616,7 @@ int __init omap_hwmod_register(struct omap_hwmod **ohs)
1616/* 1616/*
1617 * _populate_mpu_rt_base - populate the virtual address for a hwmod 1617 * _populate_mpu_rt_base - populate the virtual address for a hwmod
1618 * 1618 *
1619 * Must be called only from omap_hwmod_setup_all() so ioremap works properly. 1619 * Must be called only from omap_hwmod_setup_*() so ioremap works properly.
1620 * Assumes the caller takes care of locking if needed. 1620 * Assumes the caller takes care of locking if needed.
1621 */ 1621 */
1622static int __init _populate_mpu_rt_base(struct omap_hwmod *oh, void *data) 1622static int __init _populate_mpu_rt_base(struct omap_hwmod *oh, void *data)
@@ -1636,11 +1636,59 @@ static int __init _populate_mpu_rt_base(struct omap_hwmod *oh, void *data)
1636} 1636}
1637 1637
1638/** 1638/**
1639 * omap_hwmod_setup_one - set up a single hwmod
1640 * @oh_name: const char * name of the already-registered hwmod to set up
1641 *
1642 * Must be called after omap2_clk_init(). Resolves the struct clk
1643 * names to struct clk pointers for each registered omap_hwmod. Also
1644 * calls _setup() on each hwmod. Returns -EINVAL upon error or 0 upon
1645 * success.
1646 */
1647int __init omap_hwmod_setup_one(const char *oh_name)
1648{
1649 struct omap_hwmod *oh;
1650 int r;
1651
1652 pr_debug("omap_hwmod: %s: %s\n", oh_name, __func__);
1653
1654 if (!mpu_oh) {
1655 pr_err("omap_hwmod: %s: cannot setup_one: MPU initiator hwmod %s not yet registered\n",
1656 oh_name, MPU_INITIATOR_NAME);
1657 return -EINVAL;
1658 }
1659
1660 oh = _lookup(oh_name);
1661 if (!oh) {
1662 WARN(1, "omap_hwmod: %s: hwmod not yet registered\n", oh_name);
1663 return -EINVAL;
1664 }
1665
1666 if (mpu_oh->_state == _HWMOD_STATE_REGISTERED && oh != mpu_oh)
1667 omap_hwmod_setup_one(MPU_INITIATOR_NAME);
1668
1669 r = _populate_mpu_rt_base(oh, NULL);
1670 if (IS_ERR_VALUE(r)) {
1671 WARN(1, "omap_hwmod: %s: couldn't set mpu_rt_base\n", oh_name);
1672 return -EINVAL;
1673 }
1674
1675 r = _init_clocks(oh, NULL);
1676 if (IS_ERR_VALUE(r)) {
1677 WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh_name);
1678 return -EINVAL;
1679 }
1680
1681 _setup(oh, NULL);
1682
1683 return 0;
1684}
1685
1686/**
1639 * omap_hwmod_setup - do some post-clock framework initialization 1687 * omap_hwmod_setup - do some post-clock framework initialization
1640 * 1688 *
1641 * Must be called after omap2_clk_init(). Resolves the struct clk names 1689 * Must be called after omap2_clk_init(). Resolves the struct clk names
1642 * to struct clk pointers for each registered omap_hwmod. Also calls 1690 * to struct clk pointers for each registered omap_hwmod. Also calls
1643 * _setup() on each hwmod. Returns 0 upon success or -EINVAL upon error. 1691 * _setup() on each hwmod. Returns 0 upon success.
1644 */ 1692 */
1645static int __init omap_hwmod_setup_all(void) 1693static int __init omap_hwmod_setup_all(void)
1646{ 1694{
@@ -1654,9 +1702,9 @@ static int __init omap_hwmod_setup_all(void)
1654 1702
1655 r = omap_hwmod_for_each(_populate_mpu_rt_base, NULL); 1703 r = omap_hwmod_for_each(_populate_mpu_rt_base, NULL);
1656 1704
1657 /* XXX check return value */
1658 r = omap_hwmod_for_each(_init_clocks, NULL); 1705 r = omap_hwmod_for_each(_init_clocks, NULL);
1659 WARN(r, "omap_hwmod: %s: _init_clocks failed\n", __func__); 1706 WARN(IS_ERR_VALUE(r),
1707 "omap_hwmod: %s: _init_clocks failed\n", __func__);
1660 1708
1661 omap_hwmod_for_each(_setup, NULL); 1709 omap_hwmod_for_each(_setup, NULL);
1662 1710
@@ -2182,8 +2230,8 @@ int omap_hwmod_for_each_by_class(const char *classname,
2182 * @state: state that _setup() should leave the hwmod in 2230 * @state: state that _setup() should leave the hwmod in
2183 * 2231 *
2184 * Sets the hwmod state that @oh will enter at the end of _setup() 2232 * Sets the hwmod state that @oh will enter at the end of _setup()
2185 * (called by omap_hwmod_setup_all()). Only valid to call between 2233 * (called by omap_hwmod_setup_*()). Only valid to call between
2186 * calling omap_hwmod_register() and omap_hwmod_setup_all(). Returns 2234 * calling omap_hwmod_register() and omap_hwmod_setup_*(). Returns
2187 * 0 upon success or -EINVAL if there is a problem with the arguments 2235 * 0 upon success or -EINVAL if there is a problem with the arguments
2188 * or if the hwmod is in the wrong state. 2236 * or if the hwmod is in the wrong state.
2189 */ 2237 */