Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 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> |
Stefano Babic | 8f1fae2 | 2012-10-20 23:56:07 +0000 | [diff] [blame] | 30 | #include <asm/arch/dss.h> |
| 31 | #include <asm/arch/clocks.h> |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 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 | |
Stefano Babic | 8c735b9 | 2012-10-16 04:07:04 +0000 | [diff] [blame] | 42 | #define HOT_WATER_BUTTON 42 |
Stefano Babic | 8f1fae2 | 2012-10-20 23:56:07 +0000 | [diff] [blame] | 43 | #define LCD_OUTPUT 55 |
| 44 | |
| 45 | /* Address of the framebuffer in RAM. */ |
| 46 | #define FB_START_ADDRESS 0x88000000 |
Stefano Babic | 3ae6abb | 2012-06-13 22:34:44 +0000 | [diff] [blame] | 47 | |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 48 | #ifdef CONFIG_USB_EHCI |
| 49 | static struct omap_usbhs_board_data usbhs_bdata = { |
| 50 | .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, |
Stefano Babic | 8c735b9 | 2012-10-16 04:07:04 +0000 | [diff] [blame] | 51 | .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED, |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 52 | .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, |
| 53 | }; |
| 54 | |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 55 | int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 56 | { |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 57 | return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Lucas Stach | 676ae06 | 2012-09-26 00:14:35 +0200 | [diff] [blame] | 60 | int ehci_hcd_stop(int index) |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 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 | |
Stefano Babic | 8f1fae2 | 2012-10-20 23:56:07 +0000 | [diff] [blame] | 76 | gpio_direction_output(LCD_OUTPUT, 0); |
| 77 | |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 78 | return 0; |
| 79 | } |
| 80 | |
Stefano Babic | 3ae6abb | 2012-06-13 22:34:44 +0000 | [diff] [blame] | 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"); |
Stefano Babic | 8c735b9 | 2012-10-16 04:07:04 +0000 | [diff] [blame] | 98 | |
Stefano Babic | 3ae6abb | 2012-06-13 22:34:44 +0000 | [diff] [blame] | 99 | return 0; |
| 100 | } |
| 101 | #endif |
| 102 | |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 103 | /* |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 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 | { |
Jonathan Solnit | bbbc1ae | 2012-02-24 11:30:18 +0000 | [diff] [blame] | 117 | return omap_mmc_init(0, 0, 0); |
Ilya Yanok | 4ab779c | 2012-02-07 23:30:22 +0000 | [diff] [blame] | 118 | } |
| 119 | #endif |
Stefano Babic | 8f1fae2 | 2012-10-20 23:56:07 +0000 | [diff] [blame] | 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 | }; |
| 134 | |
| 135 | int board_video_init(void) |
| 136 | { |
| 137 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 138 | void *fb; |
| 139 | |
| 140 | fb = (void *)FB_START_ADDRESS; |
| 141 | |
| 142 | lcd_cfg.frame_buffer = fb; |
| 143 | |
| 144 | setbits_le32(&prcm_base->fclken_dss, FCK_DSS_ON); |
| 145 | setbits_le32(&prcm_base->iclken_dss, ICK_DSS_ON); |
| 146 | |
| 147 | omap3_dss_panel_config(&lcd_cfg); |
| 148 | omap3_dss_enable(); |
| 149 | |
| 150 | return 0; |
| 151 | } |
| 152 | #endif |