omap2420h4.c 29 KB

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