hw/misc/bcm2835_cprman: add a PLL channel skeleton implementation
[qemu.git] / include / hw / misc / bcm2835_cprman.h
1 /*
2 * BCM2835 CPRMAN clock manager
3 *
4 * Copyright (c) 2020 Luc Michel <luc@lmichel.fr>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9 #ifndef HW_MISC_CPRMAN_H
10 #define HW_MISC_CPRMAN_H
11
12 #include "hw/sysbus.h"
13 #include "hw/qdev-clock.h"
14
15 #define TYPE_BCM2835_CPRMAN "bcm2835-cprman"
16
17 typedef struct BCM2835CprmanState BCM2835CprmanState;
18
19 DECLARE_INSTANCE_CHECKER(BCM2835CprmanState, CPRMAN,
20 TYPE_BCM2835_CPRMAN)
21
22 #define CPRMAN_NUM_REGS (0x2000 / sizeof(uint32_t))
23
24 typedef enum CprmanPll {
25 CPRMAN_PLLA = 0,
26 CPRMAN_PLLC,
27 CPRMAN_PLLD,
28 CPRMAN_PLLH,
29 CPRMAN_PLLB,
30
31 CPRMAN_NUM_PLL
32 } CprmanPll;
33
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,
39
40 CPRMAN_PLLC_CHANNEL_CORE2,
41 CPRMAN_PLLC_CHANNEL_CORE1,
42 CPRMAN_PLLC_CHANNEL_PER,
43 CPRMAN_PLLC_CHANNEL_CORE0,
44
45 CPRMAN_PLLD_CHANNEL_DSI0,
46 CPRMAN_PLLD_CHANNEL_CORE,
47 CPRMAN_PLLD_CHANNEL_PER,
48 CPRMAN_PLLD_CHANNEL_DSI1,
49
50 CPRMAN_PLLH_CHANNEL_AUX,
51 CPRMAN_PLLH_CHANNEL_RCAL,
52 CPRMAN_PLLH_CHANNEL_PIX,
53
54 CPRMAN_PLLB_CHANNEL_ARM,
55
56 CPRMAN_NUM_PLL_CHANNEL,
57 } CprmanPllChannel;
58
59 typedef struct CprmanPllState {
60 /*< private >*/
61 DeviceState parent_obj;
62
63 /*< public >*/
64 CprmanPll id;
65
66 uint32_t *reg_cm;
67 uint32_t *reg_a2w_ctrl;
68 uint32_t *reg_a2w_ana; /* ANA[0] .. ANA[3] */
69 uint32_t prediv_mask; /* prediv bit in ana[1] */
70 uint32_t *reg_a2w_frac;
71
72 Clock *xosc_in;
73 Clock *out;
74 } CprmanPllState;
75
76 typedef struct CprmanPllChannelState {
77 /*< private >*/
78 DeviceState parent_obj;
79
80 /*< public >*/
81 CprmanPllChannel id;
82 CprmanPll parent;
83
84 uint32_t *reg_cm;
85 uint32_t hold_mask;
86 uint32_t load_mask;
87 uint32_t *reg_a2w_ctrl;
88 int fixed_divider;
89
90 Clock *pll_in;
91 Clock *out;
92 } CprmanPllChannelState;
93
94 struct BCM2835CprmanState {
95 /*< private >*/
96 SysBusDevice parent_obj;
97
98 /*< public >*/
99 MemoryRegion iomem;
100
101 CprmanPllState plls[CPRMAN_NUM_PLL];
102 CprmanPllChannelState channels[CPRMAN_NUM_PLL_CHANNEL];
103
104 uint32_t regs[CPRMAN_NUM_REGS];
105 uint32_t xosc_freq;
106
107 Clock *xosc;
108 };
109
110 #endif