* [PATCH v1] mtk-nor: update dt bindings and add suspend/resume support @ 2017-09-21 12:45 Guochun Mao [not found] ` <1505997906-30921-1-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> 2017-09-21 12:45 ` [PATCH v1 2/2] mtd: mtk-nor: add suspend/resume support Guochun Mao 0 siblings, 2 replies; 8+ messages in thread From: Guochun Mao @ 2017-09-21 12:45 UTC (permalink / raw) To: Cyrille Pitchen, Matthias Brugger, Rob Herring, Boris Brezillon Cc: Brian Norris, Marek Vasut, David Woodhouse, Richard Weinberger, Mark Rutland, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA These patches affect mtk-quadspi module in mtk/spi-nor. Add new compatible strings in dt bindings, add suspend/resume support in mtk-quadspi driver. Guochun Mao (2): dt-bindings: mtd: add new compatible strings and improve description mtd: mtk-nor: add suspend/resume support .../devicetree/bindings/mtd/mtk-quadspi.txt | 15 +++-- drivers/mtd/spi-nor/mtk-quadspi.c | 70 ++++++++++++++++++---- 2 files changed, 67 insertions(+), 18 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1505997906-30921-1-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>]
* [PATCH v1 1/2] dt-bindings: mtd: add new compatible strings and improve description [not found] ` <1505997906-30921-1-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> @ 2017-09-21 12:45 ` Guochun Mao 2017-10-11 3:15 ` Guochun Mao [not found] ` <1505997906-30921-2-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> 0 siblings, 2 replies; 8+ messages in thread From: Guochun Mao @ 2017-09-21 12:45 UTC (permalink / raw) To: Cyrille Pitchen, Matthias Brugger, Rob Herring, Boris Brezillon Cc: Brian Norris, Marek Vasut, David Woodhouse, Richard Weinberger, Mark Rutland, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Guochun Mao Add "mediatak,mt2712-nor" and "mediatek,mt7622-nor" for nor flash node's compatible strings. Explicate the fallback compatible. Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Signed-off-by: Guochun Mao <guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> --- .../devicetree/bindings/mtd/mtk-quadspi.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt index 840f940..56d3668 100644 --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt @@ -1,13 +1,16 @@ * Serial NOR flash controller for MTK MT81xx (and similar) Required properties: -- compatible: The possible values are: - "mediatek,mt2701-nor" - "mediatek,mt7623-nor" +- compatible: For mt8173, compatible should be "mediatek,mt8173-nor", + and it's the fallback compatible for other Soc. + For every other SoC, should contain both the SoC-specific compatible + string and "mediatek,mt8173-nor". + The possible values are: + "mediatek,mt2701-nor", "mediatek,mt8173-nor" + "mediatek,mt2712-nor", "mediatek,mt8173-nor" + "mediatek,mt7622-nor", "mediatek,mt8173-nor" + "mediatek,mt7623-nor", "mediatek,mt8173-nor" "mediatek,mt8173-nor" - For mt8173, compatible should be "mediatek,mt8173-nor". - For every other SoC, should contain both the SoC-specific compatible string - and "mediatek,mt8173-nor". - reg: physical base address and length of the controller's register - clocks: the phandle of the clocks needed by the nor controller - clock-names: the names of the clocks -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/2] dt-bindings: mtd: add new compatible strings and improve description 2017-09-21 12:45 ` [PATCH v1 1/2] dt-bindings: mtd: add new compatible strings and improve description Guochun Mao @ 2017-10-11 3:15 ` Guochun Mao 2017-10-22 10:30 ` Guochun Mao [not found] ` <1505997906-30921-2-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> 1 sibling, 1 reply; 8+ messages in thread From: Guochun Mao @ 2017-10-11 3:15 UTC (permalink / raw) To: Cyrille Pitchen, Marek Vasut, Matthias Brugger Cc: Rob Herring, Boris Brezillon, Brian Norris, David Woodhouse, Richard Weinberger, Mark Rutland, linux-mtd, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel gentle ping... On Thu, 2017-09-21 at 20:45 +0800, Guochun Mao wrote: > Add "mediatak,mt2712-nor" and "mediatek,mt7622-nor" > for nor flash node's compatible strings. > Explicate the fallback compatible. > > Acked-by: Rob Herring <robh@kernel.org> > Signed-off-by: Guochun Mao <guochun.mao@mediatek.com> > --- > .../devicetree/bindings/mtd/mtk-quadspi.txt | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > index 840f940..56d3668 100644 > --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > @@ -1,13 +1,16 @@ > * Serial NOR flash controller for MTK MT81xx (and similar) > > Required properties: > -- compatible: The possible values are: > - "mediatek,mt2701-nor" > - "mediatek,mt7623-nor" > +- compatible: For mt8173, compatible should be "mediatek,mt8173-nor", > + and it's the fallback compatible for other Soc. > + For every other SoC, should contain both the SoC-specific compatible > + string and "mediatek,mt8173-nor". > + The possible values are: > + "mediatek,mt2701-nor", "mediatek,mt8173-nor" > + "mediatek,mt2712-nor", "mediatek,mt8173-nor" > + "mediatek,mt7622-nor", "mediatek,mt8173-nor" > + "mediatek,mt7623-nor", "mediatek,mt8173-nor" > "mediatek,mt8173-nor" > - For mt8173, compatible should be "mediatek,mt8173-nor". > - For every other SoC, should contain both the SoC-specific compatible string > - and "mediatek,mt8173-nor". > - reg: physical base address and length of the controller's register > - clocks: the phandle of the clocks needed by the nor controller > - clock-names: the names of the clocks ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 1/2] dt-bindings: mtd: add new compatible strings and improve description 2017-10-11 3:15 ` Guochun Mao @ 2017-10-22 10:30 ` Guochun Mao 0 siblings, 0 replies; 8+ messages in thread From: Guochun Mao @ 2017-10-22 10:30 UTC (permalink / raw) To: Cyrille Pitchen, Marek Vasut Cc: Matthias Brugger, Rob Herring, Boris Brezillon, Brian Norris, David Woodhouse, Richard Weinberger, Mark Rutland, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA Hi Cyrille, Marek, Gentle ping... On Wed, 2017-10-11 at 11:15 +0800, Guochun Mao wrote: > gentle ping... > > On Thu, 2017-09-21 at 20:45 +0800, Guochun Mao wrote: > > Add "mediatak,mt2712-nor" and "mediatek,mt7622-nor" > > for nor flash node's compatible strings. > > Explicate the fallback compatible. > > > > Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > > Signed-off-by: Guochun Mao <guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> > > --- > > .../devicetree/bindings/mtd/mtk-quadspi.txt | 15 +++++++++------ > > 1 file changed, 9 insertions(+), 6 deletions(-) > > > > diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > > index 840f940..56d3668 100644 > > --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > > +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > > @@ -1,13 +1,16 @@ > > * Serial NOR flash controller for MTK MT81xx (and similar) > > > > Required properties: > > -- compatible: The possible values are: > > - "mediatek,mt2701-nor" > > - "mediatek,mt7623-nor" > > +- compatible: For mt8173, compatible should be "mediatek,mt8173-nor", > > + and it's the fallback compatible for other Soc. > > + For every other SoC, should contain both the SoC-specific compatible > > + string and "mediatek,mt8173-nor". > > + The possible values are: > > + "mediatek,mt2701-nor", "mediatek,mt8173-nor" > > + "mediatek,mt2712-nor", "mediatek,mt8173-nor" > > + "mediatek,mt7622-nor", "mediatek,mt8173-nor" > > + "mediatek,mt7623-nor", "mediatek,mt8173-nor" > > "mediatek,mt8173-nor" > > - For mt8173, compatible should be "mediatek,mt8173-nor". > > - For every other SoC, should contain both the SoC-specific compatible string > > - and "mediatek,mt8173-nor". > > - reg: physical base address and length of the controller's register > > - clocks: the phandle of the clocks needed by the nor controller > > - clock-names: the names of the clocks > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1505997906-30921-2-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>]
* Re: [PATCH v1 1/2] dt-bindings: mtd: add new compatible strings and improve description [not found] ` <1505997906-30921-2-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> @ 2017-10-24 22:02 ` Cyrille Pitchen 0 siblings, 0 replies; 8+ messages in thread From: Cyrille Pitchen @ 2017-10-24 22:02 UTC (permalink / raw) To: Guochun Mao, Matthias Brugger, Rob Herring, Boris Brezillon Cc: Brian Norris, Marek Vasut, David Woodhouse, Richard Weinberger, Mark Rutland, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA Le 21/09/2017 à 14:45, Guochun Mao a écrit : > Add "mediatak,mt2712-nor" and "mediatek,mt7622-nor" > for nor flash node's compatible strings. > Explicate the fallback compatible. > > Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> > Signed-off-by: Guochun Mao <guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> Applied to the spi-nor/next branch of l2-mtd Thanks! > --- > .../devicetree/bindings/mtd/mtk-quadspi.txt | 15 +++++++++------ > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > index 840f940..56d3668 100644 > --- a/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > +++ b/Documentation/devicetree/bindings/mtd/mtk-quadspi.txt > @@ -1,13 +1,16 @@ > * Serial NOR flash controller for MTK MT81xx (and similar) > > Required properties: > -- compatible: The possible values are: > - "mediatek,mt2701-nor" > - "mediatek,mt7623-nor" > +- compatible: For mt8173, compatible should be "mediatek,mt8173-nor", > + and it's the fallback compatible for other Soc. > + For every other SoC, should contain both the SoC-specific compatible > + string and "mediatek,mt8173-nor". > + The possible values are: > + "mediatek,mt2701-nor", "mediatek,mt8173-nor" > + "mediatek,mt2712-nor", "mediatek,mt8173-nor" > + "mediatek,mt7622-nor", "mediatek,mt8173-nor" > + "mediatek,mt7623-nor", "mediatek,mt8173-nor" > "mediatek,mt8173-nor" > - For mt8173, compatible should be "mediatek,mt8173-nor". > - For every other SoC, should contain both the SoC-specific compatible string > - and "mediatek,mt8173-nor". > - reg: physical base address and length of the controller's register > - clocks: the phandle of the clocks needed by the nor controller > - clock-names: the names of the clocks > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 2/2] mtd: mtk-nor: add suspend/resume support 2017-09-21 12:45 [PATCH v1] mtk-nor: update dt bindings and add suspend/resume support Guochun Mao [not found] ` <1505997906-30921-1-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> @ 2017-09-21 12:45 ` Guochun Mao [not found] ` <1505997906-30921-3-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> 1 sibling, 1 reply; 8+ messages in thread From: Guochun Mao @ 2017-09-21 12:45 UTC (permalink / raw) To: Cyrille Pitchen, Matthias Brugger, Rob Herring, Boris Brezillon Cc: Brian Norris, Marek Vasut, David Woodhouse, Richard Weinberger, Mark Rutland, linux-mtd, devicetree, linux-arm-kernel, linux-mediatek, linux-kernel, Guochun Mao Abstract functions of clock setting, to avoid duplicated code, these functions been used in new feature. Implement suspend/resume functions. Signed-off-by: Guochun Mao <guochun.mao@mediatek.com> --- drivers/mtd/spi-nor/mtk-quadspi.c | 70 ++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c index c258c7a..abe455c 100644 --- a/drivers/mtd/spi-nor/mtk-quadspi.c +++ b/drivers/mtd/spi-nor/mtk-quadspi.c @@ -404,6 +404,29 @@ static int mt8173_nor_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, return ret; } +static void mt8173_nor_disable_clk(struct mt8173_nor *mt8173_nor) +{ + clk_disable_unprepare(mt8173_nor->spi_clk); + clk_disable_unprepare(mt8173_nor->nor_clk); +} + +static int mt8173_nor_enable_clk(struct mt8173_nor *mt8173_nor) +{ + int ret; + + ret = clk_prepare_enable(mt8173_nor->spi_clk); + if (ret) + return ret; + + ret = clk_prepare_enable(mt8173_nor->nor_clk); + if (ret) { + clk_disable_unprepare(mt8173_nor->spi_clk); + return ret; + } + + return 0; +} + static int mtk_nor_init(struct mt8173_nor *mt8173_nor, struct device_node *flash_node) { @@ -468,15 +491,11 @@ static int mtk_nor_drv_probe(struct platform_device *pdev) return PTR_ERR(mt8173_nor->nor_clk); mt8173_nor->dev = &pdev->dev; - ret = clk_prepare_enable(mt8173_nor->spi_clk); + + ret = mt8173_nor_enable_clk(mt8173_nor); if (ret) return ret; - ret = clk_prepare_enable(mt8173_nor->nor_clk); - if (ret) { - clk_disable_unprepare(mt8173_nor->spi_clk); - return ret; - } /* only support one attached flash */ flash_np = of_get_next_available_child(pdev->dev.of_node, NULL); if (!flash_np) { @@ -487,10 +506,9 @@ static int mtk_nor_drv_probe(struct platform_device *pdev) ret = mtk_nor_init(mt8173_nor, flash_np); nor_free: - if (ret) { - clk_disable_unprepare(mt8173_nor->spi_clk); - clk_disable_unprepare(mt8173_nor->nor_clk); - } + if (ret) + mt8173_nor_disable_clk(mt8173_nor); + return ret; } @@ -498,11 +516,38 @@ static int mtk_nor_drv_remove(struct platform_device *pdev) { struct mt8173_nor *mt8173_nor = platform_get_drvdata(pdev); - clk_disable_unprepare(mt8173_nor->spi_clk); - clk_disable_unprepare(mt8173_nor->nor_clk); + mt8173_nor_disable_clk(mt8173_nor); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int mtk_nor_suspend(struct device *dev) +{ + struct mt8173_nor *mt8173_nor = dev_get_drvdata(dev); + + mt8173_nor_disable_clk(mt8173_nor); + return 0; } +static int mtk_nor_resume(struct device *dev) +{ + struct mt8173_nor *mt8173_nor = dev_get_drvdata(dev); + + return mt8173_nor_enable_clk(mt8173_nor); +} + +static const struct dev_pm_ops mtk_nor_dev_pm_ops = { + .suspend = mtk_nor_suspend, + .resume = mtk_nor_resume, +}; + +#define MTK_NOR_DEV_PM_OPS (&mtk_nor_dev_pm_ops) +#else +#define MTK_NOR_DEV_PM_OPS NULL +#endif + static const struct of_device_id mtk_nor_of_ids[] = { { .compatible = "mediatek,mt8173-nor"}, { /* sentinel */ } @@ -514,6 +559,7 @@ static int mtk_nor_drv_remove(struct platform_device *pdev) .remove = mtk_nor_drv_remove, .driver = { .name = "mtk-nor", + .pm = MTK_NOR_DEV_PM_OPS, .of_match_table = mtk_nor_of_ids, }, }; -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
[parent not found: <1505997906-30921-3-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>]
* Re: [PATCH v1 2/2] mtd: mtk-nor: add suspend/resume support [not found] ` <1505997906-30921-3-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> @ 2017-10-11 3:16 ` Guochun Mao 2017-10-24 22:03 ` Cyrille Pitchen 1 sibling, 0 replies; 8+ messages in thread From: Guochun Mao @ 2017-10-11 3:16 UTC (permalink / raw) To: Cyrille Pitchen, Marek Vasut, Matthias Brugger Cc: Rob Herring, Boris Brezillon, Brian Norris, David Woodhouse, Richard Weinberger, Mark Rutland, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, devicetree-u79uwXL29TY76Z2rM5mHXA, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-kernel-u79uwXL29TY76Z2rM5mHXA gentle ping... On Thu, 2017-09-21 at 20:45 +0800, Guochun Mao wrote: > Abstract functions of clock setting, to avoid duplicated code, > these functions been used in new feature. > Implement suspend/resume functions. > > Signed-off-by: Guochun Mao <guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> > --- > drivers/mtd/spi-nor/mtk-quadspi.c | 70 ++++++++++++++++++++++++++++++------- > 1 file changed, 58 insertions(+), 12 deletions(-) > > diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c > index c258c7a..abe455c 100644 > --- a/drivers/mtd/spi-nor/mtk-quadspi.c > +++ b/drivers/mtd/spi-nor/mtk-quadspi.c > @@ -404,6 +404,29 @@ static int mt8173_nor_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, > return ret; > } > > +static void mt8173_nor_disable_clk(struct mt8173_nor *mt8173_nor) > +{ > + clk_disable_unprepare(mt8173_nor->spi_clk); > + clk_disable_unprepare(mt8173_nor->nor_clk); > +} > + > +static int mt8173_nor_enable_clk(struct mt8173_nor *mt8173_nor) > +{ > + int ret; > + > + ret = clk_prepare_enable(mt8173_nor->spi_clk); > + if (ret) > + return ret; > + > + ret = clk_prepare_enable(mt8173_nor->nor_clk); > + if (ret) { > + clk_disable_unprepare(mt8173_nor->spi_clk); > + return ret; > + } > + > + return 0; > +} > + > static int mtk_nor_init(struct mt8173_nor *mt8173_nor, > struct device_node *flash_node) > { > @@ -468,15 +491,11 @@ static int mtk_nor_drv_probe(struct platform_device *pdev) > return PTR_ERR(mt8173_nor->nor_clk); > > mt8173_nor->dev = &pdev->dev; > - ret = clk_prepare_enable(mt8173_nor->spi_clk); > + > + ret = mt8173_nor_enable_clk(mt8173_nor); > if (ret) > return ret; > > - ret = clk_prepare_enable(mt8173_nor->nor_clk); > - if (ret) { > - clk_disable_unprepare(mt8173_nor->spi_clk); > - return ret; > - } > /* only support one attached flash */ > flash_np = of_get_next_available_child(pdev->dev.of_node, NULL); > if (!flash_np) { > @@ -487,10 +506,9 @@ static int mtk_nor_drv_probe(struct platform_device *pdev) > ret = mtk_nor_init(mt8173_nor, flash_np); > > nor_free: > - if (ret) { > - clk_disable_unprepare(mt8173_nor->spi_clk); > - clk_disable_unprepare(mt8173_nor->nor_clk); > - } > + if (ret) > + mt8173_nor_disable_clk(mt8173_nor); > + > return ret; > } > > @@ -498,11 +516,38 @@ static int mtk_nor_drv_remove(struct platform_device *pdev) > { > struct mt8173_nor *mt8173_nor = platform_get_drvdata(pdev); > > - clk_disable_unprepare(mt8173_nor->spi_clk); > - clk_disable_unprepare(mt8173_nor->nor_clk); > + mt8173_nor_disable_clk(mt8173_nor); > + > + return 0; > +} > + > +#ifdef CONFIG_PM_SLEEP > +static int mtk_nor_suspend(struct device *dev) > +{ > + struct mt8173_nor *mt8173_nor = dev_get_drvdata(dev); > + > + mt8173_nor_disable_clk(mt8173_nor); > + > return 0; > } > > +static int mtk_nor_resume(struct device *dev) > +{ > + struct mt8173_nor *mt8173_nor = dev_get_drvdata(dev); > + > + return mt8173_nor_enable_clk(mt8173_nor); > +} > + > +static const struct dev_pm_ops mtk_nor_dev_pm_ops = { > + .suspend = mtk_nor_suspend, > + .resume = mtk_nor_resume, > +}; > + > +#define MTK_NOR_DEV_PM_OPS (&mtk_nor_dev_pm_ops) > +#else > +#define MTK_NOR_DEV_PM_OPS NULL > +#endif > + > static const struct of_device_id mtk_nor_of_ids[] = { > { .compatible = "mediatek,mt8173-nor"}, > { /* sentinel */ } > @@ -514,6 +559,7 @@ static int mtk_nor_drv_remove(struct platform_device *pdev) > .remove = mtk_nor_drv_remove, > .driver = { > .name = "mtk-nor", > + .pm = MTK_NOR_DEV_PM_OPS, > .of_match_table = mtk_nor_of_ids, > }, > }; -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 2/2] mtd: mtk-nor: add suspend/resume support [not found] ` <1505997906-30921-3-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> 2017-10-11 3:16 ` Guochun Mao @ 2017-10-24 22:03 ` Cyrille Pitchen 1 sibling, 0 replies; 8+ messages in thread From: Cyrille Pitchen @ 2017-10-24 22:03 UTC (permalink / raw) To: Guochun Mao, Matthias Brugger, Rob Herring, Boris Brezillon Cc: Mark Rutland, devicetree-u79uwXL29TY76Z2rM5mHXA, Richard Weinberger, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Marek Vasut, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Brian Norris, David Woodhouse, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r Le 21/09/2017 à 14:45, Guochun Mao a écrit : > Abstract functions of clock setting, to avoid duplicated code, > these functions been used in new feature. > Implement suspend/resume functions. > > Signed-off-by: Guochun Mao <guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> Applied to the spi-nor/next branch of l2-mtd Thanks! > --- > drivers/mtd/spi-nor/mtk-quadspi.c | 70 ++++++++++++++++++++++++++++++------- > 1 file changed, 58 insertions(+), 12 deletions(-) > > diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c > index c258c7a..abe455c 100644 > --- a/drivers/mtd/spi-nor/mtk-quadspi.c > +++ b/drivers/mtd/spi-nor/mtk-quadspi.c > @@ -404,6 +404,29 @@ static int mt8173_nor_write_reg(struct spi_nor *nor, u8 opcode, u8 *buf, > return ret; > } > > +static void mt8173_nor_disable_clk(struct mt8173_nor *mt8173_nor) > +{ > + clk_disable_unprepare(mt8173_nor->spi_clk); > + clk_disable_unprepare(mt8173_nor->nor_clk); > +} > + > +static int mt8173_nor_enable_clk(struct mt8173_nor *mt8173_nor) > +{ > + int ret; > + > + ret = clk_prepare_enable(mt8173_nor->spi_clk); > + if (ret) > + return ret; > + > + ret = clk_prepare_enable(mt8173_nor->nor_clk); > + if (ret) { > + clk_disable_unprepare(mt8173_nor->spi_clk); > + return ret; > + } > + > + return 0; > +} > + > static int mtk_nor_init(struct mt8173_nor *mt8173_nor, > struct device_node *flash_node) > { > @@ -468,15 +491,11 @@ static int mtk_nor_drv_probe(struct platform_device *pdev) > return PTR_ERR(mt8173_nor->nor_clk); > > mt8173_nor->dev = &pdev->dev; > - ret = clk_prepare_enable(mt8173_nor->spi_clk); > + > + ret = mt8173_nor_enable_clk(mt8173_nor); > if (ret) > return ret; > > - ret = clk_prepare_enable(mt8173_nor->nor_clk); > - if (ret) { > - clk_disable_unprepare(mt8173_nor->spi_clk); > - return ret; > - } > /* only support one attached flash */ > flash_np = of_get_next_available_child(pdev->dev.of_node, NULL); > if (!flash_np) { > @@ -487,10 +506,9 @@ static int mtk_nor_drv_probe(struct platform_device *pdev) > ret = mtk_nor_init(mt8173_nor, flash_np); > > nor_free: > - if (ret) { > - clk_disable_unprepare(mt8173_nor->spi_clk); > - clk_disable_unprepare(mt8173_nor->nor_clk); > - } > + if (ret) > + mt8173_nor_disable_clk(mt8173_nor); > + > return ret; > } > > @@ -498,11 +516,38 @@ static int mtk_nor_drv_remove(struct platform_device *pdev) > { > struct mt8173_nor *mt8173_nor = platform_get_drvdata(pdev); > > - clk_disable_unprepare(mt8173_nor->spi_clk); > - clk_disable_unprepare(mt8173_nor->nor_clk); > + mt8173_nor_disable_clk(mt8173_nor); > + > + return 0; > +} > + > +#ifdef CONFIG_PM_SLEEP > +static int mtk_nor_suspend(struct device *dev) > +{ > + struct mt8173_nor *mt8173_nor = dev_get_drvdata(dev); > + > + mt8173_nor_disable_clk(mt8173_nor); > + > return 0; > } > > +static int mtk_nor_resume(struct device *dev) > +{ > + struct mt8173_nor *mt8173_nor = dev_get_drvdata(dev); > + > + return mt8173_nor_enable_clk(mt8173_nor); > +} > + > +static const struct dev_pm_ops mtk_nor_dev_pm_ops = { > + .suspend = mtk_nor_suspend, > + .resume = mtk_nor_resume, > +}; > + > +#define MTK_NOR_DEV_PM_OPS (&mtk_nor_dev_pm_ops) > +#else > +#define MTK_NOR_DEV_PM_OPS NULL > +#endif > + > static const struct of_device_id mtk_nor_of_ids[] = { > { .compatible = "mediatek,mt8173-nor"}, > { /* sentinel */ } > @@ -514,6 +559,7 @@ static int mtk_nor_drv_remove(struct platform_device *pdev) > .remove = mtk_nor_drv_remove, > .driver = { > .name = "mtk-nor", > + .pm = MTK_NOR_DEV_PM_OPS, > .of_match_table = mtk_nor_of_ids, > }, > }; > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-10-24 22:03 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-09-21 12:45 [PATCH v1] mtk-nor: update dt bindings and add suspend/resume support Guochun Mao [not found] ` <1505997906-30921-1-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> 2017-09-21 12:45 ` [PATCH v1 1/2] dt-bindings: mtd: add new compatible strings and improve description Guochun Mao 2017-10-11 3:15 ` Guochun Mao 2017-10-22 10:30 ` Guochun Mao [not found] ` <1505997906-30921-2-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> 2017-10-24 22:02 ` Cyrille Pitchen 2017-09-21 12:45 ` [PATCH v1 2/2] mtd: mtk-nor: add suspend/resume support Guochun Mao [not found] ` <1505997906-30921-3-git-send-email-guochun.mao-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org> 2017-10-11 3:16 ` Guochun Mao 2017-10-24 22:03 ` Cyrille Pitchen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).