Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 2 | /* |
Masahiro Yamada | fa1f73f | 2016-07-19 21:56:13 +0900 | [diff] [blame] | 3 | * Copyright (C) 2014 Panasonic Corporation |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 4 | * Copyright (C) 2015-2017 Socionext Inc. |
Masahiro Yamada | fa1f73f | 2016-07-19 21:56:13 +0900 | [diff] [blame] | 5 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 6 | */ |
| 7 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <command.h> |
Masahiro Yamada | 609cd53 | 2017-10-13 19:21:55 +0900 | [diff] [blame] | 9 | #include <stdio.h> |
Masahiro Yamada | 663a23f | 2015-05-29 17:30:00 +0900 | [diff] [blame] | 10 | #include <linux/io.h> |
Masahiro Yamada | 609cd53 | 2017-10-13 19:21:55 +0900 | [diff] [blame] | 11 | #include <linux/printk.h> |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 12 | #include <linux/sizes.h> |
Masahiro Yamada | efdf340 | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 13 | |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 14 | #include "../soc-info.h" |
Masahiro Yamada | efdf340 | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 15 | #include "ddrphy-regs.h" |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 16 | |
| 17 | /* Select either decimal or hexadecimal */ |
| 18 | #if 1 |
| 19 | #define PRINTF_FORMAT "%2d" |
| 20 | #else |
| 21 | #define PRINTF_FORMAT "%02x" |
| 22 | #endif |
| 23 | /* field separator */ |
| 24 | #define FS " " |
| 25 | |
Masahiro Yamada | b5a8393 | 2016-10-27 23:47:09 +0900 | [diff] [blame] | 26 | #define ptr_to_uint(p) ((unsigned int)(unsigned long)(p)) |
| 27 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 28 | #define UNIPHIER_MAX_NR_DDRPHY 4 |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 29 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 30 | struct uniphier_ddrphy_param { |
| 31 | unsigned int soc_id; |
| 32 | unsigned int nr_phy; |
| 33 | struct { |
| 34 | resource_size_t base; |
| 35 | unsigned int nr_dx; |
| 36 | } phy[UNIPHIER_MAX_NR_DDRPHY]; |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 37 | }; |
| 38 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 39 | static const struct uniphier_ddrphy_param uniphier_ddrphy_param[] = { |
| 40 | { |
| 41 | .soc_id = UNIPHIER_LD4_ID, |
| 42 | .nr_phy = 2, |
| 43 | .phy = { |
| 44 | { .base = 0x5bc01000, .nr_dx = 2, }, |
| 45 | { .base = 0x5be01000, .nr_dx = 2, }, |
| 46 | }, |
| 47 | }, |
| 48 | { |
| 49 | .soc_id = UNIPHIER_PRO4_ID, |
| 50 | .nr_phy = 4, |
| 51 | .phy = { |
| 52 | { .base = 0x5bc01000, .nr_dx = 2, }, |
| 53 | { .base = 0x5bc02000, .nr_dx = 2, }, |
| 54 | { .base = 0x5be01000, .nr_dx = 2, }, |
| 55 | { .base = 0x5be02000, .nr_dx = 2, }, |
| 56 | }, |
| 57 | }, |
| 58 | { |
| 59 | .soc_id = UNIPHIER_SLD8_ID, |
| 60 | .nr_phy = 2, |
| 61 | .phy = { |
| 62 | { .base = 0x5bc01000, .nr_dx = 2, }, |
| 63 | { .base = 0x5be01000, .nr_dx = 2, }, |
| 64 | }, |
| 65 | }, |
| 66 | { |
| 67 | .soc_id = UNIPHIER_LD11_ID, |
| 68 | .nr_phy = 1, |
| 69 | .phy = { |
| 70 | { .base = 0x5bc01000, .nr_dx = 4, }, |
| 71 | }, |
| 72 | }, |
Masahiro Yamada | 913b3d0 | 2016-10-27 23:47:08 +0900 | [diff] [blame] | 73 | }; |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 74 | UNIPHIER_DEFINE_SOCDATA_FUNC(uniphier_get_ddrphy_param, uniphier_ddrphy_param) |
Masahiro Yamada | b5a8393 | 2016-10-27 23:47:09 +0900 | [diff] [blame] | 75 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 76 | static void print_bdl(void __iomem *reg, int n) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 77 | { |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 78 | u32 val = readl(reg); |
| 79 | int i; |
| 80 | |
| 81 | for (i = 0; i < n; i++) |
| 82 | printf(FS PRINTF_FORMAT, (val >> i * 6) & 0x3f); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 83 | } |
| 84 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 85 | static void dump_loop(const struct uniphier_ddrphy_param *param, |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 86 | void (*callback)(void __iomem *)) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 87 | { |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 88 | void __iomem *phy_base, *dx_base; |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 89 | int phy, dx; |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 90 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 91 | for (phy = 0; phy < param->nr_phy; phy++) { |
| 92 | phy_base = ioremap(param->phy[phy].base, SZ_4K); |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 93 | dx_base = phy_base + PHY_DX_BASE; |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 94 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 95 | for (dx = 0; dx < param->phy[phy].nr_dx; dx++) { |
| 96 | printf("PHY%dDX%d:", phy, dx); |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 97 | (*callback)(dx_base); |
| 98 | dx_base += PHY_DX_STRIDE; |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 99 | printf("\n"); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 100 | } |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 101 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 102 | iounmap(phy_base); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 106 | static void __wbdl_dump(void __iomem *dx_base) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 107 | { |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 108 | print_bdl(dx_base + PHY_DX_BDLR0, 5); |
| 109 | print_bdl(dx_base + PHY_DX_BDLR1, 5); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 110 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 111 | printf(FS "(+" PRINTF_FORMAT ")", |
| 112 | readl(dx_base + PHY_DX_LCDLR1) & 0xff); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 113 | } |
| 114 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 115 | static void wbdl_dump(const struct uniphier_ddrphy_param *param) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 116 | { |
| 117 | printf("\n--- Write Bit Delay Line ---\n"); |
| 118 | printf(" DQ0 DQ1 DQ2 DQ3 DQ4 DQ5 DQ6 DQ7 DM DQS (WDQD)\n"); |
| 119 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 120 | dump_loop(param, &__wbdl_dump); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 121 | } |
| 122 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 123 | static void __rbdl_dump(void __iomem *dx_base) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 124 | { |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 125 | print_bdl(dx_base + PHY_DX_BDLR3, 5); |
| 126 | print_bdl(dx_base + PHY_DX_BDLR4, 4); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 127 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 128 | printf(FS "(+" PRINTF_FORMAT ")", |
| 129 | (readl(dx_base + PHY_DX_LCDLR1) >> 8) & 0xff); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 130 | } |
| 131 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 132 | static void rbdl_dump(const struct uniphier_ddrphy_param *param) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 133 | { |
| 134 | printf("\n--- Read Bit Delay Line ---\n"); |
| 135 | printf(" DQ0 DQ1 DQ2 DQ3 DQ4 DQ5 DQ6 DQ7 DM (RDQSD)\n"); |
| 136 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 137 | dump_loop(param, &__rbdl_dump); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 138 | } |
| 139 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 140 | static void __wld_dump(void __iomem *dx_base) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 141 | { |
| 142 | int rank; |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 143 | u32 lcdlr0 = readl(dx_base + PHY_DX_LCDLR0); |
| 144 | u32 gtr = readl(dx_base + PHY_DX_GTR); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 145 | |
| 146 | for (rank = 0; rank < 4; rank++) { |
| 147 | u32 wld = (lcdlr0 >> (8 * rank)) & 0xff; /* Delay */ |
| 148 | u32 wlsl = (gtr >> (12 + 2 * rank)) & 0x3; /* System Latency */ |
| 149 | |
| 150 | printf(FS PRINTF_FORMAT "%sT", wld, |
| 151 | wlsl == 0 ? "-1" : wlsl == 1 ? "+0" : "+1"); |
| 152 | } |
| 153 | } |
| 154 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 155 | static void wld_dump(const struct uniphier_ddrphy_param *param) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 156 | { |
| 157 | printf("\n--- Write Leveling Delay ---\n"); |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 158 | printf(" Rank0 Rank1 Rank2 Rank3\n"); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 159 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 160 | dump_loop(param, &__wld_dump); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 161 | } |
| 162 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 163 | static void __dqsgd_dump(void __iomem *dx_base) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 164 | { |
| 165 | int rank; |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 166 | u32 lcdlr2 = readl(dx_base + PHY_DX_LCDLR2); |
| 167 | u32 gtr = readl(dx_base + PHY_DX_GTR); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 168 | |
| 169 | for (rank = 0; rank < 4; rank++) { |
| 170 | u32 dqsgd = (lcdlr2 >> (8 * rank)) & 0xff; /* Delay */ |
| 171 | u32 dgsl = (gtr >> (3 * rank)) & 0x7; /* System Latency */ |
| 172 | |
| 173 | printf(FS PRINTF_FORMAT "+%dT", dqsgd, dgsl); |
| 174 | } |
| 175 | } |
| 176 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 177 | static void dqsgd_dump(const struct uniphier_ddrphy_param *param) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 178 | { |
| 179 | printf("\n--- DQS Gating Delay ---\n"); |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 180 | printf(" Rank0 Rank1 Rank2 Rank3\n"); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 181 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 182 | dump_loop(param, &__dqsgd_dump); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 183 | } |
| 184 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 185 | static void __mdl_dump(void __iomem *dx_base) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 186 | { |
| 187 | int i; |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 188 | u32 mdl = readl(dx_base + PHY_DX_MDLR); |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 189 | |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 190 | for (i = 0; i < 3; i++) |
| 191 | printf(FS PRINTF_FORMAT, (mdl >> (8 * i)) & 0xff); |
| 192 | } |
| 193 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 194 | static void mdl_dump(const struct uniphier_ddrphy_param *param) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 195 | { |
| 196 | printf("\n--- Master Delay Line ---\n"); |
| 197 | printf(" IPRD TPRD MDLD\n"); |
| 198 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 199 | dump_loop(param, &__mdl_dump); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 200 | } |
| 201 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 202 | #define REG_DUMP(x) \ |
| 203 | { int ofst = PHY_ ## x; void __iomem *reg = phy_base + ofst; \ |
Masahiro Yamada | b5a8393 | 2016-10-27 23:47:09 +0900 | [diff] [blame] | 204 | printf("%3d: %-10s: %08x : %08x\n", \ |
| 205 | ofst >> PHY_REG_SHIFT, #x, \ |
| 206 | ptr_to_uint(reg), readl(reg)); } |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 207 | |
| 208 | #define DX_REG_DUMP(dx, x) \ |
| 209 | { int ofst = PHY_DX_BASE + PHY_DX_STRIDE * (dx) + \ |
| 210 | PHY_DX_## x; \ |
| 211 | void __iomem *reg = phy_base + ofst; \ |
Masahiro Yamada | b5a8393 | 2016-10-27 23:47:09 +0900 | [diff] [blame] | 212 | printf("%3d: DX%d%-7s: %08x : %08x\n", \ |
| 213 | ofst >> PHY_REG_SHIFT, (dx), #x, \ |
| 214 | ptr_to_uint(reg), readl(reg)); } |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 215 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 216 | static void reg_dump(const struct uniphier_ddrphy_param *param) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 217 | { |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 218 | void __iomem *phy_base; |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 219 | int phy, dx; |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 220 | |
| 221 | printf("\n--- DDR PHY registers ---\n"); |
| 222 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 223 | for (phy = 0; phy < param->nr_phy; phy++) { |
| 224 | phy_base = ioremap(param->phy[phy].base, SZ_4K); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 225 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 226 | printf("== PHY%d (base: %08x) ==\n", |
| 227 | phy, ptr_to_uint(phy_base)); |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 228 | printf(" No: Name : Address : Data\n"); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 229 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 230 | REG_DUMP(RIDR); |
| 231 | REG_DUMP(PIR); |
| 232 | REG_DUMP(PGCR0); |
| 233 | REG_DUMP(PGCR1); |
| 234 | REG_DUMP(PGSR0); |
| 235 | REG_DUMP(PGSR1); |
| 236 | REG_DUMP(PLLCR); |
| 237 | REG_DUMP(PTR0); |
| 238 | REG_DUMP(PTR1); |
| 239 | REG_DUMP(PTR2); |
| 240 | REG_DUMP(PTR3); |
| 241 | REG_DUMP(PTR4); |
| 242 | REG_DUMP(ACMDLR); |
| 243 | REG_DUMP(ACBDLR); |
| 244 | REG_DUMP(DXCCR); |
| 245 | REG_DUMP(DSGCR); |
| 246 | REG_DUMP(DCR); |
| 247 | REG_DUMP(DTPR0); |
| 248 | REG_DUMP(DTPR1); |
| 249 | REG_DUMP(DTPR2); |
| 250 | REG_DUMP(MR0); |
| 251 | REG_DUMP(MR1); |
| 252 | REG_DUMP(MR2); |
| 253 | REG_DUMP(MR3); |
| 254 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 255 | for (dx = 0; dx < param->phy[phy].nr_dx; dx++) { |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 256 | DX_REG_DUMP(dx, GCR); |
| 257 | DX_REG_DUMP(dx, GTR); |
| 258 | } |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 259 | |
Masahiro Yamada | b464ff9 | 2016-10-27 23:47:07 +0900 | [diff] [blame] | 260 | iounmap(phy_base); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 264 | static int do_ddr(struct cmd_tbl *cmdtp, int flag, int argc, |
| 265 | char *const argv[]) |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 266 | { |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 267 | const struct uniphier_ddrphy_param *param; |
| 268 | char *cmd; |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 269 | |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 270 | param = uniphier_get_ddrphy_param(); |
| 271 | if (!param) { |
Masahiro Yamada | 609cd53 | 2017-10-13 19:21:55 +0900 | [diff] [blame] | 272 | pr_err("unsupported SoC\n"); |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 273 | return CMD_RET_FAILURE; |
| 274 | } |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 275 | |
| 276 | if (argc == 1) |
| 277 | cmd = "all"; |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 278 | else |
| 279 | cmd = argv[1]; |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 280 | |
| 281 | if (!strcmp(cmd, "wbdl") || !strcmp(cmd, "all")) |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 282 | wbdl_dump(param); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 283 | |
| 284 | if (!strcmp(cmd, "rbdl") || !strcmp(cmd, "all")) |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 285 | rbdl_dump(param); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 286 | |
| 287 | if (!strcmp(cmd, "wld") || !strcmp(cmd, "all")) |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 288 | wld_dump(param); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 289 | |
| 290 | if (!strcmp(cmd, "dqsgd") || !strcmp(cmd, "all")) |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 291 | dqsgd_dump(param); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 292 | |
| 293 | if (!strcmp(cmd, "mdl") || !strcmp(cmd, "all")) |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 294 | mdl_dump(param); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 295 | |
| 296 | if (!strcmp(cmd, "reg") || !strcmp(cmd, "all")) |
Masahiro Yamada | 86f0d8c | 2017-01-28 06:53:45 +0900 | [diff] [blame] | 297 | reg_dump(param); |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 298 | |
Masahiro Yamada | 820353b | 2016-03-18 16:41:45 +0900 | [diff] [blame] | 299 | return CMD_RET_SUCCESS; |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | U_BOOT_CMD( |
| 303 | ddr, 2, 1, do_ddr, |
| 304 | "UniPhier DDR PHY parameters dumper", |
Masahiro Yamada | 7facf88 | 2016-08-21 16:12:36 +0900 | [diff] [blame] | 305 | "- dump all of the following\n" |
Masahiro Yamada | 8f899ed | 2014-12-19 20:20:53 +0900 | [diff] [blame] | 306 | "ddr wbdl - dump Write Bit Delay\n" |
| 307 | "ddr rbdl - dump Read Bit Delay\n" |
| 308 | "ddr wld - dump Write Leveling\n" |
| 309 | "ddr dqsgd - dump DQS Gating Delay\n" |
| 310 | "ddr mdl - dump Master Delay Line\n" |
| 311 | "ddr reg - dump registers\n" |
| 312 | ); |