0001
0002 #ifndef __ARCH_ARM_MACH_OMAP2_SDRC_H
0003 #define __ARCH_ARM_MACH_OMAP2_SDRC_H
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #undef DEBUG
0016
0017 #ifndef __ASSEMBLER__
0018
0019 #include <linux/io.h>
0020
0021 extern void __iomem *omap2_sdrc_base;
0022 extern void __iomem *omap2_sms_base;
0023
0024 #define OMAP_SDRC_REGADDR(reg) (omap2_sdrc_base + (reg))
0025 #define OMAP_SMS_REGADDR(reg) (omap2_sms_base + (reg))
0026
0027
0028
0029 static inline void sdrc_write_reg(u32 val, u16 reg)
0030 {
0031 writel_relaxed(val, OMAP_SDRC_REGADDR(reg));
0032 }
0033
0034 static inline u32 sdrc_read_reg(u16 reg)
0035 {
0036 return readl_relaxed(OMAP_SDRC_REGADDR(reg));
0037 }
0038
0039
0040
0041 static inline void sms_write_reg(u32 val, u16 reg)
0042 {
0043 writel_relaxed(val, OMAP_SMS_REGADDR(reg));
0044 }
0045
0046 static inline u32 sms_read_reg(u16 reg)
0047 {
0048 return readl_relaxed(OMAP_SMS_REGADDR(reg));
0049 }
0050
0051 extern void omap2_set_globals_sdrc(void __iomem *sdrc, void __iomem *sms);
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 struct omap_sdrc_params {
0068 unsigned long rate;
0069 u32 actim_ctrla;
0070 u32 actim_ctrlb;
0071 u32 rfr_ctrl;
0072 u32 mr;
0073 };
0074
0075 #ifdef CONFIG_SOC_HAS_OMAP2_SDRC
0076 void omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
0077 struct omap_sdrc_params *sdrc_cs1);
0078 #else
0079 static inline void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
0080 struct omap_sdrc_params *sdrc_cs1) {};
0081 #endif
0082
0083 int omap2_sdrc_get_params(unsigned long r,
0084 struct omap_sdrc_params **sdrc_cs0,
0085 struct omap_sdrc_params **sdrc_cs1);
0086 void omap2_sms_save_context(void);
0087 void omap2_sms_restore_context(void);
0088
0089 struct memory_timings {
0090 u32 m_type;
0091 u32 dll_mode;
0092 u32 slow_dll_ctrl;
0093 u32 fast_dll_ctrl;
0094 u32 base_cs;
0095 };
0096
0097 extern void omap2xxx_sdrc_init_params(u32 force_lock_to_unlock_mode);
0098 struct omap_sdrc_params *rx51_get_sdram_timings(void);
0099
0100 u32 omap2xxx_sdrc_dll_is_unlocked(void);
0101 u32 omap2xxx_sdrc_reprogram(u32 level, u32 force);
0102
0103
0104 #else
0105 #define OMAP242X_SDRC_REGADDR(reg) \
0106 OMAP2_L3_IO_ADDRESS(OMAP2420_SDRC_BASE + (reg))
0107 #define OMAP243X_SDRC_REGADDR(reg) \
0108 OMAP2_L3_IO_ADDRESS(OMAP243X_SDRC_BASE + (reg))
0109 #define OMAP34XX_SDRC_REGADDR(reg) \
0110 OMAP2_L3_IO_ADDRESS(OMAP343X_SDRC_BASE + (reg))
0111
0112 #endif
0113
0114
0115 #define MIN_SDRC_DLL_LOCK_FREQ 83000000
0116
0117
0118 #define SDRC_MPURATE_SCALE 8
0119
0120
0121 #define SDRC_MPURATE_BASE_SHIFT 9
0122
0123
0124
0125
0126
0127 #define SDRC_MPURATE_LOOPS 96
0128
0129
0130
0131 #define SDRC_SYSCONFIG 0x010
0132 #define SDRC_CS_CFG 0x040
0133 #define SDRC_SHARING 0x044
0134 #define SDRC_ERR_TYPE 0x04C
0135 #define SDRC_DLLA_CTRL 0x060
0136 #define SDRC_DLLA_STATUS 0x064
0137 #define SDRC_DLLB_CTRL 0x068
0138 #define SDRC_DLLB_STATUS 0x06C
0139 #define SDRC_POWER 0x070
0140 #define SDRC_MCFG_0 0x080
0141 #define SDRC_MR_0 0x084
0142 #define SDRC_EMR2_0 0x08c
0143 #define SDRC_ACTIM_CTRL_A_0 0x09c
0144 #define SDRC_ACTIM_CTRL_B_0 0x0a0
0145 #define SDRC_RFR_CTRL_0 0x0a4
0146 #define SDRC_MANUAL_0 0x0a8
0147 #define SDRC_MCFG_1 0x0B0
0148 #define SDRC_MR_1 0x0B4
0149 #define SDRC_EMR2_1 0x0BC
0150 #define SDRC_ACTIM_CTRL_A_1 0x0C4
0151 #define SDRC_ACTIM_CTRL_B_1 0x0C8
0152 #define SDRC_RFR_CTRL_1 0x0D4
0153 #define SDRC_MANUAL_1 0x0D8
0154
0155 #define SDRC_POWER_AUTOCOUNT_SHIFT 8
0156 #define SDRC_POWER_AUTOCOUNT_MASK (0xffff << SDRC_POWER_AUTOCOUNT_SHIFT)
0157 #define SDRC_POWER_CLKCTRL_SHIFT 4
0158 #define SDRC_POWER_CLKCTRL_MASK (0x3 << SDRC_POWER_CLKCTRL_SHIFT)
0159 #define SDRC_SELF_REFRESH_ON_AUTOCOUNT (0x2 << SDRC_POWER_CLKCTRL_SHIFT)
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185 #define SDRC_RFR_CTRL_165MHz (0x00044c00 | 1)
0186 #define SDRC_RFR_CTRL_133MHz (0x0003de00 | 1)
0187 #define SDRC_RFR_CTRL_100MHz (0x0002da01 | 1)
0188 #define SDRC_RFR_CTRL_110MHz (0x0002da01 | 1)
0189 #define SDRC_RFR_CTRL_BYPASS (0x00005000 | 1)
0190
0191
0192
0193
0194
0195
0196 #define OMAP242X_SMS_REGADDR(reg) \
0197 (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP2420_SMS_BASE + reg)
0198 #define OMAP243X_SMS_REGADDR(reg) \
0199 (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP243X_SMS_BASE + reg)
0200 #define OMAP343X_SMS_REGADDR(reg) \
0201 (void __iomem *)OMAP2_L3_IO_ADDRESS(OMAP343X_SMS_BASE + reg)
0202
0203
0204
0205 #define SMS_SYSCONFIG 0x010
0206
0207
0208
0209
0210 #endif