Merge tag 'arc-5.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc
[linux-2.6-microblaze.git] / arch / arm / mach-ks8695 / board-dsm320.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * arch/arm/mach-ks8695/board-dsm320.c
4  *
5  * DSM-320 D-Link Wireless Media Player, board support.
6  *
7  * Copyright 2008 Simtec Electronics
8  *                Daniel Silverstone <dsilvers@simtec.co.uk>
9  */
10 #include <linux/gpio.h>
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/interrupt.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/map.h>
19 #include <linux/mtd/physmap.h>
20 #include <linux/mtd/partitions.h>
21
22 #include <asm/mach-types.h>
23
24 #include <asm/mach/arch.h>
25 #include <asm/mach/map.h>
26 #include <asm/mach/irq.h>
27
28 #include "devices.h"
29 #include <mach/gpio-ks8695.h>
30
31 #include "generic.h"
32
33 #ifdef CONFIG_PCI
34 static int dsm320_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
35 {
36         switch (slot) {
37         case 0:
38                 /* PCI-AHB bridge? */
39                 return KS8695_IRQ_EXTERN0;
40         case 18:
41                 /* Mini PCI slot */
42                 return KS8695_IRQ_EXTERN2;
43         case 20:
44                 /* RealMAGIC chip */
45                 return KS8695_IRQ_EXTERN0;
46         }
47         BUG();
48 }
49
50 static struct ks8695_pci_cfg __initdata dsm320_pci = {
51         .mode           = KS8695_MODE_MINIPCI,
52         .map_irq        = dsm320_pci_map_irq,
53 };
54
55 static void __init dsm320_register_pci(void)
56 {
57         /* Initialise the GPIO lines for interrupt mode */
58         /* RealMAGIC */
59         ks8695_gpio_interrupt(KS8695_GPIO_0, IRQ_TYPE_LEVEL_LOW);
60         /* MiniPCI Slot */
61         ks8695_gpio_interrupt(KS8695_GPIO_2, IRQ_TYPE_LEVEL_LOW);
62
63         ks8695_init_pci(&dsm320_pci);
64 }
65
66 #else
67 static inline void __init dsm320_register_pci(void) { }
68 #endif
69
70 static struct physmap_flash_data dsm320_nor_pdata = {
71         .width          = 4,
72         .nr_parts       = 0,
73 };
74
75 static struct resource dsm320_nor_resource[] = {
76         [0] = {
77                 .start = SZ_32M, /* We expect the bootloader to map
78                                   * the flash here.
79                                   */
80                 .end   = SZ_32M + SZ_4M - 1,
81                 .flags = IORESOURCE_MEM,
82         }
83 };
84
85 static struct platform_device dsm320_device_nor = {
86         .name           = "physmap-flash",
87         .id             = -1,
88         .num_resources  = ARRAY_SIZE(dsm320_nor_resource),
89         .resource       = dsm320_nor_resource,
90         .dev            = {
91                 .platform_data = &dsm320_nor_pdata,
92         },
93 };
94
95 void __init dsm320_register_nor(void)
96 {
97         int ret;
98
99         ret = platform_device_register(&dsm320_device_nor);
100         if (ret < 0)
101                 printk(KERN_ERR "failed to register physmap-flash device\n");
102 }
103
104 static void __init dsm320_init(void)
105 {
106         /* GPIO registration */
107         ks8695_register_gpios();
108
109         /* PCI registration */
110         dsm320_register_pci();
111
112         /* Network device */
113         ks8695_add_device_lan();        /* eth0 = LAN */
114
115         /* NOR devices */
116         dsm320_register_nor();
117 }
118
119 MACHINE_START(DSM320, "D-Link DSM-320 Wireless Media Player")
120         /* Maintainer: Simtec Electronics. */
121         .atag_offset    = 0x100,
122         .map_io         = ks8695_map_io,
123         .init_irq       = ks8695_init_irq,
124         .init_machine   = dsm320_init,
125         .init_time      = ks8695_timer_init,
126         .restart        = ks8695_restart,
127 MACHINE_END