Linux Audio

Check our new training course

Yocto / OpenEmbedded training

Feb 10-13, 2025
Register
Loading...
v3.15
 
  1/*
  2 * arch/sh/boards/renesas/r7780rp/setup.c
  3 *
  4 * Renesas Solutions Highlander Support.
  5 *
  6 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
  7 * Copyright (C) 2005 - 2008 Paul Mundt
  8 *
  9 * This contains support for the R7780RP-1, R7780MP, and R7785RP
 10 * Highlander modules.
 11 *
 12 * This file is subject to the terms and conditions of the GNU General Public
 13 * License.  See the file "COPYING" in the main directory of this archive
 14 * for more details.
 15 */
 16#include <linux/init.h>
 17#include <linux/io.h>
 18#include <linux/platform_device.h>
 19#include <linux/ata_platform.h>
 20#include <linux/types.h>
 21#include <linux/mtd/physmap.h>
 22#include <linux/i2c.h>
 23#include <linux/irq.h>
 24#include <linux/interrupt.h>
 25#include <linux/usb/r8a66597.h>
 26#include <linux/usb/m66592.h>
 27#include <linux/clkdev.h>
 28#include <net/ax88796.h>
 29#include <asm/machvec.h>
 30#include <mach/highlander.h>
 31#include <asm/clock.h>
 32#include <asm/heartbeat.h>
 33#include <asm/io.h>
 34#include <asm/io_trapped.h>
 35
 36static struct r8a66597_platdata r8a66597_data = {
 37	.xtal = R8A66597_PLATDATA_XTAL_12MHZ,
 38	.vif = 1,
 39};
 40
 41static struct resource r8a66597_usb_host_resources[] = {
 42	[0] = {
 43		.start	= 0xA4200000,
 44		.end	= 0xA42000FF,
 45		.flags	= IORESOURCE_MEM,
 46	},
 47	[1] = {
 48		.start	= IRQ_EXT1,		/* irq number */
 49		.end	= IRQ_EXT1,
 50		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
 51	},
 52};
 53
 54static struct platform_device r8a66597_usb_host_device = {
 55	.name		= "r8a66597_hcd",
 56	.id		= -1,
 57	.dev = {
 58		.dma_mask		= NULL,		/* don't use dma */
 59		.coherent_dma_mask	= 0xffffffff,
 60		.platform_data		= &r8a66597_data,
 61	},
 62	.num_resources	= ARRAY_SIZE(r8a66597_usb_host_resources),
 63	.resource	= r8a66597_usb_host_resources,
 64};
 65
 66static struct m66592_platdata usbf_platdata = {
 67	.xtal = M66592_PLATDATA_XTAL_24MHZ,
 68	.vif = 1,
 69};
 70
 71static struct resource m66592_usb_peripheral_resources[] = {
 72	[0] = {
 73		.name	= "m66592_udc",
 74		.start	= 0xb0000000,
 75		.end	= 0xb00000FF,
 76		.flags	= IORESOURCE_MEM,
 77	},
 78	[1] = {
 79		.name	= "m66592_udc",
 80		.start	= IRQ_EXT4,		/* irq number */
 81		.end	= IRQ_EXT4,
 82		.flags	= IORESOURCE_IRQ,
 83	},
 84};
 85
 86static struct platform_device m66592_usb_peripheral_device = {
 87	.name		= "m66592_udc",
 88	.id		= -1,
 89	.dev = {
 90		.dma_mask		= NULL,		/* don't use dma */
 91		.coherent_dma_mask	= 0xffffffff,
 92		.platform_data		= &usbf_platdata,
 93	},
 94	.num_resources	= ARRAY_SIZE(m66592_usb_peripheral_resources),
 95	.resource	= m66592_usb_peripheral_resources,
 96};
 97
 98static struct resource cf_ide_resources[] = {
 99	[0] = {
100		.start	= PA_AREA5_IO + 0x1000,
101		.end	= PA_AREA5_IO + 0x1000 + 0x08 - 1,
102		.flags	= IORESOURCE_MEM,
103	},
104	[1] = {
105		.start	= PA_AREA5_IO + 0x80c,
106		.end	= PA_AREA5_IO + 0x80c + 0x16 - 1,
107		.flags	= IORESOURCE_MEM,
108	},
109	[2] = {
110		.start	= IRQ_CF,
111		.flags	= IORESOURCE_IRQ,
112	},
113};
114
115static struct pata_platform_info pata_info = {
116	.ioport_shift	= 1,
117};
118
119static struct platform_device cf_ide_device  = {
120	.name		= "pata_platform",
121	.id		= -1,
122	.num_resources	= ARRAY_SIZE(cf_ide_resources),
123	.resource	= cf_ide_resources,
124	.dev	= {
125		.platform_data	= &pata_info,
126	},
127};
128
129static struct resource heartbeat_resources[] = {
130	[0] = {
131		.start	= PA_OBLED,
132		.end	= PA_OBLED,
133		.flags	= IORESOURCE_MEM,
134	},
135};
136
137#ifndef CONFIG_SH_R7785RP
138static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
139
140static struct heartbeat_data heartbeat_data = {
141	.bit_pos	= heartbeat_bit_pos,
142	.nr_bits	= ARRAY_SIZE(heartbeat_bit_pos),
143};
144#endif
145
146static struct platform_device heartbeat_device = {
147	.name		= "heartbeat",
148	.id		= -1,
149
150	/* R7785RP has a slightly more sensible FPGA.. */
151#ifndef CONFIG_SH_R7785RP
152	.dev	= {
153		.platform_data	= &heartbeat_data,
154	},
155#endif
156	.num_resources	= ARRAY_SIZE(heartbeat_resources),
157	.resource	= heartbeat_resources,
158};
159
160static struct ax_plat_data ax88796_platdata = {
161	.flags          = AXFLG_HAS_93CX6,
162	.wordlength     = 2,
163	.dcr_val        = 0x1,
164	.rcr_val        = 0x40,
165};
166
167static struct resource ax88796_resources[] = {
168	{
169#ifdef CONFIG_SH_R7780RP
170		.start  = 0xa5800400,
171		.end    = 0xa5800400 + (0x20 * 0x2) - 1,
172#else
173		.start  = 0xa4100400,
174		.end    = 0xa4100400 + (0x20 * 0x2) - 1,
175#endif
176		.flags  = IORESOURCE_MEM,
177	},
178	{
179		.start  = IRQ_AX88796,
180		.end    = IRQ_AX88796,
181		.flags  = IORESOURCE_IRQ,
182	},
183};
184
185static struct platform_device ax88796_device = {
186	.name           = "ax88796",
187	.id             = 0,
188
189	.dev    = {
190		.platform_data = &ax88796_platdata,
191	},
192
193	.num_resources  = ARRAY_SIZE(ax88796_resources),
194	.resource       = ax88796_resources,
195};
196
197static struct mtd_partition nor_flash_partitions[] = {
198	{
199		.name		= "loader",
200		.offset		= 0x00000000,
201		.size		= 512 * 1024,
202	},
203	{
204		.name		= "bootenv",
205		.offset		= MTDPART_OFS_APPEND,
206		.size		= 512 * 1024,
207	},
208	{
209		.name		= "kernel",
210		.offset		= MTDPART_OFS_APPEND,
211		.size		= 4 * 1024 * 1024,
212	},
213	{
214		.name		= "data",
215		.offset		= MTDPART_OFS_APPEND,
216		.size		= MTDPART_SIZ_FULL,
217	},
218};
219
220static struct physmap_flash_data nor_flash_data = {
221	.width		= 4,
222	.parts		= nor_flash_partitions,
223	.nr_parts	= ARRAY_SIZE(nor_flash_partitions),
224};
225
226/* This config is flash board for mass production. */
227static struct resource nor_flash_resources[] = {
228	[0]	= {
229		.start	= PA_NORFLASH_ADDR,
230		.end	= PA_NORFLASH_ADDR + PA_NORFLASH_SIZE - 1,
231		.flags	= IORESOURCE_MEM,
232	}
233};
234
235static struct platform_device nor_flash_device = {
236	.name		= "physmap-flash",
237	.dev		= {
238		.platform_data	= &nor_flash_data,
239	},
240	.num_resources	= ARRAY_SIZE(nor_flash_resources),
241	.resource	= nor_flash_resources,
242};
243
244static struct resource smbus_resources[] = {
245	[0] = {
246		.start	= PA_SMCR,
247		.end	= PA_SMCR + 0x100 - 1,
248		.flags	= IORESOURCE_MEM,
249	},
250	[1] = {
251		.start	= IRQ_SMBUS,
252		.end	= IRQ_SMBUS,
253		.flags	= IORESOURCE_IRQ,
254	},
255};
256
257static struct platform_device smbus_device = {
258	.name		= "i2c-highlander",
259	.id		= 0,
260	.num_resources	= ARRAY_SIZE(smbus_resources),
261	.resource	= smbus_resources,
262};
263
264static struct i2c_board_info __initdata highlander_i2c_devices[] = {
265	{
266		I2C_BOARD_INFO("r2025sd", 0x32),
267	},
268};
269
270static struct platform_device *r7780rp_devices[] __initdata = {
271	&r8a66597_usb_host_device,
272	&m66592_usb_peripheral_device,
273	&heartbeat_device,
274	&smbus_device,
275	&nor_flash_device,
276#ifndef CONFIG_SH_R7780RP
277	&ax88796_device,
278#endif
279};
280
281/*
282 * The CF is connected using a 16-bit bus where 8-bit operations are
283 * unsupported. The linux ata driver is however using 8-bit operations, so
284 * insert a trapped io filter to convert 8-bit operations into 16-bit.
285 */
286static struct trapped_io cf_trapped_io = {
287	.resource		= cf_ide_resources,
288	.num_resources		= 2,
289	.minimum_bus_width	= 16,
290};
291
292static int __init r7780rp_devices_setup(void)
293{
294	int ret = 0;
295
296#ifndef CONFIG_SH_R7780RP
297	if (register_trapped_io(&cf_trapped_io) == 0)
298		ret |= platform_device_register(&cf_ide_device);
299#endif
300
301	ret |= platform_add_devices(r7780rp_devices,
302				    ARRAY_SIZE(r7780rp_devices));
303
304	ret |= i2c_register_board_info(0, highlander_i2c_devices,
305				       ARRAY_SIZE(highlander_i2c_devices));
306
307	return ret;
308}
309device_initcall(r7780rp_devices_setup);
310
311/*
312 * Platform specific clocks
313 */
314static int ivdr_clk_enable(struct clk *clk)
315{
316	__raw_writew(__raw_readw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
317	return 0;
318}
319
320static void ivdr_clk_disable(struct clk *clk)
321{
322	__raw_writew(__raw_readw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
323}
324
325static struct sh_clk_ops ivdr_clk_ops = {
326	.enable		= ivdr_clk_enable,
327	.disable	= ivdr_clk_disable,
328};
329
330static struct clk ivdr_clk = {
331	.ops		= &ivdr_clk_ops,
332};
333
334static struct clk *r7780rp_clocks[] = {
335	&ivdr_clk,
336};
337
338static struct clk_lookup lookups[] = {
339	/* main clocks */
340	CLKDEV_CON_ID("ivdr_clk", &ivdr_clk),
341};
342
343static void r7780rp_power_off(void)
344{
345	if (mach_is_r7780mp() || mach_is_r7785rp())
346		__raw_writew(0x0001, PA_POFF);
347}
348
349/*
350 * Initialize the board
351 */
352static void __init highlander_setup(char **cmdline_p)
353{
354	u16 ver = __raw_readw(PA_VERREG);
355	int i;
356
357	printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
358			 mach_is_r7780rp() ? "R7780RP-1" :
359			 mach_is_r7780mp() ? "R7780MP"	 :
360					     "R7785RP");
361
362	printk(KERN_INFO "Board version: %d (revision %d), "
363			 "FPGA version: %d (revision %d)\n",
364			 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
365			 (ver >>  4) & 0xf, ver & 0xf);
366
367	highlander_plat_pinmux_setup();
368
369	/*
370	 * Enable the important clocks right away..
371	 */
372	for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
373		struct clk *clk = r7780rp_clocks[i];
374
375		clk_register(clk);
376		clk_enable(clk);
377	}
378
379	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
380
381	__raw_writew(0x0000, PA_OBLED);	/* Clear LED. */
382
383	if (mach_is_r7780rp())
384		__raw_writew(0x0001, PA_SDPOW);	/* SD Power ON */
385
386	__raw_writew(__raw_readw(PA_IVDRCTL) | 0x01, PA_IVDRCTL);	/* Si13112 */
387
388	pm_power_off = r7780rp_power_off;
389}
390
391static unsigned char irl2irq[HL_NR_IRL];
392
393static int highlander_irq_demux(int irq)
394{
395	if (irq >= HL_NR_IRL || irq < 0 || !irl2irq[irq])
396		return irq;
397
398	return irl2irq[irq];
399}
400
401static void __init highlander_init_irq(void)
402{
403	unsigned char *ucp = highlander_plat_irq_setup();
404
405	if (ucp) {
406		plat_irq_setup_pins(IRQ_MODE_IRL3210);
407		memcpy(irl2irq, ucp, HL_NR_IRL);
408	}
409}
410
411/*
412 * The Machine Vector
413 */
414static struct sh_machine_vector mv_highlander __initmv = {
415	.mv_name		= "Highlander",
416	.mv_setup		= highlander_setup,
417	.mv_init_irq		= highlander_init_irq,
418	.mv_irq_demux		= highlander_irq_demux,
419};
v6.8
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * arch/sh/boards/renesas/r7780rp/setup.c
  4 *
  5 * Renesas Solutions Highlander Support.
  6 *
  7 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
  8 * Copyright (C) 2005 - 2008 Paul Mundt
  9 *
 10 * This contains support for the R7780RP-1, R7780MP, and R7785RP
 11 * Highlander modules.
 
 
 
 
 12 */
 13#include <linux/init.h>
 14#include <linux/io.h>
 15#include <linux/platform_device.h>
 16#include <linux/ata_platform.h>
 17#include <linux/types.h>
 18#include <linux/mtd/physmap.h>
 19#include <linux/i2c.h>
 20#include <linux/irq.h>
 21#include <linux/interrupt.h>
 22#include <linux/usb/r8a66597.h>
 23#include <linux/usb/m66592.h>
 24#include <linux/clkdev.h>
 25#include <net/ax88796.h>
 26#include <asm/machvec.h>
 27#include <mach/highlander.h>
 28#include <asm/clock.h>
 29#include <asm/heartbeat.h>
 30#include <asm/io.h>
 31#include <asm/io_trapped.h>
 32
 33static struct r8a66597_platdata r8a66597_data = {
 34	.xtal = R8A66597_PLATDATA_XTAL_12MHZ,
 35	.vif = 1,
 36};
 37
 38static struct resource r8a66597_usb_host_resources[] = {
 39	[0] = {
 40		.start	= 0xA4200000,
 41		.end	= 0xA42000FF,
 42		.flags	= IORESOURCE_MEM,
 43	},
 44	[1] = {
 45		.start	= IRQ_EXT1,		/* irq number */
 46		.end	= IRQ_EXT1,
 47		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
 48	},
 49};
 50
 51static struct platform_device r8a66597_usb_host_device = {
 52	.name		= "r8a66597_hcd",
 53	.id		= -1,
 54	.dev = {
 55		.dma_mask		= NULL,		/* don't use dma */
 56		.coherent_dma_mask	= 0xffffffff,
 57		.platform_data		= &r8a66597_data,
 58	},
 59	.num_resources	= ARRAY_SIZE(r8a66597_usb_host_resources),
 60	.resource	= r8a66597_usb_host_resources,
 61};
 62
 63static struct m66592_platdata usbf_platdata = {
 64	.xtal = M66592_PLATDATA_XTAL_24MHZ,
 65	.vif = 1,
 66};
 67
 68static struct resource m66592_usb_peripheral_resources[] = {
 69	[0] = {
 70		.name	= "m66592_udc",
 71		.start	= 0xb0000000,
 72		.end	= 0xb00000FF,
 73		.flags	= IORESOURCE_MEM,
 74	},
 75	[1] = {
 76		.name	= "m66592_udc",
 77		.start	= IRQ_EXT4,		/* irq number */
 78		.end	= IRQ_EXT4,
 79		.flags	= IORESOURCE_IRQ,
 80	},
 81};
 82
 83static struct platform_device m66592_usb_peripheral_device = {
 84	.name		= "m66592_udc",
 85	.id		= -1,
 86	.dev = {
 87		.dma_mask		= NULL,		/* don't use dma */
 88		.coherent_dma_mask	= 0xffffffff,
 89		.platform_data		= &usbf_platdata,
 90	},
 91	.num_resources	= ARRAY_SIZE(m66592_usb_peripheral_resources),
 92	.resource	= m66592_usb_peripheral_resources,
 93};
 94
 95static struct resource cf_ide_resources[] = {
 96	[0] = {
 97		.start	= PA_AREA5_IO + 0x1000,
 98		.end	= PA_AREA5_IO + 0x1000 + 0x08 - 1,
 99		.flags	= IORESOURCE_MEM,
100	},
101	[1] = {
102		.start	= PA_AREA5_IO + 0x80c,
103		.end	= PA_AREA5_IO + 0x80c + 0x16 - 1,
104		.flags	= IORESOURCE_MEM,
105	},
106	[2] = {
107		.start	= IRQ_CF,
108		.flags	= IORESOURCE_IRQ,
109	},
110};
111
112static struct pata_platform_info pata_info = {
113	.ioport_shift	= 1,
114};
115
116static struct platform_device cf_ide_device  = {
117	.name		= "pata_platform",
118	.id		= -1,
119	.num_resources	= ARRAY_SIZE(cf_ide_resources),
120	.resource	= cf_ide_resources,
121	.dev	= {
122		.platform_data	= &pata_info,
123	},
124};
125
126static struct resource heartbeat_resources[] = {
127	[0] = {
128		.start	= PA_OBLED,
129		.end	= PA_OBLED,
130		.flags	= IORESOURCE_MEM,
131	},
132};
133
134#ifndef CONFIG_SH_R7785RP
135static unsigned char heartbeat_bit_pos[] = { 2, 1, 0, 3, 6, 5, 4, 7 };
136
137static struct heartbeat_data heartbeat_data = {
138	.bit_pos	= heartbeat_bit_pos,
139	.nr_bits	= ARRAY_SIZE(heartbeat_bit_pos),
140};
141#endif
142
143static struct platform_device heartbeat_device = {
144	.name		= "heartbeat",
145	.id		= -1,
146
147	/* R7785RP has a slightly more sensible FPGA.. */
148#ifndef CONFIG_SH_R7785RP
149	.dev	= {
150		.platform_data	= &heartbeat_data,
151	},
152#endif
153	.num_resources	= ARRAY_SIZE(heartbeat_resources),
154	.resource	= heartbeat_resources,
155};
156
157static struct ax_plat_data ax88796_platdata = {
158	.flags          = AXFLG_HAS_93CX6,
159	.wordlength     = 2,
160	.dcr_val        = 0x1,
161	.rcr_val        = 0x40,
162};
163
164static struct resource ax88796_resources[] = {
165	{
166#ifdef CONFIG_SH_R7780RP
167		.start  = 0xa5800400,
168		.end    = 0xa5800400 + (0x20 * 0x2) - 1,
169#else
170		.start  = 0xa4100400,
171		.end    = 0xa4100400 + (0x20 * 0x2) - 1,
172#endif
173		.flags  = IORESOURCE_MEM,
174	},
175	{
176		.start  = IRQ_AX88796,
177		.end    = IRQ_AX88796,
178		.flags  = IORESOURCE_IRQ,
179	},
180};
181
182static struct platform_device ax88796_device = {
183	.name           = "ax88796",
184	.id             = 0,
185
186	.dev    = {
187		.platform_data = &ax88796_platdata,
188	},
189
190	.num_resources  = ARRAY_SIZE(ax88796_resources),
191	.resource       = ax88796_resources,
192};
193
194static struct mtd_partition nor_flash_partitions[] = {
195	{
196		.name		= "loader",
197		.offset		= 0x00000000,
198		.size		= 512 * 1024,
199	},
200	{
201		.name		= "bootenv",
202		.offset		= MTDPART_OFS_APPEND,
203		.size		= 512 * 1024,
204	},
205	{
206		.name		= "kernel",
207		.offset		= MTDPART_OFS_APPEND,
208		.size		= 4 * 1024 * 1024,
209	},
210	{
211		.name		= "data",
212		.offset		= MTDPART_OFS_APPEND,
213		.size		= MTDPART_SIZ_FULL,
214	},
215};
216
217static struct physmap_flash_data nor_flash_data = {
218	.width		= 4,
219	.parts		= nor_flash_partitions,
220	.nr_parts	= ARRAY_SIZE(nor_flash_partitions),
221};
222
223/* This config is flash board for mass production. */
224static struct resource nor_flash_resources[] = {
225	[0]	= {
226		.start	= PA_NORFLASH_ADDR,
227		.end	= PA_NORFLASH_ADDR + PA_NORFLASH_SIZE - 1,
228		.flags	= IORESOURCE_MEM,
229	}
230};
231
232static struct platform_device nor_flash_device = {
233	.name		= "physmap-flash",
234	.dev		= {
235		.platform_data	= &nor_flash_data,
236	},
237	.num_resources	= ARRAY_SIZE(nor_flash_resources),
238	.resource	= nor_flash_resources,
239};
240
241static struct resource smbus_resources[] = {
242	[0] = {
243		.start	= PA_SMCR,
244		.end	= PA_SMCR + 0x100 - 1,
245		.flags	= IORESOURCE_MEM,
246	},
247	[1] = {
248		.start	= IRQ_SMBUS,
249		.end	= IRQ_SMBUS,
250		.flags	= IORESOURCE_IRQ,
251	},
252};
253
254static struct platform_device smbus_device = {
255	.name		= "i2c-highlander",
256	.id		= 0,
257	.num_resources	= ARRAY_SIZE(smbus_resources),
258	.resource	= smbus_resources,
259};
260
261static struct i2c_board_info __initdata highlander_i2c_devices[] = {
262	{
263		I2C_BOARD_INFO("r2025sd", 0x32),
264	},
265};
266
267static struct platform_device *r7780rp_devices[] __initdata = {
268	&r8a66597_usb_host_device,
269	&m66592_usb_peripheral_device,
270	&heartbeat_device,
271	&smbus_device,
272	&nor_flash_device,
273#ifndef CONFIG_SH_R7780RP
274	&ax88796_device,
275#endif
276};
277
278/*
279 * The CF is connected using a 16-bit bus where 8-bit operations are
280 * unsupported. The linux ata driver is however using 8-bit operations, so
281 * insert a trapped io filter to convert 8-bit operations into 16-bit.
282 */
283static struct trapped_io cf_trapped_io = {
284	.resource		= cf_ide_resources,
285	.num_resources		= 2,
286	.minimum_bus_width	= 16,
287};
288
289static int __init r7780rp_devices_setup(void)
290{
291	int ret = 0;
292
293#ifndef CONFIG_SH_R7780RP
294	if (register_trapped_io(&cf_trapped_io) == 0)
295		ret |= platform_device_register(&cf_ide_device);
296#endif
297
298	ret |= platform_add_devices(r7780rp_devices,
299				    ARRAY_SIZE(r7780rp_devices));
300
301	ret |= i2c_register_board_info(0, highlander_i2c_devices,
302				       ARRAY_SIZE(highlander_i2c_devices));
303
304	return ret;
305}
306device_initcall(r7780rp_devices_setup);
307
308/*
309 * Platform specific clocks
310 */
311static int ivdr_clk_enable(struct clk *clk)
312{
313	__raw_writew(__raw_readw(PA_IVDRCTL) | (1 << IVDR_CK_ON), PA_IVDRCTL);
314	return 0;
315}
316
317static void ivdr_clk_disable(struct clk *clk)
318{
319	__raw_writew(__raw_readw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
320}
321
322static struct sh_clk_ops ivdr_clk_ops = {
323	.enable		= ivdr_clk_enable,
324	.disable	= ivdr_clk_disable,
325};
326
327static struct clk ivdr_clk = {
328	.ops		= &ivdr_clk_ops,
329};
330
331static struct clk *r7780rp_clocks[] = {
332	&ivdr_clk,
333};
334
335static struct clk_lookup lookups[] = {
336	/* main clocks */
337	CLKDEV_CON_ID("ivdr_clk", &ivdr_clk),
338};
339
340static void r7780rp_power_off(void)
341{
342	if (mach_is_r7780mp() || mach_is_r7785rp())
343		__raw_writew(0x0001, PA_POFF);
344}
345
346/*
347 * Initialize the board
348 */
349static void __init highlander_setup(char **cmdline_p)
350{
351	u16 ver = __raw_readw(PA_VERREG);
352	int i;
353
354	printk(KERN_INFO "Renesas Solutions Highlander %s support.\n",
355			 mach_is_r7780rp() ? "R7780RP-1" :
356			 mach_is_r7780mp() ? "R7780MP"	 :
357					     "R7785RP");
358
359	printk(KERN_INFO "Board version: %d (revision %d), "
360			 "FPGA version: %d (revision %d)\n",
361			 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
362			 (ver >>  4) & 0xf, ver & 0xf);
363
364	highlander_plat_pinmux_setup();
365
366	/*
367	 * Enable the important clocks right away..
368	 */
369	for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
370		struct clk *clk = r7780rp_clocks[i];
371
372		clk_register(clk);
373		clk_enable(clk);
374	}
375
376	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
377
378	__raw_writew(0x0000, PA_OBLED);	/* Clear LED. */
379
380	if (mach_is_r7780rp())
381		__raw_writew(0x0001, PA_SDPOW);	/* SD Power ON */
382
383	__raw_writew(__raw_readw(PA_IVDRCTL) | 0x01, PA_IVDRCTL);	/* Si13112 */
384
385	pm_power_off = r7780rp_power_off;
386}
387
388static unsigned char irl2irq[HL_NR_IRL];
389
390static int highlander_irq_demux(int irq)
391{
392	if (irq >= HL_NR_IRL + 16 || irq < 16 || !irl2irq[irq - 16])
393		return irq;
394
395	return irl2irq[irq - 16];
396}
397
398static void __init highlander_init_irq(void)
399{
400	unsigned char *ucp = highlander_plat_irq_setup();
401
402	if (ucp) {
403		plat_irq_setup_pins(IRQ_MODE_IRL3210);
404		memcpy(irl2irq, ucp, HL_NR_IRL);
405	}
406}
407
408/*
409 * The Machine Vector
410 */
411static struct sh_machine_vector mv_highlander __initmv = {
412	.mv_name		= "Highlander",
413	.mv_setup		= highlander_setup,
414	.mv_init_irq		= highlander_init_irq,
415	.mv_irq_demux		= highlander_irq_demux,
416};