~ubuntu-branches/ubuntu/karmic/linux-mvl-dove/karmic-proposed

« back to all changes in this revision

Viewing changes to arch/arm/mach-dove/dove-db-z0-setup.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader
  • Date: 2010-03-10 22:24:12 UTC
  • mto: (15.1.2 karmic-security)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20100310222412-k86m3r53jw0je7x1
Tags: upstream-2.6.31
ImportĀ upstreamĀ versionĀ 2.6.31

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * arch/arm/mach-dove/dove-db-z0-setup.c
3
 
 *
4
 
 * Marvell DB-MV88F6781-BP Z0 Development Board Setup
5
 
 *
6
 
 * Author: Tzachi Perelstein <tzachi@marvell.com>
7
 
 *
8
 
 * This file is licensed under the terms of the GNU General Public
9
 
 * License version 2.  This program is licensed "as is" without any
10
 
 * warranty of any kind, whether express or implied.
11
 
 */
12
 
 
13
 
#include <linux/kernel.h>
14
 
#include <linux/init.h>
15
 
#include <linux/platform_device.h>
16
 
#include <linux/irq.h>
17
 
#include <linux/mtd/physmap.h>
18
 
#include <linux/mtd/nand.h>
19
 
#include <linux/timer.h>
20
 
#include <linux/ata_platform.h>
21
 
#include <linux/mv643xx_eth.h>
22
 
#include <linux/i2c.h>
23
 
#include <linux/pci.h>
24
 
#include <linux/gpio_mouse.h>
25
 
#include <linux/spi/spi.h>
26
 
#include <linux/spi/orion_spi.h>
27
 
#include <linux/spi/flash.h>
28
 
#include <linux/spi/ads7846.h>
29
 
#include <video/dovefb.h>
30
 
#include <plat/i2s-orion.h>
31
 
#include <asm/mach-types.h>
32
 
#include <asm/gpio.h>
33
 
#include <asm/mach/arch.h>
34
 
#include <mach/dove.h>
35
 
#include <asm/hardware/pxa-dma.h>
36
 
#include <mach/dove_nand.h>
37
 
#include "common.h"
38
 
#include "clock.h"
39
 
#include "mpp.h"
40
 
#include "dove-front-panel-common.h"
41
 
#include <mach/pm.h>
42
 
#include "pmu/mvPmu.h"
43
 
#include "pmu/mvPmuRegs.h"
44
 
 
45
 
#define DOVE_DB_WAKEUP_GPIO     (3)
46
 
static unsigned int front_panel = 0;
47
 
module_param(front_panel, uint, 0);
48
 
MODULE_PARM_DESC(front_panel, "set to 1 if the dove DB front panel connected");
49
 
 
50
 
static unsigned int left_tact = 0;
51
 
module_param(left_tact, uint, 0);
52
 
MODULE_PARM_DESC(left_tact, "Use left tact as mouse. this will disable I2S"
53
 
                 "JPR 3 should be removed, JPR 6 on 2-3");
54
 
 
55
 
static unsigned int use_hal_giga = 1;
56
 
#ifdef CONFIG_MV643XX_ETH
57
 
module_param(use_hal_giga, uint, 0);
58
 
MODULE_PARM_DESC(use_hal_giga, "Use the HAL giga driver");
59
 
#endif
60
 
 
61
 
extern int __init pxa_init_dma_wins(struct mbus_dram_target_info * dram);
62
 
 
63
 
static struct orion_i2s_platform_data i2s1_data = {
64
 
        .i2s_play       = 1,
65
 
        .i2s_rec        = 1,
66
 
        .spdif_play     = 1,
67
 
};
68
 
 
69
 
static struct mv643xx_eth_platform_data dove_db_ge00_data = {
70
 
        .phy_addr       = MV643XX_ETH_PHY_ADDR_DEFAULT,
71
 
};
72
 
 
73
 
static struct mv_sata_platform_data dove_db_sata_data = {
74
 
        .n_ports        = 1,
75
 
};
76
 
 
77
 
static struct gpio_mouse_platform_data tact_dove_db_data = {
78
 
        .scan_ms = 10,
79
 
        .polarity = 1,
80
 
        {
81
 
                {
82
 
                        .up = 54,
83
 
                        .down = 52,
84
 
                        .left = 55,
85
 
                        .right = 56,
86
 
                        .bleft = 57,
87
 
                        .bright = -1,
88
 
                        .bmiddle = -1
89
 
                } 
90
 
        }
91
 
};
92
 
/*****************************************************************************
93
 
 * SPI Devices:
94
 
 *      SPI0: 4M Flash ST-M25P32-VMF6P
95
 
 ****************************************************************************/
96
 
static const struct flash_platform_data dove_db_spi_flash_data = {
97
 
        .type           = "m25p64",
98
 
};
99
 
 
100
 
static struct spi_board_info __initdata dove_db_spi_flash_info[] = {
101
 
        {
102
 
                .modalias       = "m25p80",
103
 
                .platform_data  = &dove_db_spi_flash_data,
104
 
                .irq            = -1,
105
 
                .max_speed_hz   = 20000000,
106
 
                .bus_num        = 0,
107
 
                .chip_select    = 0,
108
 
        },
109
 
};
110
 
 
111
 
/*****************************************************************************
112
 
 * 7-Segment on GPIO 14,15,18,19
113
 
 * Dummy counter up to 7 every 1 sec
114
 
 ****************************************************************************/
115
 
 
116
 
static struct timer_list dove_db_timer;
117
 
static int dove_db_7seg_gpios[] = {14,15,18,19};
118
 
 
119
 
static void dove_db_7seg_event(unsigned long data)
120
 
{
121
 
     static int count = 0;
122
 
 
123
 
     gpio_set_value(dove_db_7seg_gpios[0], count & 1);
124
 
     gpio_set_value(dove_db_7seg_gpios[1], count & (1 << 1));
125
 
     gpio_set_value(dove_db_7seg_gpios[2], count & (1 << 2));
126
 
     gpio_set_value(dove_db_7seg_gpios[3], count & (1 << 3));
127
 
 
128
 
     count = (count + 1) & 7;
129
 
     mod_timer(&dove_db_timer, jiffies + 1 * HZ);
130
 
}
131
 
 
132
 
static int __init dove_db_7seg_init(void)
133
 
{
134
 
        if (machine_is_dove_db_z0()) {
135
 
                int i;
136
 
                
137
 
                for(i = 0; i < 4; i++){
138
 
                        int pin = dove_db_7seg_gpios[i];
139
 
 
140
 
                        if (gpio_request(pin, "7seg LED") == 0) {
141
 
                                if (gpio_direction_output(pin, 0) != 0) {
142
 
                                        printk(KERN_ERR "%s failed "
143
 
                                               "to set output pin %d\n", __func__,
144
 
                                               pin);
145
 
                                        gpio_free(pin);
146
 
                                        return 0;
147
 
                                }
148
 
                        } else {
149
 
                                printk(KERN_ERR "%s failed "
150
 
                                       "to request gpio %d\n", __func__, pin);
151
 
                                return 0;
152
 
                        }
153
 
                }
154
 
                setup_timer(&dove_db_timer, dove_db_7seg_event, 0);
155
 
                mod_timer(&dove_db_timer, jiffies + 1 * HZ);
156
 
        }
157
 
 
158
 
        return 0;
159
 
}
160
 
 
161
 
__initcall(dove_db_7seg_init);
162
 
 
163
 
/*****************************************************************************
164
 
 * PCI
165
 
 ****************************************************************************/
166
 
static int __init dove_db_pci_init(void)
167
 
{
168
 
        if (machine_is_dove_db_z0())
169
 
                        dove_pcie_init(1, 1);
170
 
 
171
 
        return 0;
172
 
}
173
 
 
174
 
subsys_initcall(dove_db_pci_init);
175
 
 
176
 
/*****************************************************************************
177
 
 * A2D on I2C bus
178
 
 ****************************************************************************/
179
 
static struct i2c_board_info __initdata i2c_a2d = {
180
 
        I2C_BOARD_INFO("i2s_i2c", 0x4A),
181
 
};
182
 
 
183
 
/*****************************************************************************
184
 
 * NAND
185
 
 ****************************************************************************/
186
 
static struct mtd_partition partition_dove[] = {
187
 
        { .name         = "UBoot",
188
 
          .offset       = 0,
189
 
          .size         = 1 * SZ_1M },
190
 
        { .name         = "UImage",
191
 
          .offset       = MTDPART_OFS_APPEND,
192
 
          .size         = 4 * SZ_1M },
193
 
        { .name         = "Root",
194
 
          .offset       = MTDPART_OFS_APPEND,
195
 
          .size         = 1019 * SZ_1M },
196
 
};
197
 
static u64 nfc_dmamask = DMA_BIT_MASK(32);
198
 
static struct dove_nand_platform_data dove_db_nfc_data = {
199
 
        .nfc_width      = 8,
200
 
        .use_dma        = 1,
201
 
        .use_ecc        = 1,
202
 
        .use_bch        = 1,
203
 
        .parts = partition_dove,
204
 
        .nr_parts = ARRAY_SIZE(partition_dove)
205
 
};
206
 
 
207
 
static struct resource dove_nfc_resources[]  = {
208
 
        [0] = {
209
 
                .start  = (DOVE_NFC_PHYS_BASE),
210
 
                .end    = (DOVE_NFC_PHYS_BASE + 0xFF),
211
 
                .flags  = IORESOURCE_MEM,
212
 
        },
213
 
        [1] = {
214
 
                .start  = IRQ_NAND,
215
 
                .end    = IRQ_NAND,
216
 
                .flags  = IORESOURCE_IRQ,
217
 
        },
218
 
        [2] = {
219
 
                /* DATA DMA */
220
 
                .start  = 97,
221
 
                .end    = 97,
222
 
                .flags  = IORESOURCE_DMA,
223
 
        },
224
 
        [3] = {
225
 
                /* COMMAND DMA */
226
 
                .start  = 99,
227
 
                .end    = 99,
228
 
                .flags  = IORESOURCE_DMA,
229
 
        },
230
 
};
231
 
 
232
 
static struct platform_device dove_nfc = {
233
 
        .name           = "dove-nand",
234
 
        .id             = -1,
235
 
        .dev            = {
236
 
                .dma_mask               = &nfc_dmamask,
237
 
                .coherent_dma_mask      = DMA_BIT_MASK(32),
238
 
                .platform_data          = &dove_db_nfc_data,
239
 
        },
240
 
        .resource       = dove_nfc_resources,
241
 
        .num_resources  = ARRAY_SIZE(dove_nfc_resources),
242
 
};
243
 
 
244
 
static void __init dove_db_nfc_init(void)
245
 
{
246
 
        dove_db_nfc_data.tclk = dove_tclk_get();
247
 
        platform_device_register(&dove_nfc);
248
 
}
249
 
 
250
 
static struct dove_mpp_mode dove_db_mpp_modes[] __initdata = {
251
 
        {  1, MPP_PMU },                /* CPU power control */
252
 
        {  3, MPP_PMU },                /* Wakeup - power button */
253
 
        {  4, MPP_PMU },                /* CPU power good inication */
254
 
        {  7, MPP_PMU },                /* Standby Led */
255
 
        { 10, MPP_PMU },                /* DVS SDI control */
256
 
        { 11, MPP_SATA_ACT },           /* SATA active */
257
 
        { 14, MPP_GPIO },               /* 7segDebug Led */
258
 
        { 15, MPP_GPIO },               /* 7segDebug Led */
259
 
        { 18, MPP_GPIO },               /* 7segDebug Led */
260
 
        { 19, MPP_GPIO },               /* 7segDebug Led */
261
 
        { 62, MPP_UART1 },              /* 7segDebug Led */
262
 
        { 52, MPP_AUDIO1 },             /* AU1 Group to GPIO */
263
 
        { -1 },
264
 
};
265
 
 
266
 
static struct dove_mpp_mode dove_db_mpp_modes_ltact[] __initdata = {
267
 
        { 52, MPP_GPIO },               /* AU1 Group to GPIO */
268
 
        { -1 },
269
 
};
270
 
 
271
 
/*****************************************************************************
272
 
 * POWER MANAGEMENT
273
 
 ****************************************************************************/
274
 
static int __init dove_db_z0_pm_init(void)
275
 
{
276
 
        MV_PMU_INFO pmuInitInfo;        
277
 
 
278
 
        if (!machine_is_dove_db_z0())
279
 
                return 0;
280
 
 
281
 
        pmuInitInfo.batFltMngDis = MV_FALSE;                    /* Keep battery fault enabled */
282
 
        pmuInitInfo.exitOnBatFltDis = MV_FALSE;                 /* Keep exit from STANDBY on battery fail enabled */
283
 
        pmuInitInfo.sigSelctor[0] = PMU_SIGNAL_NC;
284
 
        pmuInitInfo.sigSelctor[1] = PMU_SIGNAL_CPU_PWRDWN;      /* DEEP-IdLE => 0: CPU off, 1: CPU on */
285
 
        pmuInitInfo.sigSelctor[2] = PMU_SIGNAL_NC;              /* STANDBY => Not used in Z0 */
286
 
        pmuInitInfo.sigSelctor[3] = PMU_SIGNAL_EXT0_WKUP;       /* power on push button */
287
 
        pmuInitInfo.sigSelctor[4] = PMU_SIGNAL_CPU_PWRGOOD;     /* CORE power good used as Standby PG */
288
 
        pmuInitInfo.sigSelctor[5] = PMU_SIGNAL_NC;              /* NON PMU in Z0 Board */
289
 
        pmuInitInfo.sigSelctor[6] = PMU_SIGNAL_NC;              /* Charger interrupt - not used */
290
 
        pmuInitInfo.sigSelctor[7] = PMU_SIGNAL_1;               /* Standby Led - inverted */
291
 
        pmuInitInfo.sigSelctor[8] = PMU_SIGNAL_NC;              /* PM OFF Control - used as GPIO */
292
 
        pmuInitInfo.sigSelctor[9] = PMU_SIGNAL_NC;              /* CPU power good  - not used */
293
 
        pmuInitInfo.sigSelctor[10] = PMU_SIGNAL_SDI;            /* Voltage regulator control */
294
 
        pmuInitInfo.sigSelctor[11] = PMU_SIGNAL_NC;
295
 
        pmuInitInfo.sigSelctor[12] = PMU_SIGNAL_NC;
296
 
        pmuInitInfo.sigSelctor[13] = PMU_SIGNAL_NC;
297
 
        pmuInitInfo.sigSelctor[14] = PMU_SIGNAL_NC;
298
 
        pmuInitInfo.sigSelctor[15] = PMU_SIGNAL_NC;
299
 
        pmuInitInfo.dvsDelay = 0;                               /* PMU cc delay for DVS change */
300
 
        pmuInitInfo.ddrTermGpioNum = -1;                        /* No GPIO is used to disable terminations */
301
 
 
302
 
        /* Initialize the PMU HAL */
303
 
        if (mvPmuInit(&pmuInitInfo) != MV_OK)
304
 
                printk(KERN_NOTICE "Failed to initialive the PMU!\n");
305
 
 
306
 
        /* Configure wakeup events */
307
 
        mvPmuWakeupEventSet(PMU_STBY_WKUP_CTRL_EXT0_FALL | PMU_STBY_WKUP_CTRL_RTC_MASK);
308
 
 
309
 
        /* Register the PM operation in the Linux stack */
310
 
        dove_pm_register();
311
 
 
312
 
        return 0;
313
 
}
314
 
 
315
 
__initcall(dove_db_z0_pm_init);
316
 
 
317
 
/*****************************************************************************
318
 
 * Board Init
319
 
 ****************************************************************************/
320
 
 
321
 
 
322
 
//extern struct mbus_dram_target_info dove_mbus_dram_info;
323
 
//extern int __init pxa_init_dma_wins(struct mbus_dram_target_info * dram);
324
 
static void __init dove_db_init(void)
325
 
{
326
 
        /*
327
 
         * Basic Dove setup. Needs to be called early.
328
 
         */
329
 
        dove_init();
330
 
        dove_mpp_conf(dove_db_mpp_modes);
331
 
 
332
 
        /* the (SW1) button is for use as a "wakeup" button */
333
 
        dove_wakeup_button_setup(DOVE_DB_WAKEUP_GPIO);
334
 
 
335
 
        /* card interrupt workaround using GPIOs */
336
 
        dove_sd_card_int_wa_setup(0);
337
 
        dove_sd_card_int_wa_setup(1);
338
 
 
339
 
 
340
 
        if(front_panel) {
341
 
                if(left_tact)
342
 
                        dove_mpp_conf(dove_db_mpp_modes_ltact);
343
 
                /* JPR6 shoud be on 1-2 for touchscreen irq line */
344
 
 
345
 
                if (dove_fp_ts_gpio_setup() != 0)
346
 
                        return;
347
 
        }
348
 
 
349
 
        /* Initialize AC'97 related regs.       */
350
 
        dove_ac97_setup();
351
 
 
352
 
        dove_rtc_init();
353
 
        pxa_init_dma_wins(&dove_mbus_dram_info);
354
 
        pxa_init_dma(16);
355
 
        dove_xor0_init();
356
 
        dove_xor1_init();
357
 
#ifdef CONFIG_MV_ETHERNET
358
 
        if(use_hal_giga)
359
 
                dove_mv_eth_init();
360
 
        else
361
 
#endif
362
 
        dove_ge00_init(&dove_db_ge00_data);
363
 
 
364
 
        dove_ehci0_init();
365
 
        dove_ehci1_init();
366
 
 
367
 
        /* ehci init functions access the usb port, only now it's safe to disable
368
 
         * all clocks
369
 
         */
370
 
        ds_clks_disable_all(0, 0);
371
 
 
372
 
        dove_sata_init(&dove_db_sata_data);
373
 
        dove_spi0_init(0);
374
 
        dove_spi1_init(0);
375
 
 
376
 
        /* uart1 is the debug port, register it first so it will be */
377
 
        /* represented by device ttyS0, root filesystems usually expect the */
378
 
        /* console to be on that device */
379
 
        dove_uart1_init();
380
 
        dove_uart0_init();
381
 
        dove_i2c_init();
382
 
        dove_i2c_exp_init(0);
383
 
        dove_sdhci_cam_mbus_init();
384
 
        dove_sdio0_init();
385
 
        dove_sdio1_init();
386
 
        dove_db_nfc_init();
387
 
        dove_fp_clcd_init();
388
 
        dove_vmeta_init();
389
 
        dove_gpu_init();
390
 
        dove_cesa_init();
391
 
 
392
 
        if(front_panel) {
393
 
                dove_lcd_spi_init();
394
 
                dove_cam_init(&dove_cafe_cam_data);
395
 
        }
396
 
        if(front_panel && left_tact)
397
 
                dove_tact_init(&tact_dove_db_data);
398
 
        else
399
 
                dove_i2s_init(1, &i2s1_data);
400
 
        i2c_register_board_info(0, &i2c_a2d, 1);
401
 
        spi_register_board_info(dove_db_spi_flash_info,
402
 
                                ARRAY_SIZE(dove_db_spi_flash_info));
403
 
        spi_register_board_info(dove_fp_spi_devs, dove_fp_spi_devs_num());
404
 
}
405
 
 
406
 
MACHINE_START(DOVE_DB, "Marvell DB-MV88F6781-BP-Z0 Development Board")
407
 
        .phys_io        = DOVE_SB_REGS_PHYS_BASE,
408
 
        .io_pg_offst    = ((DOVE_SB_REGS_VIRT_BASE) >> 18) & 0xfffc,
409
 
        .boot_params    = 0x00000100,
410
 
        .init_machine   = dove_db_init,
411
 
        .map_io         = dove_map_io,
412
 
        .init_irq       = dove_init_irq,
413
 
        .timer          = &dove_timer,
414
 
/* reserve memory for VMETA and GPU */
415
 
        .fixup          = dove_tag_fixup_mem32,
416
 
MACHINE_END