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 21 #include <common.h> 22 #include <asm/io.h> 23 #include <asm/arch/mem.h> 24 #include <asm/arch/mmc_host_def.h> 25 #include <asm/arch/mux.h> 26 #include <asm/arch/sys_proto.h> 27 #include <asm/mach-types.h> 28 #include <asm/gpio.h> 29 #include <asm/omap_gpio.h> 30 #include <asm/arch/dss.h> 31 #include <asm/arch/clocks.h> 32 #include "errno.h" 33 #include <i2c.h> 34 #ifdef CONFIG_USB_EHCI 35 #include <usb.h> 36 #include <asm/ehci-omap.h> 37 #endif 38 #include "mcx.h" 39 40 DECLARE_GLOBAL_DATA_PTR; 41 42 #define HOT_WATER_BUTTON 42 43 #define LCD_OUTPUT 55 44 45 /* Address of the framebuffer in RAM. */ 46 #define FB_START_ADDRESS 0x88000000 47 48 #ifdef CONFIG_USB_EHCI 49 static struct omap_usbhs_board_data usbhs_bdata = { 50 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, 51 .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED, 52 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, 53 }; 54 55 int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) 56 { 57 return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); 58 } 59 60 int ehci_hcd_stop(int index) 61 { 62 return omap_ehci_hcd_stop(); 63 } 64 #endif 65 66 /* 67 * Routine: board_init 68 * Description: Early hardware init. 69 */ 70 int board_init(void) 71 { 72 gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ 73 /* boot param addr */ 74 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); 75 76 gpio_direction_output(LCD_OUTPUT, 0); 77 78 return 0; 79 } 80 81 #ifdef CONFIG_BOARD_LATE_INIT 82 int board_late_init(void) 83 { 84 if (gpio_request(HOT_WATER_BUTTON, "hot-water-button") < 0) { 85 puts("Failed to get hot-water-button pin\n"); 86 return -ENODEV; 87 } 88 gpio_direction_input(HOT_WATER_BUTTON); 89 90 /* 91 * if hot-water-button is pressed 92 * change bootcmd 93 */ 94 if (gpio_get_value(HOT_WATER_BUTTON)) 95 return 0; 96 97 setenv("bootcmd", "run swupdate"); 98 99 return 0; 100 } 101 #endif 102 103 /* 104 * Routine: set_muxconf_regs 105 * Description: Setting up the configuration Mux registers specific to the 106 * hardware. Many pins need to be moved from protect to primary 107 * mode. 108 */ 109 void set_muxconf_regs(void) 110 { 111 MUX_MCX(); 112 } 113 114 #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD) 115 int board_mmc_init(bd_t *bis) 116 { 117 return omap_mmc_init(0, 0, 0, -1, -1); 118 } 119 #endif 120 121 #if defined(CONFIG_VIDEO) && !defined(CONFIG_SPL_BUILD) 122 123 static struct panel_config lcd_cfg = { 124 .timing_h = PANEL_TIMING_H(40, 40, 48), 125 .timing_v = PANEL_TIMING_V(29, 13, 3), 126 .pol_freq = 0x00003000, /* Pol Freq */ 127 .divisor = 0x0001000E, 128 .panel_type = 0x01, /* TFT */ 129 .data_lines = 0x03, /* 24 Bit RGB */ 130 .load_mode = 0x02, /* Frame Mode */ 131 .panel_color = 0, 132 .lcd_size = PANEL_LCD_SIZE(800, 480), 133 .gfx_format = GFXFORMAT_RGB24_UNPACKED, 134 }; 135 136 int board_video_init(void) 137 { 138 struct prcm *prcm_base = (struct prcm *)PRCM_BASE; 139 void *fb; 140 141 fb = (void *)FB_START_ADDRESS; 142 143 lcd_cfg.frame_buffer = fb; 144 145 setbits_le32(&prcm_base->fclken_dss, FCK_DSS_ON); 146 setbits_le32(&prcm_base->iclken_dss, ICK_DSS_ON); 147 148 omap3_dss_panel_config(&lcd_cfg); 149 omap3_dss_enable(); 150 151 return 0; 152 } 153 #endif 154