Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 1 | /* |
| 2 | * keystone2: common pll clock definitions |
| 3 | * (C) Copyright 2012-2014 |
| 4 | * Texas Instruments Incorporated, <www.ti.com> |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0+ |
| 7 | */ |
| 8 | |
| 9 | #ifndef _CLOCK_DEFS_H_ |
| 10 | #define _CLOCK_DEFS_H_ |
| 11 | |
| 12 | #include <asm/arch/hardware.h> |
| 13 | |
Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 14 | /* PLL Control Registers */ |
| 15 | struct pllctl_regs { |
| 16 | u32 ctl; /* 00 */ |
| 17 | u32 ocsel; /* 04 */ |
| 18 | u32 secctl; /* 08 */ |
| 19 | u32 resv0; |
| 20 | u32 mult; /* 10 */ |
| 21 | u32 prediv; /* 14 */ |
| 22 | u32 div1; /* 18 */ |
| 23 | u32 div2; /* 1c */ |
| 24 | u32 div3; /* 20 */ |
| 25 | u32 oscdiv1; /* 24 */ |
| 26 | u32 resv1; /* 28 */ |
| 27 | u32 bpdiv; /* 2c */ |
| 28 | u32 wakeup; /* 30 */ |
| 29 | u32 resv2; |
| 30 | u32 cmd; /* 38 */ |
| 31 | u32 stat; /* 3c */ |
| 32 | u32 alnctl; /* 40 */ |
| 33 | u32 dchange; /* 44 */ |
| 34 | u32 cken; /* 48 */ |
| 35 | u32 ckstat; /* 4c */ |
| 36 | u32 systat; /* 50 */ |
| 37 | u32 ckctl; /* 54 */ |
| 38 | u32 resv3[2]; |
| 39 | u32 div4; /* 60 */ |
| 40 | u32 div5; /* 64 */ |
| 41 | u32 div6; /* 68 */ |
| 42 | u32 div7; /* 6c */ |
| 43 | u32 div8; /* 70 */ |
| 44 | u32 div9; /* 74 */ |
| 45 | u32 div10; /* 78 */ |
| 46 | u32 div11; /* 7c */ |
| 47 | u32 div12; /* 80 */ |
| 48 | }; |
| 49 | |
| 50 | static struct pllctl_regs *pllctl_regs[] = { |
Khoronzhuk, Ivan | d5cb1bb | 2014-07-09 23:44:44 +0300 | [diff] [blame] | 51 | (struct pllctl_regs *)(KS2_CLOCK_BASE + 0x100) |
Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | #define pllctl_reg(pll, reg) (&(pllctl_regs[pll]->reg)) |
| 55 | #define pllctl_reg_read(pll, reg) __raw_readl(pllctl_reg(pll, reg)) |
| 56 | #define pllctl_reg_write(pll, reg, val) __raw_writel(val, pllctl_reg(pll, reg)) |
| 57 | |
| 58 | #define pllctl_reg_rmw(pll, reg, mask, val) \ |
| 59 | pllctl_reg_write(pll, reg, \ |
| 60 | (pllctl_reg_read(pll, reg) & ~(mask)) | val) |
| 61 | |
| 62 | #define pllctl_reg_setbits(pll, reg, mask) \ |
| 63 | pllctl_reg_rmw(pll, reg, 0, mask) |
| 64 | |
| 65 | #define pllctl_reg_clrbits(pll, reg, mask) \ |
| 66 | pllctl_reg_rmw(pll, reg, mask, 0) |
| 67 | |
| 68 | #define pll0div_read(N) ((pllctl_reg_read(CORE_PLL, div##N) & 0xff) + 1) |
| 69 | |
Lokesh Vutla | 70438fc | 2015-07-28 14:16:43 +0530 | [diff] [blame] | 70 | /* PLLCTL Bits */ |
| 71 | #define PLLCTL_PLLENSRC_SHIF 5 |
| 72 | #define PLLCTL_PLLENSRC_MASK BIT(5) |
| 73 | #define PLLCTL_PLLRST_SHIFT 3 |
| 74 | #define PLLCTL_PLLRST_MASK BIT(3) |
| 75 | #define PLLCTL_PLLPWRDN_SHIFT 1 |
| 76 | #define PLLCTL_PLLPWRDN_MASK BIT(1) |
| 77 | #define PLLCTL_PLLEN_SHIFT 0 |
| 78 | #define PLLCTL_PLLEN_MASK BIT(0) |
| 79 | |
| 80 | /* SECCTL Bits */ |
| 81 | #define SECCTL_BYPASS_SHIFT 23 |
| 82 | #define SECCTL_BYPASS_MASK BIT(23) |
| 83 | #define SECCTL_OP_DIV_SHIFT 19 |
| 84 | #define SECCTL_OP_DIV_MASK (0xf << 19) |
| 85 | |
| 86 | /* PLLM Bits */ |
| 87 | #define PLLM_MULT_LO_SHIFT 0 |
| 88 | #define PLLM_MULT_LO_MASK 0x3f |
| 89 | #define PLLM_MULT_LO_BITS 6 |
| 90 | |
| 91 | /* PLLDIVn Bits */ |
| 92 | #define PLLDIV_ENABLE_SHIFT 15 |
| 93 | #define PLLDIV_ENABLE_MASK BIT(15) |
| 94 | #define PLLDIV_RATIO_SHIFT 0x0 |
| 95 | #define PLLDIV_RATIO_MASK 0xff |
| 96 | #define PLLDIV_MAX 16 |
| 97 | |
| 98 | /* PLLCMD Bits */ |
| 99 | #define PLLCMD_GOSET_SHIFT 0 |
| 100 | #define PLLCMD_GOSET_MASK BIT(0) |
| 101 | |
| 102 | /* PLLSTAT Bits */ |
| 103 | #define PLLSTAT_GOSTAT_SHIFT 0 |
| 104 | #define PLLSTAT_GOSTAT_MASK BIT(0) |
| 105 | |
| 106 | /* Device Config PLLCTL0 */ |
| 107 | #define CFG_PLLCTL0_BWADJ_SHIFT 24 |
| 108 | #define CFG_PLLCTL0_BWADJ_MASK (0xff << 24) |
| 109 | #define CFG_PLLCTL0_BWADJ_BITS 8 |
| 110 | #define CFG_PLLCTL0_BYPASS_SHIFT 23 |
| 111 | #define CFG_PLLCTL0_BYPASS_MASK BIT(23) |
| 112 | #define CFG_PLLCTL0_CLKOD_SHIFT 19 |
| 113 | #define CFG_PLLCTL0_CLKOD_MASK (0xf << 19) |
| 114 | #define CFG_PLLCTL0_PLLM_HI_SHIFT 12 |
| 115 | #define CFG_PLLCTL0_PLLM_HI_MASK (0x7f << 12) |
| 116 | #define CFG_PLLCTL0_PLLM_SHIFT 6 |
| 117 | #define CFG_PLLCTL0_PLLM_MASK (0x1fff << 6) |
| 118 | #define CFG_PLLCTL0_PLLD_SHIFT 0 |
| 119 | #define CFG_PLLCTL0_PLLD_MASK 0x3f |
| 120 | |
| 121 | /* Device Config PLLCTL1 */ |
| 122 | #define CFG_PLLCTL1_RST_SHIFT 14 |
| 123 | #define CFG_PLLCTL1_RST_MASK BIT(14) |
| 124 | #define CFG_PLLCTL1_PAPLL_SHIFT 13 |
| 125 | #define CFG_PLLCTL1_PAPLL_MASK BIT(13) |
| 126 | #define CFG_PLLCTL1_ENSAT_SHIFT 6 |
| 127 | #define CFG_PLLCTL1_ENSAT_MASK BIT(6) |
| 128 | #define CFG_PLLCTL1_BWADJ_SHIFT 0 |
| 129 | #define CFG_PLLCTL1_BWADJ_MASK 0xf |
| 130 | |
| 131 | #define MISC_CTL1_ARM_PLL_EN BIT(13) |
Vitaly Andrianov | 7bcf4d6 | 2014-04-04 13:16:53 -0400 | [diff] [blame] | 132 | |
| 133 | #endif /* _CLOCK_DEFS_H_ */ |