From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751595AbcBLJSy (ORCPT ); Fri, 12 Feb 2016 04:18:54 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:58288 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbcBLJSu (ORCPT ); Fri, 12 Feb 2016 04:18:50 -0500 From: Archit Taneja To: dri-devel@lists.freedesktop.org, treding@nvidia.com Cc: linux-kernel@vger.kernel.org, a.hajda@samsung.com, airlied@linux.ie, daniel@ffwll.ch, l.stach@pengutronix.de, robh@kernel.org, linux-arm-msm@vger.kernel.org, jani.nikula@linux.intel.com, Archit Taneja Subject: [PATCH v5 2/5] drm/dsi: Use mipi_dsi_device_register_full for DSI device creation Date: Fri, 12 Feb 2016 14:48:31 +0530 Message-Id: <1455268714-28755-3-git-send-email-architt@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1455268714-28755-1-git-send-email-architt@codeaurora.org> References: <1449751300-2841-1-git-send-email-architt@codeaurora.org> <1455268714-28755-1-git-send-email-architt@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use mipi_dsi_device_register_full for device creation. This takes in mipi_dsi_device_info as a template to populate the DSI device information. The reason to introduce this is to have a way to create DSI devices not available via DT. Drivers that want to create a DSI device can populate mipi_dsi_device_info and call this function. For DSI devices available via DT, of_mipi_dsi_device_add is used as before, but this now calls mipi_dsi_device_register_full internally. Signed-off-by: Archit Taneja --- drivers/gpu/drm/drm_mipi_dsi.c | 64 +++++++++++++++++++++++++++++++----------- include/drm/drm_mipi_dsi.h | 16 +++++++++++ 2 files changed, 63 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 4f2a704..5d7243d 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -133,8 +133,8 @@ static int mipi_dsi_device_add(struct mipi_dsi_device *dsi) static struct mipi_dsi_device * of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) { - struct mipi_dsi_device *dsi; struct device *dev = host->dev; + struct mipi_dsi_device_info info = { }; int ret; u32 reg; @@ -145,39 +145,69 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) return ERR_PTR(-EINVAL); } - if (reg > 3) { - dev_err(dev, "device node %s has invalid reg property: %u\n", - node->full_name, reg); + info.channel = reg; + info.node = of_node_get(node); + + return mipi_dsi_device_register_full(host, &info); +} +#else +static struct mipi_dsi_device * +of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) +{ + return ERR_PTR(-ENODEV); +} +#endif + +/** + * mipi_dsi_device_register_full - create a MIPI DSI device + * @host: DSI host to which this device is connected + * @info: pointer to template containing DSI device information + * + * Create a MIPI DSI device by using the device information provided by + * mipi_dsi_device_info template + * + * Returns: + * A pointer to the newly created MIPI DSI device, or, a pointer encoded + * with an error + */ +struct mipi_dsi_device * +mipi_dsi_device_register_full(struct mipi_dsi_host *host, + const struct mipi_dsi_device_info *info) +{ + struct mipi_dsi_device *dsi; + struct device *dev = host->dev; + int ret; + + if (!info) { + dev_err(dev, "invalid mipi_dsi_device_info pointer\n"); + return ERR_PTR(-EINVAL); + } + + if (info->channel > 3) { + dev_err(dev, "invalid virtual channel: %u\n", info->channel); return ERR_PTR(-EINVAL); } dsi = mipi_dsi_device_alloc(host); if (IS_ERR(dsi)) { - dev_err(dev, "failed to allocate DSI device %s: %ld\n", - node->full_name, PTR_ERR(dsi)); + dev_err(dev, "failed to allocate DSI device %ld\n", + PTR_ERR(dsi)); return dsi; } - dsi->dev.of_node = of_node_get(node); - dsi->channel = reg; + dsi->dev.of_node = info->node; + dsi->channel = info->channel; ret = mipi_dsi_device_add(dsi); if (ret) { - dev_err(dev, "failed to add DSI device %s: %d\n", - node->full_name, ret); + dev_err(dev, "failed to add DSI device %d\n", ret); kfree(dsi); return ERR_PTR(ret); } return dsi; } -#else -static struct mipi_dsi_device * -of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) -{ - return ERR_PTR(-ENODEV); -} -#endif +EXPORT_SYMBOL(mipi_dsi_device_register_full); int mipi_dsi_host_register(struct mipi_dsi_host *host) { diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index 1b3b1f8..ce5eae43 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -139,6 +139,19 @@ enum mipi_dsi_pixel_format { MIPI_DSI_FMT_RGB565, }; + /** + * struct mipi_dsi_device_info - template for creating a mipi_dsi_device + * @channel: DSI virtual channel assigned to peripheral + * @node: pointer to OF device node + * + * This is populated and passed to mipi_dsi_device_new to create a new + * DSI device + */ +struct mipi_dsi_device_info { + u32 channel; + struct device_node *node; +}; + /** * struct mipi_dsi_device - DSI peripheral device * @host: DSI host for this peripheral @@ -188,6 +201,9 @@ static inline int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt) return -EINVAL; } +struct mipi_dsi_device * +mipi_dsi_device_register_full(struct mipi_dsi_host *host, + const struct mipi_dsi_device_info *info); struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np); int mipi_dsi_attach(struct mipi_dsi_device *dsi); int mipi_dsi_detach(struct mipi_dsi_device *dsi); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation