xref: /linux/arch/sh/boards/board-edosk7760.c (revision c39f2d9db0fd81ea20bb5cce9b3f082ca63753e2)
1aaf9128aSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0+
23db91708SLuca Santini /*
33db91708SLuca Santini  * Renesas Europe EDOSK7760 Board Support
43db91708SLuca Santini  *
53db91708SLuca Santini  * Copyright (C) 2008 SPES Societa' Progettazione Elettronica e Software Ltd.
63db91708SLuca Santini  * Author: Luca Santini <luca.santini@spesonline.com>
73db91708SLuca Santini  */
83db91708SLuca Santini #include <linux/init.h>
93db91708SLuca Santini #include <linux/types.h>
103db91708SLuca Santini #include <linux/platform_device.h>
113db91708SLuca Santini #include <linux/smc91x.h>
123db91708SLuca Santini #include <linux/interrupt.h>
1303c5713cSPaul Mundt #include <linux/sh_intc.h>
143db91708SLuca Santini #include <linux/i2c.h>
154018ffcfSLuca Santini #include <linux/mtd/physmap.h>
163db91708SLuca Santini #include <asm/machvec.h>
173db91708SLuca Santini #include <asm/io.h>
183db91708SLuca Santini #include <asm/addrspace.h>
193db91708SLuca Santini #include <asm/delay.h>
203db91708SLuca Santini #include <asm/i2c-sh7760.h>
21*87dfb311SMasahiro Yamada #include <linux/sizes.h>
223db91708SLuca Santini 
233db91708SLuca Santini /* Bus state controller registers for CS4 area */
243db91708SLuca Santini #define BSC_CS4BCR	0xA4FD0010
253db91708SLuca Santini #define BSC_CS4WCR	0xA4FD0030
263db91708SLuca Santini 
273db91708SLuca Santini #define SMC_IOBASE	0xA2000000
283db91708SLuca Santini #define SMC_IO_OFFSET	0x300
293db91708SLuca Santini #define SMC_IOADDR	(SMC_IOBASE + SMC_IO_OFFSET)
303db91708SLuca Santini 
314018ffcfSLuca Santini /* NOR flash */
324018ffcfSLuca Santini static struct mtd_partition edosk7760_nor_flash_partitions[] = {
334018ffcfSLuca Santini 	{
344018ffcfSLuca Santini 		.name = "bootloader",
354018ffcfSLuca Santini 		.offset = 0,
36347cd34fSLuca Santini 		.size = SZ_256K,
374018ffcfSLuca Santini 		.mask_flags = MTD_WRITEABLE,	/* Read-only */
384018ffcfSLuca Santini 	}, {
394018ffcfSLuca Santini 		.name = "kernel",
404018ffcfSLuca Santini 		.offset = MTDPART_OFS_APPEND,
41347cd34fSLuca Santini 		.size = SZ_2M,
424018ffcfSLuca Santini 	}, {
434018ffcfSLuca Santini 		.name = "fs",
444018ffcfSLuca Santini 		.offset = MTDPART_OFS_APPEND,
45f47adbb9SPaul Mundt 		.size = (26 << 20),
464018ffcfSLuca Santini 	}, {
474018ffcfSLuca Santini 		.name = "other",
484018ffcfSLuca Santini 		.offset = MTDPART_OFS_APPEND,
494018ffcfSLuca Santini 		.size = MTDPART_SIZ_FULL,
504018ffcfSLuca Santini 	},
514018ffcfSLuca Santini };
524018ffcfSLuca Santini 
534018ffcfSLuca Santini static struct physmap_flash_data edosk7760_nor_flash_data = {
544018ffcfSLuca Santini 	.width		= 4,
554018ffcfSLuca Santini 	.parts		= edosk7760_nor_flash_partitions,
564018ffcfSLuca Santini 	.nr_parts	= ARRAY_SIZE(edosk7760_nor_flash_partitions),
574018ffcfSLuca Santini };
584018ffcfSLuca Santini 
594018ffcfSLuca Santini static struct resource edosk7760_nor_flash_resources[] = {
604018ffcfSLuca Santini 	[0] = {
614018ffcfSLuca Santini 		.name	= "NOR Flash",
624018ffcfSLuca Santini 		.start	= 0x00000000,
63347cd34fSLuca Santini 		.end	= 0x00000000 + SZ_32M - 1,
644018ffcfSLuca Santini 		.flags	= IORESOURCE_MEM,
654018ffcfSLuca Santini 	}
664018ffcfSLuca Santini };
674018ffcfSLuca Santini 
684018ffcfSLuca Santini static struct platform_device edosk7760_nor_flash_device = {
694018ffcfSLuca Santini 	.name		= "physmap-flash",
704018ffcfSLuca Santini 	.resource	= edosk7760_nor_flash_resources,
714018ffcfSLuca Santini 	.num_resources	= ARRAY_SIZE(edosk7760_nor_flash_resources),
724018ffcfSLuca Santini 	.dev		= {
734018ffcfSLuca Santini 		.platform_data = &edosk7760_nor_flash_data,
744018ffcfSLuca Santini 	},
754018ffcfSLuca Santini };
764018ffcfSLuca Santini 
773db91708SLuca Santini /* i2c initialization functions */
783db91708SLuca Santini static struct sh7760_i2c_platdata i2c_pd = {
793db91708SLuca Santini 	.speed_khz	= 400,
803db91708SLuca Santini };
813db91708SLuca Santini 
823db91708SLuca Santini static struct resource sh7760_i2c1_res[] = {
833db91708SLuca Santini 	{
843db91708SLuca Santini 		.start	= SH7760_I2C1_MMIO,
853db91708SLuca Santini 		.end	= SH7760_I2C1_MMIOEND,
863db91708SLuca Santini 		.flags	= IORESOURCE_MEM,
873db91708SLuca Santini 	},{
8803c5713cSPaul Mundt 		.start	= evt2irq(0x9e0),
8903c5713cSPaul Mundt 		.end	= evt2irq(0x9e0),
903db91708SLuca Santini 		.flags	= IORESOURCE_IRQ,
913db91708SLuca Santini 	},
923db91708SLuca Santini };
933db91708SLuca Santini 
943db91708SLuca Santini static struct platform_device sh7760_i2c1_dev = {
953db91708SLuca Santini 	.dev    = {
963db91708SLuca Santini 		.platform_data	= &i2c_pd,
973db91708SLuca Santini 	},
983db91708SLuca Santini 
993db91708SLuca Santini 	.name		= SH7760_I2C_DEVNAME,
1003db91708SLuca Santini 	.id		= 1,
1013db91708SLuca Santini 	.resource	= sh7760_i2c1_res,
1023db91708SLuca Santini 	.num_resources	= ARRAY_SIZE(sh7760_i2c1_res),
1033db91708SLuca Santini };
1043db91708SLuca Santini 
1053db91708SLuca Santini static struct resource sh7760_i2c0_res[] = {
1063db91708SLuca Santini 	{
1073db91708SLuca Santini 		.start	= SH7760_I2C0_MMIO,
1083db91708SLuca Santini 		.end	= SH7760_I2C0_MMIOEND,
1093db91708SLuca Santini 		.flags	= IORESOURCE_MEM,
1103db91708SLuca Santini 	}, {
11103c5713cSPaul Mundt 		.start	= evt2irq(0x9c0),
11203c5713cSPaul Mundt 		.end	= evt2irq(0x9c0),
1133db91708SLuca Santini 		.flags	= IORESOURCE_IRQ,
1143db91708SLuca Santini 	},
1153db91708SLuca Santini };
1163db91708SLuca Santini 
1173db91708SLuca Santini static struct platform_device sh7760_i2c0_dev = {
1183db91708SLuca Santini 	.dev    = {
1193db91708SLuca Santini 		.platform_data	= &i2c_pd,
1203db91708SLuca Santini 	},
1213db91708SLuca Santini 	.name		= SH7760_I2C_DEVNAME,
1223db91708SLuca Santini 	.id		= 0,
1233db91708SLuca Santini 	.resource	= sh7760_i2c0_res,
1243db91708SLuca Santini 	.num_resources	= ARRAY_SIZE(sh7760_i2c0_res),
1253db91708SLuca Santini };
1263db91708SLuca Santini 
1273db91708SLuca Santini /* eth initialization functions */
1283db91708SLuca Santini static struct smc91x_platdata smc91x_info = {
1293db91708SLuca Santini 	.flags = SMC91X_USE_16BIT | SMC91X_IO_SHIFT_1 | IORESOURCE_IRQ_LOWLEVEL,
1303db91708SLuca Santini };
1313db91708SLuca Santini 
1323db91708SLuca Santini static struct resource smc91x_res[] = {
1333db91708SLuca Santini 	[0] = {
1343db91708SLuca Santini 		.start	= SMC_IOADDR,
135347cd34fSLuca Santini 		.end	= SMC_IOADDR + SZ_32 - 1,
1363db91708SLuca Santini 		.flags	= IORESOURCE_MEM,
1373db91708SLuca Santini 	},
1383db91708SLuca Santini 	[1] = {
13903c5713cSPaul Mundt 		.start	= evt2irq(0x2a0),
14003c5713cSPaul Mundt 		.end	= evt2irq(0x2a0),
1413db91708SLuca Santini 		.flags	= IORESOURCE_IRQ ,
1423db91708SLuca Santini 	}
1433db91708SLuca Santini };
1443db91708SLuca Santini 
1453db91708SLuca Santini static struct platform_device smc91x_dev = {
1463db91708SLuca Santini 	.name		= "smc91x",
1473db91708SLuca Santini 	.id		= -1,
1483db91708SLuca Santini 	.num_resources	= ARRAY_SIZE(smc91x_res),
1493db91708SLuca Santini 	.resource	= smc91x_res,
1503db91708SLuca Santini 
1513db91708SLuca Santini 	.dev	= {
1523db91708SLuca Santini 		.platform_data	= &smc91x_info,
1533db91708SLuca Santini 	},
1543db91708SLuca Santini };
1553db91708SLuca Santini 
1563db91708SLuca Santini /* platform init code */
1573db91708SLuca Santini static struct platform_device *edosk7760_devices[] __initdata = {
1584018ffcfSLuca Santini 	&smc91x_dev,
1594018ffcfSLuca Santini 	&edosk7760_nor_flash_device,
1603db91708SLuca Santini 	&sh7760_i2c0_dev,
1613db91708SLuca Santini 	&sh7760_i2c1_dev,
1623db91708SLuca Santini };
1633db91708SLuca Santini 
init_edosk7760_devices(void)1643db91708SLuca Santini static int __init init_edosk7760_devices(void)
1653db91708SLuca Santini {
1663db91708SLuca Santini 	plat_irq_setup_pins(IRQ_MODE_IRQ);
1673db91708SLuca Santini 
1683db91708SLuca Santini 	return platform_add_devices(edosk7760_devices,
1693db91708SLuca Santini 				    ARRAY_SIZE(edosk7760_devices));
1703db91708SLuca Santini }
17195d210ceSNobuhiro Iwamatsu device_initcall(init_edosk7760_devices);
1723db91708SLuca Santini 
1733db91708SLuca Santini /*
1743db91708SLuca Santini  * The Machine Vector
1753db91708SLuca Santini  */
1763db91708SLuca Santini struct sh_machine_vector mv_edosk7760 __initmv = {
1773db91708SLuca Santini 	.mv_name	= "EDOSK7760",
1783db91708SLuca Santini };
179