This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TW9910 Load FAIL in kernel!

Other Parts Discussed in Thread: DA8XX, OMAPL138, PCA9543A, OMAP-L138

Hi 

    On my 138 board, I using TW9910, but when it run, cann't load TW9910 Driver:

     Unable to handle kernel paging request at virtual address 68008013

     I add log in tw9910.c,  find that it down here:

static int tw9910_probe(struct i2c_client *client,
const struct i2c_device_id *did)

{
struct tw9910_priv *priv;
struct tw9910_video_info *info;
struct soc_camera_device *icd = client->dev.platform_data;
struct i2c_adapter *adapter =
to_i2c_adapter(client->dev.parent);
struct soc_camera_link *icl;
int ret;

if (!icd) {

dev_err(&client->dev, "TW9910: missing soc-camera data!\n");
return -EINVAL;
}

icl = to_soc_camera_link(icd);
if (!icl || !icl->priv)        ----DOWN HERE
return -EINVAL;

info = icl->priv;

if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {

dev_err(&client->dev,
"I2C-Adapter doesn't support "
"I2C_FUNC_SMBUS_BYTE_DATA\n");
return -EIO;
}

priv = kzalloc(sizeof(*priv), GFP_KERNEL);

if (!priv)
return -ENOMEM;

priv->info = info;

v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops);

icd->ops = &tw9910_ops;

icd->iface = icl->bus_id;

ret = tw9910_video_probe(icd, client);

if (ret) {
icd->ops = NULL;
i2c_set_clientdata(client, NULL);
kfree(priv);
}

return ret;

}

    the soc_camera_link object is not valid! 

    All log is:

Uncompressing Linux... done, booting the kernel.
Linux version 2.6.33-rc4 (root@ubuntu) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #5 PREEMPT Fri Mar 21 17:21:57 HKT 2014
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: DaVinci DA850/OMAP-L138/AM18xx EVM
Memory policy: ECC disabled, Data cache writeback
DaVinci da850/omap-l138/am18xx variant 0x1
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: console=tty2,115200n8 noinitrd rw rootfstype=ext3 root=/dev/mmcblk0p2 rootwait mem=64M
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60492KB available (3916K code, 310K data, 144K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:245
Console: colour dummy device 80x30
Calibrating delay loop... 149.50 BogoMIPS (lpj=747520)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
DaVinci: 144 gpio irqs
NET: Registered protocol family 16
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c-gpio i2c-gpio.1: using pins 20 (SDA) and 21 (SCL)
vpif vpif: vpif probe success
Switching to clocksource timer0_1
musb_hdrc: version 6.0, cppi4.1-dma, host, debug=0
Waiting for USB PHY clock good...
musb_hdrc: USB Host mode controller at fee00000 using DMA, IRQ 58
musb_hdrc musb_hdrc: MUSB HDRC host driver
musb_hdrc musb_hdrc: new USB bus registered, assigned bus number 1
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
EMAC: MII PHY configured, RMII PHY will not be functional
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 118
io scheduler noop registered (default)
da8xx_lcdc da8xx_lcdc.0: GLCD: Found Sharp_LK043T1DG01 panel
Console: switching to colour frame buffer device 60x34
Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0x1c42000 (irq = 25) is a 16550A
serial8250.0: ttyS1 at MMIO 0x1d0c000 (irq = 53) is a 16550A
serial8250.0: ttyS2 at MMIO 0x1d0d000 (irq = 61) is a 16550A
console [ttyS2] enabled
brd: module loaded
spi_davinci spi_davinci.1: DaVinci SPI driver in EDMA mode
Using RX channel = 18 , TX channel = 19 and event queue = 1
m25p80 spi1.0: non-JEDEC variant of m25p64
m25p80 spi1.0: m25p64 (8192 Kbytes)
Creating 4 MTD partitions on "m25p80":
0x000000000000-0x000000040000 : "U-Boot"
0x000000040000-0x000000050000 : "U-Boot Environment"
0x000000050000-0x0000007f0000 : "Linux"
0x0000007f0000-0x000000800000 : "MAC Address"
spi_davinci spi_davinci.1: Controller at 0xfef0e000 
console [netcon0] enabled
netconsole: network logging started
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
ohci ohci.0: DA8xx OHCI
ohci ohci.0: new USB bus registered, assigned bus number 2
ohci ohci.0: irq 59, io mem 0x01e25000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
omap_rtc omap_rtc: rtc core: registered omap_rtc as rtc0
omap_rtc: RTC power up reset detected
i2c /dev entries driver
Linux video capture interface: v2.00
Unable to handle kernel paging request at virtual address 68008013
pgd = c0004000
[68008013] *pgd=00000000
Internal error: Oops: 1 [#1] PREEMPT
last sysfs file: 
Modules linked in:
CPU: 0    Not tainted  (2.6.33-rc4 #5)
PC is at tw9910_probe+0x5c/0x2c0
LR is at release_console_sem+0x1f8/0x210
pc : [<c0224e88>]    lr : [<c00415a8>]    psr: 20000013
sp : c3823cf0  ip : c3823c30  fp : c3823d1c
r10: c041c244  r9 : 00000000  r8 : c3854230
r7 : 68007fff  r6 : c04082f0  r5 : c38ea300  r4 : c0224e2c
r3 : 00000000  r2 : 00000001  r1 : 000012a8  r0 : 00000013
Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 0005317f  Table: c0004000  DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc3822270)
Stack: (0xc3823cf0 to 0xc3824000)
3ce0:                                     00000000 00000000 c0224e2c c38ea300
3d00: c0422a00 00000000 00000000 c041c244 c3823d34 c3823d20 c020a2f0 c0224e3c
3d20: c0422a00 c38ea320 c3823d54 c3823d38 c01b5ccc c020a26c c0422a00 c38ea320
3d40: c38ea320 00000000 c3823d6c c3823d58 c01b5e50 c01b5c2c 00000000 c01b5e0c
3d60: c3823d94 c3823d70 c01b5184 c01b5e1c c384d048 c39f70f4 c03c6d34 c38ea320
3d80: c38ea354 c3854200 c3823dac c3823d98 c01b5ed8 c01b5144 c38ea320 c38ea320
3da0: c3823dbc c3823db0 c01b4ff0 c01b5e90 c3823e04 c3823dc0 c01b39a4 c01b4fd4
3dc0: c38ea328 c3854230 c3823dec c3823dd8 c01725c8 c0172510 c38ea320 c38ea320
3de0: c38ea300 c3854200 c38ea304 00000000 00000002 00000000 c3823e1c c3823e08
3e00: c01b3b20 c01b3694 c38ea320 c38ea300 c3823e44 c3823e20 c020b5f8 c01b3b14
3e20: c3854200 00000000 c3854200 00000000 c0408058 c04473c8 c3823e64 c3823e48
3e40: c0221f88 c020b554 c38fba60 00000000 c0408054 c04473c8 c3823eac c3823e68
3e60: c001d80c c0221f1c 00000000 00000001 00000000 c0405298 c0407c10 c3854200
3e80: c3823e9c c04052a0 c04052a0 c0422c78 c39e6360 c04171c0 00000000 00000000
3ea0: c3823ebc c3823eb0 c01b6ca8 c001d490 c3823edc c3823ec0 c01b5ccc c01b6c98
3ec0: c04052a0 c04052d4 c0422c78 c39e6360 c3823efc c3823ee0 c01b5de8 c01b5c2c
3ee0: 00000000 c01b5d80 c0422c78 c39e6360 c3823f24 c3823f00 c01b548c c01b5d90
3f00: c3804638 c383aab0 c0172bcc c002440c c0422c78 c0422c78 c3823f34 c3823f28
3f20: c01b5b30 c01b544c c3823f64 c3823f38 c01b4d64 c01b5b20 c03a2d02 00000000
3f40: c002440c 00000000 c0422c78 00000001 00000000 00000000 c3823f8c c3823f68
3f60: c01b6104 c01b4cd0 c002440c 00000000 c001d464 00000001 00000000 00000000
3f80: c3823f9c c3823f90 c01b7114 c01b6064 c3823fac c3823fa0 c001d478 c01b70d8
3fa0: c3823fdc c3823fb0 c002c3a4 c001d474 00000000 00000000 c3823fdc c3823fc8
3fc0: c002440c 00000000 00000000 00000000 c3823ff4 c3823fe0 c0008480 c002c350
3fe0: 00000000 00000000 00000000 c3823ff8 c0044470 c00083e8 dfff6bff 7fffabef
Backtrace: 
[<c0224e2c>] (tw9910_probe+0x0/0x2c0) from [<c020a2f0>] (i2c_device_probe+0x94/0xac)
[<c020a25c>] (i2c_device_probe+0x0/0xac) from [<c01b5ccc>] (driver_probe_device+0xb0/0x164)
 r5:c38ea320 r4:c0422a00
[<c01b5c1c>] (driver_probe_device+0x0/0x164) from [<c01b5e50>] (__device_attach+0x44/0x48)
 r7:00000000 r6:c38ea320 r5:c38ea320 r4:c0422a00
[<c01b5e0c>] (__device_attach+0x0/0x48) from [<c01b5184>] (bus_for_each_drv+0x50/0x90)
 r5:c01b5e0c r4:00000000
[<c01b5134>] (bus_for_each_drv+0x0/0x90) from [<c01b5ed8>] (device_attach+0x58/0x70)
 r6:c3854200 r5:c38ea354 r4:c38ea320
[<c01b5e80>] (device_attach+0x0/0x70) from [<c01b4ff0>] (bus_probe_device+0x2c/0x4c)
 r5:c38ea320 r4:c38ea320
[<c01b4fc4>] (bus_probe_device+0x0/0x4c) from [<c01b39a4>] (device_add+0x320/0x480)
[<c01b3684>] (device_add+0x0/0x480) from [<c01b3b20>] (device_register+0x1c/0x20)
[<c01b3b04>] (device_register+0x0/0x20) from [<c020b5f8>] (i2c_new_device+0xb4/0x110)
 r5:c38ea300 r4:c38ea320
[<c020b544>] (i2c_new_device+0x0/0x110) from [<c0221f88>] (v4l2_i2c_new_subdev_board+0x7c/0x1d4)
 r7:c04473c8 r6:c0408058 r5:00000000 r4:c3854200
[<c0221f0c>] (v4l2_i2c_new_subdev_board+0x0/0x1d4) from [<c001d80c>] (vpif_probe+0x38c/0x524)
 r7:c04473c8 r6:c0408054 r5:00000000 r4:c38fba60
[<c001d480>] (vpif_probe+0x0/0x524) from [<c01b6ca8>] (platform_drv_probe+0x20/0x24)
[<c01b6c88>] (platform_drv_probe+0x0/0x24) from [<c01b5ccc>] (driver_probe_device+0xb0/0x164)
[<c01b5c1c>] (driver_probe_device+0x0/0x164) from [<c01b5de8>] (__driver_attach+0x68/0x8c)
 r7:c39e6360 r6:c0422c78 r5:c04052d4 r4:c04052a0
[<c01b5d80>] (__driver_attach+0x0/0x8c) from [<c01b548c>] (bus_for_each_dev+0x50/0x84)
 r7:c39e6360 r6:c0422c78 r5:c01b5d80 r4:00000000
[<c01b543c>] (bus_for_each_dev+0x0/0x84) from [<c01b5b30>] (driver_attach+0x20/0x28)
 r6:c0422c78 r5:c0422c78 r4:c002440c
[<c01b5b10>] (driver_attach+0x0/0x28) from [<c01b4d64>] (bus_add_driver+0xa4/0x230)
[<c01b4cc0>] (bus_add_driver+0x0/0x230) from [<c01b6104>] (driver_register+0xb0/0x13c)
[<c01b6054>] (driver_register+0x0/0x13c) from [<c01b7114>] (platform_driver_register+0x4c/0x60)
 r9:00000000 r8:00000000 r7:00000001 r6:c001d464 r5:00000000
r4:c002440c
[<c01b70c8>] (platform_driver_register+0x0/0x60) from [<c001d478>] (vpif_init+0x14/0x1c)
[<c001d464>] (vpif_init+0x0/0x1c) from [<c002c3a4>] (do_one_initcall+0x64/0x1c4)
[<c002c340>] (do_one_initcall+0x0/0x1c4) from [<c0008480>] (kernel_init+0xa8/0x12c)
 r7:00000000 r6:00000000 r5:00000000 r4:c002440c
[<c00083d8>] (kernel_init+0x0/0x12c) from [<c0044470>] (do_exit+0x0/0x6b4)
 r5:00000000 r4:00000000
Code: e59f0220 eb03a520 e3570000 0a00007f (e5973014) 
---[ end trace 2b72a45972d80a0f ]---
Kernel panic - not syncing: Attempted to kill init!
Backtrace: 
[<c0030730>] (dump_backtrace+0x0/0x114) from [<c030e1c4>] (dump_stack+0x18/0x1c)
 r7:c3820000 r6:c3820000 r5:00000001 r4:c042ed98
[<c030e1ac>] (dump_stack+0x0/0x1c) from [<c030e22c>] (panic+0x64/0x13c)
[<c030e1c8>] (panic+0x0/0x13c) from [<c00444e4>] (do_exit+0x74/0x6b4)
 r3:c040a3f0 r2:00000001 r1:c3823b00 r0:c03a4599
[<c0044470>] (do_exit+0x0/0x6b4) from [<c0030adc>] (die+0x298/0x2cc)
[<c0030844>] (die+0x0/0x2cc) from [<c0032308>] (__do_kernel_fault+0x6c/0x7c)
[<c003229c>] (__do_kernel_fault+0x0/0x7c) from [<c0032564>] (do_bad_area+0x64/0x70)
 r7:00000000 r6:00000000 r5:00000014 r4:e5973014
[<c0032500>] (do_bad_area+0x0/0x70) from [<c0034584>] (do_alignment+0x5ac/0x700)
[<c0033fd8>] (do_alignment+0x0/0x700) from [<c002c2e0>] (do_DataAbort+0x3c/0x9c)
[<c002c2a4>] (do_DataAbort+0x0/0x9c) from [<c002cacc>] (__dabt_svc+0x4c/0x60)
Exception stack(0xc3823ca8 to 0xc3823cf0)
3ca0:                   00000013 000012a8 00000001 00000000 c0224e2c c38ea300
3cc0: c04082f0 68007fff c3854230 00000000 c041c244 c3823d1c c3823c30 c3823cf0
3ce0: c00415a8 c0224e88 20000013 ffffffff
 r8:c3854230 r7:68007fff r6:c04082f0 r5:c3823cdc r4:ffffffff
[<c0224e2c>] (tw9910_probe+0x0/0x2c0) from [<c020a2f0>] (i2c_device_probe+0x94/0xac)
[<c020a25c>] (i2c_device_probe+0x0/0xac) from [<c01b5ccc>] (driver_probe_device+0xb0/0x164)
 r5:c38ea320 r4:c0422a00
[<c01b5c1c>] (driver_probe_device+0x0/0x164) from [<c01b5e50>] (__device_attach+0x44/0x48)
 r7:00000000 r6:c38ea320 r5:c38ea320 r4:c0422a00
[<c01b5e0c>] (__device_attach+0x0/0x48) from [<c01b5184>] (bus_for_each_drv+0x50/0x90)
 r5:c01b5e0c r4:00000000
[<c01b5134>] (bus_for_each_drv+0x0/0x90) from [<c01b5ed8>] (device_attach+0x58/0x70)
 r6:c3854200 r5:c38ea354 r4:c38ea320
[<c01b5e80>] (device_attach+0x0/0x70) from [<c01b4ff0>] (bus_probe_device+0x2c/0x4c)
 r5:c38ea320 r4:c38ea320
[<c01b4fc4>] (bus_probe_device+0x0/0x4c) from [<c01b39a4>] (device_add+0x320/0x480)
[<c01b3684>] (device_add+0x0/0x480) from [<c01b3b20>] (device_register+0x1c/0x20)
[<c01b3b04>] (device_register+0x0/0x20) from [<c020b5f8>] (i2c_new_device+0xb4/0x110)
 r5:c38ea300 r4:c38ea320
[<c020b544>] (i2c_new_device+0x0/0x110) from [<c0221f88>] (v4l2_i2c_new_subdev_board+0x7c/0x1d4)
 r7:c04473c8 r6:c0408058 r5:00000000 r4:c3854200
[<c0221f0c>] (v4l2_i2c_new_subdev_board+0x0/0x1d4) from [<c001d80c>] (vpif_probe+0x38c/0x524)
 r7:c04473c8 r6:c0408054 r5:00000000 r4:c38fba60
[<c001d480>] (vpif_probe+0x0/0x524) from [<c01b6ca8>] (platform_drv_probe+0x20/0x24)
[<c01b6c88>] (platform_drv_probe+0x0/0x24) from [<c01b5ccc>] (driver_probe_device+0xb0/0x164)
[<c01b5c1c>] (driver_probe_device+0x0/0x164) from [<c01b5de8>] (__driver_attach+0x68/0x8c)
 r7:c39e6360 r6:c0422c78 r5:c04052d4 r4:c04052a0
[<c01b5d80>] (__driver_attach+0x0/0x8c) from [<c01b548c>] (bus_for_each_dev+0x50/0x84)
 r7:c39e6360 r6:c0422c78 r5:c01b5d80 r4:00000000
[<c01b543c>] (bus_for_each_dev+0x0/0x84) from [<c01b5b30>] (driver_attach+0x20/0x28)
 r6:c0422c78 r5:c0422c78 r4:c002440c
[<c01b5b10>] (driver_attach+0x0/0x28) from [<c01b4d64>] (bus_add_driver+0xa4/0x230)
[<c01b4cc0>] (bus_add_driver+0x0/0x230) from [<c01b6104>] (driver_register+0xb0/0x13c)
[<c01b6054>] (driver_register+0x0/0x13c) from [<c01b7114>] (platform_driver_register+0x4c/0x60)
 r9:00000000 r8:00000000 r7:00000001 r6:c001d464 r5:00000000
r4:c002440c
[<c01b70c8>] (platform_driver_register+0x0/0x60) from [<c001d478>] (vpif_init+0x14/0x1c)
[<c001d464>] (vpif_init+0x0/0x1c) from [<c002c3a4>] (do_one_initcall+0x64/0x1c4)
[<c002c340>] (do_one_initcall+0x0/0x1c4) from [<c0008480>] (kernel_init+0xa8/0x12c)
 r7:00000000 r6:00000000 r5:00000000 r4:c002440c
[<c00083d8>] (kernel_init+0x0/0x12c) from [<c0044470>] (do_exit+0x0/0x6b4)
 r5:00000000 r4:00000000

    why? what should I do?

    Thanks very much!

   

  • Hi,

    Could you please attach your board file and confirm that you have added platform data for TW9910?

  • Hi Titusrathinaraj :

        Thanks very much!

        I had add platform data to board-da850-evm.c.  File is:

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/delay.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/regulator/machine.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/usb/musb.h>
    #include <linux/i2c-gpio.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <mach/flash.h>
    #include <mach/vpif.h>
    
    #include <media/tvp514x.h>
    
    #define DA850_EVM_PHY_MASK		0x1
    #define DA850_EVM_MDIO_FREQUENCY	2200000 /* PHY bus frequency */
    
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)	
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)
    #ifdef CONFIG_SOC_CAMERA_TW9900
    #define CAMERA_CH0		"tw9900-0"
    #define CAMERA_CH1		"tw9900-1"
    #else
    #define CAMERA_CH0		"tw9910-0"
    #define CAMERA_CH1		"tw9910-1"
    #endif
    #else
    #define CAMERA_CH0		"tvp514x-0"
    #define CAMERA_CH1		"tvp514x-1"
    #endif
    
    #define VPIF_STATUS	(0x002C)
    #define VPIF_STATUS_CLR	(0x0030)
    #define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4)
    #define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13)
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_2M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct davinciflash_pdata da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_norflash_device = {
    	.name		= "davinci-flash",
    	.id		= 0,
    	.dev		= {
    		.platform_data  = &da850_evm_norflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_norflash_resource),
    	.resource	= da850_evm_norflash_resource,
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= 0x200000,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.options	= NAND_USE_FLASH_BBT,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_nandflash_device = {
    	.name		= "davinci_nand",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_evm_nandflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    	.resource	= da850_evm_nandflash_resource,
    };
    
    static struct platform_device *da850_evm_devices[] __initdata = {
    	&da850_evm_nandflash_device,
    	&da850_evm_norflash_device,
    };
    
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_CE3CFG_OFFSET	0x14
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static struct mtd_partition spi_flash_partitions[] = {
    	[0] = {
    		.name = "U-Boot",
    		.offset = 0,
    		.size = SZ_256K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot Environment",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "Linux",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_8M - (SZ_256K + SZ_64K + SZ_64K),
    		.mask_flags = 0,
    	},
    	[3] = {
    		.name = "MAC Address",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    		.setup = davinci_get_mac_addr,
    		.context = (void *)0,
    	},
    };
    
    static struct flash_platform_data spi_flash_data = {
    	.name = "m25p80",
    	.parts = spi_flash_partitions,
    	.nr_parts = ARRAY_SIZE(spi_flash_partitions),
    	.type = "m25p64",
    };
    
    static struct spi_board_info da850_spi_board_info[] = {
    	[0] = {
    		.modalias = "m25p80",
    		.platform_data = &spi_flash_data,
    		.mode = SPI_MODE_0,
    		.max_speed_hz = 30000000,       /* max sample rate at 3V */
    		.bus_num = 1,
    		.chip_select = 0,
    	},
    };
    
    static u32 ui_card_detected;
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    static void __init da850_evm_init_nand(void)
    {
    	void __iomem *aemif_addr;
    	u32 ce3cfg;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	ce3cfg = 0
    		| (0 << 31)	/* selectStrobe */
    		| (0 << 30)	/* extWait */
    		| (0 << 26)	/* writeSetup */
    		| (3 << 20)	/* writeStrobe  30 ns */
    		| (3 << 17)	/* writeHold    30 ns */
    		| (2 << 13)	/* readSetup    20 ns */
    		| (4 << 7)	/* readStrobe   40 ns */
    		| (0 << 4)	/* readHold */
    		| (0 << 2)	/* turnAround */
    		| (0 << 0)	/* asyncSize    8-bit bus */
    		;
    
    	writel(ce3cfg, aemif_addr + DA8XX_AEMIF_CE3CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    
    static __init void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    //	if (ui_card_detected & !HAS_MMC) {
    		ret = da8xx_pinmux_setup(da850_nand_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nand mux setup failed: "
    					"%d\n", ret);
    
    		da850_evm_init_nand();
    
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    /*
    		// Driver GP0[11] low for NOR to work 
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = da8xx_pinmux_setup(da850_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    */
    		
    		platform_add_devices(da850_evm_devices,
    					ARRAY_SIZE(da850_evm_devices));
    //	}
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value(a, 0);
    	gpio_set_value(b, 0);
    	gpio_set_value(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + 7;
    	sel_b = gpio + 6;
    	sel_c = gpio + 5;
    
    	ret = gpio_request(sel_a, "sel_a");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, "sel_b");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, "sel_c");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	ui_card_detected = 1;
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	return 0;
    
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	/* deselect all functionalities */
    	gpio_set_value(gpio + 5, 1);
    	gpio_set_value(gpio + 6, 1);
    	gpio_set_value(gpio + 7, 1);
    
    	gpio_free(gpio + 5);
    	gpio_free(gpio + 6);
    	gpio_free(gpio + 7);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    };
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1380000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    };
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.eventq_no	= EVENTQ_1,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp0_config = {
    	.inst	= 0,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp1_config = {
    	.inst	= 1,
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE,
    //	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    //				  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	void __iomem *cfg_mstpri2_base;
    	int status;
    	u32 val;
    
    	/*
    	 * Reconfigure the LCDC priority to the highest to ensure that
    	 * the throughput/latency requirements for the LCDC are met.
    	 */
    	cfg_mstpri2_base = DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG);
    
    	val = __raw_readl(cfg_mstpri2_base);
    	val &= 0x0fffffff;
    	__raw_writel(val, cfg_mstpri2_base);
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = da8xx_pinmux_setup(da850_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = da8xx_pinmux_setup(da850_cpgmac_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
    	soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    
    //#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    #define CAMERA_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    	{
    		.name	= CAMERA_CH0,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x45),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= CAMERA_CH1,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x44),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x44),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    		.input = INPUT_SVIDEO_VI2C_VI1C,		///HUANYI_SYSTEM Test
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
           {
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_DAVINCI_MCBSP0)
    #define HAS_MCBSP0 1
    #else
    #define HAS_MCBSP0 0
    #endif
    
    #if defined(CONFIG_DAVINCI_MCBSP1)
    #define HAS_MCBSP1 1
    #else
    #define HAS_MCBSP1 0
    #endif
    
    #if defined(CONFIG_TI_DAVINCI_EMAC) || \
    	defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
    #define HAS_EMAC 1
    #else
    #define HAS_EMAC 0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DA850_UI_RMII) && (HAS_EMAC)
    #define HAS_RMII 1
    #else
    #define HAS_RMII 0
    #endif
    
    #if defined(CONFIG_DA850_UI_LCD) && defined(CONFIG_FB_DA8XX) ||\
    		defined(CONFIG_FB_DA8XX_MODULE)
    #define HAS_GLCD 1
    #else
    #define HAS_GLCD 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    static da8xx_ocic_handler_t da850_evm_usb_ocic_handler;
    
    static int da850_evm_usb_set_power(unsigned port, int on)
    {
    	gpio_set_value(DA850_USB1_VBUS_PIN, on);
    	return 0;
    }
    
    static int da850_evm_usb_get_power(unsigned port)
    {
    	return gpio_get_value(DA850_USB1_VBUS_PIN);
    }
    
    static int da850_evm_usb_get_oci(unsigned port)
    {
    	return !gpio_get_value(DA850_USB1_OC_PIN);
    }
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static int da850_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
    {
    	int irq 	= gpio_to_irq(DA850_USB1_OC_PIN);
    	int error	= 0;
    
    	if (handler != NULL) {
    		da850_evm_usb_ocic_handler = handler;
    
    		error = request_irq(irq, da850_evm_usb_ocic_irq, IRQF_DISABLED |
    				    IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
    				    "OHCI over-current indicator", NULL);
    		if (error)
    			printk(KERN_ERR "%s: could not request IRQ to watch "
    			       "over-current indicator changes\n", __func__);
    	} else
    		free_irq(irq, NULL);
    
    	return error;
    }
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.set_power	= da850_evm_usb_set_power,
    	.get_power	= da850_evm_usb_get_power,
    	.get_oci	= da850_evm_usb_get_oci,
    	.ocic_notify	= da850_evm_usb_ocic_notify,
    
    	/* TPS2065 switch @ 5V */
    	.potpgt		= (3 + 1) / 2,	/* 3 ms max */
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *dev_id)
    {
    	da850_evm_usb_ocic_handler(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static struct musb_hdrc_platform_data usb_evm_data[] = {
    	{
    #ifdef CONFIG_USB_MUSB_OTG
    		.mode = MUSB_OTG,
    #elif defined(CONFIG_USB_MUSB_DUAL_ROLE)
    		.mode = MUSB_DUAL_ROLE,
    #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
    		.mode =  MUSB_PERIPHERAL,
    #elif defined(CONFIG_USB_MUSB_HOST)
    		.mode = MUSB_HOST,
    #endif
    		.power = 255,
    		.potpgt = 8,
    		.set_vbus = NULL, /* VBUs is directly controlled by the IP */
    	}
    };
    
    static __init void da850_evm_usb_init(void)
    {
    	int ret;
    	u32 cfgchip2;
    
    	/*
    	 * Setup the Ref. clock frequency for the EVM at 24 MHz.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	da8xx_usb20_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data));
    
    	ret = da8xx_pinmux_setup(da850_evm_usb11_pins);
    	if (ret) {
    		pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
    			   __func__, ret);
    		return;
    	}
    
    	ret = gpio_request(DA850_USB1_VBUS_PIN, "USB1 VBUS\n");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "power control: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_output(DA850_USB1_VBUS_PIN, 0);
    
    	ret = gpio_request(DA850_USB1_OC_PIN, "USB1 OC");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "over-current indicator: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_input(DA850_USB1_OC_PIN);
    
    	ret = da8xx_register_usb11(&da850_evm_usb11_pdata);
    	if (ret)
    		pr_warning("%s: USB 1.1 registration failed: %d\n",
    			   __func__, ret);
    }
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    
    	ret = da8xx_register_edma();
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    
    		ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	//i2c_register_board_info(1, da850_evm_i2c_devices,
    	//		ARRAY_SIZE(da850_evm_i2c_devices));
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCBSP0) {
    		if (HAS_EMAC)
    			pr_warning("WARNING: both MCBSP0 and EMAC are "
    				"enabled, but they share pins.\n"
    				"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcbsp0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp0_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 registration"
    					"failed: %d\n",	ret);
    	}
    
    	if (HAS_MCBSP1) {
    		ret = da8xx_pinmux_setup(da850_mcbsp1_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp1_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 registration"
    					" failed: %d\n", ret);
    	}
    
    	if (HAS_MCASP) {
    		if ((HAS_MCBSP0 || HAS_MCBSP1))
    			pr_warning("WARNING: both McASP and McBSP are enabled, "
    					"but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed:"
    					"%d\n", ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_register_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_spi1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: spi1 mux setup failed: %d\n",
    				ret);
    
    	da850_init_spi1(BIT(0), da850_spi_board_info,
    			ARRAY_SIZE(da850_spi_board_info));
    
    	da850_evm_usb_init();
    
    	ret = da8xx_register_sata();
    	if (ret)
    		pr_warning("da850_evm_init: SATA registration failed: %d\n",
    						ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    	}
    
    	if (!HAS_RMII && HAS_VPIF_CAPTURE) {
    		ret = da8xx_pinmux_setup(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    
    	}
    
    	if (!HAS_GLCD && HAS_VPIF_DISPLAY) {
    		ret = da8xx_pinmux_setup(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    //		ret = da850_register_vpif_display(&da850_vpif_display_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF registration failed: "
    //					"%d\n",	ret);
    
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static __init void da850_evm_irq_init(void)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
    			soc_info->intc_irq_prios);
    }
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18xx EVM")
    	.phys_io	= IO_PHYS,
    	.io_pg_offst	= (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
    	.boot_params	= (DA8XX_DDR_BASE + 0x100),
    	.map_io		= da850_evm_map_io,
    	.init_irq	= da850_evm_irq_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    MACHINE_END
    

     

         Is there something wrong?

         Thanks.

       

  • Hi Li,

    From attached your bootup logs, You are getting errors while loading i2c driver,

    I have attached modified board file for TW9910 driver, use this and let me know the status,

    If you face any building errors try to fix it yourself like adding any include ".h" file if i missed.

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/delay.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/regulator/machine.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/usb/musb.h>
    #include <linux/i2c-gpio.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    //titus
    #include <media/tw9910.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <mach/flash.h>
    #include <mach/vpif.h>
    
    #include <media/tvp514x.h>
    
    #define DA850_EVM_PHY_MASK		0x1
    #define DA850_EVM_MDIO_FREQUENCY	2200000 /* PHY bus frequency */
    
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)	
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)
    #ifdef CONFIG_SOC_CAMERA_TW9900
    #define CAMERA_CH0		"tw9900-0"
    #define CAMERA_CH1		"tw9900-1"
    #else
    #define CAMERA_CH0		"tw9910-0"
    #define CAMERA_CH1		"tw9910-1"
    #endif
    #else
    #define CAMERA_CH0		"tvp514x-0"
    #define CAMERA_CH1		"tvp514x-1"
    #endif
    
    #define VPIF_STATUS	(0x002C)
    #define VPIF_STATUS_CLR	(0x0030)
    #define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4)
    #define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13)
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_2M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct davinciflash_pdata da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_norflash_device = {
    	.name		= "davinci-flash",
    	.id		= 0,
    	.dev		= {
    		.platform_data  = &da850_evm_norflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_norflash_resource),
    	.resource	= da850_evm_norflash_resource,
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= 0x200000,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.options	= NAND_USE_FLASH_BBT,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_nandflash_device = {
    	.name		= "davinci_nand",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_evm_nandflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    	.resource	= da850_evm_nandflash_resource,
    };
    
    static struct platform_device *da850_evm_devices[] __initdata = {
    	&da850_evm_nandflash_device,
    	&da850_evm_norflash_device,
    };
    
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_CE3CFG_OFFSET	0x14
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static struct mtd_partition spi_flash_partitions[] = {
    	[0] = {
    		.name = "U-Boot",
    		.offset = 0,
    		.size = SZ_256K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot Environment",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "Linux",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_8M - (SZ_256K + SZ_64K + SZ_64K),
    		.mask_flags = 0,
    	},
    	[3] = {
    		.name = "MAC Address",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    		.setup = davinci_get_mac_addr,
    		.context = (void *)0,
    	},
    };
    
    static struct flash_platform_data spi_flash_data = {
    	.name = "m25p80",
    	.parts = spi_flash_partitions,
    	.nr_parts = ARRAY_SIZE(spi_flash_partitions),
    	.type = "m25p64",
    };
    
    static struct spi_board_info da850_spi_board_info[] = {
    	[0] = {
    		.modalias = "m25p80",
    		.platform_data = &spi_flash_data,
    		.mode = SPI_MODE_0,
    		.max_speed_hz = 30000000,       /* max sample rate at 3V */
    		.bus_num = 1,
    		.chip_select = 0,
    	},
    };
    
    static u32 ui_card_detected;
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    static void __init da850_evm_init_nand(void)
    {
    	void __iomem *aemif_addr;
    	u32 ce3cfg;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	ce3cfg = 0
    		| (0 << 31)	/* selectStrobe */
    		| (0 << 30)	/* extWait */
    		| (0 << 26)	/* writeSetup */
    		| (3 << 20)	/* writeStrobe  30 ns */
    		| (3 << 17)	/* writeHold    30 ns */
    		| (2 << 13)	/* readSetup    20 ns */
    		| (4 << 7)	/* readStrobe   40 ns */
    		| (0 << 4)	/* readHold */
    		| (0 << 2)	/* turnAround */
    		| (0 << 0)	/* asyncSize    8-bit bus */
    		;
    
    	writel(ce3cfg, aemif_addr + DA8XX_AEMIF_CE3CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    
    static __init void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    //	if (ui_card_detected & !HAS_MMC) {
    		ret = da8xx_pinmux_setup(da850_nand_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nand mux setup failed: "
    					"%d\n", ret);
    
    		da850_evm_init_nand();
    
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    /*
    		// Driver GP0[11] low for NOR to work 
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = da8xx_pinmux_setup(da850_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    */
    		
    		platform_add_devices(da850_evm_devices,
    					ARRAY_SIZE(da850_evm_devices));
    //	}
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value(a, 0);
    	gpio_set_value(b, 0);
    	gpio_set_value(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + 7;
    	sel_b = gpio + 6;
    	sel_c = gpio + 5;
    
    	ret = gpio_request(sel_a, "sel_a");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, "sel_b");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, "sel_c");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	ui_card_detected = 1;
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	return 0;
    
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	/* deselect all functionalities */
    	gpio_set_value(gpio + 5, 1);
    	gpio_set_value(gpio + 6, 1);
    	gpio_set_value(gpio + 7, 1);
    
    	gpio_free(gpio + 5);
    	gpio_free(gpio + 6);
    	gpio_free(gpio + 7);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    };
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1380000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    
    //titus
    	{
    		I2C_BOARD_INFO("tvp5146", 0x5d),
    		.platform_data = &tvp5146_pdata,
    	},
    
    
    
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    };
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.eventq_no	= EVENTQ_1,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp0_config = {
    	.inst	= 0,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp1_config = {
    	.inst	= 1,
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE,
    //	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    //				  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	void __iomem *cfg_mstpri2_base;
    	int status;
    	u32 val;
    
    	/*
    	 * Reconfigure the LCDC priority to the highest to ensure that
    	 * the throughput/latency requirements for the LCDC are met.
    	 */
    	cfg_mstpri2_base = DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG);
    
    	val = __raw_readl(cfg_mstpri2_base);
    	val &= 0x0fffffff;
    	__raw_writel(val, cfg_mstpri2_base);
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = da8xx_pinmux_setup(da850_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = da8xx_pinmux_setup(da850_cpgmac_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
    	soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    
    //#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    //#define CAMERA_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    /*
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    	{
    		.name	= CAMERA_CH0,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x45),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= CAMERA_CH1,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x44),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x44),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    		.input = INPUT_SVIDEO_VI2C_VI1C,		///HUANYI_SYSTEM Test
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
           {
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    
    */
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_DAVINCI_MCBSP0)
    #define HAS_MCBSP0 1
    #else
    #define HAS_MCBSP0 0
    #endif
    
    #if defined(CONFIG_DAVINCI_MCBSP1)
    #define HAS_MCBSP1 1
    #else
    #define HAS_MCBSP1 0
    #endif
    
    #if defined(CONFIG_TI_DAVINCI_EMAC) || \
    	defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
    #define HAS_EMAC 1
    #else
    #define HAS_EMAC 0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DA850_UI_RMII) && (HAS_EMAC)
    #define HAS_RMII 1
    #else
    #define HAS_RMII 0
    #endif
    
    #if defined(CONFIG_DA850_UI_LCD) && defined(CONFIG_FB_DA8XX) ||\
    		defined(CONFIG_FB_DA8XX_MODULE)
    #define HAS_GLCD 1
    #else
    #define HAS_GLCD 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    static da8xx_ocic_handler_t da850_evm_usb_ocic_handler;
    
    static int da850_evm_usb_set_power(unsigned port, int on)
    {
    	gpio_set_value(DA850_USB1_VBUS_PIN, on);
    	return 0;
    }
    
    static int da850_evm_usb_get_power(unsigned port)
    {
    	return gpio_get_value(DA850_USB1_VBUS_PIN);
    }
    
    static int da850_evm_usb_get_oci(unsigned port)
    {
    	return !gpio_get_value(DA850_USB1_OC_PIN);
    }
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static int da850_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
    {
    	int irq 	= gpio_to_irq(DA850_USB1_OC_PIN);
    	int error	= 0;
    
    	if (handler != NULL) {
    		da850_evm_usb_ocic_handler = handler;
    
    		error = request_irq(irq, da850_evm_usb_ocic_irq, IRQF_DISABLED |
    				    IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
    				    "OHCI over-current indicator", NULL);
    		if (error)
    			printk(KERN_ERR "%s: could not request IRQ to watch "
    			       "over-current indicator changes\n", __func__);
    	} else
    		free_irq(irq, NULL);
    
    	return error;
    }
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.set_power	= da850_evm_usb_set_power,
    	.get_power	= da850_evm_usb_get_power,
    	.get_oci	= da850_evm_usb_get_oci,
    	.ocic_notify	= da850_evm_usb_ocic_notify,
    
    	/* TPS2065 switch @ 5V */
    	.potpgt		= (3 + 1) / 2,	/* 3 ms max */
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *dev_id)
    {
    	da850_evm_usb_ocic_handler(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static struct musb_hdrc_platform_data usb_evm_data[] = {
    	{
    #ifdef CONFIG_USB_MUSB_OTG
    		.mode = MUSB_OTG,
    #elif defined(CONFIG_USB_MUSB_DUAL_ROLE)
    		.mode = MUSB_DUAL_ROLE,
    #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
    		.mode =  MUSB_PERIPHERAL,
    #elif defined(CONFIG_USB_MUSB_HOST)
    		.mode = MUSB_HOST,
    #endif
    		.power = 255,
    		.potpgt = 8,
    		.set_vbus = NULL, /* VBUs is directly controlled by the IP */
    	}
    };
    
    static __init void da850_evm_usb_init(void)
    {
    	int ret;
    	u32 cfgchip2;
    
    	/*
    	 * Setup the Ref. clock frequency for the EVM at 24 MHz.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	da8xx_usb20_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data));
    
    	ret = da8xx_pinmux_setup(da850_evm_usb11_pins);
    	if (ret) {
    		pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
    			   __func__, ret);
    		return;
    	}
    
    	ret = gpio_request(DA850_USB1_VBUS_PIN, "USB1 VBUS\n");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "power control: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_output(DA850_USB1_VBUS_PIN, 0);
    
    	ret = gpio_request(DA850_USB1_OC_PIN, "USB1 OC");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "over-current indicator: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_input(DA850_USB1_OC_PIN);
    
    	ret = da8xx_register_usb11(&da850_evm_usb11_pdata);
    	if (ret)
    		pr_warning("%s: USB 1.1 registration failed: %d\n",
    			   __func__, ret);
    }
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    //titus
    
    //TODO : Add GPIO pin for TW9910 Power if any
    /*
    static int tw9910_power(struct device *dev, int mode)
    {
    	int val = mode ? 0 : 1;
    
    	gpio_set_value(GPIO_PTU2, val);
    	if (mode)
    		mdelay(100);
    
    	return 0;
    }
    */
    
    /* I2C Video */
    static struct i2c_board_info i2c_camera[] = {
    	{
    		I2C_BOARD_INFO("tw9910", 0x45),
    	},
    };
    
    static struct tw9910_video_info tw9910_info = {
    	.buswidth	= SOCAM_DATAWIDTH_8,
    	.mpout		= TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    	.i2c_adapter_id	= 0,
    	.bus_id		= 1,
    //	.power		= tw9910_power,
    	.power		= NULL,
    	.board_info	= &i2c_camera[0],
    	.module_name	= "tw9910",
    	.priv		= &tw9910_info,
    };
    
    
    static struct platform_device camera_devices[] = {
    	{
    		.name	= "soc-camera-pdrv",
    		.id	= 0,
    		.dev	= {
    			.platform_data = &tw9910_link,
    		},
    	},
    };
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    
    	ret = da8xx_register_edma();
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    
    		ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	//i2c_register_board_info(1, da850_evm_i2c_devices,
    	//		ARRAY_SIZE(da850_evm_i2c_devices));
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCBSP0) {
    		if (HAS_EMAC)
    			pr_warning("WARNING: both MCBSP0 and EMAC are "
    				"enabled, but they share pins.\n"
    				"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcbsp0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp0_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 registration"
    					"failed: %d\n",	ret);
    	}
    
    	if (HAS_MCBSP1) {
    		ret = da8xx_pinmux_setup(da850_mcbsp1_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp1_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 registration"
    					" failed: %d\n", ret);
    	}
    
    	if (HAS_MCASP) {
    		if ((HAS_MCBSP0 || HAS_MCBSP1))
    			pr_warning("WARNING: both McASP and McBSP are enabled, "
    					"but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed:"
    					"%d\n", ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_register_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_spi1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: spi1 mux setup failed: %d\n",
    				ret);
    
    	da850_init_spi1(BIT(0), da850_spi_board_info,
    			ARRAY_SIZE(da850_spi_board_info));
    
    	da850_evm_usb_init();
    
    	ret = da8xx_register_sata();
    	if (ret)
    		pr_warning("da850_evm_init: SATA registration failed: %d\n",
    						ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    	}
    
    	if (!HAS_RMII && HAS_VPIF_CAPTURE) {
    		ret = da8xx_pinmux_setup(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    //
    //		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF registration failed: "
    //					"%d\n",	ret);
    
    	}
    
    	if (!HAS_GLCD && HAS_VPIF_DISPLAY) {
    		ret = da8xx_pinmux_setup(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    //		ret = da850_register_vpif_display(&da850_vpif_display_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF registration failed: "
    //					"%d\n",	ret);
    
    //titus
    	platform_device_register(&camera_devices[0]);
    
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static __init void da850_evm_irq_init(void)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
    			soc_info->intc_irq_prios);
    }
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18xx EVM")
    	.phys_io	= IO_PHYS,
    	.io_pg_offst	= (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
    	.boot_params	= (DA8XX_DDR_BASE + 0x100),
    	.map_io		= da850_evm_map_io,
    	.init_irq	= da850_evm_irq_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    MACHINE_END
    

  • Hi Titusrathinaraj:

         I really thanks you!

         Using your board-da850-evm.c

        I found that it cann't run into tw9910_probe function when kernel loaded! So is tw9910 driver not load?

        I insert code:

    {
    I2C_BOARD_INFO("tw9910", TW99XX_ADDRESS),
    .platform_data = &da850_evm_ui_expander_info,
    },

        to static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { ,,,}

        so privous error can see!

        What's wrong? Is some other config code should add?

        Thanks very much!

     

        

  • Hi,

    Sorry, I forget to mention and add  "platform_add_devices" function.

    Now, Use the attached modified board file for TW9910 support.

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/delay.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/regulator/machine.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/usb/musb.h>
    #include <linux/i2c-gpio.h>
    
    //titus
    #include <media/tw9910.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <mach/flash.h>
    #include <mach/vpif.h>
    
    #include <media/tvp514x.h>
    
    #define DA850_EVM_PHY_MASK		0x1
    #define DA850_EVM_MDIO_FREQUENCY	2200000 /* PHY bus frequency */
    
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)	
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)
    #ifdef CONFIG_SOC_CAMERA_TW9900
    #define CAMERA_CH0		"tw9900-0"
    #define CAMERA_CH1		"tw9900-1"
    #else
    #define CAMERA_CH0		"tw9910-0"
    #define CAMERA_CH1		"tw9910-1"
    #endif
    #else
    #define CAMERA_CH0		"tvp514x-0"
    #define CAMERA_CH1		"tvp514x-1"
    #endif
    
    #define VPIF_STATUS	(0x002C)
    #define VPIF_STATUS_CLR	(0x0030)
    #define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4)
    #define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13)
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_2M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct davinciflash_pdata da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_norflash_device = {
    	.name		= "davinci-flash",
    	.id		= 0,
    	.dev		= {
    		.platform_data  = &da850_evm_norflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_norflash_resource),
    	.resource	= da850_evm_norflash_resource,
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= 0x200000,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.options	= NAND_USE_FLASH_BBT,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_nandflash_device = {
    	.name		= "davinci_nand",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_evm_nandflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    	.resource	= da850_evm_nandflash_resource,
    };
    
    static struct platform_device *da850_evm_devices[] __initdata = {
    	&da850_evm_nandflash_device,
    	&da850_evm_norflash_device,
    };
    
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_CE3CFG_OFFSET	0x14
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static struct mtd_partition spi_flash_partitions[] = {
    	[0] = {
    		.name = "U-Boot",
    		.offset = 0,
    		.size = SZ_256K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot Environment",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "Linux",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_8M - (SZ_256K + SZ_64K + SZ_64K),
    		.mask_flags = 0,
    	},
    	[3] = {
    		.name = "MAC Address",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    		.setup = davinci_get_mac_addr,
    		.context = (void *)0,
    	},
    };
    
    static struct flash_platform_data spi_flash_data = {
    	.name = "m25p80",
    	.parts = spi_flash_partitions,
    	.nr_parts = ARRAY_SIZE(spi_flash_partitions),
    	.type = "m25p64",
    };
    
    static struct spi_board_info da850_spi_board_info[] = {
    	[0] = {
    		.modalias = "m25p80",
    		.platform_data = &spi_flash_data,
    		.mode = SPI_MODE_0,
    		.max_speed_hz = 30000000,       /* max sample rate at 3V */
    		.bus_num = 1,
    		.chip_select = 0,
    	},
    };
    
    static u32 ui_card_detected;
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    static void __init da850_evm_init_nand(void)
    {
    	void __iomem *aemif_addr;
    	u32 ce3cfg;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	ce3cfg = 0
    		| (0 << 31)	/* selectStrobe */
    		| (0 << 30)	/* extWait */
    		| (0 << 26)	/* writeSetup */
    		| (3 << 20)	/* writeStrobe  30 ns */
    		| (3 << 17)	/* writeHold    30 ns */
    		| (2 << 13)	/* readSetup    20 ns */
    		| (4 << 7)	/* readStrobe   40 ns */
    		| (0 << 4)	/* readHold */
    		| (0 << 2)	/* turnAround */
    		| (0 << 0)	/* asyncSize    8-bit bus */
    		;
    
    	writel(ce3cfg, aemif_addr + DA8XX_AEMIF_CE3CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    
    static __init void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    //	if (ui_card_detected & !HAS_MMC) {
    		ret = da8xx_pinmux_setup(da850_nand_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nand mux setup failed: "
    					"%d\n", ret);
    
    		da850_evm_init_nand();
    
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    /*
    		// Driver GP0[11] low for NOR to work 
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = da8xx_pinmux_setup(da850_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    */
    		
    		platform_add_devices(da850_evm_devices,
    					ARRAY_SIZE(da850_evm_devices));
    //	}
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value(a, 0);
    	gpio_set_value(b, 0);
    	gpio_set_value(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + 7;
    	sel_b = gpio + 6;
    	sel_c = gpio + 5;
    
    	ret = gpio_request(sel_a, "sel_a");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, "sel_b");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, "sel_c");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	ui_card_detected = 1;
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	return 0;
    
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	/* deselect all functionalities */
    	gpio_set_value(gpio + 5, 1);
    	gpio_set_value(gpio + 6, 1);
    	gpio_set_value(gpio + 7, 1);
    
    	gpio_free(gpio + 5);
    	gpio_free(gpio + 6);
    	gpio_free(gpio + 7);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    };
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1380000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    };
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.eventq_no	= EVENTQ_1,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp0_config = {
    	.inst	= 0,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp1_config = {
    	.inst	= 1,
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE,
    //	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    //				  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	void __iomem *cfg_mstpri2_base;
    	int status;
    	u32 val;
    
    	/*
    	 * Reconfigure the LCDC priority to the highest to ensure that
    	 * the throughput/latency requirements for the LCDC are met.
    	 */
    	cfg_mstpri2_base = DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG);
    
    	val = __raw_readl(cfg_mstpri2_base);
    	val &= 0x0fffffff;
    	__raw_writel(val, cfg_mstpri2_base);
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = da8xx_pinmux_setup(da850_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = da8xx_pinmux_setup(da850_cpgmac_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
    	soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    
    //#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    #define CAMERA_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    	{
    		.name	= CAMERA_CH0,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x45),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= CAMERA_CH1,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x44),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x44),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    		.input = INPUT_SVIDEO_VI2C_VI1C,		///HUANYI_SYSTEM Test
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
           {
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_DAVINCI_MCBSP0)
    #define HAS_MCBSP0 1
    #else
    #define HAS_MCBSP0 0
    #endif
    
    #if defined(CONFIG_DAVINCI_MCBSP1)
    #define HAS_MCBSP1 1
    #else
    #define HAS_MCBSP1 0
    #endif
    
    #if defined(CONFIG_TI_DAVINCI_EMAC) || \
    	defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
    #define HAS_EMAC 1
    #else
    #define HAS_EMAC 0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DA850_UI_RMII) && (HAS_EMAC)
    #define HAS_RMII 1
    #else
    #define HAS_RMII 0
    #endif
    
    #if defined(CONFIG_DA850_UI_LCD) && defined(CONFIG_FB_DA8XX) ||\
    		defined(CONFIG_FB_DA8XX_MODULE)
    #define HAS_GLCD 1
    #else
    #define HAS_GLCD 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    static da8xx_ocic_handler_t da850_evm_usb_ocic_handler;
    
    static int da850_evm_usb_set_power(unsigned port, int on)
    {
    	gpio_set_value(DA850_USB1_VBUS_PIN, on);
    	return 0;
    }
    
    static int da850_evm_usb_get_power(unsigned port)
    {
    	return gpio_get_value(DA850_USB1_VBUS_PIN);
    }
    
    static int da850_evm_usb_get_oci(unsigned port)
    {
    	return !gpio_get_value(DA850_USB1_OC_PIN);
    }
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static int da850_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
    {
    	int irq 	= gpio_to_irq(DA850_USB1_OC_PIN);
    	int error	= 0;
    
    	if (handler != NULL) {
    		da850_evm_usb_ocic_handler = handler;
    
    		error = request_irq(irq, da850_evm_usb_ocic_irq, IRQF_DISABLED |
    				    IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
    				    "OHCI over-current indicator", NULL);
    		if (error)
    			printk(KERN_ERR "%s: could not request IRQ to watch "
    			       "over-current indicator changes\n", __func__);
    	} else
    		free_irq(irq, NULL);
    
    	return error;
    }
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.set_power	= da850_evm_usb_set_power,
    	.get_power	= da850_evm_usb_get_power,
    	.get_oci	= da850_evm_usb_get_oci,
    	.ocic_notify	= da850_evm_usb_ocic_notify,
    
    	/* TPS2065 switch @ 5V */
    	.potpgt		= (3 + 1) / 2,	/* 3 ms max */
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *dev_id)
    {
    	da850_evm_usb_ocic_handler(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static struct musb_hdrc_platform_data usb_evm_data[] = {
    	{
    #ifdef CONFIG_USB_MUSB_OTG
    		.mode = MUSB_OTG,
    #elif defined(CONFIG_USB_MUSB_DUAL_ROLE)
    		.mode = MUSB_DUAL_ROLE,
    #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
    		.mode =  MUSB_PERIPHERAL,
    #elif defined(CONFIG_USB_MUSB_HOST)
    		.mode = MUSB_HOST,
    #endif
    		.power = 255,
    		.potpgt = 8,
    		.set_vbus = NULL, /* VBUs is directly controlled by the IP */
    	}
    };
    
    static __init void da850_evm_usb_init(void)
    {
    	int ret;
    	u32 cfgchip2;
    
    	/*
    	 * Setup the Ref. clock frequency for the EVM at 24 MHz.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	da8xx_usb20_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data));
    
    	ret = da8xx_pinmux_setup(da850_evm_usb11_pins);
    	if (ret) {
    		pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
    			   __func__, ret);
    		return;
    	}
    
    	ret = gpio_request(DA850_USB1_VBUS_PIN, "USB1 VBUS\n");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "power control: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_output(DA850_USB1_VBUS_PIN, 0);
    
    	ret = gpio_request(DA850_USB1_OC_PIN, "USB1 OC");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "over-current indicator: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_input(DA850_USB1_OC_PIN);
    
    	ret = da8xx_register_usb11(&da850_evm_usb11_pdata);
    	if (ret)
    		pr_warning("%s: USB 1.1 registration failed: %d\n",
    			   __func__, ret);
    }
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    
    /* Titus Debug : TW9910 support */
    
    
    //Disable the below 3 defines (GPIO) (it is used for avoid build error) if you do not configure the camera ON/OFF
    
    #define GPIO_PTT0 0
    #define GPIO_PTT2 2
    #define GPIO_PTT3 3
    
    
    //TODO : Enable Camera ON/OFF if support avail { remove "return 0"  }
    
    static struct clk *camera_clk;
    static DEFINE_MUTEX(camera_lock);
    
    static int camera_power_on(int is_tw)
    {
    	return 0;	//titus
    
    	mutex_lock(&camera_lock);
    
    	/* Use 10 MHz VIO_CKO */
    
    	camera_clk = clk_get(NULL, "video_clk");
    	clk_set_rate(camera_clk, 10000000);
    	clk_enable(camera_clk);	/* start VIO_CKO */
    
    	/* use VIO_RST to take camera out of reset */
    	mdelay(10);
    	if (is_tw) {
    		gpio_set_value(GPIO_PTT2, 0);
    		gpio_set_value(GPIO_PTT0, 0);
    	} else {
    		gpio_set_value(GPIO_PTT0, 1);
    	}
    	gpio_set_value(GPIO_PTT3, 0);
    	mdelay(10);
    	gpio_set_value(GPIO_PTT3, 1);
    	mdelay(10); /* wait to let chip come out of reset */
    }
    
    static int camera_power_off(void)
    {
    	return 0;	//titus
    	clk_disable(camera_clk); /* stop VIO_CKO */
    	clk_put(camera_clk);
    
    	gpio_set_value(GPIO_PTT3, 0);
    	mutex_unlock(&camera_lock);
    }
    
    static int tw9910_power(struct device *dev, int mode)
    {
    	if (mode)
    		camera_power_on(1);
    	else
    		camera_power_off();
    
    	return 0;
    }
    
    
    static struct i2c_board_info tw9910_i2c_camera[] = {
    	{
    		I2C_BOARD_INFO("tw9910", 0x45),
    	},
    };
    
    static struct tw9910_video_info tw9910_info = {
    	.buswidth	= SOCAM_DATAWIDTH_8,
    	.mpout		= TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    //	.power		= tw9910_power,		//titus : Use this if you are using camera ON/OFF
    //	.power		= NULL,			//titus
    	.board_info	= &tw9910_i2c_camera[0],
    	.i2c_adapter_id	= 0,
    	.priv		= &tw9910_info,
    };
    
    static struct platform_device tw9910_camera[] = {
    	{
    		.name	= "soc-camera-pdrv",
    		.id	= 1,
    		.dev	= {
    			.platform_data = &tw9910_link,
    		},
    	},
    };
    
    static struct platform_device *tw9910_devices[] __initdata = {
    	&tw9910_camera[0],
    };
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    
    	ret = da8xx_register_edma();
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    
    		ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	//i2c_register_board_info(1, da850_evm_i2c_devices,
    	//		ARRAY_SIZE(da850_evm_i2c_devices));
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCBSP0) {
    		if (HAS_EMAC)
    			pr_warning("WARNING: both MCBSP0 and EMAC are "
    				"enabled, but they share pins.\n"
    				"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcbsp0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp0_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 registration"
    					"failed: %d\n",	ret);
    	}
    
    	if (HAS_MCBSP1) {
    		ret = da8xx_pinmux_setup(da850_mcbsp1_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp1_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 registration"
    					" failed: %d\n", ret);
    	}
    
    	if (HAS_MCASP) {
    		if ((HAS_MCBSP0 || HAS_MCBSP1))
    			pr_warning("WARNING: both McASP and McBSP are enabled, "
    					"but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed:"
    					"%d\n", ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_register_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_spi1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: spi1 mux setup failed: %d\n",
    				ret);
    
    	da850_init_spi1(BIT(0), da850_spi_board_info,
    			ARRAY_SIZE(da850_spi_board_info));
    
    	da850_evm_usb_init();
    
    	ret = da8xx_register_sata();
    	if (ret)
    		pr_warning("da850_evm_init: SATA registration failed: %d\n",
    						ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    	}
    
    	if (!HAS_RMII && HAS_VPIF_CAPTURE) {
    		ret = da8xx_pinmux_setup(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    
    	}
    
    	if (!HAS_GLCD && HAS_VPIF_DISPLAY) {
    		ret = da8xx_pinmux_setup(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    //		ret = da850_register_vpif_display(&da850_vpif_display_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF registration failed: "
    //					"%d\n",	ret);
    
    
    
    //titus
    	platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
    
    
    
    
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static __init void da850_evm_irq_init(void)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
    			soc_info->intc_irq_prios);
    }
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18xx EVM")
    	.phys_io	= IO_PHYS,
    	.io_pg_offst	= (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
    	.boot_params	= (DA8XX_DDR_BASE + 0x100),
    	.map_io		= da850_evm_map_io,
    	.init_irq	= da850_evm_irq_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    MACHINE_END
    

    Please let us know the results.

  • Hi Titusrathinaraj:

          Thanks.

          But when I modified platform_add_devices to:

    static struct platform_device *da850_evm_devices[] __initdata = {
    &da850_evm_nandflash_device,
    &da850_evm_norflash_device,
    &camera_devices,
    };

        when boot, It will down and stop at:

    Uncompressing Linux... done, booting the kernel.

       Why? Is I make a mistake?

       Thanks very much!

     

        

  • Hi,

    First try this, and confirm which one leads to issue, then try nand and nor cases.

    static struct platform_device *da850_evm_devices[] __initdata = {
    &camera_devices,
    };

     

    /* Titus Debug : TW9910 support */

    #define GPIO_PTT0 0
    #define GPIO_PTT2 2
    #define GPIO_PTT3 3


    //TODO : Enable Camera ON/OFF if support avail { remove "return 0"  }

    static struct clk *camera_clk;
    static DEFINE_MUTEX(camera_lock);

    static int camera_power_on(int is_tw)
    {
        return 0;    //titus

        mutex_lock(&camera_lock);

        /* Use 10 MHz VIO_CKO */

        camera_clk = clk_get(NULL, "video_clk");
        clk_set_rate(camera_clk, 10000000);
        clk_enable(camera_clk);    /* start VIO_CKO */

        /* use VIO_RST to take camera out of reset */
        mdelay(10);
        if (is_tw) {
            gpio_set_value(GPIO_PTT2, 0);
            gpio_set_value(GPIO_PTT0, 0);
        } else {
            gpio_set_value(GPIO_PTT0, 1);
        }
        gpio_set_value(GPIO_PTT3, 0);
        mdelay(10);
        gpio_set_value(GPIO_PTT3, 1);
        mdelay(10); /* wait to let chip come out of reset */
    }

    static int camera_power_off(void)
    {
        return 0;    //titus
        clk_disable(camera_clk); /* stop VIO_CKO */
        clk_put(camera_clk);

        gpio_set_value(GPIO_PTT3, 0);
        mutex_unlock(&camera_lock);
    }

    static int tw9910_power(struct device *dev, int mode)
    {
        if (mode)
            camera_power_on(1);
        else
            camera_power_off();

        return 0;
    }


    static struct i2c_board_info tw9910_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9910", 0x45),
        },
    };

    static struct tw9910_video_info tw9910_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout        = TW9910_MPO_FIELD,
    };

    static struct soc_camera_link tw9910_link = {
        .power        = tw9910_power,
        .board_info    = &tw9910_i2c_camera[0],
        .i2c_adapter_id    = 0,
        .priv        = &tw9910_info,
    };

    static struct platform_device tw9910_camera[] = {
        {
            .name    = "soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9910_link,
            },
        },
    };

    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };

     

    add this line to __init fn.

        platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));

  • Hi Titusrathinaraj:

         The result is same with previous!

  • Hi,

    when boot, It will down and stop at:

    Uncompressing Linux... done, booting the kernel.


    Can you please attache the latest board file which has camera platform changes and facing the above mentioned issues?

  • Hi Titusrathinaraj:

        Thanks very much!

        I need VPIF mode,  when kernel loaded, there is error:

    vpif_capture vpif_capture: Error registering v4l2 subdevice

       Board-da850-evm.c is:

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/delay.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/regulator/machine.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/usb/musb.h>
    #include <linux/i2c-gpio.h>
    
    #include <linux/spi/ads7846.h>	//added by HUANYI_SYSTEM ealge 20140320
    #include <mach/spi.h>			//added by HUANYI_SYSTEM ealge 20140320
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    //titus
    #include <media/tw9910.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <mach/flash.h>
    #include <mach/vpif.h>
    
    #include <media/tvp514x.h>
    
    #define DA850_EVM_PHY_MASK		0x1
    #define DA850_EVM_MDIO_FREQUENCY	2200000 /* PHY bus frequency */
    
    //#define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    //#define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(6, 5)	//HUANYI_SYSTEM  eagle.lee
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(8, 15)
    #define DA850_LCD_RST_PIN		GPIO_TO_PIN(6, 14)
    #define DA850_LCD_NCS_PIN		GPIO_TO_PIN(2, 0)
    #define DA850_LCD_LED_PIN		GPIO_TO_PIN(8, 12)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)	
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #define TW99XX_ADDRESS	0x45
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)
    #ifdef CONFIG_SOC_CAMERA_TW9900
    #define CAMERA_CH0		"tw9900-0"
    #define CAMERA_CH1		"tw9900-1"
    #else
    #define CAMERA_CH0		"tw9910-0"
    #define CAMERA_CH1		"tw9910-1"
    #endif
    #else
    #define CAMERA_CH0		"tvp514x-0"
    #define CAMERA_CH1		"tvp514x-1"
    #endif
    
    #define VPIF_STATUS	(0x002C)
    #define VPIF_STATUS_CLR	(0x0030)
    #define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4)
    #define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13)
    
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio, unsigned ngpio, void *c);
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,unsigned gpio, unsigned ngpio, void *c);
    
    
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_2M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct davinciflash_pdata da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_norflash_device = {
    	.name		= "davinci-flash",
    	.id		= 0,
    	.dev		= {
    		.platform_data  = &da850_evm_norflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_norflash_resource),
    	.resource	= da850_evm_norflash_resource,
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= 0x200000,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.options	= NAND_USE_FLASH_BBT,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_nandflash_device = {
    	.name		= "davinci_nand",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_evm_nandflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    	.resource	= da850_evm_nandflash_resource,
    };
    
    static struct platform_device *da850_evm_devices[] __initdata = {
    	&da850_evm_nandflash_device,
    	&da850_evm_norflash_device,
    };
    
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_CE3CFG_OFFSET	0x14
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static struct mtd_partition spi_flash_partitions[] = {
    	[0] = {
    		.name = "U-Boot",
    		.offset = 0,
    		.size = SZ_256K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot Environment",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "Linux",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_8M - (SZ_256K + SZ_64K + SZ_64K),
    		.mask_flags = 0,
    	},
    	[3] = {
    		.name = "MAC Address",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    		.setup = davinci_get_mac_addr,
    		.context = (void *)0,
    	},
    };
    
    static struct flash_platform_data spi_flash_data = {
    	.name = "m25p80",
    	.parts = spi_flash_partitions,
    	.nr_parts = ARRAY_SIZE(spi_flash_partitions),
    	.type = "m25p64",
    };
    
    static struct spi_board_info da850_spi_board_info[] = {
    	[0] = {
    		.modalias = "m25p80",
    		.platform_data = &spi_flash_data,
    		.mode = SPI_MODE_0,
    		.max_speed_hz = 30000000,       /* max sample rate at 3V */
    		.bus_num = 1,
    		.chip_select = 0,
    	},
    };
    
    //added by HUANYI_SYSTEM eagle 20130320
    //davinci_spi_config_t
    
    
    struct davinci_spi_platform_data ads7846_spi_config = {
    	.version		= SPI_VERSION_2,//new
    	.num_chipselect	= 1,			//new
    	.wdelay         = 0,
    	.odd_parity     = 0,
    	.parity_enable  = 0,
    	.wait_enable    = 0,
    	//.lsb_first      = 0,
    	.timer_disable  = 0,
    	.clk_internal   = 1,
    	.cs_hold        = 1,
    	.intr_level     = 0,
    #ifndef CONFIG_SPI_INTERRUPT
    	.poll_mode      = 1,
    #endif
    	.use_dma		= 0,
    	.c2tdelay		= NULL,
    	.t2cdelay		= NULL,
    	//.clk_high       = 0,
    	//.phase_in       = 1,	
    	//.loop_back      = 0,	
    	//.pin_op_modes   = SPI_OPMODE_3PIN,
    
    };
    
    /*
    struct davinci_spi_config_t ads7846_spi_config = {
    	.wdelay         = 0,
    	.odd_parity     = 0,
    	.parity_enable  = 0,
    	.wait_enable    = 0,
    	.lsb_first      = 0,
    	.timer_disable  = 0,
    	.clk_high       = 0,
    	.phase_in       = 1,
    	.clk_internal   = 1,
    	.loop_back      = 0,
    	.cs_hold        = 1,
    	.intr_level     = 0,
    	.pin_op_modes   = SPI_OPMODE_3PIN,
    #ifndef CONFIG_SPI_INTERRUPT
    	.poll_mode      = 1,
    #endif
    };
    */
    static int ads7846_get_pendown_state(void)
    {
    	return !gpio_get_value(DA850_TSC_PEN);
    }
    
    static struct ads7846_platform_data ads7846_config = {
    	.x_max			= 0x0fff,
    	.y_max			= 0x0fff,
    	.x_plate_ohms		= 180,
    	.pressure_max		= 10000, 
    	.debounce_max		= 10,
    	.debounce_tol		= 15,
    	.debounce_rep		= 1,
    	.get_pendown_state	= ads7846_get_pendown_state,
    	.keep_vref_on		= 1,
    };
    
    static struct spi_board_info tsc_spi_info[] __initdata = {
    	[0] = {
    		.modalias		= "ads7846",
    		.bus_num		= 1,
    		.chip_select		= 0,
    		.max_speed_hz		= 2000000,
    		.controller_data	= &ads7846_spi_config,
    		//.irq			= gpio_to_irq(DA850_TSC_PEN),//zmy
    		.platform_data		= &ads7846_config,
    	}
    	
    };
    /*
    static struct spi_board_info lcd_spi_info[] __initdata = {
    	[0] = {
    		.modalias			= "ili9341",
    		.bus_num			= 0,
    		.chip_select		= 0,
    		.max_speed_hz		= 2000000,
    		.controller_data	= &ili9341_spi_config,
    		//.irq			= gpio_to_irq(DA850_TSC_PEN),//zmy
    		.platform_data		= &ili9341_config,
    	}
    };
    */
    
    //end
    
    static u32 ui_card_detected;
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    static void __init da850_evm_init_nand(void)
    {
    	void __iomem *aemif_addr;
    	u32 ce3cfg;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	ce3cfg = 0
    		| (0 << 31)	/* selectStrobe */
    		| (0 << 30)	/* extWait */
    		| (0 << 26)	/* writeSetup */
    		| (3 << 20)	/* writeStrobe  30 ns */
    		| (3 << 17)	/* writeHold    30 ns */
    		| (2 << 13)	/* readSetup    20 ns */
    		| (4 << 7)	/* readStrobe   40 ns */
    		| (0 << 4)	/* readHold */
    		| (0 << 2)	/* turnAround */
    		| (0 << 0)	/* asyncSize    8-bit bus */
    		;
    
    	writel(ce3cfg, aemif_addr + DA8XX_AEMIF_CE3CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    
    //EAGLE HUANYI_SYSTEM END
    
    static __init void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    //	if (ui_card_detected & !HAS_MMC) {
    		ret = da8xx_pinmux_setup(da850_nand_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nand mux setup failed: "
    					"%d\n", ret);
    
    		da850_evm_init_nand();
    
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] low for NOR to work */
    		/*gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = da8xx_pinmux_setup(da850_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    		*/
    		
    		platform_add_devices(da850_evm_devices,
    					ARRAY_SIZE(da850_evm_devices));
    		//platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));		
    
    
    		pr_info("NAND_FLASH Init OK!\n");
    //	}
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value(a, 0);
    	gpio_set_value(b, 0);
    	gpio_set_value(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + 7;
    	sel_b = gpio + 6;
    	sel_c = gpio + 5;
    
    	ret = gpio_request(sel_a, "sel_a");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, "sel_b");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, "sel_c");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	ui_card_detected = 1;
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	//da850_evm_setup_nor_nand();	//HUANYI_SYSTEM eagle  
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	return 0;
    
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	/* deselect all functionalities */
    	gpio_set_value(gpio + 5, 1);
    	gpio_set_value(gpio + 6, 1);
    	gpio_set_value(gpio + 7, 1);
    
    	gpio_free(gpio + 5);
    	gpio_free(gpio + 6);
    	gpio_free(gpio + 7);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    };
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1380000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    };
    
    
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    
    //titus
    	{
    		I2C_BOARD_INFO("tvp5146", 0x5d),
    		.platform_data = &tvp5146_pdata,
    	},
    
    
    
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    	/*
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	*/
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    /*
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    	{
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		I2C_BOARD_INFO("tw9900", TW99XX_ADDRESS),
    #else
    		I2C_BOARD_INFO("tw9910", TW99XX_ADDRESS),
    #endif	
    		.platform_data = &da850_evm_ui_expander_info,	
    	},
    #endif
    */
    	{
    		I2C_BOARD_INFO("bq34z100", 0x55),
    	},
    };
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.eventq_no	= EVENTQ_1,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp0_config = {
    	.inst	= 0,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp1_config = {
    	.inst	= 1,
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    //	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    //				  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value(DA850_LCD_BL_PIN, val);
    }
    
    //added by eagle 20130320
    static int da850_ads7846_init(void)
    {
    	int status;
    	int irq = gpio_to_irq(DA850_TSC_PEN);
    
    	status = gpio_request(DA850_TSC_PEN, "ADS7846_PENDOWN\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_TSC_CS, "ADS7846_CS\n");
    	if (status < 0)
    		return status;
    
    	gpio_direction_input(DA850_TSC_PEN);
    	gpio_direction_output(DA850_TSC_CS, 0);
    	gpio_set_value(DA850_TSC_CS, 0);
    
    	tsc_spi_info[0].irq = irq;//zmy
    
    #if 0
    	spi_register_board_info(tsc_spi_info,
    			ARRAY_SIZE(tsc_spi_info));
    #else
    	//da850_init_spi1(NULL, 1, tsc_spi_info,
    	//		ARRAY_SIZE(tsc_spi_info));
    	da850_init_spi1(1, tsc_spi_info,		//modified by eagle
    			ARRAY_SIZE(tsc_spi_info));
    #endif
    }
    //end
    
    
    static int da850_lcd_hw_init(void)
    {
    	void __iomem *cfg_mstpri2_base;
    	int status;
    	u32 val;
    
    	/*
    	 * Reconfigure the LCDC priority to the highest to ensure that
    	 * the throughput/latency requirements for the LCDC are met.
    	 */
    	cfg_mstpri2_base = DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG);
    
    	val = __raw_readl(cfg_mstpri2_base);
    	val &= 0x0fffffff;
    	__raw_writel(val, cfg_mstpri2_base);
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    /*************************Added by eagle******************************/	
    	status = gpio_request(DA850_LCD_RST_PIN, "lcd rst\n");
    	if (status < 0){
    		gpio_free(DA850_LCD_RST_PIN);
    		return status;
    	}
    	status = gpio_request(DA850_LCD_NCS_PIN, "lcd ncs\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_NCS_PIN);
    		return status;
    	}
    
    	status = gpio_request(DA850_LCD_LED_PIN, "led led\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_LED_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 1);
    	gpio_direction_output(DA850_LCD_RST_PIN, 1);
    	gpio_direction_output(DA850_LCD_NCS_PIN, 1);
    	gpio_direction_output(DA850_LCD_LED_PIN, 1);
    
    
    	/* reset lcd */
    	//gpio_set_value(DA850_LCD_RST_PIN, 0);
    
    	/* reset lcd */
    	gpio_set_value(DA850_LCD_RST_PIN, 0);
    	mdelay(50);
    	gpio_set_value(DA850_LCD_RST_PIN, 1);
    
    	/* select lcd */
    	gpio_set_value(DA850_LCD_NCS_PIN, 0);
    
    	/* enable lcd backlight */
    	gpio_set_value(DA850_LCD_BL_PIN, 1);
    
    	/* turn on led */
    	gpio_set_value(DA850_LCD_LED_PIN, 0);
    /********************************************************************/
    	
    /*	modified by eagle
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    */
    
    	return 0;
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	//DA850_GPIO2_8, DA850_GPIO2_15,
    	DA850_GPIO8_15,DA850_GPIO6_14,DA850_GPIO2_0,DA850_GPIO8_12,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = da8xx_pinmux_setup(da850_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = da8xx_pinmux_setup(da850_cpgmac_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
    	soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    //#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    #define CAMERA_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    	{
    		.name	= CAMERA_CH0,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", TW99XX_ADDRESS),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", TW99XX_ADDRESS),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= CAMERA_CH1,
    			
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", TW99XX_ADDRESS),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", TW99XX_ADDRESS),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    		.input = INPUT_SVIDEO_VI2C_VI1C,		///HUANYI_SYSTEM Test
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
           {
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_DAVINCI_MCBSP0)
    #define HAS_MCBSP0 1
    #else
    #define HAS_MCBSP0 0
    #endif
    
    #if defined(CONFIG_DAVINCI_MCBSP1)
    #define HAS_MCBSP1 1
    #else
    #define HAS_MCBSP1 0
    #endif
    
    #if defined(CONFIG_TI_DAVINCI_EMAC) || \
    	defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
    #define HAS_EMAC 1
    #else
    #define HAS_EMAC 0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DA850_UI_RMII) && (HAS_EMAC)
    #define HAS_RMII 1
    #else
    #define HAS_RMII 0
    #endif
    
    #if defined(CONFIG_DA850_UI_LCD) && defined(CONFIG_FB_DA8XX) ||\
    		defined(CONFIG_FB_DA8XX_MODULE)
    #define HAS_GLCD 1
    #else
    #define HAS_GLCD 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    static da8xx_ocic_handler_t da850_evm_usb_ocic_handler;
    
    static int da850_evm_usb_set_power(unsigned port, int on)
    {
    	gpio_set_value(DA850_USB1_VBUS_PIN, on);
    	return 0;
    }
    
    static int da850_evm_usb_get_power(unsigned port)
    {
    	return gpio_get_value(DA850_USB1_VBUS_PIN);
    }
    
    static int da850_evm_usb_get_oci(unsigned port)
    {
    	return !gpio_get_value(DA850_USB1_OC_PIN);
    }
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static int da850_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
    {
    	int irq 	= gpio_to_irq(DA850_USB1_OC_PIN);
    	int error	= 0;
    
    	if (handler != NULL) {
    		da850_evm_usb_ocic_handler = handler;
    
    		error = request_irq(irq, da850_evm_usb_ocic_irq, IRQF_DISABLED |
    				    IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
    				    "OHCI over-current indicator", NULL);
    		if (error)
    			printk(KERN_ERR "%s: could not request IRQ to watch "
    			       "over-current indicator changes\n", __func__);
    	} else
    		free_irq(irq, NULL);
    
    	return error;
    }
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.set_power	= da850_evm_usb_set_power,
    	.get_power	= da850_evm_usb_get_power,
    	.get_oci	= da850_evm_usb_get_oci,
    	.ocic_notify= da850_evm_usb_ocic_notify,
    
    	/* TPS2065 switch @ 5V */
    	.potpgt		= (3 + 1) / 2,	/* 3 ms max */
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *dev_id)
    {
    	da850_evm_usb_ocic_handler(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static struct musb_hdrc_platform_data usb_evm_data[] = {
    	{
    #ifdef CONFIG_USB_MUSB_OTG
    		.mode = MUSB_OTG,
    #elif defined(CONFIG_USB_MUSB_DUAL_ROLE)
    		.mode = MUSB_DUAL_ROLE,
    #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
    		.mode =  MUSB_PERIPHERAL,
    #elif defined(CONFIG_USB_MUSB_HOST)
    		.mode = MUSB_HOST,
    #endif
    		.power = 255,
    		.potpgt = 8,
    		.set_vbus = NULL, /* VBUs is directly controlled by the IP */
    	}
    };
    
    static __init void da850_evm_usb_init(void)
    {
    	int ret;
    	u32 cfgchip2;
    
    	/*
    	 * Setup the Ref. clock frequency for the EVM at 24 MHz.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	da8xx_usb20_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data));
    
    	ret = da8xx_pinmux_setup(da850_evm_usb11_pins);
    	if (ret) {
    		pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
    			   __func__, ret);
    		return;
    	}
    
    	ret = gpio_request(DA850_USB1_VBUS_PIN, "USB1 VBUS\n");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "power control: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_output(DA850_USB1_VBUS_PIN, 0);
    
    	ret = gpio_request(DA850_USB1_OC_PIN, "USB1 OC");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "over-current indicator: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_input(DA850_USB1_OC_PIN);
    
    	ret = da8xx_register_usb11(&da850_evm_usb11_pdata);
    	if (ret)
    		pr_warning("%s: USB 1.1 registration failed: %d\n",
    			   __func__, ret);
    }
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    //titus
    
    //TODO : Add GPIO pin for TW9910 Power if any
    /*
    static int tw9910_power(struct device *dev, int mode)
    {
    	int val = mode ? 0 : 1;
    
    	gpio_set_value(GPIO_PTU2, val);
    	if (mode)
    		mdelay(100);
    
    	return 0;
    }
    */
    
    /* I2C Video */
    static struct i2c_board_info i2c_camera[] = {
    	{
    		I2C_BOARD_INFO("tw9910", 0x45),
    	},
    };
    
    static struct tw9910_video_info tw9910_info = {
    	.buswidth	= SOCAM_DATAWIDTH_8,
    	.mpout		= TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    	.i2c_adapter_id	= 0,
    	.bus_id		= 1,
    //	.power		= tw9910_power,
    	.power		= NULL,
    	.board_info	= &i2c_camera[0],
    	.module_name	= "tw9910",
    	.priv		= &tw9910_info,
    };
    
    static struct platform_device tw9910_camera[] = {
    	{
    		.name	= "TW9910 for soc-camera",
    		.id	= 2,
    		.dev	= {
    			.platform_data = &tw9910_link,
    		},
    	},
    };
    
    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    
    	ret = da8xx_register_edma();
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    	/*
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    	*/
    		/* Driver GP0[11] high for SD to work */
    	//	gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    
    		ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    		/*
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    		*/
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    	//}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	//i2c_register_board_info(1, da850_evm_i2c_devices,
    	//		ARRAY_SIZE(da850_evm_i2c_devices));
    	printk("da850_evm_init i2c_register_board_info");
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	//__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
    	//__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    /*
    	if (HAS_MCBSP0) {
    		if (HAS_EMAC)
    			pr_warning("WARNING: both MCBSP0 and EMAC are "
    				"enabled, but they share pins.\n"
    				"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcbsp0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp0_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 registration"
    					"failed: %d\n",	ret);
    	}
    
    	if (HAS_MCBSP1) {
    		ret = da8xx_pinmux_setup(da850_mcbsp1_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp1_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 registration"
    					" failed: %d\n", ret);
    	}
    
    	if (HAS_MCASP) {
    		if ((HAS_MCBSP0 || HAS_MCBSP1))
    			pr_warning("WARNING: both McASP and McBSP are enabled, "
    					"but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed:"
    					"%d\n", ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    */
    	printk("da850_evm_init da8xx_pinmux_setup");
    	ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	printk("da850_evm_init da8xx_pinmux_setup");
    	/* Handle board specific muxing for LCD here */
    	ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    	
    	da850_evm_setup_nor_nand();
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    	
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_register_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    #if 0	//eagle
    	ret = da8xx_pinmux_setup(da850_spi1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: spi1 mux setup failed: %d\n",
    				ret);
    
    	da850_init_spi1(BIT(0), da850_spi_board_info,
    			ARRAY_SIZE(da850_spi_board_info));
    #endif
    
    	da850_ads7846_init();	//added by eagle
    
    	da850_evm_usb_init();
    /*
    	ret = da8xx_register_sata();
    	if (ret)
    		pr_warning("da850_evm_init: SATA registration failed: %d\n",
    						ret);
    */
    	printk("da850_evm_init da850_register_vpif");
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		printk("da850_evm_init da850_register_vpif 1");
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    	}
    
    	printk("da850_evm_init x");
    	if (!HAS_RMII && HAS_VPIF_CAPTURE) {
    		ret = da8xx_pinmux_setup(da850_vpif_capture_pins);
    		printk("da850_evm_init x1");
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    	//titus
    //	platform_device_register(&tw9900_camera[0]);
    	platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));		
    
    // *
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		printk("da850_evm_init x3");
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    //*/
    
    	}
    
    	if (!HAS_GLCD && HAS_VPIF_DISPLAY) {
    		ret = da8xx_pinmux_setup(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    //		ret = da850_register_vpif_display(&da850_vpif_display_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF registration failed: "
    //					"%d\n",	ret);
    
    //titus
    //	platform_device_register(&tw9910_camera[0]);
    
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static __init void da850_evm_irq_init(void)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
    			soc_info->intc_irq_prios);
    }
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18xx EVM")
    	.phys_io	= IO_PHYS,
    	.io_pg_offst	= (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
    	.boot_params	= (DA8XX_DDR_BASE + 0x100),
    	.map_io		= da850_evm_map_io,
    	.init_irq	= da850_evm_irq_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    MACHINE_END
    

      Can you help me to solve this problem?

      Thanks.

     

  • Hi,

    PFA of modified board file for TW9910 camera support,

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/delay.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/regulator/machine.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/usb/musb.h>
    #include <linux/i2c-gpio.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <mach/flash.h>
    #include <mach/vpif.h>
    
    #include <media/tvp514x.h>
    
    #define DA850_EVM_PHY_MASK		0x1
    #define DA850_EVM_MDIO_FREQUENCY	2200000 /* PHY bus frequency */
    
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)	
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)
    #ifdef CONFIG_SOC_CAMERA_TW9900
    #define CAMERA_CH0		"tw9900-0"
    #define CAMERA_CH1		"tw9900-1"
    #else
    #define CAMERA_CH0		"tw9910-0"
    #define CAMERA_CH1		"tw9910-1"
    #endif
    #else
    #define CAMERA_CH0		"tvp514x-0"
    #define CAMERA_CH1		"tvp514x-1"
    #endif
    
    #define VPIF_STATUS	(0x002C)
    #define VPIF_STATUS_CLR	(0x0030)
    #define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4)
    #define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13)
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_2M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct davinciflash_pdata da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_norflash_device = {
    	.name		= "davinci-flash",
    	.id		= 0,
    	.dev		= {
    		.platform_data  = &da850_evm_norflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_norflash_resource),
    	.resource	= da850_evm_norflash_resource,
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= 0x200000,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.options	= NAND_USE_FLASH_BBT,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_nandflash_device = {
    	.name		= "davinci_nand",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_evm_nandflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    	.resource	= da850_evm_nandflash_resource,
    };
    
    static struct platform_device *da850_evm_devices[] __initdata = {
    	&da850_evm_nandflash_device,
    	&da850_evm_norflash_device,
    };
    
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_CE3CFG_OFFSET	0x14
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static struct mtd_partition spi_flash_partitions[] = {
    	[0] = {
    		.name = "U-Boot",
    		.offset = 0,
    		.size = SZ_256K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot Environment",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "Linux",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_8M - (SZ_256K + SZ_64K + SZ_64K),
    		.mask_flags = 0,
    	},
    	[3] = {
    		.name = "MAC Address",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    		.setup = davinci_get_mac_addr,
    		.context = (void *)0,
    	},
    };
    
    static struct flash_platform_data spi_flash_data = {
    	.name = "m25p80",
    	.parts = spi_flash_partitions,
    	.nr_parts = ARRAY_SIZE(spi_flash_partitions),
    	.type = "m25p64",
    };
    
    static struct spi_board_info da850_spi_board_info[] = {
    	[0] = {
    		.modalias = "m25p80",
    		.platform_data = &spi_flash_data,
    		.mode = SPI_MODE_0,
    		.max_speed_hz = 30000000,       /* max sample rate at 3V */
    		.bus_num = 1,
    		.chip_select = 0,
    	},
    };
    
    static u32 ui_card_detected;
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    static void __init da850_evm_init_nand(void)
    {
    	void __iomem *aemif_addr;
    	u32 ce3cfg;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	ce3cfg = 0
    		| (0 << 31)	/* selectStrobe */
    		| (0 << 30)	/* extWait */
    		| (0 << 26)	/* writeSetup */
    		| (3 << 20)	/* writeStrobe  30 ns */
    		| (3 << 17)	/* writeHold    30 ns */
    		| (2 << 13)	/* readSetup    20 ns */
    		| (4 << 7)	/* readStrobe   40 ns */
    		| (0 << 4)	/* readHold */
    		| (0 << 2)	/* turnAround */
    		| (0 << 0)	/* asyncSize    8-bit bus */
    		;
    
    	writel(ce3cfg, aemif_addr + DA8XX_AEMIF_CE3CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    
    static __init void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    //	if (ui_card_detected & !HAS_MMC) {
    		ret = da8xx_pinmux_setup(da850_nand_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nand mux setup failed: "
    					"%d\n", ret);
    
    		da850_evm_init_nand();
    
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    /*
    		// Driver GP0[11] low for NOR to work 
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = da8xx_pinmux_setup(da850_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    */
    		
    		platform_add_devices(da850_evm_devices,
    					ARRAY_SIZE(da850_evm_devices));
    //	}
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value(a, 0);
    	gpio_set_value(b, 0);
    	gpio_set_value(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + 7;
    	sel_b = gpio + 6;
    	sel_c = gpio + 5;
    
    	ret = gpio_request(sel_a, "sel_a");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, "sel_b");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, "sel_c");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	ui_card_detected = 1;
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	return 0;
    
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	/* deselect all functionalities */
    	gpio_set_value(gpio + 5, 1);
    	gpio_set_value(gpio + 6, 1);
    	gpio_set_value(gpio + 7, 1);
    
    	gpio_free(gpio + 5);
    	gpio_free(gpio + 6);
    	gpio_free(gpio + 7);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    };
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1380000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    };
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.eventq_no	= EVENTQ_1,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp0_config = {
    	.inst	= 0,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp1_config = {
    	.inst	= 1,
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE,
    //	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    //				  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	void __iomem *cfg_mstpri2_base;
    	int status;
    	u32 val;
    
    	/*
    	 * Reconfigure the LCDC priority to the highest to ensure that
    	 * the throughput/latency requirements for the LCDC are met.
    	 */
    	cfg_mstpri2_base = DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG);
    
    	val = __raw_readl(cfg_mstpri2_base);
    	val &= 0x0fffffff;
    	__raw_writel(val, cfg_mstpri2_base);
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = da8xx_pinmux_setup(da850_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = da8xx_pinmux_setup(da850_cpgmac_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
    	soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    
    //#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    #define CAMERA_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    //titus
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    	{
    		.name	= "tw9910",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = (void *)1,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,	//Titus : RAW capture
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #else
    	{
    		.name	= CAMERA_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,		///HUANYI_SYSTEM Test
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    //titus
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = "tw9910",
    	},
    
    #if 0
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH0,
    	},
    #endif
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
           {
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_DAVINCI_MCBSP0)
    #define HAS_MCBSP0 1
    #else
    #define HAS_MCBSP0 0
    #endif
    
    #if defined(CONFIG_DAVINCI_MCBSP1)
    #define HAS_MCBSP1 1
    #else
    #define HAS_MCBSP1 0
    #endif
    
    #if defined(CONFIG_TI_DAVINCI_EMAC) || \
    	defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
    #define HAS_EMAC 1
    #else
    #define HAS_EMAC 0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DA850_UI_RMII) && (HAS_EMAC)
    #define HAS_RMII 1
    #else
    #define HAS_RMII 0
    #endif
    
    #if defined(CONFIG_DA850_UI_LCD) && defined(CONFIG_FB_DA8XX) ||\
    		defined(CONFIG_FB_DA8XX_MODULE)
    #define HAS_GLCD 1
    #else
    #define HAS_GLCD 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    static da8xx_ocic_handler_t da850_evm_usb_ocic_handler;
    
    static int da850_evm_usb_set_power(unsigned port, int on)
    {
    	gpio_set_value(DA850_USB1_VBUS_PIN, on);
    	return 0;
    }
    
    static int da850_evm_usb_get_power(unsigned port)
    {
    	return gpio_get_value(DA850_USB1_VBUS_PIN);
    }
    
    static int da850_evm_usb_get_oci(unsigned port)
    {
    	return !gpio_get_value(DA850_USB1_OC_PIN);
    }
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static int da850_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
    {
    	int irq 	= gpio_to_irq(DA850_USB1_OC_PIN);
    	int error	= 0;
    
    	if (handler != NULL) {
    		da850_evm_usb_ocic_handler = handler;
    
    		error = request_irq(irq, da850_evm_usb_ocic_irq, IRQF_DISABLED |
    				    IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
    				    "OHCI over-current indicator", NULL);
    		if (error)
    			printk(KERN_ERR "%s: could not request IRQ to watch "
    			       "over-current indicator changes\n", __func__);
    	} else
    		free_irq(irq, NULL);
    
    	return error;
    }
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.set_power	= da850_evm_usb_set_power,
    	.get_power	= da850_evm_usb_get_power,
    	.get_oci	= da850_evm_usb_get_oci,
    	.ocic_notify	= da850_evm_usb_ocic_notify,
    
    	/* TPS2065 switch @ 5V */
    	.potpgt		= (3 + 1) / 2,	/* 3 ms max */
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *dev_id)
    {
    	da850_evm_usb_ocic_handler(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static struct musb_hdrc_platform_data usb_evm_data[] = {
    	{
    #ifdef CONFIG_USB_MUSB_OTG
    		.mode = MUSB_OTG,
    #elif defined(CONFIG_USB_MUSB_DUAL_ROLE)
    		.mode = MUSB_DUAL_ROLE,
    #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
    		.mode =  MUSB_PERIPHERAL,
    #elif defined(CONFIG_USB_MUSB_HOST)
    		.mode = MUSB_HOST,
    #endif
    		.power = 255,
    		.potpgt = 8,
    		.set_vbus = NULL, /* VBUs is directly controlled by the IP */
    	}
    };
    
    static __init void da850_evm_usb_init(void)
    {
    	int ret;
    	u32 cfgchip2;
    
    	/*
    	 * Setup the Ref. clock frequency for the EVM at 24 MHz.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	da8xx_usb20_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data));
    
    	ret = da8xx_pinmux_setup(da850_evm_usb11_pins);
    	if (ret) {
    		pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
    			   __func__, ret);
    		return;
    	}
    
    	ret = gpio_request(DA850_USB1_VBUS_PIN, "USB1 VBUS\n");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "power control: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_output(DA850_USB1_VBUS_PIN, 0);
    
    	ret = gpio_request(DA850_USB1_OC_PIN, "USB1 OC");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "over-current indicator: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_input(DA850_USB1_OC_PIN);
    
    	ret = da8xx_register_usb11(&da850_evm_usb11_pdata);
    	if (ret)
    		pr_warning("%s: USB 1.1 registration failed: %d\n",
    			   __func__, ret);
    }
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    
    	ret = da8xx_register_edma();
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    
    		ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	//i2c_register_board_info(1, da850_evm_i2c_devices,
    	//		ARRAY_SIZE(da850_evm_i2c_devices));
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCBSP0) {
    		if (HAS_EMAC)
    			pr_warning("WARNING: both MCBSP0 and EMAC are "
    				"enabled, but they share pins.\n"
    				"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcbsp0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp0_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 registration"
    					"failed: %d\n",	ret);
    	}
    
    	if (HAS_MCBSP1) {
    		ret = da8xx_pinmux_setup(da850_mcbsp1_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp1_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 registration"
    					" failed: %d\n", ret);
    	}
    
    	if (HAS_MCASP) {
    		if ((HAS_MCBSP0 || HAS_MCBSP1))
    			pr_warning("WARNING: both McASP and McBSP are enabled, "
    					"but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed:"
    					"%d\n", ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_register_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_spi1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: spi1 mux setup failed: %d\n",
    				ret);
    
    	da850_init_spi1(BIT(0), da850_spi_board_info,
    			ARRAY_SIZE(da850_spi_board_info));
    
    	da850_evm_usb_init();
    
    	ret = da8xx_register_sata();
    	if (ret)
    		pr_warning("da850_evm_init: SATA registration failed: %d\n",
    						ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    	}
    
    	if (!HAS_RMII && HAS_VPIF_CAPTURE) {
    		ret = da8xx_pinmux_setup(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    
    	}
    
    	if (!HAS_GLCD && HAS_VPIF_DISPLAY) {
    		ret = da8xx_pinmux_setup(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    //		ret = da850_register_vpif_display(&da850_vpif_display_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF registration failed: "
    //					"%d\n",	ret);
    
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static __init void da850_evm_irq_init(void)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
    			soc_info->intc_irq_prios);
    }
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18xx EVM")
    	.phys_io	= IO_PHYS,
    	.io_pg_offst	= (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
    	.boot_params	= (DA8XX_DDR_BASE + 0x100),
    	.map_io		= da850_evm_map_io,
    	.init_irq	= da850_evm_irq_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    MACHINE_END
    

    I have not modified completely and Sorry I do not have time to complete and check,

    Please take this board file which implemented for MT9T031 camera through VPIF interface and modify for your TW9910 camera.

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/clk.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/input.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/gpio_keys.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/mtd/physmap.h>
    #include <linux/regulator/machine.h>
    #include <linux/regulator/tps6507x.h>
    #include <linux/input/tps6507x-ts.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/delay.h>
    #include <linux/wl12xx.h>
    #include <linux/pwm_backlight.h>
    #include <linux/i2c-gpio.h>
    #include <linux/videodev2.h>
    #include <linux/module.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <linux/mfd/davinci_aemif.h>
    #include <mach/spi.h>
    #include <mach/usb.h>
    #include <media/tvp514x.h>
    #include <media/davinci/vpif_types.h>
    
    #define DA850_EVM_PHY_ID		"davinci_mdio-0:00"
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_WLAN_EN			GPIO_TO_PIN(6, 9)
    #define DA850_WLAN_IRQ			GPIO_TO_PIN(6, 10)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #define DAVINCI_BACKLIGHT_MAX_BRIGHTNESS	250
    #define DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS	250
    #define DAVINCI_PWM_PERIOD_NANO_SECONDS		10000000
    
    
    static struct platform_pwm_backlight_data da850evm_backlight_data = {
    	.max_brightness	= DAVINCI_BACKLIGHT_MAX_BRIGHTNESS,
    	.dft_brightness	= DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS,
    	.pwm_period_ns	= DAVINCI_PWM_PERIOD_NANO_SECONDS,
    };
    
    static struct platform_device da850evm_backlight = {
    	.name		= "pwm-backlight",
    	.id		= -1,
    };
    
    static struct mtd_partition da850evm_spiflash_part[] = {
    	[0] = {
    		.name = "UBL",
    		.offset = 0,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_512K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "U-Boot-Env",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[3] = {
    		.name = "Kernel",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_2M + SZ_512K,
    		.mask_flags = 0,
    	},
    	[4] = {
    		.name = "Filesystem",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_4M,
    		.mask_flags = 0,
    	},
    	[5] = {
    		.name = "MAC-Address",
    		.offset = SZ_8M - SZ_64K,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    };
    
    static struct flash_platform_data da850evm_spiflash_data = {
    	.name		= "m25p80",
    	.parts		= da850evm_spiflash_part,
    	.nr_parts	= ARRAY_SIZE(da850evm_spiflash_part),
    	.type		= "m25p64",
    };
    
    static struct davinci_spi_config da850evm_spiflash_cfg = {
    	.io_type	= SPI_IO_TYPE_DMA,
    	.c2tdelay	= 8,
    	.t2cdelay	= 8,
    };
    
    static struct spi_board_info da850evm_spi_info[] = {
    	{
    		.modalias		= "m25p80",
    		.platform_data		= &da850evm_spiflash_data,
    		.controller_data	= &da850evm_spiflash_cfg,
    		.mode			= SPI_MODE_0,
    		.max_speed_hz		= 30000000,
    		.bus_num		= 1,
    		.chip_select		= 0,
    	},
    };
    
    #define TVP5147_CH0		"tvp514x-0"
    #define TVP5147_CH1		"tvp514x-1"
    
    #define VPIF_STATUS		0x002c
    #define VPIF_STATUS_CLR		0x0030
    
    #ifdef CONFIG_MTD
    static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
    {
    	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
    	size_t retlen;
    
    	if (!strcmp(mtd->name, "MAC-Address")) {
    		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
    		if (retlen == ETH_ALEN)
    			pr_info("Read MAC addr from SPI Flash: %pM\n",
    				mac_addr);
    	}
    }
    
    static struct mtd_notifier da850evm_spi_notifier = {
    	.add	= da850_evm_m25p80_notify_add,
    };
    
    static void da850_evm_setup_mac_addr(void)
    {
    	register_mtd_user(&da850evm_spi_notifier);
    }
    #else
    static void da850_evm_setup_mac_addr(void) { }
    #endif
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_4M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct physmap_flash_data da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    static struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.bbt_options	= NAND_BBT_USE_FLASH,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_devices[] = {
    	{
    		.name		= "davinci_nand",
    		.id		= 1,
    		.dev		= {
    			.platform_data	= &da850_evm_nandflash_data,
    		},
    		.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    		.resource	= da850_evm_nandflash_resource,
    	},
    #if !defined(CONFIG_MMC_DAVINCI) || \
        !defined(CONFIG_MMC_DAVINCI_MODULE)
    	{
    		.name		= "physmap-flash",
    		.id		= 0,
    		.dev		= {
    			.platform_data  = &da850_evm_norflash_data,
    		},
    		.num_resources	= 1,
    		.resource	= da850_evm_norflash_resource,
    
    	},
    #endif
    };
    static struct davinci_aemif_devices da850_emif_devices = {
    	.devices	= da850_evm_devices,
    	.num_devices	= ARRAY_SIZE(da850_evm_devices),
    };
    
    static struct platform_device davinci_emif_device = {
    	.name	= "davinci_aemif",
    	.id	= -1,
    	.dev	= {
    		.platform_data	= &da850_emif_devices,
    	},
    };
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static void __init da850_evm_init_nor(void)
    {
    	void __iomem *aemif_addr;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	/* Configure data bus width of CS2 to 16 bit */
    	writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
    		DA8XX_AEMIF_ASIZE_16BIT,
    		aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    static const short da850_evm_nand_pins[] = {
    	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
    	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
    	DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
    	DA850_NEMA_WE, DA850_NEMA_OE,
    	-1
    };
    
    static const short da850_evm_nor_pins[] = {
    	DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
    	DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
    	DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
    	DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
    	DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
    	DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
    	DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
    	DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
    	DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
    	DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
    	DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
    	DA850_EMA_A_22, DA850_EMA_A_23,
    	-1
    };
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    #if defined(CONFIG_SPI_DAVINCI)
    #define HAS_SPI 1
    #else
    #define HAS_SPI 0
    #endif
    
    #if defined(CONFIG_FB_DA8XX)
    #define HAS_LCD	1
    #else
    #define HAS_LCD	0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DAVINCI_EHRPWM) || defined(CONFIG_DAVINCI_EHRPWM_MODULE)
    #define HAS_EHRPWM 1
    #else
    #define HAS_EHRPWM 0
    #endif
    
    #if defined(CONFIG_ECAP_PWM) || \
    	defined(CONFIG_ECAP_PWM_MODULE)
    #define HAS_ECAP_PWM 1
    #else
    #define HAS_ECAP_PWM 0
    #endif
    
    #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
    #define HAS_BACKLIGHT 1
    #else
    #define HAS_BACKLIGHT 0
    #endif
    
    #if defined(CONFIG_ECAP_CAP) || defined(CONFIG_ECAP_CAP_MODULE)
    #define HAS_ECAP_CAP 1
    #else
    #define HAS_ECAP_CAP 0
    #endif
    
    /* have_imager() - Check if we have support for imager interface */
    static inline int have_imager(void)
    {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	return 1;
    #else
    	return 0;
    #endif
    }
    
    static inline void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    	ret = davinci_cfg_reg_list(da850_evm_nand_pins);
    	if (ret)
    		pr_warning("da850_evm_init: nand mux setup failed: "
    				"%d\n", ret);
    
    	if (!HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] low for NOR to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = davinci_cfg_reg_list(da850_evm_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    
    		da850_evm_init_nor();
    	} else {
    		/*
    		 * On Logic PD Rev.3 EVMs GP0[11] pin needs to be configured
    		 * for MMC and NOR to work. When GP0[11] is low, the SD0
    		 * interface will not work, but NOR flash will. When GP0[11]
    		 * is high, SD0 will work but NOR flash will not. By default
    		 * we are assuming that GP0[11] pin is driven high, when UI
    		 * card is not connected. Hence we are not configuring the
    		 * GP0[11] pin when MMC/SD is enabled and UI card is not
    		 * connected. Not configuring the GPIO pin will enable the
    		 * bluetooth to work on AM18x as it requires the GP0[11]
    		 * pin for UART flow control.
    		 */
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    	}
    
    	platform_device_register(&davinci_emif_device);
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value_cansleep(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    
    #define DA850_KEYS_DEBOUNCE_MS	10
    /*
     * At 200ms polling interval it is possible to miss an
     * event by tapping very lightly on the push button but most
     * pushes do result in an event; longer intervals require the
     * user to hold the button whereas shorter intervals require
     * more CPU time for polling.
     */
    #define DA850_GPIO_KEYS_POLL_MS	200
    
    enum da850_evm_ui_exp_pins {
    	DA850_EVM_UI_EXP_SEL_C = 5,
    	DA850_EVM_UI_EXP_SEL_B,
    	DA850_EVM_UI_EXP_SEL_A,
    	DA850_EVM_UI_EXP_PB8,
    	DA850_EVM_UI_EXP_PB7,
    	DA850_EVM_UI_EXP_PB6,
    	DA850_EVM_UI_EXP_PB5,
    	DA850_EVM_UI_EXP_PB4,
    	DA850_EVM_UI_EXP_PB3,
    	DA850_EVM_UI_EXP_PB2,
    	DA850_EVM_UI_EXP_PB1,
    };
    
    static const char const *da850_evm_ui_exp[] = {
    	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c",
    	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b",
    	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a",
    	[DA850_EVM_UI_EXP_PB8]          = "pb8",
    	[DA850_EVM_UI_EXP_PB7]          = "pb7",
    	[DA850_EVM_UI_EXP_PB6]          = "pb6",
    	[DA850_EVM_UI_EXP_PB5]          = "pb5",
    	[DA850_EVM_UI_EXP_PB4]          = "pb4",
    	[DA850_EVM_UI_EXP_PB3]          = "pb3",
    	[DA850_EVM_UI_EXP_PB2]          = "pb2",
    	[DA850_EVM_UI_EXP_PB1]          = "pb1",
    };
    
    #define DA850_N_UI_PB		8
    
    static struct gpio_keys_button da850_evm_ui_keys[] = {
    	[0 ... DA850_N_UI_PB - 1] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
    	.buttons = da850_evm_ui_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_ui_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 0,
    	.dev = {
    		.platform_data = &da850_evm_ui_keys_pdata
    	},
    };
    
    static void da850_evm_ui_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	for (i = 0; i < DA850_N_UI_PB; i++) {
    		button = &da850_evm_ui_keys[i];
    		button->code = KEY_F8 - i;
    		button->desc = (char *)
    				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
    		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
    	}
    }
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value_cansleep(a, 0);
    	gpio_set_value_cansleep(b, 0);
    	gpio_set_value_cansleep(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value_cansleep(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CAMERA
    static inline void da850_evm_setup_camera(int camera_sel)
    {
    	gpio_set_value_cansleep(camera_sel, 0);
    }
    #else
    static inline void da850_evm_setup_camera(int camera_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
    	sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
    	sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
    
    	ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	da850_evm_ui_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_ui_keys_device);
    	if (ret) {
    		pr_warning("Could not register UI GPIO expander push-buttons");
    		goto exp_setup_keys_fail;
    	}
    
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	da850_evm_setup_camera(sel_b);
    
    	return 0;
    
    exp_setup_keys_fail:
    	gpio_free(sel_c);
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_ui_keys_device);
    
    	/* deselect all functionalities */
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
    
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
    
    	return 0;
    }
    
    /* assign the baseboard expander's GPIOs after the UI board's */
    #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
    #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
    
    enum da850_evm_bb_exp_pins {
    	DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
    	DA850_EVM_BB_EXP_SW_RST,
    	DA850_EVM_BB_EXP_TP_23,
    	DA850_EVM_BB_EXP_TP_22,
    	DA850_EVM_BB_EXP_TP_21,
    	DA850_EVM_BB_EXP_USER_PB1,
    	DA850_EVM_BB_EXP_USER_LED2,
    	DA850_EVM_BB_EXP_USER_LED1,
    	DA850_EVM_BB_EXP_USER_SW1,
    	DA850_EVM_BB_EXP_USER_SW2,
    	DA850_EVM_BB_EXP_USER_SW3,
    	DA850_EVM_BB_EXP_USER_SW4,
    	DA850_EVM_BB_EXP_USER_SW5,
    	DA850_EVM_BB_EXP_USER_SW6,
    	DA850_EVM_BB_EXP_USER_SW7,
    	DA850_EVM_BB_EXP_USER_SW8
    };
    
    static const char const *da850_evm_bb_exp[] = {
    	[DA850_EVM_BB_EXP_DEEP_SLEEP_EN]	= "deep_sleep_en",
    	[DA850_EVM_BB_EXP_SW_RST]		= "sw_rst",
    	[DA850_EVM_BB_EXP_TP_23]		= "tp_23",
    	[DA850_EVM_BB_EXP_TP_22]		= "tp_22",
    	[DA850_EVM_BB_EXP_TP_21]		= "tp_21",
    	[DA850_EVM_BB_EXP_USER_PB1]		= "user_pb1",
    	[DA850_EVM_BB_EXP_USER_LED2]		= "user_led2",
    	[DA850_EVM_BB_EXP_USER_LED1]		= "user_led1",
    	[DA850_EVM_BB_EXP_USER_SW1]		= "user_sw1",
    	[DA850_EVM_BB_EXP_USER_SW2]		= "user_sw2",
    	[DA850_EVM_BB_EXP_USER_SW3]		= "user_sw3",
    	[DA850_EVM_BB_EXP_USER_SW4]		= "user_sw4",
    	[DA850_EVM_BB_EXP_USER_SW5]		= "user_sw5",
    	[DA850_EVM_BB_EXP_USER_SW6]		= "user_sw6",
    	[DA850_EVM_BB_EXP_USER_SW7]		= "user_sw7",
    	[DA850_EVM_BB_EXP_USER_SW8]		= "user_sw8",
    };
    
    #define DA850_N_BB_USER_SW	8
    
    static struct gpio_keys_button da850_evm_bb_keys[] = {
    	[0] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= KEY_PROG1,
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    	[1 ... DA850_N_BB_USER_SW] = {
    		.type			= EV_SW,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
    	.buttons = da850_evm_bb_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_bb_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 1,
    	.dev = {
    		.platform_data = &da850_evm_bb_keys_pdata
    	},
    };
    
    static void da850_evm_bb_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	button = &da850_evm_bb_keys[0];
    	button->desc = (char *)
    		da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
    	button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
    
    	for (i = 0; i < DA850_N_BB_USER_SW; i++) {
    		button = &da850_evm_bb_keys[i + 1];
    		button->code = SW_LID + i;
    		button->desc = (char *)
    				da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
    		button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
    	}
    }
    
    #define DA850_N_BB_USER_LED	2
    
    static struct gpio_led da850_evm_bb_leds[] = {
    	[0 ... DA850_N_BB_USER_LED - 1] = {
    		.active_low = 1,
    		.gpio = -1, /* assigned at runtime */
    		.name = NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
    	.leds = da850_evm_bb_leds,
    	.num_leds = ARRAY_SIZE(da850_evm_bb_leds),
    };
    
    static struct platform_device da850_evm_bb_leds_device = {
    	.name		= "leds-gpio",
    	.id		= -1,
    	.dev = {
    		.platform_data = &da850_evm_bb_leds_pdata
    	}
    };
    
    static void da850_evm_bb_leds_init(unsigned gpio)
    {
    	int i;
    	struct gpio_led *led;
    
    	for (i = 0; i < DA850_N_BB_USER_LED; i++) {
    		led = &da850_evm_bb_leds[i];
    
    		led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
    		led->name =
    			da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
    	}
    }
    
    static int da850_evm_bb_expander_setup(struct i2c_client *client,
    						unsigned gpio, unsigned ngpio,
    						void *c)
    {
    	int ret;
    
    	/*
    	 * Register the switches and pushbutton on the baseboard as a gpio-keys
    	 * device.
    	 */
    	da850_evm_bb_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_keys_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander keys");
    		goto io_exp_setup_sw_fail;
    	}
    
    	da850_evm_bb_leds_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_leds_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander LEDS");
    		goto io_exp_setup_leds_fail;
    	}
    
    	return 0;
    
    io_exp_setup_leds_fail:
    	platform_device_unregister(&da850_evm_bb_keys_device);
    io_exp_setup_sw_fail:
    	return ret;
    }
    
    static int da850_evm_bb_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_bb_leds_device);
    	platform_device_unregister(&da850_evm_bb_keys_device);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    	.names		= da850_evm_ui_exp,
    };
    
    static struct pca953x_platform_data da850_evm_bb_expander_info = {
    	.gpio_base	= DA850_BB_EXPANDER_GPIO_BASE,
    	.setup		= da850_evm_bb_expander_setup,
    	.teardown	= da850_evm_bb_expander_teardown,
    	.names		= da850_evm_bb_exp,
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x21),
    		.platform_data = &da850_evm_bb_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    	{
    		I2C_BOARD_INFO("PCA9543A", 0x73),
    	},
    };
    
    /*
     * USB1 VBUS is controlled by GPIO2[4], over-current is reported on GPIO6[13].
     */
    #define ON_BD_USB_DRV	GPIO_TO_PIN(2, 4)
    #define ON_BD_USB_OVC	GPIO_TO_PIN(6, 13)
    
    static const short da850_evm_usb11_pins[] = {
    	DA850_GPIO2_4, DA850_GPIO6_13,
    	-1
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.type			= GPIO_BASED,
    	.method	= {
    		.gpio_method = {
    			.power_control_pin	= ON_BD_USB_DRV,
    			.over_current_indicator = ON_BD_USB_OVC,
    		},
    	},
    	.board_ocic_handler	= da850_evm_usb_ocic_irq,
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *handler)
    {
    	if (handler != NULL)
    		((da8xx_ocic_handler_t)handler)(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static __init void da850_evm_usb_init(void)
    {
    	u32 cfgchip2;
    	int ret;
    
    	/*
    	 * Set up USB clock/mode in the CFGCHIP2 register.
    	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/* USB2.0 PHY reference clock is 24 MHz */
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    
    	/*
    	 * Select internal reference clock for USB 2.0 PHY
    	 * and use it as a clock source for USB 1.1 PHY
    	 * (this is the default setting anyway).
    	 */
    	cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
    	cfgchip2 |=  CFGCHIP2_USB2PHYCLKMUX;
    	/*
    	 * We have to override VBUS/ID signals when MUSB is configured into the
    	 * host-only mode -- ID pin will float if no cable is connected, so the
    	 * controller won't be able to drive VBUS thinking that it's a B-device.
    	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
    	 */
    	cfgchip2 &= ~CFGCHIP2_OTGMODE;
    	cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
    
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/*
    	 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
    	 * with the power on to power good time of 3 ms.
    	 */
    	ret = da8xx_register_usb20(1000, 3);
    	if (ret)
    		pr_warning("%s: USB 2.0 registration failed: %d\n",
    			   __func__, ret);
    
    	/* initilaize usb module */
    	da8xx_board_usb_init(da850_evm_usb11_pins, &da850_evm_usb11_pdata);
    }
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.asp_chan_q	= EVENTQ_0,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static const short da850_evm_mcasp_pins[] __initconst = {
    	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
    	DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
    	DA850_AXR_11, DA850_AXR_12,
    	-1
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= da850_evm_mmc_get_ro,
    	.get_cd		= da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_evm_mmcsd0_pins[] __initconst = {
    	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
    	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
    	DA850_GPIO4_0, DA850_GPIO4_1,
    	-1
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value_cansleep(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value_cansleep(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	int status;
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    /* We take advantage of the fact that both defdcdc{2,3} are tied high */
    static struct tps6507x_reg_platform_data tps6507x_platform_data = {
    	.defdcdc_default = true,
    };
    
    static struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1350000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct touchscreen_init_data tps6507x_touchscreen_data = {
    	.poll_period =  30,	/* ms between touch samples */
    	.min_pressure = 0x30,	/* minimum pressure to trigger touch */
    	.vref = 0,		/* turn off vref when not using A/D */
    	.vendor = 0,		/* /sys/class/input/input?/id/vendor */
    	.product = 65070,	/* /sys/class/input/input?/id/product */
    	.version = 0x100,	/* /sys/class/input/input?/id/version */
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    	.tps6507x_ts_init_data = &tps6507x_touchscreen_data,
    };
    
    static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    };
    
    static int __init pmic_tps65070_init(void)
    {
    	return i2c_register_board_info(1, da850_evm_tps65070_info,
    					ARRAY_SIZE(da850_evm_tps65070_info));
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static struct i2c_client *pca9543a;
    
    static int pca9543a_probe(struct i2c_client *client,
    		const struct i2c_device_id *id)
    {
    	pr_info("pca9543a_probe");
    	pca9543a = client;
    	return 0;
    }
    
    static int pca9543a_remove(struct i2c_client *client)
    {
    	pca9543a = NULL;
    	return 0;
    }
    
    static const struct i2c_device_id pca9543a_ids[] = {
    	{ "PCA9543A", 0, },
    	{ /* end of list */ },
    };
    
    /* This is for i2c driver for the MT9T031 header i2c switch */
    static struct i2c_driver pca9543a_driver = {
    	.driver.name	= "PCA9543A",
    	.id_table	= pca9543a_ids,
    	.probe		= pca9543a_probe,
    	.remove		= pca9543a_remove,
    };
    
    /**
     * da850_enable_pca9543a() - Enable/Disable I2C switch PCA9543A for sensor
     * @en: enable/disable flag
     */
    static int da850_enable_pca9543a(int en)
    {
    	static char val = 1;
    	int status;
    	struct i2c_msg msg = {
    			.flags = 0,
    			.len = 1,
    			.buf = &val,
    		};
    
    	pr_info("da850evm_enable_pca9543a\n");
    	if (!en)
    		val = 0;
    
    	if (!pca9543a)
    		return -ENXIO;
    
    	msg.addr = pca9543a->addr;
    	/* turn i2c switch, pca9543a, on/off */
    	status = i2c_transfer(pca9543a->adapter, &msg, 1);
    	pr_info("da850evm_enable_pca9543a, status = %d\n", status);
    	return status;
    }
    
    static const short da850_evm_mii_pins[] = {
    	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
    	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
    	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
    	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static const short da850_evm_rmii_pins[] = {
    	DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
    	DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
    	DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_mii_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = "mt9t031",
    	},
    };
    
    /*
     * The following EDMA channels/slots are not being used by drivers (for
     * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
     * they are being reserved for codecs on the DSP side.
     */
    static const s16 da850_dma0_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma0_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30, 50},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30, 90},
    	{-1, -1}
    };
    
    static struct edma_rsv_info da850_edma_cc0_rsv = {
    	.rsv_chans	= da850_dma0_rsv_chans,
    	.rsv_slots	= da850_dma0_rsv_slots,
    };
    
    static struct edma_rsv_info da850_edma_cc1_rsv = {
    	.rsv_chans	= da850_dma1_rsv_chans,
    	.rsv_slots	= da850_dma1_rsv_slots,
    };
    
    static struct edma_rsv_info *da850_edma_rsv[2] = {
    	&da850_edma_cc0_rsv,
    	&da850_edma_cc1_rsv,
    };
    
    #ifdef CONFIG_CPU_FREQ
    static __init int da850_evm_init_cpufreq(void)
    {
    	switch (system_rev & 0xF) {
    	case 3:
    		da850_max_speed = 456000;
    		break;
    	case 2:
    		da850_max_speed = 408000;
    		break;
    	case 1:
    		da850_max_speed = 372000;
    		break;
    	}
    
    	return da850_register_cpufreq("pll0_sysclk3");
    }
    #else
    static __init int da850_evm_init_cpufreq(void) { return 0; }
    #endif
    
    #if defined(CONFIG_DAVINCI_UART1_AFE)
    #define HAS_UART1_AFE 1
    #else
    #define HAS_UART1_AFE 0
    #endif
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    int da850_vpif_setup_input_path(int ch, const char *name)
    {
    	int ret = 1;
    
    	 if (!strcmp(name, "mt9t031") && have_imager())
    		ret = da850_enable_pca9543a(1);
    
    	return ret;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    #endif
    
    #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	{
    		.name	= "mt9t031",
    		.board_info = {
    			I2C_BOARD_INFO("mt9t031", 0x5d),
    			.platform_data = (void *)1,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #elif defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	{
    		.name	= TVP5147_CH0,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= TVP5147_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	.setup_input_path = da850_vpif_setup_input_path,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    #elif defined(CONFIG_DA850_UI_CAMERA)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    #endif
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    #ifdef CONFIG_DA850_WL12XX
    
    static void wl12xx_set_power(int index, bool power_on)
    {
    	static bool power_state;
    
    	pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
    
    	if (power_on == power_state)
    		return;
    	power_state = power_on;
    
    	if (power_on) {
    		/* Power up sequence required for wl127x devices */
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		usleep_range(15000, 15000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    		usleep_range(1000, 1000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		msleep(70);
    	} else {
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    	}
    }
    
    static struct davinci_mmc_config da850_wl12xx_mmc_config = {
    	.set_power	= wl12xx_set_power,
    	.wires		= 4,
    	.max_freq	= 25000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    			  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_wl12xx_pins[] __initconst = {
    	DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
    	DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
    	DA850_GPIO6_9, DA850_GPIO6_10,
    	-1
    };
    
    static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
    	.irq			= -1,
    	.board_ref_clock	= WL12XX_REFCLOCK_38,
    	.platform_quirks	= WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    };
    
    static __init int da850_wl12xx_init(void)
    {
    	int ret;
    
    	ret = davinci_cfg_reg_list(da850_wl12xx_pins);
    	if (ret) {
    		pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
    	if (ret) {
    		pr_err("wl12xx/mmc registration failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
    	if (ret) {
    		pr_err("Could not request wl12xx enable gpio: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
    	if (ret) {
    		pr_err("Could not request wl12xx irq gpio: %d\n", ret);
    		goto free_wlan_en;
    	}
    
    	da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
    
    	ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
    	if (ret) {
    		pr_err("Could not set wl12xx data: %d\n", ret);
    		goto free_wlan_irq;
    	}
    
    	return 0;
    
    free_wlan_irq:
    	gpio_free(DA850_WLAN_IRQ);
    
    free_wlan_en:
    	gpio_free(DA850_WLAN_EN);
    
    exit:
    	return ret;
    }
    
    #else /* CONFIG_DA850_WL12XX */
    
    static __init int da850_wl12xx_init(void)
    {
    	return 0;
    }
    
    #endif /* CONFIG_DA850_WL12XX */
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init int da850_set_emif_clk_rate(void)
    {
    	struct clk *emif_clk;
    
    	emif_clk = clk_get(NULL, "pll0_sysclk3");
    	if (WARN(IS_ERR(emif_clk), "Unable to get emif clock\n"))
    		return PTR_ERR(emif_clk);
    
    	return clk_set_rate(emif_clk, CONFIG_DA850_FIX_PLL0_SYSCLK3RATE);
    }
    
    struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
    	.pintc_base	= 0x4000,
    };
    
    #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    	char mask = 0;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	ret = pmic_tps65070_init();
    	if (ret)
    		pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
    				ret);
    
    	/*
    	 * Though bootloader takes care to set emif clock at allowed
    	 * possible rate. Kernel needs to reconfigure this rate to
    	 * support platforms requiring fixed emif clock rate.
    	 */
    	ret = da850_set_emif_clk_rate();
    	if (ret)
    		pr_warning("da850_evm_init: Failed to set rate of pll0_sysclk3/emif clock: %d\n",
    				ret);
    
    	ret = da850_register_edma(da850_edma_rsv);
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = davinci_cfg_reg_list(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	/* Support for UART 1 */
    	ret = davinci_cfg_reg_list(da850_uart1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: UART 1 mux setup failed:"
    						" %d\n", ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    
    		ret = da850_wl12xx_init();
    		if (ret)
    			pr_warning("da850_evm_init: wl12xx initialization"
    				   " failed: %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	if (have_imager())
    		i2c_add_driver(&pca9543a_driver);
    
    	i2c_register_board_info(1, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCASP) {
    		if (HAS_UART1_AFE)
    			pr_warning("WARNING: both McASP and UART1_AFE are "
    				"enabled, but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
    					ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
    	if (ret)
    		pr_warning("%s: pruss_uio initialization failed: %d\n",
    				__func__, ret);	
    
    	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_evm_init_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF setup failed: %d\n",
    				   ret);
    	}
    
    	if (HAS_VPIF_CAPTURE) {
    		ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture mux failed:"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture setup failed:"
    					"%d\n", ret);
    	}
    
    	if (HAS_VPIF_DISPLAY) {
    		ret = davinci_cfg_reg_list(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init : VPIF capture mux failed :"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_display(&da850_vpif_display_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF display setup failed:"
    					"%d\n", ret);
    	}
    
    	ret = da8xx_register_spi(1, da850evm_spi_info,
    				 ARRAY_SIZE(da850evm_spi_info));
    	if (ret)
    		pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
    				ret);
    
    	ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
    	if (ret)
    		pr_warning("da850_evm_init: sata registration failed: %d\n",
    				ret);
    
    	da850_evm_setup_mac_addr();
    
    	da850_evm_usb_init();
    
    	if (HAS_EHRPWM) {
    		if (rmii_en) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm0_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" ehrpwm0 mux setup failed: %d\n", ret);
    			else
    				mask = BIT(0) | BIT(1);
    		} else {
    			pr_warning("da850_evm_init:"
    			" eHRPWM module 0 cannot be used"
    			" since it is being used by MII interface\n");
    			mask = 0;
    		}
    
    		if (!HAS_LCD) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm1_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" eHRPWM module1 output A mux"
    				" setup failed %d\n", ret);
    			else
    				mask = mask | BIT(2);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputA cannot be"
    				" used since it is being used by LCD\n");
    		}
    
    		if (!HAS_SPI) {
    			ret = davinci_cfg_reg(DA850_EHRPWM1_B);
    			if (ret)
    				pr_warning("da850_evm_init:"
    					" eHRPWM module1 outputB mux"
    					" setup failed %d\n", ret);
    		else
    			mask =  mask  | BIT(3);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputB cannot be"
    				" used since it is being used by spi1\n");
    		}
    
    		da850_register_ehrpwm(mask);
    	}
    
    	if (HAS_ECAP_PWM) {
    		ret = davinci_cfg_reg(DA850_ECAP2_APWM2);
    		if (ret)
    			pr_warning("da850_evm_init:ecap mux failed:"
    					" %d\n", ret);
    		ret = da850_register_ecap(2);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" eCAP registration failed: %d\n", ret);
    	}
    
    	if (HAS_BACKLIGHT) {
    		ret = da850_register_backlight(&da850evm_backlight,
    				&da850evm_backlight_data);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" backlight device registration"
    				" failed: %d\n", ret);
    	}
    
    	if (HAS_ECAP_CAP) {
    		if (HAS_MCASP)
    			pr_warning("da850_evm_init:"
    				"ecap module 1 cannot be used "
    				"since it shares pins with McASP\n");
    		else {
    			ret = davinci_cfg_reg(DA850_ECAP1_APWM1);
    			if (ret)
    				pr_warning("da850_evm_init:ecap mux failed:%d\n"
    						, ret);
    			else {
    				ret = da850_register_ecap_cap(1);
    				if (ret)
    					pr_warning("da850_evm_init"
    					"eCAP registration failed: %d\n", ret);
    			}
    		}
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
    	.atag_offset	= 0x100,
    	.map_io		= da850_evm_map_io,
    	.init_irq	= cp_intc_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    	.dma_zone_size	= SZ_128M,
    	.restart	= da8xx_restart,
    MACHINE_END
    

    Please let me know the status, So others also get benefited.

    Thanks for your understanding.

  • Hi Titusrathinaraj:

        Thanks very much!

        I read MT9T031 board file that your protected to me! But I found that in 

         in my board file:

    static __init void da850_evm_init(void)
    {
    ....

    i2c_register_board_info(0, da850_evm_i2c_devices,
    ARRAY_SIZE(da850_evm_i2c_devices));    //is BUS_ID=0 right? I using BUS_ID=1  ???

    ....

    if (!HAS_RMII && HAS_VPIF_CAPTURE) {
    ret = da8xx_pinmux_setup(da850_vpif_capture_pins);
    if (ret)
    pr_warning("da850_evm_init: vpif capture mux failed: "
    "%d\n", ret);

    //titus

    //When add this , it can run tw9910_probe() ok.
    platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));  

    //But I cann't run da850_register_vpif_capture ok. Always I can get error:

    //vpif_capture vpif_capture: Error registering v4l2 subdevice
     ret = da850_register_vpif_capture(&da850_vpif_capture_config);
     if (ret)
     pr_warning("da850_evm_init: VPIF registration failed: "
     "%d\n", ret);

    ....

    }

       the full board_da850_evm.c file is:

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/delay.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/regulator/machine.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/usb/musb.h>
    #include <linux/i2c-gpio.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <media/tw9910.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <mach/flash.h>
    #include <mach/vpif.h>
    
    #include <media/tvp514x.h>
    
    #define DA850_EVM_PHY_MASK		0x1
    #define DA850_EVM_MDIO_FREQUENCY	2200000 /* PHY bus frequency */
    
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)
    #ifdef CONFIG_SOC_CAMERA_TW9900
    asfsadfsfdasfdsdf
    #define CAMERA_CH0		"tw9900-0"
    #define CAMERA_CH1		"tw9900-1"
    #define CAMERA_NAME		"tw9900"
    #else
    #define CAMERA_CH0		"tw9910-0"
    #define CAMERA_CH1		"tw9910-1"
    #define CAMERA_NAME		"tw9910"
    #endif
    #else
    #define CAMERA_NAME		"camera xxx"
    #define CAMERA_CH0		"tvp514x-0"
    #define CAMERA_CH1		"tvp514x-1"
    #endif
    
    //#define CAMERA_CH0		"tvp514x-0"
    //#define CAMERA_CH1		"tvp514x-1"
    
    #define VPIF_STATUS	(0x002C)
    #define VPIF_STATUS_CLR	(0x0030)
    #define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4)
    #define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13)
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_2M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct davinciflash_pdata da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_norflash_device = {
    	.name		= "davinci-flash",
    	.id		= 0,
    	.dev		= {
    		.platform_data  = &da850_evm_norflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_norflash_resource),
    	.resource	= da850_evm_norflash_resource,
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= 0x200000,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.options	= NAND_USE_FLASH_BBT,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_nandflash_device = {
    	.name		= "davinci_nand",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_evm_nandflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    	.resource	= da850_evm_nandflash_resource,
    };
    
    static struct platform_device *da850_evm_devices[] __initdata = {
    	&da850_evm_nandflash_device,
    	&da850_evm_norflash_device,
    };
    
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_CE3CFG_OFFSET	0x14
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static struct mtd_partition spi_flash_partitions[] = {
    	[0] = {
    		.name = "U-Boot",
    		.offset = 0,
    		.size = SZ_256K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot Environment",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "Linux",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_8M - (SZ_256K + SZ_64K + SZ_64K),
    		.mask_flags = 0,
    	},
    	[3] = {
    		.name = "MAC Address",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    		.setup = davinci_get_mac_addr,
    		.context = (void *)0,
    	},
    };
    
    static struct flash_platform_data spi_flash_data = {
    	.name = "m25p80",
    	.parts = spi_flash_partitions,
    	.nr_parts = ARRAY_SIZE(spi_flash_partitions),
    	.type = "m25p64",
    };
    
    static struct spi_board_info da850_spi_board_info[] = {
    	[0] = {
    		.modalias = "m25p80",
    		.platform_data = &spi_flash_data,
    		.mode = SPI_MODE_0,
    		.max_speed_hz = 30000000,       /* max sample rate at 3V */
    		.bus_num = 1,
    		.chip_select = 0,
    	},
    };
    
    static u32 ui_card_detected;
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    static void __init da850_evm_init_nand(void)
    {
    	void __iomem *aemif_addr;
    	u32 ce3cfg;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	ce3cfg = 0
    		| (0 << 31)	/* selectStrobe */
    		| (0 << 30)	/* extWait */
    		| (0 << 26)	/* writeSetup */
    		| (3 << 20)	/* writeStrobe  30 ns */
    		| (3 << 17)	/* writeHold    30 ns */
    		| (2 << 13)	/* readSetup    20 ns */
    		| (4 << 7)	/* readStrobe   40 ns */
    		| (0 << 4)	/* readHold */
    		| (0 << 2)	/* turnAround */
    		| (0 << 0)	/* asyncSize    8-bit bus */
    		;
    
    	writel(ce3cfg, aemif_addr + DA8XX_AEMIF_CE3CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    
    static __init void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    //	if (ui_card_detected & !HAS_MMC) {
    		ret = da8xx_pinmux_setup(da850_nand_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nand mux setup failed: "
    					"%d\n", ret);
    
    		da850_evm_init_nand();
    
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    /*
    		// Driver GP0[11] low for NOR to work 
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = da8xx_pinmux_setup(da850_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    */
    		
    		platform_add_devices(da850_evm_devices,
    					ARRAY_SIZE(da850_evm_devices));
    		pr_info("NAND_FLASH Init OK!\n");
    //	}
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value(a, 0);
    	gpio_set_value(b, 0);
    	gpio_set_value(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + 7;
    	sel_b = gpio + 6;
    	sel_c = gpio + 5;
    
    	ret = gpio_request(sel_a, "sel_a");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, "sel_b");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, "sel_c");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	ui_card_detected = 1;
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    //	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	return 0;
    
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	/* deselect all functionalities */
    	gpio_set_value(gpio + 5, 1);
    	gpio_set_value(gpio + 6, 1);
    	gpio_set_value(gpio + 7, 1);
    
    	gpio_free(gpio + 5);
    	gpio_free(gpio + 6);
    	gpio_free(gpio + 7);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    };
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1380000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    	{
    		I2C_BOARD_INFO(CAMERA_NAME, 0x45),
    		//.platform_data = &da850_evm_ui_expander_info,	
    	},
    #endif
    
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    };
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.eventq_no	= EVENTQ_1,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp0_config = {
    	.inst	= 0,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp1_config = {
    	.inst	= 1,
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	void __iomem *cfg_mstpri2_base;
    	int status;
    	u32 val;
    
    	/*
    	 * Reconfigure the LCDC priority to the highest to ensure that
    	 * the throughput/latency requirements for the LCDC are met.
    	 */
    	cfg_mstpri2_base = DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG);
    
    	val = __raw_readl(cfg_mstpri2_base);
    	val &= 0x0fffffff;
    	__raw_writel(val, cfg_mstpri2_base);
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = da8xx_pinmux_setup(da850_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = da8xx_pinmux_setup(da850_cpgmac_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
    	soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    
    device_initcall(da850_evm_config_emac);
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    static struct tw9910_platform_data tw9910_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    
    
    /* I2C Video */
    static struct i2c_board_info i2c_camera[] = {
    	{
    		I2C_BOARD_INFO(CAMERA_NAME, 0x45),
    	},
    };
    
    static struct tw9910_video_info tw9910_info = {
    	.buswidth	= SOCAM_DATAWIDTH_8,
    	.mpout		= TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    	.i2c_adapter_id	= 0,
    	.bus_id		= 1,
    	//.power		= tw9910_power,
    	.power		= NULL,
    	.board_info	= &i2c_camera[0],
    	.module_name	= CAMERA_NAME,
    	.priv		= &tw9910_info,
    };
    
    static struct platform_device tw9910_camera[] = {
    	{
    		.name	= "TW9910 for soc-camera",
    		.id	= 1,
    		.dev	= {
    			.platform_data = &tw9910_link,
    		},
    	},
    };
    
    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };
    
    
    #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    #if defined(CONFIG_DA850_UI_CAMERA) || defined(CONFIG_SOC_CAMERA_TW9910)
    	{
    		.name	= CAMERA_NAME,
    		.board_info = {
    			I2C_BOARD_INFO(CAMERA_NAME, 0x45),
    			.platform_data = &da850_evm_ui_expander_info,//&da850_evm_ui_expander_info,//&da850_evm_ui_expander_info,//&tw9910_pdata,//&da850_evm_ui_expander_info,//(void *)1,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #if 0
    	{
    		.name	= CAMERA_CH0,
    		.board_info = {
    			I2C_BOARD_INFO(CAMERA_NAME, 0x45),
    			.platform_data = &tw9910_pdata,
    		},
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= CAMERA_CH1,
    		.board_info = {
    			I2C_BOARD_INFO(CAMERA_NAME, 0x46),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    #elif defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    asdfsadfa
    	{
    		.name	= CAMERA_CH0,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= CAMERA_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
           {
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH1,
    	},
    };
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,	//V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = CAMERA_NAME,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    #if defined(CONFIG_DA850_UI_CAMERA) || defined(CONFIG_SOC_CAMERA_TW9910)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    #else
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    #endif	
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_DAVINCI_MCBSP0)
    #define HAS_MCBSP0 1
    #else
    #define HAS_MCBSP0 0
    #endif
    
    #if defined(CONFIG_DAVINCI_MCBSP1)
    #define HAS_MCBSP1 1
    #else
    #define HAS_MCBSP1 0
    #endif
    
    #if defined(CONFIG_TI_DAVINCI_EMAC) || \
    	defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
    #define HAS_EMAC 1
    #else
    #define HAS_EMAC 0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DA850_UI_RMII) && (HAS_EMAC)
    #define HAS_RMII 1
    #else
    #define HAS_RMII 0
    #endif
    
    #if defined(CONFIG_DA850_UI_LCD) && defined(CONFIG_FB_DA8XX) ||\
    		defined(CONFIG_FB_DA8XX_MODULE)
    #define HAS_GLCD 1
    #else
    #define HAS_GLCD 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    static da8xx_ocic_handler_t da850_evm_usb_ocic_handler;
    
    static int da850_evm_usb_set_power(unsigned port, int on)
    {
    	gpio_set_value(DA850_USB1_VBUS_PIN, on);
    	return 0;
    }
    
    static int da850_evm_usb_get_power(unsigned port)
    {
    	return gpio_get_value(DA850_USB1_VBUS_PIN);
    }
    
    static int da850_evm_usb_get_oci(unsigned port)
    {
    	return !gpio_get_value(DA850_USB1_OC_PIN);
    }
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static int da850_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
    {
    	int irq 	= gpio_to_irq(DA850_USB1_OC_PIN);
    	int error	= 0;
    
    	if (handler != NULL) {
    		da850_evm_usb_ocic_handler = handler;
    
    		error = request_irq(irq, da850_evm_usb_ocic_irq, IRQF_DISABLED |
    				    IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
    				    "OHCI over-current indicator", NULL);
    		if (error)
    			printk(KERN_ERR "%s: could not request IRQ to watch "
    			       "over-current indicator changes\n", __func__);
    	} else
    		free_irq(irq, NULL);
    
    	return error;
    }
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.set_power	= da850_evm_usb_set_power,
    	.get_power	= da850_evm_usb_get_power,
    	.get_oci	= da850_evm_usb_get_oci,
    	.ocic_notify	= da850_evm_usb_ocic_notify,
    
    	/* TPS2065 switch @ 5V */
    	.potpgt		= (3 + 1) / 2,	/* 3 ms max */
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *dev_id)
    {
    	da850_evm_usb_ocic_handler(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static struct musb_hdrc_platform_data usb_evm_data[] = {
    	{
    #ifdef CONFIG_USB_MUSB_OTG
    		.mode = MUSB_OTG,
    #elif defined(CONFIG_USB_MUSB_DUAL_ROLE)
    		.mode = MUSB_DUAL_ROLE,
    #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
    		.mode =  MUSB_PERIPHERAL,
    #elif defined(CONFIG_USB_MUSB_HOST)
    		.mode = MUSB_HOST,
    #endif
    		.power = 255,
    		.potpgt = 8,
    		.set_vbus = NULL, /* VBUs is directly controlled by the IP */
    	}
    };
    
    static __init void da850_evm_usb_init(void)
    {
    	int ret;
    	u32 cfgchip2;
    
    	/*
    	 * Setup the Ref. clock frequency for the EVM at 24 MHz.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	da8xx_usb20_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data));
    
    	ret = da8xx_pinmux_setup(da850_evm_usb11_pins);
    	if (ret) {
    		pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
    			   __func__, ret);
    		return;
    	}
    
    	ret = gpio_request(DA850_USB1_VBUS_PIN, "USB1 VBUS\n");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "power control: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_output(DA850_USB1_VBUS_PIN, 0);
    
    	ret = gpio_request(DA850_USB1_OC_PIN, "USB1 OC");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "over-current indicator: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_input(DA850_USB1_OC_PIN);
    
    	ret = da8xx_register_usb11(&da850_evm_usb11_pdata);
    	if (ret)
    		pr_warning("%s: USB 1.1 registration failed: %d\n",
    			   __func__, ret);
    }
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    	.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    #if 0
    /* I2C Video */
    static struct i2c_board_info i2c_camera[] = {
    	{
    		I2C_BOARD_INFO(CAMERA_NAME, 0x45),
    	},
    };
    
    static struct tw9910_video_info tw9910_info = {
    	.buswidth	= SOCAM_DATAWIDTH_8,
    	.mpout		= TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    	.i2c_adapter_id	= 0,
    	.bus_id		= 1,
    	//.power		= tw9910_power,
    	.power		= NULL,
    	.board_info	= &i2c_camera[0],
    	.module_name	= CAMERA_NAME,
    	.priv		= &tw9910_info,
    };
    
    static struct platform_device tw9910_camera[] = {
    	{
    		.name	= "TW9910 for soc-camera",
    		.id	= 1,
    		.dev	= {
    			.platform_data = &tw9910_link,
    		},
    	},
    };
    
    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };
    #endif
    
    extern void device_initialize(struct device *dev);
    static __init void da850_evm_init(void)
    {
    	int ret;
    
    	ret = da8xx_register_edma();
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    
    		ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    #if 0
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCBSP0) {
    		if (HAS_EMAC)
    			pr_warning("WARNING: both MCBSP0 and EMAC are "
    				"enabled, but they share pins.\n"
    				"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcbsp0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp0_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 registration"
    					"failed: %d\n",	ret);
    	}
    
    	if (HAS_MCBSP1) {
    		ret = da8xx_pinmux_setup(da850_mcbsp1_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp1_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 registration"
    					" failed: %d\n", ret);
    	}
    
    	if (HAS_MCASP) {
    		if ((HAS_MCBSP0 || HAS_MCBSP1))
    			pr_warning("WARNING: both McASP and McBSP are enabled, "
    					"but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed:"
    					"%d\n", ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    #endif	
    	
    
    #if 0
    	ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    #endif
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_register_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_spi1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: spi1 mux setup failed: %d\n",
    				ret);
    
    	da850_init_spi1(BIT(0), da850_spi_board_info,
    			ARRAY_SIZE(da850_spi_board_info));
    
    	da850_evm_usb_init();
    
    #if 0
    	ret = da8xx_register_sata();
    	if (ret)
    		pr_warning("da850_evm_init: SATA registration failed: %d\n",
    						ret);
    #endif
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    		else
    			printk("VPIF registered ok!\n");
    	}
    
    	if (!HAS_RMII && HAS_VPIF_CAPTURE) {
    		ret = da8xx_pinmux_setup(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    		//titus
    		platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));	
    		printk("tw9910_devices ok!\n");
    //		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF registration failed: "
    //					"%d\n",	ret);
    
    	}
    
    	if (0)//!HAS_GLCD && HAS_VPIF_DISPLAY) 
    	{
    		ret = da8xx_pinmux_setup(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    
    		ret = da850_register_vpif_display(&da850_vpif_display_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static __init void da850_evm_irq_init(void)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
    			soc_info->intc_irq_prios);
    }
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18xx EVM")
    	.phys_io	= IO_PHYS,
    	.io_pg_offst	= (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
    	.boot_params	= (DA8XX_DDR_BASE + 0x100),
    	.map_io		= da850_evm_map_io,
    	.init_irq	= da850_evm_irq_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    MACHINE_END
    

       Is da850_register_vpif_capture's param wrong? Or it is not need to do da850_register_vpif_capture?

       Can you give me tome time to help me? I really need your help!

        Thanks very much!

         

  • Hi,

    I will check your board file,

    mean while Can you please attach your complete bootup logs and .config file.

  • Hi,

    i2c_register_board_info(0, da850_evm_i2c_devices,
    ARRAY_SIZE(da850_evm_i2c_devices));    //is BUS_ID=0 right? I using BUS_ID=1  ???


    This will change as per the kernel versions,

    From this, I assume that you are using old kernel (2.6.37 or below)

    Correct me if I'm wrong.

    I have taken that board file from new kernel,

    In old kernel version the i2c bus is '0'

    In new kernel version the i2c bus is '1'

    Better to confirm in linux prompt shell and then choose and give your bus ID in board file,

    Try to check,

    target # ls /dev/i2c-0

    or

    target # ls /dev/i2c-1

  • Hi Titusrathinaraj:

        Thanks very much for your help!

        The all log is:

    Uncompressing Linux... done, booting the kernel.
    Linux version 2.6.33-rc4 (root@ubuntu) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #91 PREEMPT Thu Mar 27 21:44:30 HKT 2014
    CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
    CPU: VIVT data cache, VIVT instruction cache
    Machine: DaVinci DA850/OMAP-L138/AM18xx EVM
    Memory policy: ECC disabled, Data cache writeback
    DaVinci da850/omap-l138/am18xx variant 0x1
    Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
    Kernel command line: console=tty2,115200n8 noinitrd rw rootfstype=ext3 root=/dev/mmcblk0p2 rootwait mem=64M
    PID hash table entries: 256 (order: -2, 1024 bytes)
    Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
    Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
    Memory: 64MB = 64MB total
    Memory: 60408KB available (3992K code, 312K data, 148K init, 0K highmem)
    SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
    Hierarchical RCU implementation.
    NR_IRQS:245
    Console: colour dummy device 80x30
    Calibrating delay loop... 149.50 BogoMIPS (lpj=747520)
    Mount-cache hash table entries: 512
    CPU: Testing write buffer coherency: ok
    DaVinci: 144 gpio irqs
    NET: Registered protocol family 16
    VPIF registered ok!
    tw9910_devices ok!
    bio: create slab <bio-0> at 0
    SCSI subsystem initialized
    usbcore: registered new interface driver usbfs
    usbcore: registered new interface driver hub
    usbcore: registered new device driver usb
    i2c-gpio i2c-gpio.1: using pins 20 (SDA) and 21 (SCL)
    vpif vpif: vpif probe success
    Switching to clocksource timer0_1
    musb_hdrc: version 6.0, cppi4.1-dma, host, debug=0
    Waiting for USB PHY clock good...
    musb_hdrc: USB Host mode controller at fee00000 using DMA, IRQ 58
    musb_hdrc musb_hdrc: MUSB HDRC host driver
    musb_hdrc musb_hdrc: new USB bus registered, assigned bus number 1
    hub 1-0:1.0: USB hub found
    hub 1-0:1.0: 1 port detected
    NET: Registered protocol family 2
    IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
    TCP established hash table entries: 2048 (order: 2, 16384 bytes)
    TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
    TCP: Hash tables configured (established 2048 bind 2048)
    TCP reno registered
    UDP hash table entries: 256 (order: 0, 4096 bytes)
    UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
    NET: Registered protocol family 1
    RPC: Registered udp transport module.
    RPC: Registered tcp transport module.
    RPC: Registered tcp NFSv4.1 backchannel transport module.
    EMAC: MII PHY configured, RMII PHY will not be functional
    JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
    msgmni has been set to 118
    io scheduler noop registered (default)
    Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
    serial8250.0: ttyS0 at MMIO 0x1c42000 (irq = 25) is a 16550A
    serial8250.0: ttyS1 at MMIO 0x1d0c000 (irq = 53) is a 16550A
    serial8250.0: ttyS2 at MMIO 0x1d0d000 (irq = 61) is a 16550A
    console [ttyS2] enabled
    brd: module loaded
    spi_davinci spi_davinci.1: DaVinci SPI driver in EDMA mode
    Using RX channel = 18 , TX channel = 19 and event queue = 1
    m25p80 spi1.0: non-JEDEC variant of m25p64
    m25p80 spi1.0: m25p64 (8192 Kbytes)
    Creating 4 MTD partitions on "m25p80":
    0x000000000000-0x000000040000 : "U-Boot"
    0x000000040000-0x000000050000 : "U-Boot Environment"
    0x000000050000-0x0000007f0000 : "Linux"
    0x0000007f0000-0x000000800000 : "MAC Address"
    spi_davinci spi_davinci.1: Controller at 0xfef0e000 
    PPP generic driver version 2.4.2
    PPP Deflate Compression module registered
    PPP BSD Compression module registered
    console [netcon0] enabled
    netconsole: network logging started
    ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
    ohci ohci.0: DA8xx OHCI
    ohci ohci.0: new USB bus registered, assigned bus number 2
    ohci ohci.0: irq 59, io mem 0x01e25000
    hub 2-0:1.0: USB hub found
    hub 2-0:1.0: 1 port detected
    Initializing USB Mass Storage driver...
    usbcore: registered new interface driver usb-storage
    USB Mass Storage support registered.
    omap_rtc omap_rtc: rtc core: registered omap_rtc as rtc0
    omap_rtc: RTC power up reset detected
    i2c /dev entries driver
    Linux video capture interface: v2.00
    vpif_capture vpif_capture: Error registering v4l2 subdevice
    usbcore: registered new interface driver uvcvideo
    USB Video Class driver (v0.1.0)
    watchdog watchdog: heartbeat 60 sec
    cpuidle: using governor ladder
    cpuidle: using governor menu
    davinci_mmc davinci_mmc.0: Using DMA, 4-bit mode
    usbcore: registered new interface driver usbhid
    usbhid: USB HID core driver
    Advanced Linux Sound Architecture Driver Version 1.0.21.
    usbcore: registered new interface driver snd-usb-audio
    ALSA device list:
      No soundcards found.
    TCP cubic registered
    NET: Registered protocol family 17
    Clocks: disable unused i2c1
    Clocks: disable unused emac
    Clocks: disable unused mcasp
    Clocks: disable unused lcdc
    Clocks: disable unused aemif
    Clocks: disable unused spi0
    Clocks: disable unused mcbsp0
    Clocks: disable unused mcbsp1
    davinci_emac_probe: using random MAC addr: da:dc:05:62:d3:e5
    emac-mii: probed
    omap_rtc omap_rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
    Waiting for root device /dev/mmcblk0p2...
    mmc0: host does not support reading read-only switch. assuming write-enable.
    mmc0: new high speed SDHC card at address 1234
    mmcblk0: mmc0:1234 SA04G 3.63 GiB 
     mmcblk0: p1 p2
    EXT3-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended
    kjournald starting.  Commit interval 5 seconds
    EXT3-fs (mmcblk0p2): using internal journal
    EXT3-fs (mmcblk0p2): recovery complete
    EXT3-fs (mmcblk0p2): mounted filesystem with writeback data mode
    VFS: Mounted root (ext3 filesystem) on device 179:2.
    Freeing init memory: 148K
    INIT: version 2.86 booting
    Please wait: booting...
    Starting udev
    Remounting root file system...
    logger: mount: mount point /proc/bus/usb does not exist
    Configuring network interfaces... eth0: no PHY found
    ifconfig: SIOCSIFFLAGS: Operation not permitted
    done.
    Setting up IP spoofing protection: rp_filter.
    Thu Jan 13 02:20:00 UTC 2011
    INIT: Entering runlevel: 5
    Starting telnet daemon.
    Starting syslogd/klogd: done
    Starting thttpdNET: Registered protocol family 10
    .
    CMEMK module: built on Mar 18 2014 at 11:45:10
      Reference Linux version 2.6.33
      File /work/dvsdk/linuxutils_2_25_05_11/packages/ti/sdo/linuxutils/cmem/src/module/cmemk.c
    phys_end_kernel=0xc4000000 block_start[0]=0xc2000000
    CMEM Range Overlaps Kernel Physical - allowing overlap
    CMEM phys_start (0xc2000000) overlaps kernel (0xc0000000 -> 0xc4000000)
    CMEMK Error: Failed to request_mem_region(0xc2000000, 18874368)
    FATAL: Error inserting cmemk (/lib/modules/2.6.33-rc4/kernel/drivers/dsp/cmemk.ko): Bad address
    DSPLINK Module (1.65.00.02) created on Date: Jan 13 2011 Time: 01:20:38
    
     _____                    _____           _         _   
    |  _  |___ ___ ___ ___   |  _  |___ ___  |_|___ ___| |_ 
    |     |  _| .'| . | . |  |   __|  _| . | | | -_|  _|  _|
    |__|__|_| |__,|_  |___|  |__|  |_| |___|_| |___|___|_|  
                  |___|                    |___|            
    
    Arago Project http://arago-project.org arago ttyS2
    
    Arago 2010.11 arago ttyS2
    
    arago login: 

        The .Config file is:

     

     

         In /dev directory, there is exist i2c-1 only!

         Thanks.

        

  • Hi,

         In /dev directory, there is exist i2c-1 only!


    I think then you need to use "1" only,

    Why you are not using latest linux SDK of OMAPL138?

    Who do you commented out the below line from your board file ?

        //i2c_register_board_info(1, da850_evm_i2c_devices,
        //        ARRAY_SIZE(da850_evm_i2c_devices));
        i2c_register_board_info(0, da850_evm_i2c_devices,
                ARRAY_SIZE(da850_evm_i2c_devices));


    Have you tried before passing the bus ID of i2c  as  ' 1' ?

    Try to pass "1" for bus ID of i2c and me the logs too.

    PFA of latest board file and  don't change anything just use and provide me the kernel bootup logs.

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/delay.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/regulator/machine.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/usb/musb.h>
    #include <linux/i2c-gpio.h>
    
    #include <media/tw9910.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <mach/flash.h>
    #include <mach/vpif.h>
    
    #include <media/tvp514x.h>
    
    #define DA850_EVM_PHY_MASK		0x1
    #define DA850_EVM_MDIO_FREQUENCY	2200000 /* PHY bus frequency */
    
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)	
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)
    #ifdef CONFIG_SOC_CAMERA_TW9900
    #define CAMERA_CH0		"tw9900-0"
    #define CAMERA_CH1		"tw9900-1"
    #else
    #define CAMERA_CH0		"tw9910-0"
    #define CAMERA_CH1		"tw9910-1"
    #endif
    #else
    #define CAMERA_CH0		"tvp514x-0"
    #define CAMERA_CH1		"tvp514x-1"
    #endif
    
    #define VPIF_STATUS	(0x002C)
    #define VPIF_STATUS_CLR	(0x0030)
    #define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4)
    #define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13)
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_2M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct davinciflash_pdata da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_norflash_device = {
    	.name		= "davinci-flash",
    	.id		= 0,
    	.dev		= {
    		.platform_data  = &da850_evm_norflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_norflash_resource),
    	.resource	= da850_evm_norflash_resource,
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= 0x200000,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.options	= NAND_USE_FLASH_BBT,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_nandflash_device = {
    	.name		= "davinci_nand",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_evm_nandflash_data,
    	},
    	.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    	.resource	= da850_evm_nandflash_resource,
    };
    
    static struct platform_device *da850_evm_devices[] __initdata = {
    	&da850_evm_nandflash_device,
    	&da850_evm_norflash_device,
    };
    
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_CE3CFG_OFFSET	0x14
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static struct mtd_partition spi_flash_partitions[] = {
    	[0] = {
    		.name = "U-Boot",
    		.offset = 0,
    		.size = SZ_256K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot Environment",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "Linux",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_8M - (SZ_256K + SZ_64K + SZ_64K),
    		.mask_flags = 0,
    	},
    	[3] = {
    		.name = "MAC Address",
    		.offset = MTDPART_OFS_NXTBLK,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    		.setup = davinci_get_mac_addr,
    		.context = (void *)0,
    	},
    };
    
    static struct flash_platform_data spi_flash_data = {
    	.name = "m25p80",
    	.parts = spi_flash_partitions,
    	.nr_parts = ARRAY_SIZE(spi_flash_partitions),
    	.type = "m25p64",
    };
    
    static struct spi_board_info da850_spi_board_info[] = {
    	[0] = {
    		.modalias = "m25p80",
    		.platform_data = &spi_flash_data,
    		.mode = SPI_MODE_0,
    		.max_speed_hz = 30000000,       /* max sample rate at 3V */
    		.bus_num = 1,
    		.chip_select = 0,
    	},
    };
    
    static u32 ui_card_detected;
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    static void __init da850_evm_init_nand(void)
    {
    	void __iomem *aemif_addr;
    	u32 ce3cfg;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	ce3cfg = 0
    		| (0 << 31)	/* selectStrobe */
    		| (0 << 30)	/* extWait */
    		| (0 << 26)	/* writeSetup */
    		| (3 << 20)	/* writeStrobe  30 ns */
    		| (3 << 17)	/* writeHold    30 ns */
    		| (2 << 13)	/* readSetup    20 ns */
    		| (4 << 7)	/* readStrobe   40 ns */
    		| (0 << 4)	/* readHold */
    		| (0 << 2)	/* turnAround */
    		| (0 << 0)	/* asyncSize    8-bit bus */
    		;
    
    	writel(ce3cfg, aemif_addr + DA8XX_AEMIF_CE3CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    
    static __init void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    //	if (ui_card_detected & !HAS_MMC) {
    		ret = da8xx_pinmux_setup(da850_nand_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nand mux setup failed: "
    					"%d\n", ret);
    
    		da850_evm_init_nand();
    
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    /*
    		// Driver GP0[11] low for NOR to work 
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = da8xx_pinmux_setup(da850_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    */
    		
    		platform_add_devices(da850_evm_devices,
    					ARRAY_SIZE(da850_evm_devices));
    //	}
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value(a, 0);
    	gpio_set_value(b, 0);
    	gpio_set_value(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + 7;
    	sel_b = gpio + 6;
    	sel_c = gpio + 5;
    
    	ret = gpio_request(sel_a, "sel_a");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, "sel_b");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, "sel_c");
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	ui_card_detected = 1;
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	return 0;
    
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	/* deselect all functionalities */
    	gpio_set_value(gpio + 5, 1);
    	gpio_set_value(gpio + 6, 1);
    	gpio_set_value(gpio + 7, 1);
    
    	gpio_free(gpio + 5);
    	gpio_free(gpio + 6);
    	gpio_free(gpio + 7);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    };
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1380000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = (void *) 1,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    };
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.eventq_no	= EVENTQ_1,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp0_config = {
    	.inst	= 0,
    };
    
    static struct davinci_mcbsp_platform_data da850_mcbsp1_config = {
    	.inst	= 1,
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE,
    //	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    //				  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	void __iomem *cfg_mstpri2_base;
    	int status;
    	u32 val;
    
    	/*
    	 * Reconfigure the LCDC priority to the highest to ensure that
    	 * the throughput/latency requirements for the LCDC are met.
    	 */
    	cfg_mstpri2_base = DA8XX_SYSCFG0_VIRT(DA8XX_MSTPRI2_REG);
    
    	val = __raw_readl(cfg_mstpri2_base);
    	val &= 0x0fffffff;
    	__raw_writel(val, cfg_mstpri2_base);
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = da8xx_pinmux_setup(da850_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = da8xx_pinmux_setup(da850_cpgmac_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
    	soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    
    //#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    #define CAMERA_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    
    /* Titus Debug: Disable the all config and add only the camera */
    
    	{
    		.name	= "tw9910",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = (void *)1,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER, /* Titus Debug : Need to try 'VPIF_IF_BT656' or 'VPIF_IF_BT1120' */
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    
    
    
    
    #if 0
    	{
    		.name	= CAMERA_CH0,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x45),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= CAMERA_CH1,
    #if defined(CONFIG_SOC_CAMERA_TW9900) || defined(CONFIG_SOC_CAMERA_TW9910)			
    #if defined(CONFIG_SOC_CAMERA_TW9900)
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x44),
    			.platform_data = &tvp5146_pdata,
    		},
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x44),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    #else
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    #endif		
    		.input = INPUT_SVIDEO_VI2C_VI1C,		///HUANYI_SYSTEM Test
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
           {
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL,
    		},
    		.subdev_name = CAMERA_CH1,
    	},
    };
    
    /* Titus Debug : CH2 for TW9910 camera */
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = CAMERA_STD_ALL
    		},
    		.subdev_name = "tw9910",
    	},
    };
    
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    
    /* Titus Debug : Camera */
    /* TODO : Need to add condition for TW9910 : #if defined(CONFIG_SOC_CAMERA_TW9910) */
    
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    
    
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_DAVINCI_MCBSP0)
    #define HAS_MCBSP0 1
    #else
    #define HAS_MCBSP0 0
    #endif
    
    #if defined(CONFIG_DAVINCI_MCBSP1)
    #define HAS_MCBSP1 1
    #else
    #define HAS_MCBSP1 0
    #endif
    
    #if defined(CONFIG_TI_DAVINCI_EMAC) || \
    	defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
    #define HAS_EMAC 1
    #else
    #define HAS_EMAC 0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DA850_UI_RMII) && (HAS_EMAC)
    #define HAS_RMII 1
    #else
    #define HAS_RMII 0
    #endif
    
    #if defined(CONFIG_DA850_UI_LCD) && defined(CONFIG_FB_DA8XX) ||\
    		defined(CONFIG_FB_DA8XX_MODULE)
    #define HAS_GLCD 1
    #else
    #define HAS_GLCD 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    static da8xx_ocic_handler_t da850_evm_usb_ocic_handler;
    
    static int da850_evm_usb_set_power(unsigned port, int on)
    {
    	gpio_set_value(DA850_USB1_VBUS_PIN, on);
    	return 0;
    }
    
    static int da850_evm_usb_get_power(unsigned port)
    {
    	return gpio_get_value(DA850_USB1_VBUS_PIN);
    }
    
    static int da850_evm_usb_get_oci(unsigned port)
    {
    	return !gpio_get_value(DA850_USB1_OC_PIN);
    }
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static int da850_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
    {
    	int irq 	= gpio_to_irq(DA850_USB1_OC_PIN);
    	int error	= 0;
    
    	if (handler != NULL) {
    		da850_evm_usb_ocic_handler = handler;
    
    		error = request_irq(irq, da850_evm_usb_ocic_irq, IRQF_DISABLED |
    				    IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
    				    "OHCI over-current indicator", NULL);
    		if (error)
    			printk(KERN_ERR "%s: could not request IRQ to watch "
    			       "over-current indicator changes\n", __func__);
    	} else
    		free_irq(irq, NULL);
    
    	return error;
    }
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.set_power	= da850_evm_usb_set_power,
    	.get_power	= da850_evm_usb_get_power,
    	.get_oci	= da850_evm_usb_get_oci,
    	.ocic_notify	= da850_evm_usb_ocic_notify,
    
    	/* TPS2065 switch @ 5V */
    	.potpgt		= (3 + 1) / 2,	/* 3 ms max */
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *dev_id)
    {
    	da850_evm_usb_ocic_handler(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static struct musb_hdrc_platform_data usb_evm_data[] = {
    	{
    #ifdef CONFIG_USB_MUSB_OTG
    		.mode = MUSB_OTG,
    #elif defined(CONFIG_USB_MUSB_DUAL_ROLE)
    		.mode = MUSB_DUAL_ROLE,
    #elif defined(CONFIG_USB_MUSB_PERIPHERAL)
    		.mode =  MUSB_PERIPHERAL,
    #elif defined(CONFIG_USB_MUSB_HOST)
    		.mode = MUSB_HOST,
    #endif
    		.power = 255,
    		.potpgt = 8,
    		.set_vbus = NULL, /* VBUs is directly controlled by the IP */
    	}
    };
    
    static __init void da850_evm_usb_init(void)
    {
    	int ret;
    	u32 cfgchip2;
    
    	/*
    	 * Setup the Ref. clock frequency for the EVM at 24 MHz.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	da8xx_usb20_configure(usb_evm_data, ARRAY_SIZE(usb_evm_data));
    
    	ret = da8xx_pinmux_setup(da850_evm_usb11_pins);
    	if (ret) {
    		pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
    			   __func__, ret);
    		return;
    	}
    
    	ret = gpio_request(DA850_USB1_VBUS_PIN, "USB1 VBUS\n");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "power control: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_output(DA850_USB1_VBUS_PIN, 0);
    
    	ret = gpio_request(DA850_USB1_OC_PIN, "USB1 OC");
    	if (ret) {
    		printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
    		       "over-current indicator: %d\n", __func__, ret);
    		return;
    	}
    	gpio_direction_input(DA850_USB1_OC_PIN);
    
    	ret = da8xx_register_usb11(&da850_evm_usb11_pdata);
    	if (ret)
    		pr_warning("%s: USB 1.1 registration failed: %d\n",
    			   __func__, ret);
    }
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    
    	ret = da8xx_register_edma();
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    
    		ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	//i2c_register_board_info(1, da850_evm_i2c_devices,
    	//		ARRAY_SIZE(da850_evm_i2c_devices));
    
    /* Titus Debug: Need to pass '1' or '0' bus ID of i2c vice versa */
    
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCBSP0) {
    		if (HAS_EMAC)
    			pr_warning("WARNING: both MCBSP0 and EMAC are "
    				"enabled, but they share pins.\n"
    				"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcbsp0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp0_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp0 registration"
    					"failed: %d\n",	ret);
    	}
    
    	if (HAS_MCBSP1) {
    		ret = da8xx_pinmux_setup(da850_mcbsp1_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 mux setup failed:"
    					" %d\n", ret);
    
    		ret = da850_init_mcbsp(&da850_mcbsp1_config);
    		if (ret)
    			pr_warning("da850_evm_init: mcbsp1 registration"
    					" failed: %d\n", ret);
    	}
    
    	if (HAS_MCASP) {
    		if ((HAS_MCBSP0 || HAS_MCBSP1))
    			pr_warning("WARNING: both McASP and McBSP are enabled, "
    					"but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = da8xx_pinmux_setup(da850_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed:"
    					"%d\n", ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = da8xx_pinmux_setup(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_register_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	ret = da8xx_pinmux_setup(da850_spi1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: spi1 mux setup failed: %d\n",
    				ret);
    
    	da850_init_spi1(BIT(0), da850_spi_board_info,
    			ARRAY_SIZE(da850_spi_board_info));
    
    	da850_evm_usb_init();
    
    	ret = da8xx_register_sata();
    	if (ret)
    		pr_warning("da850_evm_init: SATA registration failed: %d\n",
    						ret);
    
    /* Titus Debug : VPIF has been enabled by default and condition compilation removed */
    
    //	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    
    		ret = da850_register_vpif();
    		if (ret)
    			{
    			printk("##### TI E2E probe5 ######  da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    			}
    		else
    			{
    			printk("##### TI E2E probe6 ######  da850_evm_init: VPIF registration success: "
    					"%d\n",	ret);
    			}
    
    			
    //	}
    
    
    
    
    /* Titus Debug : Checking whether the VPIF reg happenening */
    
    //	if (!HAS_RMII && HAS_VPIF_CAPTURE) {
    
    		ret = da8xx_pinmux_setup(da850_vpif_capture_pins);
    		if (ret)
    			{
    			printk("##### TI E2E probe1 ######  da850_evm_init: vpif capture mux failed: "
    					"%d\n",	ret);
    			}
    		else
    			{
    			printk("##### TI E2E probe2 ######  da850_evm_init: vpif capture mux success: "
    					"%d\n",	ret);
    			}
    
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			{
    			printk("##### TI E2E probe3 ######  da850_evm_init: VPIF registration failed: "
    					"%d\n",	ret);
    			}
    		else
    			{
    			printk("##### TI E2E probe4 ######  da850_evm_init: VPIF registration success: "
    					"%d\n",	ret);
    			}
    
    
    //	}
    
    
    /* Titus Debug : VPIF display totally including pinmux & config */
    
    //	if (!HAS_GLCD && HAS_VPIF_DISPLAY) {
    //		ret = da8xx_pinmux_setup(da850_vpif_display_pins);
    //		if (ret)
    //			pr_warning("da850_evm_init: vpif capture mux failed: "
    //					"%d\n",	ret);
    
    //		ret = da850_register_vpif_display(&da850_vpif_display_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF registration failed: "
    //					"%d\n",	ret);
    
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static __init void da850_evm_irq_init(void)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
    			soc_info->intc_irq_prios);
    }
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18xx EVM")
    	.phys_io	= IO_PHYS,
    	.io_pg_offst	= (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
    	.boot_params	= (DA8XX_DDR_BASE + 0x100),
    	.map_io		= da850_evm_map_io,
    	.init_irq	= da850_evm_irq_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    MACHINE_END
    

    Please just refer these links for TW9910 but different board and interface too.

    https://gitorious.org/efikamx/linux-kernel/source/ba3a17019181af5d6ab898760620c4e9916396c2:arch/sh/boards/mach-migor/setup.c#L54

    http://marc.info/?l=linux-sh&m=126085544224243

     

  • Hi Titusrathinaraj:

        Thanks very very much! As I waste your much more time!

        Now I use version: 03.22.00.02

         But in my board, there is not chip:  pca9543a. 

         My new board-da850-evm.c file is:

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/clk.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/input.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/gpio_keys.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/mtd/physmap.h>
    #include <linux/regulator/machine.h>
    #include <linux/regulator/tps6507x.h>
    #include <linux/input/tps6507x-ts.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/delay.h>
    #include <linux/wl12xx.h>
    #include <linux/pwm_backlight.h>
    #include <linux/i2c-gpio.h>
    #include <linux/videodev2.h>
    #include <linux/module.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <linux/mfd/davinci_aemif.h>
    #include <mach/spi.h>
    #include <mach/usb.h>
    #include <media/tvp514x.h>
    #include <media/davinci/vpif_types.h>
    
    #include <media/tw9910.h>
    
    #define DA850_EVM_PHY_ID		"davinci_mdio-0:00"
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_WLAN_EN			GPIO_TO_PIN(6, 9)
    #define DA850_WLAN_IRQ			GPIO_TO_PIN(6, 10)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #define DAVINCI_BACKLIGHT_MAX_BRIGHTNESS	250
    #define DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS	250
    #define DAVINCI_PWM_PERIOD_NANO_SECONDS		10000000
    
    
    static struct platform_pwm_backlight_data da850evm_backlight_data = {
    	.max_brightness	= DAVINCI_BACKLIGHT_MAX_BRIGHTNESS,
    	.dft_brightness	= DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS,
    	.pwm_period_ns	= DAVINCI_PWM_PERIOD_NANO_SECONDS,
    };
    
    static struct platform_device da850evm_backlight = {
    	.name		= "pwm-backlight",
    	.id		= -1,
    };
    
    static struct mtd_partition da850evm_spiflash_part[] = {
    	[0] = {
    		.name = "UBL",
    		.offset = 0,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_512K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "U-Boot-Env",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[3] = {
    		.name = "Kernel",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_2M + SZ_512K,
    		.mask_flags = 0,
    	},
    	[4] = {
    		.name = "Filesystem",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_4M,
    		.mask_flags = 0,
    	},
    	[5] = {
    		.name = "MAC-Address",
    		.offset = SZ_8M - SZ_64K,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    };
    
    static struct flash_platform_data da850evm_spiflash_data = {
    	.name		= "m25p80",
    	.parts		= da850evm_spiflash_part,
    	.nr_parts	= ARRAY_SIZE(da850evm_spiflash_part),
    	.type		= "m25p64",
    };
    
    static struct davinci_spi_config da850evm_spiflash_cfg = {
    	.io_type	= SPI_IO_TYPE_DMA,
    	.c2tdelay	= 8,
    	.t2cdelay	= 8,
    };
    
    static struct spi_board_info da850evm_spi_info[] = {
    	{
    		.modalias		= "m25p80",
    		.platform_data		= &da850evm_spiflash_data,
    		.controller_data	= &da850evm_spiflash_cfg,
    		.mode			= SPI_MODE_0,
    		.max_speed_hz		= 30000000,
    		.bus_num		= 1,
    		.chip_select		= 0,
    	},
    };
    
    #define TVP5147_CH0		"tvp514x-0"
    #define TVP5147_CH1		"tvp514x-1"
    
    #define VPIF_STATUS		0x002c
    #define VPIF_STATUS_CLR		0x0030
    
    #ifdef CONFIG_MTD
    static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
    {
    	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
    	size_t retlen;
    
    	if (!strcmp(mtd->name, "MAC-Address")) {
    		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
    		if (retlen == ETH_ALEN)
    			pr_info("Read MAC addr from SPI Flash: %pM\n",
    				mac_addr);
    	}
    }
    
    static struct mtd_notifier da850evm_spi_notifier = {
    	.add	= da850_evm_m25p80_notify_add,
    };
    
    static void da850_evm_setup_mac_addr(void)
    {
    	register_mtd_user(&da850evm_spi_notifier);
    }
    #else
    static void da850_evm_setup_mac_addr(void) { }
    #endif
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_4M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct physmap_flash_data da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    static struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.bbt_options	= NAND_BBT_USE_FLASH,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_devices[] = {
    	{
    		.name		= "davinci_nand",
    		.id		= 1,
    		.dev		= {
    			.platform_data	= &da850_evm_nandflash_data,
    		},
    		.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    		.resource	= da850_evm_nandflash_resource,
    	},
    #if !defined(CONFIG_MMC_DAVINCI) || \
        !defined(CONFIG_MMC_DAVINCI_MODULE)
    	{
    		.name		= "physmap-flash",
    		.id		= 0,
    		.dev		= {
    			.platform_data  = &da850_evm_norflash_data,
    		},
    		.num_resources	= 1,
    		.resource	= da850_evm_norflash_resource,
    
    	},
    #endif
    };
    static struct davinci_aemif_devices da850_emif_devices = {
    	.devices	= da850_evm_devices,
    	.num_devices	= ARRAY_SIZE(da850_evm_devices),
    };
    
    static struct platform_device davinci_emif_device = {
    	.name	= "davinci_aemif",
    	.id	= -1,
    	.dev	= {
    		.platform_data	= &da850_emif_devices,
    	},
    };
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static void __init da850_evm_init_nor(void)
    {
    	void __iomem *aemif_addr;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	/* Configure data bus width of CS2 to 16 bit */
    	writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
    		DA8XX_AEMIF_ASIZE_16BIT,
    		aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    static const short da850_evm_nand_pins[] = {
    	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
    	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
    	DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
    	DA850_NEMA_WE, DA850_NEMA_OE,
    	-1
    };
    
    static const short da850_evm_nor_pins[] = {
    	DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
    	DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
    	DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
    	DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
    	DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
    	DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
    	DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
    	DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
    	DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
    	DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
    	DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
    	DA850_EMA_A_22, DA850_EMA_A_23,
    	-1
    };
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    #if defined(CONFIG_SPI_DAVINCI)
    #define HAS_SPI 1
    #else
    #define HAS_SPI 0
    #endif
    
    #if defined(CONFIG_FB_DA8XX)
    #define HAS_LCD	1
    #else
    #define HAS_LCD	0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DAVINCI_EHRPWM) || defined(CONFIG_DAVINCI_EHRPWM_MODULE)
    #define HAS_EHRPWM 1
    #else
    #define HAS_EHRPWM 0
    #endif
    
    #if defined(CONFIG_ECAP_PWM) || \
    	defined(CONFIG_ECAP_PWM_MODULE)
    #define HAS_ECAP_PWM 1
    #else
    #define HAS_ECAP_PWM 0
    #endif
    
    #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
    #define HAS_BACKLIGHT 1
    #else
    #define HAS_BACKLIGHT 0
    #endif
    
    #if defined(CONFIG_ECAP_CAP) || defined(CONFIG_ECAP_CAP_MODULE)
    #define HAS_ECAP_CAP 1
    #else
    #define HAS_ECAP_CAP 0
    #endif
    
    /* have_imager() - Check if we have support for imager interface */
    static inline int have_imager(void)
    {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	return 1;
    #else
    	return 0;
    #endif
    }
    
    static inline void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    	ret = davinci_cfg_reg_list(da850_evm_nand_pins);
    	if (ret)
    		pr_warning("da850_evm_init: nand mux setup failed: "
    				"%d\n", ret);
    
    	if (!HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] low for NOR to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = davinci_cfg_reg_list(da850_evm_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    
    		da850_evm_init_nor();
    	} else {
    		/*
    		 * On Logic PD Rev.3 EVMs GP0[11] pin needs to be configured
    		 * for MMC and NOR to work. When GP0[11] is low, the SD0
    		 * interface will not work, but NOR flash will. When GP0[11]
    		 * is high, SD0 will work but NOR flash will not. By default
    		 * we are assuming that GP0[11] pin is driven high, when UI
    		 * card is not connected. Hence we are not configuring the
    		 * GP0[11] pin when MMC/SD is enabled and UI card is not
    		 * connected. Not configuring the GPIO pin will enable the
    		 * bluetooth to work on AM18x as it requires the GP0[11]
    		 * pin for UART flow control.
    		 */
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    	}
    
    	platform_device_register(&davinci_emif_device);
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value_cansleep(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    
    #define DA850_KEYS_DEBOUNCE_MS	10
    /*
     * At 200ms polling interval it is possible to miss an
     * event by tapping very lightly on the push button but most
     * pushes do result in an event; longer intervals require the
     * user to hold the button whereas shorter intervals require
     * more CPU time for polling.
     */
    #define DA850_GPIO_KEYS_POLL_MS	200
    
    enum da850_evm_ui_exp_pins {
    	DA850_EVM_UI_EXP_SEL_C = 5,
    	DA850_EVM_UI_EXP_SEL_B,
    	DA850_EVM_UI_EXP_SEL_A,
    	DA850_EVM_UI_EXP_PB8,
    	DA850_EVM_UI_EXP_PB7,
    	DA850_EVM_UI_EXP_PB6,
    	DA850_EVM_UI_EXP_PB5,
    	DA850_EVM_UI_EXP_PB4,
    	DA850_EVM_UI_EXP_PB3,
    	DA850_EVM_UI_EXP_PB2,
    	DA850_EVM_UI_EXP_PB1,
    };
    
    static const char const *da850_evm_ui_exp[] = {
    	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c",
    	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b",
    	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a",
    	[DA850_EVM_UI_EXP_PB8]          = "pb8",
    	[DA850_EVM_UI_EXP_PB7]          = "pb7",
    	[DA850_EVM_UI_EXP_PB6]          = "pb6",
    	[DA850_EVM_UI_EXP_PB5]          = "pb5",
    	[DA850_EVM_UI_EXP_PB4]          = "pb4",
    	[DA850_EVM_UI_EXP_PB3]          = "pb3",
    	[DA850_EVM_UI_EXP_PB2]          = "pb2",
    	[DA850_EVM_UI_EXP_PB1]          = "pb1",
    };
    
    #define DA850_N_UI_PB		8
    
    static struct gpio_keys_button da850_evm_ui_keys[] = {
    	[0 ... DA850_N_UI_PB - 1] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
    	.buttons = da850_evm_ui_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_ui_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 0,
    	.dev = {
    		.platform_data = &da850_evm_ui_keys_pdata
    	},
    };
    
    static void da850_evm_ui_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	for (i = 0; i < DA850_N_UI_PB; i++) {
    		button = &da850_evm_ui_keys[i];
    		button->code = KEY_F8 - i;
    		button->desc = (char *)
    				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
    		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
    	}
    }
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value_cansleep(a, 0);
    	gpio_set_value_cansleep(b, 0);
    	gpio_set_value_cansleep(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value_cansleep(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CAMERA
    static inline void da850_evm_setup_camera(int camera_sel)
    {
    	gpio_set_value_cansleep(camera_sel, 0);
    }
    #else
    static inline void da850_evm_setup_camera(int camera_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
    	sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
    	sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
    
    	ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	da850_evm_ui_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_ui_keys_device);
    	if (ret) {
    		pr_warning("Could not register UI GPIO expander push-buttons");
    		goto exp_setup_keys_fail;
    	}
    
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	da850_evm_setup_camera(sel_b);
    
    	return 0;
    
    exp_setup_keys_fail:
    	gpio_free(sel_c);
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_ui_keys_device);
    
    	/* deselect all functionalities */
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
    
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
    
    	return 0;
    }
    
    /* assign the baseboard expander's GPIOs after the UI board's */
    #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
    #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
    
    enum da850_evm_bb_exp_pins {
    	DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
    	DA850_EVM_BB_EXP_SW_RST,
    	DA850_EVM_BB_EXP_TP_23,
    	DA850_EVM_BB_EXP_TP_22,
    	DA850_EVM_BB_EXP_TP_21,
    	DA850_EVM_BB_EXP_USER_PB1,
    	DA850_EVM_BB_EXP_USER_LED2,
    	DA850_EVM_BB_EXP_USER_LED1,
    	DA850_EVM_BB_EXP_USER_SW1,
    	DA850_EVM_BB_EXP_USER_SW2,
    	DA850_EVM_BB_EXP_USER_SW3,
    	DA850_EVM_BB_EXP_USER_SW4,
    	DA850_EVM_BB_EXP_USER_SW5,
    	DA850_EVM_BB_EXP_USER_SW6,
    	DA850_EVM_BB_EXP_USER_SW7,
    	DA850_EVM_BB_EXP_USER_SW8
    };
    
    static const char const *da850_evm_bb_exp[] = {
    	[DA850_EVM_BB_EXP_DEEP_SLEEP_EN]	= "deep_sleep_en",
    	[DA850_EVM_BB_EXP_SW_RST]		= "sw_rst",
    	[DA850_EVM_BB_EXP_TP_23]		= "tp_23",
    	[DA850_EVM_BB_EXP_TP_22]		= "tp_22",
    	[DA850_EVM_BB_EXP_TP_21]		= "tp_21",
    	[DA850_EVM_BB_EXP_USER_PB1]		= "user_pb1",
    	[DA850_EVM_BB_EXP_USER_LED2]		= "user_led2",
    	[DA850_EVM_BB_EXP_USER_LED1]		= "user_led1",
    	[DA850_EVM_BB_EXP_USER_SW1]		= "user_sw1",
    	[DA850_EVM_BB_EXP_USER_SW2]		= "user_sw2",
    	[DA850_EVM_BB_EXP_USER_SW3]		= "user_sw3",
    	[DA850_EVM_BB_EXP_USER_SW4]		= "user_sw4",
    	[DA850_EVM_BB_EXP_USER_SW5]		= "user_sw5",
    	[DA850_EVM_BB_EXP_USER_SW6]		= "user_sw6",
    	[DA850_EVM_BB_EXP_USER_SW7]		= "user_sw7",
    	[DA850_EVM_BB_EXP_USER_SW8]		= "user_sw8",
    };
    
    #define DA850_N_BB_USER_SW	8
    
    static struct gpio_keys_button da850_evm_bb_keys[] = {
    	[0] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= KEY_PROG1,
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    	[1 ... DA850_N_BB_USER_SW] = {
    		.type			= EV_SW,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
    	.buttons = da850_evm_bb_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_bb_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 1,
    	.dev = {
    		.platform_data = &da850_evm_bb_keys_pdata
    	},
    };
    
    static void da850_evm_bb_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	button = &da850_evm_bb_keys[0];
    	button->desc = (char *)
    		da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
    	button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
    
    	for (i = 0; i < DA850_N_BB_USER_SW; i++) {
    		button = &da850_evm_bb_keys[i + 1];
    		button->code = SW_LID + i;
    		button->desc = (char *)
    				da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
    		button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
    	}
    }
    
    #define DA850_N_BB_USER_LED	2
    
    static struct gpio_led da850_evm_bb_leds[] = {
    	[0 ... DA850_N_BB_USER_LED - 1] = {
    		.active_low = 1,
    		.gpio = -1, /* assigned at runtime */
    		.name = NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
    	.leds = da850_evm_bb_leds,
    	.num_leds = ARRAY_SIZE(da850_evm_bb_leds),
    };
    
    static struct platform_device da850_evm_bb_leds_device = {
    	.name		= "leds-gpio",
    	.id		= -1,
    	.dev = {
    		.platform_data = &da850_evm_bb_leds_pdata
    	}
    };
    
    static void da850_evm_bb_leds_init(unsigned gpio)
    {
    	int i;
    	struct gpio_led *led;
    
    	for (i = 0; i < DA850_N_BB_USER_LED; i++) {
    		led = &da850_evm_bb_leds[i];
    
    		led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
    		led->name =
    			da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
    	}
    }
    
    static int da850_evm_bb_expander_setup(struct i2c_client *client,
    						unsigned gpio, unsigned ngpio,
    						void *c)
    {
    	int ret;
    
    	/*
    	 * Register the switches and pushbutton on the baseboard as a gpio-keys
    	 * device.
    	 */
    	da850_evm_bb_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_keys_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander keys");
    		goto io_exp_setup_sw_fail;
    	}
    
    	da850_evm_bb_leds_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_leds_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander LEDS");
    		goto io_exp_setup_leds_fail;
    	}
    
    	return 0;
    
    io_exp_setup_leds_fail:
    	platform_device_unregister(&da850_evm_bb_keys_device);
    io_exp_setup_sw_fail:
    	return ret;
    }
    
    static int da850_evm_bb_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_bb_leds_device);
    	platform_device_unregister(&da850_evm_bb_keys_device);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    	.names		= da850_evm_ui_exp,
    };
    
    static struct pca953x_platform_data da850_evm_bb_expander_info = {
    	.gpio_base	= DA850_BB_EXPANDER_GPIO_BASE,
    	.setup		= da850_evm_bb_expander_setup,
    	.teardown	= da850_evm_bb_expander_teardown,
    	.names		= da850_evm_bb_exp,
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    /*
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x21),
    		.platform_data = &da850_evm_bb_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    	{
    		I2C_BOARD_INFO("PCA9543A", 0x73),
    	},
    */	
    	{
    		I2C_BOARD_INFO("tw9910", 0x45),
    	},
    };
    
    /*
     * USB1 VBUS is controlled by GPIO2[4], over-current is reported on GPIO6[13].
     */
    #define ON_BD_USB_DRV	GPIO_TO_PIN(2, 4)
    #define ON_BD_USB_OVC	GPIO_TO_PIN(6, 13)
    
    static const short da850_evm_usb11_pins[] = {
    	DA850_GPIO2_4, DA850_GPIO6_13,
    	-1
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.type			= GPIO_BASED,
    	.method	= {
    		.gpio_method = {
    			.power_control_pin	= ON_BD_USB_DRV,
    			.over_current_indicator = ON_BD_USB_OVC,
    		},
    	},
    	.board_ocic_handler	= da850_evm_usb_ocic_irq,
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *handler)
    {
    	if (handler != NULL)
    		((da8xx_ocic_handler_t)handler)(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static __init void da850_evm_usb_init(void)
    {
    	u32 cfgchip2;
    	int ret;
    
    	/*
    	 * Set up USB clock/mode in the CFGCHIP2 register.
    	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/* USB2.0 PHY reference clock is 24 MHz */
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    
    	/*
    	 * Select internal reference clock for USB 2.0 PHY
    	 * and use it as a clock source for USB 1.1 PHY
    	 * (this is the default setting anyway).
    	 */
    	cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
    	cfgchip2 |=  CFGCHIP2_USB2PHYCLKMUX;
    	/*
    	 * We have to override VBUS/ID signals when MUSB is configured into the
    	 * host-only mode -- ID pin will float if no cable is connected, so the
    	 * controller won't be able to drive VBUS thinking that it's a B-device.
    	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
    	 */
    	cfgchip2 &= ~CFGCHIP2_OTGMODE;
    	cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
    
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/*
    	 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
    	 * with the power on to power good time of 3 ms.
    	 */
    	ret = da8xx_register_usb20(1000, 3);
    	if (ret)
    		pr_warning("%s: USB 2.0 registration failed: %d\n",
    			   __func__, ret);
    
    	/* initilaize usb module */
    	da8xx_board_usb_init(da850_evm_usb11_pins, &da850_evm_usb11_pdata);
    }
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.asp_chan_q	= EVENTQ_0,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static const short da850_evm_mcasp_pins[] __initconst = {
    	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
    	DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
    	DA850_AXR_11, DA850_AXR_12,
    	-1
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_evm_mmcsd0_pins[] __initconst = {
    	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
    	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
    	DA850_GPIO4_0, DA850_GPIO4_1,
    	-1
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value_cansleep(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value_cansleep(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	int status;
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    /* We take advantage of the fact that both defdcdc{2,3} are tied high */
    static struct tps6507x_reg_platform_data tps6507x_platform_data = {
    	.defdcdc_default = true,
    };
    
    static struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1350000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct touchscreen_init_data tps6507x_touchscreen_data = {
    	.poll_period =  30,	/* ms between touch samples */
    	.min_pressure = 0x30,	/* minimum pressure to trigger touch */
    	.vref = 0,		/* turn off vref when not using A/D */
    	.vendor = 0,		/* /sys/class/input/input?/id/vendor */
    	.product = 65070,	/* /sys/class/input/input?/id/product */
    	.version = 0x100,	/* /sys/class/input/input?/id/version */
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    	.tps6507x_ts_init_data = &tps6507x_touchscreen_data,
    };
    
    static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    };
    
    static int __init pmic_tps65070_init(void)
    {
    	return i2c_register_board_info(1, da850_evm_tps65070_info,
    					ARRAY_SIZE(da850_evm_tps65070_info));
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static struct i2c_client *pca9543a;
    
    static int pca9543a_probe(struct i2c_client *client,
    		const struct i2c_device_id *id)
    {
    	pr_info("pca9543a_probe");
    	pca9543a = client;
    	return 0;
    }
    
    static int pca9543a_remove(struct i2c_client *client)
    {
    	pca9543a = NULL;
    	return 0;
    }
    
    static const struct i2c_device_id pca9543a_ids[] = {
    	{ "PCA9543A", 0, },
    	{ /* end of list */ },
    };
    
    #if 0
    /* This is for i2c driver for the MT9T031 header i2c switch */
    static struct i2c_driver pca9543a_driver = {
    	.driver.name	= "PCA9543A",
    	.id_table	= pca9543a_ids,
    	.probe		= pca9543a_probe,
    	.remove		= pca9543a_remove,
    };
    #endif
    
    /**
     * da850_enable_pca9543a() - Enable/Disable I2C switch PCA9543A for sensor
     * @en: enable/disable flag
     */
    static int da850_enable_pca9543a(int en)
    {
    	static char val = 1;
    	int status;
    	struct i2c_msg msg = {
    			.flags = 0,
    			.len = 1,
    			.buf = &val,
    		};
    
    	pr_info("da850evm_enable_pca9543a\n");
    	if (!en)
    		val = 0;
    
    	if (!pca9543a)
    		return -ENXIO;
    
    	msg.addr = pca9543a->addr;
    	/* turn i2c switch, pca9543a, on/off */
    	status = i2c_transfer(pca9543a->adapter, &msg, 1);
    	pr_info("da850evm_enable_pca9543a, status = %d\n", status);
    	return status;
    }
    
    static const short da850_evm_mii_pins[] = {
    	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
    	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
    	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
    	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static const short da850_evm_rmii_pins[] = {
    	DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
    	DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
    	DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_mii_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = "tw9910",//"mt9t031",
    	},
    };
    
    /*
     * The following EDMA channels/slots are not being used by drivers (for
     * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
     * they are being reserved for codecs on the DSP side.
     */
    static const s16 da850_dma0_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma0_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30, 50},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30, 90},
    	{-1, -1}
    };
    
    static struct edma_rsv_info da850_edma_cc0_rsv = {
    	.rsv_chans	= da850_dma0_rsv_chans,
    	.rsv_slots	= da850_dma0_rsv_slots,
    };
    
    static struct edma_rsv_info da850_edma_cc1_rsv = {
    	.rsv_chans	= da850_dma1_rsv_chans,
    	.rsv_slots	= da850_dma1_rsv_slots,
    };
    
    static struct edma_rsv_info *da850_edma_rsv[2] = {
    	&da850_edma_cc0_rsv,
    	&da850_edma_cc1_rsv,
    };
    
    #ifdef CONFIG_CPU_FREQ
    static __init int da850_evm_init_cpufreq(void)
    {
    	switch (system_rev & 0xF) {
    	case 3:
    		da850_max_speed = 456000;
    		break;
    	case 2:
    		da850_max_speed = 408000;
    		break;
    	case 1:
    		da850_max_speed = 372000;
    		break;
    	}
    
    	return da850_register_cpufreq("pll0_sysclk3");
    }
    #else
    static __init int da850_evm_init_cpufreq(void) { return 0; }
    #endif
    
    #if defined(CONFIG_DAVINCI_UART1_AFE)
    #define HAS_UART1_AFE 1
    #else
    #define HAS_UART1_AFE 0
    #endif
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    int da850_vpif_setup_input_path(int ch, const char *name)
    {
    	int ret = 1;
    
    	 //if (!strcmp(name, "mt9t031") && have_imager())
    	 if (!strcmp(name, "tw9910") && have_imager())
    		ret = da850_enable_pca9543a(1);
    
    	return ret;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    #endif
    
    #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	{
    		.name	= "tw9910",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = (void *)1,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #elif defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	{
    		.name	= TVP5147_CH0,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= TVP5147_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	//.setup_input_path = da850_vpif_setup_input_path,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    #elif defined(CONFIG_DA850_UI_CAMERA)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    #endif
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    #ifdef CONFIG_DA850_WL12XX
    
    static void wl12xx_set_power(int index, bool power_on)
    {
    	static bool power_state;
    
    	pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
    
    	if (power_on == power_state)
    		return;
    	power_state = power_on;
    
    	if (power_on) {
    		/* Power up sequence required for wl127x devices */
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		usleep_range(15000, 15000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    		usleep_range(1000, 1000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		msleep(70);
    	} else {
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    	}
    }
    
    static struct davinci_mmc_config da850_wl12xx_mmc_config = {
    	.set_power	= wl12xx_set_power,
    	.wires		= 4,
    	.max_freq	= 25000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    			  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_wl12xx_pins[] __initconst = {
    	DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
    	DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
    	DA850_GPIO6_9, DA850_GPIO6_10,
    	-1
    };
    
    static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
    	.irq			= -1,
    	.board_ref_clock	= WL12XX_REFCLOCK_38,
    	.platform_quirks	= WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    };
    
    static __init int da850_wl12xx_init(void)
    {
    	int ret;
    
    	ret = davinci_cfg_reg_list(da850_wl12xx_pins);
    	if (ret) {
    		pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
    	if (ret) {
    		pr_err("wl12xx/mmc registration failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
    	if (ret) {
    		pr_err("Could not request wl12xx enable gpio: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
    	if (ret) {
    		pr_err("Could not request wl12xx irq gpio: %d\n", ret);
    		goto free_wlan_en;
    	}
    
    	da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
    
    	ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
    	if (ret) {
    		pr_err("Could not set wl12xx data: %d\n", ret);
    		goto free_wlan_irq;
    	}
    
    	return 0;
    
    free_wlan_irq:
    	gpio_free(DA850_WLAN_IRQ);
    
    free_wlan_en:
    	gpio_free(DA850_WLAN_EN);
    
    exit:
    	return ret;
    }
    
    #else /* CONFIG_DA850_WL12XX */
    
    static __init int da850_wl12xx_init(void)
    {
    	return 0;
    }
    
    #endif /* CONFIG_DA850_WL12XX */
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init int da850_set_emif_clk_rate(void)
    {
    	struct clk *emif_clk;
    
    	emif_clk = clk_get(NULL, "pll0_sysclk3");
    	if (WARN(IS_ERR(emif_clk), "Unable to get emif clock\n"))
    		return PTR_ERR(emif_clk);
    
    	return clk_set_rate(emif_clk, CONFIG_DA850_FIX_PLL0_SYSCLK3RATE);
    }
    
    struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
    	.pintc_base	= 0x4000,
    };
    
    #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    	char mask = 0;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	ret = pmic_tps65070_init();
    	if (ret)
    		pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
    				ret);
    
    	/*
    	 * Though bootloader takes care to set emif clock at allowed
    	 * possible rate. Kernel needs to reconfigure this rate to
    	 * support platforms requiring fixed emif clock rate.
    	 */
    	ret = da850_set_emif_clk_rate();
    	if (ret)
    		pr_warning("da850_evm_init: Failed to set rate of pll0_sysclk3/emif clock: %d\n",
    				ret);
    
    	ret = da850_register_edma(da850_edma_rsv);
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = davinci_cfg_reg_list(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	/* Support for UART 1 */
    	ret = davinci_cfg_reg_list(da850_uart1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: UART 1 mux setup failed:"
    						" %d\n", ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    
    		ret = da850_wl12xx_init();
    		if (ret)
    			pr_warning("da850_evm_init: wl12xx initialization"
    				   " failed: %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    /*
    	if (have_imager())
    		i2c_add_driver(&pca9543a_driver);
    */
    
    	i2c_register_board_info(1, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCASP) {
    		if (HAS_UART1_AFE)
    			pr_warning("WARNING: both McASP and UART1_AFE are "
    				"enabled, but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
    					ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
    	if (ret)
    		pr_warning("%s: pruss_uio initialization failed: %d\n",
    				__func__, ret);	
    
    	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_evm_init_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF setup failed: %d\n",
    				   ret);
    	}
    
    	if (HAS_VPIF_CAPTURE) {
    		ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture mux failed:"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture setup failed:"
    					"%d\n", ret);
    	}
    
    	if (HAS_VPIF_DISPLAY) {
    		ret = davinci_cfg_reg_list(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init : VPIF capture mux failed :"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_display(&da850_vpif_display_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF display setup failed:"
    					"%d\n", ret);
    	}
    
    	ret = da8xx_register_spi(1, da850evm_spi_info,
    				 ARRAY_SIZE(da850evm_spi_info));
    	if (ret)
    		pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
    				ret);
    
    	ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
    	if (ret)
    		pr_warning("da850_evm_init: sata registration failed: %d\n",
    				ret);
    
    	da850_evm_setup_mac_addr();
    
    	da850_evm_usb_init();
    
    	if (HAS_EHRPWM) {
    		if (rmii_en) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm0_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" ehrpwm0 mux setup failed: %d\n", ret);
    			else
    				mask = BIT(0) | BIT(1);
    		} else {
    			pr_warning("da850_evm_init:"
    			" eHRPWM module 0 cannot be used"
    			" since it is being used by MII interface\n");
    			mask = 0;
    		}
    
    		if (!HAS_LCD) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm1_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" eHRPWM module1 output A mux"
    				" setup failed %d\n", ret);
    			else
    				mask = mask | BIT(2);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputA cannot be"
    				" used since it is being used by LCD\n");
    		}
    
    		if (!HAS_SPI) {
    			ret = davinci_cfg_reg(DA850_EHRPWM1_B);
    			if (ret)
    				pr_warning("da850_evm_init:"
    					" eHRPWM module1 outputB mux"
    					" setup failed %d\n", ret);
    		else
    			mask =  mask  | BIT(3);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputB cannot be"
    				" used since it is being used by spi1\n");
    		}
    
    		da850_register_ehrpwm(mask);
    	}
    
    	if (HAS_ECAP_PWM) {
    		ret = davinci_cfg_reg(DA850_ECAP2_APWM2);
    		if (ret)
    			pr_warning("da850_evm_init:ecap mux failed:"
    					" %d\n", ret);
    		ret = da850_register_ecap(2);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" eCAP registration failed: %d\n", ret);
    	}
    
    	if (HAS_BACKLIGHT) {
    		ret = da850_register_backlight(&da850evm_backlight,
    				&da850evm_backlight_data);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" backlight device registration"
    				" failed: %d\n", ret);
    	}
    
    	if (HAS_ECAP_CAP) {
    		if (HAS_MCASP)
    			pr_warning("da850_evm_init:"
    				"ecap module 1 cannot be used "
    				"since it shares pins with McASP\n");
    		else {
    			ret = davinci_cfg_reg(DA850_ECAP1_APWM1);
    			if (ret)
    				pr_warning("da850_evm_init:ecap mux failed:%d\n"
    						, ret);
    			else {
    				ret = da850_register_ecap_cap(1);
    				if (ret)
    					pr_warning("da850_evm_init"
    					"eCAP registration failed: %d\n", ret);
    			}
    		}
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
    	.atag_offset	= 0x100,
    	.map_io		= da850_evm_map_io,
    	.init_irq	= cp_intc_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    	.dma_zone_size	= SZ_128M,
    	.restart	= da8xx_restart,
    MACHINE_END
    

        After kernel loaded, I find an error about TW9910 and VPIF:

    Linux video capture interface: v2.00
    tw9910 1-0045: TW9910: missing platform data!
    tw9910: probe of 1-0045 failed with error -22
    i2c i2c-1: Failed to register i2c client tw9910 at 0x45 (-16)
    vpif_capture vpif_capture: Error registering v4l2 subdevice

       But when I changed TW9910 code to previous that you give me, tw9910_probe will load OK.

       All log is:

    Uncompressing Linux... done, booting the kernel.
    Booting Linux on physical CPU 0
    Linux version 3.3.0 (root@ubuntu) (gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) ) #3 PREEMPT Fri Mar 28 15:48:37 HKT 2014
    CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
    CPU: VIVT data cache, VIVT instruction cache
    Machine: DaVinci DA850/OMAP-L138/AM18x EVM
    Memory policy: ECC disabled, Data cache writeback
    BUG: mapping for 0x80000000 at 0xfffe0000 out of vmalloc space
    DaVinci da850/omap-l138/am18x variant 0x1
    Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
    Kernel command line: console=tty2,115200n8 noinitrd rw rootfstype=ext3 root=/dev/mmcblk0p2 rootwait mem=64M
    PID hash table entries: 256 (order: -2, 1024 bytes)
    Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
    Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
    Memory: 64MB = 64MB total
    Memory: 59692k/59692k available, 5844k reserved, 0K highmem
    Virtual kernel memory layout:
        vector  : 0xffff0000 - 0xffff1000   (   4 kB)
        fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
        vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
        lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
        modules : 0xbf000000 - 0xc0000000   (  16 MB)
          .text : 0xc0008000 - 0xc049b000   (4684 kB)
          .init : 0xc049b000 - 0xc04c5000   ( 168 kB)
          .data : 0xc04c6000 - 0xc04ffd00   ( 232 kB)
           .bss : 0xc04ffd24 - 0xc051c70c   ( 115 kB)
    SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
    NR_IRQS:245
    Console: colour dummy device 80x30
    Calibrating delay loop... 148.88 BogoMIPS (lpj=744448)
    pid_max: default: 32768 minimum: 301
    Mount-cache hash table entries: 512
    CPU: Testing write buffer coherency: ok
    Setting up static identity map for 0xc0382048 - 0xc03820a0
    gpiochip_add: registered GPIOs 0 to 31 on device: DaVinci
    gpiochip_add: registered GPIOs 32 to 63 on device: DaVinci
    gpiochip_add: registered GPIOs 64 to 95 on device: DaVinci
    gpiochip_add: registered GPIOs 96 to 127 on device: DaVinci
    gpiochip_add: registered GPIOs 128 to 143 on device: DaVinci
    DaVinci: 144 gpio irqs
    NET: Registered protocol family 16
    bio: create slab <bio-0> at 0
    SCSI subsystem initialized
    usbcore: registered new interface driver usbfs
    usbcore: registered new interface driver hub
    usbcore: registered new device driver usb
    i2c-gpio i2c-gpio.1: using pins 20 (SDA) and 21 (SCL)
    vpif vpif: vpif probe success
    Advanced Linux Sound Architecture Driver Version 1.0.24.
    Switching to clocksource timer0_1
    musb-hdrc: version 6.0, ?dma?, otg (peripheral+host)
    musb-hdrc musb-hdrc: dma type: dma-cppi41
    MUSB255 controller's USBSS revision = 4ea11003
    Waiting for USB PHY clock good...
    musb-hdrc musb-hdrc: USB OTG mode controller at fee00000 using DMA, IRQ 58
    NET: Registered protocol family 2
    IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
    TCP established hash table entries: 2048 (order: 2, 16384 bytes)
    TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
    TCP: Hash tables configured (established 2048 bind 2048)
    TCP reno registered
    UDP hash table entries: 256 (order: 0, 4096 bytes)
    UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
    NET: Registered protocol family 1
    RPC: Registered named UNIX socket transport module.
    RPC: Registered udp transport module.
    RPC: Registered tcp transport module.
    RPC: Registered tcp NFSv4.1 backchannel transport module.
    EMAC: MII PHY configured, RMII PHY will not be functional
    JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
    msgmni has been set to 116
    io scheduler noop registered (default)
    da8xx_lcdc da8xx_lcdc.0: GLCD: Found Sharp_LK043T1DG01 panel
    Console: switching to colour frame buffer device 60x34
    Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
    serial8250.0: ttyS0 at MMIO 0x1c42000 (irq = 25) is a AR7
    serial8250.0: ttyS1 at MMIO 0x1d0c000 (irq = 53) is a AR7
    serial8250.0: ttyS2 at MMIO 0x1d0d000 (irq = 61) is a AR7
    console [ttyS2] enabled
    brd: module loaded
    spi_davinci spi_davinci.1: DMA: supported
    spi_davinci spi_davinci.1: DMA: RX channel: 18, TX channel: 19, event queue: 0
    m25p80 spi1.0: unrecognized JEDEC id ffffff
    spi_davinci spi_davinci.1: Controller at 0xfef0e000
    davinci_mdio davinci_mdio.0: davinci mdio revision 1.5
    davinci_mdio davinci_mdio.0: no live phy, scanning all
    davinci_mdio: probe of davinci_mdio.0 failed with error -5
    ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
    ohci ohci.0: DA8xx OHCI
    ohci ohci.0: new USB bus registered, assigned bus number 1
    Waiting for USB PHY clock good...
    ohci ohci.0: irq 59, io mem 0x01e25000
    hub 1-0:1.0: USB hub found
    hub 1-0:1.0: 1 port detected
    Initializing USB Mass Storage driver...
    usbcore: registered new interface driver usb-storage
    USB Mass Storage support registered.
    omap_rtc omap_rtc: rtc core: registered omap_rtc as rtc0
    omap_rtc: RTC power up reset detected
    i2c /dev entries driver
    lirc_dev: IR Remote Control driver registered, major 253 
    IR NEC protocol handler initialized
    IR RC5(x) protocol handler initialized
    IR RC6 protocol handler initialized
    IR JVC protocol handler initialized
    IR Sony protocol handler initialized
    IR RC5 (streamzap) protocol handler initialized
    IR SANYO protocol handler initialized
    IR MCE Keyboard/mouse protocol handler initialized
    IR LIRC bridge handler initialized
    Linux video capture interface: v2.00
    tw9910 1-0045: TW9910: missing platform data!
    tw9910: probe of 1-0045 failed with error -22
    i2c i2c-1: Failed to register i2c client tw9910 at 0x45 (-16)
    vpif_capture vpif_capture: Error registering v4l2 subdevice
    usbcore: registered new interface driver uvcvideo
    USB Video Class driver (1.1.1)
    watchdog watchdog: heartbeat 60 sec
    cpuidle: using governor ladder
    cpuidle: using governor menu
    davinci_mmc davinci_mmc.0: Using DMA, 4-bit mode
    usbcore: registered new interface driver snd-usb-audio
    soc-audio soc-audio.0: ASoC: Failed to create card debugfs directory
    ALSA device list:
      No soundcards found.
    TCP cubic registered
    NET: Registered protocol family 17
    console [netcon0] enabled
    netconsole: network logging started
    davinci_emac davinci_emac.1: using random MAC addr: 06:0f:43:36:09:9d
    omap_rtc omap_rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
    Waiting for root device /dev/mmcblk0p2...
    mmc0: host does not support reading read-only switch. assuming write-enable.
    mmc0: new high speed SDHC card at address 1234
    mmcblk0: mmc0:1234 SA04G 3.63 GiB 
     mmcblk0: p1 p2
    EXT3-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended
    kjournald starting.  Commit interval 5 seconds
    EXT3-fs (mmcblk0p2): using internal journal
    EXT3-fs (mmcblk0p2): recovery complete
    EXT3-fs (mmcblk0p2): mounted filesystem with writeback data mode
    VFS: Mounted root (ext3 filesystem) on device 179:2.
    Freeing init memory: 168K
    INIT: version 2.86 booting
    Please wait: booting...
    Starting udev
    udevd (557): /proc/557/oom_adj is deprecated, please use /proc/557/oom_score_adj instead.
    Remounting root file system...
    logger: mount: mount point /proc/bus/usb does not exist
    Configuring network interfaces... PHY davinci_mdio-0:00 not found
    net eth0: could not connect to phy davinci_mdio-0:00
    ifconfig: SIOCSIFFLAGS: No such device
    done.
    Setting up IP spoofing protection: rp_filter.
    Thu Jan 13 02:20:00 UTC 2011
    INIT: Entering runlevel: 5
    Starting telnet daemon.
    Starting syslogd/klogd: done
    Starting thttpd.
    FATAL: Module cmemk not found.
    FATAL: Module dsplinkk not found.
    
     _____                    _____           _         _   
    |  _  |___ ___ ___ ___   |  _  |___ ___  |_|___ ___| |_ 
    |     |  _| .'| . | . |  |   __|  _| . | | | -_|  _|  _|
    |__|__|_| |__,|_  |___|  |__|  |_| |___|_| |___|___|_|  
                  |___|                    |___|            
    
    Arago Project http://arago-project.org arago ttyS2
    
    Arago 2010.11 arago ttyS2
    
    arago login: 

        Can you help me to solve this problem? I really need your help!

        Thanks very much!

     

     

  • Hi,

    Try to put some printk's to confirm that function has been called,

    Did you defined "CONFIG_DA850_UI_CAMERA" in menuconfig.

    As per your board file then only it will build, Please check or remove the declarations.

    Symbol: DA850_UI_CAMERA [=y]

    Location:                                                                                                                
    -> System Type                                                                                                          
     -> TI DaVinci Implementations                                                                                       
       -> TI DA850/OMAP-L138/AM18x Reference Platform (MACH_DAVINCI_DA850_EVM [=y])                                      
         -> Select peripherals connected to expander on UI board (<choice> [=y])                     

  • yes, had defined.

    include/generated/autoconf.h:#define CONFIG_DA850_UI_CAMERA 1
    .config:CONFIG_DA850_UI_CAMERA=y

     And I had selected UI board to :

     Select peripherals connected to expander on UI board (CAMERA)  

      Is it right?

      Thanks.

  • Hi,

    1)

       But when I changed TW9910 code to previous that you give me, tw9910_probe will load OK.

    Use the old board file and kernel source and ry to add the patches from the following links

    http://davinci-linux-open-source.1494791.n2.nabble.com/PATCH-next-media-davinci-vpif-capture-fix-error-return-code-in-vpif-probe-td7583856.html

    http://lkml.org/lkml/2013/4/22/146

    http://lkml.org/lkml/2013/1/9/208

    2)

    What is the bus ID in new linux kernel ?

    have you modified the bus ID while i2c bus registering to avoid below error?

    i2c i2c-1: Failed to register i2c client tw9910 at 0x45 (-16)

    3)

    tw9910 1-0045: TW9910: missing platform data!

    This issue could be wrong platform data

    For this try in new board file,


    static struct i2c_board_info tw9910_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9910", 0x45),
        },
    };

    static struct tw9910_video_info tw9910_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout        = TW9910_MPO_FIELD,
    };

    static struct soc_camera_link tw9910_link = {
        .power        = tw9910_power,
        .board_info    = &tw9910_i2c_camera[0],
        .i2c_adapter_id    = 0,
        .priv        = &tw9910_info,
    };

    static struct platform_device tw9910_camera[] = {
        {
            .name    = "soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9910_link,
            },
        },
    };

    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };

     

    add this line to __init fn.

        platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));

  • Hi Titusrathinaraj:

        Thanks very much for your help!

       I add code to board-da850-evm.c

       But error still exist:

    Linux video capture interface: v2.00
    TW9910 probe ...
    tw9910 1-0045: bus width error    //In Version 2.6.37, this error is not exist!
    TW9910 probe ok!
    vpif_capture vpif_capture: Error registering v4l2 subdevice

      Some code list is:

    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    {
    I2C_BOARD_INFO("tw9910", 0x45),
    };

    /* I2C Video */
    static struct i2c_board_info i2c_camera[] = {
    {
    I2C_BOARD_INFO(CAMERA_NAME, 0x45),
    },
    };

    static struct tw9910_video_info tw9910_info = {
    .buswidth = SOCAM_DATAWIDTH_8,
    .mpout = TW9910_MPO_FIELD,
    };

    static struct soc_camera_link tw9910_link = {
    .i2c_adapter_id = 0,
    .bus_id = 1,
    //.power = tw9910_power,
    .power = NULL,
    .board_info = &i2c_camera[0],
    .module_name = CAMERA_NAME,
    .priv = &tw9910_info,
    };

    static struct platform_device tw9910_camera[] = {
    {
    .name = "TW9910 for soc-camera",
    .id = 1,
    .dev = {
    .platform_data = &tw9910_link,
    },
    },
    };

    static struct platform_device *tw9910_devices[] __initdata = {
    &tw9910_camera[0],
    };

    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    #if defined(CONFIG_DA850_UI_CAMERA)
    {
    .name = "tw9910",
    .board_info = {
    I2C_BOARD_INFO("tw9910", 0x45),
    .platform_data = &da850_evm_ui_expander_info,     //Is it right?
    },
    .vpif_if = {
    .if_type = VPIF_IF_RAW_BAYER,
    .hd_pol = 0,
    .vd_pol = 0,
    .fid_pol = 0,
    },
    },

    static __init void da850_evm_init(void)

    {

         ....

               i2c_register_board_info(1, da850_evm_i2c_devices,
    ARRAY_SIZE(da850_evm_i2c_devices));

         ....

            if (HAS_VPIF_CAPTURE) {
                    ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
                    if (ret)
                           pr_warning("da850_evm_init: VPIF capture mux failed:"
    "%d\n", ret);

                     //LiChangsheng add
                     platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
                     ret = da850_register_vpif_capture(&da850_vpif_capture_config);
                     if (ret)
                            pr_warning("da850_evm_init: VPIF capture setup failed:"
    "%d\n", ret);
            }

          ....

    }

       So I had some question:

        1 Does it need to add I2C_BOARD_INFO to da850_evm_i2c_devices? Because TW9910 device add by platform_add_devices:

    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    {
    I2C_BOARD_INFO("tw9910", 0x45),
    };

       2 Does da850_register_vpif_capture need to call?  Or what should I do to init some config to get CAMERA frame data?

          3  What's type does tw9910's platform_data need?

    da850_vpif_capture_sdev_info[] = {

    ....

    .platform_data = &da850_evm_ui_expander_info,     //Is it right?

    ....

    }

       

        Full board-da850-evm.c is:

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/clk.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/input.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/gpio_keys.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/mtd/physmap.h>
    #include <linux/regulator/machine.h>
    #include <linux/regulator/tps6507x.h>
    #include <linux/input/tps6507x-ts.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/delay.h>
    #include <linux/wl12xx.h>
    #include <linux/pwm_backlight.h>
    #include <linux/i2c-gpio.h>
    #include <linux/videodev2.h>
    #include <linux/module.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <linux/mfd/davinci_aemif.h>
    #include <mach/spi.h>
    #include <mach/usb.h>
    #include <media/tvp514x.h>
    #include <media/davinci/vpif_types.h>
    
    #include <media/tw9910.h>
    
    #define DA850_EVM_PHY_ID		"davinci_mdio-0:00"
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_WLAN_EN			GPIO_TO_PIN(6, 9)
    #define DA850_WLAN_IRQ			GPIO_TO_PIN(6, 10)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #define DAVINCI_BACKLIGHT_MAX_BRIGHTNESS	250
    #define DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS	250
    #define DAVINCI_PWM_PERIOD_NANO_SECONDS		10000000
    
    
    static struct platform_pwm_backlight_data da850evm_backlight_data = {
    	.max_brightness	= DAVINCI_BACKLIGHT_MAX_BRIGHTNESS,
    	.dft_brightness	= DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS,
    	.pwm_period_ns	= DAVINCI_PWM_PERIOD_NANO_SECONDS,
    };
    
    static struct platform_device da850evm_backlight = {
    	.name		= "pwm-backlight",
    	.id		= -1,
    };
    
    static struct mtd_partition da850evm_spiflash_part[] = {
    	[0] = {
    		.name = "UBL",
    		.offset = 0,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_512K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "U-Boot-Env",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[3] = {
    		.name = "Kernel",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_2M + SZ_512K,
    		.mask_flags = 0,
    	},
    	[4] = {
    		.name = "Filesystem",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_4M,
    		.mask_flags = 0,
    	},
    	[5] = {
    		.name = "MAC-Address",
    		.offset = SZ_8M - SZ_64K,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    };
    
    static struct flash_platform_data da850evm_spiflash_data = {
    	.name		= "m25p80",
    	.parts		= da850evm_spiflash_part,
    	.nr_parts	= ARRAY_SIZE(da850evm_spiflash_part),
    	.type		= "m25p64",
    };
    
    static struct davinci_spi_config da850evm_spiflash_cfg = {
    	.io_type	= SPI_IO_TYPE_DMA,
    	.c2tdelay	= 8,
    	.t2cdelay	= 8,
    };
    
    static struct spi_board_info da850evm_spi_info[] = {
    	{
    		.modalias		= "m25p80",
    		.platform_data		= &da850evm_spiflash_data,
    		.controller_data	= &da850evm_spiflash_cfg,
    		.mode			= SPI_MODE_0,
    		.max_speed_hz		= 30000000,
    		.bus_num		= 1,
    		.chip_select		= 0,
    	},
    };
    
    #define TVP5147_CH0		"tvp514x-0"
    #define TVP5147_CH1		"tvp514x-1"
    
    #define VPIF_STATUS		0x002c
    #define VPIF_STATUS_CLR		0x0030
    
    #ifdef CONFIG_MTD
    static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
    {
    	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
    	size_t retlen;
    
    	if (!strcmp(mtd->name, "MAC-Address")) {
    		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
    		if (retlen == ETH_ALEN)
    			pr_info("Read MAC addr from SPI Flash: %pM\n",
    				mac_addr);
    	}
    }
    
    static struct mtd_notifier da850evm_spi_notifier = {
    	.add	= da850_evm_m25p80_notify_add,
    };
    
    static void da850_evm_setup_mac_addr(void)
    {
    	register_mtd_user(&da850evm_spi_notifier);
    }
    #else
    static void da850_evm_setup_mac_addr(void) { }
    #endif
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_4M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct physmap_flash_data da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    static struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.bbt_options	= NAND_BBT_USE_FLASH,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_devices[] = {
    	{
    		.name		= "davinci_nand",
    		.id		= 1,
    		.dev		= {
    			.platform_data	= &da850_evm_nandflash_data,
    		},
    		.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    		.resource	= da850_evm_nandflash_resource,
    	},
    #if !defined(CONFIG_MMC_DAVINCI) || \
        !defined(CONFIG_MMC_DAVINCI_MODULE)
    	{
    		.name		= "physmap-flash",
    		.id		= 0,
    		.dev		= {
    			.platform_data  = &da850_evm_norflash_data,
    		},
    		.num_resources	= 1,
    		.resource	= da850_evm_norflash_resource,
    
    	},
    #endif
    };
    static struct davinci_aemif_devices da850_emif_devices = {
    	.devices	= da850_evm_devices,
    	.num_devices	= ARRAY_SIZE(da850_evm_devices),
    };
    
    static struct platform_device davinci_emif_device = {
    	.name	= "davinci_aemif",
    	.id	= -1,
    	.dev	= {
    		.platform_data	= &da850_emif_devices,
    	},
    };
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static void __init da850_evm_init_nor(void)
    {
    	void __iomem *aemif_addr;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	/* Configure data bus width of CS2 to 16 bit */
    	writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
    		DA8XX_AEMIF_ASIZE_16BIT,
    		aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    static const short da850_evm_nand_pins[] = {
    	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
    	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
    	DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
    	DA850_NEMA_WE, DA850_NEMA_OE,
    	-1
    };
    
    static const short da850_evm_nor_pins[] = {
    	DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
    	DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
    	DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
    	DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
    	DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
    	DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
    	DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
    	DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
    	DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
    	DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
    	DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
    	DA850_EMA_A_22, DA850_EMA_A_23,
    	-1
    };
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    #if defined(CONFIG_SPI_DAVINCI)
    #define HAS_SPI 1
    #else
    #define HAS_SPI 0
    #endif
    
    #if defined(CONFIG_FB_DA8XX)
    #define HAS_LCD	1
    #else
    #define HAS_LCD	0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DAVINCI_EHRPWM) || defined(CONFIG_DAVINCI_EHRPWM_MODULE)
    #define HAS_EHRPWM 1
    #else
    #define HAS_EHRPWM 0
    #endif
    
    #if defined(CONFIG_ECAP_PWM) || \
    	defined(CONFIG_ECAP_PWM_MODULE)
    #define HAS_ECAP_PWM 1
    #else
    #define HAS_ECAP_PWM 0
    #endif
    
    #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
    #define HAS_BACKLIGHT 1
    #else
    #define HAS_BACKLIGHT 0
    #endif
    
    #if defined(CONFIG_ECAP_CAP) || defined(CONFIG_ECAP_CAP_MODULE)
    #define HAS_ECAP_CAP 1
    #else
    #define HAS_ECAP_CAP 0
    #endif
    
    /* have_imager() - Check if we have support for imager interface */
    static inline int have_imager(void)
    {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	return 1;
    #else
    	return 0;
    #endif
    }
    
    static inline void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    	ret = davinci_cfg_reg_list(da850_evm_nand_pins);
    	if (ret)
    		pr_warning("da850_evm_init: nand mux setup failed: "
    				"%d\n", ret);
    
    	if (!HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] low for NOR to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = davinci_cfg_reg_list(da850_evm_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    
    		da850_evm_init_nor();
    	} else {
    		/*
    		 * On Logic PD Rev.3 EVMs GP0[11] pin needs to be configured
    		 * for MMC and NOR to work. When GP0[11] is low, the SD0
    		 * interface will not work, but NOR flash will. When GP0[11]
    		 * is high, SD0 will work but NOR flash will not. By default
    		 * we are assuming that GP0[11] pin is driven high, when UI
    		 * card is not connected. Hence we are not configuring the
    		 * GP0[11] pin when MMC/SD is enabled and UI card is not
    		 * connected. Not configuring the GPIO pin will enable the
    		 * bluetooth to work on AM18x as it requires the GP0[11]
    		 * pin for UART flow control.
    		 */
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    	}
    
    	platform_device_register(&davinci_emif_device);
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value_cansleep(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    
    #define DA850_KEYS_DEBOUNCE_MS	10
    /*
     * At 200ms polling interval it is possible to miss an
     * event by tapping very lightly on the push button but most
     * pushes do result in an event; longer intervals require the
     * user to hold the button whereas shorter intervals require
     * more CPU time for polling.
     */
    #define DA850_GPIO_KEYS_POLL_MS	200
    
    enum da850_evm_ui_exp_pins {
    	DA850_EVM_UI_EXP_SEL_C = 5,
    	DA850_EVM_UI_EXP_SEL_B,
    	DA850_EVM_UI_EXP_SEL_A,
    	DA850_EVM_UI_EXP_PB8,
    	DA850_EVM_UI_EXP_PB7,
    	DA850_EVM_UI_EXP_PB6,
    	DA850_EVM_UI_EXP_PB5,
    	DA850_EVM_UI_EXP_PB4,
    	DA850_EVM_UI_EXP_PB3,
    	DA850_EVM_UI_EXP_PB2,
    	DA850_EVM_UI_EXP_PB1,
    };
    
    static const char const *da850_evm_ui_exp[] = {
    	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c",
    	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b",
    	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a",
    	[DA850_EVM_UI_EXP_PB8]          = "pb8",
    	[DA850_EVM_UI_EXP_PB7]          = "pb7",
    	[DA850_EVM_UI_EXP_PB6]          = "pb6",
    	[DA850_EVM_UI_EXP_PB5]          = "pb5",
    	[DA850_EVM_UI_EXP_PB4]          = "pb4",
    	[DA850_EVM_UI_EXP_PB3]          = "pb3",
    	[DA850_EVM_UI_EXP_PB2]          = "pb2",
    	[DA850_EVM_UI_EXP_PB1]          = "pb1",
    };
    
    #define DA850_N_UI_PB		8
    
    static struct gpio_keys_button da850_evm_ui_keys[] = {
    	[0 ... DA850_N_UI_PB - 1] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
    	.buttons = da850_evm_ui_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_ui_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 0,
    	.dev = {
    		.platform_data = &da850_evm_ui_keys_pdata
    	},
    };
    
    static void da850_evm_ui_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	for (i = 0; i < DA850_N_UI_PB; i++) {
    		button = &da850_evm_ui_keys[i];
    		button->code = KEY_F8 - i;
    		button->desc = (char *)
    				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
    		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
    	}
    }
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value_cansleep(a, 0);
    	gpio_set_value_cansleep(b, 0);
    	gpio_set_value_cansleep(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value_cansleep(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CAMERA
    static inline void da850_evm_setup_camera(int camera_sel)
    {
    	gpio_set_value_cansleep(camera_sel, 0);
    }
    #else
    static inline void da850_evm_setup_camera(int camera_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
    	sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
    	sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
    
    	ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	da850_evm_ui_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_ui_keys_device);
    	if (ret) {
    		pr_warning("Could not register UI GPIO expander push-buttons");
    		goto exp_setup_keys_fail;
    	}
    
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	da850_evm_setup_camera(sel_b);
    
    	return 0;
    
    exp_setup_keys_fail:
    	gpio_free(sel_c);
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_ui_keys_device);
    
    	/* deselect all functionalities */
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
    
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
    
    	return 0;
    }
    
    /* assign the baseboard expander's GPIOs after the UI board's */
    #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
    #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
    
    enum da850_evm_bb_exp_pins {
    	DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
    	DA850_EVM_BB_EXP_SW_RST,
    	DA850_EVM_BB_EXP_TP_23,
    	DA850_EVM_BB_EXP_TP_22,
    	DA850_EVM_BB_EXP_TP_21,
    	DA850_EVM_BB_EXP_USER_PB1,
    	DA850_EVM_BB_EXP_USER_LED2,
    	DA850_EVM_BB_EXP_USER_LED1,
    	DA850_EVM_BB_EXP_USER_SW1,
    	DA850_EVM_BB_EXP_USER_SW2,
    	DA850_EVM_BB_EXP_USER_SW3,
    	DA850_EVM_BB_EXP_USER_SW4,
    	DA850_EVM_BB_EXP_USER_SW5,
    	DA850_EVM_BB_EXP_USER_SW6,
    	DA850_EVM_BB_EXP_USER_SW7,
    	DA850_EVM_BB_EXP_USER_SW8
    };
    
    static const char const *da850_evm_bb_exp[] = {
    	[DA850_EVM_BB_EXP_DEEP_SLEEP_EN]	= "deep_sleep_en",
    	[DA850_EVM_BB_EXP_SW_RST]		= "sw_rst",
    	[DA850_EVM_BB_EXP_TP_23]		= "tp_23",
    	[DA850_EVM_BB_EXP_TP_22]		= "tp_22",
    	[DA850_EVM_BB_EXP_TP_21]		= "tp_21",
    	[DA850_EVM_BB_EXP_USER_PB1]		= "user_pb1",
    	[DA850_EVM_BB_EXP_USER_LED2]		= "user_led2",
    	[DA850_EVM_BB_EXP_USER_LED1]		= "user_led1",
    	[DA850_EVM_BB_EXP_USER_SW1]		= "user_sw1",
    	[DA850_EVM_BB_EXP_USER_SW2]		= "user_sw2",
    	[DA850_EVM_BB_EXP_USER_SW3]		= "user_sw3",
    	[DA850_EVM_BB_EXP_USER_SW4]		= "user_sw4",
    	[DA850_EVM_BB_EXP_USER_SW5]		= "user_sw5",
    	[DA850_EVM_BB_EXP_USER_SW6]		= "user_sw6",
    	[DA850_EVM_BB_EXP_USER_SW7]		= "user_sw7",
    	[DA850_EVM_BB_EXP_USER_SW8]		= "user_sw8",
    };
    
    #define DA850_N_BB_USER_SW	8
    
    static struct gpio_keys_button da850_evm_bb_keys[] = {
    	[0] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= KEY_PROG1,
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    	[1 ... DA850_N_BB_USER_SW] = {
    		.type			= EV_SW,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
    	.buttons = da850_evm_bb_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_bb_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 1,
    	.dev = {
    		.platform_data = &da850_evm_bb_keys_pdata
    	},
    };
    
    static void da850_evm_bb_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	button = &da850_evm_bb_keys[0];
    	button->desc = (char *)
    		da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
    	button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
    
    	for (i = 0; i < DA850_N_BB_USER_SW; i++) {
    		button = &da850_evm_bb_keys[i + 1];
    		button->code = SW_LID + i;
    		button->desc = (char *)
    				da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
    		button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
    	}
    }
    
    #define DA850_N_BB_USER_LED	2
    
    static struct gpio_led da850_evm_bb_leds[] = {
    	[0 ... DA850_N_BB_USER_LED - 1] = {
    		.active_low = 1,
    		.gpio = -1, /* assigned at runtime */
    		.name = NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
    	.leds = da850_evm_bb_leds,
    	.num_leds = ARRAY_SIZE(da850_evm_bb_leds),
    };
    
    static struct platform_device da850_evm_bb_leds_device = {
    	.name		= "leds-gpio",
    	.id		= -1,
    	.dev = {
    		.platform_data = &da850_evm_bb_leds_pdata
    	}
    };
    
    static void da850_evm_bb_leds_init(unsigned gpio)
    {
    	int i;
    	struct gpio_led *led;
    
    	for (i = 0; i < DA850_N_BB_USER_LED; i++) {
    		led = &da850_evm_bb_leds[i];
    
    		led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
    		led->name =
    			da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
    	}
    }
    
    static int da850_evm_bb_expander_setup(struct i2c_client *client,
    						unsigned gpio, unsigned ngpio,
    						void *c)
    {
    	int ret;
    
    	/*
    	 * Register the switches and pushbutton on the baseboard as a gpio-keys
    	 * device.
    	 */
    	da850_evm_bb_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_keys_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander keys");
    		goto io_exp_setup_sw_fail;
    	}
    
    	da850_evm_bb_leds_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_leds_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander LEDS");
    		goto io_exp_setup_leds_fail;
    	}
    
    	return 0;
    
    io_exp_setup_leds_fail:
    	platform_device_unregister(&da850_evm_bb_keys_device);
    io_exp_setup_sw_fail:
    	return ret;
    }
    
    static int da850_evm_bb_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_bb_leds_device);
    	platform_device_unregister(&da850_evm_bb_keys_device);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    	.names		= da850_evm_ui_exp,
    };
    
    static struct pca953x_platform_data da850_evm_bb_expander_info = {
    	.gpio_base	= DA850_BB_EXPANDER_GPIO_BASE,
    	.setup		= da850_evm_bb_expander_setup,
    	.teardown	= da850_evm_bb_expander_teardown,
    	.names		= da850_evm_bb_exp,
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    /*
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x21),
    		.platform_data = &da850_evm_bb_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    	{
    		I2C_BOARD_INFO("PCA9543A", 0x73),
    	},
    	{
    		I2C_BOARD_INFO("tw9910", 0x45),
    	},
    */	
    };
    
    /*
     * USB1 VBUS is controlled by GPIO2[4], over-current is reported on GPIO6[13].
     */
    #define ON_BD_USB_DRV	GPIO_TO_PIN(2, 4)
    #define ON_BD_USB_OVC	GPIO_TO_PIN(6, 13)
    
    static const short da850_evm_usb11_pins[] = {
    	DA850_GPIO2_4, DA850_GPIO6_13,
    	-1
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.type			= GPIO_BASED,
    	.method	= {
    		.gpio_method = {
    			.power_control_pin	= ON_BD_USB_DRV,
    			.over_current_indicator = ON_BD_USB_OVC,
    		},
    	},
    	.board_ocic_handler	= da850_evm_usb_ocic_irq,
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *handler)
    {
    	if (handler != NULL)
    		((da8xx_ocic_handler_t)handler)(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static __init void da850_evm_usb_init(void)
    {
    	u32 cfgchip2;
    	int ret;
    
    	/*
    	 * Set up USB clock/mode in the CFGCHIP2 register.
    	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/* USB2.0 PHY reference clock is 24 MHz */
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    
    	/*
    	 * Select internal reference clock for USB 2.0 PHY
    	 * and use it as a clock source for USB 1.1 PHY
    	 * (this is the default setting anyway).
    	 */
    	cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
    	cfgchip2 |=  CFGCHIP2_USB2PHYCLKMUX;
    	/*
    	 * We have to override VBUS/ID signals when MUSB is configured into the
    	 * host-only mode -- ID pin will float if no cable is connected, so the
    	 * controller won't be able to drive VBUS thinking that it's a B-device.
    	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
    	 */
    	cfgchip2 &= ~CFGCHIP2_OTGMODE;
    	cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
    
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/*
    	 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
    	 * with the power on to power good time of 3 ms.
    	 */
    	ret = da8xx_register_usb20(1000, 3);
    	if (ret)
    		pr_warning("%s: USB 2.0 registration failed: %d\n",
    			   __func__, ret);
    
    	/* initilaize usb module */
    	da8xx_board_usb_init(da850_evm_usb11_pins, &da850_evm_usb11_pdata);
    }
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.asp_chan_q	= EVENTQ_0,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static const short da850_evm_mcasp_pins[] __initconst = {
    	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
    	DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
    	DA850_AXR_11, DA850_AXR_12,
    	-1
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_evm_mmcsd0_pins[] __initconst = {
    	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
    	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
    	DA850_GPIO4_0, DA850_GPIO4_1,
    	-1
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value_cansleep(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value_cansleep(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	int status;
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    /* We take advantage of the fact that both defdcdc{2,3} are tied high */
    static struct tps6507x_reg_platform_data tps6507x_platform_data = {
    	.defdcdc_default = true,
    };
    
    static struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1350000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct touchscreen_init_data tps6507x_touchscreen_data = {
    	.poll_period =  30,	/* ms between touch samples */
    	.min_pressure = 0x30,	/* minimum pressure to trigger touch */
    	.vref = 0,		/* turn off vref when not using A/D */
    	.vendor = 0,		/* /sys/class/input/input?/id/vendor */
    	.product = 65070,	/* /sys/class/input/input?/id/product */
    	.version = 0x100,	/* /sys/class/input/input?/id/version */
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    	.tps6507x_ts_init_data = &tps6507x_touchscreen_data,
    };
    
    static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    };
    
    static int __init pmic_tps65070_init(void)
    {
    	return i2c_register_board_info(1, da850_evm_tps65070_info,
    					ARRAY_SIZE(da850_evm_tps65070_info));
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static struct i2c_client *pca9543a;
    
    static int pca9543a_probe(struct i2c_client *client,
    		const struct i2c_device_id *id)
    {
    	pr_info("pca9543a_probe");
    	pca9543a = client;
    	return 0;
    }
    
    static int pca9543a_remove(struct i2c_client *client)
    {
    	pca9543a = NULL;
    	return 0;
    }
    
    static const struct i2c_device_id pca9543a_ids[] = {
    	{ "PCA9543A", 0, },
    	{ /* end of list */ },
    };
    
    #if 0
    /* This is for i2c driver for the MT9T031 header i2c switch */
    static struct i2c_driver pca9543a_driver = {
    	.driver.name	= "PCA9543A",
    	.id_table	= pca9543a_ids,
    	.probe		= pca9543a_probe,
    	.remove		= pca9543a_remove,
    };
    #endif
    
    /**
     * da850_enable_pca9543a() - Enable/Disable I2C switch PCA9543A for sensor
     * @en: enable/disable flag
     */
    static int da850_enable_pca9543a(int en)
    {
    	static char val = 1;
    	int status;
    	struct i2c_msg msg = {
    			.flags = 0,
    			.len = 1,
    			.buf = &val,
    		};
    
    	pr_info("da850evm_enable_pca9543a\n");
    	if (!en)
    		val = 0;
    
    	if (!pca9543a)
    		return -ENXIO;
    
    	msg.addr = pca9543a->addr;
    	/* turn i2c switch, pca9543a, on/off */
    	status = i2c_transfer(pca9543a->adapter, &msg, 1);
    	pr_info("da850evm_enable_pca9543a, status = %d\n", status);
    	return status;
    }
    
    static const short da850_evm_mii_pins[] = {
    	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
    	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
    	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
    	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static const short da850_evm_rmii_pins[] = {
    	DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
    	DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
    	DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_mii_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = "tw9910",//"mt9t031",
    	},
    };
    
    /*
     * The following EDMA channels/slots are not being used by drivers (for
     * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
     * they are being reserved for codecs on the DSP side.
     */
    static const s16 da850_dma0_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma0_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30, 50},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30, 90},
    	{-1, -1}
    };
    
    static struct edma_rsv_info da850_edma_cc0_rsv = {
    	.rsv_chans	= da850_dma0_rsv_chans,
    	.rsv_slots	= da850_dma0_rsv_slots,
    };
    
    static struct edma_rsv_info da850_edma_cc1_rsv = {
    	.rsv_chans	= da850_dma1_rsv_chans,
    	.rsv_slots	= da850_dma1_rsv_slots,
    };
    
    static struct edma_rsv_info *da850_edma_rsv[2] = {
    	&da850_edma_cc0_rsv,
    	&da850_edma_cc1_rsv,
    };
    
    #ifdef CONFIG_CPU_FREQ
    static __init int da850_evm_init_cpufreq(void)
    {
    	switch (system_rev & 0xF) {
    	case 3:
    		da850_max_speed = 456000;
    		break;
    	case 2:
    		da850_max_speed = 408000;
    		break;
    	case 1:
    		da850_max_speed = 372000;
    		break;
    	}
    
    	return da850_register_cpufreq("pll0_sysclk3");
    }
    #else
    static __init int da850_evm_init_cpufreq(void) { return 0; }
    #endif
    
    #if defined(CONFIG_DAVINCI_UART1_AFE)
    #define HAS_UART1_AFE 1
    #else
    #define HAS_UART1_AFE 0
    #endif
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    int da850_vpif_setup_input_path(int ch, const char *name)
    {
    	int ret = 1;
    
    	 //if (!strcmp(name, "mt9t031") && have_imager())
    	 if (!strcmp(name, "tw9910") && have_imager())
    		ret = da850_enable_pca9543a(1);
    
    	return ret;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    #endif
    
    #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct i2c_board_info tw9910_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9910", 0x45),
        },
    };
    
    static struct tw9910_video_info tw9910_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout        = TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    //    .power        = tw9910_power,
        .board_info    = &tw9910_i2c_camera[0],
        .i2c_adapter_id    = 0,
    	.bus_id		= 1,
        .priv        = &tw9910_info,
    };
    
    static struct platform_device tw9910_camera[] = {
        {
            .name    = "TW9910 soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9910_link,
            },
        },
    };
    
    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };
    
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	{
    		.name	= "tw9910",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = &da850_evm_ui_expander_info,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #elif defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	{
    		.name	= TVP5147_CH0,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= TVP5147_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	//.setup_input_path = da850_vpif_setup_input_path,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    #elif defined(CONFIG_DA850_UI_CAMERA)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    #endif
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    #ifdef CONFIG_DA850_WL12XX
    
    static void wl12xx_set_power(int index, bool power_on)
    {
    	static bool power_state;
    
    	pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
    
    	if (power_on == power_state)
    		return;
    	power_state = power_on;
    
    	if (power_on) {
    		/* Power up sequence required for wl127x devices */
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		usleep_range(15000, 15000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    		usleep_range(1000, 1000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		msleep(70);
    	} else {
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    	}
    }
    
    static struct davinci_mmc_config da850_wl12xx_mmc_config = {
    	.set_power	= wl12xx_set_power,
    	.wires		= 4,
    	.max_freq	= 25000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    			  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_wl12xx_pins[] __initconst = {
    	DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
    	DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
    	DA850_GPIO6_9, DA850_GPIO6_10,
    	-1
    };
    
    static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
    	.irq			= -1,
    	.board_ref_clock	= WL12XX_REFCLOCK_38,
    	.platform_quirks	= WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    };
    
    static __init int da850_wl12xx_init(void)
    {
    	int ret;
    
    	ret = davinci_cfg_reg_list(da850_wl12xx_pins);
    	if (ret) {
    		pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
    	if (ret) {
    		pr_err("wl12xx/mmc registration failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
    	if (ret) {
    		pr_err("Could not request wl12xx enable gpio: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
    	if (ret) {
    		pr_err("Could not request wl12xx irq gpio: %d\n", ret);
    		goto free_wlan_en;
    	}
    
    	da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
    
    	ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
    	if (ret) {
    		pr_err("Could not set wl12xx data: %d\n", ret);
    		goto free_wlan_irq;
    	}
    
    	return 0;
    
    free_wlan_irq:
    	gpio_free(DA850_WLAN_IRQ);
    
    free_wlan_en:
    	gpio_free(DA850_WLAN_EN);
    
    exit:
    	return ret;
    }
    
    #else /* CONFIG_DA850_WL12XX */
    
    static __init int da850_wl12xx_init(void)
    {
    	return 0;
    }
    
    #endif /* CONFIG_DA850_WL12XX */
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init int da850_set_emif_clk_rate(void)
    {
    	struct clk *emif_clk;
    
    	emif_clk = clk_get(NULL, "pll0_sysclk3");
    	if (WARN(IS_ERR(emif_clk), "Unable to get emif clock\n"))
    		return PTR_ERR(emif_clk);
    
    	return clk_set_rate(emif_clk, CONFIG_DA850_FIX_PLL0_SYSCLK3RATE);
    }
    
    struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
    	.pintc_base	= 0x4000,
    };
    
    #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    	char mask = 0;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	ret = pmic_tps65070_init();
    	if (ret)
    		pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
    				ret);
    
    	/*
    	 * Though bootloader takes care to set emif clock at allowed
    	 * possible rate. Kernel needs to reconfigure this rate to
    	 * support platforms requiring fixed emif clock rate.
    	 */
    	ret = da850_set_emif_clk_rate();
    	if (ret)
    		pr_warning("da850_evm_init: Failed to set rate of pll0_sysclk3/emif clock: %d\n",
    				ret);
    
    	ret = da850_register_edma(da850_edma_rsv);
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = davinci_cfg_reg_list(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	/* Support for UART 1 */
    	ret = davinci_cfg_reg_list(da850_uart1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: UART 1 mux setup failed:"
    						" %d\n", ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    
    		ret = da850_wl12xx_init();
    		if (ret)
    			pr_warning("da850_evm_init: wl12xx initialization"
    				   " failed: %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    /*
    	if (have_imager())
    		i2c_add_driver(&pca9543a_driver);
    */
    
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCASP) {
    		if (HAS_UART1_AFE)
    			pr_warning("WARNING: both McASP and UART1_AFE are "
    				"enabled, but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
    					ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
    	if (ret)
    		pr_warning("%s: pruss_uio initialization failed: %d\n",
    				__func__, ret);	
    
    	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_evm_init_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF setup failed: %d\n",
    				   ret);
    	}
    
    	if (HAS_VPIF_CAPTURE) {
    		ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture mux failed:"
    					"%d\n", ret);
    
    		//HUANYI_SYSTEM LiChangsheng add
    		platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture setup failed:"
    					"%d\n", ret);
    	}
    
    	if (HAS_VPIF_DISPLAY) {
    		ret = davinci_cfg_reg_list(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init : VPIF capture mux failed :"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_display(&da850_vpif_display_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF display setup failed:"
    					"%d\n", ret);
    	}
    
    	ret = da8xx_register_spi(1, da850evm_spi_info,
    				 ARRAY_SIZE(da850evm_spi_info));
    	if (ret)
    		pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
    				ret);
    
    	ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
    	if (ret)
    		pr_warning("da850_evm_init: sata registration failed: %d\n",
    				ret);
    
    	da850_evm_setup_mac_addr();
    
    	da850_evm_usb_init();
    
    	if (HAS_EHRPWM) {
    		if (rmii_en) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm0_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" ehrpwm0 mux setup failed: %d\n", ret);
    			else
    				mask = BIT(0) | BIT(1);
    		} else {
    			pr_warning("da850_evm_init:"
    			" eHRPWM module 0 cannot be used"
    			" since it is being used by MII interface\n");
    			mask = 0;
    		}
    
    		if (!HAS_LCD) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm1_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" eHRPWM module1 output A mux"
    				" setup failed %d\n", ret);
    			else
    				mask = mask | BIT(2);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputA cannot be"
    				" used since it is being used by LCD\n");
    		}
    
    		if (!HAS_SPI) {
    			ret = davinci_cfg_reg(DA850_EHRPWM1_B);
    			if (ret)
    				pr_warning("da850_evm_init:"
    					" eHRPWM module1 outputB mux"
    					" setup failed %d\n", ret);
    		else
    			mask =  mask  | BIT(3);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputB cannot be"
    				" used since it is being used by spi1\n");
    		}
    
    		da850_register_ehrpwm(mask);
    	}
    
    	if (HAS_ECAP_PWM) {
    		ret = davinci_cfg_reg(DA850_ECAP2_APWM2);
    		if (ret)
    			pr_warning("da850_evm_init:ecap mux failed:"
    					" %d\n", ret);
    		ret = da850_register_ecap(2);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" eCAP registration failed: %d\n", ret);
    	}
    
    	if (HAS_BACKLIGHT) {
    		ret = da850_register_backlight(&da850evm_backlight,
    				&da850evm_backlight_data);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" backlight device registration"
    				" failed: %d\n", ret);
    	}
    
    	if (HAS_ECAP_CAP) {
    		if (HAS_MCASP)
    			pr_warning("da850_evm_init:"
    				"ecap module 1 cannot be used "
    				"since it shares pins with McASP\n");
    		else {
    			ret = davinci_cfg_reg(DA850_ECAP1_APWM1);
    			if (ret)
    				pr_warning("da850_evm_init:ecap mux failed:%d\n"
    						, ret);
    			else {
    				ret = da850_register_ecap_cap(1);
    				if (ret)
    					pr_warning("da850_evm_init"
    					"eCAP registration failed: %d\n", ret);
    			}
    		}
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
    	.atag_offset	= 0x100,
    	.map_io		= da850_evm_map_io,
    	.init_irq	= cp_intc_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    	.dma_zone_size	= SZ_128M,
    	.restart	= da8xx_restart,
    MACHINE_END
    
     

       

        Thanks very much! 

       

       

  • Hi,

      1 Does it need to add I2C_BOARD_INFO to da850_evm_i2c_devices? Because TW9910 device add by platform_add_devices:

    Not required, I2C registration once is sufficient.

       2 Does  need to call?  Or what should I do to init some config to get CAMERA frame data?

    Yes, It is required.

          3  What's type does tw9910's platform_data need?

    .platform_data = &da850_evm_ui_expander_info,

    Don't use this, instead use the below,

                .platform_data = (void *)1,

     

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/clk.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/input.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/gpio_keys.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/mtd/physmap.h>
    #include <linux/regulator/machine.h>
    #include <linux/regulator/tps6507x.h>
    #include <linux/input/tps6507x-ts.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/delay.h>
    #include <linux/wl12xx.h>
    #include <linux/pwm_backlight.h>
    #include <linux/i2c-gpio.h>
    #include <linux/videodev2.h>
    #include <linux/module.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <linux/mfd/davinci_aemif.h>
    #include <mach/spi.h>
    #include <mach/usb.h>
    #include <media/tvp514x.h>
    #include <media/davinci/vpif_types.h>
    
    #include <media/tw9910.h>
    
    #define DA850_EVM_PHY_ID		"davinci_mdio-0:00"
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_WLAN_EN			GPIO_TO_PIN(6, 9)
    #define DA850_WLAN_IRQ			GPIO_TO_PIN(6, 10)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #define DAVINCI_BACKLIGHT_MAX_BRIGHTNESS	250
    #define DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS	250
    #define DAVINCI_PWM_PERIOD_NANO_SECONDS		10000000
    
    
    static struct platform_pwm_backlight_data da850evm_backlight_data = {
    	.max_brightness	= DAVINCI_BACKLIGHT_MAX_BRIGHTNESS,
    	.dft_brightness	= DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS,
    	.pwm_period_ns	= DAVINCI_PWM_PERIOD_NANO_SECONDS,
    };
    
    static struct platform_device da850evm_backlight = {
    	.name		= "pwm-backlight",
    	.id		= -1,
    };
    
    static struct mtd_partition da850evm_spiflash_part[] = {
    	[0] = {
    		.name = "UBL",
    		.offset = 0,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_512K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "U-Boot-Env",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[3] = {
    		.name = "Kernel",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_2M + SZ_512K,
    		.mask_flags = 0,
    	},
    	[4] = {
    		.name = "Filesystem",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_4M,
    		.mask_flags = 0,
    	},
    	[5] = {
    		.name = "MAC-Address",
    		.offset = SZ_8M - SZ_64K,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    };
    
    static struct flash_platform_data da850evm_spiflash_data = {
    	.name		= "m25p80",
    	.parts		= da850evm_spiflash_part,
    	.nr_parts	= ARRAY_SIZE(da850evm_spiflash_part),
    	.type		= "m25p64",
    };
    
    static struct davinci_spi_config da850evm_spiflash_cfg = {
    	.io_type	= SPI_IO_TYPE_DMA,
    	.c2tdelay	= 8,
    	.t2cdelay	= 8,
    };
    
    static struct spi_board_info da850evm_spi_info[] = {
    	{
    		.modalias		= "m25p80",
    		.platform_data		= &da850evm_spiflash_data,
    		.controller_data	= &da850evm_spiflash_cfg,
    		.mode			= SPI_MODE_0,
    		.max_speed_hz		= 30000000,
    		.bus_num		= 1,
    		.chip_select		= 0,
    	},
    };
    
    #define TVP5147_CH0		"tvp514x-0"
    #define TVP5147_CH1		"tvp514x-1"
    
    #define VPIF_STATUS		0x002c
    #define VPIF_STATUS_CLR		0x0030
    
    #ifdef CONFIG_MTD
    static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
    {
    	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
    	size_t retlen;
    
    	if (!strcmp(mtd->name, "MAC-Address")) {
    		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
    		if (retlen == ETH_ALEN)
    			pr_info("Read MAC addr from SPI Flash: %pM\n",
    				mac_addr);
    	}
    }
    
    static struct mtd_notifier da850evm_spi_notifier = {
    	.add	= da850_evm_m25p80_notify_add,
    };
    
    static void da850_evm_setup_mac_addr(void)
    {
    	register_mtd_user(&da850evm_spi_notifier);
    }
    #else
    static void da850_evm_setup_mac_addr(void) { }
    #endif
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_4M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct physmap_flash_data da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    static struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.bbt_options	= NAND_BBT_USE_FLASH,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_devices[] = {
    	{
    		.name		= "davinci_nand",
    		.id		= 1,
    		.dev		= {
    			.platform_data	= &da850_evm_nandflash_data,
    		},
    		.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    		.resource	= da850_evm_nandflash_resource,
    	},
    #if !defined(CONFIG_MMC_DAVINCI) || \
        !defined(CONFIG_MMC_DAVINCI_MODULE)
    	{
    		.name		= "physmap-flash",
    		.id		= 0,
    		.dev		= {
    			.platform_data  = &da850_evm_norflash_data,
    		},
    		.num_resources	= 1,
    		.resource	= da850_evm_norflash_resource,
    
    	},
    #endif
    };
    static struct davinci_aemif_devices da850_emif_devices = {
    	.devices	= da850_evm_devices,
    	.num_devices	= ARRAY_SIZE(da850_evm_devices),
    };
    
    static struct platform_device davinci_emif_device = {
    	.name	= "davinci_aemif",
    	.id	= -1,
    	.dev	= {
    		.platform_data	= &da850_emif_devices,
    	},
    };
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static void __init da850_evm_init_nor(void)
    {
    	void __iomem *aemif_addr;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	/* Configure data bus width of CS2 to 16 bit */
    	writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
    		DA8XX_AEMIF_ASIZE_16BIT,
    		aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    static const short da850_evm_nand_pins[] = {
    	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
    	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
    	DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
    	DA850_NEMA_WE, DA850_NEMA_OE,
    	-1
    };
    
    static const short da850_evm_nor_pins[] = {
    	DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
    	DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
    	DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
    	DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
    	DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
    	DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
    	DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
    	DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
    	DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
    	DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
    	DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
    	DA850_EMA_A_22, DA850_EMA_A_23,
    	-1
    };
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    #if defined(CONFIG_SPI_DAVINCI)
    #define HAS_SPI 1
    #else
    #define HAS_SPI 0
    #endif
    
    #if defined(CONFIG_FB_DA8XX)
    #define HAS_LCD	1
    #else
    #define HAS_LCD	0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DAVINCI_EHRPWM) || defined(CONFIG_DAVINCI_EHRPWM_MODULE)
    #define HAS_EHRPWM 1
    #else
    #define HAS_EHRPWM 0
    #endif
    
    #if defined(CONFIG_ECAP_PWM) || \
    	defined(CONFIG_ECAP_PWM_MODULE)
    #define HAS_ECAP_PWM 1
    #else
    #define HAS_ECAP_PWM 0
    #endif
    
    #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
    #define HAS_BACKLIGHT 1
    #else
    #define HAS_BACKLIGHT 0
    #endif
    
    #if defined(CONFIG_ECAP_CAP) || defined(CONFIG_ECAP_CAP_MODULE)
    #define HAS_ECAP_CAP 1
    #else
    #define HAS_ECAP_CAP 0
    #endif
    
    /* have_imager() - Check if we have support for imager interface */
    static inline int have_imager(void)
    {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	return 1;
    #else
    	return 0;
    #endif
    }
    
    static inline void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    	ret = davinci_cfg_reg_list(da850_evm_nand_pins);
    	if (ret)
    		pr_warning("da850_evm_init: nand mux setup failed: "
    				"%d\n", ret);
    
    	if (!HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] low for NOR to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = davinci_cfg_reg_list(da850_evm_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    
    		da850_evm_init_nor();
    	} else {
    		/*
    		 * On Logic PD Rev.3 EVMs GP0[11] pin needs to be configured
    		 * for MMC and NOR to work. When GP0[11] is low, the SD0
    		 * interface will not work, but NOR flash will. When GP0[11]
    		 * is high, SD0 will work but NOR flash will not. By default
    		 * we are assuming that GP0[11] pin is driven high, when UI
    		 * card is not connected. Hence we are not configuring the
    		 * GP0[11] pin when MMC/SD is enabled and UI card is not
    		 * connected. Not configuring the GPIO pin will enable the
    		 * bluetooth to work on AM18x as it requires the GP0[11]
    		 * pin for UART flow control.
    		 */
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    	}
    
    	platform_device_register(&davinci_emif_device);
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value_cansleep(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    
    #define DA850_KEYS_DEBOUNCE_MS	10
    /*
     * At 200ms polling interval it is possible to miss an
     * event by tapping very lightly on the push button but most
     * pushes do result in an event; longer intervals require the
     * user to hold the button whereas shorter intervals require
     * more CPU time for polling.
     */
    #define DA850_GPIO_KEYS_POLL_MS	200
    
    enum da850_evm_ui_exp_pins {
    	DA850_EVM_UI_EXP_SEL_C = 5,
    	DA850_EVM_UI_EXP_SEL_B,
    	DA850_EVM_UI_EXP_SEL_A,
    	DA850_EVM_UI_EXP_PB8,
    	DA850_EVM_UI_EXP_PB7,
    	DA850_EVM_UI_EXP_PB6,
    	DA850_EVM_UI_EXP_PB5,
    	DA850_EVM_UI_EXP_PB4,
    	DA850_EVM_UI_EXP_PB3,
    	DA850_EVM_UI_EXP_PB2,
    	DA850_EVM_UI_EXP_PB1,
    };
    
    static const char const *da850_evm_ui_exp[] = {
    	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c",
    	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b",
    	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a",
    	[DA850_EVM_UI_EXP_PB8]          = "pb8",
    	[DA850_EVM_UI_EXP_PB7]          = "pb7",
    	[DA850_EVM_UI_EXP_PB6]          = "pb6",
    	[DA850_EVM_UI_EXP_PB5]          = "pb5",
    	[DA850_EVM_UI_EXP_PB4]          = "pb4",
    	[DA850_EVM_UI_EXP_PB3]          = "pb3",
    	[DA850_EVM_UI_EXP_PB2]          = "pb2",
    	[DA850_EVM_UI_EXP_PB1]          = "pb1",
    };
    
    #define DA850_N_UI_PB		8
    
    static struct gpio_keys_button da850_evm_ui_keys[] = {
    	[0 ... DA850_N_UI_PB - 1] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
    	.buttons = da850_evm_ui_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_ui_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 0,
    	.dev = {
    		.platform_data = &da850_evm_ui_keys_pdata
    	},
    };
    
    static void da850_evm_ui_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	for (i = 0; i < DA850_N_UI_PB; i++) {
    		button = &da850_evm_ui_keys[i];
    		button->code = KEY_F8 - i;
    		button->desc = (char *)
    				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
    		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
    	}
    }
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value_cansleep(a, 0);
    	gpio_set_value_cansleep(b, 0);
    	gpio_set_value_cansleep(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value_cansleep(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CAMERA
    static inline void da850_evm_setup_camera(int camera_sel)
    {
    	gpio_set_value_cansleep(camera_sel, 0);
    }
    #else
    static inline void da850_evm_setup_camera(int camera_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
    	sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
    	sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
    
    	ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	da850_evm_ui_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_ui_keys_device);
    	if (ret) {
    		pr_warning("Could not register UI GPIO expander push-buttons");
    		goto exp_setup_keys_fail;
    	}
    
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	da850_evm_setup_camera(sel_b);
    
    	return 0;
    
    exp_setup_keys_fail:
    	gpio_free(sel_c);
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_ui_keys_device);
    
    	/* deselect all functionalities */
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
    
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
    
    	return 0;
    }
    
    /* assign the baseboard expander's GPIOs after the UI board's */
    #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
    #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
    
    enum da850_evm_bb_exp_pins {
    	DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
    	DA850_EVM_BB_EXP_SW_RST,
    	DA850_EVM_BB_EXP_TP_23,
    	DA850_EVM_BB_EXP_TP_22,
    	DA850_EVM_BB_EXP_TP_21,
    	DA850_EVM_BB_EXP_USER_PB1,
    	DA850_EVM_BB_EXP_USER_LED2,
    	DA850_EVM_BB_EXP_USER_LED1,
    	DA850_EVM_BB_EXP_USER_SW1,
    	DA850_EVM_BB_EXP_USER_SW2,
    	DA850_EVM_BB_EXP_USER_SW3,
    	DA850_EVM_BB_EXP_USER_SW4,
    	DA850_EVM_BB_EXP_USER_SW5,
    	DA850_EVM_BB_EXP_USER_SW6,
    	DA850_EVM_BB_EXP_USER_SW7,
    	DA850_EVM_BB_EXP_USER_SW8
    };
    
    static const char const *da850_evm_bb_exp[] = {
    	[DA850_EVM_BB_EXP_DEEP_SLEEP_EN]	= "deep_sleep_en",
    	[DA850_EVM_BB_EXP_SW_RST]		= "sw_rst",
    	[DA850_EVM_BB_EXP_TP_23]		= "tp_23",
    	[DA850_EVM_BB_EXP_TP_22]		= "tp_22",
    	[DA850_EVM_BB_EXP_TP_21]		= "tp_21",
    	[DA850_EVM_BB_EXP_USER_PB1]		= "user_pb1",
    	[DA850_EVM_BB_EXP_USER_LED2]		= "user_led2",
    	[DA850_EVM_BB_EXP_USER_LED1]		= "user_led1",
    	[DA850_EVM_BB_EXP_USER_SW1]		= "user_sw1",
    	[DA850_EVM_BB_EXP_USER_SW2]		= "user_sw2",
    	[DA850_EVM_BB_EXP_USER_SW3]		= "user_sw3",
    	[DA850_EVM_BB_EXP_USER_SW4]		= "user_sw4",
    	[DA850_EVM_BB_EXP_USER_SW5]		= "user_sw5",
    	[DA850_EVM_BB_EXP_USER_SW6]		= "user_sw6",
    	[DA850_EVM_BB_EXP_USER_SW7]		= "user_sw7",
    	[DA850_EVM_BB_EXP_USER_SW8]		= "user_sw8",
    };
    
    #define DA850_N_BB_USER_SW	8
    
    static struct gpio_keys_button da850_evm_bb_keys[] = {
    	[0] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= KEY_PROG1,
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    	[1 ... DA850_N_BB_USER_SW] = {
    		.type			= EV_SW,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
    	.buttons = da850_evm_bb_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_bb_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 1,
    	.dev = {
    		.platform_data = &da850_evm_bb_keys_pdata
    	},
    };
    
    static void da850_evm_bb_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	button = &da850_evm_bb_keys[0];
    	button->desc = (char *)
    		da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
    	button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
    
    	for (i = 0; i < DA850_N_BB_USER_SW; i++) {
    		button = &da850_evm_bb_keys[i + 1];
    		button->code = SW_LID + i;
    		button->desc = (char *)
    				da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
    		button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
    	}
    }
    
    #define DA850_N_BB_USER_LED	2
    
    static struct gpio_led da850_evm_bb_leds[] = {
    	[0 ... DA850_N_BB_USER_LED - 1] = {
    		.active_low = 1,
    		.gpio = -1, /* assigned at runtime */
    		.name = NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
    	.leds = da850_evm_bb_leds,
    	.num_leds = ARRAY_SIZE(da850_evm_bb_leds),
    };
    
    static struct platform_device da850_evm_bb_leds_device = {
    	.name		= "leds-gpio",
    	.id		= -1,
    	.dev = {
    		.platform_data = &da850_evm_bb_leds_pdata
    	}
    };
    
    static void da850_evm_bb_leds_init(unsigned gpio)
    {
    	int i;
    	struct gpio_led *led;
    
    	for (i = 0; i < DA850_N_BB_USER_LED; i++) {
    		led = &da850_evm_bb_leds[i];
    
    		led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
    		led->name =
    			da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
    	}
    }
    
    static int da850_evm_bb_expander_setup(struct i2c_client *client,
    						unsigned gpio, unsigned ngpio,
    						void *c)
    {
    	int ret;
    
    	/*
    	 * Register the switches and pushbutton on the baseboard as a gpio-keys
    	 * device.
    	 */
    	da850_evm_bb_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_keys_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander keys");
    		goto io_exp_setup_sw_fail;
    	}
    
    	da850_evm_bb_leds_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_leds_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander LEDS");
    		goto io_exp_setup_leds_fail;
    	}
    
    	return 0;
    
    io_exp_setup_leds_fail:
    	platform_device_unregister(&da850_evm_bb_keys_device);
    io_exp_setup_sw_fail:
    	return ret;
    }
    
    static int da850_evm_bb_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_bb_leds_device);
    	platform_device_unregister(&da850_evm_bb_keys_device);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    	.names		= da850_evm_ui_exp,
    };
    
    static struct pca953x_platform_data da850_evm_bb_expander_info = {
    	.gpio_base	= DA850_BB_EXPANDER_GPIO_BASE,
    	.setup		= da850_evm_bb_expander_setup,
    	.teardown	= da850_evm_bb_expander_teardown,
    	.names		= da850_evm_bb_exp,
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    /*
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x21),
    		.platform_data = &da850_evm_bb_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    	{
    		I2C_BOARD_INFO("PCA9543A", 0x73),
    	},
    	{
    		I2C_BOARD_INFO("tw9910", 0x45),
    	},
    */	
    };
    
    /*
     * USB1 VBUS is controlled by GPIO2[4], over-current is reported on GPIO6[13].
     */
    #define ON_BD_USB_DRV	GPIO_TO_PIN(2, 4)
    #define ON_BD_USB_OVC	GPIO_TO_PIN(6, 13)
    
    static const short da850_evm_usb11_pins[] = {
    	DA850_GPIO2_4, DA850_GPIO6_13,
    	-1
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.type			= GPIO_BASED,
    	.method	= {
    		.gpio_method = {
    			.power_control_pin	= ON_BD_USB_DRV,
    			.over_current_indicator = ON_BD_USB_OVC,
    		},
    	},
    	.board_ocic_handler	= da850_evm_usb_ocic_irq,
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *handler)
    {
    	if (handler != NULL)
    		((da8xx_ocic_handler_t)handler)(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static __init void da850_evm_usb_init(void)
    {
    	u32 cfgchip2;
    	int ret;
    
    	/*
    	 * Set up USB clock/mode in the CFGCHIP2 register.
    	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/* USB2.0 PHY reference clock is 24 MHz */
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    
    	/*
    	 * Select internal reference clock for USB 2.0 PHY
    	 * and use it as a clock source for USB 1.1 PHY
    	 * (this is the default setting anyway).
    	 */
    	cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
    	cfgchip2 |=  CFGCHIP2_USB2PHYCLKMUX;
    	/*
    	 * We have to override VBUS/ID signals when MUSB is configured into the
    	 * host-only mode -- ID pin will float if no cable is connected, so the
    	 * controller won't be able to drive VBUS thinking that it's a B-device.
    	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
    	 */
    	cfgchip2 &= ~CFGCHIP2_OTGMODE;
    	cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
    
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/*
    	 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
    	 * with the power on to power good time of 3 ms.
    	 */
    	ret = da8xx_register_usb20(1000, 3);
    	if (ret)
    		pr_warning("%s: USB 2.0 registration failed: %d\n",
    			   __func__, ret);
    
    	/* initilaize usb module */
    	da8xx_board_usb_init(da850_evm_usb11_pins, &da850_evm_usb11_pdata);
    }
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.asp_chan_q	= EVENTQ_0,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static const short da850_evm_mcasp_pins[] __initconst = {
    	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
    	DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
    	DA850_AXR_11, DA850_AXR_12,
    	-1
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_evm_mmcsd0_pins[] __initconst = {
    	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
    	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
    	DA850_GPIO4_0, DA850_GPIO4_1,
    	-1
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value_cansleep(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value_cansleep(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	int status;
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    /* We take advantage of the fact that both defdcdc{2,3} are tied high */
    static struct tps6507x_reg_platform_data tps6507x_platform_data = {
    	.defdcdc_default = true,
    };
    
    static struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1350000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct touchscreen_init_data tps6507x_touchscreen_data = {
    	.poll_period =  30,	/* ms between touch samples */
    	.min_pressure = 0x30,	/* minimum pressure to trigger touch */
    	.vref = 0,		/* turn off vref when not using A/D */
    	.vendor = 0,		/* /sys/class/input/input?/id/vendor */
    	.product = 65070,	/* /sys/class/input/input?/id/product */
    	.version = 0x100,	/* /sys/class/input/input?/id/version */
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    	.tps6507x_ts_init_data = &tps6507x_touchscreen_data,
    };
    
    static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    };
    
    static int __init pmic_tps65070_init(void)
    {
    	return i2c_register_board_info(1, da850_evm_tps65070_info,
    					ARRAY_SIZE(da850_evm_tps65070_info));
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static struct i2c_client *pca9543a;
    
    static int pca9543a_probe(struct i2c_client *client,
    		const struct i2c_device_id *id)
    {
    	pr_info("pca9543a_probe");
    	pca9543a = client;
    	return 0;
    }
    
    static int pca9543a_remove(struct i2c_client *client)
    {
    	pca9543a = NULL;
    	return 0;
    }
    
    static const struct i2c_device_id pca9543a_ids[] = {
    	{ "PCA9543A", 0, },
    	{ /* end of list */ },
    };
    
    #if 0
    /* This is for i2c driver for the MT9T031 header i2c switch */
    static struct i2c_driver pca9543a_driver = {
    	.driver.name	= "PCA9543A",
    	.id_table	= pca9543a_ids,
    	.probe		= pca9543a_probe,
    	.remove		= pca9543a_remove,
    };
    #endif
    
    /**
     * da850_enable_pca9543a() - Enable/Disable I2C switch PCA9543A for sensor
     * @en: enable/disable flag
     */
    static int da850_enable_pca9543a(int en)
    {
    	static char val = 1;
    	int status;
    	struct i2c_msg msg = {
    			.flags = 0,
    			.len = 1,
    			.buf = &val,
    		};
    
    	pr_info("da850evm_enable_pca9543a\n");
    	if (!en)
    		val = 0;
    
    	if (!pca9543a)
    		return -ENXIO;
    
    	msg.addr = pca9543a->addr;
    	/* turn i2c switch, pca9543a, on/off */
    	status = i2c_transfer(pca9543a->adapter, &msg, 1);
    	pr_info("da850evm_enable_pca9543a, status = %d\n", status);
    	return status;
    }
    
    static const short da850_evm_mii_pins[] = {
    	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
    	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
    	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
    	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static const short da850_evm_rmii_pins[] = {
    	DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
    	DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
    	DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_mii_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = "tw9910",//"mt9t031",
    	},
    };
    
    /*
     * The following EDMA channels/slots are not being used by drivers (for
     * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
     * they are being reserved for codecs on the DSP side.
     */
    static const s16 da850_dma0_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma0_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30, 50},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30, 90},
    	{-1, -1}
    };
    
    static struct edma_rsv_info da850_edma_cc0_rsv = {
    	.rsv_chans	= da850_dma0_rsv_chans,
    	.rsv_slots	= da850_dma0_rsv_slots,
    };
    
    static struct edma_rsv_info da850_edma_cc1_rsv = {
    	.rsv_chans	= da850_dma1_rsv_chans,
    	.rsv_slots	= da850_dma1_rsv_slots,
    };
    
    static struct edma_rsv_info *da850_edma_rsv[2] = {
    	&da850_edma_cc0_rsv,
    	&da850_edma_cc1_rsv,
    };
    
    #ifdef CONFIG_CPU_FREQ
    static __init int da850_evm_init_cpufreq(void)
    {
    	switch (system_rev & 0xF) {
    	case 3:
    		da850_max_speed = 456000;
    		break;
    	case 2:
    		da850_max_speed = 408000;
    		break;
    	case 1:
    		da850_max_speed = 372000;
    		break;
    	}
    
    	return da850_register_cpufreq("pll0_sysclk3");
    }
    #else
    static __init int da850_evm_init_cpufreq(void) { return 0; }
    #endif
    
    #if defined(CONFIG_DAVINCI_UART1_AFE)
    #define HAS_UART1_AFE 1
    #else
    #define HAS_UART1_AFE 0
    #endif
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    int da850_vpif_setup_input_path(int ch, const char *name)
    {
    	int ret = 1;
    
    	 //if (!strcmp(name, "mt9t031") && have_imager())
    	 if (!strcmp(name, "tw9910") && have_imager())
    		ret = da850_enable_pca9543a(1);
    
    	return ret;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    #endif
    
    #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct i2c_board_info tw9910_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9910", 0x45),
        },
    };
    
    static struct tw9910_video_info tw9910_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout        = TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    //    .power        = tw9910_power,
        .board_info    = &tw9910_i2c_camera[0],
        .i2c_adapter_id    = 0,
    	.bus_id		= 1,
        .priv        = &tw9910_info,
    };
    
    static struct platform_device tw9910_camera[] = {
        {
            .name    = "TW9910 soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9910_link,
            },
        },
    };
    
    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };
    
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	{
    		.name	= "tw9910",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
                .platform_data = (void *)1,		//titus
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #elif defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	{
    		.name	= TVP5147_CH0,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= TVP5147_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	//.setup_input_path = da850_vpif_setup_input_path,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    #elif defined(CONFIG_DA850_UI_CAMERA)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    #endif
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    #ifdef CONFIG_DA850_WL12XX
    
    static void wl12xx_set_power(int index, bool power_on)
    {
    	static bool power_state;
    
    	pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
    
    	if (power_on == power_state)
    		return;
    	power_state = power_on;
    
    	if (power_on) {
    		/* Power up sequence required for wl127x devices */
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		usleep_range(15000, 15000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    		usleep_range(1000, 1000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		msleep(70);
    	} else {
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    	}
    }
    
    static struct davinci_mmc_config da850_wl12xx_mmc_config = {
    	.set_power	= wl12xx_set_power,
    	.wires		= 4,
    	.max_freq	= 25000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    			  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_wl12xx_pins[] __initconst = {
    	DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
    	DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
    	DA850_GPIO6_9, DA850_GPIO6_10,
    	-1
    };
    
    static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
    	.irq			= -1,
    	.board_ref_clock	= WL12XX_REFCLOCK_38,
    	.platform_quirks	= WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    };
    
    static __init int da850_wl12xx_init(void)
    {
    	int ret;
    
    	ret = davinci_cfg_reg_list(da850_wl12xx_pins);
    	if (ret) {
    		pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
    	if (ret) {
    		pr_err("wl12xx/mmc registration failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
    	if (ret) {
    		pr_err("Could not request wl12xx enable gpio: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
    	if (ret) {
    		pr_err("Could not request wl12xx irq gpio: %d\n", ret);
    		goto free_wlan_en;
    	}
    
    	da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
    
    	ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
    	if (ret) {
    		pr_err("Could not set wl12xx data: %d\n", ret);
    		goto free_wlan_irq;
    	}
    
    	return 0;
    
    free_wlan_irq:
    	gpio_free(DA850_WLAN_IRQ);
    
    free_wlan_en:
    	gpio_free(DA850_WLAN_EN);
    
    exit:
    	return ret;
    }
    
    #else /* CONFIG_DA850_WL12XX */
    
    static __init int da850_wl12xx_init(void)
    {
    	return 0;
    }
    
    #endif /* CONFIG_DA850_WL12XX */
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init int da850_set_emif_clk_rate(void)
    {
    	struct clk *emif_clk;
    
    	emif_clk = clk_get(NULL, "pll0_sysclk3");
    	if (WARN(IS_ERR(emif_clk), "Unable to get emif clock\n"))
    		return PTR_ERR(emif_clk);
    
    	return clk_set_rate(emif_clk, CONFIG_DA850_FIX_PLL0_SYSCLK3RATE);
    }
    
    struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
    	.pintc_base	= 0x4000,
    };
    
    #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    	char mask = 0;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	ret = pmic_tps65070_init();
    	if (ret)
    		pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
    				ret);
    
    	/*
    	 * Though bootloader takes care to set emif clock at allowed
    	 * possible rate. Kernel needs to reconfigure this rate to
    	 * support platforms requiring fixed emif clock rate.
    	 */
    	ret = da850_set_emif_clk_rate();
    	if (ret)
    		pr_warning("da850_evm_init: Failed to set rate of pll0_sysclk3/emif clock: %d\n",
    				ret);
    
    	ret = da850_register_edma(da850_edma_rsv);
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = davinci_cfg_reg_list(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	/* Support for UART 1 */
    	ret = davinci_cfg_reg_list(da850_uart1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: UART 1 mux setup failed:"
    						" %d\n", ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    
    		ret = da850_wl12xx_init();
    		if (ret)
    			pr_warning("da850_evm_init: wl12xx initialization"
    				   " failed: %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    /*
    	if (have_imager())
    		i2c_add_driver(&pca9543a_driver);
    */
    
    	i2c_register_board_info(0, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCASP) {
    		if (HAS_UART1_AFE)
    			pr_warning("WARNING: both McASP and UART1_AFE are "
    				"enabled, but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
    					ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
    	if (ret)
    		pr_warning("%s: pruss_uio initialization failed: %d\n",
    				__func__, ret);	
    
    	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_evm_init_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF setup failed: %d\n",
    				   ret);
    	}
    
    	if (HAS_VPIF_CAPTURE) {
    		ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture mux failed:"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture setup failed:"
    					"%d\n", ret);
    	}
    
    	if (HAS_VPIF_DISPLAY) {
    		ret = davinci_cfg_reg_list(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init : VPIF capture mux failed :"
    					"%d\n", ret);
    
    		//HUANYI_SYSTEM LiChangsheng add
    		platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
    //Titus : Add the platform init  after VPIF reg.
    
    //Do not use VPIF display now,
    //		ret = da850_register_vpif_display(&da850_vpif_display_config);
    //		if (ret)
    //			pr_warning("da850_evm_init: VPIF display setup failed:"
    //					"%d\n", ret);
    //	}
    
    	ret = da8xx_register_spi(1, da850evm_spi_info,
    				 ARRAY_SIZE(da850evm_spi_info));
    	if (ret)
    		pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
    				ret);
    
    	ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
    	if (ret)
    		pr_warning("da850_evm_init: sata registration failed: %d\n",
    				ret);
    
    	da850_evm_setup_mac_addr();
    
    	da850_evm_usb_init();
    
    	if (HAS_EHRPWM) {
    		if (rmii_en) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm0_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" ehrpwm0 mux setup failed: %d\n", ret);
    			else
    				mask = BIT(0) | BIT(1);
    		} else {
    			pr_warning("da850_evm_init:"
    			" eHRPWM module 0 cannot be used"
    			" since it is being used by MII interface\n");
    			mask = 0;
    		}
    
    		if (!HAS_LCD) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm1_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" eHRPWM module1 output A mux"
    				" setup failed %d\n", ret);
    			else
    				mask = mask | BIT(2);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputA cannot be"
    				" used since it is being used by LCD\n");
    		}
    
    		if (!HAS_SPI) {
    			ret = davinci_cfg_reg(DA850_EHRPWM1_B);
    			if (ret)
    				pr_warning("da850_evm_init:"
    					" eHRPWM module1 outputB mux"
    					" setup failed %d\n", ret);
    		else
    			mask =  mask  | BIT(3);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputB cannot be"
    				" used since it is being used by spi1\n");
    		}
    
    		da850_register_ehrpwm(mask);
    	}
    
    	if (HAS_ECAP_PWM) {
    		ret = davinci_cfg_reg(DA850_ECAP2_APWM2);
    		if (ret)
    			pr_warning("da850_evm_init:ecap mux failed:"
    					" %d\n", ret);
    		ret = da850_register_ecap(2);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" eCAP registration failed: %d\n", ret);
    	}
    
    	if (HAS_BACKLIGHT) {
    		ret = da850_register_backlight(&da850evm_backlight,
    				&da850evm_backlight_data);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" backlight device registration"
    				" failed: %d\n", ret);
    	}
    
    	if (HAS_ECAP_CAP) {
    		if (HAS_MCASP)
    			pr_warning("da850_evm_init:"
    				"ecap module 1 cannot be used "
    				"since it shares pins with McASP\n");
    		else {
    			ret = davinci_cfg_reg(DA850_ECAP1_APWM1);
    			if (ret)
    				pr_warning("da850_evm_init:ecap mux failed:%d\n"
    						, ret);
    			else {
    				ret = da850_register_ecap_cap(1);
    				if (ret)
    					pr_warning("da850_evm_init"
    					"eCAP registration failed: %d\n", ret);
    			}
    		}
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
    	.atag_offset	= 0x100,
    	.map_io		= da850_evm_map_io,
    	.init_irq	= cp_intc_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    	.dma_zone_size	= SZ_128M,
    	.restart	= da8xx_restart,
    MACHINE_END
    

    static __init void da850_evm_init(void)

    {

         ....

               i2c_register_board_info(1, da850_evm_i2c_devices,
    ARRAY_SIZE(da850_evm_i2c_devices));

         ....

            if (HAS_VPIF_CAPTURE) {
                    ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
                    if (ret)
                           pr_warning("da850_evm_init: VPIF capture mux failed:"
    "%d\n", ret);

                     ret = da850_register_vpif_capture(&da850_vpif_capture_config);
                     if (ret)
                            pr_warning("da850_evm_init: VPIF capture setup failed:"
    "%d\n", ret);

                     //LiChangsheng add
                     platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));

    //Titus Debug: Add this line at last of VPIF reg.
            }

          ....

    }

     

  • Hi Titusrathinaraj:

        Thanks very much!

        It seems VPIF registered ok. 

        Thanks!

  • Hi Chang,

    Good to hear this news from you,

    Sounds really good.

    Can you please tell me what you have done, So that others also get benefited know!

  • Hi Titusrathinaraj:

       Sorry! 

       In evm init:

    if (HAS_VPIF_CAPTURE) {
    ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
    if (ret)
    pr_warning("da850_evm_init: VPIF capture mux failed:"
    "%d\n", ret);

    ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    if (ret)
    pr_warning("da850_evm_init: VPIF capture setup failed:"
    "%d\n", ret);
    //HUANYI_SYSTEM LiChangsheng add
    platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
    }

     

       I found that  after kernel loaded, func:

       tw9910_probe() 

       won't be excuted!

       What's wrong?

  • Hi,

    Please explain clearly what you have faced,

    How it is started to working and when it is stopped to working?

    Titus said:

                     //LiChangsheng add
                     platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));

    //Titus Debug: Add this line at last of VPIF reg.


    Have you fixed your issue from the above suggestion?

    Could you please attach your both logs before & after working,

  • Hi Titusrathinaraj:

        Yes!  I had added this line:

    platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));

         at last of :

        da850_register_vpif_capture 

         or  after: da850_register_vpif

      The result is same. tw9910_probe had not called! 

      What 's wrong?

       Thanks.

  • Hi Titusrathinaraj:

        I think that it is ok. But I found error:

    Linux video capture interface: v2.00
    TW9910 probe ...
    Unable to handle kernel NULL pointer dereference at virtual address 00000015
    pgd = c0004000
    [00000015] *pgd=00000000
    Internal error: Oops: 1 [#1] PREEMPT
    Modules linked in:
    CPU: 0 Not tainted (3.3.0 #17)
    PC is at tw9910_probe+0x28/0x194
    LR is at console_unlock+0x210/0x220
    pc : [<c02931d0>] lr : [<c0018638>] psr: 20000013
    sp : c3829cd0 ip : c3829bf0 fp : c3829cec
    r10: c051e290 r9 : 00000000 r8 : c398f400
    r7 : 00000000 r6 : c3853628 r5 : 00000001 r4 : c398f400
    r3 : 60000013 r2 : 60000013 r1 : 00000000 r0 : 00000014
    Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
    Control: 0005317f Table: c0004000 DAC: 00000017
    Process swapper (pid: 1, stack limit = 0xc3828270)
    Stack: (0xc3829cd0 to 0xc382a000)
    9cc0: c02931a8 c398f400 c052a8e8 00000000
    9ce0: c3829d0c c3829cf0 c02684b4 c02931b8 c052a8e8 c398f420 c052a8e8 00000000

          In board-da850-evm.c,

    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    {
    .name = "tw9910",
    .board_info = {
    I2C_BOARD_INFO("tw9910", 0x45),
    .platform_data = (void *)1,      //Value:1 cause NULL pointer, is it right?
    },
    .vpif_if = {
    .if_type = VPIF_IF_RAW_BAYER,
    .hd_pol = 0,
    .vd_pol = 0,
    .fid_pol = 0,
    },
    },
    };

        Full board-da850-evm.c is:

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/clk.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/input.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/gpio_keys.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/mtd/physmap.h>
    #include <linux/regulator/machine.h>
    #include <linux/regulator/tps6507x.h>
    #include <linux/input/tps6507x-ts.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/delay.h>
    #include <linux/wl12xx.h>
    #include <linux/pwm_backlight.h>
    #include <linux/i2c-gpio.h>
    #include <linux/videodev2.h>
    #include <linux/module.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <linux/mfd/davinci_aemif.h>
    #include <mach/spi.h>
    #include <mach/usb.h>
    #include <media/tvp514x.h>
    #include <media/davinci/vpif_types.h>
    
    #include <media/tw9910.h>
    
    #define DA850_EVM_PHY_ID		"davinci_mdio-0:00"
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_WLAN_EN			GPIO_TO_PIN(6, 9)
    #define DA850_WLAN_IRQ			GPIO_TO_PIN(6, 10)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #define DAVINCI_BACKLIGHT_MAX_BRIGHTNESS	250
    #define DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS	250
    #define DAVINCI_PWM_PERIOD_NANO_SECONDS		10000000
    
    
    static struct platform_pwm_backlight_data da850evm_backlight_data = {
    	.max_brightness	= DAVINCI_BACKLIGHT_MAX_BRIGHTNESS,
    	.dft_brightness	= DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS,
    	.pwm_period_ns	= DAVINCI_PWM_PERIOD_NANO_SECONDS,
    };
    
    static struct platform_device da850evm_backlight = {
    	.name		= "pwm-backlight",
    	.id		= -1,
    };
    
    static struct mtd_partition da850evm_spiflash_part[] = {
    	[0] = {
    		.name = "UBL",
    		.offset = 0,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_512K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "U-Boot-Env",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[3] = {
    		.name = "Kernel",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_2M + SZ_512K,
    		.mask_flags = 0,
    	},
    	[4] = {
    		.name = "Filesystem",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_4M,
    		.mask_flags = 0,
    	},
    	[5] = {
    		.name = "MAC-Address",
    		.offset = SZ_8M - SZ_64K,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    };
    
    static struct flash_platform_data da850evm_spiflash_data = {
    	.name		= "m25p80",
    	.parts		= da850evm_spiflash_part,
    	.nr_parts	= ARRAY_SIZE(da850evm_spiflash_part),
    	.type		= "m25p64",
    };
    
    static struct davinci_spi_config da850evm_spiflash_cfg = {
    	.io_type	= SPI_IO_TYPE_DMA,
    	.c2tdelay	= 8,
    	.t2cdelay	= 8,
    };
    
    static struct spi_board_info da850evm_spi_info[] = {
    	{
    		.modalias		= "m25p80",
    		.platform_data		= &da850evm_spiflash_data,
    		.controller_data	= &da850evm_spiflash_cfg,
    		.mode			= SPI_MODE_0,
    		.max_speed_hz		= 30000000,
    		.bus_num		= 1,
    		.chip_select		= 0,
    	},
    };
    
    #define TVP5147_CH0		"tvp514x-0"
    #define TVP5147_CH1		"tvp514x-1"
    
    #define VPIF_STATUS		0x002c
    #define VPIF_STATUS_CLR		0x0030
    
    #ifdef CONFIG_MTD
    static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
    {
    	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
    	size_t retlen;
    
    	if (!strcmp(mtd->name, "MAC-Address")) {
    		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
    		if (retlen == ETH_ALEN)
    			pr_info("Read MAC addr from SPI Flash: %pM\n",
    				mac_addr);
    	}
    }
    
    static struct mtd_notifier da850evm_spi_notifier = {
    	.add	= da850_evm_m25p80_notify_add,
    };
    
    static void da850_evm_setup_mac_addr(void)
    {
    	register_mtd_user(&da850evm_spi_notifier);
    }
    #else
    static void da850_evm_setup_mac_addr(void) { }
    #endif
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_4M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct physmap_flash_data da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    static struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.bbt_options	= NAND_BBT_USE_FLASH,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_devices[] = {
    	{
    		.name		= "davinci_nand",
    		.id		= 1,
    		.dev		= {
    			.platform_data	= &da850_evm_nandflash_data,
    		},
    		.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    		.resource	= da850_evm_nandflash_resource,
    	},
    #if !defined(CONFIG_MMC_DAVINCI) || \
        !defined(CONFIG_MMC_DAVINCI_MODULE)
    	{
    		.name		= "physmap-flash",
    		.id		= 0,
    		.dev		= {
    			.platform_data  = &da850_evm_norflash_data,
    		},
    		.num_resources	= 1,
    		.resource	= da850_evm_norflash_resource,
    
    	},
    #endif
    };
    static struct davinci_aemif_devices da850_emif_devices = {
    	.devices	= da850_evm_devices,
    	.num_devices	= ARRAY_SIZE(da850_evm_devices),
    };
    
    static struct platform_device davinci_emif_device = {
    	.name	= "davinci_aemif",
    	.id	= -1,
    	.dev	= {
    		.platform_data	= &da850_emif_devices,
    	},
    };
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static void __init da850_evm_init_nor(void)
    {
    	void __iomem *aemif_addr;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	/* Configure data bus width of CS2 to 16 bit */
    	writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
    		DA8XX_AEMIF_ASIZE_16BIT,
    		aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    static const short da850_evm_nand_pins[] = {
    	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
    	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
    	DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
    	DA850_NEMA_WE, DA850_NEMA_OE,
    	-1
    };
    
    static const short da850_evm_nor_pins[] = {
    	DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
    	DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
    	DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
    	DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
    	DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
    	DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
    	DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
    	DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
    	DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
    	DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
    	DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
    	DA850_EMA_A_22, DA850_EMA_A_23,
    	-1
    };
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    #if defined(CONFIG_SPI_DAVINCI)
    #define HAS_SPI 1
    #else
    #define HAS_SPI 0
    #endif
    
    #if defined(CONFIG_FB_DA8XX)
    #define HAS_LCD	1
    #else
    #define HAS_LCD	0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DAVINCI_EHRPWM) || defined(CONFIG_DAVINCI_EHRPWM_MODULE)
    #define HAS_EHRPWM 1
    #else
    #define HAS_EHRPWM 0
    #endif
    
    #if defined(CONFIG_ECAP_PWM) || \
    	defined(CONFIG_ECAP_PWM_MODULE)
    #define HAS_ECAP_PWM 1
    #else
    #define HAS_ECAP_PWM 0
    #endif
    
    #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
    #define HAS_BACKLIGHT 1
    #else
    #define HAS_BACKLIGHT 0
    #endif
    
    #if defined(CONFIG_ECAP_CAP) || defined(CONFIG_ECAP_CAP_MODULE)
    #define HAS_ECAP_CAP 1
    #else
    #define HAS_ECAP_CAP 0
    #endif
    
    /* have_imager() - Check if we have support for imager interface */
    static inline int have_imager(void)
    {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	return 1;
    #else
    	return 0;
    #endif
    }
    
    static inline void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    	ret = davinci_cfg_reg_list(da850_evm_nand_pins);
    	if (ret)
    		pr_warning("da850_evm_init: nand mux setup failed: "
    				"%d\n", ret);
    
    	if (!HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] low for NOR to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = davinci_cfg_reg_list(da850_evm_nor_pins);
    		if (ret)
    			pr_warning("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    
    		da850_evm_init_nor();
    	} else {
    		/*
    		 * On Logic PD Rev.3 EVMs GP0[11] pin needs to be configured
    		 * for MMC and NOR to work. When GP0[11] is low, the SD0
    		 * interface will not work, but NOR flash will. When GP0[11]
    		 * is high, SD0 will work but NOR flash will not. By default
    		 * we are assuming that GP0[11] pin is driven high, when UI
    		 * card is not connected. Hence we are not configuring the
    		 * GP0[11] pin when MMC/SD is enabled and UI card is not
    		 * connected. Not configuring the GPIO pin will enable the
    		 * bluetooth to work on AM18x as it requires the GP0[11]
    		 * pin for UART flow control.
    		 */
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			pr_warning("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			pr_warning("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    	}
    
    	platform_device_register(&davinci_emif_device);
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value_cansleep(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    
    #define DA850_KEYS_DEBOUNCE_MS	10
    /*
     * At 200ms polling interval it is possible to miss an
     * event by tapping very lightly on the push button but most
     * pushes do result in an event; longer intervals require the
     * user to hold the button whereas shorter intervals require
     * more CPU time for polling.
     */
    #define DA850_GPIO_KEYS_POLL_MS	200
    
    enum da850_evm_ui_exp_pins {
    	DA850_EVM_UI_EXP_SEL_C = 5,
    	DA850_EVM_UI_EXP_SEL_B,
    	DA850_EVM_UI_EXP_SEL_A,
    	DA850_EVM_UI_EXP_PB8,
    	DA850_EVM_UI_EXP_PB7,
    	DA850_EVM_UI_EXP_PB6,
    	DA850_EVM_UI_EXP_PB5,
    	DA850_EVM_UI_EXP_PB4,
    	DA850_EVM_UI_EXP_PB3,
    	DA850_EVM_UI_EXP_PB2,
    	DA850_EVM_UI_EXP_PB1,
    };
    
    static const char const *da850_evm_ui_exp[] = {
    	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c",
    	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b",
    	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a",
    	[DA850_EVM_UI_EXP_PB8]          = "pb8",
    	[DA850_EVM_UI_EXP_PB7]          = "pb7",
    	[DA850_EVM_UI_EXP_PB6]          = "pb6",
    	[DA850_EVM_UI_EXP_PB5]          = "pb5",
    	[DA850_EVM_UI_EXP_PB4]          = "pb4",
    	[DA850_EVM_UI_EXP_PB3]          = "pb3",
    	[DA850_EVM_UI_EXP_PB2]          = "pb2",
    	[DA850_EVM_UI_EXP_PB1]          = "pb1",
    };
    
    #define DA850_N_UI_PB		8
    
    static struct gpio_keys_button da850_evm_ui_keys[] = {
    	[0 ... DA850_N_UI_PB - 1] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
    	.buttons = da850_evm_ui_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_ui_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 0,
    	.dev = {
    		.platform_data = &da850_evm_ui_keys_pdata
    	},
    };
    
    static void da850_evm_ui_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	for (i = 0; i < DA850_N_UI_PB; i++) {
    		button = &da850_evm_ui_keys[i];
    		button->code = KEY_F8 - i;
    		button->desc = (char *)
    				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
    		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
    	}
    }
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value_cansleep(a, 0);
    	gpio_set_value_cansleep(b, 0);
    	gpio_set_value_cansleep(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value_cansleep(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CAMERA
    static inline void da850_evm_setup_camera(int camera_sel)
    {
    	gpio_set_value_cansleep(camera_sel, 0);
    }
    #else
    static inline void da850_evm_setup_camera(int camera_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
    	sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
    	sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
    
    	ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
    	if (ret) {
    		pr_warning("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	da850_evm_ui_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_ui_keys_device);
    	if (ret) {
    		pr_warning("Could not register UI GPIO expander push-buttons");
    		goto exp_setup_keys_fail;
    	}
    
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	da850_evm_setup_camera(sel_b);
    
    	return 0;
    
    exp_setup_keys_fail:
    	gpio_free(sel_c);
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_ui_keys_device);
    
    	/* deselect all functionalities */
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
    
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
    
    	return 0;
    }
    
    /* assign the baseboard expander's GPIOs after the UI board's */
    #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
    #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
    
    enum da850_evm_bb_exp_pins {
    	DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
    	DA850_EVM_BB_EXP_SW_RST,
    	DA850_EVM_BB_EXP_TP_23,
    	DA850_EVM_BB_EXP_TP_22,
    	DA850_EVM_BB_EXP_TP_21,
    	DA850_EVM_BB_EXP_USER_PB1,
    	DA850_EVM_BB_EXP_USER_LED2,
    	DA850_EVM_BB_EXP_USER_LED1,
    	DA850_EVM_BB_EXP_USER_SW1,
    	DA850_EVM_BB_EXP_USER_SW2,
    	DA850_EVM_BB_EXP_USER_SW3,
    	DA850_EVM_BB_EXP_USER_SW4,
    	DA850_EVM_BB_EXP_USER_SW5,
    	DA850_EVM_BB_EXP_USER_SW6,
    	DA850_EVM_BB_EXP_USER_SW7,
    	DA850_EVM_BB_EXP_USER_SW8
    };
    
    static const char const *da850_evm_bb_exp[] = {
    	[DA850_EVM_BB_EXP_DEEP_SLEEP_EN]	= "deep_sleep_en",
    	[DA850_EVM_BB_EXP_SW_RST]		= "sw_rst",
    	[DA850_EVM_BB_EXP_TP_23]		= "tp_23",
    	[DA850_EVM_BB_EXP_TP_22]		= "tp_22",
    	[DA850_EVM_BB_EXP_TP_21]		= "tp_21",
    	[DA850_EVM_BB_EXP_USER_PB1]		= "user_pb1",
    	[DA850_EVM_BB_EXP_USER_LED2]		= "user_led2",
    	[DA850_EVM_BB_EXP_USER_LED1]		= "user_led1",
    	[DA850_EVM_BB_EXP_USER_SW1]		= "user_sw1",
    	[DA850_EVM_BB_EXP_USER_SW2]		= "user_sw2",
    	[DA850_EVM_BB_EXP_USER_SW3]		= "user_sw3",
    	[DA850_EVM_BB_EXP_USER_SW4]		= "user_sw4",
    	[DA850_EVM_BB_EXP_USER_SW5]		= "user_sw5",
    	[DA850_EVM_BB_EXP_USER_SW6]		= "user_sw6",
    	[DA850_EVM_BB_EXP_USER_SW7]		= "user_sw7",
    	[DA850_EVM_BB_EXP_USER_SW8]		= "user_sw8",
    };
    
    #define DA850_N_BB_USER_SW	8
    
    static struct gpio_keys_button da850_evm_bb_keys[] = {
    	[0] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= KEY_PROG1,
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    	[1 ... DA850_N_BB_USER_SW] = {
    		.type			= EV_SW,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
    	.buttons = da850_evm_bb_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_bb_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 1,
    	.dev = {
    		.platform_data = &da850_evm_bb_keys_pdata
    	},
    };
    
    static void da850_evm_bb_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	button = &da850_evm_bb_keys[0];
    	button->desc = (char *)
    		da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
    	button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
    
    	for (i = 0; i < DA850_N_BB_USER_SW; i++) {
    		button = &da850_evm_bb_keys[i + 1];
    		button->code = SW_LID + i;
    		button->desc = (char *)
    				da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
    		button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
    	}
    }
    
    #define DA850_N_BB_USER_LED	2
    
    static struct gpio_led da850_evm_bb_leds[] = {
    	[0 ... DA850_N_BB_USER_LED - 1] = {
    		.active_low = 1,
    		.gpio = -1, /* assigned at runtime */
    		.name = NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
    	.leds = da850_evm_bb_leds,
    	.num_leds = ARRAY_SIZE(da850_evm_bb_leds),
    };
    
    static struct platform_device da850_evm_bb_leds_device = {
    	.name		= "leds-gpio",
    	.id		= -1,
    	.dev = {
    		.platform_data = &da850_evm_bb_leds_pdata
    	}
    };
    
    static void da850_evm_bb_leds_init(unsigned gpio)
    {
    	int i;
    	struct gpio_led *led;
    
    	for (i = 0; i < DA850_N_BB_USER_LED; i++) {
    		led = &da850_evm_bb_leds[i];
    
    		led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
    		led->name =
    			da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
    	}
    }
    
    static int da850_evm_bb_expander_setup(struct i2c_client *client,
    						unsigned gpio, unsigned ngpio,
    						void *c)
    {
    	int ret;
    
    	/*
    	 * Register the switches and pushbutton on the baseboard as a gpio-keys
    	 * device.
    	 */
    	da850_evm_bb_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_keys_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander keys");
    		goto io_exp_setup_sw_fail;
    	}
    
    	da850_evm_bb_leds_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_leds_device);
    	if (ret) {
    		pr_warning("Could not register baseboard GPIO expander LEDS");
    		goto io_exp_setup_leds_fail;
    	}
    
    	return 0;
    
    io_exp_setup_leds_fail:
    	platform_device_unregister(&da850_evm_bb_keys_device);
    io_exp_setup_sw_fail:
    	return ret;
    }
    
    static int da850_evm_bb_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_bb_leds_device);
    	platform_device_unregister(&da850_evm_bb_keys_device);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    	.names		= da850_evm_ui_exp,
    };
    
    static struct pca953x_platform_data da850_evm_bb_expander_info = {
    	.gpio_base	= DA850_BB_EXPANDER_GPIO_BASE,
    	.setup		= da850_evm_bb_expander_setup,
    	.teardown	= da850_evm_bb_expander_teardown,
    	.names		= da850_evm_bb_exp,
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    /*
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x21),
    		.platform_data = &da850_evm_bb_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    	{
    		I2C_BOARD_INFO("PCA9543A", 0x73),
    	},
    	{
    		I2C_BOARD_INFO("tw9910", 0x45),
    	},
    */	
    };
    
    /*
     * USB1 VBUS is controlled by GPIO2[4], over-current is reported on GPIO6[13].
     */
    #define ON_BD_USB_DRV	GPIO_TO_PIN(2, 4)
    #define ON_BD_USB_OVC	GPIO_TO_PIN(6, 13)
    
    static const short da850_evm_usb11_pins[] = {
    	DA850_GPIO2_4, DA850_GPIO6_13,
    	-1
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.type			= GPIO_BASED,
    	.method	= {
    		.gpio_method = {
    			.power_control_pin	= ON_BD_USB_DRV,
    			.over_current_indicator = ON_BD_USB_OVC,
    		},
    	},
    	.board_ocic_handler	= da850_evm_usb_ocic_irq,
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *handler)
    {
    	if (handler != NULL)
    		((da8xx_ocic_handler_t)handler)(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static __init void da850_evm_usb_init(void)
    {
    	u32 cfgchip2;
    	int ret;
    
    	/*
    	 * Set up USB clock/mode in the CFGCHIP2 register.
    	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/* USB2.0 PHY reference clock is 24 MHz */
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    
    	/*
    	 * Select internal reference clock for USB 2.0 PHY
    	 * and use it as a clock source for USB 1.1 PHY
    	 * (this is the default setting anyway).
    	 */
    	cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
    	cfgchip2 |=  CFGCHIP2_USB2PHYCLKMUX;
    	/*
    	 * We have to override VBUS/ID signals when MUSB is configured into the
    	 * host-only mode -- ID pin will float if no cable is connected, so the
    	 * controller won't be able to drive VBUS thinking that it's a B-device.
    	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
    	 */
    	cfgchip2 &= ~CFGCHIP2_OTGMODE;
    	cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
    
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/*
    	 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
    	 * with the power on to power good time of 3 ms.
    	 */
    	ret = da8xx_register_usb20(1000, 3);
    	if (ret)
    		pr_warning("%s: USB 2.0 registration failed: %d\n",
    			   __func__, ret);
    
    	/* initilaize usb module */
    	da8xx_board_usb_init(da850_evm_usb11_pins, &da850_evm_usb11_pdata);
    }
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.asp_chan_q	= EVENTQ_0,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static const short da850_evm_mcasp_pins[] __initconst = {
    	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
    	DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
    	DA850_AXR_11, DA850_AXR_12,
    	-1
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_evm_mmcsd0_pins[] __initconst = {
    	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
    	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
    	DA850_GPIO4_0, DA850_GPIO4_1,
    	-1
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value_cansleep(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value_cansleep(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	int status;
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    /* We take advantage of the fact that both defdcdc{2,3} are tied high */
    static struct tps6507x_reg_platform_data tps6507x_platform_data = {
    	.defdcdc_default = true,
    };
    
    static struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1350000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct touchscreen_init_data tps6507x_touchscreen_data = {
    	.poll_period =  30,	/* ms between touch samples */
    	.min_pressure = 0x30,	/* minimum pressure to trigger touch */
    	.vref = 0,		/* turn off vref when not using A/D */
    	.vendor = 0,		/* /sys/class/input/input?/id/vendor */
    	.product = 65070,	/* /sys/class/input/input?/id/product */
    	.version = 0x100,	/* /sys/class/input/input?/id/version */
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    	.tps6507x_ts_init_data = &tps6507x_touchscreen_data,
    };
    
    static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    };
    
    static int __init pmic_tps65070_init(void)
    {
    	return i2c_register_board_info(1, da850_evm_tps65070_info,
    					ARRAY_SIZE(da850_evm_tps65070_info));
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static struct i2c_client *pca9543a;
    
    static int pca9543a_probe(struct i2c_client *client,
    		const struct i2c_device_id *id)
    {
    	pr_info("pca9543a_probe");
    	pca9543a = client;
    	return 0;
    }
    
    static int pca9543a_remove(struct i2c_client *client)
    {
    	pca9543a = NULL;
    	return 0;
    }
    
    static const struct i2c_device_id pca9543a_ids[] = {
    	{ "PCA9543A", 0, },
    	{ /* end of list */ },
    };
    
    #if 0
    /* This is for i2c driver for the MT9T031 header i2c switch */
    static struct i2c_driver pca9543a_driver = {
    	.driver.name	= "PCA9543A",
    	.id_table	= pca9543a_ids,
    	.probe		= pca9543a_probe,
    	.remove		= pca9543a_remove,
    };
    #endif
    
    /**
     * da850_enable_pca9543a() - Enable/Disable I2C switch PCA9543A for sensor
     * @en: enable/disable flag
     */
    static int da850_enable_pca9543a(int en)
    {
    	static char val = 1;
    	int status;
    	struct i2c_msg msg = {
    			.flags = 0,
    			.len = 1,
    			.buf = &val,
    		};
    
    	pr_info("da850evm_enable_pca9543a\n");
    	if (!en)
    		val = 0;
    
    	if (!pca9543a)
    		return -ENXIO;
    
    	msg.addr = pca9543a->addr;
    	/* turn i2c switch, pca9543a, on/off */
    	status = i2c_transfer(pca9543a->adapter, &msg, 1);
    	pr_info("da850evm_enable_pca9543a, status = %d\n", status);
    	return status;
    }
    
    static const short da850_evm_mii_pins[] = {
    	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
    	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
    	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
    	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static const short da850_evm_rmii_pins[] = {
    	DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
    	DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
    	DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_mii_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		pr_warning("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		pr_warning("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		pr_warning("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = "tw9910",//"mt9t031",
    	},
    };
    
    /*
     * The following EDMA channels/slots are not being used by drivers (for
     * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
     * they are being reserved for codecs on the DSP side.
     */
    static const s16 da850_dma0_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma0_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30, 50},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30, 90},
    	{-1, -1}
    };
    
    static struct edma_rsv_info da850_edma_cc0_rsv = {
    	.rsv_chans	= da850_dma0_rsv_chans,
    	.rsv_slots	= da850_dma0_rsv_slots,
    };
    
    static struct edma_rsv_info da850_edma_cc1_rsv = {
    	.rsv_chans	= da850_dma1_rsv_chans,
    	.rsv_slots	= da850_dma1_rsv_slots,
    };
    
    static struct edma_rsv_info *da850_edma_rsv[2] = {
    	&da850_edma_cc0_rsv,
    	&da850_edma_cc1_rsv,
    };
    
    #ifdef CONFIG_CPU_FREQ
    static __init int da850_evm_init_cpufreq(void)
    {
    	switch (system_rev & 0xF) {
    	case 3:
    		da850_max_speed = 456000;
    		break;
    	case 2:
    		da850_max_speed = 408000;
    		break;
    	case 1:
    		da850_max_speed = 372000;
    		break;
    	}
    
    	return da850_register_cpufreq("pll0_sysclk3");
    }
    #else
    static __init int da850_evm_init_cpufreq(void) { return 0; }
    #endif
    
    #if defined(CONFIG_DAVINCI_UART1_AFE)
    #define HAS_UART1_AFE 1
    #else
    #define HAS_UART1_AFE 0
    #endif
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    int da850_vpif_setup_input_path(int ch, const char *name)
    {
    	int ret = 1;
    
    	 //if (!strcmp(name, "mt9t031") && have_imager())
    	 if (!strcmp(name, "tw9910") && have_imager())
    		ret = da850_enable_pca9543a(1);
    
    	return ret;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    #endif
    
    #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct i2c_board_info tw9910_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9910", 0x45),
        },
    };
    
    static struct tw9910_video_info tw9910_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout        = TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    //    .power        = tw9910_power,
        .board_info    = &tw9910_i2c_camera[0],
        .i2c_adapter_id    = 0,
    	.bus_id		= 1,
        .priv        = &tw9910_info,
    };
    
    static struct platform_device tw9910_camera[] = {
        {
            .name    = "TW9910 soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9910_link,
            },
        },
    };
    
    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };
    
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	{
    		.name	= "tw9910",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = (void *)1,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #elif defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	{
    		.name	= TVP5147_CH0,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5d),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_CVBS_VI2B,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	{
    		.name	= TVP5147_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    #endif
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH0,
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	//.setup_input_path = da850_vpif_setup_input_path,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	.chan_config[0] = {
    		.inputs = da850_ch0_inputs,
    		.input_count = ARRAY_SIZE(da850_ch0_inputs),
    	},
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    #elif defined(CONFIG_DA850_UI_CAMERA)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    #endif
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    #ifdef CONFIG_DA850_WL12XX
    
    static void wl12xx_set_power(int index, bool power_on)
    {
    	static bool power_state;
    
    	pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
    
    	if (power_on == power_state)
    		return;
    	power_state = power_on;
    
    	if (power_on) {
    		/* Power up sequence required for wl127x devices */
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		usleep_range(15000, 15000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    		usleep_range(1000, 1000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		msleep(70);
    	} else {
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    	}
    }
    
    static struct davinci_mmc_config da850_wl12xx_mmc_config = {
    	.set_power	= wl12xx_set_power,
    	.wires		= 4,
    	.max_freq	= 25000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    			  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_wl12xx_pins[] __initconst = {
    	DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
    	DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
    	DA850_GPIO6_9, DA850_GPIO6_10,
    	-1
    };
    
    static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
    	.irq			= -1,
    	.board_ref_clock	= WL12XX_REFCLOCK_38,
    	.platform_quirks	= WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    };
    
    static __init int da850_wl12xx_init(void)
    {
    	int ret;
    
    	ret = davinci_cfg_reg_list(da850_wl12xx_pins);
    	if (ret) {
    		pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
    	if (ret) {
    		pr_err("wl12xx/mmc registration failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
    	if (ret) {
    		pr_err("Could not request wl12xx enable gpio: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
    	if (ret) {
    		pr_err("Could not request wl12xx irq gpio: %d\n", ret);
    		goto free_wlan_en;
    	}
    
    	da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
    
    	ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
    	if (ret) {
    		pr_err("Could not set wl12xx data: %d\n", ret);
    		goto free_wlan_irq;
    	}
    
    	return 0;
    
    free_wlan_irq:
    	gpio_free(DA850_WLAN_IRQ);
    
    free_wlan_en:
    	gpio_free(DA850_WLAN_EN);
    
    exit:
    	return ret;
    }
    
    #else /* CONFIG_DA850_WL12XX */
    
    static __init int da850_wl12xx_init(void)
    {
    	return 0;
    }
    
    #endif /* CONFIG_DA850_WL12XX */
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init int da850_set_emif_clk_rate(void)
    {
    	struct clk *emif_clk;
    
    	emif_clk = clk_get(NULL, "pll0_sysclk3");
    	if (WARN(IS_ERR(emif_clk), "Unable to get emif clock\n"))
    		return PTR_ERR(emif_clk);
    
    	return clk_set_rate(emif_clk, CONFIG_DA850_FIX_PLL0_SYSCLK3RATE);
    }
    
    struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
    	.pintc_base	= 0x4000,
    };
    
    #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    	char mask = 0;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	ret = pmic_tps65070_init();
    	if (ret)
    		pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
    				ret);
    
    	/*
    	 * Though bootloader takes care to set emif clock at allowed
    	 * possible rate. Kernel needs to reconfigure this rate to
    	 * support platforms requiring fixed emif clock rate.
    	 */
    	ret = da850_set_emif_clk_rate();
    	if (ret)
    		pr_warning("da850_evm_init: Failed to set rate of pll0_sysclk3/emif clock: %d\n",
    				ret);
    
    	ret = da850_register_edma(da850_edma_rsv);
    	if (ret)
    		pr_warning("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = davinci_cfg_reg_list(da850_i2c0_pins);
    	if (ret)
    		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		pr_warning("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	/* Support for UART 1 */
    	ret = davinci_cfg_reg_list(da850_uart1_pins);
    	if (ret)
    		pr_warning("da850_evm_init: UART 1 mux setup failed:"
    						" %d\n", ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			pr_warning("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			pr_warning("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    
    		ret = da850_wl12xx_init();
    		if (ret)
    			pr_warning("da850_evm_init: wl12xx initialization"
    				   " failed: %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    /*
    	if (have_imager())
    		i2c_add_driver(&pca9543a_driver);
    */
    
    	i2c_register_board_info(1, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	if (HAS_MCASP) {
    		if (HAS_UART1_AFE)
    			pr_warning("WARNING: both McASP and UART1_AFE are "
    				"enabled, but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
    		if (ret)
    			pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
    					ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
    	if (ret)
    		pr_warning("%s: pruss_uio initialization failed: %d\n",
    				__func__, ret);	
    
    	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
    	if (ret)
    		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
    	if (ret)
    		pr_warning("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    
    	ret = da850_lcd_hw_init();
    	if (ret)
    		pr_warning("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		pr_warning("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_evm_init_cpufreq();
    	if (ret)
    		pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		pr_warning("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		ret = da850_register_vpif();
    		if (ret)
    			pr_warning("da850_evm_init: VPIF setup failed: %d\n",
    				   ret);
    		//platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
    	}
    
    	if (HAS_VPIF_CAPTURE) {
    		ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture mux failed:"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF capture setup failed:"
    					"%d\n", ret);
    		//HUANYI_SYSTEM LiChangsheng add
    		platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
    	}
    
    	if (HAS_VPIF_DISPLAY) {
    		ret = davinci_cfg_reg_list(da850_vpif_display_pins);
    		if (ret)
    			pr_warning("da850_evm_init : VPIF capture mux failed :"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_display(&da850_vpif_display_config);
    		if (ret)
    			pr_warning("da850_evm_init: VPIF display setup failed:"
    					"%d\n", ret);
    	}
    
    	ret = da8xx_register_spi(1, da850evm_spi_info,
    				 ARRAY_SIZE(da850evm_spi_info));
    	if (ret)
    		pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
    				ret);
    
    	ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
    	if (ret)
    		pr_warning("da850_evm_init: sata registration failed: %d\n",
    				ret);
    
    	da850_evm_setup_mac_addr();
    
    	da850_evm_usb_init();
    
    	if (HAS_EHRPWM) {
    		if (rmii_en) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm0_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" ehrpwm0 mux setup failed: %d\n", ret);
    			else
    				mask = BIT(0) | BIT(1);
    		} else {
    			pr_warning("da850_evm_init:"
    			" eHRPWM module 0 cannot be used"
    			" since it is being used by MII interface\n");
    			mask = 0;
    		}
    
    		if (!HAS_LCD) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm1_pins);
    			if (ret)
    				pr_warning("da850_evm_init:"
    				" eHRPWM module1 output A mux"
    				" setup failed %d\n", ret);
    			else
    				mask = mask | BIT(2);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputA cannot be"
    				" used since it is being used by LCD\n");
    		}
    
    		if (!HAS_SPI) {
    			ret = davinci_cfg_reg(DA850_EHRPWM1_B);
    			if (ret)
    				pr_warning("da850_evm_init:"
    					" eHRPWM module1 outputB mux"
    					" setup failed %d\n", ret);
    		else
    			mask =  mask  | BIT(3);
    		} else {
    			pr_warning("da850_evm_init:"
    				" eHRPWM module1 outputB cannot be"
    				" used since it is being used by spi1\n");
    		}
    
    		da850_register_ehrpwm(mask);
    	}
    
    	if (HAS_ECAP_PWM) {
    		ret = davinci_cfg_reg(DA850_ECAP2_APWM2);
    		if (ret)
    			pr_warning("da850_evm_init:ecap mux failed:"
    					" %d\n", ret);
    		ret = da850_register_ecap(2);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" eCAP registration failed: %d\n", ret);
    	}
    
    	if (HAS_BACKLIGHT) {
    		ret = da850_register_backlight(&da850evm_backlight,
    				&da850evm_backlight_data);
    		if (ret)
    			pr_warning("da850_evm_init:"
    				" backlight device registration"
    				" failed: %d\n", ret);
    	}
    
    	if (HAS_ECAP_CAP) {
    		if (HAS_MCASP)
    			pr_warning("da850_evm_init:"
    				"ecap module 1 cannot be used "
    				"since it shares pins with McASP\n");
    		else {
    			ret = davinci_cfg_reg(DA850_ECAP1_APWM1);
    			if (ret)
    				pr_warning("da850_evm_init:ecap mux failed:%d\n"
    						, ret);
    			else {
    				ret = da850_register_ecap_cap(1);
    				if (ret)
    					pr_warning("da850_evm_init"
    					"eCAP registration failed: %d\n", ret);
    			}
    		}
    	}
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
    	.atag_offset	= 0x100,
    	.map_io		= da850_evm_map_io,
    	.init_irq	= cp_intc_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    	.dma_zone_size	= SZ_128M,
    	.restart	= da8xx_restart,
    MACHINE_END
    

        Thanks.

     

     

     

  • Hi Titusrathinaraj:

         I am sorry! And thanks very much for your help!

         I think this error is caused by :

         .platform_data = (void *)1,  

         I donn't understand these para.

        Can you spend more some time to this problem?

        Thanks.

  • Hi Chang,

        It seems VPIF registered ok.


    Earlier, You have told that you fixed it know!

    What happened now?

    Still Are you facing any issues and Have you changed anything after got fixed?

    This errors seems that getting the same error again which you posted initially,

  • Hi Titusrathinaraj:

        Sorry! I make a misstake earlier! Because I disable SOC CAMERA!

        Thanks.

  • Hi,

        Sorry! I make a misstake earlier! Because I disable SOC CAMERA!


    Okay, No problem, Human errors!

    I have modified the board file for your TW9910,

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/clk.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/input.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/gpio_keys.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/mtd/physmap.h>
    #include <linux/regulator/machine.h>
    #include <linux/regulator/tps6507x.h>
    #include <linux/input/tps6507x-ts.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/delay.h>
    #include <linux/wl12xx.h>
    #include <linux/pwm_backlight.h>
    #include <linux/i2c-gpio.h>
    #include <linux/videodev2.h>
    #include <linux/module.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <linux/mfd/davinci_aemif.h>
    #include <mach/spi.h>
    #include <mach/usb.h>
    #include <media/tvp514x.h>
    #include <media/davinci/vpif_types.h>
    
    #include <media/tw9910.h>
    
    
    #define DA850_EVM_PHY_ID		"davinci_mdio-0:00"
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_WLAN_EN			GPIO_TO_PIN(6, 9)
    #define DA850_WLAN_IRQ			GPIO_TO_PIN(6, 10)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #define DAVINCI_BACKLIGHT_MAX_BRIGHTNESS	250
    #define DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS	250
    #define DAVINCI_PWM_PERIOD_NANO_SECONDS		10000000
    
    
    static struct platform_pwm_backlight_data da850evm_backlight_data = {
    	.max_brightness	= DAVINCI_BACKLIGHT_MAX_BRIGHTNESS,
    	.dft_brightness	= DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS,
    	.pwm_period_ns	= DAVINCI_PWM_PERIOD_NANO_SECONDS,
    };
    
    static struct platform_device da850evm_backlight = {
    	.name		= "pwm-backlight",
    	.id		= -1,
    };
    
    static struct mtd_partition da850evm_spiflash_part[] = {
    	[0] = {
    		.name = "UBL",
    		.offset = 0,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_512K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "U-Boot-Env",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[3] = {
    		.name = "Kernel",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_2M + SZ_512K,
    		.mask_flags = 0,
    	},
    	[4] = {
    		.name = "Filesystem",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_4M,
    		.mask_flags = 0,
    	},
    	[5] = {
    		.name = "MAC-Address",
    		.offset = SZ_8M - SZ_64K,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    };
    
    static struct flash_platform_data da850evm_spiflash_data = {
    	.name		= "m25p80",
    	.parts		= da850evm_spiflash_part,
    	.nr_parts	= ARRAY_SIZE(da850evm_spiflash_part),
    	.type		= "m25p64",
    };
    
    static struct davinci_spi_config da850evm_spiflash_cfg = {
    	.io_type	= SPI_IO_TYPE_DMA,
    	.c2tdelay	= 8,
    	.t2cdelay	= 8,
    };
    
    static struct spi_board_info da850evm_spi_info[] = {
    	{
    		.modalias		= "m25p80",
    		.platform_data		= &da850evm_spiflash_data,
    		.controller_data	= &da850evm_spiflash_cfg,
    		.mode			= SPI_MODE_0,
    		.max_speed_hz		= 30000000,
    		.bus_num		= 1,
    		.chip_select		= 0,
    	},
    };
    
    #define TVP5147_CH0		"tvp514x-0"
    #define TVP5147_CH1		"tvp514x-1"
    
    #define VPIF_STATUS		0x002c
    #define VPIF_STATUS_CLR		0x0030
    
    #ifdef CONFIG_MTD
    static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
    {
    	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
    	size_t retlen;
    
    	if (!strcmp(mtd->name, "MAC-Address")) {
    		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
    		if (retlen == ETH_ALEN)
    			pr_info("Read MAC addr from SPI Flash: %pM\n",
    				mac_addr);
    	}
    }
    
    static struct mtd_notifier da850evm_spi_notifier = {
    	.add	= da850_evm_m25p80_notify_add,
    };
    
    static void da850_evm_setup_mac_addr(void)
    {
    	register_mtd_user(&da850evm_spi_notifier);
    }
    #else
    static void da850_evm_setup_mac_addr(void) { }
    #endif
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_4M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct physmap_flash_data da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    static struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.bbt_options	= NAND_BBT_USE_FLASH,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_devices[] = {
    	{
    		.name		= "davinci_nand",
    		.id		= 1,
    		.dev		= {
    			.platform_data	= &da850_evm_nandflash_data,
    		},
    		.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    		.resource	= da850_evm_nandflash_resource,
    	},
    #if !defined(CONFIG_MMC_DAVINCI) || \
        !defined(CONFIG_MMC_DAVINCI_MODULE)
    	{
    		.name		= "physmap-flash",
    		.id		= 0,
    		.dev		= {
    			.platform_data  = &da850_evm_norflash_data,
    		},
    		.num_resources	= 1,
    		.resource	= da850_evm_norflash_resource,
    
    	},
    #endif
    };
    static struct davinci_aemif_devices da850_emif_devices = {
    	.devices	= da850_evm_devices,
    	.num_devices	= ARRAY_SIZE(da850_evm_devices),
    };
    
    static struct platform_device davinci_emif_device = {
    	.name	= "davinci_aemif",
    	.id	= -1,
    	.dev	= {
    		.platform_data	= &da850_emif_devices,
    	},
    };
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static void __init da850_evm_init_nor(void)
    {
    	void __iomem *aemif_addr;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	/* Configure data bus width of CS2 to 16 bit */
    	writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
    		DA8XX_AEMIF_ASIZE_16BIT,
    		aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    static const short da850_evm_nand_pins[] = {
    	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
    	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
    	DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
    	DA850_NEMA_WE, DA850_NEMA_OE,
    	-1
    };
    
    static const short da850_evm_nor_pins[] = {
    	DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
    	DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
    	DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
    	DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
    	DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
    	DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
    	DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
    	DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
    	DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
    	DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
    	DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
    	DA850_EMA_A_22, DA850_EMA_A_23,
    	-1
    };
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    #if defined(CONFIG_SPI_DAVINCI)
    #define HAS_SPI 1
    #else
    #define HAS_SPI 0
    #endif
    
    #if defined(CONFIG_FB_DA8XX)
    #define HAS_LCD	1
    #else
    #define HAS_LCD	0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DAVINCI_EHRPWM) || defined(CONFIG_DAVINCI_EHRPWM_MODULE)
    #define HAS_EHRPWM 1
    #else
    #define HAS_EHRPWM 0
    #endif
    
    #if defined(CONFIG_ECAP_PWM) || \
    	defined(CONFIG_ECAP_PWM_MODULE)
    #define HAS_ECAP_PWM 1
    #else
    #define HAS_ECAP_PWM 0
    #endif
    
    #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
    #define HAS_BACKLIGHT 1
    #else
    #define HAS_BACKLIGHT 0
    #endif
    
    #if defined(CONFIG_ECAP_CAP) || defined(CONFIG_ECAP_CAP_MODULE)
    #define HAS_ECAP_CAP 1
    #else
    #define HAS_ECAP_CAP 0
    #endif
    
    /* have_imager() - Check if we have support for imager interface */
    static inline int have_imager(void)
    {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	return 1;
    #else
    	return 0;
    #endif
    }
    
    static inline void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    	ret = davinci_cfg_reg_list(da850_evm_nand_pins);
    	if (ret)
    		printk("da850_evm_init: nand mux setup failed: "
    				"%d\n", ret);
    
    	if (!HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			printk("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			printk("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] low for NOR to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = davinci_cfg_reg_list(da850_evm_nor_pins);
    		if (ret)
    			printk("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    
    		da850_evm_init_nor();
    	} else {
    		/*
    		 * On Logic PD Rev.3 EVMs GP0[11] pin needs to be configured
    		 * for MMC and NOR to work. When GP0[11] is low, the SD0
    		 * interface will not work, but NOR flash will. When GP0[11]
    		 * is high, SD0 will work but NOR flash will not. By default
    		 * we are assuming that GP0[11] pin is driven high, when UI
    		 * card is not connected. Hence we are not configuring the
    		 * GP0[11] pin when MMC/SD is enabled and UI card is not
    		 * connected. Not configuring the GPIO pin will enable the
    		 * bluetooth to work on AM18x as it requires the GP0[11]
    		 * pin for UART flow control.
    		 */
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			printk("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			printk("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    	}
    
    	platform_device_register(&davinci_emif_device);
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value_cansleep(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    
    #define DA850_KEYS_DEBOUNCE_MS	10
    /*
     * At 200ms polling interval it is possible to miss an
     * event by tapping very lightly on the push button but most
     * pushes do result in an event; longer intervals require the
     * user to hold the button whereas shorter intervals require
     * more CPU time for polling.
     */
    #define DA850_GPIO_KEYS_POLL_MS	200
    
    enum da850_evm_ui_exp_pins {
    	DA850_EVM_UI_EXP_SEL_C = 5,
    	DA850_EVM_UI_EXP_SEL_B,
    	DA850_EVM_UI_EXP_SEL_A,
    	DA850_EVM_UI_EXP_PB8,
    	DA850_EVM_UI_EXP_PB7,
    	DA850_EVM_UI_EXP_PB6,
    	DA850_EVM_UI_EXP_PB5,
    	DA850_EVM_UI_EXP_PB4,
    	DA850_EVM_UI_EXP_PB3,
    	DA850_EVM_UI_EXP_PB2,
    	DA850_EVM_UI_EXP_PB1,
    };
    
    static const char const *da850_evm_ui_exp[] = {
    	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c",
    	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b",
    	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a",
    	[DA850_EVM_UI_EXP_PB8]          = "pb8",
    	[DA850_EVM_UI_EXP_PB7]          = "pb7",
    	[DA850_EVM_UI_EXP_PB6]          = "pb6",
    	[DA850_EVM_UI_EXP_PB5]          = "pb5",
    	[DA850_EVM_UI_EXP_PB4]          = "pb4",
    	[DA850_EVM_UI_EXP_PB3]          = "pb3",
    	[DA850_EVM_UI_EXP_PB2]          = "pb2",
    	[DA850_EVM_UI_EXP_PB1]          = "pb1",
    };
    
    #define DA850_N_UI_PB		8
    
    static struct gpio_keys_button da850_evm_ui_keys[] = {
    	[0 ... DA850_N_UI_PB - 1] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
    	.buttons = da850_evm_ui_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_ui_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 0,
    	.dev = {
    		.platform_data = &da850_evm_ui_keys_pdata
    	},
    };
    
    static void da850_evm_ui_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	for (i = 0; i < DA850_N_UI_PB; i++) {
    		button = &da850_evm_ui_keys[i];
    		button->code = KEY_F8 - i;
    		button->desc = (char *)
    				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
    		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
    	}
    }
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value_cansleep(a, 0);
    	gpio_set_value_cansleep(b, 0);
    	gpio_set_value_cansleep(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value_cansleep(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CAMERA
    static inline void da850_evm_setup_camera(int camera_sel)
    {
    	gpio_set_value_cansleep(camera_sel, 0);
    }
    #else
    static inline void da850_evm_setup_camera(int camera_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
    	sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
    	sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
    
    	ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
    	if (ret) {
    		printk("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
    	if (ret) {
    		printk("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
    	if (ret) {
    		printk("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	da850_evm_ui_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_ui_keys_device);
    	if (ret) {
    		printk("Could not register UI GPIO expander push-buttons");
    		goto exp_setup_keys_fail;
    	}
    
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	da850_evm_setup_camera(sel_b);
    
    	return 0;
    
    exp_setup_keys_fail:
    	gpio_free(sel_c);
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_ui_keys_device);
    
    	/* deselect all functionalities */
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
    
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
    
    	return 0;
    }
    
    /* assign the baseboard expander's GPIOs after the UI board's */
    #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
    #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
    
    enum da850_evm_bb_exp_pins {
    	DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
    	DA850_EVM_BB_EXP_SW_RST,
    	DA850_EVM_BB_EXP_TP_23,
    	DA850_EVM_BB_EXP_TP_22,
    	DA850_EVM_BB_EXP_TP_21,
    	DA850_EVM_BB_EXP_USER_PB1,
    	DA850_EVM_BB_EXP_USER_LED2,
    	DA850_EVM_BB_EXP_USER_LED1,
    	DA850_EVM_BB_EXP_USER_SW1,
    	DA850_EVM_BB_EXP_USER_SW2,
    	DA850_EVM_BB_EXP_USER_SW3,
    	DA850_EVM_BB_EXP_USER_SW4,
    	DA850_EVM_BB_EXP_USER_SW5,
    	DA850_EVM_BB_EXP_USER_SW6,
    	DA850_EVM_BB_EXP_USER_SW7,
    	DA850_EVM_BB_EXP_USER_SW8
    };
    
    static const char const *da850_evm_bb_exp[] = {
    	[DA850_EVM_BB_EXP_DEEP_SLEEP_EN]	= "deep_sleep_en",
    	[DA850_EVM_BB_EXP_SW_RST]		= "sw_rst",
    	[DA850_EVM_BB_EXP_TP_23]		= "tp_23",
    	[DA850_EVM_BB_EXP_TP_22]		= "tp_22",
    	[DA850_EVM_BB_EXP_TP_21]		= "tp_21",
    	[DA850_EVM_BB_EXP_USER_PB1]		= "user_pb1",
    	[DA850_EVM_BB_EXP_USER_LED2]		= "user_led2",
    	[DA850_EVM_BB_EXP_USER_LED1]		= "user_led1",
    	[DA850_EVM_BB_EXP_USER_SW1]		= "user_sw1",
    	[DA850_EVM_BB_EXP_USER_SW2]		= "user_sw2",
    	[DA850_EVM_BB_EXP_USER_SW3]		= "user_sw3",
    	[DA850_EVM_BB_EXP_USER_SW4]		= "user_sw4",
    	[DA850_EVM_BB_EXP_USER_SW5]		= "user_sw5",
    	[DA850_EVM_BB_EXP_USER_SW6]		= "user_sw6",
    	[DA850_EVM_BB_EXP_USER_SW7]		= "user_sw7",
    	[DA850_EVM_BB_EXP_USER_SW8]		= "user_sw8",
    };
    
    #define DA850_N_BB_USER_SW	8
    
    static struct gpio_keys_button da850_evm_bb_keys[] = {
    	[0] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= KEY_PROG1,
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    	[1 ... DA850_N_BB_USER_SW] = {
    		.type			= EV_SW,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
    	.buttons = da850_evm_bb_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_bb_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 1,
    	.dev = {
    		.platform_data = &da850_evm_bb_keys_pdata
    	},
    };
    
    static void da850_evm_bb_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	button = &da850_evm_bb_keys[0];
    	button->desc = (char *)
    		da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
    	button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
    
    	for (i = 0; i < DA850_N_BB_USER_SW; i++) {
    		button = &da850_evm_bb_keys[i + 1];
    		button->code = SW_LID + i;
    		button->desc = (char *)
    				da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
    		button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
    	}
    }
    
    #define DA850_N_BB_USER_LED	2
    
    static struct gpio_led da850_evm_bb_leds[] = {
    	[0 ... DA850_N_BB_USER_LED - 1] = {
    		.active_low = 1,
    		.gpio = -1, /* assigned at runtime */
    		.name = NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
    	.leds = da850_evm_bb_leds,
    	.num_leds = ARRAY_SIZE(da850_evm_bb_leds),
    };
    
    static struct platform_device da850_evm_bb_leds_device = {
    	.name		= "leds-gpio",
    	.id		= -1,
    	.dev = {
    		.platform_data = &da850_evm_bb_leds_pdata
    	}
    };
    
    static void da850_evm_bb_leds_init(unsigned gpio)
    {
    	int i;
    	struct gpio_led *led;
    
    	for (i = 0; i < DA850_N_BB_USER_LED; i++) {
    		led = &da850_evm_bb_leds[i];
    
    		led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
    		led->name =
    			da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
    	}
    }
    
    static int da850_evm_bb_expander_setup(struct i2c_client *client,
    						unsigned gpio, unsigned ngpio,
    						void *c)
    {
    	int ret;
    
    	/*
    	 * Register the switches and pushbutton on the baseboard as a gpio-keys
    	 * device.
    	 */
    	da850_evm_bb_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_keys_device);
    	if (ret) {
    		printk("Could not register baseboard GPIO expander keys");
    		goto io_exp_setup_sw_fail;
    	}
    
    	da850_evm_bb_leds_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_leds_device);
    	if (ret) {
    		printk("Could not register baseboard GPIO expander LEDS");
    		goto io_exp_setup_leds_fail;
    	}
    
    	return 0;
    
    io_exp_setup_leds_fail:
    	platform_device_unregister(&da850_evm_bb_keys_device);
    io_exp_setup_sw_fail:
    	return ret;
    }
    
    static int da850_evm_bb_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_bb_leds_device);
    	platform_device_unregister(&da850_evm_bb_keys_device);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    	.names		= da850_evm_ui_exp,
    };
    
    static struct pca953x_platform_data da850_evm_bb_expander_info = {
    	.gpio_base	= DA850_BB_EXPANDER_GPIO_BASE,
    	.setup		= da850_evm_bb_expander_setup,
    	.teardown	= da850_evm_bb_expander_teardown,
    	.names		= da850_evm_bb_exp,
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    	/*
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
     	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x21),
    		.platform_data = &da850_evm_bb_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    
     	{
    		I2C_BOARD_INFO("tw9910", 0x45),
    	},
    	{
    		I2C_BOARD_INFO("PCA9543A", 0x73),
    	},
    	*/
    };
    
    /*
     * USB1 VBUS is controlled by GPIO2[4], over-current is reported on GPIO6[13].
     */
    #define ON_BD_USB_DRV	GPIO_TO_PIN(2, 4)
    #define ON_BD_USB_OVC	GPIO_TO_PIN(6, 13)
    
    static const short da850_evm_usb11_pins[] = {
    	DA850_GPIO2_4, DA850_GPIO6_13,
    	-1
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.type			= GPIO_BASED,
    	.method	= {
    		.gpio_method = {
    			.power_control_pin	= ON_BD_USB_DRV,
    			.over_current_indicator = ON_BD_USB_OVC,
    		},
    	},
    	.board_ocic_handler	= da850_evm_usb_ocic_irq,
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *handler)
    {
    	if (handler != NULL)
    		((da8xx_ocic_handler_t)handler)(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static __init void da850_evm_usb_init(void)
    {
    	u32 cfgchip2;
    	int ret;
    
    	/*
    	 * Set up USB clock/mode in the CFGCHIP2 register.
    	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/* USB2.0 PHY reference clock is 24 MHz */
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    
    	/*
    	 * Select internal reference clock for USB 2.0 PHY
    	 * and use it as a clock source for USB 1.1 PHY
    	 * (this is the default setting anyway).
    	 */
    	cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
    	cfgchip2 |=  CFGCHIP2_USB2PHYCLKMUX;
    	/*
    	 * We have to override VBUS/ID signals when MUSB is configured into the
    	 * host-only mode -- ID pin will float if no cable is connected, so the
    	 * controller won't be able to drive VBUS thinking that it's a B-device.
    	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
    	 */
    	cfgchip2 &= ~CFGCHIP2_OTGMODE;
    	cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
    
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/*
    	 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
    	 * with the power on to power good time of 3 ms.
    	 */
    	ret = da8xx_register_usb20(1000, 3);
    	if (ret)
    		printk("%s: USB 2.0 registration failed: %d\n",
    			   __func__, ret);
    
    	/* initilaize usb module */
    	da8xx_board_usb_init(da850_evm_usb11_pins, &da850_evm_usb11_pdata);
    }
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.asp_chan_q	= EVENTQ_0,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static const short da850_evm_mcasp_pins[] __initconst = {
    	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
    	DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
    	DA850_AXR_11, DA850_AXR_12,
    	-1
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_evm_mmcsd0_pins[] __initconst = {
    	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
    	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
    	DA850_GPIO4_0, DA850_GPIO4_1,
    	-1
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value_cansleep(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value_cansleep(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	int status;
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    /* We take advantage of the fact that both defdcdc{2,3} are tied high */
    static struct tps6507x_reg_platform_data tps6507x_platform_data = {
    	.defdcdc_default = true,
    };
    
    static struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1350000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct touchscreen_init_data tps6507x_touchscreen_data = {
    	.poll_period =  30,	/* ms between touch samples */
    	.min_pressure = 0x30,	/* minimum pressure to trigger touch */
    	.vref = 0,		/* turn off vref when not using A/D */
    	.vendor = 0,		/* /sys/class/input/input?/id/vendor */
    	.product = 65070,	/* /sys/class/input/input?/id/product */
    	.version = 0x100,	/* /sys/class/input/input?/id/version */
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    	.tps6507x_ts_init_data = &tps6507x_touchscreen_data,
    };
    
    static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    };
    
    static int __init pmic_tps65070_init(void)
    {
    	return i2c_register_board_info(1, da850_evm_tps65070_info,
    					ARRAY_SIZE(da850_evm_tps65070_info));
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static struct i2c_client *pca9543a;
    
    
    static int pca9543a_probe(struct i2c_client *client,
    		const struct i2c_device_id *id)
    {
    	pr_info("pca9543a_probe");
    	pca9543a = client;
    	return 0;
    }
    
    static int pca9543a_remove(struct i2c_client *client)
    {
    	pca9543a = NULL;
    	return 0;
    }
    
    static const struct i2c_device_id pca9543a_ids[] = {
    	{ "PCA9543A", 0, },
    	{ /* end of list */ },
    };
    
    /* This is for i2c driver for the MT9T031 header i2c switch */
    static struct i2c_driver pca9543a_driver = {
    	.driver.name	= "PCA9543A",
    	.id_table	= pca9543a_ids,
    	.probe		= pca9543a_probe,
    	.remove		= pca9543a_remove,
    };
    
    //#ifdef CONFIG_SOC_CAMERA_TW9910
    static struct i2c_board_info tw9910_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9910", 0x45),
        },
    };
    
    #if 1
    static struct tw9910_video_info tw9910_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout        = TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    //    .power        = tw9910_power,
    	.board_info    = &tw9910_i2c_camera[0],
    	.i2c_adapter_id    = 1,
    	.bus_id		= 1,
    	.priv        = &tw9910_info,
    };
    #endif
    
    #if 0
    static struct tw9910_video_info tw9910_info = {
    	.buswidth = SOCAM_DATAWIDTH_8,
    	.mpout = TW9910_MPO_FIELD,
    	.link = {
    		.power = tw9910_power,
    		.board_info = &tw9910_i2c_camera[0],
    		.i2c_adapter_id = 0,
    		.module_name = "tw9910",
    		}
    };
    
    #endif
    
    
    #if 0
    static struct platform_device tw9910_camera[] = {
        {
            .name    = "soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9910_link,
            },
        },
    };
    #endif
    
    static struct platform_device tw9910_camera[] = {
    	{
    	.name = "soc-camera-pdrv",
    	.id = 1,
    	.dev = {
    		.platform_data = &tw9910_info,
    		},
    	},
    };
    
    
    
    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };
    //#else
    
    #if 0
    static struct i2c_board_info tw9910_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9910", 0x45),
        },
    };
    
    static struct tw9910_video_info tw9910_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout        = TW9910_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9910_link = {
    //    .power        = tw9910_power,
        .board_info    = &tw9910_i2c_camera[0],
        .i2c_adapter_id    = 0,
    	.bus_id		= 1,
        .priv        = &tw9910_info,
    };
    
    static struct platform_device tw9910_camera[] = {
        {
            .name    = "TW9910 soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9910_link,
            },
        },
    };
    
    static struct platform_device *tw9910_devices[] __initdata = {
        &tw9910_camera[0],
    };
    //#endif
    
    #endif //#if 0
    
    /**
     * da850_enable_pca9543a() - Enable/Disable I2C switch PCA9543A for sensor
     * @en: enable/disable flag
     */
    static int da850_enable_pca9543a(int en)
    {
    	static char val = 1;
    	int status;
    	struct i2c_msg msg = {
    			.flags = 0,
    			.len = 1,
    			.buf = &val,
    		};
    
    	pr_info("da850evm_enable_pca9543a\n");
    	if (!en)
    		val = 0;
    
    	if (!pca9543a)
    		return -ENXIO;
    
    	msg.addr = pca9543a->addr;
    	/* turn i2c switch, pca9543a, on/off */
    	status = i2c_transfer(pca9543a->adapter, &msg, 1);
    	pr_info("da850evm_enable_pca9543a, status = %d\n", status);
    	return status;
    }
    
    static const short da850_evm_mii_pins[] = {
    	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
    	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
    	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
    	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static const short da850_evm_rmii_pins[] = {
    	DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
    	DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
    	DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_mii_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		printk("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		printk("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		printk("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		printk("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = "tw9910",
    	},
    };
    
    /*
     * The following EDMA channels/slots are not being used by drivers (for
     * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
     * they are being reserved for codecs on the DSP side.
     */
    static const s16 da850_dma0_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma0_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30, 50},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30, 90},
    	{-1, -1}
    };
    
    static struct edma_rsv_info da850_edma_cc0_rsv = {
    	.rsv_chans	= da850_dma0_rsv_chans,
    	.rsv_slots	= da850_dma0_rsv_slots,
    };
    
    static struct edma_rsv_info da850_edma_cc1_rsv = {
    	.rsv_chans	= da850_dma1_rsv_chans,
    	.rsv_slots	= da850_dma1_rsv_slots,
    };
    
    static struct edma_rsv_info *da850_edma_rsv[2] = {
    	&da850_edma_cc0_rsv,
    	&da850_edma_cc1_rsv,
    };
    
    #ifdef CONFIG_CPU_FREQ
    static __init int da850_evm_init_cpufreq(void)
    {
    	switch (system_rev & 0xF) {
    	case 3:
    		da850_max_speed = 456000;
    		break;
    	case 2:
    		da850_max_speed = 408000;
    		break;
    	case 1:
    		da850_max_speed = 372000;
    		break;
    	}
    
    	return da850_register_cpufreq("pll0_sysclk3");
    }
    #else
    static __init int da850_evm_init_cpufreq(void) { return 0; }
    #endif
    
    #if defined(CONFIG_DAVINCI_UART1_AFE)
    #define HAS_UART1_AFE 1
    #else
    #define HAS_UART1_AFE 0
    #endif
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    int da850_vpif_setup_input_path(int ch, const char *name)
    {
    	int ret = 0;
    
    	 if (!strcmp(name, "mt9t031") && have_imager())
    		ret = da850_enable_pca9543a(1);
    
    	return ret;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    #endif
    
    #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    	{
    		.name	= "tw9910",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    //	.platform_data = (void *)1,
    	.platform_data = &tw9910_link,		//Titus latest Debug
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #if 0
    //#elif defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	{
    		.name	= "tw9910",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = (void *)1,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    /*
    	{
    		.name	= "tw9910-0",
    		.board_info = {
    			I2C_BOARD_INFO("tw9910", 0x45),
    			.platform_data = (void *)1,
    		},
    		.input = INPUT_CVBS_VI2B,
    //		.output = OUTPUT_8BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    
     	{
    		.name	= TVP5147_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	*/
    //#endif
    
    #endif  //#if 0
    
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = "tw9910-0",
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	//.setup_input_path = da850_vpif_setup_input_path,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    #if 0
    //#if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    	/*
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    	*/
    #endif //#if 0
    
    //#elif defined(CONFIG_DA850_UI_CAMERA)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    //#endif
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    #ifdef CONFIG_DA850_WL12XX
    
    static void wl12xx_set_power(int index, bool power_on)
    {
    	static bool power_state;
    
    	pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
    
    	if (power_on == power_state)
    		return;
    	power_state = power_on;
    
    	if (power_on) {
    		/* Power up sequence required for wl127x devices */
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		usleep_range(15000, 15000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    		usleep_range(1000, 1000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		msleep(70);
    	} else {
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    	}
    }
    
    static struct davinci_mmc_config da850_wl12xx_mmc_config = {
    	.set_power	= wl12xx_set_power,
    	.wires		= 4,
    	.max_freq	= 25000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    			  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_wl12xx_pins[] __initconst = {
    	DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
    	DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
    	DA850_GPIO6_9, DA850_GPIO6_10,
    	-1
    };
    
    static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
    	.irq			= -1,
    	.board_ref_clock	= WL12XX_REFCLOCK_38,
    	.platform_quirks	= WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    };
    
    static __init int da850_wl12xx_init(void)
    {
    	int ret;
    
    	ret = davinci_cfg_reg_list(da850_wl12xx_pins);
    	if (ret) {
    		pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
    	if (ret) {
    		pr_err("wl12xx/mmc registration failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
    	if (ret) {
    		pr_err("Could not request wl12xx enable gpio: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
    	if (ret) {
    		pr_err("Could not request wl12xx irq gpio: %d\n", ret);
    		goto free_wlan_en;
    	}
    
    	da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
    
    	ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
    	if (ret) {
    		pr_err("Could not set wl12xx data: %d\n", ret);
    		goto free_wlan_irq;
    	}
    
    	return 0;
    
    free_wlan_irq:
    	gpio_free(DA850_WLAN_IRQ);
    
    free_wlan_en:
    	gpio_free(DA850_WLAN_EN);
    
    exit:
    	return ret;
    }
    
    #else /* CONFIG_DA850_WL12XX */
    
    static __init int da850_wl12xx_init(void)
    {
    	return 0;
    }
    
    #endif /* CONFIG_DA850_WL12XX */
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init int da850_set_emif_clk_rate(void)
    {
    	struct clk *emif_clk;
    
    	emif_clk = clk_get(NULL, "pll0_sysclk3");
    	if (WARN(IS_ERR(emif_clk), "Unable to get emif clock\n"))
    		return PTR_ERR(emif_clk);
    
    	return clk_set_rate(emif_clk, CONFIG_DA850_FIX_PLL0_SYSCLK3RATE);
    }
    
    struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
    	.pintc_base	= 0x4000,
    };
    
    #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    	char mask = 0;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	pr_info("da850 init!\n");
    
    	ret = pmic_tps65070_init();
    	if (ret)
    		printk("da850_evm_init: TPS65070 PMIC init failed: %d\n",
    				ret);
    
    	/*
    	 * Though bootloader takes care to set emif clock at allowed
    	 * possible rate. Kernel needs to reconfigure this rate to
    	 * support platforms requiring fixed emif clock rate.
    	 */
    	ret = da850_set_emif_clk_rate();
    	if (ret)
    		printk("da850_evm_init: Failed to set rate of pll0_sysclk3/emif clock: %d\n",
    				ret);
    
    	ret = da850_register_edma(da850_edma_rsv);
    	if (ret)
    		printk("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = davinci_cfg_reg_list(da850_i2c0_pins);
    	if (ret)
    		printk("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		printk("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	/* Support for UART 1 */
    	ret = davinci_cfg_reg_list(da850_uart1_pins);
    	if (ret)
    		printk("da850_evm_init: UART 1 mux setup failed:"
    						" %d\n", ret);
    
    	if (HAS_MMC) {
    		ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
    		if (ret)
    			printk("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			printk("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			printk("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			printk("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    
    		ret = da850_wl12xx_init();
    		if (ret)
    			printk("da850_evm_init: wl12xx initialization"
    				   " failed: %d\n", ret);
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	if (have_imager())
    		i2c_add_driver(&pca9543a_driver);
    	
    	i2c_register_board_info(1, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    	
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	
    	if (HAS_MCASP) {
    		if (HAS_UART1_AFE)
    			printk("WARNING: both McASP and UART1_AFE are "
    				"enabled, but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
    		if (ret)
    			printk("da850_evm_init: mcasp mux setup failed: %d\n",
    					ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
    	if (ret)
    		printk("%s: pruss_uio initialization failed: %d\n",
    				__func__, ret);	
    
    	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
    	if (ret)
    		printk("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
    	if (ret)
    		printk("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    	ret = da850_lcd_hw_init();
    	if (ret)
    		printk("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		printk("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		printk("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_evm_init_cpufreq();
    	if (ret)
    		printk("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		printk("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		printk("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		pr_info("Register VPIF VPIF ...\n");
    		ret = da850_register_vpif();
    		if (ret)
    			printk("da850_evm_init: VPIF setup failed: %d\n",
    				   ret);
    		else
    			pr_info("Register VPIF ok!\n");
    	}
    
    	if (HAS_VPIF_CAPTURE) {
    		
    		ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
    		if (ret)
    			printk("da850_evm_init: VPIF capture mux failed:"
    					"%d\n", ret);
    #if 0
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			printk("da850_evm_init: VPIF capture setup failed:"
    					"%d\n", ret);
    		else
    			printk("da850_evm_init: VPIF capture setup success:"
    					"%d\n", ret);
    #endif
    
    		//I think that if da850_vpif_capture_config is ok, this line is not need?
    		//platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
    	}
    
    	if (HAS_VPIF_DISPLAY) {
    		ret = davinci_cfg_reg_list(da850_vpif_display_pins);
    		if (ret)
    			printk("da850_evm_init : VPIF capture mux failed :"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_display(&da850_vpif_display_config);
    		if (ret)
    			printk("da850_evm_init: VPIF display setup failed:"
    					"%d\n", ret);
    	}
    
    	ret = da8xx_register_spi(1, da850evm_spi_info,
    				 ARRAY_SIZE(da850evm_spi_info));
    	if (ret)
    		printk("da850_evm_init: spi 1 registration failed: %d\n",
    				ret);
    
    	ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
    	if (ret)
    		printk("da850_evm_init: sata registration failed: %d\n",
    				ret);
    
    	da850_evm_setup_mac_addr();
    
    	da850_evm_usb_init();
    
    	if (HAS_EHRPWM) {
    		if (rmii_en) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm0_pins);
    			if (ret)
    				printk("da850_evm_init:"
    				" ehrpwm0 mux setup failed: %d\n", ret);
    			else
    				mask = BIT(0) | BIT(1);
    		} else {
    			printk("da850_evm_init:"
    			" eHRPWM module 0 cannot be used"
    			" since it is being used by MII interface\n");
    			mask = 0;
    		}
    
    		if (!HAS_LCD) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm1_pins);
    			if (ret)
    				printk("da850_evm_init:"
    				" eHRPWM module1 output A mux"
    				" setup failed %d\n", ret);
    			else
    				mask = mask | BIT(2);
    		} else {
    			printk("da850_evm_init:"
    				" eHRPWM module1 outputA cannot be"
    				" used since it is being used by LCD\n");
    		}
    
    		if (!HAS_SPI) {
    			ret = davinci_cfg_reg(DA850_EHRPWM1_B);
    			if (ret)
    				printk("da850_evm_init:"
    					" eHRPWM module1 outputB mux"
    					" setup failed %d\n", ret);
    		else
    			mask =  mask  | BIT(3);
    		} else {
    			printk("da850_evm_init:"
    				" eHRPWM module1 outputB cannot be"
    				" used since it is being used by spi1\n");
    		}
    
    		da850_register_ehrpwm(mask);
    	}
    
    	if (HAS_ECAP_PWM) {
    		ret = davinci_cfg_reg(DA850_ECAP2_APWM2);
    		if (ret)
    			printk("da850_evm_init:ecap mux failed:"
    					" %d\n", ret);
    		ret = da850_register_ecap(2);
    		if (ret)
    			printk("da850_evm_init:"
    				" eCAP registration failed: %d\n", ret);
    	}
    
    	if (HAS_BACKLIGHT) {
    		ret = da850_register_backlight(&da850evm_backlight,
    				&da850evm_backlight_data);
    		if (ret)
    			printk("da850_evm_init:"
    				" backlight device registration"
    				" failed: %d\n", ret);
    	}
    
    	if (HAS_ECAP_CAP) {
    		if (HAS_MCASP)
    			printk("da850_evm_init:"
    				"ecap module 1 cannot be used "
    				"since it shares pins with McASP\n");
    		else {
    			ret = davinci_cfg_reg(DA850_ECAP1_APWM1);
    			if (ret)
    				printk("da850_evm_init:ecap mux failed:%d\n"
    						, ret);
    			else {
    				ret = da850_register_ecap_cap(1);
    				if (ret)
    					printk("da850_evm_init"
    					"eCAP registration failed: %d\n", ret);
    			}
    		}
    	}
    		
    
    //Titus debug latest
    	
    	ret = platform_add_devices(tw9910_devices, ARRAY_SIZE(tw9910_devices));
    	if (ret)
    		printk("da850_evm_init: tw9910_devices failed: %d\n", ret);
    	else
    		printk("da850_evm_init: tw9910_devices success: %d\n", ret);
    
    
    	
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
    	.atag_offset	= 0x100,
    	.map_io		= da850_evm_map_io,
    	.init_irq	= cp_intc_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    	.dma_zone_size	= SZ_128M,
    	.restart	= da8xx_restart,
    MACHINE_END
    

    Please let us know the status,

  • Hi Titusrathinaraj:

       Thanks very much!

       I solved TW9910/TW9900 driver and VPIF register problem.

       board-da850-evm.c is:

    /*
     * TI DA850/OMAP-L138 EVM board
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-davinci/board-da830-evm.c
     * Original Copyrights follow:
     *
     * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
     * the terms of the GNU General Public License version 2. This program
     * is licensed "as is" without any warranty of any kind, whether express
     * or implied.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/clk.h>
    #include <linux/console.h>
    #include <linux/i2c.h>
    #include <linux/i2c/at24.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/input.h>
    #include <linux/mfd/tps6507x.h>
    #include <linux/gpio.h>
    #include <linux/gpio_keys.h>
    #include <linux/platform_device.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/mtd/physmap.h>
    #include <linux/regulator/machine.h>
    #include <linux/regulator/tps6507x.h>
    #include <linux/input/tps6507x-ts.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/delay.h>
    #include <linux/wl12xx.h>
    #include <linux/pwm_backlight.h>
    #include <linux/i2c-gpio.h>
    #include <linux/videodev2.h>
    #include <linux/module.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    
    #include <mach/cp_intc.h>
    #include <mach/da8xx.h>
    #include <mach/nand.h>
    #include <mach/mux.h>
    #include <linux/mfd/davinci_aemif.h>
    #include <mach/spi.h>
    #include <mach/usb.h>
    #include <media/tvp514x.h>
    #include <media/davinci/vpif_types.h>
    
    #include <media/tw9900.h>
    
    
    #define DA850_EVM_PHY_ID		"davinci_mdio-0:00"
    #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)
    #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)
    
    #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
    #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
    
    #define DA850_WLAN_EN			GPIO_TO_PIN(6, 9)
    #define DA850_WLAN_IRQ			GPIO_TO_PIN(6, 10)
    
    #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
    
    #define DA850_SD_ENABLE_PIN		GPIO_TO_PIN(0, 11)
    
    #define DAVINCI_BACKLIGHT_MAX_BRIGHTNESS	250
    #define DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS	250
    #define DAVINCI_PWM_PERIOD_NANO_SECONDS		10000000
    
    
    static struct platform_pwm_backlight_data da850evm_backlight_data = {
    	.max_brightness	= DAVINCI_BACKLIGHT_MAX_BRIGHTNESS,
    	.dft_brightness	= DAVINVI_BACKLIGHT_DEFAULT_BRIGHTNESS,
    	.pwm_period_ns	= DAVINCI_PWM_PERIOD_NANO_SECONDS,
    };
    
    static struct platform_device da850evm_backlight = {
    	.name		= "pwm-backlight",
    	.id		= -1,
    };
    
    static struct mtd_partition da850evm_spiflash_part[] = {
    	[0] = {
    		.name = "UBL",
    		.offset = 0,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[1] = {
    		.name = "U-Boot",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_512K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[2] = {
    		.name = "U-Boot-Env",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    	[3] = {
    		.name = "Kernel",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_2M + SZ_512K,
    		.mask_flags = 0,
    	},
    	[4] = {
    		.name = "Filesystem",
    		.offset = MTDPART_OFS_APPEND,
    		.size = SZ_4M,
    		.mask_flags = 0,
    	},
    	[5] = {
    		.name = "MAC-Address",
    		.offset = SZ_8M - SZ_64K,
    		.size = SZ_64K,
    		.mask_flags = MTD_WRITEABLE,
    	},
    };
    
    static struct flash_platform_data da850evm_spiflash_data = {
    	.name		= "m25p80",
    	.parts		= da850evm_spiflash_part,
    	.nr_parts	= ARRAY_SIZE(da850evm_spiflash_part),
    	.type		= "m25p64",
    };
    
    static struct davinci_spi_config da850evm_spiflash_cfg = {
    	.io_type	= SPI_IO_TYPE_DMA,
    	.c2tdelay	= 8,
    	.t2cdelay	= 8,
    };
    
    static struct spi_board_info da850evm_spi_info[] = {
    	{
    		.modalias		= "m25p80",
    		.platform_data		= &da850evm_spiflash_data,
    		.controller_data	= &da850evm_spiflash_cfg,
    		.mode			= SPI_MODE_0,
    		.max_speed_hz		= 30000000,
    		.bus_num		= 1,
    		.chip_select		= 0,
    	},
    };
    
    #define TVP5147_CH0		"tvp514x-0"
    #define TVP5147_CH1		"tvp514x-1"
    
    #define VPIF_STATUS		0x002c
    #define VPIF_STATUS_CLR		0x0030
    
    #ifdef CONFIG_MTD
    static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
    {
    	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
    	size_t retlen;
    
    	if (!strcmp(mtd->name, "MAC-Address")) {
    		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
    		if (retlen == ETH_ALEN)
    			pr_info("Read MAC addr from SPI Flash: %pM\n",
    				mac_addr);
    	}
    }
    
    static struct mtd_notifier da850evm_spi_notifier = {
    	.add	= da850_evm_m25p80_notify_add,
    };
    
    static void da850_evm_setup_mac_addr(void)
    {
    	register_mtd_user(&da850evm_spi_notifier);
    }
    #else
    static void da850_evm_setup_mac_addr(void) { }
    #endif
    
    static struct mtd_partition da850_evm_norflash_partition[] = {
    	{
    		.name           = "bootloaders + env",
    		.offset         = 0,
    		.size           = SZ_512K,
    		.mask_flags     = MTD_WRITEABLE,
    	},
    	{
    		.name           = "kernel",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = SZ_4M,
    		.mask_flags     = 0,
    	},
    	{
    		.name           = "filesystem",
    		.offset         = MTDPART_OFS_APPEND,
    		.size           = MTDPART_SIZ_FULL,
    		.mask_flags     = 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_norflash_timing = {
    	.wsetup		= 10,
    	.wstrobe	= 60,
    	.whold		= 10,
    	.rsetup		= 10,
    	.rstrobe	= 110,
    	.rhold		= 10,
    	.ta		= 30,
    };
    
    static struct physmap_flash_data da850_evm_norflash_data = {
    	.width		= 2,
    	.parts		= da850_evm_norflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_norflash_partition),
    	.timing		= &da850_evm_norflash_timing,
    };
    
    static struct resource da850_evm_norflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS2_BASE,
    		.end	= DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct davinci_pm_config da850_pm_pdata = {
    	.sleepcount = 128,
    };
    
    static struct platform_device da850_pm_device = {
    	.name           = "pm-davinci",
    	.dev = {
    		.platform_data	= &da850_pm_pdata,
    	},
    	.id             = -1,
    };
    
    /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
     * (128K blocks). It may be used instead of the (default) SPI flash
     * to boot, using TI's tools to install the secondary boot loader
     * (UBL) and U-Boot.
     */
    static struct mtd_partition da850_evm_nandflash_partition[] = {
    	{
    		.name		= "u-boot env",
    		.offset		= 0,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	 },
    	{
    		.name		= "UBL",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "u-boot",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= 4 * SZ_128K,
    		.mask_flags	= MTD_WRITEABLE,
    	},
    	{
    		.name		= "kernel",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= SZ_4M,
    		.mask_flags	= 0,
    	},
    	{
    		.name		= "filesystem",
    		.offset		= MTDPART_OFS_APPEND,
    		.size		= MTDPART_SIZ_FULL,
    		.mask_flags	= 0,
    	},
    };
    
    static struct davinci_aemif_timing da850_evm_nandflash_timing = {
    	.wsetup		= 24,
    	.wstrobe	= 21,
    	.whold		= 14,
    	.rsetup		= 19,
    	.rstrobe	= 50,
    	.rhold		= 0,
    	.ta		= 20,
    };
    
    static struct davinci_nand_pdata da850_evm_nandflash_data = {
    	.parts		= da850_evm_nandflash_partition,
    	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),
    	.ecc_mode	= NAND_ECC_HW,
    	.ecc_bits	= 4,
    	.bbt_options	= NAND_BBT_USE_FLASH,
    	.timing		= &da850_evm_nandflash_timing,
    };
    
    static struct resource da850_evm_nandflash_resource[] = {
    	{
    		.start	= DA8XX_AEMIF_CS3_BASE,
    		.end	= DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    	{
    		.start	= DA8XX_AEMIF_CTL_BASE,
    		.end	= DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
    		.flags	= IORESOURCE_MEM,
    	},
    };
    
    static struct platform_device da850_evm_devices[] = {
    	{
    		.name		= "davinci_nand",
    		.id		= 1,
    		.dev		= {
    			.platform_data	= &da850_evm_nandflash_data,
    		},
    		.num_resources	= ARRAY_SIZE(da850_evm_nandflash_resource),
    		.resource	= da850_evm_nandflash_resource,
    	},
    #if !defined(CONFIG_MMC_DAVINCI) || \
        !defined(CONFIG_MMC_DAVINCI_MODULE)
    	{
    		.name		= "physmap-flash",
    		.id		= 0,
    		.dev		= {
    			.platform_data  = &da850_evm_norflash_data,
    		},
    		.num_resources	= 1,
    		.resource	= da850_evm_norflash_resource,
    
    	},
    #endif
    };
    static struct davinci_aemif_devices da850_emif_devices = {
    	.devices	= da850_evm_devices,
    	.num_devices	= ARRAY_SIZE(da850_evm_devices),
    };
    
    static struct platform_device davinci_emif_device = {
    	.name	= "davinci_aemif",
    	.id	= -1,
    	.dev	= {
    		.platform_data	= &da850_emif_devices,
    	},
    };
    
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static void __init da850_evm_init_nor(void)
    {
    	void __iomem *aemif_addr;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	/* Configure data bus width of CS2 to 16 bit */
    	writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
    		DA8XX_AEMIF_ASIZE_16BIT,
    		aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    static const short da850_evm_nand_pins[] = {
    	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
    	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
    	DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
    	DA850_NEMA_WE, DA850_NEMA_OE,
    	-1
    };
    
    static const short da850_evm_nor_pins[] = {
    	DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
    	DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
    	DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
    	DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
    	DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
    	DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
    	DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
    	DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
    	DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
    	DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
    	DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
    	DA850_EMA_A_22, DA850_EMA_A_23,
    	-1
    };
    
    #if defined(CONFIG_MMC_DAVINCI) || \
        defined(CONFIG_MMC_DAVINCI_MODULE)
    #define HAS_MMC 1
    #else
    #define HAS_MMC 0
    #endif
    
    #if defined(CONFIG_SPI_DAVINCI)
    #define HAS_SPI 1
    #else
    #define HAS_SPI 0
    #endif
    
    #if defined(CONFIG_FB_DA8XX)
    #define HAS_LCD	1
    #else
    #define HAS_LCD	0
    #endif
    
    #if defined(CONFIG_SND_DA850_SOC_EVM) || \
    	defined(CONFIG_SND_DA850_SOC_EVM_MODULE)
    #define HAS_MCASP 1
    #else
    #define HAS_MCASP 0
    #endif
    
    #if defined(CONFIG_DAVINCI_EHRPWM) || defined(CONFIG_DAVINCI_EHRPWM_MODULE)
    #define HAS_EHRPWM 1
    #else
    #define HAS_EHRPWM 0
    #endif
    
    #if defined(CONFIG_ECAP_PWM) || \
    	defined(CONFIG_ECAP_PWM_MODULE)
    #define HAS_ECAP_PWM 1
    #else
    #define HAS_ECAP_PWM 0
    #endif
    
    #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
    #define HAS_BACKLIGHT 1
    #else
    #define HAS_BACKLIGHT 0
    #endif
    
    #if defined(CONFIG_ECAP_CAP) || defined(CONFIG_ECAP_CAP_MODULE)
    #define HAS_ECAP_CAP 1
    #else
    #define HAS_ECAP_CAP 0
    #endif
    
    /* have_imager() - Check if we have support for imager interface */
    static inline int have_imager(void)
    {
    #if defined(CONFIG_DA850_UI_CAMERA)
    	return 1;
    #else
    	return 0;
    #endif
    }
    #define DA8XX_AEMIF_CE2CFG_OFFSET	0x10
    #define DA8XX_AEMIF_CE3CFG_OFFSET	0x14
    #define DA8XX_AEMIF_ASIZE_16BIT		0x1
    
    static void __init da850_evm_init_nand(void)
    {
    	void __iomem *aemif_addr;
    	u32 ce3cfg;
    
    	aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
    
    	ce3cfg = 0
    		| (0 << 31)	/* selectStrobe */
    		| (0 << 30)	/* extWait */
    		| (0 << 26)	/* writeSetup */
    		| (3 << 20)	/* writeStrobe  30 ns */
    		| (3 << 17)	/* writeHold    30 ns */
    		| (2 << 13)	/* readSetup    20 ns */
    		| (4 << 7)	/* readStrobe   40 ns */
    		| (0 << 4)	/* readHold */
    		| (0 << 2)	/* turnAround */
    		| (0 << 0)	/* asyncSize    8-bit bus */
    		;
    
    	writel(ce3cfg, aemif_addr + DA8XX_AEMIF_CE3CFG_OFFSET);
    
    	iounmap(aemif_addr);
    }
    
    static inline void da850_evm_setup_nor_nand(void)
    {
    	int ret = 0;
    
    	ret = davinci_cfg_reg_list(da850_evm_nand_pins);
    	if (ret)
    		printk("da850_evm_init: nand mux setup failed: "
    				"%d\n", ret);
    
    	da850_evm_init_nand();	//HuanYi eagle
    #if 0
    	if (!HAS_MMC) {
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			printk("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			printk("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] low for NOR to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 0);
    
    		ret = davinci_cfg_reg_list(da850_evm_nor_pins);
    		if (ret)
    			printk("da850_evm_init: nor mux setup failed: %d\n",
    				ret);
    
    		da850_evm_init_nor();
    	} else {
    		/*
    		 * On Logic PD Rev.3 EVMs GP0[11] pin needs to be configured
    		 * for MMC and NOR to work. When GP0[11] is low, the SD0
    		 * interface will not work, but NOR flash will. When GP0[11]
    		 * is high, SD0 will work but NOR flash will not. By default
    		 * we are assuming that GP0[11] pin is driven high, when UI
    		 * card is not connected. Hence we are not configuring the
    		 * GP0[11] pin when MMC/SD is enabled and UI card is not
    		 * connected. Not configuring the GPIO pin will enable the
    		 * bluetooth to work on AM18x as it requires the GP0[11]
    		 * pin for UART flow control.
    		 */
    		ret = davinci_cfg_reg(DA850_GPIO0_11);
    		if (ret)
    			printk("da850_evm_init:GPIO(0,11) mux setup "
    					"failed\n");
    
    		ret = gpio_request(DA850_SD_ENABLE_PIN, "mmc_sd_en");
    		if (ret)
    			printk("Cannot open GPIO %d\n",
    					DA850_SD_ENABLE_PIN);
    
    		/* Driver GP0[11] high for SD to work */
    		gpio_direction_output(DA850_SD_ENABLE_PIN, 1);
    	}
    #endif
    
    	platform_device_register(&davinci_emif_device);
    }
    
    #ifdef CONFIG_DA850_UI_RMII
    static inline void da850_evm_setup_emac_rmii(int rmii_sel)
    {
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	soc_info->emac_pdata->rmii_en = 1;
    	gpio_set_value_cansleep(rmii_sel, 0);
    }
    #else
    static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
    #endif
    
    
    #define DA850_KEYS_DEBOUNCE_MS	10
    /*
     * At 200ms polling interval it is possible to miss an
     * event by tapping very lightly on the push button but most
     * pushes do result in an event; longer intervals require the
     * user to hold the button whereas shorter intervals require
     * more CPU time for polling.
     */
    #define DA850_GPIO_KEYS_POLL_MS	200
    
    enum da850_evm_ui_exp_pins {
    	DA850_EVM_UI_EXP_SEL_C = 5,
    	DA850_EVM_UI_EXP_SEL_B,
    	DA850_EVM_UI_EXP_SEL_A,
    	DA850_EVM_UI_EXP_PB8,
    	DA850_EVM_UI_EXP_PB7,
    	DA850_EVM_UI_EXP_PB6,
    	DA850_EVM_UI_EXP_PB5,
    	DA850_EVM_UI_EXP_PB4,
    	DA850_EVM_UI_EXP_PB3,
    	DA850_EVM_UI_EXP_PB2,
    	DA850_EVM_UI_EXP_PB1,
    };
    
    static const char const *da850_evm_ui_exp[] = {
    	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c",
    	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b",
    	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a",
    	[DA850_EVM_UI_EXP_PB8]          = "pb8",
    	[DA850_EVM_UI_EXP_PB7]          = "pb7",
    	[DA850_EVM_UI_EXP_PB6]          = "pb6",
    	[DA850_EVM_UI_EXP_PB5]          = "pb5",
    	[DA850_EVM_UI_EXP_PB4]          = "pb4",
    	[DA850_EVM_UI_EXP_PB3]          = "pb3",
    	[DA850_EVM_UI_EXP_PB2]          = "pb2",
    	[DA850_EVM_UI_EXP_PB1]          = "pb1",
    };
    
    #define DA850_N_UI_PB		8
    
    static struct gpio_keys_button da850_evm_ui_keys[] = {
    	[0 ... DA850_N_UI_PB - 1] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
    	.buttons = da850_evm_ui_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_ui_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 0,
    	.dev = {
    		.platform_data = &da850_evm_ui_keys_pdata
    	},
    };
    
    static void da850_evm_ui_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	for (i = 0; i < DA850_N_UI_PB; i++) {
    		button = &da850_evm_ui_keys[i];
    		button->code = KEY_F8 - i;
    		button->desc = (char *)
    				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
    		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
    	}
    }
    
    #ifdef CONFIG_DA850_UI_CLCD
    static inline void da850_evm_setup_char_lcd(int a, int b, int c)
    {
    	gpio_set_value_cansleep(a, 0);
    	gpio_set_value_cansleep(b, 0);
    	gpio_set_value_cansleep(c, 0);
    }
    #else
    static inline void da850_evm_setup_char_lcd(int a, int b, int c) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT
    static inline void da850_evm_setup_video_port(int video_sel)
    {
    	gpio_set_value_cansleep(video_sel, 0);
    }
    #else
    static inline void da850_evm_setup_video_port(int video_sel) { }
    #endif
    
    #ifdef CONFIG_DA850_UI_CAMERA
    static inline void da850_evm_setup_camera(int camera_sel)
    {
    	gpio_set_value_cansleep(camera_sel, 0);
    }
    #else
    static inline void da850_evm_setup_camera(int camera_sel) { }
    #endif
    
    static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
    						unsigned ngpio, void *c)
    {
    	int sel_a, sel_b, sel_c, ret;
    
    	sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
    	sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
    	sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
    
    	ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
    	if (ret) {
    		printk("Cannot open UI expander pin %d\n", sel_a);
    		goto exp_setup_sela_fail;
    	}
    
    	ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
    	if (ret) {
    		printk("Cannot open UI expander pin %d\n", sel_b);
    		goto exp_setup_selb_fail;
    	}
    
    	ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
    	if (ret) {
    		printk("Cannot open UI expander pin %d\n", sel_c);
    		goto exp_setup_selc_fail;
    	}
    
    	/* deselect all functionalities */
    	gpio_direction_output(sel_a, 1);
    	gpio_direction_output(sel_b, 1);
    	gpio_direction_output(sel_c, 1);
    
    	da850_evm_ui_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_ui_keys_device);
    	if (ret) {
    		printk("Could not register UI GPIO expander push-buttons");
    		goto exp_setup_keys_fail;
    	}
    
    	pr_info("DA850/OMAP-L138 EVM UI card detected\n");
    
    	da850_evm_setup_nor_nand();
    
    	da850_evm_setup_emac_rmii(sel_a);
    
    	da850_evm_setup_char_lcd(sel_a, sel_b, sel_c);
    
    	da850_evm_setup_video_port(sel_c);
    
    	da850_evm_setup_camera(sel_b);
    
    	return 0;
    
    exp_setup_keys_fail:
    	gpio_free(sel_c);
    exp_setup_selc_fail:
    	gpio_free(sel_b);
    exp_setup_selb_fail:
    	gpio_free(sel_a);
    exp_setup_sela_fail:
    	return ret;
    }
    
    static int da850_evm_ui_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_ui_keys_device);
    
    	/* deselect all functionalities */
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
    	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
    
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
    	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
    
    	return 0;
    }
    
    /* assign the baseboard expander's GPIOs after the UI board's */
    #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
    #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
    
    enum da850_evm_bb_exp_pins {
    	DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
    	DA850_EVM_BB_EXP_SW_RST,
    	DA850_EVM_BB_EXP_TP_23,
    	DA850_EVM_BB_EXP_TP_22,
    	DA850_EVM_BB_EXP_TP_21,
    	DA850_EVM_BB_EXP_USER_PB1,
    	DA850_EVM_BB_EXP_USER_LED2,
    	DA850_EVM_BB_EXP_USER_LED1,
    	DA850_EVM_BB_EXP_USER_SW1,
    	DA850_EVM_BB_EXP_USER_SW2,
    	DA850_EVM_BB_EXP_USER_SW3,
    	DA850_EVM_BB_EXP_USER_SW4,
    	DA850_EVM_BB_EXP_USER_SW5,
    	DA850_EVM_BB_EXP_USER_SW6,
    	DA850_EVM_BB_EXP_USER_SW7,
    	DA850_EVM_BB_EXP_USER_SW8
    };
    
    static const char const *da850_evm_bb_exp[] = {
    	[DA850_EVM_BB_EXP_DEEP_SLEEP_EN]	= "deep_sleep_en",
    	[DA850_EVM_BB_EXP_SW_RST]		= "sw_rst",
    	[DA850_EVM_BB_EXP_TP_23]		= "tp_23",
    	[DA850_EVM_BB_EXP_TP_22]		= "tp_22",
    	[DA850_EVM_BB_EXP_TP_21]		= "tp_21",
    	[DA850_EVM_BB_EXP_USER_PB1]		= "user_pb1",
    	[DA850_EVM_BB_EXP_USER_LED2]		= "user_led2",
    	[DA850_EVM_BB_EXP_USER_LED1]		= "user_led1",
    	[DA850_EVM_BB_EXP_USER_SW1]		= "user_sw1",
    	[DA850_EVM_BB_EXP_USER_SW2]		= "user_sw2",
    	[DA850_EVM_BB_EXP_USER_SW3]		= "user_sw3",
    	[DA850_EVM_BB_EXP_USER_SW4]		= "user_sw4",
    	[DA850_EVM_BB_EXP_USER_SW5]		= "user_sw5",
    	[DA850_EVM_BB_EXP_USER_SW6]		= "user_sw6",
    	[DA850_EVM_BB_EXP_USER_SW7]		= "user_sw7",
    	[DA850_EVM_BB_EXP_USER_SW8]		= "user_sw8",
    };
    
    #define DA850_N_BB_USER_SW	8
    
    static struct gpio_keys_button da850_evm_bb_keys[] = {
    	[0] = {
    		.type			= EV_KEY,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= KEY_PROG1,
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    	[1 ... DA850_N_BB_USER_SW] = {
    		.type			= EV_SW,
    		.active_low		= 1,
    		.wakeup			= 0,
    		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS,
    		.code			= -1, /* assigned at runtime */
    		.desc			= NULL, /* assigned at runtime */
    		.gpio			= -1, /* assigned at runtime */
    	},
    };
    
    static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
    	.buttons = da850_evm_bb_keys,
    	.nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
    	.poll_interval = DA850_GPIO_KEYS_POLL_MS,
    };
    
    static struct platform_device da850_evm_bb_keys_device = {
    	.name = "gpio-keys-polled",
    	.id = 1,
    	.dev = {
    		.platform_data = &da850_evm_bb_keys_pdata
    	},
    };
    
    static void da850_evm_bb_keys_init(unsigned gpio)
    {
    	int i;
    	struct gpio_keys_button *button;
    
    	button = &da850_evm_bb_keys[0];
    	button->desc = (char *)
    		da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
    	button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
    
    	for (i = 0; i < DA850_N_BB_USER_SW; i++) {
    		button = &da850_evm_bb_keys[i + 1];
    		button->code = SW_LID + i;
    		button->desc = (char *)
    				da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
    		button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
    	}
    }
    
    #define DA850_N_BB_USER_LED	2
    
    static struct gpio_led da850_evm_bb_leds[] = {
    	[0 ... DA850_N_BB_USER_LED - 1] = {
    		.active_low = 1,
    		.gpio = -1, /* assigned at runtime */
    		.name = NULL, /* assigned at runtime */
    	},
    };
    
    static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
    	.leds = da850_evm_bb_leds,
    	.num_leds = ARRAY_SIZE(da850_evm_bb_leds),
    };
    
    static struct platform_device da850_evm_bb_leds_device = {
    	.name		= "leds-gpio",
    	.id		= -1,
    	.dev = {
    		.platform_data = &da850_evm_bb_leds_pdata
    	}
    };
    
    static void da850_evm_bb_leds_init(unsigned gpio)
    {
    	int i;
    	struct gpio_led *led;
    
    	for (i = 0; i < DA850_N_BB_USER_LED; i++) {
    		led = &da850_evm_bb_leds[i];
    
    		led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
    		led->name =
    			da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
    	}
    }
    
    static int da850_evm_bb_expander_setup(struct i2c_client *client,
    						unsigned gpio, unsigned ngpio,
    						void *c)
    {
    	int ret;
    
    	/*
    	 * Register the switches and pushbutton on the baseboard as a gpio-keys
    	 * device.
    	 */
    	da850_evm_bb_keys_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_keys_device);
    	if (ret) {
    		printk("Could not register baseboard GPIO expander keys");
    		goto io_exp_setup_sw_fail;
    	}
    
    	da850_evm_bb_leds_init(gpio);
    	ret = platform_device_register(&da850_evm_bb_leds_device);
    	if (ret) {
    		printk("Could not register baseboard GPIO expander LEDS");
    		goto io_exp_setup_leds_fail;
    	}
    
    	return 0;
    
    io_exp_setup_leds_fail:
    	platform_device_unregister(&da850_evm_bb_keys_device);
    io_exp_setup_sw_fail:
    	return ret;
    }
    
    static int da850_evm_bb_expander_teardown(struct i2c_client *client,
    					unsigned gpio, unsigned ngpio, void *c)
    {
    	platform_device_unregister(&da850_evm_bb_leds_device);
    	platform_device_unregister(&da850_evm_bb_keys_device);
    
    	return 0;
    }
    
    static struct pca953x_platform_data da850_evm_ui_expander_info = {
    	.gpio_base	= DAVINCI_N_GPIO,
    	.setup		= da850_evm_ui_expander_setup,
    	.teardown	= da850_evm_ui_expander_teardown,
    	.names		= da850_evm_ui_exp,
    };
    
    static struct pca953x_platform_data da850_evm_bb_expander_info = {
    	.gpio_base	= DA850_BB_EXPANDER_GPIO_BASE,
    	.setup		= da850_evm_bb_expander_setup,
    	.teardown	= da850_evm_bb_expander_teardown,
    	.names		= da850_evm_bb_exp,
    };
    
    static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
    	/*
    	{
    		I2C_BOARD_INFO("tlv320aic3x", 0x18),
    	},
     	{
    		I2C_BOARD_INFO("tca6416", 0x20),
    		.platform_data = &da850_evm_ui_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("tca6416", 0x21),
    		.platform_data = &da850_evm_bb_expander_info,
    	},
    	{
    		I2C_BOARD_INFO("cdce913", 0x65),
    	},
    
     	{
    		I2C_BOARD_INFO("tw9900", 0x45),
    	},
    	{
    		I2C_BOARD_INFO("PCA9543A", 0x73),
    	},
    	*/
    };
    
    /*
     * USB1 VBUS is controlled by GPIO2[4], over-current is reported on GPIO6[13].
     */
    #define ON_BD_USB_DRV	GPIO_TO_PIN(2, 4)
    #define ON_BD_USB_OVC	GPIO_TO_PIN(6, 13)
    
    static const short da850_evm_usb11_pins[] = {
    	DA850_GPIO2_4, DA850_GPIO6_13,
    	-1
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int, void *);
    
    static struct da8xx_ohci_root_hub da850_evm_usb11_pdata = {
    	.type			= GPIO_BASED,
    	.method	= {
    		.gpio_method = {
    			.power_control_pin	= ON_BD_USB_DRV,
    			.over_current_indicator = ON_BD_USB_OVC,
    		},
    	},
    	.board_ocic_handler	= da850_evm_usb_ocic_irq,
    };
    
    static irqreturn_t da850_evm_usb_ocic_irq(int irq, void *handler)
    {
    	if (handler != NULL)
    		((da8xx_ocic_handler_t)handler)(&da850_evm_usb11_pdata, 1);
    	return IRQ_HANDLED;
    }
    
    static __init void da850_evm_usb_init(void)
    {
    	u32 cfgchip2;
    	int ret;
    
    	/*
    	 * Set up USB clock/mode in the CFGCHIP2 register.
    	 * FYI:  CFGCHIP2 is 0x0000ef00 initially.
    	 */
    	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/* USB2.0 PHY reference clock is 24 MHz */
    	cfgchip2 &= ~CFGCHIP2_REFFREQ;
    	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ;
    
    	/*
    	 * Select internal reference clock for USB 2.0 PHY
    	 * and use it as a clock source for USB 1.1 PHY
    	 * (this is the default setting anyway).
    	 */
    	cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
    	cfgchip2 |=  CFGCHIP2_USB2PHYCLKMUX;
    	/*
    	 * We have to override VBUS/ID signals when MUSB is configured into the
    	 * host-only mode -- ID pin will float if no cable is connected, so the
    	 * controller won't be able to drive VBUS thinking that it's a B-device.
    	 * Otherwise, we want to use the OTG mode and enable VBUS comparators.
    	 */
    	cfgchip2 &= ~CFGCHIP2_OTGMODE;
    	cfgchip2 |=  CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN;
    
    	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
    
    	/*
    	 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
    	 * with the power on to power good time of 3 ms.
    	 */
    	ret = da8xx_register_usb20(1000, 3);
    	if (ret)
    		printk("%s: USB 2.0 registration failed: %d\n",
    			   __func__, ret);
    
    	/* initilaize usb module */
    	da8xx_board_usb_init(da850_evm_usb11_pins, &da850_evm_usb11_pdata);
    }
    
    static struct davinci_uart_config da850_evm_uart_config __initdata = {
    	.enabled_uarts = 0x7,
    };
    
    /* davinci da850 evm audio machine driver */
    static u8 da850_iis_serializer_direction[] = {
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	TX_MODE,
    	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data da850_evm_snd_data = {
    	.tx_dma_offset	= 0x2000,
    	.rx_dma_offset	= 0x2000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction),
    	.tdm_slots	= 2,
    	.serial_dir	= da850_iis_serializer_direction,
    	.asp_chan_q	= EVENTQ_0,
    	.version	= MCASP_VERSION_2,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static const short da850_evm_mcasp_pins[] __initconst = {
    	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
    	DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
    	DA850_AXR_11, DA850_AXR_12,
    	-1
    };
    
    static int da850_evm_mmc_get_ro(int index)
    {
    	return gpio_get_value(DA850_MMCSD_WP_PIN);
    }
    
    static int da850_evm_mmc_get_cd(int index)
    {
    	return !gpio_get_value(DA850_MMCSD_CD_PIN);
    }
    
    static struct davinci_mmc_config da850_mmc_config = {
    	.get_ro		= NULL,//da850_evm_mmc_get_ro,
    	.get_cd		= NULL,//da850_evm_mmc_get_cd,
    	.wires		= 4,
    	.max_freq	= 50000000,		//HUANYI_SYSTEM 
    	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_evm_mmcsd0_pins[] __initconst = {
    	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
    	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
    //	DA850_GPIO4_0, DA850_GPIO4_1, //HUANYI_SYSTEM 
    	-1
    };
    
    static void da850_panel_power_ctrl(int val)
    {
    	/* lcd power */
    	gpio_set_value_cansleep(DA850_LCD_PWR_PIN, val);
    
    	mdelay(200);
    
    	/* lcd backlight */
    	gpio_set_value_cansleep(DA850_LCD_BL_PIN, val);
    }
    
    static int da850_lcd_hw_init(void)
    {
    	int status;
    
    	status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
    	if (status < 0)
    		return status;
    
    	status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
    	if (status < 0) {
    		gpio_free(DA850_LCD_BL_PIN);
    		return status;
    	}
    
    	gpio_direction_output(DA850_LCD_BL_PIN, 0);
    	gpio_direction_output(DA850_LCD_PWR_PIN, 0);
    
    	return 0;
    }
    
    /* TPS65070 voltage regulator support */
    
    /* 3.3V */
    static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
    	{
    		.supply = "usb0_vdda33",
    	},
    	{
    		.supply = "usb1_vdda33",
    	},
    };
    
    /* 3.3V or 1.8V */
    static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
    	{
    		.supply = "dvdd3318_a",
    	},
    	{
    		.supply = "dvdd3318_b",
    	},
    	{
    		.supply = "dvdd3318_c",
    	},
    };
    
    /* 1.2V */
    static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
    	{
    		.supply = "cvdd",
    	},
    };
    
    /* 1.8V LDO */
    static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
    	{
    		.supply = "sata_vddr",
    	},
    	{
    		.supply = "usb0_vdda18",
    	},
    	{
    		.supply = "usb1_vdda18",
    	},
    	{
    		.supply = "ddr_dvdd18",
    	},
    };
    
    /* 1.2V LDO */
    static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
    	{
    		.supply = "sata_vdd",
    	},
    	{
    		.supply = "pll0_vdda",
    	},
    	{
    		.supply = "pll1_vdda",
    	},
    	{
    		.supply = "usbs_cvdd",
    	},
    	{
    		.supply = "vddarnwa1",
    	},
    };
    
    /* We take advantage of the fact that both defdcdc{2,3} are tied high */
    static struct tps6507x_reg_platform_data tps6507x_platform_data = {
    	.defdcdc_default = true,
    };
    
    static struct regulator_init_data tps65070_regulator_data[] = {
    	/* dcdc1 */
    	{
    		.constraints = {
    			.min_uV = 3150000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
    		.consumer_supplies = tps65070_dcdc1_consumers,
    	},
    
    	/* dcdc2 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 3450000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
    		.consumer_supplies = tps65070_dcdc2_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* dcdc3 */
    	{
    		.constraints = {
    			.min_uV = 950000,
    			.max_uV = 1350000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
    		.consumer_supplies = tps65070_dcdc3_consumers,
    		.driver_data = &tps6507x_platform_data,
    	},
    
    	/* ldo1 */
    	{
    		.constraints = {
    			.min_uV = 1710000,
    			.max_uV = 1890000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
    		.consumer_supplies = tps65070_ldo1_consumers,
    	},
    
    	/* ldo2 */
    	{
    		.constraints = {
    			.min_uV = 1140000,
    			.max_uV = 1320000,
    			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
    				REGULATOR_CHANGE_STATUS),
    			.boot_on = 1,
    		},
    		.num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
    		.consumer_supplies = tps65070_ldo2_consumers,
    	},
    };
    
    static struct touchscreen_init_data tps6507x_touchscreen_data = {
    	.poll_period =  30,	/* ms between touch samples */
    	.min_pressure = 0x30,	/* minimum pressure to trigger touch */
    	.vref = 0,		/* turn off vref when not using A/D */
    	.vendor = 0,		/* /sys/class/input/input?/id/vendor */
    	.product = 65070,	/* /sys/class/input/input?/id/product */
    	.version = 0x100,	/* /sys/class/input/input?/id/version */
    };
    
    static struct tps6507x_board tps_board = {
    	.tps6507x_pmic_init_data = &tps65070_regulator_data[0],
    	.tps6507x_ts_init_data = &tps6507x_touchscreen_data,
    };
    
    static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
    	{
    		I2C_BOARD_INFO("tps6507x", 0x48),
    		.platform_data = &tps_board,
    	},
    };
    
    static int __init pmic_tps65070_init(void)
    {
    	return i2c_register_board_info(1, da850_evm_tps65070_info,
    					ARRAY_SIZE(da850_evm_tps65070_info));
    }
    
    static const short da850_evm_lcdc_pins[] = {
    	DA850_GPIO2_8, DA850_GPIO2_15,
    	-1
    };
    
    static struct i2c_client *pca9543a;
    
    
    static int pca9543a_probe(struct i2c_client *client,
    		const struct i2c_device_id *id)
    {
    	pr_info("pca9543a_probe");
    	pca9543a = client;
    	return 0;
    }
    
    static int pca9543a_remove(struct i2c_client *client)
    {
    	pca9543a = NULL;
    	return 0;
    }
    
    static const struct i2c_device_id pca9543a_ids[] = {
    	{ "PCA9543A", 0, },
    	{ /* end of list */ },
    };
    
    /* This is for i2c driver for the MT9T031 header i2c switch */
    static struct i2c_driver pca9543a_driver = {
    	.driver.name	= "PCA9543A",
    	.id_table	= pca9543a_ids,
    	.probe		= pca9543a_probe,
    	.remove		= pca9543a_remove,
    };
    
    //#ifdef CONFIG_SOC_CAMERA_tw9900
    static struct i2c_board_info tw9900_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9900", 0x45),
        },
    };
    
    #if 1
    static struct tw9900_video_info tw9900_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout       = TW9900_MPO_FIELD,
    //    .link		 = &tw9900_info,
    };
    
    static struct soc_camera_link tw9900_link = {
    //    .power        = tw9900_power,
    	.board_info    = &tw9900_i2c_camera[0],
    	.i2c_adapter_id    = 1,
    	.bus_id		= 1,
    	.priv        = &tw9900_info,
    };
    #endif
    
    #if 0
    static struct tw9900_video_info tw9900_info = {
    	.buswidth = SOCAM_DATAWIDTH_8,
    	.mpout = tw9900_MPO_FIELD,
    	.link = {
    //		.power = tw9900_power,
    		.board_info = &tw9900_i2c_camera[0],
    		.i2c_adapter_id = 0,
    		.module_name = "tw9900",
    		}
    };
    
    #endif
    
    
    #if 0
    static struct platform_device tw9900_camera[] = {
        {
            .name    = "soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9900_link,
            },
        },
    };
    #else
    
    static struct platform_device tw9900_camera[] = {
    	{
    	.name = "soc-camera-pdrv",
    	.id = 0,
    	.dev = {
    		.platform_data = &tw9900_link,//&tw9900_info,
    		},
    	},
    };
    #endif
    
    
    
    static struct platform_device *tw9900_devices[] __initdata = {
        &tw9900_camera[0],
    };
    //#else
    
    #if 0
    static struct i2c_board_info tw9900_i2c_camera[] = {
        {
            I2C_BOARD_INFO("tw9900", 0x45),
        },
    };
    
    static struct tw9900_video_info tw9900_info = {
        .buswidth    = SOCAM_DATAWIDTH_8,
        .mpout        = tw9900_MPO_FIELD,
    };
    
    static struct soc_camera_link tw9900_link = {
    //    .power        = tw9900_power,
        .board_info    = &tw9900_i2c_camera[0],
        .i2c_adapter_id    = 0,
    	.bus_id		= 1,
        .priv        = &tw9900_info,
    };
    
    static struct platform_device tw9900_camera[] = {
        {
            .name    = "tw9900 soc-camera-pdrv",
            .id    = 1,
            .dev    = {
                .platform_data = &tw9900_link,
            },
        },
    };
    
    static struct platform_device *tw9900_devices[] __initdata = {
        &tw9900_camera[0],
    };
    //#endif
    
    #endif //#if 0
    
    /**
     * da850_enable_pca9543a() - Enable/Disable I2C switch PCA9543A for sensor
     * @en: enable/disable flag
     */
    static int da850_enable_pca9543a(int en)
    {
    	static char val = 1;
    	int status;
    	struct i2c_msg msg = {
    			.flags = 0,
    			.len = 1,
    			.buf = &val,
    		};
    
    	pr_info("da850evm_enable_pca9543a\n");
    	if (!en)
    		val = 0;
    
    	if (!pca9543a)
    		return -ENXIO;
    
    	msg.addr = pca9543a->addr;
    	/* turn i2c switch, pca9543a, on/off */
    	status = i2c_transfer(pca9543a->adapter, &msg, 1);
    	pr_info("da850evm_enable_pca9543a, status = %d\n", status);
    	return status;
    }
    
    static const short da850_evm_mii_pins[] = {
    	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
    	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
    	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
    	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static const short da850_evm_rmii_pins[] = {
    	DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
    	DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
    	DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
    	DA850_MDIO_D,
    	-1
    };
    
    static int __init da850_evm_config_emac(void)
    {
    	void __iomem *cfg_chip3_base;
    	int ret;
    	u32 val;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
    
    	val = __raw_readl(cfg_chip3_base);
    
    	if (rmii_en) {
    		val |= BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
    		pr_info("EMAC: RMII PHY configured, MII PHY will not be"
    							" functional\n");
    	} else {
    		val &= ~BIT(8);
    		ret = davinci_cfg_reg_list(da850_evm_mii_pins);
    		pr_info("EMAC: MII PHY configured, RMII PHY will not be"
    							" functional\n");
    	}
    
    	if (ret)
    		printk("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
    				ret);
    
    	/* configure the CFGCHIP3 register for RMII or MII */
    	__raw_writel(val, cfg_chip3_base);
    
    	ret = davinci_cfg_reg(DA850_GPIO2_6);
    	if (ret)
    		printk("da850_evm_init:GPIO(2,6) mux setup "
    							"failed\n");
    
    	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
    	if (ret) {
    		printk("Cannot open GPIO %d\n",
    					DA850_MII_MDIO_CLKEN_PIN);
    		return ret;
    	}
    
    	/* Enable/Disable MII MDIO clock */
    	gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
    
    	soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
    
    	ret = da8xx_register_emac();
    	if (ret)
    		printk("da850_evm_init: emac registration failed: %d\n",
    				ret);
    
    	return 0;
    }
    device_initcall(da850_evm_config_emac);
    
    static const struct vpif_input da850_ch2_inputs[] = {
    		{
    		.input = {
    			.index = 0,
    			.name = "Camera",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = V4L2_STD_BAYER_ALL
    		},
    		.subdev_name = "tw9900",
    	},
    };
    
    /*
     * The following EDMA channels/slots are not being used by drivers (for
     * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
     * they are being reserved for codecs on the DSP side.
     */
    static const s16 da850_dma0_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma0_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 8,  6},
    	{24,  4},
    	{30, 50},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_chans[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30,  2},
    	{-1, -1}
    };
    
    static const s16 da850_dma1_rsv_slots[][2] = {
    	/* (offset, number) */
    	{ 0, 28},
    	{30, 90},
    	{-1, -1}
    };
    
    static struct edma_rsv_info da850_edma_cc0_rsv = {
    	.rsv_chans	= da850_dma0_rsv_chans,
    	.rsv_slots	= da850_dma0_rsv_slots,
    };
    
    static struct edma_rsv_info da850_edma_cc1_rsv = {
    	.rsv_chans	= da850_dma1_rsv_chans,
    	.rsv_slots	= da850_dma1_rsv_slots,
    };
    
    static struct edma_rsv_info *da850_edma_rsv[2] = {
    	&da850_edma_cc0_rsv,
    	&da850_edma_cc1_rsv,
    };
    
    #ifdef CONFIG_CPU_FREQ
    static __init int da850_evm_init_cpufreq(void)
    {
    	switch (system_rev & 0xF) {
    	case 3:
    		da850_max_speed = 456000;
    		break;
    	case 2:
    		da850_max_speed = 408000;
    		break;
    	case 1:
    		da850_max_speed = 372000;
    		break;
    	}
    
    	return da850_register_cpufreq("pll0_sysclk3");
    }
    #else
    static __init int da850_evm_init_cpufreq(void) { return 0; }
    #endif
    
    #if defined(CONFIG_DAVINCI_UART1_AFE)
    #define HAS_UART1_AFE 1
    #else
    #define HAS_UART1_AFE 0
    #endif
    
    /* Retaining these APIs, since the VPIF drivers do not check NULL handlers */
    static int da850_set_vpif_clock(int mux_mode, int hd)
    {
    	return 0;
    }
    
    static int da850_setup_vpif_input_channel_mode(int mux_mode)
    {
    	return 0;
    }
    
    int da850_vpif_setup_input_path(int ch, const char *name)
    {
    	int ret = 0;
    
    	 if (!strcmp(name, "mt9t031") && have_imager())
    		ret = da850_enable_pca9543a(1);
    
    	return ret;
    }
    
    static int da850_vpif_intr_status(void __iomem *vpif_base, int channel)
    {
    	int status = 0;
    	int mask;
    
    	if (channel < 0 || channel > 3)
    		return 0;
    
    	mask = 1 << channel;
    	status = __raw_readl((vpif_base + VPIF_STATUS)) & mask;
    	__raw_writel(status, (vpif_base + VPIF_STATUS_CLR));
    
    	return status;
    }
    
    #if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    /* VPIF capture configuration */
    static struct tvp514x_platform_data tvp5146_pdata = {
    	.clk_polarity = 0,
    	.hs_polarity = 1,
    	.vs_polarity = 1
    };
    #endif
    
    #define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
    
    static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = {
    	{
    		.name	= "tw9900",
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x45),
    			.platform_data = &tw9900_link,		//Titus latest Debug
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    #if 0
    //#elif defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	{
    		.name	= "tw9900",
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x45),
    			.platform_data = (void *)1,
    		},
    		.vpif_if = {
    			.if_type = VPIF_IF_RAW_BAYER,
    			.hd_pol = 0,
    			.vd_pol = 0,
    			.fid_pol = 0,
    		},
    	},
    /*
    	{
    		.name	= "tw9900-0",
    		.board_info = {
    			I2C_BOARD_INFO("tw9900", 0x45),
    			.platform_data = (void *)1,
    		},
    		.input = INPUT_CVBS_VI2B,
    //		.output = OUTPUT_8BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    
     	{
    		.name	= TVP5147_CH1,
    		.board_info = {
    			I2C_BOARD_INFO("tvp5146", 0x5c),
    			.platform_data = &tvp5146_pdata,
    		},
    		.input = INPUT_SVIDEO_VI2C_VI1C,
    		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
    		.can_route = 1,
    		.vpif_if = {
    			.if_type = VPIF_IF_BT656,
    			.hd_pol = 1,
    			.vd_pol = 1,
    			.fid_pol = 0,
    		},
    	},
    	*/
    //#endif
    
    #endif  //#if 0
    
    };
    
    static const struct vpif_input da850_ch0_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "Composite",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = "tw9900-0",
    	},
    };
    
    static const struct vpif_input da850_ch1_inputs[] = {
    	{
    		.input = {
    			.index = 0,
    			.name = "S-Video",
    			.type = V4L2_INPUT_TYPE_CAMERA,
    			.std = TVP514X_STD_ALL,
    		},
    		.subdev_name = TVP5147_CH1,
    	},
    };
    
    static struct vpif_capture_config da850_vpif_capture_config = {
    	.setup_input_channel_mode = da850_setup_vpif_input_channel_mode,
    	//.setup_input_path = da850_vpif_setup_input_path,
    	.intr_status = da850_vpif_intr_status,
    	.subdev_info = da850_vpif_capture_sdev_info,
    	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info),
    #if 0
    //#if defined(CONFIG_DA850_UI_SD_VIDEO_PORT)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    	/*
    	.chan_config[1] = {
    		.inputs = da850_ch1_inputs,
    		.input_count = ARRAY_SIZE(da850_ch1_inputs),
    	},
    	*/
    #endif //#if 0
    
    //#elif defined(CONFIG_DA850_UI_CAMERA)
    	.chan_config[0] = {
    		.inputs = da850_ch2_inputs,
    		.input_count = ARRAY_SIZE(da850_ch2_inputs),
    	},
    //#endif
    	.card_name      = "DA850/OMAP-L138 Video Capture",
    };
    
    /* VPIF display configuration */
    static struct vpif_subdev_info da850_vpif_subdev[] = {
    	{
    		.name	= "adv7343",
    		.board_info = {
    			I2C_BOARD_INFO("adv7343", 0x2a),
    		},
    	},
    };
    
    static const char *vpif_output[] = {
    	"Composite",
    	"Component",
    	"S-Video",
    };
    
    static struct vpif_display_config da850_vpif_display_config = {
    	.set_clock	= da850_set_vpif_clock,
    	.intr_status	= da850_vpif_intr_status,
    	.subdevinfo	= da850_vpif_subdev,
    	.subdev_count	= ARRAY_SIZE(da850_vpif_subdev),
    	.output		= vpif_output,
    	.output_count	= ARRAY_SIZE(vpif_output),
    	.card_name	= "DA850/OMAP-L138 Video Display",
    };
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_DISPLAY_MODULE)
    #define HAS_VPIF_DISPLAY 1
    #else
    #define HAS_VPIF_DISPLAY 0
    #endif
    
    #if defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE) ||\
    		defined(CONFIG_VIDEO_DAVINCI_VPIF_CAPTURE_MODULE)
    #define HAS_VPIF_CAPTURE 1
    #else
    #define HAS_VPIF_CAPTURE 0
    #endif
    
    #ifdef CONFIG_DA850_WL12XX
    
    static void wl12xx_set_power(int index, bool power_on)
    {
    	static bool power_state;
    
    	pr_debug("Powering %s wl12xx", power_on ? "on" : "off");
    
    	if (power_on == power_state)
    		return;
    	power_state = power_on;
    
    	if (power_on) {
    		/* Power up sequence required for wl127x devices */
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		usleep_range(15000, 15000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    		usleep_range(1000, 1000);
    		gpio_set_value_cansleep(DA850_WLAN_EN, 1);
    		msleep(70);
    	} else {
    		gpio_set_value_cansleep(DA850_WLAN_EN, 0);
    	}
    }
    
    static struct davinci_mmc_config da850_wl12xx_mmc_config = {
    	.set_power	= wl12xx_set_power,
    	.wires		= 4,
    	.max_freq	= 25000000,
    	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE |
    			  MMC_CAP_POWER_OFF_CARD,
    	.version	= MMC_CTLR_VERSION_2,
    };
    
    static const short da850_wl12xx_pins[] __initconst = {
    	DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2,
    	DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD,
    //	DA850_GPIO6_9, DA850_GPIO6_10,
    	-1
    };
    
    static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
    	.irq			= -1,
    	.board_ref_clock	= WL12XX_REFCLOCK_38,
    	.platform_quirks	= WL12XX_PLATFORM_QUIRK_EDGE_IRQ,
    };
    
    static __init int da850_wl12xx_init(void)
    {
    	int ret;
    
    	ret = davinci_cfg_reg_list(da850_wl12xx_pins);
    	if (ret) {
    		pr_err("wl12xx/mmc mux setup failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config);
    	if (ret) {
    		pr_err("wl12xx/mmc registration failed: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en");
    	if (ret) {
    		pr_err("Could not request wl12xx enable gpio: %d\n", ret);
    		goto exit;
    	}
    
    	ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq");
    	if (ret) {
    		pr_err("Could not request wl12xx irq gpio: %d\n", ret);
    		goto free_wlan_en;
    	}
    
    	da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ);
    
    	ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data);
    	if (ret) {
    		pr_err("Could not set wl12xx data: %d\n", ret);
    		goto free_wlan_irq;
    	}
    
    	return 0;
    
    free_wlan_irq:
    	gpio_free(DA850_WLAN_IRQ);
    
    free_wlan_en:
    	gpio_free(DA850_WLAN_EN);
    
    exit:
    	return ret;
    }
    
    #else /* CONFIG_DA850_WL12XX */
    
    static __init int da850_wl12xx_init(void)
    {
    	return 0;
    }
    
    #endif /* CONFIG_DA850_WL12XX */
    
    static struct i2c_gpio_platform_data da850_gpio_i2c_pdata = {
    	.sda_pin	= GPIO_TO_PIN(1, 4),
    	.scl_pin	= GPIO_TO_PIN(1, 5),
    	.udelay		= 2,			/* 250 KHz */
    };
    
    static struct platform_device da850_gpio_i2c = {
    	.name		= "i2c-gpio",
    	.id		= 1,
    	.dev		= {
    		.platform_data	= &da850_gpio_i2c_pdata,
    	},
    };
    
    static __init int da850_set_emif_clk_rate(void)
    {
    	struct clk *emif_clk;
    
    	emif_clk = clk_get(NULL, "pll0_sysclk3");
    	if (WARN(IS_ERR(emif_clk), "Unable to get emif clock\n"))
    		return PTR_ERR(emif_clk);
    
    	return clk_set_rate(emif_clk, CONFIG_DA850_FIX_PLL0_SYSCLK3RATE);
    }
    
    struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
    	.pintc_base	= 0x4000,
    };
    
    #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
    
    static __init void da850_evm_init(void)
    {
    	int ret;
    	char mask = 0;
    	struct davinci_soc_info *soc_info = &davinci_soc_info;
    
    	u8 rmii_en = soc_info->emac_pdata->rmii_en;
    
    	pr_info("da850 init!\n");
    
    	ret = pmic_tps65070_init();
    	if (ret)
    		printk("da850_evm_init: TPS65070 PMIC init failed: %d\n",
    				ret);
    
    	/*
    	 * Though bootloader takes care to set emif clock at allowed
    	 * possible rate. Kernel needs to reconfigure this rate to
    	 * support platforms requiring fixed emif clock rate.
    	 */
    	ret = da850_set_emif_clk_rate();
    	if (ret)
    		printk("da850_evm_init: Failed to set rate of pll0_sysclk3/emif clock: %d\n",
    				ret);
    
    	ret = da850_register_edma(da850_edma_rsv);
    	if (ret)
    		printk("da850_evm_init: edma registration failed: %d\n",
    				ret);
    
    	ret = davinci_cfg_reg_list(da850_i2c0_pins);
    	if (ret)
    		printk("da850_evm_init: i2c0 mux setup failed: %d\n",
    				ret);
    
    	platform_device_register(&da850_gpio_i2c);
    
    	ret = da8xx_register_watchdog();
    	if (ret)
    		printk("da830_evm_init: watchdog registration failed: %d\n",
    				ret);
    
    	/* Support for UART 1 */
    	ret = davinci_cfg_reg_list(da850_uart1_pins);
    	if (ret)
    		printk("da850_evm_init: UART 1 mux setup failed:"
    						" %d\n", ret);
    
    	//if (HAS_MMC) 
    	{
    		ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
    		if (ret)
    			printk("da850_evm_init: mmcsd0 mux setup failed:"
    					" %d\n", ret);
    
    #if 0
    		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
    		if (ret)
    			printk("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_CD_PIN);
    		gpio_direction_input(DA850_MMCSD_CD_PIN);
    
    		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
    		if (ret)
    			printk("da850_evm_init: can not open GPIO %d\n",
    					DA850_MMCSD_WP_PIN);
    		gpio_direction_input(DA850_MMCSD_WP_PIN);
    #endif		
    
    		ret = da8xx_register_mmcsd0(&da850_mmc_config);
    		if (ret)
    			printk("da850_evm_init: mmcsd0 registration failed:"
    					" %d\n", ret);
    
    #if 0
    		ret = da850_wl12xx_init();
    		if (ret)
    			printk("da850_evm_init: wl12xx initialization"
    				   " failed: %d\n", ret);
    #endif
    	}
    
    	davinci_serial_init(&da850_evm_uart_config);
    
    	if (have_imager())
    		i2c_add_driver(&pca9543a_driver);
    	
    	i2c_register_board_info(1, da850_evm_i2c_devices,
    			ARRAY_SIZE(da850_evm_i2c_devices));
    	
    	/*
    	 * shut down uart 0 and 1; they are not used on the board and
    	 * accessing them causes endless "too much work in irq53" messages
    	 * with arago fs
    	 */
    	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
    
    	
    	if (HAS_MCASP) {
    		if (HAS_UART1_AFE)
    			printk("WARNING: both McASP and UART1_AFE are "
    				"enabled, but they share pins.\n"
    					"\tDisable one of them.\n");
    
    		ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
    		if (ret)
    			printk("da850_evm_init: mcasp mux setup failed: %d\n",
    					ret);
    
    		da8xx_register_mcasp(0, &da850_evm_snd_data);
    	}
    
    	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
    	if (ret)
    		printk("%s: pruss_uio initialization failed: %d\n",
    				__func__, ret);	
    
    	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
    	if (ret)
    		printk("da850_evm_init: lcdcntl mux setup failed: %d\n",
    				ret);
    
    	/* Handle board specific muxing for LCD here */
    	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
    	if (ret)
    		printk("da850_evm_init: evm specific lcd mux setup "
    				"failed: %d\n",	ret);
    	ret = da850_lcd_hw_init();
    	if (ret)
    		printk("da850_evm_init: lcd initialization failed: %d\n",
    				ret);
    
    	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
    	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
    	if (ret)
    		printk("da850_evm_init: lcdc registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_rtc();
    	if (ret)
    		printk("da850_evm_init: rtc setup failed: %d\n", ret);
    
    	ret = da850_evm_init_cpufreq();
    	if (ret)
    		printk("da850_evm_init: cpufreq registration failed: %d\n",
    				ret);
    
    	ret = da8xx_register_cpuidle();
    	if (ret)
    		printk("da850_evm_init: cpuidle registration failed: %d\n",
    				ret);
    
    	ret = da850_register_pm(&da850_pm_device);
    	if (ret)
    		printk("da850_evm_init: suspend registration failed: %d\n",
    				ret);
    
    	if (HAS_VPIF_DISPLAY || HAS_VPIF_CAPTURE) {
    		pr_info("Register VPIF VPIF ...\n");
    		ret = da850_register_vpif();
    		if (ret)
    			printk("da850_evm_init: VPIF setup failed: %d\n",
    				   ret);
    		else
    			pr_info("Register VPIF ok!\n");
    	}
    
    	if (HAS_VPIF_CAPTURE) {
    		
    		printk("tw9900_probe tw9900_i2c_camera[0x%x] \n", (int)&tw9900_i2c_camera);
    		printk("tw9900_probe tw9900_info[0x%x] \n", (int)&tw9900_info);
    		printk("tw9900_probe tw9900_link[0x%x] \n", (int)&tw9900_link);
    		printk("tw9900_probe tw9900_link.priv[0x%x] \n", (int)(tw9900_link.priv));
    		printk("tw9900_probe tw9900_camera[0x%x] \n", (int)&tw9900_camera);
    		printk("tw9900_probe tw9900_camera[0][0x%x] \n", (int)&(tw9900_camera[0]));
    		printk("tw9900_probe tw9900_camera.dev.platform_data[0x%x] \n", (int)(tw9900_camera[0].dev.platform_data));
    		printk("tw9900_probe tw9900_devices[0x%x] \n", (int)&tw9900_devices);
    
    		printk("tw9900_probe da850_vpif_capture_config[0x%x] \n", (int)&da850_vpif_capture_config);
    		printk("tw9900_probe da850_vpif_capture_sdev_info[0x%x] \n", (int)&da850_vpif_capture_sdev_info);
    		
    		ret = davinci_cfg_reg_list(da850_vpif_capture_pins);
    		if (ret)
    			printk("da850_evm_init: VPIF capture mux failed:"
    					"%d\n", ret);
    #if 1
    		ret = da850_register_vpif_capture(&da850_vpif_capture_config);
    		if (ret)
    			printk("da850_evm_init: VPIF capture setup failed:"
    					"%d\n", ret);
    		else
    			printk("da850_evm_init: VPIF capture setup success:"
    					"%d\n", ret);
    #endif
    
    		//I think that if da850_vpif_capture_config is ok, this line is not need?
    		//platform_add_devices(tw9900_devices, ARRAY_SIZE(tw9900_devices));
    	}
    
    	if (0){//HAS_VPIF_DISPLAY) {
    		ret = davinci_cfg_reg_list(da850_vpif_display_pins);
    		if (ret)
    			printk("da850_evm_init : VPIF capture mux failed :"
    					"%d\n", ret);
    
    		ret = da850_register_vpif_display(&da850_vpif_display_config);
    		if (ret)
    			printk("da850_evm_init: VPIF display setup failed:"
    					"%d\n", ret);
    	}
    
    	ret = da8xx_register_spi(1, da850evm_spi_info,
    				 ARRAY_SIZE(da850evm_spi_info));
    	if (ret)
    		printk("da850_evm_init: spi 1 registration failed: %d\n",
    				ret);
    
    	ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE);
    	if (ret)
    		printk("da850_evm_init: sata registration failed: %d\n",
    				ret);
    
    	da850_evm_setup_mac_addr();
    
    	da850_evm_usb_init();
    
    	if (HAS_EHRPWM) {
    		if (rmii_en) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm0_pins);
    			if (ret)
    				printk("da850_evm_init:"
    				" ehrpwm0 mux setup failed: %d\n", ret);
    			else
    				mask = BIT(0) | BIT(1);
    		} else {
    			printk("da850_evm_init:"
    			" eHRPWM module 0 cannot be used"
    			" since it is being used by MII interface\n");
    			mask = 0;
    		}
    
    		if (!HAS_LCD) {
    			ret = davinci_cfg_reg_list(da850_ehrpwm1_pins);
    			if (ret)
    				printk("da850_evm_init:"
    				" eHRPWM module1 output A mux"
    				" setup failed %d\n", ret);
    			else
    				mask = mask | BIT(2);
    		} else {
    			printk("da850_evm_init:"
    				" eHRPWM module1 outputA cannot be"
    				" used since it is being used by LCD\n");
    		}
    
    		if (!HAS_SPI) {
    			ret = davinci_cfg_reg(DA850_EHRPWM1_B);
    			if (ret)
    				printk("da850_evm_init:"
    					" eHRPWM module1 outputB mux"
    					" setup failed %d\n", ret);
    		else
    			mask =  mask  | BIT(3);
    		} else {
    			printk("da850_evm_init:"
    				" eHRPWM module1 outputB cannot be"
    				" used since it is being used by spi1\n");
    		}
    
    		da850_register_ehrpwm(mask);
    	}
    
    	if (HAS_ECAP_PWM) {
    		ret = davinci_cfg_reg(DA850_ECAP2_APWM2);
    		if (ret)
    			printk("da850_evm_init:ecap mux failed:"
    					" %d\n", ret);
    		ret = da850_register_ecap(2);
    		if (ret)
    			printk("da850_evm_init:"
    				" eCAP registration failed: %d\n", ret);
    	}
    
    	if (HAS_BACKLIGHT) {
    		ret = da850_register_backlight(&da850evm_backlight,
    				&da850evm_backlight_data);
    		if (ret)
    			printk("da850_evm_init:"
    				" backlight device registration"
    				" failed: %d\n", ret);
    	}
    
    	if (HAS_ECAP_CAP) {
    		if (HAS_MCASP)
    			printk("da850_evm_init:"
    				"ecap module 1 cannot be used "
    				"since it shares pins with McASP\n");
    		else {
    			ret = davinci_cfg_reg(DA850_ECAP1_APWM1);
    			if (ret)
    				printk("da850_evm_init:ecap mux failed:%d\n"
    						, ret);
    			else {
    				ret = da850_register_ecap_cap(1);
    				if (ret)
    					printk("da850_evm_init"
    					"eCAP registration failed: %d\n", ret);
    			}
    		}
    	}
    		
    
    //Titus debug latest
    #if 0
    	ret = platform_add_devices(tw9900_devices, ARRAY_SIZE(tw9900_devices));
    	if (ret)
    		printk("da850_evm_init: tw9900_devices failed: %d\n", ret);
    	else
    		printk("da850_evm_init: tw9900_devices success: %d\n", ret);
    #endif
    
    	
    }
    
    #ifdef CONFIG_SERIAL_8250_CONSOLE
    static int __init da850_evm_console_init(void)
    {
    	if (!machine_is_davinci_da850_evm())
    		return 0;
    
    	return add_preferred_console("ttyS", 2, "115200");
    }
    console_initcall(da850_evm_console_init);
    #endif
    
    static void __init da850_evm_map_io(void)
    {
    	da850_init();
    }
    
    MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
    	.atag_offset	= 0x100,
    	.map_io		= da850_evm_map_io,
    	.init_irq	= cp_intc_init,
    	.timer		= &davinci_timer,
    	.init_machine	= da850_evm_init,
    	.dma_zone_size	= SZ_128M,
    	.restart	= da8xx_restart,
    MACHINE_END
    

     

        Thanks very much for your help!

  • Hi Chang,

    Thanks for your update.