From patchwork Sat Feb 6 03:24:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xinliang Liu X-Patchwork-Id: 8241101 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BBC86BEEE5 for ; Sat, 6 Feb 2016 03:26:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E488E2034B for ; Sat, 6 Feb 2016 03:26:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 020D02027D for ; Sat, 6 Feb 2016 03:26:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 49C2E8A33C; Fri, 5 Feb 2016 19:26:17 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-f169.google.com (mail-pf0-f169.google.com [209.85.192.169]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7840E8A33C for ; Fri, 5 Feb 2016 19:26:15 -0800 (PST) Received: by mail-pf0-f169.google.com with SMTP id c10so12342303pfc.2 for ; Fri, 05 Feb 2016 19:26:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=88rNis8iP1BwmmUwNdw04UC61u6TDGsyDldo2f9nSE8=; b=ErCt6d9+qgogCPpcHYqZVtTj+GtbE0lNTAgdId0t3Da8JC44zDSSk4xHRQM9xKirC+ E92BAeTI6dEcv6bUd8Bwz6V/1nE3KUzd84yVJz8LJJVZPX7CW3T3X010IWEXaLnhHVXR tEmGbMkNDTEewf5KmUcfPWUSXoUZQrssoYcP0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=88rNis8iP1BwmmUwNdw04UC61u6TDGsyDldo2f9nSE8=; b=nGwWuCPWUZdD4H/txy7GLlNmtNU3x3wMn5qbOuGNrADFN1RwXqGyN5HRkygPnd+1Zd dW+gjdG8egroHNGp/smssjnXGRaU9hRfxwU62Bn24gT8R63sEpHD/1kcg7F8J556+b/j 1J6wGmSYcOE1a8tciSv+qHdcroawGiZmThQnuZ8fkTiAas8A4jdwjfo4jT/L0RpgUMtu nebsYv0jVBNNjDvHhbkFN5XZeeadQNvIOiHgcaSHp2F09/oKOf4fG7mVLZkS73G1WMyD opb7CsvJn7UipHL0DcsateHVqYq7GIeY0ttUBhVjAT3099piL3mprSaztrnzBfnCUCEZ 3hhA== X-Gm-Message-State: AG10YOSj9dnlR1//Y9sjNRrpBLlw8f9wtSi5ixKY648h0YPU7cztw+X69Z5OwBDWJRBu+vRt X-Received: by 10.98.8.80 with SMTP id c77mr3224627pfd.42.1454729175164; Fri, 05 Feb 2016 19:26:15 -0800 (PST) Received: from localhost.localdomain ([219.134.80.72]) by smtp.gmail.com with ESMTPSA id a21sm27472023pfj.40.2016.02.05.19.26.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Feb 2016 19:26:14 -0800 (PST) From: Xinliang Liu To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, daniel@ffwll.ch, robh@kernel.org, daniel@fooishbar.org, architt@codeaurora.org, airlied@linux.ie, corbet@lwn.net, catalin.marinas@arm.com, will.deacon@arm.com, emil.l.velikov@gmail.com Subject: [PATCH v4 08/11] drm/hisilicon: Add designware dsi host driver Date: Sat, 6 Feb 2016 11:24:55 +0800 Message-Id: <1454729098-79807-9-git-send-email-xinliang.liu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454729098-79807-1-git-send-email-xinliang.liu@linaro.org> References: <1454729098-79807-1-git-send-email-xinliang.liu@linaro.org> Cc: andy.green@linaro.org, xuyiping@hisilicon.com, guodong.xu@linaro.org, linux-doc@vger.kernel.org, w.f@huawei.com, zourongrong@huawei.com, linuxarm@huawei.com, xuwei5@hisilicon.com, bintian.wang@huawei.com, haojian.zhuang@linaro.org, benjamin.gaignard@linaro.org, puck.chen@hisilicon.com, liguozhu@hisilicon.com, linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add DesignWare dsi host driver for hi6220 SoC. v4: None. v3: None. v2: - Remove abtraction layer. Signed-off-by: Xinliang Liu --- drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c index 7c9423537b71..2837af01e935 100644 --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c @@ -79,6 +79,7 @@ struct dsi_hw_ctx { struct dw_dsi { struct drm_encoder encoder; + struct mipi_dsi_host host; struct drm_display_mode cur_mode; struct dsi_hw_ctx *ctx; struct mipi_phy_params phy; @@ -642,6 +643,51 @@ static int dw_drm_encoder_init(struct device *dev, return 0; } +static int dsi_host_attach(struct mipi_dsi_host *host, + struct mipi_dsi_device *mdsi) +{ + struct dw_dsi *dsi = host_to_dsi(host); + + if (mdsi->lanes < 1 || mdsi->lanes > 4) { + DRM_ERROR("dsi device params invalid\n"); + return -EINVAL; + } + + dsi->lanes = mdsi->lanes; + dsi->format = mdsi->format; + dsi->mode_flags = mdsi->mode_flags; + + return 0; +} + +static int dsi_host_detach(struct mipi_dsi_host *host, + struct mipi_dsi_device *mdsi) +{ + /* do nothing */ + return 0; +} + +static const struct mipi_dsi_host_ops dsi_host_ops = { + .attach = dsi_host_attach, + .detach = dsi_host_detach, +}; + +static int dsi_host_init(struct device *dev, struct dw_dsi *dsi) +{ + struct mipi_dsi_host *host = &dsi->host; + int ret; + + host->dev = dev; + host->ops = &dsi_host_ops; + ret = mipi_dsi_host_register(host); + if (ret) { + DRM_ERROR("failed to register dsi host\n"); + return ret; + } + + return 0; +} + static int dsi_bind(struct device *dev, struct device *master, void *data) { struct dsi_data *ddata = dev_get_drvdata(dev); @@ -653,6 +699,10 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; + ret = dsi_host_init(dev, dsi); + if (ret) + return ret; + return 0; }