From patchwork Fri Nov 9 07:42:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 197979 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 714512C01FA for ; Fri, 9 Nov 2012 18:46:10 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B4D364AB59; Fri, 9 Nov 2012 08:45:30 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1YQ95qOunzOt; Fri, 9 Nov 2012 08:45:30 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 599514A9C2; Fri, 9 Nov 2012 08:44:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 96B7F4A8D4 for ; Fri, 9 Nov 2012 08:44:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pb6uWPJCGkjF for ; Fri, 9 Nov 2012 08:44:18 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by theia.denx.de (Postfix) with ESMTP id 18FF04A8D5 for ; Fri, 9 Nov 2012 08:43:36 +0100 (CET) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MD7007LXMR1F5K0@mailout4.samsung.com> for u-boot@lists.denx.de; Fri, 09 Nov 2012 16:43:35 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-c5-509cb4270373 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id AE.A0.01231.724BC905; Fri, 09 Nov 2012 16:43:35 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MD700H3CMQZYP10@mmp1.samsung.com> for u-boot@lists.denx.de; Fri, 09 Nov 2012 16:43:35 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Fri, 09 Nov 2012 08:42:24 +0100 Message-id: <1352446951-12558-20-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1352446951-12558-1-git-send-email-l.majewski@samsung.com> References: <1352446951-12558-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAV31LXMCDP5f07Z4u7eT3YHR4+yd HYwBjFFcNimpOZllqUX6dglcGTcP3GIveChZsX97K3sD43PhLkYODgkBE4nJvQJdjJxAppjE hXvr2boYuTiEBBYxSrw8/YsdwlnMJLHz7W5mkCo2AT2Jz3efMoHYIgISEr/6rzKCFDEL7GCU aD55lg0kISyQLjG34xULiM0ioCqxcMUeMJtXwF3i1HWQBpB18hJP7/eB1XMCxXdeXARmCwm4 SfTOf8w0gZF3ASPDKkbR1ILkguKk9FxDveLE3OLSvHS95PzcTYxgrz+T2sG4ssHiEKMAB6MS D2/ig9kBQqyJZcWVuYcYJTiYlUR452bOCRDiTUmsrEotyo8vKs1JLT7EKM3BoiTO2+yREiAk kJ5YkpqdmlqQWgSTZeLglGpgTHpsWv6YuUJAnFe4QkhS4nK3d8Hib+ymZzhso9gePhTbYehx yz+mxubQnJNzzO/sO6NatujJMz/xE1UZCveLJ3iwn6xaL/+mct/Ki69vN148GrPvBuvSy1fe TUzfFrD2JZPybY+64m/2kaxZDos9eU+sCA8NWr9HcCLPyvIo7eDsDUtXe6W8UGIpzkg01GIu Kk4EAGqQhnf2AQAA Cc: Tom Rini , Kyungmin Park Subject: [U-Boot] [PATCH v6 19/26] arm:trats:pmic: Power consumption reduction state for Samsung's TRATS board X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de When charging battery is necessary, the development board needs to be turned into low power mode for better efficiency. Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Cc: Minkyu Kang --- Changes for v2: - None Changes for v3: - None Changes for v4: - None Changes for v5: - None Changes for v6: - Explanation of a magic numbers (APLL, CLOCK) --- board/samsung/trats/trats.c | 58 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c index 5c23744..8683fd8 100644 --- a/board/samsung/trats/trats.c +++ b/board/samsung/trats/trats.c @@ -89,6 +89,64 @@ void i2c_init_board(void) s5p_gpio_direction_output(&gpio2->y4, 1, 1); } +static void trats_low_power_mode(void) +{ + struct exynos4_clock *clk = + (struct exynos4_clock *)samsung_get_base_clock(); + struct exynos4_power *pwr = + (struct exynos4_power *)samsung_get_base_power(); + + /* Power down CORE1 */ + /* LOCAL_PWR_CFG [1:0] 0x3 EN, 0x0 DIS */ + writel(0x0, &pwr->arm_core1_configuration); + + /* Change the APLL frequency */ + /* ENABLE (1 enable) | LOCKED (1 locked) */ + /* [31] | [29] */ + /* FSEL | MDIV | PDIV | SDIV */ + /* [27] | [25:16] | [13:8] | [2:0] */ + writel(0xa0c80604, &clk->apll_con0); + + /* Change CPU0 clock divider */ + /* CORE2_RATIO | APLL_RATIO | PCLK_DBG_RATIO | ATB_RATIO */ + /* [30:28] | [26:24] | [22:20] | [18:16] */ + /* PERIPH_RATIO | COREM1_RATIO | COREM0_RATIO | CORE_RATIO */ + /* [14:12] | [10:8] | [6:4] | [2:0] */ + writel(0x00000100, &clk->div_cpu0); + + /* CLK_DIV_STAT_CPU0 - wait until clock gets stable (0 = stable) */ + while (readl(&clk->div_stat_cpu0) & 0x1111111) + continue; + + /* Change clock divider ratio for DMC */ + /* DMCP_RATIO | DMCD_RATIO */ + /* [22:20] | [18:16] */ + /* DMC_RATIO | DPHY_RATIO | ACP_PCLK_RATIO | ACP_RATIO */ + /* [14:12] | [10:8] | [6:4] | [2:0] */ + writel(0x13113117, &clk->div_dmc0); + + /* CLK_DIV_STAT_DMC0 - wait until clock gets stable (0 = stable) */ + while (readl(&clk->div_stat_dmc0) & 0x11111111) + continue; + + /* Turn off unnecessary power domains */ + writel(0x0, &pwr->xxti_configuration); /* XXTI */ + writel(0x0, &pwr->cam_configuration); /* CAM */ + writel(0x0, &pwr->tv_configuration); /* TV */ + writel(0x0, &pwr->mfc_configuration); /* MFC */ + writel(0x0, &pwr->g3d_configuration); /* G3D */ + writel(0x0, &pwr->gps_configuration); /* GPS */ + writel(0x0, &pwr->gps_alive_configuration); /* GPS_ALIVE */ + + /* Turn off unnecessary clocks */ + writel(0x0, &clk->gate_ip_cam); /* CAM */ + writel(0x0, &clk->gate_ip_tv); /* TV */ + writel(0x0, &clk->gate_ip_mfc); /* MFC */ + writel(0x0, &clk->gate_ip_g3d); /* G3D */ + writel(0x0, &clk->gate_ip_image); /* IMAGE */ + writel(0x0, &clk->gate_ip_gps); /* GPS */ +} + static int pmic_init_max8997(void) { struct pmic *p = pmic_get("MAX8997_PMIC");