staging:iio:gyro:adis16260 fix missing num_channels setup.
[linux-2.6/next.git] / arch / arm / mach-omap2 / common-board-devices.c
blob94ccf464677b78eeb831671f54f862325881a0ac
1 /*
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
19 * 02110-1301 USA
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>
30 #include <plat/i2c.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 = {
37 .addr = 0x48,
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 = {
56 .turbo_mode = 0,
57 .single_channel = 1, /* 0: slave, 1: master */
60 static struct ads7846_platform_data ads7846_config = {
61 .x_max = 0x0fff,
62 .y_max = 0x0fff,
63 .x_plate_ohms = 180,
64 .pressure_max = 255,
65 .debounce_max = 10,
66 .debounce_tol = 3,
67 .debounce_rep = 1,
68 .gpio_pendown = -EINVAL,
69 .keep_vref_on = 1,
72 static struct spi_board_info ads7846_spi_board_info __initdata = {
73 .modalias = "ads7846",
74 .bus_num = -EINVAL,
75 .chip_select = 0,
76 .max_speed_hz = 1500000,
77 .controller_data = &ads7846_mcspi_config,
78 .irq = -EINVAL,
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;
86 int err;
88 if (board_pdata && board_pdata->get_pendown_state) {
89 err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
90 if (err) {
91 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
92 return;
94 gpio_export(gpio_pendown, 0);
96 if (gpio_debounce)
97 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);
105 if (board_pdata)
106 spi_bi->platform_data = board_pdata;
108 spi_register_board_info(&ads7846_spi_board_info, 1);
110 #else
111 void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
112 struct ads7846_platform_data *board_pdata)
115 #endif
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,
123 int nr_parts)
125 u8 cs = 0;
126 u8 nandcs = GPMC_CS_NUM + 1;
128 /* find out the chip-select on which NAND exists */
129 while (cs < GPMC_CS_NUM) {
130 u32 ret = 0;
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)
136 nandcs = cs;
138 cs++;
141 if (nandcs > GPMC_CS_NUM) {
142 printk(KERN_INFO "NAND: Unable to find configuration "
143 "in GPMC\n ");
144 return;
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");
158 #else
159 void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
160 int nr_parts)
163 #endif