~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sh/boards/mach-highlander/psw.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /*
  3  * arch/sh/boards/renesas/r7780rp/psw.c
  4  *
  5  * push switch support for RDBRP-1/RDBREVRP-1 debug boards.
  6  *
  7  * Copyright (C) 2006  Paul Mundt
  8  */
  9 #include <linux/io.h>
 10 #include <linux/module.h>
 11 #include <linux/interrupt.h>
 12 #include <linux/platform_device.h>
 13 #include <mach/highlander.h>
 14 #include <asm/push-switch.h>
 15 
 16 static irqreturn_t psw_irq_handler(int irq, void *arg)
 17 {
 18         struct platform_device *pdev = arg;
 19         struct push_switch *psw = platform_get_drvdata(pdev);
 20         struct push_switch_platform_info *psw_info = pdev->dev.platform_data;
 21         unsigned int l, mask;
 22         int ret = 0;
 23 
 24         l = __raw_readw(PA_DBSW);
 25 
 26         /* Nothing to do if there's no state change */
 27         if (psw->state) {
 28                 ret = 1;
 29                 goto out;
 30         }
 31 
 32         mask = l & 0x70;
 33         /* Figure out who raised it */
 34         if (mask & (1 << psw_info->bit)) {
 35                 psw->state = !!(mask & (1 << psw_info->bit));
 36                 if (psw->state) /* debounce */
 37                         mod_timer(&psw->debounce, jiffies + 50);
 38 
 39                 ret = 1;
 40         }
 41 
 42 out:
 43         /* Clear the switch IRQs */
 44         l |= (0x7 << 12);
 45         __raw_writew(l, PA_DBSW);
 46 
 47         return IRQ_RETVAL(ret);
 48 }
 49 
 50 static struct resource psw_resources[] = {
 51         [0] = {
 52                 .start  = IRQ_PSW,
 53                 .flags  = IORESOURCE_IRQ,
 54         },
 55 };
 56 
 57 static struct push_switch_platform_info s2_platform_data = {
 58         .name           = "s2",
 59         .bit            = 6,
 60         .irq_flags      = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
 61                           IRQF_SHARED,
 62         .irq_handler    = psw_irq_handler,
 63 };
 64 
 65 static struct platform_device s2_switch_device = {
 66         .name           = "push-switch",
 67         .id             = 0,
 68         .num_resources  = ARRAY_SIZE(psw_resources),
 69         .resource       = psw_resources,
 70         .dev            = {
 71                 .platform_data = &s2_platform_data,
 72         },
 73 };
 74 
 75 static struct push_switch_platform_info s3_platform_data = {
 76         .name           = "s3",
 77         .bit            = 5,
 78         .irq_flags      = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
 79                           IRQF_SHARED,
 80         .irq_handler    = psw_irq_handler,
 81 };
 82 
 83 static struct platform_device s3_switch_device = {
 84         .name           = "push-switch",
 85         .id             = 1,
 86         .num_resources  = ARRAY_SIZE(psw_resources),
 87         .resource       = psw_resources,
 88         .dev            = {
 89                 .platform_data = &s3_platform_data,
 90         },
 91 };
 92 
 93 static struct push_switch_platform_info s4_platform_data = {
 94         .name           = "s4",
 95         .bit            = 4,
 96         .irq_flags      = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
 97                           IRQF_SHARED,
 98         .irq_handler    = psw_irq_handler,
 99 };
100 
101 static struct platform_device s4_switch_device = {
102         .name           = "push-switch",
103         .id             = 2,
104         .num_resources  = ARRAY_SIZE(psw_resources),
105         .resource       = psw_resources,
106         .dev            = {
107                 .platform_data = &s4_platform_data,
108         },
109 };
110 
111 static struct platform_device *psw_devices[] = {
112         &s2_switch_device, &s3_switch_device, &s4_switch_device,
113 };
114 
115 static int __init psw_init(void)
116 {
117         return platform_add_devices(psw_devices, ARRAY_SIZE(psw_devices));
118 }
119 module_init(psw_init);
120 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php