summaryrefslogtreecommitdiff
path: root/target/linux/ifxmips/files-2.6.32/arch/mips/ifxmips/common/devices.c
blob: dcd2346c8ef9dcfb2e0428898b04d1b7ed80b347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <linux/init.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/mtd/physmap.h>
#include <linux/kernel.h>
#include <linux/reboot.h>
#include <linux/platform_device.h>
#include <linux/leds.h>
#include <linux/etherdevice.h>
#include <linux/reboot.h>
#include <linux/time.h>
#include <linux/io.h>
#include <linux/gpio.h>
#include <linux/leds.h>

#include <asm/bootinfo.h>
#include <asm/irq.h>

#include <ifxmips.h>
#include <ifxmips_irq.h>

/* gpiodev */
static struct platform_device ifxmips_gpio_dev =
{
	.name			= "GPIODEV",
	.num_resources	= 1,
};

void __init
ifxmips_register_gpio_dev(void)
{
	platform_device_register(&ifxmips_gpio_dev);
}

/* gpio leds */
#ifdef CONFIG_LEDS_GPIO
static struct gpio_led_platform_data ifxmips_gpio_led_data;

static struct platform_device ifxmips_gpio_leds =
{
	.name = "leds-gpio",
	.dev = {
		.platform_data = (void *) &ifxmips_gpio_led_data,
	}
};

void __init
ifxmips_register_gpio_leds(struct gpio_led *leds, int cnt)
{
	ifxmips_gpio_led_data.leds = leds;
	ifxmips_gpio_led_data.num_leds = cnt;
	platform_device_register(&ifxmips_gpio_leds);
}
#endif

/* leds */
static struct gpio_led_platform_data ifxmips_led_data;

static struct platform_device ifxmips_led =
{
	.name = "ifxmips_led",
	.dev = {
		.platform_data = (void *) &ifxmips_led_data,
	}
};

void __init
ifxmips_register_leds(struct gpio_led *leds, int cnt)
{
	ifxmips_led_data.leds = leds;
	ifxmips_led_data.num_leds = cnt;
	platform_device_register(&ifxmips_led);
}

/* mtd flash */
static struct resource ifxmips_mtd_resource =
{
	.start  = IFXMIPS_FLASH_START,
	.end    = IFXMIPS_FLASH_START + IFXMIPS_FLASH_MAX - 1,
	.flags  = IORESOURCE_MEM,
};

static struct platform_device ifxmips_mtd =
{
	.name			= "ifxmips_mtd",
	.resource		= &ifxmips_mtd_resource,
	.num_resources	= 1,
};

void __init
ifxmips_register_mtd(struct physmap_flash_data *pdata)
{
	ifxmips_mtd.dev.platform_data = pdata;
	platform_device_register(&ifxmips_mtd);
}

/* watchdog */
static struct resource ifxmips_wdt_resource =
{
	.start  = IFXMIPS_WDT_BASE_ADDR,
	.end    = IFXMIPS_WDT_BASE_ADDR + IFXMIPS_WDT_SIZE - 1,
	.flags  = IORESOURCE_MEM,
};

static struct platform_device ifxmips_wdt =
{
	.name			= "ifxmips_wdt",
	.resource		= &ifxmips_wdt_resource,
	.num_resources = 1,
};

void __init
ifxmips_register_wdt(void)
{
	platform_device_register(&ifxmips_wdt);
}

/* gpio */
static struct platform_device ifxmips_gpio0 =
{
	.name = "ifxmips_gpio",
};

static struct platform_device ifxmips_gpio1 =
{
	.name = "ifxmips_gpio1",
};

void __init
ifxmips_register_gpio(void)
{
	platform_device_register(&ifxmips_gpio0);
	platform_device_register(&ifxmips_gpio1);
}