diff options
author | Arve Hjønnevåg <arve@android.com> | 2009-05-21 03:52:36 +0400 |
---|---|---|
committer | Daniel Walker <dwalker@codeaurora.org> | 2010-05-12 20:15:03 +0400 |
commit | 283794100d2b1c1645b2949273aa4be29929812d (patch) | |
tree | 30c371ec32ff2d8767ec3b3fb72c7a0b32c0e513 /arch/arm/mach-msm/smd.c | |
parent | 5b0f5a3f6084397194a8b556cdca572ad8e14f05 (diff) | |
download | linux-283794100d2b1c1645b2949273aa4be29929812d.tar.xz |
[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/arm/mach-msm/smd.c')
-rw-r--r-- | arch/arm/mach-msm/smd.c | 58 |
1 files changed, 28 insertions, 30 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; struct shared_info { int ready; - unsigned state_apps; - unsigned state_modem; + unsigned state; }; -static unsigned dummy_state_apps; -static unsigned dummy_state_modem; +static unsigned dummy_state[SMSM_STATE_COUNT]; static struct shared_info smd_info = { - .state_apps = (unsigned) &dummy_state_apps, - .state_modem = (unsigned) &dummy_state_modem, + .state = (unsigned) &dummy_state, }; module_param_named(debug_mask, msm_smd_debug_mask, @@ -115,9 +112,14 @@ static void handle_modem_crash(void) extern int (*msm_check_for_modem_crash)(void); +uint32_t raw_smsm_get_state(enum smsm_state_item item) +{ + return readl(smd_info.state + item * 4); +} + static int check_for_modem_crash(void) { - if (readl(smd_info.state_modem) & SMSM_RESET) { + if (raw_smsm_get_state(SMSM_STATE_MODEM) & SMSM_RESET) { handle_modem_crash(); return -1; } @@ -978,8 +980,8 @@ static irqreturn_t smsm_irq_handler(int irq, void *data) spin_lock_irqsave(&smem_lock, flags); - apps = readl(smd_info.state_apps); - modm = readl(smd_info.state_modem); + apps = raw_smsm_get_state(SMSM_STATE_APPS); + modm = raw_smsm_get_state(SMSM_STATE_MODEM); if (msm_smd_debug_mask & MSM_SMSM_DEBUG) pr_info("<SM %08x %08x>\n", apps, modm); @@ -992,24 +994,26 @@ static irqreturn_t smsm_irq_handler(int irq, void *data) return IRQ_HANDLED; } -int smsm_change_state(uint32_t clear_mask, uint32_t set_mask) +int smsm_change_state(enum smsm_state_item item, + uint32_t clear_mask, uint32_t set_mask) { unsigned long flags; unsigned state; + unsigned addr = smd_info.state + item * 4; if (!smd_info.ready) return -EIO; spin_lock_irqsave(&smem_lock, flags); - if (readl(smd_info.state_modem) & SMSM_RESET) + if (raw_smsm_get_state(SMSM_STATE_MODEM) & SMSM_RESET) handle_modem_crash(); - state = (readl(smd_info.state_apps) & ~clear_mask) | set_mask; - writel(state, smd_info.state_apps); + state = (readl(addr) & ~clear_mask) | set_mask; + writel(state, addr); if (msm_smd_debug_mask & MSM_SMSM_DEBUG) - pr_info("smsm_change_state %x\n", state); + pr_info("smsm_change_state %d %x\n", item, state); notify_other_smsm(); spin_unlock_irqrestore(&smem_lock, flags); @@ -1017,16 +1021,16 @@ int smsm_change_state(uint32_t clear_mask, uint32_t set_mask) return 0; } -uint32_t smsm_get_state(void) +uint32_t smsm_get_state(enum smsm_state_item item) { unsigned long flags; uint32_t rv; spin_lock_irqsave(&smem_lock, flags); - rv = readl(smd_info.state_modem); + rv = readl(smd_info.state + item * 4); - if (rv & SMSM_RESET) + if (item == SMSM_STATE_MODEM && (rv & SMSM_RESET)) handle_modem_crash(); spin_unlock_irqrestore(&smem_lock, flags); @@ -1145,14 +1149,8 @@ int smd_core_init(void) unsigned size; void *state; state = smem_item(SMEM_SMSM_SHARED_STATE, &size); - if (size == SMSM_V1_SIZE) { - smd_info.state_apps = state + SMSM_V1_STATE_APPS; - smd_info.state_modem = state + SMSM_V1_STATE_MODEM; - break; - } - if (size == SMSM_V2_SIZE) { - smd_info.state_apps = state + SMSM_V2_STATE_APPS; - smd_info.state_modem = state + SMSM_V2_STATE_MODEM; + if (size == SMSM_V1_SIZE || size == SMSM_V2_SIZE) { + smd_info.state = (unsigned)state; break; } } @@ -1181,8 +1179,8 @@ int smd_core_init(void) do_smd_probe(); /* indicate that we're up and running */ - writel(SMSM_INIT | SMSM_SMDINIT | SMSM_RPCINIT, smd_info.state_apps); - notify_other_smsm(); + smsm_change_state(SMSM_STATE_APPS, + ~0, SMSM_INIT | SMSM_SMDINIT | SMSM_RPCINIT); pr_info("smd_core_init() done\n"); @@ -1227,13 +1225,13 @@ static int debug_read_stat(char *buf, int max) msg = smem_find(ID_DIAG_ERR_MSG, SZ_DIAG_ERR_MSG); - if (readl(smd_info.state_modem) & SMSM_RESET) + if (raw_smsm_get_state(SMSM_STATE_MODEM) & SMSM_RESET) i += scnprintf(buf + i, max - i, "smsm: ARM9 HAS CRASHED\n"); i += scnprintf(buf + i, max - i, "smsm: a9: %08x a11: %08x\n", - readl(smd_info.state_modem), - readl(smd_info.state_apps)); + raw_smsm_get_state(SMSM_STATE_MODEM), + raw_smsm_get_state(SMSM_STATE_APPS)); if (msg) { msg[SZ_DIAG_ERR_MSG - 1] = 0; |