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