1 /* 2 * IMX Clock Control Module base class 3 * 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" 15 16 #define CKIL_FREQ 32768 /* nominal 32khz clock */ 17 18 /* PLL control registers */ 19 #define PD(v) (((v) >> 26) & 0xf) 20 #define MFD(v) (((v) >> 16) & 0x3ff) 21 #define MFI(v) (((v) >> 10) & 0xf); 22 #define MFN(v) ((v) & 0x3ff) 23 24 #define PLL_PD(x) (((x) & 0xf) << 26) 25 #define PLL_MFD(x) (((x) & 0x3ff) << 16) 26 #define PLL_MFI(x) (((x) & 0xf) << 10) 27 #define PLL_MFN(x) (((x) & 0x3ff) << 0) 28 29 #define TYPE_IMX_CCM "imx.ccm" 30 #define IMX_CCM(obj) \ 31 OBJECT_CHECK(IMXCCMState, (obj), TYPE_IMX_CCM) 32 #define IMX_CCM_CLASS(klass) \ 33 OBJECT_CLASS_CHECK(IMXCCMClass, (klass), TYPE_IMX_CCM) 34 #define IMX_GET_CLASS(obj) \ 35 OBJECT_GET_CLASS(IMXCCMClass, (obj), TYPE_IMX_CCM) 36 37 typedef struct IMXCCMState { 38 /* <private> */ 39 SysBusDevice parent_obj; 40 41 /* <public> */ 42 43 } IMXCCMState; 44 45 typedef enum { 46 NOCLK, 47 CLK_MPLL, 48 CLK_UPLL, 49 CLK_MCU, 50 CLK_HSP, 51 CLK_MAX, 52 CLK_AHB, 53 CLK_IPG, 54 CLK_PER, 55 CLK_32k 56 } IMXClk; 57 58 typedef struct IMXCCMClass { 59 /* <private> */ 60 SysBusDeviceClass parent_class; 61 62 /* <public> */ 63 uint32_t (*get_clock_frequency)(IMXCCMState *s, IMXClk clk); 64 } IMXCCMClass; 65 66 uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq); 67 68 uint32_t imx_ccm_get_clock_frequency(IMXCCMState *s, IMXClk clock); 69 70 #endif /* IMX_CCM_H */ 71