From patchwork Wed Feb 9 09:12:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 12739938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31FCEC41535 for ; Wed, 9 Feb 2022 09:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229517AbiBIJlc (ORCPT ); Wed, 9 Feb 2022 04:41:32 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:58122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236456AbiBIJgT (ORCPT ); Wed, 9 Feb 2022 04:36:19 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D0F66E061472 for ; Wed, 9 Feb 2022 01:36:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644399301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IVaOePIAiXFw8U75tAHDUKWkv70g1B3730fSEy8H3OQ=; b=OxVx82ScEGi85ReLcx9/ylCvy8tLNLcsknSZGFM+11yFdPqWq6kUIb7dbTtzuHgT1kMbx4 YBx1tYHPCKqKk8cWYXy8KgBM5Yg9EA9I3rvtZ4YCLojQJ8Tjr/dd9XcqCcwygFB0doQG2i jlUKkCa060MR37k+wbLhPyOXzpXZayg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-59-XegtZ9oCNm21dO5MFSmBOA-1; Wed, 09 Feb 2022 04:12:24 -0500 X-MC-Unique: XegtZ9oCNm21dO5MFSmBOA-1 Received: by mail-wr1-f70.google.com with SMTP id e11-20020adf9bcb000000b001e316b01456so826449wrc.21 for ; Wed, 09 Feb 2022 01:12:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IVaOePIAiXFw8U75tAHDUKWkv70g1B3730fSEy8H3OQ=; b=uUIpIGyFVU3KBg6BABsuskqHrw4BRpmIPzlmSL6NCyhc+7WrUKo762ajUJ++xM6hS0 fIrLzjJ6zpyc+Ekm6E1HrOBFYsvnIuGPyTppQ5eAHT+FM4qycvwx4GyK39qQ9nFYEyoJ HyXgqwW25BQcvJyqjGy7M6oXIx1pTRcQceuhipIQbdC4EglKmTdSUu3/z1dX/zVMOmR/ GTWVn44kmBHDNTOgujgtDUDXw4Ys7ga9r3ku/Piiu8dBGt8H+mLwtAFPEnxSUnvm+eO1 IweSNnGRNO0QhKVr/NfaVguxzm6IajoHTLUULMrgRjW8XrbvXxieJFCZpgiHaGhAhNzR WF1w== X-Gm-Message-State: AOAM530ZKSILRm1MoSThsj6BI70wc+kQ5pL+aNBEvB/57mRyqWemPg5d Uw+5RutB+Ec4gAUuWuqQqg42m3iNPsM07GH985Dg5yQXi4hcOQmalZPDfW27Ni//P3e1yph4uIp yw5HMPjW7uUwMlz+cbH/Bugg= X-Received: by 2002:a05:600c:3b97:: with SMTP id n23mr116344wms.116.1644397943072; Wed, 09 Feb 2022 01:12:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmy9te2m+nFf5NChLb1Oyfbsc9hQqFDn/UG2mRdylATQQhkHE0nZ3daEy/SuR9+qJRmFJzGg== X-Received: by 2002:a05:600c:3b97:: with SMTP id n23mr116329wms.116.1644397942870; Wed, 09 Feb 2022 01:12:22 -0800 (PST) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id m30sm4588068wms.34.2022.02.09.01.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 01:12:22 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Andy Shevchenko , Daniel Vetter , Geert Uytterhoeven , Maxime Ripard , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Javier Martinez Canillas Subject: [PATCH v3 5/7] (WIP) drm/solomon: Add SSD130X OLED displays SPI support Date: Wed, 9 Feb 2022 10:12:04 +0100 Message-Id: <20220209091204.2513437-1-javierm@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209090314.2511959-1-javierm@redhat.com> References: <20220209090314.2511959-1-javierm@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The ssd130x driver only provides the core support for these devices but it does not have any bus transport logic. Add a driver to interface over SPI. Signed-off-by: Javier Martinez Canillas --- Changes in v3: - Add a separate driver for SSD130X chips SPI support (Andy Shevchenko) drivers/gpu/drm/solomon/Kconfig | 9 ++ drivers/gpu/drm/solomon/Makefile | 1 + drivers/gpu/drm/solomon/ssd130x-spi.c | 114 ++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 drivers/gpu/drm/solomon/ssd130x-spi.c diff --git a/drivers/gpu/drm/solomon/Kconfig b/drivers/gpu/drm/solomon/Kconfig index 47e16bc20e0d..16a2098f438c 100644 --- a/drivers/gpu/drm/solomon/Kconfig +++ b/drivers/gpu/drm/solomon/Kconfig @@ -19,3 +19,12 @@ config DRM_SSD130X_I2C Say Y here if the SSD130X OLED display is connected via I2C bus. If M is selected the module will be called ssd130x-i2c. + +config DRM_SSD130X_SPI + tristate "DRM support for Solomon SSD130X OLED displays (SPI bus)" + depends on DRM_SSD130X && SPI + select REGMAP_SPI + help + Say Y here if the SSD130X OLED display is connected via SPI bus. + + If M is selected the module will be called ssd130x-spi. diff --git a/drivers/gpu/drm/solomon/Makefile b/drivers/gpu/drm/solomon/Makefile index 4bfc5acb0447..b5fc792257d7 100644 --- a/drivers/gpu/drm/solomon/Makefile +++ b/drivers/gpu/drm/solomon/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_DRM_SSD130X) += ssd130x.o obj-$(CONFIG_DRM_SSD130X_I2C) += ssd130x-i2c.o +obj-$(CONFIG_DRM_SSD130X_SPI) += ssd130x-spi.o diff --git a/drivers/gpu/drm/solomon/ssd130x-spi.c b/drivers/gpu/drm/solomon/ssd130x-spi.c new file mode 100644 index 000000000000..ccc56d2f3026 --- /dev/null +++ b/drivers/gpu/drm/solomon/ssd130x-spi.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * DRM driver for Solomon SSD130X OLED displays (SPI bus) + * + * Copyright 2022 Red Hat Inc. + * Authors: Javier Martinez Canillas + */ +#include +#include + +#include "ssd130x.h" + +#define DRIVER_NAME "ssd130x-spi" +#define DRIVER_DESC "DRM driver for Solomon SSD130X OLED displays (SPI)" + +static const struct regmap_config ssd130x_spi_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int ssd130x_spi_probe(struct spi_device *spi) +{ + struct ssd130x_device *ssd130x; + struct regmap *regmap; + + regmap = devm_regmap_init_spi(spi, &ssd130x_spi_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + ssd130x = ssd130x_probe(&spi->dev, regmap); + + if (IS_ERR(ssd130x)) + return PTR_ERR(ssd130x); + + spi_set_drvdata(spi, ssd130x); + + return 0; +} + +static int ssd130x_spi_remove(struct spi_device *spi) +{ + struct ssd130x_device *ssd130x = spi_get_drvdata(spi); + + return ssd130x_remove(ssd130x); +} + +static void ssd130x_spi_shutdown(struct spi_device *spi) +{ + struct ssd130x_device *ssd130x = spi_get_drvdata(spi); + + ssd130x_shutdown(ssd130x); +} + +static struct ssd130x_deviceinfo ssd130x_ssd1305_deviceinfo = { + .default_vcomh = 0x34, + .default_dclk_div = 1, + .default_dclk_frq = 7, +}; + +static struct ssd130x_deviceinfo ssd130x_ssd1306_deviceinfo = { + .default_vcomh = 0x20, + .default_dclk_div = 1, + .default_dclk_frq = 8, + .need_chargepump = 1, +}; + +static struct ssd130x_deviceinfo ssd130x_ssd1307_deviceinfo = { + .default_vcomh = 0x20, + .default_dclk_div = 2, + .default_dclk_frq = 12, + .need_pwm = 1, +}; + +static struct ssd130x_deviceinfo ssd130x_ssd1309_deviceinfo = { + .default_vcomh = 0x34, + .default_dclk_div = 1, + .default_dclk_frq = 10, +}; + +static const struct of_device_id ssd130x_of_match[] = { + { + .compatible = "solomon,ssd1305fb-spi", + .data = (void *)&ssd130x_ssd1305_deviceinfo, + }, + { + .compatible = "solomon,ssd1306fb-spi", + .data = (void *)&ssd130x_ssd1306_deviceinfo, + }, + { + .compatible = "solomon,ssd1307fb-spi", + .data = (void *)&ssd130x_ssd1307_deviceinfo, + }, + { + .compatible = "solomon,ssd1309fb-spi", + .data = (void *)&ssd130x_ssd1309_deviceinfo, + }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, ssd130x_of_match); + +static struct spi_driver ssd130x_spi_driver = { + .driver = { + .name = DRIVER_NAME, + .of_match_table = ssd130x_of_match, + }, + .probe = ssd130x_spi_probe, + .remove = ssd130x_spi_remove, + .shutdown = ssd130x_spi_shutdown, +}; +module_spi_driver(ssd130x_spi_driver); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_AUTHOR("Javier Martinez Canillas "); +MODULE_LICENSE("GPL v2");