From: Ramon Fried <ramon.fried@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 1/3] snapdragon: added msm_board_serial() func
Date: Fri, 3 Aug 2018 16:25:35 +0300 [thread overview]
Message-ID: <20180803132537.1747-2-ramon.fried@gmail.com> (raw)
In-Reply-To: <20180803132537.1747-1-ramon.fried@gmail.com>
This commit adds a function to get the board
serial number.
In snapdragon it's actually the eMMC serial number.
Function added in a new file misc.c that will
include further snapdragon miscellaneous functions.
Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---
arch/arm/mach-snapdragon/Makefile | 1 +
arch/arm/mach-snapdragon/include/mach/misc.h | 12 +++++++
arch/arm/mach-snapdragon/misc.c | 37 ++++++++++++++++++++
3 files changed, 50 insertions(+)
create mode 100644 arch/arm/mach-snapdragon/include/mach/misc.h
create mode 100644 arch/arm/mach-snapdragon/misc.c
diff --git a/arch/arm/mach-snapdragon/Makefile b/arch/arm/mach-snapdragon/Makefile
index f375d07d03..2d94083600 100644
--- a/arch/arm/mach-snapdragon/Makefile
+++ b/arch/arm/mach-snapdragon/Makefile
@@ -8,5 +8,6 @@ obj-$(CONFIG_TARGET_DRAGONBOARD410C) += clock-apq8016.o
obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
obj-$(CONFIG_TARGET_DRAGONBOARD410C) += pinctrl-apq8016.o
obj-$(CONFIG_TARGET_DRAGONBOARD410C) += pinctrl-snapdragon.o
+obj-y += misc.o
obj-y += clock-snapdragon.o
obj-y += dram.o
diff --git a/arch/arm/mach-snapdragon/include/mach/misc.h b/arch/arm/mach-snapdragon/include/mach/misc.h
new file mode 100644
index 0000000000..5af6ae8da4
--- /dev/null
+++ b/arch/arm/mach-snapdragon/include/mach/misc.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Snapdragon DRAM
+ * Copyright (C) 2018 Ramon Fried <ramon.fried@gmail.com>
+ */
+
+#ifndef MISC_H
+#define MISC_H
+
+u32 msm_board_serial(void);
+
+#endif
diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
new file mode 100644
index 0000000000..678bd69f83
--- /dev/null
+++ b/arch/arm/mach-snapdragon/misc.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Miscellaneous Snapdragon functionality
+ *
+ * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
+ *
+ */
+
+#include <common.h>
+#include <mmc.h>
+#include <asm/arch/misc.h>
+
+/* UNSTUFF_BITS macro taken from Linux Kernel: drivers/mmc/core/sd.c */
+#define UNSTUFF_BITS(resp, start, size) \
+ ({ \
+ const int __size = size; \
+ const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \
+ const int __off = 3 - ((start) / 32); \
+ const int __shft = (start) & 31; \
+ u32 __res; \
+ \
+ __res = resp[__off] >> __shft; \
+ if (__size + __shft > 32) \
+ __res |= resp[__off - 1] << ((32 - __shft) % 32); \
+ __res & __mask; \
+ })
+
+u32 msm_board_serial(void)
+{
+ struct mmc *mmc_dev;
+
+ mmc_dev = find_mmc_device(0);
+ if (!mmc_dev)
+ return 0;
+
+ return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
+}
--
2.18.0
next prev parent reply other threads:[~2018-08-03 13:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-03 13:25 [U-Boot] [PATCH v1 0/3] Let U-Boot generate MAC address for db410 Ramon Fried
2018-08-03 13:25 ` Ramon Fried [this message]
2018-08-13 23:57 ` [U-Boot] [U-Boot, v1, 1/3] snapdragon: added msm_board_serial() func Tom Rini
2018-08-03 13:25 ` [U-Boot] [PATCH v1 2/3] snapdragon: added MAC generation functions Ramon Fried
2018-08-13 23:57 ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-08-03 13:25 ` [U-Boot] [PATCH v1 3/3] db410: alter WLAN/BT MAC address fixup Ramon Fried
2018-08-13 23:57 ` [U-Boot] [U-Boot, v1, " Tom Rini
2018-08-13 23:57 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180803132537.1747-2-ramon.fried@gmail.com \
--to=ramon.fried@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox