Path: blob/master/arch/powerpc/platforms/512x/pdm360ng.c
10820 views
/*1* Copyright (C) 2010 DENX Software Engineering2*3* Anatolij Gustschin, <[email protected]>4*5* PDM360NG board setup6*7* This is free software; you can redistribute it and/or modify it8* under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12*/1314#include <linux/kernel.h>15#include <linux/io.h>16#include <linux/of_platform.h>1718#include <asm/machdep.h>19#include <asm/ipic.h>2021#include "mpc512x.h"2223#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \24defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)25#include <linux/interrupt.h>26#include <linux/spi/ads7846.h>27#include <linux/spi/spi.h>28#include <linux/notifier.h>2930static void *pdm360ng_gpio_base;3132static int pdm360ng_get_pendown_state(void)33{34u32 reg;3536reg = in_be32(pdm360ng_gpio_base + 0xc);37if (reg & 0x40)38setbits32(pdm360ng_gpio_base + 0xc, 0x40);3940reg = in_be32(pdm360ng_gpio_base + 0x8);4142/* return 1 if pen is down */43return (reg & 0x40) == 0;44}4546static struct ads7846_platform_data pdm360ng_ads7846_pdata = {47.model = 7845,48.get_pendown_state = pdm360ng_get_pendown_state,49.irq_flags = IRQF_TRIGGER_LOW,50};5152static int __init pdm360ng_penirq_init(void)53{54struct device_node *np;5556np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-gpio");57if (!np) {58pr_err("%s: Can't find 'mpc5121-gpio' node\n", __func__);59return -ENODEV;60}6162pdm360ng_gpio_base = of_iomap(np, 0);63of_node_put(np);64if (!pdm360ng_gpio_base) {65pr_err("%s: Can't map gpio regs.\n", __func__);66return -ENODEV;67}68out_be32(pdm360ng_gpio_base + 0xc, 0xffffffff);69setbits32(pdm360ng_gpio_base + 0x18, 0x2000);70setbits32(pdm360ng_gpio_base + 0x10, 0x40);7172return 0;73}7475static int pdm360ng_touchscreen_notifier_call(struct notifier_block *nb,76unsigned long event, void *__dev)77{78struct device *dev = __dev;7980if ((event == BUS_NOTIFY_ADD_DEVICE) &&81of_device_is_compatible(dev->of_node, "ti,ads7846")) {82dev->platform_data = &pdm360ng_ads7846_pdata;83return NOTIFY_OK;84}85return NOTIFY_DONE;86}8788static struct notifier_block pdm360ng_touchscreen_nb = {89.notifier_call = pdm360ng_touchscreen_notifier_call,90};9192static void __init pdm360ng_touchscreen_init(void)93{94if (pdm360ng_penirq_init())95return;9697bus_register_notifier(&spi_bus_type, &pdm360ng_touchscreen_nb);98}99#else100static inline void __init pdm360ng_touchscreen_init(void)101{102}103#endif /* CONFIG_TOUCHSCREEN_ADS7846 */104105void __init pdm360ng_init(void)106{107mpc512x_init();108pdm360ng_touchscreen_init();109}110111static int __init pdm360ng_probe(void)112{113unsigned long root = of_get_flat_dt_root();114115return of_flat_dt_is_compatible(root, "ifm,pdm360ng");116}117118define_machine(pdm360ng) {119.name = "PDM360NG",120.probe = pdm360ng_probe,121.setup_arch = mpc512x_setup_diu,122.init = pdm360ng_init,123.init_early = mpc512x_init_diu,124.init_IRQ = mpc512x_init_IRQ,125.get_irq = ipic_get_irq,126.calibrate_decr = generic_calibrate_decr,127.restart = mpc512x_restart,128};129130131