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