Merge "target: msm8610: Add support to set boot done flag."
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 9a45feb..d50be73 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -77,7 +77,6 @@
#define EXPAND(NAME) #NAME
#define TARGET(NAME) EXPAND(NAME)
-#define DEFAULT_CMDLINE "mem=100M console=null";
#ifdef MEMBASE
#define EMMC_BOOT_IMG_HEADER_ADDR (0xFF000+(MEMBASE))
@@ -106,8 +105,6 @@
/* Assuming unauthorized kernel image by default */
static int auth_kernel_img = 0;
-static uint32_t app_dev_tree = 0;
-
static device_info device = {DEVICE_MAGIC, 0, 0};
static struct udc_device surf_udc_device = {
@@ -134,6 +131,29 @@
extern int fastboot_trigger(void);
#endif
+static void update_ker_tags_rdisk_addr(struct boot_img_hdr *hdr)
+{
+ /* overwrite the destination of specified for the project */
+ /*
+ * Update the value to sane values only when the boot image
+ * header does not have sane values, this is added to make sure
+ * that we always use values from boot.img header and use the
+ * force values when boot image header has default values.
+ */
+#ifdef ABOOT_FORCE_KERNEL_ADDR
+ if (hdr->kernel_addr == ABOOT_DEFAULT_KERNEL_ADDR)
+ hdr->kernel_addr = ABOOT_FORCE_KERNEL_ADDR;
+#endif
+#ifdef ABOOT_FORCE_RAMDISK_ADDR
+ if (hdr->ramdisk_addr == ABOOT_DEFAULT_RAMDISK_ADDR)
+ hdr->ramdisk_addr = ABOOT_FORCE_RAMDISK_ADDR;
+#endif
+#ifdef ABOOT_FORCE_TAGS_ADDR
+ if (hdr->tags_addr == ABOOT_DEFAULT_TAGS_ADDR)
+ hdr->tags_addr = ABOOT_FORCE_TAGS_ADDR;
+#endif
+}
+
static void ptentry_to_tag(unsigned **ptr, struct ptentry *ptn)
{
struct atag_ptbl_entry atag_ptn;
@@ -465,8 +485,6 @@
struct boot_img_hdr *uhdr;
unsigned offset = 0;
unsigned long long ptn = 0;
- const char *cmdline;
- void *tags;
int index = INVALID_PTN;
unsigned char *image_addr = 0;
@@ -520,6 +538,13 @@
page_mask = page_size - 1;
}
+ /*
+ * Update the kernel/ramdisk/tags address if the boot image header
+ * has default values, these default values come from mkbootimg when
+ * the boot image is flashed using fastboot flash:raw
+ */
+ update_ker_tags_rdisk_addr(hdr);
+
/* Get virtual addresses since the hdr saves physical addresses. */
hdr->kernel_addr = VA((addr_t)(hdr->kernel_addr));
hdr->ramdisk_addr = VA((addr_t)(hdr->ramdisk_addr));
@@ -611,15 +636,18 @@
/* Read device device tree in the "tags_add */
memmove((void *)hdr->tags_addr, (char *)dt_table_offset + dt_entry_ptr->offset, dt_entry_ptr->size);
} else {
- /*
- * Look for appended device tree if DTB is not found in boot image
- * If found load the kernel & boot up
- */
- app_dev_tree = dev_tree_appended((void*) hdr->kernel_addr);
- if (!app_dev_tree) {
- dprintf(CRITICAL, "ERROR: Appended Device Tree Blob not found\n");
- return -1;
- }
+ /*
+ * If appended dev tree is found, update the atags with
+ * memory address to the DTB appended location on RAM.
+ * Else update with the atags address in the kernel header
+ */
+ void *dtb;
+ dtb = dev_tree_appended((void*) hdr->kernel_addr,
+ (void *)hdr->tags_addr);
+ if (!dtb) {
+ dprintf(CRITICAL, "ERROR: Appended Device Tree Blob not found\n");
+ return -1;
+ }
}
#endif
/* Make sure everything from scratch address is read before next step!*/
@@ -705,39 +733,26 @@
return -1;
}
} else {
- /*
- * Look for appended device tree if DTB is not found in boot image
- * If found load the kernel & boot up
- */
- app_dev_tree = dev_tree_appended((void*) hdr->kernel_addr);
- if (!app_dev_tree) {
- dprintf(CRITICAL, "ERROR: Appended Device Tree Blob not found\n");
- return -1;
- }
+ /*
+ * If appended dev tree is found, update the atags with
+ * memory address to the DTB appended location on RAM.
+ * Else update with the atags address in the kernel header
+ */
+ void *dtb;
+ dtb = dev_tree_appended((void*) hdr->kernel_addr,
+ (void *)hdr->tags_addr);
+ if (!dtb) {
+ dprintf(CRITICAL, "ERROR: Appended Device Tree Blob not found\n");
+ return -1;
+ }
}
#endif
}
unified_boot:
- if(hdr->cmdline[0]) {
- cmdline = (char*) hdr->cmdline;
- } else {
- cmdline = DEFAULT_CMDLINE;
- }
-
- /*
- * If appended dev tree is found, update the atags with
- * memory address to the DTB appended location on RAM.
- * Else update with the atags address in the kernel header
- */
- if (app_dev_tree)
- tags = (void *)app_dev_tree;
- else
- tags = (void *)hdr->tags_addr;
-
- boot_linux((void *)hdr->kernel_addr, (unsigned *)tags,
- (const char *)cmdline, board_machtype(),
+ boot_linux((void *)hdr->kernel_addr, (void *)hdr->tags_addr,
+ (const char *)hdr->cmdline, board_machtype(),
(void *)hdr->ramdisk_addr, hdr->ramdisk_size);
return 0;
@@ -749,7 +764,6 @@
struct ptentry *ptn;
struct ptable *ptable;
unsigned offset = 0;
- const char *cmdline;
unsigned char *image_addr = 0;
unsigned kernel_actual;
@@ -811,6 +825,13 @@
return -1;
}
+ /*
+ * Update the kernel/ramdisk/tags address if the boot image header
+ * has default values, these default values come from mkbootimg when
+ * the boot image is flashed using fastboot flash:raw
+ */
+ update_ker_tags_rdisk_addr(hdr);
+
/* Get virtual addresses since the hdr saves physical addresses. */
hdr->kernel_addr = VA(hdr->kernel_addr);
hdr->ramdisk_addr = VA(hdr->ramdisk_addr);
@@ -959,17 +980,10 @@
}
continue_boot:
- if(hdr->cmdline[0]) {
- cmdline = (char*) hdr->cmdline;
- } else {
- cmdline = DEFAULT_CMDLINE;
- }
- dprintf(INFO, "cmdline = '%s'\n", cmdline);
-
/* TODO: create/pass atags to kernel */
boot_linux((void *)hdr->kernel_addr, (void *)hdr->tags_addr,
- (const char *)cmdline, board_machtype(),
+ (const char *)hdr->cmdline, board_machtype(),
(void *)hdr->ramdisk_addr, hdr->ramdisk_size);
return 0;
@@ -1188,12 +1202,14 @@
dt_entry_ptr->size);
} else {
/*
- * Look for appended device tree if DTB is not found in boot image
- * If found load the kernel & boot up
+ * If appended dev tree is found, update the atags with
+ * memory address to the DTB appended location on RAM.
+ * Else update with the atags address in the kernel header
*/
- memmove((void*) hdr->kernel_addr, boot_image_start + page_size, hdr->kernel_size);
- app_dev_tree = dev_tree_appended((void*) hdr->kernel_addr);
- if (!app_dev_tree) {
+ void *dtb;
+ dtb = dev_tree_appended((void *)hdr->kernel_addr,
+ (void *)hdr->tags_addr);
+ if (!dtb) {
dprintf(CRITICAL, "ERROR: Appended Device Tree Blob not found\n");
return -1;
}
@@ -1210,7 +1226,6 @@
unsigned ramdisk_actual;
struct boot_img_hdr *hdr;
char *ptr = ((char*) data);
- void *tags;
if (sz < sizeof(hdr)) {
fastboot_fail("invalid bootimage header");
@@ -1230,6 +1245,13 @@
kernel_actual = ROUND_TO_PAGE(hdr->kernel_size, page_mask);
ramdisk_actual = ROUND_TO_PAGE(hdr->ramdisk_size, page_mask);
+ /*
+ * Update the kernel/ramdisk/tags address if the boot image header
+ * has default values, these default values come from mkbootimg when
+ * the boot image is flashed using fastboot flash:raw
+ */
+ update_ker_tags_rdisk_addr(hdr);
+
/* Get virtual addresses since the hdr saves physical addresses. */
hdr->kernel_addr = VA(hdr->kernel_addr);
hdr->ramdisk_addr = VA(hdr->ramdisk_addr);
@@ -1241,6 +1263,9 @@
return;
}
+ memmove((void*) hdr->kernel_addr, ptr + page_size, hdr->kernel_size);
+ memmove((void*) hdr->ramdisk_addr, ptr + page_size + kernel_actual, hdr->ramdisk_size);
+
#if DEVICE_TREE
/* find correct dtb and copy it to right location */
if(copy_dtb(data))
@@ -1253,20 +1278,7 @@
fastboot_okay("");
udc_stop();
- memmove((void*) hdr->ramdisk_addr, ptr + page_size + kernel_actual, hdr->ramdisk_size);
- memmove((void*) hdr->kernel_addr, ptr + page_size, hdr->kernel_size);
-
- /*
- * If appended dev tree is found, update the atags with
- * memory address to the DTB appended location on RAM.
- * Else update with the atags address in the kernel header
- */
- if (app_dev_tree)
- tags = (void *)app_dev_tree;
- else
- tags = (void *)hdr->tags_addr;
-
- boot_linux((void*) hdr->kernel_addr, (void*) tags,
+ boot_linux((void*) hdr->kernel_addr, (void*) hdr->tags_addr,
(const char*) hdr->cmdline, board_machtype(),
(void*) hdr->ramdisk_addr, hdr->ramdisk_size);
}
diff --git a/app/tests/i2c_test.c b/app/tests/i2c_test.c
index cfaa920..8d2c1e3 100644
--- a/app/tests/i2c_test.c
+++ b/app/tests/i2c_test.c
@@ -38,7 +38,7 @@
struct qup_i2c_dev *dev;
char ret[100] = {'\0'};
- dev = qup_blsp_i2c_init(BLSP_ID_2, QUP_ID_4, 100000, 24000000);
+ dev = qup_blsp_i2c_init(BLSP_ID_2, QUP_ID_4, 100000, 19200000);
if (!dev) {
dprintf(CRITICAL, "Failed initializing I2c\n");
diff --git a/platform/msm8974/acpuclock.c b/platform/msm8974/acpuclock.c
index 9f4b6e4..d466f40 100644
--- a/platform/msm8974/acpuclock.c
+++ b/platform/msm8974/acpuclock.c
@@ -61,9 +61,6 @@
iclk = clk_get("usb_iface_clk");
cclk = clk_get("usb_core_clk");
- /* Disable USB all clock init */
- writel(0, USB_BOOT_CLOCK_CTL);
-
clk_disable(iclk);
clk_disable(cclk);
@@ -331,8 +328,11 @@
uint32_t reg = 0;
reg = readl(MDP_GDSCR);
if (enable) {
- if (reg & 0x1)
- writel((reg & ~0x1), MDP_GDSCR);
+ if (reg & 0x1) {
+ reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK);
+ reg |= GDSC_EN_FEW_WAIT_256_MASK;
+ writel(reg, MDP_GDSCR);
+ }
while(readl(MDP_GDSCR) & ((GDSC_POWER_ON_BIT) | (GDSC_POWER_ON_STATUS_BIT)));
} else
diff --git a/platform/msm8974/include/platform/clock.h b/platform/msm8974/include/platform/clock.h
index 6906ed2..0e11d4e 100644
--- a/platform/msm8974/include/platform/clock.h
+++ b/platform/msm8974/include/platform/clock.h
@@ -39,6 +39,8 @@
#define MDP_GDSCR REG_MM(0x2304)
#define GDSC_POWER_ON_BIT BIT(31)
#define GDSC_POWER_ON_STATUS_BIT BIT(29)
+#define GDSC_EN_FEW_WAIT_MASK (0x0F << 16)
+#define GDSC_EN_FEW_WAIT_256_MASK BIT(19)
#define MDP_CMD_RCGR REG_MM(0x2040)
#define MDP_CFG_RCGR REG_MM(0x2044)
diff --git a/platform/msm8974/include/platform/iomap.h b/platform/msm8974/include/platform/iomap.h
index 55b3291..a033ac8 100644
--- a/platform/msm8974/include/platform/iomap.h
+++ b/platform/msm8974/include/platform/iomap.h
@@ -84,7 +84,6 @@
#define GCC_WDOG_DEBUG (CLK_CTL_BASE + 0x00001780)
#define USB_HS_BCR (CLK_CTL_BASE + 0x480)
-#define USB_BOOT_CLOCK_CTL (CLK_CTL_BASE + 0x1A00)
#define SPMI_BASE 0xFC4C0000
#define SPMI_GENI_BASE (SPMI_BASE + 0xA000)
@@ -154,7 +153,7 @@
#define BLSP2_QUP5_I2C_APPS_CBCR (CLK_CTL_BASE + 0xB88)
#define BLSP_QUP_BASE(blsp_id, qup_id) ((blsp_id == 1) ? \
- (PERIPH_SS_BASE + 0x00023000 \
+ (PERIPH_SS_BASE + 0x00123000 \
+ (qup_id * 0x1000)) :\
(PERIPH_SS_BASE + 0x00163000 + \
(qup_id * 0x1000)))
diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c
index 6a06a12..bb3bf64 100644
--- a/platform/msm_shared/dev_tree.c
+++ b/platform/msm_shared/dev_tree.c
@@ -40,25 +40,37 @@
extern uint32_t target_dev_tree_mem(void *fdt, uint32_t memory_node_offset);
/*
- * Argument: Start address of the kernel loaded in RAM
+ * Will relocate the DTB to the tags addr if the device tree is found and return
+ * its address
+ *
+ * Arguments: kernel - Start address of the kernel loaded in RAM
+ * tags - Start address of the tags loaded in RAM
* Return Value: DTB address : If appended device tree is found
- * '0' : Otherwise
+ * 'NULL' : Otherwise
*/
-uint32_t dev_tree_appended(void *kernel)
+void *dev_tree_appended(void *kernel, void *tags)
{
uint32_t app_dtb_offset = 0;
uint32_t dtb_magic = 0;
- uint32_t dtb = 0;
memcpy((void*) &app_dtb_offset, (void*) (kernel + DTB_OFFSET), sizeof(uint32_t));
memcpy((void*) &dtb_magic, (void*) (kernel + app_dtb_offset), sizeof(uint32_t));
if (dtb_magic == DTB_MAGIC) {
+ void *dtb;
+ int rc;
+
dprintf(INFO, "Found Appeneded Flattened Device tree\n");
- dtb = (uint32_t) (kernel + app_dtb_offset);
+ dtb = kernel + app_dtb_offset;
+ rc = fdt_open_into(dtb, tags, fdt_totalsize(dtb) + DTB_PAD_SIZE);
+ if (rc == 0) {
+ /* clear out the old DTB magic so kernel doesn't find it */
+ *((uint32_t *)dtb) = 0;
+ return tags;
+ }
}
- return dtb;
+ return NULL;
}
/* Function to return the pointer to the start of the correct device tree
diff --git a/platform/msm_shared/include/dev_tree.h b/platform/msm_shared/include/dev_tree.h
index 389ab49..a27fafd 100644
--- a/platform/msm_shared/include/dev_tree.h
+++ b/platform/msm_shared/include/dev_tree.h
@@ -40,6 +40,8 @@
#define DTB_MAGIC 0xedfe0dd0
#define DTB_OFFSET 0x2C
+#define DTB_PAD_SIZE 1024
+
struct dt_entry
{
uint32_t platform_id;
@@ -65,5 +67,5 @@
struct dt_entry * dev_tree_get_entry_ptr(struct dt_table *);
int update_device_tree(void *, const char *, void *, unsigned);
int dev_tree_add_mem_info(void *fdt, uint32_t offset, uint32_t size, uint32_t addr);
-uint32_t dev_tree_appended(void *);
+void *dev_tree_appended(void *kernel, void *tags);
#endif
diff --git a/project/msm8974.mk b/project/msm8974.mk
index ab53f9f..2cbec50 100644
--- a/project/msm8974.mk
+++ b/project/msm8974.mk
@@ -7,6 +7,7 @@
MODULES += app/aboot
DEBUG := 1
+EMMC_BOOT := 1
#DEFINES += WITH_DEBUG_DCC=1
DEFINES += WITH_DEBUG_UART=1
@@ -17,3 +18,16 @@
#Disable thumb mode
ENABLE_THUMB := false
+
+DEFINES += ABOOT_FORCE_KERNEL_ADDR=0x00008000
+DEFINES += ABOOT_FORCE_RAMDISK_ADDR=0x02000000
+DEFINES += ABOOT_FORCE_TAGS_ADDR=0x01e00000
+
+# Right now we are assuming these are the only default values
+DEFINES += ABOOT_DEFAULT_KERNEL_ADDR=0x10008000
+DEFINES += ABOOT_DEFAULT_RAMDISK_ADDR=0x1100000
+DEFINES += ABOOT_DEFAULT_TAGS_ADDR=0x10000100
+
+ifeq ($(EMMC_BOOT),1)
+DEFINES += _EMMC_BOOT=1
+endif
diff --git a/target/msm8974/init.c b/target/msm8974/init.c
index c4dc69d..b21142f 100644
--- a/target/msm8974/init.c
+++ b/target/msm8974/init.c
@@ -279,6 +279,11 @@
};
}
+unsigned target_baseband()
+{
+ return board_baseband();
+}
+
void target_serialno(unsigned char *buf)
{
unsigned int serialno;