Linux Audio

Check our new training course

Loading...
v3.15
 
  1/*
  2 * Renesas Technology Sales RTS7751R2D Support.
  3 *
  4 * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
  5 * Copyright (C) 2004 - 2007 Paul Mundt
  6 *
  7 * This file is subject to the terms and conditions of the GNU General Public
  8 * License.  See the file "COPYING" in the main directory of this archive
  9 * for more details.
 10 */
 11#include <linux/init.h>
 12#include <linux/platform_device.h>
 13#include <linux/mtd/mtd.h>
 14#include <linux/mtd/partitions.h>
 15#include <linux/mtd/physmap.h>
 16#include <linux/ata_platform.h>
 17#include <linux/sm501.h>
 18#include <linux/sm501-regs.h>
 19#include <linux/pm.h>
 20#include <linux/fb.h>
 21#include <linux/spi/spi.h>
 22#include <linux/spi/spi_bitbang.h>
 23#include <asm/machvec.h>
 24#include <mach/r2d.h>
 25#include <asm/io.h>
 26#include <asm/io_trapped.h>
 27#include <asm/spi.h>
 28
 29static struct resource cf_ide_resources[] = {
 30	[0] = {
 31		.start	= PA_AREA5_IO + 0x1000,
 32		.end	= PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
 33		.flags	= IORESOURCE_MEM,
 34	},
 35	[1] = {
 36		.start	= PA_AREA5_IO + 0x80c,
 37		.end	= PA_AREA5_IO + 0x80c,
 38		.flags	= IORESOURCE_MEM,
 39	},
 40#ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
 41	[2] = {
 42		.start	= IRQ_CF_IDE,
 43		.flags	= IORESOURCE_IRQ,
 44	},
 45#endif
 46};
 47
 48static struct pata_platform_info pata_info = {
 49	.ioport_shift	= 1,
 50};
 51
 52static struct platform_device cf_ide_device  = {
 53	.name		= "pata_platform",
 54	.id		= -1,
 55	.num_resources	= ARRAY_SIZE(cf_ide_resources),
 56	.resource	= cf_ide_resources,
 57	.dev	= {
 58		.platform_data	= &pata_info,
 59	},
 60};
 61
 62static struct spi_board_info spi_bus[] = {
 63	{
 64		.modalias	= "rtc-r9701",
 65		.max_speed_hz	= 1000000,
 66		.mode		= SPI_MODE_3,
 67	},
 68};
 69
 70static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state)
 71{
 72	BUG_ON(cs != 0);  /* Single Epson RTC-9701JE attached on CS0 */
 73	__raw_writew(state == BITBANG_CS_ACTIVE, PA_RTCCE);
 74}
 75
 76static struct sh_spi_info spi_info = {
 77	.num_chipselect = 1,
 78	.chip_select = r2d_chip_select,
 79};
 80
 81static struct resource spi_sh_sci_resources[] = {
 82	{
 83		.start	= 0xffe00000,
 84		.end	= 0xffe0001f,
 85		.flags	= IORESOURCE_MEM,
 86	},
 87};
 88
 89static struct platform_device spi_sh_sci_device  = {
 90	.name		= "spi_sh_sci",
 91	.id		= -1,
 92	.num_resources	= ARRAY_SIZE(spi_sh_sci_resources),
 93	.resource	= spi_sh_sci_resources,
 94	.dev	= {
 95		.platform_data	= &spi_info,
 96	},
 97};
 98
 99static struct resource heartbeat_resources[] = {
100	[0] = {
101		.start	= PA_OUTPORT,
102		.end	= PA_OUTPORT,
103		.flags	= IORESOURCE_MEM,
104	},
105};
106
107static struct platform_device heartbeat_device = {
108	.name		= "heartbeat",
109	.id		= -1,
110	.num_resources	= ARRAY_SIZE(heartbeat_resources),
111	.resource	= heartbeat_resources,
112};
113
114static struct resource sm501_resources[] = {
115	[0]	= {
116		.start	= 0x10000000,
117		.end	= 0x13e00000 - 1,
118		.flags	= IORESOURCE_MEM,
119	},
120	[1]	= {
121		.start	= 0x13e00000,
122		.end	= 0x13ffffff,
123		.flags	= IORESOURCE_MEM,
124	},
125	[2]	= {
126		.start	= IRQ_VOYAGER,
127		.flags	= IORESOURCE_IRQ,
128	},
129};
130
131static struct fb_videomode sm501_default_mode = {
132	.pixclock	= 35714,
133	.xres		= 640,
134	.yres		= 480,
135	.left_margin	= 105,
136	.right_margin	= 50,
137	.upper_margin	= 35,
138	.lower_margin	= 0,
139	.hsync_len	= 96,
140	.vsync_len	= 2,
141	.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
142};
143
144static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
145	.def_bpp	= 16,
146	.def_mode	= &sm501_default_mode,
147	.flags		= SM501FB_FLAG_USE_INIT_MODE |
148			  SM501FB_FLAG_USE_HWCURSOR |
149			  SM501FB_FLAG_USE_HWACCEL |
150			  SM501FB_FLAG_DISABLE_AT_EXIT,
151};
152
153static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
154	.flags		= (SM501FB_FLAG_USE_INIT_MODE |
155			   SM501FB_FLAG_USE_HWCURSOR |
156			   SM501FB_FLAG_USE_HWACCEL |
157			   SM501FB_FLAG_DISABLE_AT_EXIT),
158
159};
160
161static struct sm501_platdata_fb sm501_fb_pdata = {
162	.fb_route	= SM501_FB_OWN,
163	.fb_crt		= &sm501_pdata_fbsub_crt,
164	.fb_pnl		= &sm501_pdata_fbsub_pnl,
165	.flags		= SM501_FBPD_SWAP_FB_ENDIAN,
166};
167
168static struct sm501_initdata sm501_initdata = {
169	.devices	= SM501_USE_USB_HOST | SM501_USE_UART0,
170};
171
172static struct sm501_platdata sm501_platform_data = {
173	.init		= &sm501_initdata,
174	.fb		= &sm501_fb_pdata,
175};
176
177static struct platform_device sm501_device = {
178	.name		= "sm501",
179	.id		= -1,
180	.dev		= {
181		.platform_data	= &sm501_platform_data,
182	},
183	.num_resources	= ARRAY_SIZE(sm501_resources),
184	.resource	= sm501_resources,
185};
186
187static struct mtd_partition r2d_partitions[] = {
188	{
189		.name		= "U-Boot",
190		.offset		= 0x00000000,
191		.size		= 0x00040000,
192		.mask_flags	= MTD_WRITEABLE,
193	}, {
194		.name		= "Environment",
195		.offset		= MTDPART_OFS_NXTBLK,
196		.size		= 0x00040000,
197		.mask_flags	= MTD_WRITEABLE,
198	}, {
199		.name		= "Kernel",
200		.offset		= MTDPART_OFS_NXTBLK,
201		.size		= 0x001c0000,
202	}, {
203		.name		= "Flash_FS",
204		.offset		= MTDPART_OFS_NXTBLK,
205		.size		= MTDPART_SIZ_FULL,
206	}
207};
208
209static struct physmap_flash_data flash_data = {
210	.width		= 2,
211	.nr_parts	= ARRAY_SIZE(r2d_partitions),
212	.parts		= r2d_partitions,
213};
214
215static struct resource flash_resource = {
216	.start		= 0x00000000,
217	.end		= 0x02000000,
218	.flags		= IORESOURCE_MEM,
219};
220
221static struct platform_device flash_device = {
222	.name		= "physmap-flash",
223	.id		= -1,
224	.resource	= &flash_resource,
225	.num_resources	= 1,
226	.dev		= {
227		.platform_data = &flash_data,
228	},
229};
230
231static struct platform_device *rts7751r2d_devices[] __initdata = {
232	&sm501_device,
233	&heartbeat_device,
234	&spi_sh_sci_device,
235};
236
237/*
238 * The CF is connected with a 16-bit bus where 8-bit operations are
239 * unsupported. The linux ata driver is however using 8-bit operations, so
240 * insert a trapped io filter to convert 8-bit operations into 16-bit.
241 */
242static struct trapped_io cf_trapped_io = {
243	.resource		= cf_ide_resources,
244	.num_resources		= 2,
245	.minimum_bus_width	= 16,
246};
247
248static int __init rts7751r2d_devices_setup(void)
249{
250	if (register_trapped_io(&cf_trapped_io) == 0)
251		platform_device_register(&cf_ide_device);
252
253	if (mach_is_r2d_plus())
254		platform_device_register(&flash_device);
255
256	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
257
258	return platform_add_devices(rts7751r2d_devices,
259				    ARRAY_SIZE(rts7751r2d_devices));
260}
261device_initcall(rts7751r2d_devices_setup);
262
263static void rts7751r2d_power_off(void)
264{
265	__raw_writew(0x0001, PA_POWOFF);
266}
267
268/*
269 * Initialize the board
270 */
271static void __init rts7751r2d_setup(char **cmdline_p)
272{
273	void __iomem *sm501_reg;
274	u16 ver = __raw_readw(PA_VERREG);
275
276	printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
277
278	printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
279					(ver >> 4) & 0xf, ver & 0xf);
280
281	__raw_writew(0x0000, PA_OUTPORT);
282	pm_power_off = rts7751r2d_power_off;
283
284	/* sm501 dram configuration:
285	 * ColSizeX = 11 - External Memory Column Size: 256 words.
286	 * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
287	 * RstX = 1 - External Memory Reset: Normal.
288	 * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
289	 * BwC =  1 - Local Memory Block Write Cycle Time: 2 clocks.
290	 * BwP =  1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
291	 * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
292	 * Rst = 1 - Internal Memory Reset: Normal.
293	 * RA = 1 - Internal Memory Remain in Active State: Do not remain.
294	 */
295
296	sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
297	writel(readl(sm501_reg) | 0x00f107c0, sm501_reg);
298}
299
300/*
301 * The Machine Vector
302 */
303static struct sh_machine_vector mv_rts7751r2d __initmv = {
304	.mv_name		= "RTS7751R2D",
305	.mv_setup		= rts7751r2d_setup,
306	.mv_init_irq		= init_rts7751r2d_IRQ,
307	.mv_irq_demux		= rts7751r2d_irq_demux,
308};
v5.4
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * Renesas Technology Sales RTS7751R2D Support.
  4 *
  5 * Copyright (C) 2002 - 2006 Atom Create Engineering Co., Ltd.
  6 * Copyright (C) 2004 - 2007 Paul Mundt
 
 
 
 
  7 */
  8#include <linux/init.h>
  9#include <linux/platform_device.h>
 10#include <linux/mtd/mtd.h>
 11#include <linux/mtd/partitions.h>
 12#include <linux/mtd/physmap.h>
 13#include <linux/ata_platform.h>
 14#include <linux/sm501.h>
 15#include <linux/sm501-regs.h>
 16#include <linux/pm.h>
 17#include <linux/fb.h>
 18#include <linux/spi/spi.h>
 19#include <linux/spi/spi_bitbang.h>
 20#include <asm/machvec.h>
 21#include <mach/r2d.h>
 22#include <asm/io.h>
 23#include <asm/io_trapped.h>
 24#include <asm/spi.h>
 25
 26static struct resource cf_ide_resources[] = {
 27	[0] = {
 28		.start	= PA_AREA5_IO + 0x1000,
 29		.end	= PA_AREA5_IO + 0x1000 + 0x10 - 0x2,
 30		.flags	= IORESOURCE_MEM,
 31	},
 32	[1] = {
 33		.start	= PA_AREA5_IO + 0x80c,
 34		.end	= PA_AREA5_IO + 0x80c,
 35		.flags	= IORESOURCE_MEM,
 36	},
 37#ifndef CONFIG_RTS7751R2D_1 /* For R2D-1 polling is preferred */
 38	[2] = {
 39		.start	= IRQ_CF_IDE,
 40		.flags	= IORESOURCE_IRQ,
 41	},
 42#endif
 43};
 44
 45static struct pata_platform_info pata_info = {
 46	.ioport_shift	= 1,
 47};
 48
 49static struct platform_device cf_ide_device  = {
 50	.name		= "pata_platform",
 51	.id		= -1,
 52	.num_resources	= ARRAY_SIZE(cf_ide_resources),
 53	.resource	= cf_ide_resources,
 54	.dev	= {
 55		.platform_data	= &pata_info,
 56	},
 57};
 58
 59static struct spi_board_info spi_bus[] = {
 60	{
 61		.modalias	= "rtc-r9701",
 62		.max_speed_hz	= 1000000,
 63		.mode		= SPI_MODE_3,
 64	},
 65};
 66
 67static void r2d_chip_select(struct sh_spi_info *spi, int cs, int state)
 68{
 69	BUG_ON(cs != 0);  /* Single Epson RTC-9701JE attached on CS0 */
 70	__raw_writew(state == BITBANG_CS_ACTIVE, PA_RTCCE);
 71}
 72
 73static struct sh_spi_info spi_info = {
 74	.num_chipselect = 1,
 75	.chip_select = r2d_chip_select,
 76};
 77
 78static struct resource spi_sh_sci_resources[] = {
 79	{
 80		.start	= 0xffe00000,
 81		.end	= 0xffe0001f,
 82		.flags	= IORESOURCE_MEM,
 83	},
 84};
 85
 86static struct platform_device spi_sh_sci_device  = {
 87	.name		= "spi_sh_sci",
 88	.id		= -1,
 89	.num_resources	= ARRAY_SIZE(spi_sh_sci_resources),
 90	.resource	= spi_sh_sci_resources,
 91	.dev	= {
 92		.platform_data	= &spi_info,
 93	},
 94};
 95
 96static struct resource heartbeat_resources[] = {
 97	[0] = {
 98		.start	= PA_OUTPORT,
 99		.end	= PA_OUTPORT,
100		.flags	= IORESOURCE_MEM,
101	},
102};
103
104static struct platform_device heartbeat_device = {
105	.name		= "heartbeat",
106	.id		= -1,
107	.num_resources	= ARRAY_SIZE(heartbeat_resources),
108	.resource	= heartbeat_resources,
109};
110
111static struct resource sm501_resources[] = {
112	[0]	= {
113		.start	= 0x10000000,
114		.end	= 0x13e00000 - 1,
115		.flags	= IORESOURCE_MEM,
116	},
117	[1]	= {
118		.start	= 0x13e00000,
119		.end	= 0x13ffffff,
120		.flags	= IORESOURCE_MEM,
121	},
122	[2]	= {
123		.start	= IRQ_VOYAGER,
124		.flags	= IORESOURCE_IRQ,
125	},
126};
127
128static struct fb_videomode sm501_default_mode = {
129	.pixclock	= 35714,
130	.xres		= 640,
131	.yres		= 480,
132	.left_margin	= 105,
133	.right_margin	= 50,
134	.upper_margin	= 35,
135	.lower_margin	= 0,
136	.hsync_len	= 96,
137	.vsync_len	= 2,
138	.sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
139};
140
141static struct sm501_platdata_fbsub sm501_pdata_fbsub_pnl = {
142	.def_bpp	= 16,
143	.def_mode	= &sm501_default_mode,
144	.flags		= SM501FB_FLAG_USE_INIT_MODE |
145			  SM501FB_FLAG_USE_HWCURSOR |
146			  SM501FB_FLAG_USE_HWACCEL |
147			  SM501FB_FLAG_DISABLE_AT_EXIT,
148};
149
150static struct sm501_platdata_fbsub sm501_pdata_fbsub_crt = {
151	.flags		= (SM501FB_FLAG_USE_INIT_MODE |
152			   SM501FB_FLAG_USE_HWCURSOR |
153			   SM501FB_FLAG_USE_HWACCEL |
154			   SM501FB_FLAG_DISABLE_AT_EXIT),
155
156};
157
158static struct sm501_platdata_fb sm501_fb_pdata = {
159	.fb_route	= SM501_FB_OWN,
160	.fb_crt		= &sm501_pdata_fbsub_crt,
161	.fb_pnl		= &sm501_pdata_fbsub_pnl,
162	.flags		= SM501_FBPD_SWAP_FB_ENDIAN,
163};
164
165static struct sm501_initdata sm501_initdata = {
166	.devices	= SM501_USE_USB_HOST | SM501_USE_UART0,
167};
168
169static struct sm501_platdata sm501_platform_data = {
170	.init		= &sm501_initdata,
171	.fb		= &sm501_fb_pdata,
172};
173
174static struct platform_device sm501_device = {
175	.name		= "sm501",
176	.id		= -1,
177	.dev		= {
178		.platform_data	= &sm501_platform_data,
179	},
180	.num_resources	= ARRAY_SIZE(sm501_resources),
181	.resource	= sm501_resources,
182};
183
184static struct mtd_partition r2d_partitions[] = {
185	{
186		.name		= "U-Boot",
187		.offset		= 0x00000000,
188		.size		= 0x00040000,
189		.mask_flags	= MTD_WRITEABLE,
190	}, {
191		.name		= "Environment",
192		.offset		= MTDPART_OFS_NXTBLK,
193		.size		= 0x00040000,
194		.mask_flags	= MTD_WRITEABLE,
195	}, {
196		.name		= "Kernel",
197		.offset		= MTDPART_OFS_NXTBLK,
198		.size		= 0x001c0000,
199	}, {
200		.name		= "Flash_FS",
201		.offset		= MTDPART_OFS_NXTBLK,
202		.size		= MTDPART_SIZ_FULL,
203	}
204};
205
206static struct physmap_flash_data flash_data = {
207	.width		= 2,
208	.nr_parts	= ARRAY_SIZE(r2d_partitions),
209	.parts		= r2d_partitions,
210};
211
212static struct resource flash_resource = {
213	.start		= 0x00000000,
214	.end		= 0x02000000,
215	.flags		= IORESOURCE_MEM,
216};
217
218static struct platform_device flash_device = {
219	.name		= "physmap-flash",
220	.id		= -1,
221	.resource	= &flash_resource,
222	.num_resources	= 1,
223	.dev		= {
224		.platform_data = &flash_data,
225	},
226};
227
228static struct platform_device *rts7751r2d_devices[] __initdata = {
229	&sm501_device,
230	&heartbeat_device,
231	&spi_sh_sci_device,
232};
233
234/*
235 * The CF is connected with a 16-bit bus where 8-bit operations are
236 * unsupported. The linux ata driver is however using 8-bit operations, so
237 * insert a trapped io filter to convert 8-bit operations into 16-bit.
238 */
239static struct trapped_io cf_trapped_io = {
240	.resource		= cf_ide_resources,
241	.num_resources		= 2,
242	.minimum_bus_width	= 16,
243};
244
245static int __init rts7751r2d_devices_setup(void)
246{
247	if (register_trapped_io(&cf_trapped_io) == 0)
248		platform_device_register(&cf_ide_device);
249
250	if (mach_is_r2d_plus())
251		platform_device_register(&flash_device);
252
253	spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
254
255	return platform_add_devices(rts7751r2d_devices,
256				    ARRAY_SIZE(rts7751r2d_devices));
257}
258device_initcall(rts7751r2d_devices_setup);
259
260static void rts7751r2d_power_off(void)
261{
262	__raw_writew(0x0001, PA_POWOFF);
263}
264
265/*
266 * Initialize the board
267 */
268static void __init rts7751r2d_setup(char **cmdline_p)
269{
270	void __iomem *sm501_reg;
271	u16 ver = __raw_readw(PA_VERREG);
272
273	printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
274
275	printk(KERN_INFO "FPGA version:%d (revision:%d)\n",
276					(ver >> 4) & 0xf, ver & 0xf);
277
278	__raw_writew(0x0000, PA_OUTPORT);
279	pm_power_off = rts7751r2d_power_off;
280
281	/* sm501 dram configuration:
282	 * ColSizeX = 11 - External Memory Column Size: 256 words.
283	 * APX = 1 - External Memory Active to Pre-Charge Delay: 7 clocks.
284	 * RstX = 1 - External Memory Reset: Normal.
285	 * Rfsh = 1 - Local Memory Refresh to Command Delay: 12 clocks.
286	 * BwC =  1 - Local Memory Block Write Cycle Time: 2 clocks.
287	 * BwP =  1 - Local Memory Block Write to Pre-Charge Delay: 1 clock.
288	 * AP = 1 - Internal Memory Active to Pre-Charge Delay: 7 clocks.
289	 * Rst = 1 - Internal Memory Reset: Normal.
290	 * RA = 1 - Internal Memory Remain in Active State: Do not remain.
291	 */
292
293	sm501_reg = (void __iomem *)0xb3e00000 + SM501_DRAM_CONTROL;
294	writel(readl(sm501_reg) | 0x00f107c0, sm501_reg);
295}
296
297/*
298 * The Machine Vector
299 */
300static struct sh_machine_vector mv_rts7751r2d __initmv = {
301	.mv_name		= "RTS7751R2D",
302	.mv_setup		= rts7751r2d_setup,
303	.mv_init_irq		= init_rts7751r2d_IRQ,
304	.mv_irq_demux		= rts7751r2d_irq_demux,
305};