omap2420h4.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. /*
  2. * (C) Copyright 2004
  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 as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <asm/arch/omap2420.h>
  26. #include <asm/io.h>
  27. #include <asm/arch/bits.h>
  28. #include <asm/arch/mux.h>
  29. #include <asm/arch/sys_proto.h>
  30. #include <asm/arch/sys_info.h>
  31. #include <asm/arch/mem.h>
  32. #include <i2c.h>
  33. #include <asm/mach-types.h>
  34. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  35. #include <linux/mtd/nand.h>
  36. extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
  37. #endif
  38. static void wait_for_command_complete(unsigned int wd_base);
  39. /*******************************************************
  40. * Routine: delay
  41. * Description: spinning delay to use before udelay works
  42. ******************************************************/
  43. static inline void delay (unsigned long loops)
  44. {
  45. __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
  46. "bne 1b":"=r" (loops):"0" (loops));
  47. }
  48. /*****************************************
  49. * Routine: board_init
  50. * Description: Early hardware init.
  51. *****************************************/
  52. int board_init (void)
  53. {
  54. DECLARE_GLOBAL_DATA_PTR;
  55. gpmc_init(); /* in SRAM or SDRM, finish GPMC */
  56. gd->bd->bi_arch_number = MACH_TYPE_OMAP_H4; /* board id for linux */
  57. gd->bd->bi_boot_params = (OMAP2420_SDRC_CS0+0x100); /* adress of boot parameters */
  58. return 0;
  59. }
  60. /**********************************************************
  61. * Routine: s_init
  62. * Description: Does early system init of muxing and clocks.
  63. * - Called path is with sram stack.
  64. **********************************************************/
  65. void s_init(void)
  66. {
  67. int in_sdram = running_in_sdram();
  68. watchdog_init();
  69. set_muxconf_regs();
  70. delay(100);
  71. if(!in_sdram)
  72. prcm_init();
  73. peripheral_enable();
  74. icache_enable();
  75. if (!in_sdram)
  76. sdrc_init();
  77. }
  78. /*******************************************************
  79. * Routine: misc_init_r
  80. * Description: Init ethernet (done here so udelay works)
  81. ********************************************************/
  82. int misc_init_r (void)
  83. {
  84. ether_init(); /* better done here so timers are init'ed */
  85. return(0);
  86. }
  87. /****************************************
  88. * Routine: watchdog_init
  89. * Description: Shut down watch dogs
  90. *****************************************/
  91. void watchdog_init(void)
  92. {
  93. int mode;
  94. #define GP (BIT8|BIT9)
  95. /* There are 4 watch dogs. 1 secure, and 3 general purpose.
  96. * I would expect that the ROM takes care of the secure one,
  97. * but we will try also. Of the 3 GP ones, 1 can reset us
  98. * directly, the other 2 only generate MPU interrupts.
  99. */
  100. mode = (__raw_readl(CONTROL_STATUS) & (BIT8|BIT9));
  101. if (mode == GP) {
  102. __raw_writel(WD_UNLOCK1 ,WD1_BASE+WSPR);
  103. wait_for_command_complete(WD1_BASE);
  104. __raw_writel(WD_UNLOCK2 ,WD1_BASE+WSPR);
  105. }
  106. __raw_writel(WD_UNLOCK1 ,WD2_BASE+WSPR);
  107. wait_for_command_complete(WD2_BASE);
  108. __raw_writel(WD_UNLOCK2 ,WD2_BASE+WSPR);
  109. #if MPU_WD_CLOCKED /* value 0x10 stick on aptix, BIT4 polarity seems oppsite*/
  110. __raw_writel(WD_UNLOCK1 ,WD3_BASE+WSPR);
  111. wait_for_command_complete(WD3_BASE);
  112. __raw_writel(WD_UNLOCK2 ,WD3_BASE+WSPR);
  113. __raw_writel(WD_UNLOCK1 ,WD4_BASE+WSPR);
  114. wait_for_command_complete(WD4_BASE);
  115. __raw_writel(WD_UNLOCK2 ,WD4_BASE+WSPR);
  116. #endif
  117. }
  118. /******************************************************
  119. * Routine: wait_for_command_complete
  120. * Description: Wait for posting to finish on watchdog
  121. ******************************************************/
  122. static void wait_for_command_complete(unsigned int wd_base)
  123. {
  124. int pending = 1;
  125. do {
  126. pending = __raw_readl(wd_base+WWPS);
  127. } while (pending);
  128. }
  129. /*******************************************************************
  130. * Routine:ether_init
  131. * Description: take the Ethernet controller out of reset and wait
  132. * for the EEPROM load to complete.
  133. ******************************************************************/
  134. void ether_init (void)
  135. {
  136. #ifdef CONFIG_DRIVER_LAN91C96
  137. int cnt = 20;
  138. __raw_writeb(0x3,OMAP2420_CTRL_BASE+0x10a); /*protect->gpio95 */
  139. __raw_writew(0x0, LAN_RESET_REGISTER);
  140. do {
  141. __raw_writew(0x1, LAN_RESET_REGISTER);
  142. udelay (100);
  143. if (cnt == 0)
  144. goto h4reset_err_out;
  145. --cnt;
  146. } while (__raw_readw(LAN_RESET_REGISTER) != 0x1);
  147. cnt = 20;
  148. do {
  149. __raw_writew(0x0, LAN_RESET_REGISTER);
  150. udelay (100);
  151. if (cnt == 0)
  152. goto h4reset_err_out;
  153. --cnt;
  154. } while (__raw_readw(LAN_RESET_REGISTER) != 0x0000);
  155. udelay (1000);
  156. *((volatile unsigned char *) ETH_CONTROL_REG) &= ~0x01;
  157. udelay (1000);
  158. h4reset_err_out:
  159. return;
  160. #endif
  161. }
  162. /**********************************************
  163. * Routine: dram_init
  164. * Description: sets uboots idea of sdram size
  165. **********************************************/
  166. int dram_init (void)
  167. {
  168. DECLARE_GLOBAL_DATA_PTR;
  169. unsigned int size0=0,size1=0;
  170. u32 mtype, btype;
  171. u8 chg_on = 0x5; /* enable charge of back up battery */
  172. u8 vmode_on = 0x8C;
  173. #define NOT_EARLY 0
  174. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE); /* need this a bit early */
  175. btype = get_board_type();
  176. mtype = get_mem_type();
  177. display_board_info(btype);
  178. if (btype == BOARD_H4_MENELAUS){
  179. update_mux(btype,mtype); /* combo part on menelaus */
  180. i2c_write(I2C_MENELAUS, 0x20, 1, &chg_on, 1); /*fix POR reset bug */
  181. i2c_write(I2C_MENELAUS, 0x2, 1, &vmode_on, 1); /* VCORE change on VMODE */
  182. }
  183. if ((mtype == DDR_COMBO) || (mtype == DDR_STACKED)) {
  184. do_sdrc_init(SDRC_CS1_OSET, NOT_EARLY); /* init other chip select */
  185. size0 = size1 = SZ_32M;
  186. } else if (mtype == SDR_DISCRETE)
  187. size0 = SZ_128M;
  188. else
  189. size0 = SZ_64M;
  190. gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
  191. gd->bd->bi_dram[0].size = size0;
  192. gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
  193. gd->bd->bi_dram[1].size = size1;
  194. return 0;
  195. }
  196. /**********************************************************
  197. * Routine: set_muxconf_regs
  198. * Description: Setting up the configuration Mux registers
  199. * specific to the hardware
  200. *********************************************************/
  201. void set_muxconf_regs (void)
  202. {
  203. muxSetupSDRC();
  204. muxSetupGPMC();
  205. muxSetupUsb0();
  206. muxSetupUart3();
  207. muxSetupI2C1();
  208. muxSetupUART1();
  209. muxSetupLCD();
  210. muxSetupCamera();
  211. muxSetupMMCSD();
  212. muxSetupTouchScreen();
  213. muxSetupHDQ();
  214. }
  215. /*****************************************************************
  216. * Routine: peripheral_enable
  217. * Description: Enable the clks & power for perifs (GPT2, UART1,...)
  218. ******************************************************************/
  219. void peripheral_enable(void)
  220. {
  221. unsigned int v, if_clks=0, func_clks=0;
  222. /* Enable GP2 timer.*/
  223. if_clks |= BIT4;
  224. func_clks |= BIT4;
  225. v = __raw_readl(CM_CLKSEL2_CORE) | 0x4; /* Sys_clk input OMAP2420_GPT2 */
  226. __raw_writel(v, CM_CLKSEL2_CORE);
  227. __raw_writel(0x1, CM_CLKSEL_WKUP);
  228. #ifdef CFG_NS16550
  229. /* Enable UART1 clock */
  230. func_clks |= BIT21;
  231. if_clks |= BIT21;
  232. #endif
  233. v = __raw_readl(CM_ICLKEN1_CORE) | if_clks; /* Interface clocks on */
  234. __raw_writel(v,CM_ICLKEN1_CORE );
  235. v = __raw_readl(CM_FCLKEN1_CORE) | func_clks; /* Functional Clocks on */
  236. __raw_writel(v, CM_FCLKEN1_CORE);
  237. delay(1000);
  238. #ifndef KERNEL_UPDATED
  239. {
  240. #define V1 0xffffffff
  241. #define V2 0x00000007
  242. __raw_writel(V1, CM_FCLKEN1_CORE);
  243. __raw_writel(V2, CM_FCLKEN2_CORE);
  244. __raw_writel(V1, CM_ICLKEN1_CORE);
  245. __raw_writel(V1, CM_ICLKEN2_CORE);
  246. }
  247. #endif
  248. }
  249. /****************************************
  250. * Routine: muxSetupUsb0 (ostboot)
  251. * Description: Setup usb muxing
  252. *****************************************/
  253. void muxSetupUsb0(void)
  254. {
  255. volatile uint8 *MuxConfigReg;
  256. volatile uint32 *otgCtrlReg;
  257. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_PUEN;
  258. *MuxConfigReg &= (uint8)(~0x1F);
  259. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_VP;
  260. *MuxConfigReg &= (uint8)(~0x1F);
  261. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_VM;
  262. *MuxConfigReg &= (uint8)(~0x1F);
  263. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_RCV;
  264. *MuxConfigReg &= (uint8)(~0x1F);
  265. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_TXEN;
  266. *MuxConfigReg &= (uint8)(~0x1F);
  267. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_SE0;
  268. *MuxConfigReg &= (uint8)(~0x1F);
  269. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_USB0_DAT;
  270. *MuxConfigReg &= (uint8)(~0x1F);
  271. /* setup for USB VBus detection */
  272. otgCtrlReg = (volatile uint32 *)USB_OTG_CTRL;
  273. *otgCtrlReg |= 0x00040000; /* bit 18 */
  274. }
  275. /****************************************
  276. * Routine: muxSetupUart3 (ostboot)
  277. * Description: Setup uart3 muxing
  278. *****************************************/
  279. void muxSetupUart3(void)
  280. {
  281. volatile uint8 *MuxConfigReg;
  282. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_UART3_TX_IRTX;
  283. *MuxConfigReg &= (uint8)(~0x1F);
  284. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_UART3_RX_IRRX;
  285. *MuxConfigReg &= (uint8)(~0x1F);
  286. }
  287. /****************************************
  288. * Routine: muxSetupI2C1 (ostboot)
  289. * Description: Setup i2c muxing
  290. *****************************************/
  291. void muxSetupI2C1(void)
  292. {
  293. volatile unsigned char *MuxConfigReg;
  294. /* I2C1 Clock pin configuration, PIN = M19 */
  295. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_I2C1_SCL;
  296. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  297. /* I2C1 Data pin configuration, PIN = L15 */
  298. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_I2C1_SDA;
  299. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  300. /* Pull-up required on data line */
  301. /* external pull-up already present. */
  302. /* *MuxConfigReg |= 0x18 ;*/ /* Mode = 0, PullTypeSel=PU, PullUDEnable=Enabled */
  303. }
  304. /****************************************
  305. * Routine: muxSetupUART1 (ostboot)
  306. * Description: Set up uart1 muxing
  307. *****************************************/
  308. void muxSetupUART1(void)
  309. {
  310. volatile unsigned char *MuxConfigReg;
  311. /* UART1_CTS pin configuration, PIN = D21 */
  312. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_CTS;
  313. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  314. /* UART1_RTS pin configuration, PIN = H21 */
  315. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_RTS;
  316. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  317. /* UART1_TX pin configuration, PIN = L20 */
  318. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_TX;
  319. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  320. /* UART1_RX pin configuration, PIN = T21 */
  321. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_UART1_RX;
  322. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  323. }
  324. /****************************************
  325. * Routine: muxSetupLCD (ostboot)
  326. * Description: Setup lcd muxing
  327. *****************************************/
  328. void muxSetupLCD(void)
  329. {
  330. volatile unsigned char *MuxConfigReg;
  331. /* LCD_D0 pin configuration, PIN = Y7 */
  332. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D0;
  333. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  334. /* LCD_D1 pin configuration, PIN = P10 */
  335. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D1;
  336. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  337. /* LCD_D2 pin configuration, PIN = V8 */
  338. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D2;
  339. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  340. /* LCD_D3 pin configuration, PIN = Y8 */
  341. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D3;
  342. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  343. /* LCD_D4 pin configuration, PIN = W8 */
  344. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D4;
  345. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  346. /* LCD_D5 pin configuration, PIN = R10 */
  347. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D5;
  348. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  349. /* LCD_D6 pin configuration, PIN = Y9 */
  350. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D6;
  351. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  352. /* LCD_D7 pin configuration, PIN = V9 */
  353. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D7;
  354. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  355. /* LCD_D8 pin configuration, PIN = W9 */
  356. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D8;
  357. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  358. /* LCD_D9 pin configuration, PIN = P11 */
  359. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D9;
  360. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  361. /* LCD_D10 pin configuration, PIN = V10 */
  362. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D10;
  363. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  364. /* LCD_D11 pin configuration, PIN = Y10 */
  365. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D11;
  366. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  367. /* LCD_D12 pin configuration, PIN = W10 */
  368. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D12;
  369. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  370. /* LCD_D13 pin configuration, PIN = R11 */
  371. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D13;
  372. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  373. /* LCD_D14 pin configuration, PIN = V11 */
  374. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D14;
  375. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  376. /* LCD_D15 pin configuration, PIN = W11 */
  377. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D15;
  378. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  379. /* LCD_D16 pin configuration, PIN = P12 */
  380. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D16;
  381. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  382. /* LCD_D17 pin configuration, PIN = R12 */
  383. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_D17;
  384. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  385. /* LCD_PCLK pin configuration, PIN = W6 */
  386. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_PCLK;
  387. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  388. /* LCD_VSYNC pin configuration, PIN = V7 */
  389. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_VSYNC;
  390. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  391. /* LCD_HSYNC pin configuration, PIN = Y6 */
  392. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_HSYNC;
  393. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  394. /* LCD_ACBIAS pin configuration, PIN = W7 */
  395. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_DSS_ACBIAS;
  396. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  397. }
  398. /****************************************
  399. * Routine: muxSetupCamera (ostboot)
  400. * Description: Setup camera muxing
  401. *****************************************/
  402. void muxSetupCamera(void)
  403. {
  404. volatile unsigned char *MuxConfigReg;
  405. /* CAMERA_RSTZ pin configuration, PIN = Y16 */
  406. /* CAM_RST is connected through the I2C IO expander.*/
  407. /* MuxConfigReg = (volatile unsigned char *), CONTROL_PADCONF_SYS_NRESWARM*/
  408. /* *MuxConfigReg = 0x00 ; / * Mode = 0, PUPD=Disabled */
  409. /* CAMERA_XCLK pin configuration, PIN = U3 */
  410. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_XCLK;
  411. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  412. /* CAMERA_LCLK pin configuration, PIN = V5 */
  413. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_LCLK;
  414. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  415. /* CAMERA_VSYNC pin configuration, PIN = U2 */
  416. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_VS,
  417. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  418. /* CAMERA_HSYNC pin configuration, PIN = T3 */
  419. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_HS,
  420. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  421. /* CAMERA_DAT0 pin configuration, PIN = T4 */
  422. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D0,
  423. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  424. /* CAMERA_DAT1 pin configuration, PIN = V2 */
  425. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D1,
  426. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  427. /* CAMERA_DAT2 pin configuration, PIN = V3 */
  428. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D2,
  429. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  430. /* CAMERA_DAT3 pin configuration, PIN = U4 */
  431. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D3,
  432. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  433. /* CAMERA_DAT4 pin configuration, PIN = W2 */
  434. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D4,
  435. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  436. /* CAMERA_DAT5 pin configuration, PIN = V4 */
  437. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D5,
  438. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  439. /* CAMERA_DAT6 pin configuration, PIN = W3 */
  440. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D6,
  441. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  442. /* CAMERA_DAT7 pin configuration, PIN = Y2 */
  443. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D7,
  444. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  445. /* CAMERA_DAT8 pin configuration, PIN = Y4 */
  446. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D8,
  447. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  448. /* CAMERA_DAT9 pin configuration, PIN = V6 */
  449. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_CAM_D9,
  450. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  451. }
  452. /****************************************
  453. * Routine: muxSetupMMCSD (ostboot)
  454. * Description: set up MMC muxing
  455. *****************************************/
  456. void muxSetupMMCSD(void)
  457. {
  458. volatile unsigned char *MuxConfigReg;
  459. /* SDMMC_CLKI pin configuration, PIN = H15 */
  460. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CLKI,
  461. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  462. /* SDMMC_CLKO pin configuration, PIN = G19 */
  463. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CLKO,
  464. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  465. /* SDMMC_CMD pin configuration, PIN = H18 */
  466. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CMD,
  467. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  468. /* External pull-ups are present. */
  469. /* *MuxConfigReg |= 0x18 ; #/ PullUDEnable=Enabled, PullTypeSel=PU */
  470. /* SDMMC_DAT0 pin configuration, PIN = F20 */
  471. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT0,
  472. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  473. /* External pull-ups are present. */
  474. /* *MuxConfigReg |= 0x18 ; #/ PullUDEnable=Enabled, PullTypeSel=PU */
  475. /* SDMMC_DAT1 pin configuration, PIN = H14 */
  476. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT1,
  477. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  478. /* External pull-ups are present. */
  479. /* *MuxConfigReg |= 0x18 ; #/ PullUDEnable=Enabled, PullTypeSel=PU */
  480. /* SDMMC_DAT2 pin configuration, PIN = E19 */
  481. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT2,
  482. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  483. /* External pull-ups are present. */
  484. /* *MuxConfigReg |= 0x18 ; #/ PullUDEnable=Enabled, PullTypeSel=PU */
  485. /* SDMMC_DAT3 pin configuration, PIN = D19 */
  486. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT3,
  487. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  488. /* External pull-ups are present. */
  489. /* *MuxConfigReg |= 0x18 ; #/ PullUDEnable=Enabled, PullTypeSel=PU */
  490. /* SDMMC_DDIR0 pin configuration, PIN = F19 */
  491. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR0,
  492. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  493. /* SDMMC_DDIR1 pin configuration, PIN = E20 */
  494. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR1,
  495. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  496. /* SDMMC_DDIR2 pin configuration, PIN = F18 */
  497. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR2,
  498. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  499. /* SDMMC_DDIR3 pin configuration, PIN = E18 */
  500. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_DAT_DIR3,
  501. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  502. /* SDMMC_CDIR pin configuration, PIN = G18 */
  503. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MMC_CMD_DIR,
  504. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  505. /* MMC_CD pin configuration, PIN = B3 ---2420IP ONLY---*/
  506. /* MMC_CD for 2422IP=K1 */
  507. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SDRC_A14,
  508. *MuxConfigReg = 0x03 ; /* Mode = 3, PUPD=Disabled */
  509. /* MMC_WP pin configuration, PIN = B4 */
  510. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SDRC_A13,
  511. *MuxConfigReg = 0x03 ; /* Mode = 3, PUPD=Disabled */
  512. }
  513. /******************************************
  514. * Routine: muxSetupTouchScreen (ostboot)
  515. * Description: Set up touch screen muxing
  516. *******************************************/
  517. void muxSetupTouchScreen(void)
  518. {
  519. volatile unsigned char *MuxConfigReg;
  520. /* SPI1_CLK pin configuration, PIN = U18 */
  521. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_CLK,
  522. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  523. /* SPI1_MOSI pin configuration, PIN = V20 */
  524. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_SIMO,
  525. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  526. /* SPI1_MISO pin configuration, PIN = T18 */
  527. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_SOMI,
  528. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  529. /* SPI1_nCS0 pin configuration, PIN = U19 */
  530. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_SPI1_NCS0,
  531. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  532. /* PEN_IRQ pin configuration, PIN = P20 */
  533. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_MCBSP1_FSR,
  534. *MuxConfigReg = 0x03 ; /* Mode = 3, PUPD=Disabled */
  535. }
  536. /****************************************
  537. * Routine: muxSetupHDQ (ostboot)
  538. * Description: setup 1wire mux
  539. *****************************************/
  540. void muxSetupHDQ(void)
  541. {
  542. volatile unsigned char *MuxConfigReg;
  543. /* HDQ_SIO pin configuration, PIN = N18 */
  544. MuxConfigReg = (volatile unsigned char *)CONTROL_PADCONF_HDQ_SIO,
  545. *MuxConfigReg = 0x00 ; /* Mode = 0, PUPD=Disabled */
  546. }
  547. /***************************************************************
  548. * Routine: muxSetupGPMC (ostboot)
  549. * Description: Configures balls which cam up in protected mode
  550. ***************************************************************/
  551. void muxSetupGPMC(void)
  552. {
  553. volatile uint8 *MuxConfigReg;
  554. volatile unsigned int *MCR = (volatile unsigned int *)0x4800008C;
  555. /* gpmc_io_dir */
  556. *MCR = 0x19000000;
  557. /* NOR FLASH CS0 */
  558. /* signal - Gpmc_clk; pin - J4; offset - 0x0088; mode - 0; Byte-3 Pull/up - N/A */
  559. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_D2_BYTE3,
  560. *MuxConfigReg = 0x00 ;
  561. /* signal - Gpmc_iodir; pin - n2; offset - 0x008C; mode - 1; Byte-3 Pull/up - N/A */
  562. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE3,
  563. *MuxConfigReg = 0x01 ;
  564. /* MPDB(Multi Port Debug Port) CS1 */
  565. /* signal - gpmc_ncs1; pin - N8; offset - 0x008C; mode - 0; Byte-1 Pull/up - N/A */
  566. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE1,
  567. *MuxConfigReg = 0x00 ;
  568. /* signal - Gpmc_ncs2; pin - E2; offset - 0x008C; mode - 0; Byte-2 Pull/up - N/A */
  569. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_GPMC_NCS0_BYTE2,
  570. *MuxConfigReg = 0x00 ;
  571. }
  572. /****************************************************************
  573. * Routine: muxSetupSDRC (ostboot)
  574. * Description: Configures balls which come up in protected mode
  575. ****************************************************************/
  576. void muxSetupSDRC(void)
  577. {
  578. volatile uint8 *MuxConfigReg;
  579. /* signal - sdrc_ncs1; pin - C12; offset - 0x00A0; mode - 0; Byte-1 Pull/up - N/A */
  580. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_NCS0_BYTE1,
  581. *MuxConfigReg = 0x00 ;
  582. /* signal - sdrc_a12; pin - D11; offset - 0x0030; mode - 0; Byte-2 Pull/up - N/A */
  583. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_A14_BYTE2,
  584. *MuxConfigReg = 0x00 ;
  585. /* signal - sdrc_cke1; pin - B13; offset - 0x00A0; mode - 0; Byte-3 Pull/up - N/A */
  586. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_NCS0_BYTE3,
  587. *MuxConfigReg = 0x00;
  588. if (get_cpu_type() == CPU_2422) {
  589. MuxConfigReg = (volatile uint8 *)CONTROL_PADCONF_SDRC_A14_BYTE0,
  590. *MuxConfigReg = 0x1b;
  591. }
  592. }
  593. /*****************************************************************************
  594. * Routine: update_mux()
  595. * Description: Update balls which are different beween boards. All should be
  596. * updated to match functionaly. However, I'm only updating ones
  597. * which I'll be using for now. When power comes into play they
  598. * all need updating.
  599. *****************************************************************************/
  600. void update_mux(u32 btype,u32 mtype)
  601. {
  602. u32 cpu, base = OMAP2420_CTRL_BASE;
  603. cpu = get_cpu_type();
  604. if (btype == BOARD_H4_MENELAUS) {
  605. if (cpu == CPU_2420) {
  606. /* PIN = B3, GPIO.0->KBR5, mode 3, (pun?),-DO-*/
  607. __raw_writeb(0x3, base+0x30);
  608. /* PIN = B13, GPIO.38->KBC6, mode 3, (pun?)-DO-*/
  609. __raw_writeb(0x3, base+0xa3);
  610. /* PIN = F1, GPIO.25->HSUSBxx mode 3, (for external HS USB)*/
  611. /* PIN = H1, GPIO.26->HSUSBxx mode 3, (for external HS USB)*/
  612. /* PIN = K1, GPMC_ncs6 mode 0, (on board nand access)*/
  613. /* PIN = L2, GPMC_ncs67 mode 0, (for external HS USB)*/
  614. /* PIN = M1 (HSUSBOTG) */
  615. /* PIN = P1, GPIO.35->MEN_POK mode 3, (menelaus powerok)-DO-*/
  616. __raw_writeb(0x3, base+0x9d);
  617. /* PIN = U32, (WLAN_CLKREQ) */
  618. /* PIN = Y11, WLAN */
  619. /* PIN = AA4, GPIO.15->KBC2, mode 3, -DO- */
  620. __raw_writeb(0x3, base+0xe7);
  621. /* PIN = AA8, mDOC */
  622. /* PIN = AA10, BT */
  623. /* PIN = AA13, WLAN */
  624. /* PIN = M18 GPIO.96->MMC2_WP mode 3 -DO- */
  625. __raw_writeb(0x3, base+0x10e);
  626. /* PIN = N19 GPIO.98->WLAN_INT mode 3 -DO- */
  627. __raw_writeb(0x3, base+0x110);
  628. /* PIN = J15 HHUSB */
  629. /* PIN = H19 HSUSB */
  630. /* PIN = W13, P13, R13, W16 ... */
  631. /* PIN = V12 GPIO.25->I2C_CAMEN mode 3 -DO- */
  632. __raw_writeb(0x3, base+0xde);
  633. /* PIN = W19 sys_nirq->MENELAUS_INT mode 0 -DO- */
  634. __raw_writeb(0x0, base+0x12c);
  635. /* PIN = AA17->sys_clkreq mode 0 -DO- */
  636. __raw_writeb(0x0, base+0x136);
  637. } else if (cpu == CPU_2422) {
  638. /* PIN = B3, GPIO.0->nc, mode 3, set above (pun?)*/
  639. /* PIN = B13, GPIO.cke1->nc, mode 0, set above, (pun?)*/
  640. /* PIN = F1, GPIO.25->HSUSBxx mode 3, (for external HS USB)*/
  641. /* PIN = H1, GPIO.26->HSUSBxx mode 3, (for external HS USB)*/
  642. /* PIN = K1, GPMC_ncs6 mode 0, (on board nand access)*/
  643. __raw_writeb(0x0, base+0x92);
  644. /* PIN = L2, GPMC_ncs67 mode 0, (for external HS USB)*/
  645. /* PIN = M1 (HSUSBOTG) */
  646. /* PIN = P1, GPIO.35->MEN_POK mode 3, (menelaus powerok)-DO-*/
  647. __raw_writeb(0x3, base+0x10c);
  648. /* PIN = U32, (WLAN_CLKREQ) */
  649. /* PIN = AA4, GPIO.15->KBC2, mode 3, -DO- */
  650. __raw_writeb(0x3, base+0x30);
  651. /* PIN = AA8, mDOC */
  652. /* PIN = AA10, BT */
  653. /* PIN = AA12, WLAN */
  654. /* PIN = M18 GPIO.96->MMC2_WP mode 3 -DO- */
  655. __raw_writeb(0x3, base+0x10e);
  656. /* PIN = N19 GPIO.98->WLAN_INT mode 3 -DO- */
  657. __raw_writeb(0x3, base+0x110);
  658. /* PIN = J15 HHUSB */
  659. /* PIN = H19 HSUSB */
  660. /* PIN = W13, P13, R13, W16 ... */
  661. /* PIN = V12 GPIO.25->I2C_CAMEN mode 3 -DO- */
  662. __raw_writeb(0x3, base+0xde);
  663. /* PIN = W19 sys_nirq->MENELAUS_INT mode 0 -DO- */
  664. __raw_writeb(0x0, base+0x12c);
  665. /* PIN = AA17->sys_clkreq mode 0 -DO- */
  666. __raw_writeb(0x0, base+0x136);
  667. }
  668. } else if (btype == BOARD_H4_SDP) {
  669. if (cpu == CPU_2420) {
  670. /* PIN = B3, GPIO.0->nc mode 3, set above (pun?)*/
  671. /* PIN = B13, GPIO.cke1->nc, mode 0, set above, (pun?)*/
  672. /* Pin = Y11 VLNQ */
  673. /* Pin = AA4 VLNQ */
  674. /* Pin = AA6 VLNQ */
  675. /* Pin = AA8 VLNQ */
  676. /* Pin = AA10 VLNQ */
  677. /* Pin = AA12 VLNQ */
  678. /* PIN = M18 GPIO.96->KBR5 mode 3 -DO- */
  679. __raw_writeb(0x3, base+0x10e);
  680. /* PIN = N19 GPIO.98->KBC6 mode 3 -DO- */
  681. __raw_writeb(0x3, base+0x110);
  682. /* PIN = J15 MDOC_nDMAREQ */
  683. /* PIN = H19 GPIO.100->KBC2 mode 3 -DO- */
  684. __raw_writeb(0x3, base+0x114);
  685. /* PIN = W13, V12, P13, R13, W19, W16 ... */
  686. /* PIN = AA17 sys_clkreq->bt_clk_req mode 0 */
  687. } else if (cpu == CPU_2422) {
  688. /* PIN = B3, GPIO.0->MMC_CD, mode 3, set above */
  689. /* PIN = B13, GPIO.38->wlan_int, mode 3, (pun?)*/
  690. /* Pin = Y11 VLNQ */
  691. /* Pin = AA4 VLNQ */
  692. /* Pin = AA6 VLNQ */
  693. /* Pin = AA8 VLNQ */
  694. /* Pin = AA10 VLNQ */
  695. /* Pin = AA12 VLNQ */
  696. /* PIN = M18 GPIO.96->KBR5 mode 3 -DO- */
  697. __raw_writeb(0x3, base+0x10e);
  698. /* PIN = N19 GPIO.98->KBC6 mode 3 -DO- */
  699. __raw_writeb(0x3, base+0x110);
  700. /* PIN = J15 MDOC_nDMAREQ */
  701. /* PIN = H19 GPIO.100->KBC2 mode 3 -DO- */
  702. __raw_writeb(0x3, base+0x114);
  703. /* PIN = W13, V12, P13, R13, W19, W16 ... */
  704. /* PIN = AA17 sys_clkreq->bt_clk_req mode 0 */
  705. }
  706. }
  707. }
  708. #if (CONFIG_COMMANDS & CFG_CMD_NAND)
  709. void nand_init(void)
  710. {
  711. extern flash_info_t flash_info[];
  712. nand_probe(CFG_NAND_ADDR);
  713. if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
  714. print_size(nand_dev_desc[0].totlen, "\n");
  715. }
  716. #ifdef CFG_JFFS2_MEM_NAND
  717. flash_info[CFG_JFFS2_FIRST_BANK].flash_id = nand_dev_desc[0].id;
  718. flash_info[CFG_JFFS2_FIRST_BANK].size = 1024*1024*2; /* only read kernel single meg partition */
  719. flash_info[CFG_JFFS2_FIRST_BANK].sector_count = 1024; /* 1024 blocks in 16meg chip (use less for raw/copied partition) */
  720. flash_info[CFG_JFFS2_FIRST_BANK].start[0] = 0x80200000; /* ?, ram for now, open question, copy to RAM or adapt for NAND */
  721. #endif
  722. }
  723. #endif