| Luca Santini | 3db9170 | 2008-09-08 12:01:15 +0900 | [diff] [blame] | 1 | /* | 
|  | 2 | * Renesas Europe EDOSK7760 Board Support | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 2008 SPES Societa' Progettazione Elettronica e Software Ltd. | 
|  | 5 | * Author: Luca Santini <luca.santini@spesonline.com> | 
|  | 6 | * | 
|  | 7 | * This program is free software; you can redistribute it and/or modify | 
|  | 8 | * it under the terms of the GNU General Public License as published by | 
|  | 9 | * the Free Software Foundation; either version 2 of the License, or | 
|  | 10 | * (at your option) any later version. | 
|  | 11 | * | 
|  | 12 | * This program is distributed in the hope that it will be useful, | 
|  | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 15 | * GNU General Public License for more details. | 
|  | 16 | * | 
|  | 17 | * You should have received a copy of the GNU General Public License | 
|  | 18 | * along with this program; if not, write to the Free Software | 
|  | 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
|  | 20 | */ | 
|  | 21 | #include <linux/init.h> | 
|  | 22 | #include <linux/types.h> | 
|  | 23 | #include <linux/platform_device.h> | 
|  | 24 | #include <linux/smc91x.h> | 
|  | 25 | #include <linux/interrupt.h> | 
|  | 26 | #include <linux/i2c.h> | 
| Luca Santini | 4018ffc | 2008-09-12 18:07:16 +0900 | [diff] [blame] | 27 | #include <linux/mtd/physmap.h> | 
| Luca Santini | 3db9170 | 2008-09-08 12:01:15 +0900 | [diff] [blame] | 28 | #include <asm/machvec.h> | 
|  | 29 | #include <asm/io.h> | 
|  | 30 | #include <asm/addrspace.h> | 
|  | 31 | #include <asm/delay.h> | 
|  | 32 | #include <asm/i2c-sh7760.h> | 
| Luca Santini | 347cd34 | 2008-09-21 10:32:29 +0900 | [diff] [blame] | 33 | #include <asm/sizes.h> | 
| Luca Santini | 3db9170 | 2008-09-08 12:01:15 +0900 | [diff] [blame] | 34 |  | 
|  | 35 | /* Bus state controller registers for CS4 area */ | 
|  | 36 | #define BSC_CS4BCR	0xA4FD0010 | 
|  | 37 | #define BSC_CS4WCR	0xA4FD0030 | 
|  | 38 |  | 
|  | 39 | #define SMC_IOBASE	0xA2000000 | 
|  | 40 | #define SMC_IO_OFFSET	0x300 | 
|  | 41 | #define SMC_IOADDR	(SMC_IOBASE + SMC_IO_OFFSET) | 
|  | 42 |  | 
|  | 43 | #define ETHERNET_IRQ	5 | 
|  | 44 |  | 
| Luca Santini | 4018ffc | 2008-09-12 18:07:16 +0900 | [diff] [blame] | 45 | /* NOR flash */ | 
|  | 46 | static struct mtd_partition edosk7760_nor_flash_partitions[] = { | 
|  | 47 | { | 
|  | 48 | .name = "bootloader", | 
|  | 49 | .offset = 0, | 
| Luca Santini | 347cd34 | 2008-09-21 10:32:29 +0900 | [diff] [blame] | 50 | .size = SZ_256K, | 
| Luca Santini | 4018ffc | 2008-09-12 18:07:16 +0900 | [diff] [blame] | 51 | .mask_flags = MTD_WRITEABLE,	/* Read-only */ | 
|  | 52 | }, { | 
|  | 53 | .name = "kernel", | 
|  | 54 | .offset = MTDPART_OFS_APPEND, | 
| Luca Santini | 347cd34 | 2008-09-21 10:32:29 +0900 | [diff] [blame] | 55 | .size = SZ_2M, | 
| Luca Santini | 4018ffc | 2008-09-12 18:07:16 +0900 | [diff] [blame] | 56 | }, { | 
|  | 57 | .name = "fs", | 
|  | 58 | .offset = MTDPART_OFS_APPEND, | 
| Paul Mundt | f47adbb | 2011-03-22 22:43:09 +0900 | [diff] [blame] | 59 | .size = (26 << 20), | 
| Luca Santini | 4018ffc | 2008-09-12 18:07:16 +0900 | [diff] [blame] | 60 | }, { | 
|  | 61 | .name = "other", | 
|  | 62 | .offset = MTDPART_OFS_APPEND, | 
|  | 63 | .size = MTDPART_SIZ_FULL, | 
|  | 64 | }, | 
|  | 65 | }; | 
|  | 66 |  | 
|  | 67 | static struct physmap_flash_data edosk7760_nor_flash_data = { | 
|  | 68 | .width		= 4, | 
|  | 69 | .parts		= edosk7760_nor_flash_partitions, | 
|  | 70 | .nr_parts	= ARRAY_SIZE(edosk7760_nor_flash_partitions), | 
|  | 71 | }; | 
|  | 72 |  | 
|  | 73 | static struct resource edosk7760_nor_flash_resources[] = { | 
|  | 74 | [0] = { | 
|  | 75 | .name	= "NOR Flash", | 
|  | 76 | .start	= 0x00000000, | 
| Luca Santini | 347cd34 | 2008-09-21 10:32:29 +0900 | [diff] [blame] | 77 | .end	= 0x00000000 + SZ_32M - 1, | 
| Luca Santini | 4018ffc | 2008-09-12 18:07:16 +0900 | [diff] [blame] | 78 | .flags	= IORESOURCE_MEM, | 
|  | 79 | } | 
|  | 80 | }; | 
|  | 81 |  | 
|  | 82 | static struct platform_device edosk7760_nor_flash_device = { | 
|  | 83 | .name		= "physmap-flash", | 
|  | 84 | .resource	= edosk7760_nor_flash_resources, | 
|  | 85 | .num_resources	= ARRAY_SIZE(edosk7760_nor_flash_resources), | 
|  | 86 | .dev		= { | 
|  | 87 | .platform_data = &edosk7760_nor_flash_data, | 
|  | 88 | }, | 
|  | 89 | }; | 
|  | 90 |  | 
| Luca Santini | 3db9170 | 2008-09-08 12:01:15 +0900 | [diff] [blame] | 91 | /* i2c initialization functions */ | 
|  | 92 | static struct sh7760_i2c_platdata i2c_pd = { | 
|  | 93 | .speed_khz	= 400, | 
|  | 94 | }; | 
|  | 95 |  | 
|  | 96 | static struct resource sh7760_i2c1_res[] = { | 
|  | 97 | { | 
|  | 98 | .start	= SH7760_I2C1_MMIO, | 
|  | 99 | .end	= SH7760_I2C1_MMIOEND, | 
|  | 100 | .flags	= IORESOURCE_MEM, | 
|  | 101 | },{ | 
|  | 102 | .start	= SH7760_I2C1_IRQ, | 
|  | 103 | .end	= SH7760_I2C1_IRQ, | 
|  | 104 | .flags	= IORESOURCE_IRQ, | 
|  | 105 | }, | 
|  | 106 | }; | 
|  | 107 |  | 
|  | 108 | static struct platform_device sh7760_i2c1_dev = { | 
|  | 109 | .dev    = { | 
|  | 110 | .platform_data	= &i2c_pd, | 
|  | 111 | }, | 
|  | 112 |  | 
|  | 113 | .name		= SH7760_I2C_DEVNAME, | 
|  | 114 | .id		= 1, | 
|  | 115 | .resource	= sh7760_i2c1_res, | 
|  | 116 | .num_resources	= ARRAY_SIZE(sh7760_i2c1_res), | 
|  | 117 | }; | 
|  | 118 |  | 
|  | 119 | static struct resource sh7760_i2c0_res[] = { | 
|  | 120 | { | 
|  | 121 | .start	= SH7760_I2C0_MMIO, | 
|  | 122 | .end	= SH7760_I2C0_MMIOEND, | 
|  | 123 | .flags	= IORESOURCE_MEM, | 
|  | 124 | }, { | 
|  | 125 | .start	= SH7760_I2C0_IRQ, | 
|  | 126 | .end	= SH7760_I2C0_IRQ, | 
|  | 127 | .flags	= IORESOURCE_IRQ, | 
|  | 128 | }, | 
|  | 129 | }; | 
|  | 130 |  | 
|  | 131 | static struct platform_device sh7760_i2c0_dev = { | 
|  | 132 | .dev    = { | 
|  | 133 | .platform_data	= &i2c_pd, | 
|  | 134 | }, | 
|  | 135 | .name		= SH7760_I2C_DEVNAME, | 
|  | 136 | .id		= 0, | 
|  | 137 | .resource	= sh7760_i2c0_res, | 
|  | 138 | .num_resources	= ARRAY_SIZE(sh7760_i2c0_res), | 
|  | 139 | }; | 
|  | 140 |  | 
|  | 141 | /* eth initialization functions */ | 
|  | 142 | static struct smc91x_platdata smc91x_info = { | 
|  | 143 | .flags = SMC91X_USE_16BIT | SMC91X_IO_SHIFT_1 | IORESOURCE_IRQ_LOWLEVEL, | 
|  | 144 | }; | 
|  | 145 |  | 
|  | 146 | static struct resource smc91x_res[] = { | 
|  | 147 | [0] = { | 
|  | 148 | .start	= SMC_IOADDR, | 
| Luca Santini | 347cd34 | 2008-09-21 10:32:29 +0900 | [diff] [blame] | 149 | .end	= SMC_IOADDR + SZ_32 - 1, | 
| Luca Santini | 3db9170 | 2008-09-08 12:01:15 +0900 | [diff] [blame] | 150 | .flags	= IORESOURCE_MEM, | 
|  | 151 | }, | 
|  | 152 | [1] = { | 
|  | 153 | .start	= ETHERNET_IRQ, | 
|  | 154 | .end	= ETHERNET_IRQ, | 
|  | 155 | .flags	= IORESOURCE_IRQ , | 
|  | 156 | } | 
|  | 157 | }; | 
|  | 158 |  | 
|  | 159 | static struct platform_device smc91x_dev = { | 
|  | 160 | .name		= "smc91x", | 
|  | 161 | .id		= -1, | 
|  | 162 | .num_resources	= ARRAY_SIZE(smc91x_res), | 
|  | 163 | .resource	= smc91x_res, | 
|  | 164 |  | 
|  | 165 | .dev	= { | 
|  | 166 | .platform_data	= &smc91x_info, | 
|  | 167 | }, | 
|  | 168 | }; | 
|  | 169 |  | 
|  | 170 | /* platform init code */ | 
|  | 171 | static struct platform_device *edosk7760_devices[] __initdata = { | 
| Luca Santini | 4018ffc | 2008-09-12 18:07:16 +0900 | [diff] [blame] | 172 | &smc91x_dev, | 
|  | 173 | &edosk7760_nor_flash_device, | 
| Luca Santini | 3db9170 | 2008-09-08 12:01:15 +0900 | [diff] [blame] | 174 | &sh7760_i2c0_dev, | 
|  | 175 | &sh7760_i2c1_dev, | 
| Luca Santini | 3db9170 | 2008-09-08 12:01:15 +0900 | [diff] [blame] | 176 | }; | 
|  | 177 |  | 
|  | 178 | static int __init init_edosk7760_devices(void) | 
|  | 179 | { | 
|  | 180 | plat_irq_setup_pins(IRQ_MODE_IRQ); | 
|  | 181 |  | 
|  | 182 | return platform_add_devices(edosk7760_devices, | 
|  | 183 | ARRAY_SIZE(edosk7760_devices)); | 
|  | 184 | } | 
| Nobuhiro Iwamatsu | 95d210c | 2011-01-07 03:02:15 +0000 | [diff] [blame] | 185 | device_initcall(init_edosk7760_devices); | 
| Luca Santini | 3db9170 | 2008-09-08 12:01:15 +0900 | [diff] [blame] | 186 |  | 
|  | 187 | /* | 
|  | 188 | * The Machine Vector | 
|  | 189 | */ | 
|  | 190 | struct sh_machine_vector mv_edosk7760 __initmv = { | 
|  | 191 | .mv_name	= "EDOSK7760", | 
|  | 192 | .mv_nr_irqs	= 128, | 
|  | 193 | }; |