Commit 69018ce2e086e9caf35b914d675b82bc4888f077

Authored by Kumar Gala
Committed by Wolfgang Denk
1 parent 37e3c62fa0

QE: Move FDT support into a common file

Move the flat device tree setup for QE related devices into
a common file shared between 83xx & 85xx platforms that have QE's.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Showing 6 changed files with 99 additions and 64 deletions Side-by-side Diff

common/fdt_support.c
... ... @@ -30,9 +30,6 @@
30 30 #include <fdt_support.h>
31 31 #include <exports.h>
32 32  
33   -#ifdef CONFIG_QE
34   -#include "../drivers/qe/qe.h"
35   -#endif
36 33 /*
37 34 * Global data (for the gd->bd)
38 35 */
... ... @@ -617,50 +614,5 @@
617 614 #endif
618 615 }
619 616 }
620   -
621   -#ifdef CONFIG_QE
622   -/*
623   - * If a QE firmware has been uploaded, then add the 'firmware' node under
624   - * the 'qe' node.
625   - */
626   -void fdt_fixup_qe_firmware(void *fdt)
627   -{
628   - struct qe_firmware_info *qe_fw_info;
629   - int node, ret;
630   -
631   - qe_fw_info = qe_get_firmware_info();
632   - if (!qe_fw_info)
633   - return;
634   -
635   - node = fdt_path_offset(fdt, "/qe");
636   - if (node < 0)
637   - return;
638   -
639   - /* We assume the node doesn't exist yet */
640   - node = fdt_add_subnode(fdt, node, "firmware");
641   - if (node < 0)
642   - return;
643   -
644   - ret = fdt_setprop(fdt, node, "extended-modes",
645   - &qe_fw_info->extended_modes, sizeof(u64));
646   - if (ret < 0)
647   - goto error;
648   -
649   - ret = fdt_setprop_string(fdt, node, "id", qe_fw_info->id);
650   - if (ret < 0)
651   - goto error;
652   -
653   - ret = fdt_setprop(fdt, node, "virtual-traps", qe_fw_info->vtraps,
654   - sizeof(qe_fw_info->vtraps));
655   - if (ret < 0)
656   - goto error;
657   -
658   - return;
659   -
660   -error:
661   - fdt_del_node(fdt, node);
662   -}
663   -#endif
664   -
665 617 #endif
... ... @@ -30,6 +30,8 @@
30 30 #include <libfdt.h>
31 31 #include <fdt_support.h>
32 32  
  33 +extern void ft_qe_setup(void *blob);
  34 +
33 35 DECLARE_GLOBAL_DATA_PTR;
34 36  
35 37 void ft_cpu_setup(void *blob, bd_t *bd)
... ... @@ -48,16 +50,7 @@
48 50 do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
49 51 "bus-frequency", bd->bi_busfreq, 1);
50 52 #ifdef CONFIG_QE
51   - do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
52   - "bus-frequency", gd->qe_clk, 1);
53   - do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
54   - "brg-frequency", gd->brg_clk, 1);
55   - do_fixup_by_compat_u32(blob, "fsl,qe",
56   - "clock-frequency", gd->qe_clk, 1);
57   - do_fixup_by_compat_u32(blob, "fsl,qe",
58   - "bus-frequency", gd->qe_clk, 1);
59   - do_fixup_by_compat_u32(blob, "fsl,qe",
60   - "brg-frequency", gd->brg_clk, 1);
  53 + ft_qe_setup(blob);
61 54 #endif
62 55  
63 56 #ifdef CFG_NS16550
... ... @@ -27,6 +27,8 @@
27 27 #include <libfdt.h>
28 28 #include <fdt_support.h>
29 29  
  30 +extern void ft_qe_setup(void *blob);
  31 +
30 32 void ft_cpu_setup(void *blob, bd_t *bd)
31 33 {
32 34 #if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
... ... @@ -43,11 +45,7 @@
43 45 do_fixup_by_prop_u32(blob, "device_type", "soc", 4,
44 46 "bus-frequency", bd->bi_busfreq, 1);
45 47 #ifdef CONFIG_QE
46   - do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
47   - "bus-frequency", bd->bi_busfreq, 1);
48   - do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
49   - "brg-frequency", bd->bi_busfreq / 2, 1);
50   - fdt_fixup_qe_firmware(blob);
  48 + ft_qe_setup(blob);
51 49 #endif
52 50  
53 51 #ifdef CFG_NS16550
... ... @@ -24,7 +24,8 @@
24 24  
25 25 LIB := $(obj)qe.a
26 26  
27   -COBJS := qe.o uccf.o uec.o uec_phy.o
  27 +COBJS-$(CONFIG_OF_LIBFDT) += fdt.o
  28 +COBJS := qe.o uccf.o uec.o uec_phy.o $(COBJS-y)
28 29  
29 30 SRCS := $(COBJS:.o=.c)
30 31 OBJS := $(addprefix $(obj),$(COBJS))
  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 +{
  77 +#ifdef CONFIG_QE
  78 + do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
  79 + "bus-frequency", gd->qe_clk, 1);
  80 + do_fixup_by_prop_u32(blob, "device_type", "qe", 4,
  81 + "brg-frequency", gd->brg_clk, 1);
  82 + do_fixup_by_compat_u32(blob, "fsl,qe",
  83 + "clock-frequency", gd->qe_clk, 1);
  84 + do_fixup_by_compat_u32(blob, "fsl,qe",
  85 + "bus-frequency", gd->qe_clk, 1);
  86 + do_fixup_by_compat_u32(blob, "fsl,qe",
  87 + "brg-frequency", gd->brg_clk, 1);
  88 + fdt_fixup_qe_firmware(blob);
  89 +#endif
  90 +}
... ... @@ -289,6 +289,7 @@
289 289 int qe_set_mii_clk_src(int ucc_num);
290 290 int qe_upload_firmware(const struct qe_firmware *firmware);
291 291 struct qe_firmware_info *qe_get_firmware_info(void);
  292 +void ft_qe_setup(void *blob);
292 293  
293 294 #endif /* __QE_H__ */