Path: blob/master/arch/sh/boards/mach-highlander/setup.c
15125 views
/*1* arch/sh/boards/renesas/r7780rp/setup.c2*3* Renesas Solutions Highlander Support.4*5* Copyright (C) 2002 Atom Create Engineering Co., Ltd.6* Copyright (C) 2005 - 2008 Paul Mundt7*8* This contains support for the R7780RP-1, R7780MP, and R7785RP9* Highlander modules.10*11* This file is subject to the terms and conditions of the GNU General Public12* License. See the file "COPYING" in the main directory of this archive13* for more details.14*/15#include <linux/init.h>16#include <linux/io.h>17#include <linux/platform_device.h>18#include <linux/ata_platform.h>19#include <linux/types.h>20#include <linux/mtd/physmap.h>21#include <linux/i2c.h>22#include <linux/irq.h>23#include <linux/interrupt.h>24#include <linux/usb/r8a66597.h>25#include <linux/usb/m66592.h>26#include <linux/clkdev.h>27#include <net/ax88796.h>28#include <asm/machvec.h>29#include <mach/highlander.h>30#include <asm/clock.h>31#include <asm/heartbeat.h>32#include <asm/io.h>33#include <asm/io_trapped.h>3435static struct r8a66597_platdata r8a66597_data = {36.xtal = R8A66597_PLATDATA_XTAL_12MHZ,37.vif = 1,38};3940static struct resource r8a66597_usb_host_resources[] = {41[0] = {42.start = 0xA4200000,43.end = 0xA42000FF,44.flags = IORESOURCE_MEM,45},46[1] = {47.start = IRQ_EXT1, /* irq number */48.end = IRQ_EXT1,49.flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,50},51};5253static struct platform_device r8a66597_usb_host_device = {54.name = "r8a66597_hcd",55.id = -1,56.dev = {57.dma_mask = NULL, /* don't use dma */58.coherent_dma_mask = 0xffffffff,59.platform_data = &r8a66597_data,60},61.num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),62.resource = r8a66597_usb_host_resources,63};6465static struct m66592_platdata usbf_platdata = {66.xtal = M66592_PLATDATA_XTAL_24MHZ,67.vif = 1,68};6970static struct resource m66592_usb_peripheral_resources[] = {71[0] = {72.name = "m66592_udc",73.start = 0xb0000000,74.end = 0xb00000FF,75.flags = IORESOURCE_MEM,76},77[1] = {78.name = "m66592_udc",79.start = IRQ_EXT4, /* irq number */80.end = IRQ_EXT4,81.flags = IORESOURCE_IRQ,82},83};8485static struct platform_device m66592_usb_peripheral_device = {86.name = "m66592_udc",87.id = -1,88.dev = {89.dma_mask = NULL, /* don't use dma */90.coherent_dma_mask = 0xffffffff,91.platform_data = &usbf_platdata,92},93.num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),94.resource = m66592_usb_peripheral_resources,95};9697static struct resource cf_ide_resources[] = {98[0] = {99.start = PA_AREA5_IO + 0x1000,100.end = PA_AREA5_IO + 0x1000 + 0x08 - 1,101.flags = IORESOURCE_MEM,102},103[1] = {104.start = PA_AREA5_IO + 0x80c,105.end = PA_AREA5_IO + 0x80c + 0x16 - 1,106.flags = IORESOURCE_MEM,107},108[2] = {109.start = IRQ_CF,110.flags = IORESOURCE_IRQ,111},112};113114static struct pata_platform_info pata_info = {115.ioport_shift = 1,116};117118static struct platform_device cf_ide_device = {119.name = "pata_platform",120.id = -1,121.num_resources = ARRAY_SIZE(cf_ide_resources),122.resource = cf_ide_resources,123.dev = {124.platform_data = &pata_info,125},126};127128static struct resource heartbeat_resources[] = {129[0] = {130.start = PA_OBLED,131.end = PA_OBLED,132.flags = IORESOURCE_MEM,133},134};135136#ifndef CONFIG_SH_R7785RP137static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };138139static struct heartbeat_data heartbeat_data = {140.bit_pos = heartbeat_bit_pos,141.nr_bits = ARRAY_SIZE(heartbeat_bit_pos),142};143#endif144145static struct platform_device heartbeat_device = {146.name = "heartbeat",147.id = -1,148149/* R7785RP has a slightly more sensible FPGA.. */150#ifndef CONFIG_SH_R7785RP151.dev = {152.platform_data = &heartbeat_data,153},154#endif155.num_resources = ARRAY_SIZE(heartbeat_resources),156.resource = heartbeat_resources,157};158159static struct ax_plat_data ax88796_platdata = {160.flags = AXFLG_HAS_93CX6,161.wordlength = 2,162.dcr_val = 0x1,163.rcr_val = 0x40,164};165166static struct resource ax88796_resources[] = {167{168#ifdef CONFIG_SH_R7780RP169.start = 0xa5800400,170.end = 0xa5800400 + (0x20 * 0x2) - 1,171#else172.start = 0xa4100400,173.end = 0xa4100400 + (0x20 * 0x2) - 1,174#endif175.flags = IORESOURCE_MEM,176},177{178.start = IRQ_AX88796,179.end = IRQ_AX88796,180.flags = IORESOURCE_IRQ,181},182};183184static struct platform_device ax88796_device = {185.name = "ax88796",186.id = 0,187188.dev = {189.platform_data = &ax88796_platdata,190},191192.num_resources = ARRAY_SIZE(ax88796_resources),193.resource = ax88796_resources,194};195196static struct mtd_partition nor_flash_partitions[] = {197{198.name = "loader",199.offset = 0x00000000,200.size = 512 * 1024,201},202{203.name = "bootenv",204.offset = MTDPART_OFS_APPEND,205.size = 512 * 1024,206},207{208.name = "kernel",209.offset = MTDPART_OFS_APPEND,210.size = 4 * 1024 * 1024,211},212{213.name = "data",214.offset = MTDPART_OFS_APPEND,215.size = MTDPART_SIZ_FULL,216},217};218219static struct physmap_flash_data nor_flash_data = {220.width = 4,221.parts = nor_flash_partitions,222.nr_parts = ARRAY_SIZE(nor_flash_partitions),223};224225/* This config is flash board for mass production. */226static struct resource nor_flash_resources[] = {227[0] = {228.start = PA_NORFLASH_ADDR,229.end = PA_NORFLASH_ADDR + PA_NORFLASH_SIZE - 1,230.flags = IORESOURCE_MEM,231}232};233234static struct platform_device nor_flash_device = {235.name = "physmap-flash",236.dev = {237.platform_data = &nor_flash_data,238},239.num_resources = ARRAY_SIZE(nor_flash_resources),240.resource = nor_flash_resources,241};242243static struct resource smbus_resources[] = {244[0] = {245.start = PA_SMCR,246.end = PA_SMCR + 0x100 - 1,247.flags = IORESOURCE_MEM,248},249[1] = {250.start = IRQ_SMBUS,251.end = IRQ_SMBUS,252.flags = IORESOURCE_IRQ,253},254};255256static struct platform_device smbus_device = {257.name = "i2c-highlander",258.id = 0,259.num_resources = ARRAY_SIZE(smbus_resources),260.resource = smbus_resources,261};262263static struct i2c_board_info __initdata highlander_i2c_devices[] = {264{265I2C_BOARD_INFO("r2025sd", 0x32),266},267};268269static struct platform_device *r7780rp_devices[] __initdata = {270&r8a66597_usb_host_device,271&m66592_usb_peripheral_device,272&heartbeat_device,273&smbus_device,274&nor_flash_device,275#ifndef CONFIG_SH_R7780RP276&ax88796_device,277#endif278};279280/*281* The CF is connected using a 16-bit bus where 8-bit operations are282* unsupported. The linux ata driver is however using 8-bit operations, so283* insert a trapped io filter to convert 8-bit operations into 16-bit.284*/285static struct trapped_io cf_trapped_io = {286.resource = cf_ide_resources,287.num_resources = 2,288.minimum_bus_width = 16,289};290291static int __init r7780rp_devices_setup(void)292{293int ret = 0;294295#ifndef CONFIG_SH_R7780RP296if (register_trapped_io(&cf_trapped_io) == 0)297ret |= platform_device_register(&cf_ide_device);298#endif299300ret |= platform_add_devices(r7780rp_devices,301ARRAY_SIZE(r7780rp_devices));302303ret |= i2c_register_board_info(0, highlander_i2c_devices,304ARRAY_SIZE(highlander_i2c_devices));305306return ret;307}308device_initcall(r7780rp_devices_setup);309310/*311* Platform specific clocks312*/313static int ivdr_clk_enable(struct clk *clk)314{315__raw_writew(__raw_readw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);316return 0;317}318319static void ivdr_clk_disable(struct clk *clk)320{321__raw_writew(__raw_readw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);322}323324static struct clk_ops ivdr_clk_ops = {325.enable = ivdr_clk_enable,326.disable = ivdr_clk_disable,327};328329static struct clk ivdr_clk = {330.ops = &ivdr_clk_ops,331};332333static struct clk *r7780rp_clocks[] = {334&ivdr_clk,335};336337#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }338339static struct clk_lookup lookups[] = {340/* main clocks */341CLKDEV_CON_ID("ivdr_clk", &ivdr_clk),342};343344static void r7780rp_power_off(void)345{346if (mach_is_r7780mp() || mach_is_r7785rp())347__raw_writew(0x0001, PA_POFF);348}349350/*351* Initialize the board352*/353static void __init highlander_setup(char **cmdline_p)354{355u16 ver = __raw_readw(PA_VERREG);356int i;357358printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",359mach_is_r7780rp() ? "R7780RP-1" :360mach_is_r7780mp() ? "R7780MP" :361"R7785RP");362363printk(KERN_INFO "Board version: %d (revision %d), "364"FPGA version: %d (revision %d)\n",365(ver >> 12) & 0xf, (ver >> 8) & 0xf,366(ver >> 4) & 0xf, ver & 0xf);367368highlander_plat_pinmux_setup();369370/*371* Enable the important clocks right away..372*/373for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {374struct clk *clk = r7780rp_clocks[i];375376clk_register(clk);377clk_enable(clk);378}379380clkdev_add_table(lookups, ARRAY_SIZE(lookups));381382__raw_writew(0x0000, PA_OBLED); /* Clear LED. */383384if (mach_is_r7780rp())385__raw_writew(0x0001, PA_SDPOW); /* SD Power ON */386387__raw_writew(__raw_readw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */388389pm_power_off = r7780rp_power_off;390}391392static unsigned char irl2irq[HL_NR_IRL];393394static int highlander_irq_demux(int irq)395{396if (irq >= HL_NR_IRL || irq < 0 || !irl2irq[irq])397return irq;398399return irl2irq[irq];400}401402static void __init highlander_init_irq(void)403{404unsigned char *ucp = highlander_plat_irq_setup();405406if (ucp) {407plat_irq_setup_pins(IRQ_MODE_IRL3210);408memcpy(irl2irq, ucp, HL_NR_IRL);409}410}411412/*413* The Machine Vector414*/415static struct sh_machine_vector mv_highlander __initmv = {416.mv_name = "Highlander",417.mv_setup = highlander_setup,418.mv_init_irq = highlander_init_irq,419.mv_irq_demux = highlander_irq_demux,420};421422423