Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Po-Yu Chuang | 43a5f0d | 2009-11-11 17:27:30 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2009 Faraday Technology |
| 4 | * Po-Yu Chuang <ratbert@faraday-tech.com> |
Po-Yu Chuang | 43a5f0d | 2009-11-11 17:27:30 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <config.h> |
| 8 | #include <common.h> |
| 9 | #include <asm/io.h> |
Macpaul Lin | 00d10eb | 2011-04-15 21:37:11 +0000 | [diff] [blame] | 10 | #include <faraday/ftsmc020.h> |
Po-Yu Chuang | 43a5f0d | 2009-11-11 17:27:30 +0800 | [diff] [blame] | 11 | |
| 12 | struct ftsmc020_config { |
| 13 | unsigned int config; |
| 14 | unsigned int timing; |
| 15 | }; |
| 16 | |
Po-Yu Chuang | 43a5f0d | 2009-11-11 17:27:30 +0800 | [diff] [blame] | 17 | static void ftsmc020_setup_bank(unsigned int bank, struct ftsmc020_config *cfg) |
| 18 | { |
Macpaul Lin | f194f6b | 2011-05-01 22:17:29 +0000 | [diff] [blame] | 19 | struct ftsmc020 *smc = (struct ftsmc020 *)CONFIG_FTSMC020_BASE; |
| 20 | |
Po-Yu Chuang | 43a5f0d | 2009-11-11 17:27:30 +0800 | [diff] [blame] | 21 | 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 | |
| 30 | void ftsmc020_init(void) |
| 31 | { |
Macpaul Lin | f194f6b | 2011-05-01 22:17:29 +0000 | [diff] [blame] | 32 | struct ftsmc020_config config[] = CONFIG_SYS_FTSMC020_CONFIGS; |
Po-Yu Chuang | 43a5f0d | 2009-11-11 17:27:30 +0800 | [diff] [blame] | 33 | int i; |
| 34 | |
| 35 | for (i = 0; i < ARRAY_SIZE(config); i++) |
| 36 | ftsmc020_setup_bank(i, &config[i]); |
| 37 | } |