Lines Matching +full:ec +full:- +full:pwm
1 // SPDX-License-Identifier: GPL-2.0+
7 * Fan control is provided via pwm interface in the range [0-255].
8 * Old AMD boards use [0-100] as range in the EC, the written value is
10 * AOKZOE are not scaled but have the same EC layout. Newer models
11 * like the 2 and X1 are [0-184] and are scaled to 0-255. OrangePi
12 * are [1-244] and scaled to 0-255.
68 /* Fan reading and PWM */
71 #define OXP_SENSOR_PWM_ENABLE_REG 0x4A /* PWM enable is 1 register long */
72 #define OXP_SENSOR_PWM_REG 0x4B /* PWM reading is 1 register long */
76 /* OrangePi fan reading and PWM */
78 #define ORANGEPI_SENSOR_PWM_ENABLE_REG 0x40 /* PWM enable is 1 register long */
79 #define ORANGEPI_SENSOR_PWM_REG 0x38 /* PWM reading is 1 register long */
82 * Different boards have different values and EC registers
158 DMI_EXACT_MATCH(DMI_BOARD_NAME, "AB05-Mendocino"),
193 DMI_EXACT_MATCH(DMI_BOARD_NAME, "NEO-01"),
199 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
206 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
213 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
220 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
221 DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 EVA-01"),
227 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
234 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
241 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
248 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
249 DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 EVA-02"),
255 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
262 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
269 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
276 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
283 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
290 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
297 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
304 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
311 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
318 DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
319 DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1Pro EVA-02"),
326 /* Helper functions to handle EC read/write */
334 return -EBUSY; in read_from_ec()
346 return -EBUSY; in read_from_ec()
356 return -EBUSY; in write_to_ec()
361 return -EBUSY; in write_to_ec()
379 return attr->mode; in tt_toggle_is_visible()
418 return -EINVAL; in tt_toggle_store()
464 return -EINVAL; in tt_toggle_show()
482 return attr->mode; in tt_led_is_visible()
507 return -EINVAL; in tt_led_store()
531 return -EINVAL; in tt_led_show()
573 return -EINVAL; in oxp_psy_ext_get_prop()
574 val->intval = raw_val; in oxp_psy_ext_get_prop()
582 val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE; in oxp_psy_ext_get_prop()
585 val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_INHIBIT_CHARGE_AWAKE; in oxp_psy_ext_get_prop()
587 val->intval = POWER_SUPPLY_CHARGE_BEHAVIOUR_AUTO; in oxp_psy_ext_get_prop()
590 return -EINVAL; in oxp_psy_ext_get_prop()
604 if (val->intval < 0 || val->intval > 100) in oxp_psy_ext_set_prop()
605 return -EINVAL; in oxp_psy_ext_set_prop()
606 return write_to_ec(OXP_X1_CHARGE_LIMIT_REG, val->intval); in oxp_psy_ext_set_prop()
608 switch (val->intval) { in oxp_psy_ext_set_prop()
619 return -EINVAL; in oxp_psy_ext_set_prop()
624 return -EINVAL; in oxp_psy_ext_set_prop()
642 .name = "oxp-charge-control",
668 /* PWM enable/disable functions */
692 return -EINVAL; in oxp_pwm_enable()
720 return -EINVAL; in oxp_pwm_disable()
748 return -EOPNOTSUPP; in oxp_pwm_read()
792 return -EOPNOTSUPP; in oxp_pwm_fan_speed()
796 /* PWM input read/write functions */
800 return -EINVAL; in oxp_pwm_input_write()
804 /* scale to range [1-244] */ in oxp_pwm_input_write()
805 val = ((val - 1) * 243 / 254) + 1; in oxp_pwm_input_write()
810 /* scale to range [0-184] */ in oxp_pwm_input_write()
823 /* scale to range [0-100] */ in oxp_pwm_input_write()
832 return -EOPNOTSUPP; in oxp_pwm_input_write()
845 /* scale from range [1-244] */ in oxp_pwm_input_read()
846 *val = ((*val - 1) * 254 / 243) + 1; in oxp_pwm_input_read()
854 /* scale from range [0-184] */ in oxp_pwm_input_read()
870 /* scale from range [0-100] */ in oxp_pwm_input_read()
933 return -EOPNOTSUPP; in oxp_platform_read()
950 return -EINVAL; in oxp_platform_write()
952 /* Enable PWM and set to max speed */ in oxp_platform_write()
966 return -EOPNOTSUPP; in oxp_platform_write()
969 /* Known sensors in the OXP EC controllers */
973 HWMON_CHANNEL_INFO(pwm,
1018 struct device *dev = &pdev->dev; in oxp_platform_probe()
1040 .name = "oxp-platform",
1054 return -ENODEV; in oxp_platform_init()
1056 board = (enum oxp_board)(unsigned long)dmi_entry->driver_data; in oxp_platform_init()
1061 * to tell them apart is the CPU. Old Intel boards have an unsupported EC. in oxp_platform_init()
1064 return -ENODEV; in oxp_platform_init()
1085 MODULE_DESCRIPTION("Platform driver that handles EC sensors of OneXPlayer devices");