1*e7647de0SChiaEn Wu // SPDX-License-Identifier: GPL-2.0-only 2*e7647de0SChiaEn Wu /* 3*e7647de0SChiaEn Wu * Copyright (C) 2022 Richtek Technology Corp. 4*e7647de0SChiaEn Wu * 5*e7647de0SChiaEn Wu * Author: ChiaEn Wu <chiaen_wu@richtek.com> 6*e7647de0SChiaEn Wu */ 7*e7647de0SChiaEn Wu 8*e7647de0SChiaEn Wu #include <linux/backlight.h> 9*e7647de0SChiaEn Wu #include <linux/bitfield.h> 10*e7647de0SChiaEn Wu #include <linux/bits.h> 11*e7647de0SChiaEn Wu #include <linux/gpio/consumer.h> 12*e7647de0SChiaEn Wu #include <linux/kernel.h> 13*e7647de0SChiaEn Wu #include <linux/minmax.h> 14*e7647de0SChiaEn Wu #include <linux/mod_devicetable.h> 15*e7647de0SChiaEn Wu #include <linux/module.h> 16*e7647de0SChiaEn Wu #include <linux/platform_device.h> 17*e7647de0SChiaEn Wu #include <linux/property.h> 18*e7647de0SChiaEn Wu #include <linux/regmap.h> 19*e7647de0SChiaEn Wu 20*e7647de0SChiaEn Wu #define MT6370_REG_DEV_INFO 0x100 21*e7647de0SChiaEn Wu #define MT6370_REG_BL_EN 0x1A0 22*e7647de0SChiaEn Wu #define MT6370_REG_BL_BSTCTRL 0x1A1 23*e7647de0SChiaEn Wu #define MT6370_REG_BL_PWM 0x1A2 24*e7647de0SChiaEn Wu #define MT6370_REG_BL_DIM2 0x1A4 25*e7647de0SChiaEn Wu 26*e7647de0SChiaEn Wu #define MT6370_VENID_MASK GENMASK(7, 4) 27*e7647de0SChiaEn Wu #define MT6370_BL_EXT_EN_MASK BIT(7) 28*e7647de0SChiaEn Wu #define MT6370_BL_EN_MASK BIT(6) 29*e7647de0SChiaEn Wu #define MT6370_BL_CODE_MASK BIT(0) 30*e7647de0SChiaEn Wu #define MT6370_BL_CH_MASK GENMASK(5, 2) 31*e7647de0SChiaEn Wu #define MT6370_BL_CH_SHIFT 2 32*e7647de0SChiaEn Wu #define MT6370_BL_DIM2_COMMON_MASK GENMASK(2, 0) 33*e7647de0SChiaEn Wu #define MT6370_BL_DIM2_COMMON_SHIFT 3 34*e7647de0SChiaEn Wu #define MT6370_BL_DIM2_6372_MASK GENMASK(5, 0) 35*e7647de0SChiaEn Wu #define MT6370_BL_DIM2_6372_SHIFT 6 36*e7647de0SChiaEn Wu #define MT6370_BL_PWM_EN_MASK BIT(7) 37*e7647de0SChiaEn Wu #define MT6370_BL_PWM_HYS_EN_MASK BIT(2) 38*e7647de0SChiaEn Wu #define MT6370_BL_PWM_HYS_SEL_MASK GENMASK(1, 0) 39*e7647de0SChiaEn Wu #define MT6370_BL_OVP_EN_MASK BIT(7) 40*e7647de0SChiaEn Wu #define MT6370_BL_OVP_SEL_MASK GENMASK(6, 5) 41*e7647de0SChiaEn Wu #define MT6370_BL_OVP_SEL_SHIFT 5 42*e7647de0SChiaEn Wu #define MT6370_BL_OC_EN_MASK BIT(3) 43*e7647de0SChiaEn Wu #define MT6370_BL_OC_SEL_MASK GENMASK(2, 1) 44*e7647de0SChiaEn Wu #define MT6370_BL_OC_SEL_SHIFT 1 45*e7647de0SChiaEn Wu 46*e7647de0SChiaEn Wu #define MT6370_BL_PWM_HYS_TH_MIN_STEP 1 47*e7647de0SChiaEn Wu #define MT6370_BL_PWM_HYS_TH_MAX_STEP 64 48*e7647de0SChiaEn Wu #define MT6370_BL_OVP_MIN_UV 17000000 49*e7647de0SChiaEn Wu #define MT6370_BL_OVP_MAX_UV 29000000 50*e7647de0SChiaEn Wu #define MT6370_BL_OVP_STEP_UV 4000000 51*e7647de0SChiaEn Wu #define MT6370_BL_OCP_MIN_UA 900000 52*e7647de0SChiaEn Wu #define MT6370_BL_OCP_MAX_UA 1800000 53*e7647de0SChiaEn Wu #define MT6370_BL_OCP_STEP_UA 300000 54*e7647de0SChiaEn Wu #define MT6370_BL_MAX_COMMON_BRIGHTNESS 2048 55*e7647de0SChiaEn Wu #define MT6370_BL_MAX_6372_BRIGHTNESS 16384 56*e7647de0SChiaEn Wu #define MT6370_BL_MAX_CH 15 57*e7647de0SChiaEn Wu 58*e7647de0SChiaEn Wu enum { 59*e7647de0SChiaEn Wu MT6370_VID_COMMON = 1, 60*e7647de0SChiaEn Wu MT6370_VID_6372, 61*e7647de0SChiaEn Wu }; 62*e7647de0SChiaEn Wu 63*e7647de0SChiaEn Wu struct mt6370_priv { 64*e7647de0SChiaEn Wu u8 dim2_mask; 65*e7647de0SChiaEn Wu u8 dim2_shift; 66*e7647de0SChiaEn Wu int def_max_brightness; 67*e7647de0SChiaEn Wu struct backlight_device *bl; 68*e7647de0SChiaEn Wu struct device *dev; 69*e7647de0SChiaEn Wu struct gpio_desc *enable_gpio; 70*e7647de0SChiaEn Wu struct regmap *regmap; 71*e7647de0SChiaEn Wu }; 72*e7647de0SChiaEn Wu 73*e7647de0SChiaEn Wu static int mt6370_bl_update_status(struct backlight_device *bl_dev) 74*e7647de0SChiaEn Wu { 75*e7647de0SChiaEn Wu struct mt6370_priv *priv = bl_get_data(bl_dev); 76*e7647de0SChiaEn Wu int brightness = backlight_get_brightness(bl_dev); 77*e7647de0SChiaEn Wu unsigned int enable_val; 78*e7647de0SChiaEn Wu u8 brightness_val[2]; 79*e7647de0SChiaEn Wu int ret; 80*e7647de0SChiaEn Wu 81*e7647de0SChiaEn Wu if (brightness) { 82*e7647de0SChiaEn Wu brightness_val[0] = (brightness - 1) & priv->dim2_mask; 83*e7647de0SChiaEn Wu brightness_val[1] = (brightness - 1) >> priv->dim2_shift; 84*e7647de0SChiaEn Wu 85*e7647de0SChiaEn Wu ret = regmap_raw_write(priv->regmap, MT6370_REG_BL_DIM2, 86*e7647de0SChiaEn Wu brightness_val, sizeof(brightness_val)); 87*e7647de0SChiaEn Wu if (ret) 88*e7647de0SChiaEn Wu return ret; 89*e7647de0SChiaEn Wu } 90*e7647de0SChiaEn Wu 91*e7647de0SChiaEn Wu gpiod_set_value(priv->enable_gpio, !!brightness); 92*e7647de0SChiaEn Wu 93*e7647de0SChiaEn Wu enable_val = brightness ? MT6370_BL_EN_MASK : 0; 94*e7647de0SChiaEn Wu return regmap_update_bits(priv->regmap, MT6370_REG_BL_EN, 95*e7647de0SChiaEn Wu MT6370_BL_EN_MASK, enable_val); 96*e7647de0SChiaEn Wu } 97*e7647de0SChiaEn Wu 98*e7647de0SChiaEn Wu static int mt6370_bl_get_brightness(struct backlight_device *bl_dev) 99*e7647de0SChiaEn Wu { 100*e7647de0SChiaEn Wu struct mt6370_priv *priv = bl_get_data(bl_dev); 101*e7647de0SChiaEn Wu unsigned int enable; 102*e7647de0SChiaEn Wu u8 brightness_val[2]; 103*e7647de0SChiaEn Wu int brightness, ret; 104*e7647de0SChiaEn Wu 105*e7647de0SChiaEn Wu ret = regmap_read(priv->regmap, MT6370_REG_BL_EN, &enable); 106*e7647de0SChiaEn Wu if (ret) 107*e7647de0SChiaEn Wu return ret; 108*e7647de0SChiaEn Wu 109*e7647de0SChiaEn Wu if (!(enable & MT6370_BL_EN_MASK)) 110*e7647de0SChiaEn Wu return 0; 111*e7647de0SChiaEn Wu 112*e7647de0SChiaEn Wu ret = regmap_raw_read(priv->regmap, MT6370_REG_BL_DIM2, 113*e7647de0SChiaEn Wu brightness_val, sizeof(brightness_val)); 114*e7647de0SChiaEn Wu if (ret) 115*e7647de0SChiaEn Wu return ret; 116*e7647de0SChiaEn Wu 117*e7647de0SChiaEn Wu brightness = brightness_val[1] << priv->dim2_shift; 118*e7647de0SChiaEn Wu brightness += brightness_val[0] & priv->dim2_mask; 119*e7647de0SChiaEn Wu 120*e7647de0SChiaEn Wu return brightness + 1; 121*e7647de0SChiaEn Wu } 122*e7647de0SChiaEn Wu 123*e7647de0SChiaEn Wu static const struct backlight_ops mt6370_bl_ops = { 124*e7647de0SChiaEn Wu .options = BL_CORE_SUSPENDRESUME, 125*e7647de0SChiaEn Wu .update_status = mt6370_bl_update_status, 126*e7647de0SChiaEn Wu .get_brightness = mt6370_bl_get_brightness, 127*e7647de0SChiaEn Wu }; 128*e7647de0SChiaEn Wu 129*e7647de0SChiaEn Wu static int mt6370_init_backlight_properties(struct mt6370_priv *priv, 130*e7647de0SChiaEn Wu struct backlight_properties *props) 131*e7647de0SChiaEn Wu { 132*e7647de0SChiaEn Wu struct device *dev = priv->dev; 133*e7647de0SChiaEn Wu u8 prop_val; 134*e7647de0SChiaEn Wu u32 brightness, ovp_uV, ocp_uA; 135*e7647de0SChiaEn Wu unsigned int mask, val; 136*e7647de0SChiaEn Wu int ret; 137*e7647de0SChiaEn Wu 138*e7647de0SChiaEn Wu /* Vendor optional properties */ 139*e7647de0SChiaEn Wu val = 0; 140*e7647de0SChiaEn Wu if (device_property_read_bool(dev, "mediatek,bled-pwm-enable")) 141*e7647de0SChiaEn Wu val |= MT6370_BL_PWM_EN_MASK; 142*e7647de0SChiaEn Wu 143*e7647de0SChiaEn Wu if (device_property_read_bool(dev, "mediatek,bled-pwm-hys-enable")) 144*e7647de0SChiaEn Wu val |= MT6370_BL_PWM_HYS_EN_MASK; 145*e7647de0SChiaEn Wu 146*e7647de0SChiaEn Wu ret = device_property_read_u8(dev, 147*e7647de0SChiaEn Wu "mediatek,bled-pwm-hys-input-th-steps", 148*e7647de0SChiaEn Wu &prop_val); 149*e7647de0SChiaEn Wu if (!ret) { 150*e7647de0SChiaEn Wu prop_val = clamp_val(prop_val, 151*e7647de0SChiaEn Wu MT6370_BL_PWM_HYS_TH_MIN_STEP, 152*e7647de0SChiaEn Wu MT6370_BL_PWM_HYS_TH_MAX_STEP); 153*e7647de0SChiaEn Wu prop_val = prop_val <= 1 ? 0 : 154*e7647de0SChiaEn Wu prop_val <= 4 ? 1 : 155*e7647de0SChiaEn Wu prop_val <= 16 ? 2 : 3; 156*e7647de0SChiaEn Wu val |= prop_val; 157*e7647de0SChiaEn Wu } 158*e7647de0SChiaEn Wu 159*e7647de0SChiaEn Wu ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_PWM, 160*e7647de0SChiaEn Wu val, val); 161*e7647de0SChiaEn Wu if (ret) 162*e7647de0SChiaEn Wu return ret; 163*e7647de0SChiaEn Wu 164*e7647de0SChiaEn Wu val = 0; 165*e7647de0SChiaEn Wu if (device_property_read_bool(dev, "mediatek,bled-ovp-shutdown")) 166*e7647de0SChiaEn Wu val |= MT6370_BL_OVP_EN_MASK; 167*e7647de0SChiaEn Wu 168*e7647de0SChiaEn Wu ret = device_property_read_u32(dev, "mediatek,bled-ovp-microvolt", 169*e7647de0SChiaEn Wu &ovp_uV); 170*e7647de0SChiaEn Wu if (!ret) { 171*e7647de0SChiaEn Wu ovp_uV = clamp_val(ovp_uV, MT6370_BL_OVP_MIN_UV, 172*e7647de0SChiaEn Wu MT6370_BL_OVP_MAX_UV); 173*e7647de0SChiaEn Wu ovp_uV = DIV_ROUND_UP(ovp_uV - MT6370_BL_OVP_MIN_UV, 174*e7647de0SChiaEn Wu MT6370_BL_OVP_STEP_UV); 175*e7647de0SChiaEn Wu val |= ovp_uV << MT6370_BL_OVP_SEL_SHIFT; 176*e7647de0SChiaEn Wu } 177*e7647de0SChiaEn Wu 178*e7647de0SChiaEn Wu if (device_property_read_bool(dev, "mediatek,bled-ocp-shutdown")) 179*e7647de0SChiaEn Wu val |= MT6370_BL_OC_EN_MASK; 180*e7647de0SChiaEn Wu 181*e7647de0SChiaEn Wu ret = device_property_read_u32(dev, "mediatek,bled-ocp-microamp", 182*e7647de0SChiaEn Wu &ocp_uA); 183*e7647de0SChiaEn Wu if (!ret) { 184*e7647de0SChiaEn Wu ocp_uA = clamp_val(ocp_uA, MT6370_BL_OCP_MIN_UA, 185*e7647de0SChiaEn Wu MT6370_BL_OCP_MAX_UA); 186*e7647de0SChiaEn Wu ocp_uA = DIV_ROUND_UP(ocp_uA - MT6370_BL_OCP_MIN_UA, 187*e7647de0SChiaEn Wu MT6370_BL_OCP_STEP_UA); 188*e7647de0SChiaEn Wu val |= ocp_uA << MT6370_BL_OC_SEL_SHIFT; 189*e7647de0SChiaEn Wu } 190*e7647de0SChiaEn Wu 191*e7647de0SChiaEn Wu ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_BSTCTRL, 192*e7647de0SChiaEn Wu val, val); 193*e7647de0SChiaEn Wu if (ret) 194*e7647de0SChiaEn Wu return ret; 195*e7647de0SChiaEn Wu 196*e7647de0SChiaEn Wu /* Common properties */ 197*e7647de0SChiaEn Wu ret = device_property_read_u32(dev, "max-brightness", &brightness); 198*e7647de0SChiaEn Wu if (ret) 199*e7647de0SChiaEn Wu brightness = priv->def_max_brightness; 200*e7647de0SChiaEn Wu 201*e7647de0SChiaEn Wu props->max_brightness = min_t(u32, brightness, priv->def_max_brightness); 202*e7647de0SChiaEn Wu 203*e7647de0SChiaEn Wu ret = device_property_read_u32(dev, "default-brightness", &brightness); 204*e7647de0SChiaEn Wu if (ret) 205*e7647de0SChiaEn Wu brightness = props->max_brightness; 206*e7647de0SChiaEn Wu 207*e7647de0SChiaEn Wu props->brightness = min_t(u32, brightness, props->max_brightness); 208*e7647de0SChiaEn Wu 209*e7647de0SChiaEn Wu val = 0; 210*e7647de0SChiaEn Wu if (device_property_read_bool(dev, "mediatek,bled-exponential-mode-enable")) { 211*e7647de0SChiaEn Wu val |= MT6370_BL_CODE_MASK; 212*e7647de0SChiaEn Wu props->scale = BACKLIGHT_SCALE_NON_LINEAR; 213*e7647de0SChiaEn Wu } else 214*e7647de0SChiaEn Wu props->scale = BACKLIGHT_SCALE_LINEAR; 215*e7647de0SChiaEn Wu 216*e7647de0SChiaEn Wu ret = device_property_read_u8(dev, "mediatek,bled-channel-use", 217*e7647de0SChiaEn Wu &prop_val); 218*e7647de0SChiaEn Wu if (ret) { 219*e7647de0SChiaEn Wu dev_err(dev, "mediatek,bled-channel-use DT property missing\n"); 220*e7647de0SChiaEn Wu return ret; 221*e7647de0SChiaEn Wu } 222*e7647de0SChiaEn Wu 223*e7647de0SChiaEn Wu if (!prop_val || prop_val > MT6370_BL_MAX_CH) { 224*e7647de0SChiaEn Wu dev_err(dev, 225*e7647de0SChiaEn Wu "No channel specified or over than upper bound (%d)\n", 226*e7647de0SChiaEn Wu prop_val); 227*e7647de0SChiaEn Wu return -EINVAL; 228*e7647de0SChiaEn Wu } 229*e7647de0SChiaEn Wu 230*e7647de0SChiaEn Wu mask = MT6370_BL_EXT_EN_MASK | MT6370_BL_CH_MASK; 231*e7647de0SChiaEn Wu val |= prop_val << MT6370_BL_CH_SHIFT; 232*e7647de0SChiaEn Wu 233*e7647de0SChiaEn Wu if (priv->enable_gpio) 234*e7647de0SChiaEn Wu val |= MT6370_BL_EXT_EN_MASK; 235*e7647de0SChiaEn Wu 236*e7647de0SChiaEn Wu return regmap_update_bits(priv->regmap, MT6370_REG_BL_EN, mask, val); 237*e7647de0SChiaEn Wu } 238*e7647de0SChiaEn Wu 239*e7647de0SChiaEn Wu static int mt6370_check_vendor_info(struct mt6370_priv *priv) 240*e7647de0SChiaEn Wu { 241*e7647de0SChiaEn Wu /* 242*e7647de0SChiaEn Wu * Because MT6372 uses 14 bits to control the brightness, 243*e7647de0SChiaEn Wu * MT6370 and MT6371 use 11 bits. This function is used 244*e7647de0SChiaEn Wu * to check the vendor's ID and set the relative hardware 245*e7647de0SChiaEn Wu * mask, shift and default maximum brightness value that 246*e7647de0SChiaEn Wu * should be used. 247*e7647de0SChiaEn Wu */ 248*e7647de0SChiaEn Wu unsigned int dev_info, hw_vid, of_vid; 249*e7647de0SChiaEn Wu int ret; 250*e7647de0SChiaEn Wu 251*e7647de0SChiaEn Wu ret = regmap_read(priv->regmap, MT6370_REG_DEV_INFO, &dev_info); 252*e7647de0SChiaEn Wu if (ret) 253*e7647de0SChiaEn Wu return ret; 254*e7647de0SChiaEn Wu 255*e7647de0SChiaEn Wu of_vid = (uintptr_t)device_get_match_data(priv->dev); 256*e7647de0SChiaEn Wu hw_vid = FIELD_GET(MT6370_VENID_MASK, dev_info); 257*e7647de0SChiaEn Wu hw_vid = (hw_vid == 0x9 || hw_vid == 0xb) ? MT6370_VID_6372 : MT6370_VID_COMMON; 258*e7647de0SChiaEn Wu if (hw_vid != of_vid) 259*e7647de0SChiaEn Wu return dev_err_probe(priv->dev, -EINVAL, 260*e7647de0SChiaEn Wu "Buggy DT, wrong compatible string\n"); 261*e7647de0SChiaEn Wu 262*e7647de0SChiaEn Wu if (hw_vid == MT6370_VID_6372) { 263*e7647de0SChiaEn Wu priv->dim2_mask = MT6370_BL_DIM2_6372_MASK; 264*e7647de0SChiaEn Wu priv->dim2_shift = MT6370_BL_DIM2_6372_SHIFT; 265*e7647de0SChiaEn Wu priv->def_max_brightness = MT6370_BL_MAX_6372_BRIGHTNESS; 266*e7647de0SChiaEn Wu } else { 267*e7647de0SChiaEn Wu priv->dim2_mask = MT6370_BL_DIM2_COMMON_MASK; 268*e7647de0SChiaEn Wu priv->dim2_shift = MT6370_BL_DIM2_COMMON_SHIFT; 269*e7647de0SChiaEn Wu priv->def_max_brightness = MT6370_BL_MAX_COMMON_BRIGHTNESS; 270*e7647de0SChiaEn Wu } 271*e7647de0SChiaEn Wu 272*e7647de0SChiaEn Wu return 0; 273*e7647de0SChiaEn Wu } 274*e7647de0SChiaEn Wu 275*e7647de0SChiaEn Wu static int mt6370_bl_probe(struct platform_device *pdev) 276*e7647de0SChiaEn Wu { 277*e7647de0SChiaEn Wu struct backlight_properties props = { 278*e7647de0SChiaEn Wu .type = BACKLIGHT_RAW, 279*e7647de0SChiaEn Wu }; 280*e7647de0SChiaEn Wu struct device *dev = &pdev->dev; 281*e7647de0SChiaEn Wu struct mt6370_priv *priv; 282*e7647de0SChiaEn Wu int ret; 283*e7647de0SChiaEn Wu 284*e7647de0SChiaEn Wu priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 285*e7647de0SChiaEn Wu if (!priv) 286*e7647de0SChiaEn Wu return -ENOMEM; 287*e7647de0SChiaEn Wu 288*e7647de0SChiaEn Wu priv->dev = dev; 289*e7647de0SChiaEn Wu 290*e7647de0SChiaEn Wu priv->regmap = dev_get_regmap(dev->parent, NULL); 291*e7647de0SChiaEn Wu if (!priv->regmap) 292*e7647de0SChiaEn Wu return dev_err_probe(dev, -ENODEV, "Failed to get regmap\n"); 293*e7647de0SChiaEn Wu 294*e7647de0SChiaEn Wu ret = mt6370_check_vendor_info(priv); 295*e7647de0SChiaEn Wu if (ret) 296*e7647de0SChiaEn Wu return dev_err_probe(dev, ret, "Failed to check vendor info\n"); 297*e7647de0SChiaEn Wu 298*e7647de0SChiaEn Wu priv->enable_gpio = devm_gpiod_get_optional(dev, "enable", 299*e7647de0SChiaEn Wu GPIOD_OUT_HIGH); 300*e7647de0SChiaEn Wu if (IS_ERR(priv->enable_gpio)) 301*e7647de0SChiaEn Wu return dev_err_probe(dev, PTR_ERR(priv->enable_gpio), 302*e7647de0SChiaEn Wu "Failed to get 'enable' gpio\n"); 303*e7647de0SChiaEn Wu 304*e7647de0SChiaEn Wu ret = mt6370_init_backlight_properties(priv, &props); 305*e7647de0SChiaEn Wu if (ret) 306*e7647de0SChiaEn Wu return dev_err_probe(dev, ret, 307*e7647de0SChiaEn Wu "Failed to init backlight properties\n"); 308*e7647de0SChiaEn Wu 309*e7647de0SChiaEn Wu priv->bl = devm_backlight_device_register(dev, pdev->name, dev, priv, 310*e7647de0SChiaEn Wu &mt6370_bl_ops, &props); 311*e7647de0SChiaEn Wu if (IS_ERR(priv->bl)) 312*e7647de0SChiaEn Wu return dev_err_probe(dev, PTR_ERR(priv->bl), 313*e7647de0SChiaEn Wu "Failed to register backlight\n"); 314*e7647de0SChiaEn Wu 315*e7647de0SChiaEn Wu backlight_update_status(priv->bl); 316*e7647de0SChiaEn Wu platform_set_drvdata(pdev, priv); 317*e7647de0SChiaEn Wu 318*e7647de0SChiaEn Wu return 0; 319*e7647de0SChiaEn Wu } 320*e7647de0SChiaEn Wu 321*e7647de0SChiaEn Wu static int mt6370_bl_remove(struct platform_device *pdev) 322*e7647de0SChiaEn Wu { 323*e7647de0SChiaEn Wu struct mt6370_priv *priv = platform_get_drvdata(pdev); 324*e7647de0SChiaEn Wu struct backlight_device *bl_dev = priv->bl; 325*e7647de0SChiaEn Wu 326*e7647de0SChiaEn Wu bl_dev->props.brightness = 0; 327*e7647de0SChiaEn Wu backlight_update_status(priv->bl); 328*e7647de0SChiaEn Wu 329*e7647de0SChiaEn Wu return 0; 330*e7647de0SChiaEn Wu } 331*e7647de0SChiaEn Wu 332*e7647de0SChiaEn Wu static const struct of_device_id mt6370_bl_of_match[] = { 333*e7647de0SChiaEn Wu { .compatible = "mediatek,mt6370-backlight", .data = (void *)MT6370_VID_COMMON }, 334*e7647de0SChiaEn Wu { .compatible = "mediatek,mt6372-backlight", .data = (void *)MT6370_VID_6372 }, 335*e7647de0SChiaEn Wu {} 336*e7647de0SChiaEn Wu }; 337*e7647de0SChiaEn Wu MODULE_DEVICE_TABLE(of, mt6370_bl_of_match); 338*e7647de0SChiaEn Wu 339*e7647de0SChiaEn Wu static struct platform_driver mt6370_bl_driver = { 340*e7647de0SChiaEn Wu .driver = { 341*e7647de0SChiaEn Wu .name = "mt6370-backlight", 342*e7647de0SChiaEn Wu .of_match_table = mt6370_bl_of_match, 343*e7647de0SChiaEn Wu }, 344*e7647de0SChiaEn Wu .probe = mt6370_bl_probe, 345*e7647de0SChiaEn Wu .remove = mt6370_bl_remove, 346*e7647de0SChiaEn Wu }; 347*e7647de0SChiaEn Wu module_platform_driver(mt6370_bl_driver); 348*e7647de0SChiaEn Wu 349*e7647de0SChiaEn Wu MODULE_AUTHOR("ChiaEn Wu <chiaen_wu@richtek.com>"); 350*e7647de0SChiaEn Wu MODULE_DESCRIPTION("MediaTek MT6370 Backlight Driver"); 351*e7647de0SChiaEn Wu MODULE_LICENSE("GPL v2"); 352