All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Mergnat <amergnat@baylibre.com>
To: AngeloGioacchino Del Regno  <angelogioacchino.delregno@collabora.com>
Cc: matthias.bgg@gmail.com, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, flora.fu@mediatek.com,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, kernel@collabora.com,
	phone-devel@vger.kernel.org,
	~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH v2 2/6] soc: mediatek: pwrap: Move PMIC read test sequence in function
Date: Tue, 28 Mar 2023 11:19:52 +0200	[thread overview]
Message-ID: <CAFGrd9oyOz8-gf10-1QkaBzZwTvm9V7b63BZeoUbbM45CO8E1Q@mail.gmail.com> (raw)
In-Reply-To: <20230324094205.33266-3-angelogioacchino.delregno@collabora.com>

Le ven. 24 mars 2023 à 10:42, AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> a écrit :
>
> The PMIC read test is performed in two places: pwrap_init_dual_io()
> and pwrap_init_sidly().
> In preparation for adding support for PMICs requiring a companion
> part, move this sequence to a new function pwrap_pmic_read_test().
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>  drivers/soc/mediatek/mtk-pmic-wrap.c | 32 +++++++++++++++++-----------
>  1 file changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
> index 15789a03e6c6..5c500be48f7c 100644
> --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
> @@ -1455,6 +1455,18 @@ static int pwrap_regmap_write(void *context, u32 adr, u32 wdata)
>         return pwrap_write(context, adr, wdata);
>  }
>
> +static bool pwrap_pmic_read_test(struct pmic_wrapper *wrp, const u32 *dew_regs,
> +                                u16 read_test_val)
> +{
> +       bool is_success;
> +       u32 rdata;
> +
> +       pwrap_read(wrp, dew_regs[PWRAP_DEW_READ_TEST], &rdata);
> +       is_success = ((rdata & U16_MAX) == read_test_val);
> +
> +       return is_success;
> +}
> +
>  static int pwrap_reset_spislave(struct pmic_wrapper *wrp)
>  {
>         bool tmp;
> @@ -1498,18 +1510,18 @@ static int pwrap_reset_spislave(struct pmic_wrapper *wrp)
>   */
>  static int pwrap_init_sidly(struct pmic_wrapper *wrp)
>  {
> -       u32 rdata;
>         u32 i;
>         u32 pass = 0;
> +       bool read_ok;
>         signed char dly[16] = {
>                 -1, 0, 1, 0, 2, -1, 1, 1, 3, -1, -1, -1, 3, -1, 2, 1
>         };
>
>         for (i = 0; i < 4; i++) {
>                 pwrap_writel(wrp, i, PWRAP_SIDLY);
> -               pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_READ_TEST],
> -                          &rdata);
> -               if (rdata == PWRAP_DEW_READ_TEST_VAL) {
> +               read_ok = pwrap_pmic_read_test(wrp, wrp->slave->dew_regs,
> +                                              PWRAP_DEW_READ_TEST_VAL);
> +               if (read_ok) {
>                         dev_dbg(wrp->dev, "[Read Test] pass, SIDLY=%x\n", i);
>                         pass |= 1 << i;
>                 }
> @@ -1529,8 +1541,7 @@ static int pwrap_init_sidly(struct pmic_wrapper *wrp)
>  static int pwrap_init_dual_io(struct pmic_wrapper *wrp)
>  {
>         int ret;
> -       bool tmp;
> -       u32 rdata;
> +       bool read_ok, tmp;
>
>         /* Enable dual IO mode */
>         pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1);
> @@ -1546,12 +1557,9 @@ static int pwrap_init_dual_io(struct pmic_wrapper *wrp)
>         pwrap_writel(wrp, 1, PWRAP_DIO_EN);
>
>         /* Read Test */
> -       pwrap_read(wrp,
> -                  wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], &rdata);
> -       if (rdata != PWRAP_DEW_READ_TEST_VAL) {
> -               dev_err(wrp->dev,
> -                       "Read failed on DIO mode: 0x%04x!=0x%04x\n",
> -                       PWRAP_DEW_READ_TEST_VAL, rdata);
> +       read_ok = pwrap_pmic_read_test(wrp, wrp->slave->dew_regs, PWRAP_DEW_READ_TEST_VAL);
> +       if (!read_ok) {
> +               dev_err(wrp->dev, "Read failed on DIO mode.\n");
>                 return -EFAULT;
>         }

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>

Regards,
Alexandre

WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Mergnat <amergnat@baylibre.com>
To: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: matthias.bgg@gmail.com, robh+dt@kernel.org,
	 krzysztof.kozlowski+dt@linaro.org, flora.fu@mediatek.com,
	 devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,  kernel@collabora.com,
	phone-devel@vger.kernel.org,
	 ~postmarketos/upstreaming@lists.sr.ht
Subject: Re: [PATCH v2 2/6] soc: mediatek: pwrap: Move PMIC read test sequence in function
Date: Tue, 28 Mar 2023 11:19:52 +0200	[thread overview]
Message-ID: <CAFGrd9oyOz8-gf10-1QkaBzZwTvm9V7b63BZeoUbbM45CO8E1Q@mail.gmail.com> (raw)
In-Reply-To: <20230324094205.33266-3-angelogioacchino.delregno@collabora.com>

Le ven. 24 mars 2023 à 10:42, AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> a écrit :
>
> The PMIC read test is performed in two places: pwrap_init_dual_io()
> and pwrap_init_sidly().
> In preparation for adding support for PMICs requiring a companion
> part, move this sequence to a new function pwrap_pmic_read_test().
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>  drivers/soc/mediatek/mtk-pmic-wrap.c | 32 +++++++++++++++++-----------
>  1 file changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-pmic-wrap.c b/drivers/soc/mediatek/mtk-pmic-wrap.c
> index 15789a03e6c6..5c500be48f7c 100644
> --- a/drivers/soc/mediatek/mtk-pmic-wrap.c
> +++ b/drivers/soc/mediatek/mtk-pmic-wrap.c
> @@ -1455,6 +1455,18 @@ static int pwrap_regmap_write(void *context, u32 adr, u32 wdata)
>         return pwrap_write(context, adr, wdata);
>  }
>
> +static bool pwrap_pmic_read_test(struct pmic_wrapper *wrp, const u32 *dew_regs,
> +                                u16 read_test_val)
> +{
> +       bool is_success;
> +       u32 rdata;
> +
> +       pwrap_read(wrp, dew_regs[PWRAP_DEW_READ_TEST], &rdata);
> +       is_success = ((rdata & U16_MAX) == read_test_val);
> +
> +       return is_success;
> +}
> +
>  static int pwrap_reset_spislave(struct pmic_wrapper *wrp)
>  {
>         bool tmp;
> @@ -1498,18 +1510,18 @@ static int pwrap_reset_spislave(struct pmic_wrapper *wrp)
>   */
>  static int pwrap_init_sidly(struct pmic_wrapper *wrp)
>  {
> -       u32 rdata;
>         u32 i;
>         u32 pass = 0;
> +       bool read_ok;
>         signed char dly[16] = {
>                 -1, 0, 1, 0, 2, -1, 1, 1, 3, -1, -1, -1, 3, -1, 2, 1
>         };
>
>         for (i = 0; i < 4; i++) {
>                 pwrap_writel(wrp, i, PWRAP_SIDLY);
> -               pwrap_read(wrp, wrp->slave->dew_regs[PWRAP_DEW_READ_TEST],
> -                          &rdata);
> -               if (rdata == PWRAP_DEW_READ_TEST_VAL) {
> +               read_ok = pwrap_pmic_read_test(wrp, wrp->slave->dew_regs,
> +                                              PWRAP_DEW_READ_TEST_VAL);
> +               if (read_ok) {
>                         dev_dbg(wrp->dev, "[Read Test] pass, SIDLY=%x\n", i);
>                         pass |= 1 << i;
>                 }
> @@ -1529,8 +1541,7 @@ static int pwrap_init_sidly(struct pmic_wrapper *wrp)
>  static int pwrap_init_dual_io(struct pmic_wrapper *wrp)
>  {
>         int ret;
> -       bool tmp;
> -       u32 rdata;
> +       bool read_ok, tmp;
>
>         /* Enable dual IO mode */
>         pwrap_write(wrp, wrp->slave->dew_regs[PWRAP_DEW_DIO_EN], 1);
> @@ -1546,12 +1557,9 @@ static int pwrap_init_dual_io(struct pmic_wrapper *wrp)
>         pwrap_writel(wrp, 1, PWRAP_DIO_EN);
>
>         /* Read Test */
> -       pwrap_read(wrp,
> -                  wrp->slave->dew_regs[PWRAP_DEW_READ_TEST], &rdata);
> -       if (rdata != PWRAP_DEW_READ_TEST_VAL) {
> -               dev_err(wrp->dev,
> -                       "Read failed on DIO mode: 0x%04x!=0x%04x\n",
> -                       PWRAP_DEW_READ_TEST_VAL, rdata);
> +       read_ok = pwrap_pmic_read_test(wrp, wrp->slave->dew_regs, PWRAP_DEW_READ_TEST_VAL);
> +       if (!read_ok) {
> +               dev_err(wrp->dev, "Read failed on DIO mode.\n");
>                 return -EFAULT;
>         }

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>

Regards,
Alexandre

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-03-28  9:20 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24  9:41 [PATCH v2 0/6] MediaTek Helio X10 MT6795 - MT6331/6332 PMIC Wrapper AngeloGioacchino Del Regno
2023-03-24  9:41 ` AngeloGioacchino Del Regno
2023-03-24  9:42 ` [PATCH v2 1/6] dt-bindings: soc: mediatek: pwrap: Add compatible for MT6795 Helio X10 AngeloGioacchino Del Regno
2023-03-24  9:42   ` AngeloGioacchino Del Regno
2023-03-27  7:23   ` Krzysztof Kozlowski
2023-03-27  7:23     ` Krzysztof Kozlowski
2023-03-24  9:42 ` [PATCH v2 2/6] soc: mediatek: pwrap: Move PMIC read test sequence in function AngeloGioacchino Del Regno
2023-03-24  9:42   ` AngeloGioacchino Del Regno
2023-03-28  9:19   ` Alexandre Mergnat [this message]
2023-03-28  9:19     ` Alexandre Mergnat
2023-03-24  9:42 ` [PATCH v2 3/6] soc: mediatek: pwrap: Add kerneldoc for struct pwrap_slv_type AngeloGioacchino Del Regno
2023-03-24  9:42   ` AngeloGioacchino Del Regno
2023-03-28  9:22   ` Alexandre Mergnat
2023-03-28  9:22     ` Alexandre Mergnat
2023-03-24  9:42 ` [PATCH v2 4/6] soc: mediatek: mtk-pmic-wrap: Add support for companion PMICs AngeloGioacchino Del Regno
2023-03-24  9:42   ` AngeloGioacchino Del Regno
2023-03-29 22:40   ` Alexandre Mergnat
2023-03-29 22:40     ` Alexandre Mergnat
2023-03-24  9:42 ` [PATCH v2 5/6] soc: mediatek: mtk-pmic-wrap: Add support for MT6331 w/ MT6332 companion AngeloGioacchino Del Regno
2023-03-24  9:42   ` AngeloGioacchino Del Regno
2023-03-29 23:17   ` Alexandre Mergnat
2023-03-29 23:17     ` Alexandre Mergnat
2023-03-24  9:42 ` [PATCH v2 6/6] soc: mediatek: pwrap: Add support for MT6795 Helio X10 AngeloGioacchino Del Regno
2023-03-24  9:42   ` AngeloGioacchino Del Regno
2023-03-29 23:07   ` Alexandre Mergnat
2023-03-29 23:07     ` Alexandre Mergnat
2023-04-12 12:55     ` Matthias Brugger
2023-04-12 12:55       ` Matthias Brugger
2023-04-12 13:01       ` AngeloGioacchino Del Regno
2023-04-12 13:01         ` AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFGrd9oyOz8-gf10-1QkaBzZwTvm9V7b63BZeoUbbM45CO8E1Q@mail.gmail.com \
    --to=amergnat@baylibre.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=flora.fu@mediatek.com \
    --cc=kernel@collabora.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=phone-devel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.