From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796038940; b=M4lrEEsAZXfjHR1syq38LQv5qduYfnLcKXrKrulUKmONGsutbpM8vRmQoCT41ShkuYr8 hBEnicEBf0flf5S10x43gS2PM8SmxCAAVtJwQhJZb8PRO3b/Ll7K635w3I8glL3abnB+p hwaDwwsBrw935aYOv1jA21bioDXj5wnqzAzktT6wGQ6MWNM02mzdOPEpDDmQaJR4j2RA6 Lg547W3xXU6wA4sHt1BP4uhh+PNiRq9qlababXFUPur3/CfeOjzHf/0QdmHmXpE0Za6Lw BPpyZnLbFZHNcwt4irF8J/g1T0i/60PuAJieIc/awaTd+FEShjuQCH6qcY0/4tYn10A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796038940; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=icJCncEc6jkMKlCGYLsqGCMIoQln+/tXoYBptf+l5WI=; b=xshPVuaQ9XKD0vUGHRpbgswEBCpsZzzGjBpaZ/fFOVv+BZVn19ajShznvc/ooEcjvmo9 3yV9TU/Q0R2tY798Hf2mP7yGp82YG3zE1gBaqyO+gOPvzUGYuJaO3Xo61hm59kpZNk7ZR 0BqjKMcM+UWIDMebqbZJfi6VIv+mBUcZ/tHRF/PEy13zWfoeu6HIwjam/J9gBMHRbBMxG mDpT5EUod0LaMTVOTXdJL7S5qmznR8qhmcDKUATQYstWll+tDqwywAKRHCpy7Mej3epKt FZRYuHM1ujP+vJRWLXfp+46QRsYu/Xt6llwqJEhwNvo3MuoGVgPcYwiWe2zy7Psyfsg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rXQtcwkx; arc=none smtp.remote-ip=209.85.218.41 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A2B2606A332 for ; Mon, 30 Nov 2026 11:42:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2A2B2606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=rXQtcwkx Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-c4d21051042so696326366b.0 for ; Mon, 30 Nov 2026 03:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796038938; x=1796643738; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=icJCncEc6jkMKlCGYLsqGCMIoQln+/tXoYBptf+l5WI=; b=rXQtcwkxtKx9jvfpCn7U+a47h8d9hY49op/I1xE/vbqAib+chPCF5k/+FXuOdHbCYZ kBxNBMDFcmfboaucMUC4Xp31YNFS+3TGpVYGWhU8B685A9K9ltc1XQvnGlpvMdHSipbM M88lQQCUTsR6vR5UJvOCCCK7WfGvOa+p7LZnb78ZpcXYXw7jNYq8EVOiXQOWURO9DfvC Yz7Xa84QooRMJbsC7aKuoNi4MN9fBr50tq5pDq+YxruBBVPkOSR5LkBApMv9PDn2IRG2 M8R8pzIZVqWu4NnE4+SZfiQkH3fU9fMXTJvcpvyGSHFccq8qGJy6wLJww1054qdYoGc/ ZTOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796038938; x=1796643738; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=icJCncEc6jkMKlCGYLsqGCMIoQln+/tXoYBptf+l5WI=; b=F4VFWjhrGlrGAfxtN0ehilkUyW+aOpe4ABzZT7RljFJq4Eu3adulN8InoLZZL4lQvd pywnfxQbwZlC+Off3I2/JHKIJchqBOgXxC+3bGR3GXBKShlphkSdBZ7DYNRRNLH0NJjM zLzM7Cpeug0jE/WGQBpfcODXUahwfBFbIIkl/k1bPcvGaRWT1Ux83kY3zuh6Sh3cAyri jvoiB7vByahrVk59BMvNw7HG5Vf09XyrAb9xpUO0u7kG7TWhYzp8902RgBldtK9Pm2T0 T6bAnjf3tcq8jZTuJhxPm12XDIHE6H5YnQXw4MSrMiOLP2jfuNb3E8Z5Cy8rsKEIJiNC CVfQ== X-Forwarded-Encrypted: i=1; AL+hErHXNEIEU74GzkcDvuNiPaGFhG9fHCyN/cOO5VPoof8+gpvMgsgn+xqrZWuVxcGy9G++VdzmOFRnZfBs@vger.kernel.org X-Gm-Message-State: APuU4Z/vmsuRO8CDW+itgOGW4iZEUG7p1KI4DI1Pa9wJgYmbdJd8egSB OAEANmnbWPKMgWXjCNzdxsTpBZ6r1laVTOj5OrGWihPS3v9pESm6rjvv X-Gm-Gg: AZFdTZdxvIGW/Hqo2udYjwTvnRfqEMMFsCUlMetBmXp58cbZZZA4jVEDaYRCuxnjffL SzEtglOy+VbEfxDJCssd7m79j3lXtN9g8f3k223MlY5rvDYXV15fLN0H/lDcrYAKCTzOEXF1vw1 sr1Yc0TjGuJEm59KmNOBCYfVhBN9mTTQAnkvc60C6qps5HavQ1KyXXcpZt3OxkoeAKBA/cBAHPm U7HnwFQsYiOC8moYNkioH833yCc36ukG8/1cfNrbYk7ya2fnE9wyC5rOxRvI57kOlP8e9JpJJKm W7ehsnK3BFIZAiRrzuqTPhP6knzVuPu+gwnn0LlcRyQIqs54b0c5/g80gg+dya+1Kzw6L2dnyEB 6DJcSMIZts2vbSOg854yvdAmPO3JG353w5qQl94FS1Y6LkLtsRAdEPSXwGGHuNkGwhDMkDLzcXw SH5wVxu7fbUYfTQ5+CltGevQHh+x9IkPKrsOQRCXVwQc0MbbLtA23A2HXykp+NBF7NWJ2sbA9pX l9wpkH++5oKrBtgQ6dK5X8hTe4oh6DhdJ8mxMNsQYrBuVGz2YSJKi8NQfrOAk8liLa79CQO1Sje 2l1dUganYxAd4jHTV/l8Mmqphl8eV7CxhtNGUlq32fn5WTejkPPwozjA1qNWxuj+511KPyMz71q HLoEihDltgg== X-Received: by 2002:a17:907:e98a:b0:c51:9ab1:d1e8 with SMTP id a640c23a62f3a-c519ab1d4ccmr1350402166b.47.1796038938371; Mon, 30 Nov 2026 03:42:18 -0800 (PST) Received: from xeon ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513afc73d3sm1139733466b.64.2026.11.30.03.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 03:42:17 -0800 (PST) From: Svyatoslav Ryhel To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thierry Reding , Jonathan Hunter , Neil Armstrong , Jessica Zhang , Mikko Perttunen , Svyatoslav Ryhel Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 01/13] drm: Add MIPI DBI bus support for MIPI DBI Type A and B Date: Mon, 30 Nov 2026 13:41:42 +0200 Message-ID: <20261130114155.72920-2-clamor95@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261130114155.72920-1-clamor95@gmail.com> References: <20261130114155.72920-1-clamor95@gmail.com> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The MIPI DBI bus allows modeling DBI hosts and peripherals using the Linux driver model. DBI hosts are registered by their respective drivers. During registration, DBI peripherals are created from the device tree nodes provided by the host. DBI hosts expose operations that can be used by peripheral drivers to access associated devices. This implementation adds support for MIPI DBI Type A and Type B only. Type C support existing in drm_mipi_dbi.c was not altered. The framework is modeled to closely resemble the existing MIPI DSI setup for seamless integration. Suggested-by: Mikko Perttunen # preliminary sketch Signed-off-by: Svyatoslav Ryhel --- drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/drm_mipi_dbi_bus.c | 265 +++++++++++++++++++++++++++++ include/drm/drm_mipi_dbi_bus.h | 148 ++++++++++++++++ 3 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/drm_mipi_dbi_bus.c create mode 100644 include/drm/drm_mipi_dbi_bus.h diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 2c6bc093a923a..880f0dc930b85 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -166,7 +166,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o obj-y += tests/ -obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o +obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o drm_mipi_dbi_bus.o obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o obj-y += arm/ obj-y += clients/ diff --git a/drivers/gpu/drm/drm_mipi_dbi_bus.c b/drivers/gpu/drm/drm_mipi_dbi_bus.c new file mode 100644 index 0000000000000..0c9b93d72021b --- /dev/null +++ b/drivers/gpu/drm/drm_mipi_dbi_bus.c @@ -0,0 +1,265 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * MIPI DBI devices with command transport through parallel interface + * + * Copyright 2026 Mikko Perttunen + * Copyright 2026 Svyatoslav Ryhel + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +/** + * DOC: overview + * + * There are three MIPI DBI implementation types: + * + * A. Motorola 6800-type parallel bus + * + * B. Intel 8080-type parallel bus + * + * C. SPI-type with three options: + * + * 1. 9-bit with the Data/Command signal as the ninth bit + * 2. Same as above, except it is sent as 16 bits + * 3. 8-bit with the Data/Command signal as a separate D/CX pin + * + * This library provides a framework for MIPI Display Bus Interface (DBI) + * compatible display controllers using Type A and Type B. This + * implementation closely matches existing DSI framework behavior to + * allow seamless integration. + * + * Type C options 1 and 3 are covered by drm_mipi_dbi.c with + * mipi_dbi_spi_init(). + */ + +static int mipi_dbi_bus_probe(struct device *dev) +{ + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver); + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev); + + if (!drv->probe) + return 0; + + return drv->probe(dbidev); +} + +static void mipi_dbi_bus_remove(struct device *dev) +{ + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver); + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev); + + if (drv->remove) + drv->remove(dbidev); +} + +static void mipi_dbi_bus_shutdown(struct device *dev) +{ + struct mipi_dbi_driver *drv = to_mipi_dbi_driver(dev->driver); + struct mipi_dbi_device *dbidev = to_mipi_dbi_device(dev); + + if (drv->shutdown) + drv->shutdown(dbidev); +} + +static const struct bus_type mipi_dbi_bus_type = { + .name = "mipi-dbi", + .match = of_driver_match_device, + .uevent = of_device_uevent_modalias, + .probe = mipi_dbi_bus_probe, + .remove = mipi_dbi_bus_remove, + .shutdown = mipi_dbi_bus_shutdown, +}; + +static void mipi_dbi_device_release(struct device *dev) +{ + of_node_put(dev->of_node); + kfree(to_mipi_dbi_device(dev)); +} + +static void mipi_dbi_device_unregister(void *data) +{ + struct device *dev = data; + + of_node_clear_flag(dev->of_node, OF_POPULATED); + device_unregister(dev); +} + +/** + * devm_mipi_dbi_device_register() - create a managed peripheral MIPI DBI + * Type A or B device. + * @dev: device to tie the MIPI-DBI device lifetime to + * @host: DBI host to which this device is connected + * @np: device tree node associated with the panel MIPI DBI device + * + * This function is called by DBI host driver to create panel device. + * It automatically calls mipi_dbi_device_unregister() when @dev is + * unbound. It does not automatically free passed device node pointer, + * it must be put manually. + * + * Returns: + * A pointer to the newly created MIPI DBI device, or, an error pointer. + */ +struct mipi_dbi_device * +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host, + struct device_node *np) +{ + struct mipi_dbi_device *dbidev; + int ret; + + if (!host || !host->dev || !host->dbi || !host->dbi->command || + !host->ops || !host->ops->attach || !host->ops->detach || !np) + return ERR_PTR(-EINVAL); + + if (!of_device_is_available(np)) + return ERR_PTR(-ENODEV); + + dbidev = kzalloc_obj(*dbidev); + if (!dbidev) + return ERR_PTR(-ENOMEM); + + if (of_node_test_and_set_flag(np, OF_POPULATED)) { + kfree(dbidev); + return ERR_PTR(-EBUSY); + } + + dbidev->host = host; + dbidev->dbi = host->dbi; + device_initialize(&dbidev->dev); + dbidev->dev.parent = host->dev; + dbidev->dev.bus = &mipi_dbi_bus_type; + dbidev->dev.release = mipi_dbi_device_release; + device_set_node(&dbidev->dev, of_fwnode_handle(of_node_get(np))); + + ret = dev_set_name(&dbidev->dev, "%s:%s", dev_name(host->dev), np->full_name); + if (ret) + goto put_device; + + ret = device_add(&dbidev->dev); + if (ret) + goto put_device; + + ret = devm_add_action_or_reset(dev, mipi_dbi_device_unregister, + &dbidev->dev); + if (ret) + return ERR_PTR(ret); + + return dbidev; + +put_device: + of_node_clear_flag(np, OF_POPULATED); + put_device(&dbidev->dev); + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(devm_mipi_dbi_device_register); + +static void mipi_dbi_detach(void *data) +{ + struct mipi_dbi_device *dbidev = data; + + dbidev->host->ops->detach(dbidev->host, dbidev); + dbidev->attached = false; +} + +/** + * devm_mipi_dbi_attach() - managed attach of peripheral DBI device to its MIPI + * DBI Type A or B devices. + * @dev: device to tie the MIPI-DBI device lifetime to + * @dbidev: DBI peripheral + * + * Return: 0 on success or a negative error code on failure. + */ +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev) +{ + int ret; + + if (dbidev->attached) + return -EBUSY; + + ret = dbidev->host->ops->attach(dbidev->host, dbidev); + if (ret) + return ret; + + dbidev->attached = true; + return devm_add_action_or_reset(dev, mipi_dbi_detach, dbidev); +} +EXPORT_SYMBOL_GPL(devm_mipi_dbi_attach); + +/** + * mipi_dbi_write_buffer_multi() - mipi_dbi_command() w/ accum_err but for + * MIPI DBI Type A and B + * @ctx: context for multiple DBI transactions + * @cmd: command to be sent + * @data: buffer containing data to be transmitted + * @len: size of transmission buffer + * + * Acts like mipi_dbi_command() for MIPI DBI Type C but for Types A and B + * and deals with errors in a way that makes it convenient to make several + * calls in a row. + */ +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx, + u8 cmd, const u8 *data, size_t len) +{ + struct mipi_dbi_device *dbidev = ctx->dbidev; + struct device *dev = &dbidev->dev; + int ret; + + if (ctx->accum_err) + return; + + ret = mipi_dbi_command_stackbuf(dbidev->dbi, cmd, data, len); + if (ret < 0) { + ctx->accum_err = ret; + dev_err(dev, "sending dcs data %*ph failed: %d\n", + (int)len, data, ctx->accum_err); + } +} +EXPORT_SYMBOL(mipi_dbi_write_buffer_multi); + +/** + * __mipi_dbi_driver_register() - register a driver for MIPI DBI Type A or B devices. + * @drv: DBI driver structure + * @owner: owner module + * + * Return: 0 on success or a negative error code on failure. + */ +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner) +{ + drv->driver.bus = &mipi_dbi_bus_type; + drv->driver.owner = owner; + + return driver_register(&drv->driver); +} +EXPORT_SYMBOL_GPL(__mipi_dbi_driver_register); + +/** + * mipi_dbi_driver_unregister() - unregister a driver for MIPI DBI Type A or B devices. + * @drv: DBI driver structure + */ +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv) +{ + driver_unregister(&drv->driver); +} +EXPORT_SYMBOL_GPL(mipi_dbi_driver_unregister); + +static int __init mipi_dbi_bus_init(void) +{ + return bus_register(&mipi_dbi_bus_type); +} +subsys_initcall(mipi_dbi_bus_init); + +static void __exit mipi_dbi_bus_exit(void) +{ + bus_unregister(&mipi_dbi_bus_type); +} +module_exit(mipi_dbi_bus_exit); + +MODULE_DESCRIPTION("MIPI DBI devices with command transport through parallel interface"); +MODULE_LICENSE("GPL"); diff --git a/include/drm/drm_mipi_dbi_bus.h b/include/drm/drm_mipi_dbi_bus.h new file mode 100644 index 0000000000000..559793a31c0a1 --- /dev/null +++ b/include/drm/drm_mipi_dbi_bus.h @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * MIPI DBI devices with command transport through parallel interface + * + * Copyright 2026 Mikko Perttunen + * Copyright 2026 Svyatoslav Ryhel + */ + +#ifndef __DRM_MIPI_DBI_BUS_H__ +#define __DRM_MIPI_DBI_BUS_H__ + +#include +#include + +struct device_node; +struct mipi_dbi; +struct mipi_dbi_device; +struct mipi_dbi_host; + +/** + * struct mipi_dbi_host_ops - DBI bus operations for MIPI DBI Type A and B. + * @attach: attach DBI device to DBI host + * @detach: detach DBI device from DBI host + */ +struct mipi_dbi_host_ops { + int (*attach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev); + void (*detach)(struct mipi_dbi_host *host, struct mipi_dbi_device *dev); +}; + +/** + * struct mipi_dbi_host - DBI host device for MIPI DBI Type A and B. + * @dev: driver model device node for this DBI host + * @dbi: MIPI DBI interface + * @ops: DBI host operations + */ +struct mipi_dbi_host { + struct device *dev; + struct mipi_dbi *dbi; + const struct mipi_dbi_host_ops *ops; +}; + +/** + * struct mipi_dbi_device - DBI peripheral device for MIPI DBI Type A and B. + * This structure describes a peripheral DBI device, + * an endpoint for DCS commands and video data, and must + * be paired with a DBI host device for MIPI DBI Type A + * and B. This layout is built to closely resemble + * the DSI framework. + * + * If your device is MIPI DBI Type C (with an SPI + * control bus) and incorporates DBI within, you + * should use the mipi_dbi_dev structure and Type C + * framework from drm_mipi_dbi.c. + * @dev: driver model device node for this peripheral + * @dbi: MIPI DBI interface + * @host: DBI host for this peripheral + * @attached: the DBI device has been successfully attached + */ +struct mipi_dbi_device { + struct device dev; + struct mipi_dbi *dbi; + struct mipi_dbi_host *host; + bool attached; +}; + +/** + * struct mipi_dbi_multi_context - Context to call multiple MIPI DBI funcs in a row + * @dbidev: Pointer to the peripheral MIPI DBI Type A and B device + * @accum_err: Storage for the accumulated error over the multiple calls + * Init to 0. If a function encounters an error then the error code + * will be stored here. If you call a function and this points to a + * non-zero value then the function will be a noop. This allows calling + * a function many times in a row and just checking the error at the + * end to see if any of them failed. + */ + +struct mipi_dbi_multi_context { + struct mipi_dbi_device *dbidev; + int accum_err; +}; + +#define to_mipi_dbi_device(__dev) container_of_const(__dev, struct mipi_dbi_device, dev) + +void mipi_dbi_write_buffer_multi(struct mipi_dbi_multi_context *ctx, + u8 cmd, const u8 *data, size_t len); + +/** + * mipi_dbi_write_seq_multi() - transmit a command with payload + * + * This macro will print errors for you and error handling is optimized for + * callers that call this multiple times in a row. + * + * @ctx: context for multiple DBI transactions + * @cmd: command to be sent + * @seq: buffer containing data to be transmitted + */ +#define mipi_dbi_write_seq_multi(ctx, cmd, seq...) \ + do { \ + static const u8 d[] = { seq }; \ + mipi_dbi_write_buffer_multi(ctx, cmd, d, ARRAY_SIZE(d)); \ + } while (0) + +struct mipi_dbi_device * +devm_mipi_dbi_device_register(struct device *dev, struct mipi_dbi_host *host, + struct device_node *np); +int devm_mipi_dbi_attach(struct device *dev, struct mipi_dbi_device *dbidev); + +/** + * struct mipi_dbi_driver - DBI driver for MIPI DBI Type A and B. + * @driver: device driver model driver + * @probe: callback for device binding + * @remove: callback for device unbinding + * @shutdown: called at shutdown time to quiesce the device + */ +struct mipi_dbi_driver { + struct device_driver driver; + int (*probe)(struct mipi_dbi_device *dbi); + void (*remove)(struct mipi_dbi_device *dbi); + void (*shutdown)(struct mipi_dbi_device *dbi); +}; + +static inline struct mipi_dbi_driver * +to_mipi_dbi_driver(struct device_driver *driver) +{ + return container_of(driver, struct mipi_dbi_driver, driver); +} + +static inline void *mipi_dbi_get_drvdata(const struct mipi_dbi_device *dbi) +{ + return dev_get_drvdata(&dbi->dev); +} + +static inline void mipi_dbi_set_drvdata(struct mipi_dbi_device *dbi, void *data) +{ + dev_set_drvdata(&dbi->dev, data); +} + +int __mipi_dbi_driver_register(struct mipi_dbi_driver *drv, struct module *owner); +void mipi_dbi_driver_unregister(struct mipi_dbi_driver *drv); + +#define mipi_dbi_driver_register(driver) \ + __mipi_dbi_driver_register(driver, THIS_MODULE) + +#define module_mipi_dbi_driver(__mipi_dbi_driver) \ + module_driver(__mipi_dbi_driver, mipi_dbi_driver_register, \ + mipi_dbi_driver_unregister) + +#endif /* __DRM_MIPI_DBI_BUS_H__ */ -- 2.53.0