mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Alexey Galakhov <agalakhov@gmail.com>
Subject: Re: [PATCH 4/4] S5PV210 iROM magic boot code
Date: Thu, 3 May 2012 19:59:56 +0200	[thread overview]
Message-ID: <201205031959.57093.jbe@pengutronix.de> (raw)
In-Reply-To: <1336050844-7043-5-git-send-email-agalakhov@gmail.com>

Alexey Galakhov wrote:
> [...]
> diff --git a/arch/arm/mach-samsung/s5p-irom-boot.c b/arch/arm/mach-samsung/s5p-irom-boot.c
> new file mode 100644 
> index 0000000..8fa0de4
> --- /dev/null
> +++ b/arch/arm/mach-samsung/s5p-irom-boot.c
> @@ -0,0 +1,64 @@
> +/*
> + * Copyright (C) 2012 Alexey Galakhov
> + *
> + * Based on code from u-boot found somewhere on the web
> + * that seems to originate from Samsung
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <config.h>
> +#include <common.h>
> +#include <init.h>
> +#include <mach/s3c-generic.h>
> +
> +/*
> + * These magical address values are from u-boot
> + * Not sure what they really mean but they work
> + */
> +#if 1 /* S5PV210 and other CPUs */
> +# define MADDR_CH 0xD0037488
> +# define MADDR_CP 0xD0037F98
> +#else /* not sure when, some older CPUs */
> +# define MADDR_CH 0xD003A508
> +# define MADDR_CP 0xD003E008
> +#endif
> +
> +typedef uint32_t (*mmc2mem_func)
> +(uint32_t channel, uint32_t start_block, uint16_t block_count, uint32_t *dest, uint32_t init);
> + 
> +/*
> + * Call to the magical iROM code present on S5P CPUs
> + * Block seems to be 512 bytes
> + */
> +int __bare_init s5p_irom_mmc_load(void *dest, uint32_t start_block, uint16_t block_count)
> +{ 
> +	uint32_t ret;
> +	uint32_t chan;
> +	uint32_t ch = *(volatile uint32_t*)(MADDR_CH);
> +	mmc2mem_func cp_func = (mmc2mem_func)(*(uint32_t*)(MADDR_CP));
> +	switch (ch)
> +	{
> +	case 0xEB000000:
> +		chan = 0;
> +		break;
> +	case 0xEB200000:
> +		chan = 2;
> +		break;
> +	default:
> +		return 0;
> +	}
> +
> +	ret = cp_func(chan, start_block, block_count, (uint32_t*)dest, 0);
> +	if (ret == 0)
> +		return 0; /* error */
> +	return 1;
> +}

It seems to be a low hanging fruit to use the iROM to access some of the
peripherals. But there is no way to tell the compiler the calling convention
to the ROM functions. And the entry points seems guessed only. This results
into "it works for me with this compiler and these compiler flags and that
CPU's silicon revision"...

The S3C6410 CPU comes also with such an iROM. But calling it is only useful in
the first stage loader (and the S3C6410 iROM has a defined jump table to
call specific functions, there is no need to guess the real entry points).

Writing a Barebox driver for this MMC/SD unit instead should be the correct
way.

Juergen

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-05-03 18:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03 13:14 [PATCH 0/4] Support Samsung S5PV210 CPU Alexey Galakhov
2012-05-03 13:14 ` [PATCH 1/4] Support most Samsung SoCs in S3C serial driver Alexey Galakhov
2012-05-03 13:14 ` [PATCH 2/4] Fine split S3C arch dependencies from generic code Alexey Galakhov
2012-05-03 17:41   ` Juergen Beisert
2012-05-04  9:39     ` Alexey Galakhov
2012-05-04  9:58       ` Juergen Beisert
2012-05-04 10:50         ` Alexey Galakhov
2012-05-04 11:13           ` Juergen Beisert
2012-05-04 11:26             ` missing sscanf christian.buettner
2012-05-04 11:40             ` [PATCH 2/4] Fine split S3C arch dependencies from generic code Alexey Galakhov
2012-05-04 12:00               ` Juergen Beisert
2012-05-04 12:34                 ` Alexey Galakhov
2012-05-04 10:52         ` Alexey Galakhov
2012-05-03 13:14 ` [PATCH 3/4] Minimal S5PV210 + Tiny210 support (2nd stage only) Alexey Galakhov
2012-05-03 17:49   ` Juergen Beisert
2012-05-04  9:41     ` Alexey Galakhov
2012-05-03 13:14 ` [PATCH 4/4] S5PV210 iROM magic boot code Alexey Galakhov
2012-05-03 17:59   ` Juergen Beisert [this message]
2012-05-04  9:47     ` Alexey Galakhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201205031959.57093.jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=agalakhov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox