#define MCU_WOL_REG 0x21
#define MCU_FAN_CTRL 0x88
#define MCU_USB_PCIE_SWITCH 0x33 /* VIM3 only */
+#define MCU_PWR_OFF_CMD 0x80
#define KHADAS_FAN_TRIG_TEMP_LEVEL0 50 // 50 degree if not set
#define KHADAS_FAN_TRIG_TEMP_LEVEL1 60 // 60 degree if not set
struct i2c_client *client;
struct class *wol_class;
struct class *usb_pcie_switch_class;
+ struct class *mcu_class;
int wol_enable;
u8 usb_pcie_switch_mode;
struct khadas_fan_data fan_data;
return sprintf(buf, "%d\n", g_mcu_data->usb_pcie_switch_mode);
}
+static ssize_t store_mcu_poweroff(struct class *cls, struct class_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ int val;
+ u8 reg;
+
+ if (kstrtoint(buf, 0, &val))
+ return -EINVAL;
+
+ if (1 != val)
+ return -EINVAL;
+
+ reg = (u8)val;
+ ret = mcu_i2c_write_regs(g_mcu_data->client, MCU_PWR_OFF_CMD, ®, 1);
+ if (ret < 0) {
+ printk("write poweroff cmd error\n");
+
+ return ret;
+ }
+
+ return count;
+}
+
static struct class_attribute wol_class_attrs[] = {
__ATTR(enable, 0644, show_wol_enable, store_wol_enable),
};
__ATTR(mode, 0644, show_usb_pcie_switch_mode, store_usb_pcie_switch_mode),
};
+static struct class_attribute mcu_class_attrs[] = {
+ __ATTR(poweroff, 0644, NULL, store_mcu_poweroff),
+};
+
static void create_mcu_attrs(void)
{
int i;
return;
}
+ g_mcu_data->mcu_class = class_create(THIS_MODULE, "mcu");
+ if (IS_ERR(g_mcu_data->mcu_class)) {
+ pr_err("create mcu_class debug class fail\n");
+ return;
+ }
+
for (i = 0; i < ARRAY_SIZE(wol_class_attrs); i++) {
if (class_create_file(g_mcu_data->wol_class, &wol_class_attrs[i]))
pr_err("create wol attribute %s fail\n", wol_class_attrs[i].attr.name);
}
+ for (i = 0; i < ARRAY_SIZE(mcu_class_attrs); i++) {
+ if (class_create_file(g_mcu_data->mcu_class, &mcu_class_attrs[i]))
+ pr_err("create mcu attribute %s fail\n", mcu_class_attrs[i].attr.name);
+ }
+
if (is_mcu_fan_control_available()) {
g_mcu_data->fan_data.fan_class = class_create(THIS_MODULE, "fan");
if (IS_ERR(g_mcu_data->fan_data.fan_class)) {