Merge branch 'master' of git://git.denx.de/u-boot-nds32
[platform/kernel/u-boot.git] / drivers / mtd / ftsmc020.c
1 /*
2  * (C) Copyright 2009 Faraday Technology
3  * Po-Yu Chuang <ratbert@faraday-tech.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <config.h>
9 #include <common.h>
10 #include <asm/io.h>
11 #include <faraday/ftsmc020.h>
12
13 struct ftsmc020_config {
14         unsigned int    config;
15         unsigned int    timing;
16 };
17
18 static void ftsmc020_setup_bank(unsigned int bank, struct ftsmc020_config *cfg)
19 {
20         struct ftsmc020 *smc = (struct ftsmc020 *)CONFIG_FTSMC020_BASE;
21
22         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
31 void ftsmc020_init(void)
32 {
33         struct ftsmc020_config config[] = CONFIG_SYS_FTSMC020_CONFIGS;
34         int i;
35
36         for (i = 0; i < ARRAY_SIZE(config); i++)
37                 ftsmc020_setup_bank(i, &config[i]);
38 }