From: Dmitry Rokosov <ddrokosov@salutedevices.com>
To: <lee@kernel.org>, <pavel@ucw.cz>, <robh+dt@kernel.org>,
<krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>,
<andy.shevchenko@gmail.com>
Cc: <kernel@sberdevices.ru>, <rockosov@gmail.com>,
<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-leds@vger.kernel.org>,
Dmitry Rokosov <ddrokosov@salutedevices.com>
Subject: [PATCH v1 03/11] leds: aw200xx: support HWEN hardware control
Date: Fri, 6 Oct 2023 19:04:29 +0300 [thread overview]
Message-ID: <20231006160437.15627-4-ddrokosov@salutedevices.com> (raw)
In-Reply-To: <20231006160437.15627-1-ddrokosov@salutedevices.com>
HWEN is hardware control, which is used for enable/disable aw200xx chip.
It's high active, internally pulled down to GND.
After HWEN pin set high the chip begins to load the OTP information,
which takes 200us to complete. About 200us wait time is needed for
internal oscillator startup and display SRAM initialization. After
display SRAM initialization, the registers in page1 to page5 can be
configured via i2c interface.
Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
---
drivers/leds/leds-aw200xx.c | 45 +++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/leds/leds-aw200xx.c b/drivers/leds/leds-aw200xx.c
index 4c1e7caf8941..d92c082d4ab3 100644
--- a/drivers/leds/leds-aw200xx.c
+++ b/drivers/leds/leds-aw200xx.c
@@ -15,6 +15,7 @@
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/of_gpio.h>
#include <linux/regmap.h>
#include <linux/time.h>
#include <linux/units.h>
@@ -116,6 +117,7 @@ struct aw200xx {
struct mutex mutex;
u32 num_leds;
u32 display_rows;
+ int hwen;
struct aw200xx_led leds[];
};
@@ -358,6 +360,29 @@ static int aw200xx_chip_check(const struct aw200xx *const chip)
return 0;
}
+static void aw200xx_enable(const struct aw200xx *const chip)
+{
+ if (!gpio_is_valid(chip->hwen))
+ return;
+
+ gpio_set_value(chip->hwen, 1);
+
+ /*
+ * After HWEN pin set high the chip begins to load the OTP information,
+ * which takes 200us to complete. About 200us wait time is needed for
+ * internal oscillator startup and display SRAM initialization. After
+ * display SRAM initialization, the registers in page1 to page5 can be
+ * configured via i2c interface.
+ */
+ usleep_range(400, 500);
+}
+
+static void aw200xx_disable(const struct aw200xx *const chip)
+{
+ if (gpio_is_valid(chip->hwen))
+ gpio_set_value(chip->hwen, 0);
+}
+
static int aw200xx_probe_fw(struct device *dev, struct aw200xx *chip)
{
struct fwnode_handle *child;
@@ -445,6 +470,18 @@ static int aw200xx_probe_fw(struct device *dev, struct aw200xx *chip)
return aw200xx_set_imax(chip, min_uA);
}
+static void aw200xx_probe_hwen(struct device *dev, struct aw200xx *chip)
+{
+ chip->hwen = of_get_named_gpio(dev->of_node, "awinic,hwen-gpio", 0);
+ if (gpio_is_valid(chip->hwen))
+ if (devm_gpio_request_one(dev, chip->hwen, GPIOF_OUT_INIT_HIGH,
+ "AW200XX HWEN")) {
+ dev_warn(dev, "Can't request gpio %d, tag it invalid\n",
+ chip->hwen);
+ chip->hwen = -EINVAL;
+ }
+}
+
static const struct regmap_range_cfg aw200xx_ranges[] = {
{
.name = "aw200xx",
@@ -517,6 +554,10 @@ static int aw200xx_probe(struct i2c_client *client)
if (IS_ERR(chip->regmap))
return PTR_ERR(chip->regmap);
+ aw200xx_probe_hwen(&client->dev, chip);
+
+ aw200xx_enable(chip);
+
ret = aw200xx_chip_check(chip);
if (ret)
return ret;
@@ -537,6 +578,9 @@ static int aw200xx_probe(struct i2c_client *client)
ret = aw200xx_chip_init(chip);
out_unlock:
+ if (ret)
+ aw200xx_disable(chip);
+
mutex_unlock(&chip->mutex);
return ret;
}
@@ -546,6 +590,7 @@ static void aw200xx_remove(struct i2c_client *client)
struct aw200xx *chip = i2c_get_clientdata(client);
aw200xx_chip_reset(chip);
+ aw200xx_disable(chip);
mutex_destroy(&chip->mutex);
}
--
2.36.0
next prev parent reply other threads:[~2023-10-06 16:05 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 16:04 [PATCH v1 00/11] leds: aw200xx: several driver updates Dmitry Rokosov
2023-10-06 16:04 ` [PATCH v1 01/11] leds: aw200xx: fix write to DIM parameter Dmitry Rokosov
2023-10-06 16:04 ` [PATCH v1 02/11] dt-bindings: leds: aw200xx: fix led dt node pattern Dmitry Rokosov
2023-10-10 14:11 ` Rob Herring
2023-10-06 16:04 ` Dmitry Rokosov [this message]
2023-10-06 17:57 ` [PATCH v1 03/11] leds: aw200xx: support HWEN hardware control Andy Shevchenko
2023-10-09 13:09 ` Dmitry Rokosov
2023-10-06 16:04 ` [PATCH v1 04/11] dt-bindings: leds: aw200xx: introduce optional hwen-gpio property Dmitry Rokosov
2023-10-10 14:13 ` Rob Herring
2023-10-10 14:57 ` Dmitry Rokosov
2023-10-06 16:04 ` [PATCH v1 05/11] leds: aw200xx: calculate dts property display_rows in driver Dmitry Rokosov
2023-10-06 17:59 ` Andy Shevchenko
2023-10-09 13:20 ` Dmitry Rokosov
2023-10-16 23:30 ` George Stark
2023-10-06 16:04 ` [PATCH v1 06/11] dt-bindings: leds: aw200xx: remove property "awinic,display-rows" Dmitry Rokosov
2023-10-10 14:15 ` Rob Herring
2023-10-06 16:04 ` [PATCH v1 07/11] leds: aw200xx: add delay after software reset Dmitry Rokosov
2023-10-06 18:01 ` Andy Shevchenko
2023-10-09 13:14 ` Dmitry Rokosov
2023-10-06 16:04 ` [PATCH v1 08/11] leds: aw200xx: enable disable_locking flag in regmap config Dmitry Rokosov
2023-10-06 16:04 ` [PATCH v1 09/11] leds: aw200xx: improve autodim calculation method Dmitry Rokosov
2023-10-06 18:03 ` Andy Shevchenko
2023-10-09 13:18 ` Dmitry Rokosov
2023-10-09 14:02 ` Dmitry Rokosov
2023-10-16 21:22 ` George Stark
2023-10-06 16:04 ` [PATCH v1 10/11] leds: aw200xx: add support for aw20108 device Dmitry Rokosov
2023-10-06 16:04 ` [PATCH v1 11/11] dt-bindings: leds: Add binding for AW20108 led driver Dmitry Rokosov
2023-10-10 14:17 ` Rob Herring
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=20231006160437.15627-4-ddrokosov@salutedevices.com \
--to=ddrokosov@salutedevices.com \
--cc=andy.shevchenko@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kernel@sberdevices.ru \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=robh+dt@kernel.org \
--cc=rockosov@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®