From patchwork Tue Apr 24 09:47:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 10359221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 03C36601BE for ; Tue, 24 Apr 2018 10:07:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4600205AB for ; Tue, 24 Apr 2018 10:07:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D92602267B; Tue, 24 Apr 2018 10:07:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 36B40205AB for ; Tue, 24 Apr 2018 10:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=L3fz0UcUSQqz4lONHsHDiHrz0R6iN131mkLZV21WdyY=; b=A5w/VBOYWXn6i4CqUcji00IFMR GQzZHvVD89RfPTs/oMxA3Ur5zYPOf2ViVITd0KXlzrM4i6LjbzDblvnCB9eoQ8i4IBfIvx+bS4ghF wAagaI/oZK+8+00re7TCtev8+yFZLtQbmEaXquSoMrfesqv7YeNA9r/tVgFM9rvdcjFJM5HfwT1Ro HvFni/bCS+RmZnDvic0UlnsA437nrXadAqPo6qAaoQD/62HpZNcP7bOYFDYNVffACIhlpA+Z8RCzh YJ4E8xJGqvZCfIAl1lSQA6dLYiTYokwFXiberK6vS9uh9gGl5F1jewaf2wg9Jk8Es6y9iTfZVeR/C PS5h1POQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAurY-0002eA-Dh; Tue, 24 Apr 2018 10:07:52 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAurV-0002dl-Kd; Tue, 24 Apr 2018 10:07:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qW4HDFfmXx6IK2sYRpxIrGa7sf+sp0zwgEHKHX5GmGw=; b=oi2oGNwHJtaqmzFWhh3mJ92bm 2v/RNdiLhn4EYTyqYutsj3hvc1NOh5QVxfCxggzB3nYwpviZQHKr1z69IOQYINvVBkpHVLiY3VWev m1wNYbBEZOn0XWa9K7TNZ2MAD7kmJG+FwHdzGT3DaLq0iuPSFbjwe/VCiwuJb4SsLgTa+tuRbign6 M0Fmv2Md0K8n9KiMsj2H+biOmITsPZFIUeRj/OoG4GUQ/3NALsJGGT76oryZKV3utHJzdbQfk2ORT ANnaWVHtxlLCrRu5HalVI8lcUiqCui61VUZpvkt7C6VsJmZrY9+/IIb/+10EZtD6sx3dVxr8xog2W 7ZI53cpOQ==; Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fAuY7-0006PZ-9x; Tue, 24 Apr 2018 09:47:48 +0000 Received: from ziggy.de (144.pool85-56-49.dynamic.orange.es [85.56.49.144]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 03FFC21835; Tue, 24 Apr 2018 09:47:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03FFC21835 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=matthias.bgg@kernel.org From: matthias.bgg@kernel.org To: ulrich.hecht+renesas@gmail.com, laurent.pinchart@ideasonboard.com, ck.hu@mediatek.com, p.zabel@pengutronix.de, airlied@linux.ie, robh+dt@kernel.org, mark.rutland@arm.com, mturquette@baylibre.com, sboyd@codeaurora.org, lee.jones@linaro.org Subject: [v2 resend 03/10] mfd: mtk-mmsys: Add mmsys driver Date: Tue, 24 Apr 2018 11:47:00 +0200 Message-Id: <99bef17c57ad60eff6104da780cf59b785bd3e42.1524563001.git.mbrugger@suse.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180424_054747_654077_DCE18D44 X-CRM114-Status: GOOD ( 20.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sean.wang@mediatek.com, gregkh@linuxfoundation.org, rdunlap@infradead.org, linux@armlinux.org.uk, dri-devel@lists.freedesktop.org, linux-clk@vger.kernel.org, Matthias Brugger , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com, mchehab@kernel.org, pi-cheng.chen@linaro.org, davem@davemloft.net, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matthias Brugger The MMSYS subsystem includes clocks and drm components. This patch adds a MFD device to probe both drivers from the same device tree compatible. Signed-off-by: Matthias Brugger --- drivers/mfd/Kconfig | 9 ++++++ drivers/mfd/Makefile | 2 ++ drivers/mfd/mtk-mmsys.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 drivers/mfd/mtk-mmsys.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index b860eb5aa194..a2c928e26026 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -378,6 +378,15 @@ config MFD_MC13XXX_I2C help Select this if your MC13xxx is connected via an I2C bus. +config MFD_MEDIATEK_MMSYS + tristate "Mediatek MMSYS interface" + select MDF_CORE + select REGMAP_MMIO + help + Select this if you have a MMSYS subsystem in your SoC. The + MMSYS subsystem has at least a clock driver part and some + DRM components. + config MFD_MXS_LRADC tristate "Freescale i.MX23/i.MX28 LRADC" depends on ARCH_MXS || COMPILE_TEST diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index d9d2cf0d32ef..b96118bd68d9 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -98,6 +98,8 @@ obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o obj-$(CONFIG_MFD_MC13XXX_SPI) += mc13xxx-spi.o obj-$(CONFIG_MFD_MC13XXX_I2C) += mc13xxx-i2c.o +obj-$(CONFIG_MFD_MEDIATEK_MMSYS) += mtk-mmsys.o + obj-$(CONFIG_MFD_CORE) += mfd-core.o obj-$(CONFIG_EZX_PCAP) += ezx-pcap.o diff --git a/drivers/mfd/mtk-mmsys.c b/drivers/mfd/mtk-mmsys.c new file mode 100644 index 000000000000..c802343fb1c6 --- /dev/null +++ b/drivers/mfd/mtk-mmsys.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/* + * mtk-mmsys.c -- Mediatek MMSYS multi-function driver + * + * Copyright (c) 2018 Matthias Brugger + * + * Author: Matthias Brugger + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MMSYS_MT2701 = 1, +}; + +static const struct mfd_cell mmsys_mt2701_devs[] = { + { .name = "clk-mt2701-mm", }, + { .name = "drm-mt2701-mm", }, +}; + +static int mmsys_probe(struct platform_device *pdev) +{ + const struct mfd_cell *mmsys_cells; + int nr_cells; + long id; + int ret; + + id = (long) of_device_get_match_data(&pdev->dev); + if (!id) { + dev_err(&pdev->dev, "of_device_get match_data() failed\n"); + return -EINVAL; + } + + switch (id) { + case MMSYS_MT2701: + mmsys_cells = mmsys_mt2701_devs; + nr_cells = ARRAY_SIZE(mmsys_mt2701_devs); + break; + default: + return -ENODEV; + } + + ret = devm_mfd_add_devices(&pdev->dev, 0, mmsys_cells, nr_cells, + NULL, 0, NULL); + if (ret) { + dev_err(&pdev->dev, "failed to add MFD devices %d\n", ret); + return ret; + } + + return 0; +}; + +static const struct of_device_id of_match_mmsys[] = { + { .compatible = "mediatek,mt2701-mmsys", + .data = (void *) MMSYS_MT2701, + }, + { /* sentinel */ }, +}; + +static struct platform_driver mmsys_drv = { + .probe = mmsys_probe, + .driver = { + .name = "mediatek-mmysys", + .of_match_table = of_match_ptr(of_match_mmsys), + }, +}; + +builtin_platform_driver(mmsys_drv); + +MODULE_DESCRIPTION("Mediatek MMSYS multi-function driver"); +MODULE_LICENSE("GPL");