Path: blob/master/arch/sh/boards/mach-highlander/setup.c
26535 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/boards/renesas/r7780rp/setup.c3*4* Renesas Solutions Highlander Support.5*6* Copyright (C) 2002 Atom Create Engineering Co., Ltd.7* Copyright (C) 2005 - 2008 Paul Mundt8*9* This contains support for the R7780RP-1, R7780MP, and R7785RP10* Highlander modules.11*/12#include <linux/init.h>13#include <linux/io.h>14#include <linux/platform_device.h>15#include <linux/ata_platform.h>16#include <linux/types.h>17#include <linux/mtd/physmap.h>18#include <linux/i2c.h>19#include <linux/irq.h>20#include <linux/interrupt.h>21#include <linux/usb/r8a66597.h>22#include <linux/usb/m66592.h>23#include <linux/clkdev.h>24#include <net/ax88796.h>25#include <asm/machvec.h>26#include <mach/highlander.h>27#include <asm/clock.h>28#include <asm/heartbeat.h>29#include <asm/io.h>30#include <asm/io_trapped.h>3132static struct r8a66597_platdata r8a66597_data = {33.xtal = R8A66597_PLATDATA_XTAL_12MHZ,34.vif = 1,35};3637static struct resource r8a66597_usb_host_resources[] = {38[0] = {39.start = 0xA4200000,40.end = 0xA42000FF,41.flags = IORESOURCE_MEM,42},43[1] = {44.start = IRQ_EXT1, /* irq number */45.end = IRQ_EXT1,46.flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,47},48};4950static struct platform_device r8a66597_usb_host_device = {51.name = "r8a66597_hcd",52.id = -1,53.dev = {54.dma_mask = NULL, /* don't use dma */55.coherent_dma_mask = 0xffffffff,56.platform_data = &r8a66597_data,57},58.num_resources = ARRAY_SIZE(r8a66597_usb_host_resources),59.resource = r8a66597_usb_host_resources,60};6162static struct m66592_platdata usbf_platdata = {63.xtal = M66592_PLATDATA_XTAL_24MHZ,64.vif = 1,65};6667static struct resource m66592_usb_peripheral_resources[] = {68[0] = {69.name = "m66592_udc",70.start = 0xb0000000,71.end = 0xb00000FF,72.flags = IORESOURCE_MEM,73},74[1] = {75.name = "m66592_udc",76.start = IRQ_EXT4, /* irq number */77.end = IRQ_EXT4,78.flags = IORESOURCE_IRQ,79},80};8182static struct platform_device m66592_usb_peripheral_device = {83.name = "m66592_udc",84.id = -1,85.dev = {86.dma_mask = NULL, /* don't use dma */87.coherent_dma_mask = 0xffffffff,88.platform_data = &usbf_platdata,89},90.num_resources = ARRAY_SIZE(m66592_usb_peripheral_resources),91.resource = m66592_usb_peripheral_resources,92};9394static struct resource cf_ide_resources[] = {95[0] = {96.start = PA_AREA5_IO + 0x1000,97.end = PA_AREA5_IO + 0x1000 + 0x08 - 1,98.flags = IORESOURCE_MEM,99},100[1] = {101.start = PA_AREA5_IO + 0x80c,102.end = PA_AREA5_IO + 0x80c + 0x16 - 1,103.flags = IORESOURCE_MEM,104},105[2] = {106.start = IRQ_CF,107.flags = IORESOURCE_IRQ,108},109};110111static struct pata_platform_info pata_info = {112.ioport_shift = 1,113};114115static struct platform_device cf_ide_device = {116.name = "pata_platform",117.id = -1,118.num_resources = ARRAY_SIZE(cf_ide_resources),119.resource = cf_ide_resources,120.dev = {121.platform_data = &pata_info,122},123};124125static struct resource heartbeat_resources[] = {126[0] = {127.start = PA_OBLED,128.end = PA_OBLED,129.flags = IORESOURCE_MEM,130},131};132133#ifndef CONFIG_SH_R7785RP134static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };135136static struct heartbeat_data heartbeat_data = {137.bit_pos = heartbeat_bit_pos,138.nr_bits = ARRAY_SIZE(heartbeat_bit_pos),139};140#endif141142static struct platform_device heartbeat_device = {143.name = "heartbeat",144.id = -1,145146/* R7785RP has a slightly more sensible FPGA.. */147#ifndef CONFIG_SH_R7785RP148.dev = {149.platform_data = &heartbeat_data,150},151#endif152.num_resources = ARRAY_SIZE(heartbeat_resources),153.resource = heartbeat_resources,154};155156static struct ax_plat_data ax88796_platdata = {157.flags = AXFLG_HAS_93CX6,158.wordlength = 2,159.dcr_val = 0x1,160.rcr_val = 0x40,161};162163static struct resource ax88796_resources[] = {164{165#ifdef CONFIG_SH_R7780RP166.start = 0xa5800400,167.end = 0xa5800400 + (0x20 * 0x2) - 1,168#else169.start = 0xa4100400,170.end = 0xa4100400 + (0x20 * 0x2) - 1,171#endif172.flags = IORESOURCE_MEM,173},174{175.start = IRQ_AX88796,176.end = IRQ_AX88796,177.flags = IORESOURCE_IRQ,178},179};180181static struct platform_device ax88796_device = {182.name = "ax88796",183.id = 0,184185.dev = {186.platform_data = &ax88796_platdata,187},188189.num_resources = ARRAY_SIZE(ax88796_resources),190.resource = ax88796_resources,191};192193static struct mtd_partition nor_flash_partitions[] = {194{195.name = "loader",196.offset = 0x00000000,197.size = 512 * 1024,198},199{200.name = "bootenv",201.offset = MTDPART_OFS_APPEND,202.size = 512 * 1024,203},204{205.name = "kernel",206.offset = MTDPART_OFS_APPEND,207.size = 4 * 1024 * 1024,208},209{210.name = "data",211.offset = MTDPART_OFS_APPEND,212.size = MTDPART_SIZ_FULL,213},214};215216static struct physmap_flash_data nor_flash_data = {217.width = 4,218.parts = nor_flash_partitions,219.nr_parts = ARRAY_SIZE(nor_flash_partitions),220};221222/* This config is flash board for mass production. */223static struct resource nor_flash_resources[] = {224[0] = {225.start = PA_NORFLASH_ADDR,226.end = PA_NORFLASH_ADDR + PA_NORFLASH_SIZE - 1,227.flags = IORESOURCE_MEM,228}229};230231static struct platform_device nor_flash_device = {232.name = "physmap-flash",233.dev = {234.platform_data = &nor_flash_data,235},236.num_resources = ARRAY_SIZE(nor_flash_resources),237.resource = nor_flash_resources,238};239240static struct resource smbus_resources[] = {241[0] = {242.start = PA_SMCR,243.end = PA_SMCR + 0x100 - 1,244.flags = IORESOURCE_MEM,245},246[1] = {247.start = IRQ_SMBUS,248.end = IRQ_SMBUS,249.flags = IORESOURCE_IRQ,250},251};252253static struct platform_device smbus_device = {254.name = "i2c-highlander",255.id = 0,256.num_resources = ARRAY_SIZE(smbus_resources),257.resource = smbus_resources,258};259260static struct i2c_board_info __initdata highlander_i2c_devices[] = {261{262I2C_BOARD_INFO("r2025sd", 0x32),263},264};265266static struct platform_device *r7780rp_devices[] __initdata = {267&r8a66597_usb_host_device,268&m66592_usb_peripheral_device,269&heartbeat_device,270&smbus_device,271&nor_flash_device,272#ifndef CONFIG_SH_R7780RP273&ax88796_device,274#endif275};276277/*278* The CF is connected using a 16-bit bus where 8-bit operations are279* unsupported. The linux ata driver is however using 8-bit operations, so280* insert a trapped io filter to convert 8-bit operations into 16-bit.281*/282static struct trapped_io cf_trapped_io = {283.resource = cf_ide_resources,284.num_resources = 2,285.minimum_bus_width = 16,286};287288static int __init r7780rp_devices_setup(void)289{290int ret = 0;291292#ifndef CONFIG_SH_R7780RP293if (register_trapped_io(&cf_trapped_io) == 0)294ret |= platform_device_register(&cf_ide_device);295#endif296297ret |= platform_add_devices(r7780rp_devices,298ARRAY_SIZE(r7780rp_devices));299300ret |= i2c_register_board_info(0, highlander_i2c_devices,301ARRAY_SIZE(highlander_i2c_devices));302303return ret;304}305device_initcall(r7780rp_devices_setup);306307/*308* Platform specific clocks309*/310static int ivdr_clk_enable(struct clk *clk)311{312__raw_writew(__raw_readw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);313return 0;314}315316static void ivdr_clk_disable(struct clk *clk)317{318__raw_writew(__raw_readw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);319}320321static struct sh_clk_ops ivdr_clk_ops = {322.enable = ivdr_clk_enable,323.disable = ivdr_clk_disable,324};325326static struct clk ivdr_clk = {327.ops = &ivdr_clk_ops,328};329330static struct clk *r7780rp_clocks[] = {331&ivdr_clk,332};333334static struct clk_lookup lookups[] = {335/* main clocks */336CLKDEV_CON_ID("ivdr_clk", &ivdr_clk),337};338339static void r7780rp_power_off(void)340{341if (mach_is_r7780mp() || mach_is_r7785rp())342__raw_writew(0x0001, PA_POFF);343}344345/*346* Initialize the board347*/348static void __init highlander_setup(char **cmdline_p)349{350u16 ver = __raw_readw(PA_VERREG);351int i;352353printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",354mach_is_r7780rp() ? "R7780RP-1" :355mach_is_r7780mp() ? "R7780MP" :356"R7785RP");357358printk(KERN_INFO "Board version: %d (revision %d), "359"FPGA version: %d (revision %d)\n",360(ver >> 12) & 0xf, (ver >> 8) & 0xf,361(ver >> 4) & 0xf, ver & 0xf);362363highlander_plat_pinmux_setup();364365/*366* Enable the important clocks right away..367*/368for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {369struct clk *clk = r7780rp_clocks[i];370371clk_register(clk);372clk_enable(clk);373}374375clkdev_add_table(lookups, ARRAY_SIZE(lookups));376377__raw_writew(0x0000, PA_OBLED); /* Clear LED. */378379if (mach_is_r7780rp())380__raw_writew(0x0001, PA_SDPOW); /* SD Power ON */381382__raw_writew(__raw_readw(PA_IVDRCTL) | 0x01, PA_IVDRCTL); /* Si13112 */383384pm_power_off = r7780rp_power_off;385}386387static unsigned char irl2irq[HL_NR_IRL];388389static int highlander_irq_demux(int irq)390{391if (irq >= HL_NR_IRL + 16 || irq < 16 || !irl2irq[irq - 16])392return irq;393394return irl2irq[irq - 16];395}396397static void __init highlander_init_irq(void)398{399unsigned char *ucp = highlander_plat_irq_setup();400401if (ucp) {402plat_irq_setup_pins(IRQ_MODE_IRL3210);403memcpy(irl2irq, ucp, HL_NR_IRL);404}405}406407/*408* The Machine Vector409*/410static struct sh_machine_vector mv_highlander __initmv = {411.mv_name = "Highlander",412.mv_setup = highlander_setup,413.mv_init_irq = highlander_init_irq,414.mv_irq_demux = highlander_irq_demux,415};416417418