board-apollon-keys.c 1.83 KB
Newer Older
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
/*
 * linux/arch/arm/mach-omap2/board-apollon-keys.c
 *
 * Copyright (C) 2007 Samsung Electronics
 * Author: Kyungmin Park <kyungmin.park@samsung.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/gpio_keys.h>

#include <asm/arch/gpio.h>
#include <asm/arch/mux.h>

#define SW_ENTER_GPIO16		16
#define SW_UP_GPIO17		17
#define SW_DOWN_GPIO58		58

static struct gpio_keys_button apollon_gpio_keys_buttons[] = {
	[0] = {
		.keycode	= KEY_ENTER,
		.gpio		= SW_ENTER_GPIO16,
		.desc		= "enter sw",
	},
	[1] = {
		.keycode	= KEY_UP,
		.gpio		= SW_UP_GPIO17,
		.desc		= "up sw",
	},
	[2] = {
		.keycode	= KEY_DOWN,
		.gpio		= SW_DOWN_GPIO58,
		.desc		= "down sw",
	},
};

static struct gpio_keys_platform_data apollon_gpio_keys = {
	.buttons		= apollon_gpio_keys_buttons,
	.nbuttons		= ARRAY_SIZE(apollon_gpio_keys_buttons),
};

static struct platform_device apollon_gpio_keys_device = {
	.name			= "gpio-keys",
	.id			= -1,
	.dev			= {
		.platform_data	= &apollon_gpio_keys,
	},
};

static void __init apollon_sw_init(void)
{
	/* Enter SW - Y11 */
	omap_cfg_reg(Y11_242X_GPIO16);
	omap_request_gpio(SW_ENTER_GPIO16);
	omap_set_gpio_direction(SW_ENTER_GPIO16, 1);
	/* Up SW - AA12 */
	omap_cfg_reg(AA12_242X_GPIO17);
	omap_request_gpio(SW_UP_GPIO17);
	omap_set_gpio_direction(SW_UP_GPIO17, 1);
	/* Down SW - AA8 */
	omap_cfg_reg(AA8_242X_GPIO58);
	omap_request_gpio(SW_DOWN_GPIO58);
	omap_set_gpio_direction(SW_DOWN_GPIO58, 1);
}

static int __init omap_apollon_keys_init(void)
{
	apollon_sw_init();

	return platform_device_register(&apollon_gpio_keys_device);
}

arch_initcall(omap_apollon_keys_init);