MIPS: SEAD3: Collect LED platform device registration in a single file.
[linux-drm-fsl-dcu.git] / arch / mips / mti-sead3 / sead3-leds.c
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
7  */
8 #include <linux/init.h>
9 #include <linux/leds.h>
10 #include <linux/platform_device.h>
11
12 #define LEDFLAGS(bits, shift)           \
13         ((bits << 8) | (shift << 8))
14
15 #define LEDBITS(id, shift, bits)        \
16         .name = id #shift,              \
17         .flags = LEDFLAGS(bits, shift)
18
19 struct led_info led_data_info[] = {
20         { LEDBITS("bit", 0, 1) },
21         { LEDBITS("bit", 1, 1) },
22         { LEDBITS("bit", 2, 1) },
23         { LEDBITS("bit", 3, 1) },
24         { LEDBITS("bit", 4, 1) },
25         { LEDBITS("bit", 5, 1) },
26         { LEDBITS("bit", 6, 1) },
27         { LEDBITS("bit", 7, 1) },
28         { LEDBITS("all", 0, 8) },
29 };
30
31 static struct led_platform_data led_data = {
32         .num_leds       = ARRAY_SIZE(led_data_info),
33         .leds           = led_data_info
34 };
35
36 static struct resource pled_resources[] = {
37         {
38                 .start  = 0x1f000210,
39                 .end    = 0x1f000217,
40                 .flags  = IORESOURCE_MEM
41         }
42 };
43
44 static struct platform_device pled_device = {
45         .name                   = "sead3::pled",
46         .id                     = 0,
47         .dev                    = {
48                 .platform_data  = &led_data,
49         },
50         .num_resources          = ARRAY_SIZE(pled_resources),
51         .resource               = pled_resources
52 };
53
54
55 static struct resource fled_resources[] = {
56         {
57                 .start                  = 0x1f000218,
58                 .end                    = 0x1f00021f,
59                 .flags                  = IORESOURCE_MEM
60         }
61 };
62
63 static struct platform_device fled_device = {
64         .name                   = "sead3::fled",
65         .id                     = 0,
66         .dev                    = {
67                 .platform_data  = &led_data,
68         },
69         .num_resources          = ARRAY_SIZE(fled_resources),
70         .resource               = fled_resources
71 };
72
73 static struct platform_device sead3_led_device = {
74         .name   = "sead3-led",
75         .id     = -1,
76 };
77
78 struct platform_device *sead3_led_devices[] = {
79         &pled_device,
80         &fled_device,
81         &sead3_led_device,
82 };
83
84 static int __init sead3_led_init(void)
85 {
86         return platform_add_devices(sead3_led_devices, ARRAY_SIZE(sead3_led_devices));
87 }
88
89 device_initcall(sead3_led_init);