Efika MX platform support
[efikamx:linux-kernel.git] / arch / arm / mach-mx5 / mx51_efikamx_i2c.c
1 /*
2  * Copyright 2009 Pegatron Corporation. All Rights Reserved.
3  * Copyright 2009-2010 Genesi USA, Inc. All Rights Reserved.
4  */
5
6 /*
7  * The code contained herein is licensed under the GNU General Public
8  * License. You may obtain a copy of the GNU General Public License
9  * Version 2 or later at the following locations:
10  *
11  * http://www.opensource.org/licenses/gpl-license.html
12  * http://www.gnu.org/copyleft/gpl.html
13  */
14
15 #include <linux/errno.h>
16 #include <linux/module.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/i2c.h>
20 #include <mach/i2c.h>
21 #include <mach/common.h>
22 #include <mach/hardware.h>
23 #include <mach/gpio.h>
24
25 #include "devices.h"
26 #include "mx51_pins.h"
27 #include "iomux.h"
28
29 #include "mx51_efikamx.h"
30
31 #if defined(CONFIG_I2C_MXC) && defined(CONFIG_I2C_IMX)
32 #error pick CONFIG_I2C_MXC or CONFIG_I2C_IMX but not both, please..
33 #endif
34
35 static struct mxc_iomux_pin_cfg __initdata mx51_efikamx_i2c_iomux_pins[] = {
36         {
37          MX51_PIN_GPIO1_2, IOMUX_CONFIG_ALT0,
38          },
39         {
40          MX51_PIN_GPIO1_3, IOMUX_CONFIG_ALT0,
41          },
42         {
43          MX51_PIN_KEY_COL5, (IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION),
44                 (PAD_CTL_SRE_FAST | PAD_CTL_ODE_OPENDRAIN_ENABLE |
45                  PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | PAD_CTL_HYS_ENABLE),
46                 MUX_IN_I2C2_IPP_SDA_IN_SELECT_INPUT, INPUT_CTL_PATH1,
47         },
48         {
49          MX51_PIN_KEY_COL4, (IOMUX_CONFIG_ALT3 | IOMUX_CONFIG_SION),
50                 (PAD_CTL_SRE_FAST | PAD_CTL_ODE_OPENDRAIN_ENABLE |
51                  PAD_CTL_DRV_HIGH | PAD_CTL_100K_PU | PAD_CTL_HYS_ENABLE),
52                 MUX_IN_I2C2_IPP_SCL_IN_SELECT_INPUT, INPUT_CTL_PATH1,
53         },
54 };
55
56 extern void mx51_efikamx_display_reset(void);
57 static struct mxc_lcd_platform_data mx51_efikamx_cs8556_data = {
58         .core_reg = "VCAM",
59         .io_reg = "VGEN3",
60         .analog_reg = "VAUDIO",
61         .reset = mx51_efikamx_display_reset,
62 };
63
64 static struct mxc_lcd_platform_data mx51_efikamx_sii9022_data = {
65         .core_reg = "VGEN1",
66         .io_reg = "VGEN3",
67         .reset = mx51_efikamx_display_reset,
68 };
69
70 static struct i2c_board_info mx51_efikamx_i2c_board_info[] __initdata = {
71         {
72          .type = "sgtl5000-i2c",
73          .addr = 0x0a,
74          },
75         {
76          .type = "cs8556",
77          .addr = 0x3d,
78          .platform_data = &mx51_efikamx_cs8556_data,
79          },
80         {
81          .type = "sii9022",
82          .addr = 0x39,
83          .platform_data = &mx51_efikamx_sii9022_data,
84          },
85 };
86
87
88 #if defined(CONFIG_I2C_MXC)
89 static struct mxc_i2c_platform_data mx51_efikamx_i2c2_data = {
90         .i2c_clk = 100000,
91 };
92 #endif
93
94 #if defined(CONFIG_I2C_IMX)
95 static struct imxi2c_platform_data mx51_efikamx_imxi2c2_data = {
96         .bitrate = 100000,
97 };
98
99 static struct resource imxi2c2_resources[] = {
100         {
101                 .start = I2C2_BASE_ADDR,
102                 .end = I2C2_BASE_ADDR + SZ_4K - 1,
103                 .flags = IORESOURCE_MEM,
104         },
105         {
106                 .start = MXC_INT_I2C2,
107                 .end = MXC_INT_I2C2,
108                 .flags = IORESOURCE_IRQ,
109         },
110 };
111
112 static struct platform_device imxi2c2_device = {
113         .name = "imx-i2c",
114         .id = 1,
115         .resource = imxi2c2_resources,
116         .num_resources = ARRAY_SIZE(imxi2c2_resources),
117 };
118 #endif
119
120
121
122 void __init mx51_efikamx_init_i2c(void)
123 {
124         DBG(("IOMUX for I2C (%d pins)", ARRAY_SIZE(mx51_efikamx_i2c_iomux_pins)));
125
126         CONFIG_IOMUX(mx51_efikamx_i2c_iomux_pins);
127
128 #if defined(CONFIG_I2C_MXC)
129         mxc_register_device(&mxci2c_devices[1], &mx51_efikamx_i2c_data);
130 #elif defined(CONFIG_I2C_IMX)
131         mxc_register_device(&imxi2c2_device, &mx51_efikamx_imxi2c2_data);
132 #else
133         #error Please pick at least one of CONFIG_I2C_MXC or CONFIG_I2C_IMX
134 #endif
135
136         i2c_register_board_info(1, mx51_efikamx_i2c_board_info,
137                                         ARRAY_SIZE(mx51_efikamx_i2c_board_info));
138 };