All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 11/11] sandbox: tests: Add tests for mc34708 PMIC device
Date: Tue, 15 May 2018 16:26:43 +0200	[thread overview]
Message-ID: <20180515142643.11599-12-lukma@denx.de> (raw)
In-Reply-To: <20180515142643.11599-1-lukma@denx.de>

Following tests has been added for mc34708 device:

- get_test for mc34708 PMIC
- Check if proper number of registers is read
- Check if default (emulated via i2c device) value is properly read
- Check if value write/read operation is correct
- Perform tests to check if pmic_clrsetbits() is working correctly

Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>

---

Changes in v3:
- Fix pmic.c test code after adjusting the sandbox PMIC related dts

Changes in v2:
- New patch

 test/dm/pmic.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/test/dm/pmic.c b/test/dm/pmic.c
index c24bd3b0a1..b582329a9c 100644
--- a/test/dm/pmic.c
+++ b/test/dm/pmic.c
@@ -19,6 +19,7 @@
 #include <power/pmic.h>
 #include <power/sandbox_pmic.h>
 #include <test/ut.h>
+#include <fsl_pmic.h>
 
 /* Test PMIC get method */
 
@@ -44,6 +45,16 @@ static int dm_test_power_pmic_get(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_power_pmic_get, DM_TESTF_SCAN_FDT);
 
+/* PMIC get method - MC34708 - for 3 bytes transmission */
+static int dm_test_power_pmic_mc34708_get(struct unit_test_state *uts)
+{
+	power_pmic_get(uts, "pmic at 41");
+
+	return 0;
+}
+
+DM_TEST(dm_test_power_pmic_mc34708_get, DM_TESTF_SCAN_FDT);
+
 /* Test PMIC I/O */
 static int dm_test_power_pmic_io(struct unit_test_state *uts)
 {
@@ -72,3 +83,48 @@ static int dm_test_power_pmic_io(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_power_pmic_io, DM_TESTF_SCAN_FDT);
+
+#define MC34708_PMIC_REG_COUNT 64
+#define MC34708_PMIC_TEST_VAL 0x125534
+static int dm_test_power_pmic_mc34708_regs_check(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	int reg_count;
+
+	ut_assertok(pmic_get("pmic at 41", &dev));
+
+	/* Check number of PMIC registers */
+	reg_count = pmic_reg_count(dev);
+	ut_asserteq(reg_count, MC34708_PMIC_REG_COUNT);
+
+	return 0;
+}
+
+DM_TEST(dm_test_power_pmic_mc34708_regs_check, DM_TESTF_SCAN_FDT);
+
+static int dm_test_power_pmic_mc34708_rw_val(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	int val;
+
+	ut_assertok(pmic_get("pmic at 41", &dev));
+
+	/* Check if single 3 byte read is successful */
+	val = pmic_reg_read(dev, REG_POWER_CTL2);
+	ut_asserteq(val, 0x422100);
+
+	/* Check if RW works */
+	val = 0;
+	ut_assertok(pmic_reg_write(dev, REG_RTC_TIME, val));
+	ut_assertok(pmic_reg_write(dev, REG_RTC_TIME, MC34708_PMIC_TEST_VAL));
+	val = pmic_reg_read(dev, REG_RTC_TIME);
+	ut_asserteq(val, MC34708_PMIC_TEST_VAL);
+
+	pmic_clrsetbits(dev, REG_POWER_CTL2, 0x3 << 8, 1 << 9);
+	val = pmic_reg_read(dev, REG_POWER_CTL2);
+	ut_asserteq(val, (0x422100 & ~(0x3 << 8)) | (1 << 9));
+
+	return 0;
+}
+
+DM_TEST(dm_test_power_pmic_mc34708_rw_val, DM_TESTF_SCAN_FDT);
-- 
2.11.0

      parent reply	other threads:[~2018-05-15 14:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 14:26 [U-Boot] [PATCH v3 00/11] pmic: sandbox: Add support for MC34709 PMIC Lukasz Majewski
2018-05-15 14:26 ` [U-Boot] [PATCH v3 01/11] pmic: fsl: Provide some more definitions for MC34708 PMIC Lukasz Majewski
2018-05-15 16:05   ` Simon Glass
2018-05-15 14:26 ` [U-Boot] [PATCH v3 02/11] pmic: fsl: Define number of bytes sent at once by " Lukasz Majewski
2018-05-15 14:26 ` [U-Boot] [PATCH v3 03/11] pmic: Add support for setting transmission length in uclass private data Lukasz Majewski
2018-05-15 14:26 ` [U-Boot] [PATCH v3 04/11] pmic: dm: Rewrite pmic_reg_{read|write|clrsetbits} to support 3 bytes transmissions Lukasz Majewski
2018-05-15 14:26 ` [U-Boot] [PATCH v3 05/11] pmic: dm: Add support for MC34708 for PMIC DM Lukasz Majewski
2018-05-15 16:05   ` Simon Glass
2018-05-15 14:26 ` [U-Boot] [PATCH v3 06/11] pmic: Rewrite the pmic command to not only work with single byte transmission Lukasz Majewski
2018-05-15 14:26 ` [U-Boot] [PATCH v3 07/11] sandbox: Rewrite i2c_pmic_emul.c to support PMIC with 3 bytes transmission Lukasz Majewski
2018-05-15 14:26 ` [U-Boot] [PATCH v3 08/11] sandbox: Enable support for MC34708 PMIC in DTS Lukasz Majewski
2018-05-15 14:26 ` [U-Boot] [PATCH v3 09/11] sandbox: Enable MC34708 PMIC support Lukasz Majewski
2018-05-15 14:26 ` [U-Boot] [PATCH v3 10/11] sandbox: tests: Exclude common test code (pmic_get) in test/dm/pmic.c Lukasz Majewski
2018-05-15 14:26 ` Lukasz Majewski [this message]

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=20180515142643.11599-12-lukma@denx.de \
    --to=lukma@denx.de \
    --cc=u-boot@lists.denx.de \
    /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.