linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mundt <lethal@linux-sh.org>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH] sh: add romImage MMCIF boot for sh7724 and Ecovec
Date: Tue, 18 May 2010 08:55:45 +0000	[thread overview]
Message-ID: <20100518085545.GA2544@linux-sh.org> (raw)
In-Reply-To: <20100513142728.20439.17880.sendpatchset@t400s>

On Thu, May 13, 2010 at 11:27:28PM +0900, Magnus Damm wrote:
> --- 0001/arch/sh/boot/romimage/Makefile
> +++ work/arch/sh/boot/romimage/Makefile	2010-05-13 22:12:58.000000000 +0900
> @@ -6,8 +6,17 @@
>  
>  targets		:= vmlinux head.o zeropage.bin piggy.o
>  
> +IMAGE_ADDRESS	:= 0
>  OBJECTS = $(obj)/head.o
> -LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext 0 -e romstart \
> +
> +ifeq ($(CONFIG_ROMIMAGE_MMCIF),y)
> +ifeq ($(CONFIG_CPU_SUBTYPE_SH7724),y)
> +IMAGE_ADDRESS	:= 0xe5200000 # ILRAM
> +OBJECTS += $(obj)/mmcif-sh7724.o
> +endif
> +endif
> +
> +LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_ADDRESS) -e romstart \
>  		   -T $(obj)/../../kernel/vmlinux.lds
>  
This is looking pretty dire. Perhaps it's time to start looking at having
per-CPU and per-machine type boot files for exporting these things. A
combination of what MIPS and ARM are doing would fit this pretty well.

> +#ifdef CONFIG_ROMIMAGE_MMCIF
> +	mov.l	load_mem_base, r4
> +	mov.l	bytes_to_load, r5
> +	mov.l	loader_function, r7
> +	jsr	@r7
> +	 mov	r4, r15
> +
> +	mov.l	load_mem_base, r4
> +	mov.l	loaded_code_offs, r5
> +	add	r4, r5
> +	jmp	@r5
> +	 nop
> +
> +        .balign 4
> +load_mem_base:
> +	.long	P1SEG | CONFIG_MEMORY_START | (1 << 20) /* 1 MiB offset */

Not only is this totally bogus for 32-bit, it's also of questionable
veracity for 29-bit. This is basically a questionable way of saying you
want PAGE_OFFSET + MEMORY_START, which we already have via KERNEL_LOAD.

KERNEL_LOAD does factor in the zero page offset, which you can either
mask off or account for depending on what level of flexibility you are
aiming for. Note that the zero page offset is Kconfig selectable, so if
anyone were to put the zero page at a 1MiB offset you would be in trouble
here (and yes, boards have done this in the past, although the current
worst offender is only 64kB in).

> +#include <linux/io.h>
> +#include "../../../../drivers/sh/mmcif_loader.c"
> +
Uhm.. no. Just because sh-sci did it doesn't make it a good idea. In
fact, if sh-sci does it, it's probably a stupid idea.

> +/* Ecovec board specific information:
> + *
> + * Set the following to enable MMCIF boot from the MMC card in CN12:
> + *
> + * DS1.5 = OFF (SH BOOT pin set to L)
> + * DS2.6 = OFF (Select MMCIF on CN12 instead of SDHI1)
> + * DS2.7 = ON  (Select MMCIF on CN12 instead of SDHI1)
> + *
> + */
> +#ifdef CONFIG_SH_ECOVEC
> +static void set_led(int nr)
> +{
> +	/* disable Hi-Z for LED pins */
> +	__raw_writew(__raw_readw(HIZCRA) & ~(1 << 1), HIZCRA);
> +
> +	/* update progress on LED4, LED5, LED6 and LED7 */
> +	__raw_writeb(1 << (nr - 1), PGDR);
> +}
> +#else
> +#define set_led(nr) do { } while (0)
> +#endif
> +
This too, just no. You already have a romimage.h for the boards, just use
that with an __ASSEMBLY__ case.

> +/* SH7724 specific MMCIF loader
> + *
> + * loads the romImage from an MMC card starting from block 512
> + * use the following line to write the romImage to an MMC card
> + * # dd if=arch/sh/boot/romImage of=/dev/sdx bsQ2 seekQ2
> + */
> +void mmcif_loader(unsigned char *buf, unsigned long no_bytes)
> +{
asmlinkage?

> +	/* update progress */
> +	set_led(1);
> +
[snip]

> +	/* update progress */
> +	set_led(2);
> +
[snip]

> +	/* update progress */
> +	set_led(3);

I'm amazed that given your perverse obsession with enums that you've
failed to employ them in something that would actually benefit from them
in a legitimate fashion. These comments are also about as meaningful as
the hardcoded values.

> --- /dev/null
> +++ work/drivers/sh/mmcif_loader.c	2010-05-13 22:55:23.000000000 +0900

This is definitely getting out of hand, drivers/sh/ is not a dumping
ground for anything and everything. I could live with this under
linux/sh_mmcif.h or so, though some of these cases are probably a bit
large for inlining.

We may at some point simply have to live with building a library for
things on the SH side and linking them in on the ARM side. Or if that
fails, then revisit the idea of a common architecture directory.

> +#define BLOCK_SIZE 512
> +
This really wants a better name. If any of linux/io.h asm/ references
bring in linux/fs.h you're going to be screwed.

      reply	other threads:[~2010-05-18  8:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-13 14:27 [PATCH] sh: add romImage MMCIF boot for sh7724 and Ecovec Magnus Damm
2010-05-18  8:55 ` Paul Mundt [this message]

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=20100518085545.GA2544@linux-sh.org \
    --to=lethal@linux-sh.org \
    --cc=linux-sh@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).