setup.c 4.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 * linux/arch/sh/boards/se/7722/setup.c
 *
 * Copyright (C) 2007 Nobuhiro Iwamatsu
 *
 * Hitachi UL SolutionEngine 7722 Support.
 *
 * 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.
 *
 */
#include <linux/init.h>
#include <linux/platform_device.h>
15
#include <linux/ata_platform.h>
16
#include <linux/input.h>
17
#include <linux/smc91x.h>
18 19
#include <mach-se/mach/se7722.h>
#include <mach-se/mach/mrshpc.h>
20
#include <asm/machvec.h>
21
#include <asm/clock.h>
22
#include <asm/io.h>
23
#include <asm/heartbeat.h>
24
#include <asm/sh_keysc.h>
25
#include <cpu/sh7722.h>
26 27

/* Heartbeat */
28 29 30 31
static struct heartbeat_data heartbeat_data = {
	.regsize = 16,
};

32 33 34
static struct resource heartbeat_resources[] = {
	[0] = {
		.start  = PA_LED,
35
		.end    = PA_LED,
36 37 38 39 40 41 42
		.flags  = IORESOURCE_MEM,
	},
};

static struct platform_device heartbeat_device = {
	.name           = "heartbeat",
	.id             = -1,
43 44 45
	.dev = {
		.platform_data = &heartbeat_data,
	},
46 47 48 49 50
	.num_resources  = ARRAY_SIZE(heartbeat_resources),
	.resource       = heartbeat_resources,
};

/* SMC91x */
51 52 53 54
static struct smc91x_platdata smc91x_info = {
	.flags = SMC91X_USE_16BIT,
};

55 56 57 58 59 60 61 62
static struct resource smc91x_eth_resources[] = {
	[0] = {
		.name   = "smc91x-regs" ,
		.start  = PA_LAN + 0x300,
		.end    = PA_LAN + 0x300 + 0x10 ,
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
63
		/* Filled in later */
64 65 66 67 68 69 70 71 72 73
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device smc91x_eth_device = {
	.name           = "smc91x",
	.id             = 0,
	.dev = {
		.dma_mask               = NULL,         /* don't use dma */
		.coherent_dma_mask      = 0xffffffff,
74
		.platform_data	= &smc91x_info,
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
	},
	.num_resources  = ARRAY_SIZE(smc91x_eth_resources),
	.resource       = smc91x_eth_resources,
};

static struct resource cf_ide_resources[] = {
	[0] = {
		.start  = PA_MRSHPC_IO + 0x1f0,
		.end    = PA_MRSHPC_IO + 0x1f0 + 8 ,
		.flags  = IORESOURCE_IO,
	},
	[1] = {
		.start  = PA_MRSHPC_IO + 0x1f0 + 0x206,
		.end    = PA_MRSHPC_IO + 0x1f0 +8 + 0x206 + 8,
		.flags  = IORESOURCE_IO,
	},
	[2] = {
92
		/* Filled in later */
93 94 95 96 97 98 99 100 101 102 103
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device cf_ide_device  = {
	.name           = "pata_platform",
	.id             = -1,
	.num_resources  = ARRAY_SIZE(cf_ide_resources),
	.resource       = cf_ide_resources,
};

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
static struct sh_keysc_info sh_keysc_info = {
	.mode = SH_KEYSC_MODE_1, /* KEYOUT0->5, KEYIN0->4 */
	.scan_timing = 3,
	.delay = 5,
	.keycodes = { /* SW1 -> SW30 */
		KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
		KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
		KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
		KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T,
		KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y,
		KEY_Z,
		KEY_HOME, KEY_SLEEP, KEY_WAKEUP, KEY_COFFEE, /* life */
	},
};

static struct resource sh_keysc_resources[] = {
	[0] = {
		.start  = 0x044b0000,
		.end    = 0x044b000f,
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
		.start  = 79,
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device sh_keysc_device = {
	.name           = "sh_keysc",
133
	.id             = 0, /* "keysc0" clock */
134 135 136 137 138
	.num_resources  = ARRAY_SIZE(sh_keysc_resources),
	.resource       = sh_keysc_resources,
	.dev	= {
		.platform_data	= &sh_keysc_info,
	},
139 140 141
	.archdata = {
		.hwblk_id = HWBLK_KEYSC,
	},
142 143
};

144 145 146 147
static struct platform_device *se7722_devices[] __initdata = {
	&heartbeat_device,
	&smc91x_eth_device,
	&cf_ide_device,
148
	&sh_keysc_device,
149 150 151 152
};

static int __init se7722_devices_setup(void)
{
153
	mrshpc_setup_windows();
154 155 156 157 158 159 160 161

	/* Wire-up dynamic vectors */
	cf_ide_resources[2].start = cf_ide_resources[2].end =
		se7722_fpga_irq[SE7722_FPGA_IRQ_MRSHPC0];

	smc91x_eth_resources[1].start = smc91x_eth_resources[1].end =
		se7722_fpga_irq[SE7722_FPGA_IRQ_SMC];

162
	return platform_add_devices(se7722_devices, ARRAY_SIZE(se7722_devices));
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
}
device_initcall(se7722_devices_setup);

static void __init se7722_setup(char **cmdline_p)
{
	ctrl_outw(0x010D, FPGA_OUT);    /* FPGA */

	ctrl_outw(0x0000, PORT_PECR);   /* PORT E 1 = IRQ5 ,E 0 = BS */
	ctrl_outw(0x1000, PORT_PJCR);   /* PORT J 1 = IRQ1,J 0 =IRQ0 */

	/* LCDC I/O */
	ctrl_outw(0x0020, PORT_PSELD);

	/* SIOF1*/
	ctrl_outw(0x0003, PORT_PSELB);
	ctrl_outw(0xe000, PORT_PSELC);
	ctrl_outw(0x0000, PORT_PKCR);

	/* LCDC */
	ctrl_outw(0x4020, PORT_PHCR);
	ctrl_outw(0x0000, PORT_PLCR);
	ctrl_outw(0x0000, PORT_PMCR);
	ctrl_outw(0x0002, PORT_PRCR);
	ctrl_outw(0x0000, PORT_PXCR);   /* LCDC,CS6A */

	/* KEYSC */
	ctrl_outw(0x0A10, PORT_PSELA); /* BS,SHHID2 */
	ctrl_outw(0x0000, PORT_PYCR);
	ctrl_outw(0x0000, PORT_PZCR);
192 193
	ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x4000, PORT_HIZCRA);
	ctrl_outw(ctrl_inw(PORT_HIZCRC) & ~0xc000, PORT_HIZCRC);
194 195 196 197 198
}

/*
 * The Machine Vector
 */
P
Paul Mundt 已提交
199
static struct sh_machine_vector mv_se7722 __initmv = {
200 201 202 203
	.mv_name                = "Solution Engine 7722" ,
	.mv_setup               = se7722_setup ,
	.mv_init_irq		= init_se7722_IRQ,
};