blob: 7f0330dc038139914a92e0ba1b15fd360b903d54 [file] [log] [blame]
Ilya Yanok4ab779c2012-02-07 23:30:22 +00001/*
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 Babic8f1fae22012-10-20 23:56:07 +000030#include <asm/arch/dss.h>
Lokesh Vutlaaf1d0022013-05-30 02:54:32 +000031#include <asm/arch/clock.h>
Ilya Yanok4ab779c2012-02-07 23:30:22 +000032#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
40DECLARE_GLOBAL_DATA_PTR;
41
Stefano Babic8c735b92012-10-16 04:07:04 +000042#define HOT_WATER_BUTTON 42
Stefano Babic8f1fae22012-10-20 23:56:07 +000043#define LCD_OUTPUT 55
44
45/* Address of the framebuffer in RAM. */
46#define FB_START_ADDRESS 0x88000000
Stefano Babic3ae6abb2012-06-13 22:34:44 +000047
Ilya Yanok4ab779c2012-02-07 23:30:22 +000048#ifdef CONFIG_USB_EHCI
49static struct omap_usbhs_board_data usbhs_bdata = {
50 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
Stefano Babic8c735b92012-10-16 04:07:04 +000051 .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
Ilya Yanok4ab779c2012-02-07 23:30:22 +000052 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
53};
54
Lucas Stach676ae062012-09-26 00:14:35 +020055int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
Ilya Yanok4ab779c2012-02-07 23:30:22 +000056{
Lucas Stach676ae062012-09-26 00:14:35 +020057 return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
Ilya Yanok4ab779c2012-02-07 23:30:22 +000058}
59
Lucas Stach676ae062012-09-26 00:14:35 +020060int ehci_hcd_stop(int index)
Ilya Yanok4ab779c2012-02-07 23:30:22 +000061{
62 return omap_ehci_hcd_stop();
63}
64#endif
65
66/*
67 * Routine: board_init
68 * Description: Early hardware init.
69 */
70int 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 Babic8f1fae22012-10-20 23:56:07 +000076 gpio_direction_output(LCD_OUTPUT, 0);
77
Ilya Yanok4ab779c2012-02-07 23:30:22 +000078 return 0;
79}
80
Stefano Babic3ae6abb2012-06-13 22:34:44 +000081#ifdef CONFIG_BOARD_LATE_INIT
82int 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 Babic8c735b92012-10-16 04:07:04 +000098
Stefano Babic3ae6abb2012-06-13 22:34:44 +000099 return 0;
100}
101#endif
102
Ilya Yanok4ab779c2012-02-07 23:30:22 +0000103/*
Ilya Yanok4ab779c2012-02-07 23:30:22 +0000104 * 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 */
109void set_muxconf_regs(void)
110{
111 MUX_MCX();
112}
113
114#if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
115int board_mmc_init(bd_t *bis)
116{
Nikita Kiryanove3913f52012-12-03 02:19:47 +0000117 return omap_mmc_init(0, 0, 0, -1, -1);
Ilya Yanok4ab779c2012-02-07 23:30:22 +0000118}
119#endif
Stefano Babic8f1fae22012-10-20 23:56:07 +0000120
121#if defined(CONFIG_VIDEO) && !defined(CONFIG_SPL_BUILD)
122
123static 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),
Nikita Kiryanovbcc6cc92013-01-30 21:39:55 +0000133 .gfx_format = GFXFORMAT_RGB24_UNPACKED,
Stefano Babic8f1fae22012-10-20 23:56:07 +0000134};
135
136int 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