Marek Vasut | f670cd7 | 2022-05-21 16:56:26 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2022 Marek Vasut <marex@denx.de> |
| 4 | */ |
| 5 | |
Marek Vasut | f670cd7 | 2022-05-21 16:56:26 +0200 | [diff] [blame] | 6 | #include <asm/io.h> |
| 7 | #include <asm-generic/gpio.h> |
| 8 | |
| 9 | #include "lpddr4_timing.h" |
| 10 | |
| 11 | DECLARE_GLOBAL_DATA_PTR; |
| 12 | |
| 13 | u8 dh_get_memcfg(void) |
| 14 | { |
| 15 | struct gpio_desc gpio[4]; |
| 16 | u8 memcfg = 0; |
| 17 | ofnode node; |
| 18 | int i, ret; |
| 19 | |
| 20 | node = ofnode_path("/config"); |
| 21 | if (!ofnode_valid(node)) { |
| 22 | printf("%s: no /config node?\n", __func__); |
| 23 | return BIT(2) | BIT(0); |
| 24 | } |
| 25 | |
| 26 | ret = gpio_request_list_by_name_nodev(node, |
| 27 | "dh,ram-coding-gpios", |
| 28 | gpio, ARRAY_SIZE(gpio), |
| 29 | GPIOD_IS_IN); |
| 30 | for (i = 0; i < ret; i++) |
| 31 | memcfg |= !!dm_gpio_get_value(&(gpio[i])) << i; |
| 32 | |
| 33 | gpio_free_list_nodev(gpio, ret); |
| 34 | |
| 35 | return memcfg; |
| 36 | } |