1 // SPDX-License-Identifier: GPL-2.0-only 1 2 /* 3 * OMAP2xxx PRM module functions 4 * 5 * Copyright (C) 2010-2012 Texas Instruments, 6 * Copyright (C) 2010 Nokia Corporation 7 * BenoƮt Cousson 8 * Paul Walmsley 9 * Rajendra Nayak <rnayak@ti.com> 10 */ 11 12 #include <linux/kernel.h> 13 #include <linux/errno.h> 14 #include <linux/err.h> 15 #include <linux/io.h> 16 #include <linux/irq.h> 17 18 #include "powerdomain.h" 19 #include "clockdomain.h" 20 #include "prm2xxx.h" 21 #include "cm2xxx_3xxx.h" 22 #include "prm-regbits-24xx.h" 23 24 /* 25 * OMAP24xx PM_PWSTCTRL_*.POWERSTATE and PM_PW 26 * these are reversed from the bits used on OM 27 */ 28 #define OMAP24XX_PWRDM_POWER_ON 29 #define OMAP24XX_PWRDM_POWER_RET 30 #define OMAP24XX_PWRDM_POWER_OFF 31 32 /* 33 * omap2xxx_prm_reset_src_map - map from bits 34 * hardware register (which are specific to 35 * reset source ID bit shifts (which is an O 36 * enumeration) 37 */ 38 static struct prm_reset_src_map omap2xxx_prm_r 39 { OMAP_GLOBALCOLD_RST_SHIFT, OMAP_GLOB 40 { OMAP_GLOBALWARM_RST_SHIFT, OMAP_GLOB 41 { OMAP24XX_SECU_VIOL_RST_SHIFT, OMAP_S 42 { OMAP24XX_MPU_WD_RST_SHIFT, OMAP_MPU_ 43 { OMAP24XX_SECU_WD_RST_SHIFT, OMAP_SEC 44 { OMAP24XX_EXTWMPU_RST_SHIFT, OMAP_EXT 45 { -1, -1 }, 46 }; 47 48 /** 49 * omap2xxx_prm_read_reset_sources - return th 50 * 51 * Return a u32 representing the last reset so 52 * returned reset source bits are standardized 53 */ 54 static u32 omap2xxx_prm_read_reset_sources(voi 55 { 56 struct prm_reset_src_map *p; 57 u32 r = 0; 58 u32 v; 59 60 v = omap2_prm_read_mod_reg(WKUP_MOD, O 61 62 p = omap2xxx_prm_reset_src_map; 63 while (p->reg_shift >= 0 && p->std_shi 64 if (v & (1 << p->reg_shift)) 65 r |= 1 << p->std_shift 66 p++; 67 } 68 69 return r; 70 } 71 72 /** 73 * omap2xxx_pwrst_to_common_pwrst - convert OM 74 * @omap2xxx_pwrst: OMAP2xxx hardware power st 75 * 76 * Return the common power state bits correspo 77 * hardware power state bits @omap2xxx_pwrst, 78 */ 79 static int omap2xxx_pwrst_to_common_pwrst(u8 o 80 { 81 u8 pwrst; 82 83 switch (omap2xxx_pwrst) { 84 case OMAP24XX_PWRDM_POWER_OFF: 85 pwrst = PWRDM_POWER_OFF; 86 break; 87 case OMAP24XX_PWRDM_POWER_RET: 88 pwrst = PWRDM_POWER_RET; 89 break; 90 case OMAP24XX_PWRDM_POWER_ON: 91 pwrst = PWRDM_POWER_ON; 92 break; 93 default: 94 return -EINVAL; 95 } 96 97 return pwrst; 98 } 99 100 /** 101 * omap2xxx_prm_dpll_reset - use DPLL reset to 102 * 103 * Set the DPLL reset bit, which should reboot 104 * recommended way to restart the SoC. No ret 105 */ 106 static void omap2xxx_prm_dpll_reset(void) 107 { 108 omap2_prm_set_mod_reg_bits(OMAP_RST_DP 109 OMAP2_RM_RS 110 /* OCP barrier */ 111 omap2_prm_read_mod_reg(WKUP_MOD, OMAP2 112 } 113 114 /** 115 * omap2xxx_prm_clear_mod_irqs - clear wakeup 116 * @module: PRM module to clear wakeups from 117 * @regs: register offset to clear 118 * @wkst_mask: wakeup status mask to clear 119 * 120 * Clears wakeup status bits for a given modul 121 * re-enter idle. 122 */ 123 static int omap2xxx_prm_clear_mod_irqs(s16 mod 124 { 125 u32 wkst; 126 127 wkst = omap2_prm_read_mod_reg(module, 128 wkst &= wkst_mask; 129 omap2_prm_write_mod_reg(wkst, module, 130 return 0; 131 } 132 133 int omap2xxx_clkdm_sleep(struct clockdomain *c 134 { 135 omap2_prm_set_mod_reg_bits(OMAP24XX_FO 136 clkdm->pwrd 137 OMAP2_PM_PW 138 return 0; 139 } 140 141 int omap2xxx_clkdm_wakeup(struct clockdomain * 142 { 143 omap2_prm_clear_mod_reg_bits(OMAP24XX_ 144 clkdm->pw 145 OMAP2_PM_ 146 return 0; 147 } 148 149 static int omap2xxx_pwrdm_set_next_pwrst(struc 150 { 151 u8 omap24xx_pwrst; 152 153 switch (pwrst) { 154 case PWRDM_POWER_OFF: 155 omap24xx_pwrst = OMAP24XX_PWRD 156 break; 157 case PWRDM_POWER_RET: 158 omap24xx_pwrst = OMAP24XX_PWRD 159 break; 160 case PWRDM_POWER_ON: 161 omap24xx_pwrst = OMAP24XX_PWRD 162 break; 163 default: 164 return -EINVAL; 165 } 166 167 omap2_prm_rmw_mod_reg_bits(OMAP_POWERS 168 (omap24xx_p 169 pwrdm->prcm 170 return 0; 171 } 172 173 static int omap2xxx_pwrdm_read_next_pwrst(stru 174 { 175 u8 omap2xxx_pwrst; 176 177 omap2xxx_pwrst = omap2_prm_read_mod_bi 178 179 180 181 return omap2xxx_pwrst_to_common_pwrst( 182 } 183 184 static int omap2xxx_pwrdm_read_pwrst(struct po 185 { 186 u8 omap2xxx_pwrst; 187 188 omap2xxx_pwrst = omap2_prm_read_mod_bi 189 190 191 192 return omap2xxx_pwrst_to_common_pwrst( 193 } 194 195 struct pwrdm_ops omap2_pwrdm_operations = { 196 .pwrdm_set_next_pwrst = omap2xxx_pwr 197 .pwrdm_read_next_pwrst = omap2xxx_pwr 198 .pwrdm_read_pwrst = omap2xxx_pwr 199 .pwrdm_set_logic_retst = omap2_pwrdm_ 200 .pwrdm_set_mem_onst = omap2_pwrdm_ 201 .pwrdm_set_mem_retst = omap2_pwrdm_ 202 .pwrdm_read_mem_pwrst = omap2_pwrdm_ 203 .pwrdm_read_mem_retst = omap2_pwrdm_ 204 .pwrdm_wait_transition = omap2_pwrdm_ 205 }; 206 207 /* 208 * 209 */ 210 211 static struct prm_ll_data omap2xxx_prm_ll_data 212 .read_reset_sources = &omap2xxx_prm_re 213 .assert_hardreset = &omap2_prm_assert_ 214 .deassert_hardreset = &omap2_prm_deass 215 .is_hardreset_asserted = &omap2_prm_is 216 .reset_system = &omap2xxx_prm_dpll_res 217 .clear_mod_irqs = &omap2xxx_prm_clear_ 218 }; 219 220 int __init omap2xxx_prm_init(const struct omap 221 { 222 return prm_register(&omap2xxx_prm_ll_d 223 } 224 225 static void __exit omap2xxx_prm_exit(void) 226 { 227 prm_unregister(&omap2xxx_prm_ll_data); 228 } 229 __exitcall(omap2xxx_prm_exit); 230
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.