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