Exemplo n.º 1
0
static ssize_t show_control(struct device *d,
		struct device_attribute *attr, char *buf)
{
	char buffer[7];
	convert_debug_level_int(kernel_sec_get_debug_level(), buffer);

	return sprintf(buf, "%s\n", buffer);
}
static ssize_t debug_level_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	char buffer[7];
	convert_debug_level_int(kernel_sec_get_debug_level(), buffer);

	return snprintf(buf, sizeof(buffer)+1, "%s\n", buffer);

}
Exemplo n.º 3
0
static ssize_t debug_level_show(struct device *dev,
                                struct device_attribute *attr, char *buf)
{
    char buffer[7];
#if defined(CONFIG_SEC_DEBUG)
    convert_debug_level_int(kernel_sec_get_debug_level(), buffer);
#endif
    return snprintf(buf, sizeof(buffer)+1, "%s\n", buffer);

}
Exemplo n.º 4
0
void enter_upload_mode(unsigned long val)
{
	bool uploadmode = true;
	int i;

	// not to enter forced upload mode in boot PARAM_LOW
	if( KERNEL_SEC_DEBUG_LEVEL_LOW == kernel_sec_get_debug_level() )
		return;

	for (i = 0; i < g_pdata->nbuttons; i++)
	{
		struct gpio_keys_button *button = &g_pdata->buttons[i];
		if(gpio_get_value(button->gpio))
		{
			uploadmode = false;
			break;
		}
	}

	if(uploadmode)
	{
		if (kernel_sec_viraddr_wdt_reset_reg)
		{
		//dump_debug_info_forced_ramd_dump();
#ifdef CONFIG_KERNEL_DEBUG_SEC
#ifdef CONFIG_TARGET_LOCALE_KOR
		local_irq_disable();
		local_fiq_disable();
#endif /* CONFIG_TARGET_LOCALE_KOR */
#endif /* CONFIG_KERNEL_DEBUG_SEC */
		kernel_sec_set_cp_upload();
		kernel_sec_save_final_context(); // Save theh final context.
		kernel_sec_set_upload_cause(UPLOAD_CAUSE_FORCED_UPLOAD);
		kernel_sec_hw_reset(false);      // Reboot.
		}
	}
}
Exemplo n.º 5
0
void input_event(struct input_dev *dev,
		 unsigned int type, unsigned int code, int value)
{
	unsigned long flags;
/*
 *  Forced upload mode key string (tkhwang)
 */
     
#ifdef CONFIG_KERNEL_DEBUG_SEC
    static bool first=0, second=0, third = 0;
    
#if defined (CONFIG_KEYPAD_S3C)

    if(strcmp(dev->name,"s3c-keypad")==0)
    {
        if(value)
        {
            if(code==KERNEL_SEC_FORCED_UPLOAD_1ST_KEY)
            {
                first =1;
            }
            if(first==1 && code==KERNEL_SEC_FORCED_UPLOAD_2ND_KEY)
            {
                if ( (KERNEL_SEC_DEBUG_LEVEL_MID == kernel_sec_get_debug_level()) ||
                	    KERNEL_SEC_DEBUG_LEVEL_HIGH == kernel_sec_get_debug_level() )
                {
                    // Display the working callstack for the debugging.
                    dump_stack();

                    if (kernel_sec_viraddr_wdt_reset_reg)
                    {
                       kernel_sec_set_cp_upload();
                       kernel_sec_save_final_context(); // Save theh final context.
                       kernel_sec_set_upload_cause(UPLOAD_CAUSE_FORCED_UPLOAD);
                       kernel_sec_hw_reset(false);      // Reboot.
                    }
                 }                
            }                
        }
        else
        {
            if(code==KERNEL_SEC_FORCED_UPLOAD_1ST_KEY)
            {
                first = 0;
            }
        }
    }
#endif //CONFIG_KEYPAD_S3C

#if defined (CONFIG_KEYBOARD_GPIO)    
    if(strcmp(dev->name,"gpio-keys")==0)
    {
        if(value)
        {
            if(code == KEY_VOLUMEUP)
                first = true;
                
            if(code == KEY_POWER)
                second = true;

		if(code == KEY_VOLUMEDOWN)
                third = true;
                
            if(first&&second&&third)
            {
            
                if (kernel_sec_viraddr_wdt_reset_reg)
                {
                printk("[%s][line:%d]\n",__func__, __LINE__);
                      kernel_sec_set_cp_upload();
                      kernel_sec_save_final_context(); // Save theh final context.
                      kernel_sec_set_upload_cause(UPLOAD_CAUSE_FORCED_UPLOAD);
                      kernel_sec_hw_reset(false);      // Reboot.
                }
            }
        }
        else
        {
            if(code == KEY_VOLUMEUP)
                first = false;

            if(code == KEY_POWER)
                second = false;

		if(code == KEY_VOLUMEDOWN)
                third = false;
		     
        }
    }
#endif  //CONFIG_KEYBOARD_GPIO

#endif // CONFIG_KERNEL_DEBUG_SEC


	if (is_event_supported(type, dev->evbit, EV_MAX)) {

		spin_lock_irqsave(&dev->event_lock, flags);
		add_input_randomness(type, code, value);
		input_handle_event(dev, type, code, value);
		spin_unlock_irqrestore(&dev->event_lock, flags);
	}
}
static int max77693_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max77693_dev *max77693;
	struct max77693_platform_data *pdata = i2c->dev.platform_data;
	u8 reg_data;
	int ret = 0;

	max77693 = kzalloc(sizeof(struct max77693_dev), GFP_KERNEL);
	if (max77693 == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, max77693);
	max77693->dev = &i2c->dev;
	max77693->i2c = i2c;
	max77693->irq = i2c->irq;
	max77693->type = id->driver_data;
	if (pdata) {
		max77693->irq_base = pdata->irq_base;
		max77693->irq_gpio = pdata->irq_gpio;
		max77693->wakeup = pdata->wakeup;
	} else
		goto err;

	mutex_init(&max77693->iolock);

	if (max77693_read_reg(i2c, MAX77693_PMIC_REG_PMIC_ID2, &reg_data) < 0) {
		dev_err(max77693->dev,
			"device not found on this channel (this is not an error)\n");
		ret = -ENODEV;
		goto err;
	} else {
		/* print rev */
		max77693->pmic_rev = (reg_data & 0x7);
		max77693->pmic_ver = ((reg_data & 0xF8) >> 0x3);
		pr_info("%s: device found: rev.0x%x, ver.0x%x\n", __func__,
				max77693->pmic_rev, max77693->pmic_ver);
	}

#if defined(CONFIG_MACH_JF_VZW) || defined(CONFIG_MACH_JF_LGT)
	if (kernel_sec_get_debug_level() == KERNEL_SEC_DEBUG_LEVEL_LOW) {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, 0x04);
	} else {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, 0x0c);
	}
#else
	if (kernel_sec_get_debug_level() == KERNEL_SEC_DEBUG_LEVEL_LOW) {
		max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, 0x04);
	} else {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77693_write_reg(i2c, MAX77693_PMIC_REG_MAINCTRL1, 0x0c);
	}
#endif
	max77693_update_reg(i2c, MAX77693_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30);

	max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
	i2c_set_clientdata(max77693->muic, max77693);

	max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
	i2c_set_clientdata(max77693->haptic, max77693);

	ret = max77693_irq_init(max77693);
	if (ret < 0)
		goto err_irq_init;

	ret = mfd_add_devices(max77693->dev, -1, max77693_devs,
			ARRAY_SIZE(max77693_devs), NULL, 0);
	if (ret < 0)
		goto err_mfd;

	device_init_wakeup(max77693->dev, pdata->wakeup);

	return ret;

err_mfd:
	mfd_remove_devices(max77693->dev);
err_irq_init:
	i2c_unregister_device(max77693->muic);
	i2c_unregister_device(max77693->haptic);
err:
	kfree(max77693);
	return ret;
}
Exemplo n.º 7
0
void input_event(struct input_dev *dev,
		 unsigned int type, unsigned int code, int value)
{
	unsigned long flags;

/*
 *  Forced upload mode key string (tkhwang)
 */
     
#ifdef CONFIG_KERNEL_DEBUG_SEC

    static int first=0, second=0;

    if(strcmp(dev->name,"s3c-keypad")==0)
    {
        if(value)
        {
            if(code==KERNEL_SEC_FORCED_UPLOAD_1ST_KEY)
            {
                first =1;
            }
            if(first==1 && code==KERNEL_SEC_FORCED_UPLOAD_2ND_KEY)
            {

                printk(KERN_ERR"level %d  reg %x \n",kernel_sec_get_debug_level(), kernel_sec_viraddr_wdt_reset_reg);
               			
                if ( (KERNEL_SEC_DEBUG_LEVEL_MID == kernel_sec_get_debug_level()) ||
                	    KERNEL_SEC_DEBUG_LEVEL_HIGH == kernel_sec_get_debug_level() )
                {

                printk(KERN_ERR" USER Press volume key + Power key ==> Force RAM DUMP \n");

#if 0 
                    // Display the working callstack for the debugging.
                    dump_stack();

                    if (kernel_sec_viraddr_wdt_reset_reg)
                    {
                       kernel_sec_set_cp_upload();
                       kernel_sec_save_final_context(); // Save theh final context.
                       kernel_sec_set_upload_cause(UPLOAD_CAUSE_FORCED_UPLOAD);
                       kernel_sec_hw_reset(false);      // Reboot.
                    }


#endif 
                 }                
           }
        }
        else
        {
            if(code==KERNEL_SEC_FORCED_UPLOAD_1ST_KEY)
            {
                first = 0;
            }
        }
    }
#endif // CONFIG_KERNEL_DEBUG_SEC    

	if (is_event_supported(type, dev->evbit, EV_MAX)) {

		spin_lock_irqsave(&dev->event_lock, flags);
		add_input_randomness(type, code, value);
		input_handle_event(dev, type, code, value);
		spin_unlock_irqrestore(&dev->event_lock, flags);
	}
}
Exemplo n.º 8
0
static void keypad_timer_handler(unsigned long data)
{
	u32 press_mask;
	u32 release_mask;
	u32 restart_timer = 0;
	int i,col;
	struct s3c_keypad *pdata = (struct s3c_keypad *)data;
	struct input_dev *dev = pdata->dev;

	keypad_scan();


	for(col=0; col < KEYPAD_COLUMNS; col++) {
		press_mask = ((keymask[col] ^ prevmask[col]) & keymask[col]); 
		release_mask = ((keymask[col] ^ prevmask[col]) & prevmask[col]); 

#ifdef CONFIG_CPU_FREQ
#if USE_PERF_LEVEL_KEYPAD
		if (press_mask || release_mask)
			set_dvfs_target_level(LEV_400MHZ);
#endif
#endif
		i = col * KEYPAD_ROWS;

		while (press_mask) {
			if (press_mask & 1) {
				if(s3ckeypad_evt_enable_status){		//NAGSM_Android_SEL_Kernel_Aakash_20100319

					#if defined(CONFIG_KEPLER_VER_B2) || defined(CONFIG_KEPLER_VER_B4) || defined(CONFIG_T959_VER_B5)|| defined (CONFIG_S5PC110_VIBRANTPLUS_BOARD)
						if((i != 1) && (i !=2)){
							input_report_key(dev,pdata->keycodes[i],1);
							printk("\nkey Pressed  : key %d map %d\n",i, pdata->keycodes[i]);
						}
					#elif defined(CONFIG_HAWK_VER_B0)
						if((i != 0) && (i !=1) && (i != 2) && (i !=3) ){
							input_report_key(dev,pdata->keycodes[i],1);
							printk("\nkey Pressed  : key %d map %d\n",i, pdata->keycodes[i]);
						}
					#else					
				input_report_key(dev,pdata->keycodes[i],1);
				printk("\nkey Pressed  : key %d map %d\n",i, pdata->keycodes[i]);
					#endif
				}
						}
			press_mask >>= 1;
			i++;
		}

		i = col * KEYPAD_ROWS;

		while (release_mask) {
			if (release_mask & 1) {
				if(s3ckeypad_evt_enable_status){		//NAGSM_Android_SEL_Kernel_Aakash_20100319
					#if defined(CONFIG_KEPLER_VER_B2) || defined(CONFIG_KEPLER_VER_B4) || defined(CONFIG_T959_VER_B5) || defined(CONFIG_HAWK_VER_B0)|| defined (CONFIG_S5PC110_VIBRANTPLUS_BOARD)
						if((i != 1) && (i !=2)){
							input_report_key(dev,pdata->keycodes[i],0);
							printk("\nkey Released : %d  map %d\n",i,pdata->keycodes[i]);
						}
					#else					
				input_report_key(dev,pdata->keycodes[i],0);
				printk("\nkey Released : %d  map %d\n",i,pdata->keycodes[i]);
					#endif
				}
				
#ifdef CONFIG_KERNEL_DEBUG_SEC
#if defined(CONFIG_S5PC110_KEPLER_BOARD) || defined(CONFIG_S5PC110_FLEMING_BOARD) || defined(CONFIG_T959_VER_B5) || defined(CONFIG_HAWK_VER_B0) || defined (CONFIG_S5PC110_VIBRANTPLUS_BOARD)

	#if defined(CONFIG_KEPLER_VER_B2) || defined(CONFIG_KEPLER_VER_B4) || defined(CONFIG_T959_VER_B5) || defined(CONFIG_HAWK_VER_B0) || defined (CONFIG_S5PC110_VIBRANTPLUS_BOARD)
		if((i != 1) && (i !=2)){
			dump_mode_key_sequence[dump_mode_key_count%DUMP_SEQUENCE_COUNT] = i;
			dump_mode_key_count++;
		}
	#endif
	#if defined(CONFIG_KEPLER_VER_B0)
	dump_mode_key_sequence[dump_mode_key_count%DUMP_SEQUENCE_COUNT] = i;
	dump_mode_key_count++;
	#endif

       {
            // check time inverval between force upload key sequence input
		int this_cpu;
		this_cpu = smp_processor_id();
		unsigned long nanosec_rem;
						
		dump_mode_key_pressed = cpu_clock(this_cpu);
		nanosec_rem = do_div(dump_mode_key_pressed, 1000000000);

		if ((dump_mode_key_pressed-dump_mode_key_pressed_prev>=2) && dump_mode_key_pressed_prev!=0)
                {
			forced_dump_time_limit=1;
              printk("force upload long time : %ul\n ",
			dump_mode_key_pressed-dump_mode_key_pressed_prev);
                 }
	
		dump_mode_key_pressed_prev=dump_mode_key_pressed;
						
	}

	if(i == PRESSED_DOWN){	
		if(is_first_key_down == 1)
		{	// when down key is pressed twice, will check whether pressed keys are same as dump seqence 
			is_dump_sequence = 0;

			//for(dump_compare_count=0; dump_compare_count<DUMP_SEQUENCE_COUNT; dump_compare_count++)
				//printk("dump_mode_key_sequence[%d] : %d\n",(dump_mode_key_count + dump_compare_count)%DUMP_SEQUENCE_COUNT, dump_mode_key_sequence[(dump_mode_key_count + dump_compare_count)%DUMP_SEQUENCE_COUNT]);
			
			for(dump_compare_count=0; dump_compare_count<DUMP_SEQUENCE_COUNT; dump_compare_count++)
			{			
				//printk("forced_dump_sequence[%d] : %d, dump_mode_key_sequence[%d] : %d\n",dump_compare_count, forced_dump_sequence[dump_compare_count],(dump_mode_key_count + dump_compare_count)%DUMP_SEQUENCE_COUNT, dump_mode_key_sequence[(dump_mode_key_count + dump_compare_count)%DUMP_SEQUENCE_COUNT]);
				if(forced_dump_sequence[dump_compare_count] == dump_mode_key_sequence[((dump_mode_key_count + dump_compare_count) % DUMP_SEQUENCE_COUNT)]){
					is_dump_sequence++;
					continue;
				}else
				{	
					//printk("This is not dump sequence.\n");
					is_dump_sequence = 0;
					break;
				}
			}
			
			if(is_dump_sequence == DUMP_SEQUENCE_COUNT)
			{		
                  if (forced_dump_time_limit==1)
                                {
                                        // case of long time between force upload key sequence
                       forced_dump_time_limit=0;
                       is_dump_sequence=0;
                       dump_mode_key_pressed_prev=0;
                       printk("Dump Mode Fail\n");
                                }
                  else	
                                {	

						if( (KERNEL_SEC_DEBUG_LEVEL_MID == kernel_sec_get_debug_level()) || 
							  (KERNEL_SEC_DEBUG_LEVEL_HIGH == kernel_sec_get_debug_level()) )	
							{
								
					printk("Now going to Dump Mode\n");
					if (kernel_sec_viraddr_wdt_reset_reg)
					{
						kernel_sec_set_cp_upload();
						kernel_sec_save_final_context(); // Save theh final context.
						kernel_sec_set_upload_cause(UPLOAD_CAUSE_FORCED_UPLOAD);
						kernel_sec_hw_reset(FALSE); 	 // Reboot.
					}
							}

            }
			}
		}else{
			is_first_key_down = 1;
		}
	}else{
		#if defined(CONFIG_KEPLER_VER_B2) || defined(CONFIG_KEPLER_VER_B4) || defined(CONFIG_T959_VER_B5) || defined(CONFIG_HAWK_VER_B0)|| defined (CONFIG_S5PC110_VIBRANTPLUS_BOARD)
			if((i != 1) && (i !=2)){
				is_first_key_down = 0;
			}
		#endif
		#if defined(CONFIG_KEPLER_VER_B0)
		is_first_key_down = 0;
		#endif			
	}				
#endif
#endif
            }
			release_mask >>= 1;
			i++;
		}
		prevmask[col] = keymask[col];

		restart_timer |= keymask[col];
	}


	if (restart_timer) {
		mod_timer(&keypad_timer,jiffies + HZ/10);
	} else {
		writel(KEYIFCON_INIT, key_base+S3C_KEYIFCON);
		is_timer_on = FALSE;
	}

}
Exemplo n.º 9
0
static int max77803_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max77803_dev *max77803;
	struct max77803_platform_data *pdata;
	u8 reg_data;
	int ret = 0;
	dev_info(&i2c->dev, "%s\n", __func__);

	max77803 = kzalloc(sizeof(struct max77803_dev), GFP_KERNEL);
	if (max77803 == NULL)
		return -ENOMEM;

	if (i2c->dev.of_node) {
		pdata = devm_kzalloc(&i2c->dev,
				sizeof(struct max77803_platform_data),
				GFP_KERNEL);
		if (!pdata) {
			dev_err(&i2c->dev, "Failed to allocate memory \n");
			ret = -ENOMEM;
			goto err;
		}

		ret = of_max77803_dt(&i2c->dev, pdata);
		if (ret < 0){
			dev_err(&i2c->dev, "Failed to get device of_node \n");
			return ret;
		}
		/*Filling the platform data*/
		pdata->num_regulators = MAX77803_REG_MAX;
		pdata->muic_data = &max77803_muic;
		pdata->charger_data = &sec_battery_pdata;
		pdata->regulators = max77803_regulators,
#ifdef CONFIG_VIBETONZ
		pdata->haptic_data = &max77803_haptic_pdata;
#endif
		pdata->led_data = &max77803_led_pdata;
		/* set irq_base at sec_battery_pdata */
		sec_battery_pdata.bat_irq = pdata->irq_base + MAX77803_CHG_IRQ_BATP_I;
		/*pdata update to other modules*/
		i2c->dev.platform_data = pdata;
	} else
		pdata = i2c->dev.platform_data;

	i2c_set_clientdata(i2c, max77803);
	max77803->dev = &i2c->dev;

	max77803->i2c = i2c;
	max77803->irq = i2c->irq;
//	max77803->type = id->driver_data;
	if (pdata) {
		max77803->irq_base = pdata->irq_base;
		max77803->irq_gpio = pdata->irq_gpio;
		max77803->wakeup = pdata->wakeup;
		gpio_tlmm_config(GPIO_CFG(max77803->irq_gpio,  0, GPIO_CFG_INPUT,
                GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE);
	} else {
		ret = -EINVAL;
		goto err;
	}

	mutex_init(&max77803->iolock);

	if (max77803_read_reg(i2c, MAX77803_PMIC_REG_PMIC_ID2, &reg_data) < 0) {
		dev_err(max77803->dev,
			"device not found on this channel (this is not an error)\n");
		ret = -ENODEV;
		goto err;
	} else {
		/* print rev */
		max77803->pmic_rev = (reg_data & 0x7);
		max77803->pmic_ver = ((reg_data & 0xF8) >> 0x3);
		pr_info("%s: device found: rev.0x%x, ver.0x%x\n", __func__,
				max77803->pmic_rev, max77803->pmic_ver);
	}
#if 0
#if defined(CONFIG_MACH_JF_VZW) || defined(CONFIG_MACH_JF_LGT)
	if (kernel_sec_get_debug_level() == KERNEL_SEC_DEBUG_LEVEL_LOW) {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77803_write_reg(i2c, MAX77803_PMIC_REG_MAINCTRL1, 0x04);
	} else {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77803_write_reg(i2c, MAX77803_PMIC_REG_MAINCTRL1, 0x0c);
	}
#else
	if (kernel_sec_get_debug_level() == KERNEL_SEC_DEBUG_LEVEL_LOW) {
		max77803_write_reg(i2c, MAX77803_PMIC_REG_MAINCTRL1, 0x04);
	} else {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77803_write_reg(i2c, MAX77803_PMIC_REG_MAINCTRL1, 0x0c);
	}
#endif
#endif
	max77803_update_reg(i2c, MAX77803_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30);

	max77803->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
	i2c_set_clientdata(max77803->muic, max77803);

	max77803->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
	i2c_set_clientdata(max77803->haptic, max77803);

	ret = max77803_irq_init(max77803);
	if (ret < 0)
		goto err_irq_init;

	ret = mfd_add_devices(max77803->dev, -1, max77803_devs,
			ARRAY_SIZE(max77803_devs), NULL, 0);
	if (ret < 0)
		goto err_mfd;

	device_init_wakeup(max77803->dev, pdata->wakeup);

	return ret;

err_mfd:
	mfd_remove_devices(max77803->dev);
	max77803_irq_exit(max77803);
err_irq_init:
	i2c_unregister_device(max77803->muic);
	i2c_unregister_device(max77803->haptic);
err:
	kfree(max77803);
	return ret;
}