diag: Add diag support for new 8625 and 8974 targets
Also, add more generic cpu type identification logic
to remove having to modify code each time a new target
variant comes out.
Change-Id: I9493ffad0960ab4863205191937ea5c56be97de2
Signed-off-by: Dixon Peterson <dixonp@codeaurora.org>
diff --git a/drivers/char/diag/diagchar.h b/drivers/char/diag/diagchar.h
index 4153b7b..228c77fb 100644
--- a/drivers/char/diag/diagchar.h
+++ b/drivers/char/diag/diagchar.h
@@ -134,6 +134,7 @@
int num_clients;
int polling_reg_flag;
struct diag_write_device *buf_tbl;
+ int use_device_tree;
/* Memory pool parameters */
unsigned int itemsize;
diff --git a/drivers/char/diag/diagfwd.c b/drivers/char/diag/diagfwd.c
index cc2b6e5..f16aa0c 100644
--- a/drivers/char/diag/diagfwd.c
+++ b/drivers/char/diag/diagfwd.c
@@ -21,6 +21,7 @@
#include <linux/diagchar.h>
#include <linux/delay.h>
#include <linux/reboot.h>
+#include <linux/of.h>
#ifdef CONFIG_DIAG_OVER_USB
#include <mach/usbdiag.h>
#endif
@@ -76,27 +77,54 @@
#define CHK_OVERFLOW(bufStart, start, end, length) \
((bufStart <= start) && (end - start >= length)) ? 1 : 0
+/* Determine if this device uses a device tree */
+#ifdef CONFIG_OF
+static int has_device_tree(void)
+{
+ struct device_node *node;
+
+ node = of_find_node_by_path("/");
+ if (node) {
+ of_node_put(node);
+ return 1;
+ }
+ return 0;
+}
+#else
+static int has_device_tree(void)
+{
+ return 0;
+}
+#endif
+
int chk_config_get_id(void)
{
/* For all Fusion targets, Modem will always be present */
if (machine_is_msm8x60_fusion() || machine_is_msm8x60_fusn_ffa())
return 0;
- switch (socinfo_get_id()) {
- case APQ8060_MACHINE_ID:
- case MSM8660_MACHINE_ID:
- return APQ8060_TOOLS_ID;
- case AO8960_MACHINE_ID:
- case MSM8260A_MACHINE_ID:
- return AO8960_TOOLS_ID;
- case APQ8064_MACHINE_ID:
- return APQ8064_TOOLS_ID;
- case MSM8930_MACHINE_ID:
- return MSM8930_TOOLS_ID;
- case MSM8974_MACHINE_ID:
- return MSM8974_TOOLS_ID;
- default:
- return 0;
+ if (driver->use_device_tree) {
+ if (machine_is_copper())
+ return MSM8974_TOOLS_ID;
+ else
+ return 0;
+ } else {
+ switch (socinfo_get_msm_cpu()) {
+ case MSM_CPU_8X60:
+ return APQ8060_TOOLS_ID;
+ case MSM_CPU_8960:
+ return AO8960_TOOLS_ID;
+ case MSM_CPU_8064:
+ return APQ8064_TOOLS_ID;
+ case MSM_CPU_8930:
+ return MSM8930_TOOLS_ID;
+ case MSM_CPU_COPPER:
+ return MSM8974_TOOLS_ID;
+ case MSM_CPU_8625:
+ return MSM8625_TOOLS_ID;
+ default:
+ return 0;
+ }
}
}
@@ -106,18 +134,16 @@
*/
int chk_apps_only(void)
{
- switch (socinfo_get_id()) {
- case AO8960_MACHINE_ID:
- case APQ8064_MACHINE_ID:
- case MSM8930_MACHINE_ID:
- case MSM8630_MACHINE_ID:
- case MSM8230_MACHINE_ID:
- case APQ8030_MACHINE_ID:
- case MSM8627_MACHINE_ID:
- case MSM8227_MACHINE_ID:
- case MSM8974_MACHINE_ID:
- case MDM9615_MACHINE_ID:
- case MSM8260A_MACHINE_ID:
+ if (driver->use_device_tree)
+ return 1;
+
+ switch (socinfo_get_msm_cpu()) {
+ case MSM_CPU_8960:
+ case MSM_CPU_8064:
+ case MSM_CPU_8930:
+ case MSM_CPU_8627:
+ case MSM_CPU_9615:
+ case MSM_CPU_COPPER:
return 1;
default:
return 0;
@@ -131,8 +157,28 @@
*/
int chk_apps_master(void)
{
- if (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm9615() ||
- cpu_is_apq8064() || cpu_is_msm8627())
+ if (driver->use_device_tree)
+ return 1;
+ else if (cpu_is_msm8960() || cpu_is_msm8930() || cpu_is_msm9615() ||
+ cpu_is_apq8064() || cpu_is_msm8627())
+ return 1;
+ else
+ return 0;
+}
+
+inline int chk_polling_response(void)
+{
+ if (!(driver->polling_reg_flag) && chk_apps_master())
+ /*
+ * If the apps processor is master and no other processor
+ * has registered to respond for polling
+ */
+ return 1;
+ else if (!(driver->ch) && !(chk_apps_master()))
+ /*
+ * If the apps processor is not the master and the modem
+ * is not up
+ */
return 1;
else
return 0;
@@ -1062,7 +1108,7 @@
else if ((*buf == 0x4b) && (*(buf+1) == 0x32) &&
(*(buf+2) == 0x03)) {
/* If no one has registered for polling */
- if (!(driver->polling_reg_flag)) {
+ if (chk_polling_response()) {
/* Respond to polling for Apps only DIAG */
for (i = 0; i < 3; i++)
driver->apps_rsp_buf[i] = *(buf+i);
@@ -1074,7 +1120,7 @@
}
}
/* Check for ID for NO MODEM present */
- else if (!(driver->polling_reg_flag)) {
+ else if (chk_polling_response()) {
/* respond to 0x0 command */
if (*buf == 0x00) {
for (i = 0; i < 55; i++)
@@ -1481,6 +1527,7 @@
{
diag_debug_buf_idx = 0;
driver->read_len_legacy = 0;
+ driver->use_device_tree = has_device_tree();
if (driver->event_mask == NULL) {
driver->event_mask = kzalloc(sizeof(
diff --git a/include/linux/diagchar.h b/include/linux/diagchar.h
index 17580b4..5d3a6a1 100644
--- a/include/linux/diagchar.h
+++ b/include/linux/diagchar.h
@@ -36,23 +36,11 @@
#define DIAG_IOCTL_GET_DELAYED_RSP_ID 8
#define DIAG_IOCTL_LSM_DEINIT 9
-/* Machine ID and corresponding PC Tools IDs */
-#define APQ8060_MACHINE_ID 86
-#define AO8960_MACHINE_ID 87
-#define MSM8660_MACHINE_ID 71
-#define MDM9615_MACHINE_ID 104
-#define APQ8064_MACHINE_ID 109
-#define MSM8930_MACHINE_ID 116
-#define MSM8630_MACHINE_ID 117
-#define MSM8230_MACHINE_ID 118
-#define APQ8030_MACHINE_ID 119
-#define MSM8627_MACHINE_ID 120
-#define MSM8227_MACHINE_ID 121
-#define MSM8260A_MACHINE_ID 123
-#define MSM8974_MACHINE_ID 126
+/* PC Tools IDs */
#define APQ8060_TOOLS_ID 4062
#define AO8960_TOOLS_ID 4064
#define APQ8064_TOOLS_ID 4072
+#define MSM8625_TOOLS_ID 4075
#define MSM8930_TOOLS_ID 4076
#define MSM8630_TOOLS_ID 4077
#define MSM8230_TOOLS_ID 4078