Bluetooth:Add ioctl to power control connectivity chip
Added new ioctl command to perform power on/off operations on connectivity chipset from userspace process. CRs-Fixed: 1049512 Change-Id: Id254a12ba8fc2d57951d158c8fce80168375586d Signed-off-by: Satish kumar sugasi <ssugas@codeaurora.org> Signed-off-by: Bhakthavatsala Raghavendra <braghave@codeaurora.org>
This commit is contained in:
parent
827d048300
commit
63288e7dc9
2 changed files with 18 additions and 2 deletions
|
@ -46,6 +46,7 @@ static const struct of_device_id bt_power_match_table[] = {
|
||||||
static struct bluetooth_power_platform_data *bt_power_pdata;
|
static struct bluetooth_power_platform_data *bt_power_pdata;
|
||||||
static struct platform_device *btpdev;
|
static struct platform_device *btpdev;
|
||||||
static bool previous;
|
static bool previous;
|
||||||
|
static int pwr_state;
|
||||||
struct class *bt_class;
|
struct class *bt_class;
|
||||||
static int bt_major;
|
static int bt_major;
|
||||||
|
|
||||||
|
@ -636,6 +637,7 @@ static int bt_power_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
memcpy(bt_power_pdata, pdev->dev.platform_data,
|
memcpy(bt_power_pdata, pdev->dev.platform_data,
|
||||||
sizeof(struct bluetooth_power_platform_data));
|
sizeof(struct bluetooth_power_platform_data));
|
||||||
|
pwr_state = 0;
|
||||||
} else {
|
} else {
|
||||||
BT_PWR_ERR("Failed to get platform data");
|
BT_PWR_ERR("Failed to get platform data");
|
||||||
goto free_pdata;
|
goto free_pdata;
|
||||||
|
@ -680,7 +682,7 @@ int bt_register_slimdev(struct device *dev)
|
||||||
|
|
||||||
static long bt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
static long bt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret, pwr_cntrl = 0;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case BT_CMD_SLIM_TEST:
|
case BT_CMD_SLIM_TEST:
|
||||||
|
@ -692,6 +694,18 @@ static long bt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
bt_power_pdata->slim_dev->platform_data
|
bt_power_pdata->slim_dev->platform_data
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case BT_CMD_PWR_CTRL:
|
||||||
|
pwr_cntrl = (int)arg;
|
||||||
|
BT_PWR_ERR("BT_CMD_PWR_CTRL pwr_cntrl:%d", pwr_cntrl);
|
||||||
|
if (pwr_state != pwr_cntrl) {
|
||||||
|
ret = bluetooth_power(pwr_cntrl);
|
||||||
|
if (!ret)
|
||||||
|
pwr_state = pwr_cntrl;
|
||||||
|
} else {
|
||||||
|
BT_PWR_ERR("BT chip state is already :%d no change d\n"
|
||||||
|
, pwr_state);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -711,6 +725,7 @@ static struct platform_driver bt_power_driver = {
|
||||||
static const struct file_operations bt_dev_fops = {
|
static const struct file_operations bt_dev_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.unlocked_ioctl = bt_ioctl,
|
.unlocked_ioctl = bt_ioctl,
|
||||||
|
.compat_ioctl = bt_ioctl,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init bluetooth_power_init(void)
|
static int __init bluetooth_power_init(void)
|
||||||
|
@ -733,7 +748,7 @@ static int __init bluetooth_power_init(void)
|
||||||
|
|
||||||
|
|
||||||
if (device_create(bt_class, NULL, MKDEV(bt_major, 0),
|
if (device_create(bt_class, NULL, MKDEV(bt_major, 0),
|
||||||
NULL, "pintest") == NULL) {
|
NULL, "btpower") == NULL) {
|
||||||
BTFMSLIM_ERR("failed to allocate char dev\n");
|
BTFMSLIM_ERR("failed to allocate char dev\n");
|
||||||
goto chrdev_unreg;
|
goto chrdev_unreg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,4 +85,5 @@ struct bluetooth_power_platform_data {
|
||||||
int bt_register_slimdev(struct device *dev);
|
int bt_register_slimdev(struct device *dev);
|
||||||
|
|
||||||
#define BT_CMD_SLIM_TEST 0xbfac
|
#define BT_CMD_SLIM_TEST 0xbfac
|
||||||
|
#define BT_CMD_PWR_CTRL 0xbfad
|
||||||
#endif /* __LINUX_BLUETOOTH_POWER_H */
|
#endif /* __LINUX_BLUETOOTH_POWER_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue