Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * omap2-restart.c - code common to all OMAP2xxx machines.
0004  *
0005  * Copyright (C) 2012 Texas Instruments
0006  * Paul Walmsley
0007  */
0008 #include <linux/kernel.h>
0009 #include <linux/init.h>
0010 #include <linux/clk.h>
0011 #include <linux/io.h>
0012 
0013 #include "soc.h"
0014 #include "common.h"
0015 #include "prm.h"
0016 
0017 /*
0018  * reset_virt_prcm_set_ck, reset_sys_ck: pointers to the virt_prcm_set
0019  * clock and the sys_ck.  Used during the reset process
0020  */
0021 static struct clk *reset_virt_prcm_set_ck, *reset_sys_ck;
0022 
0023 /* Reboot handling */
0024 
0025 /**
0026  * omap2xxx_restart - Set DPLL to bypass mode for reboot to work
0027  *
0028  * Set the DPLL to bypass so that reboot completes successfully.  No
0029  * return value.
0030  */
0031 void omap2xxx_restart(enum reboot_mode mode, const char *cmd)
0032 {
0033     u32 rate;
0034 
0035     rate = clk_get_rate(reset_sys_ck);
0036     clk_set_rate(reset_virt_prcm_set_ck, rate);
0037 
0038     /* XXX Should save the cmd argument for use after the reboot */
0039 
0040     omap_prm_reset_system();
0041 }
0042 
0043 /**
0044  * omap2xxx_common_look_up_clks_for_reset - look up clocks needed for restart
0045  *
0046  * Some clocks need to be looked up in advance for the SoC restart
0047  * operation to work - see omap2xxx_restart().  Returns -EINVAL upon
0048  * error or 0 upon success.
0049  */
0050 static int __init omap2xxx_common_look_up_clks_for_reset(void)
0051 {
0052     reset_virt_prcm_set_ck = clk_get(NULL, "virt_prcm_set");
0053     if (IS_ERR(reset_virt_prcm_set_ck))
0054         return -EINVAL;
0055 
0056     reset_sys_ck = clk_get(NULL, "sys_ck");
0057     if (IS_ERR(reset_sys_ck))
0058         return -EINVAL;
0059 
0060     return 0;
0061 }
0062 omap_postcore_initcall(omap2xxx_common_look_up_clks_for_reset);