• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <stdint.h>
8 
9 #include <drivers/arm/sp805.h>
10 #include <lib/mmio.h>
11 
12 /* Inline register access functions */
13 
sp805_write_wdog_load(uintptr_t base,uint32_t value)14 static inline void sp805_write_wdog_load(uintptr_t base, uint32_t value)
15 {
16 	mmio_write_32(base + SP805_WDOG_LOAD_OFF, value);
17 }
18 
sp805_write_wdog_ctrl(uintptr_t base,uint32_t value)19 static inline void sp805_write_wdog_ctrl(uintptr_t base, uint32_t value)
20 {
21 	mmio_write_32(base + SP805_WDOG_CTR_OFF, value);
22 }
23 
sp805_write_wdog_lock(uintptr_t base,uint32_t value)24 static inline void sp805_write_wdog_lock(uintptr_t base, uint32_t value)
25 {
26 	mmio_write_32(base + SP805_WDOG_LOCK_OFF, value);
27 }
28 
29 
30 /* Public API implementation */
31 
sp805_start(uintptr_t base,unsigned int ticks)32 void sp805_start(uintptr_t base, unsigned int ticks)
33 {
34 	sp805_write_wdog_load(base, ticks);
35 	sp805_write_wdog_ctrl(base, SP805_CTR_RESEN | SP805_CTR_INTEN);
36 	/* Lock registers access */
37 	sp805_write_wdog_lock(base, 0U);
38 }
39 
sp805_stop(uintptr_t base)40 void sp805_stop(uintptr_t base)
41 {
42 	sp805_write_wdog_lock(base, WDOG_UNLOCK_KEY);
43 	sp805_write_wdog_ctrl(base, 0U);
44 }
45 
sp805_refresh(uintptr_t base,unsigned int ticks)46 void sp805_refresh(uintptr_t base, unsigned int ticks)
47 {
48 	sp805_write_wdog_lock(base, WDOG_UNLOCK_KEY);
49 	sp805_write_wdog_load(base, ticks);
50 	sp805_write_wdog_lock(base, 0U);
51 }
52