xref: /linux/arch/mips/cobalt/buttons.c (revision ada8e9514b5880f81cdbbd212d121380ceef7acc)
1d0a0515fSDmitry Torokhov /*
2d0a0515fSDmitry Torokhov  *  Cobalt buttons platform device.
3d0a0515fSDmitry Torokhov  *
4*ada8e951SYoichi Yuasa  *  Copyright (C) 2007  Yoichi Yuasa <yuasa@linux-mips.org>
5d0a0515fSDmitry Torokhov  *
6d0a0515fSDmitry Torokhov  *  This program is free software; you can redistribute it and/or modify
7d0a0515fSDmitry Torokhov  *  it under the terms of the GNU General Public License as published by
8d0a0515fSDmitry Torokhov  *  the Free Software Foundation; either version 2 of the License, or
9d0a0515fSDmitry Torokhov  *  (at your option) any later version.
10d0a0515fSDmitry Torokhov  *
11d0a0515fSDmitry Torokhov  *  This program is distributed in the hope that it will be useful,
12d0a0515fSDmitry Torokhov  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13d0a0515fSDmitry Torokhov  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14d0a0515fSDmitry Torokhov  *  GNU General Public License for more details.
15d0a0515fSDmitry Torokhov  *
16d0a0515fSDmitry Torokhov  *  You should have received a copy of the GNU General Public License
17d0a0515fSDmitry Torokhov  *  along with this program; if not, write to the Free Software
18d0a0515fSDmitry Torokhov  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19d0a0515fSDmitry Torokhov  */
20d0a0515fSDmitry Torokhov 
21d0a0515fSDmitry Torokhov #include <linux/platform_device.h>
22d0a0515fSDmitry Torokhov #include <linux/errno.h>
23d0a0515fSDmitry Torokhov #include <linux/init.h>
24d0a0515fSDmitry Torokhov 
25d0a0515fSDmitry Torokhov static struct resource cobalt_buttons_resource __initdata = {
26d0a0515fSDmitry Torokhov 	.start	= 0x1d000000,
27d0a0515fSDmitry Torokhov 	.end	= 0x1d000003,
28d0a0515fSDmitry Torokhov 	.flags	= IORESOURCE_MEM,
29d0a0515fSDmitry Torokhov };
30d0a0515fSDmitry Torokhov 
31d0a0515fSDmitry Torokhov static __init int cobalt_add_buttons(void)
32d0a0515fSDmitry Torokhov {
33d0a0515fSDmitry Torokhov 	struct platform_device *pd;
34d0a0515fSDmitry Torokhov 	int error;
35d0a0515fSDmitry Torokhov 
36d0a0515fSDmitry Torokhov 	pd = platform_device_alloc("Cobalt buttons", -1);
37d0a0515fSDmitry Torokhov 	if (!pd)
38d0a0515fSDmitry Torokhov 		return -ENOMEM;
39d0a0515fSDmitry Torokhov 
40d0a0515fSDmitry Torokhov 	error = platform_device_add_resources(pd, &cobalt_buttons_resource, 1);
41d0a0515fSDmitry Torokhov 	if (error)
42d0a0515fSDmitry Torokhov 		goto err_free_device;
43d0a0515fSDmitry Torokhov 
44d0a0515fSDmitry Torokhov 	error = platform_device_add(pd);
45d0a0515fSDmitry Torokhov 	if (error)
46d0a0515fSDmitry Torokhov 		goto err_free_device;
47d0a0515fSDmitry Torokhov 
48d0a0515fSDmitry Torokhov 	return 0;
49d0a0515fSDmitry Torokhov 
50d0a0515fSDmitry Torokhov  err_free_device:
51d0a0515fSDmitry Torokhov 	platform_device_put(pd);
52d0a0515fSDmitry Torokhov 	return error;
53d0a0515fSDmitry Torokhov }
54d0a0515fSDmitry Torokhov device_initcall(cobalt_add_buttons);
55