These patches are first version of Mediatek auxadc driver for mt7622.
These patches include three patches.
The First patch adds mt7622 compatible node in binding document.
The second patch adds support for suspend/resume.
The last patch adds mt7622 compatible node in auxadc driver.
Zhiyong Tao (3):
dt-bindings: adc: mt7622: add binding document
iio: adc: mt7622: add support for suspend/resume.
iio: adc: mt7622: Add compatible node for mt7622.
.../devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 +
drivers/iio/adc/mt6577_auxadc.c | 38 ++++++++++++++++++++
2 files changed, 39 insertions(+)
--
1.7.9.5
The commit adds mt7622 compatible node in binding document.
Signed-off-by: Zhiyong Tao <[email protected]>
---
.../devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
index 68c45cb..e6aa30a 100644
--- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
@@ -13,6 +13,7 @@ Required properties:
- compatible: Should be one of:
- "mediatek,mt2701-auxadc": For MT2701 family of SoCs
- "mediatek,mt8173-auxadc": For MT8173 family of SoCs
+ - "mediatek,mt7622-auxadc": For MT7622 family of SoCs
- reg: Address range of the AUXADC unit.
- clocks: Should contain a clock specifier for each entry in clock-names
- clock-names: Should contain "main".
--
1.7.9.5
This patch supports auxadc suspend/resume flow.
Disable auxadc clk and power in suspend function.
Enable axuadc clk and power in resume function.
Signed-off-by: Zhiyong Tao <[email protected]>
---
drivers/iio/adc/mt6577_auxadc.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
index 2d104c8..2dd7c74 100644
--- a/drivers/iio/adc/mt6577_auxadc.c
+++ b/drivers/iio/adc/mt6577_auxadc.c
@@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev,
.read_raw = &mt6577_auxadc_read_raw,
};
+static int mt6577_auxadc_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
+ int ret;
+
+ ret = clk_prepare_enable(adc_dev->adc_clk);
+ if (ret) {
+ pr_err("failed to enable auxadc clock\n");
+ return ret;
+ }
+
+ mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
+ MT6577_AUXADC_PDN_EN, 0);
+ mdelay(MT6577_AUXADC_POWER_READY_MS);
+
+ return 0;
+}
+
+static int mt6577_auxadc_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(dev);
+ struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
+
+ mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
+ 0, MT6577_AUXADC_PDN_EN);
+ clk_disable_unprepare(adc_dev->adc_clk);
+
+ return 0;
+}
+
static int mt6577_auxadc_probe(struct platform_device *pdev)
{
struct mt6577_auxadc_device *adc_dev;
@@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
return 0;
}
+static const struct dev_pm_ops mt6577_auxadc_pm_ops = {
+ .suspend = mt6577_auxadc_suspend,
+ .resume = mt6577_auxadc_resume,
+};
+
static const struct of_device_id mt6577_auxadc_of_match[] = {
{ .compatible = "mediatek,mt2701-auxadc", },
{ .compatible = "mediatek,mt8173-auxadc", },
@@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
.driver = {
.name = "mt6577-auxadc",
.of_match_table = mt6577_auxadc_of_match,
+ .pm = &mt6577_auxadc_pm_ops,
},
.probe = mt6577_auxadc_probe,
.remove = mt6577_auxadc_remove,
--
1.7.9.5
This commit adds mt7622 compatible node.
Signed-off-by: Zhiyong Tao <[email protected]>
---
drivers/iio/adc/mt6577_auxadc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
index 2dd7c74..4a2cd9e 100644
--- a/drivers/iio/adc/mt6577_auxadc.c
+++ b/drivers/iio/adc/mt6577_auxadc.c
@@ -308,6 +308,7 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
static const struct of_device_id mt6577_auxadc_of_match[] = {
{ .compatible = "mediatek,mt2701-auxadc", },
{ .compatible = "mediatek,mt8173-auxadc", },
+ { .compatible = "mediatek,mt7622-auxadc", },
{ }
};
MODULE_DEVICE_TABLE(of, mt6577_auxadc_of_match);
--
1.7.9.5
On Thu, 22 Jun 2017 13:44:33 +0800
Zhiyong Tao <[email protected]> wrote:
> This patch supports auxadc suspend/resume flow.
> Disable auxadc clk and power in suspend function.
> Enable axuadc clk and power in resume function.
>
> Signed-off-by: Zhiyong Tao <[email protected]>
Worth handling the cases where power management is not configured into the
kernel properly.
So a few minor suggestions. Otherwise looks good to me.
> ---
> drivers/iio/adc/mt6577_auxadc.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
> index 2d104c8..2dd7c74 100644
> --- a/drivers/iio/adc/mt6577_auxadc.c
> +++ b/drivers/iio/adc/mt6577_auxadc.c
> @@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev,
> .read_raw = &mt6577_auxadc_read_raw,
> };
>
> +static int mt6577_auxadc_resume(struct device *dev)
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
> + int ret;
> +
> + ret = clk_prepare_enable(adc_dev->adc_clk);
> + if (ret) {
> + pr_err("failed to enable auxadc clock\n");
> + return ret;
> + }
> +
> + mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
> + MT6577_AUXADC_PDN_EN, 0);
> + mdelay(MT6577_AUXADC_POWER_READY_MS);
> +
> + return 0;
> +}
> +
> +static int mt6577_auxadc_suspend(struct device *dev)
Mark these __maybe_unused for the CONFIG_PM but not CONFIG_PM_SLEEP case.
> +{
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
> +
> + mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
> + 0, MT6577_AUXADC_PDN_EN);
> + clk_disable_unprepare(adc_dev->adc_clk);
> +
> + return 0;
> +}
> +
> static int mt6577_auxadc_probe(struct platform_device *pdev)
> {
> struct mt6577_auxadc_device *adc_dev;
> @@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
> return 0;
> }
>
> +static const struct dev_pm_ops mt6577_auxadc_pm_ops = {
> + .suspend = mt6577_auxadc_suspend,
> + .resume = mt6577_auxadc_resume,
> +};
> +
Use the SIMPLE_SYSTEM_PM_OPS macro to make these assignments magically go away
if PM_CONFIG_SLEEP is not defined.
> static const struct of_device_id mt6577_auxadc_of_match[] = {
> { .compatible = "mediatek,mt2701-auxadc", },
> { .compatible = "mediatek,mt8173-auxadc", },
> @@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
> .driver = {
> .name = "mt6577-auxadc",
> .of_match_table = mt6577_auxadc_of_match,
> + .pm = &mt6577_auxadc_pm_ops,
> },
> .probe = mt6577_auxadc_probe,
> .remove = mt6577_auxadc_remove,
On Thu, 22 Jun 2017 13:44:34 +0800
Zhiyong Tao <[email protected]> wrote:
> This commit adds mt7622 compatible node.
>
> Signed-off-by: Zhiyong Tao <[email protected]>
> ---
> drivers/iio/adc/mt6577_auxadc.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
> index 2dd7c74..4a2cd9e 100644
> --- a/drivers/iio/adc/mt6577_auxadc.c
> +++ b/drivers/iio/adc/mt6577_auxadc.c
> @@ -308,6 +308,7 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
> static const struct of_device_id mt6577_auxadc_of_match[] = {
> { .compatible = "mediatek,mt2701-auxadc", },
> { .compatible = "mediatek,mt8173-auxadc", },
> + { .compatible = "mediatek,mt7622-auxadc", },
Keep them in numeric order perhaps?
Might become a worthwhile step if this logic gets used for lot more parts in future!
Jonathan
> { }
> };
> MODULE_DEVICE_TABLE(of, mt6577_auxadc_of_match);
On Sat, 2017-06-24 at 21:02 +0100, Jonathan Cameron wrote:
> On Thu, 22 Jun 2017 13:44:34 +0800
> Zhiyong Tao <[email protected]> wrote:
>
> > This commit adds mt7622 compatible node.
> >
> > Signed-off-by: Zhiyong Tao <[email protected]>
> > ---
> > drivers/iio/adc/mt6577_auxadc.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
> > index 2dd7c74..4a2cd9e 100644
> > --- a/drivers/iio/adc/mt6577_auxadc.c
> > +++ b/drivers/iio/adc/mt6577_auxadc.c
> > @@ -308,6 +308,7 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
> > static const struct of_device_id mt6577_auxadc_of_match[] = {
> > { .compatible = "mediatek,mt2701-auxadc", },
> > { .compatible = "mediatek,mt8173-auxadc", },
> > + { .compatible = "mediatek,mt7622-auxadc", },
> Keep them in numeric order perhaps?
>
> Might become a worthwhile step if this logic gets used for lot more parts in future!
>
> Jonathan
==>Ok, we will change them in numeric order perhaps in v2.
Thanks.
> > { }
> > };
> > MODULE_DEVICE_TABLE(of, mt6577_auxadc_of_match);
>
On Sat, 2017-06-24 at 21:00 +0100, Jonathan Cameron wrote:
> On Thu, 22 Jun 2017 13:44:33 +0800
> Zhiyong Tao <[email protected]> wrote:
>
> > This patch supports auxadc suspend/resume flow.
> > Disable auxadc clk and power in suspend function.
> > Enable axuadc clk and power in resume function.
> >
> > Signed-off-by: Zhiyong Tao <[email protected]>
> Worth handling the cases where power management is not configured into the
> kernel properly.
>
> So a few minor suggestions. Otherwise looks good to me.
> > ---
> > drivers/iio/adc/mt6577_auxadc.c | 37 +++++++++++++++++++++++++++++++++++++
> > 1 file changed, 37 insertions(+)
> >
> > diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c
> > index 2d104c8..2dd7c74 100644
> > --- a/drivers/iio/adc/mt6577_auxadc.c
> > +++ b/drivers/iio/adc/mt6577_auxadc.c
> > @@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev,
> > .read_raw = &mt6577_auxadc_read_raw,
> > };
> >
> > +static int mt6577_auxadc_resume(struct device *dev)
> > +{
> > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
> > + int ret;
> > +
> > + ret = clk_prepare_enable(adc_dev->adc_clk);
> > + if (ret) {
> > + pr_err("failed to enable auxadc clock\n");
> > + return ret;
> > + }
> > +
> > + mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
> > + MT6577_AUXADC_PDN_EN, 0);
> > + mdelay(MT6577_AUXADC_POWER_READY_MS);
> > +
> > + return 0;
> > +}
> > +
> > +static int mt6577_auxadc_suspend(struct device *dev)
> Mark these __maybe_unused for the CONFIG_PM but not CONFIG_PM_SLEEP case.
==> ok, We will add CONFIG_PM_SLEEP for the suspend/resume case in v2.
thanks!
> > +{
> > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> > + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
> > +
> > + mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
> > + 0, MT6577_AUXADC_PDN_EN);
> > + clk_disable_unprepare(adc_dev->adc_clk);
> > +
> > + return 0;
> > +}
> > +
> > static int mt6577_auxadc_probe(struct platform_device *pdev)
> > {
> > struct mt6577_auxadc_device *adc_dev;
> > @@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
> > return 0;
> > }
> >
> > +static const struct dev_pm_ops mt6577_auxadc_pm_ops = {
> > + .suspend = mt6577_auxadc_suspend,
> > + .resume = mt6577_auxadc_resume,
> > +};
> > +
> Use the SIMPLE_SYSTEM_PM_OPS macro to make these assignments magically go away
> if PM_CONFIG_SLEEP is not defined.
==> ok, We will use SIMPLE_DEV_PM_OPS macro to change it in v2. Thanks.
>> static const struct of_device_id mt6577_auxadc_of_match[] = {
> > { .compatible = "mediatek,mt2701-auxadc", },
> > { .compatible = "mediatek,mt8173-auxadc", },
> > @@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct platform_device *pdev)
> > .driver = {
> > .name = "mt6577-auxadc",
> > .of_match_table = mt6577_auxadc_of_match,
> > + .pm = &mt6577_auxadc_pm_ops,
> > },
> > .probe = mt6577_auxadc_probe,
> > .remove = mt6577_auxadc_remove,
>
On 26 June 2017 04:54:52 CEST, zhiyong tao <[email protected]> wrote:
>On Sat, 2017-06-24 at 21:00 +0100, Jonathan Cameron wrote:
>> On Thu, 22 Jun 2017 13:44:33 +0800
>> Zhiyong Tao <[email protected]> wrote:
>>
>> > This patch supports auxadc suspend/resume flow.
>> > Disable auxadc clk and power in suspend function.
>> > Enable axuadc clk and power in resume function.
>> >
>> > Signed-off-by: Zhiyong Tao <[email protected]>
>> Worth handling the cases where power management is not configured
>into the
>> kernel properly.
>>
>> So a few minor suggestions. Otherwise looks good to me.
>> > ---
>> > drivers/iio/adc/mt6577_auxadc.c | 37
>+++++++++++++++++++++++++++++++++++++
>> > 1 file changed, 37 insertions(+)
>> >
>> > diff --git a/drivers/iio/adc/mt6577_auxadc.c
>b/drivers/iio/adc/mt6577_auxadc.c
>> > index 2d104c8..2dd7c74 100644
>> > --- a/drivers/iio/adc/mt6577_auxadc.c
>> > +++ b/drivers/iio/adc/mt6577_auxadc.c
>> > @@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct
>iio_dev *indio_dev,
>> > .read_raw = &mt6577_auxadc_read_raw,
>> > };
>> >
>> > +static int mt6577_auxadc_resume(struct device *dev)
>> > +{
>> > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> > + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
>> > + int ret;
>> > +
>> > + ret = clk_prepare_enable(adc_dev->adc_clk);
>> > + if (ret) {
>> > + pr_err("failed to enable auxadc clock\n");
>> > + return ret;
>> > + }
>> > +
>> > + mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
>> > + MT6577_AUXADC_PDN_EN, 0);
>> > + mdelay(MT6577_AUXADC_POWER_READY_MS);
>> > +
>> > + return 0;
>> > +}
>> > +
>> > +static int mt6577_auxadc_suspend(struct device *dev)
>> Mark these __maybe_unused for the CONFIG_PM but not CONFIG_PM_SLEEP
>case.
Preferred to mark __maybe_unused and use the macro mentioned below.
>
>==> ok, We will add CONFIG_PM_SLEEP for the suspend/resume case in v2.
>thanks!
>
>> > +{
>> > + struct iio_dev *indio_dev = dev_get_drvdata(dev);
>> > + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev);
>> > +
>> > + mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC,
>> > + 0, MT6577_AUXADC_PDN_EN);
>> > + clk_disable_unprepare(adc_dev->adc_clk);
>> > +
>> > + return 0;
>> > +}
>> > +
>> > static int mt6577_auxadc_probe(struct platform_device *pdev)
>> > {
>> > struct mt6577_auxadc_device *adc_dev;
>> > @@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct
>platform_device *pdev)
>> > return 0;
>> > }
>> >
>> > +static const struct dev_pm_ops mt6577_auxadc_pm_ops = {
>> > + .suspend = mt6577_auxadc_suspend,
>> > + .resume = mt6577_auxadc_resume,
>> > +};
>> > +
>> Use the SIMPLE_SYSTEM_PM_OPS macro to make these assignments
>magically go away
>> if PM_CONFIG_SLEEP is not defined.
>
>==> ok, We will use SIMPLE_DEV_PM_OPS macro to change it in v2. Thanks.
>>> static const struct of_device_id mt6577_auxadc_of_match[] = {
>> > { .compatible = "mediatek,mt2701-auxadc", },
>> > { .compatible = "mediatek,mt8173-auxadc", },
>> > @@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct
>platform_device *pdev)
>> > .driver = {
>> > .name = "mt6577-auxadc",
>> > .of_match_table = mt6577_auxadc_of_match,
>> > + .pm = &mt6577_auxadc_pm_ops,
>> > },
>> > .probe = mt6577_auxadc_probe,
>> > .remove = mt6577_auxadc_remove,
>>
>
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>the body of a message to [email protected]
>More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
On Thu, 22 Jun 2017 13:44:32 +0800
Zhiyong Tao <[email protected]> wrote:
> The commit adds mt7622 compatible node in binding document.
>
> Signed-off-by: Zhiyong Tao <[email protected]>
> ---
> .../devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> index 68c45cb..e6aa30a 100644
> --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> @@ -13,6 +13,7 @@ Required properties:
> - compatible: Should be one of:
> - "mediatek,mt2701-auxadc": For MT2701 family of SoCs
> - "mediatek,mt8173-auxadc": For MT8173 family of SoCs
> + - "mediatek,mt7622-auxadc": For MT7622 family of SoCs
numeric order?
> - reg: Address range of the AUXADC unit.
> - clocks: Should contain a clock specifier for each entry in clock-names
> - clock-names: Should contain "main".
On Sat, 2017-06-24 at 21:02 +0100, Jonathan Cameron wrote:
> On Thu, 22 Jun 2017 13:44:32 +0800
> Zhiyong Tao <[email protected]> wrote:
>
> > The commit adds mt7622 compatible node in binding document.
> >
> > Signed-off-by: Zhiyong Tao <[email protected]>
> > ---
> > .../devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> > index 68c45cb..e6aa30a 100644
> > --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> > +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt
> > @@ -13,6 +13,7 @@ Required properties:
> > - compatible: Should be one of:
> > - "mediatek,mt2701-auxadc": For MT2701 family of SoCs
> > - "mediatek,mt8173-auxadc": For MT8173 family of SoCs
> > + - "mediatek,mt7622-auxadc": For MT7622 family of SoCs
> numeric order?
==> yes, we have changed it as numeric order in v2. Thanks.
> > - reg: Address range of the AUXADC unit.
> > - clocks: Should contain a clock specifier for each entry in clock-names
> > - clock-names: Should contain "main".
>