From patchwork Tue Apr 19 21:48:19 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: 12819459 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C495CC433F5 for ; Tue, 19 Apr 2022 21:48:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C7AE89F82; Tue, 19 Apr 2022 21:48:47 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 29B2689DA5 for ; Tue, 19 Apr 2022 21:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650404923; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ao+QLGVykP8whEqJzniS6nnN6H0GlmSyDd2RtpQtg0Q=; b=b7ZoxKqkWgW4m/Yk8+bUFDyItjIHdg8TGptTx9R0k/8qfqHh0EqQD5kq/Bw3lyEw3tAERf RuxnV8kHPk1d2NqGVqPqCD8cW8i1m5Lp/B/jZdX6qnD5QAppEqRSqd4N60rGuJSJ1OGOFG wMujst5LA332ChCfTq76+b9RcN90zSI= 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-171-MIS7b-njNY-98Gxq6G3QOw-1; Tue, 19 Apr 2022 17:48:32 -0400 X-MC-Unique: MIS7b-njNY-98Gxq6G3QOw-1 Received: by mail-wm1-f69.google.com with SMTP id k16-20020a7bc310000000b0038e6cf00439so35377wmj.0 for ; Tue, 19 Apr 2022 14:48:32 -0700 (PDT) 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=Ao+QLGVykP8whEqJzniS6nnN6H0GlmSyDd2RtpQtg0Q=; b=TpWmNM7GwXCxZu6XY5Vxd4c+5wDwKNkvI17Iko1AxM8NtqOWetywFcvixr0vDj8dgq NtHk+O8ctBiL+Q81S2gbBNU3SmhgYup3wdrp43+3GAZVJ9Myyc8cB2bPl6DvuJx89iLv EvlHVdOALfQN09SenCOFNP9Mm+xShYMR44sMSZnwzauXUrn5AyV9SQnHdDvi5hq+iFdj EQfNMSxO5VzDHIOkOVDeBHWTNnnT4PqP1wdX/eIsm7eFMMUcoenQL523wPuwRDrZEDfs yrWwMieooZtp8x4KHgu9zCBky9hhAPH54xPhB6Pbr1PX/kK1dn7rq9bhBUCeLTKgxb1A BSng== X-Gm-Message-State: AOAM532yEHXU9JqaBH+sOlF8gqrfbhgWg6s5EgOcxnKRbsTE3gdCbW8p C0Ga9qgyeavJJmmnqkNu21EpXUDIDQDcD6prSmTxOQbZPj/QiWw9aplIYcLjWQd+dyPSQ7iHKfp KbzMotdsnhEpLmt2ck1qRtxgQl+EY X-Received: by 2002:a1c:7408:0:b0:38e:b7af:c503 with SMTP id p8-20020a1c7408000000b0038eb7afc503mr555998wmc.58.1650404911591; Tue, 19 Apr 2022 14:48:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1gaQ3suhLg9SEod8ZyG+DXS89puSlsOl7NF/Ht6muE6d9H9FpIgRAib149d2EYzLX5Lni2w== X-Received: by 2002:a1c:7408:0:b0:38e:b7af:c503 with SMTP id p8-20020a1c7408000000b0038eb7afc503mr555977wmc.58.1650404911359; Tue, 19 Apr 2022 14:48:31 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id i7-20020a5d5587000000b00207a8cde900sm13333699wrv.19.2022.04.19.14.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 14:48:31 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH v5 1/5] dt-bindings: display: ssd1307fb: Deprecate "-i2c" compatible strings Date: Tue, 19 Apr 2022 23:48:19 +0200 Message-Id: <20220419214824.335075-2-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419214824.335075-1-javierm@redhat.com> References: <20220419214824.335075-1-javierm@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=javierm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Shevchenko , Geert Uytterhoeven , Neil Armstrong , David Airlie , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, Rob Herring , devicetree@vger.kernel.org, Mark Brown , Geert Uytterhoeven , Krzysztof Kozlowski , Chen-Yu Tsai Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current compatible strings for SSD130x I2C controllers contain both an "fb" and "-i2c" suffixes. It seems to indicate that are for a fbdev driver and also that are for devices that can be accessed over an I2C bus. But a DT is supposed to describe the hardware and not Linux implementation details. So let's deprecate those compatible strings and add new ones that only contain the vendor and device name, without any of these suffixes. These will just describe the device and can be matched by both I2C and SPI DRM drivers. The required properties should still be enforced for old ones. While being there, just drop the "sinowealth,sh1106-i2c" compatible string since that was never present in a released Linux version. Signed-off-by: Javier Martinez Canillas Acked-by: Mark Brown Reviewed-by: Geert Uytterhoeven --- (no changes since v3) Changes in v3: - Drop the "sinowealth,sh1106-i2c", wasn't in a released version (Chen-Yu Tsai) - Continue enforcing required properties for deprecated strings (Maxime Ripard) Changes in v2: - Drop the -i2c suffixes from the compatible strings too (Geert Uytterhoeven) .../bindings/display/solomon,ssd1307fb.yaml | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml b/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml index ade61d502edd..7653b6c3fcb6 100644 --- a/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml +++ b/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml @@ -12,12 +12,22 @@ maintainers: properties: compatible: - enum: - - sinowealth,sh1106-i2c - - solomon,ssd1305fb-i2c - - solomon,ssd1306fb-i2c - - solomon,ssd1307fb-i2c - - solomon,ssd1309fb-i2c + oneOf: + # Deprecated compatible strings + - items: + - enum: + - solomon,ssd1305fb-i2c + - solomon,ssd1306fb-i2c + - solomon,ssd1307fb-i2c + - solomon,ssd1309fb-i2c + deprecated: true + - items: + - enum: + - sinowealth,sh1106 + - solomon,ssd1305 + - solomon,ssd1306 + - solomon,ssd1307 + - solomon,ssd1309 reg: maxItems: 1 @@ -136,7 +146,7 @@ allOf: properties: compatible: contains: - const: sinowealth,sh1106-i2c + const: sinowealth,sh1106 then: properties: solomon,dclk-div: @@ -148,7 +158,9 @@ allOf: properties: compatible: contains: - const: solomon,ssd1305fb-i2c + enum: + - solomon,ssd1305-i2c + - solomon,ssd1305 then: properties: solomon,dclk-div: @@ -160,7 +172,9 @@ allOf: properties: compatible: contains: - const: solomon,ssd1306fb-i2c + enum: + - solomon,ssd1306-i2c + - solomon,ssd1306 then: properties: solomon,dclk-div: @@ -172,7 +186,9 @@ allOf: properties: compatible: contains: - const: solomon,ssd1307fb-i2c + enum: + - solomon,ssd1307-i2c + - solomon,ssd1307 then: properties: solomon,dclk-div: @@ -186,7 +202,9 @@ allOf: properties: compatible: contains: - const: solomon,ssd1309fb-i2c + enum: + - solomon,ssd1309-i2c + - solomon,ssd1309 then: properties: solomon,dclk-div: @@ -203,14 +221,14 @@ examples: #size-cells = <0>; ssd1307: oled@3c { - compatible = "solomon,ssd1307fb-i2c"; + compatible = "solomon,ssd1307"; reg = <0x3c>; pwms = <&pwm 4 3000>; reset-gpios = <&gpio2 7>; }; ssd1306: oled@3d { - compatible = "solomon,ssd1306fb-i2c"; + compatible = "solomon,ssd1306"; reg = <0x3c>; pwms = <&pwm 4 3000>; reset-gpios = <&gpio2 7>; From patchwork Tue Apr 19 21:48:20 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: 12819455 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06ABFC433EF for ; Tue, 19 Apr 2022 21:48:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2FDC089D4D; Tue, 19 Apr 2022 21:48:38 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 13DCA89D4D for ; Tue, 19 Apr 2022 21:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650404915; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tOWD5uHxwjIw4P4KTgLk1c7Fc4yJRbBCDK06WY08/Ts=; b=XPXvOcao8ddqjDu7RFQp8BUJSLv3F8jqzUp8NXzanMb+sW+meve3J7JCxMc8jY/k+6PBfr p0w5BBuzC2k1FojAR2Rl+PzSCP/yHzT5/T5bJs95Ie0ZIcOoGWHIhki4KkAHFiNOLBKz0C zwDwQZo+/J7MWct+1Oz4ELl3p3EMRDI= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-265-ApnAtYP8MVO_l3SuMV1c7g-1; Tue, 19 Apr 2022 17:48:34 -0400 X-MC-Unique: ApnAtYP8MVO_l3SuMV1c7g-1 Received: by mail-wm1-f71.google.com with SMTP id y11-20020a7bc18b000000b0038eac019fc0so6503wmi.9 for ; Tue, 19 Apr 2022 14:48:33 -0700 (PDT) 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=tOWD5uHxwjIw4P4KTgLk1c7Fc4yJRbBCDK06WY08/Ts=; b=N0N+bgyubplVDWvcU+UUAS2PTjHkT8zJ9xZCNYl5NYvDjBi27u8XunmHD2EMKxFwXR EF4rPR7JE7vflq/ME7Ovpyd9dqQS0nWvhjtfJsMi+SvXiKDOW2WzW4j0uagaAB1BrYGn ahMWq2yxT4VPUow6+TcngYHzMvIsuSwzktPJxyhwXSDk87W7SxDXB3LOaME73Ezk0rx3 nSYH9MZJHNCd7haWIshUxJxclIo4+fKq8aSl/otm64nqr3r7FSK3eo84RnDQO6RdoXzq m6l4Iywkp4mD3ZsljjUer4hZX/lGCeFs/oIItXmyKFKhoF1JWuKxxtY0AwRripObQHk6 mRHQ== X-Gm-Message-State: AOAM530bs1qqgATCKXLwjoT/O9X1d7KR8tdqUsLGG3QcyGvwub1aocLd wQRvab+A3gF+vtWUu37Ph5xjWpDWOFcmu93l3zlM4gC1yE8v39x0SVLHXhu7ZDVsZMKuesgRHAC 85rnxoz3F/3yhZwwFyCj1PVZeMAdf X-Received: by 2002:a5d:4e4c:0:b0:207:a883:cf3a with SMTP id r12-20020a5d4e4c000000b00207a883cf3amr13440363wrt.534.1650404912799; Tue, 19 Apr 2022 14:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtK/nKbkXvYZOyVAfoxwqPAU4d5VNvQn2+OPjUudoKqzOB3izC+Q3htlXoreIBc6gm8H2luw== X-Received: by 2002:a5d:4e4c:0:b0:207:a883:cf3a with SMTP id r12-20020a5d4e4c000000b00207a883cf3amr13440351wrt.534.1650404912596; Tue, 19 Apr 2022 14:48:32 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id i7-20020a5d5587000000b00207a8cde900sm13333699wrv.19.2022.04.19.14.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 14:48:32 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH v5 2/5] dt-bindings: display: ssd1307fb: Extend schema for SPI controllers Date: Tue, 19 Apr 2022 23:48:20 +0200 Message-Id: <20220419214824.335075-3-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419214824.335075-1-javierm@redhat.com> References: <20220419214824.335075-1-javierm@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=javierm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Shevchenko , Geert Uytterhoeven , Neil Armstrong , David Airlie , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, Rob Herring , devicetree@vger.kernel.org, Mark Brown , Geert Uytterhoeven , Krzysztof Kozlowski , Chen-Yu Tsai Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The Solomon SSD130x OLED displays can either have an I2C or SPI interface, add to the schema the properties and examples for OLED devices under SPI. Signed-off-by: Javier Martinez Canillas Acked-by: Mark Brown Reviewed-by: Geert Uytterhoeven --- (no changes since v4) Changes in v4: - Add a description for the dc-gpios property for SPI (Geert Uytterhoeven) Changes in v3: - Add a comment to the properties required for SPI (Geert Uytterhoeven) Changes in v2: - Don't add compatible strings with an "-spi" suffix (Geert Uytterhoeven) .../bindings/display/solomon,ssd1307fb.yaml | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml b/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml index 7653b6c3fcb6..3fbd87c2c120 100644 --- a/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml +++ b/Documentation/devicetree/bindings/display/solomon,ssd1307fb.yaml @@ -38,9 +38,20 @@ properties: reset-gpios: maxItems: 1 + # Only required for SPI + dc-gpios: + description: + GPIO connected to the controller's D/C# (Data/Command) pin, + that is needed for 4-wire SPI to tell the controller if the + data sent is for a command register or the display data RAM + maxItems: 1 + vbat-supply: description: The supply for VBAT + # Only required for SPI + spi-max-frequency: true + solomon,height: $ref: /schemas/types.yaml#/definitions/uint32 default: 16 @@ -220,14 +231,14 @@ examples: #address-cells = <1>; #size-cells = <0>; - ssd1307: oled@3c { + ssd1307_i2c: oled@3c { compatible = "solomon,ssd1307"; reg = <0x3c>; pwms = <&pwm 4 3000>; reset-gpios = <&gpio2 7>; }; - ssd1306: oled@3d { + ssd1306_i2c: oled@3d { compatible = "solomon,ssd1306"; reg = <0x3c>; pwms = <&pwm 4 3000>; @@ -238,3 +249,30 @@ examples: solomon,lookup-table = /bits/ 8 <0x3f 0x3f 0x3f 0x3f>; }; }; + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + ssd1307_spi: oled@0 { + compatible = "solomon,ssd1307"; + reg = <0x0>; + pwms = <&pwm 4 3000>; + reset-gpios = <&gpio2 7>; + dc-gpios = <&gpio2 8>; + spi-max-frequency = <10000000>; + }; + + ssd1306_spi: oled@1 { + compatible = "solomon,ssd1306"; + reg = <0x1>; + pwms = <&pwm 4 3000>; + reset-gpios = <&gpio2 7>; + dc-gpios = <&gpio2 8>; + spi-max-frequency = <10000000>; + solomon,com-lrremap; + solomon,com-invdir; + solomon,com-offset = <32>; + solomon,lookup-table = /bits/ 8 <0x3f 0x3f 0x3f 0x3f>; + }; + }; From patchwork Tue Apr 19 21:48:21 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: 12819457 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 533C3C433FE for ; Tue, 19 Apr 2022 21:48:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8ED9089DA5; Tue, 19 Apr 2022 21:48:46 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 317BB89D7F for ; Tue, 19 Apr 2022 21:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650404918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gRH7/XsoiL6rwdT/9IqjyebTEGbdFQMOqcD3x5JmGak=; b=bNLji1jRWJXwpOnW9botTBXrgX6UsT6WGS3ImCYX9wisGCTdjmkn6HlPMiTIbnCJ8oKJ+w kBil9kh51TEh7C4z+scjhXjje2yw2KbECG+8oS8t4Xq5x92aoRwhBC27kE0kl8cbCJYc2j QJ5zOyZYNNzxGrVW7EoU1GFtj9aL5IE= 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-576-IGUY9uhyOEW9Yd179mpVkw-1; Tue, 19 Apr 2022 17:48:35 -0400 X-MC-Unique: IGUY9uhyOEW9Yd179mpVkw-1 Received: by mail-wm1-f69.google.com with SMTP id bh11-20020a05600c3d0b00b003928fe7ba07so11789wmb.6 for ; Tue, 19 Apr 2022 14:48:34 -0700 (PDT) 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=gRH7/XsoiL6rwdT/9IqjyebTEGbdFQMOqcD3x5JmGak=; b=xe2KmX2KVlPZsfzFfUQOQxjW67wQzHSXKbkjGlcnFHSkaZ7UgwO/hexx06mn5gcKfB S8zN9WLc+ETBNUkrFyg4WSgnUuDzDS8XfYxQXtJaWKghNXxmqa2UfnJmqtJbujPPSmgJ Z59yMxkLO1EtuGGvCmkIj7QVkODWfcdUrK6lIf3DxSU8EV2D2mH+UD4iSIj4iMwNuxkr Cr8TWYW7c7cw4vtQUAxQsJw8Od0BcIJF++QUw5r5RoJfi+vK8L0tEqfMey3pAkBjvw3j zdSMz7jnFhxi4fLpoyA4C+w7J3KzEBJ5A8uVGDLcyYpuo5eK5X8xQuyC+3ube7ah6P5l fB8Q== X-Gm-Message-State: AOAM533Ja+cO4wyAJTO0fgRelM9K5j7jrEuXbaq9TATVsOUoKRVSXHEv BBx4LrfSC5Hkc9eJP1szbruxSf1JffkotSeLr3lhiHpaTZUV/WUVUutNFuRiAN+yB1+L9Q2FT4V w1iluPhwGwhkPUuBqBXSCqmlzvZ1q X-Received: by 2002:a5d:50ce:0:b0:207:bb5e:ad27 with SMTP id f14-20020a5d50ce000000b00207bb5ead27mr13329520wrt.84.1650404913891; Tue, 19 Apr 2022 14:48:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGiUWXSsU4DetoBt3ut0OT5Db3AG0bTsAxOWQgbdm53BhlvdW/DOLJi54rlv1isl8O0rnW9Q== X-Received: by 2002:a5d:50ce:0:b0:207:bb5e:ad27 with SMTP id f14-20020a5d50ce000000b00207bb5ead27mr13329512wrt.84.1650404913690; Tue, 19 Apr 2022 14:48:33 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id i7-20020a5d5587000000b00207a8cde900sm13333699wrv.19.2022.04.19.14.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 14:48:33 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH v5 3/5] drm/solomon: Add ssd130x new compatible strings and deprecate old ones. Date: Tue, 19 Apr 2022 23:48:21 +0200 Message-Id: <20220419214824.335075-4-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419214824.335075-1-javierm@redhat.com> References: <20220419214824.335075-1-javierm@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=javierm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Shevchenko , Geert Uytterhoeven , Neil Armstrong , David Airlie , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, Mark Brown , Geert Uytterhoeven , Chen-Yu Tsai Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The current compatible strings for SSD130x I2C controllers contain an "fb" and "-i2c" suffixes. These have been deprecated and more correct ones were added, that don't encode a subsystem or bus used to interface the devices. Signed-off-by: Javier Martinez Canillas Acked-by: Mark Brown Reviewed-by: Geert Uytterhoeven --- (no changes since v3) Changes in v3: - Drop the "sinowealth,sh1106-i2c", wasn't in a released version (Chen-Yu Tsai) Changes in v2: - Use the compatible strings that don't have "fb-i2c" (Geert Uytterhoeven). drivers/gpu/drm/solomon/ssd130x-i2c.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/solomon/ssd130x-i2c.c b/drivers/gpu/drm/solomon/ssd130x-i2c.c index d099b241dd3f..45867ef2bc8b 100644 --- a/drivers/gpu/drm/solomon/ssd130x-i2c.c +++ b/drivers/gpu/drm/solomon/ssd130x-i2c.c @@ -88,9 +88,26 @@ static struct ssd130x_deviceinfo ssd130x_ssd1309_deviceinfo = { static const struct of_device_id ssd130x_of_match[] = { { - .compatible = "sinowealth,sh1106-i2c", + .compatible = "sinowealth,sh1106", .data = &ssd130x_sh1106_deviceinfo, }, + { + .compatible = "solomon,ssd1305", + .data = &ssd130x_ssd1305_deviceinfo, + }, + { + .compatible = "solomon,ssd1306", + .data = &ssd130x_ssd1306_deviceinfo, + }, + { + .compatible = "solomon,ssd1307", + .data = &ssd130x_ssd1307_deviceinfo, + }, + { + .compatible = "solomon,ssd1309", + .data = &ssd130x_ssd1309_deviceinfo, + }, + /* Deprecated but kept for backward compatibility */ { .compatible = "solomon,ssd1305fb-i2c", .data = &ssd130x_ssd1305_deviceinfo, From patchwork Tue Apr 19 21:48:22 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: 12819456 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE1E0C433FE for ; Tue, 19 Apr 2022 21:48:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B0E489D8D; Tue, 19 Apr 2022 21:48:43 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4A07389D58 for ; Tue, 19 Apr 2022 21:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650404917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xVLLH9C759FHMpXQwwKHJScD/DCbIHfB8SwIPo2nJQ0=; b=axsYuzWvKS/rhZKJkaJCETLkGdBz0WXULc0aVsM4WlA+lFX49jmepUKgR6BQcM+O8mWFf6 d5ZooDYjN1Ir+us9TN/IQgh4WH/sg6QzrLwbOseKOv4sNo95g/uHf8GFP3a0+7wXKfkeHm x+a1mxnFc/Vkg31r0Y+2Tg5B8PKjwmM= 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-435-P5ERpEGBMp-OhnLjPhHPaA-1; Tue, 19 Apr 2022 17:48:36 -0400 X-MC-Unique: P5ERpEGBMp-OhnLjPhHPaA-1 Received: by mail-wm1-f69.google.com with SMTP id bh11-20020a05600c3d0b00b003928fe7ba07so11804wmb.6 for ; Tue, 19 Apr 2022 14:48:36 -0700 (PDT) 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=xVLLH9C759FHMpXQwwKHJScD/DCbIHfB8SwIPo2nJQ0=; b=Wz7cZZ3RolN7LoolupoTWxIrAKn8kGgEaJRWrMxwMez8jET8uudtFqWIxxf2MmxvpW Ue3RJlUBn8caDNnYZ/3qv07MOer/NXQP1DrB0I96IU1w3hbdnOtBRc7yUpuHUaKCSUhr k9cO2i/V6uWdbUe1umDEZ4PjWulShzZ6xcIfqLLBOaeUwTThIaVe4Pucvw2yYu5Fi/jo +w3z6yekKR5Gi97LyI7xFyfLH/ylicUs10htVYk6WY68TFA9ROl65CKJ6DySR0nwDNl0 kZebXwZya/GUHG/R95YNCKn6ww+thFeF2GX/6iZ9LJuyPIlwFNfSxIIH9gc71DqlUd9F le+Q== X-Gm-Message-State: AOAM533JgoCtIFpv9v2vk6PHN1Y7ekBBe/LJzOUH7NilOMLZjZ1kz5o1 TC/Y4C0bih4WX6jplJNRczskWeTmf3CVlWLwKMfkVzUysRypAb7Q9+NhMo/dOp1auNrFdzNRjDp eychZP1f3M7zlIA6t0VpV/qBwAZMk X-Received: by 2002:a5d:588b:0:b0:20a:9570:de77 with SMTP id n11-20020a5d588b000000b0020a9570de77mr9040554wrf.27.1650404915022; Tue, 19 Apr 2022 14:48:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzatn+dYelnkGoOsI6bvv8PKpP08+CPJhO0Hu57/jsMjYH4dmAtg8p9Rd0YiNjJRCa9cn9xbg== X-Received: by 2002:a5d:588b:0:b0:20a:9570:de77 with SMTP id n11-20020a5d588b000000b0020a9570de77mr9040539wrf.27.1650404914803; Tue, 19 Apr 2022 14:48:34 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id i7-20020a5d5587000000b00207a8cde900sm13333699wrv.19.2022.04.19.14.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 14:48:34 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH v5 4/5] drm/solomon: Move device info from ssd130x-i2c to the core driver Date: Tue, 19 Apr 2022 23:48:22 +0200 Message-Id: <20220419214824.335075-5-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419214824.335075-1-javierm@redhat.com> References: <20220419214824.335075-1-javierm@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=javierm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Shevchenko , Geert Uytterhoeven , Neil Armstrong , David Airlie , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, Mark Brown , Geert Uytterhoeven , Chen-Yu Tsai Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" These are declared in the ssd130x-i2c transport driver but the information is not I2C specific, and could be used by other SSD130x transport drivers. Move them to the ssd130x core driver and just set the OF device entries to an ID that could be used to lookup the correct device info from an array. While being there, also move the SSD130X_DATA and SSD130X_COMMAND control bytes. Since even though they are used by the I2C interface, they could also be useful for other transport protocols such as SPI. Suggested-by: Chen-Yu Tsai Signed-off-by: Javier Martinez Canillas Acked-by: Mark Brown Reviewed-by: Geert Uytterhoeven --- Changes in v5: - Remove unnecessary blank line added by mistake in v4 (Andy Shevchenko). Changes in v4: - Export ssd13x_variants array using EXPORT_SYMBOL_NS_GPL() (Andy Shevchenko) - Use MODULE_IMPORT_NS(DRM_SSD130X) in the ssd130x-i2c driver (Andy Shevchenko) Changes in v3: - s/it/they in the commit description (Geert Uytterhoeven) - Drop unnecessary blank line (Geert Uytterhoeven) - Export variants array and use &info[ID] in device table (Andy Shevchenko) Changes in v2: - Drop ssd13x_variant_to_info() and just use the array index (Neil Armstrong). drivers/gpu/drm/solomon/ssd130x-i2c.c | 52 ++++++--------------------- drivers/gpu/drm/solomon/ssd130x.c | 35 ++++++++++++++++-- drivers/gpu/drm/solomon/ssd130x.h | 14 ++++++++ 3 files changed, 56 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/solomon/ssd130x-i2c.c b/drivers/gpu/drm/solomon/ssd130x-i2c.c index 45867ef2bc8b..d6835ec71c39 100644 --- a/drivers/gpu/drm/solomon/ssd130x-i2c.c +++ b/drivers/gpu/drm/solomon/ssd130x-i2c.c @@ -53,76 +53,43 @@ static void ssd130x_i2c_shutdown(struct i2c_client *client) ssd130x_shutdown(ssd130x); } -static struct ssd130x_deviceinfo ssd130x_sh1106_deviceinfo = { - .default_vcomh = 0x40, - .default_dclk_div = 1, - .default_dclk_frq = 5, - .page_mode_only = 1, -}; - -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 = "sinowealth,sh1106", - .data = &ssd130x_sh1106_deviceinfo, + .data = &ssd130x_variants[SH1106_ID], }, { .compatible = "solomon,ssd1305", - .data = &ssd130x_ssd1305_deviceinfo, + .data = &ssd130x_variants[SSD1305_ID], }, { .compatible = "solomon,ssd1306", - .data = &ssd130x_ssd1306_deviceinfo, + .data = &ssd130x_variants[SSD1306_ID], }, { .compatible = "solomon,ssd1307", - .data = &ssd130x_ssd1307_deviceinfo, + .data = &ssd130x_variants[SSD1307_ID], }, { .compatible = "solomon,ssd1309", - .data = &ssd130x_ssd1309_deviceinfo, + .data = &ssd130x_variants[SSD1309_ID], }, /* Deprecated but kept for backward compatibility */ { .compatible = "solomon,ssd1305fb-i2c", - .data = &ssd130x_ssd1305_deviceinfo, + .data = &ssd130x_variants[SSD1305_ID], }, { .compatible = "solomon,ssd1306fb-i2c", - .data = &ssd130x_ssd1306_deviceinfo, + .data = &ssd130x_variants[SSD1306_ID], }, { .compatible = "solomon,ssd1307fb-i2c", - .data = &ssd130x_ssd1307_deviceinfo, + .data = &ssd130x_variants[SSD1307_ID], }, { .compatible = "solomon,ssd1309fb-i2c", - .data = &ssd130x_ssd1309_deviceinfo, + .data = &ssd130x_variants[SSD1309_ID], }, { /* sentinel */ } }; @@ -142,3 +109,4 @@ module_i2c_driver(ssd130x_i2c_driver); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_AUTHOR("Javier Martinez Canillas "); MODULE_LICENSE("GPL v2"); +MODULE_IMPORT_NS(DRM_SSD130X); diff --git a/drivers/gpu/drm/solomon/ssd130x.c b/drivers/gpu/drm/solomon/ssd130x.c index a7e784518c69..ba2de93d00f0 100644 --- a/drivers/gpu/drm/solomon/ssd130x.c +++ b/drivers/gpu/drm/solomon/ssd130x.c @@ -39,9 +39,6 @@ #define DRIVER_MAJOR 1 #define DRIVER_MINOR 0 -#define SSD130X_DATA 0x40 -#define SSD130X_COMMAND 0x80 - #define SSD130X_PAGE_COL_START_LOW 0x00 #define SSD130X_PAGE_COL_START_HIGH 0x10 #define SSD130X_SET_ADDRESS_MODE 0x20 @@ -94,6 +91,38 @@ #define MAX_CONTRAST 255 +const struct ssd130x_deviceinfo ssd130x_variants[] = { + [SH1106_ID] = { + .default_vcomh = 0x40, + .default_dclk_div = 1, + .default_dclk_frq = 5, + .page_mode_only = 1, + }, + [SSD1305_ID] = { + .default_vcomh = 0x34, + .default_dclk_div = 1, + .default_dclk_frq = 7, + }, + [SSD1306_ID] = { + .default_vcomh = 0x20, + .default_dclk_div = 1, + .default_dclk_frq = 8, + .need_chargepump = 1, + }, + [SSD1307_ID] = { + .default_vcomh = 0x20, + .default_dclk_div = 2, + .default_dclk_frq = 12, + .need_pwm = 1, + }, + [SSD1309_ID] = { + .default_vcomh = 0x34, + .default_dclk_div = 1, + .default_dclk_frq = 10, + } +}; +EXPORT_SYMBOL_NS_GPL(ssd130x_variants, DRM_SSD130X); + static inline struct ssd130x_device *drm_to_ssd130x(struct drm_device *drm) { return container_of(drm, struct ssd130x_device, drm); diff --git a/drivers/gpu/drm/solomon/ssd130x.h b/drivers/gpu/drm/solomon/ssd130x.h index f5b062576fdf..d14f78c2eb07 100644 --- a/drivers/gpu/drm/solomon/ssd130x.h +++ b/drivers/gpu/drm/solomon/ssd130x.h @@ -18,6 +18,18 @@ #include +#define SSD130X_DATA 0x40 +#define SSD130X_COMMAND 0x80 + +enum ssd130x_variants { + SH1106_ID, + SSD1305_ID, + SSD1306_ID, + SSD1307_ID, + SSD1309_ID, + NR_SSD130X_VARIANTS +}; + struct ssd130x_deviceinfo { u32 default_vcomh; u32 default_dclk_div; @@ -71,6 +83,8 @@ struct ssd130x_device { u8 page_end; }; +extern const struct ssd130x_deviceinfo ssd130x_variants[]; + struct ssd130x_device *ssd130x_probe(struct device *dev, struct regmap *regmap); int ssd130x_remove(struct ssd130x_device *ssd130x); void ssd130x_shutdown(struct ssd130x_device *ssd130x); From patchwork Tue Apr 19 21:48:23 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: 12819458 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED469C4332F for ; Tue, 19 Apr 2022 21:48:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0862B89DDD; Tue, 19 Apr 2022 21:48:47 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8142689D66 for ; Tue, 19 Apr 2022 21:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650404918; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7BABEWfImdlFz6h6c/n67mZugkGxrntzCJH3oamrW2E=; b=CG+ldWJ/zbOeiAKgvJG1qVPH9kk4Yf6dnefNIIhbS8Le2rR9WxQQiCLCOSFE8APQRx3/nI e/JJQU7PFLix3xTK+jbGifPY0nM8ZKBFSJH3sO30T+tnILgRYh5m0EP2YuJat1WR5jS1RR /SGjkbziUsYN726AXF8bqVpr73kMgo0= 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-22-jCB13JLzPcqzloC9LiZ1PQ-1; Tue, 19 Apr 2022 17:48:37 -0400 X-MC-Unique: jCB13JLzPcqzloC9LiZ1PQ-1 Received: by mail-wm1-f69.google.com with SMTP id b12-20020a05600c4e0c00b003914432b970so8311wmq.8 for ; Tue, 19 Apr 2022 14:48:37 -0700 (PDT) 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=7BABEWfImdlFz6h6c/n67mZugkGxrntzCJH3oamrW2E=; b=0D2iljeETaoMSnvOwfpfE8rYpSD8sSnXJIbkdr5V433fHJCZwx/zpSxmGnJrexpptD VnWzEwUB1fGdd/FfD0uA/c8s8/MWGygtB8RbFt5RbbulVb2rrTRkaaIiSG5o0t5yDn3A BBxVH8JZ33rUIrG131aIYeKIr5OpYyMGMRKQXGwedtW4aV3H+JQ472c1kVdOHxmncC05 4LLH6rVI6QIC1yDrpUju+g+zzQfN8caDDZYg/PVus4MXX4jAv0Sr4vCm+sgA/4b6i3Mz DlGrAycyLmdzL4V6pPhH5ajNupJ44nRg5/zarG0y8fUbqkZkBVyAbehdS46JDYKtPldB frZA== X-Gm-Message-State: AOAM533EDgfmMKXdaHpQDWVFUoJRrFYv64IIDFNVH39e9gphXLkeTeuK IYB+UqtQqgzp5OFTvLvu0AlV/wHA7Fm9qJD6YwxPP9Yk7spg/4jz4YV7XX9CCIu8br/5p1zfgbC GgN4BT3m92QOnrh7yorz9PzjkxR2b X-Received: by 2002:a05:6000:1f83:b0:207:a4d8:5173 with SMTP id bw3-20020a0560001f8300b00207a4d85173mr13509735wrb.556.1650404916140; Tue, 19 Apr 2022 14:48:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF2skj/V3EtDOGqDPbahJ0c56qmLcV68R71JLptBPDt4NcJfm0DW9YIY+OPcNJy8tLV2Jqxw== X-Received: by 2002:a05:6000:1f83:b0:207:a4d8:5173 with SMTP id bw3-20020a0560001f8300b00207a4d85173mr13509714wrb.556.1650404915863; Tue, 19 Apr 2022 14:48:35 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id i7-20020a5d5587000000b00207a8cde900sm13333699wrv.19.2022.04.19.14.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 14:48:35 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH v5 5/5] drm/solomon: Add SSD130x OLED displays SPI support Date: Tue, 19 Apr 2022 23:48:23 +0200 Message-Id: <20220419214824.335075-6-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419214824.335075-1-javierm@redhat.com> References: <20220419214824.335075-1-javierm@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=javierm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andy Shevchenko , Geert Uytterhoeven , Neil Armstrong , David Airlie , YueHaibing , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, Chen-Yu Tsai , Mark Brown , Geert Uytterhoeven , Maxime Ripard , Chen-Yu Tsai Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. There is a difference in the communication protocol when using 4-wire SPI instead of I2C. For the latter, a control byte that contains a D/C# field has to be sent. This field tells the controller whether the data has to be written to the command register or to the graphics display data memory. But for 4-wire SPI that control byte is not used, instead a real D/C# line must be pulled HIGH for commands data and LOW for graphics display data. For this reason the standard SPI regmap can't be used and a custom .write bus handler is needed. Signed-off-by: Javier Martinez Canillas Acked-by: Mark Brown Reviewed-by: Geert Uytterhoeven --- Changes in v5: - Remove cast by just using u8 *reg instead of void *data (Geert Uytterhoeven). - Add Geert Uytterhoeven's Reviewed-by tag to patch 5/5. Changes in v4: - Use MODULE_IMPORT_NS(DRM_SSD130X) in the ssd130x-spi driver (Andy Shevchenko) Changes in v3: - Drop ssd130x_spi_get_dc() helper and open code it (Geert Uytterhoeven) - Export variants array and use &info[ID] in device table (Andy Shevchenko) Changes in v2: - Add the same compatible strings than I2C (Geert Uytterhoeven) drivers/gpu/drm/solomon/Kconfig | 9 ++ drivers/gpu/drm/solomon/Makefile | 1 + drivers/gpu/drm/solomon/ssd130x-spi.c | 178 ++++++++++++++++++++++++++ 3 files changed, 188 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 8c0a0c788385..e170716d976b 100644 --- a/drivers/gpu/drm/solomon/Kconfig +++ b/drivers/gpu/drm/solomon/Kconfig @@ -20,3 +20,12 @@ config DRM_SSD130X_I2C 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 + 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..43722adab1f8 --- /dev/null +++ b/drivers/gpu/drm/solomon/ssd130x-spi.c @@ -0,0 +1,178 @@ +// 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)" + +struct ssd130x_spi_transport { + struct spi_device *spi; + struct gpio_desc *dc; +}; + +static const struct regmap_config ssd130x_spi_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +/* + * The regmap bus .write handler, it is just a wrapper around spi_write() + * but toggling the Data/Command control pin (D/C#). Since for 4-wire SPI + * a D/C# pin is used, in contrast with I2C where a control byte is sent, + * prior to every data byte, that contains a bit with the D/C# value. + * + * These control bytes are considered registers by the ssd130x core driver + * and can be used by the ssd130x SPI driver to determine if the data sent + * is for a command register or for the Graphic Display Data RAM (GDDRAM). + */ +static int ssd130x_spi_write(void *context, const void *data, size_t count) +{ + struct ssd130x_spi_transport *t = context; + struct spi_device *spi = t->spi; + const u8 *reg = data; + + if (*reg == SSD130X_COMMAND) + gpiod_set_value_cansleep(t->dc, 0); + + if (*reg == SSD130X_DATA) + gpiod_set_value_cansleep(t->dc, 1); + + /* Remove control byte since is not used in a 4-wire SPI interface */ + return spi_write(spi, reg + 1, count - 1); +} + +/* The ssd130x driver does not read registers but regmap expects a .read */ +static int ssd130x_spi_read(void *context, const void *reg, size_t reg_size, + void *val, size_t val_size) +{ + return -EOPNOTSUPP; +} + +/* + * A custom bus is needed due the special write that toggles a D/C# pin, + * another option could be to just have a .reg_write() callback but that + * will prevent to do data writes in bulk. + * + * Once the regmap API is extended to support defining a bulk write handler + * in the struct regmap_config, this can be simplified and the bus dropped. + */ +static struct regmap_bus regmap_ssd130x_spi_bus = { + .write = ssd130x_spi_write, + .read = ssd130x_spi_read, +}; + +static int ssd130x_spi_probe(struct spi_device *spi) +{ + struct ssd130x_spi_transport *t; + struct ssd130x_device *ssd130x; + struct regmap *regmap; + struct gpio_desc *dc; + struct device *dev = &spi->dev; + + dc = devm_gpiod_get(dev, "dc", GPIOD_OUT_LOW); + if (IS_ERR(dc)) + return dev_err_probe(dev, PTR_ERR(dc), + "Failed to get dc gpio\n"); + + t = devm_kzalloc(dev, sizeof(*t), GFP_KERNEL); + if (!t) + return dev_err_probe(dev, -ENOMEM, + "Failed to allocate SPI transport data\n"); + + t->spi = spi; + t->dc = dc; + + regmap = devm_regmap_init(dev, ®map_ssd130x_spi_bus, t, + &ssd130x_spi_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + ssd130x = ssd130x_probe(dev, regmap); + if (IS_ERR(ssd130x)) + return PTR_ERR(ssd130x); + + spi_set_drvdata(spi, ssd130x); + + return 0; +} + +static void ssd130x_spi_remove(struct spi_device *spi) +{ + struct ssd130x_device *ssd130x = spi_get_drvdata(spi); + + ssd130x_remove(ssd130x); +} + +static void ssd130x_spi_shutdown(struct spi_device *spi) +{ + struct ssd130x_device *ssd130x = spi_get_drvdata(spi); + + ssd130x_shutdown(ssd130x); +} + +static const struct of_device_id ssd130x_of_match[] = { + { + .compatible = "sinowealth,sh1106", + .data = &ssd130x_variants[SH1106_ID], + }, + { + .compatible = "solomon,ssd1305", + .data = &ssd130x_variants[SSD1305_ID], + }, + { + .compatible = "solomon,ssd1306", + .data = &ssd130x_variants[SSD1306_ID], + }, + { + .compatible = "solomon,ssd1307", + .data = &ssd130x_variants[SSD1307_ID], + }, + { + .compatible = "solomon,ssd1309", + .data = &ssd130x_variants[SSD1309_ID], + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, ssd130x_of_match); + +/* + * The SPI core always reports a MODALIAS uevent of the form "spi:", even + * if the device was registered via OF. This means that the module will not be + * auto loaded, unless it contains an alias that matches the MODALIAS reported. + * + * To workaround this issue, add a SPI device ID table. Even when this should + * not be needed for this driver to match the registered SPI devices. + */ +static const struct spi_device_id ssd130x_spi_table[] = { + { "sh1106", SH1106_ID }, + { "ssd1305", SSD1305_ID }, + { "ssd1306", SSD1306_ID }, + { "ssd1307", SSD1307_ID }, + { "ssd1309", SSD1309_ID }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(spi, ssd130x_spi_table); + +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"); +MODULE_IMPORT_NS(DRM_SSD130X);