blob: e2e8082270929e479deacfdd3352d8b9cd59afdf [file] [log] [blame]
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +08001/*
2 * (C) Copyright 2009 Faraday Technology
3 * Po-Yu Chuang <ratbert@faraday-tech.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +08006 */
7
8#include <config.h>
9#include <common.h>
10#include <asm/io.h>
Macpaul Lin00d10eb2011-04-15 21:37:11 +000011#include <faraday/ftsmc020.h>
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +080012
13struct ftsmc020_config {
14 unsigned int config;
15 unsigned int timing;
16};
17
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +080018static void ftsmc020_setup_bank(unsigned int bank, struct ftsmc020_config *cfg)
19{
Macpaul Linf194f6b2011-05-01 22:17:29 +000020 struct ftsmc020 *smc = (struct ftsmc020 *)CONFIG_FTSMC020_BASE;
21
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +080022 if (bank > 3) {
23 printf("bank # %u invalid\n", bank);
24 return;
25 }
26
27 writel(cfg->config, &smc->bank[bank].cr);
28 writel(cfg->timing, &smc->bank[bank].tpr);
29}
30
31void ftsmc020_init(void)
32{
Macpaul Linf194f6b2011-05-01 22:17:29 +000033 struct ftsmc020_config config[] = CONFIG_SYS_FTSMC020_CONFIGS;
Po-Yu Chuang43a5f0d2009-11-11 17:27:30 +080034 int i;
35
36 for (i = 0; i < ARRAY_SIZE(config); i++)
37 ftsmc020_setup_bank(i, &config[i]);
38}