1282e74c8SJean-Christophe Dubois /* 2cb54d868SJean-Christophe Dubois * IMX Clock Control Module base class 3282e74c8SJean-Christophe Dubois * 4282e74c8SJean-Christophe Dubois * Copyright (C) 2012 NICTA 5282e74c8SJean-Christophe Dubois * Updated by Jean-Christophe Dubois <jcd@tribudubois.net> 6282e74c8SJean-Christophe Dubois * 7282e74c8SJean-Christophe Dubois * This work is licensed under the terms of the GNU GPL, version 2 or later. 8282e74c8SJean-Christophe Dubois * See the COPYING file in the top-level directory. 9282e74c8SJean-Christophe Dubois */ 10282e74c8SJean-Christophe Dubois 11282e74c8SJean-Christophe Dubois #ifndef IMX_CCM_H 12282e74c8SJean-Christophe Dubois #define IMX_CCM_H 13282e74c8SJean-Christophe Dubois 14282e74c8SJean-Christophe Dubois #include "hw/sysbus.h" 15db1015e9SEduardo Habkost #include "qom/object.h" 16282e74c8SJean-Christophe Dubois 17cb54d868SJean-Christophe Dubois #define CKIL_FREQ 32768 /* nominal 32khz clock */ 18282e74c8SJean-Christophe Dubois 19282e74c8SJean-Christophe Dubois /* PLL control registers */ 20282e74c8SJean-Christophe Dubois #define PD(v) (((v) >> 26) & 0xf) 21282e74c8SJean-Christophe Dubois #define MFD(v) (((v) >> 16) & 0x3ff) 22282e74c8SJean-Christophe Dubois #define MFI(v) (((v) >> 10) & 0xf); 23282e74c8SJean-Christophe Dubois #define MFN(v) ((v) & 0x3ff) 24282e74c8SJean-Christophe Dubois 25282e74c8SJean-Christophe Dubois #define PLL_PD(x) (((x) & 0xf) << 26) 26282e74c8SJean-Christophe Dubois #define PLL_MFD(x) (((x) & 0x3ff) << 16) 27282e74c8SJean-Christophe Dubois #define PLL_MFI(x) (((x) & 0xf) << 10) 28282e74c8SJean-Christophe Dubois #define PLL_MFN(x) (((x) & 0x3ff) << 0) 29282e74c8SJean-Christophe Dubois 30282e74c8SJean-Christophe Dubois #define TYPE_IMX_CCM "imx.ccm" 31*a489d195SEduardo Habkost OBJECT_DECLARE_TYPE(IMXCCMState, IMXCCMClass, IMX_CCM) 32282e74c8SJean-Christophe Dubois 33db1015e9SEduardo Habkost struct IMXCCMState { 34282e74c8SJean-Christophe Dubois /* <private> */ 35282e74c8SJean-Christophe Dubois SysBusDevice parent_obj; 36282e74c8SJean-Christophe Dubois 37282e74c8SJean-Christophe Dubois /* <public> */ 38282e74c8SJean-Christophe Dubois 39db1015e9SEduardo Habkost }; 40282e74c8SJean-Christophe Dubois 41282e74c8SJean-Christophe Dubois typedef enum { 42c91a5883SJean-Christophe Dubois CLK_NONE, 43aaa9ec3bSJean-Christophe Dubois CLK_IPG, 44d552f675SJean-Christophe Dubois CLK_IPG_HIGH, 4566542f63SJean-Christophe Dubois CLK_32k, 4666542f63SJean-Christophe Dubois CLK_EXT, 4766542f63SJean-Christophe Dubois CLK_HIGH_DIV, 4866542f63SJean-Christophe Dubois CLK_HIGH, 49282e74c8SJean-Christophe Dubois } IMXClk; 50282e74c8SJean-Christophe Dubois 51db1015e9SEduardo Habkost struct IMXCCMClass { 52cb54d868SJean-Christophe Dubois /* <private> */ 53cb54d868SJean-Christophe Dubois SysBusDeviceClass parent_class; 54cb54d868SJean-Christophe Dubois 55cb54d868SJean-Christophe Dubois /* <public> */ 56cb54d868SJean-Christophe Dubois uint32_t (*get_clock_frequency)(IMXCCMState *s, IMXClk clk); 57db1015e9SEduardo Habkost }; 58cb54d868SJean-Christophe Dubois 59cb54d868SJean-Christophe Dubois uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq); 60cb54d868SJean-Christophe Dubois 61cb54d868SJean-Christophe Dubois uint32_t imx_ccm_get_clock_frequency(IMXCCMState *s, IMXClk clock); 62282e74c8SJean-Christophe Dubois 63282e74c8SJean-Christophe Dubois #endif /* IMX_CCM_H */ 64