blob: 28217de4ab73f8b5cb7e2ac2f00425e72315713f [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{
83}
84
85void secondary_core(unsigned sec_entry)
86{
87 writel(sec_entry, 0x2A040020);
88 writel(0x0, 0x009035A0); //VDD_SC1_ARRAY_CLAMP_GFS_CTL
89 writel(0x0, 0x00902D80); //SCSS_CPU1CORE_RESET
90 writel(0x3, 0x00902E64); //SCSS_DBG_STATUS_CORE_PWRDUP
91}
Shashank Mittalc69512e2010-09-22 16:40:48 -070092
93static struct qup_i2c_dev* dev = NULL;
94
95uint32_t eprom_read (uint16_t addr, uint8_t count) {
96 uint32_t ret = 0;
97 if(!dev){
98 return ret;
99 }
100 /* Create a i2c_msg buffer, that is used to put the controller into
101 * read mode and then to read some data.
102 */
103 struct i2c_msg msg_buf[] = {
104 {EEPROM_I2C_ADDRESS, I2C_M_WR, 2, &addr},
105 {EEPROM_I2C_ADDRESS, I2C_M_RD, count, &ret}
106 };
107
108 qup_i2c_xfer(dev, msg_buf, 2);
109 return ret;
110}
111
112/* Read EEPROM to find out product id. Return 0 in case of failure */
113uint32_t platform_id_read (void)
114{
115 uint32_t id = 0;
116 uint16_t offset = 0;
117 dev = qup_i2c_init(GSBI8_BASE, 100000, 24000000);
118 if(!dev){
119 return id;
120 }
121 /* Check if EPROM is valid */
122 if (CONVERT_ENDIAN_U32(eprom_read(0, 4)) == CDT_MAGIC_NUMBER)
123 {
124 /* Get offset for platform ID info from Meta Data block 0 */
125 offset = eprom_read(CONVERT_ENDIAN_U16(0 +
126 sizeof(struct cdt_header)), 2);
127 /* Read platform ID */
128 id = eprom_read(CONVERT_ENDIAN_U16(offset), 4);
129 id = CONVERT_ENDIAN_U32(id);
130 id = (id & 0x00FF0000) >> 16;
131 }
132 return id;
133}
134