blob: 41cdd0e59b75f30458bc1652c67e3ae437cafa13 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +08002/*
3 * (C) Copyright 2009 Faraday Technology
4 * Po-Yu Chuang <ratbert@faraday-tech.com>
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +08005 */
6
7#include <config.h>
8#include <common.h>
9#include <asm/io.h>
Macpaul Lin00d10eb2011-04-15 21:37:11 +000010#include <faraday/ftsmc020.h>
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +080011
12struct ftsmc020_config {
13 unsigned int config;
14 unsigned int timing;
15};
16
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +080017static void ftsmc020_setup_bank(unsigned int bank, struct ftsmc020_config *cfg)
18{
Macpaul Linf194f6b2011-05-01 22:17:29 +000019 struct ftsmc020 *smc = (struct ftsmc020 *)CONFIG_FTSMC020_BASE;
20
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +080021 if (bank > 3) {
22 printf("bank # %u invalid\n", bank);
23 return;
24 }
25
26 writel(cfg->config, &smc->bank[bank].cr);
27 writel(cfg->timing, &smc->bank[bank].tpr);
28}
29
30void ftsmc020_init(void)
31{
Macpaul Linf194f6b2011-05-01 22:17:29 +000032 struct ftsmc020_config config[] = CONFIG_SYS_FTSMC020_CONFIGS;
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +080033 int i;
34
35 for (i = 0; i < ARRAY_SIZE(config); i++)
36 ftsmc020_setup_bank(i, &config[i]);
37}