Lines Matching refs:regulator

48  * Each override should be a pair, the first entry is the name of the regulator
49 * the second is the voltage (in millivolts) to set for the given regulator.
92 * Register offsets within a LDO regulator register set
267 twl_vreg_read_1(struct twl_vreg_softc *sc, struct twl_regulator_entry *regulator,
270 return (twl_read(sc->sc_pdev, regulator->sub_dev,
271 regulator->reg_off + off, val, 1));
275 twl_vreg_write_1(struct twl_vreg_softc *sc, struct twl_regulator_entry *regulator,
278 return (twl_write(sc->sc_pdev, regulator->sub_dev,
279 regulator->reg_off + off, &val, 1));
284 * for a desired voltage and regulator
286 * @regulator: pointer to the regulator device
291 * actual supported voltages for the given regulator. If a match is found
301 struct twl_regulator_entry *regulator, int millivolts, uint8_t *vsel)
308 if (regulator->supp_voltages == NULL)
314 for (i = 0; i < regulator->num_supp_voltages; i++) {
317 if (regulator->supp_voltages[i] == UNDF)
321 delta = millivolts - (int)regulator->supp_voltages[i];
339 * twl_vreg_is_regulator_enabled - returns the enabled status of the regulator
341 * @regulator: pointer to the regulator device
354 struct twl_regulator_entry *regulator, int *enabled)
373 err = twl_vreg_read_1(sc, regulator, TWL_VREG_GRP, &state);
381 /* Check the regulator is in the application group */
383 err = twl_vreg_read_1(sc, regulator, TWL_VREG_GRP, &grp);
394 err = twl_vreg_read_1(sc, regulator, TWL_VREG_STATE, &state);
412 * twl_vreg_disable_regulator - disables a voltage regulator
414 * @regulator: pointer to the regulator device
416 * Disables the regulator which will stop the output drivers.
428 struct twl_regulator_entry *regulator)
442 /* Read the regulator CFG_GRP register */
443 err = twl_vreg_read_1(sc, regulator, TWL_VREG_GRP, &grp);
447 /* On the TWL4030 we just need to remove the regulator from all the
451 err = twl_vreg_write_1(sc, regulator, TWL_VREG_GRP, grp);
462 err = twl_vreg_write_1(sc, regulator, TWL_VREG_STATE, (grp << 5));
473 * twl_vreg_enable_regulator - enables the voltage regulator
475 * @regulator: pointer to the regulator device
477 * Enables the regulator which will enable the voltage out at the currently
491 struct twl_regulator_entry *regulator)
504 err = twl_vreg_read_1(sc, regulator, TWL_VREG_GRP, &grp);
508 /* Enable the regulator by ensuring it's in the application power group
513 /* On the TWL4030 we just need to ensure the regulator is in the right
517 err = twl_vreg_write_1(sc, regulator, TWL_VREG_GRP, grp);
523 err = twl_vreg_write_1(sc, regulator, TWL_VREG_GRP, grp);
529 err = twl_vreg_write_1(sc, regulator, TWL_VREG_STATE, (grp << 5) | 0x01);
540 * twl_vreg_write_regulator_voltage - sets the voltage level on a regulator
542 * @regulator: pointer to the regulator structure
545 * Sets the voltage output on a given regulator, if the regulator is not
557 struct twl_regulator_entry *regulator, int millivolts)
567 return (twl_vreg_disable_regulator(sc, regulator));
569 /* If the regulator has a fixed voltage then check the setting matches
572 if (regulator->supp_voltages == NULL || regulator->num_supp_voltages == 0) {
573 if (millivolts != regulator->fixed_voltage)
576 return (twl_vreg_enable_regulator(sc, regulator));
580 err = twl_vreg_millivolt_to_vsel(sc, regulator, millivolts, &vsel);
592 err = twl_vreg_write_1(sc, regulator, TWL_VREG_VSEL, (vsel & 0x1f));
594 err = twl_vreg_enable_regulator(sc, regulator);
602 regulator->name, millivolts, vsel);
608 * twl_vreg_read_regulator_voltage - reads the voltage on a given regulator
610 * @regulator: pointer to the regulator structure
611 * @millivolts: upon return will contain the voltage on the regulator
623 struct twl_regulator_entry *regulator, int *millivolts)
640 /* Check if the regulator is currently enabled */
641 err = twl_vreg_is_regulator_enabled(sc, regulator, &en);
651 if (regulator->supp_voltages == NULL || !regulator->num_supp_voltages) {
652 *millivolts = regulator->fixed_voltage;
657 err = twl_vreg_read_1(sc, regulator, TWL_VREG_VSEL, &vsel);
661 vsel &= (regulator->num_supp_voltages - 1);
662 if (regulator->supp_voltages[vsel] == UNDF) {
667 *millivolts = regulator->supp_voltages[vsel];
675 regulator->name, *millivolts, vsel);
681 * twl_vreg_get_voltage - public interface to read the voltage on a regulator
683 * @name: the name of the regulator to read the voltage of
686 * If the regulator is disabled the function will set the @millivolts to zero.
698 struct twl_regulator_entry *regulator;
708 LIST_FOREACH(regulator, &sc->sc_vreg_list, entries) {
709 if (strcmp(regulator->name, name) == 0) {
710 err = twl_vreg_read_regulator_voltage(sc, regulator, millivolts);
721 * twl_vreg_set_voltage - public interface to write the voltage on a regulator
723 * @name: the name of the regulator to read the voltage of
726 * Sets the output voltage on a given regulator. If the regulator is a fixed
728 * a variable regulator then the @millivolt value must fit within the max/min
729 * range of the given regulator.
741 struct twl_regulator_entry *regulator;
748 LIST_FOREACH(regulator, &sc->sc_vreg_list, entries) {
749 if (strcmp(regulator->name, name) == 0) {
750 err = twl_vreg_write_regulator_voltage(sc, regulator, millivolts);
761 * twl_sysctl_voltage - reads or writes the voltage for a regulator
764 * Callback for the sysctl entry for the regulator, simply used to return
765 * the voltage on a particular regulator.
777 struct twl_regulator_entry *regulator;
783 /* Find the regulator with the matching name */
784 LIST_FOREACH(regulator, &sc->sc_vreg_list, entries) {
785 if (strcmp(regulator->name, oidp->oid_name) == 0) {
791 /* Sanity check that we found the regulator */
797 twl_vreg_read_regulator_voltage(sc, regulator, &voltage);
805 * twl_add_regulator - adds single voltage regulator sysctls for the device
807 * @name: the name of the regulator
809 * @regbase: the base address of the voltage regulator registers
810 * @fixed_voltage: if a fixed voltage regulator this defines it's voltage
811 * @voltages: if a variable voltage regulator, an array of possible voltages
814 * Adds a voltage regulator to the device and also a sysctl interface for the
815 * regulator.
821 * Pointer to the new regulator entry on success, otherwise on failure NULL.
852 twl_vreg_sysctl_voltage, "I", "voltage regulator");
854 /* Finally add the regulator to list of supported regulators */
893 /* Add the regulator to the list */
1016 struct twl_regulator_entry *regulator;
1024 LIST_FOREACH_SAFE(regulator, &sc->sc_vreg_list, entries, tmp) {
1025 LIST_REMOVE(regulator, entries);
1026 sysctl_remove_oid(regulator->oid, 1, 0);
1027 free(regulator, M_DEVBUF);