blob: 0727ef92f2b37431cb4f3de3ab3234b360eeef02 [file] [log] [blame]
Paul Mundt5283ecb2006-09-27 15:59:17 +09001/*
2 * arch/sh/boards/renesas/r7780rp/setup.c
3 *
Paul Mundt32351a22007-03-12 14:38:59 +09004 * Renesas Solutions Highlander Support.
5 *
Paul Mundt5283ecb2006-09-27 15:59:17 +09006 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
Paul Mundt71074d32007-02-14 14:49:04 +09007 * Copyright (C) 2005 - 2007 Paul Mundt
Paul Mundt5283ecb2006-09-27 15:59:17 +09008 *
Paul Mundt32351a22007-03-12 14:38:59 +09009 * This contains support for the R7780RP-1, R7780MP, and R7785RP
10 * Highlander modules.
Paul Mundt5283ecb2006-09-27 15:59:17 +090011 *
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file "COPYING" in the main directory of this archive
14 * for more details.
15 */
16#include <linux/init.h>
17#include <linux/platform_device.h>
Paul Mundt71074d32007-02-14 14:49:04 +090018#include <linux/pata_platform.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090019#include <asm/machvec.h>
Paul Mundt082c44d2006-10-19 16:16:18 +090020#include <asm/r7780rp.h>
Paul Mundt5283ecb2006-09-27 15:59:17 +090021#include <asm/clock.h>
22#include <asm/io.h>
23
Paul Mundt0c020e32006-12-06 10:43:44 +090024static struct resource cf_ide_resources[] = {
25 [0] = {
Paul Mundt71074d32007-02-14 14:49:04 +090026 .start = PA_AREA5_IO + 0x1000,
27 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1,
28 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090029 },
30 [1] = {
Paul Mundt71074d32007-02-14 14:49:04 +090031 .start = PA_AREA5_IO + 0x80c,
32 .end = PA_AREA5_IO + 0x80c + 0x16 - 1,
33 .flags = IORESOURCE_MEM,
Paul Mundt0c020e32006-12-06 10:43:44 +090034 },
35 [2] = {
Paul Mundt32351a22007-03-12 14:38:59 +090036#ifdef CONFIG_SH_R7780RP
Paul Mundt0c020e32006-12-06 10:43:44 +090037 .start = 4,
Paul Mundt32351a22007-03-12 14:38:59 +090038#else
39 .start = 1,
Paul Mundt0c020e32006-12-06 10:43:44 +090040#endif
41 .flags = IORESOURCE_IRQ,
42 },
43};
44
Paul Mundt71074d32007-02-14 14:49:04 +090045static struct pata_platform_info pata_info = {
46 .ioport_shift = 1,
47};
48
Paul Mundt0c020e32006-12-06 10:43:44 +090049static struct platform_device cf_ide_device = {
50 .name = "pata_platform",
51 .id = -1,
52 .num_resources = ARRAY_SIZE(cf_ide_resources),
53 .resource = cf_ide_resources,
Paul Mundt71074d32007-02-14 14:49:04 +090054 .dev = {
55 .platform_data = &pata_info,
56 },
Paul Mundt0c020e32006-12-06 10:43:44 +090057};
58
Paul Mundt3b4d9532007-02-13 15:42:28 +090059static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
60
61static struct resource heartbeat_resources[] = {
62 [0] = {
63 .start = PA_OBLED,
64 .end = PA_OBLED + ARRAY_SIZE(heartbeat_bit_pos) - 1,
65 .flags = IORESOURCE_MEM,
66 },
67};
68
69static struct platform_device heartbeat_device = {
70 .name = "heartbeat",
71 .id = -1,
Paul Mundt32351a22007-03-12 14:38:59 +090072
73 /* R7785RP has a slightly more sensible FPGA.. */
74#ifndef CONFIG_SH_R7785RP
Paul Mundt3b4d9532007-02-13 15:42:28 +090075 .dev = {
76 .platform_data = heartbeat_bit_pos,
77 },
Paul Mundt32351a22007-03-12 14:38:59 +090078#endif
Paul Mundt3b4d9532007-02-13 15:42:28 +090079 .num_resources = ARRAY_SIZE(heartbeat_resources),
80 .resource = heartbeat_resources,
81};
82
Paul Mundt5283ecb2006-09-27 15:59:17 +090083static struct platform_device *r7780rp_devices[] __initdata = {
Paul Mundt0c020e32006-12-06 10:43:44 +090084 &cf_ide_device,
Paul Mundt3b4d9532007-02-13 15:42:28 +090085 &heartbeat_device,
Paul Mundt5283ecb2006-09-27 15:59:17 +090086};
87
88static int __init r7780rp_devices_setup(void)
89{
90 return platform_add_devices(r7780rp_devices,
91 ARRAY_SIZE(r7780rp_devices));
92}
Paul Mundt32351a22007-03-12 14:38:59 +090093device_initcall(r7780rp_devices_setup);
Paul Mundt5283ecb2006-09-27 15:59:17 +090094
95/*
96 * Platform specific clocks
97 */
98static void ivdr_clk_enable(struct clk *clk)
99{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900100 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900101}
102
103static void ivdr_clk_disable(struct clk *clk)
104{
Ryusuke Sakato39374aa2007-05-07 10:48:56 +0900105 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900106}
107
108static struct clk_ops ivdr_clk_ops = {
109 .enable = ivdr_clk_enable,
110 .disable = ivdr_clk_disable,
111};
112
113static struct clk ivdr_clk = {
114 .name = "ivdr_clk",
115 .ops = &ivdr_clk_ops,
116};
117
118static struct clk *r7780rp_clocks[] = {
119 &ivdr_clk,
120};
121
Paul Mundt5283ecb2006-09-27 15:59:17 +0900122static void r7780rp_power_off(void)
123{
Paul Mundt32351a22007-03-12 14:38:59 +0900124 if (mach_is_r7780mp() || mach_is_r7785rp())
125 ctrl_outw(0x0001, PA_POFF);
Paul Mundt5283ecb2006-09-27 15:59:17 +0900126}
127
128/*
129 * Initialize the board
130 */
Paul Mundt32351a22007-03-12 14:38:59 +0900131static void __init highlander_setup(char **cmdline_p)
Paul Mundt5283ecb2006-09-27 15:59:17 +0900132{
133 u16 ver = ctrl_inw(PA_VERREG);
134 int i;
135
Paul Mundt32351a22007-03-12 14:38:59 +0900136 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
137 mach_is_r7780rp() ? "R7780RP-1" :
138 mach_is_r7780mp() ? "R7780MP" :
139 "R7785RP");
Paul Mundt5283ecb2006-09-27 15:59:17 +0900140
141 printk(KERN_INFO "Board version: %d (revision %d), "
142 "FPGA version: %d (revision %d)\n",
143 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
144 (ver >> 4) & 0xf, ver & 0xf);
145
146 /*
147 * Enable the important clocks right away..
148 */
149 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
150 struct clk *clk = r7780rp_clocks[i];
151
152 clk_register(clk);
153 clk_enable(clk);
154 }
155
156 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
Paul Mundt32351a22007-03-12 14:38:59 +0900157
158 if (mach_is_r7780rp())
159 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
160
Paul Mundt2c081e72006-12-25 18:28:33 +0900161 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */
Paul Mundt5283ecb2006-09-27 15:59:17 +0900162
163 pm_power_off = r7780rp_power_off;
164}
Paul Mundt2c7834a2006-09-27 18:17:31 +0900165
166/*
167 * The Machine Vector
168 */
Paul Mundt32351a22007-03-12 14:38:59 +0900169struct sh_machine_vector mv_highlander __initmv = {
170 .mv_name = "Highlander",
Paul Mundt2c7834a2006-09-27 18:17:31 +0900171 .mv_nr_irqs = 109,
Paul Mundt32351a22007-03-12 14:38:59 +0900172 .mv_setup = highlander_setup,
173 .mv_init_irq = highlander_init_irq,
Paul Mundt2c7834a2006-09-27 18:17:31 +0900174};
Paul Mundt32351a22007-03-12 14:38:59 +0900175ALIAS_MV(highlander)