2 * BCM2835 CPRMAN clock manager
4 * Copyright (c) 2020 Luc Michel <luc@lmichel.fr>
6 * SPDX-License-Identifier: GPL-2.0-or-later
9 #ifndef HW_MISC_BCM2835_CPRMAN_H
10 #define HW_MISC_BCM2835_CPRMAN_H
12 #include "hw/sysbus.h"
13 #include "hw/qdev-clock.h"
15 #define TYPE_BCM2835_CPRMAN "bcm2835-cprman"
17 typedef struct BCM2835CprmanState BCM2835CprmanState
;
19 DECLARE_INSTANCE_CHECKER(BCM2835CprmanState
, CPRMAN
,
22 #define CPRMAN_NUM_REGS (0x2000 / sizeof(uint32_t))
24 typedef enum CprmanPll
{
34 typedef enum CprmanPllChannel
{
35 CPRMAN_PLLA_CHANNEL_DSI0
= 0,
36 CPRMAN_PLLA_CHANNEL_CORE
,
37 CPRMAN_PLLA_CHANNEL_PER
,
38 CPRMAN_PLLA_CHANNEL_CCP2
,
40 CPRMAN_PLLC_CHANNEL_CORE2
,
41 CPRMAN_PLLC_CHANNEL_CORE1
,
42 CPRMAN_PLLC_CHANNEL_PER
,
43 CPRMAN_PLLC_CHANNEL_CORE0
,
45 CPRMAN_PLLD_CHANNEL_DSI0
,
46 CPRMAN_PLLD_CHANNEL_CORE
,
47 CPRMAN_PLLD_CHANNEL_PER
,
48 CPRMAN_PLLD_CHANNEL_DSI1
,
50 CPRMAN_PLLH_CHANNEL_AUX
,
51 CPRMAN_PLLH_CHANNEL_RCAL
,
52 CPRMAN_PLLH_CHANNEL_PIX
,
54 CPRMAN_PLLB_CHANNEL_ARM
,
56 CPRMAN_NUM_PLL_CHANNEL
,
58 /* Special values used when connecting clock sources to clocks */
59 CPRMAN_CLOCK_SRC_NORMAL
= -1,
60 CPRMAN_CLOCK_SRC_FORCE_GROUND
= -2,
61 CPRMAN_CLOCK_SRC_DSI0HSCK
= -3,
64 typedef enum CprmanClockMux
{
105 typedef enum CprmanClockMuxSource
{
106 CPRMAN_CLOCK_SRC_GND
= 0,
107 CPRMAN_CLOCK_SRC_XOSC
,
108 CPRMAN_CLOCK_SRC_TD0
,
109 CPRMAN_CLOCK_SRC_TD1
,
110 CPRMAN_CLOCK_SRC_PLLA
,
111 CPRMAN_CLOCK_SRC_PLLC
,
112 CPRMAN_CLOCK_SRC_PLLD
,
113 CPRMAN_CLOCK_SRC_PLLH
,
114 CPRMAN_CLOCK_SRC_PLLC_CORE1
,
115 CPRMAN_CLOCK_SRC_PLLC_CORE2
,
117 CPRMAN_NUM_CLOCK_MUX_SRC
118 } CprmanClockMuxSource
;
120 typedef struct CprmanPllState
{
122 DeviceState parent_obj
;
128 uint32_t *reg_a2w_ctrl
;
129 uint32_t *reg_a2w_ana
; /* ANA[0] .. ANA[3] */
130 uint32_t prediv_mask
; /* prediv bit in ana[1] */
131 uint32_t *reg_a2w_frac
;
137 typedef struct CprmanPllChannelState
{
139 DeviceState parent_obj
;
148 uint32_t *reg_a2w_ctrl
;
153 } CprmanPllChannelState
;
155 typedef struct CprmanClockMuxState
{
157 DeviceState parent_obj
;
167 Clock
*srcs
[CPRMAN_NUM_CLOCK_MUX_SRC
];
171 * Used by clock srcs update callback to retrieve both the clock and the
174 struct CprmanClockMuxState
*backref
[CPRMAN_NUM_CLOCK_MUX_SRC
];
175 } CprmanClockMuxState
;
177 typedef struct CprmanDsi0HsckMuxState
{
179 DeviceState parent_obj
;
189 } CprmanDsi0HsckMuxState
;
191 struct BCM2835CprmanState
{
193 SysBusDevice parent_obj
;
198 CprmanPllState plls
[CPRMAN_NUM_PLL
];
199 CprmanPllChannelState channels
[CPRMAN_NUM_PLL_CHANNEL
];
200 CprmanClockMuxState clock_muxes
[CPRMAN_NUM_CLOCK_MUX
];
201 CprmanDsi0HsckMuxState dsi0hsck_mux
;
203 uint32_t regs
[CPRMAN_NUM_REGS
];