Patchwork [U-Boot,RFC] ARM: U-boot and 2 GiB of ram with get_ram_size only being long

login
register
mail settings
Submitter Oliver Schinagl
Date Oct. 7, 2013, 2:41 a.m.
Message ID <52521F5B.4090002@schinagl.nl>
Download mbox | patch
Permalink /patch/281094/
State New
Delegated to: Tom Rini
Headers show

Comments

Oliver Schinagl - Oct. 7, 2013, 2:41 a.m.
Hey all,

Having not received any feed back at all, I went ahead and did the 
changes anyway. Everything seems to run and work fine for sunxi and 
prints proper sizes.

For the other boards, I tried to run a MAKEALL but there where so many 
random other warnings I can't say for 100% certainty there where no 
mistakes that crept in. Boards where strange size conversion where done 
or it was assumed that the return value of get_ram_size() was long are 
typecast to have the same (erroneous) behavior. Boards that had simple 
fixes where fixed.

Ideally, every maintainer should check if their board requires deeper 
review and fixing due to this change.

Oliver

On 03-10-13 23:15, Oliver Schinagl wrote:
> Hey all,
>
> I just yesterday received my CubieTruck (cubieboard3) with 2 GiB of Ram
> and added support for it to the sunxi-u-boot branch. While I know this
> isn't merged into the main u-boot tree (yet), I ran into the following
> problem.
>
> At the end of the dram init code, it is customary to call get_ram_size()
> and return its value. This is then used to print the DRAM size and also
> is passed to the Linux kernel.
>
> However the return size of get_ram_size() is a long. While I don't
> understand why not unsigned long or even u64 was chosen, this causes
> get_dram_size to overflow when having a ramsize of 2 GiB. While only
> printing of the value isn't hugely important, this does indicate u-boot
> seems to be somewhat artificially limited to 2 GiB of Ram? This only
> seems to affect the SPL as, if I understood correctly, there it stores
> the ram_size into the gd struct which I think is unsigned long.
>
> I've started working on a patch to convert common/memsize.c's
> get_ram_size(), to be completely unsigned long, however there seems to
> be quite a lot of code that calls this. So my question is now before
> going over all drivers and change that and submit a big patch-set, did I
> overlook anything and are my conclusions correct, get_ram_size should
> return unsigned long.
>
> Finally, a long is 32 bits on x86 and armv7, but how will that relate to
> 64bits armv8? As I understood, Windows treats long's as 4 bytes no
> matter if it's 32 bit or 64 bit. Linux is better and a long is 4 bytes
> on 32 bits, and 8 bytes on 64 bits versions. So how will u-boot work on
> armv8? Will the long datatype work well, or should I consider changing
> things more future proof? (u32 and u64 come to mind).
>
> Thank you for any input regarding that issue.
>
> Oliver
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Albert ARIBAUD - Oct. 15, 2013, 7:12 a.m.
Hi Oliver,

On Mon, 07 Oct 2013 04:41:31 +0200, Oliver Schinagl
<oliver+list@schinagl.nl> wrote:

> Hey all,
> 
> Having not received any feed back at all, I went ahead and did the 
> changes anyway. Everything seems to run and work fine for sunxi and 
> prints proper sizes.
> 
> For the other boards, I tried to run a MAKEALL but there where so many 
> random other warnings I can't say for 100% certainty there where no 
> mistakes that crept in.

There cannot possibly be a single warning if you're working from an
official U-Boot repo, as warnings are considered failures and thus no
patch reaches u-boot/master if it causes a warning. Thus, any warning
stems from the change you're introducing, and they are probably due to
a few common causes.

Can you provide a rough analysis/classification of the warnings? 

Amicalement,
Scott Wood - Oct. 15, 2013, 5:57 p.m.
On Tue, 2013-10-15 at 09:12 +0200, Albert ARIBAUD wrote:
> Hi Oliver,
> 
> On Mon, 07 Oct 2013 04:41:31 +0200, Oliver Schinagl
> <oliver+list@schinagl.nl> wrote:
> 
> > Hey all,
> > 
> > Having not received any feed back at all, I went ahead and did the 
> > changes anyway. Everything seems to run and work fine for sunxi and 
> > prints proper sizes.
> > 
> > For the other boards, I tried to run a MAKEALL but there where so many 
> > random other warnings I can't say for 100% certainty there where no 
> > mistakes that crept in.
> 
> There cannot possibly be a single warning if you're working from an
> official U-Boot repo, as warnings are considered failures and thus no
> patch reaches u-boot/master if it causes a warning.

That might be the theory, but in practice this is simply false.
Different toolchains produce different warnings, and not all patches
always get test-built on every target (especially on obscure
architectures).  And since it's false that no warnings exist, that means
sometimes even when a patch is test-built, some newly introduced
warnings get missed (I got an e-mail pointing out such an occurance just
today).

-Scott
Albert ARIBAUD - Oct. 17, 2013, 6:27 a.m.
Hi Scott,

On Tue, 15 Oct 2013 12:57:33 -0500, Scott Wood
<scottwood@freescale.com> wrote:

> On Tue, 2013-10-15 at 09:12 +0200, Albert ARIBAUD wrote:
> > Hi Oliver,
> > 
> > On Mon, 07 Oct 2013 04:41:31 +0200, Oliver Schinagl
> > <oliver+list@schinagl.nl> wrote:
> > 
> > > Hey all,
> > > 
> > > Having not received any feed back at all, I went ahead and did the 
> > > changes anyway. Everything seems to run and work fine for sunxi and 
> > > prints proper sizes.
> > > 
> > > For the other boards, I tried to run a MAKEALL but there where so many 
> > > random other warnings I can't say for 100% certainty there where no 
> > > mistakes that crept in.
> > 
> > There cannot possibly be a single warning if you're working from an
> > official U-Boot repo, as warnings are considered failures and thus no
> > patch reaches u-boot/master if it causes a warning.
> 
> That might be the theory, but in practice this is simply false.
> Different toolchains produce different warnings, and not all patches
> always get test-built on every target (especially on obscure
> architectures).  And since it's false that no warnings exist, that means
> sometimes even when a patch is test-built, some newly introduced
> warnings get missed (I got an e-mail pointing out such an occurance just
> today).

You are correct that the same code may or may not emit warnings
depending on the toolchain, and that U-Boot's build system won't stop
building because of warnings.

However, when a new toolchain version causes such warnings, but they
are not 'random' in any case; they may be numerous though, if in some
source code used in a lot of boards.

In any case, if Oliver gets warnings, chances are we'll get them to
when applying his code, in which case it'll be rejected, or we'll see
them happening later if he's unsing a common toolchain in a new
version, or he's using an unusual toolchain.

> -Scott

Amicalement,
Oliver Schinagl - Oct. 18, 2013, 12:04 a.m.
On 17-10-13 08:27, Albert ARIBAUD wrote:
> Hi Scott,
>
> On Tue, 15 Oct 2013 12:57:33 -0500, Scott Wood
> <scottwood@freescale.com> wrote:
>
>> On Tue, 2013-10-15 at 09:12 +0200, Albert ARIBAUD wrote:
>>> Hi Oliver,
>>>
>>> On Mon, 07 Oct 2013 04:41:31 +0200, Oliver Schinagl
>>> <oliver+list@schinagl.nl> wrote:
>>>
>>>> Hey all,
>>>>
>>>> Having not received any feed back at all, I went ahead and did the
>>>> changes anyway. Everything seems to run and work fine for sunxi and
>>>> prints proper sizes.
>>>>
>>>> For the other boards, I tried to run a MAKEALL but there where so many
>>>> random other warnings I can't say for 100% certainty there where no
>>>> mistakes that crept in.
>>>
>>> There cannot possibly be a single warning if you're working from an
>>> official U-Boot repo, as warnings are considered failures and thus no
>>> patch reaches u-boot/master if it causes a warning.
>>
>> That might be the theory, but in practice this is simply false.
>> Different toolchains produce different warnings, and not all patches
>> always get test-built on every target (especially on obscure
>> architectures).  And since it's false that no warnings exist, that means
>> sometimes even when a patch is test-built, some newly introduced
>> warnings get missed (I got an e-mail pointing out such an occurance just
>> today).
>
> You are correct that the same code may or may not emit warnings
> depending on the toolchain, and that U-Boot's build system won't stop
> building because of warnings.
>
> However, when a new toolchain version causes such warnings, but they
> are not 'random' in any case; they may be numerous though, if in some
> source code used in a lot of boards.
>
> In any case, if Oliver gets warnings, chances are we'll get them to
> when applying his code, in which case it'll be rejected, or we'll see
> them happening later if he's unsing a common toolchain in a new
> version, or he's using an unusual toolchain.
I wasn't getting warnings or errors even remotely related to my patches 
and while it's a pitty we are discussing peanuts without even looking at 
the patch, cest la vie.

A few of the warnings are from my toolchain (missing bits) a few others 
from random stuff, here a few one liners to give an indication where 
boards break:

mxc_gpio.c:105:9: error: dereferencing pointer to incomplete type

at91rm9200_devices.c:64:20: error: ‘AT91_PIO_PORTA’ undeclared (first 
use in this function)

mini2440.c:70:24: error: ‘GPH8’ undeclared (first use in this function

/silo/build/sunxi-bsp/u-boot-sunxi/include/config.h:7:0: warning: 
"CONFIG_SYS_SOC" redefined [enabled by default]
/silo/build/sunxi-bsp/build/u-boot-all/include/config.h:9:0: note: this 
is the location of the previous definition
/silo/build/sunxi-bsp/u-boot-sunxi/include/config.h:8:0: warning: 
"CONFIG_BOARDDIR" redefined [enabled by default]
/
tons of errors on this one for the atmel at91sam configs

at91sam9260_devices.c:34:20: error: ‘AT91_PIO_PORTB’ undeclared (first 
use in this function)

da8xx_gpio.c:388:1: error: dereferencing pointer to incomplete type

dm355leopard.c:35:2: error: ‘DAVINCI_GPIO_BINTEN’ undeclared (first use 
in this function)
dm355leopard.c:38:2: error: dereferencing pointer to incomplete type

I must admit however, quite a few boards built cleanly, so I may have 
overstated things?

I'm building using gcc-4.6.3 on gentoo (with gcc build natively via 
cross-dev)
The command I used was:
CROSS_COMPILE=arm-pc-linux-gnueabi- 
BUILD_DIR=/silo/build/sunxi-bsp/build/u-build-all ./MAKEALL -a arm

So while a few of these errors might be long fixed, we merge the u-boot 
patches on a monthly or so basis, I can't imagine all these errors being 
from the wrong toolchain?

So now that that's settled, anything fundamentally wrong with my patch? :)

oliver
>
>> -Scott
>
> Amicalement,
>
Scott Wood - Oct. 18, 2013, 4:43 p.m.
On Fri, 2013-10-18 at 02:04 +0200, Oliver Schinagl wrote:
> So now that that's settled, anything fundamentally wrong with my patch? :)

Did you see my other mail in this thread?  This patch is sort of OK for
raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
risk of false positives from I/O), but it can't go beyond that on
32-bit.  A better approach would be to get the RAM size from the memory
controller, which is what we do on many Freescale PPC boards.

-Scott
Wolfgang Denk - Oct. 18, 2013, 8:26 p.m.
Dear Scott Wood,

In message <1382114601.7979.843.camel@snotra.buserror.net> you wrote:
>
> Did you see my other mail in this thread?  This patch is sort of OK for
> raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
> risk of false positives from I/O), but it can't go beyond that on
> 32-bit.  A better approach would be to get the RAM size from the memory
> controller, which is what we do on many Freescale PPC boards.

This is NOT a better approach.  Reading the memory controller just
tells you what is supposed to be there, i. e. what you programmed into
the controller.  get_ram_size() shows you what is _actually_ there,
which may be a totally different thing, for example when different RAM
chips can be fit on the board, or when the working area of the RAM is
not the same as the actual chip size, for example due to hardware
errors (shorts or interruptions on the address lines, etc.).

get_ram_size() is a very efficient memory test that detects 95% or
more of all RAM related hardware issues.

Best regards,

Wolfgang Denk
Scott Wood - Oct. 18, 2013, 9:04 p.m.
On Fri, 2013-10-18 at 22:26 +0200, Wolfgang Denk wrote:
> Dear Scott Wood,
> 
> In message <1382114601.7979.843.camel@snotra.buserror.net> you wrote:
> >
> > Did you see my other mail in this thread?  This patch is sort of OK for
> > raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
> > risk of false positives from I/O), but it can't go beyond that on
> > 32-bit.  A better approach would be to get the RAM size from the memory
> > controller, which is what we do on many Freescale PPC boards.
> 
> This is NOT a better approach.  Reading the memory controller just
> tells you what is supposed to be there, i. e. what you programmed into
> the controller.  get_ram_size() shows you what is _actually_ there,

That may be useful with simpler memory controllers where there isn't
much to get wrong other than size, but on modern DDR controllers you're
pretty screwed anyway if you don't know what's actually there.  If you
don't get the size right, what are the odds you got the timing right?
We hard code a lot of other things in U-Boot such as the address of
various I/O...

And if RAM is socketed (or the board designer was nice enough to include
it with non-socketed RAM), the information should be coming from SPD
EEPROMs, not hardcoded in the U-Boot image.

> which may be a totally different thing, for example when different RAM
> chips can be fit on the board, or when the working area of the RAM is
> not the same as the actual chip size, for example due to hardware
> errors (shorts or interruptions on the address lines, etc.).
> 
> get_ram_size() is a very efficient memory test that detects 95% or
> more of all RAM related hardware issues.

So call it something like test_ram_simple() and bound it by the maximum
amount of RAM that you expect to be there, so you don't accidentally
touch I/O.  For RAM beyond 2G, either leave it untested or use the MMU
to test it, but don't tell the rest of the system that RAM beyond that
doesn't exist.  For RAM that ends on a non-power-of-2 (below 2G), do one
final test at the end of the supplied size.

And if the test finds missing/bad RAM below the supplied limit, the
caller should generally make noise that there's a problem rather than
just use less RAM.

-Scott
Wolfgang Denk - Oct. 18, 2013, 9:53 p.m.
Dear Scott,

In message <1382130258.7979.896.camel@snotra.buserror.net> you wrote:
>
> > This is NOT a better approach.  Reading the memory controller just
> > tells you what is supposed to be there, i. e. what you programmed into
> > the controller.  get_ram_size() shows you what is _actually_ there,
> 
> That may be useful with simpler memory controllers where there isn't
> much to get wrong other than size, but on modern DDR controllers you're
> pretty screwed anyway if you don't know what's actually there.  If you

The standard approach here is to go through all expected memory
configurations...

> don't get the size right, what are the odds you got the timing right?
> We hard code a lot of other things in U-Boot such as the address of
> various I/O...

You sound as if you were proud of that?  I don't think this is any
special kind of "acchievement".

> And if RAM is socketed (or the board designer was nice enough to include
> it with non-socketed RAM), the information should be coming from SPD
> EEPROMs, not hardcoded in the U-Boot image.

Agreed - but then, still, get_ram_size() is a pretty efficient test if
your memory is actually working as expected.  Even DIMMs with SPD
EEPROMs tend to fail every now and then.  And when you know you have
fit a 1 GB module, and U-Boot recognizes only 128 MB, you might start
to think...

> > get_ram_size() is a very efficient memory test that detects 95% or
> > more of all RAM related hardware issues.
> 
> So call it something like test_ram_simple() and bound it by the maximum

Actually the _primary_ function is the memory sizing.  The testimg is
just a pleasant side effect.

> amount of RAM that you expect to be there, so you don't accidentally
> touch I/O.  For RAM beyond 2G, either leave it untested or use the MMU
> to test it, but don't tell the rest of the system that RAM beyond that
> doesn't exist.  For RAM that ends on a non-power-of-2 (below 2G), do one
> final test at the end of the supplied size.

Patches welcoem :-)

> And if the test finds missing/bad RAM below the supplied limit, the
> caller should generally make noise that there's a problem rather than
> just use less RAM.

Well, it reports the working RAM size.  You can check that, if you
like.

Best regards,

Wolfgang Denk
Oliver Schinagl - Oct. 18, 2013, 11:07 p.m.
On 10/18/13 18:43, Scott Wood wrote:
> On Fri, 2013-10-18 at 02:04 +0200, Oliver Schinagl wrote:
>> So now that that's settled, anything fundamentally wrong with my patch? :)
>
> Did you see my other mail in this thread?  This patch is sort of OK for
Sorry I did and I got distracted from it.

> raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
> risk of false positives from I/O), but it can't go beyond that on
I'd ask 'how so' but I'm not sure I'd understand anyway ;)

> 32-bit.  A better approach would be to get the RAM size from the memory
> controller, which is what we do on many Freescale PPC boards.
Not possible for us at this moment. The memory controller is programed 
with hard-coded values on a per board basis. I think we could 
technically obtain values via/from the memory controller, but have no 
knowledge at this moment. Allwinner has a tool, livesuit, which is used 
to flash full disk images to a device. We currently guesstimate that 
livesuit can somehow detect the memory parameters and injects it into 
the stock bootloader. But we really have no clue if that really happens 
or how it's done. So we rely on extracting the information from a 
running stock android/linux and hardcode it into u-boot.

Oliver

>
> -Scott
>
>
>
Oliver Schinagl - Oct. 18, 2013, 11:11 p.m.
On 10/18/13 22:26, Wolfgang Denk wrote:
> Dear Scott Wood,
>
> In message <1382114601.7979.843.camel@snotra.buserror.net> you wrote:
>>
>> Did you see my other mail in this thread?  This patch is sort of OK for
>> raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
>> risk of false positives from I/O), but it can't go beyond that on
>> 32-bit.  A better approach would be to get the RAM size from the memory
>> controller, which is what we do on many Freescale PPC boards.
>
> This is NOT a better approach.  Reading the memory controller just
> tells you what is supposed to be there, i. e. what you programmed into
> the controller.  get_ram_size() shows you what is _actually_ there,
> which may be a totally different thing, for example when different RAM
> chips can be fit on the board, or when the working area of the RAM is
> not the same as the actual chip size, for example due to hardware
> errors (shorts or interruptions on the address lines, etc.).
>
> get_ram_size() is a very efficient memory test that detects 95% or
> more of all RAM related hardware issues.
But is my patch acceptable and does it fix the phys_size_t = long vs 
phys_size_t = unsigned long 'issue'. Does this patch fix that or make it 
worse? And if so, how would that needed to be fixed.

Oliver
>
> Best regards,
>
> Wolfgang Denk
>
Scott Wood - Oct. 18, 2013, 11:25 p.m.
On Sat, 2013-10-19 at 01:07 +0200, Oliver Schinagl wrote:
> On 10/18/13 18:43, Scott Wood wrote:
> > On Fri, 2013-10-18 at 02:04 +0200, Oliver Schinagl wrote:
> >> So now that that's settled, anything fundamentally wrong with my patch? :)
> >
> > Did you see my other mail in this thread?  This patch is sort of OK for
> Sorry I did and I got distracted from it.
> 
> > raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
> > risk of false positives from I/O), but it can't go beyond that on
> I'd ask 'how so' but I'm not sure I'd understand anyway ;)

Do you mean why it can't go beyond 2 GiB?  The next address to probe
after 0x8000_0000 would be 0x1_0000_0000 which is beyond what can be
addressed in a 32-bit environment.  I suppose you could return 4 GiB if
0x8000_0000 tests OK, but nothing beyond that.  You'd need a larger
datatype than "unsigned long" if you want to return 4 GiB, though.

And the one 64-bit environment that we're about to have in U-Boot
(armv8) has discontiguous memory, which is another case where
get_ram_size() won't work.

> > 32-bit.  A better approach would be to get the RAM size from the memory
> > controller, which is what we do on many Freescale PPC boards.
> Not possible for us at this moment. The memory controller is programed 
> with hard-coded values on a per board basis. I think we could 
> technically obtain values via/from the memory controller, but have no 
> knowledge at this moment. Allwinner has a tool, livesuit, which is used 
> to flash full disk images to a device. We currently guesstimate that 
> livesuit can somehow detect the memory parameters and injects it into 
> the stock bootloader. But we really have no clue if that really happens 
> or how it's done. So we rely on extracting the information from a 
> running stock android/linux and hardcode it into u-boot.

So the issue is that you don't have documentation on what the values you
program into the memory controller mean?  Can you extract the memory
size as well from a running stock image?

BTW, shouldn't get_ram_size restore the original data in the final
"return (maxsize)" case?  I know, patches welcome. :-)

-Scott
Scott Wood - Oct. 18, 2013, 11:25 p.m.
On Fri, 2013-10-18 at 18:25 -0500, Scott Wood wrote:
> On Sat, 2013-10-19 at 01:07 +0200, Oliver Schinagl wrote:
> > On 10/18/13 18:43, Scott Wood wrote:
> > > On Fri, 2013-10-18 at 02:04 +0200, Oliver Schinagl wrote:
> > >> So now that that's settled, anything fundamentally wrong with my patch? :)
> > >
> > > Did you see my other mail in this thread?  This patch is sort of OK for
> > Sorry I did and I got distracted from it.
> > 
> > > raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
> > > risk of false positives from I/O), but it can't go beyond that on
> > I'd ask 'how so' but I'm not sure I'd understand anyway ;)
> 
> Do you mean why it can't go beyond 2 GiB?  The next address to probe
> after 0x8000_0000 would be 0x1_0000_0000 which is beyond what can be
> addressed in a 32-bit environment.  I suppose you could return 4 GiB if
> 0x8000_0000 tests OK, but nothing beyond that.  You'd need a larger
> datatype than "unsigned long" if you want to return 4 GiB, though.

Oh, and if you actually had 4 GiB of RAM mapped in a 32-bit environment,
where would I/O go?

-Scott
Oliver Schinagl - Oct. 19, 2013, 9:07 a.m.
On 10/19/13 01:25, Scott Wood wrote:
> On Sat, 2013-10-19 at 01:07 +0200, Oliver Schinagl wrote:
>> On 10/18/13 18:43, Scott Wood wrote:
>>> On Fri, 2013-10-18 at 02:04 +0200, Oliver Schinagl wrote:
>>>> So now that that's settled, anything fundamentally wrong with my patch? :)
>>>
>>> Did you see my other mail in this thread?  This patch is sort of OK for
>> Sorry I did and I got distracted from it.
>>
>>> raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
>>> risk of false positives from I/O), but it can't go beyond that on
>> I'd ask 'how so' but I'm not sure I'd understand anyway ;)
>
> Do you mean why it can't go beyond 2 GiB?  The next address to probe
> after 0x8000_0000 would be 0x1_0000_0000 which is beyond what can be
Yeah why can't it go beyond 2 GiB. It should be an unsigned long, so it 
should be able to go beyond 2 GiB, as you state, upto 4 GiB on a 32-bit 
environment.

What my patch fixes is, that u-boot passes ram parameters (ramsize) via 
the global data -> ramsize. Ramsize is a phys_size_t which is defined as 
unsigned long (yay for typedef :p). Nearly all platforms pass the memory 
size to the linux kernel as gd->ramsize = get_ram_size();

And here is the bug, (unsigned long)ramsize = (signed long)get_ram_size();

 > addressed in a 32-bit environment.  I suppose you could return 4 GiB > if
 > 0x8000_0000 tests OK, but nothing beyond that.  You'd need a larger
 > datatype than "unsigned long" if you want to return 4 GiB, though.
As for returning exactly 4 GiB, assuming that register space is 0 bytes 
(impossible but lets just say for arguments sake) we now have 
0x8000_0000 addresses available, so exactly 4 GiB. If for whatever 
reason it ends up being only 4 GiB -1 byte, I don't think anybody will 
care/notice (but it would have to be taken into account I suppose?

>
> And the one 64-bit environment that we're about to have in U-Boot
> (armv8) has discontiguous memory, which is another case where
> get_ram_size() won't work.
So get_ram_size() needs a brother, get_discont_ram_size? :)
>
>>> 32-bit.  A better approach would be to get the RAM size from the memory
>>> controller, which is what we do on many Freescale PPC boards.
>> Not possible for us at this moment. The memory controller is programed
>> with hard-coded values on a per board basis. I think we could
>> technically obtain values via/from the memory controller, but have no
>> knowledge at this moment. Allwinner has a tool, livesuit, which is used
>> to flash full disk images to a device. We currently guesstimate that
>> livesuit can somehow detect the memory parameters and injects it into
>> the stock bootloader. But we really have no clue if that really happens
>> or how it's done. So we rely on extracting the information from a
>> running stock android/linux and hardcode it into u-boot.
>
> So the issue is that you don't have documentation on what the values you
> program into the memory controller mean?  Can you extract the memory
> size as well from a running stock image?
Sort of, we bus-width, io-size and chip density, from those values we 
determine the chip-size/ram-size we can't exctract the actual number.

That said, io-size I think (or was it bus-width?) while programmed into 
the ram controller, isn't even highly important, it is expected that it 
is used for drive strength, 2 chips vs 4 chips, but physical examination 
of the tablet/board helps here.

Oliver
>
> BTW, shouldn't get_ram_size restore the original data in the final
> "return (maxsize)" case?  I know, patches welcome. :-)
>
> -Scott
>
>
>
Oliver Schinagl - Oct. 19, 2013, 9:21 a.m.
On 10/19/13 01:25, Scott Wood wrote:
> On Fri, 2013-10-18 at 18:25 -0500, Scott Wood wrote:
>> On Sat, 2013-10-19 at 01:07 +0200, Oliver Schinagl wrote:
>>> On 10/18/13 18:43, Scott Wood wrote:
>>>> On Fri, 2013-10-18 at 02:04 +0200, Oliver Schinagl wrote:
>>>>> So now that that's settled, anything fundamentally wrong with my patch? :)
>>>>
>>>> Did you see my other mail in this thread?  This patch is sort of OK for
>>> Sorry I did and I got distracted from it.
>>>
>>>> raising the get_ram_size() limit from 1 GiB to 2 GiB (with an increased
>>>> risk of false positives from I/O), but it can't go beyond that on
>>> I'd ask 'how so' but I'm not sure I'd understand anyway ;)
>>
>> Do you mean why it can't go beyond 2 GiB?  The next address to probe
>> after 0x8000_0000 would be 0x1_0000_0000 which is beyond what can be
>> addressed in a 32-bit environment.  I suppose you could return 4 GiB if
>> 0x8000_0000 tests OK, but nothing beyond that.  You'd need a larger
>> datatype than "unsigned long" if you want to return 4 GiB, though.
>
> Oh, and if you actually had 4 GiB of RAM mapped in a 32-bit environment,
> where would I/O go?
Well you need 4 GiB of address-space don't you? If you have 2 GiB of 
ram, the other 2 GiB is used as register-space isn't it. So to support 2 
GiB of ram you need 4 GiB of address sapce. Granted having more then 2 
GiB of ram is highly unlikly as you probably can't get ramsizes that 
would fit. But the bug exists with 2 GiB, get_ram_size in its current 
form, which triggered me into fixing it. get_ram_size reports negative 
ram on our 2 GiB board. Obviously incidentally it doesn't hugely matter 
because ramsize = get_ram_size(); you put a long inside an unsigned long 
and it gets automagically fixed.

My point was simply get_ram_size is bugged, it cramps signed long into 
an unsigned long, and I tried to fix that. A side effect is that upto 4 
GiB of address space is fixed. :)

Oliver
>
> -Scott
>
>
>
Tom Rini - Oct. 19, 2013, 6:25 p.m.
On Sat, Oct 19, 2013 at 11:07:54AM +0200, Oliver Schinagl wrote:

[snip]
> What my patch fixes is, that u-boot passes ram parameters (ramsize)
> via the global data -> ramsize. Ramsize is a phys_size_t which is
> defined as unsigned long (yay for typedef :p). Nearly all platforms
> pass the memory size to the linux kernel as gd->ramsize =
> get_ram_size();
> 
> And here is the bug, (unsigned long)ramsize = (signed long)get_ram_size();

Well, here's where we have a few related problems.  We need to:
a) Know how much memory U-Boot has available to it, to work with (for
relocation, image loading, etc, etc)
b) Tell an OS how much memory exists via ATAGs or Device Tree.

(b) is what gets complicated because the rule of thumb U-Boot has had
forever is to update the device tree to have "correct" memory
information.  A number of PowerPC boards have dtb files with 0x0 for
size, for auto-detect in U-Boot.  A number of ARM boards just have
128MiB size and then work well in Linux as we fixup that incorrect
amount to the larger real value.

We need a way to add in support for case (c) of "Device Tree has correct
memory information, DO NOT TOUCH".  This has been talked about before
but what I said in (b) complicates things.  We may way to see if for
example the DT indicates a size beyond what we can determine and if so,
just go with it (and perhaps a debug() print about not touching).
Wolfgang Denk - Oct. 21, 2013, 7:44 p.m.
Dear Scott Wood,

In message <1382138723.7979.928.camel@snotra.buserror.net> you wrote:
>
> And the one 64-bit environment that we're about to have in U-Boot
> (armv8) has discontiguous memory, which is another case where
> get_ram_size() won't work.

get_ram_size() is supposed to be run per memory bank.  If you have
discontiguous memory, then you probably have several memory banks that
can be sized separately?

> BTW, shouldn't get_ram_size restore the original data in the final
> "return (maxsize)" case?  I know, patches welcome. :-)

Yes, get_ram_size() is non-destructive (at least in the no-error
case; otherwise things like PRAM would not work).

Best regards,

Wolfgang Denk
Oliver Schinagl - March 24, 2014, 10:14 a.m.
Hey all,

*ping*

On 10/21/2013 09:44 PM, Wolfgang Denk wrote:
> Dear Scott Wood,
>
> In message <1382138723.7979.928.camel@snotra.buserror.net> you wrote:
>>
>> And the one 64-bit environment that we're about to have in U-Boot
>> (armv8) has discontiguous memory, which is another case where
>> get_ram_size() won't work.
>
> get_ram_size() is supposed to be run per memory bank.  If you have
> discontiguous memory, then you probably have several memory banks that
> can be sized separately?
>
>> BTW, shouldn't get_ram_size restore the original data in the final
>> "return (maxsize)" case?  I know, patches welcome. :-)
>
> Yes, get_ram_size() is non-destructive (at least in the no-error
> case; otherwise things like PRAM would not work).
Is there anything else that needs to be cleaned up in the patch I 
submitted back then (other then re-basing it I suppose).

With all the sunxi stuff slowly being cleaned up, this patch came to 
mind again and I was just wondering if anything needs to be done to get 
it merged. There was quite a big discussion about get_ram_size() in 
general, but nobody ever said if the signed long -> unsigned long was a 
good fix.

Olliver

>
> Best regards,
>
> Wolfgang Denk
>

Patch

From d143924a89917f68b59ecdaacd8e08bf85cf220a Mon Sep 17 00:00:00 2001
From: Oliver Schinagl <oliver@schinagl.nl>
Date: Mon, 7 Oct 2013 12:25:15 +0200
Subject: [PATCH u-boot (sc) 2/3] Update all references to get_ram_size to
 unsigned long

With the recent change to use unsigned longs over longs for get_ram_size
all references have to be updated. Since the old behavior was broken to
begin with, changes are kept as close to begin with for boards. For
boards where there where no consequences and could be safely converted
from long to unsigned long, those have been changed.

Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
---
 arch/arm/cpu/arm926ejs/davinci/misc.c           |  2 +-
 arch/arm/cpu/arm926ejs/kirkwood/dram.c          |  2 +-
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c       |  2 +-
 arch/arm/cpu/arm926ejs/orion5x/dram.c           |  2 +-
 arch/arm/cpu/armv7/am33xx/emif4.c               |  2 +-
 arch/arm/cpu/armv7/omap-common/emif-common.c    |  4 ++--
 arch/arm/cpu/armv7/socfpga/misc.c               |  2 +-
 arch/powerpc/cpu/mpc512x/fixed_sdram.c          |  2 +-
 arch/powerpc/cpu/ppc4xx/sdram.c                 |  8 ++++----
 board/AndesTech/adp-ag101/adp-ag101.c           |  2 +-
 board/AndesTech/adp-ag101p/adp-ag101p.c         |  2 +-
 board/AndesTech/adp-ag102/adp-ag102.c           |  2 +-
 board/BuS/eb_cpux9k2/cpux9k2.c                  |  2 +-
 board/BuS/vl_ma2sc/vl_ma2sc.c                   |  2 +-
 board/CarMediaLab/flea3/flea3.c                 |  2 +-
 board/LEOX/elpt860/elpt860.c                    |  2 +-
 board/RPXClassic/RPXClassic.c                   |  2 +-
 board/RPXlite/RPXlite.c                         |  2 +-
 board/RPXlite_dw/RPXlite_dw.c                   |  2 +-
 board/RRvision/RRvision.c                       |  2 +-
 board/a3000/a3000.c                             |  8 ++++----
 board/a3m071/a3m071.c                           |  4 ++--
 board/a4m072/a4m072.c                           |  4 ++--
 board/adder/adder.c                             |  2 +-
 board/afeb9260/afeb9260.c                       |  2 +-
 board/armltd/integrator/integrator.c            |  4 ++--
 board/armltd/versatile/versatile.c              |  2 +-
 board/armltd/vexpress/vexpress_common.c         |  6 +++---
 board/atc/atc.c                                 |  2 +-
 board/atmel/at91rm9200ek/at91rm9200ek.c         |  2 +-
 board/atmel/at91sam9260ek/at91sam9260ek.c       |  2 +-
 board/atmel/at91sam9261ek/at91sam9261ek.c       |  2 +-
 board/atmel/at91sam9263ek/at91sam9263ek.c       |  2 +-
 board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c |  2 +-
 board/atmel/at91sam9n12ek/at91sam9n12ek.c       |  2 +-
 board/atmel/at91sam9rlek/at91sam9rlek.c         |  2 +-
 board/atmel/at91sam9x5ek/at91sam9x5ek.c         |  2 +-
 board/atmel/atngw100/atngw100.c                 |  2 +-
 board/atmel/atngw100mkii/atngw100mkii.c         |  2 +-
 board/atmel/atstk1000/atstk1000.c               |  2 +-
 board/atmel/sama5d3xek/sama5d3xek.c             |  2 +-
 board/bc3450/bc3450.c                           |  8 ++++----
 board/bluewater/snapper9260/snapper9260.c       |  2 +-
 board/calao/sbc35_a9g20/sbc35_a9g20.c           |  2 +-
 board/calao/tny_a9260/tny_a9260.c               |  2 +-
 board/canmb/canmb.c                             |  8 ++++----
 board/cm5200/cm5200.c                           |  4 ++--
 board/congatec/cgtqmx6eval/cgtqmx6eval.c        |  2 +-
 board/cpu86/cpu86.c                             |  2 +-
 board/cpu87/cpu87.c                             |  2 +-
 board/cu824/cu824.c                             |  8 ++++----
 board/davedenx/qong/qong.c                      |  2 +-
 board/denx/m53evk/m53evk.c                      |  6 +++---
 board/earthlcd/favr-32-ezkit/favr-32-ezkit.c    |  2 +-
 board/egnite/ethernut5/ethernut5.c              |  2 +-
 board/emk/top9000/top9000.c                     |  2 +-
 board/ep88x/ep88x.c                             |  2 +-
 board/esd/cpci5200/cpci5200.c                   |  4 ++--
 board/esd/mecp5123/mecp5123.c                   |  2 +-
 board/esd/meesc/meesc.c                         |  2 +-
 board/esd/otc570/otc570.c                       |  2 +-
 board/esd/pf5200/pf5200.c                       |  4 ++--
 board/esd/vme8349/vme8349.c                     |  2 +-
 board/esg/ima3-mx53/ima3-mx53.c                 |  2 +-
 board/esteem192e/esteem192e.c                   |  4 ++--
 board/eukrea/cpu9260/cpu9260.c                  |  2 +-
 board/eukrea/cpuat91/cpuat91.c                  |  2 +-
 board/fads/fads.c                               |  2 +-
 board/faraday/a320evb/a320evb.c                 |  2 +-
 board/freescale/mpc8308rdb/sdram.c              |  2 +-
 board/freescale/mx25pdk/mx25pdk.c               |  2 +-
 board/freescale/mx31ads/mx31ads.c               |  2 +-
 board/freescale/mx31pdk/mx31pdk.c               |  2 +-
 board/freescale/mx35pdk/mx35pdk.c               |  6 +++---
 board/freescale/mx51evk/mx51evk.c               |  2 +-
 board/freescale/mx53ard/mx53ard.c               |  6 +++---
 board/freescale/mx53evk/mx53evk.c               |  2 +-
 board/freescale/mx53loco/mx53loco.c             |  6 +++---
 board/freescale/mx53smd/mx53smd.c               |  6 +++---
 board/freescale/mx6qarm2/mx6qarm2.c             |  2 +-
 board/freescale/mx6qsabreauto/mx6qsabreauto.c   |  2 +-
 board/freescale/mx6sabresd/mx6sabresd.c         |  2 +-
 board/freescale/mx6slevk/mx6slevk.c             |  2 +-
 board/freescale/titanium/titanium.c             |  2 +-
 board/freescale/vf610twr/vf610twr.c             |  2 +-
 board/friendlyarm/mini2440/mini2440.c           |  2 +-
 board/galaxy5200/galaxy5200.c                   |  4 ++--
 board/genesi/mx51_efikamx/efikamx.c             |  2 +-
 board/genietv/genietv.c                         |  6 +++---
 board/hale/tt01/tt01.c                          |  2 +-
 board/hermes/hermes.c                           |  3 ++-
 board/hidden_dragon/hidden_dragon.c             |  8 ++++----
 board/icecube/icecube.c                         |  8 ++++----
 board/icpdas/lp8x4x/lp8x4x.c                    |  2 +-
 board/icu862/icu862.c                           |  2 +-
 board/ids8247/ids8247.c                         |  4 ++--
 board/ifm/o2dnt2/o2dnt2.c                       |  8 ++++----
 board/imx31_phycore/imx31_phycore.c             |  2 +-
 board/in-circuit/grasshopper/grasshopper.c      |  2 +-
 board/incaip/incaip.c                           |  2 +-
 board/inka4x0/inka4x0.c                         |  6 +++---
 board/intercontrol/digsy_mtc/digsy_mtc.c        |  6 +++---
 board/ip860/ip860.c                             |  3 ++-
 board/ipek01/ipek01.c                           |  4 ++--
 board/iphase4539/iphase4539.c                   |  2 +-
 board/ispan/ispan.c                             |  2 +-
 board/ivm/ivm.c                                 |  3 ++-
 board/jupiter/jupiter.c                         |  8 ++++----
 board/karo/tx25/tx25.c                          |  6 +++---
 board/keymile/km82xx/km82xx.c                   |  2 +-
 board/logicpd/imx27lite/imx27lite.c             |  6 +++---
 board/logicpd/imx31_litekit/imx31_litekit.c     |  2 +-
 board/lwmon/lwmon.c                             |  2 +-
 board/manroland/hmi1001/hmi1001.c               |  4 ++--
 board/manroland/mucmc52/mucmc52.c               |  8 ++++----
 board/manroland/uc101/uc101.c                   |  4 ++--
 board/matrix_vision/mvbc_p/mvbc_p.c             |  4 ++--
 board/matrix_vision/mvsmr/mvsmr.c               |  4 ++--
 board/mcc200/mcc200.c                           |  8 ++++----
 board/micronas/vct/vct.c                        |  2 +-
 board/mimc/mimc200/mimc200.c                    |  2 +-
 board/miromico/hammerhead/hammerhead.c          |  2 +-
 board/motionpro/motionpro.c                     |  4 ++--
 board/muas3001/muas3001.c                       |  2 +-
 board/munices/munices.c                         |  4 ++--
 board/musenki/musenki.c                         |  8 ++++----
 board/mvblue/mvblue.c                           |  8 ++++----
 board/mx1ads/mx1ads.c                           |  2 +-
 board/netphone/netphone.c                       |  2 +-
 board/netta/netta.c                             |  2 +-
 board/netta2/netta2.c                           |  2 +-
 board/nx823/nx823.c                             |  3 ++-
 board/phytec/pcm030/pcm030.c                    |  4 ++--
 board/pm520/pm520.c                             |  8 ++++----
 board/pm826/pm826.c                             |  2 +-
 board/pn62/pn62.c                               |  8 ++++----
 board/r360mpi/r360mpi.c                         |  2 +-
 board/rbc823/rbc823.c                           |  3 ++-
 board/ronetix/pm9261/pm9261.c                   |  2 +-
 board/ronetix/pm9263/pm9263.c                   |  2 +-
 board/ronetix/pm9g45/pm9g45.c                   |  2 +-
 board/samsung/arndale/arndale.c                 |  4 ++--
 board/samsung/origen/origen.c                   | 20 ++++++++++++--------
 board/samsung/smdk5250/exynos5-dt.c             |  8 ++++----
 board/samsung/smdk5250/smdk5250.c               |  8 ++++----
 board/samsung/smdkc100/smdkc100.c               |  2 +-
 board/samsung/smdkv310/smdkv310.c               | 20 ++++++++++++--------
 board/samsung/trats/trats.c                     | 12 ++++++++----
 board/samsung/universal_c210/universal.c        |  6 ++++--
 board/sandpoint/sandpoint.c                     |  8 ++++----
 board/scb9328/scb9328.c                         |  2 +-
 board/snmc/qs850/qs850.c                        |  2 +-
 board/snmc/qs860t/qs860t.c                      |  2 +-
 board/socrates/sdram.c                          |  2 +-
 board/spc1920/spc1920.c                         |  2 +-
 board/spd8xx/spd8xx.c                           |  2 +-
 board/stx/stxxtc/stxxtc.c                       |  4 ++--
 board/syteco/jadecpu/jadecpu.c                  |  2 +-
 board/syteco/zmx25/zmx25.c                      |  2 +-
 board/taskit/stamp9g20/stamp9g20.c              |  2 +-
 board/ti/omap5912osk/omap5912osk.c              |  2 +-
 board/timll/devkit3250/devkit3250.c             |  2 +-
 board/total5200/sdram.c                         |  8 ++++----
 board/tqc/tqm5200/tqm5200.c                     |  8 ++++----
 board/tqc/tqm8260/tqm8260.c                     |  4 ++--
 board/tqc/tqm8272/tqm8272.c                     |  4 ++--
 board/tqc/tqm834x/tqm834x.c                     |  2 +-
 board/tqc/tqm8xx/tqm8xx.c                       |  2 +-
 board/ttcontrol/vision2/vision2.c               |  2 +-
 board/utx8245/utx8245.c                         | 10 +++++-----
 board/v38b/v38b.c                               |  8 ++++----
 board/ve8313/ve8313.c                           |  2 +-
 board/woodburn/woodburn.c                       |  2 +-
 post/board/lwmon5/fpga.c                        |  2 +-
 post/board/lwmon5/gdc.c                         |  2 +-
 175 files changed, 323 insertions(+), 304 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/davinci/misc.c b/arch/arm/cpu/arm926ejs/davinci/misc.c
index e18bdfc..65448ed 100644
--- a/arch/arm/cpu/arm926ejs/davinci/misc.c
+++ b/arch/arm/cpu/arm926ejs/davinci/misc.c
@@ -23,7 +23,7 @@  int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
 	gd->ram_size = get_ram_size(
-			(void *)CONFIG_SYS_SDRAM_BASE,
+			(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			CONFIG_MAX_RAM_BANK_SIZE);
 	return 0;
 }
diff --git a/arch/arm/cpu/arm926ejs/kirkwood/dram.c b/arch/arm/cpu/arm926ejs/kirkwood/dram.c
index d73ae47..e13493e 100644
--- a/arch/arm/cpu/arm926ejs/kirkwood/dram.c
+++ b/arch/arm/cpu/arm926ejs/kirkwood/dram.c
@@ -86,7 +86,7 @@  void kw_sdram_size_adjust(enum memory_bank bank)
 	u32 size;
 
 	/* probe currently equipped RAM size */
-	size = get_ram_size((void *)kw_sdram_bar(bank), kw_sdram_bs(bank));
+	size = (u32)get_ram_size((unsigned long *)kw_sdram_bar(bank), (unsigned long)kw_sdram_bs(bank));
 
 	/* adjust SDRAM window size accordingly */
 	kw_sdram_bs_set(bank, size);
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
index 3baf4dd..a6f3c1f 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
@@ -226,7 +226,7 @@  uint32_t mxs_mem_get_size(void)
 	da = vt[4];
 	vt[4] = data_abort_memdetect_handler;
 
-	sz = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	sz = (uint32_t)get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
 
 	/* Restore the old DABT handler. */
 	vt[4] = da;
diff --git a/arch/arm/cpu/arm926ejs/orion5x/dram.c b/arch/arm/cpu/arm926ejs/orion5x/dram.c
index 9ed93d2..6fe38e5 100644
--- a/arch/arm/cpu/arm926ejs/orion5x/dram.c
+++ b/arch/arm/cpu/arm926ejs/orion5x/dram.c
@@ -37,7 +37,7 @@  int dram_init (void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
 	gd->ram_size = get_ram_size(
-			(long *) orion5x_sdram_bar(0),
+			(unsigned long *) orion5x_sdram_bar(0),
 			CONFIG_MAX_RAM_BANK_SIZE);
 	return 0;
 }
diff --git a/arch/arm/cpu/armv7/am33xx/emif4.c b/arch/arm/cpu/armv7/am33xx/emif4.c
index 59ad25c..f4a876b 100644
--- a/arch/arm/cpu/armv7/am33xx/emif4.c
+++ b/arch/arm/cpu/armv7/am33xx/emif4.c
@@ -23,7 +23,7 @@  int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
 	gd->ram_size = get_ram_size(
-			(void *)CONFIG_SYS_SDRAM_BASE,
+			(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			CONFIG_MAX_RAM_BANK_SIZE);
 	return 0;
 }
diff --git a/arch/arm/cpu/armv7/omap-common/emif-common.c b/arch/arm/cpu/armv7/omap-common/emif-common.c
index b0e1caa..aa9bb04 100644
--- a/arch/arm/cpu/armv7/omap-common/emif-common.c
+++ b/arch/arm/cpu/armv7/omap-common/emif-common.c
@@ -1307,8 +1307,8 @@  void sdram_init(void)
 		size_prog = log_2_n_round_down(size_prog);
 		size_prog = (1 << size_prog);
 
-		size_detect = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
-						size_prog);
+		size_detect = (u32)get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
+						(unsigned long)size_prog);
 		/* Compare with the size programmed */
 		if (size_detect != size_prog) {
 			printf("SDRAM: identified size not same as expected"
diff --git a/arch/arm/cpu/armv7/socfpga/misc.c b/arch/arm/cpu/armv7/socfpga/misc.c
index 2f1c716..058a5ea 100644
--- a/arch/arm/cpu/armv7/socfpga/misc.c
+++ b/arch/arm/cpu/armv7/socfpga/misc.c
@@ -11,6 +11,6 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/arch/powerpc/cpu/mpc512x/fixed_sdram.c b/arch/powerpc/cpu/mpc512x/fixed_sdram.c
index 6451ea9..6517f36 100644
--- a/arch/powerpc/cpu/mpc512x/fixed_sdram.c
+++ b/arch/powerpc/cpu/mpc512x/fixed_sdram.c
@@ -146,7 +146,7 @@  long int fixed_sdram(ddr512x_config_t *mddrc_config,
 	/* Allow for the DLL to startup before accessing data */
 	udelay(10);
 
-	msize = get_ram_size(CONFIG_SYS_DDR_BASE, CONFIG_SYS_MAX_RAM_SIZE);
+	msize = (u32)get_ram_size(CONFIG_SYS_DDR_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 	/* Fix DDR Local Window for new size */
 	out_be32(&im->sysconf.ddrlaw.ar, __ilog2(msize) - 1);
 	sync_law(&im->sysconf.ddrlaw.ar);
diff --git a/arch/powerpc/cpu/ppc4xx/sdram.c b/arch/powerpc/cpu/ppc4xx/sdram.c
index 2d95bc5..eca59a1 100644
--- a/arch/powerpc/cpu/ppc4xx/sdram.c
+++ b/arch/powerpc/cpu/ppc4xx/sdram.c
@@ -192,7 +192,7 @@  phys_size_t initdram(int board_type)
 
 		udelay(10000);
 
-		if (get_ram_size(0, mb0cf[i].size) == mb0cf[i].size) {
+		if (get_ram_size((unsigned long *)0, mb0cf[i].size) == mb0cf[i].size) {
 			phys_size_t size = mb0cf[i].size;
 
 			/*
@@ -210,7 +210,7 @@  phys_size_t initdram(int board_type)
 			 * If the size not equal to the size of the first
 			 * bank, then disable the 2nd bank completely.
 			 */
-			if (get_ram_size((long *)mb0cf[i].size, mb0cf[i].size) !=
+			if (get_ram_size((unsigned long *)mb0cf[i].size, (unsigned long)mb0cf[i].size) !=
 			    mb0cf[i].size) {
 				mtsdram(SDRAM0_B1CR, 0);
 				mtsdram(SDRAM0_CFG, 0);
@@ -394,7 +394,7 @@  phys_size_t initdram(int board_type)
 		mtsdram(SDRAM0_CFG0, CONFIG_SYS_SDRAM0_CFG0);
 		udelay(10000);
 
-		if (get_ram_size(0, mb0cf[i].size) == mb0cf[i].size) {
+		if (get_ram_size((unsigned long *)0, mb0cf[i].size) == mb0cf[i].size) {
 			phys_size_t size = mb0cf[i].size;
 			/*
 			 * Optimize TR1 to current hardware environment
@@ -418,7 +418,7 @@  phys_size_t initdram(int board_type)
 			 * If the size not equal to the size of the first
 			 * bank, then disable the 2nd bank completely.
 			 */
-			if (get_ram_size((long *)mb0cf[i].size, mb0cf[i].size)
+			if (get_ram_size((unsigned long *)mb0cf[i].size, mb0cf[i].size)
 			    != mb0cf[i].size) {
 				mtsdram(SDRAM0_CFG0, 0);
 				mtsdram(SDRAM0_B1CR, 0);
diff --git a/board/AndesTech/adp-ag101/adp-ag101.c b/board/AndesTech/adp-ag101/adp-ag101.c
index 9884a5b..a579503 100644
--- a/board/AndesTech/adp-ag101/adp-ag101.c
+++ b/board/AndesTech/adp-ag101/adp-ag101.c
@@ -38,7 +38,7 @@  int dram_init(void)
 	unsigned long expected_size = PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE;
 	unsigned long actual_size;
 
-	actual_size = get_ram_size((void *)sdram_base, expected_size);
+	actual_size = get_ram_size((unsigned long *)sdram_base, expected_size);
 
 	gd->ram_size = actual_size;
 
diff --git a/board/AndesTech/adp-ag101p/adp-ag101p.c b/board/AndesTech/adp-ag101p/adp-ag101p.c
index dd8a6653..4992c6c 100644
--- a/board/AndesTech/adp-ag101p/adp-ag101p.c
+++ b/board/AndesTech/adp-ag101p/adp-ag101p.c
@@ -38,7 +38,7 @@  int dram_init(void)
 	unsigned long expected_size = PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE;
 	unsigned long actual_size;
 
-	actual_size = get_ram_size((void *)sdram_base, expected_size);
+	actual_size = get_ram_size((unsigned long *)sdram_base, expected_size);
 
 	gd->ram_size = actual_size;
 
diff --git a/board/AndesTech/adp-ag102/adp-ag102.c b/board/AndesTech/adp-ag102/adp-ag102.c
index 3f879ab..ad6482f 100644
--- a/board/AndesTech/adp-ag102/adp-ag102.c
+++ b/board/AndesTech/adp-ag102/adp-ag102.c
@@ -43,7 +43,7 @@  int dram_init(void)
 	unsigned long expected_size = PHYS_SDRAM_0_SIZE;
 	unsigned long actual_size;
 
-	actual_size = get_ram_size((void *)sdram_base, expected_size);
+	actual_size = get_ram_size((unsigned long *)sdram_base, expected_size);
 
 	gd->ram_size = actual_size;
 
diff --git a/board/BuS/eb_cpux9k2/cpux9k2.c b/board/BuS/eb_cpux9k2/cpux9k2.c
index 5e4778e..5742b50 100644
--- a/board/BuS/eb_cpux9k2/cpux9k2.c
+++ b/board/BuS/eb_cpux9k2/cpux9k2.c
@@ -121,7 +121,7 @@  void reset_phy(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/BuS/vl_ma2sc/vl_ma2sc.c b/board/BuS/vl_ma2sc/vl_ma2sc.c
index e2ae6fd..30f6f7e 100644
--- a/board/BuS/vl_ma2sc/vl_ma2sc.c
+++ b/board/BuS/vl_ma2sc/vl_ma2sc.c
@@ -280,7 +280,7 @@  int misc_init_r(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE,
 			CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/CarMediaLab/flea3/flea3.c b/board/CarMediaLab/flea3/flea3.c
index 7f5cfc8..c668e2b 100644
--- a/board/CarMediaLab/flea3/flea3.c
+++ b/board/CarMediaLab/flea3/flea3.c
@@ -52,7 +52,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 		PHYS_SDRAM_1_SIZE);
 
 	return 0;
diff --git a/board/LEOX/elpt860/elpt860.c b/board/LEOX/elpt860/elpt860.c
index 81820cb..6c9cb57 100644
--- a/board/LEOX/elpt860/elpt860.c
+++ b/board/LEOX/elpt860/elpt860.c
@@ -312,7 +312,7 @@  dram_size (long int mamr_value, long int *base, long int maxsize)
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size (base, maxsize));
+	return (long int)(get_ram_size ((unsigned long)base, (unsigned long)maxsize));
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/board/RPXClassic/RPXClassic.c b/board/RPXClassic/RPXClassic.c
index f47e8fa..6dd3f0f 100644
--- a/board/RPXClassic/RPXClassic.c
+++ b/board/RPXClassic/RPXClassic.c
@@ -218,7 +218,7 @@  static long int dram_size (long int mamr_value, long int *base, long int maxsize
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long)base, (unsigned long)maxsize));
 }
 /*-----------------------------------------------------------------------------
  * aschex_to_byte --
diff --git a/board/RPXlite/RPXlite.c b/board/RPXlite/RPXlite.c
index 08575a4..48f225f 100644
--- a/board/RPXlite/RPXlite.c
+++ b/board/RPXlite/RPXlite.c
@@ -145,5 +145,5 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size (base, maxsize));
+	return (long int)(get_ram_size ((unsigned long)base, (unsigned long)maxsize));
 }
diff --git a/board/RPXlite_dw/RPXlite_dw.c b/board/RPXlite_dw/RPXlite_dw.c
index 29d52de..48ac59c 100644
--- a/board/RPXlite_dw/RPXlite_dw.c
+++ b/board/RPXlite_dw/RPXlite_dw.c
@@ -160,5 +160,5 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size (base, maxsize));
+	return (long int)(get_ram_size ((unsigned long)base, (unsigned long)maxsize));
 }
diff --git a/board/RRvision/RRvision.c b/board/RRvision/RRvision.c
index d94e238..e048b8c 100644
--- a/board/RRvision/RRvision.c
+++ b/board/RRvision/RRvision.c
@@ -218,5 +218,5 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long)base, (unsigned long)maxsize));
 }
diff --git a/board/a3000/a3000.c b/board/a3000/a3000.c
index 3e2f6b0..6432dd0 100644
--- a/board/a3000/a3000.c
+++ b/board/a3000/a3000.c
@@ -25,10 +25,10 @@  int checkboard (void)
 
 phys_size_t initdram (int board_type)
 {
-	long size;
-	long new_bank0_end;
-	long mear1;
-	long emear1;
+	unsigned long size;
+	unsigned long new_bank0_end;
+	unsigned long mear1;
+	unsigned long emear1;
 
 	size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 
diff --git a/board/a3m071/a3m071.c b/board/a3m071/a3m071.c
index 7aeefb2..9c9a7b4 100644
--- a/board/a3m071/a3m071.c
+++ b/board/a3m071/a3m071.c
@@ -100,9 +100,9 @@  phys_size_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/a4m072/a4m072.c b/board/a4m072/a4m072.c
index d3d4c18..aca3677 100644
--- a/board/a4m072/a4m072.c
+++ b/board/a4m072/a4m072.c
@@ -97,9 +97,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/adder/adder.c b/board/adder/adder.c
index fa1a54b..c24ec8b 100644
--- a/board/adder/adder.c
+++ b/board/adder/adder.c
@@ -81,7 +81,7 @@  phys_size_t initdram (int board_type)
 	memctl->memc_or1   = ~(CONFIG_SYS_SDRAM_MAX_SIZE - 1) | OR_CSNT_SAM;
 	memctl->memc_br1   =  CONFIG_SYS_SDRAM_BASE | BR_PS_32 | BR_MS_UPMA | BR_V;
 
-	msize = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_SDRAM_MAX_SIZE);
+	msize = (long int)get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_SDRAM_MAX_SIZE);
 	memctl->memc_or1  |= ~(msize - 1);
 
 	return msize;
diff --git a/board/afeb9260/afeb9260.c b/board/afeb9260/afeb9260.c
index e1b1c10..bb8c791 100644
--- a/board/afeb9260/afeb9260.c
+++ b/board/afeb9260/afeb9260.c
@@ -153,7 +153,7 @@  int board_init(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-	(void *)CONFIG_SYS_SDRAM_BASE,
+	(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 
 	return 0;
diff --git a/board/armltd/integrator/integrator.c b/board/armltd/integrator/integrator.c
index 62870c6..3772588 100644
--- a/board/armltd/integrator/integrator.c
+++ b/board/armltd/integrator/integrator.c
@@ -137,12 +137,12 @@  extern void dram_query(void);
 	 *
 	 */
 	sdram_shift = ((cm_reg_sdram & 0x0000001C)/4)%4;
-	gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE +
+	gd->ram_size = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE +
 				    REMAPPED_FLASH_SZ,
 				    0x01000000 << sdram_shift);
 	}
 #else
-	gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE +
+	gd->ram_size = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE +
 				    REMAPPED_FLASH_SZ,
 				    PHYS_SDRAM_1_SIZE);
 #endif /* CM_SPD_DETECT */
diff --git a/board/armltd/versatile/versatile.c b/board/armltd/versatile/versatile.c
index 30a3b90..0b8ae6b 100644
--- a/board/armltd/versatile/versatile.c
+++ b/board/armltd/versatile/versatile.c
@@ -78,7 +78,7 @@  int misc_init_r (void)
 int dram_init (void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/armltd/vexpress/vexpress_common.c b/board/armltd/vexpress/vexpress_common.c
index 4c7a7f4..4b975e1 100644
--- a/board/armltd/vexpress/vexpress_common.c
+++ b/board/armltd/vexpress/vexpress_common.c
@@ -108,7 +108,7 @@  static void flash__init(void)
 int dram_init(void)
 {
 	gd->ram_size =
-		get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, PHYS_SDRAM_1_SIZE);
+		get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, PHYS_SDRAM_1_SIZE);
 	return 0;
 }
 
@@ -116,10 +116,10 @@  void dram_init_banksize(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
 	gd->bd->bi_dram[0].size =
-			get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+			get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
 	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
 	gd->bd->bi_dram[1].size =
-			get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+			get_ram_size((unsigned long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
 }
 
 int timer_init(void)
diff --git a/board/atc/atc.c b/board/atc/atc.c
index 0038561..147867a 100644
--- a/board/atc/atc.c
+++ b/board/atc/atc.c
@@ -306,7 +306,7 @@  static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
 	*sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
 	*base = c;
 
-	size = get_ram_size((long *)base, maxsize);
+	size = get_ram_size((unsigned long *)base, maxsize);
 
 	*orx_ptr = orx | ~(size - 1);
 
diff --git a/board/atmel/at91rm9200ek/at91rm9200ek.c b/board/atmel/at91rm9200ek/at91rm9200ek.c
index 64ab572..31c4bd1 100644
--- a/board/atmel/at91rm9200ek/at91rm9200ek.c
+++ b/board/atmel/at91rm9200ek/at91rm9200ek.c
@@ -48,7 +48,7 @@  int board_early_init_f(void)
 int dram_init (void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/atmel/at91sam9260ek/at91sam9260ek.c b/board/atmel/at91sam9260ek/at91sam9260ek.c
index 263de49..abc9873 100644
--- a/board/atmel/at91sam9260ek/at91sam9260ek.c
+++ b/board/atmel/at91sam9260ek/at91sam9260ek.c
@@ -171,7 +171,7 @@  int board_init(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-		(void *)CONFIG_SYS_SDRAM_BASE,
+		(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c
index 3e8f062..bd20112 100644
--- a/board/atmel/at91sam9261ek/at91sam9261ek.c
+++ b/board/atmel/at91sam9261ek/at91sam9261ek.c
@@ -261,7 +261,7 @@  int board_eth_init(bd_t *bis)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 
 	return 0;
diff --git a/board/atmel/at91sam9263ek/at91sam9263ek.c b/board/atmel/at91sam9263ek/at91sam9263ek.c
index 2e9246f..f6021ec 100644
--- a/board/atmel/at91sam9263ek/at91sam9263ek.c
+++ b/board/atmel/at91sam9263ek/at91sam9263ek.c
@@ -270,7 +270,7 @@  int board_init(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 
 	return 0;
diff --git a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
index 6a071f6..f812bfc 100644
--- a/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
+++ b/board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
@@ -275,7 +275,7 @@  int board_init(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE,
 				    CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/atmel/at91sam9n12ek/at91sam9n12ek.c b/board/atmel/at91sam9n12ek/at91sam9n12ek.c
index 2ec32eb..1adb646 100644
--- a/board/atmel/at91sam9n12ek/at91sam9n12ek.c
+++ b/board/atmel/at91sam9n12ek/at91sam9n12ek.c
@@ -242,7 +242,7 @@  int board_eth_init(bd_t *bis)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 					CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/atmel/at91sam9rlek/at91sam9rlek.c b/board/atmel/at91sam9rlek/at91sam9rlek.c
index c700a90..b61ffdc 100644
--- a/board/atmel/at91sam9rlek/at91sam9rlek.c
+++ b/board/atmel/at91sam9rlek/at91sam9rlek.c
@@ -197,7 +197,7 @@  int board_init(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-		(void *)CONFIG_SYS_SDRAM_BASE,
+		(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
index 6f67c34..2e00500 100644
--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
@@ -290,7 +290,7 @@  int board_init(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE,
 					CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/atmel/atngw100/atngw100.c b/board/atmel/atngw100/atngw100.c
index 03d767a..e4b40df 100644
--- a/board/atmel/atngw100/atngw100.c
+++ b/board/atmel/atngw100/atngw100.c
@@ -77,7 +77,7 @@  phys_size_t initdram(int board_type)
 	sdram_base = uncached(EBI_SDRAM_BASE);
 
 	expected_size = sdram_init(sdram_base, &sdram_config);
-	actual_size = get_ram_size(sdram_base, expected_size);
+	actual_size = get_ram_size((unsigned long *)sdram_base, expected_size);
 
 	if (expected_size != actual_size)
 		printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
diff --git a/board/atmel/atngw100mkii/atngw100mkii.c b/board/atmel/atngw100mkii/atngw100mkii.c
index 72d19e4..90524a9 100644
--- a/board/atmel/atngw100mkii/atngw100mkii.c
+++ b/board/atmel/atngw100mkii/atngw100mkii.c
@@ -94,7 +94,7 @@  phys_size_t initdram(int board_type)
 	sdram_base = uncached(EBI_SDRAM_BASE);
 
 	expected_size = sdram_init(sdram_base, &sdram_config);
-	actual_size = get_ram_size(sdram_base, expected_size);
+	actual_size = get_ram_size((unsigned long *)sdram_base, expected_size);
 
 	if (expected_size != actual_size)
 		printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
diff --git a/board/atmel/atstk1000/atstk1000.c b/board/atmel/atstk1000/atstk1000.c
index 4b6b90f..75ddd13 100644
--- a/board/atmel/atstk1000/atstk1000.c
+++ b/board/atmel/atstk1000/atstk1000.c
@@ -99,7 +99,7 @@  phys_size_t initdram(int board_type)
 	sdram_base = uncached(EBI_SDRAM_BASE);
 
 	expected_size = sdram_init(sdram_base, &sdram_config);
-	actual_size = get_ram_size(sdram_base, expected_size);
+	actual_size = get_ram_size((unsigned long *)sdram_base, expected_size);
 
 	if (expected_size != actual_size)
 		printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
diff --git a/board/atmel/sama5d3xek/sama5d3xek.c b/board/atmel/sama5d3xek/sama5d3xek.c
index 97caf64..3c0ba65 100644
--- a/board/atmel/sama5d3xek/sama5d3xek.c
+++ b/board/atmel/sama5d3xek/sama5d3xek.c
@@ -191,7 +191,7 @@  int board_init(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				    CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/bc3450/bc3450.c b/board/bc3450/bc3450.c
index bfb11bf..4c0f291 100644
--- a/board/bc3450/bc3450.c
+++ b/board/bc3450/bc3450.c
@@ -113,9 +113,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -141,9 +141,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS1 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
+	test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
+	test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize2 = test1;
diff --git a/board/bluewater/snapper9260/snapper9260.c b/board/bluewater/snapper9260/snapper9260.c
index 8a6919d..2a04e99 100644
--- a/board/bluewater/snapper9260/snapper9260.c
+++ b/board/bluewater/snapper9260/snapper9260.c
@@ -146,7 +146,7 @@  int board_eth_init(bd_t *bis)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				    CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/calao/sbc35_a9g20/sbc35_a9g20.c b/board/calao/sbc35_a9g20/sbc35_a9g20.c
index ecf261c..5047e77 100644
--- a/board/calao/sbc35_a9g20/sbc35_a9g20.c
+++ b/board/calao/sbc35_a9g20/sbc35_a9g20.c
@@ -151,7 +151,7 @@  int board_init(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-		(void *)CONFIG_SYS_SDRAM_BASE,
+		(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/calao/tny_a9260/tny_a9260.c b/board/calao/tny_a9260/tny_a9260.c
index 337be43..c2c4bfb 100644
--- a/board/calao/tny_a9260/tny_a9260.c
+++ b/board/calao/tny_a9260/tny_a9260.c
@@ -79,7 +79,7 @@  int board_init(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-		(void *)CONFIG_SYS_SDRAM_BASE,
+		(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/canmb/canmb.c b/board/canmb/canmb.c
index 15c934d..1164df4 100644
--- a/board/canmb/canmb.c
+++ b/board/canmb/canmb.c
@@ -90,9 +90,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -118,10 +118,10 @@  phys_size_t initdram (int board_type)
 	/* find RAM size using SDRAM CS1 only */
 	if (!dramsize)
 		sdram_start(0);
-	test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+	test2 = test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	if (!dramsize) {
 		sdram_start(1);
-		test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+		test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	}
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/cm5200/cm5200.c b/board/cm5200/cm5200.c
index e391dfc..40ad9c4 100644
--- a/board/cm5200/cm5200.c
+++ b/board/cm5200/cm5200.c
@@ -114,9 +114,9 @@  phys_size_t initdram(int board_type)
 	*(vu_long *)MPC5XXX_SDRAM_CONFIG2 = mem_conf->config2;
 
 	sdram_start(0, mem_conf);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1, mem_conf);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0, mem_conf);
 		dramsize = test1;
diff --git a/board/congatec/cgtqmx6eval/cgtqmx6eval.c b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
index d421527..7fbeaa4 100644
--- a/board/congatec/cgtqmx6eval/cgtqmx6eval.c
+++ b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
@@ -29,7 +29,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
 
 	return 0;
 }
diff --git a/board/cpu86/cpu86.c b/board/cpu86/cpu86.c
index 9292910..e9b90f6 100644
--- a/board/cpu86/cpu86.c
+++ b/board/cpu86/cpu86.c
@@ -250,7 +250,7 @@  static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
 	*sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
 	*base = c;
 
-	size = get_ram_size((long *)base, maxsize);
+	size = get_ram_size((unsigned long *)base, maxsize);
 
 	*orx_ptr = orx | ~(size - 1);
 
diff --git a/board/cpu87/cpu87.c b/board/cpu87/cpu87.c
index 01f90d2..6cc5a8c 100644
--- a/board/cpu87/cpu87.c
+++ b/board/cpu87/cpu87.c
@@ -252,7 +252,7 @@  static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
 	*sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
 	*base = c;
 
-	size = get_ram_size((long *)base, maxsize);
+	size = get_ram_size((unsigned long *)base, maxsize);
 
 	*orx_ptr = orx | ~(size - 1);
 
diff --git a/board/cu824/cu824.c b/board/cu824/cu824.c
index 6b23c53..a980bd2 100644
--- a/board/cu824/cu824.c
+++ b/board/cu824/cu824.c
@@ -32,10 +32,10 @@  int checkboard (void)
 
 phys_size_t initdram(int board_type)
 {
-	long size;
-	long new_bank0_end;
-	long mear1;
-	long emear1;
+	unsigned long size;
+	unsigned long new_bank0_end;
+	unsigned long mear1;
+	unsigned long emear1;
 
 	size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 
diff --git a/board/davedenx/qong/qong.c b/board/davedenx/qong/qong.c
index ad1694b..bc9b6eb 100644
--- a/board/davedenx/qong/qong.c
+++ b/board/davedenx/qong/qong.c
@@ -24,7 +24,7 @@  DECLARE_GLOBAL_DATA_PTR;
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/denx/m53evk/m53evk.c b/board/denx/m53evk/m53evk.c
index 3275170..4b8114a 100644
--- a/board/denx/m53evk/m53evk.c
+++ b/board/denx/m53evk/m53evk.c
@@ -27,10 +27,10 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	u32 size1, size2;
+	unsigned long size1, size2;
 
-	size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
-	size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+	size1 = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	size2 = get_ram_size((unsigned long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
 
 	gd->ram_size = size1 + size2;
 
diff --git a/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c b/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c
index a74547b..0b41d6c 100644
--- a/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c
+++ b/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c
@@ -67,7 +67,7 @@  phys_size_t initdram(int board_type)
 {
 	unsigned long expected_size;
 	unsigned long actual_size;
-	void *sdram_base;
+	unsigned long *sdram_base;
 
 	sdram_base = uncached(EBI_SDRAM_BASE);
 
diff --git a/board/egnite/ethernut5/ethernut5.c b/board/egnite/ethernut5/ethernut5.c
index 1f5eea5..bd84f63 100644
--- a/board/egnite/ethernut5/ethernut5.c
+++ b/board/egnite/ethernut5/ethernut5.c
@@ -105,7 +105,7 @@  dataflash_protect_t area_list[NB_DATAFLASH_AREA] = {
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-			(void *)CONFIG_SYS_SDRAM_BASE,
+			(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/emk/top9000/top9000.c b/board/emk/top9000/top9000.c
index 6e2ffdd..32c8008 100644
--- a/board/emk/top9000/top9000.c
+++ b/board/emk/top9000/top9000.c
@@ -171,7 +171,7 @@  int misc_init_r(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-		(void *)CONFIG_SYS_SDRAM_BASE,
+		(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/ep88x/ep88x.c b/board/ep88x/ep88x.c
index 8a60b58..8e436ff 100644
--- a/board/ep88x/ep88x.c
+++ b/board/ep88x/ep88x.c
@@ -93,7 +93,7 @@  phys_size_t initdram (int board_type)
 	memctl->memc_or1   = ~(CONFIG_SYS_SDRAM_MAX_SIZE - 1) | OR_CSNT_SAM;
 	memctl->memc_br1   =  CONFIG_SYS_SDRAM_BASE | BR_PS_32 | BR_MS_UPMA | BR_V;
 
-	msize = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_SDRAM_MAX_SIZE);
+	msize = (long int)get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_SDRAM_MAX_SIZE);
 	memctl->memc_or1  |= ~(msize - 1);
 
 	return msize;
diff --git a/board/esd/cpci5200/cpci5200.c b/board/esd/cpci5200/cpci5200.c
index 8bded0b..9aebcdf 100644
--- a/board/esd/cpci5200/cpci5200.c
+++ b/board/esd/cpci5200/cpci5200.c
@@ -90,9 +90,9 @@  phys_size_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
 
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/esd/mecp5123/mecp5123.c b/board/esd/mecp5123/mecp5123.c
index 9700611..d854470 100644
--- a/board/esd/mecp5123/mecp5123.c
+++ b/board/esd/mecp5123/mecp5123.c
@@ -64,7 +64,7 @@  int board_early_init_f(void)
 
 phys_size_t initdram(int board_type)
 {
-	return get_ram_size(0, fixed_sdram(NULL, NULL, 0));
+	return get_ram_size((unsigned long *)0, (unsigned long)fixed_sdram(NULL, NULL, 0));
 }
 
 int misc_init_r(void)
diff --git a/board/esd/meesc/meesc.c b/board/esd/meesc/meesc.c
index 9bf6739..9696fb3 100644
--- a/board/esd/meesc/meesc.c
+++ b/board/esd/meesc/meesc.c
@@ -125,7 +125,7 @@  static void meesc_ethercat_hw_init(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-		(void *)CONFIG_SYS_SDRAM_BASE,
+		(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/esd/otc570/otc570.c b/board/esd/otc570/otc570.c
index acc1b31..0c9149f 100644
--- a/board/esd/otc570/otc570.c
+++ b/board/esd/otc570/otc570.c
@@ -222,7 +222,7 @@  void lcd_show_board_info(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-		(void *)CONFIG_SYS_SDRAM_BASE,
+		(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/esd/pf5200/pf5200.c b/board/esd/pf5200/pf5200.c
index 7a9ed22..53794f5 100644
--- a/board/esd/pf5200/pf5200.c
+++ b/board/esd/pf5200/pf5200.c
@@ -90,9 +90,9 @@  phys_size_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE, 0x80000000);
 
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/esd/vme8349/vme8349.c b/board/esd/vme8349/vme8349.c
index 01365dc..6712209 100644
--- a/board/esd/vme8349/vme8349.c
+++ b/board/esd/vme8349/vme8349.c
@@ -49,7 +49,7 @@  phys_size_t initdram(int board_type)
 #endif
 
 	/* Now check memory size (after ECC is initialized) */
-	msize = get_ram_size(0, msize);
+	msize = get_ram_size((unsigned long *)0, (unsigned long)msize);
 
 	/* return total bus SDRAM size(bytes)  -- DDR */
 	return msize * 1024 * 1024;
diff --git a/board/esg/ima3-mx53/ima3-mx53.c b/board/esg/ima3-mx53/ima3-mx53.c
index df758ee..e8290b8 100644
--- a/board/esg/ima3-mx53/ima3-mx53.c
+++ b/board/esg/ima3-mx53/ima3-mx53.c
@@ -45,7 +45,7 @@  static void weim_nor_settings(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE,
 			PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/esteem192e/esteem192e.c b/board/esteem192e/esteem192e.c
index b54c614..7680f8f 100644
--- a/board/esteem192e/esteem192e.c
+++ b/board/esteem192e/esteem192e.c
@@ -129,8 +129,8 @@  phys_size_t initdram (int board_type)
 	 * Check Bank 0 Memory Size for re-configuration
 	 *
 	 */
-	size_b0 = get_ram_size ( (long *)SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE);
-	size_b1 = get_ram_size ( (long *)SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE);
+	size_b0 = get_ram_size ( (unsigned long *)SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE);
+	size_b1 = get_ram_size ( (unsigned long *)SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE);
 
 	printf ("\nbank 0 size %lu\nbank 1 size %lu\n", size_b0, size_b1);
 
diff --git a/board/eukrea/cpu9260/cpu9260.c b/board/eukrea/cpu9260/cpu9260.c
index 5e1524e..1506710 100644
--- a/board/eukrea/cpu9260/cpu9260.c
+++ b/board/eukrea/cpu9260/cpu9260.c
@@ -158,7 +158,7 @@  int board_init(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/eukrea/cpuat91/cpuat91.c b/board/eukrea/cpuat91/cpuat91.c
index ec0ce0b..afabdba 100644
--- a/board/eukrea/cpuat91/cpuat91.c
+++ b/board/eukrea/cpuat91/cpuat91.c
@@ -45,7 +45,7 @@  int board_early_init_f(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/fads/fads.c b/board/fads/fads.c
index 3fe318f..a5b792e 100644
--- a/board/fads/fads.c
+++ b/board/fads/fads.c
@@ -255,7 +255,7 @@  static int _draminit (uint base, uint noMbytes, uint edo, uint delay)
 	/* check bytes / 2 because get_ram_size tests at base+bytes, which
 	 * is not mapped */
 	if (noMbytes == 8)
-		if (get_ram_size ((long *) base, noMbytes << 19) != noMbytes << 19) {
+		if (get_ram_size ((unsigned long *) base, noMbytes << 19) != noMbytes << 19) {
 			*((uint *) BCSR1) |= BCSR1_DRAM_EN;	/* disable dram */
 			return -1;
 		}
diff --git a/board/faraday/a320evb/a320evb.c b/board/faraday/a320evb/a320evb.c
index c42635b..cd6fb12 100644
--- a/board/faraday/a320evb/a320evb.c
+++ b/board/faraday/a320evb/a320evb.c
@@ -31,7 +31,7 @@  int dram_init(void)
 	unsigned long expected_size = PHYS_SDRAM_1_SIZE;
 	unsigned long actual_size;
 
-	actual_size = get_ram_size((void *)sdram_base, expected_size);
+	actual_size = get_ram_size((unsigned long *)sdram_base, expected_size);
 
 	gd->ram_size = actual_size;
 
diff --git a/board/freescale/mpc8308rdb/sdram.c b/board/freescale/mpc8308rdb/sdram.c
index 89b665e..4676b8e 100644
--- a/board/freescale/mpc8308rdb/sdram.c
+++ b/board/freescale/mpc8308rdb/sdram.c
@@ -62,7 +62,7 @@  static long fixed_sdram(void)
 	setbits_be32(&im->ddr.sdram_cfg, SDRAM_CFG_MEM_EN);
 	sync();
 
-	return get_ram_size(CONFIG_SYS_DDR_SDRAM_BASE, msize);
+	return (long)get_ram_size(CONFIG_SYS_DDR_SDRAM_BASE, msize);
 }
 
 phys_size_t initdram(int board_type)
diff --git a/board/freescale/mx25pdk/mx25pdk.c b/board/freescale/mx25pdk/mx25pdk.c
index ebe3bcb..cb36231 100644
--- a/board/freescale/mx25pdk/mx25pdk.c
+++ b/board/freescale/mx25pdk/mx25pdk.c
@@ -85,7 +85,7 @@  static void mx25pdk_fec_init(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/freescale/mx31ads/mx31ads.c b/board/freescale/mx31ads/mx31ads.c
index ad89cb0..6c55f3a 100644
--- a/board/freescale/mx31ads/mx31ads.c
+++ b/board/freescale/mx31ads/mx31ads.c
@@ -16,7 +16,7 @@  DECLARE_GLOBAL_DATA_PTR;
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/freescale/mx31pdk/mx31pdk.c b/board/freescale/mx31pdk/mx31pdk.c
index 148b4f4..9efe66a 100644
--- a/board/freescale/mx31pdk/mx31pdk.c
+++ b/board/freescale/mx31pdk/mx31pdk.c
@@ -45,7 +45,7 @@  void board_init_f(ulong bootflag)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/freescale/mx35pdk/mx35pdk.c b/board/freescale/mx35pdk/mx35pdk.c
index 427c83a..99a2794 100644
--- a/board/freescale/mx35pdk/mx35pdk.c
+++ b/board/freescale/mx35pdk/mx35pdk.c
@@ -37,10 +37,10 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	u32 size1, size2;
+	unsigned long size1, size2;
 
-	size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
-	size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+	size1 = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	size2 = get_ram_size((unsigned long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
 
 	gd->ram_size = size1 + size2;
 
diff --git a/board/freescale/mx51evk/mx51evk.c b/board/freescale/mx51evk/mx51evk.c
index d01465e..8ca5289 100644
--- a/board/freescale/mx51evk/mx51evk.c
+++ b/board/freescale/mx51evk/mx51evk.c
@@ -34,7 +34,7 @@  struct fsl_esdhc_cfg esdhc_cfg[2] = {
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/freescale/mx53ard/mx53ard.c b/board/freescale/mx53ard/mx53ard.c
index c960c44..940fbb7 100644
--- a/board/freescale/mx53ard/mx53ard.c
+++ b/board/freescale/mx53ard/mx53ard.c
@@ -23,10 +23,10 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	u32 size1, size2;
+	unsigned long size1, size2;
 
-	size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
-	size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+	size1 = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	size2 = get_ram_size((unsigned long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
 
 	gd->ram_size = size1 + size2;
 
diff --git a/board/freescale/mx53evk/mx53evk.c b/board/freescale/mx53evk/mx53evk.c
index 3b398b6..82a6cdf 100644
--- a/board/freescale/mx53evk/mx53evk.c
+++ b/board/freescale/mx53evk/mx53evk.c
@@ -27,7 +27,7 @@  DECLARE_GLOBAL_DATA_PTR;
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c
index ae7eca8..8d2a6fb 100644
--- a/board/freescale/mx53loco/mx53loco.c
+++ b/board/freescale/mx53loco/mx53loco.c
@@ -32,10 +32,10 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	u32 size1, size2;
+	unsigned long size1, size2;
 
-	size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
-	size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+	size1 = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	size2 = get_ram_size((unsigned long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
 
 	gd->ram_size = size1 + size2;
 
diff --git a/board/freescale/mx53smd/mx53smd.c b/board/freescale/mx53smd/mx53smd.c
index d64c674..d45bbf6 100644
--- a/board/freescale/mx53smd/mx53smd.c
+++ b/board/freescale/mx53smd/mx53smd.c
@@ -21,10 +21,10 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	u32 size1, size2;
+	unsigned long size1, size2;
 
-	size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
-	size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+	size1 = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	size2 = get_ram_size((unsigned long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
 
 	gd->ram_size = size1 + size2;
 
diff --git a/board/freescale/mx6qarm2/mx6qarm2.c b/board/freescale/mx6qarm2/mx6qarm2.c
index 05c938f..20ed0a7 100644
--- a/board/freescale/mx6qarm2/mx6qarm2.c
+++ b/board/freescale/mx6qarm2/mx6qarm2.c
@@ -32,7 +32,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
 
 	return 0;
 }
diff --git a/board/freescale/mx6qsabreauto/mx6qsabreauto.c b/board/freescale/mx6qsabreauto/mx6qsabreauto.c
index 1cdf2cb..77c2517 100644
--- a/board/freescale/mx6qsabreauto/mx6qsabreauto.c
+++ b/board/freescale/mx6qsabreauto/mx6qsabreauto.c
@@ -45,7 +45,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
 
 	return 0;
 }
diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
index 5db516d..a21a9e7 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -39,7 +39,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
 
 	return 0;
 }
diff --git a/board/freescale/mx6slevk/mx6slevk.c b/board/freescale/mx6slevk/mx6slevk.c
index 5b6ef81..9eb62fd 100644
--- a/board/freescale/mx6slevk/mx6slevk.c
+++ b/board/freescale/mx6slevk/mx6slevk.c
@@ -31,7 +31,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
 
 	return 0;
 }
diff --git a/board/freescale/titanium/titanium.c b/board/freescale/titanium/titanium.c
index 6025eb7..8709c3b 100644
--- a/board/freescale/titanium/titanium.c
+++ b/board/freescale/titanium/titanium.c
@@ -39,7 +39,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
 
 	return 0;
 }
diff --git a/board/freescale/vf610twr/vf610twr.c b/board/freescale/vf610twr/vf610twr.c
index 699ea7f..fbc88c9 100644
--- a/board/freescale/vf610twr/vf610twr.c
+++ b/board/freescale/vf610twr/vf610twr.c
@@ -235,7 +235,7 @@  int dram_init(void)
 	setup_iomux_ddr();
 
 	ddr_ctrl_init();
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
 
 	return 0;
 }
diff --git a/board/friendlyarm/mini2440/mini2440.c b/board/friendlyarm/mini2440/mini2440.c
index 59ed054..d1ceb33 100644
--- a/board/friendlyarm/mini2440/mini2440.c
+++ b/board/friendlyarm/mini2440/mini2440.c
@@ -103,7 +103,7 @@  int dram_init(void)
 	writel(B6_MRSR, &memctl->mrsrb6);
 	writel(B7_MRSR, &memctl->mrsrb7);
 
-	gd->ram_size = get_ram_size((void *) CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE,
 			PHYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/galaxy5200/galaxy5200.c b/board/galaxy5200/galaxy5200.c
index 29e40eb..9b07531 100644
--- a/board/galaxy5200/galaxy5200.c
+++ b/board/galaxy5200/galaxy5200.c
@@ -96,9 +96,9 @@  phys_size_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
+	test1 = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
+	test2 = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/genesi/mx51_efikamx/efikamx.c b/board/genesi/mx51_efikamx/efikamx.c
index 76753f9..7cc3dba 100644
--- a/board/genesi/mx51_efikamx/efikamx.c
+++ b/board/genesi/mx51_efikamx/efikamx.c
@@ -117,7 +117,7 @@  u32 get_board_rev(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 						PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/genietv/genietv.c b/board/genietv/genietv.c
index 0a015ea..0743515 100644
--- a/board/genietv/genietv.c
+++ b/board/genietv/genietv.c
@@ -252,11 +252,11 @@  phys_size_t initdram (int board_type)
 static long int dram_size (long int mbmr_value, long int *base,
 			   long int maxsize)
 {
-	long size;
+	unsigned long size;
 
 	/*memctl->memc_mbmr = mbmr_value; */
 
-	size = get_ram_size (base, maxsize);
+	size = get_ram_size ((unsigned long *)base, (unsigned long *)maxsize);
 
 	if (size) {
 /*      printf("(%08lx)", size); */
@@ -264,7 +264,7 @@  static long int dram_size (long int mbmr_value, long int *base,
 		printf ("(0)");
 	}
 
-	return (size);
+	return (long int)(size);
 }
 
 #if defined(CONFIG_CMD_PCMCIA)
diff --git a/board/hale/tt01/tt01.c b/board/hale/tt01/tt01.c
index 011aed0..dbf8888 100644
--- a/board/hale/tt01/tt01.c
+++ b/board/hale/tt01/tt01.c
@@ -122,7 +122,7 @@  static void tt01_spi3_hw_init(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE,
 			PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/hermes/hermes.c b/board/hermes/hermes.c
index 6126b73..ce92b67 100644
--- a/board/hermes/hermes.c
+++ b/board/hermes/hermes.c
@@ -210,7 +210,8 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long *)base,
+				(unsigned long)maxsize));
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/board/hidden_dragon/hidden_dragon.c b/board/hidden_dragon/hidden_dragon.c
index 8d47f37..4dda9dd 100644
--- a/board/hidden_dragon/hidden_dragon.c
+++ b/board/hidden_dragon/hidden_dragon.c
@@ -31,10 +31,10 @@  int checkboard (void)
 
 phys_size_t initdram (int board_type)
 {
-	long size;
-	long new_bank0_end;
-	long mear1;
-	long emear1;
+	unsigned long size;
+	unsigned long new_bank0_end;
+	unsigned long mear1;
+	unsigned long emear1;
 
 	size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 
diff --git a/board/icecube/icecube.c b/board/icecube/icecube.c
index a99416b..4966842 100644
--- a/board/icecube/icecube.c
+++ b/board/icecube/icecube.c
@@ -145,9 +145,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -173,10 +173,10 @@  phys_size_t initdram (int board_type)
 	/* find RAM size using SDRAM CS1 only */
 	if (!dramsize)
 		sdram_start(0);
-	test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+	test2 = test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	if (!dramsize) {
 		sdram_start(1);
-		test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+		test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	}
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/icpdas/lp8x4x/lp8x4x.c b/board/icpdas/lp8x4x/lp8x4x.c
index 1b68ef3..eb76c01 100644
--- a/board/icpdas/lp8x4x/lp8x4x.c
+++ b/board/icpdas/lp8x4x/lp8x4x.c
@@ -39,7 +39,7 @@  int board_init(void)
 int dram_init(void)
 {
 	pxa2xx_dram_init();
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
 	return 0;
 }
 
diff --git a/board/icu862/icu862.c b/board/icu862/icu862.c
index 4c0e919..79e7f3a 100644
--- a/board/icu862/icu862.c
+++ b/board/icu862/icu862.c
@@ -195,5 +195,5 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long *)base, (unsigned long)maxsize));
 }
diff --git a/board/ids8247/ids8247.c b/board/ids8247/ids8247.c
index de6b8fb..9cd7ce5 100644
--- a/board/ids8247/ids8247.c
+++ b/board/ids8247/ids8247.c
@@ -254,10 +254,10 @@  static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
 	*sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
 	*base = c;
 
-	size = get_ram_size((long *)base, maxsize);
+	size = get_ram_size((unsigned long *)base, maxsize);
 	*orx_ptr = orx | ~(size - 1);
 
-	return (size);
+	return (long int)(size);
 }
 
 phys_size_t initdram (int board_type)
diff --git a/board/ifm/o2dnt2/o2dnt2.c b/board/ifm/o2dnt2/o2dnt2.c
index 6716ffc..5a92de9 100644
--- a/board/ifm/o2dnt2/o2dnt2.c
+++ b/board/ifm/o2dnt2/o2dnt2.c
@@ -93,9 +93,9 @@  phys_size_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -122,11 +122,11 @@  phys_size_t initdram(int board_type)
 	if (!dramsize)
 		sdram_start(0);
 
-	test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
+	test2 = test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
 					0x80000000);
 	if (!dramsize) {
 		sdram_start(1);
-		test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
+		test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
 					0x80000000);
 	}
 
diff --git a/board/imx31_phycore/imx31_phycore.c b/board/imx31_phycore/imx31_phycore.c
index 3f45e4e..4d400a1 100644
--- a/board/imx31_phycore/imx31_phycore.c
+++ b/board/imx31_phycore/imx31_phycore.c
@@ -18,7 +18,7 @@  DECLARE_GLOBAL_DATA_PTR;
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/in-circuit/grasshopper/grasshopper.c b/board/in-circuit/grasshopper/grasshopper.c
index 340b713..4124f1e 100644
--- a/board/in-circuit/grasshopper/grasshopper.c
+++ b/board/in-circuit/grasshopper/grasshopper.c
@@ -73,7 +73,7 @@  phys_size_t initdram(int board_type)
 {
 	unsigned long expected_size;
 	unsigned long actual_size;
-	void *sdram_base;
+	unsigned long *sdram_base;
 
 	sdram_base = uncached(EBI_SDRAM_BASE);
 
diff --git a/board/incaip/incaip.c b/board/incaip/incaip.c
index 911fb63..72afd4b 100644
--- a/board/incaip/incaip.c
+++ b/board/incaip/incaip.c
@@ -59,7 +59,7 @@  phys_size_t initdram(int board_type)
 		{
 			*INCA_IP_SDRAM_MC_CFGPB0 = (0x14 << 8) |
 			                           (rows << 4) | cols;
-			size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+			size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			                                     max_sdram_size());
 
 			if (size > max_size)
diff --git a/board/inka4x0/inka4x0.c b/board/inka4x0/inka4x0.c
index fc3333e..644ff0f 100644
--- a/board/inka4x0/inka4x0.c
+++ b/board/inka4x0/inka4x0.c
@@ -87,7 +87,7 @@  phys_size_t initdram (int board_type)
 		(struct mpc5xxx_sdram *)    MPC5XXX_SDRAM;
 	ulong dramsize = 0;
 #ifndef CONFIG_SYS_RAMBOOT
-	long test1, test2;
+	unsigned long test1, test2;
 
 	/* setup SDRAM chip selects */
 	out_be32(&mm->sdram0, 0x0000001c);	/* 512MB at 0x0 */
@@ -104,9 +104,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/intercontrol/digsy_mtc/digsy_mtc.c b/board/intercontrol/digsy_mtc/digsy_mtc.c
index 5843725..5718b85 100644
--- a/board/intercontrol/digsy_mtc/digsy_mtc.c
+++ b/board/intercontrol/digsy_mtc/digsy_mtc.c
@@ -97,9 +97,9 @@  phys_size_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x08000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -123,7 +123,7 @@  phys_size_t initdram(int board_type)
 	out_be32((void *)MPC5XXX_SDRAM_CS1CFG, dramsize + 0x0000001C);
 
 	/* find RAM size using SDRAM CS1 only */
-	test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
+	test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize),
 			0x08000000);
 		dramsize2 = test1;
 
diff --git a/board/ip860/ip860.c b/board/ip860/ip860.c
index 4e3b1b5..7447916 100644
--- a/board/ip860/ip860.c
+++ b/board/ip860/ip860.c
@@ -240,7 +240,8 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long *)base,
+				(unsigned long)maxsize));
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/board/ipek01/ipek01.c b/board/ipek01/ipek01.c
index d44c4bf..c3cf3d6 100644
--- a/board/ipek01/ipek01.c
+++ b/board/ipek01/ipek01.c
@@ -103,9 +103,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start (0);
-	test1 = get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size ((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start (1);
-	test2 = get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size ((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start (0);
 		dramsize = test1;
diff --git a/board/iphase4539/iphase4539.c b/board/iphase4539/iphase4539.c
index d40d2b6..24a7be6 100644
--- a/board/iphase4539/iphase4539.c
+++ b/board/iphase4539/iphase4539.c
@@ -220,7 +220,7 @@  phys_size_t initdram (int board_type)
 	 */
 	maxsize = (1 + (~memctl->memc_or1 | 0x7fff)) / 2;
 
-	maxsize = get_ram_size((long *)base, maxsize);
+	maxsize = get_ram_size((unsigned long *)base, maxsize);
 
 	memctl->memc_or1 |= ~(maxsize - 1);
 
diff --git a/board/ispan/ispan.c b/board/ispan/ispan.c
index c610c3b..cb274c1 100644
--- a/board/ispan/ispan.c
+++ b/board/ispan/ispan.c
@@ -398,7 +398,7 @@  phys_size_t initdram (int board_type)
 	 */
 	maxsize = (~(memctl->memc_or1 & BRx_BA_MSK) + 1) / 2;
 
-	maxsize = get_ram_size((long *)(memctl->memc_br1 & BRx_BA_MSK), maxsize);
+	maxsize = (long)get_ram_size((unsigned long *)(memctl->memc_br1 & BRx_BA_MSK), maxsize);
 
 	memctl->memc_or1 |= ~(maxsize - 1);
 
diff --git a/board/ivm/ivm.c b/board/ivm/ivm.c
index 3bdbdd1..3529818 100644
--- a/board/ivm/ivm.c
+++ b/board/ivm/ivm.c
@@ -261,7 +261,8 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mbmr = mamr_value;
 
-	return (get_ram_size (base, maxsize));
+	return (long int)(get_ram_size ((unsigned long)base,
+				(unsigned long)maxsize));
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/board/jupiter/jupiter.c b/board/jupiter/jupiter.c
index 78e4b5d..2c0b4e3 100644
--- a/board/jupiter/jupiter.c
+++ b/board/jupiter/jupiter.c
@@ -103,9 +103,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -131,10 +131,10 @@  phys_size_t initdram (int board_type)
 	/* find RAM size using SDRAM CS1 only */
 	if (!dramsize)
 		sdram_start(0);
-	test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+	test2 = test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	if (!dramsize) {
 		sdram_start(1);
-		test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+		test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	}
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/karo/tx25/tx25.c b/board/karo/tx25/tx25.c
index 4d1a0ec..9abb801 100644
--- a/board/karo/tx25/tx25.c
+++ b/board/karo/tx25/tx25.c
@@ -184,7 +184,7 @@  int board_late_init(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
@@ -192,11 +192,11 @@  int dram_init(void)
 void dram_init_banksize(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = get_ram_size((void *)PHYS_SDRAM_1,
+	gd->bd->bi_dram[0].size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 			PHYS_SDRAM_1_SIZE);
 #if CONFIG_NR_DRAM_BANKS > 1
 	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
-	gd->bd->bi_dram[1].size = get_ram_size((void *)PHYS_SDRAM_2,
+	gd->bd->bi_dram[1].size = get_ram_size((unsigned long *)PHYS_SDRAM_2,
 			PHYS_SDRAM_2_SIZE);
 #else
 
diff --git a/board/keymile/km82xx/km82xx.c b/board/keymile/km82xx/km82xx.c
index dfbfab8..b69958e 100644
--- a/board/keymile/km82xx/km82xx.c
+++ b/board/keymile/km82xx/km82xx.c
@@ -236,7 +236,7 @@  static long int try_init(memctl8260_t *memctl, ulong sdmr,
 	out_be32(&memctl->memc_psdmr, sdmr | PSDMR_OP_NORM | PSDMR_RFEN);
 	out_8(base, c);
 
-	size = get_ram_size((long *)base, maxsize);
+	size = get_ram_size((unsigned long *)base, maxsize);
 	out_be32(&memctl->memc_or1, orx | ~(size - 1));
 
 	return size;
diff --git a/board/logicpd/imx27lite/imx27lite.c b/board/logicpd/imx27lite/imx27lite.c
index 07b07a0..0d4eae3 100644
--- a/board/logicpd/imx27lite/imx27lite.c
+++ b/board/logicpd/imx27lite/imx27lite.c
@@ -52,7 +52,7 @@  int board_init(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
@@ -60,11 +60,11 @@  int dram_init(void)
 void dram_init_banksize(void)
 {
 	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
-	gd->bd->bi_dram[0].size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->bd->bi_dram[0].size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			PHYS_SDRAM_1_SIZE);
 #if CONFIG_NR_DRAM_BANKS > 1
 	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
-	gd->bd->bi_dram[1].size = get_ram_size((void *)PHYS_SDRAM_2,
+	gd->bd->bi_dram[1].size = get_ram_size((unsigned long *)PHYS_SDRAM_2,
 			PHYS_SDRAM_2_SIZE);
 #endif
 }
diff --git a/board/logicpd/imx31_litekit/imx31_litekit.c b/board/logicpd/imx31_litekit/imx31_litekit.c
index 386e106..e5ed1e0 100644
--- a/board/logicpd/imx31_litekit/imx31_litekit.c
+++ b/board/logicpd/imx31_litekit/imx31_litekit.c
@@ -17,7 +17,7 @@  DECLARE_GLOBAL_DATA_PTR;
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/lwmon/lwmon.c b/board/lwmon/lwmon.c
index 225b1ef..5166d66 100644
--- a/board/lwmon/lwmon.c
+++ b/board/lwmon/lwmon.c
@@ -315,7 +315,7 @@  static long int dram_size (long int mamr_value, long int *base, long int maxsize
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long *)base, (unsigned long)maxsize));
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/board/manroland/hmi1001/hmi1001.c b/board/manroland/hmi1001/hmi1001.c
index 781f10b..da6c04b 100644
--- a/board/manroland/hmi1001/hmi1001.c
+++ b/board/manroland/hmi1001/hmi1001.c
@@ -89,9 +89,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/manroland/mucmc52/mucmc52.c b/board/manroland/mucmc52/mucmc52.c
index 63dc2ad..17166cf 100644
--- a/board/manroland/mucmc52/mucmc52.c
+++ b/board/manroland/mucmc52/mucmc52.c
@@ -102,9 +102,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start (0);
-	test1 = get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test1 = get_ram_size ((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	sdram_start(1);
-	test2 = get_ram_size ((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test2 = get_ram_size ((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	if (test1 > test2) {
 		sdram_start (0);
 		dramsize = test1;
@@ -131,10 +131,10 @@  phys_size_t initdram (int board_type)
 	/* find RAM size using SDRAM CS1 only */
 	if (!dramsize)
 		sdram_start (0);
-	test2 = test1 = get_ram_size ((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
+	test2 = test1 = get_ram_size ((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
 	if (!dramsize) {
 		sdram_start (1);
-		test2 = get_ram_size ((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
+		test2 = get_ram_size ((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
 	}
 	if (test1 > test2) {
 		sdram_start (0);
diff --git a/board/manroland/uc101/uc101.c b/board/manroland/uc101/uc101.c
index 6e1246e..b07d009 100644
--- a/board/manroland/uc101/uc101.c
+++ b/board/manroland/uc101/uc101.c
@@ -155,9 +155,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/matrix_vision/mvbc_p/mvbc_p.c b/board/matrix_vision/mvbc_p/mvbc_p.c
index 8faebee..085b33f 100644
--- a/board/matrix_vision/mvbc_p/mvbc_p.c
+++ b/board/matrix_vision/mvbc_p/mvbc_p.c
@@ -70,9 +70,9 @@  phys_addr_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/matrix_vision/mvsmr/mvsmr.c b/board/matrix_vision/mvsmr/mvsmr.c
index 2c51389..cb3bca3 100644
--- a/board/matrix_vision/mvsmr/mvsmr.c
+++ b/board/matrix_vision/mvsmr/mvsmr.c
@@ -81,9 +81,9 @@  phys_addr_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/mcc200/mcc200.c b/board/mcc200/mcc200.c
index 706886b..5f39f93 100644
--- a/board/mcc200/mcc200.c
+++ b/board/mcc200/mcc200.c
@@ -106,9 +106,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -134,10 +134,10 @@  phys_size_t initdram (int board_type)
 	/* find RAM size using SDRAM CS1 only */
 	if (!dramsize)
 		sdram_start(0);
-	test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+	test2 = test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	if (!dramsize) {
 		sdram_start(1);
-		test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+		test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	}
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/micronas/vct/vct.c b/board/micronas/vct/vct.c
index 0745cee..ad7d2d2 100644
--- a/board/micronas/vct/vct.c
+++ b/board/micronas/vct/vct.c
@@ -61,7 +61,7 @@  void _machine_restart(void)
  */
 phys_size_t initdram(int board_type)
 {
-	return get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
+	return get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 			    CONFIG_SYS_MBYTES_SDRAM << 20);
 }
 
diff --git a/board/mimc/mimc200/mimc200.c b/board/mimc/mimc200/mimc200.c
index 2ad53ec..e061c00 100644
--- a/board/mimc/mimc200/mimc200.c
+++ b/board/mimc/mimc200/mimc200.c
@@ -155,7 +155,7 @@  phys_size_t initdram(int board_type)
 {
 	unsigned long expected_size;
 	unsigned long actual_size;
-	void *sdram_base;
+	unsigned long *sdram_base;
 
 	sdram_base = uncached(EBI_SDRAM_BASE);
 
diff --git a/board/miromico/hammerhead/hammerhead.c b/board/miromico/hammerhead/hammerhead.c
index d82fee7..6539705 100644
--- a/board/miromico/hammerhead/hammerhead.c
+++ b/board/miromico/hammerhead/hammerhead.c
@@ -78,7 +78,7 @@  phys_size_t initdram(int board_type)
 {
 	unsigned long expected_size;
 	unsigned long actual_size;
-	void *sdram_base;
+	unsigned long *sdram_base;
 
 	sdram_base = uncached(EBI_SDRAM_BASE);
 
diff --git a/board/motionpro/motionpro.c b/board/motionpro/motionpro.c
index a6235e5..3781136 100644
--- a/board/motionpro/motionpro.c
+++ b/board/motionpro/motionpro.c
@@ -137,9 +137,9 @@  phys_size_t initdram(int board_type)
 	*(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
 
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/muas3001/muas3001.c b/board/muas3001/muas3001.c
index 42b0a03..94f0c29 100644
--- a/board/muas3001/muas3001.c
+++ b/board/muas3001/muas3001.c
@@ -232,7 +232,7 @@  static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
 	*sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
 	*base = c;
 
-	size = get_ram_size ((long *)base, maxsize);
+	size = get_ram_size ((unsigned long *)base, maxsize);
 	*orx_ptr = orx | ~(size - 1);
 
 	return (size);
diff --git a/board/munices/munices.c b/board/munices/munices.c
index 319fa8c..7a2c0b3 100644
--- a/board/munices/munices.c
+++ b/board/munices/munices.c
@@ -83,9 +83,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = (ulong )get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x10000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x10000000);
 	sdram_start(1);
-	test2 = (ulong )get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x10000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x10000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/musenki/musenki.c b/board/musenki/musenki.c
index aa92fc4..fe5c497 100644
--- a/board/musenki/musenki.c
+++ b/board/musenki/musenki.c
@@ -32,10 +32,10 @@  int checkflash (void)
 
 phys_size_t initdram (int board_type)
 {
-	long size;
-	long new_bank0_end;
-	long mear1;
-	long emear1;
+	unsigned long size;
+	unsigned long new_bank0_end;
+	unsigned long mear1;
+	unsigned long emear1;
 
 	size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 
diff --git a/board/mvblue/mvblue.c b/board/mvblue/mvblue.c
index 69abb06..723fed9 100644
--- a/board/mvblue/mvblue.c
+++ b/board/mvblue/mvblue.c
@@ -79,10 +79,10 @@  int checkboard (void)
 
 phys_size_t initdram (int board_type)
 {
-	long size;
-	long new_bank0_end;
-	long mear1;
-	long emear1;
+	unsigned long size;
+	unsigned long new_bank0_end;
+	unsigned long mear1;
+	unsigned long emear1;
 
 	size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 
diff --git a/board/mx1ads/mx1ads.c b/board/mx1ads/mx1ads.c
index 4266048..dee209e 100644
--- a/board/mx1ads/mx1ads.c
+++ b/board/mx1ads/mx1ads.c
@@ -155,7 +155,7 @@  int board_late_init (void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 				PHYS_SDRAM_1_SIZE);
 	return 0;
 }
diff --git a/board/netphone/netphone.c b/board/netphone/netphone.c
index 053bdf1..2b7c6d3 100644
--- a/board/netphone/netphone.c
+++ b/board/netphone/netphone.c
@@ -447,7 +447,7 @@  phys_size_t initdram(int board_type)
 		}
 	}
 
-	size = get_ram_size((long *)0, SDRAM_MAX_SIZE);
+	size = (long int)get_ram_size((unsigned long *)0, SDRAM_MAX_SIZE);
 
 	if (size == 0) {
 		printf("SIZE is zero: LOOP on 0\n");
diff --git a/board/netta/netta.c b/board/netta/netta.c
index bfd51e7..ce00369 100644
--- a/board/netta/netta.c
+++ b/board/netta/netta.c
@@ -380,7 +380,7 @@  phys_size_t initdram(int board_type)
 		}
 	}
 
-	size = get_ram_size((long *)0, SDRAM_MAX_SIZE);
+	size = (long int)get_ram_size((unsigned long *)0, SDRAM_MAX_SIZE);
 
 #if 0
 	printf("check 0\n");
diff --git a/board/netta2/netta2.c b/board/netta2/netta2.c
index 362a3c7..962dd0b 100644
--- a/board/netta2/netta2.c
+++ b/board/netta2/netta2.c
@@ -445,7 +445,7 @@  phys_size_t initdram(int board_type)
 		}
 	}
 
-	size = get_ram_size((long *)0, SDRAM_MAX_SIZE);
+	size = (long int)get_ram_size((unsigned long *)0, SDRAM_MAX_SIZE);
 
 	if (size == 0) {
 		printf("SIZE is zero: LOOP on 0\n");
diff --git a/board/nx823/nx823.c b/board/nx823/nx823.c
index d49fa8c..b3fba69 100644
--- a/board/nx823/nx823.c
+++ b/board/nx823/nx823.c
@@ -342,7 +342,8 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size (base, maxsize));
+	return (long int)(get_ram_size ((unsigned long *)base,
+				(unsigned long)maxsize));
 }
 
 int misc_init_r (void)
diff --git a/board/phytec/pcm030/pcm030.c b/board/phytec/pcm030/pcm030.c
index ce515d8..6cb6060 100644
--- a/board/phytec/pcm030/pcm030.c
+++ b/board/phytec/pcm030/pcm030.c
@@ -103,9 +103,9 @@  phys_size_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
+	test1 = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
+	test2 = get_ram_size((unsigned long *) CONFIG_SYS_SDRAM_BASE, 0x10000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
diff --git a/board/pm520/pm520.c b/board/pm520/pm520.c
index 4ec4505..e3f85d2 100644
--- a/board/pm520/pm520.c
+++ b/board/pm520/pm520.c
@@ -93,9 +93,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -121,10 +121,10 @@  phys_size_t initdram (int board_type)
 	/* find RAM size using SDRAM CS1 only */
 	if (!dramsize)
 		sdram_start(0);
-	test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+	test2 = test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	if (!dramsize) {
 		sdram_start(1);
-		test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+		test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	}
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/pm826/pm826.c b/board/pm826/pm826.c
index 93bb1b4..af55892 100644
--- a/board/pm826/pm826.c
+++ b/board/pm826/pm826.c
@@ -256,7 +256,7 @@  static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
 	*sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
 	*base = c;
 
-	size = get_ram_size((long *)base, maxsize);
+	size = get_ram_size((unsigned long *)base, maxsize);
 
 	*orx_ptr = orx | ~(size - 1);
 
diff --git a/board/pn62/pn62.c b/board/pn62/pn62.c
index 81829dd..a40617a 100644
--- a/board/pn62/pn62.c
+++ b/board/pn62/pn62.c
@@ -63,10 +63,10 @@  int checkboard (void)
 
 phys_size_t initdram (int board_type)
 {
-	long size;
-	long new_bank0_end;
-	long mear1;
-	long emear1;
+	unsigned long size;
+	unsigned long new_bank0_end;
+	unsigned long mear1;
+	unsigned long emear1;
 
 	show_startup_phase (2);
 
diff --git a/board/r360mpi/r360mpi.c b/board/r360mpi/r360mpi.c
index d06aea7..56ce26e 100644
--- a/board/r360mpi/r360mpi.c
+++ b/board/r360mpi/r360mpi.c
@@ -245,7 +245,7 @@  static long int dram_size (long int mamr_value,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long *)base, (unsigned long)maxsize));
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/board/rbc823/rbc823.c b/board/rbc823/rbc823.c
index f276e5e..7f1c03b 100644
--- a/board/rbc823/rbc823.c
+++ b/board/rbc823/rbc823.c
@@ -238,7 +238,8 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size (base, maxsize));
+	return (long int)(get_ram_size ((unsigned long *)base,
+				(unsigned long)maxsize));
 }
 
 #ifdef CONFIG_CMD_DOC
diff --git a/board/ronetix/pm9261/pm9261.c b/board/ronetix/pm9261/pm9261.c
index a2a569b..a42cbe6 100644
--- a/board/ronetix/pm9261/pm9261.c
+++ b/board/ronetix/pm9261/pm9261.c
@@ -268,7 +268,7 @@  int board_eth_init(bd_t *bis)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM,
 				PHYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/ronetix/pm9263/pm9263.c b/board/ronetix/pm9263/pm9263.c
index 48eba99..6998197 100644
--- a/board/ronetix/pm9263/pm9263.c
+++ b/board/ronetix/pm9263/pm9263.c
@@ -363,7 +363,7 @@  int board_init(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM,
 				PHYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/ronetix/pm9g45/pm9g45.c b/board/ronetix/pm9g45/pm9g45.c
index 5bb5a3c..da2078d 100644
--- a/board/ronetix/pm9g45/pm9g45.c
+++ b/board/ronetix/pm9g45/pm9g45.c
@@ -146,7 +146,7 @@  int board_init(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM,
 				PHYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/samsung/arndale/arndale.c b/board/samsung/arndale/arndale.c
index 052fecd..9c1ffc5 100644
--- a/board/samsung/arndale/arndale.c
+++ b/board/samsung/arndale/arndale.c
@@ -24,7 +24,7 @@  int dram_init(void)
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
-		gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
+		gd->ram_size += get_ram_size((unsigned long *)addr, SDRAM_BANK_SIZE);
 	}
 	return 0;
 }
@@ -42,7 +42,7 @@  void dram_init_banksize(void)
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
-		size = get_ram_size((long *)addr, SDRAM_BANK_SIZE);
+		size = get_ram_size((unsigned long *)addr, SDRAM_BANK_SIZE);
 
 		gd->bd->bi_dram[i].start = addr;
 		gd->bd->bi_dram[i].size = size;
diff --git a/board/samsung/origen/origen.c b/board/samsung/origen/origen.c
index 15f77ca..79e2844 100644
--- a/board/samsung/origen/origen.c
+++ b/board/samsung/origen/origen.c
@@ -71,10 +71,14 @@  int board_early_init_f(void)
 
 int dram_init(void)
 {
-	gd->ram_size	= get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
-			+ get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
-			+ get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
-			+ get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
+	gd->ram_size	= get_ram_size((unsigned long *)PHYS_SDRAM_1,
+							PHYS_SDRAM_1_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_2,
+							PHYS_SDRAM_2_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_3,
+							PHYS_SDRAM_3_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_4,
+							PHYS_SDRAM_4_SIZE);
 
 	return 0;
 }
@@ -82,16 +86,16 @@  int dram_init(void)
 void dram_init_banksize(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \
+	gd->bd->bi_dram[0].size = get_ram_size((unsigned long *)PHYS_SDRAM_1, \
 							PHYS_SDRAM_1_SIZE);
 	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
-	gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \
+	gd->bd->bi_dram[1].size = get_ram_size((unsigned long *)PHYS_SDRAM_2, \
 							PHYS_SDRAM_2_SIZE);
 	gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
-	gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \
+	gd->bd->bi_dram[2].size = get_ram_size((unsigned long *)PHYS_SDRAM_3, \
 							PHYS_SDRAM_3_SIZE);
 	gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
-	gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \
+	gd->bd->bi_dram[3].size = get_ram_size((unsigned long *)PHYS_SDRAM_4, \
 							PHYS_SDRAM_4_SIZE);
 }
 
diff --git a/board/samsung/smdk5250/exynos5-dt.c b/board/samsung/smdk5250/exynos5-dt.c
index bb4a82f..d9e3b0f 100644
--- a/board/samsung/smdk5250/exynos5-dt.c
+++ b/board/samsung/smdk5250/exynos5-dt.c
@@ -134,11 +134,11 @@  int board_init(void)
 int dram_init(void)
 {
 	int i;
-	u32 addr;
+	unsigned long addr;
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
-		gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
+		gd->ram_size += get_ram_size((unsigned long *)addr, SDRAM_BANK_SIZE);
 	}
 	return 0;
 }
@@ -263,11 +263,11 @@  int power_init_board(void)
 void dram_init_banksize(void)
 {
 	int i;
-	u32 addr, size;
+	unsigned long addr, size;
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
-		size = get_ram_size((long *)addr, SDRAM_BANK_SIZE);
+		size = get_ram_size((unsigned long *)addr, SDRAM_BANK_SIZE);
 
 		gd->bd->bi_dram[i].start = addr;
 		gd->bd->bi_dram[i].size = size;
diff --git a/board/samsung/smdk5250/smdk5250.c b/board/samsung/smdk5250/smdk5250.c
index 97fe0ad..f2ea92f 100644
--- a/board/samsung/smdk5250/smdk5250.c
+++ b/board/samsung/smdk5250/smdk5250.c
@@ -72,11 +72,11 @@  int board_init(void)
 int dram_init(void)
 {
 	int i;
-	u32 addr;
+	unsigned long addr;
 
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
-		gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
+		gd->ram_size += get_ram_size((unsigned long *)addr, SDRAM_BANK_SIZE);
 	}
 	return 0;
 }
@@ -201,10 +201,10 @@  int power_init_board(void)
 void dram_init_banksize(void)
 {
 	int i;
-	u32 addr, size;
+	unsigned long addr, size;
 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
 		addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
-		size = get_ram_size((long *)addr, SDRAM_BANK_SIZE);
+		size = get_ram_size((unsigned long *)addr, SDRAM_BANK_SIZE);
 		gd->bd->bi_dram[i].start = addr;
 		gd->bd->bi_dram[i].size = size;
 	}
diff --git a/board/samsung/smdkc100/smdkc100.c b/board/samsung/smdkc100/smdkc100.c
index 860c851..20cea8d 100644
--- a/board/samsung/smdkc100/smdkc100.c
+++ b/board/samsung/smdkc100/smdkc100.c
@@ -49,7 +49,7 @@  int board_init(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
 
 	return 0;
 }
diff --git a/board/samsung/smdkv310/smdkv310.c b/board/samsung/smdkv310/smdkv310.c
index 81a3060..919da46 100644
--- a/board/samsung/smdkv310/smdkv310.c
+++ b/board/samsung/smdkv310/smdkv310.c
@@ -49,10 +49,14 @@  int board_init(void)
 
 int dram_init(void)
 {
-	gd->ram_size	= get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE)
-			+ get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE)
-			+ get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE)
-			+ get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
+	gd->ram_size	= get_ram_size((unsigned long *)PHYS_SDRAM_1,
+							PHYS_SDRAM_1_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_2,
+							PHYS_SDRAM_2_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_3,
+							PHYS_SDRAM_3_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_4,
+							PHYS_SDRAM_4_SIZE);
 
 	return 0;
 }
@@ -60,16 +64,16 @@  int dram_init(void)
 void dram_init_banksize(void)
 {
 	gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
-	gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, \
+	gd->bd->bi_dram[0].size = get_ram_size((unsigned long *)PHYS_SDRAM_1, \
 							PHYS_SDRAM_1_SIZE);
 	gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
-	gd->bd->bi_dram[1].size = get_ram_size((long *)PHYS_SDRAM_2, \
+	gd->bd->bi_dram[1].size = get_ram_size((unsigned long *)PHYS_SDRAM_2, \
 							PHYS_SDRAM_2_SIZE);
 	gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
-	gd->bd->bi_dram[2].size = get_ram_size((long *)PHYS_SDRAM_3, \
+	gd->bd->bi_dram[2].size = get_ram_size((unsigned long *)PHYS_SDRAM_3, \
 							PHYS_SDRAM_3_SIZE);
 	gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
-	gd->bd->bi_dram[3].size = get_ram_size((long *)PHYS_SDRAM_4, \
+	gd->bd->bi_dram[3].size = get_ram_size((unsigned long *)PHYS_SDRAM_4, \
 							PHYS_SDRAM_4_SIZE);
 }
 
diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
index 7f61d17..84262d7 100644
--- a/board/samsung/trats/trats.c
+++ b/board/samsung/trats/trats.c
@@ -347,10 +347,14 @@  int power_init_board(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) +
-		get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE) +
-		get_ram_size((long *)PHYS_SDRAM_3, PHYS_SDRAM_3_SIZE) +
-		get_ram_size((long *)PHYS_SDRAM_4, PHYS_SDRAM_4_SIZE);
+	gd->ram_size 	= get_ram_size((unsigned long *)PHYS_SDRAM_1,
+							PHYS_SDRAM_1_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_2,
+							PHYS_SDRAM_2_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_3,
+							PHYS_SDRAM_3_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_4,
+							PHYS_SDRAM_4_SIZE);
 
 	return 0;
 }
diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
index 54d0e1e..98d8fb0 100644
--- a/board/samsung/universal_c210/universal.c
+++ b/board/samsung/universal_c210/universal.c
@@ -60,8 +60,10 @@  int power_init_board(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE) +
-		get_ram_size((long *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE);
+	gd->ram_size 	= get_ram_size((unsigned long *)PHYS_SDRAM_1,
+							PHYS_SDRAM_1_SIZE)
+			+ get_ram_size((unsigned long *)PHYS_SDRAM_2,
+							PHYS_SDRAM_2_SIZE);
 
 	return 0;
 }
diff --git a/board/sandpoint/sandpoint.c b/board/sandpoint/sandpoint.c
index 16237bd..ff6fa1d 100644
--- a/board/sandpoint/sandpoint.c
+++ b/board/sandpoint/sandpoint.c
@@ -37,10 +37,10 @@  int checkflash (void)
 
 phys_size_t initdram (int board_type)
 {
-	long size;
-	long new_bank0_end;
-	long mear1;
-	long emear1;
+	unsigned long size;
+	unsigned long new_bank0_end;
+	unsigned long mear1;
+	unsigned long emear1;
 
 	size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 
diff --git a/board/scb9328/scb9328.c b/board/scb9328/scb9328.c
index 3463f52..d067a8d 100644
--- a/board/scb9328/scb9328.c
+++ b/board/scb9328/scb9328.c
@@ -20,7 +20,7 @@  int board_init (void)
 int dram_init (void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)SCB9328_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)SCB9328_SDRAM_1,
 				    SCB9328_SDRAM_1_SIZE);
 
 	return 0;
diff --git a/board/snmc/qs850/qs850.c b/board/snmc/qs850/qs850.c
index dc4a476..c662cac 100644
--- a/board/snmc/qs850/qs850.c
+++ b/board/snmc/qs850/qs850.c
@@ -210,5 +210,5 @@  static long int dram_size (long int mamr_value, long int *base, long int maxsize
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long *)base, (unsigned long)maxsize));
 }
diff --git a/board/snmc/qs860t/qs860t.c b/board/snmc/qs860t/qs860t.c
index 7ff9945..f345d55 100644
--- a/board/snmc/qs860t/qs860t.c
+++ b/board/snmc/qs860t/qs860t.c
@@ -216,5 +216,5 @@  static long int dram_size (long int mbmr_value, long int *base, long int maxsize
 
 	memctl->memc_mbmr = mbmr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long *)base, (unsigned long)maxsize));
 }
diff --git a/board/socrates/sdram.c b/board/socrates/sdram.c
index 313efae..67a0bb8 100644
--- a/board/socrates/sdram.c
+++ b/board/socrates/sdram.c
@@ -49,7 +49,7 @@  phys_size_t fixed_sdram(void)
 	asm ("sync; isync; msync");
 	udelay(1000);
 
-	if (get_ram_size(0, CONFIG_SYS_SDRAM_SIZE<<20) == CONFIG_SYS_SDRAM_SIZE<<20) {
+	if (get_ram_size((unsigned long *)0, CONFIG_SYS_SDRAM_SIZE<<20) == CONFIG_SYS_SDRAM_SIZE<<20) {
 		/*
 		 * OK, size detected -> all done
 		 */
diff --git a/board/spc1920/spc1920.c b/board/spc1920/spc1920.c
index 1775433..1ed1082 100644
--- a/board/spc1920/spc1920.c
+++ b/board/spc1920/spc1920.c
@@ -182,7 +182,7 @@  static long int dram_size (long int mbmr_value, long int *base,
 
 	memctl->memc_mbmr = mbmr_value;
 
-	return (get_ram_size (base, maxsize));
+	return (long int)(get_ram_size ((unsigned long *)base, (unsigned long)maxsize));
 }
 
 
diff --git a/board/spd8xx/spd8xx.c b/board/spd8xx/spd8xx.c
index d3320bb..be791dd 100644
--- a/board/spd8xx/spd8xx.c
+++ b/board/spd8xx/spd8xx.c
@@ -215,7 +215,7 @@  static long int dram_size (long int mamr_value, long int *base,
 
 	memctl->memc_mbmr = mamr_value;
 
-	return (get_ram_size (base, maxsize));
+	return (long int)(get_ram_size ((unsigned long *)base, (unsigned long)maxsize));
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/board/stx/stxxtc/stxxtc.c b/board/stx/stxxtc/stxxtc.c
index 1996efb..ac4d830 100644
--- a/board/stx/stxxtc/stxxtc.c
+++ b/board/stx/stxxtc/stxxtc.c
@@ -387,7 +387,7 @@  phys_size_t initdram(int board_type)
 {
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
 	volatile memctl8xx_t *memctl = &immap->im_memctl;
-	long int size;
+	unsigned long size;
 	u32 d1, d2;
 
 	upmconfig(UPMA, (uint *) sdram_table, sizeof(sdram_table) / sizeof(sdram_table[0]));
@@ -448,7 +448,7 @@  phys_size_t initdram(int board_type)
 		DO_LOOP;
 	}
 
-	size = get_ram_size((long *)0, SDRAM_MAX_SIZE);
+	size = get_ram_size((unsigned long *)0, SDRAM_MAX_SIZE);
 
 	return size;
 }
diff --git a/board/syteco/jadecpu/jadecpu.c b/board/syteco/jadecpu/jadecpu.c
index 6c60a41..57dc1d3 100644
--- a/board/syteco/jadecpu/jadecpu.c
+++ b/board/syteco/jadecpu/jadecpu.c
@@ -138,7 +138,7 @@  int misc_init_r(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM,
 					PHYS_SDRAM_SIZE);
 
 	return 0;
diff --git a/board/syteco/zmx25/zmx25.c b/board/syteco/zmx25/zmx25.c
index bdbf02a..b916794 100644
--- a/board/syteco/zmx25/zmx25.c
+++ b/board/syteco/zmx25/zmx25.c
@@ -168,7 +168,7 @@  int board_late_init(void)
 int dram_init(void)
 {
 	/* dram_init must store complete ramsize in gd->ram_size */
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM,
 				PHYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/taskit/stamp9g20/stamp9g20.c b/board/taskit/stamp9g20/stamp9g20.c
index 704a63b..35518f9 100644
--- a/board/taskit/stamp9g20/stamp9g20.c
+++ b/board/taskit/stamp9g20/stamp9g20.c
@@ -175,7 +175,7 @@  int board_init(void)
 int dram_init(void)
 {
 	gd->ram_size = get_ram_size(
-		(void *)CONFIG_SYS_SDRAM_BASE,
+		(unsigned long *)CONFIG_SYS_SDRAM_BASE,
 		CONFIG_SYS_SDRAM_SIZE);
 	return 0;
 }
diff --git a/board/ti/omap5912osk/omap5912osk.c b/board/ti/omap5912osk/omap5912osk.c
index e402649..55e48d0 100644
--- a/board/ti/omap5912osk/omap5912osk.c
+++ b/board/ti/omap5912osk/omap5912osk.c
@@ -118,7 +118,7 @@  void ether__init (void)
 ******************************/
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
 
 	return 0;
 }
diff --git a/board/timll/devkit3250/devkit3250.c b/board/timll/devkit3250/devkit3250.c
index 6acc416..e4a2bcb 100644
--- a/board/timll/devkit3250/devkit3250.c
+++ b/board/timll/devkit3250/devkit3250.c
@@ -45,7 +45,7 @@  int board_init(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+	gd->ram_size = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
 				    CONFIG_SYS_SDRAM_SIZE);
 
 	return 0;
diff --git a/board/total5200/sdram.c b/board/total5200/sdram.c
index dbe3587..8a46953 100644
--- a/board/total5200/sdram.c
+++ b/board/total5200/sdram.c
@@ -85,9 +85,9 @@  long int mpc5xxx_sdram_init (sdram_conf_t *sdram_conf)
 
 	/* find RAM size using SDRAM CS0 only */
 	mpc5xxx_sdram_start(sdram_conf, 0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	mpc5xxx_sdram_start(sdram_conf, 1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		mpc5xxx_sdram_start(sdram_conf, 0);
 		dramsize = test1;
@@ -112,9 +112,9 @@  long int mpc5xxx_sdram_init (sdram_conf_t *sdram_conf)
 
 	/* find RAM size using SDRAM CS1 only */
 	mpc5xxx_sdram_start(sdram_conf, 0);
-	test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+	test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	mpc5xxx_sdram_start(sdram_conf, 1);
-	test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+	test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	if (test1 > test2) {
 		mpc5xxx_sdram_start(sdram_conf, 0);
 		dramsize2 = test1;
diff --git a/board/tqc/tqm5200/tqm5200.c b/board/tqc/tqm5200/tqm5200.c
index d5a8a97..b73a802 100644
--- a/board/tqc/tqm5200/tqm5200.c
+++ b/board/tqc/tqm5200/tqm5200.c
@@ -158,9 +158,9 @@  phys_size_t initdram (int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x20000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -187,10 +187,10 @@  phys_size_t initdram (int board_type)
 	/* find RAM size using SDRAM CS1 only */
 	if (!dramsize)
 		sdram_start(0);
-	test2 = test1 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
+	test2 = test1 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
 	if (!dramsize) {
 		sdram_start(1);
-		test2 = get_ram_size((long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
+		test2 = get_ram_size((unsigned long *)(CONFIG_SYS_SDRAM_BASE + dramsize), 0x20000000);
 	}
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/tqc/tqm8260/tqm8260.c b/board/tqc/tqm8260/tqm8260.c
index c361f18..9cb2a5c 100644
--- a/board/tqc/tqm8260/tqm8260.c
+++ b/board/tqc/tqm8260/tqm8260.c
@@ -261,10 +261,10 @@  static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
 	*sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
 	*base = c;
 
-	size = get_ram_size((long *)base, maxsize);
+	size = get_ram_size((unsigned long *)base, maxsize);
 	*orx_ptr = orx | ~(size - 1);
 
-	return (size);
+	return (long int)(size);
 }
 
 phys_size_t initdram (int board_type)
diff --git a/board/tqc/tqm8272/tqm8272.c b/board/tqc/tqm8272/tqm8272.c
index 334fd6d..17aa0e2 100644
--- a/board/tqc/tqm8272/tqm8272.c
+++ b/board/tqc/tqm8272/tqm8272.c
@@ -429,10 +429,10 @@  static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
 	*sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
 	*base = c;
 
-	size = get_ram_size((long *)base, maxsize);
+	size = get_ram_size((unsigned long *)base, maxsize);
 	*orx_ptr = orx | ~(size - 1);
 
-	return (size);
+	return (long int)(size);
 }
 
 phys_size_t initdram (int board_type)
diff --git a/board/tqc/tqm834x/tqm834x.c b/board/tqc/tqm834x/tqm834x.c
index 814fcb2..306aec2 100644
--- a/board/tqc/tqm834x/tqm834x.c
+++ b/board/tqc/tqm834x/tqm834x.c
@@ -279,7 +279,7 @@  static long int get_ddr_bank_size(short cs, long *base)
 		set_cs_config(cs, CSCONFIG_EN | conf[i].col | conf[i].row);
 
 		debug("Getting RAM size...\n");
-		size = get_ram_size(base, DDR_MAX_SIZE_PER_CS);
+		size = (long)get_ram_size((unsigned long *)base, DDR_MAX_SIZE_PER_CS);
 
 		if((size == conf[i].size) && (i == detected + 1))
 			detected = i;
diff --git a/board/tqc/tqm8xx/tqm8xx.c b/board/tqc/tqm8xx/tqm8xx.c
index 9ce2a57..5cc7583 100644
--- a/board/tqc/tqm8xx/tqm8xx.c
+++ b/board/tqc/tqm8xx/tqm8xx.c
@@ -411,7 +411,7 @@  static long int dram_size (long int mamr_value, long int *base, long int maxsize
 
 	memctl->memc_mamr = mamr_value;
 
-	return (get_ram_size(base, maxsize));
+	return (long int)(get_ram_size((unsigned long *)base, (unsigned long)maxsize));
 }
 
 /* ------------------------------------------------------------------------- */
diff --git a/board/ttcontrol/vision2/vision2.c b/board/ttcontrol/vision2/vision2.c
index b4d3994..2945f4c 100644
--- a/board/ttcontrol/vision2/vision2.c
+++ b/board/ttcontrol/vision2/vision2.c
@@ -116,7 +116,7 @@  static void init_drive_strength(void)
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 		PHYS_SDRAM_1_SIZE);
 
 	return 0;
diff --git a/board/utx8245/utx8245.c b/board/utx8245/utx8245.c
index 69d19e3..1d7e6b7 100644
--- a/board/utx8245/utx8245.c
+++ b/board/utx8245/utx8245.c
@@ -33,11 +33,11 @@  int checkboard(void)
 
 phys_size_t initdram(int board_type)
 {
-	long size;
-	long new_bank0_end;
-	long new_bank1_end;
-	long mear1;
-	long emear1;
+	unsigned long size;
+	unsigned long new_bank0_end;
+	unsigned long new_bank1_end;
+	unsigned long mear1;
+	unsigned long emear1;
 
 	size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
 
diff --git a/board/v38b/v38b.c b/board/v38b/v38b.c
index a337729..e4ee661 100644
--- a/board/v38b/v38b.c
+++ b/board/v38b/v38b.c
@@ -83,9 +83,9 @@  phys_size_t initdram(int board_type)
 
 	/* find RAM size using SDRAM CS0 only */
 	sdram_start(0);
-	test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test1 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	sdram_start(1);
-	test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
+	test2 = get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
 	if (test1 > test2) {
 		sdram_start(0);
 		dramsize = test1;
@@ -108,10 +108,10 @@  phys_size_t initdram(int board_type)
 	/* find RAM size using SDRAM CS1 only */
 	if (!dramsize)
 		sdram_start(0);
-	test2 = test1 = get_ram_size((long *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+	test2 = test1 = get_ram_size((unsigned long *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	if (!dramsize) {
 		sdram_start(1);
-		test2 = get_ram_size((long *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
+		test2 = get_ram_size((unsigned long *) (CONFIG_SYS_SDRAM_BASE + dramsize), 0x80000000);
 	}
 	if (test1 > test2) {
 		sdram_start(0);
diff --git a/board/ve8313/ve8313.c b/board/ve8313/ve8313.c
index c4feef8..d19c025 100644
--- a/board/ve8313/ve8313.c
+++ b/board/ve8313/ve8313.c
@@ -81,7 +81,7 @@  static long fixed_sdram(void)
 
 	/* now check the real size */
 	disable_addr_trans ();
-	msize = get_ram_size (CONFIG_SYS_DDR_BASE, msize);
+	msize = (u32)get_ram_size (CONFIG_SYS_DDR_BASE, msize);
 	enable_addr_trans ();
 #endif
 
diff --git a/board/woodburn/woodburn.c b/board/woodburn/woodburn.c
index 2744514..a2d5cca 100644
--- a/board/woodburn/woodburn.c
+++ b/board/woodburn/woodburn.c
@@ -37,7 +37,7 @@  DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1,
+	gd->ram_size = get_ram_size((unsigned long *)PHYS_SDRAM_1,
 		PHYS_SDRAM_1_SIZE);
 
 	return 0;
diff --git a/post/board/lwmon5/fpga.c b/post/board/lwmon5/fpga.c
index 1a72823..9365301 100644
--- a/post/board/lwmon5/fpga.c
+++ b/post/board/lwmon5/fpga.c
@@ -295,7 +295,7 @@  int fpga_post_test(int flags)
 	out_be32((void *)FPGA_STAT, in_be32((void *)FPGA_STAT) | 0x1000);
 
 	/* get RAM size */
-	read_value = get_ram_size((void *)CONFIG_SYS_FPGA_BASE_1, FPGA_RAM_SIZE);
+	read_value = (uint)get_ram_size((unsigned long *)CONFIG_SYS_FPGA_BASE_1, FPGA_RAM_SIZE);
 	post_log("FPGA RAM size %d bytes\n", read_value);
 	WATCHDOG_RESET();
 
diff --git a/post/board/lwmon5/gdc.c b/post/board/lwmon5/gdc.c
index 9405e7d..bca3a0b 100644
--- a/post/board/lwmon5/gdc.c
+++ b/post/board/lwmon5/gdc.c
@@ -303,7 +303,7 @@  int gdc_post_test(int flags)
 		 (old_value >> 8) & 0xFF, old_value & 0xFF,
 		 (old_value >> 16) & 0xFFFF);
 
-	old_value = get_ram_size((void *)GDC_RAM_START,
+	old_value = (uint)get_ram_size((unsigned long *)GDC_RAM_START,
 				 0x02000000);
 
 	debug("GDC RAM size (ist):  %d bytes\n", old_value);
-- 
1.8.1.5