arm: tegra: cardhu: support for PCA6416 gpio expander
[linux-2.6.git] / arch / arm / mach-tegra / board-cardhu-sensors.c
1 /*
2  * arch/arm/mach-tegra/board-cardhu-sensors.c
3  *
4  * Copyright (c) 2011, NVIDIA, All Rights Reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU 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, see <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include <linux/i2c.h>
22 #include <linux/i2c/pca954x.h>
23 #include <linux/i2c/pca953x.h>
24
25 #include "board.h"
26 #include "board-cardhu.h"
27
28 #ifdef CONFIG_I2C_MUX_PCA954x
29 static struct pca954x_platform_mode cardhu_pca954x_modes[] = {
30         { .adap_id = PCA954x_I2C_BUS0, },
31         { .adap_id = PCA954x_I2C_BUS1, },
32         { .adap_id = PCA954x_I2C_BUS2, },
33         { .adap_id = PCA954x_I2C_BUS3, },
34 };
35
36 static struct pca954x_platform_data cardhu_pca954x_data = {
37         .modes    = cardhu_pca954x_modes,
38         .num_modes      = ARRAY_SIZE(cardhu_pca954x_modes),
39 };
40
41 #endif
42
43 static const struct i2c_board_info cardhu_i2c3_board_info[] = {
44 #ifdef CONFIG_I2C_MUX_PCA954x
45         {
46                 I2C_BOARD_INFO("pca9546", 0x70),
47                 .platform_data = &cardhu_pca954x_data,
48         },
49 #endif
50 };
51
52 #if defined(CONFIG_GPIO_PCA953X)
53 static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
54         .gpio_base      = PMU_TCA6416_GPIO_BASE,
55 };
56
57 static const struct i2c_board_info cardhu_i2c4_board_info_tca6416[] = {
58         {
59                 I2C_BOARD_INFO("tca6416", 0x20),
60                 .platform_data = &cardhu_pmu_tca6416_data,
61         },
62 };
63
64 static int __init pmu_tca6416_init(void)
65 {
66         struct board_info board_info;
67         tegra_get_board_info(&board_info);
68         if ((board_info.board_id == BOARD_E1198) ||
69                         (board_info.board_id == BOARD_E1291))
70                 return 0;
71
72         pr_info("Registering pmu pca6416\n");
73         i2c_register_board_info(4, cardhu_i2c4_board_info_tca6416,
74                 ARRAY_SIZE(cardhu_i2c4_board_info_tca6416));
75         return 0;
76 }
77 #else
78 static int __init pmu_tca6416_init(void)
79 {
80         return 0;
81 }
82 #endif
83
84 int __init cardhu_sensors_init(void)
85 {
86
87         if (ARRAY_SIZE(cardhu_i2c3_board_info))
88                 i2c_register_board_info(3, cardhu_i2c3_board_info,
89                         ARRAY_SIZE(cardhu_i2c3_board_info));
90
91         pmu_tca6416_init();
92         return 0;
93 }