Path: blob/master/arch/sh/boards/mach-highlander/psw.c
15126 views
/*1* arch/sh/boards/renesas/r7780rp/psw.c2*3* push switch support for RDBRP-1/RDBREVRP-1 debug boards.4*5* Copyright (C) 2006 Paul Mundt6*7* This file is subject to the terms and conditions of the GNU General Public8* License. See the file "COPYING" in the main directory of this archive9* for more details.10*/11#include <linux/io.h>12#include <linux/init.h>13#include <linux/interrupt.h>14#include <linux/platform_device.h>15#include <mach/highlander.h>16#include <asm/push-switch.h>1718static irqreturn_t psw_irq_handler(int irq, void *arg)19{20struct platform_device *pdev = arg;21struct push_switch *psw = platform_get_drvdata(pdev);22struct push_switch_platform_info *psw_info = pdev->dev.platform_data;23unsigned int l, mask;24int ret = 0;2526l = __raw_readw(PA_DBSW);2728/* Nothing to do if there's no state change */29if (psw->state) {30ret = 1;31goto out;32}3334mask = l & 0x70;35/* Figure out who raised it */36if (mask & (1 << psw_info->bit)) {37psw->state = !!(mask & (1 << psw_info->bit));38if (psw->state) /* debounce */39mod_timer(&psw->debounce, jiffies + 50);4041ret = 1;42}4344out:45/* Clear the switch IRQs */46l |= (0x7 << 12);47__raw_writew(l, PA_DBSW);4849return IRQ_RETVAL(ret);50}5152static struct resource psw_resources[] = {53[0] = {54.start = IRQ_PSW,55.flags = IORESOURCE_IRQ,56},57};5859static struct push_switch_platform_info s2_platform_data = {60.name = "s2",61.bit = 6,62.irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |63IRQF_SHARED,64.irq_handler = psw_irq_handler,65};6667static struct platform_device s2_switch_device = {68.name = "push-switch",69.id = 0,70.num_resources = ARRAY_SIZE(psw_resources),71.resource = psw_resources,72.dev = {73.platform_data = &s2_platform_data,74},75};7677static struct push_switch_platform_info s3_platform_data = {78.name = "s3",79.bit = 5,80.irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |81IRQF_SHARED,82.irq_handler = psw_irq_handler,83};8485static struct platform_device s3_switch_device = {86.name = "push-switch",87.id = 1,88.num_resources = ARRAY_SIZE(psw_resources),89.resource = psw_resources,90.dev = {91.platform_data = &s3_platform_data,92},93};9495static struct push_switch_platform_info s4_platform_data = {96.name = "s4",97.bit = 4,98.irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |99IRQF_SHARED,100.irq_handler = psw_irq_handler,101};102103static struct platform_device s4_switch_device = {104.name = "push-switch",105.id = 2,106.num_resources = ARRAY_SIZE(psw_resources),107.resource = psw_resources,108.dev = {109.platform_data = &s4_platform_data,110},111};112113static struct platform_device *psw_devices[] = {114&s2_switch_device, &s3_switch_device, &s4_switch_device,115};116117static int __init psw_init(void)118{119return platform_add_devices(psw_devices, ARRAY_SIZE(psw_devices));120}121module_init(psw_init);122123124