From patchwork Wed Jul 3 21:45:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Hugo X-Patchwork-Id: 11031147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 786FE138B for ; Thu, 4 Jul 2019 07:27:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6419F28A33 for ; Thu, 4 Jul 2019 07:27:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 583BD28A3F; Thu, 4 Jul 2019 07:27:10 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D90BB28A33 for ; Thu, 4 Jul 2019 07:27:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8499D6E2D3; Thu, 4 Jul 2019 07:26:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B4EE6E202 for ; Wed, 3 Jul 2019 21:45:16 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id i189so1892085pfg.10 for ; Wed, 03 Jul 2019 14:45:16 -0700 (PDT) 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=rblKGIlJDkSzRoKjZR0ET2T3JOcuW5SkJJUuNM12yX4=; b=ihfbmST6i7u49V9mhvCjBPbHm3gDeQGIAZCf1NeoOYMW8UreZx53YyplWGel5Z2/Jv +DTPGrimfBJi+PLaI9cMphl3NO8Vt3E9Pve2xlKn7kA1DA0SQs/EC7bdOABarjtOP0Fd 7aIbCML+v+6CUEsK/AAiRC9Oh3/5JevtEd5/8YhJrsYvUBr5yNPjpuQJT4l+zc1enai6 r45QBkgadlAoxPMthYFfFq+hCtAnw8CP6RIaVIk4LdlFy7P7fyZo9y2vzbnMJjY+5Tv+ SeWtTB6EAxAhmD9iK/Ryzz2CY/uJRZL4TbFd/S89pRwSJxn/GqFy2uS6jojLbEG3Flz+ Reag== X-Gm-Message-State: APjAAAXNu7kCjyaS7NFzo1+X6S+ZOFRJ9vgJrQndVq3EuHFM46DmJ6qR chpe0RWHHmKBvJw5TlyJkIA= X-Google-Smtp-Source: APXvYqziW6uz8kvYxiLE8i06vq1Y2XLf9uMisxKM0llLNGE8dLv+QCJtNMLwxKg8jzpKrGeCHGMrrA== X-Received: by 2002:a63:545c:: with SMTP id e28mr40705619pgm.374.1562190315688; Wed, 03 Jul 2019 14:45:15 -0700 (PDT) Received: from aw-bldr-10.qualcomm.com (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id o14sm2895434pjp.29.2019.07.03.14.45.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jul 2019 14:45:15 -0700 (PDT) From: Jeffrey Hugo To: broonie@kernel.org Subject: [PATCH 1/2] regmap: Add DSI bus support Date: Wed, 3 Jul 2019 14:45:12 -0700 Message-Id: <20190703214512.41319-1-jeffrey.l.hugo@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703214326.41269-1-jeffrey.l.hugo@gmail.com> References: <20190703214326.41269-1-jeffrey.l.hugo@gmail.com> X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-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=rblKGIlJDkSzRoKjZR0ET2T3JOcuW5SkJJUuNM12yX4=; b=XOB4vVcYBhzEHCUq87ZYRWQIOXEMrLuy250Kzgu+UOWDM4Qj3EMhvKXiAIQMvezsV1 tTlvp2W/AJaPQuzPDD7K8vH1H+yHsUEfUEZPj0qExIR/HrLFXrQCssEZj4abmJ6EBlJp 6SUNWUXL8cnY2Y0qYAue60xyhK7PRnjwunXwdjbnrVggsbfW1VkOTNCraDV0WUxnhS1m V6B1ZK62xyCeohV7kPa4aQVKC/AdOQr9x6ZICa8GMI+CBMLzerypxLBF+PG+Z44fwoMD JlPYcZWgpUnfi4Sri+cAm+qQXQu9V0Imiu4JpNpdkyYPctK1ZTCwR5NaYzN79Pd7BVaZ 0bbQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jeffrey Hugo , airlied@linux.ie, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, bjorn.andersson@linaro.org, Laurent.pinchart@ideasonboard.com MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add basic support with a simple implementation that utilizes the generic read/write commands to allow device registers to be configured. Signed-off-by: Jeffrey Hugo --- drivers/base/regmap/Kconfig | 6 +++- drivers/base/regmap/Makefile | 1 + drivers/base/regmap/regmap-dsi.c | 62 ++++++++++++++++++++++++++++++++ include/linux/regmap.h | 37 +++++++++++++++++++ 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 drivers/base/regmap/regmap-dsi.c diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig index c8bbf5322720..27669afa9d95 100644 --- a/drivers/base/regmap/Kconfig +++ b/drivers/base/regmap/Kconfig @@ -4,7 +4,7 @@ # subsystems should select the appropriate symbols. config REGMAP - default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_I3C) + default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_I3C || REGMAP_DSI) select IRQ_DOMAIN if REGMAP_IRQ bool @@ -53,3 +53,7 @@ config REGMAP_SCCB config REGMAP_I3C tristate depends on I3C + +config REGMAP_DSI + tristate + depends on DRM_MIPI_DSI diff --git a/drivers/base/regmap/Makefile b/drivers/base/regmap/Makefile index ff6c7d8ec1cd..c1cc81f3986f 100644 --- a/drivers/base/regmap/Makefile +++ b/drivers/base/regmap/Makefile @@ -17,3 +17,4 @@ obj-$(CONFIG_REGMAP_W1) += regmap-w1.o obj-$(CONFIG_REGMAP_SOUNDWIRE) += regmap-sdw.o obj-$(CONFIG_REGMAP_SCCB) += regmap-sccb.o obj-$(CONFIG_REGMAP_I3C) += regmap-i3c.o +obj-$(CONFIG_REGMAP_DSI) += regmap-dsi.o diff --git a/drivers/base/regmap/regmap-dsi.c b/drivers/base/regmap/regmap-dsi.c new file mode 100644 index 000000000000..0c2900e2fee0 --- /dev/null +++ b/drivers/base/regmap/regmap-dsi.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Register map access API - DSI support +// +// Copyright (c) 2019 Jeffrey Hugo + +#include +#include +#include + +#include "internal.h" + +static int dsi_reg_write(void *context, unsigned int reg, unsigned int val) +{ + struct device *dev = context; + struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); + char payload[2]; + int ret; + + payload[0] = (char)reg; + payload[1] = (char)val; + + ret = mipi_dsi_generic_write(dsi, payload, 2); + return ret < 0 ? ret : 0; +} + +static int dsi_reg_read(void *context, unsigned int reg, unsigned int *val) +{ + struct device *dev = context; + struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev); + int ret; + + ret = mipi_dsi_generic_read(dsi, ®, 1, val, 1); + return ret < 0 ? ret : 0; +} + +static struct regmap_bus dsi_bus = { + .reg_write = dsi_reg_write, + .reg_read = dsi_reg_read, +}; + +struct regmap *__regmap_init_dsi(struct mipi_dsi_device *dsi, + const struct regmap_config *config, + struct lock_class_key *lock_key, + const char *lock_name) +{ + return __regmap_init(&dsi->dev, &dsi_bus, &dsi->dev, config, + lock_key, lock_name); +} +EXPORT_SYMBOL_GPL(__regmap_init_dsi); + +struct regmap *__devm_regmap_init_dsi(struct mipi_dsi_device *dsi, + const struct regmap_config *config, + struct lock_class_key *lock_key, + const char *lock_name) +{ + return __devm_regmap_init(&dsi->dev, &dsi_bus, &dsi->dev, config, + lock_key, lock_name); +} +EXPORT_SYMBOL_GPL(__devm_regmap_init_dsi); + +MODULE_LICENSE("GPL"); diff --git a/include/linux/regmap.h b/include/linux/regmap.h index dfe493ac692d..858239f7859f 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -32,6 +32,7 @@ struct regmap_range_cfg; struct regmap_field; struct snd_ac97; struct sdw_slave; +struct mipi_dsi_device; /* An enum of all the supported cache types */ enum regcache_type { @@ -573,6 +574,10 @@ struct regmap *__regmap_init_sdw(struct sdw_slave *sdw, const struct regmap_config *config, struct lock_class_key *lock_key, const char *lock_name); +struct regmap *__regmap_init_dsi(struct mipi_dsi_device *dsi, + const struct regmap_config *config, + struct lock_class_key *lock_key, + const char *lock_name); struct regmap *__devm_regmap_init(struct device *dev, const struct regmap_bus *bus, @@ -626,6 +631,10 @@ struct regmap *__devm_regmap_init_i3c(struct i3c_device *i3c, const struct regmap_config *config, struct lock_class_key *lock_key, const char *lock_name); +struct regmap *__devm_regmap_init_dsi(struct mipi_dsi_device *dsi, + const struct regmap_config *config, + struct lock_class_key *lock_key, + const char *lock_name); /* * Wrapper for regmap_init macros to include a unique lockdep key and name * for each call. No-op if CONFIG_LOCKDEP is not set. @@ -812,6 +821,19 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); __regmap_lockdep_wrapper(__regmap_init_sdw, #config, \ sdw, config) +/** + * regmap_init_dsi() - Initialise register map + * + * @dsi: Device that will be interacted with + * @config: Configuration for register map + * + * The return value will be an ERR_PTR() on error or a valid pointer to + * a struct regmap. + */ +#define regmap_init_dsi(dsi, config) \ + __regmap_lockdep_wrapper(__regmap_init_dsi, #config, \ + dsi, config) + /** * devm_regmap_init() - Initialise managed register map @@ -999,6 +1021,21 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); __regmap_lockdep_wrapper(__devm_regmap_init_i3c, #config, \ i3c, config) +/** + * devm_regmap_init_dsi() - Initialise managed register map + * + * @dsi: Device that will be interacted with + * @config: Configuration for register map + * + * The return value will be an ERR_PTR() on error or a valid pointer + * to a struct regmap. The regmap will be automatically freed by the + * device management code. + */ +#define devm_regmap_init_dsi(dsi, config) \ + __regmap_lockdep_wrapper(__devm_regmap_init_dsi, #config, \ + dsi, config) + + int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); void regmap_mmio_detach_clk(struct regmap *map); void regmap_exit(struct regmap *map);