18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * ARM timer implementation, found in Integrator, Versatile and Realview 48c2ecf20Sopenharmony_ci * platforms. Not all platforms support all registers and bits in these 58c2ecf20Sopenharmony_ci * registers, so we mark them with A for Integrator AP, C for Integrator 68c2ecf20Sopenharmony_ci * CP, V for Versatile and R for Realview. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Integrator AP has 16-bit timers, Integrator CP, Versatile and Realview 98c2ecf20Sopenharmony_ci * can have 16-bit or 32-bit selectable via a bit in the control register. 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * Every SP804 contains two identical timers. 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_ci#define NR_TIMERS 2 148c2ecf20Sopenharmony_ci#define TIMER_1_BASE 0x00 158c2ecf20Sopenharmony_ci#define TIMER_2_BASE 0x20 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define TIMER_LOAD 0x00 /* ACVR rw */ 188c2ecf20Sopenharmony_ci#define TIMER_VALUE 0x04 /* ACVR ro */ 198c2ecf20Sopenharmony_ci#define TIMER_CTRL 0x08 /* ACVR rw */ 208c2ecf20Sopenharmony_ci#define TIMER_CTRL_ONESHOT (1 << 0) /* CVR */ 218c2ecf20Sopenharmony_ci#define TIMER_CTRL_32BIT (1 << 1) /* CVR */ 228c2ecf20Sopenharmony_ci#define TIMER_CTRL_DIV1 (0 << 2) /* ACVR */ 238c2ecf20Sopenharmony_ci#define TIMER_CTRL_DIV16 (1 << 2) /* ACVR */ 248c2ecf20Sopenharmony_ci#define TIMER_CTRL_DIV256 (2 << 2) /* ACVR */ 258c2ecf20Sopenharmony_ci#define TIMER_CTRL_IE (1 << 5) /* VR */ 268c2ecf20Sopenharmony_ci#define TIMER_CTRL_PERIODIC (1 << 6) /* ACVR */ 278c2ecf20Sopenharmony_ci#define TIMER_CTRL_ENABLE (1 << 7) /* ACVR */ 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define TIMER_INTCLR 0x0c /* ACVR wo */ 308c2ecf20Sopenharmony_ci#define TIMER_RIS 0x10 /* CVR ro */ 318c2ecf20Sopenharmony_ci#define TIMER_MIS 0x14 /* CVR ro */ 328c2ecf20Sopenharmony_ci#define TIMER_BGLOAD 0x18 /* CVR rw */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct sp804_timer { 358c2ecf20Sopenharmony_ci int load; 368c2ecf20Sopenharmony_ci int load_h; 378c2ecf20Sopenharmony_ci int value; 388c2ecf20Sopenharmony_ci int value_h; 398c2ecf20Sopenharmony_ci int ctrl; 408c2ecf20Sopenharmony_ci int intclr; 418c2ecf20Sopenharmony_ci int ris; 428c2ecf20Sopenharmony_ci int mis; 438c2ecf20Sopenharmony_ci int bgload; 448c2ecf20Sopenharmony_ci int bgload_h; 458c2ecf20Sopenharmony_ci int timer_base[NR_TIMERS]; 468c2ecf20Sopenharmony_ci int width; 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistruct sp804_clkevt { 508c2ecf20Sopenharmony_ci void __iomem *base; 518c2ecf20Sopenharmony_ci void __iomem *load; 528c2ecf20Sopenharmony_ci void __iomem *load_h; 538c2ecf20Sopenharmony_ci void __iomem *value; 548c2ecf20Sopenharmony_ci void __iomem *value_h; 558c2ecf20Sopenharmony_ci void __iomem *ctrl; 568c2ecf20Sopenharmony_ci void __iomem *intclr; 578c2ecf20Sopenharmony_ci void __iomem *ris; 588c2ecf20Sopenharmony_ci void __iomem *mis; 598c2ecf20Sopenharmony_ci void __iomem *bgload; 608c2ecf20Sopenharmony_ci void __iomem *bgload_h; 618c2ecf20Sopenharmony_ci unsigned long reload; 628c2ecf20Sopenharmony_ci int width; 638c2ecf20Sopenharmony_ci}; 64