diff --git a/drivers/mmi_info/mmi_boot_info.c b/drivers/mmi_info/mmi_boot_info.c index 28d464798c67..eddc3a2151c3 100644 --- a/drivers/mmi_info/mmi_boot_info.c +++ b/drivers/mmi_info/mmi_boot_info.c @@ -215,10 +215,11 @@ static void of_blsig(void) * boot info elements */ -static u32 bi_hwrev(void) +u32 bi_hwrev(void) { return mmi_chosen_data.system_rev; } +EXPORT_SYMBOL(bi_hwrev); #define EMIT_HWREV() \ EMIT_BOOTINFO("HW_REV", "0x%04x", hwrev) diff --git a/drivers/mmi_muc_uart/muc_protocol.h b/drivers/mmi_muc_uart/muc_protocol.h index 42911ab6aa55..0668198ccdd0 100644 --- a/drivers/mmi_muc_uart/muc_protocol.h +++ b/drivers/mmi_muc_uart/muc_protocol.h @@ -35,23 +35,20 @@ struct mmi_uart_hdr_t { #define POWER_STATUS 0x0003 #define POWER_CONTROL 0x0004 #define BOOT_MODE 0x0007 -/* Test commands */ -/*#define DISABLE_RESET 0x000A -#define ENABLE_RESET 0x000B -#define GPIO_REQUEST 0x000C*/ enum { NORMAL = 0, BP_TOOLS, FACTORY, QCOM, }; struct boot_mode_t { - uint8_t boot_mode; - uint8_t ap_guid[16]; // ro.mot.build.guid - uint8_t ap_fw_ver_str[256]; // ro.build.fingerprint -}; + uint8_t boot_mode; // androidboot.mode + uint32_t hwid; // androidboot.hwrev + uint8_t ap_guid[16]; // ro.mot.build.guid + uint8_t ap_fw_ver_str[256]; // ro.build.fingerprint +} __packed; enum { VBUS_IN = 0, VBUS_IN_SPLIT, VBUS_OUT, DC_IN }; struct power_control_t { - uint8_t flow; - uint32_t voltage_uv; - int32_t current_ua; + uint8_t flow; + uint32_t voltage_uv; + int32_t current_ua; }; struct power_status_t { @@ -71,9 +68,4 @@ struct power_status_t { uint32_t mod_input_current; /* uA */ }; -/*struct gpio_request_t { - uint8_t msm_gpio_num; - bool on; -};*/ - #endif /* MODD_MUC_PROTOCOL_H */ diff --git a/drivers/mmi_muc_uart/muc_uart.c b/drivers/mmi_muc_uart/muc_uart.c index be5a8ea0f83d..4f90ab180134 100644 --- a/drivers/mmi_muc_uart/muc_uart.c +++ b/drivers/mmi_muc_uart/muc_uart.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "mmi_uart.h" #include "mmi_tty.h" #include "muc_protocol.h" @@ -426,6 +427,8 @@ static int muc_uart_send_bootmode(struct mod_muc_data_t *mm_data) memset(&bootmode, 0x00, sizeof(struct boot_mode_t)); + bootmode.hwid = bi_hwrev(); + if(strncmp(param_bootmode, "mot-factory", strlen("mot-factory")) == 0) { bootmode.boot_mode = FACTORY; } else if(strncmp(param_bootmode, "qcom", strlen("qcom")) == 0) { @@ -439,6 +442,8 @@ static int muc_uart_send_bootmode(struct mod_muc_data_t *mm_data) pr_info("muc_uart_send_bootmode sending AP bootmode %u\n", bootmode.boot_mode); + pr_info("muc_uart_send_bootmode sending AP hwid 0x%x\n", + bootmode.hwid); return muc_uart_queue_send(mm_data, BOOT_MODE, @@ -486,17 +491,11 @@ static void muc_uart_handle_message(struct mod_muc_data_t *mm_data, uint8_t *payload, size_t payload_len) { - /* TODO should this whole block be covered by the mutex, - * ... if I get a message, I should ack it before the next - * request from the queue goes out. - */ - pr_info("muc_uart_handle_message: got msg of type %d.\n", hdr->cmd); + pr_info("muc_uart_handle_message: got msg of type %x.\n", hdr->cmd); switch (hdr->cmd) { case UART_SLEEP_REQ: { /* TODO always ack for now. */ - mutex_lock(&tx_lock); muc_uart_send(mm_data, UART_SLEEP_ACK, NULL, 0); - mutex_unlock(&tx_lock); schedule_delayed_work(&mm_data->sleep_work, msecs_to_jiffies(0)); break; } @@ -513,18 +512,14 @@ static void muc_uart_handle_message(struct mod_muc_data_t *mm_data, case PACKETBUS_PROT_MSG: { if (!mmi_tty_push_to_us(MMI_TTY_DEFAULT_IDX, payload, payload_len)) { - mutex_lock(&tx_lock); muc_uart_send(mm_data, PACKETBUS_PROT_MSG|MSG_ACK_MASK, NULL, 0); - mutex_unlock(&tx_lock); } else { pr_err("muc_uart_handle_message: Couldn't pass packet to us!"); - mutex_lock(&tx_lock); muc_uart_send(mm_data, PACKETBUS_PROT_MSG|MSG_NACK_MASK, NULL, 0); - mutex_unlock(&tx_lock); } break; } @@ -546,9 +541,14 @@ static void muc_uart_handle_message(struct mod_muc_data_t *mm_data, if(payload_len == sizeof(struct power_control_t)) muc_uart_set_power_control( (struct power_control_t *)payload); - mutex_lock(&tx_lock); muc_uart_send(mm_data, hdr->cmd|MSG_ACK_MASK, NULL, 0); - mutex_unlock(&tx_lock); + break; + } + case BOOT_MODE: { + if(muc_uart_send_bootmode(mm_data) >= 0) + muc_uart_send(mm_data, BOOT_MODE|MSG_ACK_MASK, NULL, 0); + else + muc_uart_send(mm_data, BOOT_MODE|MSG_NACK_MASK, NULL, 0); break; } default: { @@ -559,9 +559,7 @@ static void muc_uart_handle_message(struct mod_muc_data_t *mm_data, else { pr_err("muc_uart_handle_message: Unhandled type %d!", hdr->cmd); - mutex_lock(&tx_lock); muc_uart_send(mm_data, hdr->cmd|MSG_NACK_MASK, NULL, 0); - mutex_unlock(&tx_lock); } } } @@ -634,10 +632,16 @@ static size_t muc_uart_rx_cb(struct platform_device *pdev, print_hex_dump_debug("muc_uart rx: ", DUMP_PREFIX_OFFSET, 16, 1, data, content_size, true); + /* TODO it still might be possible for a message to go + * out of the queue before we handle the response to a + * request. + */ + mutex_lock(&tx_lock); muc_uart_handle_message(mm_data, hdr, data + sizeof(*hdr), content_size - sizeof(*hdr)); + mutex_unlock(&tx_lock); } return segment_size; diff --git a/include/soc/qcom/mmi_boot_info.h b/include/soc/qcom/mmi_boot_info.h index 201f7dcbfe00..e5e40eca3e34 100644 --- a/include/soc/qcom/mmi_boot_info.h +++ b/include/soc/qcom/mmi_boot_info.h @@ -77,5 +77,6 @@ const char *bi_bootreason(void); u32 bi_mbm_version(void); const char *bi_bootmode(void); u32 bi_boot_seq(void); +u32 bi_hwrev(void); #endif