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: 10359135 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 DE4006054A for ; Tue, 24 Apr 2018 09:47:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEA6C20CCF for ; Tue, 24 Apr 2018 09:47:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C26692821F; Tue, 24 Apr 2018 09:47:39 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C58F20CCF for ; Tue, 24 Apr 2018 09:47:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 585F06E3BE; Tue, 24 Apr 2018 09:47:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id AA49A6E3BE for ; Tue, 24 Apr 2018 09:47:36 +0000 (UTC) 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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development 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 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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");