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