Masahiro Yamada | fa71441 | 2015-07-21 14:04:22 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <linux/types.h> |
| 9 | #include <linux/sizes.h> |
| 10 | #include <mach/sg-regs.h> |
| 11 | |
| 12 | static inline u32 sg_memconf_val_ch2(unsigned long size, int num) |
| 13 | { |
| 14 | int size_mb = size / num; |
| 15 | u32 ret; |
| 16 | |
| 17 | switch (size_mb) { |
| 18 | case SZ_64M: |
| 19 | ret = SG_MEMCONF_CH2_SZ_64M; |
| 20 | break; |
| 21 | case SZ_128M: |
| 22 | ret = SG_MEMCONF_CH2_SZ_128M; |
| 23 | break; |
| 24 | case SZ_256M: |
| 25 | ret = SG_MEMCONF_CH2_SZ_256M; |
| 26 | break; |
| 27 | case SZ_512M: |
| 28 | ret = SG_MEMCONF_CH2_SZ_512M; |
| 29 | break; |
| 30 | default: |
| 31 | BUG(); |
| 32 | break; |
| 33 | } |
| 34 | |
| 35 | switch (num) { |
| 36 | case 1: |
| 37 | ret |= SG_MEMCONF_CH2_NUM_1; |
| 38 | break; |
| 39 | case 2: |
| 40 | ret |= SG_MEMCONF_CH2_NUM_2; |
| 41 | break; |
| 42 | default: |
| 43 | BUG(); |
| 44 | break; |
| 45 | } |
| 46 | return ret; |
| 47 | } |
| 48 | |
| 49 | u32 memconf_additional_val(void) |
| 50 | { |
| 51 | return sg_memconf_val_ch2(CONFIG_SDRAM2_SIZE, CONFIG_DDR_NUM_CH2); |
| 52 | } |