diff mbox series

[v2,13/32] board: dragonboard410c: import board code from mach-snapdragon

Message ID 20231219-b4-qcom-common-target-v2-13-b6dd9704219e@linaro.org
State New
Headers show
Series Qualcomm generic board support | expand

Commit Message

Caleb Connolly Dec. 19, 2023, 4:04 p.m. UTC
Some of the db410c board support code was written to be generic and
placed in mach-snapdragon. However, as the db410c is the only board
using this, move the code out of mach-snapdragon. This makes is more
obvious what code is relevant for which targets and helps tidy things up
a little more.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 arch/arm/mach-snapdragon/Makefile                  |  2 -
 arch/arm/mach-snapdragon/include/mach/dram.h       | 12 -----
 arch/arm/mach-snapdragon/misc.c                    | 55 ----------------------
 board/qualcomm/dragonboard410c/Makefile            |  3 +-
 board/qualcomm/dragonboard410c/dragonboard410c.c   |  4 +-
 .../qualcomm/dragonboard410c/misc.c                | 51 +++++++++++++++++++-
 .../mach => board/qualcomm/dragonboard410c}/misc.h |  1 +
 7 files changed, 54 insertions(+), 74 deletions(-)

Comments

Sumit Garg Dec. 20, 2023, 1:47 p.m. UTC | #1
Hi Caleb,

On Tue, 19 Dec 2023 at 21:34, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>
> Some of the db410c board support code was written to be generic and
> placed in mach-snapdragon. However, as the db410c is the only board
> using this, move the code out of mach-snapdragon. This makes is more
> obvious what code is relevant for which targets and helps tidy things up
> a little more.

This change will be incompatible with HMIBSC board support being
proposed in the other thread. It will lead to further code duplication
among boards. You should rather reverse it to keep APQ8016 SoC
specific changes in mach-snapdragon and let the derivative boards use
them.

-Sumit

>
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
>  arch/arm/mach-snapdragon/Makefile                  |  2 -
>  arch/arm/mach-snapdragon/include/mach/dram.h       | 12 -----
>  arch/arm/mach-snapdragon/misc.c                    | 55 ----------------------
>  board/qualcomm/dragonboard410c/Makefile            |  3 +-
>  board/qualcomm/dragonboard410c/dragonboard410c.c   |  4 +-
>  .../qualcomm/dragonboard410c/misc.c                | 51 +++++++++++++++++++-
>  .../mach => board/qualcomm/dragonboard410c}/misc.h |  1 +
>  7 files changed, 54 insertions(+), 74 deletions(-)
>
> diff --git a/arch/arm/mach-snapdragon/Makefile b/arch/arm/mach-snapdragon/Makefile
> index 3a3a297c1768..d02432df8b04 100644
> --- a/arch/arm/mach-snapdragon/Makefile
> +++ b/arch/arm/mach-snapdragon/Makefile
> @@ -6,6 +6,4 @@ obj-$(CONFIG_SDM845) += sysmap-sdm845.o
>  obj-$(CONFIG_SDM845) += init_sdm845.o
>  obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
>  obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
> -obj-y += misc.o
> -obj-y += dram.o
>  obj-$(CONFIG_TARGET_QCS404EVB) += sysmap-qcs404.o
> diff --git a/arch/arm/mach-snapdragon/include/mach/dram.h b/arch/arm/mach-snapdragon/include/mach/dram.h
> deleted file mode 100644
> index 0a9eedda414c..000000000000
> --- a/arch/arm/mach-snapdragon/include/mach/dram.h
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -/* 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
> diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
> deleted file mode 100644
> index 7d452f4529b7..000000000000
> --- a/arch/arm/mach-snapdragon/misc.c
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -// 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>
> -#include <asm/unaligned.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;
> -
> -       if (mmc_init(mmc_dev))
> -               return 0;
> -
> -       return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
> -}
> -
> -void msm_generate_mac_addr(u8 *mac)
> -{
> -       /* use locally adminstrated pool */
> -       mac[0] = 0x02;
> -       mac[1] = 0x00;
> -
> -       /*
> -        * Put the 32-bit serial number in the last 32-bit of the MAC address.
> -        * Use big endian order so it is consistent with the serial number
> -        * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
> -        */
> -       put_unaligned_be32(msm_board_serial(), &mac[2]);
> -}
> diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile
> index 1b99c8b0efef..a3ae1a5f9136 100644
> --- a/board/qualcomm/dragonboard410c/Makefile
> +++ b/board/qualcomm/dragonboard410c/Makefile
> @@ -2,4 +2,5 @@
>  #
>  # (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
>
> -obj-y  := dragonboard410c.o
> +obj-y += dragonboard410c.o
> +obj-y += misc.o
> diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
> index 1adac07569ae..eea603a4148d 100644
> --- a/board/qualcomm/dragonboard410c/dragonboard410c.c
> +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
> @@ -18,10 +18,10 @@
>  #include <asm/global_data.h>
>  #include <asm/gpio.h>
>  #include <fdt_support.h>
> -#include <asm/arch/dram.h>
> -#include <asm/arch/misc.h>
>  #include <linux/delay.h>
>
> +#include "misc.h"
> +
>  DECLARE_GLOBAL_DATA_PTR;
>
>  #define USB_HUB_RESET_GPIO 2
> diff --git a/arch/arm/mach-snapdragon/dram.c b/board/qualcomm/dragonboard410c/misc.c
> similarity index 64%
> rename from arch/arm/mach-snapdragon/dram.c
> rename to board/qualcomm/dragonboard410c/misc.c
> index 499dfdf0da6e..27d51ef78914 100644
> --- a/arch/arm/mach-snapdragon/dram.c
> +++ b/board/qualcomm/dragonboard410c/misc.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> - * Onboard memory detection for Snapdragon boards
> + * Miscellaneous Snapdragon functionality
>   *
>   * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
>   *
> @@ -9,10 +9,56 @@
>  #include <common.h>
>  #include <dm.h>
>  #include <log.h>
> +#include <mmc.h>
>  #include <part.h>
>  #include <smem.h>
>  #include <fdt_support.h>
> -#include <asm/arch/dram.h>
> +#include <asm/unaligned.h>
> +
> +#include "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;
> +
> +       if (mmc_init(mmc_dev))
> +               return 0;
> +
> +       return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
> +}
> +
> +void msm_generate_mac_addr(u8 *mac)
> +{
> +       /* use locally adminstrated pool */
> +       mac[0] = 0x02;
> +       mac[1] = 0x00;
> +
> +       /*
> +        * Put the 32-bit serial number in the last 32-bit of the MAC address.
> +        * Use big endian order so it is consistent with the serial number
> +        * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
> +        */
> +       put_unaligned_be32(msm_board_serial(), &mac[2]);
> +}
>
>  #define SMEM_USABLE_RAM_PARTITION_TABLE 402
>  #define RAM_PART_NAME_LENGTH            16
> @@ -97,3 +143,4 @@ int msm_fixup_memory(void *blob)
>
>         return 0;
>  }
> +
> diff --git a/arch/arm/mach-snapdragon/include/mach/misc.h b/board/qualcomm/dragonboard410c/misc.h
> similarity index 87%
> rename from arch/arm/mach-snapdragon/include/mach/misc.h
> rename to board/qualcomm/dragonboard410c/misc.h
> index c60e3e472470..fe44caf51b18 100644
> --- a/arch/arm/mach-snapdragon/include/mach/misc.h
> +++ b/board/qualcomm/dragonboard410c/misc.h
> @@ -9,5 +9,6 @@
>
>  u32 msm_board_serial(void);
>  void msm_generate_mac_addr(u8 *mac);
> +int msm_fixup_memory(void *blob);
>
>  #endif
>
> --
> 2.42.1
>
Neil Armstrong Dec. 21, 2023, 4:24 p.m. UTC | #2
On 19/12/2023 17:04, Caleb Connolly wrote:
> Some of the db410c board support code was written to be generic and
> placed in mach-snapdragon. However, as the db410c is the only board
> using this, move the code out of mach-snapdragon. This makes is more
> obvious what code is relevant for which targets and helps tidy things up
> a little more.
> 
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
>   arch/arm/mach-snapdragon/Makefile                  |  2 -
>   arch/arm/mach-snapdragon/include/mach/dram.h       | 12 -----
>   arch/arm/mach-snapdragon/misc.c                    | 55 ----------------------
>   board/qualcomm/dragonboard410c/Makefile            |  3 +-
>   board/qualcomm/dragonboard410c/dragonboard410c.c   |  4 +-
>   .../qualcomm/dragonboard410c/misc.c                | 51 +++++++++++++++++++-
>   .../mach => board/qualcomm/dragonboard410c}/misc.h |  1 +
>   7 files changed, 54 insertions(+), 74 deletions(-)
> 
> diff --git a/arch/arm/mach-snapdragon/Makefile b/arch/arm/mach-snapdragon/Makefile
> index 3a3a297c1768..d02432df8b04 100644
> --- a/arch/arm/mach-snapdragon/Makefile
> +++ b/arch/arm/mach-snapdragon/Makefile
> @@ -6,6 +6,4 @@ obj-$(CONFIG_SDM845) += sysmap-sdm845.o
>   obj-$(CONFIG_SDM845) += init_sdm845.o
>   obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
>   obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
> -obj-y += misc.o
> -obj-y += dram.o
>   obj-$(CONFIG_TARGET_QCS404EVB) += sysmap-qcs404.o
> diff --git a/arch/arm/mach-snapdragon/include/mach/dram.h b/arch/arm/mach-snapdragon/include/mach/dram.h
> deleted file mode 100644
> index 0a9eedda414c..000000000000
> --- a/arch/arm/mach-snapdragon/include/mach/dram.h
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -/* 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
> diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
> deleted file mode 100644
> index 7d452f4529b7..000000000000
> --- a/arch/arm/mach-snapdragon/misc.c
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -// 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>
> -#include <asm/unaligned.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;
> -
> -	if (mmc_init(mmc_dev))
> -		return 0;
> -
> -	return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
> -}
> -
> -void msm_generate_mac_addr(u8 *mac)
> -{
> -	/* use locally adminstrated pool */
> -	mac[0] = 0x02;
> -	mac[1] = 0x00;
> -
> -	/*
> -	 * Put the 32-bit serial number in the last 32-bit of the MAC address.
> -	 * Use big endian order so it is consistent with the serial number
> -	 * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
> -	 */
> -	put_unaligned_be32(msm_board_serial(), &mac[2]);
> -}
> diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile
> index 1b99c8b0efef..a3ae1a5f9136 100644
> --- a/board/qualcomm/dragonboard410c/Makefile
> +++ b/board/qualcomm/dragonboard410c/Makefile
> @@ -2,4 +2,5 @@
>   #
>   # (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
>   
> -obj-y	:= dragonboard410c.o
> +obj-y += dragonboard410c.o
> +obj-y += misc.o
> diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
> index 1adac07569ae..eea603a4148d 100644
> --- a/board/qualcomm/dragonboard410c/dragonboard410c.c
> +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
> @@ -18,10 +18,10 @@
>   #include <asm/global_data.h>
>   #include <asm/gpio.h>
>   #include <fdt_support.h>
> -#include <asm/arch/dram.h>
> -#include <asm/arch/misc.h>
>   #include <linux/delay.h>
>   
> +#include "misc.h"
> +
>   DECLARE_GLOBAL_DATA_PTR;
>   
>   #define USB_HUB_RESET_GPIO 2
> diff --git a/arch/arm/mach-snapdragon/dram.c b/board/qualcomm/dragonboard410c/misc.c
> similarity index 64%
> rename from arch/arm/mach-snapdragon/dram.c
> rename to board/qualcomm/dragonboard410c/misc.c
> index 499dfdf0da6e..27d51ef78914 100644
> --- a/arch/arm/mach-snapdragon/dram.c
> +++ b/board/qualcomm/dragonboard410c/misc.c
> @@ -1,6 +1,6 @@
>   // SPDX-License-Identifier: GPL-2.0+
>   /*
> - * Onboard memory detection for Snapdragon boards
> + * Miscellaneous Snapdragon functionality
>    *
>    * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
>    *
> @@ -9,10 +9,56 @@
>   #include <common.h>
>   #include <dm.h>
>   #include <log.h>
> +#include <mmc.h>
>   #include <part.h>
>   #include <smem.h>
>   #include <fdt_support.h>
> -#include <asm/arch/dram.h>
> +#include <asm/unaligned.h>
> +
> +#include "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;
> +
> +	if (mmc_init(mmc_dev))
> +		return 0;
> +
> +	return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
> +}
> +
> +void msm_generate_mac_addr(u8 *mac)
> +{
> +	/* use locally adminstrated pool */
> +	mac[0] = 0x02;
> +	mac[1] = 0x00;
> +
> +	/*
> +	 * Put the 32-bit serial number in the last 32-bit of the MAC address.
> +	 * Use big endian order so it is consistent with the serial number
> +	 * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
> +	 */
> +	put_unaligned_be32(msm_board_serial(), &mac[2]);
> +}
>   
>   #define SMEM_USABLE_RAM_PARTITION_TABLE 402
>   #define RAM_PART_NAME_LENGTH            16
> @@ -97,3 +143,4 @@ int msm_fixup_memory(void *blob)
>   
>   	return 0;
>   }
> +

Spurious newline

> diff --git a/arch/arm/mach-snapdragon/include/mach/misc.h b/board/qualcomm/dragonboard410c/misc.h
> similarity index 87%
> rename from arch/arm/mach-snapdragon/include/mach/misc.h
> rename to board/qualcomm/dragonboard410c/misc.h
> index c60e3e472470..fe44caf51b18 100644
> --- a/arch/arm/mach-snapdragon/include/mach/misc.h
> +++ b/board/qualcomm/dragonboard410c/misc.h
> @@ -9,5 +9,6 @@
>   
>   u32 msm_board_serial(void);
>   void msm_generate_mac_addr(u8 *mac);
> +int msm_fixup_memory(void *blob);
>   
>   #endif
> 

With this fixed:
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Caleb Connolly Jan. 16, 2024, 1:33 p.m. UTC | #3
On 20/12/2023 13:47, Sumit Garg wrote:
> Hi Caleb,
> 
> On Tue, 19 Dec 2023 at 21:34, Caleb Connolly <caleb.connolly@linaro.org> wrote:
>>
>> Some of the db410c board support code was written to be generic and
>> placed in mach-snapdragon. However, as the db410c is the only board
>> using this, move the code out of mach-snapdragon. This makes is more
>> obvious what code is relevant for which targets and helps tidy things up
>> a little more.
> 
> This change will be incompatible with HMIBSC board support being
> proposed in the other thread. It will lead to further code duplication
> among boards. You should rather reverse it to keep APQ8016 SoC
> specific changes in mach-snapdragon and let the derivative boards use
> them.

Re-capping our off-list discussion: the HMIBSC board only depends on the
usb init code and button handling code.

The usb init code will be moved to mach-snapdragon in the next revision
of this series, and the button code will eventually be handled by my
proposed "button cmd" patch.

The smem code (msm_fixup_memory()) will be dropped in favour of using DT
as the source of truth.
> 
> -Sumit
> 
>>
>> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
>> ---
>>  arch/arm/mach-snapdragon/Makefile                  |  2 -
>>  arch/arm/mach-snapdragon/include/mach/dram.h       | 12 -----
>>  arch/arm/mach-snapdragon/misc.c                    | 55 ----------------------
>>  board/qualcomm/dragonboard410c/Makefile            |  3 +-
>>  board/qualcomm/dragonboard410c/dragonboard410c.c   |  4 +-
>>  .../qualcomm/dragonboard410c/misc.c                | 51 +++++++++++++++++++-
>>  .../mach => board/qualcomm/dragonboard410c}/misc.h |  1 +
>>  7 files changed, 54 insertions(+), 74 deletions(-)
>>
>> diff --git a/arch/arm/mach-snapdragon/Makefile b/arch/arm/mach-snapdragon/Makefile
>> index 3a3a297c1768..d02432df8b04 100644
>> --- a/arch/arm/mach-snapdragon/Makefile
>> +++ b/arch/arm/mach-snapdragon/Makefile
>> @@ -6,6 +6,4 @@ obj-$(CONFIG_SDM845) += sysmap-sdm845.o
>>  obj-$(CONFIG_SDM845) += init_sdm845.o
>>  obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
>>  obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
>> -obj-y += misc.o
>> -obj-y += dram.o
>>  obj-$(CONFIG_TARGET_QCS404EVB) += sysmap-qcs404.o
>> diff --git a/arch/arm/mach-snapdragon/include/mach/dram.h b/arch/arm/mach-snapdragon/include/mach/dram.h
>> deleted file mode 100644
>> index 0a9eedda414c..000000000000
>> --- a/arch/arm/mach-snapdragon/include/mach/dram.h
>> +++ /dev/null
>> @@ -1,12 +0,0 @@
>> -/* 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
>> diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
>> deleted file mode 100644
>> index 7d452f4529b7..000000000000
>> --- a/arch/arm/mach-snapdragon/misc.c
>> +++ /dev/null
>> @@ -1,55 +0,0 @@
>> -// 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>
>> -#include <asm/unaligned.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;
>> -
>> -       if (mmc_init(mmc_dev))
>> -               return 0;
>> -
>> -       return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
>> -}
>> -
>> -void msm_generate_mac_addr(u8 *mac)
>> -{
>> -       /* use locally adminstrated pool */
>> -       mac[0] = 0x02;
>> -       mac[1] = 0x00;
>> -
>> -       /*
>> -        * Put the 32-bit serial number in the last 32-bit of the MAC address.
>> -        * Use big endian order so it is consistent with the serial number
>> -        * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
>> -        */
>> -       put_unaligned_be32(msm_board_serial(), &mac[2]);
>> -}
>> diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile
>> index 1b99c8b0efef..a3ae1a5f9136 100644
>> --- a/board/qualcomm/dragonboard410c/Makefile
>> +++ b/board/qualcomm/dragonboard410c/Makefile
>> @@ -2,4 +2,5 @@
>>  #
>>  # (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
>>
>> -obj-y  := dragonboard410c.o
>> +obj-y += dragonboard410c.o
>> +obj-y += misc.o
>> diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
>> index 1adac07569ae..eea603a4148d 100644
>> --- a/board/qualcomm/dragonboard410c/dragonboard410c.c
>> +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
>> @@ -18,10 +18,10 @@
>>  #include <asm/global_data.h>
>>  #include <asm/gpio.h>
>>  #include <fdt_support.h>
>> -#include <asm/arch/dram.h>
>> -#include <asm/arch/misc.h>
>>  #include <linux/delay.h>
>>
>> +#include "misc.h"
>> +
>>  DECLARE_GLOBAL_DATA_PTR;
>>
>>  #define USB_HUB_RESET_GPIO 2
>> diff --git a/arch/arm/mach-snapdragon/dram.c b/board/qualcomm/dragonboard410c/misc.c
>> similarity index 64%
>> rename from arch/arm/mach-snapdragon/dram.c
>> rename to board/qualcomm/dragonboard410c/misc.c
>> index 499dfdf0da6e..27d51ef78914 100644
>> --- a/arch/arm/mach-snapdragon/dram.c
>> +++ b/board/qualcomm/dragonboard410c/misc.c
>> @@ -1,6 +1,6 @@
>>  // SPDX-License-Identifier: GPL-2.0+
>>  /*
>> - * Onboard memory detection for Snapdragon boards
>> + * Miscellaneous Snapdragon functionality
>>   *
>>   * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
>>   *
>> @@ -9,10 +9,56 @@
>>  #include <common.h>
>>  #include <dm.h>
>>  #include <log.h>
>> +#include <mmc.h>
>>  #include <part.h>
>>  #include <smem.h>
>>  #include <fdt_support.h>
>> -#include <asm/arch/dram.h>
>> +#include <asm/unaligned.h>
>> +
>> +#include "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;
>> +
>> +       if (mmc_init(mmc_dev))
>> +               return 0;
>> +
>> +       return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
>> +}
>> +
>> +void msm_generate_mac_addr(u8 *mac)
>> +{
>> +       /* use locally adminstrated pool */
>> +       mac[0] = 0x02;
>> +       mac[1] = 0x00;
>> +
>> +       /*
>> +        * Put the 32-bit serial number in the last 32-bit of the MAC address.
>> +        * Use big endian order so it is consistent with the serial number
>> +        * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
>> +        */
>> +       put_unaligned_be32(msm_board_serial(), &mac[2]);
>> +}
>>
>>  #define SMEM_USABLE_RAM_PARTITION_TABLE 402
>>  #define RAM_PART_NAME_LENGTH            16
>> @@ -97,3 +143,4 @@ int msm_fixup_memory(void *blob)
>>
>>         return 0;
>>  }
>> +
>> diff --git a/arch/arm/mach-snapdragon/include/mach/misc.h b/board/qualcomm/dragonboard410c/misc.h
>> similarity index 87%
>> rename from arch/arm/mach-snapdragon/include/mach/misc.h
>> rename to board/qualcomm/dragonboard410c/misc.h
>> index c60e3e472470..fe44caf51b18 100644
>> --- a/arch/arm/mach-snapdragon/include/mach/misc.h
>> +++ b/board/qualcomm/dragonboard410c/misc.h
>> @@ -9,5 +9,6 @@
>>
>>  u32 msm_board_serial(void);
>>  void msm_generate_mac_addr(u8 *mac);
>> +int msm_fixup_memory(void *blob);
>>
>>  #endif
>>
>> --
>> 2.42.1
>>
Ramon Fried Jan. 18, 2024, 9:50 p.m. UTC | #4
On Tue, Dec 19, 2023 at 6:04 PM Caleb Connolly
<caleb.connolly@linaro.org> wrote:
>
> Some of the db410c board support code was written to be generic and
> placed in mach-snapdragon. However, as the db410c is the only board
> using this, move the code out of mach-snapdragon. This makes is more
> obvious what code is relevant for which targets and helps tidy things up
> a little more.
>
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
>  arch/arm/mach-snapdragon/Makefile                  |  2 -
>  arch/arm/mach-snapdragon/include/mach/dram.h       | 12 -----
>  arch/arm/mach-snapdragon/misc.c                    | 55 ----------------------
>  board/qualcomm/dragonboard410c/Makefile            |  3 +-
>  board/qualcomm/dragonboard410c/dragonboard410c.c   |  4 +-
>  .../qualcomm/dragonboard410c/misc.c                | 51 +++++++++++++++++++-
>  .../mach => board/qualcomm/dragonboard410c}/misc.h |  1 +
>  7 files changed, 54 insertions(+), 74 deletions(-)
>
> diff --git a/arch/arm/mach-snapdragon/Makefile b/arch/arm/mach-snapdragon/Makefile
> index 3a3a297c1768..d02432df8b04 100644
> --- a/arch/arm/mach-snapdragon/Makefile
> +++ b/arch/arm/mach-snapdragon/Makefile
> @@ -6,6 +6,4 @@ obj-$(CONFIG_SDM845) += sysmap-sdm845.o
>  obj-$(CONFIG_SDM845) += init_sdm845.o
>  obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
>  obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
> -obj-y += misc.o
> -obj-y += dram.o
>  obj-$(CONFIG_TARGET_QCS404EVB) += sysmap-qcs404.o
> diff --git a/arch/arm/mach-snapdragon/include/mach/dram.h b/arch/arm/mach-snapdragon/include/mach/dram.h
> deleted file mode 100644
> index 0a9eedda414c..000000000000
> --- a/arch/arm/mach-snapdragon/include/mach/dram.h
> +++ /dev/null
> @@ -1,12 +0,0 @@
> -/* 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
> diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
> deleted file mode 100644
> index 7d452f4529b7..000000000000
> --- a/arch/arm/mach-snapdragon/misc.c
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -// 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>
> -#include <asm/unaligned.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;
> -
> -       if (mmc_init(mmc_dev))
> -               return 0;
> -
> -       return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
> -}
> -
> -void msm_generate_mac_addr(u8 *mac)
> -{
> -       /* use locally adminstrated pool */
> -       mac[0] = 0x02;
> -       mac[1] = 0x00;
> -
> -       /*
> -        * Put the 32-bit serial number in the last 32-bit of the MAC address.
> -        * Use big endian order so it is consistent with the serial number
> -        * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
> -        */
> -       put_unaligned_be32(msm_board_serial(), &mac[2]);
> -}
> diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile
> index 1b99c8b0efef..a3ae1a5f9136 100644
> --- a/board/qualcomm/dragonboard410c/Makefile
> +++ b/board/qualcomm/dragonboard410c/Makefile
> @@ -2,4 +2,5 @@
>  #
>  # (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
>
> -obj-y  := dragonboard410c.o
> +obj-y += dragonboard410c.o
> +obj-y += misc.o
> diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
> index 1adac07569ae..eea603a4148d 100644
> --- a/board/qualcomm/dragonboard410c/dragonboard410c.c
> +++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
> @@ -18,10 +18,10 @@
>  #include <asm/global_data.h>
>  #include <asm/gpio.h>
>  #include <fdt_support.h>
> -#include <asm/arch/dram.h>
> -#include <asm/arch/misc.h>
>  #include <linux/delay.h>
>
> +#include "misc.h"
> +
>  DECLARE_GLOBAL_DATA_PTR;
>
>  #define USB_HUB_RESET_GPIO 2
> diff --git a/arch/arm/mach-snapdragon/dram.c b/board/qualcomm/dragonboard410c/misc.c
> similarity index 64%
> rename from arch/arm/mach-snapdragon/dram.c
> rename to board/qualcomm/dragonboard410c/misc.c
> index 499dfdf0da6e..27d51ef78914 100644
> --- a/arch/arm/mach-snapdragon/dram.c
> +++ b/board/qualcomm/dragonboard410c/misc.c
> @@ -1,6 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> - * Onboard memory detection for Snapdragon boards
> + * Miscellaneous Snapdragon functionality
>   *
>   * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
>   *
> @@ -9,10 +9,56 @@
>  #include <common.h>
>  #include <dm.h>
>  #include <log.h>
> +#include <mmc.h>
>  #include <part.h>
>  #include <smem.h>
>  #include <fdt_support.h>
> -#include <asm/arch/dram.h>
> +#include <asm/unaligned.h>
> +
> +#include "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;
> +
> +       if (mmc_init(mmc_dev))
> +               return 0;
> +
> +       return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
> +}
> +
> +void msm_generate_mac_addr(u8 *mac)
> +{
> +       /* use locally adminstrated pool */
> +       mac[0] = 0x02;
> +       mac[1] = 0x00;
> +
> +       /*
> +        * Put the 32-bit serial number in the last 32-bit of the MAC address.
> +        * Use big endian order so it is consistent with the serial number
> +        * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
> +        */
> +       put_unaligned_be32(msm_board_serial(), &mac[2]);
> +}
>
>  #define SMEM_USABLE_RAM_PARTITION_TABLE 402
>  #define RAM_PART_NAME_LENGTH            16
> @@ -97,3 +143,4 @@ int msm_fixup_memory(void *blob)
>
>         return 0;
>  }
> +
> diff --git a/arch/arm/mach-snapdragon/include/mach/misc.h b/board/qualcomm/dragonboard410c/misc.h
> similarity index 87%
> rename from arch/arm/mach-snapdragon/include/mach/misc.h
> rename to board/qualcomm/dragonboard410c/misc.h
> index c60e3e472470..fe44caf51b18 100644
> --- a/arch/arm/mach-snapdragon/include/mach/misc.h
> +++ b/board/qualcomm/dragonboard410c/misc.h
> @@ -9,5 +9,6 @@
>
>  u32 msm_board_serial(void);
>  void msm_generate_mac_addr(u8 *mac);
> +int msm_fixup_memory(void *blob);
>
>  #endif
>
> --
> 2.42.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/arch/arm/mach-snapdragon/Makefile b/arch/arm/mach-snapdragon/Makefile
index 3a3a297c1768..d02432df8b04 100644
--- a/arch/arm/mach-snapdragon/Makefile
+++ b/arch/arm/mach-snapdragon/Makefile
@@ -6,6 +6,4 @@  obj-$(CONFIG_SDM845) += sysmap-sdm845.o
 obj-$(CONFIG_SDM845) += init_sdm845.o
 obj-$(CONFIG_TARGET_DRAGONBOARD820C) += sysmap-apq8096.o
 obj-$(CONFIG_TARGET_DRAGONBOARD410C) += sysmap-apq8016.o
-obj-y += misc.o
-obj-y += dram.o
 obj-$(CONFIG_TARGET_QCS404EVB) += sysmap-qcs404.o
diff --git a/arch/arm/mach-snapdragon/include/mach/dram.h b/arch/arm/mach-snapdragon/include/mach/dram.h
deleted file mode 100644
index 0a9eedda414c..000000000000
--- a/arch/arm/mach-snapdragon/include/mach/dram.h
+++ /dev/null
@@ -1,12 +0,0 @@ 
-/* 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
diff --git a/arch/arm/mach-snapdragon/misc.c b/arch/arm/mach-snapdragon/misc.c
deleted file mode 100644
index 7d452f4529b7..000000000000
--- a/arch/arm/mach-snapdragon/misc.c
+++ /dev/null
@@ -1,55 +0,0 @@ 
-// 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>
-#include <asm/unaligned.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;
-
-	if (mmc_init(mmc_dev))
-		return 0;
-
-	return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
-}
-
-void msm_generate_mac_addr(u8 *mac)
-{
-	/* use locally adminstrated pool */
-	mac[0] = 0x02;
-	mac[1] = 0x00;
-
-	/*
-	 * Put the 32-bit serial number in the last 32-bit of the MAC address.
-	 * Use big endian order so it is consistent with the serial number
-	 * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
-	 */
-	put_unaligned_be32(msm_board_serial(), &mac[2]);
-}
diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile
index 1b99c8b0efef..a3ae1a5f9136 100644
--- a/board/qualcomm/dragonboard410c/Makefile
+++ b/board/qualcomm/dragonboard410c/Makefile
@@ -2,4 +2,5 @@ 
 #
 # (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
 
-obj-y	:= dragonboard410c.o
+obj-y += dragonboard410c.o
+obj-y += misc.o
diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
index 1adac07569ae..eea603a4148d 100644
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
@@ -18,10 +18,10 @@ 
 #include <asm/global_data.h>
 #include <asm/gpio.h>
 #include <fdt_support.h>
-#include <asm/arch/dram.h>
-#include <asm/arch/misc.h>
 #include <linux/delay.h>
 
+#include "misc.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #define USB_HUB_RESET_GPIO 2
diff --git a/arch/arm/mach-snapdragon/dram.c b/board/qualcomm/dragonboard410c/misc.c
similarity index 64%
rename from arch/arm/mach-snapdragon/dram.c
rename to board/qualcomm/dragonboard410c/misc.c
index 499dfdf0da6e..27d51ef78914 100644
--- a/arch/arm/mach-snapdragon/dram.c
+++ b/board/qualcomm/dragonboard410c/misc.c
@@ -1,6 +1,6 @@ 
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Onboard memory detection for Snapdragon boards
+ * Miscellaneous Snapdragon functionality
  *
  * (C) Copyright 2018 Ramon Fried <ramon.fried@gmail.com>
  *
@@ -9,10 +9,56 @@ 
 #include <common.h>
 #include <dm.h>
 #include <log.h>
+#include <mmc.h>
 #include <part.h>
 #include <smem.h>
 #include <fdt_support.h>
-#include <asm/arch/dram.h>
+#include <asm/unaligned.h>
+
+#include "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;
+
+	if (mmc_init(mmc_dev))
+		return 0;
+
+	return UNSTUFF_BITS(mmc_dev->cid, 16, 32);
+}
+
+void msm_generate_mac_addr(u8 *mac)
+{
+	/* use locally adminstrated pool */
+	mac[0] = 0x02;
+	mac[1] = 0x00;
+
+	/*
+	 * Put the 32-bit serial number in the last 32-bit of the MAC address.
+	 * Use big endian order so it is consistent with the serial number
+	 * written as a hexadecimal string, e.g. 0x1234abcd -> 02:00:12:34:ab:cd
+	 */
+	put_unaligned_be32(msm_board_serial(), &mac[2]);
+}
 
 #define SMEM_USABLE_RAM_PARTITION_TABLE 402
 #define RAM_PART_NAME_LENGTH            16
@@ -97,3 +143,4 @@  int msm_fixup_memory(void *blob)
 
 	return 0;
 }
+
diff --git a/arch/arm/mach-snapdragon/include/mach/misc.h b/board/qualcomm/dragonboard410c/misc.h
similarity index 87%
rename from arch/arm/mach-snapdragon/include/mach/misc.h
rename to board/qualcomm/dragonboard410c/misc.h
index c60e3e472470..fe44caf51b18 100644
--- a/arch/arm/mach-snapdragon/include/mach/misc.h
+++ b/board/qualcomm/dragonboard410c/misc.h
@@ -9,5 +9,6 @@ 
 
 u32 msm_board_serial(void);
 void msm_generate_mac_addr(u8 *mac);
+int msm_fixup_memory(void *blob);
 
 #endif