Loading drivers/soc/qcom/bgcom_interface.c +65 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,10 @@ struct bgdaemon_regulator { struct bgdaemon_priv { struct bgdaemon_regulator rgltr; enum ldo_task ldo_action; void *pil_h; bool pending_bg_twm_wear_load; struct workqueue_struct *bgdaemon_wq; struct work_struct bgdaemon_load_twm_bg_work; }; struct bg_event { Loading Loading @@ -120,6 +124,20 @@ static int send_uevent(struct bg_event *pce) return kobject_uevent_env(&dev_ret->kobj, KOBJ_CHANGE, envp); } static void bgcom_load_twm_bg_work(struct work_struct *work) { if (dev->pil_h) { pr_err("bg-wear is already loaded\n"); subsystem_put(dev->pil_h); dev->pil_h = NULL; } else { dev->pil_h = subsystem_get_with_fwname("bg-wear", "bg-twm-wear"); if (!dev->pil_h) pr_err("failed to load bg-twm-wear\n"); } } static int bgdaemon_configure_regulators(bool state) { int retval; Loading @@ -146,6 +164,7 @@ static int bgdaemon_configure_regulators(bool state) } return retval; } static int bgdaemon_init_regulators(struct device *pdev) { int rc; Loading Loading @@ -398,8 +417,35 @@ static long bg_com_ioctl(struct file *filp, bg_app_running = true; ret = 0; break; case BG_WEAR_LOAD: ret = 0; if (dev->pil_h) { pr_err("bg-wear is already loaded\n"); ret = -EFAULT; break; } dev->pil_h = subsystem_get_with_fwname("bg-wear", "bg-wear"); if (!dev->pil_h) { pr_err("failed to load bg-wear\n"); ret = -EFAULT; } break; case BG_WEAR_TWM_LOAD: dev->pending_bg_twm_wear_load = true; queue_work(dev->bgdaemon_wq, &dev->bgdaemon_load_twm_bg_work); ret = 0; break; case BG_WEAR_UNLOAD: if (dev->pil_h) { subsystem_put(dev->pil_h); dev->pil_h = NULL; } ret = 0; break; default: ret = -ENOIOCTLCMD; break; } return ret; } Loading Loading @@ -521,7 +567,19 @@ static int __init init_bg_com_dev(void) if (platform_driver_register(&bg_daemon_driver)) pr_err("%s: failed to register bg-daemon register\n", __func__); dev->bgdaemon_wq = create_singlethread_workqueue("bgdaemon-work-queue"); if (!dev->bgdaemon_wq) { pr_err("Failed to init BG-DAEMON work-queue\n"); goto free_wq; } INIT_WORK(&dev->bgdaemon_load_twm_bg_work, bgcom_load_twm_bg_work); return 0; free_wq: destroy_workqueue(dev->bgdaemon_wq); return -EFAULT; } static void __exit exit_bg_com_dev(void) Loading Loading @@ -556,6 +614,12 @@ static int ssr_bg_cb(struct notifier_block *this, case SUBSYS_AFTER_SHUTDOWN: /* Add sleep for SPI Bus to release*/ msleep(SLEEP_FOR_SPI_BUS); if (dev->pending_bg_twm_wear_load) { /* Load bg-twm-wear */ dev->pending_bg_twm_wear_load = false; queue_work(dev->bgdaemon_wq, &dev->bgdaemon_load_twm_bg_work); } break; case SUBSYS_AFTER_POWERUP: bge.e_type = BG_AFTER_POWER_UP; Loading Loading @@ -596,6 +660,7 @@ static int ssr_modem_cb(struct notifier_block *this, } return NOTIFY_DONE; } static int ssr_adsp_cb(struct notifier_block *this, unsigned long opcode, void *data) { Loading include/uapi/linux/bgcom_interface.h +14 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ #define BGCOM_TWM_EXIT 8 #define BGCOM_BG_APP_RUNNING 9 #define BGCOM_ADSP_DOWN2_BG 10 #define BGCOM_BG_WEAR_LOAD 11 #define BGCOM_BG_WEAR_TWM_LOAD 12 #define BGCOM_BG_WEAR_UNLOAD 13 #define EXCHANGE_CODE 'V' struct bg_ui_data { Loading @@ -34,6 +37,8 @@ struct bg_ui_data { enum bg_event_type { BG_BEFORE_POWER_DOWN = 1, BG_AFTER_POWER_DOWN, BG_BEFORE_POWER_UP, BG_AFTER_POWER_UP, MODEM_BEFORE_POWER_DOWN, MODEM_AFTER_POWER_UP, Loading Loading @@ -71,6 +76,15 @@ enum bg_event_type { #define BG_MODEM_DOWN2_BG_DONE \ _IOWR(EXCHANGE_CODE, BGCOM_MODEM_DOWN2_BG, \ struct bg_ui_data) #define BG_WEAR_LOAD \ _IOWR(EXCHANGE_CODE, BGCOM_BG_WEAR_LOAD, \ struct bg_ui_data) #define BG_WEAR_TWM_LOAD \ _IOWR(EXCHANGE_CODE, BGCOM_BG_WEAR_TWM_LOAD, \ struct bg_ui_data) #define BG_WEAR_UNLOAD \ _IOWR(EXCHANGE_CODE, BGCOM_BG_WEAR_UNLOAD, \ struct bg_ui_data) #define BG_ADSP_DOWN2_BG_DONE \ _IOWR(EXCHANGE_CODE, BGCOM_ADSP_DOWN2_BG, \ struct bg_ui_data) Loading Loading
drivers/soc/qcom/bgcom_interface.c +65 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,10 @@ struct bgdaemon_regulator { struct bgdaemon_priv { struct bgdaemon_regulator rgltr; enum ldo_task ldo_action; void *pil_h; bool pending_bg_twm_wear_load; struct workqueue_struct *bgdaemon_wq; struct work_struct bgdaemon_load_twm_bg_work; }; struct bg_event { Loading Loading @@ -120,6 +124,20 @@ static int send_uevent(struct bg_event *pce) return kobject_uevent_env(&dev_ret->kobj, KOBJ_CHANGE, envp); } static void bgcom_load_twm_bg_work(struct work_struct *work) { if (dev->pil_h) { pr_err("bg-wear is already loaded\n"); subsystem_put(dev->pil_h); dev->pil_h = NULL; } else { dev->pil_h = subsystem_get_with_fwname("bg-wear", "bg-twm-wear"); if (!dev->pil_h) pr_err("failed to load bg-twm-wear\n"); } } static int bgdaemon_configure_regulators(bool state) { int retval; Loading @@ -146,6 +164,7 @@ static int bgdaemon_configure_regulators(bool state) } return retval; } static int bgdaemon_init_regulators(struct device *pdev) { int rc; Loading Loading @@ -398,8 +417,35 @@ static long bg_com_ioctl(struct file *filp, bg_app_running = true; ret = 0; break; case BG_WEAR_LOAD: ret = 0; if (dev->pil_h) { pr_err("bg-wear is already loaded\n"); ret = -EFAULT; break; } dev->pil_h = subsystem_get_with_fwname("bg-wear", "bg-wear"); if (!dev->pil_h) { pr_err("failed to load bg-wear\n"); ret = -EFAULT; } break; case BG_WEAR_TWM_LOAD: dev->pending_bg_twm_wear_load = true; queue_work(dev->bgdaemon_wq, &dev->bgdaemon_load_twm_bg_work); ret = 0; break; case BG_WEAR_UNLOAD: if (dev->pil_h) { subsystem_put(dev->pil_h); dev->pil_h = NULL; } ret = 0; break; default: ret = -ENOIOCTLCMD; break; } return ret; } Loading Loading @@ -521,7 +567,19 @@ static int __init init_bg_com_dev(void) if (platform_driver_register(&bg_daemon_driver)) pr_err("%s: failed to register bg-daemon register\n", __func__); dev->bgdaemon_wq = create_singlethread_workqueue("bgdaemon-work-queue"); if (!dev->bgdaemon_wq) { pr_err("Failed to init BG-DAEMON work-queue\n"); goto free_wq; } INIT_WORK(&dev->bgdaemon_load_twm_bg_work, bgcom_load_twm_bg_work); return 0; free_wq: destroy_workqueue(dev->bgdaemon_wq); return -EFAULT; } static void __exit exit_bg_com_dev(void) Loading Loading @@ -556,6 +614,12 @@ static int ssr_bg_cb(struct notifier_block *this, case SUBSYS_AFTER_SHUTDOWN: /* Add sleep for SPI Bus to release*/ msleep(SLEEP_FOR_SPI_BUS); if (dev->pending_bg_twm_wear_load) { /* Load bg-twm-wear */ dev->pending_bg_twm_wear_load = false; queue_work(dev->bgdaemon_wq, &dev->bgdaemon_load_twm_bg_work); } break; case SUBSYS_AFTER_POWERUP: bge.e_type = BG_AFTER_POWER_UP; Loading Loading @@ -596,6 +660,7 @@ static int ssr_modem_cb(struct notifier_block *this, } return NOTIFY_DONE; } static int ssr_adsp_cb(struct notifier_block *this, unsigned long opcode, void *data) { Loading
include/uapi/linux/bgcom_interface.h +14 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ #define BGCOM_TWM_EXIT 8 #define BGCOM_BG_APP_RUNNING 9 #define BGCOM_ADSP_DOWN2_BG 10 #define BGCOM_BG_WEAR_LOAD 11 #define BGCOM_BG_WEAR_TWM_LOAD 12 #define BGCOM_BG_WEAR_UNLOAD 13 #define EXCHANGE_CODE 'V' struct bg_ui_data { Loading @@ -34,6 +37,8 @@ struct bg_ui_data { enum bg_event_type { BG_BEFORE_POWER_DOWN = 1, BG_AFTER_POWER_DOWN, BG_BEFORE_POWER_UP, BG_AFTER_POWER_UP, MODEM_BEFORE_POWER_DOWN, MODEM_AFTER_POWER_UP, Loading Loading @@ -71,6 +76,15 @@ enum bg_event_type { #define BG_MODEM_DOWN2_BG_DONE \ _IOWR(EXCHANGE_CODE, BGCOM_MODEM_DOWN2_BG, \ struct bg_ui_data) #define BG_WEAR_LOAD \ _IOWR(EXCHANGE_CODE, BGCOM_BG_WEAR_LOAD, \ struct bg_ui_data) #define BG_WEAR_TWM_LOAD \ _IOWR(EXCHANGE_CODE, BGCOM_BG_WEAR_TWM_LOAD, \ struct bg_ui_data) #define BG_WEAR_UNLOAD \ _IOWR(EXCHANGE_CODE, BGCOM_BG_WEAR_UNLOAD, \ struct bg_ui_data) #define BG_ADSP_DOWN2_BG_DONE \ _IOWR(EXCHANGE_CODE, BGCOM_ADSP_DOWN2_BG, \ struct bg_ui_data) Loading