Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | 9d6652c | 2016-09-17 03:33:09 +0900 | [diff] [blame] | 2 | * Copyright (C) 2013-2014 Panasonic Corporation |
| 3 | * Copyright (C) 2015-2016 Socionext Inc. |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
Masahiro Yamada | eb6aeca | 2017-01-21 18:05:25 +0900 | [diff] [blame] | 8 | #include <linux/delay.h> |
Masahiro Yamada | 663a23f | 2015-05-29 17:30:00 +0900 | [diff] [blame] | 9 | #include <linux/io.h> |
Masahiro Yamada | efdf340 | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 10 | |
| 11 | #include "../init.h" |
| 12 | #include "../sc-regs.h" |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 13 | |
Masahiro Yamada | 9d6652c | 2016-09-17 03:33:09 +0900 | [diff] [blame] | 14 | int uniphier_sld8_dpll_init(const struct uniphier_board_data *bd) |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 15 | { |
| 16 | u32 tmp; |
| 17 | /* |
| 18 | * Set DPLL SSC parameters for DPLLCTRL3 |
| 19 | * [23] DIVN_TEST 0x1 |
| 20 | * [22:16] DIVN 0x50 |
| 21 | * [10] FREFSEL_TEST 0x1 |
| 22 | * [9:8] FREFSEL 0x2 |
| 23 | * [4] ICPD_TEST 0x1 |
| 24 | * [3:0] ICPD 0xb |
| 25 | */ |
| 26 | tmp = readl(SC_DPLLCTRL3); |
| 27 | tmp &= ~0x00ff0717; |
| 28 | tmp |= 0x00d0061b; |
| 29 | writel(tmp, SC_DPLLCTRL3); |
| 30 | |
| 31 | /* |
| 32 | * Set DPLL SSC parameters for DPLLCTRL |
| 33 | * <-1%> <-2%> |
| 34 | * [29:20] SSC_UPCNT 132 (0x084) 132 (0x084) |
| 35 | * [14:0] SSC_dK 6335(0x18bf) 12710(0x31a6) |
| 36 | */ |
| 37 | tmp = readl(SC_DPLLCTRL); |
| 38 | tmp &= ~0x3ff07fff; |
Masahiro Yamada | ab61550 | 2016-09-17 03:33:08 +0900 | [diff] [blame] | 39 | #ifdef DPLL_SSC_RATE_1PER |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 40 | tmp |= 0x084018bf; |
| 41 | #else |
| 42 | tmp |= 0x084031a6; |
| 43 | #endif |
| 44 | writel(tmp, SC_DPLLCTRL); |
| 45 | |
| 46 | /* |
| 47 | * Set DPLL SSC parameters for DPLLCTRL2 |
| 48 | * [31:29] SSC_STEP 0 |
| 49 | * [27] SSC_REG_REF 1 |
| 50 | * [26:20] SSC_M 79 (0x4f) |
| 51 | * [19:0] SSC_K 964689 (0xeb851) |
| 52 | */ |
| 53 | tmp = readl(SC_DPLLCTRL2); |
| 54 | tmp &= ~0xefffffff; |
| 55 | tmp |= 0x0cfeb851; |
| 56 | writel(tmp, SC_DPLLCTRL2); |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 57 | |
Masahiro Yamada | 9d6652c | 2016-09-17 03:33:09 +0900 | [diff] [blame] | 58 | /* Wait 500 usec until dpll gets stable */ |
| 59 | udelay(500); |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 60 | |
| 61 | return 0; |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 62 | } |