From patchwork Mon Feb 14 13:37:08 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: 12745624 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 20279C433F5 for ; Mon, 14 Feb 2022 13:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354425AbiBNNiG (ORCPT ); Mon, 14 Feb 2022 08:38:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354354AbiBNNhu (ORCPT ); Mon, 14 Feb 2022 08:37:50 -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 B15E655499 for ; Mon, 14 Feb 2022 05:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644845860; 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=62OmRN0+ZmJkqLoaFDxhy0eO6yAnFd+9Iv9L0ky9wLc=; b=RNJ7DGjq8TVJb9K9vbyx+h1XBdGdx+SDvVv8argrzkK68TSKFYxmTkUltociaTHryDRlkc hBpdNsbfj0SIZ4CQDgMjqo4lGxEpvg68SiPRR1uipSQH7+W68cdpCwQEiWko9fK/WZt/q4 WN4bsL3wHa5183IgQW1Gkq8+kb8lB+U= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-248-jzpfs8o6MialYp5y521Zdw-1; Mon, 14 Feb 2022 08:37:39 -0500 X-MC-Unique: jzpfs8o6MialYp5y521Zdw-1 Received: by mail-wm1-f69.google.com with SMTP id w5-20020a1cf605000000b00354d2d83490so1615524wmc.4 for ; Mon, 14 Feb 2022 05:37:39 -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=62OmRN0+ZmJkqLoaFDxhy0eO6yAnFd+9Iv9L0ky9wLc=; b=oWslOgSjKyNWGOo9LKHuvQKLHzpI6TMHDf0B7RA7qqqZfZczX/5lO52uEsdhNJXYCa J6JhUF/jkxlKrsPADPypUwEM+zGn1zJEHTIpHRCLwVCwHuyCltqrJuFe4+c2C7drhmSj 0XOCKMFzsPrk9jnVxJD/EnKntPyDh0NALpW7UpFB3naJUBkLgX+Np01qvelv6RW2HZYB Sisjdkkm2qm9MxO7Bhgt+c6I9PniYyJLAGfsy1by+LyLzacWZ5VpD6oA6+DjESIoQlnH gPFRAw0G4UNke1UwG2ijKu0n1wggbZ2fn2bQz8Ad+DGDfAV8kUE2CzjuCBEhi81CR/Ez e5tg== X-Gm-Message-State: AOAM530jaxzoF7LMyBGxoZK4u97R0gnfc4nsd72DjTYVGN1nhvGhw13M vQTY2RgezhkbZNwFMkDRwqGG4nNLpoXw1jZ3d96M2m5KXsv+7CWPGbcM+ZwRG+NHai+t+4F21dw B/VCYbwiRD/CnPtkbMzGwFWM= X-Received: by 2002:a5d:4ac7:: with SMTP id y7mr11632474wrs.521.1644845858009; Mon, 14 Feb 2022 05:37:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8VZXr0lt8TjYW2cqobZdRW50wOeVp8oV02mur3StsZ5D0CpVhMx2bj567oRG+kIrVHV4Xmw== X-Received: by 2002:a5d:4ac7:: with SMTP id y7mr11632442wrs.521.1644845857767; Mon, 14 Feb 2022 05:37:37 -0800 (PST) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id y6sm3568918wrd.30.2022.02.14.05.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 05:37:37 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: linux-fbdev@vger.kernel.org, Andy Shevchenko , Daniel Vetter , Geert Uytterhoeven , Thomas Zimmermann , Sam Ravnborg , dri-devel@lists.freedesktop.org, Maxime Ripard , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Javier Martinez Canillas , Daniel Vetter , David Airlie Subject: [PATCH v6 4/6] drm/solomon: Add SSD130x OLED displays I2C support Date: Mon, 14 Feb 2022 14:37:08 +0100 Message-Id: <20220214133710.3278506-5-javierm@redhat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220214133710.3278506-1-javierm@redhat.com> References: <20220214133710.3278506-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 I2C. Signed-off-by: Javier Martinez Canillas Reviewed-by: Andy Shevchenko Reviewed-by: Maxime Ripard --- (no changes since v5) Changes in v5: - Add Andy Shevchenko's Reviewed-by tag to patch #4. Changes in v4: - Remove unnecessary casting (Geert Uytterhoeven) - Remove redundant blank lines (Andy Shevchenko) - Remove comma after of_device_id table terminator (Andy Shevchenko) Changes in v3: - Add a separate driver for SSD130X chips I2C support (Andy Shevchenko) drivers/gpu/drm/solomon/Kconfig | 9 ++ drivers/gpu/drm/solomon/Makefile | 1 + drivers/gpu/drm/solomon/ssd130x-i2c.c | 116 ++++++++++++++++++++++++++ 3 files changed, 126 insertions(+) create mode 100644 drivers/gpu/drm/solomon/ssd130x-i2c.c diff --git a/drivers/gpu/drm/solomon/Kconfig b/drivers/gpu/drm/solomon/Kconfig index 7720a7039e8d..5861c3ab7c45 100644 --- a/drivers/gpu/drm/solomon/Kconfig +++ b/drivers/gpu/drm/solomon/Kconfig @@ -10,3 +10,12 @@ config DRM_SSD130X the appropriate bus transport in your chip also must be selected. If M is selected the module will be called ssd130x. + +config DRM_SSD130X_I2C + tristate "DRM support for Solomon SSD130x OLED displays (I2C bus)" + depends on DRM_SSD130X && I2C + select REGMAP_I2C + help + Say Y here if the SSD130x OLED display is connected via I2C bus. + + If M is selected the module will be called ssd130x-i2c. diff --git a/drivers/gpu/drm/solomon/Makefile b/drivers/gpu/drm/solomon/Makefile index f685addb19fe..4bfc5acb0447 100644 --- a/drivers/gpu/drm/solomon/Makefile +++ b/drivers/gpu/drm/solomon/Makefile @@ -1 +1,2 @@ obj-$(CONFIG_DRM_SSD130X) += ssd130x.o +obj-$(CONFIG_DRM_SSD130X_I2C) += ssd130x-i2c.o diff --git a/drivers/gpu/drm/solomon/ssd130x-i2c.c b/drivers/gpu/drm/solomon/ssd130x-i2c.c new file mode 100644 index 000000000000..3126aeda4ced --- /dev/null +++ b/drivers/gpu/drm/solomon/ssd130x-i2c.c @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * DRM driver for Solomon SSD130x OLED displays (I2C bus) + * + * Copyright 2022 Red Hat Inc. + * Author: Javier Martinez Canillas + * + * Based on drivers/video/fbdev/ssd1307fb.c + * Copyright 2012 Free Electrons + */ +#include +#include + +#include "ssd130x.h" + +#define DRIVER_NAME "ssd130x-i2c" +#define DRIVER_DESC "DRM driver for Solomon SSD130x OLED displays (I2C)" + +static const struct regmap_config ssd130x_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int ssd130x_i2c_probe(struct i2c_client *client) +{ + struct ssd130x_device *ssd130x; + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, &ssd130x_i2c_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + ssd130x = ssd130x_probe(&client->dev, regmap); + if (IS_ERR(ssd130x)) + return PTR_ERR(ssd130x); + + i2c_set_clientdata(client, ssd130x); + + return 0; +} + +static int ssd130x_i2c_remove(struct i2c_client *client) +{ + struct ssd130x_device *ssd130x = i2c_get_clientdata(client); + + return ssd130x_remove(ssd130x); +} + +static void ssd130x_i2c_shutdown(struct i2c_client *client) +{ + struct ssd130x_device *ssd130x = i2c_get_clientdata(client); + + 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-i2c", + .data = &ssd130x_ssd1305_deviceinfo, + }, + { + .compatible = "solomon,ssd1306fb-i2c", + .data = &ssd130x_ssd1306_deviceinfo, + }, + { + .compatible = "solomon,ssd1307fb-i2c", + .data = &ssd130x_ssd1307_deviceinfo, + }, + { + .compatible = "solomon,ssd1309fb-i2c", + .data = &ssd130x_ssd1309_deviceinfo, + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ssd130x_of_match); + +static struct i2c_driver ssd130x_i2c_driver = { + .driver = { + .name = DRIVER_NAME, + .of_match_table = ssd130x_of_match, + }, + .probe_new = ssd130x_i2c_probe, + .remove = ssd130x_i2c_remove, + .shutdown = ssd130x_i2c_shutdown, +}; +module_i2c_driver(ssd130x_i2c_driver); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_AUTHOR("Javier Martinez Canillas "); +MODULE_LICENSE("GPL v2");