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>
33 #include "common-board-devices.h"
35 static struct i2c_board_info __initdata pmic_i2c_board_info = {
37 .flags = I2C_CLIENT_WAKE,
40 void __init omap_pmic_init(int bus, u32 clkrate,
41 const char *pmic_type, int pmic_irq,
42 struct twl4030_platform_data *pmic_data)
44 strncpy(pmic_i2c_board_info.type, pmic_type,
45 sizeof(pmic_i2c_board_info.type));
46 pmic_i2c_board_info.irq = pmic_irq;
47 pmic_i2c_board_info.platform_data = pmic_data;
49 omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
52 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
54 .single_channel = 1, /* 0: slave, 1: master */
57 static struct ads7846_platform_data ads7846_config = {
65 .gpio_pendown = -EINVAL,
69 static struct spi_board_info ads7846_spi_board_info __initdata = {
70 .modalias = "ads7846",
73 .max_speed_hz = 1500000,
74 .controller_data = &ads7846_mcspi_config,
76 .platform_data = &ads7846_config,
79 void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
80 struct ads7846_platform_data *board_pdata)
82 struct spi_board_info *spi_bi = &ads7846_spi_board_info;
85 err = gpio_request(gpio_pendown, "TS PenDown");
87 pr_err("Could not obtain gpio for TS PenDown: %d\n", err);
91 gpio_direction_input(gpio_pendown);
92 gpio_export(gpio_pendown, 0);
95 gpio_set_debounce(gpio_pendown, gpio_debounce);
97 ads7846_config.gpio_pendown = gpio_pendown;
99 spi_bi->bus_num = bus_num;
100 spi_bi->irq = OMAP_GPIO_IRQ(gpio_pendown);
103 spi_bi->platform_data = board_pdata;
105 spi_register_board_info(&ads7846_spi_board_info, 1);