From patchwork Tue Jul 11 18:20:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 9835389 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0FDDE602A0 for ; Tue, 11 Jul 2017 18:20:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 060E01FF1D for ; Tue, 11 Jul 2017 18:20:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEAC02856A; Tue, 11 Jul 2017 18:20:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC21928573 for ; Tue, 11 Jul 2017 18:20:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756315AbdGKSUa (ORCPT ); Tue, 11 Jul 2017 14:20:30 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:34884 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756281AbdGKSU2 (ORCPT ); Tue, 11 Jul 2017 14:20:28 -0400 Received: by mail-qk0-f196.google.com with SMTP id 16so17062qkg.2; Tue, 11 Jul 2017 11:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mwFXdTY2XB56ZshvEPMG4ds2VWBLLN/D4JLX14XQ1tg=; b=nie2DQ58rlx/fz/uDjvDJWN6Nd1ho3g8fZAhRwsJ7DFOvOMOZY0xRAx9jns5pLngwT HjCnEbA7H0sCJsE95UjnfBcurw6WIqxzMFBLWiLJQhdkLuPTGGnzYQ05AJQx1ef8Ikb4 eNU+6LNp+6o/RJrnh0SN9Kma4eKWokvuS0zblgBuzenpkbxg8CXdxKQgK/FJpL1Z7dwK iv3ySfSjpHpTdfPTKJN5b4bUj3RbqZ7iWcb5Raksm+LKZqJJtzOShf4FHXQcQAEjixwR u8MkophunHjgymO5x4YaiXYY/7XBzJTXbE0DmOnwTMpqeFznAgng6n01Xr5VZ7NdZ/IQ ECRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mwFXdTY2XB56ZshvEPMG4ds2VWBLLN/D4JLX14XQ1tg=; b=HIVtr0lNmMg35AmpiN9lWNDpomvGLSouSDZ+ZTbVs1DiEW7ShhbNOwcrZZTQbPGCy2 sk3sz6pUnufd3MudXqxfQwuigORf7T90rK5YZkdWjcmv1k6MhQzajz1H4waNjpCEWfCL boO0kekW3TI3gxcvF0JISU+cxPXb7iLtd3FvewMoUHbBhF7hgt6k/4dSrFlH91G4JkW9 qAWKnXKOxBr9cErMmOo3nMMuxInHcsjRHC11TQ8wB3Bzw/DBzK2V49u7wS35aotqEa3i L5VmKifhDRwkdGiwe402nznhPOIH7qn1OwiTsifnFfA5HYFJ560qDsfE4vJfDzf70xbZ speg== X-Gm-Message-State: AIVw112nW1Xea+PTRWeRwbQAL8i0CE/IEe+hwbPpK7yRl7lGRHyz93q8 pUZc0PrsEQ2TMA== X-Received: by 10.55.185.6 with SMTP id j6mr1558135qkf.14.1499797227748; Tue, 11 Jul 2017 11:20:27 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id s6sm490792qki.44.2017.07.11.11.20.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Jul 2017 11:20:26 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org, linux-clk@vger.kernel.org Cc: Stephen Boyd , Michael Turquette , Archit Taneja , linux-arm-msm@vger.kernel.org, viresh.kumar@linaro.org, Rob Clark Subject: [RFC 3/3] drm/bridge: adv7511: deal with bootloader lighting up display Date: Tue, 11 Jul 2017 14:20:08 -0400 Message-Id: <20170711182008.28298-4-robdclark@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170711182008.28298-1-robdclark@gmail.com> References: <20170711182008.28298-1-robdclark@gmail.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to do some things a bit differently if the bridge chip is already powered up when the driver loads (ie. bootloader has already enabled display). In particular we don't want to do anything that would kill the display. --- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 57 +++++++++++++++++++--------- drivers/gpu/drm/bridge/adv7511/adv7533.c | 3 ++ 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index f75ab6278113..15e725fa8616 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -107,6 +107,7 @@ static bool adv7511_register_volatile(struct device *dev, unsigned int reg) case ADV7511_REG_BSTATUS(1): case ADV7511_REG_CHIP_ID_HIGH: case ADV7511_REG_CHIP_ID_LOW: + case ADV7511_REG_POWER: return true; } @@ -584,6 +585,8 @@ static int adv7511_get_modes(struct adv7511 *adv7511, edid_i2c_addr); } + adv7511->current_edid_segment = -1; + edid = drm_do_get_edid(connector, adv7511_get_edid_block, adv7511); if (!adv7511->powered) @@ -627,7 +630,8 @@ adv7511_detect(struct adv7511 *adv7511, struct drm_connector *connector) * has to be reinitialized. */ if (status == connector_status_connected && hpd && adv7511->powered) { regcache_mark_dirty(adv7511->regmap); - adv7511_power_on(adv7511); + if (!adv7511->powered) + adv7511_power_on(adv7511); adv7511_get_modes(adv7511, connector); if (adv7511->status == connector_status_connected) status = connector_status_disconnected; @@ -1044,33 +1048,47 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) return ret; } + adv7511->regmap = devm_regmap_init_i2c(i2c, &adv7511_regmap_config); + if (IS_ERR(adv7511->regmap)) { + ret = PTR_ERR(adv7511->regmap); + goto uninit_regulators; + } + + ret = regmap_read(adv7511->regmap, ADV7511_REG_CHIP_REVISION, &val); + if (ret) + goto uninit_regulators; + dev_dbg(dev, "Rev. %d\n", val); + + ret = regmap_read(adv7511->regmap, ADV7511_REG_POWER, &val); + if (ret) + goto uninit_regulators; + dev_dbg(dev, "Power: %x\n", val); + + if ((val & ADV7511_POWER_POWER_DOWN) == 0) { + dev_dbg(dev, "powered on at probe!\n"); + regcache_sync(adv7511->regmap); + adv7511->powered = true; + } + /* * The power down GPIO is optional. If present, toggle it from active to * inactive to wake up the encoder. */ - adv7511->gpio_pd = devm_gpiod_get_optional(dev, "pd", GPIOD_OUT_HIGH); + adv7511->gpio_pd = devm_gpiod_get_optional(dev, "pd", + adv7511->powered ? GPIOD_ASIS : GPIOD_OUT_HIGH); if (IS_ERR(adv7511->gpio_pd)) { ret = PTR_ERR(adv7511->gpio_pd); goto uninit_regulators; } - if (adv7511->gpio_pd) { + if (adv7511->gpio_pd && !adv7511->powered) { mdelay(5); gpiod_set_value_cansleep(adv7511->gpio_pd, 0); } - adv7511->regmap = devm_regmap_init_i2c(i2c, &adv7511_regmap_config); - if (IS_ERR(adv7511->regmap)) { - ret = PTR_ERR(adv7511->regmap); - goto uninit_regulators; - } - - ret = regmap_read(adv7511->regmap, ADV7511_REG_CHIP_REVISION, &val); - if (ret) - goto uninit_regulators; - dev_dbg(dev, "Rev. %d\n", val); - - if (adv7511->type == ADV7511) + if (adv7511->powered) + adv7511_hpd(adv7511); /* clear pending irq's */ + else if (adv7511->type == ADV7511) ret = regmap_register_patch(adv7511->regmap, adv7511_fixed_registers, ARRAY_SIZE(adv7511_fixed_registers)); @@ -1085,7 +1103,8 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) regmap_write(adv7511->regmap, ADV7511_REG_CEC_I2C_ADDR, main_i2c_addr - 2); - adv7511_packet_disable(adv7511, 0xffff); + if (!adv7511->powered) + adv7511_packet_disable(adv7511, 0xffff); adv7511->i2c_edid = i2c_new_dummy(i2c->adapter, edid_i2c_addr >> 1); if (!adv7511->i2c_edid) { @@ -1116,7 +1135,8 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) regmap_write(adv7511->regmap, ADV7511_REG_CEC_CTRL, ADV7511_CEC_CTRL_POWER_DOWN); - adv7511_power_off(adv7511); + if (!adv7511->powered) + adv7511_power_off(adv7511); i2c_set_clientdata(i2c, adv7511); @@ -1132,7 +1152,8 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) goto err_unregister_cec; } - adv7511_audio_init(dev, adv7511); + if (!adv7511->powered) + adv7511_audio_init(dev, adv7511); return 0; diff --git a/drivers/gpu/drm/bridge/adv7511/adv7533.c b/drivers/gpu/drm/bridge/adv7511/adv7533.c index ac804f81e2f6..43dc53821acb 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7533.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7533.c @@ -166,6 +166,9 @@ int adv7533_init_cec(struct adv7511 *adv) goto err; } + if (adv->powered) + return 0; + ret = regmap_register_patch(adv->regmap_cec, adv7533_cec_fixed_registers, ARRAY_SIZE(adv7533_cec_fixed_registers));