Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 1 | /* |
Jean-Christophe Dubois | cb54d86 | 2015-12-17 13:37:15 +0000 | [diff] [blame] | 2 | * IMX Clock Control Module base class |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 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" |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 15 | #include "qom/object.h" |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 16 | |
Jean-Christophe Dubois | cb54d86 | 2015-12-17 13:37:15 +0000 | [diff] [blame] | 17 | #define CKIL_FREQ 32768 /* nominal 32khz clock */ |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 18 | |
| 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 Habkost | a489d19 | 2020-09-16 14:25:18 -0400 | [diff] [blame] | 31 | OBJECT_DECLARE_TYPE(IMXCCMState, IMXCCMClass, IMX_CCM) |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 32 | |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 33 | struct IMXCCMState { |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 34 | /* <private> */ |
| 35 | SysBusDevice parent_obj; |
| 36 | |
| 37 | /* <public> */ |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 38 | |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 39 | }; |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 40 | |
| 41 | typedef enum { |
Jean-Christophe Dubois | c91a588 | 2016-03-16 17:05:59 +0000 | [diff] [blame] | 42 | CLK_NONE, |
Jean-Christophe Dubois | aaa9ec3 | 2015-12-17 13:37:15 +0000 | [diff] [blame] | 43 | CLK_IPG, |
Jean-Christophe Dubois | d552f67 | 2016-03-16 17:06:00 +0000 | [diff] [blame] | 44 | CLK_IPG_HIGH, |
Jean-Christophe Dubois | 66542f6 | 2016-07-07 13:47:01 +0100 | [diff] [blame] | 45 | CLK_32k, |
| 46 | CLK_EXT, |
| 47 | CLK_HIGH_DIV, |
| 48 | CLK_HIGH, |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 49 | } IMXClk; |
| 50 | |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 51 | struct IMXCCMClass { |
Jean-Christophe Dubois | cb54d86 | 2015-12-17 13:37:15 +0000 | [diff] [blame] | 52 | /* <private> */ |
| 53 | SysBusDeviceClass parent_class; |
| 54 | |
| 55 | /* <public> */ |
| 56 | uint32_t (*get_clock_frequency)(IMXCCMState *s, IMXClk clk); |
Eduardo Habkost | db1015e | 2020-09-03 16:43:22 -0400 | [diff] [blame] | 57 | }; |
Jean-Christophe Dubois | cb54d86 | 2015-12-17 13:37:15 +0000 | [diff] [blame] | 58 | |
| 59 | uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq); |
| 60 | |
| 61 | uint32_t imx_ccm_get_clock_frequency(IMXCCMState *s, IMXClk clock); |
Jean-Christophe Dubois | 282e74c | 2015-08-13 11:26:20 +0100 | [diff] [blame] | 62 | |
| 63 | #endif /* IMX_CCM_H */ |