コード例 #1
0
ファイル: bt_pm.c プロジェクト: condret/OrangePI-Kernel
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);
}
コード例 #2
0
ファイル: gps_pm.c プロジェクト: GREYFOXRGR/BPI-M3-bsp
static int __init gps_get_config(struct gps_config_info *gps_info)
{
	script_item_value_type_e type;
	script_item_u val;
	struct gpio_config  *gpio_p = NULL;

	memset(gps_info,0,sizeof(struct gps_config_info));
	type = script_get_item("gps_para", "gps_used", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_INT != type) {
		GPS_ERR("failed to fetch gps configuration!\n");
		return -1;
	}
	if (!val.val) {
		GPS_ERR("gsp not used in configuration\n");
		return -1;
	}
	gps_info->gps_used = val.val;
	
	type = script_get_item("gps_para", "gps_standby_n", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_PIO != type)
		GPS_DBG("mod has no gps_standby_n gpio\n");
	else {
		gpio_p = &val.gpio;
		gps_info->standby = gpio_p->gpio;
		sunxi_gpio_req(gpio_p);
	}

	type = script_get_item("gps_para", "gps_rst_n", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_PIO != type)
		GPS_DBG("mod has no gps_rst_n gpio\n");
	else {
		gpio_p = &val.gpio;
		gps_info->reset = gpio_p->gpio;
		sunxi_gpio_req(gpio_p);
	}
	
	type = script_get_item("gps_para", "gps_clk", &val);
	if (SCIRPT_ITEM_VALUE_TYPE_STR != type) 
		GPS_DBG("failed to fetch gps_clk\n");
	else {
		strcpy(gps_info->gps_clk, val.str);
	}
	
	return 0;
}