blob: 676139050ab6ea4b3785eb825bbec763fec8b330 [file] [log] [blame]
Shashank Mittal23b8f422010-04-16 19:27:21 -07001/*
2 * Copyright (c) 2008, Google Inc.
3 * All rights reserved.
4 * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google, Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#include <debug.h>
34#include <reg.h>
35
36#include <dev/fbcon.h>
37#include <kernel/thread.h>
38#include <platform/debug.h>
39#include <platform/iomap.h>
Shashank Mittalc69512e2010-09-22 16:40:48 -070040#include <i2c_qup.h>
41
42#define CONVERT_ENDIAN_U32(val) \
43 ((((uint32_t)(val) & 0x000000FF) << 24) | \
44 (((uint32_t)(val) & 0x0000FF00) << 8) | \
45 (((uint32_t)(val) & 0x00FF0000) >> 8) | \
46 (((uint32_t)(val) & 0xFF000000) >> 24))
47
48#define CONVERT_ENDIAN_U16(val) \
49 ((((uint16_t)(val) & 0x00FF) << 8) | \
50 (((uint16_t)(val) & 0xFF00) >> 8))
51
52/* Configuration Data Table */
53#define CDT_MAGIC_NUMBER 0x43445400
54struct cdt_header
55{
56 uint32_t magic; /* Magic number */
57 uint16_t version; /* Version number */
58 uint32_t reserved1;
59 uint32_t reserved2;
60}__attribute__((packed));
Shashank Mittal23b8f422010-04-16 19:27:21 -070061
62void platform_init_interrupts(void);
63void platform_init_timer();
64
65void uart3_clock_init(void);
66void uart_init(void);
67
68struct fbcon_config *lcdc_init(void);
69
70void platform_early_init(void)
71{
72 platform_init_interrupts();
73 platform_init_timer();
74}
75
76void platform_init(void)
77{
78 dprintf(INFO, "platform_init()\n");
79}
80
81void display_init(void)
82{
Shashank Mittal402d0972010-09-29 10:09:52 -070083 struct fbcon_config *fb_cfg;
84#if DISPLAY_TYPE_LCDC
85 mdp_clock_init();
86 fb_cfg = lcdc_init();
87 panel_poweron();
88 fbcon_setup(fb_cfg);
89#endif
Shashank Mittal23b8f422010-04-16 19:27:21 -070090}
91
Shashank Mittalc648e712010-10-06 18:37:42 -070092void display_shutdown(void)
93{
94 /* Turning off LCDC */
95 lcdc_shutdown();
96}
97
Shashank Mittalc69512e2010-09-22 16:40:48 -070098static struct qup_i2c_dev* dev = NULL;
99
100uint32_t eprom_read (uint16_t addr, uint8_t count) {
101 uint32_t ret = 0;
102 if(!dev){
103 return ret;
104 }
105 /* Create a i2c_msg buffer, that is used to put the controller into
106 * read mode and then to read some data.
107 */
108 struct i2c_msg msg_buf[] = {
109 {EEPROM_I2C_ADDRESS, I2C_M_WR, 2, &addr},
110 {EEPROM_I2C_ADDRESS, I2C_M_RD, count, &ret}
111 };
112
113 qup_i2c_xfer(dev, msg_buf, 2);
114 return ret;
115}
116
117/* Read EEPROM to find out product id. Return 0 in case of failure */
118uint32_t platform_id_read (void)
119{
120 uint32_t id = 0;
121 uint16_t offset = 0;
122 dev = qup_i2c_init(GSBI8_BASE, 100000, 24000000);
123 if(!dev){
124 return id;
125 }
126 /* Check if EPROM is valid */
127 if (CONVERT_ENDIAN_U32(eprom_read(0, 4)) == CDT_MAGIC_NUMBER)
128 {
129 /* Get offset for platform ID info from Meta Data block 0 */
130 offset = eprom_read(CONVERT_ENDIAN_U16(0 +
131 sizeof(struct cdt_header)), 2);
132 /* Read platform ID */
133 id = eprom_read(CONVERT_ENDIAN_U16(offset), 4);
134 id = CONVERT_ENDIAN_U32(id);
135 id = (id & 0x00FF0000) >> 16;
136 }
137 return id;
138}
139