setup.c 4.07 KB
Newer Older
1 2 3 4
/*
 * arch/sh/boards/renesas/r7780rp/setup.c
 *
 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
5
 * Copyright (C) 2005 - 2007 Paul Mundt
6 7 8 9 10 11 12 13 14
 *
 * Renesas Solutions Highlander R7780RP-1 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/pata_platform.h>
16
#include <asm/machvec.h>
17
#include <asm/r7780rp.h>
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
#include <asm/clock.h>
#include <asm/io.h>

extern void init_r7780rp_IRQ(void);

static struct resource m66596_usb_host_resources[] = {
	[0] = {
		.start	= 0xa4800000,
		.end	= 0xa4ffffff,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= 6,		/* irq number */
		.end	= 6,
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device m66596_usb_host_device = {
	.name		= "m66596-hcd",
	.id		= 0,
	.dev = {
		.dma_mask		= NULL,		/* don't use dma */
		.coherent_dma_mask	= 0xffffffff,
	},
	.num_resources	= ARRAY_SIZE(m66596_usb_host_resources),
	.resource	= m66596_usb_host_resources,
};

47 48
static struct resource cf_ide_resources[] = {
	[0] = {
49 50 51
		.start	= PA_AREA5_IO + 0x1000,
		.end	= PA_AREA5_IO + 0x1000 + 0x08 - 1,
		.flags	= IORESOURCE_MEM,
52 53
	},
	[1] = {
54 55 56
		.start	= PA_AREA5_IO + 0x80c,
		.end	= PA_AREA5_IO + 0x80c + 0x16 - 1,
		.flags	= IORESOURCE_MEM,
57 58 59 60 61 62 63 64 65 66 67
	},
	[2] = {
#ifdef CONFIG_SH_R7780MP
		.start	= 1,
#else
		.start	= 4,
#endif
		.flags	= IORESOURCE_IRQ,
	},
};

68 69 70 71
static struct pata_platform_info pata_info = {
	.ioport_shift	= 1,
};

72 73 74 75 76
static struct platform_device cf_ide_device  = {
	.name		= "pata_platform",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(cf_ide_resources),
	.resource	= cf_ide_resources,
77 78 79
	.dev	= {
		.platform_data	= &pata_info,
	},
80 81
};

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };

static struct resource heartbeat_resources[] = {
	[0] = {
		.start	= PA_OBLED,
		.end	= PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device heartbeat_device = {
	.name		= "heartbeat",
	.id		= -1,
	.dev	= {
		.platform_data	= heartbeat_bit_pos,
	},
	.num_resources	= ARRAY_SIZE(heartbeat_resources),
	.resource	= heartbeat_resources,
};

102 103
static struct platform_device *r7780rp_devices[] __initdata = {
	&m66596_usb_host_device,
104
	&cf_ide_device,
105
	&heartbeat_device,
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
};

static int __init r7780rp_devices_setup(void)
{
	return platform_add_devices(r7780rp_devices,
				    ARRAY_SIZE(r7780rp_devices));
}

/*
 * Platform specific clocks
 */
static void ivdr_clk_enable(struct clk *clk)
{
	ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL);
}

static void ivdr_clk_disable(struct clk *clk)
{
	ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL);
}

static struct clk_ops ivdr_clk_ops = {
	.enable		= ivdr_clk_enable,
	.disable	= ivdr_clk_disable,
};

static struct clk ivdr_clk = {
	.name		= "ivdr_clk",
	.ops		= &ivdr_clk_ops,
};

static struct clk *r7780rp_clocks[] = {
	&ivdr_clk,
};

static void r7780rp_power_off(void)
{
#ifdef CONFIG_SH_R7780MP
	ctrl_outw(0x0001, PA_POFF);
#endif
}

/*
 * Initialize the board
 */
Paul Mundt's avatar
Paul Mundt committed
151
static void __init r7780rp_setup(char **cmdline_p)
152 153 154 155
{
	u16 ver = ctrl_inw(PA_VERREG);
	int i;

Paul Mundt's avatar
Paul Mundt committed
156 157
	device_initcall(r7780rp_devices_setup);

158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
	printk(KERN_INFO "Renesas Solutions Highlander R7780RP-1 support.\n");

	printk(KERN_INFO "Board version: %d (revision %d), "
			 "FPGA version: %d (revision %d)\n",
			 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
			 (ver >>  4) & 0xf, ver & 0xf);

	/*
	 * Enable the important clocks right away..
	 */
	for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
		struct clk *clk = r7780rp_clocks[i];

		clk_register(clk);
		clk_enable(clk);
	}

	ctrl_outw(0x0000, PA_OBLED);	/* Clear LED. */
#ifndef CONFIG_SH_R7780MP
	ctrl_outw(0x0001, PA_SDPOW);	/* SD Power ON */
#endif
179
	ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL);	/* Si13112 */
180 181 182

	pm_power_off = r7780rp_power_off;
}
Paul Mundt's avatar
Paul Mundt committed
183 184 185 186 187 188 189 190 191 192 193

/*
 * The Machine Vector
 */
struct sh_machine_vector mv_r7780rp __initmv = {
	.mv_name		= "Highlander R7780RP-1",
	.mv_setup		= r7780rp_setup,
	.mv_nr_irqs		= 109,
	.mv_init_irq		= init_r7780rp_IRQ,
};
ALIAS_MV(r7780rp)