1/* 2 * arch/sh/boards/renesas/r7780rp/setup.c 3 * 4 * Renesas Solutions Highlander Support. 5 * 6 * Copyright (C) 2002 Atom Create Engineering Co., Ltd. 7 * Copyright (C) 2005 - 2007 Paul Mundt 8 * 9 * This contains support for the R7780RP-1, R7780MP, and R7785RP 10 * Highlander modules. 11 * 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> 18#include <linux/pata_platform.h> 19#include <asm/machvec.h> 20#include <asm/r7780rp.h> 21#include <asm/clock.h> 22#include <asm/io.h> 23 24static struct resource cf_ide_resources[] = { 25 [0] = { 26 .start = PA_AREA5_IO + 0x1000, 27 .end = PA_AREA5_IO + 0x1000 + 0x08 - 1, 28 .flags = IORESOURCE_MEM, 29 }, 30 [1] = { 31 .start = PA_AREA5_IO + 0x80c, 32 .end = PA_AREA5_IO + 0x80c + 0x16 - 1, 33 .flags = IORESOURCE_MEM, 34 }, 35 [2] = { 36#ifdef CONFIG_SH_R7780RP 37 .start = 4, 38#else 39 .start = 1, 40#endif 41 .flags = IORESOURCE_IRQ, 42 }, 43}; 44 45static struct pata_platform_info pata_info = { 46 .ioport_shift = 1, 47}; 48 49static 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, 54 .dev = { 55 .platform_data = &pata_info, 56 }, 57}; 58 59static 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, 72 73 /* R7785RP has a slightly more sensible FPGA.. */ 74#ifndef CONFIG_SH_R7785RP 75 .dev = { 76 .platform_data = heartbeat_bit_pos, 77 }, 78#endif 79 .num_resources = ARRAY_SIZE(heartbeat_resources), 80 .resource = heartbeat_resources, 81}; 82 83static struct platform_device *r7780rp_devices[] __initdata = { 84 &cf_ide_device, 85 &heartbeat_device, 86}; 87 88static int __init r7780rp_devices_setup(void) 89{ 90 return platform_add_devices(r7780rp_devices, 91 ARRAY_SIZE(r7780rp_devices)); 92} 93device_initcall(r7780rp_devices_setup); 94 95/* 96 * Platform specific clocks 97 */ 98static void ivdr_clk_enable(struct clk *clk) 99{ 100 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL); 101} 102 103static void ivdr_clk_disable(struct clk *clk) 104{ 105 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL); 106} 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 122static void r7780rp_power_off(void) 123{ 124 if (mach_is_r7780mp() || mach_is_r7785rp()) 125 ctrl_outw(0x0001, PA_POFF); 126} 127 128/* 129 * Initialize the board 130 */ 131static void __init highlander_setup(char **cmdline_p) 132{ 133 u16 ver = ctrl_inw(PA_VERREG); 134 int i; 135 136 printk(KERN_INFO "Renesas Solutions Highlander %s support.\n", 137 mach_is_r7780rp() ? "R7780RP-1" : 138 mach_is_r7780mp() ? "R7780MP" : 139 "R7785RP"); 140 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. */ 157 158 if (mach_is_r7780rp()) 159 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */ 160 161 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */ 162 163 pm_power_off = r7780rp_power_off; 164} 165 166/* 167 * The Machine Vector 168 */ 169struct sh_machine_vector mv_highlander __initmv = { 170 .mv_name = "Highlander", 171 .mv_nr_irqs = 109, 172 .mv_setup = highlander_setup, 173 .mv_init_irq = highlander_init_irq, 174}; 175ALIAS_MV(highlander) 176