blob: 5a0f277d0a3b37c1b426c1af04de13d43e6e9e09 [file] [log] [blame]
Kumar Gala69018ce2008-01-17 08:25:45 -06001/*
2 * Copyright 2008 Freescale Semiconductor, Inc.
3 *
4 * (C) Copyright 2000
5 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <common.h>
27#include <libfdt.h>
28#include <fdt_support.h>
29#include "qe.h"
30
31DECLARE_GLOBAL_DATA_PTR;
32
33/*
34 * If a QE firmware has been uploaded, then add the 'firmware' node under
35 * the 'qe' node.
36 */
37void fdt_fixup_qe_firmware(void *blob)
38{
39 struct qe_firmware_info *qe_fw_info;
40 int node, ret;
41
42 qe_fw_info = qe_get_firmware_info();
43 if (!qe_fw_info)
44 return;
45
46 node = fdt_path_offset(blob, "/qe");
47 if (node < 0)
48 return;
49
50 /* We assume the node doesn't exist yet */
51 node = fdt_add_subnode(blob, node, "firmware");
52 if (node < 0)
53 return;
54
55 ret = fdt_setprop(blob, node, "extended-modes",
56 &qe_fw_info->extended_modes, sizeof(u64));
57 if (ret < 0)
58 goto error;
59
60 ret = fdt_setprop_string(blob, node, "id", qe_fw_info->id);
61 if (ret < 0)
62 goto error;
63
64 ret = fdt_setprop(blob, node, "virtual-traps", qe_fw_info->vtraps,
65 sizeof(qe_fw_info->vtraps));
66 if (ret < 0)
67 goto error;
68
69 return;
70
71error:
72 fdt_del_node(blob, node);
73}
74
75void ft_qe_setup(void *blob)
76{
Kumar Gala69018ce2008-01-17 08:25:45 -060077 do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
Simon Glass45bae2e2012-12-13 20:48:50 +000078 "bus-frequency", gd->arch.qe_clk, 1);
Kumar Gala69018ce2008-01-17 08:25:45 -060079 do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
Simon Glass1206c182012-12-13 20:48:44 +000080 "brg-frequency", gd->arch.brg_clk, 1);
Kumar Gala69018ce2008-01-17 08:25:45 -060081 do_fixup_by_compat_u32(blob, "fsl,qe",
Simon Glass45bae2e2012-12-13 20:48:50 +000082 "clock-frequency", gd->arch.qe_clk, 1);
Kumar Gala69018ce2008-01-17 08:25:45 -060083 do_fixup_by_compat_u32(blob, "fsl,qe",
Simon Glass45bae2e2012-12-13 20:48:50 +000084 "bus-frequency", gd->arch.qe_clk, 1);
Kumar Gala69018ce2008-01-17 08:25:45 -060085 do_fixup_by_compat_u32(blob, "fsl,qe",
Simon Glass1206c182012-12-13 20:48:44 +000086 "brg-frequency", gd->arch.brg_clk, 1);
Anton Vorontsov3fca8032009-10-15 17:47:16 +040087 do_fixup_by_compat_u32(blob, "fsl,qe-gtm",
Simon Glass45bae2e2012-12-13 20:48:50 +000088 "clock-frequency", gd->arch.qe_clk / 2, 1);
Kumar Gala69018ce2008-01-17 08:25:45 -060089 fdt_fixup_qe_firmware(blob);
Kumar Gala69018ce2008-01-17 08:25:45 -060090}