[RAMEN9610-14929][COMMON] drivers: led: change operating mode of s2mu106 fled
authorKeunho Hwang <keunho.hwang@samsung.com>
Tue, 7 May 2019 03:41:07 +0000 (03:41 +0000)
committerKim Gunho <gunho.kim@samsung.com>
Fri, 28 Jun 2019 14:44:55 +0000 (23:44 +0900)
Change-Id: Ie217e327f908c0a1419a00475ab0647ca7c9815b
Signed-off-by: Keunho Hwang <keunho.hwang@samsung.com>
drivers/leds/leds-s2mu106.c
include/linux/leds-s2mu106.h

index 4eb87473b1aa257d4df68ec6492a36af7c297cdf..0a4ef70ef7c2a7dd09ef4f26de5575d9ef17536a 100644 (file)
@@ -29,6 +29,13 @@ static char *s2mu106_fled_mode_string[] = {
        "FLASH",
 };
 
+static char *s2mu106_fled_operating_mode_string[] = {
+       "AUTO",
+       "BOOST",
+       "TA",
+       "SYS",
+};
+
 /* IC current limit */
 static int s2mu106_fled_torch_curr_max[] = {
        0, 320, 320, 320
@@ -244,6 +251,23 @@ static int s2mu106_fled_set_torch_curr(struct s2mu106_fled_data *fled,
 
 }
 
+static void s2mu106_fled_operating_mode(struct s2mu106_fled_data *fled,
+                                       int mode)
+{
+       u8 value;
+
+       if (mode < 0 || mode > 3) {
+               pr_info ("%s, wrong mode\n", __func__);
+               mode = AUTO_MODE;
+       }
+
+       pr_info ("%s = %s\n", __func__,
+                s2mu106_fled_operating_mode_string[mode]);
+
+       value = mode << 6;
+       s2mu106_update_reg(fled->i2c, S2MU106_FLED_CTRL0, value, 0xC0);
+}
+
 static int s2mu106_fled_get_mode(struct s2mu106_fled_data *fled, int chan)
 {
        u8 status;
@@ -314,6 +338,7 @@ static int s2mu106_fled_set_mode(struct s2mu106_fled_data *fled,
                        bit = S2MU106_FLED_EN << 3;
                        break;
                case S2MU106_FLED_MODE_TORCH:
+                       s2mu106_fled_operating_mode(fled, SYS_MODE);
                        mask = S2MU106_CHX_TORCH_FLED_EN;
                        bit = S2MU106_FLED_EN;
                        break;
@@ -350,6 +375,9 @@ static int s2mu106_fled_set_mode(struct s2mu106_fled_data *fled,
        }
        s2mu106_update_reg(fled->i2c, dest, bit, mask);
 
+       if (mode == S2MU106_FLED_MODE_OFF)
+               s2mu106_fled_operating_mode(fled, AUTO_MODE);
+
        return 0;
 }
 
index 31b37a1be7748dbff78663d26839a1d84e665f06..31ed9c65556f86ba60d55cf1739b09999a175b90 100644 (file)
 #define S2MU106_F2C_LC_IBAT    MASK(6,0)
 #define S2MU106_F2C_SYS_MIN_REG        MASK(3,0)
 
+/* FLED operating mode enable */
+enum operating_mode {
+       AUTO_MODE = 0,
+       BOOST_MODE,
+       TA_MODE,
+       SYS_MODE,
+};
+
 enum cam_flash_mode{
        CAM_FLASH_MODE_NONE=0,          //CAM2_FLASH_MODE_NONE=0,
        CAM_FLASH_MODE_OFF,                     //CAM2_FLASH_MODE_OFF,