Merge branch 'cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux...
[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>
9a3f39ff 28#include <plat/nand.h>
96974a24
MR
29
30#include "common-board-devices.h"
31
9a3f39ff
MR
32#if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
33 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
96974a24
MR
34static struct omap2_mcspi_device_config ads7846_mcspi_config = {
35 .turbo_mode = 0,
96974a24
MR
36};
37
38static struct ads7846_platform_data ads7846_config = {
39 .x_max = 0x0fff,
40 .y_max = 0x0fff,
41 .x_plate_ohms = 180,
42 .pressure_max = 255,
43 .debounce_max = 10,
44 .debounce_tol = 3,
45 .debounce_rep = 1,
46 .gpio_pendown = -EINVAL,
47 .keep_vref_on = 1,
48};
49
50static struct spi_board_info ads7846_spi_board_info __initdata = {
51 .modalias = "ads7846",
52 .bus_num = -EINVAL,
53 .chip_select = 0,
54 .max_speed_hz = 1500000,
55 .controller_data = &ads7846_mcspi_config,
56 .irq = -EINVAL,
57 .platform_data = &ads7846_config,
58};
59
60void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
61 struct ads7846_platform_data *board_pdata)
62{
63 struct spi_board_info *spi_bi = &ads7846_spi_board_info;
64 int err;
65
e68273ba
IG
66 if (board_pdata && board_pdata->get_pendown_state) {
67 err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
68 if (err) {
69 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
70 return;
71 }
72 gpio_export(gpio_pendown, 0);
73
74 if (gpio_debounce)
75 gpio_set_debounce(gpio_pendown, gpio_debounce);
96974a24
MR
76 }
77
96974a24
MR
78 ads7846_config.gpio_pendown = gpio_pendown;
79
80 spi_bi->bus_num = bus_num;
81 spi_bi->irq = OMAP_GPIO_IRQ(gpio_pendown);
82
83 if (board_pdata)
84 spi_bi->platform_data = board_pdata;
85
86 spi_register_board_info(&ads7846_spi_board_info, 1);
87}
9a3f39ff
MR
88#else
89void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
90 struct ads7846_platform_data *board_pdata)
91{
92}
93#endif
94
95#if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
7a559c78 96static struct omap_nand_platform_data nand_data;
9a3f39ff
MR
97
98void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
99 int nr_parts)
100{
101 u8 cs = 0;
102 u8 nandcs = GPMC_CS_NUM + 1;
103
104 /* find out the chip-select on which NAND exists */
105 while (cs < GPMC_CS_NUM) {
106 u32 ret = 0;
107 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
108
109 if ((ret & 0xC00) == 0x800) {
110 printk(KERN_INFO "Found NAND on CS%d\n", cs);
111 if (nandcs > GPMC_CS_NUM)
112 nandcs = cs;
113 }
114 cs++;
115 }
116
117 if (nandcs > GPMC_CS_NUM) {
118 printk(KERN_INFO "NAND: Unable to find configuration "
119 "in GPMC\n ");
120 return;
121 }
122
123 if (nandcs < GPMC_CS_NUM) {
124 nand_data.cs = nandcs;
125 nand_data.parts = parts;
126 nand_data.nr_parts = nr_parts;
7a559c78 127 nand_data.devsize = options;
9a3f39ff
MR
128
129 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
130 if (gpmc_nand_init(&nand_data) < 0)
131 printk(KERN_ERR "Unable to register NAND device\n");
132 }
133}
134#else
135void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
136 int nr_parts)
137{
138}
139#endif
This page took 0.063015 seconds and 5 git commands to generate.