aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorArve Hjønnevåg <arve@android.com>2009-05-20 19:52:36 -0400
committerDaniel Walker <dwalker@codeaurora.org>2010-05-12 12:15:03 -0400
commit283794100d2b1c1645b2949273aa4be29929812d (patch)
tree30c371ec32ff2d8767ec3b3fb72c7a0b32c0e513 /arch
parent5b0f5a3f6084397194a8b556cdca572ad8e14f05 (diff)
[ARM] msm: Add item argument to smsm_change_state and smsm_get_state
The new protocol require writing to two state fields, and reading several fields. Signed-off-by: Arve Hjønnevåg <arve@android.com> Signed-off-by: Daniel Walker <dwalker@codeaurora.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-msm/smd.c58
-rw-r--r--arch/arm/mach-msm/smd_private.h30
2 files changed, 50 insertions, 38 deletions
diff --git a/arch/arm/mach-msm/smd.c b/arch/arm/mach-msm/smd.c
index f731ddeaa25c..e33fd029fa37 100644
--- a/arch/arm/mach-msm/smd.c
+++ b/arch/arm/mach-msm/smd.c
@@ -49,16 +49,13 @@ static int msm_smd_debug_mask;
49struct shared_info 49struct shared_info
50{ 50{
51 int ready; 51 int ready;
52 unsigned state_apps; 52 unsigned state;
53 unsigned state_modem;
54}; 53};
55 54
56static unsigned dummy_state_apps; 55static unsigned dummy_state[SMSM_STATE_COUNT];
57static unsigned dummy_state_modem;
58 56
59static struct shared_info smd_info = { 57static struct shared_info smd_info = {
60 .state_apps = (unsigned) &dummy_state_apps, 58 .state = (unsigned) &dummy_state,
61 .state_modem = (unsigned) &dummy_state_modem,
62}; 59};
63 60
64module_param_named(debug_mask, msm_smd_debug_mask, 61module_param_named(debug_mask, msm_smd_debug_mask,
@@ -115,9 +112,14 @@ static void handle_modem_crash(void)
115 112
116extern int (*msm_check_for_modem_crash)(void); 113extern int (*msm_check_for_modem_crash)(void);
117 114
115uint32_t raw_smsm_get_state(enum smsm_state_item item)
116{
117 return readl(smd_info.state + item * 4);
118}
119
118static int check_for_modem_crash(void) 120static int check_for_modem_crash(void)
119{ 121{
120 if (readl(smd_info.state_modem) & SMSM_RESET) { 122 if (raw_smsm_get_state(SMSM_STATE_MODEM) & SMSM_RESET) {
121 handle_modem_crash(); 123 handle_modem_crash();
122 return -1; 124 return -1;
123 } 125 }
@@ -978,8 +980,8 @@ static irqreturn_t smsm_irq_handler(int irq, void *data)
978 980
979 spin_lock_irqsave(&smem_lock, flags); 981 spin_lock_irqsave(&smem_lock, flags);
980 982
981 apps = readl(smd_info.state_apps); 983 apps = raw_smsm_get_state(SMSM_STATE_APPS);
982 modm = readl(smd_info.state_modem); 984 modm = raw_smsm_get_state(SMSM_STATE_MODEM);
983 985
984 if (msm_smd_debug_mask & MSM_SMSM_DEBUG) 986 if (msm_smd_debug_mask & MSM_SMSM_DEBUG)
985 pr_info("<SM %08x %08x>\n", apps, modm); 987 pr_info("<SM %08x %08x>\n", apps, modm);
@@ -992,24 +994,26 @@ static irqreturn_t smsm_irq_handler(int irq, void *data)
992 return IRQ_HANDLED; 994 return IRQ_HANDLED;
993} 995}
994 996
995int smsm_change_state(uint32_t clear_mask, uint32_t set_mask) 997int smsm_change_state(enum smsm_state_item item,
998 uint32_t clear_mask, uint32_t set_mask)
996{ 999{
997 unsigned long flags; 1000 unsigned long flags;
998 unsigned state; 1001 unsigned state;
1002 unsigned addr = smd_info.state + item * 4;
999 1003
1000 if (!smd_info.ready) 1004 if (!smd_info.ready)
1001 return -EIO; 1005 return -EIO;
1002 1006
1003 spin_lock_irqsave(&smem_lock, flags); 1007 spin_lock_irqsave(&smem_lock, flags);
1004 1008
1005 if (readl(smd_info.state_modem) & SMSM_RESET) 1009 if (raw_smsm_get_state(SMSM_STATE_MODEM) & SMSM_RESET)
1006 handle_modem_crash(); 1010 handle_modem_crash();
1007 1011
1008 state = (readl(smd_info.state_apps) & ~clear_mask) | set_mask; 1012 state = (readl(addr) & ~clear_mask) | set_mask;
1009 writel(state, smd_info.state_apps); 1013 writel(state, addr);
1010 1014
1011 if (msm_smd_debug_mask & MSM_SMSM_DEBUG) 1015 if (msm_smd_debug_mask & MSM_SMSM_DEBUG)
1012 pr_info("smsm_change_state %x\n", state); 1016 pr_info("smsm_change_state %d %x\n", item, state);
1013 notify_other_smsm(); 1017 notify_other_smsm();
1014 1018
1015 spin_unlock_irqrestore(&smem_lock, flags); 1019 spin_unlock_irqrestore(&smem_lock, flags);
@@ -1017,16 +1021,16 @@ int smsm_change_state(uint32_t clear_mask, uint32_t set_mask)
1017 return 0; 1021 return 0;
1018} 1022}
1019 1023
1020uint32_t smsm_get_state(void) 1024uint32_t smsm_get_state(enum smsm_state_item item)
1021{ 1025{
1022 unsigned long flags; 1026 unsigned long flags;
1023 uint32_t rv; 1027 uint32_t rv;
1024 1028
1025 spin_lock_irqsave(&smem_lock, flags); 1029 spin_lock_irqsave(&smem_lock, flags);
1026 1030
1027 rv = readl(smd_info.state_modem); 1031 rv = readl(smd_info.state + item * 4);
1028 1032
1029 if (rv & SMSM_RESET) 1033 if (item == SMSM_STATE_MODEM && (rv & SMSM_RESET))
1030 handle_modem_crash(); 1034 handle_modem_crash();
1031 1035
1032 spin_unlock_irqrestore(&smem_lock, flags); 1036 spin_unlock_irqrestore(&smem_lock, flags);
@@ -1145,14 +1149,8 @@ int smd_core_init(void)
1145 unsigned size; 1149 unsigned size;
1146 void *state; 1150 void *state;
1147 state = smem_item(SMEM_SMSM_SHARED_STATE, &size); 1151 state = smem_item(SMEM_SMSM_SHARED_STATE, &size);
1148 if (size == SMSM_V1_SIZE) { 1152 if (size == SMSM_V1_SIZE || size == SMSM_V2_SIZE) {
1149 smd_info.state_apps = state + SMSM_V1_STATE_APPS; 1153 smd_info.state = (unsigned)state;
1150 smd_info.state_modem = state + SMSM_V1_STATE_MODEM;
1151 break;
1152 }
1153 if (size == SMSM_V2_SIZE) {
1154 smd_info.state_apps = state + SMSM_V2_STATE_APPS;
1155 smd_info.state_modem = state + SMSM_V2_STATE_MODEM;
1156 break; 1154 break;
1157 } 1155 }
1158 } 1156 }
@@ -1181,8 +1179,8 @@ int smd_core_init(void)
1181 do_smd_probe(); 1179 do_smd_probe();
1182 1180
1183 /* indicate that we're up and running */ 1181 /* indicate that we're up and running */
1184 writel(SMSM_INIT | SMSM_SMDINIT | SMSM_RPCINIT, smd_info.state_apps); 1182 smsm_change_state(SMSM_STATE_APPS,
1185 notify_other_smsm(); 1183 ~0, SMSM_INIT | SMSM_SMDINIT | SMSM_RPCINIT);
1186 1184
1187 pr_info("smd_core_init() done\n"); 1185 pr_info("smd_core_init() done\n");
1188 1186
@@ -1227,13 +1225,13 @@ static int debug_read_stat(char *buf, int max)
1227 1225
1228 msg = smem_find(ID_DIAG_ERR_MSG, SZ_DIAG_ERR_MSG); 1226 msg = smem_find(ID_DIAG_ERR_MSG, SZ_DIAG_ERR_MSG);
1229 1227
1230 if (readl(smd_info.state_modem) & SMSM_RESET) 1228 if (raw_smsm_get_state(SMSM_STATE_MODEM) & SMSM_RESET)
1231 i += scnprintf(buf + i, max - i, 1229 i += scnprintf(buf + i, max - i,
1232 "smsm: ARM9 HAS CRASHED\n"); 1230 "smsm: ARM9 HAS CRASHED\n");
1233 1231
1234 i += scnprintf(buf + i, max - i, "smsm: a9: %08x a11: %08x\n", 1232 i += scnprintf(buf + i, max - i, "smsm: a9: %08x a11: %08x\n",
1235 readl(smd_info.state_modem), 1233 raw_smsm_get_state(SMSM_STATE_MODEM),
1236 readl(smd_info.state_apps)); 1234 raw_smsm_get_state(SMSM_STATE_APPS));
1237 1235
1238 if (msg) { 1236 if (msg) {
1239 msg[SZ_DIAG_ERR_MSG - 1] = 0; 1237 msg[SZ_DIAG_ERR_MSG - 1] = 0;
diff --git a/arch/arm/mach-msm/smd_private.h b/arch/arm/mach-msm/smd_private.h
index 732147c2f992..35e08359bbdb 100644
--- a/arch/arm/mach-msm/smd_private.h
+++ b/arch/arm/mach-msm/smd_private.h
@@ -59,13 +59,7 @@ struct smem_shared
59}; 59};
60 60
61#define SMSM_V1_SIZE (sizeof(unsigned) * 8) 61#define SMSM_V1_SIZE (sizeof(unsigned) * 8)
62#define SMSM_V1_STATE_APPS 0x0000
63#define SMSM_V1_STATE_MODEM 0x0004
64#define SMSM_V1_STATE_DSP 0x0008
65
66#define SMSM_V2_SIZE (sizeof(unsigned) * 4) 62#define SMSM_V2_SIZE (sizeof(unsigned) * 4)
67#define SMSM_V2_STATE_APPS 0x0004
68#define SMSM_V2_STATE_MODEM 0x000C
69 63
70struct smsm_interrupt_info 64struct smsm_interrupt_info
71{ 65{
@@ -113,9 +107,29 @@ struct smsm_interrupt_info
113#define SMSM_WKUP_REASON_ALARM 0x00000010 107#define SMSM_WKUP_REASON_ALARM 0x00000010
114#define SMSM_WKUP_REASON_RESET 0x00000020 108#define SMSM_WKUP_REASON_RESET 0x00000020
115 109
110#ifndef CONFIG_ARCH_MSM_SCORPION
111enum smsm_state_item {
112 SMSM_STATE_APPS = 1,
113 SMSM_STATE_MODEM = 3,
114 SMSM_STATE_COUNT,
115};
116#else
117enum smsm_state_item {
118 SMSM_STATE_APPS,
119 SMSM_STATE_MODEM,
120 SMSM_STATE_HEXAGON,
121 SMSM_STATE_APPS_DEM,
122 SMSM_STATE_MODEM_DEM,
123 SMSM_STATE_QDSP6_DEM,
124 SMSM_STATE_POWER_MASTER_DEM,
125 SMSM_STATE_TIME_MASTER_DEM,
126 SMSM_STATE_COUNT,
127};
128#endif
129
116void *smem_alloc(unsigned id, unsigned size); 130void *smem_alloc(unsigned id, unsigned size);
117int smsm_change_state(uint32_t clear_mask, uint32_t set_mask); 131int smsm_change_state(enum smsm_state_item item, uint32_t clear_mask, uint32_t set_mask);
118uint32_t smsm_get_state(void); 132uint32_t smsm_get_state(enum smsm_state_item item);
119int smsm_set_sleep_duration(uint32_t delay); 133int smsm_set_sleep_duration(uint32_t delay);
120int smsm_set_interrupt_info(struct smsm_interrupt_info *info); 134int smsm_set_interrupt_info(struct smsm_interrupt_info *info);
121void smsm_print_sleep_info(void); 135void smsm_print_sleep_info(void);