xloader: Panda - clean small refactors and hang with spam_leds
[x-loader-sniper.git] / board / omap4430panda / omap4430panda.c
1 /*
2  * (C) Copyright 2004-2009
3  * Texas Instruments, <www.ti.com>
4  * Richard Woodruff <r-woodruff2@ti.com>
5  *
6  * See file CREDITS for list of people who contributed to this
7  * project.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23 #include <common.h>
24 #include <asm/arch/cpu.h>
25 #include <asm/io.h>
26 #include <asm/arch/bits.h>
27 #include <asm/arch/mux.h>
28 #include <asm/arch/sys_proto.h>
29 #include <asm/arch/sys_info.h>
30 #include <asm/arch/clocks.h>
31 #include <asm/arch/mem.h>
32 #include <i2c.h>
33 #if (CONFIG_COMMANDS & CFG_CMD_NAND) && defined(CFG_NAND_LEGACY)
34 #include <linux/mtd/nand_legacy.h>
35 #endif
36
37 /* EMIF and DMM registers */
38 #define EMIF1_BASE                      0x4c000000
39 #define EMIF2_BASE                      0x4d000000
40 #define DMM_BASE                        0x4e000000
41 /* EMIF */
42 #define EMIF_MOD_ID_REV                 0x0000
43 #define EMIF_STATUS                     0x0004
44 #define EMIF_SDRAM_CONFIG               0x0008
45 #define EMIF_LPDDR2_NVM_CONFIG          0x000C
46 #define EMIF_SDRAM_REF_CTRL             0x0010
47 #define EMIF_SDRAM_REF_CTRL_SHDW        0x0014
48 #define EMIF_SDRAM_TIM_1                0x0018
49 #define EMIF_SDRAM_TIM_1_SHDW           0x001C
50 #define EMIF_SDRAM_TIM_2                0x0020
51 #define EMIF_SDRAM_TIM_2_SHDW           0x0024
52 #define EMIF_SDRAM_TIM_3                0x0028
53 #define EMIF_SDRAM_TIM_3_SHDW           0x002C
54 #define EMIF_LPDDR2_NVM_TIM             0x0030
55 #define EMIF_LPDDR2_NVM_TIM_SHDW        0x0034
56 #define EMIF_PWR_MGMT_CTRL              0x0038
57 #define EMIF_PWR_MGMT_CTRL_SHDW         0x003C
58 #define EMIF_LPDDR2_MODE_REG_DATA       0x0040
59 #define EMIF_LPDDR2_MODE_REG_CFG        0x0050
60 #define EMIF_L3_CONFIG                  0x0054
61 #define EMIF_L3_CFG_VAL_1               0x0058
62 #define EMIF_L3_CFG_VAL_2               0x005C
63 #define IODFT_TLGC                      0x0060
64 #define EMIF_PERF_CNT_1                 0x0080
65 #define EMIF_PERF_CNT_2                 0x0084
66 #define EMIF_PERF_CNT_CFG               0x0088
67 #define EMIF_PERF_CNT_SEL               0x008C
68 #define EMIF_PERF_CNT_TIM               0x0090
69 #define EMIF_READ_IDLE_CTRL             0x0098
70 #define EMIF_READ_IDLE_CTRL_SHDW        0x009c
71 #define EMIF_ZQ_CONFIG                  0x00C8
72 #define EMIF_DDR_PHY_CTRL_1             0x00E4
73 #define EMIF_DDR_PHY_CTRL_1_SHDW        0x00E8
74 #define EMIF_DDR_PHY_CTRL_2             0x00EC
75
76 #define DMM_LISA_MAP_0                  0x0040
77 #define DMM_LISA_MAP_1                  0x0044
78 #define DMM_LISA_MAP_2                  0x0048
79 #define DMM_LISA_MAP_3                  0x004C
80
81 #define MR0_ADDR                        0
82 #define MR1_ADDR                        1
83 #define MR2_ADDR                        2
84 #define MR4_ADDR                        4
85 #define MR10_ADDR                       10
86 #define MR16_ADDR                       16
87 #define REF_EN                          0x40000000
88 /* defines for MR1 */
89 #define MR1_BL4                         2
90 #define MR1_BL8                         3
91 #define MR1_BL16                        4
92
93 #define MR1_BT_SEQ                      0
94 #define BT_INT                          1
95
96 #define MR1_WC                          0
97 #define MR1_NWC                         1
98
99 #define MR1_NWR3                        1
100 #define MR1_NWR4                        2
101 #define MR1_NWR5                        3
102 #define MR1_NWR6                        4
103 #define MR1_NWR7                        5
104 #define MR1_NWR8                        6
105
106 #define MR1_VALUE       ((MR1_NWR3 << 5) | (MR1_WC << 4) | (MR1_BT_SEQ << 3)  \
107                                                         | (MR1_BL8 << 0))
108
109 /* defines for MR2 */
110 #define MR2_RL3_WL1                     1
111 #define MR2_RL4_WL2                     2
112 #define MR2_RL5_WL2                     3
113 #define MR2_RL6_WL3                     4
114
115 /* defines for MR10 */
116 #define MR10_ZQINIT                     0xFF
117 #define MR10_ZQRESET                    0xC3
118 #define MR10_ZQCL                       0xAB
119 #define MR10_ZQCS                       0x56
120
121
122 /* TODO: FREQ update method is not working so shadow registers programming
123  * is just for same of completeness. This would be safer if auto
124  * trasnitions are working
125  */
126 #define FREQ_UPDATE_EMIF
127 /* EMIF Needs to be configured@19.2 MHz and shadow registers
128  * should be programmed for new OPP.
129  */
130 /* Elpida 2x2Gbit */
131 #define SDRAM_CONFIG_INIT               0x80800EB1
132 #define DDR_PHY_CTRL_1_INIT             0x849FFFF5
133 #define READ_IDLE_CTRL                  0x000501FF
134 #define PWR_MGMT_CTRL                   0x4000000f
135 #define PWR_MGMT_CTRL_OPP100            0x4000000f
136 #define ZQ_CONFIG                       0x500b3215
137
138 #define CS1_MR(mr)      ((mr) | 0x80000000)
139 struct ddr_regs{
140         u32 tim1;
141         u32 tim2;
142         u32 tim3;
143         u32 phy_ctrl_1;
144         u32 ref_ctrl;
145         u32 config_init;
146         u32 config_final;
147         u32 zq_config;
148         u8 mr1;
149         u8 mr2;
150 };
151 const struct ddr_regs ddr_regs_380_mhz = {
152         .tim1           = 0x10cb061a,
153         .tim2           = 0x20350d52,
154         .tim3           = 0x00b1431f,
155         .phy_ctrl_1     = 0x849FF408,
156         .ref_ctrl       = 0x000005ca,
157         .config_init    = 0x80000eb1,
158         .config_final   = 0x80001ab1,
159         .zq_config      = 0x500b3215,
160         .mr1            = 0x83,
161         .mr2            = 0x4
162 };
163
164 /*
165  * Unused timings - but we may need them later
166  * Keep them commented
167  */
168 #if 0
169 const struct ddr_regs ddr_regs_400_mhz = {
170         .tim1           = 0x10eb065a,
171         .tim2           = 0x20370dd2,
172         .tim3           = 0x00b1c33f,
173         .phy_ctrl_1     = 0x849FF408,
174         .ref_ctrl       = 0x00000618,
175         .config_init    = 0x80000eb1,
176         .config_final   = 0x80001ab1,
177         .zq_config      = 0x500b3215,
178         .mr1            = 0x83,
179         .mr2            = 0x4
180 };
181
182 const struct ddr_regs ddr_regs_200_mhz = {
183         .tim1           = 0x08648309,
184         .tim2           = 0x101b06ca,
185         .tim3           = 0x0048a19f,
186         .phy_ctrl_1     = 0x849FF405,
187         .ref_ctrl       = 0x0000030c,
188         .config_init    = 0x80000eb1,
189         .config_final   = 0x80000eb1,
190         .zq_config      = 0x500b3215,
191         .mr1            = 0x23,
192         .mr2            = 0x1
193 };
194 #endif
195
196 const struct ddr_regs ddr_regs_200_mhz_2cs = {
197         .tim1           = 0x08648309,
198         .tim2           = 0x101b06ca,
199         .tim3           = 0x0048a19f,
200         .phy_ctrl_1     = 0x849FF405,
201         .ref_ctrl       = 0x0000030c,
202         .config_init    = 0x80000eb9,
203         .config_final   = 0x80000eb9,
204         .zq_config      = 0xD00b3215,
205         .mr1            = 0x23,
206         .mr2            = 0x1
207 };
208
209 const struct ddr_regs ddr_regs_400_mhz_2cs = {
210         /* tRRD changed from 10ns to 12.5ns because of the tFAW requirement*/
211         .tim1           = 0x10eb0662,
212         .tim2           = 0x20370dd2,
213         .tim3           = 0x00b1c33f,
214         .phy_ctrl_1     = 0x849FF408,
215         .ref_ctrl       = 0x00000618,
216         .config_init    = 0x80000eb9,
217         .config_final   = 0x80001ab9,
218         .zq_config      = 0xD00b3215,
219         .mr1            = 0x83,
220         .mr2            = 0x4
221 };
222
223 /*******************************************************
224  * Routine: delay
225  * Description: spinning delay to use before udelay works
226  ******************************************************/
227 static inline void delay(unsigned long loops)
228 {
229         __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
230                           "bne 1b" : "=r" (loops) : "0"(loops));
231 }
232
233
234 void big_delay(unsigned int count)
235 {
236         int i;
237         for (i = 0; i < count; i++)
238                 delay(1);
239 }
240
241 void reset_phy(unsigned int base)
242 {
243         __raw_writel(__raw_readl(base + IODFT_TLGC) | (1 << 10),
244                                                              base + IODFT_TLGC);
245 }
246
247 /* this flashes the Panda LEDs forever, if called after muxconf */
248
249 void spam_leds(void)
250 {
251         unsigned int v = __raw_readl(OMAP44XX_GPIO_BASE1 + 0x134);
252
253         /* set both LED gpio to output */
254         __raw_writel((v & ~(0x03 << 7)), OMAP44XX_GPIO_BASE1 + 0x134);
255
256         v = __raw_readl(OMAP44XX_GPIO_BASE1 + 0x13c);
257         while (1) {
258                 __raw_writel((v & ~(0x03 << 7)), OMAP44XX_GPIO_BASE1 + 0x13c);
259                 big_delay(3000000);
260                 __raw_writel((v | (0x03 << 7)), OMAP44XX_GPIO_BASE1 + 0x13c);
261                 big_delay(3000000);
262         }
263 }
264
265 /* TODO: FREQ update method is not working so shadow registers programming
266  * is just for same of completeness. This would be safer if auto
267  * trasnitions are working
268  */
269 static int emif_config(unsigned int base)
270 {
271         const struct ddr_regs *ddr_regs = &ddr_regs_400_mhz_2cs;
272
273         switch (omap_revision()) {
274         case OMAP4430_ES1_0:
275                 ddr_regs = &ddr_regs_380_mhz;
276                 break;
277         case OMAP4430_ES2_0:
278                 ddr_regs = &ddr_regs_200_mhz_2cs;
279                 break;
280         }
281
282         /*
283          * set SDRAM CONFIG register
284          * EMIF_SDRAM_CONFIG[31:29] REG_SDRAM_TYPE = 4 for LPDDR2-S4
285          * EMIF_SDRAM_CONFIG[28:27] REG_IBANK_POS = 0
286          * EMIF_SDRAM_CONFIG[13:10] REG_CL = 3
287          * EMIF_SDRAM_CONFIG[6:4] REG_IBANK = 3 - 8 banks
288          * EMIF_SDRAM_CONFIG[3] REG_EBANK = 0 - CS0
289          * EMIF_SDRAM_CONFIG[2:0] REG_PAGESIZE = 2  - 512- 9 column
290          * JDEC specs - S4-2Gb --8 banks -- R0-R13, C0-c8
291          */
292         __raw_writel(__raw_readl(base + EMIF_LPDDR2_NVM_CONFIG) & 0xbfffffff,
293                                                  base + EMIF_LPDDR2_NVM_CONFIG);
294         __raw_writel(ddr_regs->config_init, base + EMIF_SDRAM_CONFIG);
295
296         /* PHY control values */
297         __raw_writel(DDR_PHY_CTRL_1_INIT, base + EMIF_DDR_PHY_CTRL_1);
298         __raw_writel(ddr_regs->phy_ctrl_1, base + EMIF_DDR_PHY_CTRL_1_SHDW);
299
300         /*
301          * EMIF_READ_IDLE_CTRL
302          */
303         __raw_writel(READ_IDLE_CTRL, base + EMIF_READ_IDLE_CTRL);
304         __raw_writel(READ_IDLE_CTRL, base + EMIF_READ_IDLE_CTRL);
305
306         /*
307          * EMIF_SDRAM_TIM_1
308          */
309         __raw_writel(ddr_regs->tim1, base + EMIF_SDRAM_TIM_1);
310         __raw_writel(ddr_regs->tim1, base + EMIF_SDRAM_TIM_1_SHDW);
311
312         /*
313          * EMIF_SDRAM_TIM_2
314          */
315         __raw_writel(ddr_regs->tim2, base + EMIF_SDRAM_TIM_2);
316         __raw_writel(ddr_regs->tim2, base + EMIF_SDRAM_TIM_2_SHDW);
317
318         /*
319          * EMIF_SDRAM_TIM_3
320          */
321         __raw_writel(ddr_regs->tim3, base + EMIF_SDRAM_TIM_3);
322         __raw_writel(ddr_regs->tim3, base + EMIF_SDRAM_TIM_3_SHDW);
323
324         __raw_writel(ddr_regs->zq_config, base + EMIF_ZQ_CONFIG);
325
326         /*
327          * poll MR0 register (DAI bit)
328          * REG_CS[31] = 0 -- Mode register command to CS0
329          * REG_REFRESH_EN[30] = 1 -- Refresh enable after MRW
330          * REG_ADDRESS[7:0] = 00 -- Refresh enable after MRW
331          */
332
333         __raw_writel(MR0_ADDR, base + EMIF_LPDDR2_MODE_REG_CFG);
334
335         while (__raw_readl(base + EMIF_LPDDR2_MODE_REG_DATA) & 1)
336                 ;
337
338         __raw_writel(CS1_MR(MR0_ADDR), base + EMIF_LPDDR2_MODE_REG_CFG);
339
340         while (__raw_readl(base + EMIF_LPDDR2_MODE_REG_DATA) & 1)
341                 ;
342
343
344         /* set MR10 register */
345         __raw_writel(MR10_ADDR, base + EMIF_LPDDR2_MODE_REG_CFG);
346         __raw_writel(MR10_ZQINIT, base + EMIF_LPDDR2_MODE_REG_DATA);
347         __raw_writel(CS1_MR(MR10_ADDR), base + EMIF_LPDDR2_MODE_REG_CFG);
348         __raw_writel(MR10_ZQINIT, base + EMIF_LPDDR2_MODE_REG_DATA);
349
350         /* wait for tZQINIT=1us  */
351         delay(10);
352
353         /* set MR1 register */
354         __raw_writel(MR1_ADDR, base + EMIF_LPDDR2_MODE_REG_CFG);
355         __raw_writel(ddr_regs->mr1, base + EMIF_LPDDR2_MODE_REG_DATA);
356         __raw_writel(CS1_MR(MR1_ADDR), base + EMIF_LPDDR2_MODE_REG_CFG);
357         __raw_writel(ddr_regs->mr1, base + EMIF_LPDDR2_MODE_REG_DATA);
358
359         /* set MR2 register RL=6 for OPP100 */
360         __raw_writel(MR2_ADDR, base + EMIF_LPDDR2_MODE_REG_CFG);
361         __raw_writel(ddr_regs->mr2, base + EMIF_LPDDR2_MODE_REG_DATA);
362         __raw_writel(CS1_MR(MR2_ADDR), base + EMIF_LPDDR2_MODE_REG_CFG);
363         __raw_writel(ddr_regs->mr2, base + EMIF_LPDDR2_MODE_REG_DATA);
364
365         /* Set SDRAM CONFIG register again here with final RL-WL value */
366         __raw_writel(ddr_regs->config_final, base + EMIF_SDRAM_CONFIG);
367         __raw_writel(ddr_regs->phy_ctrl_1, base + EMIF_DDR_PHY_CTRL_1);
368
369         /*
370          * EMIF_SDRAM_REF_CTRL
371          * refresh rate = DDR_CLK / reg_refresh_rate
372          * 3.9 uS = (400MHz)    / reg_refresh_rate
373          */
374         __raw_writel(ddr_regs->ref_ctrl, base + EMIF_SDRAM_REF_CTRL);
375         __raw_writel(ddr_regs->ref_ctrl, base + EMIF_SDRAM_REF_CTRL_SHDW);
376
377         /* set MR16 register */
378         __raw_writel(MR16_ADDR | REF_EN, base + EMIF_LPDDR2_MODE_REG_CFG);
379         __raw_writel(0, base + EMIF_LPDDR2_MODE_REG_DATA);
380         __raw_writel(CS1_MR(MR16_ADDR | REF_EN),
381                                                base + EMIF_LPDDR2_MODE_REG_CFG);
382         __raw_writel(0, base + EMIF_LPDDR2_MODE_REG_DATA);
383
384         /* LPDDR2 init complete */
385
386         return 0;
387 }
388 /*****************************************
389  * Routine: ddr_init
390  * Description: Configure DDR
391  * EMIF1 -- CS0 -- DDR1 (256 MB)
392  * EMIF2 -- CS0 -- DDR2 (256 MB)
393  *****************************************/
394 static void ddr_init(void)
395 {
396         unsigned int base_addr;
397
398         switch (omap_revision()) {
399
400         case OMAP4430_ES1_0:
401                 /* Configurte the Control Module DDRIO device */
402                 __raw_writel(0x1c1c1c1c, 0x4A100638);
403                 __raw_writel(0x1c1c1c1c, 0x4A10063c);
404                 __raw_writel(0x1c1c1c1c, 0x4A100640);
405                 __raw_writel(0x1c1c1c1c, 0x4A100648);
406                 __raw_writel(0x1c1c1c1c, 0x4A10064c);
407                 __raw_writel(0x1c1c1c1c, 0x4A100650);
408                 /* LPDDR2IO set to NMOS PTV */
409                 __raw_writel(0x00ffc000, 0x4A100704);
410
411                 /* Both EMIFs 128 byte interleaved */
412                 __raw_writel(0x80540300, DMM_BASE + DMM_LISA_MAP_0);
413                 break;
414         case OMAP4430_ES2_0:
415                 __raw_writel(0x9e9e9e9e, 0x4A100638);
416                 __raw_writel(0x9e9e9e9e, 0x4A10063c);
417                 __raw_writel(0x9e9e9e9e, 0x4A100640);
418                 __raw_writel(0x9e9e9e9e, 0x4A100648);
419                 __raw_writel(0x9e9e9e9e, 0x4A10064c);
420                 __raw_writel(0x9e9e9e9e, 0x4A100650);
421                 /* LPDDR2IO set to NMOS PTV */
422                 __raw_writel(0x00ffc000, 0x4A100704);
423                 /* fall thru */
424         default:
425                 /* Both EMIFs 128 byte interleaved */
426                 __raw_writel(0x80640300, DMM_BASE + DMM_LISA_MAP_0);
427                 break;
428         }
429
430         /*
431          * DMM Configuration
432          */
433
434         __raw_writel(0x00000000, DMM_BASE + DMM_LISA_MAP_2);
435         __raw_writel(0xFF020100, DMM_BASE + DMM_LISA_MAP_3);
436
437         /* DDR needs to be initialised @ 19.2 MHz
438          * So put core DPLL in bypass mode
439          * Configure the Core DPLL but don't lock it
440          */
441         configure_core_dpll_no_lock();
442
443         /*
444          * the following is re-enabled because without the EMIF going idle,
445          * the shadow DPLL update scheme can delay for minutes until it is
446          * able to apply the new settings... it waits until EMIF idle.
447          *
448          * This is seen in the case the ROM enabled USB boot being tried before
449          * normal boot over MMC.
450          */
451
452         /* No IDLE: BUG in SDC */
453         sr32(CM_MEMIF_CLKSTCTRL, 0, 32, 0x2);
454         while ((__raw_readl(CM_MEMIF_CLKSTCTRL) & 0x700) != 0x700)
455                 ;
456
457         __raw_writel(0, EMIF1_BASE + EMIF_PWR_MGMT_CTRL);
458         __raw_writel(0, EMIF2_BASE + EMIF_PWR_MGMT_CTRL);
459
460         base_addr = EMIF1_BASE;
461         emif_config(base_addr);
462
463         /* Configure EMIF24D */
464         base_addr = EMIF2_BASE;
465         emif_config(base_addr);
466         /* Lock Core using shadow CM_SHADOW_FREQ_CONFIG1 */
467         lock_core_dpll_shadow();
468         /* TODO: SDC needs few hacks to get DDR freq update working */
469
470         /* Set DLL_OVERRIDE = 0 */
471         __raw_writel(0, CM_DLL_CTRL);
472
473         delay(200);
474
475         /* Check for DDR PHY ready for EMIF1 & EMIF2 */
476         while (!(__raw_readl(EMIF1_BASE + EMIF_STATUS) & 4) ||
477                                    !(__raw_readl(EMIF2_BASE + EMIF_STATUS) & 4))
478                 ;
479
480         /* Reprogram the DDR PYHY Control register */
481         /* PHY control values */
482
483         sr32(CM_MEMIF_EMIF_1_CLKCTRL, 0, 32, 0x1);
484         sr32(CM_MEMIF_EMIF_2_CLKCTRL, 0, 32, 0x1);
485
486         /* Put the Core Subsystem PD to ON State */
487
488         __raw_writel(0x80000000, EMIF1_BASE + EMIF_PWR_MGMT_CTRL);
489         __raw_writel(0x80000000, EMIF2_BASE + EMIF_PWR_MGMT_CTRL);
490
491         /* SYSTEM BUG:
492          * In n a specific situation, the OCP interface between the DMM and
493          * EMIF may hang.
494          * 1. A TILER port is used to perform 2D burst writes of
495          *       width 1 and height 8
496          * 2. ELLAn port is used to perform reads
497          * 3. All accesses are routed to the same EMIF controller
498          *
499          * Work around to avoid this issue REG_SYS_THRESH_MAX value should
500          * be kept higher than default 0x7. As per recommondation 0x0A will
501          * be used for better performance with REG_LL_THRESH_MAX = 0x00
502          */
503         if (omap_revision() == OMAP4430_ES1_0) {
504                 __raw_writel(0x0A0000FF, EMIF1_BASE + EMIF_L3_CONFIG);
505                 __raw_writel(0x0A0000FF, EMIF2_BASE + EMIF_L3_CONFIG);
506         }
507
508         /*
509          * DMM : DMM_LISA_MAP_0(Section_0)
510          * [31:24] SYS_ADDR             0x80
511          * [22:20] SYS_SIZE             0x7 - 2Gb
512          * [19:18] SDRC_INTLDMM         0x1 - 128 byte
513          * [17:16] SDRC_ADDRSPC         0x0
514          * [9:8] SDRC_MAP               0x3
515          * [7:0] SDRC_ADDR              0X0
516          */
517         reset_phy(EMIF1_BASE);
518         reset_phy(EMIF2_BASE);
519
520         __raw_writel(0, 0x80000000);
521         __raw_writel(0, 0x80000000);
522
523         /* MEMIF Clock Domain -> HW_AUTO */
524         sr32(CM_MEMIF_CLKSTCTRL, 0, 32, 0x3);
525 }
526 /*****************************************
527  * Routine: board_init
528  * Description: Early hardware init.
529  *****************************************/
530 int board_init(void)
531 {
532         unsigned int v;
533
534         /*
535          * If the ROM has started the OTG stuff, stop it and
536          * make it look as if uninitialized for Linux or U-Boot
537          */
538
539         /* hold OTG phy in reset */
540
541         v = __raw_readl(OMAP44XX_GPIO_BASE2 + 0x134);
542         __raw_writel((v & ~(0x01 << 30)), OMAP44XX_GPIO_BASE2 + 0x134);
543
544         v = __raw_readl(OMAP44XX_GPIO_BASE2 + 0x13c);
545         __raw_writel((v & ~(0x01 << 30)), OMAP44XX_GPIO_BASE2 + 0x13c);
546
547         /* kill USB PLL */
548
549         v = __raw_readl(0x4a008100 + 0x80);
550         __raw_writel((v & ~(7 << 0)) | 1, 0x4a008100 + 0x80);
551
552         return 0;
553 }
554
555 /*************************************************************
556  * Routine: get_mem_type(void) - returns the kind of memory connected
557  * to GPMC that we are trying to boot form. Uses SYS BOOT settings.
558  *************************************************************/
559 u32 get_mem_type(void)
560 {
561         /* no nand, so return GPMC_NONE */
562         return GPMC_NONE;
563 }
564
565 /*****************************************
566  * Routine: secure_unlock
567  * Description: Setup security registers for access
568  * (GP Device only)
569  *****************************************/
570 void secure_unlock_mem(void)
571 {
572         /* Permission values for registers -Full fledged permissions to all */
573         #define UNLOCK_1 0xFFFFFFFF
574         #define UNLOCK_2 0x00000000
575         #define UNLOCK_3 0x0000FFFF
576
577         /* Protection Module Register Target APE (PM_RT)*/
578         __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
579         __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
580         __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
581         __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
582
583         __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
584         __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
585         __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
586
587         __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
588         __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
589         __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
590         __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
591
592         /* IVA Changes */
593         __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
594         __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
595         __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
596
597         __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
598 }
599
600 /**********************************************************
601  * Routine: try_unlock_sram()
602  * Description: If chip is GP/EMU(special) type, unlock the SRAM for
603  *  general use.
604  ***********************************************************/
605 void try_unlock_memory(void)
606 {
607         /* if GP device unlock device SRAM for general use */
608         /* secure code breaks for Secure/Emulation device - HS/E/T*/
609 }
610
611
612 #if defined(CONFIG_MPU_600) || defined(CONFIG_MPU_1000)
613 static int scale_vcores(void)
614 {
615         unsigned int rev = omap_revision();
616         /* For VC bypass only VCOREx_CGF_FORCE  is necessary and
617          * VCOREx_CFG_VOLTAGE  changes can be discarded
618          */
619         /* PRM_VC_CFG_I2C_MODE */
620         __raw_writel(0, 0x4A307BA8);
621
622         /* PRM_VC_CFG_I2C_CLK */
623         __raw_writel(0x6026, 0x4A307BAC);
624
625         /* set VCORE1 force VSEL */
626         /* PRM_VC_VAL_BYPASS) */
627         if (rev == OMAP4430_ES1_0)
628                 __raw_writel(0x3B5512, 0x4A307BA0);
629         else
630                 __raw_writel(0x3A5512, 0x4A307BA0);
631
632         __raw_writel(__raw_readl(0x4A307BA0) | 0x1000000, 0x4A307BA0);
633         while (__raw_readl(0x4A307BA0) & 0x1000000)
634                 ;
635
636         /* PRM_IRQSTATUS_MPU */
637         __raw_writel(__raw_readl(0x4A306010), 0x4A306010);
638
639         /* FIXME: set VCORE2 force VSEL, Check the reset value */
640         /* PRM_VC_VAL_BYPASS) */
641         if (rev == OMAP4430_ES1_0)
642                 __raw_writel(0x315B12, 0x4A307BA0);
643         else
644                 __raw_writel(0x295B12, 0x4A307BA0);
645
646         __raw_writel(__raw_readl(0x4A307BA0) | 0x1000000, 0x4A307BA0);
647         while (__raw_readl(0x4A307BA0) & 0x1000000)
648                 ;
649
650         /* PRM_IRQSTATUS_MPU */
651         __raw_writel(__raw_readl(0x4A306010), 0x4A306010);
652
653         /*/set VCORE3 force VSEL */
654         /* PRM_VC_VAL_BYPASS */
655         switch (rev) {
656         case OMAP4430_ES1_0:
657                 __raw_writel(0x316112, 0x4A307BA0);
658                 break;
659         case OMAP4430_ES2_0:
660                 __raw_writel(0x296112, 0x4A307BA0);
661                 break;
662         case OMAP4430_ES2_1:
663                 __raw_writel(0x2A6112, 0x4A307BA0);
664                 break;
665         }
666         __raw_writel(__raw_readl(0x4A307BA0) | 0x1000000, 0x4A307BA0);
667         while (__raw_readl(0x4A307BA0) & 0x1000000)
668                 ;
669
670         /* PRM_IRQSTATUS_MPU */
671         __raw_writel(__raw_readl(0x4A306010), 0x4A306010);
672
673         return 0;
674 }
675 #endif
676
677 /**********************************************************
678  * Routine: s_init
679  * Description: Does early system init of muxing and clocks.
680  * - Called path is with SRAM stack.
681  **********************************************************/
682
683 void s_init(void)
684 {
685         unsigned int rev = omap_revision();
686
687         /*
688          * this is required to survive the muxconf in the case the ROM
689          * started up USB OTG
690          */
691         prcm_init();
692
693         set_muxconf_regs();
694
695         delay(100);
696
697         /* Writing to AuxCR in U-boot using SMI for GP/EMU DEV */
698         /* Currently SMI in Kernel on ES2 devices seems to have an isse
699          * Once that is resolved, we can postpone this config to kernel
700          */
701         /* setup_auxcr(get_device_type(), external_boot); */
702
703         ddr_init();
704
705 /* Set VCORE1 = 1.3 V, VCORE2 = VCORE3 = 1.21V */
706 #if defined(CONFIG_MPU_600) || defined(CONFIG_MPU_1000)
707         scale_vcores();
708 #endif
709
710         if (rev == OMAP4430_ES1_0)
711                 return;
712                 
713         if (__raw_readl(0x4805D138) & (1 << 22)) {
714                 /* enable software ioreq */
715                 sr32(0x4A30a31C, 8, 1, 0x1);
716                 /* set for sys_clk (38.4MHz) */
717                 sr32(0x4A30a31C, 1, 2, 0x0);
718                 /* set divisor to 2 */
719                 sr32(0x4A30a31C, 16, 4, 0x1);
720                 /* set the clock source to active */
721                 sr32(0x4A30a110, 0, 1, 0x1);
722                 /* enable clocks */
723                 sr32(0x4A30a110, 2, 2, 0x3);
724         } else {
725                 /* enable software ioreq */
726                 sr32(0x4A30a314, 8, 1, 0x1);
727                 /* set for PER_DPLL */
728                 sr32(0x4A30a314, 1, 2, 0x2);
729                 /* set divisor to 16 */
730                 sr32(0x4A30a314, 16, 4, 0xf);
731                 /* set the clock source to active */
732                 sr32(0x4A30a110, 0, 1, 0x1);
733                 /* enable clocks */
734                 sr32(0x4A30a110, 2, 2, 0x3);
735         }
736 }
737
738 /*******************************************************
739  * Routine: misc_init_r
740  * Description: Init ethernet (done here so udelay works)
741  ********************************************************/
742 int misc_init_r(void)
743 {
744         return 0;
745 }
746
747 /******************************************************
748  * Routine: wait_for_command_complete
749  * Description: Wait for posting to finish on watchdog
750  ******************************************************/
751 void wait_for_command_complete(unsigned int wd_base)
752 {
753         while (__raw_readl(wd_base + WWPS))
754                 ;
755 }
756
757 /*******************************************************************
758  * Routine:ether_init
759  * Description: take the Ethernet controller out of reset and wait
760  *                 for the EEPROM load to complete.
761  ******************************************************************/
762
763 /**********************************************
764  * Routine: dram_init
765  * Description: sets uboots idea of sdram size
766  **********************************************/
767 int dram_init(void)
768 {
769         return 0;
770 }
771
772 #define OMAP44XX_WKUP_CTRL_BASE 0x4A31E000
773
774 #if 1
775 #define M0_SAFE M0
776 #define M1_SAFE M1
777 #define M2_SAFE M2
778 #define M4_SAFE M4
779 #define M7_SAFE M7
780 #define M3_SAFE M3
781 #define M5_SAFE M5
782 #define M6_SAFE M6
783 #else
784 #define M0_SAFE M7
785 #define M1_SAFE M7
786 #define M2_SAFE M7
787 #define M4_SAFE M7
788 #define M7_SAFE M7
789 #define M3_SAFE M7
790 #define M5_SAFE M7
791 #define M6_SAFE M7
792 #endif
793 #define         MV(OFFSET, VALUE) \
794                         __raw_writew((VALUE), OMAP44XX_CTRL_BASE + (OFFSET));
795 #define         MV1(OFFSET, VALUE) \
796                       __raw_writew((VALUE), OMAP44XX_WKUP_CTRL_BASE + (OFFSET));
797
798 #define         CP(x)   (CONTROL_PADCONF_##x)
799 #define         WK(x)   (CONTROL_WKUP_##x)
800 /*
801  * IEN  - Input Enable
802  * IDIS - Input Disable
803  * PTD  - Pull type Down
804  * PTU  - Pull type Up
805  * DIS  - Pull type selection is inactive
806  * EN   - Pull type selection is active
807  * M0   - Mode 0
808  * The commented string gives the final mux configuration for that pin
809  */
810
811 struct omap4panda_mux {
812         unsigned int ads;
813         unsigned int value;
814 };
815
816 static const struct omap4panda_mux omap4panda_mux[] = {
817         { OMAP44XX_CTRL_BASE + CP(GPMC_AD0),
818                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_dat0 */ },
819         { OMAP44XX_CTRL_BASE + CP(GPMC_AD1),
820                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_dat1 */ },
821         { OMAP44XX_CTRL_BASE + CP(GPMC_AD2),
822                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_dat2 */ },
823         { OMAP44XX_CTRL_BASE + CP(GPMC_AD3),
824                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_dat3 */ },
825         { OMAP44XX_CTRL_BASE + CP(GPMC_AD4),
826                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_dat4 */ },
827         { OMAP44XX_CTRL_BASE + CP(GPMC_AD5),
828                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_dat5 */ },
829         { OMAP44XX_CTRL_BASE + CP(GPMC_AD6),
830                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_dat6 */ },
831         { OMAP44XX_CTRL_BASE + CP(GPMC_AD7),
832                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_dat7 */ },
833         { OMAP44XX_CTRL_BASE + CP(GPMC_AD8),
834                      PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M3  /* gpio_32 */ },
835         { OMAP44XX_CTRL_BASE + CP(GPMC_AD9),
836                                                 PTU | IEN | M3  /* gpio_33 */ },
837         { OMAP44XX_CTRL_BASE + CP(GPMC_AD10),
838                                                 PTU | IEN | M3  /* gpio_34 */ },
839         { OMAP44XX_CTRL_BASE + CP(GPMC_AD11),
840                                                 PTU | IEN | M3  /* gpio_35 */ },
841         { OMAP44XX_CTRL_BASE + CP(GPMC_AD12),
842                                                 PTU | IEN | M3  /* gpio_36 */ },
843         { OMAP44XX_CTRL_BASE + CP(GPMC_AD13),
844                       PTD | OFF_EN | OFF_PD | OFF_OUT_PTD | M3  /* gpio_37 */ },
845         { OMAP44XX_CTRL_BASE + CP(GPMC_AD14),
846                       PTD | OFF_EN | OFF_PD | OFF_OUT_PTD | M3  /* gpio_38 */ },
847         { OMAP44XX_CTRL_BASE + CP(GPMC_AD15),
848                       PTD | OFF_EN | OFF_PD | OFF_OUT_PTD | M3  /* gpio_39 */ },
849         { OMAP44XX_CTRL_BASE + CP(GPMC_A16), M3  /* gpio_40 */ },
850         { OMAP44XX_CTRL_BASE + CP(GPMC_A17), PTD | M3  /* gpio_41 */ },
851         { OMAP44XX_CTRL_BASE + CP(GPMC_A18),
852                     PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_row6 */ },
853         { OMAP44XX_CTRL_BASE + CP(GPMC_A19),
854                     PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_row7 */ },
855         { OMAP44XX_CTRL_BASE + CP(GPMC_A20),
856                                                       IEN | M3  /* gpio_44 */ },
857         { OMAP44XX_CTRL_BASE + CP(GPMC_A21), M3  /* gpio_45 */ },
858         { OMAP44XX_CTRL_BASE + CP(GPMC_A22), M3  /* gpio_46 */ },
859         { OMAP44XX_CTRL_BASE + CP(GPMC_A23),
860                                 OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_col7 */ },
861         { OMAP44XX_CTRL_BASE + CP(GPMC_A24), PTD | M3  /* gpio_48 */ },
862         { OMAP44XX_CTRL_BASE + CP(GPMC_A25), PTD | M3  /* gpio_49 */ },
863         { OMAP44XX_CTRL_BASE + CP(GPMC_NCS0), M3  /* gpio_50 */ },
864         { OMAP44XX_CTRL_BASE + CP(GPMC_NCS1), IEN | M3  /* gpio_51 */ },
865         { OMAP44XX_CTRL_BASE + CP(GPMC_NCS2), IEN | M3  /* gpio_52 */ },
866         { OMAP44XX_CTRL_BASE + CP(GPMC_NCS3), IEN | M3  /* gpio_53 */ },
867         { OMAP44XX_CTRL_BASE + CP(GPMC_NWP), M3  /* gpio_54 */ },
868         { OMAP44XX_CTRL_BASE + CP(GPMC_CLK), PTD | M3  /* gpio_55 */ },
869         { OMAP44XX_CTRL_BASE + CP(GPMC_NADV_ALE), M3  /* gpio_56 */ },
870         { OMAP44XX_CTRL_BASE + CP(GPMC_NOE),
871                       PTU | IEN | OFF_EN | OFF_OUT_PTD | M1  /* sdmmc2_clk */ },
872         { OMAP44XX_CTRL_BASE + CP(GPMC_NWE),
873                   PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* sdmmc2_cmd */ },
874         { OMAP44XX_CTRL_BASE + CP(GPMC_NBE0_CLE), M3  /* gpio_59 */ },
875         { OMAP44XX_CTRL_BASE + CP(GPMC_NBE1), PTD | M3  /* gpio_60 */ },
876         { OMAP44XX_CTRL_BASE + CP(GPMC_WAIT0), PTU | IEN | M3  /* gpio_61 */ },
877         { OMAP44XX_CTRL_BASE + CP(GPMC_WAIT1),
878                        PTD | OFF_EN | OFF_PD | OFF_OUT_PTD | M3 /* gpio_62 */ },
879         { OMAP44XX_CTRL_BASE + CP(C2C_DATA11), PTD | M3  /* gpio_100 */ },
880         { OMAP44XX_CTRL_BASE + CP(C2C_DATA12), PTD | IEN | M3  /* gpio_101 */ },
881         { OMAP44XX_CTRL_BASE + CP(C2C_DATA13), PTD | M3  /* gpio_102 */ },
882         { OMAP44XX_CTRL_BASE + CP(C2C_DATA14), M1  /* dsi2_te0 */ },
883         { OMAP44XX_CTRL_BASE + CP(C2C_DATA15), PTD | M3  /* gpio_104 */ },
884         { OMAP44XX_CTRL_BASE + CP(HDMI_HPD), M0  /* hdmi_hpd */ },
885         { OMAP44XX_CTRL_BASE + CP(HDMI_CEC), M0  /* hdmi_cec */ },
886         { OMAP44XX_CTRL_BASE + CP(HDMI_DDC_SCL), PTU | M0  /* hdmi_ddc_scl */ },
887         { OMAP44XX_CTRL_BASE + CP(HDMI_DDC_SDA),
888                                            PTU | IEN | M0  /* hdmi_ddc_sda */ },
889         { OMAP44XX_CTRL_BASE + CP(CSI21_DX0), IEN | M0  /* csi21_dx0 */ },
890         { OMAP44XX_CTRL_BASE + CP(CSI21_DY0), IEN | M0  /* csi21_dy0 */ },
891         { OMAP44XX_CTRL_BASE + CP(CSI21_DX1), IEN | M0  /* csi21_dx1 */ },
892         { OMAP44XX_CTRL_BASE + CP(CSI21_DY1), IEN | M0  /* csi21_dy1 */ },
893         { OMAP44XX_CTRL_BASE + CP(CSI21_DX2), IEN | M0  /* csi21_dx2 */ },
894         { OMAP44XX_CTRL_BASE + CP(CSI21_DY2), IEN | M0  /* csi21_dy2 */ },
895         { OMAP44XX_CTRL_BASE + CP(CSI21_DX3), PTD | M7  /* csi21_dx3 */ },
896         { OMAP44XX_CTRL_BASE + CP(CSI21_DY3), PTD | M7  /* csi21_dy3 */ },
897         { OMAP44XX_CTRL_BASE + CP(CSI21_DX4),
898                          PTD | OFF_EN | OFF_PD | OFF_IN | M7  /* csi21_dx4 */ },
899         { OMAP44XX_CTRL_BASE + CP(CSI21_DY4),
900                          PTD | OFF_EN | OFF_PD | OFF_IN | M7  /* csi21_dy4 */ },
901         { OMAP44XX_CTRL_BASE + CP(CSI22_DX0), IEN | M0  /* csi22_dx0 */ },
902         { OMAP44XX_CTRL_BASE + CP(CSI22_DY0), IEN | M0  /* csi22_dy0 */ },
903         { OMAP44XX_CTRL_BASE + CP(CSI22_DX1), IEN | M0  /* csi22_dx1 */ },
904         { OMAP44XX_CTRL_BASE + CP(CSI22_DY1), IEN | M0  /* csi22_dy1 */ },
905         { OMAP44XX_CTRL_BASE + CP(CAM_SHUTTER),
906                         OFF_EN | OFF_PD | OFF_OUT_PTD | M0  /* cam_shutter */ },
907         { OMAP44XX_CTRL_BASE + CP(CAM_STROBE),
908                          OFF_EN | OFF_PD | OFF_OUT_PTD | M0  /* cam_strobe */ },
909         { OMAP44XX_CTRL_BASE + CP(CAM_GLOBALRESET),
910                       PTD | OFF_EN | OFF_PD | OFF_OUT_PTD | M3  /* gpio_83 */ },
911         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_CLK),
912            PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_clk */ },
913         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_STP),
914                            OFF_EN | OFF_OUT_PTD | M4  /* usbb1_ulpiphy_stp */ },
915         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DIR),
916                  IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dir */ },
917         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_NXT),
918                  IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_nxt */ },
919         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DAT0),
920                 IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dat0 */ },
921         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DAT1),
922                 IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dat1 */ },
923         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DAT2),
924                 IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dat2 */ },
925         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DAT3),
926                 IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dat3 */ },
927         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DAT4),
928                 IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dat4 */ },
929         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DAT5),
930                 IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dat5 */ },
931         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DAT6),
932                 IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dat6 */ },
933         { OMAP44XX_CTRL_BASE + CP(USBB1_ULPITLL_DAT7),
934                 IEN | OFF_EN | OFF_PD | OFF_IN | M4  /* usbb1_ulpiphy_dat7 */ },
935         { OMAP44XX_CTRL_BASE + CP(USBB1_HSIC_DATA),
936                    IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* usbb1_hsic_data */ },
937         { OMAP44XX_CTRL_BASE + CP(USBB1_HSIC_STROBE),
938                  IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* usbb1_hsic_strobe */ },
939         { OMAP44XX_CTRL_BASE + CP(USBC1_ICUSB_DP),
940                                                IEN | M0  /* usbc1_icusb_dp */ },
941         { OMAP44XX_CTRL_BASE + CP(USBC1_ICUSB_DM),
942                                                IEN | M0  /* usbc1_icusb_dm */ },
943         { OMAP44XX_CTRL_BASE + CP(SDMMC1_CLK),
944                             PTU | OFF_EN | OFF_OUT_PTD | M0  /* sdmmc1_clk */ },
945         { OMAP44XX_CTRL_BASE + CP(SDMMC1_CMD),
946                   PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_cmd */ },
947         { OMAP44XX_CTRL_BASE + CP(SDMMC1_DAT0),
948                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_dat0 */ },
949         { OMAP44XX_CTRL_BASE + CP(SDMMC1_DAT1),
950                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_dat1 */ },
951         { OMAP44XX_CTRL_BASE + CP(SDMMC1_DAT2),
952                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_dat2 */ },
953         { OMAP44XX_CTRL_BASE + CP(SDMMC1_DAT3),
954                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_dat3 */ },
955         { OMAP44XX_CTRL_BASE + CP(SDMMC1_DAT4),
956                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_dat4 */ },
957         { OMAP44XX_CTRL_BASE + CP(SDMMC1_DAT5),
958                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_dat5 */ },
959         { OMAP44XX_CTRL_BASE + CP(SDMMC1_DAT6),
960                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_dat6 */ },
961         { OMAP44XX_CTRL_BASE + CP(SDMMC1_DAT7),
962                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc1_dat7 */ },
963         { OMAP44XX_CTRL_BASE + CP(ABE_MCBSP2_CLKX),
964                    IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* abe_mcbsp2_clkx */ },
965         { OMAP44XX_CTRL_BASE + CP(ABE_MCBSP2_DR),
966                          IEN | OFF_EN | OFF_OUT_PTD | M0  /* abe_mcbsp2_dr */ },
967         { OMAP44XX_CTRL_BASE + CP(ABE_MCBSP2_DX),
968                                OFF_EN | OFF_OUT_PTD | M0  /* abe_mcbsp2_dx */ },
969         { OMAP44XX_CTRL_BASE + CP(ABE_MCBSP2_FSX),
970                     IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* abe_mcbsp2_fsx */ },
971         { OMAP44XX_CTRL_BASE + CP(ABE_MCBSP1_CLKX),
972                                            IEN | M1  /* abe_slimbus1_clock */ },
973         { OMAP44XX_CTRL_BASE + CP(ABE_MCBSP1_DR),
974                                             IEN | M1  /* abe_slimbus1_data */ },
975         { OMAP44XX_CTRL_BASE + CP(ABE_MCBSP1_DX),
976                                OFF_EN | OFF_OUT_PTD | M0  /* abe_mcbsp1_dx */ },
977         { OMAP44XX_CTRL_BASE + CP(ABE_MCBSP1_FSX),
978                     IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* abe_mcbsp1_fsx */ },
979         { OMAP44XX_CTRL_BASE + CP(ABE_PDM_UL_DATA),
980              PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* abe_pdm_ul_data */ },
981         { OMAP44XX_CTRL_BASE + CP(ABE_PDM_DL_DATA),
982              PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* abe_pdm_dl_data */ },
983         { OMAP44XX_CTRL_BASE + CP(ABE_PDM_FRAME),
984                PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* abe_pdm_frame */ },
985         { OMAP44XX_CTRL_BASE + CP(ABE_PDM_LB_CLK),
986               PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* abe_pdm_lb_clk */ },
987         { OMAP44XX_CTRL_BASE + CP(ABE_CLKS),
988                     PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* abe_clks */ },
989         { OMAP44XX_CTRL_BASE + CP(ABE_DMIC_CLK1), M0  /* abe_dmic_clk1 */ },
990         { OMAP44XX_CTRL_BASE + CP(ABE_DMIC_DIN1),
991                                                 IEN | M0  /* abe_dmic_din1 */ },
992         { OMAP44XX_CTRL_BASE + CP(ABE_DMIC_DIN2),
993                                                 IEN | M0  /* abe_dmic_din2 */ },
994         { OMAP44XX_CTRL_BASE + CP(ABE_DMIC_DIN3),
995                                                 IEN | M0  /* abe_dmic_din3 */ },
996         { OMAP44XX_CTRL_BASE + CP(UART2_CTS), PTU | IEN | M0  /* uart2_cts */ },
997         { OMAP44XX_CTRL_BASE + CP(UART2_RTS), M0  /* uart2_rts */ },
998         { OMAP44XX_CTRL_BASE + CP(UART2_RX), PTU | IEN | M0  /* uart2_rx */ },
999         { OMAP44XX_CTRL_BASE + CP(UART2_TX), M0  /* uart2_tx */ },
1000         { OMAP44XX_CTRL_BASE + CP(HDQ_SIO), M3  /* gpio_127 */ },
1001         { OMAP44XX_CTRL_BASE + CP(I2C1_SCL), PTU | IEN | M0  /* i2c1_scl */ },
1002         { OMAP44XX_CTRL_BASE + CP(I2C1_SDA), PTU | IEN | M0  /* i2c1_sda */ },
1003         { OMAP44XX_CTRL_BASE + CP(I2C2_SCL), PTU | IEN | M0  /* i2c2_scl */ },
1004         { OMAP44XX_CTRL_BASE + CP(I2C2_SDA), PTU | IEN | M0  /* i2c2_sda */ },
1005         { OMAP44XX_CTRL_BASE + CP(I2C3_SCL), PTU | IEN | M0  /* i2c3_scl */ },
1006         { OMAP44XX_CTRL_BASE + CP(I2C3_SDA), PTU | IEN | M0  /* i2c3_sda */ },
1007         { OMAP44XX_CTRL_BASE + CP(I2C4_SCL), PTU | IEN | M0  /* i2c4_scl */ },
1008         { OMAP44XX_CTRL_BASE + CP(I2C4_SDA), PTU | IEN | M0  /* i2c4_sda */ },
1009         { OMAP44XX_CTRL_BASE + CP(MCSPI1_CLK),
1010                         IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* mcspi1_clk */ },
1011         { OMAP44XX_CTRL_BASE + CP(MCSPI1_SOMI),
1012                        IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* mcspi1_somi */ },
1013         { OMAP44XX_CTRL_BASE + CP(MCSPI1_SIMO),
1014                        IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* mcspi1_simo */ },
1015         { OMAP44XX_CTRL_BASE + CP(MCSPI1_CS0),
1016                   PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* mcspi1_cs0 */ },
1017         { OMAP44XX_CTRL_BASE + CP(MCSPI1_CS1),
1018                   PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M3  /* mcspi1_cs1 */ },
1019         { OMAP44XX_CTRL_BASE + CP(MCSPI1_CS2),
1020                               PTU | OFF_EN | OFF_OUT_PTU | M3  /* gpio_139 */ },
1021         { OMAP44XX_CTRL_BASE + CP(MCSPI1_CS3), PTU | IEN | M3  /* gpio_140 */ },
1022         { OMAP44XX_CTRL_BASE + CP(UART3_CTS_RCTX),
1023                                                PTU | IEN | M0  /* uart3_tx */ },
1024         { OMAP44XX_CTRL_BASE + CP(UART3_RTS_SD), M0  /* uart3_rts_sd */ },
1025         { OMAP44XX_CTRL_BASE + CP(UART3_RX_IRRX), IEN | M0  /* uart3_rx */ },
1026         { OMAP44XX_CTRL_BASE + CP(UART3_TX_IRTX), M0  /* uart3_tx */ },
1027         { OMAP44XX_CTRL_BASE + CP(SDMMC5_CLK),
1028                       PTU | IEN | OFF_EN | OFF_OUT_PTD | M0  /* sdmmc5_clk */ },
1029         { OMAP44XX_CTRL_BASE + CP(SDMMC5_CMD),
1030                   PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc5_cmd */ },
1031         { OMAP44XX_CTRL_BASE + CP(SDMMC5_DAT0),
1032                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc5_dat0 */ },
1033         { OMAP44XX_CTRL_BASE + CP(SDMMC5_DAT1),
1034                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc5_dat1 */ },
1035         { OMAP44XX_CTRL_BASE + CP(SDMMC5_DAT2),
1036                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc5_dat2 */ },
1037         { OMAP44XX_CTRL_BASE + CP(SDMMC5_DAT3),
1038                  PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* sdmmc5_dat3 */ },
1039         { OMAP44XX_CTRL_BASE + CP(MCSPI4_CLK),
1040                         IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* mcspi4_clk */ },
1041         { OMAP44XX_CTRL_BASE + CP(MCSPI4_SIMO),
1042                        IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* mcspi4_simo */ },
1043         { OMAP44XX_CTRL_BASE + CP(MCSPI4_SOMI),
1044                        IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* mcspi4_somi */ },
1045         { OMAP44XX_CTRL_BASE + CP(MCSPI4_CS0),
1046                   PTD | IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* mcspi4_cs0 */ },
1047         { OMAP44XX_CTRL_BASE + CP(UART4_RX), IEN | M0  /* uart4_rx */ },
1048         { OMAP44XX_CTRL_BASE + CP(UART4_TX), M0  /* uart4_tx */ },
1049         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_CLK),
1050                                                      IEN | M3  /* gpio_157 */ },
1051         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_STP),
1052                                                 IEN | M5  /* dispc2_data23 */ },
1053         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DIR),
1054                                                 IEN | M5  /* dispc2_data22 */ },
1055         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_NXT),
1056                                                 IEN | M5  /* dispc2_data21 */ },
1057         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DAT0),
1058                                                 IEN | M5  /* dispc2_data20 */ },
1059         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DAT1),
1060                                                 IEN | M5  /* dispc2_data19 */ },
1061         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DAT2),
1062                                                 IEN | M5  /* dispc2_data18 */ },
1063         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DAT3),
1064                                                 IEN | M5  /* dispc2_data15 */ },
1065         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DAT4),
1066                                                 IEN | M5  /* dispc2_data14 */ },
1067         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DAT5),
1068                                                 IEN | M5  /* dispc2_data13 */ },
1069         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DAT6),
1070                                                 IEN | M5  /* dispc2_data12 */ },
1071         { OMAP44XX_CTRL_BASE + CP(USBB2_ULPITLL_DAT7),
1072                                                 IEN | M5  /* dispc2_data11 */ },
1073         { OMAP44XX_CTRL_BASE + CP(USBB2_HSIC_DATA),
1074                               PTD | OFF_EN | OFF_OUT_PTU | M3  /* gpio_169 */ },
1075         { OMAP44XX_CTRL_BASE + CP(USBB2_HSIC_STROBE),
1076                               PTD | OFF_EN | OFF_OUT_PTU | M3  /* gpio_170 */ },
1077         { OMAP44XX_CTRL_BASE + CP(UNIPRO_TX0), PTD | IEN | M3  /* gpio_171 */ },
1078         { OMAP44XX_CTRL_BASE + CP(UNIPRO_TY0),
1079                                 OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_col1 */ },
1080         { OMAP44XX_CTRL_BASE + CP(UNIPRO_TX1),
1081                                 OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_col2 */ },
1082         { OMAP44XX_CTRL_BASE + CP(UNIPRO_TY1),
1083                                 OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_col3 */ },
1084         { OMAP44XX_CTRL_BASE + CP(UNIPRO_TX2), PTU | IEN | M3  /* gpio_0 */ },
1085         { OMAP44XX_CTRL_BASE + CP(UNIPRO_TY2), PTU | IEN | M3  /* gpio_1 */ },
1086         { OMAP44XX_CTRL_BASE + CP(UNIPRO_RX0),
1087                     PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_row0 */ },
1088         { OMAP44XX_CTRL_BASE + CP(UNIPRO_RY0),
1089                     PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_row1 */ },
1090         { OMAP44XX_CTRL_BASE + CP(UNIPRO_RX1),
1091                     PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_row2 */ },
1092         { OMAP44XX_CTRL_BASE + CP(UNIPRO_RY1),
1093                     PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_row3 */ },
1094         { OMAP44XX_CTRL_BASE + CP(UNIPRO_RX2),
1095                     PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_row4 */ },
1096         { OMAP44XX_CTRL_BASE + CP(UNIPRO_RY2),
1097                     PTU | IEN | OFF_EN | OFF_PD | OFF_IN | M1  /* kpd_row5 */ },
1098         { OMAP44XX_CTRL_BASE + CP(USBA0_OTG_CE),
1099                  PTD | OFF_EN | OFF_PD | OFF_OUT_PTD | M0  /* usba0_otg_ce */ },
1100         { OMAP44XX_CTRL_BASE + CP(USBA0_OTG_DP),
1101                       IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* usba0_otg_dp */ },
1102         { OMAP44XX_CTRL_BASE + CP(USBA0_OTG_DM),
1103                       IEN | OFF_EN | OFF_PD | OFF_IN | M0  /* usba0_otg_dm */ },
1104         { OMAP44XX_CTRL_BASE + CP(FREF_CLK1_OUT), M0  /* fref_clk1_out */ },
1105         { OMAP44XX_CTRL_BASE + CP(FREF_CLK2_OUT),
1106                                                PTD | IEN | M3  /* gpio_182 */ },
1107         { OMAP44XX_CTRL_BASE + CP(SYS_NIRQ1), PTU | IEN | M0  /* sys_nirq1 */ },
1108         { OMAP44XX_CTRL_BASE + CP(SYS_NIRQ2), PTU | IEN | M0  /* sys_nirq2 */ },
1109         { OMAP44XX_CTRL_BASE + CP(SYS_BOOT0), PTU | IEN | M3  /* gpio_184 */ },
1110         { OMAP44XX_CTRL_BASE + CP(SYS_BOOT1), M3  /* gpio_185 */ },
1111         { OMAP44XX_CTRL_BASE + CP(SYS_BOOT2), PTD | IEN | M3  /* gpio_186 */ },
1112         { OMAP44XX_CTRL_BASE + CP(SYS_BOOT3), M3  /* gpio_187 */ },
1113         { OMAP44XX_CTRL_BASE + CP(SYS_BOOT4), M3  /* gpio_188 */ },
1114         { OMAP44XX_CTRL_BASE + CP(SYS_BOOT5), PTD | IEN | M3  /* gpio_189 */ },
1115         { OMAP44XX_CTRL_BASE + CP(DPM_EMU0), IEN | M0  /* dpm_emu0 */ },
1116         { OMAP44XX_CTRL_BASE + CP(DPM_EMU1), IEN | M0  /* dpm_emu1 */ },
1117         { OMAP44XX_CTRL_BASE + CP(DPM_EMU2), IEN | M0  /* dpm_emu2 */ },
1118         { OMAP44XX_CTRL_BASE + CP(DPM_EMU3), IEN | M5  /* dispc2_data10 */ },
1119         { OMAP44XX_CTRL_BASE + CP(DPM_EMU4), IEN | M5  /* dispc2_data9 */ },
1120         { OMAP44XX_CTRL_BASE + CP(DPM_EMU5), IEN | M5  /* dispc2_data16 */ },
1121         { OMAP44XX_CTRL_BASE + CP(DPM_EMU6), IEN | M5  /* dispc2_data17 */ },
1122         { OMAP44XX_CTRL_BASE + CP(DPM_EMU7), IEN | M5  /* dispc2_hsync */ },
1123         { OMAP44XX_CTRL_BASE + CP(DPM_EMU8), IEN | M5  /* dispc2_pclk */ },
1124         { OMAP44XX_CTRL_BASE + CP(DPM_EMU9), IEN | M5  /* dispc2_vsync */ },
1125         { OMAP44XX_CTRL_BASE + CP(DPM_EMU10), IEN | M5  /* dispc2_de */ },
1126         { OMAP44XX_CTRL_BASE + CP(DPM_EMU11), IEN | M5  /* dispc2_data8 */ },
1127         { OMAP44XX_CTRL_BASE + CP(DPM_EMU12), IEN | M5  /* dispc2_data7 */ },
1128         { OMAP44XX_CTRL_BASE + CP(DPM_EMU13), IEN | M5  /* dispc2_data6 */ },
1129         { OMAP44XX_CTRL_BASE + CP(DPM_EMU14), IEN | M5  /* dispc2_data5 */ },
1130         { OMAP44XX_CTRL_BASE + CP(DPM_EMU15), IEN | M5  /* dispc2_data4 */ },
1131         { OMAP44XX_CTRL_BASE + CP(DPM_EMU16), M3  /* gpio_27 */ },
1132         { OMAP44XX_CTRL_BASE + CP(DPM_EMU17), IEN | M5  /* dispc2_data2 */ },
1133         { OMAP44XX_CTRL_BASE + CP(DPM_EMU18), IEN | M5  /* dispc2_data1 */ },
1134         { OMAP44XX_CTRL_BASE + CP(DPM_EMU19), IEN | M5  /* dispc2_data0 */ },
1135         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_SIM_IO), IEN | M0  /* sim_io */ },
1136         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_SIM_CLK), M0  /* sim_clk */ },
1137         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_SIM_RESET), M0  /* sim_reset */ },
1138         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_SIM_CD),
1139                                                  PTU | IEN | M0  /* sim_cd */ },
1140         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_SIM_PWRCTRL),
1141                                                         M0  /* sim_pwrctrl */ },
1142         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_SR_SCL),
1143                                                  PTU | IEN | M0  /* sr_scl */ },
1144         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_SR_SDA),
1145                                                  PTU | IEN | M0  /* sr_sda */ },
1146         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_FREF_XTAL_IN), M0  /* # */ },
1147         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_FREF_SLICER_IN),
1148                                                      M0  /* fref_slicer_in */ },
1149         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_FREF_CLK_IOREQ),
1150                                                      M0  /* fref_clk_ioreq */ },
1151         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_FREF_CLK0_OUT),
1152                                                     M2  /* sys_drm_msecure */ },
1153         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_FREF_CLK3_REQ),
1154                                                       PTU | IEN | M0  /* # */ },
1155         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_FREF_CLK3_OUT),
1156                                                       M0  /* fref_clk3_out */ },
1157         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_FREF_CLK4_REQ),
1158                                                       PTU | IEN | M0  /* # */ },
1159         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_FREF_CLK4_OUT), M0  /* # */ },
1160         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_SYS_32K), IEN | M0  /* sys_32k */ },
1161         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_SYS_NRESPWRON),
1162                                                       M0  /* sys_nrespwron */ },
1163         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_SYS_NRESWARM),
1164                                                        M0  /* sys_nreswarm */ },
1165         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_SYS_PWR_REQ),
1166                                                   PTU | M0  /* sys_pwr_req */ },
1167         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_SYS_PWRON_RESET),
1168                                                           M3  /* gpio_wk29 */ },
1169         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_SYS_BOOT6),
1170                                                      IEN | M3  /* gpio_wk9 */ },
1171         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_SYS_BOOT7),
1172                                                     IEN | M3  /* gpio_wk10 */ },
1173         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_FREF_CLK3_REQ),
1174                                                            M3 /* gpio_wk30 */ },
1175         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD1_FREF_CLK4_REQ), M3 /* gpio_wk7 */ },
1176         { OMAP44XX_WKUP_CTRL_BASE + WK(PAD0_FREF_CLK4_OUT), M3 /* gpio_wk8 */ },
1177 };
1178
1179 /**********************************************************
1180  * Routine: set_muxconf_regs
1181  * Description: Setting up the configuration Mux registers
1182  *              specific to the hardware. Many pins need
1183  *              to be moved from protect to primary mode.
1184  *********************************************************/
1185 void set_muxconf_regs(void)
1186 {
1187         int n;
1188
1189         for (n = 0; n < sizeof omap4panda_mux / sizeof omap4panda_mux[0]; n++)
1190                 __raw_writew(omap4panda_mux[n].value, omap4panda_mux[n].ads);
1191 }
1192
1193 /******************************************************************************
1194  * Routine: update_mux()
1195  * Description:Update balls which are different between boards.  All should be
1196  *             updated to match functionality.  However, I'm only updating ones
1197  *             which I'll be using for now.  When power comes into play they
1198  *             all need updating.
1199  *****************************************************************************/
1200 void update_mux(u32 btype, u32 mtype)
1201 {
1202         /* REVISIT  */
1203 }
1204
1205 void board_hang(void)
1206 {
1207         spam_leds();
1208 }
1209
1210 int nand_init(void)
1211 {
1212         return 0;
1213 }