From patchwork Wed Apr 16 17:17:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Yanovich X-Patchwork-Id: 4003331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F111D9F2CC for ; Wed, 16 Apr 2014 17:24:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B83720379 for ; Wed, 16 Apr 2014 17:24:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52E4A20375 for ; Wed, 16 Apr 2014 17:24:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WaTWO-0002wG-Ay; Wed, 16 Apr 2014 17:21:16 +0000 Received: from mail-la0-x229.google.com ([2a00:1450:4010:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WaTV4-0007Gd-Dv for linux-arm-kernel@lists.infradead.org; Wed, 16 Apr 2014 17:19:56 +0000 Received: by mail-la0-f41.google.com with SMTP id gl10so8600244lab.28 for ; Wed, 16 Apr 2014 10:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fl++KCRIVrypBRSDHYvnta9nV+MBaJTdtT4nw1+tswI=; b=WhT9NTpUWgry4lWWOc1oEfpEGVSRQ9q8dCP7BUpm1o+v9PL9zCC2/oU65eqxtJHv33 LNnqQjsuMhpTH3F62B6r9PBxwRvegY48GBEFfiji5OEwM1ULu5q5VsFSTQcf7IJk9Q1Z rAfvyt45vOCDaEsX77j4gHm4z23TjEhoYD/71H3ui6aaZ9LKltiYpWS55gZMIveZDgA/ q3FkWbBaQh5g0PMUueKTlYL9Hb3TRpyrEqIY9a4FxXoVPFN5zuiHEwS4JbiSpdUYX7Ki YvnrL8fpsSFdk3R7HdCgSlMuUlSeE0v0zoXwrZC5JAWWjQ07pTCOLjeX8MODlsGpEBDa sjmA== X-Received: by 10.112.141.10 with SMTP id rk10mr3618457lbb.26.1397668772367; Wed, 16 Apr 2014 10:19:32 -0700 (PDT) Received: from host5.omatika.ru (0893675324.static.corbina.ru. [95.31.1.192]) by mx.google.com with ESMTPSA id q4sm21186297lbh.20.2014.04.16.10.19.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Apr 2014 10:19:31 -0700 (PDT) From: Sergei Ianovich To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 15/21] misc: support for LP-8x4x DIP switch Date: Wed, 16 Apr 2014 21:17:20 +0400 Message-Id: <1397668667-27328-9-git-send-email-ynvich@gmail.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1397668667-27328-1-git-send-email-ynvich@gmail.com> References: <1397668411-27162-7-git-send-email-ynvich@gmail.com> <1397668667-27328-1-git-send-email-ynvich@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140416_101954_701780_3C73300A X-CRM114-Status: GOOD ( 13.88 ) X-Spam-Score: -0.1 (/) Cc: Mark Rutland , "open list:OPEN FIRMWARE AND..." , Arnd Bergmann , Pawel Moll , Ian Campbell , Greg Kroah-Hartman , Randy Dunlap , "open list:DOCUMENTATION" , Sergei Ianovich , Rob Herring , Kumar Gala X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Sergei Ianovich --- v3..v4 * move DTS binding to a different patch (8/21) v2..v3 * new patch .../devicetree/bindings/misc/lp8x4x-bus.txt | 2 ++ Documentation/misc-devices/lp8x4x_bus.txt | 3 +++ drivers/misc/lp8x4x_bus.c | 26 ++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/Documentation/devicetree/bindings/misc/lp8x4x-bus.txt b/Documentation/devicetree/bindings/misc/lp8x4x-bus.txt index 8a55020..1b1776a 100644 --- a/Documentation/devicetree/bindings/misc/lp8x4x-bus.txt +++ b/Documentation/devicetree/bindings/misc/lp8x4x-bus.txt @@ -7,6 +7,7 @@ Required properties: - reg: physical base addresses and region lengths of * the rotary switch + * the 8bit DIP switch * the slot count register Example: @@ -14,5 +15,6 @@ Example: backplane { compatible = "icpdas,backplane-lp8x4x"; reg = <0x0 0x2 + 0x9002 0x2 0x9046 0x2>; }; diff --git a/Documentation/misc-devices/lp8x4x_bus.txt b/Documentation/misc-devices/lp8x4x_bus.txt index bea435b..829781b 100644 --- a/Documentation/misc-devices/lp8x4x_bus.txt +++ b/Documentation/misc-devices/lp8x4x_bus.txt @@ -26,6 +26,9 @@ SYSFS /sys/bus/icpdas/devices/backplane: +dip + RO - shows status of LP-8x4x 8bit DIP switch + rotary RO - shows position of LP-8x4x rotary switch (0-9) diff --git a/drivers/misc/lp8x4x_bus.c b/drivers/misc/lp8x4x_bus.c index 18ca8f8..dfbc8c4 100644 --- a/drivers/misc/lp8x4x_bus.c +++ b/drivers/misc/lp8x4x_bus.c @@ -26,6 +26,7 @@ struct lp8x4x_master { unsigned int slot_count; void *count_addr; void *rotary_addr; + void *dip_addr; struct device dev; }; @@ -67,9 +68,20 @@ static ssize_t rotary_show(struct device *dev, static DEVICE_ATTR_RO(rotary); +static ssize_t dip_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct lp8x4x_master *m = container_of(dev, struct lp8x4x_master, dev); + + return sprintf(buf, "0x%02x\n", ioread8(m->dip_addr) ^ 0xff); +} + +static DEVICE_ATTR_RO(dip); + static struct attribute *master_dev_attrs[] = { &dev_attr_slot_count.attr, &dev_attr_rotary.attr, + &dev_attr_dip.attr, NULL, }; ATTRIBUTE_GROUPS(master_dev); @@ -118,6 +130,20 @@ static int __init lp8x4x_bus_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, r++); if (!res) { + dev_err(&pdev->dev, "Failed to get DIP switch address\n"); + err = -ENODEV; + goto err_free; + } + + m->dip_addr = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(m->dip_addr)) { + dev_err(&pdev->dev, "Failed to ioremap DIP switch address\n"); + err = PTR_ERR(m->dip_addr); + goto err_free; + } + + res = platform_get_resource(pdev, IORESOURCE_MEM, r++); + if (!res) { dev_err(&pdev->dev, "could not get slot count address\n"); err = -ENODEV; goto err_free;