* [U-Boot] [PATCH 1/2] snapdragon: Add DRAM detection & FDT fixup
@ 2018-07-22 18:46 Ramon Fried
2018-07-22 18:46 ` [U-Boot] [PATCH 2/2] db410c: Fixup DRAM Ramon Fried
2018-07-30 11:18 ` [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup Tom Rini
0 siblings, 2 replies; 5+ messages in thread
From: Ramon Fried @ 2018-07-22 18:46 UTC (permalink / raw)
To: u-boot
Fixup the Linux FDT with the detection of onboard DRAM as
provided by SBL (Secondary boot loader) by reading
the shared-memory region.
Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---
arch/arm/mach-snapdragon/Makefile | 1 +
arch/arm/mach-snapdragon/dram.c | 97 ++++++++++++++++++++
arch/arm/mach-snapdragon/include/mach/dram.h | 12 +++
3 files changed, 110 insertions(+)
create mode 100644 arch/arm/mach-snapdragon/dram.c
create mode 100644 arch/arm/mach-snapdragon/include/mach/dram.h
diff --git a/arch/arm/mach-snapdragon/Makefile b/arch/arm/mach-snapdragon/Makefile
index 1d35fea912..f375d07d03 100644
--- a/arch/arm/mach-snapdragon/Makefile
+++ b/arch/arm/mach-snapdragon/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
obj-$(CONFIG_TARGET_DRAGONBOARD410C) += pinctrl-apq8016.o
obj-$(CONFIG_TARGET_DRAGONBOARD410C) += pinctrl-snapdragon.o
obj-y += clock-snapdragon.o
+obj-y += dram.o
diff --git a/arch/arm/mach-snapdragon/dram.c b/arch/arm/mach-snapdragon/dram.c
new file mode 100644
index 0000000000..2aeefa56ca
--- /dev/null
+++ b/arch/arm/mach-snapdragon/dram.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Onboard memory detection for Snapdragon boards
+ *
+ * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <smem.h>
+#include <asm/arch/dram.h>
+
+#define SMEM_USABLE_RAM_PARTITION_TABLE 402
+#define RAM_PART_NAME_LENGTH 16
+#define RAM_NUM_PART_ENTRIES 32
+#define CATEGORY_SDRAM 0x0E
+#define TYPE_SYSMEM 0x01
+
+struct smem_ram_ptable_hdr {
+ u32 magic[2];
+ u32 version;
+ u32 reserved;
+ u32 len;
+} __attribute__ ((__packed__));
+
+struct smem_ram_ptn {
+ char name[RAM_PART_NAME_LENGTH];
+ u64 start;
+ u64 size;
+ u32 attr;
+ u32 category;
+ u32 domain;
+ u32 type;
+ u32 num_partitions;
+ u32 reserved[3];
+} __attribute__ ((__packed__));
+
+struct smem_ram_ptable {
+ struct smem_ram_ptable_hdr hdr;
+ u32 reserved; /* Added for 8 bytes alignment of header */
+ struct smem_ram_ptn parts[RAM_NUM_PART_ENTRIES];
+} __attribute__ ((__packed__));
+
+#ifndef MEMORY_BANKS_MAX
+#define MEMORY_BANKS_MAX 4
+#endif
+
+int msm_fixup_memory(void *blob)
+{
+ u64 bank_start[MEMORY_BANKS_MAX];
+ u64 bank_size[MEMORY_BANKS_MAX];
+ size_t size;
+ int i;
+ int count = 0;
+ struct udevice *smem;
+ int ret;
+ struct smem_ram_ptable *ram_ptable;
+ struct smem_ram_ptn *p;
+
+ ret = uclass_get_device_by_name(UCLASS_SMEM, "smem", &smem);
+ if (ret < 0) {
+ printf("Failed to find SMEM node. Check device tree\n");
+ return 0;
+ }
+
+ ram_ptable = smem_get(smem, -1, SMEM_USABLE_RAM_PARTITION_TABLE, &size);
+
+ if (!ram_ptable) {
+ printf("Failed to find SMEM partition.\n");
+ return -ENODEV;
+ }
+
+ /* Check validy of RAM */
+ for (i = 0; i < RAM_NUM_PART_ENTRIES; i++) {
+ p = &ram_ptable->parts[i];
+ if (p->category == CATEGORY_SDRAM && p->type == TYPE_SYSMEM) {
+ bank_start[count] = p->start;
+ bank_size[count] = p->size;
+ debug("Detected memory bank %u: start: 0x%llx size: 0x%llx\n",
+ count, p->start, p->size);
+ count++;
+ }
+ }
+
+ if (!count) {
+ printf("Failed to detect any memory bank\n");
+ return -ENODEV;
+ }
+
+ ret = fdt_fixup_memory_banks(blob, bank_start, bank_size, count);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
diff --git a/arch/arm/mach-snapdragon/include/mach/dram.h b/arch/arm/mach-snapdragon/include/mach/dram.h
new file mode 100644
index 0000000000..0a9eedda41
--- /dev/null
+++ b/arch/arm/mach-snapdragon/include/mach/dram.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Snapdragon DRAM
+ * Copyright (C) 2018 Ramon Fried <ramon.fried@gmail.com>
+ */
+
+#ifndef DRAM_H
+#define DRAM_H
+
+int msm_fixup_memory(void *blob);
+
+#endif
--
2.18.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 2/2] db410c: Fixup DRAM
2018-07-22 18:46 [U-Boot] [PATCH 1/2] snapdragon: Add DRAM detection & FDT fixup Ramon Fried
@ 2018-07-22 18:46 ` Ramon Fried
2018-07-30 11:18 ` [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup Tom Rini
1 sibling, 0 replies; 5+ messages in thread
From: Ramon Fried @ 2018-07-22 18:46 UTC (permalink / raw)
To: u-boot
Call the MSM DRAM detection and fixup function to support
dynamic detection of onboard memory.
Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---
board/qualcomm/dragonboard410c/dragonboard410c.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
index 73f50e8bba..dc911785fc 100644
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
@@ -169,6 +169,8 @@ int ft_board_setup(void *blob, bd_t *bd)
fix[i].property, mac, ARP_HLEN, 1);
}
+ msm_fixup_memory(blob);
+
return 0;
}
--
2.18.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup
2018-07-22 18:46 [U-Boot] [PATCH 1/2] snapdragon: Add DRAM detection & FDT fixup Ramon Fried
2018-07-22 18:46 ` [U-Boot] [PATCH 2/2] db410c: Fixup DRAM Ramon Fried
@ 2018-07-30 11:18 ` Tom Rini
2018-07-30 11:29 ` Ramon Fried
1 sibling, 1 reply; 5+ messages in thread
From: Tom Rini @ 2018-07-30 11:18 UTC (permalink / raw)
To: u-boot
On Sun, Jul 22, 2018 at 09:46:05PM +0300, Ramon Fried wrote:
> Fixup the Linux FDT with the detection of onboard DRAM as
> provided by SBL (Secondary boot loader) by reading
> the shared-memory region.
>
> Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
This breaks 820c and adds a warning on 410c (this is with 2/2 applied as well):
aarch64: + dragonboard820c dragonboard410c
+(dragonboard820c,dragonboard410c) ret = fdt_fixup_memory_banks(blob, bank_start, bank_size, count);
+(dragonboard820c,dragonboard410c) ^~~~~~~~~~~~~~~~~~~~~~
+(dragonboard820c,dragonboard410c) msm_fixup_memory
+(dragonboard410c) msm_fixup_memory(blob);
+(dragonboard410c) ^~~~~~~~~~~~~~~~
+(dragonboard410c) fdt_fixup_memory
w+(dragonboard820c,dragonboard410c) ../arch/arm/mach-snapdragon/dram.c: In function 'msm_fixup_memory':
w+(dragonboard820c,dragonboard410c) ../arch/arm/mach-snapdragon/dram.c:91:8: warning: implicit declaration of function 'fdt_fixup_memory_banks'; did you mean 'msm_fixup_memory'? [-Wimplicit-function-declaration]
w+(dragonboard410c) ../board/qualcomm/dragonboard410c/dragonboard410c.c: In function 'ft_board_setup':
w+(dragonboard410c) ../board/qualcomm/dragonboard410c/dragonboard410c.c:183:2: warning: implicit declaration of function 'msm_fixup_memory'; did you mean 'fdt_fixup_memory'? [-Wimplicit-function-declaration]
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180730/e8dd13de/attachment.sig>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup
2018-07-30 11:18 ` [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup Tom Rini
@ 2018-07-30 11:29 ` Ramon Fried
2018-07-31 9:31 ` Ramon Fried
0 siblings, 1 reply; 5+ messages in thread
From: Ramon Fried @ 2018-07-30 11:29 UTC (permalink / raw)
To: u-boot
On July 30, 2018 2:18:17 PM GMT+03:00, Tom Rini <trini@konsulko.com> wrote:
>On Sun, Jul 22, 2018 at 09:46:05PM +0300, Ramon Fried wrote:
>
>> Fixup the Linux FDT with the detection of onboard DRAM as
>> provided by SBL (Secondary boot loader) by reading
>> the shared-memory region.
>>
>> Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
>
>This breaks 820c and adds a warning on 410c (this is with 2/2 applied
>as well):
> aarch64: + dragonboard820c dragonboard410c
>+(dragonboard820c,dragonboard410c) ret = fdt_fixup_memory_banks(blob,
>bank_start, bank_size, count);
>+(dragonboard820c,dragonboard410c) ^~~~~~~~~~~~~~~~~~~~~~
>+(dragonboard820c,dragonboard410c) msm_fixup_memory
>+(dragonboard410c) msm_fixup_memory(blob);
>+(dragonboard410c) ^~~~~~~~~~~~~~~~
>+(dragonboard410c) fdt_fixup_memory
>w+(dragonboard820c,dragonboard410c) ../arch/arm/mach-snapdragon/dram.c:
>In function 'msm_fixup_memory':
>w+(dragonboard820c,dragonboard410c)
>../arch/arm/mach-snapdragon/dram.c:91:8: warning: implicit declaration
>of function 'fdt_fixup_memory_banks'; did you mean 'msm_fixup_memory'?
>[-Wimplicit-function-declaration]
>w+(dragonboard410c)
>../board/qualcomm/dragonboard410c/dragonboard410c.c: In function
>'ft_board_setup':
>w+(dragonboard410c)
>../board/qualcomm/dragonboard410c/dragonboard410c.c:183:2: warning:
>implicit declaration of function 'msm_fixup_memory'; did you mean
>'fdt_fixup_memory'? [-Wimplicit-function-declaration]
Thanks Tom.
Strange. I don't recall it introduced warning message. Will look into it in the evening.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup
2018-07-30 11:29 ` Ramon Fried
@ 2018-07-31 9:31 ` Ramon Fried
0 siblings, 0 replies; 5+ messages in thread
From: Ramon Fried @ 2018-07-31 9:31 UTC (permalink / raw)
To: u-boot
On Mon, Jul 30, 2018 at 2:29 PM Ramon Fried <ramon.fried@gmail.com> wrote:
> On July 30, 2018 2:18:17 PM GMT+03:00, Tom Rini <trini@konsulko.com>
> wrote:
> >On Sun, Jul 22, 2018 at 09:46:05PM +0300, Ramon Fried wrote:
> >
> >> Fixup the Linux FDT with the detection of onboard DRAM as
> >> provided by SBL (Secondary boot loader) by reading
> >> the shared-memory region.
> >>
> >> Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
> >
> >This breaks 820c and adds a warning on 410c (this is with 2/2 applied
> >as well):
> > aarch64: + dragonboard820c dragonboard410c
> >+(dragonboard820c,dragonboard410c) ret = fdt_fixup_memory_banks(blob,
> >bank_start, bank_size, count);
> >+(dragonboard820c,dragonboard410c) ^~~~~~~~~~~~~~~~~~~~~~
> >+(dragonboard820c,dragonboard410c) msm_fixup_memory
> >+(dragonboard410c) msm_fixup_memory(blob);
> >+(dragonboard410c) ^~~~~~~~~~~~~~~~
> >+(dragonboard410c) fdt_fixup_memory
> >w+(dragonboard820c,dragonboard410c) ../arch/arm/mach-snapdragon/dram.c:
> >In function 'msm_fixup_memory':
> >w+(dragonboard820c,dragonboard410c)
> >../arch/arm/mach-snapdragon/dram.c:91:8: warning: implicit declaration
> >of function 'fdt_fixup_memory_banks'; did you mean 'msm_fixup_memory'?
> >[-Wimplicit-function-declaration]
> >w+(dragonboard410c)
> >../board/qualcomm/dragonboard410c/dragonboard410c.c: In function
> >'ft_board_setup':
> >w+(dragonboard410c)
> >../board/qualcomm/dragonboard410c/dragonboard410c.c:183:2: warning:
> >implicit declaration of function 'msm_fixup_memory'; did you mean
> >'fdt_fixup_memory'? [-Wimplicit-function-declaration]
>
> Thanks Tom.
> Strange. I don't recall it introduced warning message. Will look into it
> in the evening.
>
> Well. you're right, sorry for the problem. resent the patches with the fix.
Thanks,
Ramon.
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-31 9:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-22 18:46 [U-Boot] [PATCH 1/2] snapdragon: Add DRAM detection & FDT fixup Ramon Fried
2018-07-22 18:46 ` [U-Boot] [PATCH 2/2] db410c: Fixup DRAM Ramon Fried
2018-07-30 11:18 ` [U-Boot] [U-Boot, 1/2] snapdragon: Add DRAM detection & FDT fixup Tom Rini
2018-07-30 11:29 ` Ramon Fried
2018-07-31 9:31 ` Ramon Fried
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.