aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2016-06-22 07:47:23 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-07-11 06:49:34 -0400
commite9be88a2f06b89a56499c9bfe494ddc4e5f55f46 (patch)
tree545196b30940c1bf26bc59ec654eb516a0e01164 /drivers/pwm
parent57dfd17edaf353d0880bea494be05e8cda82ebc0 (diff)
pwm: tegra: Add support for Tegra186
Tegra186 has multiple PWM controllers with only one output instead of one controller with four outputs in earlier SoC generations. Add support for Tegra186 and detect the number of PWM outputs using device tree match data. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-tegra.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
index 247156149b44..e4647840cd6e 100644
--- a/drivers/pwm/pwm-tegra.c
+++ b/drivers/pwm/pwm-tegra.c
@@ -26,6 +26,7 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/of.h> 28#include <linux/of.h>
29#include <linux/of_device.h>
29#include <linux/pwm.h> 30#include <linux/pwm.h>
30#include <linux/platform_device.h> 31#include <linux/platform_device.h>
31#include <linux/slab.h> 32#include <linux/slab.h>
@@ -37,6 +38,10 @@
37#define PWM_SCALE_WIDTH 13 38#define PWM_SCALE_WIDTH 13
38#define PWM_SCALE_SHIFT 0 39#define PWM_SCALE_SHIFT 0
39 40
41struct tegra_pwm_soc {
42 unsigned int num_channels;
43};
44
40struct tegra_pwm_chip { 45struct tegra_pwm_chip {
41 struct pwm_chip chip; 46 struct pwm_chip chip;
42 struct device *dev; 47 struct device *dev;
@@ -45,6 +50,8 @@ struct tegra_pwm_chip {
45 struct reset_control*rst; 50 struct reset_control*rst;
46 51
47 void __iomem *regs; 52 void __iomem *regs;
53
54 const struct tegra_pwm_soc *soc;
48}; 55};
49 56
50static inline struct tegra_pwm_chip *to_tegra_pwm_chip(struct pwm_chip *chip) 57static inline struct tegra_pwm_chip *to_tegra_pwm_chip(struct pwm_chip *chip)
@@ -177,6 +184,7 @@ static int tegra_pwm_probe(struct platform_device *pdev)
177 if (!pwm) 184 if (!pwm)
178 return -ENOMEM; 185 return -ENOMEM;
179 186
187 pwm->soc = of_device_get_match_data(&pdev->dev);
180 pwm->dev = &pdev->dev; 188 pwm->dev = &pdev->dev;
181 189
182 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 190 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -202,7 +210,7 @@ static int tegra_pwm_probe(struct platform_device *pdev)
202 pwm->chip.dev = &pdev->dev; 210 pwm->chip.dev = &pdev->dev;
203 pwm->chip.ops = &tegra_pwm_ops; 211 pwm->chip.ops = &tegra_pwm_ops;
204 pwm->chip.base = -1; 212 pwm->chip.base = -1;
205 pwm->chip.npwm = 4; 213 pwm->chip.npwm = pwm->soc->num_channels;
206 214
207 ret = pwmchip_add(&pwm->chip); 215 ret = pwmchip_add(&pwm->chip);
208 if (ret < 0) { 216 if (ret < 0) {
@@ -245,9 +253,17 @@ static int tegra_pwm_remove(struct platform_device *pdev)
245 return pwmchip_remove(&pc->chip); 253 return pwmchip_remove(&pc->chip);
246} 254}
247 255
256static const struct tegra_pwm_soc tegra20_pwm_soc = {
257 .num_channels = 4,
258};
259
260static const struct tegra_pwm_soc tegra186_pwm_soc = {
261 .num_channels = 1,
262};
263
248static const struct of_device_id tegra_pwm_of_match[] = { 264static const struct of_device_id tegra_pwm_of_match[] = {
249 { .compatible = "nvidia,tegra20-pwm" }, 265 { .compatible = "nvidia,tegra20-pwm", .data = &tegra20_pwm_soc },
250 { .compatible = "nvidia,tegra30-pwm" }, 266 { .compatible = "nvidia,tegra186-pwm", .data = &tegra186_pwm_soc },
251 { } 267 { }
252}; 268};
253 269