mcx.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright (C) 2011 Ilya Yanok, Emcraft Systems
  3. *
  4. * Based on ti/evm/evm.c
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc.
  19. */
  20. #include <common.h>
  21. #include <asm/io.h>
  22. #include <asm/arch/mem.h>
  23. #include <asm/arch/mmc_host_def.h>
  24. #include <asm/arch/mux.h>
  25. #include <asm/arch/sys_proto.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/gpio.h>
  28. #include <asm/omap_gpio.h>
  29. #include <asm/arch/dss.h>
  30. #include <asm/arch/clocks.h>
  31. #include "errno.h"
  32. #include <i2c.h>
  33. #ifdef CONFIG_USB_EHCI
  34. #include <usb.h>
  35. #include <asm/ehci-omap.h>
  36. #endif
  37. #include "mcx.h"
  38. DECLARE_GLOBAL_DATA_PTR;
  39. #define HOT_WATER_BUTTON 42
  40. #define LCD_OUTPUT 55
  41. /* Address of the framebuffer in RAM. */
  42. #define FB_START_ADDRESS 0x88000000
  43. #ifdef CONFIG_USB_EHCI
  44. static struct omap_usbhs_board_data usbhs_bdata = {
  45. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  46. .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
  47. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  48. };
  49. int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  50. {
  51. return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
  52. }
  53. int ehci_hcd_stop(int index)
  54. {
  55. return omap_ehci_hcd_stop();
  56. }
  57. #endif
  58. /*
  59. * Routine: board_init
  60. * Description: Early hardware init.
  61. */
  62. int board_init(void)
  63. {
  64. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  65. /* boot param addr */
  66. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  67. gpio_direction_output(LCD_OUTPUT, 0);
  68. return 0;
  69. }
  70. #ifdef CONFIG_BOARD_LATE_INIT
  71. int board_late_init(void)
  72. {
  73. if (gpio_request(HOT_WATER_BUTTON, "hot-water-button") < 0) {
  74. puts("Failed to get hot-water-button pin\n");
  75. return -ENODEV;
  76. }
  77. gpio_direction_input(HOT_WATER_BUTTON);
  78. /*
  79. * if hot-water-button is pressed
  80. * change bootcmd
  81. */
  82. if (gpio_get_value(HOT_WATER_BUTTON))
  83. return 0;
  84. setenv("bootcmd", "run swupdate");
  85. return 0;
  86. }
  87. #endif
  88. /*
  89. * Routine: set_muxconf_regs
  90. * Description: Setting up the configuration Mux registers specific to the
  91. * hardware. Many pins need to be moved from protect to primary
  92. * mode.
  93. */
  94. void set_muxconf_regs(void)
  95. {
  96. MUX_MCX();
  97. }
  98. #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
  99. int board_mmc_init(bd_t *bis)
  100. {
  101. return omap_mmc_init(0, 0, 0, -1, -1);
  102. }
  103. #endif
  104. #if defined(CONFIG_VIDEO) && !defined(CONFIG_SPL_BUILD)
  105. static struct panel_config lcd_cfg = {
  106. .timing_h = PANEL_TIMING_H(40, 40, 48),
  107. .timing_v = PANEL_TIMING_V(29, 13, 3),
  108. .pol_freq = 0x00003000, /* Pol Freq */
  109. .divisor = 0x0001000E,
  110. .panel_type = 0x01, /* TFT */
  111. .data_lines = 0x03, /* 24 Bit RGB */
  112. .load_mode = 0x02, /* Frame Mode */
  113. .panel_color = 0,
  114. .lcd_size = PANEL_LCD_SIZE(800, 480),
  115. .gfx_format = GFXFORMAT_RGB24_UNPACKED,
  116. };
  117. int board_video_init(void)
  118. {
  119. struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
  120. void *fb;
  121. fb = (void *)FB_START_ADDRESS;
  122. lcd_cfg.frame_buffer = fb;
  123. setbits_le32(&prcm_base->fclken_dss, FCK_DSS_ON);
  124. setbits_le32(&prcm_base->iclken_dss, ICK_DSS_ON);
  125. omap3_dss_panel_config(&lcd_cfg);
  126. omap3_dss_enable();
  127. return 0;
  128. }
  129. #endif