xref: /linux/arch/mips/cobalt/buttons.c (revision 58e16d792a6a8c6b750f637a4649967fcac853dc)
1*16216333SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2d0a0515fSDmitry Torokhov /*
3d0a0515fSDmitry Torokhov  *  Cobalt buttons platform device.
4d0a0515fSDmitry Torokhov  *
5ada8e951SYoichi Yuasa  *  Copyright (C) 2007  Yoichi Yuasa <yuasa@linux-mips.org>
6d0a0515fSDmitry Torokhov  */
7d0a0515fSDmitry Torokhov 
8d0a0515fSDmitry Torokhov #include <linux/platform_device.h>
9d0a0515fSDmitry Torokhov #include <linux/errno.h>
10d0a0515fSDmitry Torokhov #include <linux/init.h>
11d0a0515fSDmitry Torokhov 
12d0a0515fSDmitry Torokhov static struct resource cobalt_buttons_resource __initdata = {
13d0a0515fSDmitry Torokhov 	.start	= 0x1d000000,
14d0a0515fSDmitry Torokhov 	.end	= 0x1d000003,
15d0a0515fSDmitry Torokhov 	.flags	= IORESOURCE_MEM,
16d0a0515fSDmitry Torokhov };
17d0a0515fSDmitry Torokhov 
cobalt_add_buttons(void)18d0a0515fSDmitry Torokhov static __init int cobalt_add_buttons(void)
19d0a0515fSDmitry Torokhov {
20d0a0515fSDmitry Torokhov 	struct platform_device *pd;
21d0a0515fSDmitry Torokhov 	int error;
22d0a0515fSDmitry Torokhov 
23d0a0515fSDmitry Torokhov 	pd = platform_device_alloc("Cobalt buttons", -1);
24d0a0515fSDmitry Torokhov 	if (!pd)
25d0a0515fSDmitry Torokhov 		return -ENOMEM;
26d0a0515fSDmitry Torokhov 
27d0a0515fSDmitry Torokhov 	error = platform_device_add_resources(pd, &cobalt_buttons_resource, 1);
28d0a0515fSDmitry Torokhov 	if (error)
29d0a0515fSDmitry Torokhov 		goto err_free_device;
30d0a0515fSDmitry Torokhov 
31d0a0515fSDmitry Torokhov 	error = platform_device_add(pd);
32d0a0515fSDmitry Torokhov 	if (error)
33d0a0515fSDmitry Torokhov 		goto err_free_device;
34d0a0515fSDmitry Torokhov 
35d0a0515fSDmitry Torokhov 	return 0;
36d0a0515fSDmitry Torokhov 
37d0a0515fSDmitry Torokhov  err_free_device:
38d0a0515fSDmitry Torokhov 	platform_device_put(pd);
39d0a0515fSDmitry Torokhov 	return error;
40d0a0515fSDmitry Torokhov }
41d0a0515fSDmitry Torokhov device_initcall(cobalt_add_buttons);
42