From patchwork Tue Nov 14 21:41:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Brugger X-Patchwork-Id: 10058367 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 9B320601D3 for ; Tue, 14 Nov 2017 21:43:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AFCB29A96 for ; Tue, 14 Nov 2017 21:43:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F51229A9E; Tue, 14 Nov 2017 21:43:21 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 0837229A96 for ; Tue, 14 Nov 2017 21:43:21 +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=Vo9e1ff/FMLHYVvEN4lahRK5u36LT937fMqfsF9cD+A=; b=fEkb/WMzs2r0VlRw+Fgx+1byOb ERxBO99lttIUgHH3rLs68GLEGtKq5ETw+QpdYmt5LAEdn5m4e6eZCt1eBmXejlXj17rFRrCYpHupb o6tkq8xPtTVtxQ5pxyv+bif6QxaeOh2ocgdgxlIl3vd/ysHgMwHQTbYVnEXVykok3AHJLZ3gCDBnV ZNB1jEEWMMhZ5UaCzI5jrFNyrPeLA1Yaye8v/QVkMArBPsS1qLHDSL3JMbL3c+5lMKhAVUlqr/Rt+ mmrIZhesQMg1A/grq5u1mHp4kn/ssPMbwrifOuTjpZzioHyRZk+9d2tTITLTorytYC3nuzsuu9G5I 9JofYehg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eEizD-0000Ii-BV; Tue, 14 Nov 2017 21:43:15 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eEiyG-0007lK-Gh; Tue, 14 Nov 2017 21:42:21 +0000 Received: by mail-wm0-x241.google.com with SMTP id t139so24966759wmt.1; Tue, 14 Nov 2017 13:41:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vDL2d0vHIh4Cce4jAF6Z+SfnZwW7qauXeARGswvW4ek=; b=ZU/rEELwW9ycS8PLVrZhlffkWZBRPEySPus2al01m9TwuqslrniTMvhFu4Hqr9g60z TgISDqZHFRYCbXxn8+8imdKBBee8ykVW74NRN+8kaHHTxklj6/f0eU1tcePfL8/xSzqE KDsPnGjInntKhpsBz2a/px8s09G4dE0JWrP4sHTyTdBYTfbUXb/1be3fipCHnYwa8t2Z 0WnLEg0VQTqpjzNV5LMa5KEXyuP+95ubmlHseUW8S2GLJjkM9+1jpN7oDNgRoZ4COoQX HkHIMxbPypLuf9ibUJmXoB2dz714GpdJQtRE6R04fgV/3ikMm9X6+qD85SmuEjtHsjmU JLCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vDL2d0vHIh4Cce4jAF6Z+SfnZwW7qauXeARGswvW4ek=; b=q5Ee7WiSdI56xtkduQw8gWiVn+InByfwMmDLgdUKUy9JYouPAfJEGJJYrn/i48bfLD XjVeaqmD0AT14SE11JCd7Yg/LFN8Cj357QX+y/94r334M0+oQOImxY7+lz3zO6FO8yOH LFIU4UM2FvdZ6VNRJZiPoeUz3ajlvA2FBpZhU0CsI2ufdDSDqZZeD9BBn5tt2BMj02pY xN97kGj6nqe1ZTsPU8FmMAUlmMsUFygAaCHujreafks8xKa4MNFFmSsSECyE7Eias8fH U2J+Of7I+UmGeXnuwPJgSure4zTGjuGD/GcJNqDuJstHitB1IHuN+Nkh5uVt2eT2gS4b Be/g== X-Gm-Message-State: AJaThX7DxkbrVY5/WsBW77JLMyecb/KCtDZbvjuld0gleebw9BWqjyZ6 Mf1i7Ip7FW7CR7ISq76FxY8= X-Google-Smtp-Source: AGs4zMbQ6RdbH8oPZMbrZ2NLzMpJY7hM0biJKTlxrghjdj3JZlIksMKvYY+OkD6Beid2WPnNxbDUfw== X-Received: by 10.28.122.11 with SMTP id v11mr9950743wmc.104.1510695714533; Tue, 14 Nov 2017 13:41:54 -0800 (PST) Received: from localhost.localdomain ([92.57.80.122]) by smtp.gmail.com with ESMTPSA id s12sm46706369wrc.89.2017.11.14.13.41.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Nov 2017 13:41:53 -0800 (PST) From: Matthias Brugger X-Google-Original-From: Matthias Brugger 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: [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver Date: Tue, 14 Nov 2017 22:41:08 +0100 Message-Id: <20171114214114.15793-3-mbrugger@suse.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171114214114.15793-1-mbrugger@suse.com> References: <20171114214114.15793-1-mbrugger@suse.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171114_134216_940480_AD6B1CDF X-CRM114-Status: GOOD ( 19.40 ) 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 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 | 91 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/mmsys.h | 18 ++++++++++ 4 files changed, 120 insertions(+) create mode 100644 drivers/mfd/mtk-mmsys.c create mode 100644 include/linux/mfd/mmsys.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index fc5e4fef89d2..3250ce5d205a 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -368,6 +368,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 8703ff17998e..d4fc99df784c 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -100,6 +100,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..102b491aa28f --- /dev/null +++ b/drivers/mfd/mtk-mmsys.c @@ -0,0 +1,91 @@ +/* + * mtk-mmsys.c -- Mediatek MMSYS multi-function driver + * + * Copyright (c) 2017 Matthias Brugger + * + * Author: Matthias Brugger + * + * For licencing details see kernel-base/COPYING + * + */ + +#include +#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) +{ + struct mmsys_dev *private; + 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; + } + + private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL); + if (!private) + return -ENOMEM; + + private->dev = &pdev->dev; + dev_set_drvdata(private->dev, private); + + private->of_node = pdev->dev.of_node; + + ret = devm_mfd_add_devices(private->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"); diff --git a/include/linux/mfd/mmsys.h b/include/linux/mfd/mmsys.h new file mode 100644 index 000000000000..274b9ee03ada --- /dev/null +++ b/include/linux/mfd/mmsys.h @@ -0,0 +1,18 @@ +/* Header of MMSYS MFD core driver for Mediatek platforms + * + * Copyright (c) 2017 Matthias Brugger + * + * 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. + */ + +#ifndef __MEDIATEK_MMSYS__H__ +#define __MEDIATEK_MMSYS__H__ + +struct mmsys_dev { + struct device *dev; + struct device_node *of_node; +}; + +#endif