static void __stm_device_exit(struct stm_device_state *state) { struct stm_device_config *config = state->config; int i; stm_device_power(state, stm_device_power_off); if (config->pad_config) stm_pad_release(state->pad_state); if (config->exit) config->exit(state); for (i = 0; i < config->sysconfs_num; i++) sysconf_release(state->sysconf_fields[i]); }
static int __stm_device_init(struct stm_device_state *state, struct stm_device_config *config, struct device *dev) { int i; state->dev = dev; state->config = config; state->power_state = stm_device_power_off; for (i = 0; i < config->sysconfs_num; i++) { struct stm_device_sysconf *sysconf = &config->sysconfs[i]; state->sysconf_fields[i] = sysconf_claim(sysconf->regtype, sysconf->regnum, sysconf->lsb, sysconf->msb, dev_name(dev)); if (!state->sysconf_fields[i]) goto sysconf_error; } if (config->init && config->init(state)) goto sysconf_error; if (config->pad_config && (state->pad_state = stm_pad_claim(config->pad_config, dev_name(dev))) == NULL) goto pad_error; stm_device_power(state, stm_device_power_on); return 0; pad_error: if (config->exit) config->exit(state); sysconf_error: for (i--; i>=0; i--) sysconf_release(state->sysconf_fields[i]); return -EBUSY; }
static int emi_hibernation(int resuming) { int idx; int bank, data; static struct emi_pm *emi_saved_data; if (resuming) if (emi_saved_data) { /* restore the previous common value */ for (idx = 0; idx < emi_num_common_cfg-4; ++idx) writel(emi_saved_data->common_cfg[idx], emi_control+EMI_COMMON_CFG(idx)); writel(emi_saved_data->common_cfg[12], emi_control + EMI_BANK_ENABLE); writel(emi_saved_data->common_cfg[13], emi_control + EMI_BANKNUMBER); writel(emi_saved_data->common_cfg[14], emiss_config + EMISS_CONFIG); writel(emi_saved_data->common_cfg[15], emiss_config + EMISS_ARBITER_CONFIG); /* restore the previous bank values */ for (bank = 0; bank < emi_num_bank; ++bank) { writel(emi_saved_data->bank[bank].base_address, emi_control + BANK_BASEADDRESS(bank)); for (data = 0; data < emi_num_bank_cfg; ++data) emi_bank_configure(bank, emi_saved_data->bank[bank].cfg); } kfree(emi_saved_data); emi_saved_data = NULL; emi_clk_enable(); stm_device_power(emi_device_state, stm_device_power_on); } return 0; /* * hibernationg... */ emi_saved_data = kmalloc(sizeof(struct emi_pm), GFP_NOWAIT); if (!emi_saved_data) { printk(KERN_ERR "Unable to freeze the emi registers\n"); return -ENOMEM; } /* save the emi common values */ for (idx = 0; idx < emi_num_common_cfg-4; ++idx) emi_saved_data->common_cfg[idx] = readl(emi_control + EMI_COMMON_CFG(idx)); emi_saved_data->common_cfg[12] = readl(emi_control + EMI_BANK_ENABLE); emi_saved_data->common_cfg[13] = readl(emi_control + EMI_BANKNUMBER); emi_saved_data->common_cfg[14] = readl(emiss_config + EMISS_CONFIG); emi_saved_data->common_cfg[15] = readl(emiss_config + EMISS_ARBITER_CONFIG); /* save the emi bank value */ for (bank = 0; bank < emi_num_bank; ++bank) { emi_saved_data->bank[bank].base_address = readl(emi_control + BANK_BASEADDRESS(bank)); for (data = 0; data < emi_num_bank_cfg; ++data) emi_saved_data->bank[bank].cfg[data] = readl(emi_control + BANK_EMICONFIGDATA(bank, data)); } return 0; }
static int emi_resume(struct device *dev) { emi_clk_enable(); stm_device_power(emi_device_state, stm_device_power_on); return 0; }
static int emi_suspend(struct device *dev) { stm_device_power(emi_device_state, stm_device_power_off); emi_clk_disable(); return 0; }
static int emi_resume(void) { emi_clk_enable(); stm_device_power(emi_device_state, stm_device_power_on); return 0; }