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 | * |
| 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 | |
| 31 | DECLARE_GLOBAL_DATA_PTR; |
| 32 | |
| 33 | /* |
| 34 | * If a QE firmware has been uploaded, then add the 'firmware' node under |
| 35 | * the 'qe' node. |
| 36 | */ |
| 37 | void 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 | |
| 71 | error: |
| 72 | fdt_del_node(blob, node); |
| 73 | } |
| 74 | |
| 75 | void ft_qe_setup(void *blob) |
| 76 | { |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 77 | do_fixup_by_prop_u32(blob, "device_type", "qe", 4, |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 78 | "bus-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 79 | do_fixup_by_prop_u32(blob, "device_type", "qe", 4, |
Simon Glass | 34a194f | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 80 | "brg-frequency", gd->arch.brg_clk, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 81 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 82 | "clock-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 83 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 84 | "bus-frequency", gd->arch.qe_clk, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 85 | do_fixup_by_compat_u32(blob, "fsl,qe", |
Simon Glass | 34a194f | 2012-12-13 20:48:44 +0000 | [diff] [blame] | 86 | "brg-frequency", gd->arch.brg_clk, 1); |
Anton Vorontsov | d8e7582 | 2009-10-15 17:47:16 +0400 | [diff] [blame] | 87 | do_fixup_by_compat_u32(blob, "fsl,qe-gtm", |
Simon Glass | 8518b17 | 2012-12-13 20:48:50 +0000 | [diff] [blame] | 88 | "clock-frequency", gd->arch.qe_clk / 2, 1); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 89 | fdt_fixup_qe_firmware(blob); |
Kumar Gala | 1f16448 | 2008-01-17 08:25:45 -0600 | [diff] [blame] | 90 | } |