Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * (C) Copyright 2000 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <libfdt.h> |
| 12 | #include <fdt_support.h> |
| 13 | #include "qe.h" |
| 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
| 17 | /* |
| 18 | * If a QE firmware has been uploaded, then add the 'firmware' node under |
| 19 | * the 'qe' node. |
| 20 | */ |
| 21 | void fdt_fixup_qe_firmware(void *blob) |
| 22 | { |
| 23 | struct qe_firmware_info *qe_fw_info; |
| 24 | int node, ret; |
| 25 | |
| 26 | qe_fw_info = qe_get_firmware_info(); |
| 27 | if (!qe_fw_info) |
| 28 | return; |
| 29 | |
| 30 | node = fdt_path_offset(blob, "/qe"); |
| 31 | if (node < 0) |
| 32 | return; |
| 33 | |
| 34 | /* We assume the node doesn't exist yet */ |
| 35 | node = fdt_add_subnode(blob, node, "firmware"); |
| 36 | if (node < 0) |
| 37 | return; |
| 38 | |
| 39 | ret = fdt_setprop(blob, node, "extended-modes", |
| 40 | &qe_fw_info->extended_modes, sizeof(u64)); |
| 41 | if (ret < 0) |
| 42 | goto error; |
| 43 | |
| 44 | ret = fdt_setprop_string(blob, node, "id", qe_fw_info->id); |
| 45 | if (ret < 0) |
| 46 | goto error; |
| 47 | |
| 48 | ret = fdt_setprop(blob, node, "virtual-traps", qe_fw_info->vtraps, |
| 49 | sizeof(qe_fw_info->vtraps)); |
| 50 | if (ret < 0) |
| 51 | goto error; |
| 52 | |
| 53 | return; |
| 54 | |
| 55 | error: |
| 56 | fdt_del_node(blob, node); |
| 57 | } |
| 58 | |
| 59 | void ft_qe_setup(void *blob) |
| 60 | { |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 61 | do_fixup_by_prop_u32(blob, "device_type", "qe", 4, |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 62 | "bus-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 63 | do_fixup_by_prop_u32(blob, "device_type", "qe", 4, |
Simon Glass | 34a194f | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 64 | "brg-frequency", gd->arch.brg_clk, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 65 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 66 | "clock-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 67 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 68 | "bus-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 69 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 34a194f | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 70 | "brg-frequency", gd->arch.brg_clk, 1); |
Anton Vorontsov | d8e7582 | 2009-10-15 17:47:16 +0400 | [diff] [blame] | 71 | do_fixup_by_compat_u32(blob, "fsl,qe-gtm", |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 72 | "clock-frequency", gd->arch.qe_clk / 2, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 73 | fdt_fixup_qe_firmware(blob); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 74 | } |