diff options
author | Lukasz Majewski <l.majewski@majess.pl> | 2017-01-29 16:54:08 -0500 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2017-01-30 03:12:42 -0500 |
commit | b3c088fe0297d7580bef5d5830fa5fc69ae8443c (patch) | |
tree | b062d963b3f8b7cdab2fa00811fa5480cc649f33 /drivers/pwm/pwm-imx.c | |
parent | 0038922954236a6af424e2604ece88404dfbc41c (diff) |
pwm: imx: Rewrite v1 code to facilitate switch to atomic PWM
The code has been rewritten to remove "generic" calls to
imx_pwm_{enable|disable|config}.
Such approach would facilitate switch to atomic PWM (a.k.a ->apply())
implementation.
Suggested-by: Stefan Agner <stefan@agner.ch>
Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-imx.c')
-rw-r--r-- | drivers/pwm/pwm-imx.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index c405cb777808..5c712104066a 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c | |||
@@ -90,19 +90,33 @@ static int imx_pwm_config_v1(struct pwm_chip *chip, | |||
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | static void imx_pwm_set_enable_v1(struct pwm_chip *chip, bool enable) | 93 | static int imx_pwm_enable_v1(struct pwm_chip *chip, struct pwm_device *pwm) |
94 | { | 94 | { |
95 | struct imx_chip *imx = to_imx_chip(chip); | 95 | struct imx_chip *imx = to_imx_chip(chip); |
96 | u32 val; | 96 | u32 val; |
97 | int ret; | ||
98 | |||
99 | ret = clk_prepare_enable(imx->clk_per); | ||
100 | if (ret < 0) | ||
101 | return ret; | ||
97 | 102 | ||
98 | val = readl(imx->mmio_base + MX1_PWMC); | 103 | val = readl(imx->mmio_base + MX1_PWMC); |
104 | val |= MX1_PWMC_EN; | ||
105 | writel(val, imx->mmio_base + MX1_PWMC); | ||
99 | 106 | ||
100 | if (enable) | 107 | return 0; |
101 | val |= MX1_PWMC_EN; | 108 | } |
102 | else | 109 | |
103 | val &= ~MX1_PWMC_EN; | 110 | static void imx_pwm_disable_v1(struct pwm_chip *chip, struct pwm_device *pwm) |
111 | { | ||
112 | struct imx_chip *imx = to_imx_chip(chip); | ||
113 | u32 val; | ||
104 | 114 | ||
115 | val = readl(imx->mmio_base + MX1_PWMC); | ||
116 | val &= ~MX1_PWMC_EN; | ||
105 | writel(val, imx->mmio_base + MX1_PWMC); | 117 | writel(val, imx->mmio_base + MX1_PWMC); |
118 | |||
119 | clk_disable_unprepare(imx->clk_per); | ||
106 | } | 120 | } |
107 | 121 | ||
108 | static int imx_pwm_config_v2(struct pwm_chip *chip, | 122 | static int imx_pwm_config_v2(struct pwm_chip *chip, |
@@ -240,9 +254,9 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) | |||
240 | } | 254 | } |
241 | 255 | ||
242 | static const struct pwm_ops imx_pwm_ops_v1 = { | 256 | static const struct pwm_ops imx_pwm_ops_v1 = { |
243 | .enable = imx_pwm_enable, | 257 | .enable = imx_pwm_enable_v1, |
244 | .disable = imx_pwm_disable, | 258 | .disable = imx_pwm_disable_v1, |
245 | .config = imx_pwm_config, | 259 | .config = imx_pwm_config_v1, |
246 | .owner = THIS_MODULE, | 260 | .owner = THIS_MODULE, |
247 | }; | 261 | }; |
248 | 262 | ||
@@ -261,8 +275,6 @@ struct imx_pwm_data { | |||
261 | }; | 275 | }; |
262 | 276 | ||
263 | static struct imx_pwm_data imx_pwm_data_v1 = { | 277 | static struct imx_pwm_data imx_pwm_data_v1 = { |
264 | .config = imx_pwm_config_v1, | ||
265 | .set_enable = imx_pwm_set_enable_v1, | ||
266 | .ops = &imx_pwm_ops_v1, | 278 | .ops = &imx_pwm_ops_v1, |
267 | }; | 279 | }; |
268 | 280 | ||