Lines Matching +full:off +full:- +full:chip

1 // SPDX-License-Identifier: GPL-2.0-only
8 * This driver is a complete rewrite of the former pwm-twl6030.c authorded by:
22 * - LEDA uses PWMA
23 * - LEDB uses PWMB
49 struct pwm_chip chip; member
53 static inline struct twl_pwmled_chip *to_twl(struct pwm_chip *chip) in to_twl() argument
55 return container_of(chip, struct twl_pwmled_chip, chip); in to_twl()
58 static int twl4030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm, in twl4030_pwmled_config() argument
67 * On-cycle is set to 1 (the minimum allowed value) in twl4030_pwmled_config()
68 * The off time of 0 is not configurable, so the mapping is: in twl4030_pwmled_config()
69 * 0 -> off cycle = 2, in twl4030_pwmled_config()
70 * 1 -> off cycle = 2, in twl4030_pwmled_config()
71 * 2 -> off cycle = 3, in twl4030_pwmled_config()
72 * 126 - > off cycle 127, in twl4030_pwmled_config()
73 * 127 - > off cycle 1 in twl4030_pwmled_config()
74 * When on cycle == off cycle the PWM will be always on in twl4030_pwmled_config()
81 base = pwm->hwpwm * 2 + TWL4030_PWMA_REG; in twl4030_pwmled_config()
87 dev_err(chip->dev, "%s: Failed to configure PWM\n", pwm->label); in twl4030_pwmled_config()
92 static int twl4030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm) in twl4030_pwmled_enable() argument
94 struct twl_pwmled_chip *twl = to_twl(chip); in twl4030_pwmled_enable()
98 mutex_lock(&twl->mutex); in twl4030_pwmled_enable()
101 dev_err(chip->dev, "%s: Failed to read LEDEN\n", pwm->label); in twl4030_pwmled_enable()
105 val |= TWL4030_LED_TOGGLE(pwm->hwpwm, TWL4030_LED_PINS); in twl4030_pwmled_enable()
109 dev_err(chip->dev, "%s: Failed to enable PWM\n", pwm->label); in twl4030_pwmled_enable()
112 mutex_unlock(&twl->mutex); in twl4030_pwmled_enable()
116 static void twl4030_pwmled_disable(struct pwm_chip *chip, in twl4030_pwmled_disable() argument
119 struct twl_pwmled_chip *twl = to_twl(chip); in twl4030_pwmled_disable()
123 mutex_lock(&twl->mutex); in twl4030_pwmled_disable()
126 dev_err(chip->dev, "%s: Failed to read LEDEN\n", pwm->label); in twl4030_pwmled_disable()
130 val &= ~TWL4030_LED_TOGGLE(pwm->hwpwm, TWL4030_LED_PINS); in twl4030_pwmled_disable()
134 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label); in twl4030_pwmled_disable()
137 mutex_unlock(&twl->mutex); in twl4030_pwmled_disable()
140 static int twl6030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm, in twl6030_pwmled_config() argument
152 dev_err(chip->dev, "%s: Failed to configure PWM\n", pwm->label); in twl6030_pwmled_config()
157 static int twl6030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm) in twl6030_pwmled_enable() argument
159 struct twl_pwmled_chip *twl = to_twl(chip); in twl6030_pwmled_enable()
163 mutex_lock(&twl->mutex); in twl6030_pwmled_enable()
166 dev_err(chip->dev, "%s: Failed to read PWM_CTRL2\n", in twl6030_pwmled_enable()
167 pwm->label); in twl6030_pwmled_enable()
176 dev_err(chip->dev, "%s: Failed to enable PWM\n", pwm->label); in twl6030_pwmled_enable()
179 mutex_unlock(&twl->mutex); in twl6030_pwmled_enable()
183 static void twl6030_pwmled_disable(struct pwm_chip *chip, in twl6030_pwmled_disable() argument
186 struct twl_pwmled_chip *twl = to_twl(chip); in twl6030_pwmled_disable()
190 mutex_lock(&twl->mutex); in twl6030_pwmled_disable()
193 dev_err(chip->dev, "%s: Failed to read PWM_CTRL2\n", in twl6030_pwmled_disable()
194 pwm->label); in twl6030_pwmled_disable()
203 dev_err(chip->dev, "%s: Failed to disable PWM\n", pwm->label); in twl6030_pwmled_disable()
206 mutex_unlock(&twl->mutex); in twl6030_pwmled_disable()
209 static int twl6030_pwmled_request(struct pwm_chip *chip, struct pwm_device *pwm) in twl6030_pwmled_request() argument
211 struct twl_pwmled_chip *twl = to_twl(chip); in twl6030_pwmled_request()
215 mutex_lock(&twl->mutex); in twl6030_pwmled_request()
218 dev_err(chip->dev, "%s: Failed to read PWM_CTRL2\n", in twl6030_pwmled_request()
219 pwm->label); in twl6030_pwmled_request()
228 dev_err(chip->dev, "%s: Failed to request PWM\n", pwm->label); in twl6030_pwmled_request()
231 mutex_unlock(&twl->mutex); in twl6030_pwmled_request()
235 static void twl6030_pwmled_free(struct pwm_chip *chip, struct pwm_device *pwm) in twl6030_pwmled_free() argument
237 struct twl_pwmled_chip *twl = to_twl(chip); in twl6030_pwmled_free()
241 mutex_lock(&twl->mutex); in twl6030_pwmled_free()
244 dev_err(chip->dev, "%s: Failed to read PWM_CTRL2\n", in twl6030_pwmled_free()
245 pwm->label); in twl6030_pwmled_free()
254 dev_err(chip->dev, "%s: Failed to free PWM\n", pwm->label); in twl6030_pwmled_free()
257 mutex_unlock(&twl->mutex); in twl6030_pwmled_free()
281 twl = devm_kzalloc(&pdev->dev, sizeof(*twl), GFP_KERNEL); in twl_pwmled_probe()
283 return -ENOMEM; in twl_pwmled_probe()
286 twl->chip.ops = &twl4030_pwmled_ops; in twl_pwmled_probe()
287 twl->chip.npwm = 2; in twl_pwmled_probe()
289 twl->chip.ops = &twl6030_pwmled_ops; in twl_pwmled_probe()
290 twl->chip.npwm = 1; in twl_pwmled_probe()
293 twl->chip.dev = &pdev->dev; in twl_pwmled_probe()
294 twl->chip.base = -1; in twl_pwmled_probe()
296 mutex_init(&twl->mutex); in twl_pwmled_probe()
298 ret = pwmchip_add(&twl->chip); in twl_pwmled_probe()
311 return pwmchip_remove(&twl->chip); in twl_pwmled_remove()
316 { .compatible = "ti,twl4030-pwmled" },
317 { .compatible = "ti,twl6030-pwmled" },
325 .name = "twl-pwmled",
335 MODULE_ALIAS("platform:twl-pwmled");