omap2420h4.c 30 KB

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