From: Kishon Vijay Abraham I <kishon@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 08/21] ARM: OMAP5: Add support for disabling clocks in uboot
Date: Thu, 6 Aug 2015 21:45:58 +0530 [thread overview]
Message-ID: <1438877771-23513-9-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1438877771-23513-1-git-send-email-kishon@ti.com>
Add do_disable_clocks() to disable clock domains and module clocks.
These clocks are enabled using do_enable_clocks().
Cc: Roger Quadros <rogerq@ti.com>
Cc: Tero Kristo <t-kristo@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
arch/arm/cpu/armv7/omap-common/clocks-common.c | 53 ++++++++++++++++++++++++
arch/arm/include/asm/omap_common.h | 4 ++
2 files changed, 57 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/clocks-common.c b/arch/arm/cpu/armv7/omap-common/clocks-common.c
index c94a807..e28b795 100644
--- a/arch/arm/cpu/armv7/omap-common/clocks-common.c
+++ b/arch/arm/cpu/armv7/omap-common/clocks-common.c
@@ -648,6 +648,14 @@ static inline void enable_clock_domain(u32 const clkctrl_reg, u32 enable_mode)
debug("Enable clock domain - %x\n", clkctrl_reg);
}
+static inline void disable_clock_domain(u32 const clkctrl_reg)
+{
+ clrsetbits_le32(clkctrl_reg, CD_CLKCTRL_CLKTRCTRL_MASK,
+ CD_CLKCTRL_CLKTRCTRL_SW_SLEEP <<
+ CD_CLKCTRL_CLKTRCTRL_SHIFT);
+ debug("Disable clock domain - %x\n", clkctrl_reg);
+}
+
static inline void wait_for_clk_enable(u32 clkctrl_addr)
{
u32 clkctrl, idlest = MODULE_CLKCTRL_IDLEST_DISABLED;
@@ -677,6 +685,34 @@ static inline void enable_clock_module(u32 const clkctrl_addr, u32 enable_mode,
wait_for_clk_enable(clkctrl_addr);
}
+static inline void wait_for_clk_disable(u32 clkctrl_addr)
+{
+ u32 clkctrl, idlest = MODULE_CLKCTRL_IDLEST_FULLY_FUNCTIONAL;
+ u32 bound = LDELAY;
+
+ while ((idlest != MODULE_CLKCTRL_IDLEST_DISABLED)) {
+ clkctrl = readl(clkctrl_addr);
+ idlest = (clkctrl & MODULE_CLKCTRL_IDLEST_MASK) >>
+ MODULE_CLKCTRL_IDLEST_SHIFT;
+ if (--bound == 0) {
+ printf("Clock disable failed for 0x%x idlest 0x%x\n",
+ clkctrl_addr, clkctrl);
+ return;
+ }
+ }
+}
+
+static inline void disable_clock_module(u32 const clkctrl_addr,
+ u32 wait_for_disable)
+{
+ clrsetbits_le32(clkctrl_addr, MODULE_CLKCTRL_MODULEMODE_MASK,
+ MODULE_CLKCTRL_MODULEMODE_SW_DISABLE <<
+ MODULE_CLKCTRL_MODULEMODE_SHIFT);
+ debug("Disable clock module - %x\n", clkctrl_addr);
+ if (wait_for_disable)
+ wait_for_clk_disable(clkctrl_addr);
+}
+
void freq_update_core(void)
{
u32 freq_config1 = 0;
@@ -800,6 +836,23 @@ void do_enable_clocks(u32 const *clk_domains,
}
}
+void do_disable_clocks(u32 const *clk_domains,
+ u32 const *clk_modules_disable,
+ u8 wait_for_disable)
+{
+ u32 i, max = 100;
+
+
+ /* Clock modules that need to be put in SW_DISABLE */
+ for (i = 0; (i < max) && clk_modules_disable[i]; i++)
+ disable_clock_module(clk_modules_disable[i],
+ wait_for_disable);
+
+ /* Put the clock domains in SW_SLEEP mode */
+ for (i = 0; (i < max) && clk_domains[i]; i++)
+ disable_clock_domain(clk_domains[i]);
+}
+
void prcm_init(void)
{
switch (omap_hw_init_context()) {
diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
index 462a9ee..224fbf0 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -577,6 +577,10 @@ void do_enable_clocks(u32 const *clk_domains,
u32 const *clk_modules_explicit_en,
u8 wait_for_enable);
+void do_disable_clocks(u32 const *clk_domains,
+ u32 const *clk_modules_disable,
+ u8 wait_for_disable);
+
void setup_post_dividers(u32 const base,
const struct dpll_params *params);
u32 omap_ddr_clk(void);
--
1.7.9.5
next prev parent reply other threads:[~2015-08-06 16:15 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-06 16:15 [U-Boot] [PATCH 00/21] beagle_x15/omap5: Add dwc3 peripheral support Kishon Vijay Abraham I
2015-08-06 16:15 ` [U-Boot] [PATCH 01/21] usb: dwc3: dwc3-omap: Use the clear register inorder to clear the interrupts Kishon Vijay Abraham I
2015-08-06 22:25 ` Marek Vasut
2015-08-06 16:15 ` [U-Boot] [PATCH 02/21] usb: gadget: ether: Perform board initialization from ethernet gadget driver Kishon Vijay Abraham I
2015-08-06 22:26 ` Marek Vasut
2015-08-06 16:15 ` [U-Boot] [PATCH 03/21] ARM: DRA7: Enable clocks for USB OTGSS2 and USB PHY2 Kishon Vijay Abraham I
2015-08-06 16:15 ` [U-Boot] [PATCH 04/21] TI PHY: Add support to control 2nd USB PHY in DRA7xx/AM57xx Kishon Vijay Abraham I
2015-08-06 22:26 ` Marek Vasut
2015-08-06 16:15 ` [U-Boot] [PATCH 05/21] board: ti: beagle_x15: added USB initializtion code Kishon Vijay Abraham I
2015-08-06 16:15 ` [U-Boot] [PATCH 06/21] board: ti: OMAP5: " Kishon Vijay Abraham I
2015-08-06 16:15 ` [U-Boot] [PATCH 07/21] include: configs: Enable DWC3 and DFU in ti_omap5_common Kishon Vijay Abraham I
2015-08-06 16:15 ` Kishon Vijay Abraham I [this message]
2015-08-06 16:15 ` [U-Boot] [PATCH 09/21] ARM: OMAP5: Add functions to enable and disable USB clocks Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 10/21] ARM: AM43xx: Add support for disabling clocks in uboot Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 11/21] ARM: AM43xx: Add functions to enable and disable USB clocks Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 12/21] board: ti: invoke clock API to enable and disable clocks Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 13/21] ARM: OMAP5/AM43xx: remove enabling USB clocks from enable_basic_clocks() Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 14/21] board: ti: remove duplicate initialization of vbus_id_status Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 15/21] usb: host: xhci-omap: invoke board_usb_cleanup in xhci_hcd_stop Kishon Vijay Abraham I
2015-08-06 22:28 ` Marek Vasut
2015-08-10 6:00 ` Kishon Vijay Abraham I
2015-08-10 12:13 ` Marek Vasut
2015-08-06 16:16 ` [U-Boot] [PATCH 16/21] include: configs: am43xx_evm: add 'usb stop' in usbboot env Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 17/21] am43xx: Add USB device boot support to SPL Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 18/21] usb: gadget: ether: populate _reset_ callback Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 19/21] spl: Fix USB boot device values for am43xx Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 20/21] spl: Add USB peripheral boot device value " Kishon Vijay Abraham I
2015-08-06 16:16 ` [U-Boot] [PATCH 21/21] configs: am43xx: Add am43xx_evm_usbspl_defconfig Kishon Vijay Abraham I
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438877771-23513-9-git-send-email-kishon@ti.com \
--to=kishon@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox