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