Path: blob/master/arch/sh/boards/mach-landisk/psw.c
15126 views
/*1* arch/sh/boards/landisk/psw.c2*3* push switch support for LANDISK and USL-5P4*5* Copyright (C) 2006-2007 Paul Mundt6* Copyright (C) 2007 kogiidena7*8* This file is subject to the terms and conditions of the GNU General Public9* License. See the file "COPYING" in the main directory of this archive10* for more details.11*/12#include <linux/io.h>13#include <linux/init.h>14#include <linux/interrupt.h>15#include <linux/platform_device.h>16#include <mach-landisk/mach/iodata_landisk.h>17#include <asm/push-switch.h>1819static irqreturn_t psw_irq_handler(int irq, void *arg)20{21struct platform_device *pdev = arg;22struct push_switch *psw = platform_get_drvdata(pdev);23struct push_switch_platform_info *psw_info = pdev->dev.platform_data;24unsigned int sw_value;25int ret = 0;2627sw_value = (0x0ff & (~__raw_readb(PA_STATUS)));2829/* Nothing to do if there's no state change */30if (psw->state) {31ret = 1;32goto out;33}3435/* Figure out who raised it */36if (sw_value & (1 << psw_info->bit)) {37psw->state = 1;38mod_timer(&psw->debounce, jiffies + 50);39ret = 1;40}4142out:43/* Clear the switch IRQs */44__raw_writeb(0x00, PA_PWRINT_CLR);4546return IRQ_RETVAL(ret);47}4849static struct resource psw_power_resources[] = {50[0] = {51.start = IRQ_POWER,52.flags = IORESOURCE_IRQ,53},54};5556static struct resource psw_usl5p_resources[] = {57[0] = {58.start = IRQ_BUTTON,59.flags = IORESOURCE_IRQ,60},61};6263static struct push_switch_platform_info psw_power_platform_data = {64.name = "psw_power",65.bit = 4,66.irq_flags = IRQF_SHARED,67.irq_handler = psw_irq_handler,68};6970static struct push_switch_platform_info psw1_platform_data = {71.name = "psw1",72.bit = 0,73.irq_flags = IRQF_SHARED,74.irq_handler = psw_irq_handler,75};7677static struct push_switch_platform_info psw2_platform_data = {78.name = "psw2",79.bit = 2,80.irq_flags = IRQF_SHARED,81.irq_handler = psw_irq_handler,82};8384static struct push_switch_platform_info psw3_platform_data = {85.name = "psw3",86.bit = 1,87.irq_flags = IRQF_SHARED,88.irq_handler = psw_irq_handler,89};9091static struct platform_device psw_power_switch_device = {92.name = "push-switch",93.id = 0,94.num_resources = ARRAY_SIZE(psw_power_resources),95.resource = psw_power_resources,96.dev = {97.platform_data = &psw_power_platform_data,98},99};100101static struct platform_device psw1_switch_device = {102.name = "push-switch",103.id = 1,104.num_resources = ARRAY_SIZE(psw_usl5p_resources),105.resource = psw_usl5p_resources,106.dev = {107.platform_data = &psw1_platform_data,108},109};110111static struct platform_device psw2_switch_device = {112.name = "push-switch",113.id = 2,114.num_resources = ARRAY_SIZE(psw_usl5p_resources),115.resource = psw_usl5p_resources,116.dev = {117.platform_data = &psw2_platform_data,118},119};120121static struct platform_device psw3_switch_device = {122.name = "push-switch",123.id = 3,124.num_resources = ARRAY_SIZE(psw_usl5p_resources),125.resource = psw_usl5p_resources,126.dev = {127.platform_data = &psw3_platform_data,128},129};130131static struct platform_device *psw_devices[] = {132&psw_power_switch_device,133&psw1_switch_device,134&psw2_switch_device,135&psw3_switch_device,136};137138static int __init psw_init(void)139{140return platform_add_devices(psw_devices, ARRAY_SIZE(psw_devices));141}142module_init(psw_init);143144145