summaryrefslogtreecommitdiffstats
path: root/arch/arm/boot/compressed/sdhi-sh7372.c
blob: d403a8b24d7f322ad8b53c58ce047a06dc2bc0f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * SuperH Mobile SDHI
 *
 * Copyright (C) 2010 Magnus Damm
 * Copyright (C) 2010 Kuninori Morimoto
 * Copyright (C) 2010 Simon Horman
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Parts inspired by u-boot
 */

#include <linux/io.h>
#include <mach/mmc.h>
#include <linux/mmc/boot.h>
#include <linux/mmc/tmio.h>

#include "sdhi-shmobile.h"

#define PORT179CR       0xe60520b3
#define PORT180CR       0xe60520b4
#define PORT181CR       0xe60520b5
#define PORT182CR       0xe60520b6
#define PORT183CR       0xe60520b7
#define PORT184CR       0xe60520b8

#define SMSTPCR3        0xe615013c

#define CR_INPUT_ENABLE 0x10
#define CR_FUNCTION1    0x01

#define SDHI1_BASE	(void __iomem *)0xe6860000
#define SDHI_BASE	SDHI1_BASE

/*  SuperH Mobile SDHI loader
 *
 * loads the zImage from an SD card starting from block 0
 * on physical partition 1
 *
 * The image must be start with a vrl4 header and
 * the zImage must start at offset 512 of the image. That is,
 * at block 1 (=byte 512) of physical partition 1
 *
 * Use the following line to write the vrl4 formated zImage
 * to an SD card
 * # dd if=vrl4.out of=/dev/sdx bs=512
 */
asmlinkage void mmc_loader(unsigned short *buf, unsigned long len)
{
	int high_capacity;

	mmc_init_progress();

	mmc_update_progress(MMC_PROGRESS_ENTER);
        /* Initialise SDHI1 */
        /* PORT184CR: GPIO_FN_SDHICMD1 Control */
        __raw_writeb(CR_FUNCTION1, PORT184CR);
        /* PORT179CR: GPIO_FN_SDHICLK1 Control */
        __raw_writeb(CR_INPUT_ENABLE|CR_FUNCTION1, PORT179CR);
        /* PORT181CR: GPIO_FN_SDHID1_3 Control */
        __raw_writeb(CR_FUNCTION1, PORT183CR);
        /* PORT182CR: GPIO_FN_SDHID1_2 Control */
        __raw_writeb(CR_FUNCTION1, PORT182CR);
        /* PORT183CR: GPIO_FN_SDHID1_1 Control */
        __raw_writeb(CR_FUNCTION1, PORT181CR);
        /* PORT180CR: GPIO_FN_SDHID1_0 Control */
        __raw_writeb(CR_FUNCTION1, PORT180CR);

        /* Enable clock to SDHI1 hardware block */
        __raw_writel(__raw_readl(SMSTPCR3) & ~(1 << 13), SMSTPCR3);

	/* setup SDHI hardware */
	mmc_update_progress(MMC_PROGRESS_INIT);
	high_capacity = sdhi_boot_init(SDHI_BASE);
	if (high_capacity < 0)
		goto err;

	mmc_update_progress(MMC_PROGRESS_LOAD);
	/* load kernel */
	if (sdhi_boot_do_read(SDHI_BASE, high_capacity,
			      0, /* Kernel is at block 1 */
			      (len + TMIO_BBS - 1) / TMIO_BBS, buf))
		goto err;

        /* Disable clock to SDHI1 hardware block */
        __raw_writel(__raw_readl(SMSTPCR3) & (1 << 13), SMSTPCR3);

	mmc_update_progress(MMC_PROGRESS_DONE);

	return;
err:
	for(;;);
}
OpenPOWER on IntegriCloud