Commit | Line | Data |
---|---|---|
aaf9128a | 1 | // SPDX-License-Identifier: GPL-2.0+ |
3db91708 LS |
2 | /* |
3 | * Renesas Europe EDOSK7760 Board Support | |
4 | * | |
5 | * Copyright (C) 2008 SPES Societa' Progettazione Elettronica e Software Ltd. | |
6 | * Author: Luca Santini <luca.santini@spesonline.com> | |
3db91708 LS |
7 | */ |
8 | #include <linux/init.h> | |
9 | #include <linux/types.h> | |
10 | #include <linux/platform_device.h> | |
11 | #include <linux/smc91x.h> | |
12 | #include <linux/interrupt.h> | |
03c5713c | 13 | #include <linux/sh_intc.h> |
3db91708 | 14 | #include <linux/i2c.h> |
4018ffcf | 15 | #include <linux/mtd/physmap.h> |
3db91708 LS |
16 | #include <asm/machvec.h> |
17 | #include <asm/io.h> | |
18 | #include <asm/addrspace.h> | |
19 | #include <asm/delay.h> | |
20 | #include <asm/i2c-sh7760.h> | |
87dfb311 | 21 | #include <linux/sizes.h> |
3db91708 LS |
22 | |
23 | /* Bus state controller registers for CS4 area */ | |
24 | #define BSC_CS4BCR 0xA4FD0010 | |
25 | #define BSC_CS4WCR 0xA4FD0030 | |
26 | ||
27 | #define SMC_IOBASE 0xA2000000 | |
28 | #define SMC_IO_OFFSET 0x300 | |
29 | #define SMC_IOADDR (SMC_IOBASE + SMC_IO_OFFSET) | |
30 | ||
4018ffcf LS |
31 | /* NOR flash */ |
32 | static struct mtd_partition edosk7760_nor_flash_partitions[] = { | |
33 | { | |
34 | .name = "bootloader", | |
35 | .offset = 0, | |
347cd34f | 36 | .size = SZ_256K, |
4018ffcf LS |
37 | .mask_flags = MTD_WRITEABLE, /* Read-only */ |
38 | }, { | |
39 | .name = "kernel", | |
40 | .offset = MTDPART_OFS_APPEND, | |
347cd34f | 41 | .size = SZ_2M, |
4018ffcf LS |
42 | }, { |
43 | .name = "fs", | |
44 | .offset = MTDPART_OFS_APPEND, | |
f47adbb9 | 45 | .size = (26 << 20), |
4018ffcf LS |
46 | }, { |
47 | .name = "other", | |
48 | .offset = MTDPART_OFS_APPEND, | |
49 | .size = MTDPART_SIZ_FULL, | |
50 | }, | |
51 | }; | |
52 | ||
53 | static struct physmap_flash_data edosk7760_nor_flash_data = { | |
54 | .width = 4, | |
55 | .parts = edosk7760_nor_flash_partitions, | |
56 | .nr_parts = ARRAY_SIZE(edosk7760_nor_flash_partitions), | |
57 | }; | |
58 | ||
59 | static struct resource edosk7760_nor_flash_resources[] = { | |
60 | [0] = { | |
61 | .name = "NOR Flash", | |
62 | .start = 0x00000000, | |
347cd34f | 63 | .end = 0x00000000 + SZ_32M - 1, |
4018ffcf LS |
64 | .flags = IORESOURCE_MEM, |
65 | } | |
66 | }; | |
67 | ||
68 | static struct platform_device edosk7760_nor_flash_device = { | |
69 | .name = "physmap-flash", | |
70 | .resource = edosk7760_nor_flash_resources, | |
71 | .num_resources = ARRAY_SIZE(edosk7760_nor_flash_resources), | |
72 | .dev = { | |
73 | .platform_data = &edosk7760_nor_flash_data, | |
74 | }, | |
75 | }; | |
76 | ||
3db91708 LS |
77 | /* i2c initialization functions */ |
78 | static struct sh7760_i2c_platdata i2c_pd = { | |
79 | .speed_khz = 400, | |
80 | }; | |
81 | ||
82 | static struct resource sh7760_i2c1_res[] = { | |
83 | { | |
84 | .start = SH7760_I2C1_MMIO, | |
85 | .end = SH7760_I2C1_MMIOEND, | |
86 | .flags = IORESOURCE_MEM, | |
87 | },{ | |
03c5713c PM |
88 | .start = evt2irq(0x9e0), |
89 | .end = evt2irq(0x9e0), | |
3db91708 LS |
90 | .flags = IORESOURCE_IRQ, |
91 | }, | |
92 | }; | |
93 | ||
94 | static struct platform_device sh7760_i2c1_dev = { | |
95 | .dev = { | |
96 | .platform_data = &i2c_pd, | |
97 | }, | |
98 | ||
99 | .name = SH7760_I2C_DEVNAME, | |
100 | .id = 1, | |
101 | .resource = sh7760_i2c1_res, | |
102 | .num_resources = ARRAY_SIZE(sh7760_i2c1_res), | |
103 | }; | |
104 | ||
105 | static struct resource sh7760_i2c0_res[] = { | |
106 | { | |
107 | .start = SH7760_I2C0_MMIO, | |
108 | .end = SH7760_I2C0_MMIOEND, | |
109 | .flags = IORESOURCE_MEM, | |
110 | }, { | |
03c5713c PM |
111 | .start = evt2irq(0x9c0), |
112 | .end = evt2irq(0x9c0), | |
3db91708 LS |
113 | .flags = IORESOURCE_IRQ, |
114 | }, | |
115 | }; | |
116 | ||
117 | static struct platform_device sh7760_i2c0_dev = { | |
118 | .dev = { | |
119 | .platform_data = &i2c_pd, | |
120 | }, | |
121 | .name = SH7760_I2C_DEVNAME, | |
122 | .id = 0, | |
123 | .resource = sh7760_i2c0_res, | |
124 | .num_resources = ARRAY_SIZE(sh7760_i2c0_res), | |
125 | }; | |
126 | ||
127 | /* eth initialization functions */ | |
128 | static struct smc91x_platdata smc91x_info = { | |
129 | .flags = SMC91X_USE_16BIT | SMC91X_IO_SHIFT_1 | IORESOURCE_IRQ_LOWLEVEL, | |
130 | }; | |
131 | ||
132 | static struct resource smc91x_res[] = { | |
133 | [0] = { | |
134 | .start = SMC_IOADDR, | |
347cd34f | 135 | .end = SMC_IOADDR + SZ_32 - 1, |
3db91708 LS |
136 | .flags = IORESOURCE_MEM, |
137 | }, | |
138 | [1] = { | |
03c5713c PM |
139 | .start = evt2irq(0x2a0), |
140 | .end = evt2irq(0x2a0), | |
3db91708 LS |
141 | .flags = IORESOURCE_IRQ , |
142 | } | |
143 | }; | |
144 | ||
145 | static struct platform_device smc91x_dev = { | |
146 | .name = "smc91x", | |
147 | .id = -1, | |
148 | .num_resources = ARRAY_SIZE(smc91x_res), | |
149 | .resource = smc91x_res, | |
150 | ||
151 | .dev = { | |
152 | .platform_data = &smc91x_info, | |
153 | }, | |
154 | }; | |
155 | ||
156 | /* platform init code */ | |
157 | static struct platform_device *edosk7760_devices[] __initdata = { | |
4018ffcf LS |
158 | &smc91x_dev, |
159 | &edosk7760_nor_flash_device, | |
3db91708 LS |
160 | &sh7760_i2c0_dev, |
161 | &sh7760_i2c1_dev, | |
3db91708 LS |
162 | }; |
163 | ||
164 | static int __init init_edosk7760_devices(void) | |
165 | { | |
166 | plat_irq_setup_pins(IRQ_MODE_IRQ); | |
167 | ||
168 | return platform_add_devices(edosk7760_devices, | |
169 | ARRAY_SIZE(edosk7760_devices)); | |
170 | } | |
95d210ce | 171 | device_initcall(init_edosk7760_devices); |
3db91708 LS |
172 | |
173 | /* | |
174 | * The Machine Vector | |
175 | */ | |
176 | struct sh_machine_vector mv_edosk7760 __initmv = { | |
177 | .mv_name = "EDOSK7760", | |
3db91708 | 178 | }; |