|
|
@@ -15,31 +15,109 @@
|
|
|
#include <linux/poll.h>
|
|
|
#include <linux/mutex.h>
|
|
|
#include <linux/delay.h>
|
|
|
-#include "light_ring.h"
|
|
|
+#include <asm/io.h>
|
|
|
+#include "gpioregs.h"
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
extern struct kobject *vfiec_kobj;
|
|
|
|
|
|
|
|
|
+static int wait_ibf(void)
|
|
|
+{
|
|
|
+ int i = 0;
|
|
|
+ while (inb(EC_CMD_PORT) & EC_IBF)
|
|
|
+ {
|
|
|
+ if (++i > TIMEOUT_LOOPS)
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ udelay(1);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int wait_obf(void)
|
|
|
+{
|
|
|
+ int i = 0;
|
|
|
+ while (!(inb(EC_CMD_PORT) & EC_OBF))
|
|
|
+ {
|
|
|
+ if (++i > TIMEOUT_LOOPS)
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ udelay(1);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+static int oem_ec_read_ram(uint8_t page, uint8_t offset, uint8_t *data)
|
|
|
+{
|
|
|
+ unsigned char WEC, REC;
|
|
|
+ switch(page)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ {
|
|
|
+ WEC = 0x96;
|
|
|
+ REC = 0x95;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ WEC = 0x98;
|
|
|
+ REC = 0x97;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ WEC = EC_VERSION_WEC;
|
|
|
+ REC = EC_VERSION_REC;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (wait_ibf() < 0)
|
|
|
+ return -1;
|
|
|
+ outb(REC, EC_CMD_PORT);
|
|
|
+
|
|
|
+ if (wait_ibf() < 0)
|
|
|
+ return -1;
|
|
|
+ outb(offset, EC_DATA_PORT);
|
|
|
+
|
|
|
+ if (wait_obf() < 0)
|
|
|
+ return -1;
|
|
|
+ *data = inb(EC_DATA_PORT);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
/* ==================== mode ==================== */
|
|
|
static ssize_t fw_version_show(struct kobject *kobj, struct kobj_attribute *attr,
|
|
|
char *buf)
|
|
|
{
|
|
|
+ unsigned char data[4] = {0};
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ for(i = 0; i < 4; i++)
|
|
|
+ {
|
|
|
+ oem_ec_read_ram(2, i, &data[i]);
|
|
|
+ }
|
|
|
// 这里待完善,获取真实的,版本号
|
|
|
- memcpy(buf, "VF3965U.0x21", strlen("VF3965U.0x21"));
|
|
|
+ sprintf(buf, "%02x%02x%02x%02x", data[0], data[1], data[2], data[3]);
|
|
|
|
|
|
- return strlen("VF3965U.0x21");
|
|
|
+ return 8;
|
|
|
}
|
|
|
|
|
|
-static ssize_t mode_store(struct kobject *kobj, struct kobj_attribute *attr,
|
|
|
+static ssize_t fw_version_store(struct kobject *kobj, struct kobj_attribute *attr,
|
|
|
const char *buf, size_t count)
|
|
|
{
|
|
|
- printk("mode_store kernel rev:%s\n", buf);
|
|
|
+ printk("fw_version_store kernel rev:%s\n", buf);
|
|
|
return count;
|
|
|
}
|
|
|
|
|
|
static struct kobj_attribute ec_version_attr =
|
|
|
- __ATTR(fw_version, 0444, fw_version_show, mode_store);
|
|
|
+ __ATTR(fw_version, 0444, fw_version_show, fw_version_store);
|
|
|
|
|
|
/* ==================== 属性组 ==================== */
|
|
|
static struct attribute *ec_version_attrs[] = {
|
|
|
@@ -53,7 +131,7 @@ static struct attribute_group ec_version_attr_group = {
|
|
|
|
|
|
int ec_version_init(void)
|
|
|
{
|
|
|
- int ret;
|
|
|
+ int ret = 0;
|
|
|
|
|
|
/* 创建属性文件 */
|
|
|
ret = sysfs_create_group(vfiec_kobj, &ec_version_attr_group);
|