MLK-16918-15: drm/bridge: Update adv7511 driver with some regs for adv7535
authorRobert Chiras <robert.chiras@nxp.com>
Fri, 17 Nov 2017 09:37:09 +0000 (11:37 +0200)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:55:34 +0000 (15:55 -0500)
The low refresh rate register for ADV7535 is in 0x4A instead of 0xFB. In
order to correctly handle these differences, add the new type ADV7535.

Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
drivers/gpu/drm/bridge/adv7511/adv7511.h
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c

index 3e74e1a..f307e64 100644 (file)
@@ -294,6 +294,7 @@ struct adv7511_video_config {
 enum adv7511_type {
        ADV7511,
        ADV7533,
+       ADV7535,
 };
 
 struct adv7511 {
index bb81c48..4434339 100644 (file)
@@ -365,7 +365,7 @@ static void adv7511_power_on(struct adv7511 *adv7511)
         */
        regcache_sync(adv7511->regmap);
 
-       if (adv7511->type == ADV7533)
+       if (adv7511->type == ADV7533 || adv7511->type == ADV7535)
                adv7533_dsi_power_on(adv7511);
        adv7511->powered = true;
 }
@@ -382,7 +382,7 @@ static void __adv7511_power_off(struct adv7511 *adv7511)
 static void adv7511_power_off(struct adv7511 *adv7511)
 {
        __adv7511_power_off(adv7511);
-       if (adv7511->type == ADV7533)
+       if (adv7511->type == ADV7533 || adv7511->type == ADV7535)
                adv7533_dsi_power_off(adv7511);
        adv7511->powered = false;
 }
@@ -723,21 +723,26 @@ static void adv7511_mode_set(struct adv7511 *adv7511,
                        vsync_polarity = 1;
        }
 
-       if (mode->vrefresh <= 24000)
+       if (mode->vrefresh <= 24)
                low_refresh_rate = ADV7511_LOW_REFRESH_RATE_24HZ;
-       else if (mode->vrefresh <= 25000)
+       else if (mode->vrefresh <= 25)
                low_refresh_rate = ADV7511_LOW_REFRESH_RATE_25HZ;
-       else if (mode->vrefresh <= 30000)
+       else if (mode->vrefresh <= 30)
                low_refresh_rate = ADV7511_LOW_REFRESH_RATE_30HZ;
        else
                low_refresh_rate = ADV7511_LOW_REFRESH_RATE_NONE;
 
-       regmap_update_bits(adv7511->regmap, 0xfb,
-               0x6, low_refresh_rate << 1);
+       if (adv7511->type == ADV7535)
+               regmap_update_bits(adv7511->regmap, 0x4a,
+                       0xc, low_refresh_rate << 2);
+       else
+               regmap_update_bits(adv7511->regmap, 0xfb,
+                       0x6, low_refresh_rate << 1);
+
        regmap_update_bits(adv7511->regmap, 0x17,
                0x60, (vsync_polarity << 6) | (hsync_polarity << 5));
 
-       if (adv7511->type == ADV7533)
+       if (adv7511->type == ADV7533 || adv7511->type == ADV7535)
                adv7533_mode_set(adv7511, adj_mode);
 
        drm_mode_copy(&adv7511->curr_mode, adj_mode);
@@ -847,7 +852,7 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
                                 &adv7511_connector_helper_funcs);
        drm_mode_connector_attach_encoder(&adv->connector, bridge->encoder);
 
-       if (adv->type == ADV7533)
+       if (adv->type == ADV7533 || adv->type == ADV7535)
                ret = adv7533_attach_dsi(adv);
 
        return ret;
@@ -1025,7 +1030,7 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
        if (!adv7511->i2c_edid)
                return -ENOMEM;
 
-       if (adv7511->type == ADV7533) {
+       if (adv7511->type == ADV7533 || adv7511->type == ADV7535) {
                ret = adv7533_init_cec(adv7511);
                if (ret)
                        goto err_i2c_unregister_edid;
@@ -1078,7 +1083,7 @@ static int adv7511_remove(struct i2c_client *i2c)
 {
        struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
 
-       if (adv7511->type == ADV7533) {
+       if (adv7511->type == ADV7533 || adv7511->type == ADV7535) {
                adv7533_detach_dsi(adv7511);
                adv7533_uninit_cec(adv7511);
        }
@@ -1098,7 +1103,7 @@ static const struct i2c_device_id adv7511_i2c_ids[] = {
        { "adv7513", ADV7511 },
 #ifdef CONFIG_DRM_I2C_ADV7533
        { "adv7533", ADV7533 },
-       { "adv7535", ADV7533 },
+       { "adv7535", ADV7535 },
 #endif
        { }
 };
@@ -1110,7 +1115,7 @@ static const struct of_device_id adv7511_of_ids[] = {
        { .compatible = "adi,adv7513", .data = (void *)ADV7511 },
 #ifdef CONFIG_DRM_I2C_ADV7533
        { .compatible = "adi,adv7533", .data = (void *)ADV7533 },
-       { .compatible = "adi,adv7535", .data = (void *)ADV7533 },
+       { .compatible = "adi,adv7535", .data = (void *)ADV7535 },
 #endif
        { }
 };