blob: 7e5678e9726045e39de5f4b0e35de131f7eeeff6 [file] [log] [blame]
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +01001/*
Jean-Christophe Duboiscb54d862015-12-17 13:37:15 +00002 * IMX Clock Control Module base class
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +01003 *
4 * Copyright (C) 2012 NICTA
5 * Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2 or later.
8 * See the COPYING file in the top-level directory.
9 */
10
11#ifndef IMX_CCM_H
12#define IMX_CCM_H
13
14#include "hw/sysbus.h"
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040015#include "qom/object.h"
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +010016
Jean-Christophe Duboiscb54d862015-12-17 13:37:15 +000017#define CKIL_FREQ 32768 /* nominal 32khz clock */
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +010018
19/* PLL control registers */
20#define PD(v) (((v) >> 26) & 0xf)
21#define MFD(v) (((v) >> 16) & 0x3ff)
22#define MFI(v) (((v) >> 10) & 0xf);
23#define MFN(v) ((v) & 0x3ff)
24
25#define PLL_PD(x) (((x) & 0xf) << 26)
26#define PLL_MFD(x) (((x) & 0x3ff) << 16)
27#define PLL_MFI(x) (((x) & 0xf) << 10)
28#define PLL_MFN(x) (((x) & 0x3ff) << 0)
29
30#define TYPE_IMX_CCM "imx.ccm"
Eduardo Habkosta489d192020-09-16 14:25:18 -040031OBJECT_DECLARE_TYPE(IMXCCMState, IMXCCMClass, IMX_CCM)
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +010032
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040033struct IMXCCMState {
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +010034 /* <private> */
35 SysBusDevice parent_obj;
36
37 /* <public> */
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +010038
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040039};
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +010040
41typedef enum {
Jean-Christophe Duboisc91a5882016-03-16 17:05:59 +000042 CLK_NONE,
Jean-Christophe Duboisaaa9ec32015-12-17 13:37:15 +000043 CLK_IPG,
Jean-Christophe Duboisd552f672016-03-16 17:06:00 +000044 CLK_IPG_HIGH,
Jean-Christophe Dubois66542f62016-07-07 13:47:01 +010045 CLK_32k,
46 CLK_EXT,
47 CLK_HIGH_DIV,
48 CLK_HIGH,
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +010049} IMXClk;
50
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040051struct IMXCCMClass {
Jean-Christophe Duboiscb54d862015-12-17 13:37:15 +000052 /* <private> */
53 SysBusDeviceClass parent_class;
54
55 /* <public> */
56 uint32_t (*get_clock_frequency)(IMXCCMState *s, IMXClk clk);
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040057};
Jean-Christophe Duboiscb54d862015-12-17 13:37:15 +000058
59uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq);
60
61uint32_t imx_ccm_get_clock_frequency(IMXCCMState *s, IMXClk clock);
Jean-Christophe Dubois282e74c2015-08-13 11:26:20 +010062
63#endif /* IMX_CCM_H */