diff mbox

[U-Boot,1/1] arm: mmc: omap: spl size reduction by removing write/erase ops

Message ID 1328187876-31539-1-git-send-email-balajitk@ti.com
State Changes Requested, archived
Delegated to: Tom Rini
Headers show

Commit Message

balajitk@ti.com Feb. 2, 2012, 1:04 p.m. UTC
spl for OMAP4 does not use mmc read/write.
Add CONFIG_MMC_NO_ERASE, CONFIG_MMC_NO_WRITE to platforms where mmc
write/erase operation is not needed in spl.
Use these CONFIGS to remove write/erase code in mmc.c and omap_hsmmc.c
This reduces the spl size by ~1128 Bytes

Signed-off-by: Balaji T K <balajitk@ti.com>
---
 drivers/mmc/mmc.c              |   17 +++++++++++++++++
 drivers/mmc/omap_hsmmc.c       |    2 ++
 include/configs/omap4_common.h |    4 ++++
 3 files changed, 23 insertions(+), 0 deletions(-)

Comments

Tom Rini Feb. 2, 2012, 4:32 p.m. UTC | #1
On Thu, Feb 2, 2012 at 6:04 AM, Balaji T K <balajitk@ti.com> wrote:
> spl for OMAP4 does not use mmc read/write.
> Add CONFIG_MMC_NO_ERASE, CONFIG_MMC_NO_WRITE to platforms where mmc
> write/erase operation is not needed in spl.
> Use these CONFIGS to remove write/erase code in mmc.c and omap_hsmmc.c
> This reduces the spl size by ~1128 Bytes

Are you running into a size limitation again?  If not, I think we want
to wait until we sort out how SPL includes/excludes stuff moving
forward as this shows there's probably a lot of other unused code
being pulled in.
Aneesh V Feb. 2, 2012, 4:48 p.m. UTC | #2
Tom,

On Thursday 02 February 2012 10:02 PM, Tom Rini wrote:
> On Thu, Feb 2, 2012 at 6:04 AM, Balaji T K<balajitk@ti.com>  wrote:
>> spl for OMAP4 does not use mmc read/write.
>> Add CONFIG_MMC_NO_ERASE, CONFIG_MMC_NO_WRITE to platforms where mmc
>> write/erase operation is not needed in spl.
>> Use these CONFIGS to remove write/erase code in mmc.c and omap_hsmmc.c
>> This reduces the spl size by ~1128 Bytes
>
> Are you running into a size limitation again?  If not, I think we want

We are always on the border. Minor fluctuations are affecting us. And
our EMU boards(secure devices) are permanently broken due to this. I am
not sure if this one helps EMU devices though.

> to wait until we sort out how SPL includes/excludes stuff moving
> forward as this shows there's probably a lot of other unused code
> being pulled in.
>

We use -ffunction-sections -fdata-sections and --gc-sections while
building SPL. So, un-necessary stuff will not be included unless the
function pointers are set in some structures and not used. I think that
is what is happening in this case. Other than that I am not expecting
much scope for improvement.

One key experiment I want to do is Thumb mode build. I have some old
patches that I may cleanup and post sometime soon. But Thumb mode had
some tool-chain related issues last time I tried.

br,
Aneesh
Tom Rini Feb. 2, 2012, 5:13 p.m. UTC | #3
On Thu, Feb 2, 2012 at 9:48 AM, Aneesh V <aneesh@ti.com> wrote:
> Tom,
>
>
> On Thursday 02 February 2012 10:02 PM, Tom Rini wrote:
>>
>> On Thu, Feb 2, 2012 at 6:04 AM, Balaji T K<balajitk@ti.com>  wrote:
>>>
>>> spl for OMAP4 does not use mmc read/write.
>>> Add CONFIG_MMC_NO_ERASE, CONFIG_MMC_NO_WRITE to platforms where mmc
>>> write/erase operation is not needed in spl.
>>> Use these CONFIGS to remove write/erase code in mmc.c and omap_hsmmc.c
>>> This reduces the spl size by ~1128 Bytes
>>
>>
>> Are you running into a size limitation again?  If not, I think we want
>
> We are always on the border. Minor fluctuations are affecting us. And
> our EMU boards(secure devices) are permanently broken due to this. I am
> not sure if this one helps EMU devices though.

Ick, OK.  So lets re-do this for now with #define CONFIG_FOO not
#define CONFIG_FOO 1 and push for this going in now to solve problems
with real devices.

>> to wait until we sort out how SPL includes/excludes stuff moving
>> forward as this shows there's probably a lot of other unused code
>> being pulled in.
>>
>
> We use -ffunction-sections -fdata-sections and --gc-sections while
> building SPL. So, un-necessary stuff will not be included unless the
> function pointers are set in some structures and not used. I think that
> is what is happening in this case. Other than that I am not expecting
> much scope for improvement.

Exactly.  I think part of the problem is that this discussion is
buried in the thread about SPL YMODEM support, but Wolfgang isn't
happy with some of the direction SPL stuff is heading.
diff mbox

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 21665ec..852c896 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -31,6 +31,7 @@ 
 #include <malloc.h>
 #include <linux/list.h>
 #include <div64.h>
+#include <asm/errno.h>
 
 /* Set block count limit because of 16 bit register limit on some hardware*/
 #ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT
@@ -175,6 +176,7 @@  struct mmc *find_mmc_device(int dev_num)
 	return NULL;
 }
 
+#ifndef CONFIG_MMC_NO_ERASE
 static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt)
 {
 	struct mmc_cmd cmd;
@@ -256,7 +258,15 @@  mmc_berase(int dev_num, unsigned long start, lbaint_t blkcnt)
 
 	return blk;
 }
+#else
+static unsigned long
+mmc_berase(int dev_num, unsigned long start, lbaint_t blkcnt)
+{
+	return -ENOSYS;
+}
+#endif
 
+#ifndef CONFIG_MMC_NO_WRITE
 static ulong
 mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src)
 {
@@ -336,6 +346,13 @@  mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
 
 	return blkcnt;
 }
+#else
+static ulong
+mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void *src)
+{
+	return -ENOSYS;
+}
+#endif
 
 int mmc_read_blocks(struct mmc *mmc, void *dst, ulong start, lbaint_t blkcnt)
 {
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
index c38b9e6..ce36481 100644
--- a/drivers/mmc/omap_hsmmc.c
+++ b/drivers/mmc/omap_hsmmc.c
@@ -360,6 +360,7 @@  static int mmc_read_data(struct hsmmc *mmc_base, char *buf, unsigned int size)
 static int mmc_write_data(struct hsmmc *mmc_base, const char *buf,
 				unsigned int size)
 {
+#ifndef CONFIG_MMC_NO_WRITE
 	unsigned int *input_buf = (unsigned int *)buf;
 	unsigned int mmc_stat;
 	unsigned int count;
@@ -406,6 +407,7 @@  static int mmc_write_data(struct hsmmc *mmc_base, const char *buf,
 			break;
 		}
 	}
+#endif
 	return 0;
 }
 
diff --git a/include/configs/omap4_common.h b/include/configs/omap4_common.h
index a989721..0ae2ab3 100644
--- a/include/configs/omap4_common.h
+++ b/include/configs/omap4_common.h
@@ -109,6 +109,10 @@ 
 #define CONFIG_SYS_MMC_SET_DEV		1
 #define CONFIG_DOS_PARTITION		1
 
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_MMC_NO_WRITE		1
+#define CONFIG_MMC_NO_ERASE		1
+#endif
 
 /* USB */
 #define CONFIG_MUSB_UDC			1