aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ubicom32/files/arch/ubicom32/mach-ip5k/board-ip5170dpf.c
blob: ef04dcaa87ac6cd7af6b2aeadcf3b36afdce2b54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*
 * arch/ubicom32/mach-ip5k/board-ip5170dpf.c
 *   Platform initialization for ip5160dpf board.
 *
 * (C) Copyright 2009, Ubicom, Inc.
 *
 * This file is part of the Ubicom32 Linux Kernel Port.
 *
 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, either version 2 of the
 * License, or (at your option) any later version.
 *
 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 * the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Ubicom32 Linux Kernel Port.  If not,
 * see <http://www.gnu.org/licenses/>.
 *
 * Ubicom32 implementation derived from (with many thanks):
 *   arch/m68knommu
 *   arch/blackfin
 *   arch/parisc
 */
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/leds.h>

#include <linux/i2c.h>
#include <linux/i2c-gpio.h>

#include <linux/input.h>
#include <asm/board.h>
#include <asm/machdep.h>
#include <asm/ubicom32hid.h>
#include <asm/vdc_tio.h>

/*
 * LEDs
 *
 * WLAN			PD9	(Note this is shared with MISO, but we don't use it)
 * WPS			PD8
 *
 * TODO: check triggers, are they generic?
 */
static struct gpio_led ip5170dpf_gpio_leds[] = {
	{
		.name			= "d31:green:WLAN1",
		.default_trigger	= "WLAN1",
		.gpio			= GPIO_RD_9,
		.active_low		= 1,
	},
	{
		.name			= "d30:green:WPS",
		.default_trigger	= "WPS",
		.gpio			= GPIO_RD_8,
		.active_low		= 1,
	},
};

static struct gpio_led_platform_data ip5170dpf_gpio_led_platform_data = {
	.num_leds	= 2,
	.leds		= ip5170dpf_gpio_leds,
};

static struct platform_device ip5170dpf_gpio_leds_device = {
	.name		= "leds-gpio",
	.id		= -1,
	.dev = {
		.platform_data = &ip5170dpf_gpio_led_platform_data,
	},
};

/*
 * Backlight on the board PD0, hardware PWM
 */
static const struct ubicom32hid_button ip5170dpf_ubicom32hid_buttons[] = {
	{
		.type	= EV_KEY,
		.code	= KEY_UP,
		.bit	= 0,
	},
	{
		.type	= EV_KEY,
		.code	= KEY_LEFT,
		.bit	= 1,
	},
	{
		.type	= EV_KEY,
		.code	= KEY_RIGHT,
		.bit	= 2,
	},
	{
		.type	= EV_KEY,
		.code	= KEY_DOWN,
		.bit	= 3,
	},
	{
		.type	= EV_KEY,
		.code	= KEY_ENTER,
		.bit	= 4,
	},
	{
		.type	= EV_KEY,
		.code	= KEY_MENU,
		.bit	= 5,
	},
	{
		.type	= EV_KEY,
		.code	= KEY_ESC,
		.bit	= 7,
	},
};

static const struct ubicom32hid_ir ip5170dpf_ubicom32hid_ircodes[] = {
	{
		.type		= EV_KEY,
		.code		= KEY_UP,
		.ir_code	= 0xF807916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_DOWN,
		.ir_code	= 0xF20D916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_LEFT,
		.ir_code	= 0xF609916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_RIGHT,
		.ir_code	= 0xF40B916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_ENTER,
		.ir_code	= 0xF50A916E
	},
	{	/* rotate */
		.type		= EV_KEY,
		.code		= KEY_FN_F1,
		.ir_code	= 0xF906916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_MENU,
		.ir_code	= 0xF708916E
	},
	{	/* font size */
		.type		= EV_KEY,
		.code		= KEY_FN_F2,
		.ir_code	= 0xF30C916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_ESC,
		.ir_code	= 0xF10E916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_VOLUMEUP,
		.ir_code	= 0xF00F916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_VOLUMEDOWN,
		.ir_code	= 0xED12916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_MUTE,
		.ir_code	= 0xEA15916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_INFO,
		.ir_code	= 0xEF10916E
	},
	{	/* Like */
		.type		= EV_KEY,
		.code		= KEY_FN_F3,
		.ir_code	= 0xEE11916E
	},
	{	/* Dislike */
		.type		= EV_KEY,
		.code		= KEY_FN_F4,
		.ir_code	= 0xEB14916E
	},
	{
		.type		= EV_KEY,
		.code		= KEY_POWER,
		.ir_code	= 0xFD02916E
	},
};

static struct ubicom32hid_platform_data ip5170dpf_ubicom32hid_platform_data = {
	.gpio_reset		= GPIO_RA_4,
	.gpio_reset_polarity	= 0,
	.type			= UBICOM32HID_BL_TYPE_BINARY,
	.invert			= 0,
	.default_intensity	= 1,
	.buttons		= ip5170dpf_ubicom32hid_buttons,
	.nbuttons		= ARRAY_SIZE(ip5170dpf_ubicom32hid_buttons),
	.ircodes		= ip5170dpf_ubicom32hid_ircodes,
	.nircodes		= ARRAY_SIZE(ip5170dpf_ubicom32hid_ircodes),
};

/*
 * Devices on the I2C bus
 */
static struct i2c_board_info __initdata ip5170dpf_i2c_board_info[] = {
	/*
	 * U24, ubicom32hid
	 */
	{
		.type		= "ubicom32hid",
		.addr		= 0x08,
		.platform_data	= &ip5170dpf_ubicom32hid_platform_data,
	},

	/*
	 * U14, CS4350 DAC, address 0x4B
	 */
};

/*
 * I2C bus on the board, SDA PF13, SCL PF14
 */
static struct i2c_gpio_platform_data ip5170dpf_i2c_data = {
	.sda_pin		= GPIO_RF_13,
	.scl_pin		= GPIO_RF_14,
	.sda_is_open_drain	= 0,
	.scl_is_open_drain	= 0,
	.scl_is_output_only	= 1,
	.udelay			= 5,
};

static struct platform_device ip5170dpf_i2c_device = {
	.name	= "i2c-gpio",
	.id	= 0,
	.dev	= {
		.platform_data = &ip5170dpf_i2c_data,
	},
};

/*
 * List of all devices in our system
 */
static struct platform_device *ip5170dpf_devices[] __initdata = {
	&ip5170dpf_i2c_device,
	&ip5170dpf_gpio_leds_device,
};

/*
 * ip5170dpf_init
 *	Called to add the devices which we have on this board
 */
static int __init ip5170dpf_init(void)
{
	ubi_gpio_init();

	vdc_tio_init();

	printk(KERN_INFO "%s: registering device resources\n", __FUNCTION__);
	platform_add_devices(ip5170dpf_devices, ARRAY_SIZE(ip5170dpf_devices));

	printk(KERN_INFO "%s: registering i2c resources\n", __FUNCTION__);
	i2c_register_board_info(0, ip5170dpf_i2c_board_info, ARRAY_SIZE(ip5170dpf_i2c_board_info));

	return 0;
}

arch_initcall(ip5170dpf_init);