Commit ade8a1a6d32036381776270ebe9980473c25c821

Authored by Ying Zhang
Committed by Tom Rini
1 parent bee0dc2fec
Exists in master and in 56 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf-6.6.52-2.2.0, emb_lf_v2022.04, emb_lf_v2023.04, emb_lf_v2024.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

drivers/mmc: move spl_mmc.c to common/spl

The mpc85xx repuires a special layout on the memory device that is
connected to the eSDHC controller interface. But the file spl_mmc.c
didn't handle this specfic case, there needs a special treatmen, in
the powerpc drictory. So, there is no longer to keep spl_mmc.c on
mpc85xx, CONFIG_SPL_FRAMEWORK is not set.

When CONFIG_SPL_MMC_SUPPORT is set and CONFIG_SPL_FRAMEWORK is not
set, there was an error in drivers/mmc/spl_mmc.c:

drivers/mmc/libmmc.o:(.got2+0x8): undefined reference to `spl_image'.

Now, the solution is to move the file "spl_mmc.c" to directory "common/spl".

Signed-off-by: Ying Zhang <b40530@freescale.com>

Showing 4 changed files with 138 additions and 140 deletions Side-by-side Diff

... ... @@ -20,6 +20,7 @@
20 20 COBJS-$(CONFIG_SPL_NAND_SUPPORT) += spl_nand.o
21 21 COBJS-$(CONFIG_SPL_ONENAND_SUPPORT) += spl_onenand.o
22 22 COBJS-$(CONFIG_SPL_NET_SUPPORT) += spl_net.o
  23 +COBJS-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o
23 24 endif
24 25  
25 26 COBJS := $(sort $(COBJS-y))
common/spl/spl_mmc.c
  1 +/*
  2 + * (C) Copyright 2010
  3 + * Texas Instruments, <www.ti.com>
  4 + *
  5 + * Aneesh V <aneesh@ti.com>
  6 + *
  7 + * See file CREDITS for list of people who contributed to this
  8 + * project.
  9 + *
  10 + * This program is free software; you can redistribute it and/or
  11 + * modify it under the terms of the GNU General Public License as
  12 + * published by the Free Software Foundation; either version 2 of
  13 + * the License, or (at your option) any later version.
  14 + *
  15 + * This program is distributed in the hope that it will be useful,
  16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18 + * GNU General Public License for more details.
  19 + *
  20 + * You should have received a copy of the GNU General Public License
  21 + * along with this program; if not, write to the Free Software
  22 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23 + * MA 02111-1307 USA
  24 + */
  25 +#include <common.h>
  26 +#include <spl.h>
  27 +#include <asm/u-boot.h>
  28 +#include <asm/utils.h>
  29 +#include <mmc.h>
  30 +#include <fat.h>
  31 +#include <version.h>
  32 +
  33 +DECLARE_GLOBAL_DATA_PTR;
  34 +
  35 +static void mmc_load_image_raw(struct mmc *mmc)
  36 +{
  37 + unsigned long err;
  38 + u32 image_size_sectors;
  39 + struct image_header *header;
  40 +
  41 + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
  42 + sizeof(struct image_header));
  43 +
  44 + /* read image header to find the image size & load address */
  45 + err = mmc->block_dev.block_read(0,
  46 + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, 1,
  47 + header);
  48 +
  49 + if (err == 0)
  50 + goto end;
  51 +
  52 + spl_parse_image_header(header);
  53 +
  54 + /* convert size to sectors - round up */
  55 + image_size_sectors = (spl_image.size + mmc->read_bl_len - 1) /
  56 + mmc->read_bl_len;
  57 +
  58 + /* Read the header too to avoid extra memcpy */
  59 + err = mmc->block_dev.block_read(0,
  60 + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
  61 + image_size_sectors, (void *)spl_image.load_addr);
  62 +
  63 +end:
  64 + if (err == 0) {
  65 + printf("spl: mmc blk read err - %lu\n", err);
  66 + hang();
  67 + }
  68 +}
  69 +
  70 +#ifdef CONFIG_SPL_FAT_SUPPORT
  71 +static void mmc_load_image_fat(struct mmc *mmc)
  72 +{
  73 + int err;
  74 + struct image_header *header;
  75 +
  76 + header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
  77 + sizeof(struct image_header));
  78 +
  79 + err = fat_register_device(&mmc->block_dev,
  80 + CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION);
  81 + if (err) {
  82 + printf("spl: fat register err - %d\n", err);
  83 + hang();
  84 + }
  85 +
  86 + err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME,
  87 + header, sizeof(struct image_header));
  88 + if (err <= 0)
  89 + goto end;
  90 +
  91 + spl_parse_image_header(header);
  92 +
  93 + err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME,
  94 + (u8 *)spl_image.load_addr, 0);
  95 +
  96 +end:
  97 + if (err <= 0) {
  98 + printf("spl: error reading image %s, err - %d\n",
  99 + CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err);
  100 + hang();
  101 + }
  102 +}
  103 +#endif
  104 +
  105 +void spl_mmc_load_image(void)
  106 +{
  107 + struct mmc *mmc;
  108 + int err;
  109 + u32 boot_mode;
  110 +
  111 + mmc_initialize(gd->bd);
  112 + /* We register only one device. So, the dev id is always 0 */
  113 + mmc = find_mmc_device(0);
  114 + if (!mmc) {
  115 + puts("spl: mmc device not found!!\n");
  116 + hang();
  117 + }
  118 +
  119 + err = mmc_init(mmc);
  120 + if (err) {
  121 + printf("spl: mmc init failed: err - %d\n", err);
  122 + hang();
  123 + }
  124 + boot_mode = spl_boot_mode();
  125 + if (boot_mode == MMCSD_MODE_RAW) {
  126 + debug("boot mode - RAW\n");
  127 + mmc_load_image_raw(mmc);
  128 +#ifdef CONFIG_SPL_FAT_SUPPORT
  129 + } else if (boot_mode == MMCSD_MODE_FAT) {
  130 + debug("boot mode - FAT\n");
  131 + mmc_load_image_fat(mmc);
  132 +#endif
  133 + } else {
  134 + puts("spl: wrong MMC boot mode\n");
  135 + hang();
  136 + }
  137 +}
drivers/mmc/Makefile
... ... @@ -25,9 +25,6 @@
25 25  
26 26 LIB := $(obj)libmmc.o
27 27  
28   -ifdef CONFIG_SPL_BUILD
29   -COBJS-$(CONFIG_SPL_MMC_SUPPORT) += spl_mmc.o
30   -endif
31 28  
32 29 COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o
33 30 COBJS-$(CONFIG_DAVINCI_MMC) += davinci_mmc.o
drivers/mmc/spl_mmc.c
1   -/*
2   - * (C) Copyright 2010
3   - * Texas Instruments, <www.ti.com>
4   - *
5   - * Aneesh V <aneesh@ti.com>
6   - *
7   - * See file CREDITS for list of people who contributed to this
8   - * project.
9   - *
10   - * This program is free software; you can redistribute it and/or
11   - * modify it under the terms of the GNU General Public License as
12   - * published by the Free Software Foundation; either version 2 of
13   - * the License, or (at your option) any later version.
14   - *
15   - * This program is distributed in the hope that it will be useful,
16   - * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18   - * GNU General Public License for more details.
19   - *
20   - * You should have received a copy of the GNU General Public License
21   - * along with this program; if not, write to the Free Software
22   - * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23   - * MA 02111-1307 USA
24   - */
25   -#include <common.h>
26   -#include <spl.h>
27   -#include <asm/u-boot.h>
28   -#include <asm/utils.h>
29   -#include <mmc.h>
30   -#include <fat.h>
31   -#include <version.h>
32   -
33   -DECLARE_GLOBAL_DATA_PTR;
34   -
35   -static void mmc_load_image_raw(struct mmc *mmc)
36   -{
37   - unsigned long err;
38   - u32 image_size_sectors;
39   - struct image_header *header;
40   -
41   - header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
42   - sizeof(struct image_header));
43   -
44   - /* read image header to find the image size & load address */
45   - err = mmc->block_dev.block_read(0,
46   - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, 1,
47   - header);
48   -
49   - if (err == 0)
50   - goto end;
51   -
52   - spl_parse_image_header(header);
53   -
54   - /* convert size to sectors - round up */
55   - image_size_sectors = (spl_image.size + mmc->read_bl_len - 1) /
56   - mmc->read_bl_len;
57   -
58   - /* Read the header too to avoid extra memcpy */
59   - err = mmc->block_dev.block_read(0,
60   - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
61   - image_size_sectors, (void *)spl_image.load_addr);
62   -
63   -end:
64   - if (err == 0) {
65   - printf("spl: mmc blk read err - %lu\n", err);
66   - hang();
67   - }
68   -}
69   -
70   -#ifdef CONFIG_SPL_FAT_SUPPORT
71   -static void mmc_load_image_fat(struct mmc *mmc)
72   -{
73   - int err;
74   - struct image_header *header;
75   -
76   - header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
77   - sizeof(struct image_header));
78   -
79   - err = fat_register_device(&mmc->block_dev,
80   - CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION);
81   - if (err) {
82   - printf("spl: fat register err - %d\n", err);
83   - hang();
84   - }
85   -
86   - err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME,
87   - header, sizeof(struct image_header));
88   - if (err <= 0)
89   - goto end;
90   -
91   - spl_parse_image_header(header);
92   -
93   - err = file_fat_read(CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME,
94   - (u8 *)spl_image.load_addr, 0);
95   -
96   -end:
97   - if (err <= 0) {
98   - printf("spl: error reading image %s, err - %d\n",
99   - CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME, err);
100   - hang();
101   - }
102   -}
103   -#endif
104   -
105   -void spl_mmc_load_image(void)
106   -{
107   - struct mmc *mmc;
108   - int err;
109   - u32 boot_mode;
110   -
111   - mmc_initialize(gd->bd);
112   - /* We register only one device. So, the dev id is always 0 */
113   - mmc = find_mmc_device(0);
114   - if (!mmc) {
115   - puts("spl: mmc device not found!!\n");
116   - hang();
117   - }
118   -
119   - err = mmc_init(mmc);
120   - if (err) {
121   - printf("spl: mmc init failed: err - %d\n", err);
122   - hang();
123   - }
124   - boot_mode = spl_boot_mode();
125   - if (boot_mode == MMCSD_MODE_RAW) {
126   - debug("boot mode - RAW\n");
127   - mmc_load_image_raw(mmc);
128   -#ifdef CONFIG_SPL_FAT_SUPPORT
129   - } else if (boot_mode == MMCSD_MODE_FAT) {
130   - debug("boot mode - FAT\n");
131   - mmc_load_image_fat(mmc);
132   -#endif
133   - } else {
134   - puts("spl: wrong MMC boot mode\n");
135   - hang();
136   - }
137   -}