From patchwork Thu Jul 24 16:17:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 34235 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6EA6C235A9 for ; Thu, 24 Jul 2014 16:18:08 +0000 (UTC) Received: by mail-oi0-f70.google.com with SMTP id u20sf11419118oif.5 for ; Thu, 24 Jul 2014 09:18:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Oe4GtxFxJSQ5GAwYVOEzGq7IfXl43TQbPojUo699BQ8=; b=EYLOhpyCTjfS+3S6skiOYmazv2FhDg50VpYzxpdhwu094+Vkz/MiMtsTJMjjXWCNha D2Nj6Qawh2PH8ILBt6EuwBVewv1OzDC7LK8aNURh+agiVchWsr3STfRgI//K5NPmRrgk vgy57EUj+kLvW3uTqRjlsgJHXGATZ3K0mIgrGQwQMMV0sT1MQMq+jYZWkOZjBY05HyN5 dTeKbuWO96YsjfPjqZJYtpxUc5PtbYzwI5zfzTXMZJSwoQ5kAn8C8InEr0gSnqfyGrPD 5ZvP+27JCr5p0MBTIMqlZs8kuXqt7xAjNfkqbzN2yZg0Yl34Yelv637er6wPzPlgwRYj 5gAA== X-Gm-Message-State: ALoCoQlSo0FNfdIIfhXApIy2opTXTrf/KE4RD279y+QHtFy09EGP1j4CpHXAXCo0IpHQ7n5hg86U X-Received: by 10.182.104.68 with SMTP id gc4mr4947321obb.40.1406218687970; Thu, 24 Jul 2014 09:18:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.50.154.101 with SMTP id vn5ls1291382igb.14.gmail; Thu, 24 Jul 2014 09:18:07 -0700 (PDT) X-Received: by 10.68.197.40 with SMTP id ir8mr11712213pbc.139.1406218687789; Thu, 24 Jul 2014 09:18:07 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id p47si18536806yhk.96.2014.07.24.09.18.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Jul 2014 09:18:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hu12so5230757vcb.6 for ; Thu, 24 Jul 2014 09:18:07 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr13694567vca.45.1406218687111; Thu, 24 Jul 2014 09:18:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp378303vcb; Thu, 24 Jul 2014 09:18:06 -0700 (PDT) X-Received: by 10.68.57.175 with SMTP id j15mr4039197pbq.164.1406218685897; Thu, 24 Jul 2014 09:18:05 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id br8si3250254pdb.114.2014.07.24.09.18.04 for ; Thu, 24 Jul 2014 09:18:05 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933818AbaGXQSB (ORCPT + 13 others); Thu, 24 Jul 2014 12:18:01 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:40531 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933693AbaGXQR7 (ORCPT ); Thu, 24 Jul 2014 12:17:59 -0400 Received: by mail-wg0-f49.google.com with SMTP id k14so2958403wgh.8 for ; Thu, 24 Jul 2014 09:17:58 -0700 (PDT) X-Received: by 10.180.211.237 with SMTP id nf13mr36622669wic.47.1406218678534; Thu, 24 Jul 2014 09:17:58 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id v17sm17073595wjr.33.2014.07.24.09.17.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jul 2014 09:17:57 -0700 (PDT) From: Linus Walleij To: Jingoo Han , Bryan Wu , Lee Jones , linux-kernel@vger.kernel.org Cc: Linus Walleij Subject: [PATCH v3] fb: backlight: add driver for iPAQ micro backlight Date: Thu, 24 Jul 2014 18:17:49 +0200 Message-Id: <1406218669-2438-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This adds a driver for the backlight controlled by the microcontroller on the Compaq iPAQ series of handheld computers: h3100, h3600 and h3700. Acked-by: Jingoo Han Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Order includes alphabetically - Use explicit GPL v2 license ChangeLog v1->v2: - Add a comment to clarify message format - Coding format and style fixes - Drop driver announce boilerplate - Drop empty remove() function --- drivers/video/backlight/Kconfig | 9 ++++ drivers/video/backlight/Makefile | 1 + drivers/video/backlight/ipaq_micro_bl.c | 83 +++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 drivers/video/backlight/ipaq_micro_bl.c diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 5d449059a556..cc153f55d9f9 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -207,6 +207,15 @@ config BACKLIGHT_GENERIC known as the Corgi backlight driver. If you have a Sharp Zaurus SL-C7xx, SL-Cxx00 or SL-6000x say y. +config BACKLIGHT_IPAQ_MICRO + tristate "iPAQ microcontroller backlight driver" + depends on MFD_IPAQ_MICRO + default y + help + Say y to enable the backlight driver for Compaq iPAQ handheld + computers. Say yes if you have one of the h3100/h3600/h3700 + machines. + config BACKLIGHT_LM3533 tristate "Backlight Driver for LM3533" depends on BACKLIGHT_CLASS_DEVICE diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index bb820024f346..a9ea34a39cad 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -36,6 +36,7 @@ obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o obj-$(CONFIG_BACKLIGHT_GPIO) += gpio_backlight.o obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o +obj-$(CONFIG_BACKLIGHT_IPAQ_MICRO) += ipaq_micro_bl.o obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o obj-$(CONFIG_BACKLIGHT_LM3630A) += lm3630a_bl.o obj-$(CONFIG_BACKLIGHT_LM3639) += lm3639_bl.o diff --git a/drivers/video/backlight/ipaq_micro_bl.c b/drivers/video/backlight/ipaq_micro_bl.c new file mode 100644 index 000000000000..feab29c6b255 --- /dev/null +++ b/drivers/video/backlight/ipaq_micro_bl.c @@ -0,0 +1,83 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * iPAQ microcontroller backlight support + * Author : Linus Walleij + */ + +#include +#include +#include +#include +#include +#include +#include + +static int micro_bl_update_status(struct backlight_device *bd) +{ + struct ipaq_micro *micro = dev_get_drvdata(&bd->dev); + int intensity = bd->props.brightness; + struct ipaq_micro_msg msg = { + .id = MSG_BACKLIGHT, + .tx_len = 3, + }; + + if (bd->props.power != FB_BLANK_UNBLANK) + intensity = 0; + if (bd->props.state & (BL_CORE_FBBLANK | BL_CORE_SUSPENDED)) + intensity = 0; + + /* + * Message format: + * Byte 0: backlight instance (usually 1) + * Byte 1: on/off + * Byte 2: intensity, 0-255 + */ + msg.tx_data[0] = 0x01; + msg.tx_data[1] = intensity > 0 ? 1 : 0; + msg.tx_data[2] = intensity; + return ipaq_micro_tx_msg_sync(micro, &msg); +} + +static const struct backlight_ops micro_bl_ops = { + .options = BL_CORE_SUSPENDRESUME, + .update_status = micro_bl_update_status, +}; + +static struct backlight_properties micro_bl_props = { + .type = BACKLIGHT_RAW, + .max_brightness = 255, + .power = FB_BLANK_UNBLANK, + .brightness = 64, +}; + +static int micro_backlight_probe(struct platform_device *pdev) +{ + struct backlight_device *bd; + struct ipaq_micro *micro = dev_get_drvdata(pdev->dev.parent); + + bd = devm_backlight_device_register(&pdev->dev, "ipaq-micro-backlight", + &pdev->dev, micro, µ_bl_ops, + µ_bl_props); + if (IS_ERR(bd)) + return PTR_ERR(bd); + + platform_set_drvdata(pdev, bd); + backlight_update_status(bd); + + return 0; +} + +struct platform_driver micro_backlight_device_driver = { + .driver = { + .name = "ipaq-micro-backlight", + }, + .probe = micro_backlight_probe, +}; +module_platform_driver(micro_backlight_device_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("driver for iPAQ Atmel micro backlight"); +MODULE_ALIAS("platform:ipaq-micro-backlight");