~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to arch/arm/mach-omap2/board-ldp.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <linux/err.h>
23
23
#include <linux/clk.h>
24
24
#include <linux/spi/spi.h>
25
 
#include <linux/spi/ads7846.h>
26
25
#include <linux/regulator/machine.h>
27
26
#include <linux/i2c/twl.h>
28
27
#include <linux/io.h>
43
42
 
44
43
#include <asm/delay.h>
45
44
#include <plat/usb.h>
 
45
#include <plat/gpmc-smsc911x.h>
46
46
 
47
47
#include "board-flash.h"
48
48
#include "mux.h"
49
49
#include "hsmmc.h"
50
50
#include "control.h"
 
51
#include "common-board-devices.h"
51
52
 
52
53
#define LDP_SMSC911X_CS         1
53
54
#define LDP_SMSC911X_GPIO       152
54
55
#define DEBUG_BASE              0x08000000
55
56
#define LDP_ETHR_START          DEBUG_BASE
56
57
 
57
 
static struct resource ldp_smsc911x_resources[] = {
58
 
        [0] = {
59
 
                .start  = LDP_ETHR_START,
60
 
                .end    = LDP_ETHR_START + SZ_4K,
61
 
                .flags  = IORESOURCE_MEM,
62
 
        },
63
 
        [1] = {
64
 
                .start  = 0,
65
 
                .end    = 0,
66
 
                .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
67
 
        },
68
 
};
69
 
 
70
 
static struct smsc911x_platform_config ldp_smsc911x_config = {
71
 
        .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
72
 
        .irq_type       = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
73
 
        .flags          = SMSC911X_USE_32BIT,
74
 
        .phy_interface  = PHY_INTERFACE_MODE_MII,
75
 
};
76
 
 
77
 
static struct platform_device ldp_smsc911x_device = {
78
 
        .name           = "smsc911x",
79
 
        .id             = -1,
80
 
        .num_resources  = ARRAY_SIZE(ldp_smsc911x_resources),
81
 
        .resource       = ldp_smsc911x_resources,
82
 
        .dev            = {
83
 
                .platform_data = &ldp_smsc911x_config,
84
 
        },
85
 
};
86
 
 
87
58
static uint32_t board_keymap[] = {
88
59
        KEY(0, 0, KEY_1),
89
60
        KEY(1, 0, KEY_2),
197
168
        },
198
169
};
199
170
 
200
 
static int ts_gpio;
201
 
 
202
 
/**
203
 
 * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
204
 
 *
205
 
 * @return - void. If request gpio fails then Flag KERN_ERR.
206
 
 */
207
 
static void ads7846_dev_init(void)
208
 
{
209
 
        if (gpio_request(ts_gpio, "ads7846 irq") < 0) {
210
 
                printk(KERN_ERR "can't get ads746 pen down GPIO\n");
211
 
                return;
212
 
        }
213
 
 
214
 
        gpio_direction_input(ts_gpio);
215
 
        gpio_set_debounce(ts_gpio, 310);
216
 
}
217
 
 
218
 
static int ads7846_get_pendown_state(void)
219
 
{
220
 
        return !gpio_get_value(ts_gpio);
221
 
}
222
 
 
223
 
static struct ads7846_platform_data tsc2046_config __initdata = {
224
 
        .get_pendown_state      = ads7846_get_pendown_state,
225
 
        .keep_vref_on           = 1,
226
 
};
227
 
 
228
 
static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
229
 
        .turbo_mode     = 0,
230
 
        .single_channel = 1,    /* 0: slave, 1: master */
231
 
};
232
 
 
233
 
static struct spi_board_info ldp_spi_board_info[] __initdata = {
234
 
        [0] = {
235
 
                /*
236
 
                 * TSC2046 operates at a max freqency of 2MHz, so
237
 
                 * operate slightly below at 1.5MHz
238
 
                 */
239
 
                .modalias               = "ads7846",
240
 
                .bus_num                = 1,
241
 
                .chip_select            = 0,
242
 
                .max_speed_hz           = 1500000,
243
 
                .controller_data        = &tsc2046_mcspi_config,
244
 
                .irq                    = 0,
245
 
                .platform_data          = &tsc2046_config,
246
 
        },
 
171
static struct omap_smsc911x_platform_data smsc911x_cfg = {
 
172
        .cs             = LDP_SMSC911X_CS,
 
173
        .gpio_irq       = LDP_SMSC911X_GPIO,
 
174
        .gpio_reset     = -EINVAL,
 
175
        .flags          = SMSC911X_USE_32BIT,
247
176
};
248
177
 
249
178
static inline void __init ldp_init_smsc911x(void)
250
179
{
251
 
        int eth_cs;
252
 
        unsigned long cs_mem_base;
253
 
        int eth_gpio = 0;
254
 
 
255
 
        eth_cs = LDP_SMSC911X_CS;
256
 
 
257
 
        if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
258
 
                printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n");
259
 
                return;
260
 
        }
261
 
 
262
 
        ldp_smsc911x_resources[0].start = cs_mem_base + 0x0;
263
 
        ldp_smsc911x_resources[0].end   = cs_mem_base + 0xff;
264
 
        udelay(100);
265
 
 
266
 
        eth_gpio = LDP_SMSC911X_GPIO;
267
 
 
268
 
        ldp_smsc911x_resources[1].start = OMAP_GPIO_IRQ(eth_gpio);
269
 
 
270
 
        if (gpio_request(eth_gpio, "smsc911x irq") < 0) {
271
 
                printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n",
272
 
                                eth_gpio);
273
 
                return;
274
 
        }
275
 
        gpio_direction_input(eth_gpio);
 
180
        gpmc_smsc911x_init(&smsc911x_cfg);
276
181
}
277
182
 
278
183
static struct platform_device ldp_lcd_device = {
294
199
        omap2_init_common_devices(NULL, NULL);
295
200
}
296
201
 
297
 
static struct twl4030_usb_data ldp_usb_data = {
298
 
        .usb_mode       = T2_USB_MODE_ULPI,
299
 
};
300
 
 
301
202
static struct twl4030_gpio_platform_data ldp_gpio_data = {
302
203
        .gpio_base      = OMAP_MAX_GPIO_LINES,
303
204
        .irq_base       = TWL4030_GPIO_IRQ_BASE,
304
205
        .irq_end        = TWL4030_GPIO_IRQ_END,
305
206
};
306
207
 
307
 
static struct twl4030_madc_platform_data ldp_madc_data = {
308
 
        .irq_line       = 1,
309
 
};
310
 
 
311
208
static struct regulator_consumer_supply ldp_vmmc1_supply = {
312
209
        .supply                 = "vmmc",
313
210
};
348
245
};
349
246
 
350
247
static struct twl4030_platform_data ldp_twldata = {
351
 
        .irq_base       = TWL4030_IRQ_BASE,
352
 
        .irq_end        = TWL4030_IRQ_END,
353
 
 
354
248
        /* platform_data for children goes here */
355
 
        .madc           = &ldp_madc_data,
356
 
        .usb            = &ldp_usb_data,
357
249
        .vmmc1          = &ldp_vmmc1,
358
250
        .vaux1          = &ldp_vaux1,
359
251
        .gpio           = &ldp_gpio_data,
360
252
        .keypad         = &ldp_kp_twl4030_data,
361
253
};
362
254
 
363
 
static struct i2c_board_info __initdata ldp_i2c_boardinfo[] = {
364
 
        {
365
 
                I2C_BOARD_INFO("twl4030", 0x48),
366
 
                .flags = I2C_CLIENT_WAKE,
367
 
                .irq = INT_34XX_SYS_NIRQ,
368
 
                .platform_data = &ldp_twldata,
369
 
        },
370
 
};
371
 
 
372
255
static int __init omap_i2c_init(void)
373
256
{
374
 
        omap_register_i2c_bus(1, 2600, ldp_i2c_boardinfo,
375
 
                        ARRAY_SIZE(ldp_i2c_boardinfo));
 
257
        omap3_pmic_get_config(&ldp_twldata,
 
258
                          TWL_COMMON_PDATA_USB | TWL_COMMON_PDATA_MADC, 0);
 
259
        omap3_pmic_init("twl4030", &ldp_twldata);
376
260
        omap_register_i2c_bus(2, 400, NULL, 0);
377
261
        omap_register_i2c_bus(3, 400, NULL, 0);
378
262
        return 0;
389
273
};
390
274
 
391
275
static struct platform_device *ldp_devices[] __initdata = {
392
 
        &ldp_smsc911x_device,
393
276
        &ldp_lcd_device,
394
277
        &ldp_gpio_keys_device,
395
278
};
400
283
};
401
284
#endif
402
285
 
403
 
static struct omap_musb_board_data musb_board_data = {
404
 
        .interface_type         = MUSB_INTERFACE_ULPI,
405
 
        .mode                   = MUSB_OTG,
406
 
        .power                  = 100,
407
 
};
408
 
 
409
286
static struct mtd_partition ldp_nand_partitions[] = {
410
287
        /* All the partition sizes are listed in terms of NAND block size */
411
288
        {
446
323
        ldp_init_smsc911x();
447
324
        omap_i2c_init();
448
325
        platform_add_devices(ldp_devices, ARRAY_SIZE(ldp_devices));
449
 
        ts_gpio = 54;
450
 
        ldp_spi_board_info[0].irq = gpio_to_irq(ts_gpio);
451
 
        spi_register_board_info(ldp_spi_board_info,
452
 
                                ARRAY_SIZE(ldp_spi_board_info));
453
 
        ads7846_dev_init();
 
326
        omap_ads7846_init(1, 54, 310, NULL);
454
327
        omap_serial_init();
455
 
        usb_musb_init(&musb_board_data);
 
328
        usb_musb_init(NULL);
456
329
        board_nand_init(ldp_nand_partitions,
457
330
                ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
458
331