1 // SPDX-License-Identifier: GPL-2.0
3 * arch/sh/boards/landisk/psw.c
5 * push switch support for LANDISK and USL-5P
7 * Copyright (C) 2006-2007 Paul Mundt
8 * Copyright (C) 2007 kogiidena
11 #include <linux/init.h>
12 #include <linux/interrupt.h>
13 #include <linux/platform_device.h>
14 #include <mach-landisk/mach/iodata_landisk.h>
15 #include <asm/push-switch.h>
17 static irqreturn_t
psw_irq_handler(int irq
, void *arg
)
19 struct platform_device
*pdev
= arg
;
20 struct push_switch
*psw
= platform_get_drvdata(pdev
);
21 struct push_switch_platform_info
*psw_info
= pdev
->dev
.platform_data
;
22 unsigned int sw_value
;
25 sw_value
= (0x0ff & (~__raw_readb(PA_STATUS
)));
27 /* Nothing to do if there's no state change */
33 /* Figure out who raised it */
34 if (sw_value
& (1 << psw_info
->bit
)) {
36 mod_timer(&psw
->debounce
, jiffies
+ 50);
41 /* Clear the switch IRQs */
42 __raw_writeb(0x00, PA_PWRINT_CLR
);
44 return IRQ_RETVAL(ret
);
47 static struct resource psw_power_resources
[] = {
50 .flags
= IORESOURCE_IRQ
,
54 static struct resource psw_usl5p_resources
[] = {
57 .flags
= IORESOURCE_IRQ
,
61 static struct push_switch_platform_info psw_power_platform_data
= {
64 .irq_flags
= IRQF_SHARED
,
65 .irq_handler
= psw_irq_handler
,
68 static struct push_switch_platform_info psw1_platform_data
= {
71 .irq_flags
= IRQF_SHARED
,
72 .irq_handler
= psw_irq_handler
,
75 static struct push_switch_platform_info psw2_platform_data
= {
78 .irq_flags
= IRQF_SHARED
,
79 .irq_handler
= psw_irq_handler
,
82 static struct push_switch_platform_info psw3_platform_data
= {
85 .irq_flags
= IRQF_SHARED
,
86 .irq_handler
= psw_irq_handler
,
89 static struct platform_device psw_power_switch_device
= {
90 .name
= "push-switch",
92 .num_resources
= ARRAY_SIZE(psw_power_resources
),
93 .resource
= psw_power_resources
,
95 .platform_data
= &psw_power_platform_data
,
99 static struct platform_device psw1_switch_device
= {
100 .name
= "push-switch",
102 .num_resources
= ARRAY_SIZE(psw_usl5p_resources
),
103 .resource
= psw_usl5p_resources
,
105 .platform_data
= &psw1_platform_data
,
109 static struct platform_device psw2_switch_device
= {
110 .name
= "push-switch",
112 .num_resources
= ARRAY_SIZE(psw_usl5p_resources
),
113 .resource
= psw_usl5p_resources
,
115 .platform_data
= &psw2_platform_data
,
119 static struct platform_device psw3_switch_device
= {
120 .name
= "push-switch",
122 .num_resources
= ARRAY_SIZE(psw_usl5p_resources
),
123 .resource
= psw_usl5p_resources
,
125 .platform_data
= &psw3_platform_data
,
129 static struct platform_device
*psw_devices
[] = {
130 &psw_power_switch_device
,
136 static int __init
psw_init(void)
138 return platform_add_devices(psw_devices
, ARRAY_SIZE(psw_devices
));
140 device_initcall(psw_init
);