const char* ztemt_get_hw_wifi(void) { uint32_t tablesize; int hw_type; uint32_t i = 0; const struct hardware_id_map_st *pts= hardware_id_map; if ( pts == NULL ) return NULL; tablesize=sizeof(hardware_id_map)/sizeof(hardware_id_map[0]); ztemt_hw_version_debug("tablesize=%d\n",tablesize); hw_type=ztemt_get_hw_id(); ztemt_hw_version_debug("ztemt_hw_mv=%d\n",ztemt_hw_mv); while (i < tablesize) { if ((pts[i].hw_type == hw_type) && (pts[i].low_mv <= ztemt_hw_mv) && (ztemt_hw_mv <= pts[i].high_mv)) break; else i++; } if ( i < tablesize ){ ztemt_hw_version_debug("hw_wifi=%s\n", pts[i].hw_wifi); return pts[i].hw_wifi; } else return "unknow"; }
int ztemt_get_hw_id(void) { if(ztemt_hw_id >= 0) return ztemt_hw_id; #ifdef CONFIG_ZTEMT_HW_VERSION_NX507J ztemt_hw_id = ztemt_get_hardware_type_2( hardware_id_map, ARRAY_SIZE(hardware_id_map), ztemt_hw_mv,ztemt_hw_mv_2); ztemt_hw_version_debug("hw_id_mv=%d mv , hw_id_mv_2=%d mv ,hw_id=%d ,hw_ver=%s\n", ztemt_hw_mv,ztemt_hw_mv_2,ztemt_hw_id,hardware_id_map[ztemt_hw_id].hw_ver); #else ztemt_hw_id = ztemt_get_hardware_type( hardware_id_map, ARRAY_SIZE(hardware_id_map), ztemt_hw_mv); //printk("hw_id_mv=%d mv hw_id=%d hw_ver=%s\n", //ztemt_hw_mv,ztemt_hw_id,hardware_id_map[ztemt_hw_id].hw_ver); ztemt_hw_version_debug("hw_id_mv=%d mv hw_id=%d hw_ver=%s\n", ztemt_hw_mv,ztemt_hw_id,hardware_id_map[ztemt_hw_id].hw_ver); #endif return ztemt_hw_id; }
static ssize_t ztemt_hw_version_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { ztemt_get_hw_version(buf); //printk("%s : %d : version=%s\n",__func__,__LINE__,buf); ztemt_hw_version_debug("version=%s\n",buf); return sprintf(buf,"%s",buf); }
int __init ztemt_hw_version_init(void) { int rc = 0; ztemt_hw_version_debug("ztemt_hw_version creat attributes start \n"); //hw_version__kobj = kobject_create_and_add("ztemt_hw_version", kernel_kobj); hw_version_kobj = kobject_create_and_add("ztemt_hw_version", NULL); if (!hw_version_kobj){ printk(KERN_ERR "%s: ztemt_hw_version kobj create error\n", __func__); return -ENOMEM; } rc=sysfs_create_group(hw_version_kobj,&ztemt_hw_version_attr_group); if(rc) printk(KERN_ERR "%s: failed to create ztemt_hw_version group attributes\n", __func__); ztemt_hw_version_debug("ztemt_hw_version creat attributes end \n"); return rc; }
int ztemt_get_hw_id(void) { if(ztemt_hw_id >= 0) return ztemt_hw_id; ztemt_hw_id = ztemt_get_hardware_type_gpio( hardware_id_map, ARRAY_SIZE(hardware_id_map), board_type_gpio_str); ztemt_hw_version_debug("hw_id=%d",ztemt_hw_id); return ztemt_hw_id; }
static ssize_t ztemt_hw_config_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { const struct hardware_id_map_st *pts_tmp; pts_tmp=ztemt_get_table_item(); if(pts_tmp==NULL) return sprintf(buf,"%s","unknown"); ztemt_hw_version_debug("hw_config=%s\n", pts_tmp->hw_config); return sprintf(buf,"%s",pts_tmp->hw_config); }
const struct hardware_id_map_st *ztemt_get_table_item(void) { uint32_t tablesize; int hw_type; uint32_t i = 0; char * gpio_str_temp=board_type_gpio_str; int gpio_value_A,gpio_value_B,gpio_value_C; const struct hardware_id_map_st *pts= hardware_id_map; if ( pts == NULL ) return NULL; tablesize=sizeof(hardware_id_map)/sizeof(hardware_id_map[0]); ztemt_hw_version_debug("tablesize=%d\n",tablesize); hw_type=ztemt_get_hw_id(); ztemt_hw_version_debug("%s=%s\n",__func__, gpio_str_temp); sscanf(gpio_str_temp ,"%d,%d,%d", &gpio_value_A, &gpio_value_B, &gpio_value_C); while (i < tablesize) { if ((pts[i].hw_type == hw_type) && (pts[i].gpio_A == gpio_value_A) && (pts[i].gpio_B == gpio_value_B) && (pts[i].gpio_C == gpio_value_C)) break; else i++; } if ( i < tablesize ){ return &pts[i]; } else return NULL; }
int ztemt_get_hw_id(void) { if(ztemt_hw_id >= 0) return ztemt_hw_id; ztemt_hw_id = ztemt_get_hardware_type( hardware_id_map, ARRAY_SIZE(hardware_id_map), ztemt_hw_mv); ztemt_hw_version_debug("hw_id_mv=%d mv hw_id=%d hw_ver=%s\n", ztemt_hw_mv,ztemt_hw_id,hardware_id_map[ztemt_hw_id].hw_ver); return ztemt_hw_id; }