2 * arch/ubicom32/mach-ip7k/board-ip7160dpf.c
3 * Platform initialization for ip7160dpf board.
5 * (C) Copyright 2009, Ubicom, Inc.
7 * This file is part of the Ubicom32 Linux Kernel Port.
9 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10 * it and/or modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation, either version 2 of the
12 * License, or (at your option) any later version.
14 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with the Ubicom32 Linux Kernel Port. If not,
21 * see <http://www.gnu.org/licenses/>.
23 * Ubicom32 implementation derived from (with many thanks):
28 #include <linux/device.h>
29 #include <linux/platform_device.h>
30 #include <linux/delay.h>
31 #include <linux/gpio.h>
33 #include <linux/i2c.h>
34 #include <linux/i2c-gpio.h>
36 #include <linux/input.h>
38 #include <asm/board.h>
39 #include <asm/machdep.h>
40 #include <asm/ubicom32hid.h>
41 #include <asm/vdc_tio.h>
42 #include <asm/audio.h>
45 * Backlight on the board PD0, hardware PWM
47 static const struct ubicom32hid_button ip7160dpf_ubicom32hid_buttons
[] = {
85 static const struct ubicom32hid_ir ip7160dpf_ubicom32hid_ircodes
[] = {
104 .ir_code
= 0xF40B916E
109 .ir_code
= 0xF50A916E
114 .ir_code
= 0xF906916E
119 .ir_code
= 0xF708916E
124 .ir_code
= 0xF30C916E
129 .ir_code
= 0xF10E916E
133 .code
= KEY_VOLUMEUP
,
134 .ir_code
= 0xF00F916E
138 .code
= KEY_VOLUMEDOWN
,
139 .ir_code
= 0xED12916E
144 .ir_code
= 0xEA15916E
149 .ir_code
= 0xEF10916E
154 .ir_code
= 0xEE11916E
159 .ir_code
= 0xEB14916E
164 .ir_code
= 0xFD02916E
168 static struct ubicom32hid_platform_data ip7160dpf_ubicom32hid_platform_data
= {
169 .gpio_reset
= GPIO_RI_5
,
170 .gpio_reset_polarity
= 0,
171 .type
= UBICOM32HID_BL_TYPE_PWM
,
173 .default_intensity
= 128,
174 .buttons
= ip7160dpf_ubicom32hid_buttons
,
175 .nbuttons
= ARRAY_SIZE(ip7160dpf_ubicom32hid_buttons
),
176 .ircodes
= ip7160dpf_ubicom32hid_ircodes
,
177 .nircodes
= ARRAY_SIZE(ip7160dpf_ubicom32hid_ircodes
),
181 * Devices on the I2C bus
182 * This board has a "bus 2" which is isolated from the main bus by U47
183 * and pin RI0. It should be safe to always enable bus 2 by setting
184 * RI0 to low, however, it should be noted that on all existing configurations
185 * of this board, U49 and U51 are not populated.
187 static struct i2c_board_info __initdata ip7160dpf_i2c_board_info
[] = {
189 * U37, CS4350 DAC, address 0x4B, bus 2
190 * THIS ENTRY MUST BE FIRST
201 .type
= "ubicom32hid",
203 .platform_data
= &ip7160dpf_ubicom32hid_platform_data
,
207 * U49, ISL29001 Ambient Light Sensor, address 0x44, bus 2 (may not be stuffed)
211 * U51, S35390A RTC, address 0x30, bus 2 (may not be stuffed)
213 #ifdef CONFIG_RTC_DRV_S35390A
222 * I2C bus on the board, SDA PI1, SCL PI2
224 static struct i2c_gpio_platform_data ip7160dpf_i2c_data
= {
225 .sda_pin
= GPIO_RI_1
,
226 .scl_pin
= GPIO_RI_2
,
227 .sda_is_open_drain
= 0,
228 .scl_is_open_drain
= 0,
229 .scl_is_output_only
= 1,
233 static struct platform_device ip7160dpf_i2c_device
= {
237 .platform_data
= &ip7160dpf_i2c_data
,
242 * List of all devices in our system
244 static struct platform_device
*ip7160dpf_devices
[] __initdata
= {
245 &ip7160dpf_i2c_device
,
249 * ip7160dpf_power_off
250 * Called to turn the power off for this board
252 static void ip7160dpf_power_off(void)
254 gpio_set_value(GPIO_RF_14
, 0);
259 * Called to add the devices which we have on this board
261 static int __init
ip7160dpf_init(void)
264 struct platform_device
*audio_dev
;
269 * Hold the POWER_HOLD line
271 ret
= gpio_request(GPIO_RF_14
, "POWER_HOLD");
273 printk(KERN_ERR
"%s: could not request POWER_HOLD GPIO\n", __FUNCTION__
);
275 gpio_direction_output(GPIO_RF_14
, 1);
276 mach_power_off
= ip7160dpf_power_off
;
279 * USB SEL_HOST_USB line
281 ret
= gpio_request(GPIO_RI_13
, "SEL_HOST_USB");
283 printk(KERN_ERR
"%s: could not request SEL_HOST_USB GPIO\n", __FUNCTION__
);
285 gpio_direction_output(GPIO_RI_13
, 0);
288 * USB/DAC nRESET line
290 ret
= gpio_request(GPIO_RI_3
, "USB_DAC_nRESET");
292 printk(KERN_ERR
"%s: could not request USB_DAC_nRESET GPIO\n", __FUNCTION__
);
294 gpio_direction_output(GPIO_RI_3
, 0);
296 gpio_direction_output(GPIO_RI_3
, 1);
299 * I2C BUS2 Disable line
301 ret
= gpio_request(GPIO_RI_0
, "DISABLE_BUS2");
303 printk(KERN_ERR
"%s: could not request DISABLE_BUS2 GPIO\n", __FUNCTION__
);
305 gpio_direction_output(GPIO_RI_0
, 0);
309 printk(KERN_INFO
"%s: registering device resources\n", __FUNCTION__
);
310 platform_add_devices(ip7160dpf_devices
, ARRAY_SIZE(ip7160dpf_devices
));
313 * Allocate the audio driver if we can
315 audio_dev
= audio_device_alloc("snd-ubi32-cs4350", "audio-i2sout", 0);
317 ip7160dpf_i2c_board_info
[0].platform_data
= audio_dev
;
320 printk(KERN_INFO
"%s: registering i2c resources\n", __FUNCTION__
);
321 i2c_register_board_info(0, ip7160dpf_i2c_board_info
, ARRAY_SIZE(ip7160dpf_i2c_board_info
));
326 arch_initcall(ip7160dpf_init
);