aboutsummaryrefslogtreecommitdiff
path: root/hw/exynos4_boards.c
blob: 767dc45a542f749a226078ebd3cf5b6c9d72bcef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 *  Samsung exynos4 SoC based boards emulation
 *
 *  Copyright (c) 2011 Samsung Electronics Co., Ltd. All rights reserved.
 *    Maksim Kozlov <m.kozlov@samsung.com>
 *    Evgeny Voevodin <e.voevodin@samsung.com>
 *    Igor Mitsyanko  <i.mitsyanko@samsung.com>
 *
 *  This program is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but WITHOUT
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *  for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "sysemu.h"
#include "sysbus.h"
#include "arm-misc.h"
#include "exec-memory.h"
#include "exynos4210.h"
#include "boards.h"

#undef DEBUG

//#define DEBUG

#ifdef DEBUG
    #undef PRINT_DEBUG
    #define  PRINT_DEBUG(fmt, args...) \
        do { \
            fprintf(stderr, "  [%s:%d]   "fmt, __func__, __LINE__, ##args); \
        } while (0)
#else
    #define  PRINT_DEBUG(fmt, args...)  do {} while (0)
#endif

typedef enum Exynos4BoardType {
    EXYNOS4_BOARD_NURI,
    EXYNOS4_BOARD_SMDKC210,
    EXYNOS4_NUM_OF_BOARDS
} Exynos4BoardType;

static int exynos4_board_id[EXYNOS4_NUM_OF_BOARDS] = {
    [EXYNOS4_BOARD_NURI]     = 0xD33,
    [EXYNOS4_BOARD_SMDKC210] = 0xB16,
};

static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = {
    [EXYNOS4_BOARD_NURI]     = EXYNOS4210_SECOND_CPU_BOOTREG,
    [EXYNOS4_BOARD_SMDKC210] = EXYNOS4210_SECOND_CPU_BOOTREG,
};

static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = {
    [EXYNOS4_BOARD_NURI]     = 0x40000000,
    [EXYNOS4_BOARD_SMDKC210] = 0x40000000,
};

static struct arm_boot_info exynos4_board_binfo = {
    .loader_start     = EXYNOS4210_BASE_BOOT_ADDR,
    .smp_loader_start = EXYNOS4210_SMP_BOOT_ADDR,
    .nb_cpus          = EXYNOS4210_NCPUS,
};

static QEMUMachine exynos4_machines[EXYNOS4_NUM_OF_BOARDS];

static Exynos4210State *exynos4_boards_init_common(
        const char *kernel_filename,
        const char *kernel_cmdline,
        const char *initrd_filename,
        Exynos4BoardType board_type)
{
    if (smp_cpus != EXYNOS4210_NCPUS) {
        fprintf(stderr, "%s board supports only %d CPU cores. Ignoring smp_cpus"
                " value.\n",
                exynos4_machines[board_type].name,
                exynos4_machines[board_type].max_cpus);
    }

    exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type];
    exynos4_board_binfo.board_id = exynos4_board_id[board_type];
    exynos4_board_binfo.smp_bootreg_addr =
            exynos4_board_smp_bootreg_addr[board_type];
    exynos4_board_binfo.kernel_filename = kernel_filename;
    exynos4_board_binfo.initrd_filename = initrd_filename;
    exynos4_board_binfo.kernel_cmdline = kernel_cmdline;
    exynos4_board_binfo.smp_priv_base = EXYNOS4210_SMP_PRIVATE_BASE_ADDR;

    PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n"
            " kernel_filename: %s\n"
            " kernel_cmdline: %s\n"
            " initrd_filename: %s\n",
            exynos4_board_ram_size[board_type] / 1048576,
            exynos4_board_ram_size[board_type],
            kernel_filename,
            kernel_cmdline,
            initrd_filename);

    return exynos4210_init(get_system_memory(),
            exynos4_board_ram_size[board_type]);
}

static void nuri_init(ram_addr_t ram_size,
        const char *boot_device,
        const char *kernel_filename, const char *kernel_cmdline,
        const char *initrd_filename, const char *cpu_model)
{
    exynos4_boards_init_common(kernel_filename, kernel_cmdline,
                initrd_filename, EXYNOS4_BOARD_NURI);

    arm_load_kernel(first_cpu, &exynos4_board_binfo);
}

static void smdkc210_init(ram_addr_t ram_size,
        const char *boot_device,
        const char *kernel_filename, const char *kernel_cmdline,
        const char *initrd_filename, const char *cpu_model)
{
    exynos4_boards_init_common(kernel_filename, kernel_cmdline,
                initrd_filename, EXYNOS4_BOARD_SMDKC210);

    arm_load_kernel(first_cpu, &exynos4_board_binfo);
}

static QEMUMachine exynos4_machines[EXYNOS4_NUM_OF_BOARDS] = {
    [EXYNOS4_BOARD_NURI] = {
        .name = "nuri",
        .desc = "Samsung NURI board (Exynos4210)",
        .init = nuri_init,
        .max_cpus = EXYNOS4210_NCPUS,
    },
    [EXYNOS4_BOARD_SMDKC210] = {
        .name = "smdkc210",
        .desc = "Samsung SMDKC210 board (Exynos4210)",
        .init = smdkc210_init,
        .max_cpus = EXYNOS4210_NCPUS,
    },
};

static void exynos4_machine_init(void)
{
    qemu_register_machine(&exynos4_machines[EXYNOS4_BOARD_NURI]);
    qemu_register_machine(&exynos4_machines[EXYNOS4_BOARD_SMDKC210]);
}

machine_init(exynos4_machine_init);