From: Kamel Bouhara <kamel.bouhara@xxxxxxxxxxx>
Add driver for Maxim Integrated MAX7360 PWM controller, supporting up to
8 independent PWM outputs.
Signed-off-by: Kamel Bouhara <kamel.bouhara@xxxxxxxxxxx>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@xxxxxxxxxxx>
+static int max7360_pwm_probe(struct platform_device *pdev)
+{
+ struct max7360_pwm *max7360_pwm;
+ struct pwm_chip *chip;
+ int ret;
+
+ if (!pdev->dev.parent)
+ return dev_err_probe(&pdev->dev, -ENODEV, "no parent device\n");
+
+ chip = devm_pwmchip_alloc(pdev->dev.parent, MAX7360_NUM_PWMS,
+ sizeof(*max7360_pwm));
+ if (IS_ERR(chip))
+ return PTR_ERR(chip);
+ chip->ops = &max7360_pwm_ops;
+
+ max7360_pwm = to_max7360_pwm(chip);
+ max7360_pwm->parent = pdev->dev.parent;
+
+ max7360_pwm->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ if (!max7360_pwm->regmap)
+ return dev_err_probe(&pdev->dev, -ENODEV,
+ "could not get parent regmap\n");
+
+ ret = devm_pwmchip_add(&pdev->dev, chip);
+ if (ret != 0)
+ dev_err_probe(&pdev->dev, ret, "failed to add PWM chip");
+
+ return 0;
+}