Commit 939911a64bdf3594651e041f3b24a93b8a380643

Authored by Tom Rini
1 parent d3f041c0c4

armv7:TI: Add <asm/ti-common/sys_proto.h> and migrate omap_hw_init_context

The omap_hw_init_context function (and assorted helpers) is the same for
all OMAP-derived parts as when CHSETTINGS are used, that's the same and
our DDR base is also always the same.  In order to make this common we
simply need to update the names of the define for DDR address space
which is also common.

Cc: Sricharan R. <r.sricharan@ti.com>
Cc: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Tom Rini <trini@ti.com>
Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Showing 7 changed files with 77 additions and 112 deletions Side-by-side Diff

arch/arm/cpu/armv7/omap-common/hwinit-common.c
... ... @@ -194,8 +194,8 @@
194 194 addr = section & EMIF_SYS_ADDR_MASK;
195 195  
196 196 /* See if the address is valid */
197   - if ((addr >= DRAM_ADDR_SPACE_START) &&
198   - (addr < DRAM_ADDR_SPACE_END)) {
  197 + if ((addr >= TI_ARMV7_DRAM_ADDR_SPACE_START) &&
  198 + (addr < TI_ARMV7_DRAM_ADDR_SPACE_END)) {
199 199 size = ((section & EMIF_SYS_SIZE_MASK) >>
200 200 EMIF_SYS_SIZE_SHIFT);
201 201 size = 1 << size;
arch/arm/include/asm/arch-am33xx/sys_proto.h
... ... @@ -11,6 +11,7 @@
11 11 #ifndef _SYS_PROTO_H_
12 12 #define _SYS_PROTO_H_
13 13 #include <linux/mtd/omap_gpmc.h>
  14 +#include <asm/ti-common/sys_proto.h>
14 15 #include <asm/arch/cpu.h>
15 16  
16 17 #define BOARD_REV_ID 0x0
arch/arm/include/asm/arch-omap4/sys_proto.h
... ... @@ -14,6 +14,7 @@
14 14 #include <asm/omap_common.h>
15 15 #include <linux/mtd/omap_gpmc.h>
16 16 #include <asm/arch/mux_omap4.h>
  17 +#include <asm/ti-common/sys_proto.h>
17 18  
18 19 DECLARE_GLOBAL_DATA_PTR;
19 20  
... ... @@ -53,55 +54,5 @@
53 54 u32 warm_reset(void);
54 55 void force_emif_self_refresh(void);
55 56 void setup_warmreset_time(void);
56   -
57   -static inline u32 running_from_sdram(void)
58   -{
59   - u32 pc;
60   - asm volatile ("mov %0, pc" : "=r" (pc));
61   - return ((pc >= OMAP44XX_DRAM_ADDR_SPACE_START) &&
62   - (pc < OMAP44XX_DRAM_ADDR_SPACE_END));
63   -}
64   -
65   -static inline u8 uboot_loaded_by_spl(void)
66   -{
67   - /*
68   - * u-boot can be running from sdram either because of configuration
69   - * Header or by SPL. If because of CH, then the romcode sets the
70   - * CHSETTINGS executed bit to true in the boot parameter structure that
71   - * it passes to the bootloader.This parameter is stored in the ch_flags
72   - * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a
73   - * mandatory section if CH is present.
74   - */
75   - if ((gd->arch.omap_boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS))
76   - return 0;
77   - else
78   - return running_from_sdram();
79   -}
80   -/*
81   - * The basic hardware init of OMAP(s_init()) can happen in 4
82   - * different contexts:
83   - * 1. SPL running from SRAM
84   - * 2. U-Boot running from FLASH
85   - * 3. Non-XIP U-Boot loaded to SDRAM by SPL
86   - * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
87   - * Configuration Header feature
88   - *
89   - * This function finds this context.
90   - * Defining as inline may help in compiling out unused functions in SPL
91   - */
92   -static inline u32 omap_hw_init_context(void)
93   -{
94   -#ifdef CONFIG_SPL_BUILD
95   - return OMAP_INIT_CONTEXT_SPL;
96   -#else
97   - if (uboot_loaded_by_spl())
98   - return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
99   - else if (running_from_sdram())
100   - return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
101   - else
102   - return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
103   -#endif
104   -}
105   -
106 57 #endif
arch/arm/include/asm/arch-omap5/omap.h
... ... @@ -23,11 +23,6 @@
23 23 #define OMAP54XX_L4_WKUP_BASE 0x4Ae00000
24 24 #define OMAP54XX_L4_PER_BASE 0x48000000
25 25  
26   -#define OMAP54XX_DRAM_ADDR_SPACE_START 0x80000000
27   -#define OMAP54XX_DRAM_ADDR_SPACE_END 0xFFFFFFFF
28   -#define DRAM_ADDR_SPACE_START OMAP54XX_DRAM_ADDR_SPACE_START
29   -#define DRAM_ADDR_SPACE_END OMAP54XX_DRAM_ADDR_SPACE_END
30   -
31 26 /* CONTROL ID CODE */
32 27 #define CONTROL_CORE_ID_CODE 0x4A002204
33 28 #define CONTROL_WKUP_ID_CODE 0x4AE0C204
arch/arm/include/asm/arch-omap5/sys_proto.h
... ... @@ -14,6 +14,7 @@
14 14 #include <asm/omap_common.h>
15 15 #include <linux/mtd/omap_gpmc.h>
16 16 #include <asm/arch/clock.h>
  17 +#include <asm/ti-common/sys_proto.h>
17 18  
18 19 DECLARE_GLOBAL_DATA_PTR;
19 20  
... ... @@ -55,55 +56,6 @@
55 56 void get_ioregs(const struct ctrl_ioregs **regs);
56 57 void srcomp_enable(void);
57 58 void setup_warmreset_time(void);
58   -
59   -static inline u32 running_from_sdram(void)
60   -{
61   - u32 pc;
62   - asm volatile ("mov %0, pc" : "=r" (pc));
63   - return ((pc >= OMAP54XX_DRAM_ADDR_SPACE_START) &&
64   - (pc < OMAP54XX_DRAM_ADDR_SPACE_END));
65   -}
66   -
67   -static inline u8 uboot_loaded_by_spl(void)
68   -{
69   - /*
70   - * u-boot can be running from sdram either because of configuration
71   - * Header or by SPL. If because of CH, then the romcode sets the
72   - * CHSETTINGS executed bit to true in the boot parameter structure that
73   - * it passes to the bootloader.This parameter is stored in the ch_flags
74   - * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a
75   - * mandatory section if CH is present.
76   - */
77   - if ((gd->arch.omap_boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS))
78   - return 0;
79   - else
80   - return running_from_sdram();
81   -}
82   -/*
83   - * The basic hardware init of OMAP(s_init()) can happen in 4
84   - * different contexts:
85   - * 1. SPL running from SRAM
86   - * 2. U-Boot running from FLASH
87   - * 3. Non-XIP U-Boot loaded to SDRAM by SPL
88   - * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
89   - * Configuration Header feature
90   - *
91   - * This function finds this context.
92   - * Defining as inline may help in compiling out unused functions in SPL
93   - */
94   -static inline u32 omap_hw_init_context(void)
95   -{
96   -#ifdef CONFIG_SPL_BUILD
97   - return OMAP_INIT_CONTEXT_SPL;
98   -#else
99   - if (uboot_loaded_by_spl())
100   - return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
101   - else if (running_from_sdram())
102   - return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
103   - else
104   - return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
105   -#endif
106   -}
107 59  
108 60 static inline u32 div_round_up(u32 num, u32 den)
109 61 {
arch/arm/include/asm/omap_common.h
... ... @@ -576,12 +576,6 @@
576 576  
577 577 void usb_fake_mac_from_die_id(u32 *id);
578 578  
579   -/* HW Init Context */
580   -#define OMAP_INIT_CONTEXT_SPL 0
581   -#define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR 1
582   -#define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL 2
583   -#define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH 3
584   -
585 579 /* ABB */
586 580 #define OMAP_ABB_NOMINAL_OPP 0
587 581 #define OMAP_ABB_FAST_OPP 1
arch/arm/include/asm/ti-common/sys_proto.h
  1 +/*
  2 + * (C) Copyright 2014
  3 + * Texas Instruments, <www.ti.com>
  4 + *
  5 + * SPDX-License-Identifier: GPL-2.0+
  6 + */
  7 +#ifndef _TI_COMMON_SYS_PROTO_H_
  8 +#define _TI_COMMON_SYS_PROTO_H_
  9 +
  10 +DECLARE_GLOBAL_DATA_PTR;
  11 +
  12 +#ifdef CONFIG_OMAP_COMMON
  13 +#define TI_ARMV7_DRAM_ADDR_SPACE_START 0x80000000
  14 +#define TI_ARMV7_DRAM_ADDR_SPACE_END 0xFFFFFFFF
  15 +
  16 +#define OMAP_INIT_CONTEXT_SPL 0
  17 +#define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR 1
  18 +#define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL 2
  19 +#define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH 3
  20 +
  21 +static inline u32 running_from_sdram(void)
  22 +{
  23 + u32 pc;
  24 + asm volatile ("mov %0, pc" : "=r" (pc));
  25 + return ((pc >= TI_ARMV7_DRAM_ADDR_SPACE_START) &&
  26 + (pc < TI_ARMV7_DRAM_ADDR_SPACE_END));
  27 +}
  28 +
  29 +static inline u8 uboot_loaded_by_spl(void)
  30 +{
  31 + /*
  32 + * u-boot can be running from sdram either because of configuration
  33 + * Header or by SPL. If because of CH, then the romcode sets the
  34 + * CHSETTINGS executed bit to true in the boot parameter structure that
  35 + * it passes to the bootloader.This parameter is stored in the ch_flags
  36 + * variable by both SPL and u-boot.Check out for CHSETTINGS, which is a
  37 + * mandatory section if CH is present.
  38 + */
  39 + if ((gd->arch.omap_boot_params.ch_flags) & (CH_FLAGS_CHSETTINGS))
  40 + return 0;
  41 + else
  42 + return running_from_sdram();
  43 +}
  44 +
  45 +/*
  46 + * The basic hardware init of OMAP(s_init()) can happen in 4
  47 + * different contexts:
  48 + * 1. SPL running from SRAM
  49 + * 2. U-Boot running from FLASH
  50 + * 3. Non-XIP U-Boot loaded to SDRAM by SPL
  51 + * 4. Non-XIP U-Boot loaded to SDRAM by ROM code using the
  52 + * Configuration Header feature
  53 + *
  54 + * This function finds this context.
  55 + * Defining as inline may help in compiling out unused functions in SPL
  56 + */
  57 +static inline u32 omap_hw_init_context(void)
  58 +{
  59 +#ifdef CONFIG_SPL_BUILD
  60 + return OMAP_INIT_CONTEXT_SPL;
  61 +#else
  62 + if (uboot_loaded_by_spl())
  63 + return OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL;
  64 + else if (running_from_sdram())
  65 + return OMAP_INIT_CONTEXT_UBOOT_AFTER_CH;
  66 + else
  67 + return OMAP_INIT_CONTEXT_UBOOT_FROM_NOR;
  68 +#endif
  69 +}
  70 +#endif
  71 +
  72 +#endif