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

TOMOYO Linux Cross Reference
Linux/arch/powerpc/platforms/512x/pdm360ng.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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-or-later
  2 /*
  3  * Copyright (C) 2010 DENX Software Engineering
  4  *
  5  * Anatolij Gustschin, <agust@denx.de>
  6  *
  7  * PDM360NG board setup
  8  */
  9 
 10 #include <linux/device.h>
 11 #include <linux/kernel.h>
 12 #include <linux/io.h>
 13 #include <linux/of.h>
 14 #include <linux/of_address.h>
 15 #include <linux/of_fdt.h>
 16 
 17 #include <asm/machdep.h>
 18 #include <asm/ipic.h>
 19 
 20 #include "mpc512x.h"
 21 
 22 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
 23     defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
 24 #include <linux/interrupt.h>
 25 #include <linux/spi/ads7846.h>
 26 #include <linux/spi/spi.h>
 27 #include <linux/notifier.h>
 28 
 29 static void *pdm360ng_gpio_base;
 30 
 31 static int pdm360ng_get_pendown_state(void)
 32 {
 33         u32 reg;
 34 
 35         reg = in_be32(pdm360ng_gpio_base + 0xc);
 36         if (reg & 0x40)
 37                 setbits32(pdm360ng_gpio_base + 0xc, 0x40);
 38 
 39         reg = in_be32(pdm360ng_gpio_base + 0x8);
 40 
 41         /* return 1 if pen is down */
 42         return (reg & 0x40) == 0;
 43 }
 44 
 45 static struct ads7846_platform_data pdm360ng_ads7846_pdata = {
 46         .model                  = 7845,
 47         .get_pendown_state      = pdm360ng_get_pendown_state,
 48         .irq_flags              = IRQF_TRIGGER_LOW,
 49 };
 50 
 51 static int __init pdm360ng_penirq_init(void)
 52 {
 53         struct device_node *np;
 54 
 55         np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-gpio");
 56         if (!np) {
 57                 pr_err("%s: Can't find 'mpc5121-gpio' node\n", __func__);
 58                 return -ENODEV;
 59         }
 60 
 61         pdm360ng_gpio_base = of_iomap(np, 0);
 62         of_node_put(np);
 63         if (!pdm360ng_gpio_base) {
 64                 pr_err("%s: Can't map gpio regs.\n", __func__);
 65                 return -ENODEV;
 66         }
 67         out_be32(pdm360ng_gpio_base + 0xc, 0xffffffff);
 68         setbits32(pdm360ng_gpio_base + 0x18, 0x2000);
 69         setbits32(pdm360ng_gpio_base + 0x10, 0x40);
 70 
 71         return 0;
 72 }
 73 
 74 static int pdm360ng_touchscreen_notifier_call(struct notifier_block *nb,
 75                                         unsigned long event, void *__dev)
 76 {
 77         struct device *dev = __dev;
 78 
 79         if ((event == BUS_NOTIFY_ADD_DEVICE) &&
 80             of_device_is_compatible(dev->of_node, "ti,ads7846")) {
 81                 dev->platform_data = &pdm360ng_ads7846_pdata;
 82                 return NOTIFY_OK;
 83         }
 84         return NOTIFY_DONE;
 85 }
 86 
 87 static struct notifier_block pdm360ng_touchscreen_nb = {
 88         .notifier_call = pdm360ng_touchscreen_notifier_call,
 89 };
 90 
 91 static void __init pdm360ng_touchscreen_init(void)
 92 {
 93         if (pdm360ng_penirq_init())
 94                 return;
 95 
 96         bus_register_notifier(&spi_bus_type, &pdm360ng_touchscreen_nb);
 97 }
 98 #else
 99 static inline void __init pdm360ng_touchscreen_init(void)
100 {
101 }
102 #endif /* CONFIG_TOUCHSCREEN_ADS7846 */
103 
104 static void __init pdm360ng_init(void)
105 {
106         mpc512x_init();
107         pdm360ng_touchscreen_init();
108 }
109 
110 static int __init pdm360ng_probe(void)
111 {
112         mpc512x_init_early();
113 
114         return 1;
115 }
116 
117 define_machine(pdm360ng) {
118         .name                   = "PDM360NG",
119         .compatible             = "ifm,pdm360ng",
120         .probe                  = pdm360ng_probe,
121         .setup_arch             = mpc512x_setup_arch,
122         .init                   = pdm360ng_init,
123         .init_IRQ               = mpc512x_init_IRQ,
124         .get_irq                = ipic_get_irq,
125         .restart                = mpc512x_restart,
126 };
127 

~ [ 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