1*d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 22f334a38SPaul Walmsley /* 32f334a38SPaul Walmsley * omap2-restart.c - code common to all OMAP2xxx machines. 42f334a38SPaul Walmsley * 52f334a38SPaul Walmsley * Copyright (C) 2012 Texas Instruments 62f334a38SPaul Walmsley * Paul Walmsley 72f334a38SPaul Walmsley */ 82f334a38SPaul Walmsley #include <linux/kernel.h> 92f334a38SPaul Walmsley #include <linux/init.h> 102f334a38SPaul Walmsley #include <linux/clk.h> 112f334a38SPaul Walmsley #include <linux/io.h> 122f334a38SPaul Walmsley 13b76c8b19STony Lindgren #include "soc.h" 142f334a38SPaul Walmsley #include "common.h" 1561c8621eSTero Kristo #include "prm.h" 162f334a38SPaul Walmsley 172f334a38SPaul Walmsley /* 182f334a38SPaul Walmsley * reset_virt_prcm_set_ck, reset_sys_ck: pointers to the virt_prcm_set 192f334a38SPaul Walmsley * clock and the sys_ck. Used during the reset process 202f334a38SPaul Walmsley */ 212f334a38SPaul Walmsley static struct clk *reset_virt_prcm_set_ck, *reset_sys_ck; 222f334a38SPaul Walmsley 232f334a38SPaul Walmsley /* Reboot handling */ 242f334a38SPaul Walmsley 252f334a38SPaul Walmsley /** 262f334a38SPaul Walmsley * omap2xxx_restart - Set DPLL to bypass mode for reboot to work 272f334a38SPaul Walmsley * 282f334a38SPaul Walmsley * Set the DPLL to bypass so that reboot completes successfully. No 292f334a38SPaul Walmsley * return value. 302f334a38SPaul Walmsley */ omap2xxx_restart(enum reboot_mode mode,const char * cmd)317b6d864bSRobin Holtvoid omap2xxx_restart(enum reboot_mode mode, const char *cmd) 322f334a38SPaul Walmsley { 332f334a38SPaul Walmsley u32 rate; 342f334a38SPaul Walmsley 352f334a38SPaul Walmsley rate = clk_get_rate(reset_sys_ck); 362f334a38SPaul Walmsley clk_set_rate(reset_virt_prcm_set_ck, rate); 372f334a38SPaul Walmsley 382f334a38SPaul Walmsley /* XXX Should save the cmd argument for use after the reboot */ 392f334a38SPaul Walmsley 4061c8621eSTero Kristo omap_prm_reset_system(); 412f334a38SPaul Walmsley } 422f334a38SPaul Walmsley 432f334a38SPaul Walmsley /** 442f334a38SPaul Walmsley * omap2xxx_common_look_up_clks_for_reset - look up clocks needed for restart 452f334a38SPaul Walmsley * 462f334a38SPaul Walmsley * Some clocks need to be looked up in advance for the SoC restart 472f334a38SPaul Walmsley * operation to work - see omap2xxx_restart(). Returns -EINVAL upon 482f334a38SPaul Walmsley * error or 0 upon success. 492f334a38SPaul Walmsley */ omap2xxx_common_look_up_clks_for_reset(void)502f334a38SPaul Walmsleystatic int __init omap2xxx_common_look_up_clks_for_reset(void) 512f334a38SPaul Walmsley { 522f334a38SPaul Walmsley reset_virt_prcm_set_ck = clk_get(NULL, "virt_prcm_set"); 532f334a38SPaul Walmsley if (IS_ERR(reset_virt_prcm_set_ck)) 542f334a38SPaul Walmsley return -EINVAL; 552f334a38SPaul Walmsley 562f334a38SPaul Walmsley reset_sys_ck = clk_get(NULL, "sys_ck"); 572f334a38SPaul Walmsley if (IS_ERR(reset_sys_ck)) 582f334a38SPaul Walmsley return -EINVAL; 592f334a38SPaul Walmsley 602f334a38SPaul Walmsley return 0; 612f334a38SPaul Walmsley } 628dd5ea72STony Lindgren omap_postcore_initcall(omap2xxx_common_look_up_clks_for_reset); 63