1/* 2 * Renesas Technology Corp. SH7786 Urquell Support. 3 * 4 * Copyright (C) 2008 Kuninori Morimoto <morimoto.kuninori@renesas.com> 5 * Copyright (C) 2009, 2010 Paul Mundt 6 * 7 * Based on board-sh7785lcr.c 8 * Copyright (C) 2008 Yoshihiro Shimoda 9 * 10 * This file is subject to the terms and conditions of the GNU General Public 11 * License. See the file "COPYING" in the main directory of this archive 12 * for more details. 13 */ 14#include <linux/init.h> 15#include <linux/platform_device.h> 16#include <linux/fb.h> 17#include <linux/smc91x.h> 18#include <linux/mtd/physmap.h> 19#include <linux/delay.h> 20#include <linux/gpio.h> 21#include <linux/irq.h> 22#include <linux/clk.h> 23#include <mach/urquell.h> 24#include <cpu/sh7786.h> 25#include <asm/heartbeat.h> 26#include <asm/sizes.h> 27#include <asm/smp-ops.h> 28 29 30/* HeartBeat */ 31static struct resource heartbeat_resource = { 32 .start = BOARDREG(SLEDR), 33 .end = BOARDREG(SLEDR), 34 .flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT, 35}; 36 37static struct platform_device heartbeat_device = { 38 .name = "heartbeat", 39 .id = -1, 40 .num_resources = 1, 41 .resource = &heartbeat_resource, 42}; 43 44/* LAN91C111 */ 45static struct smc91x_platdata smc91x_info = { 46 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, 47}; 48 49static struct resource smc91x_eth_resources[] = { 50 [0] = { 51 .name = "SMC91C111" , 52 .start = 0x05800300, 53 .end = 0x0580030f, 54 .flags = IORESOURCE_MEM, 55 }, 56 [1] = { 57 .start = 11, 58 .flags = IORESOURCE_IRQ, 59 }, 60}; 61 62static struct platform_device smc91x_eth_device = { 63 .name = "smc91x", 64 .num_resources = ARRAY_SIZE(smc91x_eth_resources), 65 .resource = smc91x_eth_resources, 66 .dev = { 67 .platform_data = &smc91x_info, 68 }, 69}; 70 71/* Nor Flash */ 72static struct mtd_partition nor_flash_partitions[] = { 73 { 74 .name = "loader", 75 .offset = 0x00000000, 76 .size = SZ_512K, 77 .mask_flags = MTD_WRITEABLE, /* Read-only */ 78 }, 79 { 80 .name = "bootenv", 81 .offset = MTDPART_OFS_APPEND, 82 .size = SZ_512K, 83 .mask_flags = MTD_WRITEABLE, /* Read-only */ 84 }, 85 { 86 .name = "kernel", 87 .offset = MTDPART_OFS_APPEND, 88 .size = SZ_4M, 89 }, 90 { 91 .name = "data", 92 .offset = MTDPART_OFS_APPEND, 93 .size = MTDPART_SIZ_FULL, 94 }, 95}; 96 97static struct physmap_flash_data nor_flash_data = { 98 .width = 2, 99 .parts = nor_flash_partitions, 100 .nr_parts = ARRAY_SIZE(nor_flash_partitions), 101}; 102 103static struct resource nor_flash_resources[] = { 104 [0] = { 105 .start = NOR_FLASH_ADDR, 106 .end = NOR_FLASH_ADDR + NOR_FLASH_SIZE - 1, 107 .flags = IORESOURCE_MEM, 108 } 109}; 110 111static struct platform_device nor_flash_device = { 112 .name = "physmap-flash", 113 .dev = { 114 .platform_data = &nor_flash_data, 115 }, 116 .num_resources = ARRAY_SIZE(nor_flash_resources), 117 .resource = nor_flash_resources, 118}; 119 120static struct platform_device *urquell_devices[] __initdata = { 121 &heartbeat_device, 122 &smc91x_eth_device, 123 &nor_flash_device, 124}; 125 126static int __init urquell_devices_setup(void) 127{ 128 /* USB */ 129 gpio_request(GPIO_FN_USB_OVC0, NULL); 130 gpio_request(GPIO_FN_USB_PENC0, NULL); 131 132 /* enable LAN */ 133 __raw_writew(__raw_readw(UBOARDREG(IRL2MSKR)) & ~0x00000001, 134 UBOARDREG(IRL2MSKR)); 135 136 return platform_add_devices(urquell_devices, 137 ARRAY_SIZE(urquell_devices)); 138} 139device_initcall(urquell_devices_setup); 140 141static void urquell_power_off(void) 142{ 143 __raw_writew(0xa5a5, UBOARDREG(SRSTR)); 144} 145 146static void __init urquell_init_irq(void) 147{ 148 plat_irq_setup_pins(IRQ_MODE_IRL3210_MASK); 149} 150 151static int urquell_mode_pins(void) 152{ 153 return __raw_readw(UBOARDREG(MDSWMR)); 154} 155 156static int urquell_clk_init(void) 157{ 158 struct clk *clk; 159 int ret; 160 161 /* 162 * Only handle the EXTAL case, anyone interfacing a crystal 163 * resonator will need to provide their own input clock. 164 */ 165 if (test_mode_pin(MODE_PIN9)) 166 return -EINVAL; 167 168 clk = clk_get(NULL, "extal"); 169 if (!clk || IS_ERR(clk)) 170 return PTR_ERR(clk); 171 ret = clk_set_rate(clk, 33333333); 172 clk_put(clk); 173 174 return ret; 175} 176 177/* Initialize the board */ 178static void __init urquell_setup(char **cmdline_p) 179{ 180 printk(KERN_INFO "Renesas Technology Corp. Urquell support.\n"); 181 182 pm_power_off = urquell_power_off; 183 184 register_smp_ops(&shx3_smp_ops); 185} 186 187/* 188 * The Machine Vector 189 */ 190static struct sh_machine_vector mv_urquell __initmv = { 191 .mv_name = "Urquell", 192 .mv_setup = urquell_setup, 193 .mv_init_irq = urquell_init_irq, 194 .mv_mode_pins = urquell_mode_pins, 195 .mv_clk_init = urquell_clk_init, 196}; 197