Commit 51637afe98ba1745976382f64afc270f7f0b6974

Authored by Hans de Goede
1 parent 20779ec3a5

sunxi: dram: Un-inline dram helper functions

Move the dram helper functions to a separate C file, rather then having them
as inline helpers in dram.h. This saves 144 bytes in the .text segment for
sun6i builds.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 3 changed files with 40 additions and 26 deletions Side-by-side Diff

arch/arm/cpu/armv7/sunxi/Makefile
... ... @@ -11,6 +11,7 @@
11 11 obj-y += board.o
12 12 obj-y += clock.o
13 13 obj-y += cpu_info.o
  14 +obj-y += dram_helpers.o
14 15 obj-y += pinmux.o
15 16 obj-y += usbc.o
16 17 obj-$(CONFIG_MACH_SUN6I) += prcm.o
arch/arm/cpu/armv7/sunxi/dram_helpers.c
  1 +/*
  2 + * DRAM init helper functions
  3 + *
  4 + * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
  5 + *
  6 + * SPDX-License-Identifier: GPL-2.0+
  7 + */
  8 +
  9 +#include <common.h>
  10 +#include <asm/io.h>
  11 +#include <asm/arch/dram.h>
  12 +
  13 +/*
  14 + * Wait up to 1s for value to be set in given part of reg.
  15 + */
  16 +void mctl_await_completion(u32 *reg, u32 mask, u32 val)
  17 +{
  18 + unsigned long tmo = timer_get_us() + 1000000;
  19 +
  20 + while ((readl(reg) & mask) != val) {
  21 + if (timer_get_us() > tmo)
  22 + panic("Timeout initialising DRAM\n");
  23 + }
  24 +}
  25 +
  26 +/*
  27 + * Test if memory at offset offset matches memory at begin of DRAM
  28 + */
  29 +bool mctl_mem_matches(u32 offset)
  30 +{
  31 + /* Try to write different values to RAM at two addresses */
  32 + writel(0, CONFIG_SYS_SDRAM_BASE);
  33 + writel(0xaa55aa55, CONFIG_SYS_SDRAM_BASE + offset);
  34 + /* Check if the same value is actually observed when reading back */
  35 + return readl(CONFIG_SYS_SDRAM_BASE) ==
  36 + readl(CONFIG_SYS_SDRAM_BASE + offset);
  37 +}
arch/arm/include/asm/arch-sunxi/dram.h
... ... @@ -25,32 +25,8 @@
25 25 #endif
26 26  
27 27 unsigned long sunxi_dram_init(void);
28   -
29   -/*
30   - * Wait up to 1s for value to be set in given part of reg.
31   - */
32   -static inline void mctl_await_completion(u32 *reg, u32 mask, u32 val)
33   -{
34   - unsigned long tmo = timer_get_us() + 1000000;
35   -
36   - while ((readl(reg) & mask) != val) {
37   - if (timer_get_us() > tmo)
38   - panic("Timeout initialising DRAM\n");
39   - }
40   -}
41   -
42   -/*
43   - * Test if memory at offset offset matches memory at begin of DRAM
44   - */
45   -static inline bool mctl_mem_matches(u32 offset)
46   -{
47   - /* Try to write different values to RAM at two addresses */
48   - writel(0, CONFIG_SYS_SDRAM_BASE);
49   - writel(0xaa55aa55, CONFIG_SYS_SDRAM_BASE + offset);
50   - /* Check if the same value is actually observed when reading back */
51   - return readl(CONFIG_SYS_SDRAM_BASE) ==
52   - readl(CONFIG_SYS_SDRAM_BASE + offset);
53   -}
  28 +void mctl_await_completion(u32 *reg, u32 mask, u32 val);
  29 +bool mctl_mem_matches(u32 offset);
54 30  
55 31 #endif /* _SUNXI_DRAM_H */