_mali_osk_errcode_t mali_platform_init(_mali_osk_resource_t *resource)
{
	unsigned long rate;
	int clk_div;
	int mali_used = 0;
	
	//get mali ahb clock
	h_ahb_mali = clk_get(NULL, "ahb_mali");
	if(!h_ahb_mali){
		MALI_PRINT(("try to get ahb mali clock failed!\n"));
	}
	//get mali clk
	h_mali_clk = clk_get(NULL, "mali");
	if(!h_mali_clk){
		MALI_PRINT(("try to get mali clock failed!\n"));
	}

	h_ve_pll = clk_get(NULL, "ve_pll");
	if(!h_ve_pll){
		MALI_PRINT(("try to get ve pll clock failed!\n"));
	}

	//set mali parent clock
	if(clk_set_parent(h_mali_clk, h_ve_pll)){
		MALI_PRINT(("try to set mali clock source failed!\n"));
	}
	
	//set mali clock
	rate = clk_get_rate(h_ve_pll);

	if(!script_parser_fetch("mali_para", "mali_used", &mali_used, 1)) {
		if (mali_used == 1) {
			if (!script_parser_fetch("mali_para", "mali_clkdiv", &clk_div, 1)) {
				if (clk_div > 0) {
					pr_info("mali: use config clk_div %d\n", clk_div);
					mali_clk_div = clk_div;
				}
			}
		}
	}

	pr_info("mali: clk_div %d\n", mali_clk_div);
	rate /= mali_clk_div;

	if(clk_set_rate(h_mali_clk, rate)){
		MALI_PRINT(("try to set mali clock failed!\n"));
	}
	
	if(clk_enable(h_ahb_mali)){
		MALI_PRINT(("try to enable mali ahb failed!\n"));
	}
	if(clk_enable(h_mali_clk)){
		MALI_PRINT(("try to enable mali clock failed!\n"));
	}
	if(clk_reset(h_mali_clk,0)){
		MALI_PRINT(("try to reset release failed!\n"));
	}
	MALI_PRINT(("mali clock set completed, clock is  %d Mhz\n", rate));
    MALI_SUCCESS;
}
Exemplo n.º 2
0
/* Init driver */
static int __init dht22_sun5i_init_driver() {
    int err = 0;
    int dht22_used = 0;
    script_gpio_set_t info;

    dht22_sun5i_proc = proc_mkdir("dht22", NULL);
    create_proc_read_entry("raw_data", 0444, dht22_sun5i_proc, dht22_sun5i_proc_read, NULL);

    err = script_parser_fetch("dht22_para", "dht22_used", &dht22_used, sizeof (dht22_used) / sizeof (int));
    if (!dht22_used || err) {
        printk(KERN_INFO "%s: dht22-bus is not used in config\n", __FUNCTION__);
        return -EINVAL;
    }

    err = script_parser_fetch("dht22_para", "dht22_pin", (int *) &info, sizeof (script_gpio_set_t));
    if (err) {
        printk(KERN_INFO "%s: can not get \"dht22_para\" \"dht22_pin\" gpio handler, already used by others?", __FUNCTION__);
        return -EBUSY;
    }
    dht22_sun5i_gpio_handler = gpio_request_ex("dht22_para", "dht22_pin");
    dht22_sun5i_gpio_direction = PIN_DIR_OUT;
    PIN_DIR(PIN_DIR_OUT);

    return 0;
}
Exemplo n.º 3
0
/*
*******************************************************************************
*                     get_usb_cfg
*
* Description:
*    void
*
* Parameters:
*    void
*
* Return value:
*    void
*
* note:
*    void
*
*******************************************************************************
*/
static s32 get_usb_cfg(struct sw_hci_hcd *sw_hci)
{
	__s32 ret = 0;

	/* usbc enable */
	ret = script_parser_fetch(usbc_name[sw_hci->usbc_no], "usb_used", (int *)&sw_hci->used, 64);
	if(ret != 0){
		DMSG_PANIC("ERR: get usbc2 enable failed\n");
		//return -1;
	}

	/* request gpio */
	ret = script_parser_fetch(usbc_name[sw_hci->usbc_no], "usb_drv_vbus_gpio", (int *)&sw_hci->drv_vbus_gpio_set, 64);
	if(ret != 0){
		DMSG_PANIC("ERR: get usbc%d(%s) id failed\n", sw_hci->usbc_no, usbc_name[sw_hci->usbc_no]);
		return -1;
	}

	/* host_init_state */
	ret = script_parser_fetch(usbc_name[sw_hci->usbc_no], "usb_host_init_state", (int *)&(sw_hci->host_init_state), 64);
	if(ret != 0){
		DMSG_PANIC("ERR: script_parser_fetch host_init_state failed\n");
		return -1;
	}

	return 0;
}
Exemplo n.º 4
0
static int ap6210_gpio_wifi_get_res(void)
{
	struct ap6210_gpio_wifi_ops *ops = &ap6210_wifi_select_pm_ops;

	if (SCRIPT_PARSER_OK != script_parser_fetch(wifi_para, "wifi_used", &ops->wifi_used, 1)) {
		AP6210_ERR("parse wifi_used failed in script.fex.\n" );
		return -1;
	}
	if (!ops->wifi_used) {
		AP6210_ERR("wifi pm disable in script.fex.\n" );
		return -1;
	}

	if (SCRIPT_PARSER_OK != script_parser_fetch(wifi_para, "wifi_sdc_id", &ops->sdio_id, 1)) {
		AP6210_ERR("parse wifi_sdc_id in script.fex failed.\n" );
		return -1;
	}

	if (SCRIPT_PARSER_OK != script_parser_fetch(wifi_para, "wifi_usbc_id", &ops->usb_id, 1)) {
		AP6210_ERR("parse wifi_sdc_id in script.fex failed.\n" );
		return -1;
	}

	if (SCRIPT_PARSER_OK != script_parser_fetch(wifi_para, "wifi_mod_sel", &ops->module_sel, 1)) {
		AP6210_ERR("parse wifi_sdc_id in script.fex failed.\n" );
		return -1;
	}

	ops->mod_name = ap6210_gpio_wifi_get_name(ops->module_sel);
	
	AP6210_ERR("select wifi %s\n", ops->mod_name);

	return 0;
}
Exemplo n.º 5
0
void sunxi_pwm_get_sys_config(int pwm)
{
    int ret, val;
    char primary_key[25];
    user_gpio_set_t gpio_info[1];

    sprintf(primary_key, "pwm%d_para", pwm);
    ret = script_parser_fetch(primary_key, "pwm_used", &val, 1);
    if(ret < 0) {
        pwm_debug("fetch script data fail\n");
        } else {
            if(val == 1) {
                ret = script_parser_fetch(primary_key, "pwm_positive", (int *)&gpio_info, sizeof(user_gpio_set_t) / sizeof(int));
                if(ret < 0) {
                    pwm_debug("fetch script data fail\n");
                    } else {
                        pwm_pin_count[pwm]++;
                        memcpy(&pwm_gpio_info[pwm][0], gpio_info, sizeof(user_gpio_set_t));
                        }

                ret = script_parser_fetch(primary_key, "pwm_negative", (int *)&gpio_info, sizeof(user_gpio_set_t) / sizeof(int));
                if(ret < 0) {
                    pwm_debug("fetch script data fail\n");
                    } else {
                        pwm_pin_count[pwm]++;
                        memcpy(&pwm_gpio_info[pwm][1], gpio_info, sizeof(user_gpio_set_t));
                        }
                }
            }
}
Exemplo n.º 6
0
int modify_system_uart(void)
{
    script_gpio_set_t fetch_cfg_gpio[2];
    int uart_port_id = 0;
    char uartname[16] ;
    char uart_data[8] ;
    int sdc0_used = 0;

    if(script_parser_fetch("force_uart_para","force_uart_rx",(int *)(&fetch_cfg_gpio[0]),sizeof(script_gpio_set_t)/4))
    {
        printf("debug_mode_error: can't find force_uart_rx \n");
        return -1;
    }
    if(script_parser_fetch("force_uart_para","force_uart_tx",(int *)(&fetch_cfg_gpio[1]),sizeof(script_gpio_set_t)/4))
    {
        printf("debug_mode_error: can't find force_uart_tx \n");
        return -1;
    }
    if(script_parser_fetch("force_uart_para","force_uart_port",(int *)(&uart_port_id),sizeof(int)/4))
    {
        printf("debug_mode_error: can't find card0_tx \n");
        return -1;
    }
    memset(uartname,0,16);
    memset(uart_data,0,8);
#if defined (CONFIG_ARCH_SUN7I) ||defined(CONFIG_ARCH_SUN8IW1P1)
    strcat(uartname,"uart_para");
#else
	strcat(uartname,"uart");
#endif
    sprintf(uart_data,"%d",uart_port_id);
    strcat(uartname,uart_data);
    printf("the uartname is %s  \n",uartname);
    if(script_parser_patch(uartname,"uart_port",(int *)(&uart_port_id),sizeof(int)/4))
    {
        printf("debug_mode_error : can't find uart_debug_port \n");
        return -1;
    }
    if(script_parser_patch(uartname,"uart_rx",(void*)&fetch_cfg_gpio[0],sizeof(script_gpio_set_t)/4))
    {
        printf("debug_mode_error : can't patch uart_debug_rx\n");
        return -1;
    }
    if(script_parser_patch(uartname,"uart_tx",(void*)&fetch_cfg_gpio[1],sizeof(script_gpio_set_t)/4))
    {
        printf("debug_mode_error : can't patch uart_debug_rx\n");
        return -1;
    }
//disable card0 init in linux
    if(script_parser_patch("mmc0_para","sdc_used",(int *)(&sdc0_used),sizeof(int)/4))
    {
        printf("debug_mode_error :can not patch sdc_used \n");
        return -1;
    }
    return 0;
}
Exemplo n.º 7
0
int check_physical_key_early(void)
{
	user_gpio_set_t	gpio_recovery;
	__u32 gpio_hd;
	int ret;
	int gpio_value = 0;
	int used = 0;
	int mode = 0;

	if(uboot_spare_head.boot_data.work_mode != WORK_MODE_BOOT)
	{
		return 0;
	}

	ret = script_parser_fetch("recovery_para", "used", (int *)&used, sizeof(int) / 4);
	if (ret || !used)
	{
		printf("[recovery] no use\n");
		return 0;
	}
	ret = script_parser_fetch("recovery_para", "recovery_key", (int *)&gpio_recovery, sizeof(user_gpio_set_t) / 4);
  if (!ret)
	{
		gpio_recovery.mul_sel = 0;		//强制设置成输入
		gpio_hd = gpio_request(&gpio_recovery, 1);
		if (gpio_hd)
		{
			int time;
			gpio_value = 0;
			for(time = 0; time < 4; time++)
			{
				gpio_value += gpio_read_one_pin_value(gpio_hd, 0);
				__msdelay(5);
			}
			if (!gpio_value)
			{
				printf("[box recovery] find the key\n");
				script_parser_fetch("recovery_para", "mode", (int *)&mode, sizeof(int) / 4);
				if (mode == ONEKEY_USB_RECOVERY_MODE)
				{
					gd->key_pressd_value = USB_RECOVERY_KEY_VALUE;
				}
				else if (mode == ONEKEY_SPRITE_RECOVERY_MODE)
				{
					gd->key_pressd_value = SPRITE_RECOVERY_KEY_VALUE;
					uboot_spare_head.boot_data.work_mode = WORK_MODE_SPRITE_RECOVERY;
				}
				else
				{
					printf("[recovery] no option for one key recovery's mode (%d)\n", mode);
				}
			}
		}
	}
	return 0;
}
Exemplo n.º 8
0
int check_boot_recovery_key(void)
{
	user_gpio_set_t	gpio_recovery;
	__u32 gpio_hd;
	int ret;
	int gpio_value = 0;
	int used = 0;
	int mode = 0;

	if(uboot_spare_head.boot_data.work_mode != WORK_MODE_BOOT)
	{
		return 0;
	}
	
	ret = script_parser_fetch("recovery_para", "used", (int *)&used, sizeof(int) / 4);
	if (ret || !used)
	{
		printf("[recovery] no use\n");
		return 0;
	}
	ret = script_parser_fetch("recovery_para", "recovery_key", (int *)&gpio_recovery, sizeof(user_gpio_set_t) / 4);
  if (!ret)
	{
		gpio_recovery.mul_sel = 0;		//强制设置成输入
		gpio_hd = gpio_request(&gpio_recovery, 1);
		if (gpio_hd)
		{
			int time;
			gpio_value = 0;
			for(time = 0; time < 4; time++)
			{
				gpio_value += gpio_read_one_pin_value(gpio_hd, 0);
				__msdelay(5);
			}
			if (!gpio_value)
			{
				script_parser_fetch("recovery_para", "mode", (int *)&mode, sizeof(int) / 4);
				if (mode == ONEKEY_USB_RECOVERY)
				{
					printf("set to one key usb recovery\n");
					write_usb_recovery_to_misc();
				}
				else if (mode == ONEKEY_SPRITE_RECOVERY)
				{
					printf("set to one key sprite recovery\n");
					setenv("bootcmd", "sprite_recovery");
				}
				else
				{
					printf("[recovery] no option for one key recovery's mode\n");
				}
			}
		}
	}
	return 0;
}
Exemplo n.º 9
0
/**
 * tkey_fetch_sysconfig_para - get config info from sysconfig.fex file.
 * return value:  
 *                    = 0; success;
 *                    < 0; err
 */
static int tkey_fetch_sysconfig_para(void)
{
	int ret = -1;
	int device_used = -1;
	__u32 twi_addr = 0;

	char name[I2C_NAME_SIZE];
	script_parser_value_type_t type = SCIRPT_PARSER_VALUE_TYPE_STRING;
	
	//__u32 twi_id = 0;

	printk("========HV Inital ===================\n");
	if(SCRIPT_PARSER_OK != script_parser_fetch("tkey_para", "tkey_used", &device_used, 1)){
	                pr_err("hv_keyboard: script_parser_fetch err. \n");
	                goto script_parser_fetch_err;
	}
	if(1 == device_used){
		if(SCRIPT_PARSER_OK != script_parser_fetch_ex("tkey_para", "tkey_name", (int *)(&name), &type, sizeof(name)/sizeof(int))){
			pr_err("%s: script_parser_fetch err. \n", __func__);
			goto script_parser_fetch_err;
		}
		if(strcmp(HV_NAME, name)){
			pr_err("%s: name %s does not match HV_NAME. \n", __func__, name);
			pr_err(HV_NAME);
			//ret = 1;
			return ret;
		}
		if(SCRIPT_PARSER_OK != script_parser_fetch("tkey_para", "tkey_twi_addr", &twi_addr, sizeof(twi_addr)/sizeof(__u32))){
			pr_err("%s: script_parser_fetch err. \n", name);
			goto script_parser_fetch_err;
		}
		u_i2c_addr.dirty_addr_buf[0] = twi_addr;
		u_i2c_addr.dirty_addr_buf[1] = I2C_CLIENT_END;
		printk("%s: after: tkey_twi_addr is 0x%x, dirty_addr_buf: 0x%hx. dirty_addr_buf[1]: 0x%hx \n", \
		__func__, twi_addr, u_i2c_addr.dirty_addr_buf[0], u_i2c_addr.dirty_addr_buf[1]);
		
		if(SCRIPT_PARSER_OK != script_parser_fetch("tkey_para", "tkey_twi_id", &twi_id, 1)){
			pr_err("%s: script_parser_fetch err. \n", name);
			goto script_parser_fetch_err;
		}
		printk("%s: tkey_twi_id is %d. \n", __func__, twi_id);
		
	}else{
		pr_err("%s: tkey_unused. \n",  __func__);
		ret = -1;
	}

	return 0;

script_parser_fetch_err:
	pr_notice("=========script_parser_fetch_err============\n");
	return ret;

}
Exemplo n.º 10
0
/**
 * gsensor_fetch_sysconfig_para - get config info from sysconfig.fex file.
 * return value:  
 *                    = 0; success;
 *                    < 0; err
 */
static int gsensor_fetch_sysconfig_para(void)
{
	int ret = -1;
	int device_used = -1;
	__u32 twi_addr = 0;
	char name[I2C_NAME_SIZE];
	script_parser_value_type_t type = SCRIPT_PARSER_VALUE_TYPE_STRING;
		
	printk("========%s===================\n", __func__);
	 
	if(SCRIPT_PARSER_OK != (ret = script_parser_fetch("gsensor_para", "gsensor_used", &device_used, 1))){
	                pr_err("%s: script_parser_fetch err.ret = %d. \n", __func__, ret);
	                goto script_parser_fetch_err;
	}
	if(1 == device_used){
		if(SCRIPT_PARSER_OK != script_parser_fetch_ex("gsensor_para", "gsensor_name", (int *)(&name), &type, sizeof(name)/sizeof(int))){
			pr_err("%s: line: %d script_parser_fetch err. \n", __func__, __LINE__);
			goto script_parser_fetch_err;
		}
		if(strcmp(SENSOR_NAME, name)){
			pr_err("%s: name %s does not match SENSOR_NAME. \n", __func__, name);
			pr_err(SENSOR_NAME);
			//ret = 1;
			return ret;
		}
		if(SCRIPT_PARSER_OK != script_parser_fetch("gsensor_para", "gsensor_twi_addr", &twi_addr, sizeof(twi_addr)/sizeof(__u32))){
			pr_err("%s: line: %d: script_parser_fetch err. \n", name, __LINE__);
			goto script_parser_fetch_err;
		}
		u_i2c_addr.dirty_addr_buf[0] = twi_addr;
		u_i2c_addr.dirty_addr_buf[1] = I2C_CLIENT_END;
		printk("%s: after: gsensor_twi_addr is 0x%x, dirty_addr_buf: 0x%hx. dirty_addr_buf[1]: 0x%hx \n", \
			__func__, twi_addr, u_i2c_addr.dirty_addr_buf[0], u_i2c_addr.dirty_addr_buf[1]);

		if(SCRIPT_PARSER_OK != script_parser_fetch("gsensor_para", "gsensor_twi_id", &twi_id, 1)){
			pr_err("%s: script_parser_fetch err. \n", name);
			goto script_parser_fetch_err;
		}
		printk("%s: twi_id is %d. \n", __func__, twi_id);
		
		ret = 0;
		
	}else{
		pr_err("%s: gsensor_unused. \n",  __func__);
		ret = -1;
	}

	return ret;

script_parser_fetch_err:
	pr_notice("=========script_parser_fetch_err============\n");
	return ret;

}
Exemplo n.º 11
0
/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :
*
*    return        :
*
*    note          :
*
*
************************************************************************************************************
*/
static int detect_other_boot_mode(void)
{
    int ret1, ret2;
	int key_high, key_low;
	int keyvalue;
	int user_mode_used = 0;
	keyvalue = gd->key_pressd_value;
	printf("key %d\n", keyvalue);
	script_parser_fetch("platform", "user_mode_used", &user_mode_used, 1);
	if(user_mode_used)
	{
		if(keyvalue >0)
		{
			return USER_SELECT_MODE;
		}
	}
	else
	{
	    ret1 = script_parser_fetch("recovery_key", "key_max", &key_high, 1);
		ret2 = script_parser_fetch("recovery_key", "key_min", &key_low,  1);
		if((ret1) || (ret2))
		{
			printf("cant find rcvy value\n");
		}
		else
		{
			printf("recovery key high %d, low %d\n", key_high, key_low);
			if((keyvalue >= key_low) && (keyvalue <= key_high))
			{
				printf("key found, android recovery\n");

				return ANDROID_RECOVERY_MODE;
			}
		}
	    ret1 = script_parser_fetch("fastboot_key", "key_max", &key_high, 1);
		ret2 = script_parser_fetch("fastboot_key", "key_min", &key_low, 1);
		if((ret1) || (ret2))
		{
			printf("cant find fstbt value\n");
		}
		else
		{
			printf("fastboot key high %d, low %d\n", key_high, key_low);
			if((keyvalue >= key_low) && (keyvalue <= key_high))
			{
				printf("key found, android fastboot\n");
				return ANDROID_FASTBOOT_MODE;
			}
		}
	}
	return ANDROID_NULL_MODE;
}
static int __init sun4i_vibrator_init(void)
{
	int vibe_used;
	int err = -1;

	pr_info("hello, sun4i_vibrator init\n");
	err = script_parser_fetch("motor_para", "motor_used",
					&vibe_used, sizeof(vibe_used)/sizeof(int));
	if(err) {
		pr_err("%s script_parser_fetch \"motor_para\" \"motor_used\" error = %d\n",
				__FUNCTION__, err);
		goto exit;
	}

	if(!vibe_used) {
		pr_err("%s motor is not used in config\n", __FUNCTION__);
		err = -1;
		goto exit;
	}

	err = script_parser_fetch("motor_para", "motor_shake",
					(int *)&vibe_gpio, sizeof(vibe_gpio)/sizeof(int));

	if(err) {
		pr_err("%s script_parser_fetch \"motor_para\" \"motor_shaked\" error = %d\n",
				__FUNCTION__, err);
		goto exit;
	}

	vibe_off = vibe_gpio.data;
	pr_debug("vibe_off is %d\n", vibe_off);

	vibe_gpio_handler = gpio_request_ex("motor_para", "motor_shake");

	if(!vibe_gpio_handler) {
		pr_err("%s request motor gpio err\n", __FUNCTION__);
		err = -1;
		goto exit;
	}

	INIT_WORK(&vibrator_work, update_vibrator);

	spin_lock_init(&vibe_lock);
	vibe_state = 0;
	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	timed_output_dev_register(&sun4i_vibrator);

exit:
	return err;
}
Exemplo n.º 13
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:power_oz_patch_gpio
*
*    参数列表:
*
*    返回值  :
*
*    说明    :change the gpio data status in sys_config.fex with the vol input 
*
*
************************************************************************************************************
*/
static int power_oz_patch_gpio(int set_vol)
{
	int ret;
	int i;
	u8 index;
	char sub_name[16];
	user_gpio_set_t oz_gpio_cfg[3];
	memset(oz_gpio_cfg, 0, sizeof(oz_gpio_cfg));

	ret = script_parser_fetch("external_power", "a15_vset1", (int*)&oz_gpio_cfg[0], sizeof(oz_gpio_cfg[0])/sizeof(int));
	if(ret)
	{
		printf("get oz power cfg failed\n");
		return -1;
	}

	ret = script_parser_fetch("external_power", "a15_vset2", (int*)&oz_gpio_cfg[1], sizeof(oz_gpio_cfg[1])/sizeof(int));
	if(ret)
	{
		printf("get oz power cfg failed\n");
		return -1;
	}

	ret = script_parser_fetch("external_power", "a15_vset3", (int*)&oz_gpio_cfg[2], sizeof(oz_gpio_cfg[2])/sizeof(int));
	if(ret)
	{
		printf("get oz power cfg failed\n");
		return -1;
	}

	//get the gpio status with the set_vol
	index = power_oz_probe_gpio(set_vol);

	//配置gpio data
	for(i = 0; i < 3; i++)
	{
		oz_gpio_cfg[i].data = gpio_value[index][i];
		memset(sub_name, 0, 16);
		sprintf(sub_name, "%s%d", "a15_vset", i+1);
		ret = script_parser_patch("external_power", sub_name, (void *)&oz_gpio_cfg[i], sizeof(oz_gpio_cfg[i])/sizeof(int));
		if(ret)
		{
			printf("patch gpio config failed\n");
			return -2;
		}
	}

	return 0;
}
Exemplo n.º 14
0
__s32 Hdmi_init(void)
{
	s32 ret = 0;
	disp_hdmi_func disp_func;
	s32 val;

	hdmi_used = 0;

	ret = script_parser_fetch("hdmi_para", "hdmi_used", &val, 1);
	if(ret == 0) {
		hdmi_used = val;

		if(hdmi_used)
		{
#if defined(CONFIG_ARCH_HOMELET) //need to be same later
			ret = script_parser_fetch("hdmi_para", "hdmi_power_boot", (int *)hdmi_power, 25);
#else
			ret = script_parser_fetch("hdmi_para", "hdmi_power", (int *)hdmi_power, 25);
#endif
			if(ret == 0) {
				OSAL_Power_Enable(hdmi_power);
			}
			ret = script_parser_fetch("hdmi_para", "hdmi_cts_compatibility", &val, 1);
			if(ret == 0) {
				Hdmi_hal_cts_enable(val);
				printf("cts_enable, %d\n", val);
			}
			ret = script_parser_fetch("hdmi_para", "hdmi_hdcp_enable", &val, 1);
			if(ret == 0) {
				Hdmi_hal_hdcp_enable(val);
				printf("hdcp_enable, %d\n", val);
			}

			Hdmi_hal_init();

			disp_func.hdmi_open = Hdmi_open;
			disp_func.hdmi_close = Hdmi_close;
			disp_func.hdmi_set_mode = Hdmi_set_display_mode;
			disp_func.hdmi_mode_support = Hdmi_mode_support;
			disp_func.hdmi_get_HPD_status = Hdmi_get_HPD_status;
			disp_func.hdmi_get_video_timing_info = Hdmi_get_video_timming_info;
			disp_func.hdmi_get_video_info_index = Hdmi_get_video_info_index;
			disp_set_hdmi_func(0, &disp_func);
			disp_set_hdmi_func(1, &disp_func);
		}
	}
	return 0;
}
Exemplo n.º 15
0
static int __init sw_serial_init(void)
{
    int ret;
    int i;
    int used = 0;
    char uart_para[16];
    
    memset(sw_serial, 0, sizeof(sw_serial));
    uart_used = 0;
    for (i=0; i<MAX_PORTS; i++, used=0) {
        sprintf(uart_para, "uart_para%d", i);
        ret = script_parser_fetch(uart_para, "uart_used", &used, sizeof(int));
        if (ret)
            UART_MSG("failed to get uart%d's used information\n", i);
        if (used) {
            uart_used |= 1 << i;
            platform_device_register(&sw_uart_dev[i]);
        }
    }
    
    if (uart_used) {
        UART_MSG("used uart info.: 0x%02x\n", uart_used);
        ret = platform_driver_register(&sw_serial_driver);
        return ret;
    }

	return 0;
}
Exemplo n.º 16
0
int OSAL_Script_FetchParser_Data(char *main_name, char *sub_name, int value[], int count)
{
	int ret;
	user_gpio_set_t  gpio_info;
	disp_gpio_set_t  *gpio_list;
	ret = script_parser_fetch(main_name, sub_name, value, count);
	if(ret < 0) {
		//__wrn("fetch script data %s.%s fail\n", main_name, sub_name);
	} else {
		if(count == 1) {
			//__inf("%s.%s = %d\n", main_name, sub_name, *value);
		} else if(count == sizeof(disp_gpio_set_t)) {
			memcpy(&gpio_info, value, sizeof(user_gpio_set_t));
			gpio_list = (disp_gpio_set_t  *)value;
			gpio_list->port = gpio_info.port;
			gpio_list->port_num = gpio_info.port_num;
			gpio_list->drv_level = gpio_info.drv_level;
			gpio_list->pull = gpio_info.pull;
			gpio_list->data = gpio_info.data;
			//__inf("%s.%s gpio_port=%d,gpio_port_num:%d, data:%d\n",main_name, sub_name, gpio_list->port, gpio_list->port_num, gpio_list->data);
		} else {
			//__inf("%s.%s = %s\n", main_name, sub_name, value);
		}
	}
	
	return ret;
}
Exemplo n.º 17
0
static int __init sndspdif_codec_init(void)
{
	int ret, spdif_used = 0;

	ret = script_parser_fetch("spdif_para", "spdif_used", &spdif_used, 1);
	if (ret != 0 || !spdif_used)
		return -ENODEV;

	spd_gpio_hdle = gpio_request_ex("spdif_para", "spdif_dout");
	if (0 == spd_gpio_hdle) {
		pr_err("try to request spdif_para gpio failed\n");
		return -1;
	}

	ret = platform_device_register(&sndspdif_codec_device);
	if (ret < 0)
		return ret;

	ret = platform_driver_register(&sndspdif_codec_driver);
	if (ret < 0) {
		platform_device_unregister(&sndspdif_codec_device);
		return ret;
	}

	return 0;
}
Exemplo n.º 18
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
int power_oz_probe(void)
{
	int ret;
	u32 oz_power_hd;
	user_gpio_set_t oz_gpio_cfg[1];

	memset(oz_gpio_cfg, 0, sizeof(oz_gpio_cfg));
	ret = script_parser_fetch("external_power", "a15_pwr_en", (int*)&oz_gpio_cfg[0], sizeof(oz_gpio_cfg[0])/sizeof(int));
	if(ret)
	{
		printf("get a15_pwr_en cfg failed\n");
		return -1;
	}

	oz_gpio_cfg[0].data = 1;

	//配置使能gpio
	ret = script_parser_patch("external_power", "a15_pwr_en", (int*)&oz_gpio_cfg[0], sizeof(oz_gpio_cfg[0])/sizeof(int));
	if(ret)
	{
		printf("patch a15_pwr_en config failed\n");
		return -2;
	}

	oz_power_hd = gpio_request_simple("external_power", "a15_pwr_en");
	if(oz_power_hd)
	{
		printf("set gpio failed\n");
		return -3;
	}
	return 0;
}
Exemplo n.º 19
0
static int board_probe_bat_status(int standby_mode)
{
	int   bat_cal = 1;
	int   ret, chargemode = 0;
	//当前可以确定是火牛开机,但是是否开机还不确定,需要确认电池是否存在
	//当电池不存在即开机,电池存在则关机
	//新添加,根据环境变量,是启动当前的待机,或者android待机功能
	ret = script_parser_fetch("charging_type", "charging_type", &chargemode, 1);
	if((!ret) && chargemode)
	{
		gd->chargemode = 1;

		return 0;
	}
	if(battery_charge_cartoon_init(0) < 0)
	{
		tick_printf("init charge cartoon fail\n");

		return -1;
	}
	bat_cal = axp_probe_rest_battery_capacity();
	printf("bat not inited\n");
	if(battery_charge_cartoon_init(bat_cal/(100/(SUNXI_BAT_BMP_MAX-1))) < 0)
	{
		tick_printf("init charge cartoon fail\n");

		return -1;
	}
	if((!bat_cal) && (standby_mode))
	{
		bat_cal = 100;
	}

	return bat_cal;
}
Exemplo n.º 20
0
static void __exit gpio_sw_exit(void)
{
	int i, gpio_key_count,gpio_used,ret;

	ret = script_parser_fetch("gpio_para", "gpio_used", &gpio_used, sizeof(int));

	if (ret){
		GPIO_SW_DEBUG("failed to get gpio's used information\n");
		goto EXIT_END;
	}
	if(!gpio_used){
		GPIO_SW_DEBUG("gpio module is used not  \n");
		goto EXIT_END;
	}

	gpio_key_count = script_parser_mainkey_get_gpio_count("gpio_para");

	if(all_irq_enable){
	__raw_writel(0x00, GPIO_TEST_BASE + 0x210);
	free_irq(GPIO_IRQ,NULL);
	}
	for(i=0;i<gpio_key_count;i++){
		GPIO_SW_DEBUG("gpio_sw_dev[%d] addr = %x \n",i,&gpio_sw_dev[i]);
		gpio_key_count = script_parser_mainkey_get_gpio_count("gpio_para");
		platform_device_unregister(&gpio_sw_dev[i]);
	}

		GPIO_SW_DEBUG("platform_device_unregister finish !  \n");
		GPIO_SW_DEBUG("gpio_sw_driver addr = %x \n",&gpio_sw_driver);
	platform_driver_unregister(&gpio_sw_driver);

EXIT_END:
	GPIO_SW_DEBUG("gpio_exit finish !  \n");
}
Exemplo n.º 21
0
static int __init sun5i_sndi2s_init(void)
{
	int ret;
	int ret2;
	
	ret2 = script_parser_fetch("i2s_para","i2s_used", &i2s_used, sizeof(int));
	if (ret2) {
        printk("[I2S]sun5i_sndi2s_init fetch i2s using configuration failed\n");
    } 
    
    if (i2s_used) {
		sun5i_sndi2s_device = platform_device_alloc("soc-audio", 2);
		if(!sun5i_sndi2s_device)
			return -ENOMEM;
		platform_set_drvdata(sun5i_sndi2s_device, &snd_soc_sun5i_sndi2s);
		ret = platform_device_add(sun5i_sndi2s_device);		
		if (ret) {			
			platform_device_put(sun5i_sndi2s_device);
		}
	}else{
		printk("[I2S]sun5i_sndi2s cannot find any using configuration for controllers, return directly!\n");
        return 0;
	}
	return ret;
}
Exemplo n.º 22
0
static int __init sun5i_spdif_init(void)
{
	int err = 0;
	int ret;
	
	ret = script_parser_fetch("spdif_para","spdif_used", &spdif_used, sizeof(int));
	if (ret) {
        printk("[SPDIF]sun5i_spdif_init fetch spdif using configuration failed\n");
    } 
    
 	if (spdif_used) {	
		spdif_handle = gpio_request_ex("spdif_para", NULL);
		
		if((platform_device_register(&sun5i_spdif_device))<0)
			return err;

		if ((err = platform_driver_register(&sun5i_spdif_driver)) < 0)
			return err;
			
	} else {
        printk("[SPDIF]sun5i-spdif cannot find any using configuration for controllers, return directly!\n");
        return 0;
    }
 
	return 0;
}
Exemplo n.º 23
0
static void check_debug_mode(void)
{
    //if enter debug mode,set loglevel = 8
    char change_env_data[32];
    char *env_concole = "ttyS";
    int baud = 115200;
    int port_id = 0;

    if(!loglel_change_flag)
        return ;
    memset(change_env_data,0,32);
    sprintf(change_env_data, "%d",8);
    setenv("loglevel",change_env_data);
    if(script_parser_fetch("force_uart_para","force_uart_port",&port_id,sizeof(int)/4))
    {
        printf("card0_print_para port_id fetch error\n");
        return ;
    }
    memset(change_env_data,0,32);
    strcat(change_env_data,"ttyS");
    sprintf(change_env_data,"%s%d%s%d",env_concole,port_id,",",baud);
    setenv("console",change_env_data);

    return ;
}
Exemplo n.º 24
0
/* Init driver module */
INT __init rtusb_init(void)
{
	int ret = 0;
	
	printk("rtusb init %s --->\n", RTMP_DRV_NAME);

	ret = script_parser_fetch("usb_wifi_para", "usb_wifi_usbc_num", (int *)&usb_wifi_host, 64);
	if(ret != 0){
		printk("ERR: script_parser_fetch usb_wifi_usbc_num failed\n");
		ret = -ENOMEM;
		return ret;
	}

	printk("sw_usb_enable_hcd: usbc_num = %d\n", usb_wifi_host);

	sw_usb_enable_hcd(usb_wifi_host);
	
#ifdef RESOURCE_BOOT_ALLOC
{
	int status;
	status = rtusb_resource_init(rtusb_tx_buf_len, rtusb_rx_buf_len, rtusb_tx_buf_cnt, rtusb_rx_buf_cnt);
	if (status)
	{
		printk("resource allocate failed, don't register driver!\n");
		return -1;
	}
}
#endif /* RESOURCE_BOOT_ALLOC */

	return usb_register(&rtusb_driver);
}
Exemplo n.º 25
0
/*
************************************************************************************************************
*
*                                             function
*
*    name          :	一键恢复的按键检测
*
*    parmeters     :
*
*    return        :
*
*    note          :	[email protected]
*
*
************************************************************************************************************
*/
int check_boot_recovery_key(void)
{
	user_gpio_set_t     gpio_recovery;
	__u32			    gpio_hd;
	int					gpio_value = 0;
	int ret;

	ret = script_parser_fetch("system", "recovery_key", (int *)&gpio_recovery, sizeof(user_gpio_set_t)/4);
        if (!ret)
	{
		gpio_recovery.mul_sel = 0;		//强制设置成输入
		gpio_hd = gpio_request(&gpio_recovery, 1);
		if (gpio_hd)
		{
			int k;
			gpio_value = 0;
			for(k=0;k<4;k++)
			{
				gpio_value += gpio_read_one_pin_value(gpio_hd, 0);
				__msdelay(5);
			}
			if (!gpio_value)
			{
				printf("set to recovery\n");
				return 0;
			}
		}
	}
	return 1;
}
Exemplo n.º 26
0
/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :
*
*    return        :
*
*    note          :
*
*
************************************************************************************************************
*/
int sunxi_set_secure_mode(void)
{
	int mode;
	int ret;
	int secure_bit = 0;
	if(gd->securemode == SUNXI_NORMAL_MODE)
	{
		if(!script_parser_fetch("platform","secure_bit",&secure_bit,1))
		{
			mode = sid_probe_security_mode();
			if((mode == 0)&&(secure_bit == 1))
			{
				ret = axp_set_supply_status(0, PMU_SUPPLY_ELDO2, 1800, 1);
				if(ret)
				{
					printf("set eldo2 to 1800 failed\n");

					return -1;
				}
				else
				{
					sid_set_security_mode();
				}
			}
		}
	}

	return 0;
}
Exemplo n.º 27
0
/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :
*
*    return        :
*
*    note          :
*
*
************************************************************************************************************
*/
void dram_init_banksize(void)
{
    /*
     * We should init the Dram options, and kernel get it by tag.
     */
    int dram_size;
    int ret;
    //gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
    ret = script_parser_fetch("dram_para", "dram_para1", &dram_size, 1);
    if(!ret)
    {
        dram_size &= 0xffff;
        if(dram_size)
        {
            gd->bd->bi_dram[0].size = dram_size * 1024 * 1024;
        }
        else
        {
            gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
        }
    }
    else
    {
        gd->bd->bi_dram[0].size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
    }
    gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
}
Exemplo n.º 28
0
/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int axp20_set_dcdc3(int set_vol, int onoff)
{
	s32 vol_value;
	s32 ret;
	u8  reg_addr;
	u8  reg_value;
	
	if(set_vol == -1)
	{
		if(!dcdc3_user_set)
		{
			ret = script_parser_fetch("target", "dcdc3_vol", &vol_value, 1);
			if(ret)
			{
				printf("boot power:unable to find dcdc3 set\n");
				return -1;
			}
			dcdc3_user_set = vol_value;
		}
		vol_value = dcdc3_user_set;
	}
	else
	{
		vol_value = set_vol;
	}

	if(!vol_value)
	{
		reg_addr = BOOT_POWER20_OUTPUT_CTL;
		if(!axp_i2c_read(AXP20_ADDR, reg_addr, &reg_value))
		{
			reg_value &= ~(1<<1);
			if(axp_i2c_write(AXP20_ADDR, reg_addr, reg_value))
			{
				printf("boot power:unable to close dcdc3\n");
				return -1;
			}
		}
	}
	else
	{
		reg_addr = BOOT_POWER20_DC3OUT_VOL;
		if(!axp_i2c_read(AXP20_ADDR, reg_addr, &reg_value))
		{
			if((vol_value >= 700) && (vol_value <= 3500))
			{
				reg_value &= 0x80;
				reg_value = ((vol_value - 700)/25);
				if(axp_i2c_write(AXP20_ADDR, reg_addr, reg_value))
				{
					printf("boot power:unable to set dcdc3\n");
					return -1;
				}
			}
		}
	}

	return 0;
}
Exemplo n.º 29
0
static int sw_serial_get_config(struct sw_serial_port *sport, u32 uart_id)
{
    char uart_para[16] = {0};
    int ret;
    
    sprintf(uart_para, "uart_para%d", uart_id);
    ret = script_parser_fetch(uart_para, "uart_port", &sport->port_no, sizeof(int));
    if (ret)
        return -1;
    if (sport->port_no != uart_id)
        return -1;
    ret = script_parser_fetch(uart_para, "uart_type", &sport->pin_num, sizeof(int));
    if (ret)
        return -1;
    
    return 0;
}
Exemplo n.º 30
0
/*
 ************************************************************************************************************
 *
 *                                             function
 *
 *    函数名称:
 *
 *    参数列表:
 *
 *    返回值  :
 *
 *    说明    :
 *
 *
 ************************************************************************************************************
 */
static int axp20_set_ldo2(int set_vol, int onoff)
{
    s32 vol_value;
        s32 ret;
        u8  reg_addr;
        u8  reg_value;

        if(set_vol == -1)
        {
            if(!ldo2_user_set)
            {
                ret = script_parser_fetch("target", "ldo2_vol", &vol_value, 1);
                    if(ret)
                    {
                        printf("boot power:unable to find ldo2 set\n");

                            return -1;
                    }
                ldo2_user_set = vol_value;
            }
            vol_value = ldo2_user_set;
        }
        else
        {
            vol_value = set_vol;
        }
    if(!vol_value)
    {
        reg_addr = BOOT_POWER20_OUTPUT_CTL;
        if(!axp_i2c_read(AXP20_ADDR, reg_addr, &reg_value))
        {
            reg_value &= ~(1<<2);
            if(axp_i2c_write(AXP20_ADDR, reg_addr, reg_value))
            {
                printf("boot power:unable to set ldo2\n");
                    return -1;
            }
        }
    }
    else
    {
        reg_addr  = BOOT_POWER20_LDO24OUT_VOL;
        if(!axp_i2c_read(AXP20_ADDR, reg_addr, &reg_value))
        {
            if((vol_value >= 1800) && (vol_value <= 3300))
            {
                reg_value &= 0x0f;
                reg_value |= (((vol_value - 1800)/100) << 4);
                if(axp_i2c_write(AXP20_ADDR, reg_addr, reg_value))
                {
                    printf("boot power:unable to set ldo2\n");
                        return -1;
                }
            }
        }
    }
    return 0;
}