From patchwork Wed Jul 23 09:04:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 34123 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5C31D20672 for ; Wed, 23 Jul 2014 09:04:24 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id l4sf664176lbv.1 for ; Wed, 23 Jul 2014 02:04:23 -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=G0D3H1w2hka3m6pidnDX5DoYt1kPl+RDE4O6GsJctM8=; b=S7jfBBCbwQUhyDDomE50w/Mc6A3Hxs1qrNcIVST+Y+0Jpx4bcbh/TBA7zMv69m1hyW GBjN3APHjXpa5pM++N7yxaiA/XJrHAUKmxCnEfqUuaYuR8GV3W4A9NUhYvpACE+azLI3 tk4eEZevJLRgMTBp/N7LgSNcTAw7mg/rC7vzLk6gd+Buxa+0tCcqHeA9EN3+DphdmsVo 0eVVMTX08l+QMZutW8KA1BjFuNkzKIPpnRo7UpmYMS+hiIjpZRD8ia6CRp6bwEoRagJO 9SavgECsU2gZ0RL+gkwK612HdSIhlBdHRkwDlo+6iHTxZpA4LPBaoLcd3nX2YMjCWRMO JVOA== X-Gm-Message-State: ALoCoQmGrIfc+fMQpwRy2XXzwEy6ocAkYJ5b56Y23LUN4N8bKY2kui8a7xdwMUqV8eZkSeXN3ksU X-Received: by 10.180.85.39 with SMTP id e7mr2441064wiz.0.1406106262947; Wed, 23 Jul 2014 02:04:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.36 with SMTP id b33ls279302qgd.68.gmail; Wed, 23 Jul 2014 02:04:22 -0700 (PDT) X-Received: by 10.52.53.33 with SMTP id y1mr26974938vdo.31.1406106262743; Wed, 23 Jul 2014 02:04:22 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id o11si1352824vdh.16.2014.07.23.02.04.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 02:04:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf12so1525051vcb.40 for ; Wed, 23 Jul 2014 02:04:22 -0700 (PDT) X-Received: by 10.52.129.200 with SMTP id ny8mr10680764vdb.27.1406106262668; Wed, 23 Jul 2014 02:04:22 -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 tc5csp262340vcb; Wed, 23 Jul 2014 02:04:22 -0700 (PDT) X-Received: by 10.66.251.200 with SMTP id zm8mr20586287pac.97.1406106261730; Wed, 23 Jul 2014 02:04:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c17si922684pdm.18.2014.07.23.02.04.20 for ; Wed, 23 Jul 2014 02:04:21 -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 S1757595AbaGWJES (ORCPT + 13 others); Wed, 23 Jul 2014 05:04:18 -0400 Received: from mail-we0-f173.google.com ([74.125.82.173]:42129 "EHLO mail-we0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757374AbaGWJEO (ORCPT ); Wed, 23 Jul 2014 05:04:14 -0400 Received: by mail-we0-f173.google.com with SMTP id q58so850953wes.18 for ; Wed, 23 Jul 2014 02:04:09 -0700 (PDT) X-Received: by 10.180.82.166 with SMTP id j6mr22572435wiy.71.1406106248834; Wed, 23 Jul 2014 02:04:08 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id w5sm6986485wif.3.2014.07.23.02.04.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jul 2014 02:04:07 -0700 (PDT) From: Linus Walleij To: Jingoo Han , Bryan Wu , Lee Jones , linux-kernel@vger.kernel.org Cc: Linus Walleij Subject: [PATCH v2] fb: backlight: add driver for iPAQ micro backlight Date: Wed, 23 Jul 2014 11:04:03 +0200 Message-Id: <1406106243-20498-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.181 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. Signed-off-by: Linus Walleij Acked-by: Jingoo Han --- 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..88a3816da31e --- /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"); +MODULE_DESCRIPTION("driver for iPAQ Atmel micro backlight"); +MODULE_ALIAS("platform:ipaq-micro-backlight");