blob: e671747254035d130df782da899a759584644788 [file] [log] [blame]
Dima Zavind0850132009-01-26 20:02:33 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google, Inc. nor the names of its contributors
15 * may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <debug.h>
33#include <dev/keys.h>
34#include <dev/gpio_keypad.h>
35#include <lib/ptable.h>
36#include <dev/flash.h>
37
38#define BOARD_FLASH_OFFSET 378
39
40static struct ptable flash_ptable;
41
42/* for these partitions, start will be offset by either what we get from
43 * smem, or from the above offset if smem is not useful. Also, we should
44 * probably have smem_ptable code populate our flash_ptable.
45 *
46 * When smem provides us with a full partition table, we can get rid of
47 * this altogether.
48 *
49 */
50static struct ptentry board_part_list[] = {
51 {
52 .start = 0,
53 .length = 1,
54 .name = "aboot",
55 },
56 {
57 .start = 2,
58 .length = 40,
59 .name = "boot",
60 },
61 {
62 .start = 58,
63 .length = 608 /* 76MB */,
64 .name = "system",
65 },
66 {
67 .start = 666,
68 .length = 157 + 1024,
69 .name = "userdata",
70 },
71 {
72 .name = "",
73 },
74};
75
76void smem_ptable_init(void);
77unsigned smem_get_apps_flash_start(void);
78
79void keypad_init(void);
80
81void target_init(void)
82{
83 struct ptentry *ptn;
84 unsigned offset;
85
86 dprintf(INFO, "target_init()\n");
87
88 keys_init();
89 keypad_init();
90
91 ptable_init(&flash_ptable);
92 smem_ptable_init();
93
Dima Zavine5f64352009-03-02 16:04:20 -080094 flash_init();
95
Dima Zavind0850132009-01-26 20:02:33 -080096 offset = smem_get_apps_flash_start();
97 if (offset == 0xffffffff)
98 offset = BOARD_FLASH_OFFSET;
99
100 for (ptn = &board_part_list[0]; ptn->name[0]; ptn++) {
101 ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
102 ptn->length, ptn->flags);
103 }
104
105 ptable_dump(&flash_ptable);
Dima Zavine5f64352009-03-02 16:04:20 -0800106 flash_set_ptable(&flash_ptable);
Dima Zavind0850132009-01-26 20:02:33 -0800107}