/* * Determine the number of supported PWMs. The EC does not return the number * of PWMs it supports directly, so we have to read the pwm duty cycle for * subsequent channels until we get an error.
*/ staticint cros_ec_num_pwms(struct cros_ec_device *ec)
{ int i, ret;
/* The index field is only 8 bits */ for (i = 0; i <= U8_MAX; i++) { /* * Note that this function is only called when use_pwm_type is * false. With use_pwm_type == true the number of PWMs is fixed.
*/
ret = cros_ec_pwm_get_duty(ec, false, i); /* * We look for SUCCESS, INVALID_COMMAND, or INVALID_PARAM * responses; everything else is treated as an error. * The EC error codes map to -EOPNOTSUPP and -EINVAL, * so check for those.
*/ switch (ret) { case -EOPNOTSUPP: /* invalid command */ return -ENODEV; case -EINVAL: /* invalid parameter */ return i; default: if (ret < 0) return ret; break;
}
}
/* * The device tree binding for this device is special as it only uses a * single cell (for the hwid) and so doesn't provide a default period. * This isn't a big problem though as the hardware only supports a * single period length, it's just a bit ugly to make this fit into the * pwm core abstractions. So initialize the period here, as * of_pwm_xlate_with_flags() won't do that for us.
*/ for (i = 0; i < npwm; ++i)
chip->pwms[i].args.period = EC_PWM_MAX_DUTY;
dev_dbg(dev, "Probed %u PWMs\n", chip->npwm);
ret = devm_pwmchip_add(dev, chip); if (ret < 0) return dev_err_probe(dev, ret, "cannot register PWM\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.