aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/sam9_smc.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /arch/arm/mach-at91/sam9_smc.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'arch/arm/mach-at91/sam9_smc.c')
-rw-r--r--arch/arm/mach-at91/sam9_smc.c128
1 files changed, 21 insertions, 107 deletions
diff --git a/arch/arm/mach-at91/sam9_smc.c b/arch/arm/mach-at91/sam9_smc.c
index 99a0a1d2b7d..5eab6aa621d 100644
--- a/arch/arm/mach-at91/sam9_smc.c
+++ b/arch/arm/mach-at91/sam9_smc.c
@@ -2,7 +2,6 @@
2 * linux/arch/arm/mach-at91/sam9_smc.c 2 * linux/arch/arm/mach-at91/sam9_smc.c
3 * 3 *
4 * Copyright (C) 2008 Andrew Victor 4 * Copyright (C) 2008 Andrew Victor
5 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
6 * 5 *
7 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -11,123 +10,38 @@
11 10
12#include <linux/module.h> 11#include <linux/module.h>
13#include <linux/io.h> 12#include <linux/io.h>
14#include <linux/of.h>
15#include <linux/of_address.h>
16 13
17#include <mach/at91sam9_smc.h> 14#include <mach/at91sam9_smc.h>
18 15
19#include "sam9_smc.h" 16#include "sam9_smc.h"
20 17
21 18void __init sam9_smc_configure(int cs, struct sam9_smc_config* config)
22#define AT91_SMC_CS(id, n) (smc_base_addr[id] + ((n) * 0x10))
23
24static void __iomem *smc_base_addr[2];
25
26static void sam9_smc_cs_write_mode(void __iomem *base,
27 struct sam9_smc_config *config)
28{
29 __raw_writel(config->mode
30 | AT91_SMC_TDF_(config->tdf_cycles),
31 base + AT91_SMC_MODE);
32}
33
34void sam9_smc_write_mode(int id, int cs,
35 struct sam9_smc_config *config)
36{
37 sam9_smc_cs_write_mode(AT91_SMC_CS(id, cs), config);
38}
39
40static void sam9_smc_cs_configure(void __iomem *base,
41 struct sam9_smc_config *config)
42{
43
44 /* Setup register */
45 __raw_writel(AT91_SMC_NWESETUP_(config->nwe_setup)
46 | AT91_SMC_NCS_WRSETUP_(config->ncs_write_setup)
47 | AT91_SMC_NRDSETUP_(config->nrd_setup)
48 | AT91_SMC_NCS_RDSETUP_(config->ncs_read_setup),
49 base + AT91_SMC_SETUP);
50
51 /* Pulse register */
52 __raw_writel(AT91_SMC_NWEPULSE_(config->nwe_pulse)
53 | AT91_SMC_NCS_WRPULSE_(config->ncs_write_pulse)
54 | AT91_SMC_NRDPULSE_(config->nrd_pulse)
55 | AT91_SMC_NCS_RDPULSE_(config->ncs_read_pulse),
56 base + AT91_SMC_PULSE);
57
58 /* Cycle register */
59 __raw_writel(AT91_SMC_NWECYCLE_(config->write_cycle)
60 | AT91_SMC_NRDCYCLE_(config->read_cycle),
61 base + AT91_SMC_CYCLE);
62
63 /* Mode register */
64 sam9_smc_cs_write_mode(base, config);
65}
66
67void sam9_smc_configure(int id, int cs,
68 struct sam9_smc_config *config)
69{ 19{
70 sam9_smc_cs_configure(AT91_SMC_CS(id, cs), config);
71}
72
73static void sam9_smc_cs_read_mode(void __iomem *base,
74 struct sam9_smc_config *config)
75{
76 u32 val = __raw_readl(base + AT91_SMC_MODE);
77
78 config->mode = (val & ~AT91_SMC_NWECYCLE);
79 config->tdf_cycles = (val & AT91_SMC_NWECYCLE) >> 16 ;
80}
81
82void sam9_smc_read_mode(int id, int cs,
83 struct sam9_smc_config *config)
84{
85 sam9_smc_cs_read_mode(AT91_SMC_CS(id, cs), config);
86}
87
88static void sam9_smc_cs_read(void __iomem *base,
89 struct sam9_smc_config *config)
90{
91 u32 val;
92
93 /* Setup register */ 20 /* Setup register */
94 val = __raw_readl(base + AT91_SMC_SETUP); 21 at91_sys_write(AT91_SMC_SETUP(cs),
95 22 AT91_SMC_NWESETUP_(config->nwe_setup)
96 config->nwe_setup = val & AT91_SMC_NWESETUP; 23 | AT91_SMC_NCS_WRSETUP_(config->ncs_write_setup)
97 config->ncs_write_setup = (val & AT91_SMC_NCS_WRSETUP) >> 8; 24 | AT91_SMC_NRDSETUP_(config->nrd_setup)
98 config->nrd_setup = (val & AT91_SMC_NRDSETUP) >> 16; 25 | AT91_SMC_NCS_RDSETUP_(config->ncs_read_setup)
99 config->ncs_read_setup = (val & AT91_SMC_NCS_RDSETUP) >> 24; 26 );
100 27
101 /* Pulse register */ 28 /* Pulse register */
102 val = __raw_readl(base + AT91_SMC_PULSE); 29 at91_sys_write(AT91_SMC_PULSE(cs),
103 30 AT91_SMC_NWEPULSE_(config->nwe_pulse)
104 config->nwe_setup = val & AT91_SMC_NWEPULSE; 31 | AT91_SMC_NCS_WRPULSE_(config->ncs_write_pulse)
105 config->ncs_write_pulse = (val & AT91_SMC_NCS_WRPULSE) >> 8; 32 | AT91_SMC_NRDPULSE_(config->nrd_pulse)
106 config->nrd_pulse = (val & AT91_SMC_NRDPULSE) >> 16; 33 | AT91_SMC_NCS_RDPULSE_(config->ncs_read_pulse)
107 config->ncs_read_pulse = (val & AT91_SMC_NCS_RDPULSE) >> 24; 34 );
108 35
109 /* Cycle register */ 36 /* Cycle register */
110 val = __raw_readl(base + AT91_SMC_CYCLE); 37 at91_sys_write(AT91_SMC_CYCLE(cs),
111 38 AT91_SMC_NWECYCLE_(config->write_cycle)
112 config->write_cycle = val & AT91_SMC_NWECYCLE; 39 | AT91_SMC_NRDCYCLE_(config->read_cycle)
113 config->read_cycle = (val & AT91_SMC_NRDCYCLE) >> 16; 40 );
114 41
115 /* Mode register */ 42 /* Mode register */
116 sam9_smc_cs_read_mode(base, config); 43 at91_sys_write(AT91_SMC_MODE(cs),
117} 44 config->mode
118 45 | AT91_SMC_TDF_(config->tdf_cycles)
119void sam9_smc_read(int id, int cs, struct sam9_smc_config *config) 46 );
120{
121 sam9_smc_cs_read(AT91_SMC_CS(id, cs), config);
122}
123
124void __init at91sam9_ioremap_smc(int id, u32 addr)
125{
126 if (id > 1) {
127 pr_warn("%s: id > 2\n", __func__);
128 return;
129 }
130 smc_base_addr[id] = ioremap(addr, 512);
131 if (!smc_base_addr[id])
132 pr_warn("Impossible to ioremap smc.%d 0x%x\n", id, addr);
133} 47}