Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2008 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * (C) Copyright 2000 |
| 6 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 10 | #include <asm/global_data.h> |
Masahiro Yamada | b08c8c4 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 11 | #include <linux/libfdt.h> |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 12 | #include <fdt_support.h> |
Qianyu Gong | 2459afb | 2016-02-18 13:01:59 +0800 | [diff] [blame] | 13 | #include <fsl_qe.h> |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 14 | |
Zhao Qiang | 93d3320 | 2014-09-25 13:52:25 +0800 | [diff] [blame] | 15 | #ifdef CONFIG_QE |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
| 18 | /* |
| 19 | * If a QE firmware has been uploaded, then add the 'firmware' node under |
| 20 | * the 'qe' node. |
| 21 | */ |
| 22 | void fdt_fixup_qe_firmware(void *blob) |
| 23 | { |
| 24 | struct qe_firmware_info *qe_fw_info; |
| 25 | int node, ret; |
| 26 | |
| 27 | qe_fw_info = qe_get_firmware_info(); |
| 28 | if (!qe_fw_info) |
| 29 | return; |
| 30 | |
| 31 | node = fdt_path_offset(blob, "/qe"); |
| 32 | if (node < 0) |
| 33 | return; |
| 34 | |
| 35 | /* We assume the node doesn't exist yet */ |
| 36 | node = fdt_add_subnode(blob, node, "firmware"); |
| 37 | if (node < 0) |
| 38 | return; |
| 39 | |
| 40 | ret = fdt_setprop(blob, node, "extended-modes", |
| 41 | &qe_fw_info->extended_modes, sizeof(u64)); |
| 42 | if (ret < 0) |
| 43 | goto error; |
| 44 | |
| 45 | ret = fdt_setprop_string(blob, node, "id", qe_fw_info->id); |
| 46 | if (ret < 0) |
| 47 | goto error; |
| 48 | |
| 49 | ret = fdt_setprop(blob, node, "virtual-traps", qe_fw_info->vtraps, |
| 50 | sizeof(qe_fw_info->vtraps)); |
| 51 | if (ret < 0) |
| 52 | goto error; |
| 53 | |
| 54 | return; |
| 55 | |
| 56 | error: |
| 57 | fdt_del_node(blob, node); |
| 58 | } |
| 59 | |
| 60 | void ft_qe_setup(void *blob) |
| 61 | { |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 62 | do_fixup_by_prop_u32(blob, "device_type", "qe", 4, |
Simon Glass | 45bae2e | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 63 | "bus-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 64 | do_fixup_by_prop_u32(blob, "device_type", "qe", 4, |
Simon Glass | 1206c18 | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 65 | "brg-frequency", gd->arch.brg_clk, 1); |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 66 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 45bae2e | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 67 | "clock-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 68 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 45bae2e | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 69 | "bus-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 70 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 1206c18 | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 71 | "brg-frequency", gd->arch.brg_clk, 1); |
Anton Vorontsov | 3fca803 | 2009-10-15 17:47:16 +0400 | [diff] [blame] | 72 | do_fixup_by_compat_u32(blob, "fsl,qe-gtm", |
Simon Glass | 45bae2e | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 73 | "clock-frequency", gd->arch.qe_clk / 2, 1); |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 74 | fdt_fixup_qe_firmware(blob); |
Kumar Gala | 69018ce | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 75 | } |
Zhao Qiang | 93d3320 | 2014-09-25 13:52:25 +0800 | [diff] [blame] | 76 | #endif |