mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-07 05:13:21 +09:00
![Masahiro Yamada](/assets/img/avatar_default.png)
Before this commit, the Kconfig menu in mach-uniphier only allowed us to choose one SoC to be compiled. Each SoC has its own defconfig file for the build-test coverage. Consequently, some defconfig files are duplicated with only the difference in CONFIG_DEFAULT_DEVICE_TREE and CONFIG_{SOC_NAME}=y. Now, most of board-specific parameters have been moved to device trees, so it makes sense to include init code of multiple SoCs into a single image as long as the SoCs have similar architecture. In fact, some SoCs of UniPhier family are very similar: - PH1-LD4 and PH1-sLD8 - PH1-LD6b and ProXstream2 (will be added in the upcoming commit) This commit will be helpful to merge some defconfig files for better maintainability. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
/*
|
|
* Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <linux/err.h>
|
|
#include <linux/io.h>
|
|
#include <linux/sizes.h>
|
|
#include <mach/init.h>
|
|
#include <mach/sg-regs.h>
|
|
|
|
int ph1_sld3_memconf_init(const struct uniphier_board_data *bd)
|
|
{
|
|
u32 tmp;
|
|
unsigned long size_per_word;
|
|
|
|
tmp = readl(SG_MEMCONF);
|
|
|
|
tmp &= ~(SG_MEMCONF_CH2_SZ_MASK | SG_MEMCONF_CH2_NUM_MASK);
|
|
|
|
switch (bd->dram_ch2_width) {
|
|
case 16:
|
|
tmp |= SG_MEMCONF_CH2_NUM_1;
|
|
size_per_word = bd->dram_ch2_size;
|
|
break;
|
|
case 32:
|
|
tmp |= SG_MEMCONF_CH2_NUM_2;
|
|
size_per_word = bd->dram_ch2_size >> 1;
|
|
break;
|
|
default:
|
|
pr_err("error: unsupported DRAM Ch2 width\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
/* Set DDR size */
|
|
switch (size_per_word) {
|
|
case SZ_64M:
|
|
tmp |= SG_MEMCONF_CH2_SZ_64M;
|
|
break;
|
|
case SZ_128M:
|
|
tmp |= SG_MEMCONF_CH2_SZ_128M;
|
|
break;
|
|
case SZ_256M:
|
|
tmp |= SG_MEMCONF_CH2_SZ_256M;
|
|
break;
|
|
case SZ_512M:
|
|
tmp |= SG_MEMCONF_CH2_SZ_512M;
|
|
break;
|
|
default:
|
|
pr_err("error: unsupported DRAM Ch2 size\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
writel(tmp, SG_MEMCONF);
|
|
|
|
return 0;
|
|
}
|