omap2420h4.c 28 KB

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