Clean up warnings in lk code

Change-Id: I05b3a6cf07cde7e60586b1816c2f1279f64f5cf4
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 22b51e2..68264c5 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -43,6 +43,9 @@
 #include <dev/keys.h>
 #include <dev/fbcon.h>
 #include <baseband.h>
+#include <target.h>
+#include <mmc.h>
+#include <platform.h>
 
 #include "recovery.h"
 #include "bootimg.h"
@@ -90,27 +93,16 @@
 };
 
 char sn_buf[13];
-void platform_uninit_timer(void);
-unsigned* target_atag_mem(unsigned* ptr);
-unsigned board_machtype(void);
-unsigned check_reboot_mode(void);
-void *target_get_scratch_address(void);
-unsigned target_get_max_flash_size(void);
-int target_is_emmc_boot(void);
-void reboot_device(unsigned);
-void target_battery_charging_enable(unsigned enable, unsigned disconnect);
-unsigned int mmc_write (unsigned long long data_addr,
-			unsigned int data_len, unsigned int* in);
-unsigned long long mmc_ptn_offset (unsigned char * name);
-unsigned long long mmc_ptn_size (unsigned char * name);
-void display_shutdown(void);
+
+
 
 static void ptentry_to_tag(unsigned **ptr, struct ptentry *ptn)
 {
 	struct atag_ptbl_entry atag_ptn;
 
-	if (ptn->type == TYPE_MODEM_PARTITION)
+	if (ptn->type == TYPE_MODEM_PARTITION) {
 		return;
+	}
 	memcpy(atag_ptn.name, ptn->name, 16);
 	atag_ptn.name[15] = '\0';
 	atag_ptn.offset = ptn->start;
@@ -305,24 +297,21 @@
 		hdr = uhdr;
 		goto unified_boot;
 	}
-	if(!boot_into_recovery)
-	{
-		ptn = mmc_ptn_offset("boot");
-		if(ptn == 0) {
+	if (!boot_into_recovery) {
+		ptn = mmc_ptn_offset((unsigned char *) "boot");
+		if (ptn == 0) {
 			dprintf(CRITICAL, "ERROR: No boot partition found\n");
                     return -1;
 		}
-	}
-	else
-	{
-		ptn = mmc_ptn_offset("recovery");
-		if(ptn == 0) {
+	} else {
+		ptn = mmc_ptn_offset((unsigned char *) "recovery");
+		if (ptn == 0) {
 			dprintf(CRITICAL, "ERROR: No recovery partition found\n");
                     return -1;
 		}
 	}
 
-	if (mmc_read(ptn + offset, (unsigned int *)buf, page_size)) {
+	if (mmc_read(ptn + offset, (unsigned int *) buf, page_size)) {
 		dprintf(CRITICAL, "ERROR: Cannot read boot image header\n");
                 return -1;
 	}
@@ -542,8 +531,8 @@
 	unsigned long long ptn = 0;
 	unsigned int out[512] = {0};
 
-	ptn = mmc_ptn_offset(arg);
-	if(ptn == 0) {
+	ptn = mmc_ptn_offset((unsigned char *) arg);
+	if (ptn == 0) {
 		fastboot_fail("partition table doesn't exist");
 		return;
 	}
@@ -564,8 +553,8 @@
 	unsigned long long ptn = 0;
 	unsigned long long size = 0;
 
-	ptn = mmc_ptn_offset(arg);
-	if(ptn == 0) {
+	ptn = mmc_ptn_offset((unsigned char *) arg);
+	if (ptn == 0) {
 		fastboot_fail("partition table doesn't exist");
 		return;
 	}
@@ -577,13 +566,13 @@
 		}
 	}
 
-	size = mmc_ptn_size(arg);
-	if (ROUND_TO_PAGE(sz,511) > size) {
+	size = mmc_ptn_size((unsigned char *) arg);
+	if (ROUND_TO_PAGE(sz, 511) > size) {
 		fastboot_fail("size too large");
 		return;
 	}
 
-	if (mmc_write(ptn , sz, (unsigned int *)data)) {
+	if (mmc_write(ptn , sz, (unsigned int *) data)) {
 		fastboot_fail("flash write failure");
 		return;
 	}
@@ -591,19 +580,19 @@
 	return;
 }
 
+
+
 void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz)
 {
 	unsigned int chunk;
 	unsigned int chunk_data_sz;
 	sparse_header_t *sparse_header;
 	chunk_header_t *chunk_header;
-	uint32_t crc32 = 0;
 	uint32_t total_blocks = 0;
 	unsigned long long ptn = 0;
-	unsigned long long size = 0;
 
-	ptn = mmc_ptn_offset(arg);
-	if(ptn == 0) {
+	ptn = mmc_ptn_offset((unsigned char *) arg);
+	if (ptn == 0) {
 		fastboot_fail("partition table doesn't exist");
 		return;
 	}
@@ -714,10 +703,9 @@
 		magic_number[1] == SSD_HEADER_MAGIC_1)
 	{
 #ifdef SSD_ENABLE
-		ret = decrypt_img_scm(&data, &sz);
+		ret = decrypt_img_scm((uint32 **) &data, &sz);
 #endif
-		if(ret != 0)
-		{
+		if (ret != 0) {
 			dprintf(CRITICAL, "ERROR: Invalid secure image\n");
 			return;
 		}
@@ -814,7 +802,7 @@
 		ptable = flash_get_ptable();
 		if (ptable == NULL) {
 			dprintf(CRITICAL, "ERROR: Partition table not found\n");
-			return -1;
+			return;
 		}
 
 		ptn = ptable_find(ptable, "splash");
@@ -836,7 +824,6 @@
 void aboot_init(const struct app_descriptor *app)
 {
 	unsigned reboot_mode = 0;
-	unsigned disp_init = 0;
 	unsigned usb_init = 0;
 	unsigned sz = 0;
 
@@ -856,11 +843,10 @@
 	#if DISPLAY_SPLASH_SCREEN
 	display_init();
 	dprintf(SPEW, "Diplay initialized\n");
-	disp_init = 1;
-	diplay_image_on_screen();
+	display_image_on_screen();
 	#endif
 
-	target_serialno(sn_buf);
+	target_serialno((unsigned char *) sn_buf);
 	dprintf(SPEW,"serial number: %s\n",sn_buf);
 	surf_udc_device.serialno = sn_buf;
 
diff --git a/app/aboot/fastboot.c b/app/aboot/fastboot.c
index 6752dde..d247918 100644
--- a/app/aboot/fastboot.c
+++ b/app/aboot/fastboot.c
@@ -258,7 +258,7 @@
 		return;
 
 	r = usb_read(download_base, len);
-	if ((r < 0) || (r != len)) {
+	if ((r < 0) || ((unsigned) r != len)) {
 		fastboot_state = STATE_ERROR;
 		return;
 	}
diff --git a/app/aboot/recovery.c b/app/aboot/recovery.c
index 4584cf2..417e4b1 100644
--- a/app/aboot/recovery.c
+++ b/app/aboot/recovery.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
 
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -36,6 +36,7 @@
 #include <dev/flash.h>
 #include <lib/ptable.h>
 #include <dev/keys.h>
+#include <platform.h>
 
 #include "recovery.h"
 #include "bootimg.h"
@@ -50,8 +51,6 @@
 static char buf[4096];
 unsigned boot_into_recovery = 0;
 
-void reboot_device(unsigned);
-extern int target_is_emmc_boot(void);
 
 int get_recovery_message(struct recovery_message *out)
 {
@@ -74,7 +73,7 @@
 	}
 
 	offset += (pagesize * MISC_COMMAND_PAGE);
-	if (flash_read(ptn, offset, buf, pagesize)) {
+	if (flash_read(ptn, offset, (void *) buf, pagesize)) {
 		dprintf(CRITICAL, "ERROR: Cannot read recovery_header\n");
 		return -1;
 	}
@@ -105,18 +104,19 @@
 
 	n = pagesize * (MISC_COMMAND_PAGE + 1);
 
-	if (flash_read(ptn, offset, SCRATCH_ADDR, n)) {
+	if (flash_read(ptn, offset, (void *) SCRATCH_ADDR, n)) {
 		dprintf(CRITICAL, "ERROR: Cannot read recovery_header\n");
 		return -1;
 	}
 
 	offset += (pagesize * MISC_COMMAND_PAGE);
 	offset += SCRATCH_ADDR;
-	memcpy(offset, in, sizeof(*in));
+	memcpy((void *) offset, in, sizeof(*in));
 	if (flash_write(ptn, 0, (void *)SCRATCH_ADDR, n)) {
 		dprintf(CRITICAL, "ERROR: flash write fail!\n");
 		return -1;
 	}
+	return 0;
 }
 
 int read_update_header_for_bootloader(struct update_header *header)
@@ -143,7 +143,7 @@
 	}
 	memcpy(header, buf, sizeof(*header));
 
-	if(strncmp(header->MAGIC, UPDATE_MAGIC, UPDATE_MAGIC_SIZE))
+	if (strncmp((char *) header->MAGIC, UPDATE_MAGIC, UPDATE_MAGIC_SIZE))
 	{
 		return -1;
 	}
@@ -174,7 +174,7 @@
 	offset += header->image_offset;
 	n = (header->image_length + pagemask) & (~pagemask);
 
-	if (flash_read(ptn, offset, SCRATCH_ADDR, n)) {
+	if (flash_read(ptn, offset, (void *) SCRATCH_ADDR, n)) {
 		dprintf(CRITICAL, "ERROR: Cannot read radio image\n");
 		return -1;
 	}
@@ -185,7 +185,7 @@
 		return -1;
 	}
 
-	if (flash_write(ptn, 0, SCRATCH_ADDR, n)) {
+	if (flash_write(ptn, 0, (void *) SCRATCH_ADDR, n)) {
 		dprintf(CRITICAL, "ERROR: flash write fail!\n");
 		return -1;
 	}
@@ -290,10 +290,10 @@
 	int update_status = 0;
 
 	// get recovery message
-	if(get_recovery_message(&msg))
+	if (get_recovery_message(&msg))
 		return -1;
 	if (msg.command[0] != 0 && msg.command[0] != 255) {
-		dprintf("Recovery command: %.*s\n", sizeof(msg.command), msg.command);
+		dprintf(INFO, "Recovery command: %.*s\n", sizeof(msg.command), msg.command);
 	}
 	msg.command[sizeof(msg.command)-1] = '\0'; //Ensure termination
 
diff --git a/app/nandwrite/nandwrite.c b/app/nandwrite/nandwrite.c
index e262470..1fdcaf1 100644
--- a/app/nandwrite/nandwrite.c
+++ b/app/nandwrite/nandwrite.c
@@ -36,6 +36,7 @@
 #include <jtag.h>
 #include <kernel/thread.h>
 #include <smem.h>
+#include <platform.h>
 #include "bootimg.h"
 
 #define FLASH_PAGE_SIZE 2048
@@ -49,12 +50,11 @@
 #define ROUND_TO_PAGE(x,y) (((x) + (y)) & (~(y)))
 
 void acpu_clock_init(void);
-void platform_uninit_timer(void);
 
 int startswith(const char *str, const char *prefix)
 {
     while(*prefix){
-        if(*prefix++ != *str++) return 0;
+        if (*prefix++ != *str++) return 0;
     }
     return 1;
 }
diff --git a/dev/fbcon/fbcon.c b/dev/fbcon/fbcon.c
index 61e7cb4..071b8ed 100644
--- a/dev/fbcon/fbcon.c
+++ b/dev/fbcon/fbcon.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -33,6 +33,8 @@
 #include <stdlib.h>
 #include <dev/fbcon.h>
 #include <splash.h>
+#include <platform.h>
+#include <string.h>
 
 #include "font5x12.h"
 
@@ -206,7 +208,7 @@
     return config;
 }
 
-void diplay_image_on_screen(void)
+void display_image_on_screen(void)
 {
     unsigned i = 0;
     unsigned total_x = config->width;
diff --git a/dev/keys/gpio_keypad.c b/dev/keys/gpio_keypad.c
index 136d77b..0883c6a 100644
--- a/dev/keys/gpio_keypad.c
+++ b/dev/keys/gpio_keypad.c
@@ -42,6 +42,8 @@
 #include <kernel/timer.h>
 #include <reg.h>
 #include <platform/iomap.h>
+#include <platform/timer.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE_8660_QT      3298
 
@@ -593,24 +595,24 @@
     static int key_detected=-1;
 
     /* Row GPIOs 8,9,10 are used for sensing here */
-    for(gpio=8;gpio<=10;gpio++)
+    for (gpio=8;gpio<=10;gpio++)
     {
         bool status;
         status = pm8058_gpio_get(gpio);
-        if(status == 0)
+        if (status == 0)
             new_state |= (1<<(gpio-8));
     }
 
     bits_changed = last_state ^ new_state;
 
-    if(bits_changed)
+    if (bits_changed)
     {
-        int shift;
-        for(int rows=0;rows<(qwerty_keypad->keypad_info)->rows;rows++)
+        int shift = 0;
+        for (unsigned int rows = 0; rows < (qwerty_keypad->keypad_info)->rows; rows++)
         {
-            if((bits_changed & (1<<rows)) == 0)
+            if ((bits_changed & (1<<rows)) == 0)
                 continue;
-            shift = rows*8 + 3;
+            shift = rows * 8 + 3;
         }
         if ((qwerty_keypad->keypad_info)->keymap[shift])
         {
@@ -665,9 +667,9 @@
 void pmic_write(unsigned address, unsigned data)
 {
   write_func wr_function = &i2c_ssbi_write_bytes;
-  if(wr_function == NULL)
+  if (wr_function == NULL)
     return;
-  if ((*wr_function)(&data, 1, address))
+  if ((*wr_function)((unsigned char *) &data, 1, address))
     dprintf (CRITICAL, "Error in initializing register\n");
 
 }
diff --git a/include/dev/gpio_keypad.h b/include/dev/gpio_keypad.h
index 04093cc..4ab1449 100644
--- a/include/dev/gpio_keypad.h
+++ b/include/dev/gpio_keypad.h
@@ -210,6 +210,8 @@
 	int		inv_int_pol;	/* invert interrupt polarity */
 };
 
+bool pm8058_gpio_get(unsigned int gpio);
+
 typedef int (*read_func)(unsigned char *, unsigned short, unsigned short);
 typedef int (*write_func)(unsigned char *, unsigned short, unsigned short);
 
diff --git a/include/platform.h b/include/platform.h
index 5f7e303..cff84c3 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -35,4 +35,14 @@
 /* called by the arch init code to get the platform to set up any mmu mappings it may need */
 void platform_init_mmu_mappings(void);
 
+void display_init(void);
+void display_shutdown(void);
+void display_image_on_screen(void);
+
+unsigned board_machtype(void);
+unsigned check_reboot_mode(void);
+void platform_uninit_timer(void);
+void reboot_device(unsigned);
+
+
 #endif
diff --git a/include/platform/timer.h b/include/platform/timer.h
index 2a6e617..f2085c0 100644
--- a/include/platform/timer.h
+++ b/include/platform/timer.h
@@ -27,5 +27,9 @@
 
 status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, time_t interval);
 
+void mdelay(unsigned msecs);
+void udelay(unsigned usecs);
+
+
 #endif
 
diff --git a/include/target.h b/include/target.h
index c140d9d..b6e56bd 100644
--- a/include/target.h
+++ b/include/target.h
@@ -38,4 +38,15 @@
 /* if target is using eMMC bootup */
 int target_is_emmc_boot(void);
 
+unsigned* target_atag_mem(unsigned* ptr);
+void *target_get_scratch_address(void);
+unsigned target_get_max_flash_size(void);
+int target_is_emmc_boot(void);
+void target_battery_charging_enable(unsigned enable, unsigned disconnect);
+unsigned target_pause_for_battery_charge(void);
+unsigned target_baseband(void);
+void target_serialno(unsigned char *buf);
+void target_fastboot_init(void);
+
+
 #endif
diff --git a/lib/ptable/ptable.c b/lib/ptable/ptable.c
index 3ddf5fa..80feedf 100644
--- a/lib/ptable/ptable.c
+++ b/lib/ptable/ptable.c
@@ -2,7 +2,7 @@
  * Copyright (C) 2008 The Android Open Source Project
  * All rights reserved.
  *
- *Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ *Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -68,7 +68,7 @@
 		ptn = &ptable->parts[i];
 		dprintf(INFO, "ptn %d name='%s' start=%08x len=%08x "
 			"flags=%08x type=%s Writable=%s\n", i, ptn->name, ptn->start, ptn->length,
-			ptn->flags, ptype[ptn->type], pperm[ptn->perm]);
+			ptn->flags, ptype[(unsigned short) ptn->type], pperm[(unsigned short) ptn->perm]);
 	}
 }
 
diff --git a/platform/msm_shared/hsusb.c b/platform/msm_shared/hsusb.c
index b6decca..587bc72 100644
--- a/platform/msm_shared/hsusb.c
+++ b/platform/msm_shared/hsusb.c
@@ -115,7 +115,7 @@
 
 __WEAK void hsusb_clock_init(void)
 {
-	return 0;
+	return;
 }
 
 #if 1
diff --git a/platform/msm_shared/include/mmc.h b/platform/msm_shared/include/mmc.h
index c33729e..4fb893e 100644
--- a/platform/msm_shared/include/mmc.h
+++ b/platform/msm_shared/include/mmc.h
@@ -625,10 +625,20 @@
 #define MMC_CLK_ENABLE      1

 #define MMC_CLK_DISABLE     0

 

+

+unsigned int mmc_boot_main(unsigned char slot, unsigned int base);

 unsigned int mmc_boot_read_from_card( struct mmc_boot_host* host,

                                       struct mmc_boot_card* card,

                                       unsigned long long data_addr,

                                       unsigned int data_len,

                                       unsigned int* out );

+unsigned int mmc_write (unsigned long long data_addr,

+			unsigned int data_len, unsigned int* in);

+unsigned long long mmc_ptn_offset (unsigned char * name);

+unsigned long long mmc_ptn_size (unsigned char * name);

+

+unsigned int mmc_read (unsigned long long data_addr, unsigned int* out,

+                       unsigned int data_len);

+

 #endif

 

diff --git a/platform/msm_shared/mipi_dsi.c b/platform/msm_shared/mipi_dsi.c
index 0c747ac..941eefc 100644
--- a/platform/msm_shared/mipi_dsi.c
+++ b/platform/msm_shared/mipi_dsi.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -32,6 +32,7 @@
 #include <mipi_dsi.h>
 #include <dev/fbcon.h>
 #include <target/display.h>
+#include <stdlib.h>
 
 #define MIPI_FB_ADDR  0x43E00000
 
@@ -68,6 +69,8 @@
 #endif
 
 static int cmd_mode_status = 0;
+void secure_writel(uint32_t, uint32_t);
+uint32_t secure_readl(uint32_t);
 
 void configure_dsicore_dsiclk()
 {
@@ -113,8 +116,6 @@
 int mipi_dsi_phy_ctrl_config(struct mipi_dsi_panel_config *pinfo)
 {
 
-    unsigned char lane_1 = 1;
-    unsigned char lane_2 = 2;
     unsigned i;
     unsigned off = 0;
     struct mipi_dsi_phy_ctrl *pd;
@@ -325,8 +326,6 @@
     unsigned short WC1 = 0;     // for non embedded mode only
     int status = 0;
     unsigned char DLNx_EN;
-    unsigned char lane_1 = 1;
-    unsigned char lane_2 = 2;
 
     switch (pinfo->num_of_lanes) {
     default:
@@ -459,10 +458,8 @@
     unsigned char DLNx_EN;
     // video mode data ctrl
     int status = 0;
-    unsigned long low_pwr_stop_mode = 0;
-    unsigned char eof_bllp_pwr = 0x9;
-    unsigned char interleav = 0;
-    unsigned char ystride = 0x03;
+	unsigned char interleav = 0;
+	unsigned char ystride = 0x03;
     // disable mdp first
 
     writel(0x00000000, DSI_CLK_CTRL);
@@ -647,26 +644,9 @@
 {
 
     int status = 0;
-    unsigned long ReadValue;
-    unsigned long count = 0;
     unsigned long input_img_addr = MIPI_FB_ADDR;
-    unsigned long low_pwr_stop_mode = 0;    // low power mode 0x1111 start from
-    // bit16, high spd mode 0x0
-    unsigned char eof_bllp_pwr = 0x9;   // bit 12, 15, 1:low power stop mode or
-    // let cmd mode eng send packets in hs
-    // or lp mode
-    unsigned short display_wd = mipi_fb_cfg.width;
-    unsigned short display_ht = mipi_fb_cfg.height;
     unsigned short image_wd = mipi_fb_cfg.width;
     unsigned short image_ht = mipi_fb_cfg.height;
-    unsigned short hsync_porch_fp = MIPI_HSYNC_FRONT_PORCH_DCLK;
-    unsigned short hsync_porch_bp = MIPI_HSYNC_BACK_PORCH_DCLK;
-    unsigned short vsync_porch_fp = MIPI_VSYNC_FRONT_PORCH_LINES;
-    unsigned short vsync_porch_bp = MIPI_VSYNC_BACK_PORCH_LINES;
-    unsigned short hsync_width = MIPI_HSYNC_PULSE_WIDTH;
-    unsigned short vsync_width = MIPI_VSYNC_PULSE_WIDTH;
-    unsigned short dst_format = 0;
-    unsigned short traffic_mode = 0;
     unsigned short pack_pattern = 0x12;
     unsigned char ystride = 3;
 
@@ -735,7 +715,6 @@
 struct fbcon_config *mipi_init(void)
 {
     int status = 0;
-    unsigned char num_of_lanes = 1;
     struct mipi_dsi_panel_config *panel_info = get_panel_info();
     writel(0x00001800, MMSS_SFPB_GPREG);
     configure_dsicore_dsiclk();
diff --git a/platform/msm_shared/mmc.c b/platform/msm_shared/mmc.c
index 711e811..c19d9de 100644
--- a/platform/msm_shared/mmc.c
+++ b/platform/msm_shared/mmc.c
@@ -33,6 +33,7 @@
 #include "mmc.h"

 #include "partition_parser.h"

 #include <platform/iomap.h>

+#include <platform/timer.h>
 

 #if MMC_BOOT_ADM

 #include "adm.h"

@@ -77,8 +78,10 @@
 unsigned int ext3_count = 0;

 unsigned int vfat_count = 0;

 

+#if !(defined(PLATFORM_MSM8X60) || defined(PLATFORM_MSM8960))

 static unsigned mmc_sdc_clk[] = { SDC1_CLK, SDC2_CLK, SDC3_CLK, SDC4_CLK};

 static unsigned mmc_sdc_pclk[] = { SDC1_PCLK, SDC2_PCLK, SDC3_PCLK, SDC4_PCLK};

+#endif
 

 unsigned char mmc_slot = 0;

 unsigned int mmc_boot_mci_base = 0;

@@ -89,7 +92,6 @@
 int mmc_clock_enable_disable(unsigned id, unsigned enable);

 int mmc_clock_get_rate(unsigned id);

 int mmc_clock_set_rate(unsigned id, unsigned rate);

-void mdelay(unsigned msecs);

 

 struct mmc_boot_host mmc_host;

 struct mmc_boot_card mmc_card;

@@ -97,8 +99,6 @@
 unsigned mmc_partition_count = 0;

 static unsigned gpt_partitions_exist = 0;

 

-unsigned int mmc_read (unsigned long long data_addr, unsigned int* out,

-                       unsigned int data_len);

 static void mbr_fill_name (struct mbr_entry *mbr_ent, unsigned int type);

 static unsigned int mmc_wp(unsigned int addr, unsigned int size,

                            unsigned char set_clear_wp);

@@ -108,6 +108,7 @@
                                       unsigned int data_len,

                                       unsigned int command, unsigned int addr,

                                       unsigned int *out);

+void clock_set_enable(unsigned slot, unsigned int mclk);
 

 unsigned int SWAP_ENDIAN(unsigned int val)

 {

@@ -1683,20 +1684,19 @@
     unsigned int mmc_reg = 0;

     unsigned int xfer_type;

     unsigned int addr = 0;

-    unsigned int read_error;

     unsigned char open_ended_read = 1;

 

-    if( ( host == NULL ) || ( card == NULL ) )

+    if ( ( host == NULL ) || ( card == NULL ) )

     {

         return MMC_BOOT_E_INVAL;

     }

 

     /* Set block length. High Capacity MMC/SD card uses fixed 512 bytes block

        length. So no need to send CMD16. */

-    if( (card->type != MMC_BOOT_TYPE_MMCHC) && (card->type != MMC_BOOT_TYPE_SDHC) )

+    if ( (card->type != MMC_BOOT_TYPE_MMCHC) && (card->type != MMC_BOOT_TYPE_SDHC) )

     {

         mmc_ret = mmc_boot_set_block_len( card, card->rd_block_len );

-        if( mmc_ret != MMC_BOOT_E_SUCCESS )

+        if ( mmc_ret != MMC_BOOT_E_SUCCESS )

         {

             dprintf(CRITICAL, "Error No.%d: Failure setting block length for Card (RCA:%s)\n",

                     mmc_ret, (char *)(card->rca) );

@@ -2403,7 +2403,29 @@
     return ret;

 }

 

-

+
+
+void mmc_display_ext_csd(void)

+{

+    dprintf(SPEW,  "part_config: %x\n", ext_csd_buf[179] );

+    dprintf(SPEW,  "erase_group_def: %x\n", ext_csd_buf[175] );

+    dprintf(SPEW,  "user_wp: %x\n", ext_csd_buf[171] );

+}

+
+
+
+void mmc_display_csd(void)

+{

+    dprintf(SPEW,  "erase_grpsize: %d\n", mmc_card.csd.erase_grp_size );

+    dprintf(SPEW,  "erase_grpmult: %d\n", mmc_card.csd.erase_grp_mult );

+    dprintf(SPEW,  "wp_grpsize: %d\n", mmc_card.csd.wp_grp_size );

+    dprintf(SPEW,  "wp_grpen: %d\n", mmc_card.csd.wp_grp_enable );

+    dprintf(SPEW,  "perm_wp: %d\n", mmc_card.csd.perm_wp );

+    dprintf(SPEW,  "temp_wp: %d\n", mmc_card.csd.temp_wp );

+}

+
+
+
 /*

  * Entry point to MMC boot process

  */

@@ -2792,7 +2814,7 @@
     cmd.cmd_type = MMC_BOOT_CMD_ADDRESS;

     cmd.resp_type = MMC_BOOT_RESP_R1B;

 

-    for(int i=0;i<loop_count;i++)

+    for (unsigned int i = 0; i < loop_count; i++)

     {

         /* Sending CMD28 for each WP group size

            address is in sectors already */

@@ -2836,9 +2858,10 @@
                                             unsigned int sector)

 {

     unsigned int rc = MMC_BOOT_E_SUCCESS;

-    memset(wp_status_buf,0, 8);

+    memset(wp_status_buf, 0, 8);

 

-    rc = mmc_boot_read_reg(card,8,CMD31_SEND_WRITE_PROT_TYPE,sector,wp_status_buf);

+    rc = mmc_boot_read_reg(card, 8, CMD31_SEND_WRITE_PROT_TYPE, sector, 
+		(unsigned int *) wp_status_buf);

 

     return rc;

 }

@@ -2869,22 +2892,6 @@
     mmc_ret = mmc_wp(0xE06000,0x5000,1);

 }

 

-void mmc_display_ext_csd(void)

-{

-    dprintf(SPEW,  "part_config: %x\n", ext_csd_buf[179] );

-    dprintf(SPEW,  "erase_group_def: %x\n", ext_csd_buf[175] );

-    dprintf(SPEW,  "user_wp: %x\n", ext_csd_buf[171] );

-}

-

-void mmc_display_csd(void)

-{

-    dprintf(SPEW,  "erase_grpsize: %d\n", mmc_card.csd.erase_grp_size );

-    dprintf(SPEW,  "erase_grpmult: %d\n", mmc_card.csd.erase_grp_mult );

-    dprintf(SPEW,  "wp_grpsize: %d\n", mmc_card.csd.wp_grp_size );

-    dprintf(SPEW,  "wp_grpen: %d\n", mmc_card.csd.wp_grp_enable );

-    dprintf(SPEW,  "perm_wp: %d\n", mmc_card.csd.perm_wp );

-    dprintf(SPEW,  "temp_wp: %d\n", mmc_card.csd.temp_wp );

-}

 

 unsigned mmc_get_psn(void)

 {

diff --git a/target/init.c b/target/init.c
index 766b383..2984a96 100644
--- a/target/init.c
+++ b/target/init.c
@@ -85,7 +85,7 @@
 
 __WEAK void target_serialno(unsigned char *buf)
 {
-	sprintf(buf, "%s",TARGET(BOARD));
+	sprintf((char *) buf, "%s",TARGET(BOARD));
 }
 
 __WEAK void target_fastboot_init()
diff --git a/target/msm7625_ffa/init.c b/target/msm7625_ffa/init.c
index 0ca3fef..62b1e11 100755
--- a/target/msm7625_ffa/init.c
+++ b/target/msm7625_ffa/init.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE  2704
 
diff --git a/target/msm7625_surf/init.c b/target/msm7625_surf/init.c
index 4e227c5..69b5a6d 100755
--- a/target/msm7625_surf/init.c
+++ b/target/msm7625_surf/init.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE  2703
 
diff --git a/target/msm7627_ffa/init.c b/target/msm7627_ffa/init.c
index 366d7fa..36a9d2b 100644
--- a/target/msm7627_ffa/init.c
+++ b/target/msm7627_ffa/init.c
@@ -36,6 +36,7 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE  2706
 
diff --git a/target/msm7627_surf/init.c b/target/msm7627_surf/init.c
index 35c0e68..4b7f1ef 100644
--- a/target/msm7627_surf/init.c
+++ b/target/msm7627_surf/init.c
@@ -36,7 +36,9 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <mmc.h>
 #include <platform/iomap.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE_7x27_SURF    2705
 #define LINUX_MACHTYPE_7x27_FFA     2706
diff --git a/target/msm7627a/init.c b/target/msm7627a/init.c
index c743c4d..dcd732a 100644
--- a/target/msm7627a/init.c
+++ b/target/msm7627a/init.c
@@ -36,7 +36,9 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <mmc.h>
 #include <platform/iomap.h>
+#include <platform.h>
 
 #define MSM7X27A_FFA	3351
 #define MSM7X27A_SURF	3352
diff --git a/target/msm7630_1x/init.c b/target/msm7630_1x/init.c
index c8c598a..fe98772 100644
--- a/target/msm7630_1x/init.c
+++ b/target/msm7630_1x/init.c
@@ -37,6 +37,7 @@
 #include <dev/flash.h>
 #include <smem.h>
 #include <platform/machtype.h>
+#include <platform.h>
 
 #define MSM8255_ID                 74
 #define MSM8655_ID                 75
diff --git a/target/msm7630_surf/init.c b/target/msm7630_surf/init.c
index d9655fa..1aae5a2 100644
--- a/target/msm7630_surf/init.c
+++ b/target/msm7630_surf/init.c
@@ -38,8 +38,10 @@
 #include <dev/flash.h>
 #include <smem.h>
 #include <reg.h>
+#include <mmc.h>
 #include <platform/iomap.h>
 #include <platform/machtype.h>
+#include <platform.h>
 
 #define MSM8255_ID                 74
 #define MSM8655_ID                 75
diff --git a/target/msm8655_surf/init.c b/target/msm8655_surf/init.c
index d8fd86a..00e3627 100644
--- a/target/msm8655_surf/init.c
+++ b/target/msm8655_surf/init.c
@@ -37,8 +37,10 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <mmc.h>
 #include <reg.h>
 #include <platform/iomap.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE_7x30_SURF          2679
 #define LINUX_MACHTYPE_7x30_FFA           2707
diff --git a/target/msm8660_surf/init.c b/target/msm8660_surf/init.c
index 34cc59b..c51a260 100644
--- a/target/msm8660_surf/init.c
+++ b/target/msm8660_surf/init.c
@@ -36,10 +36,13 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <mmc.h>
+#include <platform/timer.h>
 #include <platform/iomap.h>
 #include <platform/gpio_hw.h>
 #include <baseband.h>
 #include <reg.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE_8660_SURF    2755
 #define LINUX_MACHTYPE_8660_FFA     3017
@@ -56,6 +59,7 @@
 void debug_led_write(char);
 char debug_led_read();
 uint32_t platform_id_read (void);
+void setup_fpga(void);
 
 void target_init(void)
 {
diff --git a/target/msm8660_surf/keypad.c b/target/msm8660_surf/keypad.c
index adcb10e..ba1374c 100644
--- a/target/msm8660_surf/keypad.c
+++ b/target/msm8660_surf/keypad.c
@@ -29,6 +29,7 @@
 
 #include <dev/keys.h>
 #include <dev/gpio_keypad.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE_8660_QT      3298
 #define BITS_IN_ELEMENT(x) (sizeof(x)[0] * 8)
diff --git a/target/msm8960/init.c b/target/msm8960/init.c
index 12bbbb9..db569ab 100644
--- a/target/msm8960/init.c
+++ b/target/msm8960/init.c
@@ -34,6 +34,8 @@
 #include <lib/ptable.h>
 #include <smem.h>
 #include <platform/iomap.h>
+#include <mmc.h>
+#include <platform/timer.h>
 #include <reg.h>
 #include <dev/keys.h>
 #include <dev/pm8921.h>
@@ -46,8 +48,6 @@
 #define LINUX_MACHTYPE_8960_FLUID   3398
 #define LINUX_MACHTYPE_8960_APQ     3399
 
-extern unsigned int mmc_boot_main(unsigned char slot, unsigned int base);
-extern void mdelay(unsigned msecs);
 extern void dmb(void);
 extern void keypad_init(void);
 
@@ -177,7 +177,7 @@
 	if(target_is_emmc_boot())
 	{
 		serialno =  mmc_get_psn();
-		sprintf(buf,"%x",serialno);
+		sprintf((char *) buf,"%x",serialno);
 	}
 }
 
diff --git a/target/qsd8250_surf/init.c b/target/qsd8250_surf/init.c
index 58e84a4..80c7193 100644
--- a/target/qsd8250_surf/init.c
+++ b/target/qsd8250_surf/init.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE  2708
 
diff --git a/target/qsd8650a_st1x/init.c b/target/qsd8650a_st1x/init.c
index 68ef80a..d43ea6a 100644
--- a/target/qsd8650a_st1x/init.c
+++ b/target/qsd8650a_st1x/init.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
- * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,6 +36,7 @@
 #include <lib/ptable.h>
 #include <dev/flash.h>
 #include <smem.h>
+#include <platform.h>
 
 #define LINUX_MACHTYPE  2627
 
diff --git a/target/surf-msm7k/init.c b/target/surf-msm7k/init.c
index 956ea49..8e01a08 100644
--- a/target/surf-msm7k/init.c
+++ b/target/surf-msm7k/init.c
@@ -34,6 +34,7 @@
 #include <dev/gpio_keypad.h>
 #include <lib/ptable.h>
 #include <dev/flash.h>
+#include <platform.h>
 
 #define BOARD_FLASH_OFFSET	378