Lines Matching +full:duty +full:- +full:cycle

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * e-book readers designed by the original design manufacturer Netronix, Inc.
13 * - The get_state callback is not implemented, because the current state of
15 * - The hardware can only generate normal polarity output.
16 * - The period and duty cycle can't be changed together in one atomic action.
45 * The time base used in the EC is 8MHz, or 125ns. Period and duty cycle are
58 int period, int duty) in ntxec_pwm_set_raw_period_and_duty_cycle() argument
63 * Changes to the period and duty cycle take effect as soon as the in ntxec_pwm_set_raw_period_and_duty_cycle()
66 * duty cycle is fully written. If, in such a case, the old duty cycle in ntxec_pwm_set_raw_period_and_duty_cycle()
69 * To minimize the time between the changes to period and duty cycle in ntxec_pwm_set_raw_period_and_duty_cycle()
75 { NTXEC_REG_DUTY_HIGH, ntxec_reg8(duty >> 8) }, in ntxec_pwm_set_raw_period_and_duty_cycle()
77 { NTXEC_REG_DUTY_LOW, ntxec_reg8(duty) }, in ntxec_pwm_set_raw_period_and_duty_cycle()
80 return regmap_multi_reg_write(priv->ec->regmap, regs, ARRAY_SIZE(regs)); in ntxec_pwm_set_raw_period_and_duty_cycle()
87 unsigned int period, duty; in ntxec_pwm_apply() local
90 if (state->polarity != PWM_POLARITY_NORMAL) in ntxec_pwm_apply()
91 return -EINVAL; in ntxec_pwm_apply()
93 period = min_t(u64, state->period, MAX_PERIOD_NS); in ntxec_pwm_apply()
94 duty = min_t(u64, state->duty_cycle, period); in ntxec_pwm_apply()
97 duty /= TIME_BASE_NS; in ntxec_pwm_apply()
100 * Writing a duty cycle of zero puts the device into a state where in ntxec_pwm_apply()
101 * writing a higher duty cycle doesn't result in the brightness that it in ntxec_pwm_apply()
104 * As a workaround, write ENABLE=0 when the duty cycle is zero. in ntxec_pwm_apply()
105 * The case that something has previously set the duty cycle to zero in ntxec_pwm_apply()
108 if (state->enabled && duty != 0) { in ntxec_pwm_apply()
109 res = ntxec_pwm_set_raw_period_and_duty_cycle(chip, period, duty); in ntxec_pwm_apply()
113 res = regmap_write(priv->ec->regmap, NTXEC_REG_ENABLE, ntxec_reg8(1)); in ntxec_pwm_apply()
117 /* Disable the auto-off timer */ in ntxec_pwm_apply()
118 res = regmap_write(priv->ec->regmap, NTXEC_REG_AUTO_OFF_HI, ntxec_reg8(0xff)); in ntxec_pwm_apply()
122 return regmap_write(priv->ec->regmap, NTXEC_REG_AUTO_OFF_LO, ntxec_reg8(0xff)); in ntxec_pwm_apply()
124 return regmap_write(priv->ec->regmap, NTXEC_REG_ENABLE, ntxec_reg8(0)); in ntxec_pwm_apply()
139 struct ntxec *ec = dev_get_drvdata(pdev->dev.parent); in ntxec_pwm_probe()
143 device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent); in ntxec_pwm_probe()
145 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in ntxec_pwm_probe()
147 return -ENOMEM; in ntxec_pwm_probe()
149 priv->ec = ec; in ntxec_pwm_probe()
151 chip = &priv->chip; in ntxec_pwm_probe()
152 chip->dev = &pdev->dev; in ntxec_pwm_probe()
153 chip->ops = &ntxec_pwm_ops; in ntxec_pwm_probe()
154 chip->npwm = 1; in ntxec_pwm_probe()
156 return devm_pwmchip_add(&pdev->dev, chip); in ntxec_pwm_probe()
161 .name = "ntxec-pwm",
170 MODULE_ALIAS("platform:ntxec-pwm");