2 * arch/sh/boards/landisk/psw.c
4 * push switch support for LANDISK and USL-5P
6 * Copyright (C) 2006-2007 Paul Mundt
7 * Copyright (C) 2007 kogiidena
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
14 #include <linux/init.h>
15 #include <linux/interrupt.h>
16 #include <linux/platform_device.h>
17 #include <mach-landisk/mach/iodata_landisk.h>
18 #include <asm/push-switch.h>
20 static irqreturn_t psw_irq_handler(int irq, void *arg)
22 struct platform_device *pdev = arg;
23 struct push_switch *psw = platform_get_drvdata(pdev);
24 struct push_switch_platform_info *psw_info = pdev->dev.platform_data;
25 unsigned int sw_value;
28 sw_value = (0x0ff & (~ctrl_inb(PA_STATUS)));
30 /* Nothing to do if there's no state change */
36 /* Figure out who raised it */
37 if (sw_value & (1 << psw_info->bit)) {
39 mod_timer(&psw->debounce, jiffies + 50);
44 /* Clear the switch IRQs */
45 ctrl_outb(0x00, PA_PWRINT_CLR);
47 return IRQ_RETVAL(ret);
50 static struct resource psw_power_resources[] = {
53 .flags = IORESOURCE_IRQ,
57 static struct resource psw_usl5p_resources[] = {
60 .flags = IORESOURCE_IRQ,
64 static struct push_switch_platform_info psw_power_platform_data = {
67 .irq_flags = IRQF_SHARED,
68 .irq_handler = psw_irq_handler,
71 static struct push_switch_platform_info psw1_platform_data = {
74 .irq_flags = IRQF_SHARED,
75 .irq_handler = psw_irq_handler,
78 static struct push_switch_platform_info psw2_platform_data = {
81 .irq_flags = IRQF_SHARED,
82 .irq_handler = psw_irq_handler,
85 static struct push_switch_platform_info psw3_platform_data = {
88 .irq_flags = IRQF_SHARED,
89 .irq_handler = psw_irq_handler,
92 static struct platform_device psw_power_switch_device = {
93 .name = "push-switch",
95 .num_resources = ARRAY_SIZE(psw_power_resources),
96 .resource = psw_power_resources,
98 .platform_data = &psw_power_platform_data,
102 static struct platform_device psw1_switch_device = {
103 .name = "push-switch",
105 .num_resources = ARRAY_SIZE(psw_usl5p_resources),
106 .resource = psw_usl5p_resources,
108 .platform_data = &psw1_platform_data,
112 static struct platform_device psw2_switch_device = {
113 .name = "push-switch",
115 .num_resources = ARRAY_SIZE(psw_usl5p_resources),
116 .resource = psw_usl5p_resources,
118 .platform_data = &psw2_platform_data,
122 static struct platform_device psw3_switch_device = {
123 .name = "push-switch",
125 .num_resources = ARRAY_SIZE(psw_usl5p_resources),
126 .resource = psw_usl5p_resources,
128 .platform_data = &psw3_platform_data,
132 static struct platform_device *psw_devices[] = {
133 &psw_power_switch_device,
139 static int __init psw_init(void)
141 return platform_add_devices(psw_devices, ARRAY_SIZE(psw_devices));
143 module_init(psw_init);