2020-10-10 16:57:49 +03:00
|
|
|
/*
|
|
|
|
* BCM2835 CPRMAN clock manager
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020 Luc Michel <luc@lmichel.fr>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
2022-05-06 16:49:08 +03:00
|
|
|
#ifndef HW_MISC_BCM2835_CPRMAN_H
|
|
|
|
#define HW_MISC_BCM2835_CPRMAN_H
|
2020-10-10 16:57:49 +03:00
|
|
|
|
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/qdev-clock.h"
|
|
|
|
|
|
|
|
#define TYPE_BCM2835_CPRMAN "bcm2835-cprman"
|
|
|
|
|
|
|
|
typedef struct BCM2835CprmanState BCM2835CprmanState;
|
|
|
|
|
|
|
|
DECLARE_INSTANCE_CHECKER(BCM2835CprmanState, CPRMAN,
|
|
|
|
TYPE_BCM2835_CPRMAN)
|
|
|
|
|
|
|
|
#define CPRMAN_NUM_REGS (0x2000 / sizeof(uint32_t))
|
|
|
|
|
hw/misc/bcm2835_cprman: add a PLL skeleton implementation
There are 5 PLLs in the CPRMAN, namely PLL A, C, D, H and B. All of them
take the xosc clock as input and produce a new clock.
This commit adds a skeleton implementation for the PLLs as sub-devices
of the CPRMAN. The PLLs are instantiated and connected internally to the
main oscillator.
Each PLL has 6 registers : CM, A2W_CTRL, A2W_ANA[0,1,2,3], A2W_FRAC. A
write to any of them triggers a call to the (not yet implemented)
pll_update function.
If the main oscillator changes frequency, an update is also triggered.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Luc Michel <luc@lmichel.fr>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-10-10 16:57:50 +03:00
|
|
|
typedef enum CprmanPll {
|
|
|
|
CPRMAN_PLLA = 0,
|
|
|
|
CPRMAN_PLLC,
|
|
|
|
CPRMAN_PLLD,
|
|
|
|
CPRMAN_PLLH,
|
|
|
|
CPRMAN_PLLB,
|
|
|
|
|
|
|
|
CPRMAN_NUM_PLL
|
|
|
|
} CprmanPll;
|
|
|
|
|
2020-10-10 16:57:52 +03:00
|
|
|
typedef enum CprmanPllChannel {
|
|
|
|
CPRMAN_PLLA_CHANNEL_DSI0 = 0,
|
|
|
|
CPRMAN_PLLA_CHANNEL_CORE,
|
|
|
|
CPRMAN_PLLA_CHANNEL_PER,
|
|
|
|
CPRMAN_PLLA_CHANNEL_CCP2,
|
|
|
|
|
|
|
|
CPRMAN_PLLC_CHANNEL_CORE2,
|
|
|
|
CPRMAN_PLLC_CHANNEL_CORE1,
|
|
|
|
CPRMAN_PLLC_CHANNEL_PER,
|
|
|
|
CPRMAN_PLLC_CHANNEL_CORE0,
|
|
|
|
|
|
|
|
CPRMAN_PLLD_CHANNEL_DSI0,
|
|
|
|
CPRMAN_PLLD_CHANNEL_CORE,
|
|
|
|
CPRMAN_PLLD_CHANNEL_PER,
|
|
|
|
CPRMAN_PLLD_CHANNEL_DSI1,
|
|
|
|
|
|
|
|
CPRMAN_PLLH_CHANNEL_AUX,
|
|
|
|
CPRMAN_PLLH_CHANNEL_RCAL,
|
|
|
|
CPRMAN_PLLH_CHANNEL_PIX,
|
|
|
|
|
|
|
|
CPRMAN_PLLB_CHANNEL_ARM,
|
|
|
|
|
|
|
|
CPRMAN_NUM_PLL_CHANNEL,
|
2020-10-10 16:57:54 +03:00
|
|
|
|
|
|
|
/* Special values used when connecting clock sources to clocks */
|
|
|
|
CPRMAN_CLOCK_SRC_NORMAL = -1,
|
|
|
|
CPRMAN_CLOCK_SRC_FORCE_GROUND = -2,
|
|
|
|
CPRMAN_CLOCK_SRC_DSI0HSCK = -3,
|
2020-10-10 16:57:52 +03:00
|
|
|
} CprmanPllChannel;
|
|
|
|
|
2020-10-10 16:57:54 +03:00
|
|
|
typedef enum CprmanClockMux {
|
|
|
|
CP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ockMuxSource {
|
|
|
|
CPRMAN_CLOCK_SRC_GND = 0,
|
|
|
|
CPRMAN_CLOCK_SRC_XOSC,
|
|
|
|
CPRMAN_CLOCK_SRC_TD0,
|
|
|
|
CPRMAN_CLOCK_SRC_TD1,
|
|
|
|
CPRMAN_CLOCK_SRC_PLLA,
|
|
|
|
CPRMAN_CLOCK_SRC_PLLC,
|
|
|
|
CPRMAN_CLOCK_SRC_PLLD,
|
|
|
|
CPRMAN_CLOCK_SRC_PLLH,
|
|
|
|
CPRMAN_CLOCK_SRC_PLLC_CORE1,
|
|
|
|
CPRMAN_CLOCK_SRC_PLLC_CORE2,
|
|
|
|
|
|
|
|
CPRMAN_NUM_CLOCK_MUX_SRC
|
|
|
|
} CprmanClockMuxSource;
|
|
|
|
|
hw/misc/bcm2835_cprman: add a PLL skeleton implementation
There are 5 PLLs in the CPRMAN, namely PLL A, C, D, H and B. All of them
take the xosc clock as input and produce a new clock.
This commit adds a skeleton implementation for the PLLs as sub-devices
of the CPRMAN. The PLLs are instantiated and connected internally to the
main oscillator.
Each PLL has 6 registers : CM, A2W_CTRL, A2W_ANA[0,1,2,3], A2W_FRAC. A
write to any of them triggers a call to the (not yet implemented)
pll_update function.
If the main oscillator changes frequency, an update is also triggered.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Luc Michel <luc@lmichel.fr>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-10-10 16:57:50 +03:00
|
|
|
typedef struct CprmanPllState {
|
|
|
|
/*< private >*/
|
|
|
|
DeviceState parent_obj;
|
|
|
|
|
|
|
|
/*< public >*/
|
|
|
|
CprmanPll id;
|
|
|
|
|
|
|
|
uint32_t *reg_cm;
|
|
|
|
uint32_t *reg_a2w_ctrl;
|
|
|
|
uint32_t *reg_a2w_ana; /* ANA[0] .. ANA[3] */
|
|
|
|
uint32_t prediv_mask; /* prediv bit in ana[1] */
|
|
|
|
uint32_t *reg_a2w_frac;
|
|
|
|
|
|
|
|
Clock *xosc_in;
|
|
|
|
Clock *out;
|
|
|
|
} CprmanPllState;
|
|
|
|
|
2020-10-10 16:57:52 +03:00
|
|
|
typedef struct CprmanPllChannelState {
|
|
|
|
/*< private >*/
|
|
|
|
DeviceState parent_obj;
|
|
|
|
|
|
|
|
/*< public >*/
|
|
|
|
CprmanPllChannel id;
|
|
|
|
CprmanPll parent;
|
|
|
|
|
|
|
|
uint32_t *reg_cm;
|
|
|
|
uint32_t hold_mask;
|
|
|
|
uint32_t load_mask;
|
|
|
|
uint32_t *reg_a2w_ctrl;
|
|
|
|
int fixed_divider;
|
|
|
|
|
|
|
|
Clock *pll_in;
|
|
|
|
Clock *out;
|
|
|
|
} CprmanPllChannelState;
|
|
|
|
|
2020-10-10 16:57:54 +03:00
|
|
|
typedef struct CprmanClockMuxState {
|
|
|
|
/*< private >*/
|
|
|
|
DeviceState parent_obj;
|
|
|
|
|
|
|
|
/*< public >*/
|
|
|
|
CprmanClockMux id;
|
|
|
|
|
|
|
|
uint32_t *reg_ctl;
|
|
|
|
uint32_t *reg_div;
|
|
|
|
int int_bits;
|
|
|
|
int frac_bits;
|
|
|
|
|
|
|
|
Clock *srcs[CPRMAN_NUM_CLOCK_MUX_SRC];
|
|
|
|
Clock *out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Used by clock srcs update callback to retrieve both the clock and the
|
|
|
|
* source number.
|
|
|
|
*/
|
|
|
|
struct CprmanClockMuxState *backref[CPRMAN_NUM_CLOCK_MUX_SRC];
|
|
|
|
} CprmanClockMuxState;
|
|
|
|
|
2020-10-10 16:57:56 +03:00
|
|
|
typedef struct CprmanDsi0HsckMuxState {
|
|
|
|
/*< private >*/
|
|
|
|
DeviceState parent_obj;
|
|
|
|
|
|
|
|
/*< public >*/
|
|
|
|
CprmanClockMux id;
|
|
|
|
|
|
|
|
uint32_t *reg_cm;
|
|
|
|
|
|
|
|
Clock *plla_in;
|
|
|
|
Clock *plld_in;
|
|
|
|
Clock *out;
|
|
|
|
} CprmanDsi0HsckMuxState;
|
|
|
|
|
2020-10-10 16:57:49 +03:00
|
|
|
struct BCM2835CprmanState {
|
|
|
|
/*< private >*/
|
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
|
|
|
/*< public >*/
|
|
|
|
MemoryRegion iomem;
|
|
|
|
|
hw/misc/bcm2835_cprman: add a PLL skeleton implementation
There are 5 PLLs in the CPRMAN, namely PLL A, C, D, H and B. All of them
take the xosc clock as input and produce a new clock.
This commit adds a skeleton implementation for the PLLs as sub-devices
of the CPRMAN. The PLLs are instantiated and connected internally to the
main oscillator.
Each PLL has 6 registers : CM, A2W_CTRL, A2W_ANA[0,1,2,3], A2W_FRAC. A
write to any of them triggers a call to the (not yet implemented)
pll_update function.
If the main oscillator changes frequency, an update is also triggered.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Luc Michel <luc@lmichel.fr>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-10-10 16:57:50 +03:00
|
|
|
CprmanPllState plls[CPRMAN_NUM_PLL];
|
2020-10-10 16:57:52 +03:00
|
|
|
CprmanPllChannelState channels[CPRMAN_NUM_PLL_CHANNEL];
|
2020-10-10 16:57:54 +03:00
|
|
|
CprmanClockMuxState clock_muxes[CPRMAN_NUM_CLOCK_MUX];
|
2020-10-10 16:57:56 +03:00
|
|
|
CprmanDsi0HsckMuxState dsi0hsck_mux;
|
hw/misc/bcm2835_cprman: add a PLL skeleton implementation
There are 5 PLLs in the CPRMAN, namely PLL A, C, D, H and B. All of them
take the xosc clock as input and produce a new clock.
This commit adds a skeleton implementation for the PLLs as sub-devices
of the CPRMAN. The PLLs are instantiated and connected internally to the
main oscillator.
Each PLL has 6 registers : CM, A2W_CTRL, A2W_ANA[0,1,2,3], A2W_FRAC. A
write to any of them triggers a call to the (not yet implemented)
pll_update function.
If the main oscillator changes frequency, an update is also triggered.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Luc Michel <luc@lmichel.fr>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2020-10-10 16:57:50 +03:00
|
|
|
|
2020-10-10 16:57:49 +03:00
|
|
|
uint32_t regs[CPRMAN_NUM_REGS];
|
|
|
|
uint32_t xosc_freq;
|
|
|
|
|
|
|
|
Clock *xosc;
|
2020-10-10 16:57:54 +03:00
|
|
|
Clock *gnd;
|
2020-10-10 16:57:49 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|