pwm: hibvt: Use individual struct per of-data

Split pwm_soc array in one struct per SoC and point to the corresponding
one in of-data.

Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
This commit is contained in:
Mathieu Othacehe 2019-02-19 10:58:06 +01:00 committed by Thierry Reding
parent 7ca17b2071
commit 77c3edde4a
1 changed files with 12 additions and 5 deletions

View File

@ -49,15 +49,19 @@ struct hibvt_pwm_chip {
struct clk *clk; struct clk *clk;
void __iomem *base; void __iomem *base;
struct reset_control *rstc; struct reset_control *rstc;
const struct hibvt_pwm_soc *soc;
}; };
struct hibvt_pwm_soc { struct hibvt_pwm_soc {
u32 num_pwms; u32 num_pwms;
}; };
static const struct hibvt_pwm_soc pwm_soc[2] = { static const struct hibvt_pwm_soc hi3516cv300_soc_info = {
{ .num_pwms = 4 }, .num_pwms = 4,
{ .num_pwms = 8 }, };
static const struct hibvt_pwm_soc hi3519v100_soc_info = {
.num_pwms = 8,
}; };
static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip) static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip)
@ -198,6 +202,7 @@ static int hibvt_pwm_probe(struct platform_device *pdev)
pwm_chip->chip.npwm = soc->num_pwms; pwm_chip->chip.npwm = soc->num_pwms;
pwm_chip->chip.of_xlate = of_pwm_xlate_with_flags; pwm_chip->chip.of_xlate = of_pwm_xlate_with_flags;
pwm_chip->chip.of_pwm_n_cells = 3; pwm_chip->chip.of_pwm_n_cells = 3;
pwm_chip->soc = soc;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
pwm_chip->base = devm_ioremap_resource(&pdev->dev, res); pwm_chip->base = devm_ioremap_resource(&pdev->dev, res);
@ -250,8 +255,10 @@ static int hibvt_pwm_remove(struct platform_device *pdev)
} }
static const struct of_device_id hibvt_pwm_of_match[] = { static const struct of_device_id hibvt_pwm_of_match[] = {
{ .compatible = "hisilicon,hi3516cv300-pwm", .data = &pwm_soc[0] }, { .compatible = "hisilicon,hi3516cv300-pwm",
{ .compatible = "hisilicon,hi3519v100-pwm", .data = &pwm_soc[1] }, .data = &hi3516cv300_soc_info },
{ .compatible = "hisilicon,hi3519v100-pwm",
.data = &hi3519v100_soc_info },
{ } { }
}; };
MODULE_DEVICE_TABLE(of, hibvt_pwm_of_match); MODULE_DEVICE_TABLE(of, hibvt_pwm_of_match);