2 * common-board-devices.c
4 * Copyright (C) 2011 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
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.
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.
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
23 #include <linux/gpio.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/ads7846.h>
27 #include <linux/platform_data/spi-omap2-mcspi.h>
28 #include <linux/platform_data/mtd-nand-omap2.h>
31 #include "common-board-devices.h"
33 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
34 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
35 static struct omap2_mcspi_device_config ads7846_mcspi_config
= {
39 static struct ads7846_platform_data ads7846_config
= {
47 .gpio_pendown
= -EINVAL
,
51 static struct spi_board_info ads7846_spi_board_info __initdata
= {
52 .modalias
= "ads7846",
55 .max_speed_hz
= 1500000,
56 .controller_data
= &ads7846_mcspi_config
,
58 .platform_data
= &ads7846_config
,
61 void __init
omap_ads7846_init(int bus_num
, int gpio_pendown
, int gpio_debounce
,
62 struct ads7846_platform_data
*board_pdata
)
64 struct spi_board_info
*spi_bi
= &ads7846_spi_board_info
;
68 * If a board defines get_pendown_state() function, request the pendown
69 * GPIO and set the GPIO debounce time.
70 * If a board does not define the get_pendown_state() function, then
71 * the ads7846 driver will setup the pendown GPIO itself.
73 if (board_pdata
&& board_pdata
->get_pendown_state
) {
74 err
= gpio_request_one(gpio_pendown
, GPIOF_IN
, "TSPenDown");
76 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err
);
81 gpio_set_debounce(gpio_pendown
, gpio_debounce
);
83 gpio_export(gpio_pendown
, 0);
86 spi_bi
->bus_num
= bus_num
;
87 spi_bi
->irq
= gpio_to_irq(gpio_pendown
);
89 ads7846_config
.gpio_pendown
= gpio_pendown
;
92 board_pdata
->gpio_pendown
= gpio_pendown
;
93 board_pdata
->gpio_pendown_debounce
= gpio_debounce
;
94 spi_bi
->platform_data
= board_pdata
;
97 spi_register_board_info(&ads7846_spi_board_info
, 1);
100 void __init
omap_ads7846_init(int bus_num
, int gpio_pendown
, int gpio_debounce
,
101 struct ads7846_platform_data
*board_pdata
)
106 #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
107 static struct omap_nand_platform_data nand_data
;
109 void __init
omap_nand_flash_init(int options
, struct mtd_partition
*parts
,
113 u8 nandcs
= GPMC_CS_NUM
+ 1;
115 /* find out the chip-select on which NAND exists */
116 while (cs
< GPMC_CS_NUM
) {
118 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG1
);
120 if ((ret
& 0xC00) == 0x800) {
121 printk(KERN_INFO
"Found NAND on CS%d\n", cs
);
122 if (nandcs
> GPMC_CS_NUM
)
128 if (nandcs
> GPMC_CS_NUM
) {
129 pr_info("NAND: Unable to find configuration in GPMC\n");
133 if (nandcs
< GPMC_CS_NUM
) {
134 nand_data
.cs
= nandcs
;
135 nand_data
.parts
= parts
;
136 nand_data
.nr_parts
= nr_parts
;
137 nand_data
.devsize
= options
;
139 printk(KERN_INFO
"Registering NAND on CS%d\n", nandcs
);
140 if (gpmc_nand_init(&nand_data
) < 0)
141 printk(KERN_ERR
"Unable to register NAND device\n");
145 void __init
omap_nand_flash_init(int options
, struct mtd_partition
*parts
,