summaryrefslogtreecommitdiff
path: root/drivers/pwm
diff options
context:
space:
mode:
authorTommaso Merciai <tommaso.merciai@amarulasolutions.com>2022-03-26 12:19:06 +0100
committerStefano Babic <sbabic@denx.de>2022-04-12 17:33:55 +0200
commitbfc778cb93a33233fa44006ea283b5aa36ad387d (patch)
tree86426163ff124e1bc032ec00789bb54f771ffaac /drivers/pwm
parente2d074ceadad5eb48b355ea5a149b3d7819690b9 (diff)
downloadu-boot-bfc778cb93a33233fa44006ea283b5aa36ad387d.tar.gz
u-boot-bfc778cb93a33233fa44006ea283b5aa36ad387d.tar.bz2
u-boot-bfc778cb93a33233fa44006ea283b5aa36ad387d.zip
driver: pwm: pwm-imx: get and enable per/ipg clock using dm
Get and enable ipg/per pwms clocks using dm api into imx_pwm_of_to_plat and imx_pwm_probe driver function Signed-off-by: Tommaso Merciai <tommaso.merciai@amarulasolutions.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-imx.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index 2008c1520e..becd902cc2 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -25,6 +25,7 @@ int pwm_init(int pwm_id, int div, int invert)
writel(0, &pwm->ir);
return 0;
}
+#include <clk.h>
int pwm_config_internal(struct pwm_regs *pwm, unsigned long period_cycles,
unsigned long duty_cycles, unsigned long prescale)
@@ -83,6 +84,8 @@ void pwm_disable(int pwm_id)
struct imx_pwm_priv {
struct pwm_regs *regs;
bool invert;
+ struct clk per_clk;
+ struct clk ipg_clk;
};
static int imx_pwm_set_invert(struct udevice *dev, uint channel,
@@ -128,15 +131,43 @@ static int imx_pwm_set_enable(struct udevice *dev, uint channel, bool enable)
static int imx_pwm_of_to_plat(struct udevice *dev)
{
+ int ret;
struct imx_pwm_priv *priv = dev_get_priv(dev);
priv->regs = dev_read_addr_ptr(dev);
+ ret = clk_get_by_name(dev, "per", &priv->per_clk);
+ if (ret) {
+ printf("Failed to get per_clk\n");
+ return ret;
+ }
+
+ ret = clk_get_by_name(dev, "ipg", &priv->ipg_clk);
+ if (ret) {
+ printf("Failed to get ipg_clk\n");
+ return ret;
+ }
+
return 0;
}
static int imx_pwm_probe(struct udevice *dev)
{
+ int ret;
+ struct imx_pwm_priv *priv = dev_get_priv(dev);
+
+ ret = clk_enable(&priv->per_clk);
+ if (ret) {
+ printf("Failed to enable per_clk\n");
+ return ret;
+ }
+
+ ret = clk_enable(&priv->ipg_clk);
+ if (ret) {
+ printf("Failed to enable ipg_clk\n");
+ return ret;
+ }
+
return 0;
}