mcx.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Copyright (C) 2011 Ilya Yanok, Emcraft Systems
  3. *
  4. * Based on ti/evm/evm.c
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <asm/io.h>
  10. #include <asm/arch/mem.h>
  11. #include <asm/arch/mmc_host_def.h>
  12. #include <asm/arch/mux.h>
  13. #include <asm/arch/sys_proto.h>
  14. #include <asm/mach-types.h>
  15. #include <asm/gpio.h>
  16. #include <asm/omap_gpio.h>
  17. #include <asm/arch/dss.h>
  18. #include <asm/arch/clock.h>
  19. #include <errno.h>
  20. #include <i2c.h>
  21. #ifdef CONFIG_USB_EHCI
  22. #include <usb.h>
  23. #include <asm/ehci-omap.h>
  24. #endif
  25. #include "mcx.h"
  26. DECLARE_GLOBAL_DATA_PTR;
  27. #define HOT_WATER_BUTTON 42
  28. #define LCD_OUTPUT 55
  29. /* Address of the framebuffer in RAM. */
  30. #define FB_START_ADDRESS 0x88000000
  31. #ifdef CONFIG_USB_EHCI
  32. static struct omap_usbhs_board_data usbhs_bdata = {
  33. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  34. .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
  35. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  36. };
  37. int ehci_hcd_init(int index, enum usb_init_type init,
  38. struct ehci_hccr **hccr, struct ehci_hcor **hcor)
  39. {
  40. return omap_ehci_hcd_init(index, &usbhs_bdata, hccr, hcor);
  41. }
  42. int ehci_hcd_stop(int index)
  43. {
  44. return omap_ehci_hcd_stop();
  45. }
  46. #endif
  47. /*
  48. * Routine: board_init
  49. * Description: Early hardware init.
  50. */
  51. int board_init(void)
  52. {
  53. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  54. /* boot param addr */
  55. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  56. gpio_direction_output(LCD_OUTPUT, 0);
  57. return 0;
  58. }
  59. #ifdef CONFIG_BOARD_LATE_INIT
  60. int board_late_init(void)
  61. {
  62. if (gpio_request(HOT_WATER_BUTTON, "hot-water-button") < 0) {
  63. puts("Failed to get hot-water-button pin\n");
  64. return -ENODEV;
  65. }
  66. gpio_direction_input(HOT_WATER_BUTTON);
  67. /*
  68. * if hot-water-button is pressed
  69. * change bootcmd
  70. */
  71. if (gpio_get_value(HOT_WATER_BUTTON))
  72. return 0;
  73. setenv("bootcmd", "run swupdate");
  74. return 0;
  75. }
  76. #endif
  77. /*
  78. * Routine: set_muxconf_regs
  79. * Description: Setting up the configuration Mux registers specific to the
  80. * hardware. Many pins need to be moved from protect to primary
  81. * mode.
  82. */
  83. void set_muxconf_regs(void)
  84. {
  85. MUX_MCX();
  86. }
  87. #if defined(CONFIG_OMAP_HSMMC)
  88. int board_mmc_init(bd_t *bis)
  89. {
  90. return omap_mmc_init(0, 0, 0, -1, -1);
  91. }
  92. #endif
  93. #if defined(CONFIG_VIDEO) && !defined(CONFIG_SPL_BUILD)
  94. static struct panel_config lcd_cfg = {
  95. .timing_h = PANEL_TIMING_H(40, 40, 48),
  96. .timing_v = PANEL_TIMING_V(29, 13, 3),
  97. .pol_freq = 0x00003000, /* Pol Freq */
  98. .divisor = 0x0001000E,
  99. .panel_type = 0x01, /* TFT */
  100. .data_lines = 0x03, /* 24 Bit RGB */
  101. .load_mode = 0x02, /* Frame Mode */
  102. .panel_color = 0,
  103. .lcd_size = PANEL_LCD_SIZE(800, 480),
  104. .gfx_format = GFXFORMAT_RGB24_UNPACKED,
  105. };
  106. int board_video_init(void)
  107. {
  108. struct prcm *prcm_base = (struct prcm *)PRCM_BASE;
  109. void *fb;
  110. fb = (void *)FB_START_ADDRESS;
  111. lcd_cfg.frame_buffer = fb;
  112. setbits_le32(&prcm_base->fclken_dss, FCK_DSS_ON);
  113. setbits_le32(&prcm_base->iclken_dss, ICK_DSS_ON);
  114. omap3_dss_panel_config(&lcd_cfg);
  115. omap3_dss_enable();
  116. return 0;
  117. }
  118. #endif