From patchwork Mon Dec 15 11:25:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 42227 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 38C7621772 for ; Mon, 15 Dec 2014 11:26:16 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf7091951lbv.1 for ; Mon, 15 Dec 2014 03:26:14 -0800 (PST) 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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=qBFPnzI2HGxCMBOcEXstOnijzCb73SjTb8tYVxl9K78=; b=LV78b0D6UleFO5idQkiTWBrzbS4Xi6nWewZFmlG1ntCU59DwFzNdoRBua4YjR2gbHm aptiX3JpFg/c+ST5x9atlHn6X817G3hWBx2YT3NpG3kdjdxe/cF2NJy3ziJZqY+wbKZG 0dTp9ciD3O7ZSJcYheLyAXZGkacTR1t84+PfpA797+HGp0oTyZjAtWVD10gP+W2QT3CS pQHAHhE++/SApiEc0mJtMJ49oTG7glrXBKgDT9Myu+6CpsqLHB9JUqyYk7CicswptBHT YjqUwTaiY2IviPJqwRcL8NMbdlkQPoDnRmxltcnLJlLOAwx7CJJLIpKzrD5O4OrdJ0Ek 5C2w== X-Gm-Message-State: ALoCoQkpIMYN2sUMvP3AF8OVyPA7xsJyTLEYlGzkoYUMqAhGK/DS6a895oO1t/uJKYVt2YU/N3WT X-Received: by 10.180.99.227 with SMTP id et3mr2737038wib.3.1418642774767; Mon, 15 Dec 2014 03:26:14 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.166 with SMTP id u6ls732933lag.41.gmail; Mon, 15 Dec 2014 03:26:14 -0800 (PST) X-Received: by 10.112.171.136 with SMTP id au8mr29968295lbc.71.1418642774505; Mon, 15 Dec 2014 03:26:14 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id xb8si10110961lbb.109.2014.12.15.03.26.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 03:26:14 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gm9so9114559lab.26 for ; Mon, 15 Dec 2014 03:26:14 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr29856419lal.29.1418642774420; Mon, 15 Dec 2014 03:26:14 -0800 (PST) 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.112.142.69 with SMTP id ru5csp684117lbb; Mon, 15 Dec 2014 03:26:13 -0800 (PST) X-Received: by 10.70.119.71 with SMTP id ks7mr26864851pdb.140.1418642772382; Mon, 15 Dec 2014 03:26:12 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xg13si13568329pac.74.2014.12.15.03.26.11 for ; Mon, 15 Dec 2014 03:26:12 -0800 (PST) Received-SPF: none (google.com: linux-watchdog-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 S1751941AbaLOL0C (ORCPT ); Mon, 15 Dec 2014 06:26:02 -0500 Received: from mail-yh0-f49.google.com ([209.85.213.49]:39483 "EHLO mail-yh0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751926AbaLOL0B (ORCPT ); Mon, 15 Dec 2014 06:26:01 -0500 Received: by mail-yh0-f49.google.com with SMTP id f10so4963169yha.8 for ; Mon, 15 Dec 2014 03:26:00 -0800 (PST) X-Received: by 10.170.57.211 with SMTP id 202mr24536271ykz.116.1418642760674; Mon, 15 Dec 2014 03:26:00 -0800 (PST) Received: from localhost.localdomain (host109-148-232-11.range109-148.btcentralplus.com. [109.148.232.11]) by mx.google.com with ESMTPSA id y67sm5772300yhc.11.2014.12.15.03.25.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 03:26:00 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com, a.zummo@towertech.it, rtc-linux@googlegroups.com, wim@iguana.be, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 5/8] mfd: Add ST's Low Power Controller driver Date: Mon, 15 Dec 2014 11:25:35 +0000 Message-Id: <1418642738-17407-6-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418642738-17407-1-git-send-email-lee.jones@linaro.org> References: <1418642738-17407-1-git-send-email-lee.jones@linaro.org> Sender: linux-watchdog-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@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.215.53 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: , On current ST platforms the LPC controls a number of functions. This patch enables possible support for the LPC Watchdog and LPC RTC devices and ensures only one of them operates at any one time. Signed-off-by: Lee Jones --- drivers/mfd/Kconfig | 8 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/st-lpc.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 drivers/mfd/st-lpc.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index de5abf2..75db2f2 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -752,6 +752,14 @@ config STMPE_SPI This is used to enable SPI interface of STMPE endmenu +config MFD_ST_LPC + tristate "STMicroelectronics Low-Power-Controller" + depends on OF + select MFD_CORE + help + Say yes here to add support for ST's Low-Power-Controller (LPC). + This device provides Real-Time Clock and Watchdog functionality. + config MFD_STA2X11 bool "STMicroelectronics STA2X11" depends on STA2X11 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index f001487..09aeb95 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_MFD_STA2X11) += sta2x11-mfd.o obj-$(CONFIG_MFD_STMPE) += stmpe.o obj-$(CONFIG_STMPE_I2C) += stmpe-i2c.o obj-$(CONFIG_STMPE_SPI) += stmpe-spi.o +obj-$(CONFIG_MFD_ST_LPC) += st-lpc.o obj-$(CONFIG_MFD_SUN6I_PRCM) += sun6i-prcm.o obj-$(CONFIG_MFD_TC3589X) += tc3589x.o obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o diff --git a/drivers/mfd/st-lpc.c b/drivers/mfd/st-lpc.c new file mode 100644 index 0000000..13906d9 --- /dev/null +++ b/drivers/mfd/st-lpc.c @@ -0,0 +1,88 @@ +/* + * st-lpc.c - ST's Low Power Controller (LPC) Multi-Function Device Driver + * + * Copyright (C) 2014 STMicroelectronics -- All Rights Reserved + * + * Author: Lee Jones for STMicroelectronics + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public Licence + * as published by the Free Software Foundation; either version + * 2 of the Licence, or (at your option) any later version. + */ + +#include +#include +#include +#include +#include + +static int st_lpc_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct mfd_cell *cell; + u32 mode; + int ret; + + cell = devm_kzalloc(&pdev->dev, sizeof(*cell), GFP_KERNEL); + if (!cell) + return -ENOMEM; + + ret = of_property_read_u32(np, "st,lpc-mode", &mode); + if (ret) { + dev_err(&pdev->dev, "An LPC mode must be selected\n"); + return ret; + } + + switch (mode) { + case ST_LPC_MODE_RTC: + cell->name = "st-lpc-rtc"; + break; + case ST_LPC_MODE_WDT: + cell->name = "st-lpc-wdt"; + break; + default: + dev_err(&pdev->dev, "Unsupported mode: %d\n", mode); + return ret; + } + + /* Pass resources though to selected child device. */ + cell->resources = pdev->resource; + cell->num_resources = pdev->num_resources; + + ret = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, + cell, 1, NULL, 0, NULL); + if (ret) { + dev_err(&pdev->dev, "Failed to register child devices\n"); + return ret; + } + + return 0; +} + +static int st_lpc_remove(struct platform_device *pdev) +{ + mfd_remove_devices(&pdev->dev); + + return 0; +} + +static const struct of_device_id st_lpc_dt_match[] = { + { .compatible = "st,stih407-lpc" }, + { } +}; + +static struct platform_driver st_lpc_driver = { + .driver = { + .name = "st-lpc", + .of_match_table = st_lpc_dt_match, + }, + .probe = st_lpc_probe, + .remove = st_lpc_remove, +}; + +module_platform_driver(st_lpc_driver); + +MODULE_AUTHOR("Lee Jones "); +MODULE_DESCRIPTION("ST's Low Power Controller (LPC) Multi-Function Device"); +MODULE_LICENSE("GPL");