static int sw_serial_get_config(struct sw_serial_port *sport, u32 uart_id)
{
    char uart_para[16] = {0};
    script_item_u val;
    script_item_value_type_e type;

    memset(uart_para, 0, sizeof(uart_para));
    snprintf(uart_para, sizeof(uart_para), "uart_para%d", uart_id);

    type = script_get_item(uart_para, "uart_port", &val);
    if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        UART_ERR("%s: uart%d get uart port error\n", __func__,
                uart_id);
        return -1;
    }
    sport->port_no  = val.val;

    if (sport->port_no != uart_id) {
        UART_ERR("%s: port%d and uart%d not match\n",
               __func__, sport->port_no, uart_id);
        return -1;
    }

    type = script_get_item(uart_para, "uart_type", &val);
    if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        UART_ERR("%s: uart%d get uart type error\n", __func__,
                uart_id);
        return -1;
    }
    sport->pin_num  = val.val;

    return 0;
}
/*
 * Return:
 *	0:	power on successfully
 *	others: power on failed
 */
int platform_wifi_power_on(void)
{
	int ret = 0;

#ifdef CONFIG_MMC
	{
		script_item_u val;
		script_item_value_type_e type;

#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
		unsigned int mod_sel = get_rf_mod_type();
#else
		unsigned int mod_sel = wifi_pm_get_mod_type();
#endif

		type = script_get_item("wifi_para", "wifi_sdc_id", &val);
		if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
			RTW_INFO("get wifi_sdc_id failed\n");
			ret = -1;
		} else {
			sdc_id = val.val;
			RTW_INFO("----- %s sdc_id: %d, mod_sel: %d\n", __FUNCTION__, sdc_id, mod_sel);

#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
			sw_mci_rescan_card(sdc_id, 1);
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
			sunxi_mci_rescan_card(sdc_id, 1);
#endif
			mdelay(100);
			wifi_pm_power(1);

			RTW_INFO("%s: power up, rescan card.\n", __FUNCTION__);
		}

#ifdef CONFIG_GPIO_WAKEUP
#ifdef CONFIG_PLATFORM_ARM_SUN8I_W5P1
		type = script_get_item("wifi_para", "wl_host_wake", &val);
#else
#ifdef CONFIG_RTL8723B
		type = script_get_item("wifi_para", "rtl8723bs_wl_host_wake", &val);
#endif
#ifdef CONFIG_RTL8188E
		type = script_get_item("wifi_para", "rtl8189es_host_wake", &val);
#endif
#endif /* CONFIG_PLATFORM_ARM_SUN8I_W5P1 */
		if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
			RTW_INFO("No definition of wake up host PIN\n");
			ret = -1;
		} else {
			gpio_eint_wlan = val.gpio.gpio;
#ifdef CONFIG_PLATFORM_ARM_SUN8I
			oob_irq = gpio_to_irq(gpio_eint_wlan);
#endif
		}
#endif /* CONFIG_GPIO_WAKEUP */
	}
#endif /* CONFIG_MMC */

	return ret;
}
__s32 camera_get_sysconfig(char *main_name, char *sub_name, __s32 *buf, __u32 cnt)
{
        script_item_u   val;
        script_item_value_type_e  type;
        int ret = -1;

        if(cnt == 1)
        {
                type = script_get_item(main_name, sub_name, &val);
                if(SCIRPT_ITEM_VALUE_TYPE_INT == type)
                {
                        ret = 0;
                        *buf = val.val;
                        detect_print("%s.%s=%d\n", main_name, sub_name, *buf);
                }
                else
                {
                        ret = -1;
                        detect_print("fetch script data %s.%s fail\n", main_name, sub_name);
                }
        }
        else if(cnt == sizeof(__camera_gpio_set_t)/sizeof(__s32))
        {
                type = script_get_item(main_name, sub_name, &val);
                if(SCIRPT_ITEM_VALUE_TYPE_PIO == type)
                {
                        __camera_gpio_set_t *gpio_info = (__camera_gpio_set_t *)buf;

                        ret = 0;
                        gpio_info->gpio = val.gpio.gpio;
                        gpio_info->mul_sel = val.gpio.mul_sel;
                        gpio_info->pull = val.gpio.pull;
                        gpio_info->drv_level = val.gpio.drv_level;
                        gpio_info->data = val.gpio.data;
                        memcpy(gpio_info->gpio_name, sub_name, strlen(sub_name)+1);
                        detect_print("%s.%s gpio=%d,mul_sel=%d,data:%d\n",main_name, sub_name, gpio_info->gpio, gpio_info->mul_sel, gpio_info->data);
                }
                else
                {
                        ret = -1;
                        detect_print("fetch script data %s.%s fail\n", main_name, sub_name);
                }
        }
        else if(cnt == MAX_VDD_STR_LEN)
        {
                type = script_get_item(main_name, sub_name, &val);
                if(SCIRPT_ITEM_VALUE_TYPE_STR == type)
                {
                        strcpy((char *)buf, val.str);
                        detect_print("%s.%s=%s\n", main_name, sub_name, (char *)buf);
                }
                else
                {
                        ret = -1;
                        detect_print("fetch script data %s.%s fail\n", main_name, sub_name);
                }
        }

        return ret;
}
Ejemplo n.º 4
0
static int __init sunxi_daudio0_init(void)
{	
	int err = 0;
	script_item_u val;
	script_item_value_type_e  type;

	type = script_get_item(TDM_NAME, "daudio_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        pr_err("[DAUDIO] type err!\n");
    }

	daudio_used = val.val;

	type = script_get_item(TDM_NAME, "daudio_select", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        pr_err("[DAUDIO] daudio_select:%s,line:%d type err!\n", __func__, __LINE__);
    }
	daudio_select = val.val;

 	if (daudio_used) {
		if((err = platform_device_register(&sunxi_daudio_device)) < 0)
			return err;
	
		if ((err = platform_driver_register(&sunxi_daudio_driver)) < 0)
			return err;	
	} else {
        pr_err("[DAUDIO]sunxi-daudio cannot find any using configuration for controllers, return directly!\n");
        return 0;
    }

	return 0;
}
Ejemplo n.º 5
0
static int keypad_sys_setup(void)/////unfinish
{
	int ret = -1;
	script_item_u	val;
	script_item_value_type_e  type;
	
	key_pressed[0] = 0;
	key_pressed[1] = 0;

	type = script_get_item("kp0", "keypad_used", &val);
 
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		pr_err("%s: type err  device_used = %d. \n", __func__, val.val);
		ret = -1;
	}
	
	if (1 == val.val) {
		type = script_get_item("kp0", "keypad_power_key_code", &val);
		if(SCIRPT_ITEM_VALUE_TYPE_INT != type){
			pr_err("%s: keypad power key type err! \n", __func__);
		}
		keypad_power_key = val.val;

		ret = 0;
		
	} else {
		pr_err("%s: keypad_unused. \n",  __func__);
		ret = -1;
	}

	return ret;
}
void rtl8723au_gpio_init(void)
{
	script_item_u val;
	script_item_value_type_e type;
	struct wifi_pm_ops *ops = &wifi_select_pm_ops;

	rtl8723au_msg("exec rtl8723au_wifi_gpio_init\n");

	type = script_get_item(wifi_para, "wifi_power", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_STR != type) {
		rtl8723au_msg("failed to fetch wifi_power\n");
		return ;
	}
	axp_name = val.str;

	type = script_get_item(wifi_para, "wifi_usbc_id", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		rtl8723au_msg("failed to fetch wifi_usbc_id\n");
		return ;
	}
	usbc_id = val.val;
	
	ops->standby   = rtl8723au_standby;
	rtl8723au_wifi_power = 0;
	rtl8723au_bt_power = 0;
	
	// make sure wifi power up when system start up
	rtl8723au_module_power(1);
}
Ejemplo n.º 7
0
static int sunxigk_script_init(void)
{
	script_item_u	val;
	script_item_value_type_e  type;

	type = script_get_item("gpio_power_key", "key_used", &val);

	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		pr_err("%s: key para not found, used default para. \n", __func__);
		return -1;
	}

	if(1 == val.val){
		type = script_get_item("gpio_power_key", "key_io", &val);
		if(SCIRPT_ITEM_VALUE_TYPE_PIO != type){
			pr_err("%s: get key io err! \n", __func__);
			return -1;
		}
		power_key_io = val.gpio;
		dprintk(DEBUG_INT,"%s power key io number = %d.\n", __func__, power_key_io.gpio);

	}else{
		dprintk(DEBUG_INT,"sunxi io power key no used.\n");
		return -1;
	}

	return 0;
}
Ejemplo n.º 8
0
static void twi_chan_cfg(struct sunxi_i2c_platform_data *pdata)
{
	int i;
	script_item_u item = {0};
	script_item_value_type_e type = 0;
	char twi_para[16] = {0};

	for (i=0; i<SUNXI_TWI_NUM; i++) {
		sprintf(twi_para, "twi%d", i);
		type = script_get_item(twi_para, "twi_used", &item);
		if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
			I2C_ERR("[twi%d] has no twi_used!\n", i);
			continue;
		}
		if (item.val)
			twi_used_mask |= SUNXI_TWI_CHAN_MASK(i);

		type = script_get_item(twi_para, "twi_regulator", &item);
		if (SCIRPT_ITEM_VALUE_TYPE_STR != type) {
			I2C_ERR("[twi%d] has no twi_regulator.\n", i);
			continue;
		}
		strncpy(pdata[i].regulator_id, item.str, 16);
	}
}
Ejemplo n.º 9
0
static int __init sw_rfkill_init(void)
{
	script_item_value_type_e type;
	script_item_u val;
	struct gpio_config  *gpio_p = NULL;

	type = script_get_item("bt_para", "bt_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		RF_MSG("failed to fetch bt configuration!\n");
		return -1;
	}
	if (!val.val) {
		RF_MSG("init no bt used in configuration\n");
		return 0;
	}
	bt_used = val.val;

	bt_rst_n = -1;
	type = script_get_item("bt_para", "bt_rst_n", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_PIO!=type)
		RF_MSG("mod has no bt_rst_n gpio\n");
	else {
		gpio_p = &val.gpio;
		bt_rst_n = gpio_p->gpio;
		sunxi_gpio_req(gpio_p);
	}

	platform_device_register(&sw_rfkill_dev);
	return platform_driver_register(&sw_rfkill_driver);
}
Ejemplo n.º 10
0
void ap6xxx_gpio_init(void)
{
	script_item_u val;
	script_item_value_type_e type;
	struct wifi_pm_ops *ops = &wifi_select_pm_ops;

	type = script_get_item(wifi_para, "wifi_power", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_STR != type) {
		ap6xxx_msg("failed to fetch wifi_power\n");
		return;
	}

	axp_name = val.str;
	ap6xxx_msg("module power name %s\n", axp_name);

	type = script_get_item(wifi_para, "ap6xxx_wl_regon", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_PIO!=type) 
		ap6xxx_msg("get ap6xxx ap6xxx_wl_regon gpio failed\n");
	else
		ap6xxx_wl_regon = val.gpio.gpio;

	type = script_get_item(wifi_para, "ap6xxx_bt_regon", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_PIO!=type) 
		ap6xxx_msg("get ap6xxx ap6xxx_bt_regon gpio failed\n");
	else
		ap6xxx_bt_regon = val.gpio.gpio;

	ops->gpio_ctrl	= ap6xxx_gpio_ctrl;
	ops->power = ap6xxx_power;

	ap6xxx_module_power(1);
}
Ejemplo n.º 11
0
__u32 NAND_GetNandExtPara(__u32 para_num)
{
	script_item_u nand_para;
    script_item_value_type_e type;

	if (para_num == 0) {
	    type = script_get_item("nand0_para", "nand_p0", &nand_para);
	    if(SCIRPT_ITEM_VALUE_TYPE_INT != type)
	    {
	        printk("nand0_para, nand_p0, nand type err! %d\n", type);
			return 0xffffffff;
	    }
		else
			return nand_para.val;
	} else if (para_num == 1) {
	    type = script_get_item("nand0_para", "nand_p1", &nand_para);
	    if(SCIRPT_ITEM_VALUE_TYPE_INT != type)
	    {
	        printk("nand0_para, nand_p1, nand type err! %d\n", type);
			return 0xffffffff;
	    }
		else
			return nand_para.val;
	} else {
		printk("NAND_GetNandExtPara: wrong para num: %d\n", para_num);
		return 0xffffffff;
	}
}
Ejemplo n.º 12
0
static int __init sun6i_i2s_init(void)
{	
	int err = 0;
	int cnt = 0;
	int i 	= 0;
	script_item_u val;
	script_item_u *list = NULL;
	script_item_value_type_e  type;

	type = script_get_item("i2s_para", "i2s_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[I2S] type err!\n");
    }

	i2s_used = val.val;

	type = script_get_item("i2s_para", "i2s_select", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[I2S] i2s_select type err!\n");
    }
	i2s_select = val.val;

 	if (i2s_used) {
		/* get gpio list */
		cnt = script_get_pio_list("i2s_para", &list);
		if (0 == cnt) {
			printk("get i2s_para gpio list failed\n");
			return -EFAULT;
		}
	/* req gpio */
	for (i = 0; i < cnt; i++) {
		if (0 != gpio_request(list[i].gpio.gpio, NULL)) {
			printk("[i2s] request some gpio fail\n");
			goto end;
		}
	}
	/* config gpio list */
	if (0 != sw_gpio_setall_range(&list[0].gpio, cnt)) {
		printk("sw_gpio_setall_range failed\n");
	}

	if((err = platform_device_register(&sun6i_i2s_device)) < 0)
		return err;

	if ((err = platform_driver_register(&sun6i_i2s_driver)) < 0)
			return err;	
	} else {
        printk("[I2S]sun6i-i2s cannot find any using configuration for controllers, return directly!\n");
        return 0;
    }

end:
	/* release gpio */
	while(i--)
		gpio_free(list[i].gpio.gpio);

	return 0;
}
Ejemplo n.º 13
0
static int __devinit sunxi_snddaudio0_dev_probe(struct platform_device *pdev)
{
	int ret = 0;
	script_item_u val;
	script_item_value_type_e  type;
	struct snd_soc_card *card = &snd_soc_sunxi_snddaudio;

	type = script_get_item(TDM_NAME, "daudio_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        	pr_err("[daudio0]:%s,line:%d type err!\n", __func__, __LINE__);
	}
	daudio_used = val.val;
	type = script_get_item(TDM_NAME, "daudio_select", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		pr_err("[I2S0] daudio_select type err!\n");
	}
	daudio_pcm_select = val.val;

	type = script_get_item(TDM_NAME, "daudio_master", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		pr_err("[I2S0] daudio_master type err!\n");
	}
	daudio_master = val.val;

	type = script_get_item(TDM_NAME, "audio_format", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		pr_err("[I2S0] audio_format type err!\n");
	}
	audio_format = val.val;

	type = script_get_item(TDM_NAME, "signal_inversion", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		pr_err("[I2S0] signal_inversion type err!\n");
	}
	signal_inversion = val.val;

	pr_debug("%s, line:%d, daudio_used:%d,daudio_pcm_select:%d,daudio_master:%d,audio_format:%d,signal_inversion:%d\n", __func__,
			__LINE__, daudio_used,daudio_pcm_select,daudio_master,audio_format,signal_inversion);
	if (daudio_used) {
		card->dev = &pdev->dev;
	
		ret = snd_soc_register_card(card);
		if (ret) {
			dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
				ret);
		}
	} else {
		pr_err("[daudio0]sunxi_snddaudio0 cannot find any using configuration for controllers, return directly!\n");
        return 0;
	}
		
	return ret;
}
Ejemplo n.º 14
0
static int ls_fetch_sysconfig_para(enum input_sensor_type *ls_type)
{
	int ret = -1;
	script_item_u	val;
	script_item_value_type_e  type;
	struct sensor_config_info *data = container_of(ls_type,
					struct sensor_config_info, input_type);

	type = script_get_item("ls_para", "ls_used", &val);

	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		pr_err("%s: type err  device_used = %d. \n", __func__, val.val);
		goto script_get_err;
	}
	data->sensor_used = val.val;
	
	if (1 == data->sensor_used) {
		type = script_get_item("ls_para", "ls_twi_id", &val);	
		if(SCIRPT_ITEM_VALUE_TYPE_INT != type){
			pr_err("%s: type err twi_id = %d. \n", __func__, val.val);
			goto script_get_err;
		}
		data->twi_id = val.val;

		type = script_get_item("ls_para", "ls_int", &val);	
		if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
			printk("%s: type err twi int1 = %d. \n", __func__, val.gpio.gpio);
			goto script_get_err;
		}
		data->irq_gpio = val.gpio;
		data->int_number = val.gpio.gpio;
		
		type = script_get_item("ls_para", "ls_ldo", &val);
		if (SCIRPT_ITEM_VALUE_TYPE_STR != type)
			pr_err("%s: no ldo for light distance sensor, ignore it\n", __func__);
		else
			data->ldo = val.str;

		ret = 0;
		
	} else {
		pr_err("%s: ls_unused. \n",  __func__);
		ret = -1;
	}

	return ret;

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

}
Ejemplo n.º 15
0
/*
*********************************************************************************************************
*                           aw_pm_init
*
*Description: initial pm sub-system for platform;
*
*Arguments  : none;
*
*Return     : result;
*
*Notes      :
*
*********************************************************************************************************
*/
static int __init aw_pm_init(void)
{
    script_item_u item;
    script_item_u   *list = NULL;
    int cpu0_en = 0;
    int dram_selfresh_en = 0;
    int wakeup_src_cnt = 0;
    
    PM_DBG("aw_pm_init!\n");

    if (fetch_dram_para(&standby_info.dram_para) != 0)
    {
        memset(&standby_info.dram_para, 0, sizeof(standby_info.dram_para));
        pr_err("%s: fetch_dram_para err. \n", __func__);
    }
    memcpy(&mem_para_info.dram_para, &standby_info.dram_para, sizeof(standby_info.dram_para));
    
    //get standby_mode.
    if(SCIRPT_ITEM_VALUE_TYPE_INT != script_get_item("pm_para", "standby_mode", &item)){
        pr_err("%s: script_parser_fetch err. \n", __func__);
        standby_mode = 0;
        //standby_mode = 1;
        pr_err("notice: standby_mode = %d.\n", standby_mode);
    }else{
        standby_mode = item.val;
        pr_info("standby_mode = %d. \n", standby_mode);
        if(1 != standby_mode){
            pr_err("%s: not support super standby. \n",  __func__);
        }
    }

    //get wakeup_src_para cpu_en
    if(SCIRPT_ITEM_VALUE_TYPE_INT != script_get_item("wakeup_src_para", "cpu_en", &item)){
        cpu0_en = 0;
    }else{
        cpu0_en = item.val;
    }
    pr_info("cpu0_en = %d.\n", cpu0_en);

    //get dram_selfresh en
    if(SCIRPT_ITEM_VALUE_TYPE_INT != script_get_item("wakeup_src_para", "dram_selfresh_en", &item)){
        dram_selfresh_en = 1;
    }else{
        dram_selfresh_en = item.val;
    }
    pr_info("dram_selfresh_en = %d.\n", dram_selfresh_en);

    if(0 == dram_selfresh_en && 0 == cpu0_en){
        pr_err("Notice: if u don't want the dram enter selfresh mode,\n \
                make sure the cpu0 is not allowed to be powered off.\n");
        goto script_para_err;
    }else{
Ejemplo n.º 16
0
/*
 * Return:
 *	0:	power on successfully
 *	others: power on failed
 */
int platform_wifi_power_on(void)
{
	int ret = 0;

#ifdef CONFIG_MMC
{
	script_item_u val;
	script_item_value_type_e type;

	type = script_get_item("wifi_para", "wifi_used", &val);
	if ((SCIRPT_ITEM_VALUE_TYPE_INT != type) || (0 == val.val)) {
		DBG_871X("wifi is not used\n");
		return -1;
	}

	type = script_get_item("wifi_para", "wifi_sdc_id", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT!=type) {
		DBG_871X("get wifi_sdc_id failed\n");
		ret = -1;
	} else {
		sdc_id = val.val;
		DBG_871X("----- %s sdc_id: %d\n", __FUNCTION__, sdc_id);

#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
		sw_mci_rescan_card(sdc_id, 1);
#elif defined(CONFIG_PLATFORM_ARM_SUN8I)
		sunxi_mci_rescan_card(sdc_id, 1);
#endif
		mdelay(100);
		wifi_pm_power(1);

		DBG_871X("%s: power up, rescan card.\n", __FUNCTION__);
	}

#ifdef CONFIG_GPIO_WAKEUP
	type = script_get_item("wifi_para", "wl_host_wake", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
		DBG_871X("No definition of wake up host PIN\n");
		ret = -1;
	} else {
		gpio_eint_wlan = val.gpio.gpio;
#ifdef CONFIG_PLATFORM_ARM_SUN8I
		oob_irq = gpio_to_irq(gpio_eint_wlan);
#endif
	}
#endif // CONFIG_GPIO_WAKEUP
}
#endif // CONFIG_MMC

	return ret;
}
Ejemplo n.º 17
0
static int sunxi_pin_init(struct sunxi_otgc *otgc)
{
	int ret = 0;

	script_item_value_type_e type = 0;
	script_item_u item_temp;

	/* usbc drv_vbus */
	type = script_get_item("usbc0", "usb_drv_vbus_gpio", &(otgc->port_ctl.drv_vbus.gpio_set));
	if (type == SCIRPT_ITEM_VALUE_TYPE_PIO) {
		otgc->port_ctl.drv_vbus.valid = 1;
	} else {
		otgc->port_ctl.drv_vbus.valid  = 0;
		DMSG_PANIC("ERR: get usbc det_vbus failed\n");
	}

	if (otgc->port_ctl.drv_vbus.valid) {
		ret = gpio_request(otgc->port_ctl.drv_vbus.gpio_set.gpio.gpio, "otg_drv_vbus");
		if (ret != 0) {
			DMSG_PANIC("ERR: gpio_request failed\n");
			otgc->port_ctl.drv_vbus.valid = 0;
		} else {
			gpio_direction_output(otgc->port_ctl.drv_vbus.gpio_set.gpio.gpio, 0);
		}
	}

	/* get regulator io information */
	type = script_get_item("usbc0", "usb_regulator_io", &item_temp);
	if (type == SCIRPT_ITEM_VALUE_TYPE_STR) {
		if (!strcmp(item_temp.str, "nocare")) {
			DMSG_INFO("get usbc0_regulator is nocare\n");
			otgc->port_ctl.regulator_io = NULL;
		}else{
			otgc->port_ctl.regulator_io = item_temp.str;

			type = script_get_item("usbc0",  "usb_regulator_vol", &item_temp);
			if(type == SCIRPT_ITEM_VALUE_TYPE_INT){
				otgc->port_ctl.regulator_value = item_temp.val;
			}else{
				DMSG_INFO("get usbc0_value is failed\n");
				otgc->port_ctl.regulator_value = 0;
			}
		}
	}else {
		DMSG_INFO("get usbc0_regulator is failed\n");
		otgc->port_ctl.regulator_io = NULL;
	}

	return 0;
}
Ejemplo n.º 18
0
static int __init sunxi_sndi2s1_init(void)
{
	int ret = 0;
	script_item_u val;
	script_item_value_type_e  type;

	type = script_get_item("i2s1", "i2s1_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[I2S1] type err!\n");
    }
	i2s1_used = val.val;
	type = script_get_item("i2s1", "i2s1_select", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[I2S1] i2s1_select type err!\n");
    }
	i2s1_pcm_select = val.val;
	
	type = script_get_item("i2s1", "i2s1_master", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[I2S1] i2s1_master type err!\n");
    }
	i2s1_master = val.val;
	
	type = script_get_item("i2s1", "audio_format", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[I2S1] audio_format type err!\n");
    }
	audio_format = val.val;

	type = script_get_item("i2s1", "signal_inversion", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[I2S1] signal_inversion type err!\n");
    }
	signal_inversion = val.val;

    if (i2s1_used) {
		sunxi_sndi2s1_device = platform_device_alloc("soc-audio", 3);
		if(!sunxi_sndi2s1_device)
			return -ENOMEM;
		platform_set_drvdata(sunxi_sndi2s1_device, &snd_soc_sunxi_sndi2s1);
		ret = platform_device_add(sunxi_sndi2s1_device);
		if (ret) {
			platform_device_put(sunxi_sndi2s1_device);
		}
	}else{
		printk("[I2S1]sunxi_sndi2s1 cannot find any using configuration for controllers, return directly!\n");
        return 0;
	}
	return ret;
}
int platform_wifi_power_on(void)
{
	int ret = 0;

#if defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)
	{
		script_item_value_type_e type;

		type = script_get_item("wifi_para", "wifi_usbc_id", &item);
		if(SCIRPT_ITEM_VALUE_TYPE_INT != type){
			printk("ERR: script_get_item wifi_usbc_id failed\n");
			ret = -ENOMEM;
			goto exit;
		}

		printk("sw_usb_enable_hcd: usbc_num = %d\n", item.val);
		wifi_pm_power(1);
		mdelay(10);
	
		#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
		sw_usb_enable_hcd(item.val);
		#endif
	}
#endif //defined(CONFIG_PLATFORM_ARM_SUN6I) || defined(CONFIG_PLATFORM_ARM_SUN7I)

#if defined(CONFIG_PLATFORM_ARM_SUNxI)
	{
		script_item_value_type_e type;

		type = script_get_item("wifi_para", "wifi_usbc_id", &item);
		if(SCIRPT_ITEM_VALUE_TYPE_INT != type){
			printk("ERR: script_get_item wifi_usbc_id failed\n");
			ret = -ENOMEM;
			goto exit;
		}

		printk("sunxi_usb_enable_hcd: usbc_num = %d\n", item.val);
		wifi_pm_power(1);
		mdelay(10);
	
		#if !(defined(CONFIG_RTL8723A)) && !(defined(CONFIG_RTL8723B))
		sunxi_usb_enable_hcd(item.val);
		#endif
	}
#endif //CONFIG_PLATFORM_ARM_SUNxI

exit:
	return ret;
}
static __s32 camera_req_mclk_pin(__u32 csi_index)
{
        char *csi_para[2] = {"csi0_para", "csi1_para"};
        int	                        req_status;
	script_item_u                   item;
	script_item_value_type_e        type;    

        /* »ñÈ¡gpio list */
	type = script_get_item(csi_para[csi_index], "csi_ck", &item);
	if(SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
		camera_err("script_get_item return type err\n");
		return -ECFGERR;
	}

        /* ÉêÇëgpio */
	req_status = gpio_request(item.gpio.gpio, NULL);
	if(0 != req_status) {
		camera_err("request gpio failed\n");
                return -ENORMALPIN;
	}

        /* ÅäÖÃgpio */
	if(0 != sw_gpio_setall_range(&item.gpio, 1)) {
		camera_err("sw_gpio_setall_range failed\n");

                gpio_free(item.gpio.gpio);
                return -ECFGPIN;
	}

        /* ÊÍ·Ågpio */
	if(0 == req_status)
		gpio_free(item.gpio.gpio);

        return 0;
}
Ejemplo n.º 21
0
int bcm_wlan_get_oob_irq(void)
{
	int host_oob_irq = 0;
	int ret = 0;
	int wl_host_wake = 0;
	script_item_u val ;
	script_item_value_type_e type;
	
	printk("bcm_wlan_get_oob_irq enter.\n");
	
	type = script_get_item("wifi_para", "ap6xxx_wl_host_wake", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_PIO!=type) 
		printk("get bcmdhd ap6xxx_wl_host_wake gpio failed\n");
	else
		wl_host_wake = val.gpio.gpio;
		
	host_oob_irq = gpio_to_irq(wl_host_wake);
	if (IS_ERR_VALUE(host_oob_irq)) {
		printk("map gpio [%d] to virq failed, errno = %d\n",wl_host_wake, host_oob_irq);
		return 0;
	}
	printk("gpio [%d] map to virq [%d] ok\n",wl_host_wake, host_oob_irq);

	return host_oob_irq;
}
Ejemplo n.º 22
0
int ir_cut_sys_script_get_item(char *main_name, char *sub_name, int value[], int count)
{
    script_item_u   val;
	script_item_value_type_e  type;
	int ret = -1;

	type = script_get_item(main_name, sub_name, &val);
	if(SCIRPT_ITEM_VALUE_TYPE_INT == type) {
		ret = 0;
		*value = val.val;
		__inf("%s.%s=%d\n", main_name, sub_name, *value);
	}	else if(SCIRPT_ITEM_VALUE_TYPE_PIO == type) {
		ir_cut_gpio_set_t *gpio_info = (ir_cut_gpio_set_t *)value;

		ret = 0;
		gpio_info->gpio = val.gpio.gpio;
		gpio_info->mul_sel = val.gpio.mul_sel;
		gpio_info->pull = val.gpio.pull;
		gpio_info->drv_level = val.gpio.drv_level;
		gpio_info->data = val.gpio.data;
		memcpy(gpio_info->gpio_name, sub_name, strlen(sub_name)+1);
		__inf("%s.%s gpio=%d,mul_sel=%d,data:%d\n",main_name, sub_name, gpio_info->gpio, gpio_info->mul_sel, gpio_info->data);
	}	else if(SCIRPT_ITEM_VALUE_TYPE_STR == type) {
		memcpy((void*)value, (void*)val.str, strlen(val.str)+1);
		__inf("%s.%s=%s\n",main_name, sub_name, val.str);
	} else {
		ret = -1;
		__inf("fetch script data %s.%s fail\n", main_name, sub_name);
	}

	return type;

}
Ejemplo n.º 23
0
static int __init sunxi_spdif_init(void)
{
	int err = 0;
	script_item_u val;
	script_item_value_type_e  type;

	type = script_get_item("spdif0", "spdif_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[SPDIF] type err!\n");
    }

	spdif_used = val.val;
	printk("%s, line:%d, spdif_used:%d\n", __func__, __LINE__, spdif_used);
 	if (spdif_used) {
		if((platform_device_register(&sunxi_spdif_device))<0)
			return err;

		if ((err = platform_driver_register(&sunxi_spdif_driver)) < 0)
			return err;
	} else {
        printk("[SPDIF]sunxi-spdif cannot find any using configuration for controllers, return directly!\n");
        return 0;
    }
 
	return 0;
}
Ejemplo n.º 24
0
static int GetParaFromFex(char *main_key, char *second_key, int max_value)
{
    u32 value;
    script_item_u val;
    script_item_value_type_e type;
    type = script_get_item(main_key, second_key, &val);
    if (SCIRPT_ITEM_VALUE_TYPE_INT != type)
	{
        PVR_DPF((PVR_DBG_ERROR, "%s: %s in sys_config.fex is invalid!\n", main_key, second_key));
        return -1;
    }
    value = val.val;

    if(max_value)
    {
        if(value <= max_value)
        {
            return value;
        }
        else
        {
            return -1;
        }
    }
    else
    {
        return value;
    }
}
Ejemplo n.º 25
0
static int __init sndspdif_codec_init(void)
{	
	int err = 0;
	script_item_u val;
	script_item_value_type_e  type;

	type = script_get_item("spdif_para", "spdif_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[SPDIF] type err!\n");
    }

	spdif_used = val.val;
	if (spdif_used) {
		if((err = platform_device_register(&sndspdif_codec_device)) < 0)
			return err;

		if ((err = platform_driver_register(&sndspdif_codec_driver)) < 0)
			return err;
	} else {
        printk("[SPDIF]sndspdif cannot find any using configuration for controllers, return directly!\n");
        return 0;
    }
	
	return 0;
}
Ejemplo n.º 26
0
static int __init sun6i_sndspdif_init(void)
{
	int ret = 0;
	static script_item_u val;
	script_item_value_type_e  type;

	type = script_get_item("spdif_para", "spdif_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[SPDIF] type err!\n");
        return -EINVAL;
    }

    spdif_used = val.val;
    if (spdif_used) {
		sun6i_sndspdif_device = platform_device_alloc("soc-audio", 1);
		
		if(!sun6i_sndspdif_device)
			return -ENOMEM;
			
		platform_set_drvdata(sun6i_sndspdif_device, &snd_soc_sun6i_sndspdif);
		
		ret = platform_device_add(sun6i_sndspdif_device);
		if (ret) {			
			platform_device_put(sun6i_sndspdif_device);
		}
	} else {
		printk("[SPDIF]sun6i_sndspdif cannot find any using configuration for controllers, return directly!\n");
        return 0;
	}
		
	return ret;
}
Ejemplo n.º 27
0
static int __init snddaudio_codec_init(void)
{	
	int err = 0;
	script_item_u val;
	script_item_value_type_e  type;

	type = script_get_item(TDM_NAME, "daudio_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        pr_err("[I2S] type err!\n");
    }

	daudio_used = val.val;

	if (daudio_used) {
		if((err = platform_device_register(&snddaudio_codec_device)) < 0)
			return err;
	
		if ((err = platform_driver_register(&snddaudio_codec_driver)) < 0)
			return err;
	} else {
       pr_err("[I2S]snddaudio cannot find any using configuration for controllers, return directly!\n");
       return 0;
    }
	
	return 0;
}
Ejemplo n.º 28
0
uint bcm_wlan_get_oob_irq_flags(void)
{
	uint host_oob_irq_flags = 0;

#ifdef CONFIG_MACH_ODROID_4210
#ifdef HW_OOB
	host_oob_irq_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE;
#else
	host_oob_irq_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_SHAREABLE;
#endif
#endif
#ifdef CUSTOMER_HW_ALLWINNER
	script_item_value_type_e type;
	script_item_u val;
	int host_wake_invert = 0;

	type = script_get_item("wifi_para", "wl_host_wake_invert", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type)
		printk("has no wl_host_wake_invert\n");
	else
		host_wake_invert = val.val;

#ifdef HW_OOB
	if(!host_wake_invert)
		host_oob_irq_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL | IORESOURCE_IRQ_SHAREABLE;
	else
		host_oob_irq_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL | IORESOURCE_IRQ_SHAREABLE;
#else
	host_oob_irq_flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE | IORESOURCE_IRQ_SHAREABLE;
#endif
#endif
	printk("host_oob_irq_flags=%d\n", host_oob_irq_flags);

	return host_oob_irq_flags;
}
Ejemplo n.º 29
0
static script_item_u get_para_value(char* keyname, char* subname)
{
        script_item_u	val;
        script_item_value_type_e type = 0;

        
        if((!keyname) || (!subname)) {
               printk("keyname:%s  subname:%s \n", keyname, subname);
               goto script_get_item_err;
        }
                
        memset(&val, 0, sizeof(val));
        type = script_get_item(keyname, subname, &val);
         
        if((SCIRPT_ITEM_VALUE_TYPE_INT != type) && (SCIRPT_ITEM_VALUE_TYPE_STR != type) &&
          (SCIRPT_ITEM_VALUE_TYPE_PIO != type)) {
	        goto script_get_item_err;
	}
	
        return val;
        
script_get_item_err:
        printk("keyname:%s  subname:%s ,get error!\n", keyname, subname);
        val.val = -1;
	return val;
}
Ejemplo n.º 30
0
static int __init sndpcm_codec_init(void)
{	
	int err = 0;
	script_item_u val;
	script_item_value_type_e  type;
	printk("func:%s(line:%d)sndpcm.c\n",__func__,__LINE__);
	type = script_get_item("pcm_para", "pcm_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
        printk("[PCM] type err!\n");
    }
	pcm_used = val.val;
	printk("func:%s(line:%d)sndpcm.c,pcm_used:%d\n",__func__,__LINE__,pcm_used);
	if (pcm_used) {
		if((err = platform_device_register(&sndpcm_codec_device)) < 0)
			return err;
	
		if ((err = platform_driver_register(&sndpcm_codec_driver)) < 0)
			return err;
	} else {
       printk("[PCM]sndi2s cannot find any using configuration for controllers, return directly!\n");
       return 0;
    }
	
	return 0;
}