[ifxmips]
[openwrt.git] / target / linux / ifxmips / files-2.6.33 / arch / mips / ifxmips / danube / devices.c
1 #include <linux/init.h>
2 #include <linux/module.h>
3 #include <linux/types.h>
4 #include <linux/string.h>
5 #include <linux/mtd/physmap.h>
6 #include <linux/kernel.h>
7 #include <linux/reboot.h>
8 #include <linux/platform_device.h>
9 #include <linux/leds.h>
10 #include <linux/etherdevice.h>
11 #include <linux/reboot.h>
12 #include <linux/time.h>
13 #include <linux/io.h>
14 #include <linux/gpio.h>
15 #include <linux/leds.h>
16
17 #include <asm/bootinfo.h>
18 #include <asm/irq.h>
19
20 #include <ifxmips.h>
21 #include <ifxmips_irq.h>
22
23 #include "devices.h"
24
25 /* usb */
26 static struct resource dwc_usb_res[] =
27 {
28         {
29                 .name = "dwc3884_membase",
30                 .flags = IORESOURCE_MEM,
31                 .start = 0x1E101000,
32                 .end = 0x1E101FFF
33         },
34         {
35                 .name = "dwc3884_irq",
36                 .flags = IORESOURCE_IRQ,
37                 .start = IFXMIPS_USB_INT,
38         }
39 };
40
41 static struct platform_device dwc_usb =
42 {
43         .name = "dwc3884-hcd",
44         .resource = dwc_usb_res,
45         .num_resources = ARRAY_SIZE(dwc_usb_res),
46 };
47
48 void __init
49 danube_register_usb(void)
50 {
51         platform_device_register(&dwc_usb);
52 }
53
54 /* ebu gpio */
55 static struct platform_device ifxmips_ebu_gpio =
56 {
57         .name = "ifxmips_ebu",
58         .num_resources = 1,
59 };
60
61 void __init
62 danube_register_ebu_gpio(struct resource *resource, u32 value)
63 {
64         ifxmips_ebu_gpio.resource = resource;
65         ifxmips_ebu_gpio.dev.platform_data = (void*)value;
66         platform_device_register(&ifxmips_ebu_gpio);
67 }
68
69 /* ethernet */
70 unsigned char ifxmips_ethaddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
71 static struct resource danube_ethernet_resources =
72 {
73         .start  = IFXMIPS_PPE32_BASE_ADDR,
74         .end    = IFXMIPS_PPE32_BASE_ADDR + IFXMIPS_PPE32_SIZE - 1,
75         .flags  = IORESOURCE_MEM,
76 };
77
78 static struct platform_device danube_ethernet =
79 {
80         .name                   = "ifxmips_mii0",
81         .resource               = &danube_ethernet_resources,
82         .num_resources  = 1,
83         .dev = {
84                 .platform_data = ifxmips_ethaddr,
85         }
86 };
87
88 void __init
89 danube_register_ethernet(unsigned char *mac, int mii_mode)
90 {
91         struct ifxmips_eth_data *eth = kmalloc(sizeof(struct ifxmips_eth_data), GFP_KERNEL);
92         memset(eth, 0, sizeof(struct ifxmips_eth_data));
93         if(mac)
94                 eth->mac = mac;
95         else
96                 eth->mac = ifxmips_ethaddr;
97         eth->mii_mode = mii_mode;
98         danube_ethernet.dev.platform_data = eth;
99         platform_device_register(&danube_ethernet);
100 }
101
102 /* pci */
103 extern int ifxmips_pci_external_clock;
104 extern int ifxmips_pci_req_mask;
105
106 void __init
107 danube_register_pci(int clock, int irq_mask)
108 {
109         ifxmips_pci_external_clock = clock;
110         if(irq_mask)
111                 ifxmips_pci_req_mask = irq_mask;
112 }