| Daniel Silverstone | 6174dee | 2008-12-13 20:44:15 +0000 | [diff] [blame] | 1 | /* | 
 | 2 |  * arch/arm/mach-ks8695/board-dsm320.c | 
 | 3 |  * | 
 | 4 |  * DSM-320 D-Link Wireless Media Player, board support. | 
 | 5 |  * | 
 | 6 |  * Copyright 2008 Simtec Electronics | 
 | 7 |  *		  Daniel Silverstone <dsilvers@simtec.co.uk> | 
 | 8 |  * | 
 | 9 |  * This program is free software; you can redistribute it and/or modify | 
 | 10 |  * it under the terms of the GNU General Public License version 2 as | 
 | 11 |  * published by the Free Software Foundation. | 
 | 12 |  */ | 
| Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 13 | #include <linux/gpio.h> | 
| Daniel Silverstone | 6174dee | 2008-12-13 20:44:15 +0000 | [diff] [blame] | 14 | #include <linux/kernel.h> | 
 | 15 | #include <linux/types.h> | 
 | 16 | #include <linux/interrupt.h> | 
 | 17 | #include <linux/init.h> | 
 | 18 | #include <linux/platform_device.h> | 
 | 19 |  | 
 | 20 | #include <linux/mtd/mtd.h> | 
 | 21 | #include <linux/mtd/map.h> | 
 | 22 | #include <linux/mtd/physmap.h> | 
 | 23 | #include <linux/mtd/partitions.h> | 
 | 24 |  | 
 | 25 | #include <asm/mach-types.h> | 
 | 26 |  | 
 | 27 | #include <asm/mach/arch.h> | 
 | 28 | #include <asm/mach/map.h> | 
 | 29 | #include <asm/mach/irq.h> | 
 | 30 |  | 
 | 31 | #include <mach/devices.h> | 
| Linus Walleij | e24e449 | 2011-08-22 08:37:38 +0100 | [diff] [blame] | 32 | #include <mach/gpio-ks8695.h> | 
| Daniel Silverstone | 6174dee | 2008-12-13 20:44:15 +0000 | [diff] [blame] | 33 |  | 
 | 34 | #include "generic.h" | 
 | 35 |  | 
 | 36 | #ifdef CONFIG_PCI | 
| Ralf Baechle | d534194 | 2011-06-10 15:30:21 +0100 | [diff] [blame] | 37 | static int dsm320_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 
| Daniel Silverstone | 6174dee | 2008-12-13 20:44:15 +0000 | [diff] [blame] | 38 | { | 
 | 39 | 	switch (slot) { | 
 | 40 | 	case 0: | 
 | 41 | 		/* PCI-AHB bridge? */ | 
 | 42 | 		return KS8695_IRQ_EXTERN0; | 
 | 43 | 	case 18: | 
 | 44 | 		/* Mini PCI slot */ | 
 | 45 | 		return KS8695_IRQ_EXTERN2; | 
 | 46 | 	case 20: | 
 | 47 | 		/* RealMAGIC chip */ | 
 | 48 | 		return KS8695_IRQ_EXTERN0; | 
 | 49 | 	} | 
 | 50 | 	BUG(); | 
 | 51 | } | 
 | 52 |  | 
 | 53 | static struct ks8695_pci_cfg __initdata dsm320_pci = { | 
 | 54 | 	.mode		= KS8695_MODE_MINIPCI, | 
 | 55 | 	.map_irq	= dsm320_pci_map_irq, | 
 | 56 | }; | 
 | 57 |  | 
 | 58 | static void __init dsm320_register_pci(void) | 
 | 59 | { | 
 | 60 | 	/* Initialise the GPIO lines for interrupt mode */ | 
 | 61 | 	/* RealMAGIC */ | 
 | 62 | 	ks8695_gpio_interrupt(KS8695_GPIO_0, IRQ_TYPE_LEVEL_LOW); | 
 | 63 | 	/* MiniPCI Slot */ | 
 | 64 | 	ks8695_gpio_interrupt(KS8695_GPIO_2, IRQ_TYPE_LEVEL_LOW); | 
 | 65 |  | 
 | 66 | 	ks8695_init_pci(&dsm320_pci); | 
 | 67 | } | 
 | 68 |  | 
 | 69 | #else | 
 | 70 | static inline void __init dsm320_register_pci(void) { } | 
 | 71 | #endif | 
 | 72 |  | 
 | 73 | static struct physmap_flash_data dsm320_nor_pdata = { | 
 | 74 | 	.width		= 4, | 
 | 75 | 	.nr_parts	= 0, | 
 | 76 | }; | 
 | 77 |  | 
 | 78 | static struct resource dsm320_nor_resource[] = { | 
 | 79 | 	[0] = { | 
 | 80 | 		.start = SZ_32M, /* We expect the bootloader to map | 
 | 81 | 				  * the flash here. | 
 | 82 | 				  */ | 
 | 83 | 		.end   = SZ_32M + SZ_4M - 1, | 
 | 84 | 		.flags = IORESOURCE_MEM, | 
 | 85 | 	} | 
 | 86 | }; | 
 | 87 |  | 
 | 88 | static struct platform_device dsm320_device_nor = { | 
 | 89 | 	.name		= "physmap-flash", | 
 | 90 | 	.id		= -1, | 
 | 91 | 	.num_resources	= ARRAY_SIZE(dsm320_nor_resource), | 
 | 92 | 	.resource	= dsm320_nor_resource, | 
 | 93 | 	.dev		= { | 
 | 94 | 		.platform_data = &dsm320_nor_pdata, | 
 | 95 | 	}, | 
 | 96 | }; | 
 | 97 |  | 
 | 98 | void __init dsm320_register_nor(void) | 
 | 99 | { | 
 | 100 | 	int ret; | 
 | 101 |  | 
 | 102 | 	ret = platform_device_register(&dsm320_device_nor); | 
 | 103 | 	if (ret < 0) | 
 | 104 | 		printk(KERN_ERR "failed to register physmap-flash device\n"); | 
 | 105 | } | 
 | 106 |  | 
 | 107 | static void __init dsm320_init(void) | 
 | 108 | { | 
 | 109 | 	/* GPIO registration */ | 
 | 110 | 	ks8695_register_gpios(); | 
 | 111 |  | 
 | 112 | 	/* PCI registration */ | 
 | 113 | 	dsm320_register_pci(); | 
 | 114 |  | 
 | 115 | 	/* Network device */ | 
 | 116 | 	ks8695_add_device_lan();	/* eth0 = LAN */ | 
 | 117 |  | 
 | 118 | 	/* NOR devices */ | 
 | 119 | 	dsm320_register_nor(); | 
 | 120 | } | 
 | 121 |  | 
 | 122 | MACHINE_START(DSM320, "D-Link DSM-320 Wireless Media Player") | 
 | 123 | 	/* Maintainer: Simtec Electronics. */ | 
| Nicolas Pitre | 0318ce9 | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 124 | 	.atag_offset	= 0x100, | 
| Daniel Silverstone | 6174dee | 2008-12-13 20:44:15 +0000 | [diff] [blame] | 125 | 	.map_io		= ks8695_map_io, | 
 | 126 | 	.init_irq	= ks8695_init_irq, | 
 | 127 | 	.init_machine	= dsm320_init, | 
 | 128 | 	.timer		= &ks8695_timer, | 
| Russell King | 114c19b | 2011-11-11 15:30:47 +0000 | [diff] [blame] | 129 | 	.restart	= ks8695_restart, | 
| Daniel Silverstone | 6174dee | 2008-12-13 20:44:15 +0000 | [diff] [blame] | 130 | MACHINE_END |