omap: consolidate touch screen initialization among different boards
[deliverable/linux.git] / arch / arm / mach-omap2 / common-board-devices.c
CommitLineData
96974a24
MR
1/*
2 * common-board-devices.c
3 *
4 * Copyright (C) 2011 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 *
21 */
22
23#include <linux/gpio.h>
24#include <linux/spi/spi.h>
25#include <linux/spi/ads7846.h>
26
27#include <plat/mcspi.h>
28
29#include "common-board-devices.h"
30
31static struct omap2_mcspi_device_config ads7846_mcspi_config = {
32 .turbo_mode = 0,
33 .single_channel = 1, /* 0: slave, 1: master */
34};
35
36static struct ads7846_platform_data ads7846_config = {
37 .x_max = 0x0fff,
38 .y_max = 0x0fff,
39 .x_plate_ohms = 180,
40 .pressure_max = 255,
41 .debounce_max = 10,
42 .debounce_tol = 3,
43 .debounce_rep = 1,
44 .gpio_pendown = -EINVAL,
45 .keep_vref_on = 1,
46};
47
48static struct spi_board_info ads7846_spi_board_info __initdata = {
49 .modalias = "ads7846",
50 .bus_num = -EINVAL,
51 .chip_select = 0,
52 .max_speed_hz = 1500000,
53 .controller_data = &ads7846_mcspi_config,
54 .irq = -EINVAL,
55 .platform_data = &ads7846_config,
56};
57
58void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
59 struct ads7846_platform_data *board_pdata)
60{
61 struct spi_board_info *spi_bi = &ads7846_spi_board_info;
62 int err;
63
64 err = gpio_request(gpio_pendown, "TS PenDown");
65 if (err) {
66 pr_err("Could not obtain gpio for TS PenDown: %d\n", err);
67 return;
68 }
69
70 gpio_direction_input(gpio_pendown);
71 gpio_export(gpio_pendown, 0);
72
73 if (gpio_debounce)
74 gpio_set_debounce(gpio_pendown, gpio_debounce);
75
76 ads7846_config.gpio_pendown = gpio_pendown;
77
78 spi_bi->bus_num = bus_num;
79 spi_bi->irq = OMAP_GPIO_IRQ(gpio_pendown);
80
81 if (board_pdata)
82 spi_bi->platform_data = board_pdata;
83
84 spi_register_board_info(&ads7846_spi_board_info, 1);
85}
This page took 0.027147 seconds and 5 git commands to generate.