omap2420h4.c 30 KB

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