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.

DM3730EVM - DVSDK boot issue.

Other Parts Discussed in Thread: DM3730, ADS7846, TPS65951, MAX3232

Hi,

HW: DM3730EVM - mistral
SW: dvsdk_04_03_00_06

  I downloaded the fresh dvsdk4 from ti's website and trying to boot my dm3730 evm. referring to  developers guide, prepared my SD card using mksdboot.sh available in dvsdk. 

  • Used all the prebuilt Images to prepare bootable SD card
  • Used the Images which I have built on my ubuntu-10.04 32bit PC
  • Checked all the switch settings and confirmed that all switches are configured as suggested in TI's omap3 beginners guide and mistrals hardware reference manual, which came along with dvsdk.
  • I am using TI's arago tool chains (already available in dvsdk)and in Rules.make platform is specified as dm3730. 

    Both the cases, it couldn't boot. kernel either hangs or crashes at same point every time. Please find the logs below.

Texas Instruments X-Loader 1.51 (Dec 22 2011 - 23:00:39)
Starting X-loader on MMC

229036 Bytes Read from MMC
Starting OS Bootloader from MMC...
Starting OS Bootloader...


U-Boot 2010.06 (Dec 22 2011 - 23:11:38)

OMAP34xx/35xx-GP ES1.0, CPU-OPP2 L3-165MHz
OMAP3 EVM board + LPDDR/NAND
I2C: ready
DRAM: 256 MiB
NAND: HW ECC [Kernel/FS layout] selected
512 MiB
In: serial
Out: serial
Err: serial
Read back SMSC id 0x92200000
Die ID #1c2e0000000000000156087c0a022026
Net: smc911x-0
Hit any key to stop autoboot: 0
mmc1 is available
reading boot.scr

302 bytes read
Running bootscript from mmc ...
## Executing script at 82000000
reading uImage

3279160 bytes read
## Booting kernel from Legacy Image at 80200000 ...
Image Name: Linux-2.6.37
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3279096 Bytes = 3.1 MiB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[ 0.000000] Linux version 2.6.37 (root@ravikiranlapsony) (gcc version 4.3.3 (GCC) ) #1 Thu Feb 27 23:14:59 IST 2014
[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7f
[ 0.000000] CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] Machine: OMAP3 EVM
[ 0.000000] Reserving 4194304 bytes SDRAM for VRAM
[ 0.000000] Memory policy: ECC disabled, Data cache writeback
[ 0.000000] OMAP3630 ES1.0 (l2cache iva sgx neon isp 192mhz_clk )
[ 0.000000] SRAM: Mapped pa 0x40200000 to va 0xfe400000 size: 0x10000
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 45312
[ 0.000000] Kernel command line: console=ttyO0,115200n8 root=/dev/mmcblk0p2 rw ip=off mem=55M@0x80000000 mpurate=1000 omap_vout.vid1_static_vrfb_alloc=y o
mapfb.vram=0:4M mem=128M@0x88000000 rootwait
[ 0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[ 0.000000] Memory: 55MB 124MB = 179MB total
[ 0.000000] Memory: 168884k/168884k available, 18508k reserved, 0K highmem
[ 0.000000] Virtual kernel memory layout:
[ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
[ 0.000000] fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
[ 0.000000] DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
[ 0.000000] vmalloc : 0xd0800000 - 0xf8000000 ( 632 MB)
[ 0.000000] lowmem : 0xc0000000 - 0xd0000000 ( 256 MB)
[ 0.000000] modules : 0xbf000000 - 0xc0000000 ( 16 MB)
[ 0.000000] .init : 0xc0008000 - 0xc003f000 ( 220 kB)
[ 0.000000] .text : 0xc003f000 - 0xc061f35c (6017 kB)
[ 0.000000] .data : 0xc0620000 - 0xc07e2520 (1802 kB)
[ 0.000000] NR_IRQS:409
[ 0.000000] Clocking rate (Crystal/Core/MPU): 26.0/400/1000 MHz
[ 0.000000] omap_hwmod: i2c1: softreset failed (waited 10000 usec)
[ 0.000000] omap_hwmod: i2c2: softreset failed (waited 10000 usec)
[ 0.000000] omap_hwmod: i2c3: softreset failed (waited 10000 usec)
[ 0.000000] Reprogramming SDRC clock to 400000000 Hz
[ 0.000000] IRQ: Found an INTC at 0xfa200000 (revision 4.0) with 96 interrupts
[ 0.000000] Total of 96 interrupts on 1 active controller
[ 0.000000] GPMC revision 5.0
[ 0.000000] Trying to install interrupt handler for IRQ402
[ 0.000000] Trying to install interrupt handler for IRQ403
[ 0.000000] Trying to install interrupt handler for IRQ404
[ 0.000000] Trying to install interrupt handler for IRQ405
[ 0.000000] Trying to install interrupt handler for IRQ406
[ 0.000000] Trying to install interrupt handler for IRQ407
[ 0.000000] Trying to install interrupt handler for IRQ408
[ 0.000000] Trying to install type control for IRQ409
[ 0.000000] Trying to set irq flags for IRQ409
[ 0.000000] OMAP clockevent source: GPTIMER1 at 32768 Hz
[ 0.000000] Console: colour dummy device 80x30
[ 0.000000] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[ 0.000000] ... MAX_LOCKDEP_SUBCLASSES: 8
[ 0.000000] ... MAX_LOCK_DEPTH: 48
[ 0.000000] ... MAX_LOCKDEP_KEYS: 8191
[ 0.000000] ... CLASSHASH_SIZE: 4096
[ 0.000000] ... MAX_LOCKDEP_ENTRIES: 16384
[ 0.000000] ... MAX_LOCKDEP_CHAINS: 32768
[ 0.000000] ... CHAINHASH_SIZE: 16384
[ 0.000000] memory used by lock dependency info: 3935 kB
[ 0.000000] per task-struct memory footprint: 2304 bytes
[ 0.000000] Calibrating delay loop... 998.84 BogoMIPS (lpj=3899392)
[ 0.000000] pid_max: default: 32768 minimum: 301
[ 0.000000] Security Framework initialized
[ 0.000000] Mount-cache hash table entries: 512
[ 0.000000] CPU: Testing write buffer coherency: ok
[ 0.000000] regulator: core version 0.5
[ 0.000000] regulator: dummy:
[ 0.000000] NET: Registered protocol family 16
[ 0.000000] OMAP GPIO hardware version 2.5
[ 0.000000] OMAP GPIO hardware version 2.5
[ 0.000000] OMAP GPIO hardware version 2.5
[ 0.000000] OMAP GPIO hardware version 2.5
[ 0.000000] OMAP GPIO hardware version 2.5
[ 0.000000] OMAP GPIO hardware version 2.5
[ 0.000000] omap_mux_init: Add partition: #1: core, flags: 0
[ 0.000000] hw-breakpoint: debug architecture 0x4 unsupported.
[ 0.000000] ------------[ cut here ]------------
[ 0.000000] WARNING: at arch/arm/mach-omap2/clock.c:438 omap2_clk_switch_mpurate_at_boot+0x80/0xb4()
[ 0.000000] clock: dpll1_ck: unable to set MPU rate to 1000: -22
[ 0.000000] Modules linked in:
[ 0.000000] [<c004fa88>] (unwind_backtrace+0x0/0xec) from [<c0078f10>] (warn_slowpath_common+0x4c/0x64)
[ 0.000000] [<c0078f10>] (warn_slowpath_common+0x4c/0x64) from [<c0078fbc>] (warn_slowpath_fmt+0x30/0x40)
[ 0.000000] [<c0078fbc>] (warn_slowpath_fmt+0x30/0x40) from [<c001389c>] (omap2_clk_switch_mpurate_at_boot+0x80/0xb4)
[ 0.000000] [<c001389c>] (omap2_clk_switch_mpurate_at_boot+0x80/0xb4) from [<c00138dc>] (omap3xxx_clk_arch_init+0xc/0x3c)
[ 0.000000] [<c00138dc>] (omap3xxx_clk_arch_init+0xc/0x3c) from [<c003f3c8>] (do_one_initcall+0xc8/0x194)
[ 0.000000] [<c003f3c8>] (do_one_initcall+0xc8/0x194) from [<c000869c>] (kernel_init+0x98/0x150)
[ 0.000000] [<c000869c>] (kernel_init+0x98/0x150) from [<c004accc>] (kernel_thread_exit+0x0/0x8)
[ 0.000000] ---[ end trace 1b75b31a2719ed1c ]---
[ 0.000000] OMAP DMA hardware revision 5.0
[ 0.062744] bio: create slab <bio-0> at 0
[ 0.065277] regulator: vwl1271: 1800 mV
[ 0.068328] SCSI subsystem initialized
[ 0.074554] usbcore: registered new interface driver usbfs
[ 0.075317] usbcore: registered new interface driver hub
[ 0.075805] usbcore: registered new device driver usb
[ 0.078552] omap_i2c omap_i2c.1: bus 1 rev4.0 at 2600 kHz
[ 0.084136] twl4030: PIH (irq 7) chaining IRQs 368..375
[ 0.084228] twl4030: power (irq 373) chaining IRQs 376..383
[ 0.085449] twl4030: gpio (irq 368) chaining IRQs 384..401
[ 0.094390] regulator: VIO: 1800 mV normal standby
[ 0.095764] regulator: VMMC1: 1850 <--> 3150 mV at 3000 mV normal standby
[ 0.097137] regulator: VDAC: 1800 mV normal standby
[ 0.098480] regulator: VAUX2_4030: 2800 mV normal standby
[ 0.099792] regulator: VPLL2: 1800 mV normal standby
[ 0.101165] regulator: VSIM: 1800 <--> 3000 mV at 1800 mV normal standby
[ 0.102508] regulator: VAUX3: 2800 mV normal standby
[ 0.103210] omap_device: omap_i2c.1: new worst case deactivate latency 0: 30517
[ 0.112487] omap_i2c omap_i2c.2: bus 2 rev4.0 at 400 kHz
[ 0.128021] omap_i2c omap_i2c.3: bus 3 rev4.0 at 400 kHz
[ 0.131439] Advanced Linux Sound Architecture Driver Version 1.0.23.
[ 0.133056] Bluetooth: Core ver 2.15
[ 0.133514] NET: Registered protocol family 31
[ 0.133514] Bluetooth: HCI device and connection manager initialized
[ 0.133575] Bluetooth: HCI socket layer initialized
[ 0.134613] Switching to clocksource 32k_counter
[ 0.201843] musb-hdrc: version 6.0, otg (peripheral+host), debug=0
[ 0.202087] musb-hdrc musb-hdrc.0: dma type: dma-inventra
[ 0.202606] musb-hdrc musb-hdrc.0: USB OTG mode controller at fa0ab000 using DMA, IRQ 92
[ 0.203552] NET: Registered protocol family 2
[ 0.203857] IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.204620] TCP established hash table entries: 8192 (order: 4, 65536 bytes)
[ 0.204833] TCP bind hash table entries: 8192 (order: 6, 360448 bytes)
[ 0.206207] TCP: Hash tables configured (established 8192 bind 8192)
[ 0.206237] TCP reno registered
[ 0.206237] UDP hash table entries: 128 (order: 1, 12288 bytes)
[ 0.206359] UDP-Lite hash table entries: 128 (order: 1, 12288 bytes)
[ 0.206817] NET: Registered protocol family 1
[ 0.207580] RPC: Registered udp transport module.
[ 0.207580] RPC: Registered tcp transport module.
[ 0.207611] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.208068] NetWinder Floating Point Emulator V0.97 (double precision)
[ 0.210083] omap_device: omap_i2c.1: new worst case activate latency 0: 30517
[ 0.212036] omap3evm camera init done successfully...
[ 0.212493] omap-iommu omap-iommu.0: isp registered
[ 0.213043] AM37x/DM37x Linux PSP version 04.02.00.07 (OMAP3EVM)
[ 0.315460] VFS: Disk quotas dquot_6.5.2
[ 0.315521] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[ 0.316802] JFFS2 version 2.2. (NAND) (SUMMARY) �© 2001-2006 Red Hat, Inc.
[ 0.317321] msgmni has been set to 329
[ 0.320281] io scheduler noop registered
[ 0.320281] io scheduler deadline registered
[ 0.320404] io scheduler cfq registered (default)
[ 0.385009] OMAP DSS rev 2.0
[ 0.385192] OMAP DISPC rev 3.0
[ 0.385253] OMAP VENC rev 2
[ 0.385864] OMAP DSI rev 1.0
[ 0.715393] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 0.719482] omap_uart.0: ttyO0 at MMIO 0x4806a000 (irq = 72) is a OMAP UART0
[ 1.552886] console [ttyO0] enabled
[ 1.557373] omap_uart.1: ttyO1 at MMIO 0x4806c000 (irq = 73) is a OMAP UART1
[ 1.565521] omap_uart.2: ttyO2 at MMIO 0x49020000 (irq = 74) is a OMAP UART2
[ 1.573608] omap_uart.3: ttyO3 at MMIO 0x49042000 (irq = 80) is a OMAP UART3
[ 1.604858] brd: module loaded
[ 1.619537] loop: module loaded
[ 1.627746] mtdoops: mtd device (mtddev=name/number) must be supplied
[ 1.634490] omap2-nand driver initializing
[ 1.639282] NAND device: Manufacturer ID: 0xad, Chip ID: 0xbc (Hynix )
[ 1.646179] Creating 5 MTD partitions on "omap2-nand.0":
[ 1.651763] 0x000000000000-0x000000080000 : "X-Loader-NAND"
[ 1.661712] 0x000000080000-0x0000001c0000 : "U-Boot-NAND"
[ 1.671173] 0x0000001c0000-0x000000280000 : "Boot Env-NAND"
[ 1.680480] 0x000000280000-0x000000780000 : "Kernel-NAND"
[ 1.691497] 0x000000780000-0x000020000000 : "File System - NAND"
[ 1.933410] OneNAND driver initializing
[ 1.937591] omap2-onenand omap2-onenand: Cannot request GPMC CS
[ 1.943939] omap2-onenand: probe of omap2-onenand failed with error -16
[ 1.953186] smsc911x: Driver version 2008-10-21.
[ 1.961486] smsc911x-mdio: probed
[ 1.965332] eth0: attached PHY driver [SMSC LAN8700] (mii_bus:phy_addr=ffffffff:01, irq=-1)
[ 1.974426] net eth0: MAC Address: 00:50:c2:7e:92:e9
[ 1.980560] usbcore: registered new interface driver asix
[ 1.986633] usbcore: registered new interface driver cdc_ether
[ 1.993103] usbcore: registered new interface driver net1080
[ 1.999420] usbcore: registered new interface driver cdc_subset
[ 2.006011] usbcore: registered new interface driver zaurus
[ 2.011901] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 3.025390] ehci-omap ehci-omap.0: OMAP-EHCI Host Controller
[ 3.031768] ehci-omap ehci-omap.0: new USB bus registered, assigned bus number 1
[ 3.039855] ehci-omap ehci-omap.0: irq 77, io mem 0x48064800
[ 3.056701] ehci-omap ehci-omap.0: USB 2.0 started, EHCI 1.00
[ 3.063049] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 3.070190] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 3.077758] usb usb1: Product: OMAP-EHCI Host Controller
[ 3.083343] usb usb1: Manufacturer: Linux 2.6.37 ehci_hcd
[ 3.089019] usb usb1: SerialNumber: ehci-omap.0
[ 3.095916] hub 1-0:1.0: USB hub found
[ 3.099884] hub 1-0:1.0: 3 ports detected
[ 3.135345] Initializing USB Mass Storage driver...
[ 3.140930] usbcore: registered new interface driver usb-storage
[ 3.147247] USB Mass Storage support registered.
[ 3.152557] usbcore: registered new interface driver usbtest
[ 3.158599] g_ether gadget: using random self ethernet address
[ 3.164733] g_ether gadget: using random host ethernet address
[ 3.171905] usb0: MAC 56:17:5c:59:e4:63
[ 3.175964] usb0: HOST MAC 1a:90:6a:42:d1:31
[ 3.180480] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[ 3.187438] g_ether gadget: g_ether ready
[ 3.191650] musb-hdrc musb-hdrc.0: MUSB HDRC host driver
[ 3.197357] musb-hdrc musb-hdrc.0: new USB bus registered, assigned bus number 2
[ 3.205718] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[ 3.212829] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 3.220428] usb usb2: Product: MUSB HDRC host driver
[ 3.225616] usb usb2: Manufacturer: Linux 2.6.37 musb-hcd
[ 3.231292] usb usb2: SerialNumber: musb-hdrc.0
[ 3.237823] hub 2-0:1.0: USB hub found
[ 3.241790] hub 2-0:1.0: 1 port detected
[ 3.248535] mice: PS/2 mouse device common for all mice
[ 3.256072] input: TWL4030 Keypad as /devices/platform/omap/omap_i2c.1/i2c-1/1-004a/twl4030_keypad/input/input0
[ 3.267608] omap_device: omap_i2c.1: new worst case activate latency 0: 61035
[ 3.279602] ads7846 spi1.0: touchscreen, irq 335
[ 3.285858] input: ADS7846 Touchscreen as /devices/platform/omap2_mcspi.1/spi1.0/input/input1
[ 3.298583] input: twl4030_pwrbutton as /devices/platform/omap/omap_i2c.1/i2c-1/1-0049/twl4030_pwrbutton/input/input2
[ 3.312103] twl_rtc twl_rtc: rtc core: registered twl_rtc as rtc0
[ 3.319122] twl_rtc twl_rtc: Power up reset detected.
[ 3.325225] twl_rtc twl_rtc: Enabling TWL-RTC.
[ 3.331268] i2c /dev entries driver
[ 3.338165] Linux media interface: v0.10
[ 3.342651] Linux video capture interface: v2.00
[ 3.349121] omap3isp supply VDD_CSIPHY1 not found, using dummy regulator
[ 3.356231] omap3isp supply VDD_CSIPHY2 not found, using dummy regulator
[ 3.363525] omap3isp omap3isp: Revision 15.0 found
[ 3.368652] omap-iommu omap-iommu.0: isp: version 1.1
[ 3.437957] mt9t111 2-003c: Unable to detectmt9t111sensor
[ 3.446838] isp_register_subdev_group: Unable to register subdev mt9t111
[ 3.454986] tvp514x 3-005c: tvp514x 3-005c decoder driver registered !!
[ 3.462799] tvp514x 3-005c: Write: retry ... 0
[ 3.486694] tvp514x 3-005c: Write: retry ... 1
[ 3.510101] tvp514x 3-005c: Write: retry ... 2
[ 3.533538] tvp514x 3-005c: Write: retry ... 3
[ 3.556976] tvp514x 3-005c: Write: retry ... 4
[ 3.580413] tvp514x 3-005c: Write: retry ... 5
[ 3.603851] tvp514x 3-005c: Write failed. Err[-121]
[ 3.608917] tvp514x 3-005c: Unable to turn on decoder
[ 3.614410] tvp514x 3-005c: Read: retry ... 0
[ 3.635101] tvp514x 3-005c: Read: retry ... 1
[ 3.658538] tvp514x 3-005c: Read: retry ... 2
[ 3.681976] tvp514x 3-005c: Read: retry ... 3
[ 3.705413] tvp514x 3-005c: Read: retry ... 4
[ 3.728851] tvp514x 3-005c: Read: retry ... 5
[ 3.752288] tvp514x 3-005c: Unable to query std
[ 3.757934] usbcore: registered new interface driver uvcvideo
[ 3.763977] USB Video Class driver (v1.0.0)
[ 3.769561] OMAP Watchdog Timer Rev 0x31: initial timeout 60 sec
[ 3.776336] Bluetooth: HCI UART driver ver 2.2
[ 3.781005] Bluetooth: HCI H4 protocol initialized
[ 3.786041] Bluetooth: HCILL protocol initialized
[ 3.796783] mmci-omap-hs.1 supply vmmc_aux not found, using dummy regulator
[ 3.878479] usbcore: registered new interface driver usbhid
[ 3.884307] usbhid: USB HID core driver
[ 3.890045] usbcore: registered new interface driver snd-usb-audio
[ 3.899444] OMAP3 EVM SoC init
[ 3.938903] mmc1: card claims to support voltages below the defined range. These will be ignored.
[ 3.988098] asoc: twl4030-hifi <-> omap-mcbsp-dai.1 mapping ok
[ 3.997222] ALSA device list:
[ 4.000335] #0: omap3evm
[ 4.003204] oprofile: hardware counters not available
[ 4.008483] oprofile: using timer interrupt.
[ 4.013153] nf_conntrack version 0.5.0 (2638 buckets, 10552 max)
[ 4.020385] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 4.026306] TCP cubic registered
[ 4.029693] Initializing XFRM netlink socket
[ 4.034301] NET: Registered protocol family 17
[ 4.039001] NET: Registered protocol family 15
[ 4.044036] Bluetooth: L2CAP ver 2.15
[ 4.047912] Bluetooth: L2CAP socket layer initialized
[ 4.053253] Bluetooth: SCO (Voice Link) ver 0.6
[ 4.058013] Bluetooth: SCO socket layer initialized
[ 4.063446] Bluetooth: RFCOMM TTY layer initialized
[ 4.068634] Bluetooth: RFCOMM socket layer initialized
[ 4.074035] Bluetooth: RFCOMM ver 1.11
[ 4.077941] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 4.083526] Bluetooth: BNEP filters: protocol multicast
[ 4.089019] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[ 4.096405] Registering the dns_resolver key type
[ 4.101593] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
[ 4.110443] ThumbEE CPU extension supported.
[ 4.121459] ------------[ cut here ]------------
[ 4.126312] Unable to handle kernel paging request at virtual address 9008d992
[ 4.133850] pgd = c0004000
[ 4.136657] [9008d992] *pgd=00000000
[ 4.140411] Internal error: Oops: 5 [#1]
[ 4.144500] last sysfs file:
[ 4.147583] Modules linked in:
[ 4.150787] CPU: 0 Tainted: G W (2.6.37 #1)
[ 4.156341] PC is at kallsyms_expand_symbol+0xc/0x84
[ 4.161529] LR is at kallsyms_lookup+0xa4/0xe4
[ 4.166198] pc : [<c00b13a8>] lr : [<c00b1b24>] psr: 20000093
[ 4.166198] sp : cf429ccc ip : 9008d992 fp : 00000400
[ 4.178192] r10: c07f3c9c r9 : c0571c11 r8 : cf429d10
[ 4.183654] r7 : cf429d0c r6 : cf429d14 r5 : cf429d31 r4 : c046e9ac
[ 4.190460] r3 : c04e1890 r2 : cf429d11 r1 : cf429d31 r0 : cfbac102
[ 4.197296] Flags: nzCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel
[ 4.205017] Control: 10c5387d Table: 80004019 DAC: 00000017
[ 4.211029] Process swapper (pid: 1, stack limit = 0xcf4282f0)
[ 4.217102] Stack: (0xcf429ccc to 0xcf42a000)
[ 4.221649] 9cc0: c046e9ac cf429d31 cf429d14 cf429d0c cf429d10
[ 4.230224] 9ce0: c07f3c9c c00b1b24 cf429d31 c046e9ac c0571c12 c07f409c c07f409c c00b1b8c
[ 4.238769] 9d00: cf429d31 c0634fec 00000001 60000093 00000000 cf41a4f0 00000002 c07f3cbe
[ 4.247314] 9d20: c07f409c c021530c 00000000 60000093 00000000 c0067910 c0634fdc 0012400e
[ 4.255859] 9d40: 00000000 c00a4e14 00000000 0012400e 00000000 cf41a040 c0058e9c c0067910
[ 4.264404] 9d60: c0063e5c cf41a070 00000000 c00a5c68 c06359f0 cf41a0a0 00000000 00000001
[ 4.272949] 9d80: 00000000 0001da73 00000000 1b478423 00000000 c0213f98 c0635c40 cf429dd6
4.281524] 9da0: cf429ea5 cf429dde c07f3cba 0000ffff cf429dde c07f3cba 0000ffff 00000002
[ 4.290069] 9dc0: c07f409c c0214110 00000000 00000000 c0e69148 0000ffff 31323134 31320155
[ 4.298614] 9de0: 00000033 c0266c2c cf6a9410 cf6a9400 c0636400 00000033 c02668f8 c07e8434
[ 4.307159] 9e00: cf6a9400 cf6a9400 000026cb c0636478 c0636468 c07f3cbe c046e9ac c0215b20
[ 4.315704] 9e20: c0636400 ff0a0005 ffffffff 00000053 c0571c0d cf429f0c c07f3cbe 00000001
[ 4.324249] 9e40: c0571c10 c0215e44 ff0a0005 ffffffff c0636414 cf429e58 ff0a0005 ffffffff
[ 4.332794] 9e60: 00000000 00000400 c0573605 00000000 cf429f04 00000004 00000000 c0571bfb
[ 4.341369] 9e80: 00000000 c0216058 c07f3c9c c0079c24 00000034 60000013 00000001 205b0000
[ 4.349914] 9ea0: 34202020 3132312e 5d393534 00000020 00000000 c0067910 00000002 00000071
[ 4.358459] 9ec0: 00000000 c00a4e14 00000000 00000071 00000000 00000138 c0573605 c046e9ac
[ 4.367004] 9ee0: 00000000 00000009 00000000 00000000 00000000 c046d804 000041ed c0078ef8
[ 4.375549] 9f00: c0571bfb c0573605 00000138 c046e9ac c01d5dac cf0007fc 00000000 cf001660
[ 4.384094] 9f20: c0c50268 c0078f44 00000000 cf000758 cf109858 c046e9ac cf000758 cf109858
[ 4.392639] 9f40: 00000000 c01d5dac cf1098d8 00000000 00000001 c0032c68 c0032cc8 c004accc
[ 4.401214] 9f60: 00000013 c0010c4c 00000000 c01d5e60 00000000 00000000 00000092 c0012a64
[ 4.409759] 9f80: c005b478 c02134e8 80000013 c0032c68 c0032cc8 c004accc 00000013 c0010c4c
[ 4.418304] 9fa0: 00000000 00000000 00000000 c0010c60 00000000 c003f3c8 00000038 00000000
[ 4.426849] 9fc0: 00000013 00000199 c079961c c0032c68 c0032cc8 c004accc 00000013 00000000
[ 4.435394] 9fe0: 00000000 c000869c 00000000 00000000 c0008604 c004accc ffffffff ffffffff
[ 4.443969] [<c00b13a8>] (kallsyms_expand_symbol+0xc/0x84) from [<c00b1b24>] (kallsyms_lookup+0xa4/0xe4)
[ 4.453887] [<c00b1b24>] (kallsyms_lookup+0xa4/0xe4) from [<c00b1b8c>] (sprint_symbol+0x28/0xb4)
[ 4.463073] [<c00b1b8c>] (sprint_symbol+0x28/0xb4) from [<c021530c>] (symbol_string+0x40/0x84)
[ 4.472076] [<c021530c>] (symbol_string+0x40/0x84) from [<c0215b20>] (pointer+0xd0/0x210)
[ 4.480621] [<c0215b20>] (pointer+0xd0/0x210) from [<c0215e44>] (vsnprintf+0x1e4/0x358)
[ 4.488983] [<c0215e44>] (vsnprintf+0x1e4/0x358) from [<c0216058>] (vscnprintf+0xc/0x18)
[ 4.497467] [<c0216058>] (vscnprintf+0xc/0x18) from [<c0079c24>] (vprintk+0x180/0x3e0)
[ 4.505737] [<c0079c24>] (vprintk+0x180/0x3e0) from [<c046d804>] (printk+0x18/0x28)
[ 4.513763] [<c046d804>] (printk+0x18/0x28) from [<c0078ef8>] (warn_slowpath_common+0x34/0x64)
[ 4.522766] [<c0078ef8>] (warn_slowpath_common+0x34/0x64) from [<c0078f44>] (warn_slowpath_null+0x1c/0x24)
[ 4.532867] [<c0078f44>] (warn_slowpath_null+0x1c/0x24) from [<c046e9ac>] (__mutex_unlock_slowpath+0x60/0x114)
[ 4.543334] [<c046e9ac>] (__mutex_unlock_slowpath+0x60/0x114) from [<c01d5dac>] (debugfs_create_file+0x16c/0x1a0)
[ 4.554046] [<c01d5dac>] (debugfs_create_file+0x16c/0x1a0) from [<c01d5e60>] (debugfs_create_dir+0x20/0x28)
[ 4.564239] [<c01d5e60>] (debugfs_create_dir+0x20/0x28) from [<c0012a64>] (omap_voltage_late_init+0x38/0x314)
[ 4.574615] [<c0012a64>] (omap_voltage_late_init+0x38/0x314) from [<c0010c60>] (omap2_common_pm_late_init+0x14/0x64)
[ 4.585632] [<c0010c60>] (omap2_common_pm_late_init+0x14/0x64) from [<c003f3c8>] (do_one_initcall+0xc8/0x194)
[ 4.596008] [<c003f3c8>] (do_one_initcall+0xc8/0x194) from [<c000869c>] (kernel_init+0x98/0x150)
[ 4.605194] [<c000869c>] (kernel_init+0x98/0x150) from [<c004accc>] (kernel_thread_exit+0x0/0x8)
[ 4.614379] Code: 28020288AA8 e59f3070 e92d45f0 e083c000 (e7d36000)

Reading boot sector Online 00:09

  • Hi Ravikiran,

    The following rows of the log (according ../linux-2.6.37/arch/arm/mm/fault.c file):

    [ 4.126312] Unable to handle kernel paging request at virtual address 9008d992
    [ 4.133850] pgd = c0004000
    [ 4.136657] [9008d992] *pgd=00000000
    [ 4.140411] Internal error: Oops: 5 [#1]

    indicate that the kernel tried to access some page that wasn't present but sometimes such crash could be observed when there is some hardware issue with the memory. If this is the DVSDK 4.03 with no changes I suggest you to check with other evm board if it is available.

    BR

    Tsvetolin Shulev

  • Cvetolin Shulev-XID,

    Thanks for the info.  Unfortunately I don't have a second EVM to check !!  Since you mentioned "some hardware issue with the memory", you mean to say that, hardware has gone bad? i.e. RAM?

  • Hi Ravikiran,

    I could not guarantee at 100% that this is a hardware problem with RAM but I have seen some time ago this error during booting with dvsdk 4.03 on one evm board but the other boot successfully with the same sd card. After exhaustive debugging the reason for error was found.

    BR

    Tsvetolin Shulev

  • Cvetolin Shulev-XID,

           Thanks for the information. I will try to find some alternatives .

    -Ravikiran

  • Hi,

    I am making a board with DM3730 processor in taking reference from the DM330 EVM by Mistral. My hardware details are as follows:


    1. Processor: DM3730CUS.

    2. Power IC: TPS65951.

    3. USB OTG: TPS65951, Connected to HSUSB0 port.

    4. NAND Flash: MT29F4G08ABB, Connected to nCS0 in GPMC.

    5. NOR Flash: JS28F256P30, Connected to nCS3 in GPMC.

    6. LPDDR: Two no. of MT46H128M16LFBF sharing Address, Chip-select, Controls and Clock signals. Chip select connected to nCS0, Clock enable connected to CKE0.

    7. Ethernet: Not Present.

    8. SD Card: Connected to MMC1 port.

    9. WiFi module TiWi-BLE: Connected to MMC2 port.

    10. USB Host: USB3320, Connected to HSUSB2 port.

    11. UART: MAX3232, only one channel of UART connected to UART1 port.

    For the board, I have installed the DM3730 DVSDK as per the user manual. I ran the "setup.sh" file and completed it as it is shown below:

    ubuntu@ubuntu:~/ti-dvsdk_dm3730-evm_04_03_00_06$ ./setup.sh

    --------------------------------------------------------------------------------
    TISDK setup script

    This script will set up your development host for dvsdk development.
    Parts of this script require administrator priviliges (sudo access).
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    Verifying Linux host distribution
    Unsupported host machine, only Ubuntu 10.04 LTS supported
    ./bin/setup-host-check.sh: line 9:  exit 1: command not found
    Ubuntu 10.04 LTS found successfully, continuing..
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    This step will make sure you have the proper host support packages installed
    using the following command: sudo apt-get install xinetd tftpd nfs-kernel-server minicom build-essential libncurses5-dev uboot-mkimage autoconf automake

    Note! This command requires you to have administrator priviliges (sudo access)
    on your host.
    Press return to continue

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    autoconf is already the newest version.
    automake is already the newest version.
    libncurses5-dev is already the newest version.
    uboot-mkimage is already the newest version.
    xinetd is already the newest version.
    minicom is already the newest version.
    tftpd is already the newest version.
    build-essential is already the newest version.
    nfs-kernel-server is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 442 not upgraded.

    Package verification and installation successfully completed
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    In which directory do you want to install the target filesystem?(if this directory does not exist it will be created)
    [ /home/ubuntu/targetfs ]
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    This step will extract the target filesystem to /home/ubuntu/targetfs

    Note! This command requires you to have administrator priviliges (sudo access)
    on your host.
    Press return to continue
    /home/ubuntu/targetfs already exists
    (r) rename existing filesystem (o) overwrite existing filesystem (s) skip filesystem extraction
    [r] o
    Old /home/ubuntu/targetfs removed

    Successfully extracted dvsdk-dm37x-evm-rootfs.tar.gz to /home/ubuntu/targetfs
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    This step will update the EXEC_DIR variables in the Rules.make file
    This will facilitate the SDK to install (with make install) rebuilt binaries in
        /home/ubuntu/targetfs

    The files will be available from / on the target.

    This setting can be changed later by editing Rules.make and changing the
    EXEC_DIR variable.

    Press return to continue
    Rules.make edited successfully..
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    This step will export your target filesystem for NFS access.

    Note! This command requires you to have administrator priviliges (sudo access)
    on your host.
    Press return to continue
    /home/ubuntu/targetfs already NFS exported, skipping..

     * Stopping NFS kernel daemon                                                                                                            [ OK ]
     * Unexporting directories for NFS kernel daemon...                                                                                      [ OK ]
     * Exporting directories for NFS kernel daemon...                                                                                        [ OK ]
     * Starting NFS kernel daemon                                                                                                            [ OK ]
    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------
    Which directory do you want to be your tftp root directory?(if this directory does not exist it will be created for you)
    [ /tftpboot ]
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    This step will set up the tftp server in the /tftpboot directory.

    Note! This command requires you to have administrator priviliges (sudo access)
    on your host.
    Press return to continue

    /tftpboot already exists, not creating..

    /tftpboot/uImage-dm37x-evm.bin already exists. The existing installed file can be renamed and saved under the new name.
    (r) rename (o) overwrite (s) skip copy
    [r] o

    Successfully overwritten uImage-dm37x-evm.bin in tftp root directory /tftpboot

    /etc/xinetd.d/tftp already exists..
    Copying old /etc/xinetd.d/tftp to /etc/xinetd.d/tftp.old

    /etc/xinetd.d/tftp successfully created

    Restarting tftp server
    Rather than invoking init scripts through /etc/init.d, use the service(8)
    utility, e.g. service xinetd stop

    Since the script you are attempting to invoke has been converted to an
    Upstart job, you may also use the stop(8) utility, e.g. stop xinetd
    xinetd stop/waiting
    Rather than invoking init scripts through /etc/init.d, use the service(8)
    utility, e.g. service xinetd start

    Since the script you are attempting to invoke has been converted to an
    Upstart job, you may also use the start(8) utility, e.g. start xinetd
    xinetd start/running, process 9656
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    This step will set up minicom (serial communication application) for
    DVSDK development

    Which serial port do you want to use with minicom?
    [ /dev/ttyS0 ] /dev/ttyUSB0

    Copied existing /home/ubuntu/.minirc.dfl to /home/ubuntu/.minirc.dfl.old

    Configuration saved to /home/ubuntu/.minirc.dfl. You can change it further from inside
    minicom, see the Software Development Guide for more information.
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    This step will set up the u-boot variables for booting the EVM.
    Autodetected the following ip address of your host, correct it if necessary
    [ 192.168.0.96 ]

    Select Primary display output:
     1: LCD
     2: DVI

    [ 1 ] 1
    Select Linux kernel location:
     1: TFTP
     2: SD card

    [ 1 ] 2

    Select root file system location:
     1: NFS
     2: SD card

    [ 1 ] 2

    Resulting u-boot variable settings:

    setenv bootdelay 4
    setenv baudrate 115200
    setenv bootargs console=ttyO0,115200n8 rw mem=55M@0x80000000 mpurate=1000 mem=128M@0x88000000 omap_vout.vid1_static_vrfb_alloc=y omapfb.vram=0:4M root=/dev/mmcblk0p2 rootfstype=ext3 rootwait ip=off
    setenv bootcmd 'mmc init;fatload mmc 0 0x82000000 uImage;bootm 0x82000000'
    --------------------------------------------------------------------------------

    --------------------------------------------------------------------------------
    Would you like to create a minicom script with the above parameters (y/n)?
    [ y ] y

    Moving existing setup_uimage-sd_fs-sd.minicom to setup_uimage-sd_fs-sd.minicom.old
    Successfully wrote setup_uimage-sd_fs-sd.minicom

    Would you like to run the setup script now (y/n)? This requires you to connect
    the RS-232 cable between your host and EVM as well as your ethernet cable as
    described in the Quick Start Guide. Once answering 'y' on the prompt below
    you will have 300 seconds to connect the board and power cycle it
    before the setup times out

    After successfully executing this script, your EVM will be set up. You will be
    able to connect to it by executing 'minicom -w' or if you prefer a windows host
    you can set up Tera Term as explained in the Software Developer's Guide.
    If you connect minicom or Tera Term and power cycle the board Linux will boot.

    [ y ] y
    ~/ti-dvsdk_dm3730-evm_04_03_00_06 ~/ti-dvsdk_dm3730-evm_04_03_00_06
    minicom: cannot open /dev/ttyUSB0: Permission denied
    You can manually run minicom in the future with this setup script using: minicom -S setup_uimage-sd_fs-sd.minicom
    --------------------------------------------------------------------------------

    TISDK setup completed!
    Please continue reading the Software Developer's Guide for more information on
    how to develop software on the EVM

    After setting up the SDK, the SD Card is prepared as per the user manual; and the board is powered on with the SD card inserted and the boot mode kept in MMC1 boot mode. However, the U-boot is not getting loaded in the target. I checked with a different boot setting, and found proper output coming in the minicom terminal; indicating proper loading of the MLO file into the target.

    Please suggest how to download the U-boot image and kernel image in this case. Also let me know how to modify and build the existing U-boot source codes to match the components connected in my board.

    -Anindya

  • Hi Anindya,

    I'm not sure that understanding what exactly is the issue. Could you give some clarifying details about both cases of "different boot setting". Could you describe boot settings in both cases and add the console output. If there is something different also add it.

    BR

    Tsvetolin Shulev

  • Hi,


     I have designed the board with reference to the DM3730 EVM, but I have not kept the Ethernet interface on the board. Please help me by suggesting how to boot linux kernel in the processor in my case.

    The procedure in DM3730 software development guide is based on downloading linux using tftp server; and is not working in my board. Hence I re-ran the "setup.sh" file as shown in the previous post. Still linux in not loading in the board from SD card.

    As different boot setting, I kept the sysboot pins in the modes 'case 6' and 'case 24' as per the omap3evm.c file

    /*
     * (C) Copyright 2006
     * Texas Instruments, <www.ti.com>
     * Jian Zhang <jzhang@ti.com>
     * Richard Woodruff <r-woodruff2@ti.com>
     *
     * See file CREDITS for list of people who contributed to this
     * project.
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     * MA 02111-1307 USA
     */
    #include <common.h>
    #include <command.h>
    #include <part.h>
    #include <fat.h>
    #include <asm/arch/cpu.h>
    #include <asm/arch/bits.h>
    #include <asm/arch/mux.h>
    #include <asm/arch/sys_proto.h>
    #include <asm/arch/sys_info.h>
    #include <asm/arch/clocks.h>
    #include <asm/arch/mem.h>
    
    /* Used to index into DPLL parameter tables */
    struct dpll_param {
            unsigned int m;
            unsigned int n;
            unsigned int fsel;
            unsigned int m2;
    };
    
    struct dpll_per_36x_param {
    	unsigned int sys_clk;
    	unsigned int m;
    	unsigned int n;
    	unsigned int m2;
    	unsigned int m3;
    	unsigned int m4;
    	unsigned int m5;
    	unsigned int m6;
    	unsigned int m2div;
    };
    
    typedef struct dpll_param dpll_param;
    
    extern unsigned int is_ddr_166M;
    
    #define MAX_SIL_INDEX	3
    
    /* Following functions are exported from lowlevel_init.S */
    extern dpll_param *get_mpu_dpll_param(void);
    extern dpll_param *get_iva_dpll_param(void);
    extern dpll_param *get_core_dpll_param(void);
    extern dpll_param *get_per_dpll_param(void);
    
    extern dpll_param *get_36x_mpu_dpll_param(void);
    extern dpll_param *get_36x_iva_dpll_param(void);
    extern dpll_param *get_36x_core_dpll_param(void);
    extern dpll_param *get_36x_per_dpll_param(void);
    
    extern int mmc_init(int verbose);
    extern block_dev_desc_t *mmc_get_dev(int dev);
    
    #define __raw_readl(a)    (*(volatile unsigned int *)(a))
    #define __raw_writel(v,a) (*(volatile unsigned int *)(a) = (v))
    #define __raw_readw(a)    (*(volatile unsigned short *)(a))
    #define __raw_writew(v,a) (*(volatile unsigned short *)(a) = (v))
    
    /*******************************************************
     * Routine: delay
     * Description: spinning delay to use before udelay works
     ******************************************************/
    static inline void delay(unsigned long loops)
    {
    	__asm__ volatile ("1:\n" "subs %0, %1, #1\n"
    			  "bne 1b":"=r" (loops):"0"(loops));
    }
    
    void udelay (unsigned long usecs) {
    	delay(usecs);
    }
    
    /*****************************************
     * Routine: board_init
     * Description: Early hardware init.
     *****************************************/
    int board_init (void)
    {
    	return 0;
    }
    
    /*************************************************************
     *  get_device_type(): tell if GP/HS/EMU/TST
     *************************************************************/
    u32 get_device_type(void)
    {
            int mode;
            mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
            return(mode >>= 8);
    }
    
    /************************************************
     * get_sysboot_value(void) - return SYS_BOOT[4:0]
     ************************************************/
    u32 get_sysboot_value(void)
    {
            int mode;
            mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
            return mode;
    }
    /*************************************************************
     * Routine: get_mem_type(void) - returns the kind of memory connected
     * to GPMC that we are trying to boot form. Uses SYS BOOT settings.
     *************************************************************/
    u32 get_mem_type(void)
    {
            u32   mem_type = get_sysboot_value();
            switch (mem_type){
                case 0:
                case 2:
                case 4:
                case 16:
                case 22:    return GPMC_ONENAND;
    
                case 1:
                case 12:
                case 15:
                case 21:
                case 27:    return GPMC_NAND;
    
                case 3:
                case 6:     return MMC_ONENAND;
    
                case 8:
                case 11:
                case 14:
                case 20:
                case 26:    return GPMC_MDOC;
    
                case 17:
                case 18:
                case 24:	return MMC_NAND;
    
                case 7:
                case 10:
                case 13:
                case 19:
                case 25:
                default:    return GPMC_NOR;
            }
    }
    
    /******************************************
     * get_cpu_rev(void) - extract version info
     ******************************************/
    u32 get_cpu_rev(void)
    {
    	u32 cpuid=0;
    	/* On ES1.0 the IDCODE register is not exposed on L4
    	 * so using CPU ID to differentiate
    	 * between ES2.0 and ES1.0.
    	 */
    	__asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r" (cpuid));
    	if((cpuid  & 0xf) == 0x0)
    		return CPU_3430_ES1;
    	else
    		return CPU_3430_ES2;
    
    }
    
    u32 is_cpu_family(void)
    {
    	u32 cpuid = 0, cpu_family = 0;
    	u16 hawkeye;
    
    	__asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
    	if ((cpuid & 0xf) == 0x0) {
    		cpu_family = CPU_OMAP34XX;
    	} else {
    		cpuid = __raw_readl(OMAP34XX_CONTROL_ID);
    		hawkeye  = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
    
    		switch (hawkeye) {
    			case HAWKEYE_OMAP34XX:
    				cpu_family = CPU_OMAP34XX;
    				break;
    			case HAWKEYE_AM35XX:
    				cpu_family = CPU_AM35XX;
    				break;
    			case HAWKEYE_OMAP36XX:
    				cpu_family = CPU_OMAP36XX;
    				break;
    			default:
    				cpu_family = CPU_OMAP34XX;
    				break;
    		}
    	}
    	return cpu_family;
    }
    /******************************************
     * cpu_is_3410(void) - returns true for 3410
     ******************************************/
    u32 cpu_is_3410(void)
    {
    	int status;
    	if(get_cpu_rev() < CPU_3430_ES2) {
    		return 0;
    	} else {
    		/* read scalability status and return 1 for 3410*/
    		status = __raw_readl(CONTROL_SCALABLE_OMAP_STATUS);
    		/* Check whether MPU frequency is set to 266 MHz which
    		 * is nominal for 3410. If yes return true else false
    		 */
    		if (((status >> 8) & 0x3) == 0x2)
    			return 1;
    		else
    			return 0;
    	}
    }
    
    /*****************************************************************
     * sr32 - clear & set a value in a bit range for a 32 bit address
     *****************************************************************/
    void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
    {
    	u32 tmp, msk = 0;
    	msk = 1 << num_bits;
    	--msk;
    	tmp = __raw_readl(addr) & ~(msk << start_bit);
    	tmp |=  value << start_bit;
    	__raw_writel(tmp, addr);
    }
    
    /*********************************************************************
     * wait_on_value() - common routine to allow waiting for changes in
     *   volatile regs.
     *********************************************************************/
    u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
    {
    	u32 i = 0, val;
    	do {
    		++i;
    		val = __raw_readl(read_addr) & read_bit_mask;
    		if (val == match_value)
    			return (1);
    		if (i == bound)
    			return (0);
    	} while (1);
    }
    
    #ifdef CFG_OMAPEVM_DDR
    #ifdef CONFIG_DDR_256MB_STACKED
    /**************************************************************************
     * make_cs1_contiguous() - for es2 and above remap cs1 behind cs0 to allow
     *  command line mem=xyz use all memory with out discontinuous support
     *  compiled in.  Could do it at the ATAG, but there really is two banks...
     * Called as part of 2nd phase DDR init.
     **************************************************************************/
    void make_cs1_contiguous(void)
    {
    	u32 size, a_add_low, a_add_high;
    
    	size = get_sdr_cs_size(SDRC_CS0_OSET);
    	size /= SZ_32M;         /* find size to offset CS1 */
    	a_add_high = (size & 3) << 8;   /* set up low field */
    	a_add_low = (size & 0x3C) >> 2; /* set up high field */
    	__raw_writel((a_add_high | a_add_low), SDRC_CS_CFG);
    }
    
    /***********************************************************************
     * get_cs0_size() - get size of chip select 0/1
     ************************************************************************/
    u32 get_sdr_cs_size(u32 offset)
    {
    	u32 size;
    
    	/* get ram size field */
    	size = __raw_readl(SDRC_MCFG_0 + offset) >> 8;
    	size &= 0x3FF;          /* remove unwanted bits */
    	size *= SZ_2M;          /* find size in MB */
    	return size;
    }
    #endif
    
    /*********************************************************************
     * config_3430sdram_ddr() - Init DDR on 3430SDP dev board.
     *********************************************************************/
    void config_3430sdram_ddr(void)
    {
    
    #ifndef CONFIG_DDR_256MB_STACKED
    	/* reset sdrc controller */
    	__raw_writel(SOFTRESET, SDRC_SYSCONFIG);
    	wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000);
    	__raw_writel(0, SDRC_SYSCONFIG);
    
    	/* setup sdrc to ball mux */
    	__raw_writel(SDP_SDRC_SHARING, SDRC_SHARING);
    
    	/* set mdcfg */
    	__raw_writel(SDP_SDRC_MDCFG_0_DDR, SDRC_MCFG_0);
    
    	/* set timing */
    	if (is_cpu_family() == CPU_OMAP36XX) {
    		if (is_ddr_166M) {
    			__raw_writel(MICRON_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_0);
    			__raw_writel(MICRON_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_0);
    		} else {
    			__raw_writel(HYNIX_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_0);
    			__raw_writel(HYNIX_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_0);
    		}
    
    	} else {
    		if ((get_mem_type() == GPMC_ONENAND) || (get_mem_type() == MMC_ONENAND)){
    			__raw_writel(INFINEON_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_0);
    			__raw_writel(INFINEON_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_0);
    		}
    		if ((get_mem_type() == GPMC_NAND) ||(get_mem_type() == MMC_NAND)){
    			__raw_writel(MICRON_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_0);
    			__raw_writel(MICRON_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_0);
    		}
    	 }
    
    	__raw_writel(SDP_SDRC_RFR_CTRL, SDRC_RFR_CTRL_0);
    	__raw_writel(SDP_SDRC_POWER_POP, SDRC_POWER);
    
    	/* init sequence for mDDR/mSDR using manual commands (DDR is different) */
    	__raw_writel(CMD_NOP, SDRC_MANUAL_0);
    	delay(5000);
    	__raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0);
    	__raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
    	__raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
    
    	/* set mr0 */
    	__raw_writel(SDP_SDRC_MR_0_DDR, SDRC_MR_0);
    
    	/* set up dll */
    	__raw_writel(SDP_SDRC_DLLAB_CTRL, SDRC_DLLA_CTRL);
    	delay(0x2000);	/* give time to lock */
    #else
           /* reset sdrc controller */
             __raw_writel(SOFTRESET, SDRC_SYSCONFIG);
             wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000);
             __raw_writel(0, SDRC_SYSCONFIG);
    
             /* setup sdrc to ball mux */
             __raw_writel(SDP_SDRC_SHARING, SDRC_SHARING);
    
             /* SDRC_MCFG0 register */
             (*(unsigned int*)0x6D000080) = 0x02584099;//from Micron
    
    	 if (is_cpu_family() == CPU_OMAP36XX) {
    		 if (is_ddr_166M) {
    			 /* SDRC_ACTIM_CTRLA0 register */
    			 (*(unsigned int*)0x6D00009c) = 0xaa9db4c6;// for 166M
    			 /* SDRC_ACTIM_CTRLB0 register */
    			 (*(unsigned int*)0x6D0000a0) = 0x00011517;
    		 } else {
    			 /* SDRC_ACTIM_CTRLA0 register */
    			 (*(unsigned int*)0x6D00009c) = 0x92e1c4c6;// for 200M
    			 /* SDRC_ACTIM_CTRLB0 register */
    			 (*(unsigned int*)0x6D0000a0) = 0x0002111c;
    			 /* SDRC_MCFG0 register - for Hynix*/
    			 (*(unsigned int *)0x6D000080) = 0x03588099;
    		 }
    	 } else {
    		 /* SDRC_ACTIM_CTRLA0 register */
    		 (*(unsigned int*)0x6D00009c) = 0xaa9db4c6;// for 166M
    		 /* SDRC_ACTIM_CTRLB0 register */
    		 (*(unsigned int*)0x6D0000a0) = 0x00011517;
    	 }
    
    
             (*(unsigned int*)0x6D0000a4) =0x0004DC01;
    
             /* Disble Power Down of CKE cuz of 1 CKE on combo part */
             (*(unsigned int*)0x6D000070) = 0x00000081;
    
             /* SDRC_Manual command register */
             (*(unsigned int*)0x6D0000a8) = 0x00000000; // NOP command
             delay(5000);
             (*(unsigned int*)0x6D0000a8) = 0x00000001; // Precharge command
             (*(unsigned int*)0x6D0000a8) = 0x00000002; // Auto-refresh command
             (*(unsigned int*)0x6D0000a8) = 0x00000002; // Auto-refresh command
    
             /* SDRC MR0 register */
             (*(int*)0x6D000084) = 0x00000032; // Burst length =4
             // CAS latency = 3
             // Write Burst = Read Burst
             // Serial Mode
    
             /* SDRC DLLA control register */
             (*(unsigned int*)0x6D000060) = 0x0000A;
             delay(0x20000); // some delay
    
    #endif
    
    #ifdef CONFIG_DDR_256MB_STACKED
    	make_cs1_contiguous();
    
    	__raw_writel(SDP_SDRC_MDCFG_0_DDR, SDRC_MCFG_0 + SDRC_CS1_OSET);
    	__raw_writel(MICRON_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_1);
    	__raw_writel(MICRON_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_1);
    
    	__raw_writel(SDP_SDRC_RFR_CTRL, SDRC_RFR_CTRL_0 + SDRC_CS1_OSET);
    	/* init sequence for mDDR/mSDR using manual commands */
    	__raw_writel(CMD_NOP, SDRC_MANUAL_0 + SDRC_CS1_OSET);
    	delay(5000);   /* supposed to be 100us per design spec for mddr/msdr */
    	__raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0 + SDRC_CS1_OSET);
    	__raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0 + SDRC_CS1_OSET);
    	__raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0 + SDRC_CS1_OSET);
    	__raw_writel(SDP_SDRC_MR_0_DDR, SDRC_MR_0 + SDRC_CS1_OSET);
    #endif
    }
    #endif /* CFG_OMAPEVM_DDR */
    
    /*************************************************************
     * get_sys_clk_speed - determine reference oscillator speed
     *  based on known 32kHz clock and gptimer.
     *************************************************************/
    u32 get_osc_clk_speed(void)
    {
    	u32 start, cstart, cend, cdiff, cdiv, val;
    
    	val = __raw_readl(PRM_CLKSRC_CTRL);
    
    	if (val & BIT7)
    		cdiv = 2;
    	else if (val & BIT6)
    		cdiv = 1;
    	else
    		/*
    		 * Should never reach here!
    		 * TBD: Add a WARN()/BUG()
    		 *      For now, assume divider as 1.
    		 */
    		cdiv = 1;
    
    	/* enable timer2 */
    	val = __raw_readl(CM_CLKSEL_WKUP) | BIT0;
    	__raw_writel(val, CM_CLKSEL_WKUP);	/* select sys_clk for GPT1 */
    
    	/* Enable I and F Clocks for GPT1 */
    	val = __raw_readl(CM_ICLKEN_WKUP) | BIT0 | BIT2;
    	__raw_writel(val, CM_ICLKEN_WKUP);
    	val = __raw_readl(CM_FCLKEN_WKUP) | BIT0;
    	__raw_writel(val, CM_FCLKEN_WKUP);
    
    	__raw_writel(0, OMAP34XX_GPT1 + TLDR);	/* start counting at 0 */
    	__raw_writel(GPT_EN, OMAP34XX_GPT1 + TCLR);     /* enable clock */
    	/* enable 32kHz source *//* enabled out of reset */
    	/* determine sys_clk via gauging */
    
    	start = 20 + __raw_readl(S32K_CR);	/* start time in 20 cycles */
    	while (__raw_readl(S32K_CR) < start);	/* dead loop till start time */
    	cstart = __raw_readl(OMAP34XX_GPT1 + TCRR);	/* get start sys_clk count */
    	while (__raw_readl(S32K_CR) < (start + 20));	/* wait for 40 cycles */
    	cend = __raw_readl(OMAP34XX_GPT1 + TCRR);	/* get end sys_clk count */
    	cdiff = cend - cstart;				/* get elapsed ticks */
    
    	if (cdiv == 2)
    	{
    		cdiff *= 2;
    	}
    
    	/* based on number of ticks assign speed */
    	if (cdiff > 19000)
    		return (S38_4M);
    	else if (cdiff > 15200)
    		return (S26M);
    	else if (cdiff > 13000)
    		return (S24M);
    	else if (cdiff > 9000)
    		return (S19_2M);
    	else if (cdiff > 7600)
    		return (S13M);
    	else
    		return (S12M);
    }
    
    /******************************************************************************
     * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
     *   -- input oscillator clock frequency.
     *
     *****************************************************************************/
    void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
    {
    	if(osc_clk == S38_4M)
    		*sys_clkin_sel=  4;
    	else if(osc_clk == S26M)
    		*sys_clkin_sel = 3;
    	else if(osc_clk == S19_2M)
    		*sys_clkin_sel = 2;
    	else if(osc_clk == S13M)
    		*sys_clkin_sel = 1;
    	else if(osc_clk == S12M)
    		*sys_clkin_sel = 0;
    }
    
    /*
     * OMAP34x/35x specific functions
     */
    static void dpll3_init_34xx(u32 sil_index, u32 clk_index)
    {
    	dpll_param *ptr;
    
    	/* Getting the base address of Core DPLL param table*/
    	ptr = (dpll_param *)get_core_dpll_param();
    
    	/* Moving it to the right sysclk and ES rev base */
    	ptr = ptr + 2*clk_index + sil_index;
    
    	/* CORE DPLL */
    	/* Select relock bypass: CM_CLKEN_PLL[0:2] */
    	sr32(CM_CLKEN_PLL, 0, 3, PLL_FAST_RELOCK_BYPASS);
    	wait_on_value(BIT0, 0, CM_IDLEST_CKGEN, LDELAY);
    
    	/* CM_CLKSEL1_EMU[DIV_DPLL3] */
    	sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2);
    
    	/* M2 (CORE_DPLL_CLKOUT_DIV): CM_CLKSEL1_PLL[27:31] */
    	sr32(CM_CLKSEL1_PLL, 27, 5, ptr->m2);
    
    	/* M (CORE_DPLL_MULT): CM_CLKSEL1_PLL[16:26] */
    	sr32(CM_CLKSEL1_PLL, 16, 11, ptr->m);
    
    	/* N (CORE_DPLL_DIV): CM_CLKSEL1_PLL[8:14] */
    	sr32(CM_CLKSEL1_PLL, 8, 7, ptr->n);
    
    	/* Source is the CM_96M_FCLK: CM_CLKSEL1_PLL[6] */
    	sr32(CM_CLKSEL1_PLL, 6, 1, 0);
    
    	sr32(CM_CLKSEL_CORE, 8, 4, CORE_SSI_DIV);	/* ssi */
    	sr32(CM_CLKSEL_CORE, 4, 2, CORE_FUSB_DIV);	/* fsusb */
    	sr32(CM_CLKSEL_CORE, 2, 2, CORE_L4_DIV);	/* l4 */
    	sr32(CM_CLKSEL_CORE, 0, 2, CORE_L3_DIV);	/* l3 */
    
    	sr32(CM_CLKSEL_GFX,  0, 3, GFX_DIV_34X);	/* gfx */
    	sr32(CM_CLKSEL_WKUP, 1, 2, WKUP_RSM);		/* reset mgr */
    
    	/* FREQSEL (CORE_DPLL_FREQSEL): CM_CLKEN_PLL[4:7] */
    	sr32(CM_CLKEN_PLL,   4, 4, ptr->fsel);
    	sr32(CM_CLKEN_PLL,   0, 3, PLL_LOCK);		/* lock mode */
    
    	wait_on_value(BIT0, 1, CM_IDLEST_CKGEN, LDELAY);
    }
    
    static void dpll4_init_34xx(u32 sil_index, u32 clk_index)
    {
    	dpll_param *ptr;
    
    	ptr = (dpll_param *)get_per_dpll_param();
    
    	/* Moving it to the right sysclk base */
    	ptr = ptr + clk_index;
    
    	/* EN_PERIPH_DPLL: CM_CLKEN_PLL[16:18] */
    	sr32(CM_CLKEN_PLL, 16, 3, PLL_STOP);
    	wait_on_value(BIT1, 0, CM_IDLEST_CKGEN, LDELAY);
    
    	sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2);		/* set M6 */
    	sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2);		/* set M5 */
    	sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2);		/* set M4 */
    	sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2);		/* set M3 */
    
    	/* M2 (DIV_96M): CM_CLKSEL3_PLL[0:4] */
    	sr32(CM_CLKSEL3_PLL, 0, 5, ptr->m2);
    
    	/* M (PERIPH_DPLL_MULT): CM_CLKSEL2_PLL[8:18] */
    	sr32(CM_CLKSEL2_PLL, 8, 11, ptr->m);
    
    	/* N (PERIPH_DPLL_DIV): CM_CLKSEL2_PLL[0:6] */
    	sr32(CM_CLKSEL2_PLL, 0, 7, ptr->n);
    
    	/* FREQSEL (PERIPH_DPLL_FREQSEL): CM_CLKEN_PLL[20:23] */
    	sr32(CM_CLKEN_PLL, 20, 4, ptr->fsel);
    
    	/* LOCK MODE (EN_PERIPH_DPLL) : CM_CLKEN_PLL[16:18] */
    	sr32(CM_CLKEN_PLL, 16, 3, PLL_LOCK);
    	wait_on_value(BIT1, 2, CM_IDLEST_CKGEN, LDELAY);
    }
    
    static void mpu_init_34xx(u32 sil_index, u32 clk_index)
    {
    	dpll_param *ptr;
    
    	/* Getting the base address to MPU DPLL param table*/
    	ptr = (dpll_param *)get_mpu_dpll_param();
    
    	/* Moving it to the right sysclk and ES rev base */
    	ptr = ptr + 2*clk_index + sil_index;
    
    	/* MPU DPLL (unlocked already) */
    	/* M2 (MPU_DPLL_CLKOUT_DIV) : CM_CLKSEL2_PLL_MPU[0:4] */
    	sr32(CM_CLKSEL2_PLL_MPU, 0, 5, ptr->m2);
    
    	/* M (MPU_DPLL_MULT) : CM_CLKSEL2_PLL_MPU[8:18] */
    	sr32(CM_CLKSEL1_PLL_MPU, 8, 11, ptr->m);
    
    	/* N (MPU_DPLL_DIV) : CM_CLKSEL2_PLL_MPU[0:6] */
    	sr32(CM_CLKSEL1_PLL_MPU, 0, 7, ptr->n);
    
    	/* FREQSEL (MPU_DPLL_FREQSEL) : CM_CLKEN_PLL_MPU[4:7] */
    	sr32(CM_CLKEN_PLL_MPU, 4, 4, ptr->fsel);
    }
    
    static void iva_init_34xx(u32 sil_index, u32 clk_index)
    {
    	dpll_param *ptr;
    
    	/* Getting the base address to IVA DPLL param table*/
    	ptr = (dpll_param *)get_iva_dpll_param();
    
    	/* Moving it to the right sysclk and ES rev base */
    	ptr = ptr + 2*clk_index + sil_index;
    
    	/* IVA DPLL */
    	/* EN_IVA2_DPLL : CM_CLKEN_PLL_IVA2[0:2] */
    	sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_STOP);
    	wait_on_value(BIT0, 0, CM_IDLEST_PLL_IVA2, LDELAY);
    
    	/* M2 (IVA2_DPLL_CLKOUT_DIV) : CM_CLKSEL2_PLL_IVA2[0:4] */
    	sr32(CM_CLKSEL2_PLL_IVA2, 0, 5, ptr->m2);
    
    	/* M (IVA2_DPLL_MULT) : CM_CLKSEL1_PLL_IVA2[8:18] */
    	sr32(CM_CLKSEL1_PLL_IVA2, 8, 11, ptr->m);
    
    	/* N (IVA2_DPLL_DIV) : CM_CLKSEL1_PLL_IVA2[0:6] */
    	sr32(CM_CLKSEL1_PLL_IVA2, 0, 7, ptr->n);
    
    	/* FREQSEL (IVA2_DPLL_FREQSEL) : CM_CLKEN_PLL_IVA2[4:7] */
    	sr32(CM_CLKEN_PLL_IVA2, 4, 4, ptr->fsel);
    
    	/* LOCK MODE (EN_IVA2_DPLL) : CM_CLKEN_PLL_IVA2[0:2] */
    	sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_LOCK);
    
    	wait_on_value(BIT0, 1, CM_IDLEST_PLL_IVA2, LDELAY);
    }
    
    /*
     * OMAP3630 specific functions
     */
    static void dpll3_init_36xx(u32 sil_index, u32 clk_index)
    {
    	dpll_param *ptr;
    
    	/* Getting the base address of Core DPLL param table*/
    	ptr = (dpll_param *)get_36x_core_dpll_param();
    
    	/* Moving it to the right sysclk and ES rev base */
    	ptr += clk_index;
    
    	/* CORE DPLL */
    	/* Select relock bypass: CM_CLKEN_PLL[0:2] */
    	sr32(CM_CLKEN_PLL, 0, 3, PLL_FAST_RELOCK_BYPASS);
    	wait_on_value(BIT0, 0, CM_IDLEST_CKGEN, LDELAY);
    
    	/* CM_CLKSEL1_EMU[DIV_DPLL3] */
    	sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2);
    
    	/* M2 (CORE_DPLL_CLKOUT_DIV): CM_CLKSEL1_PLL[27:31] */
    	sr32(CM_CLKSEL1_PLL, 27, 5, ptr->m2);
    
    	/* M (CORE_DPLL_MULT): CM_CLKSEL1_PLL[16:26] */
    	sr32(CM_CLKSEL1_PLL, 16, 11, ptr->m);
    
    	/* N (CORE_DPLL_DIV): CM_CLKSEL1_PLL[8:14] */
    	sr32(CM_CLKSEL1_PLL, 8, 7, ptr->n);
    
    	/* Source is the CM_96M_FCLK: CM_CLKSEL1_PLL[6] */
    	sr32(CM_CLKSEL1_PLL, 6, 1, 0);
    
    	sr32(CM_CLKSEL_CORE, 8, 4, CORE_SSI_DIV);	/* ssi */
    	sr32(CM_CLKSEL_CORE, 4, 2, CORE_FUSB_DIV);	/* fsusb */
    	sr32(CM_CLKSEL_CORE, 2, 2, CORE_L4_DIV);	/* l4 */
    	sr32(CM_CLKSEL_CORE, 0, 2, CORE_L3_DIV);	/* l3 */
    
    	sr32(CM_CLKSEL_GFX,  0, 3, GFX_DIV_36X);		/* gfx */
    	sr32(CM_CLKSEL_WKUP, 1, 2, WKUP_RSM);		/* reset mgr */
    
    	/* FREQSEL (CORE_DPLL_FREQSEL): CM_CLKEN_PLL[4:7] */
    	sr32(CM_CLKEN_PLL,   4, 4, ptr->fsel);
    	sr32(CM_CLKEN_PLL,   0, 3, PLL_LOCK);		/* lock mode */
    
    	wait_on_value(BIT0, 1, CM_IDLEST_CKGEN, LDELAY);
    }
    
    static void dpll4_init_36xx(u32 sil_index, u32 clk_index)
    {
    	struct dpll_per_36x_param *ptr;
    
    	ptr = (struct dpll_per_36x_param *)get_36x_per_dpll_param();
    
    	/* Moving it to the right sysclk base */
    	ptr += clk_index;
    
    	/* EN_PERIPH_DPLL: CM_CLKEN_PLL[16:18] */
    	sr32(CM_CLKEN_PLL, 16, 3, PLL_STOP);
    	wait_on_value(BIT1, 0, CM_IDLEST_CKGEN, LDELAY);
    
    	/* M6 (DIV_DPLL4): CM_CLKSEL1_EMU[24:29] */
    	sr32(CM_CLKSEL1_EMU, 24, 6, ptr->m6);
    
    	/* M5 (CLKSEL_CAM): CM_CLKSEL1_EMU[0:5] */
    	sr32(CM_CLKSEL_CAM, 0, 6, ptr->m5);
    
    	/* M4 (CLKSEL_DSS1): CM_CLKSEL_DSS[0:5] */
    	sr32(CM_CLKSEL_DSS, 0, 6, ptr->m4);
    
    	/* M3 (CLKSEL_DSS1): CM_CLKSEL_DSS[8:13] */
    	sr32(CM_CLKSEL_DSS, 8, 6, ptr->m3);
    
    	/* M2 (DIV_96M): CM_CLKSEL3_PLL[0:4] */
    	sr32(CM_CLKSEL3_PLL, 0, 5, ptr->m2);
    
    	/* M (PERIPH_DPLL_MULT): CM_CLKSEL2_PLL[8:19] */
    	sr32(CM_CLKSEL2_PLL, 8, 12, ptr->m);
    
    	/* N (PERIPH_DPLL_DIV): CM_CLKSEL2_PLL[0:6] */
    	sr32(CM_CLKSEL2_PLL, 0, 7, ptr->n);
    
    	/* M2DIV (CLKSEL_96M): CM_CLKSEL_CORE[12:13] */
    	sr32(CM_CLKSEL_CORE, 12, 2, ptr->m2div);
    
    	/* LOCK MODE (EN_PERIPH_DPLL): CM_CLKEN_PLL[16:18] */
    	sr32(CM_CLKEN_PLL, 16, 3, PLL_LOCK);
    	wait_on_value(BIT1, 2, CM_IDLEST_CKGEN, LDELAY);
    }
    
    static void mpu_init_36xx(u32 sil_index, u32 clk_index)
    {
    	dpll_param *ptr;
    
    	/* Getting the base address to MPU DPLL param table*/
    	ptr = (dpll_param *)get_36x_mpu_dpll_param();
    
    	/* Moving it to the right sysclk and ES rev base */
    	ptr = ptr + (2*clk_index) + sil_index;
    
    	/* MPU DPLL (unlocked already) */
    	/* M2 (MPU_DPLL_CLKOUT_DIV) : CM_CLKSEL2_PLL_MPU[0:4] */
    	sr32(CM_CLKSEL2_PLL_MPU, 0, 5, ptr->m2);
    
    	/* M (MPU_DPLL_MULT) : CM_CLKSEL2_PLL_MPU[8:18] */
    	sr32(CM_CLKSEL1_PLL_MPU, 8, 11, ptr->m);
    
    	/* N (MPU_DPLL_DIV) : CM_CLKSEL2_PLL_MPU[0:6] */
    	sr32(CM_CLKSEL1_PLL_MPU, 0, 7, ptr->n);
    
    	/* LOCK MODE (EN_MPU_DPLL) : CM_CLKEN_PLL_IVA2[0:2] */
    	sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOCK);
    	wait_on_value(BIT0, 1, CM_IDLEST_PLL_MPU, LDELAY);
    }
    
    static void iva_init_36xx(u32 sil_index, u32 clk_index)
    {
    	dpll_param *ptr;
    
    	/* Getting the base address to IVA DPLL param table*/
    	ptr = (dpll_param *)get_36x_iva_dpll_param();
    
    	/* Moving it to the right sysclk and ES rev base */
    	ptr = ptr + (2*clk_index) + sil_index;
    
    	/* IVA DPLL */
    	/* EN_IVA2_DPLL : CM_CLKEN_PLL_IVA2[0:2] */
    	sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_STOP);
    	wait_on_value(BIT0, 0, CM_IDLEST_PLL_IVA2, LDELAY);
    
    	/* M2 (IVA2_DPLL_CLKOUT_DIV) : CM_CLKSEL2_PLL_IVA2[0:4] */
    	sr32(CM_CLKSEL2_PLL_IVA2, 0, 5, ptr->m2);
    
    	/* M (IVA2_DPLL_MULT) : CM_CLKSEL1_PLL_IVA2[8:18] */
    	sr32(CM_CLKSEL1_PLL_IVA2, 8, 11, ptr->m);
    
    	/* N (IVA2_DPLL_DIV) : CM_CLKSEL1_PLL_IVA2[0:6] */
    	sr32(CM_CLKSEL1_PLL_IVA2, 0, 7, ptr->n);
    
    	/* LOCK MODE (EN_IVA2_DPLL) : CM_CLKEN_PLL_IVA2[0:2] */
    	sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_LOCK);
    
    	wait_on_value(BIT0, 1, CM_IDLEST_PLL_IVA2, LDELAY);
    }
    
    
    /******************************************************************************
     * prcm_init() - inits clocks for PRCM as defined in clocks.h
     *   -- called from SRAM, or Flash (using temp SRAM stack).
     *****************************************************************************/
    void prcm_init(void)
    {
    	u32 osc_clk=0, sys_clkin_sel;
    	u32 clk_index, sil_index;
    
    	/* Gauge the input clock speed and find out the sys_clkin_sel
    	 * value corresponding to the input clock.
    	 */
    	osc_clk = get_osc_clk_speed();
    	get_sys_clkin_sel(osc_clk, &sys_clkin_sel);
    
    	sr32(PRM_CLKSEL, 0, 3, sys_clkin_sel); /* set input crystal speed */
    
    	/* If the input clock is greater than 19.2M always divide/2 */
    	/*
    	 * On OMAP3630, DDR data corruption has been observed on OFF mode
    	 * exit if the sys clock was lower than 26M. As a work around,
    	 * OMAP3630 is operated at 26M sys clock and this internal division
    	 * is not performed.
    	 */
    	if((is_cpu_family() != CPU_OMAP36XX) && (sys_clkin_sel > 2)) {
    		sr32(PRM_CLKSRC_CTRL, 6, 2, 2);/* input clock divider */
    		clk_index = sys_clkin_sel/2;
    	} else {
    		sr32(PRM_CLKSRC_CTRL, 6, 2, 1);/* input clock divider */
    		clk_index = sys_clkin_sel;
    	}
    
    	if (is_cpu_family() == CPU_OMAP36XX) {
    		dpll3_init_36xx(0, clk_index);
    		dpll4_init_36xx(0, clk_index);
    		mpu_init_36xx(0, clk_index);
    		iva_init_36xx(0, clk_index);
    	} else {
    		sil_index = get_cpu_rev() - 1;
    
    		/* The DPLL tables are defined according to sysclk value and
    		 * silicon revision. The clk_index value will be used to get
    		 * the values for that input sysclk from the DPLL param table
    		 * and sil_index will get the values for that SysClk for the
    		 * appropriate silicon rev.
    		 */
    
    		/* Unlock MPU DPLL (slows things down, and needed later) */
    		sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOW_POWER_BYPASS);
    		wait_on_value(BIT0, 0, CM_IDLEST_PLL_MPU, LDELAY);
    
    		dpll3_init_34xx(sil_index, clk_index);
    		dpll4_init_34xx(sil_index, clk_index);
    		iva_init_34xx(sil_index, clk_index);
    		mpu_init_34xx(sil_index, clk_index);
    
    		/* Lock MPU DPLL to set frequency */
    		sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOCK);
    		wait_on_value(BIT0, 1, CM_IDLEST_PLL_MPU, LDELAY);
    	}
    
    	/* Set up GPTimers to sys_clk source only */
     	sr32(CM_CLKSEL_PER, 0, 8, 0xff);
    	sr32(CM_CLKSEL_WKUP, 0, 1, 1);
    
    	delay(5000);
    }
    
    /*****************************************
     * Routine: secure_unlock
     * Description: Setup security registers for access
     * (GP Device only)
     *****************************************/
    void secure_unlock(void)
    {
    	/* Permission values for registers -Full fledged permissions to all */
    	#define UNLOCK_1 0xFFFFFFFF
    	#define UNLOCK_2 0x00000000
    	#define UNLOCK_3 0x0000FFFF
    	/* Protection Module Register Target APE (PM_RT)*/
    	__raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
    	__raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
    	__raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
    	__raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
    
    	__raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
    	__raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
    	__raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
    
    	__raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
    	__raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
    	__raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
    	__raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
    
    	/* IVA Changes */
    	__raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
    	__raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
    	__raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
    
    	__raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
    }
    
    /**********************************************************
     * Routine: try_unlock_sram()
     * Description: If chip is GP type, unlock the SRAM for
     *  general use.
     ***********************************************************/
    void try_unlock_memory(void)
    {
    	int mode;
    
    	/* if GP device unlock device SRAM for general use */
    	/* secure code breaks for Secure/Emulation device - HS/E/T*/
    	mode = get_device_type();
    	if (mode == GP_DEVICE) {
    		secure_unlock();
    	}
    	return;
    }
    
    /**********************************************************
     * Routine: s_init
     * Description: Does early system init of muxing and clocks.
     * - Called at time when only stack is available.
     **********************************************************/
    
    void s_init(void)
    {
    	watchdog_init();
    #ifdef CONFIG_3430_AS_3410
    	/* setup the scalability control register for
    	 * 3430 to work in 3410 mode
    	 */
    	__raw_writel(0x5ABF,CONTROL_SCALABLE_OMAP_OCP);
    #endif
    	try_unlock_memory();
    	set_muxconf_regs();
    	delay(100);
    	prcm_init();
    	per_clocks_enable();
    	/*
    	 * WORKAROUND: To suuport both Micron and Hynix NAND/DDR parts
    	 */
    	if ((get_mem_type() == GPMC_NAND) || (get_mem_type() == MMC_NAND))
    		nand_init();
    	config_3430sdram_ddr();
    }
    
    /*******************************************************
     * Routine: misc_init_r
     * Description: Init ethernet (done here so udelay works)
     ********************************************************/
    int misc_init_r (void)
    {
    	return(0);
    }
    
    /******************************************************
     * Routine: wait_for_command_complete
     * Description: Wait for posting to finish on watchdog
     ******************************************************/
    void wait_for_command_complete(unsigned int wd_base)
    {
    	int pending = 1;
    	do {
    		pending = __raw_readl(wd_base + WWPS);
    	} while (pending);
    }
    
    /****************************************
     * Routine: watchdog_init
     * Description: Shut down watch dogs
     *****************************************/
    void watchdog_init(void)
    {
    	/* There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
    	 * either taken care of by ROM (HS/EMU) or not accessible (GP).
    	 * We need to take care of WD2-MPU or take a PRCM reset.  WD3
    	 * should not be running and does not generate a PRCM reset.
    	 */
    	sr32(CM_FCLKEN_WKUP, 5, 1, 1);
    	sr32(CM_ICLKEN_WKUP, 5, 1, 1);
    	wait_on_value(BIT5, 0x20, CM_IDLEST_WKUP, 5); /* some issue here */
    
    	__raw_writel(WD_UNLOCK1, WD2_BASE + WSPR);
    	wait_for_command_complete(WD2_BASE);
    	__raw_writel(WD_UNLOCK2, WD2_BASE + WSPR);
    }
    
    /**********************************************
     * Routine: dram_init
     * Description: sets uboots idea of sdram size
     **********************************************/
    int dram_init (void)
    {
    	return 0;
    }
    
    /*****************************************************************
     * Routine: peripheral_enable
     * Description: Enable the clks & power for perifs (GPT2, UART1,...)
     ******************************************************************/
    void per_clocks_enable(void)
    {
    	/* Enable GP2 timer. */
    	sr32(CM_CLKSEL_PER, 0, 1, 0x1); /* GPT2 = sys clk */
    	sr32(CM_ICLKEN_PER, 3, 1, 0x1); /* ICKen GPT2 */
    	sr32(CM_FCLKEN_PER, 3, 1, 0x1); /* FCKen GPT2 */
    
    #ifdef CFG_NS16550
    	/* Enable UART1 clocks */
    	sr32(CM_FCLKEN1_CORE, 13, 1, 0x1);
    	sr32(CM_ICLKEN1_CORE, 13, 1, 0x1);
    #endif
    
    #ifdef CONFIG_MMC
    	/* Enable MMC1 clocks */
    	sr32(CM_FCLKEN1_CORE, 24, 1, 0x1);
    	sr32(CM_ICLKEN1_CORE, 24, 1, 0x1);
    #endif
    	delay(1000);
    }
    
    /* Set MUX for UART, GPMC, SDRC, GPIO */
    
    #define 	MUX_VAL(OFFSET,VALUE)\
    		__raw_writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
    
    #define		CP(x)	(CONTROL_PADCONF_##x)
    /*
     * IEN  - Input Enable
     * IDIS - Input Disable
     * PTD  - Pull type Down
     * PTU  - Pull type Up
     * DIS  - Pull type selection is inactive
     * EN   - Pull type selection is active
     * M0   - Mode 0
     * The commented string gives the final mux configuration for that pin
     */
    #define MUX_DEFAULT()\
    	MUX_VAL(CP(SDRC_D0),        (IEN  | PTD | DIS | M0)) /*SDRC_D0*/\
    	MUX_VAL(CP(SDRC_D1),        (IEN  | PTD | DIS | M0)) /*SDRC_D1*/\
    	MUX_VAL(CP(SDRC_D2),        (IEN  | PTD | DIS | M0)) /*SDRC_D2*/\
    	MUX_VAL(CP(SDRC_D3),        (IEN  | PTD | DIS | M0)) /*SDRC_D3*/\
    	MUX_VAL(CP(SDRC_D4),        (IEN  | PTD | DIS | M0)) /*SDRC_D4*/\
    	MUX_VAL(CP(SDRC_D5),        (IEN  | PTD | DIS | M0)) /*SDRC_D5*/\
    	MUX_VAL(CP(SDRC_D6),        (IEN  | PTD | DIS | M0)) /*SDRC_D6*/\
    	MUX_VAL(CP(SDRC_D7),        (IEN  | PTD | DIS | M0)) /*SDRC_D7*/\
    	MUX_VAL(CP(SDRC_D8),        (IEN  | PTD | DIS | M0)) /*SDRC_D8*/\
    	MUX_VAL(CP(SDRC_D9),        (IEN  | PTD | DIS | M0)) /*SDRC_D9*/\
    	MUX_VAL(CP(SDRC_D10),       (IEN  | PTD | DIS | M0)) /*SDRC_D10*/\
    	MUX_VAL(CP(SDRC_D11),       (IEN  | PTD | DIS | M0)) /*SDRC_D11*/\
    	MUX_VAL(CP(SDRC_D12),       (IEN  | PTD | DIS | M0)) /*SDRC_D12*/\
    	MUX_VAL(CP(SDRC_D13),       (IEN  | PTD | DIS | M0)) /*SDRC_D13*/\
    	MUX_VAL(CP(SDRC_D14),       (IEN  | PTD | DIS | M0)) /*SDRC_D14*/\
    	MUX_VAL(CP(SDRC_D15),       (IEN  | PTD | DIS | M0)) /*SDRC_D15*/\
    	MUX_VAL(CP(SDRC_D16),       (IEN  | PTD | DIS | M0)) /*SDRC_D16*/\
    	MUX_VAL(CP(SDRC_D17),       (IEN  | PTD | DIS | M0)) /*SDRC_D17*/\
    	MUX_VAL(CP(SDRC_D18),       (IEN  | PTD | DIS | M0)) /*SDRC_D18*/\
    	MUX_VAL(CP(SDRC_D19),       (IEN  | PTD | DIS | M0)) /*SDRC_D19*/\
    	MUX_VAL(CP(SDRC_D20),       (IEN  | PTD | DIS | M0)) /*SDRC_D20*/\
    	MUX_VAL(CP(SDRC_D21),       (IEN  | PTD | DIS | M0)) /*SDRC_D21*/\
    	MUX_VAL(CP(SDRC_D22),       (IEN  | PTD | DIS | M0)) /*SDRC_D22*/\
    	MUX_VAL(CP(SDRC_D23),       (IEN  | PTD | DIS | M0)) /*SDRC_D23*/\
    	MUX_VAL(CP(SDRC_D24),       (IEN  | PTD | DIS | M0)) /*SDRC_D24*/\
    	MUX_VAL(CP(SDRC_D25),       (IEN  | PTD | DIS | M0)) /*SDRC_D25*/\
    	MUX_VAL(CP(SDRC_D26),       (IEN  | PTD | DIS | M0)) /*SDRC_D26*/\
    	MUX_VAL(CP(SDRC_D27),       (IEN  | PTD | DIS | M0)) /*SDRC_D27*/\
    	MUX_VAL(CP(SDRC_D28),       (IEN  | PTD | DIS | M0)) /*SDRC_D28*/\
    	MUX_VAL(CP(SDRC_D29),       (IEN  | PTD | DIS | M0)) /*SDRC_D29*/\
    	MUX_VAL(CP(SDRC_D30),       (IEN  | PTD | DIS | M0)) /*SDRC_D30*/\
    	MUX_VAL(CP(SDRC_D31),       (IEN  | PTD | DIS | M0)) /*SDRC_D31*/\
    	MUX_VAL(CP(SDRC_CLK),       (IEN  | PTD | DIS | M0)) /*SDRC_CLK*/\
    	MUX_VAL(CP(SDRC_DQS0),      (IEN  | PTD | DIS | M0)) /*SDRC_DQS0*/\
    	MUX_VAL(CP(SDRC_DQS1),      (IEN  | PTD | DIS | M0)) /*SDRC_DQS1*/\
    	MUX_VAL(CP(SDRC_DQS2),      (IEN  | PTD | DIS | M0)) /*SDRC_DQS2*/\
    	MUX_VAL(CP(SDRC_DQS3),      (IEN  | PTD | DIS | M0)) /*SDRC_DQS3*/\
    	MUX_VAL(CP(GPMC_A1),        (IDIS | PTD | DIS | M0)) /*GPMC_A1*/\
    	MUX_VAL(CP(GPMC_A2),        (IDIS | PTD | DIS | M0)) /*GPMC_A2*/\
    	MUX_VAL(CP(GPMC_A3),        (IDIS | PTD | DIS | M0)) /*GPMC_A3*/\
    	MUX_VAL(CP(GPMC_A4),        (IDIS | PTD | DIS | M0)) /*GPMC_A4*/\
    	MUX_VAL(CP(GPMC_A5),        (IDIS | PTD | DIS | M0)) /*GPMC_A5*/\
    	MUX_VAL(CP(GPMC_A6),        (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\
    	MUX_VAL(CP(GPMC_A7),        (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\
    	MUX_VAL(CP(GPMC_A8),        (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\
    	MUX_VAL(CP(GPMC_A9),        (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\
    	MUX_VAL(CP(GPMC_A10),       (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\
    	MUX_VAL(CP(GPMC_D0),        (IEN  | PTD | DIS | M0)) /*GPMC_D0*/\
    	MUX_VAL(CP(GPMC_D1),        (IEN  | PTD | DIS | M0)) /*GPMC_D1*/\
    	MUX_VAL(CP(GPMC_D2),        (IEN  | PTD | DIS | M0)) /*GPMC_D2*/\
    	MUX_VAL(CP(GPMC_D3),        (IEN  | PTD | DIS | M0)) /*GPMC_D3*/\
    	MUX_VAL(CP(GPMC_D4),        (IEN  | PTD | DIS | M0)) /*GPMC_D4*/\
    	MUX_VAL(CP(GPMC_D5),        (IEN  | PTD | DIS | M0)) /*GPMC_D5*/\
    	MUX_VAL(CP(GPMC_D6),        (IEN  | PTD | DIS | M0)) /*GPMC_D6*/\
    	MUX_VAL(CP(GPMC_D7),        (IEN  | PTD | DIS | M0)) /*GPMC_D7*/\
    	MUX_VAL(CP(GPMC_D8),        (IEN  | PTD | DIS | M0)) /*GPMC_D8*/\
    	MUX_VAL(CP(GPMC_D9),        (IEN  | PTD | DIS | M0)) /*GPMC_D9*/\
    	MUX_VAL(CP(GPMC_D10),       (IEN  | PTD | DIS | M0)) /*GPMC_D10*/\
    	MUX_VAL(CP(GPMC_D11),       (IEN  | PTD | DIS | M0)) /*GPMC_D11*/\
    	MUX_VAL(CP(GPMC_D12),       (IEN  | PTD | DIS | M0)) /*GPMC_D12*/\
    	MUX_VAL(CP(GPMC_D13),       (IEN  | PTD | DIS | M0)) /*GPMC_D13*/\
    	MUX_VAL(CP(GPMC_D14),       (IEN  | PTD | DIS | M0)) /*GPMC_D14*/\
    	MUX_VAL(CP(GPMC_D15),       (IEN  | PTD | DIS | M0)) /*GPMC_D15*/\
    	MUX_VAL(CP(GPMC_nCS0),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS0*/\
    	MUX_VAL(CP(GPMC_nCS1),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS1*/\
    	MUX_VAL(CP(GPMC_nCS2),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS2*/\
    	MUX_VAL(CP(GPMC_nCS3),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS3*/\
    	MUX_VAL(CP(GPMC_nCS4),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS4*/\
    	MUX_VAL(CP(GPMC_nCS5),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS5*/\
    	MUX_VAL(CP(GPMC_nCS6),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS6*/\
    	MUX_VAL(CP(GPMC_nCS7),      (IDIS | PTU | EN  | M0)) /*GPMC_nCS7*/\
    	MUX_VAL(CP(GPMC_CLK),       (IDIS | PTD | DIS | M0)) /*GPMC_CLK*/\
    	MUX_VAL(CP(GPMC_nADV_ALE),  (IDIS | PTD | DIS | M0)) /*GPMC_nADV_ALE*/\
    	MUX_VAL(CP(GPMC_nOE),       (IDIS | PTD | DIS | M0)) /*GPMC_nOE*/\
    	MUX_VAL(CP(GPMC_nWE),       (IDIS | PTD | DIS | M0)) /*GPMC_nWE*/\
    	MUX_VAL(CP(GPMC_nBE0_CLE),  (IDIS | PTD | DIS | M0)) /*GPMC_nBE0_CLE*/\
    	MUX_VAL(CP(GPMC_nBE1),      (IDIS | PTD | DIS | M4)) /*GPIO_61*/\
    	MUX_VAL(CP(GPMC_nWP),       (IEN  | PTD | DIS | M0)) /*GPMC_nWP*/\
    	MUX_VAL(CP(GPMC_WAIT0),     (IEN  | PTU | EN  | M0)) /*GPMC_WAIT0*/\
    	MUX_VAL(CP(GPMC_WAIT1),     (IEN  | PTU | EN  | M0)) /*GPMC_WAIT1*/\
    	MUX_VAL(CP(GPMC_WAIT2),     (IEN  | PTU | EN  | M4)) /*GPIO_64*/\
    	MUX_VAL(CP(GPMC_WAIT3),     (IEN  | PTU | EN  | M4)) /*GPIO_65*/\
    	MUX_VAL(CP(DSS_DATA18),     (IEN  | PTD | DIS | M4)) /*GPIO_88*/\
    	MUX_VAL(CP(DSS_DATA19),     (IEN  | PTD | DIS | M4)) /*GPIO_89*/\
    	MUX_VAL(CP(DSS_DATA20),     (IEN  | PTD | DIS | M4)) /*GPIO_90*/\
    	MUX_VAL(CP(DSS_DATA21),     (IEN  | PTD | DIS | M4)) /*GPIO_91*/\
    	MUX_VAL(CP(CAM_WEN),        (IEN  | PTD | DIS | M4)) /*GPIO_167*/\
    	MUX_VAL(CP(UART1_TX),       (IDIS | PTD | DIS | M0)) /*UART1_TX*/\
    	MUX_VAL(CP(UART1_RTS),      (IDIS | PTD | DIS | M0)) /*UART1_RTS*/\
    	MUX_VAL(CP(UART1_CTS),      (IEN | PTU | DIS | M0)) /*UART1_CTS*/\
    	MUX_VAL(CP(UART1_RX),       (IEN | PTD | DIS | M0)) /*UART1_RX*/\
    	MUX_VAL(CP(McBSP1_DX),      (IEN  | PTD | DIS | M4)) /*GPIO_158*/\
    	MUX_VAL(CP(SYS_32K),        (IEN  | PTD | DIS | M0)) /*SYS_32K*/\
    	MUX_VAL(CP(SYS_BOOT0),      (IEN  | PTD | DIS | M4)) /*GPIO_2 */\
    	MUX_VAL(CP(SYS_BOOT1),      (IEN  | PTD | DIS | M4)) /*GPIO_3 */\
    	MUX_VAL(CP(SYS_BOOT2),      (IEN  | PTD | DIS | M4)) /*GPIO_4 */\
    	MUX_VAL(CP(SYS_BOOT3),      (IEN  | PTD | DIS | M4)) /*GPIO_5 */\
    	MUX_VAL(CP(SYS_BOOT4),      (IEN  | PTD | DIS | M4)) /*GPIO_6 */\
    	MUX_VAL(CP(SYS_BOOT5),      (IEN  | PTD | DIS | M4)) /*GPIO_7 */\
    	MUX_VAL(CP(SYS_BOOT6),      (IEN  | PTD | DIS | M4)) /*GPIO_8 */\
    	MUX_VAL(CP(SYS_CLKOUT2),    (IEN  | PTU | EN  | M4)) /*GPIO_186*/\
    	MUX_VAL(CP(JTAG_nTRST),     (IEN  | PTD | DIS | M0)) /*JTAG_nTRST*/\
    	MUX_VAL(CP(JTAG_TCK),       (IEN  | PTD | DIS | M0)) /*JTAG_TCK*/\
    	MUX_VAL(CP(JTAG_TMS),       (IEN  | PTD | DIS | M0)) /*JTAG_TMS*/\
    	MUX_VAL(CP(JTAG_TDI),       (IEN  | PTD | DIS | M0)) /*JTAG_TDI*/\
    	MUX_VAL(CP(JTAG_EMU0),      (IEN  | PTD | DIS | M0)) /*JTAG_EMU0*/\
    	MUX_VAL(CP(JTAG_EMU1),      (IEN  | PTD | DIS | M0)) /*JTAG_EMU1*/\
    	MUX_VAL(CP(ETK_CLK),        (IEN  | PTD | DIS | M4)) /*GPIO_12*/\
    	MUX_VAL(CP(ETK_CTL),        (IEN  | PTD | DIS | M4)) /*GPIO_13*/\
    	MUX_VAL(CP(ETK_D0 ),        (IEN  | PTD | DIS | M4)) /*GPIO_14*/\
    	MUX_VAL(CP(ETK_D1 ),        (IEN  | PTD | DIS | M4)) /*GPIO_15*/\
    	MUX_VAL(CP(ETK_D2 ),        (IEN  | PTD | DIS | M4)) /*GPIO_16*/\
    	MUX_VAL(CP(ETK_D10),        (IEN  | PTD | DIS | M4)) /*GPIO_24*/\
    	MUX_VAL(CP(ETK_D11),        (IEN  | PTD | DIS | M4)) /*GPIO_25*/\
    	MUX_VAL(CP(ETK_D12),        (IEN  | PTD | DIS | M4)) /*GPIO_26*/\
    	MUX_VAL(CP(ETK_D13),        (IEN  | PTD | DIS | M4)) /*GPIO_27*/\
    	MUX_VAL(CP(ETK_D14),        (IEN  | PTD | DIS | M4)) /*GPIO_28*/\
    	MUX_VAL(CP(ETK_D15),        (IEN  | PTD | DIS | M4)) /*GPIO_29*/
    
    /**********************************************************
     * Routine: set_muxconf_regs
     * Description: Setting up the configuration Mux registers
     *              specific to the hardware. Many pins need
     *              to be moved from protect to primary mode.
     *********************************************************/
    void set_muxconf_regs(void)
    {
    	MUX_DEFAULT();
    }
    
    int nor_read_boot(unsigned char *buf)
    {
    	return 0;
    }
    
    /**********************************************************
     * Routine: nand+_init
     * Description: Set up nand for nand and jffs2 commands
     *********************************************************/
    int nand_init(void)
    {
    	/* global settings */
    	__raw_writel(0x10, GPMC_SYSCONFIG);	/* smart idle */
    	__raw_writel(0x0, GPMC_IRQENABLE);	/* isr's sources masked */
    	__raw_writel(0, GPMC_TIMEOUT_CONTROL);/* timeout disable */
    
    	/* Set the GPMC Vals . For NAND boot on 3430SDP, NAND is mapped at CS0
             *  , NOR at CS1 and MPDB at CS3. And oneNAND boot, we map oneNAND at CS0.
    	 *  We configure only GPMC CS0 with required values. Configiring other devices
    	 *  at other CS in done in u-boot anyway. So we don't have to bother doing it here.
             */
    	__raw_writel(0 , GPMC_CONFIG7 + GPMC_CONFIG_CS0);
    	delay(1000);
    #ifdef ECC_HW_ENABLE
    	if (get_mem_type() == GPMC_NAND){
            	__raw_writel( (ECCCLEAR | ECCRESULTREG1), GPMC_ECC_CONTROL + GPMC_CONFIG_CS0);
            	__raw_writel( (ECCSIZE1 | ECCSIZE0 | ECCSIZE0SEL), GPMC_ECC_SIZE_CONFIG + GPMC_CONFIG_CS0);
    	}
    #endif
    	if ((get_mem_type() == GPMC_NAND) || (get_mem_type() == MMC_NAND)){
            	__raw_writel( M_NAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0);
            	__raw_writel( M_NAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0);
            	__raw_writel( M_NAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0);
            	__raw_writel( M_NAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0);
            	__raw_writel( M_NAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0);
            	__raw_writel( M_NAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0);
    
            	/* Enable the GPMC Mapping */
            	__raw_writel(( ((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) |
            		     ((NAND_BASE_ADR>>24) & 0x3F) |
            		     (1<<6) ),  (GPMC_CONFIG7 + GPMC_CONFIG_CS0));
            	delay(2000);
    
             	if (nand_chip()){
    #ifdef CFG_PRINTF
            		printf("Unsupported Chip!\n");
    #endif
            		return 1;
            	}
    
    	}
    
    	if ((get_mem_type() == GPMC_ONENAND) || (get_mem_type() == MMC_ONENAND)){
            	__raw_writel( ONENAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0);
            	__raw_writel( ONENAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0);
            	__raw_writel( ONENAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0);
            	__raw_writel( ONENAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0);
            	__raw_writel( ONENAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0);
            	__raw_writel( ONENAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0);
    
            	/* Enable the GPMC Mapping */
            	__raw_writel(( ((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) |
            		     ((ONENAND_BASE>>24) & 0x3F) |
            		     (1<<6) ),  (GPMC_CONFIG7 + GPMC_CONFIG_CS0));
            	delay(2000);
    
            	if (onenand_chip()){
    #ifdef CFG_PRINTF
            		printf("OneNAND Unsupported !\n");
    #endif
            		return 1;
            	}
    	}
    	return 0;
    }
    
    #ifdef ECC_HW_ENABLE
    void omap_enable_hw_ecc(void)
    {
    	uint32_t val,dev_width = 0;
            uint8_t cs = 0;
    #ifdef NAND_16BIT
    	dev_width = 1;
    #endif
    	/* Clear the ecc result registers, select ecc reg as 1 */
    	__raw_writel(ECCCLEAR | ECCRESULTREG1, GPMC_ECC_CONTROL + GPMC_CONFIG_CS0);
    
    	/*
    	* Size 0 = 0xFF, Size1 is 0xFF - both are 512 bytes
    	* tell all regs to generate size0 sized regs
    	* we just have a single ECC engine for all CS
    	*/
    	__raw_writel(ECCSIZE1 | ECCSIZE0 | ECCSIZE0SEL,
    			GPMC_ECC_SIZE_CONFIG + GPMC_CONFIG_CS0);
    	val = (dev_width << 7) | (cs << 1) | (0x1);
    	__raw_writel(val, GPMC_ECC_CONFIG + GPMC_CONFIG_CS0);
    	return;
    }
    /*
     * hweightN: returns the hamming weight (i.e. the number
     * of bits set) of a N-bit word
     */
    
    static inline unsigned int hweight32(unsigned int w)
    {
            unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
            res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
            res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
            res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
            return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
    }
    /*
     * gen_true_ecc - This function will generate true ECC value, which
     * can be used when correcting data read from NAND flash memory core
     *
     * @ecc_buf:    buffer to store ecc code
     *
     * @return:     re-formatted ECC value
     */
    static uint32_t gen_true_ecc(uint8_t *ecc_buf)
    {
            return ecc_buf[0] | (ecc_buf[1] << 16) | ((ecc_buf[2] & 0xF0) << 20) |
                    ((ecc_buf[2] & 0x0F) << 8);
    }
    
    
    int omap_correct_data_hw_ecc(u_char *dat, u_char *read_ecc, u_char *calc_ecc)
    {
            uint32_t orig_ecc, new_ecc, res, hm;
            uint16_t parity_bits, byte;
            uint8_t bit;
    
            /* Regenerate the orginal ECC */
            orig_ecc = gen_true_ecc(read_ecc);
            new_ecc = gen_true_ecc(calc_ecc);
            /* Get the XOR of real ecc */
            res = orig_ecc ^ new_ecc;
            if (res) {
                    /* Get the hamming width */
                    hm = hweight32(res);
                    /* Single bit errors can be corrected! */
                    if (hm == 12) {
                            /* Correctable data! */
                            parity_bits = res >> 16;
                            bit = (parity_bits & 0x7);
                            byte = (parity_bits >> 3) & 0x1FF;
                            /* Flip the bit to correct */
                            dat[byte] ^= (0x1 << bit);
                    } else if (hm == 1) {
                            printf("Error: Ecc is wrong\n");
                            /* ECC itself is corrupted */
                            return 2;
                    } else {
                            /*
                             * hm distance != parity pairs OR one, could mean 2 bit
                             * error OR potentially be on a blank page..
                             * orig_ecc: contains spare area data from nand flash.
                             * new_ecc: generated ecc while reading data area.
                             * Note: if the ecc = 0, all data bits from which it was
                             * generated are 0xFF.
                             * The 3 byte(24 bits) ecc is generated per 512byte
                             * chunk of a page. If orig_ecc(from spare area)
                             * is 0xFF && new_ecc(computed now from data area)=0x0,
                             * this means that data area is 0xFF and spare area is
                             * 0xFF. A sure sign of a erased page!
                             */
                            if ((orig_ecc == 0x0FFF0FFF) && (new_ecc == 0x00000000))
                                    return 0;
                            printf("Error: Bad compare! failed\n");
                            /* detected 2 bit error */
                            return -1;
                    }
            }
            return 0;
    }
    void omap_calculate_hw_ecc(const u_char *dat, u_char *ecc_code)
    {
            u_int32_t val;
    
            /* Start Reading from HW ECC1_Result = 0x200 */
            val = __raw_readl(GPMC_ECC1_RESULT + GPMC_CONFIG_CS0);
    
            ecc_code[0] = val & 0xFF;
            ecc_code[1] = (val >> 16) & 0xFF;
            ecc_code[2] = ((val >> 8) & 0x0F) | ((val >> 20) & 0xF0);
    
            /*
             * Stop reading anymore ECC vals and clear old results
             * enable will be called if more reads are required
             */
    	__raw_writel(0x000 , GPMC_ECC_CONFIG + GPMC_CONFIG_CS0);
    
            return;
    }
    #endif
    typedef int (mmc_boot_addr) (void);
    int mmc_boot(unsigned char *buf)
    {
    
           long size = 0;
    #ifdef CFG_CMD_FAT
           block_dev_desc_t *dev_desc = NULL;
           unsigned char ret = 0;
    
           printf("Starting X-loader on MMC\n");
    
           ret = mmc_init(1);
           if(ret == 0){
                   printf("\n MMC init failed\n");
                   return 0;
           }
    
           dev_desc = mmc_get_dev(0);
           fat_register_device(dev_desc, 1);
           size = file_fat_read("u-boot.bin", buf, 0);
           if (size == -1) {
                   return 0;
           }
           printf("\n%ld Bytes Read from MMC\n", size);
    
           printf("Starting OS Bootloader from MMC...\n");
    #endif
           return size;
    }
    
    /* optionally do something like blinking LED */
    void board_hang (void)
    { while (0) {};}
    
    .

    In "case 6", I find that it is showing in the minicom terminal "OneNAND not supported" and "X-loader failed; which is proper as per the functions called in the above file. In "case 24", the processor boots from MMC card and checks for NAND interface. In my board, NAND flash is connected at GPMC with Chip select at nCS0. Hence similar message don't appear in the terminal. But the process is not getting ahead and booting linux in the board.

    -Anindya

  • Hi Anindya,

    After putting through some investigation I probably found the reason for unsuccessful onenand initialization and x-loader stuck in 'case 6' as per the omap3evm.c file. I traced the "case 6:     return MMC_ONENAND;" and went to the nand_init() function and checking the onenand_chip(). Then look at the nand_chip() function in the ./drivers/onenand.c where trying to recognize the device id (onenand chip id).
    I suggest you to print the dev_id of the onenand chip which you are using and add something like:

    int onenand_chip()
    {
    ...

        if(mf_id == SAMSUNG_MFR_ID) {
            if (dev_id == KFM1G16Q2A_DEV_ID) {
            printf("Detected Samsung MuxOneNAND1G Flash \r\n");
            return 0;
    ...
    }

    but insted of KFM1G16Q2A_DEV_ID write the dev_id of your chip.

    Also I suggest you to add debug messages at each one step to be sure that your code takes effect and you are at right way.

    BR

    Tsvetolin Shulev

  • Hi,

    Thanks for your nice suggestion.

    But, even if I keep it in 'case 24', which corresponds to MMC_NAND, the x-loader does not go on to completion. In the serial console, no message comes up at all. Is it so that in the MMC_NAND cases the X-loader runs from MMC card but the u-boot code is taken from NAND flash?.bin 

    If so, please let me know what changes are required to boot all of x-loader,u-boot and kernel from MMC card only.

    Please also let me know what DDR settings are to be changed for my board, which contains two MT46H128M16LFB7 LPDDRs connected in the following scheme

    -Anindya

  • Anindya,

    I only summarize that you have 2 different issues.

    Initialization of the ONENAND memory which at first could be avoid by using MMC and continue with investigating this issue as described in the my previous post. The more serious issue is that the u-boot does not start. I suspect that the initialization of the LPDDR does not succeed.

    Check the config_3430sdram_ddr and mmc_boot functions in the omap3evm.c file and add there debugging messages. The console output should be useful to understand where the system hangs. This is what I can do remotely without hardware.

    BR

    Tsvetolin Shulev

  • Hi Tsvetolin,

    Thank you very much for your suggestion. I have changed the DDR settings and now U-boot and Kernel are loading.

    I'm facing a different problem now. The Kernel Loading process is stopping at "Calibrating Touchscreen" step. My board does not contain any Touchscreen LCD interface. Please suggest how to proceed to complete linux booting in my board.


    Regards,

    Anindya