2015-09-22 00:27:41 +09:00
|
|
|
/*
|
|
|
|
* 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>
|
2016-01-09 01:51:13 +09:00
|
|
|
|
|
|
|
#include "../init.h"
|
|
|
|
#include "../sg-regs.h"
|
2015-09-22 00:27:41 +09:00
|
|
|
|
2016-03-30 20:17:02 +09:00
|
|
|
int uniphier_pxs2_memconf_init(const struct uniphier_board_data *bd)
|
2015-09-22 00:27:41 +09:00
|
|
|
{
|
|
|
|
u32 tmp;
|
|
|
|
unsigned long size_per_word;
|
|
|
|
|
|
|
|
tmp = readl(SG_MEMCONF);
|
|
|
|
|
|
|
|
tmp &= ~(SG_MEMCONF_CH2_SZ_MASK | SG_MEMCONF_CH2_NUM_MASK);
|
|
|
|
|
2016-02-26 14:21:34 +09:00
|
|
|
switch (bd->dram_ch[2].width) {
|
2015-09-22 00:27:41 +09:00
|
|
|
case 16:
|
|
|
|
tmp |= SG_MEMCONF_CH2_NUM_1;
|
2016-02-26 14:21:34 +09:00
|
|
|
size_per_word = bd->dram_ch[2].size;
|
2015-09-22 00:27:41 +09:00
|
|
|
break;
|
|
|
|
case 32:
|
|
|
|
tmp |= SG_MEMCONF_CH2_NUM_2;
|
2016-02-26 14:21:34 +09:00
|
|
|
size_per_word = bd->dram_ch[2].size >> 1;
|
2015-09-22 00:27:41 +09:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size_per_word)
|
|
|
|
tmp &= ~SG_MEMCONF_CH2_DISABLE;
|
|
|
|
else
|
|
|
|
tmp |= SG_MEMCONF_CH2_DISABLE;
|
|
|
|
|
|
|
|
writel(tmp, SG_MEMCONF);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|