static ssize_t boot_show(struct kobject *kobj, struct attribute *a, char *buf) { if (!strncmp(a->name, MD_SYSFS_ATTR, strlen(MD_SYSFS_ATTR)) && md_show) { return md_show(buf); } else if (!strncmp(a->name, INFO_SYSFS_ATTR, strlen(INFO_SYSFS_ATTR))) { return sprintf(buf, "%x%x%x%X%s %X%X%X%X%s\n", get_reg_chip_code(), get_reg_chip_hw_subcode(), get_reg_chip_hw_ver(), get_reg_chip_sw_ver(), get_chip_str(get_chip_eco_ver()), get_chip_code(), get_chip_hw_subcode(), get_chip_hw_ver(), get_chip_sw_ver(), get_chip_str(get_chip_ver())); } //kaka_11_0622 add else if(!strncmp(a->name, FACTORY_RTC_ATTR, strlen(FACTORY_RTC_ATTR)) ){ return factory_mode_show(buf); } //kaka_11_0622 end else { return sprintf(buf, "%d\n", g_boot_mode); } }
static ssize_t boot_show(struct kobject *kobj, struct attribute *a, char *buf) { if (!strncmp(a->name, MD_SYSFS_ATTR, strlen(MD_SYSFS_ATTR)) && md_show) { return md_show(buf); } else if (!strncmp(a->name, INFO_SYSFS_ATTR, strlen(INFO_SYSFS_ATTR))) { return sprintf(buf, "%04X%04X%04X%04X %x\n", get_chip_code(), get_chip_hw_subcode(), get_chip_hw_ver_code(), get_chip_sw_ver_code(), mt_get_chip_sw_ver()); } else { return sprintf(buf, "%d\n", g_boot_mode); } }
static int __init boot_mod_init(void) { int ret; /* allocate device major number */ if (alloc_chrdev_region(&boot_dev_num, 0, 1, BOOT_DEV_NAME) < 0) { printk("[%s] fail to register chrdev\n",MOD); return -1; } /* add character driver */ cdev_init(&boot_cdev, &boot_fops); ret = cdev_add(&boot_cdev, boot_dev_num, 1); if (ret < 0) { printk("[%s] fail to add cdev\n",MOD); return ret; } /* create class (device model) */ boot_class = class_create(THIS_MODULE, BOOT_DEV_NAME); if (IS_ERR(boot_class)) { printk("[%s] fail to create class\n",MOD); return (int)boot_class; } boot_device = device_create(boot_class, NULL, boot_dev_num, NULL, BOOT_DEV_NAME); if (IS_ERR(boot_device)) { printk("[%s] fail to create device\n",MOD); return (int)boot_device; } /* add kobject */ ret = kobject_init_and_add(&boot_kobj, &boot_ktype, &(boot_device->kobj), BOOT_SYSFS); if (ret < 0) { printk("[%s] fail to add kobject\n",MOD); return ret; } printk("[%s] chip hw code = 0x%x\n",MOD,get_chip_code()); printk("[%s] chip eco version = 0x%x\n",MOD,get_chip_eco_ver()); /* create proc entry at /proc/boot_mode */ create_proc_read_entry("boot_mode", S_IRUGO, NULL, boot_mode_proc, NULL); return 0; }
static int __init boot_mod_init(void) { int ret; /* allocate device major number */ if (alloc_chrdev_region(&boot_dev_num, 0, 1, BOOT_DEV_NAME) < 0) { printk("[%s] fail to register chrdev\n",MOD); return -1; } /* add character driver */ cdev_init(&boot_cdev, &boot_fops); ret = cdev_add(&boot_cdev, boot_dev_num, 1); if (ret < 0) { printk("[%s] fail to add cdev\n",MOD); return ret; } /* create class (device model) */ boot_class = class_create(THIS_MODULE, BOOT_DEV_NAME); if (IS_ERR(boot_class)) { printk("[%s] fail to create class\n",MOD); return (int)boot_class; } boot_device = device_create(boot_class, NULL, boot_dev_num, NULL, BOOT_DEV_NAME); if (IS_ERR(boot_device)) { printk("[%s] fail to create device\n",MOD); return (int)boot_device; } /* add kobject */ ret = kobject_init_and_add(&boot_kobj, &boot_ktype, &(boot_device->kobj), BOOT_SYSFS); if (ret < 0) { printk("[%s] fail to add kobject\n",MOD); return ret; } /* read chip version */ ret = load_chip_desp(&g_chip_desp); if (ret < 0) { printk("[%s] fail to load chip verion", MOD); return ret; } printk("[%s] APHW_CODE = 0x%x\n",MOD,get_chip_code()); printk("[%s] APHW_VER = 0x%x\n",MOD,get_chip_eco_ver()); /* create proc entry at /proc/boot_mode */ create_proc_read_entry("boot_mode", S_IRUGO, NULL, boot_mode_proc, NULL); if(g_boot_mode == META_BOOT || g_boot_mode == ADVMETA_BOOT) { /* register driver and create sysfs files */ ret = driver_register(&meta_com_type_info); if (ret) { printk("fail to register META COM TYPE driver\n"); } ret = driver_create_file(&meta_com_type_info, &driver_attr_meta_com_type_info); if (ret) { printk("[BOOT INIT] Fail to create META COM TPYE sysfs file\n"); } ret = driver_register(&meta_com_id_info); if (ret) { printk("fail to register META COM ID driver\n"); } ret = driver_create_file(&meta_com_id_info, &driver_attr_meta_com_id_info); if (ret) { printk("[BOOT INIT] Fail to create META COM ID sysfs file\n"); } } return 0; }
void get_ap_platform_ver(char * ver) { sprintf(ver, "MT%04x_S%02x", get_chip_code(), (get_chip_sw_ver_code()&0xFF)); }
unsigned int mt_get_chip_id(void) { unsigned int chip_id = get_chip_code(); /*convert id if necessary*/ return chip_id; }