diff options
author | Han Xu <b45815@freescale.com> | 2015-06-18 16:35:37 -0500 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-23 16:57:23 +0300 |
commit | 57cf89988127f2b59b4152f0547e7f09f537f95d (patch) | |
tree | 85be19790ac127e168f782204e35c43b46799e34 /drivers/mtd/nand/gpmi-nand/gpmi-lib.c | |
parent | 9bf7412015e5b2d56561b291552f6908444cbe19 (diff) |
MLK-11133: mtd:gpmi: support runtime pm for gpmi nand
support runtime PM on gpmi nand to save the cost to enable/disable clock
in each NAND IO. The driver also claim high-freq bus when resumed.
Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit: 5b72b3388d1399420f3b49a0ca937ca5792e2d7d)
Diffstat (limited to 'drivers/mtd/nand/gpmi-nand/gpmi-lib.c')
-rw-r--r-- | drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c index 50955c917187..283f875fa47d 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c @@ -21,6 +21,8 @@ #include <linux/delay.h> #include <linux/clk.h> #include <linux/slab.h> +#include <linux/pm_runtime.h> + #include "gpmi-nand.h" #include "gpmi-regs.h" @@ -124,7 +126,7 @@ error: return -ETIMEDOUT; } -static int __gpmi_enable_clk(struct gpmi_nand_data *this, bool v) +int __gpmi_enable_clk(struct gpmi_nand_data *this, bool v) { struct clk *clk; int ret; @@ -151,17 +153,17 @@ err_clk: return ret; } -#define gpmi_enable_clk(x) __gpmi_enable_clk(x, true) -#define gpmi_disable_clk(x) __gpmi_enable_clk(x, false) - int gpmi_init(struct gpmi_nand_data *this) { struct resources *r = &this->resources; int ret; - ret = gpmi_enable_clk(this); - if (ret) + ret = pm_runtime_get_sync(this->dev); + if (ret < 0) { + dev_err(this->dev, "Failed to enable clock\n"); return ret; + } + ret = gpmi_reset_block(r->gpmi_regs, false); if (ret) goto err_out; @@ -194,10 +196,10 @@ int gpmi_init(struct gpmi_nand_data *this) */ writel(BM_GPMI_CTRL1_DECOUPLE_CS, r->gpmi_regs + HW_GPMI_CTRL1_SET); - gpmi_disable_clk(this); - return 0; err_out: - gpmi_disable_clk(this); + pm_runtime_mark_last_busy(this->dev); + pm_runtime_put_autosuspend(this->dev); + return ret; } @@ -269,9 +271,11 @@ int bch_set_geometry(struct gpmi_nand_data *this) page_size = bch_geo->page_size; gf_len = bch_geo->gf_len; - ret = gpmi_enable_clk(this); - if (ret) + ret = pm_runtime_get_sync(this->dev); + if (ret < 0) { + dev_err(this->dev, "Failed to enable clock\n"); return ret; + } /* * Due to erratum #2847 of the MX23, the BCH cannot be soft reset on this @@ -311,10 +315,10 @@ int bch_set_geometry(struct gpmi_nand_data *this) writel(BM_BCH_CTRL_COMPLETE_IRQ_EN, r->bch_regs + HW_BCH_CTRL_SET); - gpmi_disable_clk(this); - return 0; err_out: - gpmi_disable_clk(this); + pm_runtime_mark_last_busy(this->dev); + pm_runtime_put_autosuspend(this->dev); + return ret; } @@ -1007,9 +1011,9 @@ void gpmi_begin(struct gpmi_nand_data *this) int ret; /* Enable the clock. */ - ret = gpmi_enable_clk(this); - if (ret) { - dev_err(this->dev, "We failed in enable the clk\n"); + ret = pm_runtime_get_sync(this->dev); + if (ret < 0) { + dev_err(this->dev, "Failed to enable clock\n"); goto err_out; } @@ -1081,7 +1085,8 @@ err_out: void gpmi_end(struct gpmi_nand_data *this) { - gpmi_disable_clk(this); + pm_runtime_mark_last_busy(this->dev); + pm_runtime_put_autosuspend(this->dev); } /* Clears a BCH interrupt. */ |