omap2420h4.c 30 KB

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