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/i2c.h>
24 #include <linux/i2c/twl.h>
26 #include <linux/gpio.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ads7846.h>
31 #include <plat/mcspi.h>
32 #include <plat/nand.h>
34 #include "common-board-devices.h"
36 static struct i2c_board_info __initdata pmic_i2c_board_info = {
38 .flags = I2C_CLIENT_WAKE,
41 void __init omap_pmic_init(int bus, u32 clkrate,
42 const char *pmic_type, int pmic_irq,
43 struct twl4030_platform_data *pmic_data)
45 strncpy(pmic_i2c_board_info.type, pmic_type,
46 sizeof(pmic_i2c_board_info.type));
47 pmic_i2c_board_info.irq = pmic_irq;
48 pmic_i2c_board_info.platform_data = pmic_data;
50 omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
53 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
54 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
55 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
57 .single_channel = 1, /* 0: slave, 1: master */
60 static struct ads7846_platform_data ads7846_config = {
68 .gpio_pendown = -EINVAL,
72 static struct spi_board_info ads7846_spi_board_info __initdata = {
73 .modalias = "ads7846",
76 .max_speed_hz = 1500000,
77 .controller_data = &ads7846_mcspi_config,
79 .platform_data = &ads7846_config,
82 void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
83 struct ads7846_platform_data *board_pdata)
85 struct spi_board_info *spi_bi = &ads7846_spi_board_info;
88 err = gpio_request(gpio_pendown, "TS PenDown");
90 pr_err("Could not obtain gpio for TS PenDown: %d\n", err);
94 gpio_direction_input(gpio_pendown);
95 gpio_export(gpio_pendown, 0);
98 gpio_set_debounce(gpio_pendown, gpio_debounce);
100 ads7846_config.gpio_pendown = gpio_pendown;
102 spi_bi->bus_num = bus_num;
103 spi_bi->irq = OMAP_GPIO_IRQ(gpio_pendown);
106 spi_bi->platform_data = board_pdata;
108 spi_register_board_info(&ads7846_spi_board_info, 1);
111 void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
112 struct ads7846_platform_data *board_pdata)
117 #if defined(CONFIG_MTD_NAND_OMAP2) || defined(CONFIG_MTD_NAND_OMAP2_MODULE)
118 static struct omap_nand_platform_data nand_data = {
119 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
122 void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
126 u8 nandcs = GPMC_CS_NUM + 1;
128 /* find out the chip-select on which NAND exists */
129 while (cs < GPMC_CS_NUM) {
131 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
133 if ((ret & 0xC00) == 0x800) {
134 printk(KERN_INFO "Found NAND on CS%d\n", cs);
135 if (nandcs > GPMC_CS_NUM)
141 if (nandcs > GPMC_CS_NUM) {
142 printk(KERN_INFO "NAND: Unable to find configuration "
147 if (nandcs < GPMC_CS_NUM) {
148 nand_data.cs = nandcs;
149 nand_data.parts = parts;
150 nand_data.nr_parts = nr_parts;
151 nand_data.options = options;
153 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
154 if (gpmc_nand_init(&nand_data) < 0)
155 printk(KERN_ERR "Unable to register NAND device\n");
159 void __init omap_nand_flash_init(int options, struct mtd_partition *parts,