1 /*
2  *  This program is free software; you can redistribute it and/or modify it
3  *  under the terms of the GNU General Public License version 2 as published
4  *  by the Free Software Foundation.
5  *
6  *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
7  */
8 
9 #include <linux/init.h>
10 #include <linux/export.h>
11 #include <linux/types.h>
12 #include <linux/string.h>
13 #include <linux/kernel.h>
14 #include <linux/reboot.h>
15 #include <linux/platform_device.h>
16 #include <linux/leds.h>
17 #include <linux/etherdevice.h>
18 #include <linux/time.h>
19 #include <linux/io.h>
20 #include <linux/gpio.h>
21 
22 #include <asm/bootinfo.h>
23 #include <asm/irq.h>
24 
25 #include <lantiq_soc.h>
26 
27 #include "devices.h"
28 
29 /* nor flash */
30 static struct resource ltq_nor_resource = {
31 	.name	= "nor",
32 	.start	= LTQ_FLASH_START,
33 	.end	= LTQ_FLASH_START + LTQ_FLASH_MAX - 1,
34 	.flags  = IORESOURCE_MEM,
35 };
36 
37 static struct platform_device ltq_nor = {
38 	.name		= "ltq_nor",
39 	.resource	= &ltq_nor_resource,
40 	.num_resources	= 1,
41 };
42 
ltq_register_nor(struct physmap_flash_data * data)43 void __init ltq_register_nor(struct physmap_flash_data *data)
44 {
45 	ltq_nor.dev.platform_data = data;
46 	platform_device_register(&ltq_nor);
47 }
48 
49 /* watchdog */
50 static struct resource ltq_wdt_resource = {
51 	.name	= "watchdog",
52 	.start  = LTQ_WDT_BASE_ADDR,
53 	.end    = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1,
54 	.flags  = IORESOURCE_MEM,
55 };
56 
ltq_register_wdt(void)57 void __init ltq_register_wdt(void)
58 {
59 	platform_device_register_simple("ltq_wdt", 0, &ltq_wdt_resource, 1);
60 }
61 
62 /* asc ports */
63 static struct resource ltq_asc0_resources[] = {
64 	{
65 		.name	= "asc0",
66 		.start  = LTQ_ASC0_BASE_ADDR,
67 		.end    = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1,
68 		.flags  = IORESOURCE_MEM,
69 	},
70 	IRQ_RES(tx, LTQ_ASC_TIR(0)),
71 	IRQ_RES(rx, LTQ_ASC_RIR(0)),
72 	IRQ_RES(err, LTQ_ASC_EIR(0)),
73 };
74 
75 static struct resource ltq_asc1_resources[] = {
76 	{
77 		.name	= "asc1",
78 		.start  = LTQ_ASC1_BASE_ADDR,
79 		.end    = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
80 		.flags  = IORESOURCE_MEM,
81 	},
82 	IRQ_RES(tx, LTQ_ASC_TIR(1)),
83 	IRQ_RES(rx, LTQ_ASC_RIR(1)),
84 	IRQ_RES(err, LTQ_ASC_EIR(1)),
85 };
86 
ltq_register_asc(int port)87 void __init ltq_register_asc(int port)
88 {
89 	switch (port) {
90 	case 0:
91 		platform_device_register_simple("ltq_asc", 0,
92 			ltq_asc0_resources, ARRAY_SIZE(ltq_asc0_resources));
93 		break;
94 	case 1:
95 		platform_device_register_simple("ltq_asc", 1,
96 			ltq_asc1_resources, ARRAY_SIZE(ltq_asc1_resources));
97 		break;
98 	default:
99 		break;
100 	}
101 }
102 
103 #ifdef CONFIG_PCI
104 /* pci */
105 static struct platform_device ltq_pci = {
106 	.name		= "ltq_pci",
107 	.num_resources	= 0,
108 };
109 
ltq_register_pci(struct ltq_pci_data * data)110 void __init ltq_register_pci(struct ltq_pci_data *data)
111 {
112 	ltq_pci.dev.platform_data = data;
113 	platform_device_register(&ltq_pci);
114 }
115 #else
ltq_register_pci(struct ltq_pci_data * data)116 void __init ltq_register_pci(struct ltq_pci_data *data)
117 {
118 	pr_err("kernel is compiled without PCI support\n");
119 }
120 #endif
121