Commit 5597152d9f93ecd0db54a3789f304dc4ca85bb88

Authored by Hou Zhiqiang
Committed by Priyanka Jain
1 parent 0636b7aa1d

arm64: layerscape: Move GIC RD tables initialization to CPU setup function

Move GIC redistributor tables initialization to CPU setup function.

This patch introduces a GIC redistributor tables init function, and
moves the function of reserving memory for GIC redistributor tables
to soc.c and adds a argument for the memory size to reserve, BTW
rename the function so that it is more readable.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>

Showing 4 changed files with 52 additions and 27 deletions Side-by-side Diff

arch/arm/cpu/armv8/fsl-layerscape/fdt.c
... ... @@ -610,6 +610,10 @@
610 610 do_fixup_by_path_u32(blob, "/sysclk", "clock-frequency",
611 611 CONFIG_SYS_CLK_FREQ, 1);
612 612  
  613 +#ifdef CONFIG_GIC_V3_ITS
  614 + ls_gic_rd_tables_init(blob);
  615 +#endif
  616 +
613 617 #if defined(CONFIG_PCIE_LAYERSCAPE) || defined(CONFIG_PCIE_LAYERSCAPE_GEN4)
614 618 ft_pci_setup(blob, bd);
615 619 #endif
arch/arm/cpu/armv8/fsl-layerscape/soc.c
... ... @@ -6,10 +6,12 @@
6 6  
7 7 #include <common.h>
8 8 #include <clock_legacy.h>
  9 +#include <cpu_func.h>
9 10 #include <env.h>
10 11 #include <fsl_immap.h>
11 12 #include <fsl_ifc.h>
12 13 #include <init.h>
  14 +#include <linux/sizes.h>
13 15 #include <asm/arch/fsl_serdes.h>
14 16 #include <asm/arch/soc.h>
15 17 #include <asm/io.h>
... ... @@ -17,6 +19,7 @@
17 19 #include <asm/arch-fsl-layerscape/config.h>
18 20 #include <asm/arch-fsl-layerscape/ns_access.h>
19 21 #include <asm/arch-fsl-layerscape/fsl_icid.h>
  22 +#include <asm/gic-v3.h>
20 23 #ifdef CONFIG_LAYERSCAPE_NS_ACCESS
21 24 #include <fsl_csu.h>
22 25 #endif
23 26  
... ... @@ -30,10 +33,51 @@
30 33 #include <fsl_immap.h>
31 34 #ifdef CONFIG_TFABOOT
32 35 #include <env_internal.h>
  36 +#endif
  37 +#if defined(CONFIG_TFABOOT) || defined(CONFIG_GIC_V3_ITS)
33 38 DECLARE_GLOBAL_DATA_PTR;
34 39 #endif
35 40 #include <dm.h>
36 41 #include <linux/err.h>
  42 +
  43 +#ifdef CONFIG_GIC_V3_ITS
  44 +#define PENDTABLE_MAX_SZ ALIGN(BIT(ITS_MAX_LPI_NRBITS), SZ_64K)
  45 +#define PROPTABLE_MAX_SZ ALIGN(BIT(ITS_MAX_LPI_NRBITS) / 8, SZ_64K)
  46 +#define GIC_LPI_SIZE ALIGN(cpu_numcores() * PENDTABLE_MAX_SZ + \
  47 + PROPTABLE_MAX_SZ, SZ_1M)
  48 +static int fdt_add_resv_mem_gic_rd_tables(void *blob, u64 base, size_t size)
  49 +{
  50 + u32 phandle;
  51 + int err;
  52 + struct fdt_memory gic_rd_tables;
  53 +
  54 + gic_rd_tables.start = base;
  55 + gic_rd_tables.end = base + size - 1;
  56 + err = fdtdec_add_reserved_memory(blob, "gic-rd-tables", &gic_rd_tables,
  57 + &phandle);
  58 + if (err < 0)
  59 + debug("%s: failed to add reserved memory: %d\n", __func__, err);
  60 +
  61 + return err;
  62 +}
  63 +
  64 +int ls_gic_rd_tables_init(void *blob)
  65 +{
  66 + u64 gic_lpi_base;
  67 + int ret;
  68 +
  69 + gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
  70 + ret = fdt_add_resv_mem_gic_rd_tables(blob, gic_lpi_base, GIC_LPI_SIZE);
  71 + if (ret)
  72 + return ret;
  73 +
  74 + ret = gic_lpi_tables_init(gic_lpi_base, cpu_numcores());
  75 + if (ret)
  76 + debug("%s: failed to init gic-lpi-tables\n", __func__);
  77 +
  78 + return ret;
  79 +}
  80 +#endif
37 81  
38 82 bool soc_has_dp_ddr(void)
39 83 {
arch/arm/include/asm/arch-fsl-layerscape/soc.h
... ... @@ -133,6 +133,10 @@
133 133  
134 134 bool soc_has_dp_ddr(void);
135 135 bool soc_has_aiop(void);
  136 +
  137 +#ifdef CONFIG_GIC_V3_ITS
  138 +int ls_gic_rd_tables_init(void *blob);
  139 +#endif
136 140 #endif
137 141  
138 142 #endif /* _ASM_ARMV8_FSL_LAYERSCAPE_SOC_H_ */
board/freescale/lx2160a/lx2160a.c
... ... @@ -17,7 +17,6 @@
17 17 #include <fdt_support.h>
18 18 #include <linux/libfdt.h>
19 19 #include <linux/delay.h>
20   -#include <linux/sizes.h>
21 20 #include <fsl-mc/fsl_mc.h>
22 21 #include <env_internal.h>
23 22 #include <efi_loader.h>
24 23  
... ... @@ -31,14 +30,12 @@
31 30 #include "../common/vid.h"
32 31 #include <fsl_immap.h>
33 32 #include <asm/arch-fsl-layerscape/fsl_icid.h>
34   -#include <asm/gic-v3.h>
35 33 #include <cpu_func.h>
36 34  
37 35 #ifdef CONFIG_EMC2305
38 36 #include "../common/emc2305.h"
39 37 #endif
40 38  
41   -#define GIC_LPI_SIZE 0x200000
42 39 #if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS)
43 40 #define CFG_MUX_I2C_SDHC(reg, value) ((reg & 0x3f) | value)
44 41 #define SET_CFG_MUX1_SDHC1_SDHC(reg) (reg & 0x3f)
... ... @@ -700,21 +697,6 @@
700 697 }
701 698 #endif
702 699  
703   -#ifdef CONFIG_GIC_V3_ITS
704   -void fdt_fixup_gic_lpi_memory(void *blob, u64 gic_lpi_base)
705   -{
706   - u32 phandle;
707   - int err;
708   - struct fdt_memory gic_lpi;
709   -
710   - gic_lpi.start = gic_lpi_base;
711   - gic_lpi.end = gic_lpi_base + GIC_LPI_SIZE - 1;
712   - err = fdtdec_add_reserved_memory(blob, "gic-lpi", &gic_lpi, &phandle);
713   - if (err < 0)
714   - debug("failed to add reserved memory: %d\n", err);
715   -}
716   -#endif
717   -
718 700 #ifdef CONFIG_OF_BOARD_SETUP
719 701 int ft_board_setup(void *blob, bd_t *bd)
720 702 {
... ... @@ -726,8 +708,6 @@
726 708 u64 mc_memory_base = 0;
727 709 u64 mc_memory_size = 0;
728 710 u16 total_memory_banks;
729   - u64 gic_lpi_base;
730   - int ret;
731 711  
732 712 ft_cpu_setup(blob, bd);
733 713  
... ... @@ -746,13 +726,6 @@
746 726 base[i] = gd->bd->bi_dram[i].start;
747 727 size[i] = gd->bd->bi_dram[i].size;
748 728 }
749   -
750   -#ifdef CONFIG_GIC_V3_ITS
751   - gic_lpi_base = ALIGN(gd->arch.resv_ram - GIC_LPI_SIZE, SZ_64K);
752   - ret = fdt_fixup_gic_lpi_memory(blob, gic_lpi_base);
753   - if (!ret && gic_lpi_tables_init(gic_lpi_base, cpu_numcores()))
754   - debug("%s: failed to init gic-lpi-tables\n", __func__);
755   -#endif
756 729  
757 730 #ifdef CONFIG_RESV_RAM
758 731 /* reduce size if reserved memory is within this bank */