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: 10058987 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 D3DC76023A for ; Wed, 15 Nov 2017 08:32:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1EBD29E3B for ; Wed, 15 Nov 2017 08:32:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B64CE29E3D; Wed, 15 Nov 2017 08:32:11 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 5623229E3B for ; Wed, 15 Nov 2017 08:32:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E07946E39F; Wed, 15 Nov 2017 08:31:52 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1ECFA6E2F6 for ; Tue, 14 Nov 2017 21:41:55 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id b189so18029243wmd.0 for ; Tue, 14 Nov 2017 13:41:55 -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=Sy9nNQbk/kHghLAd5kt+8pVJjVdayb3nE46rwPTAQkVnd+pYlVyWxy9a8HHU6hdNLp gyvwv/v9SJzX92tG5L0UIDay8myYvTLCv07eMfBzxMdcEXx/mL4L5e64cNsSQgeg53Q/ +HqnLhmDist9ttkglDc8vWepXHonb1bqTFx3RGLIedR4l3ItKLX0nx3BXee5QlUxI0S+ pO3bO2YHLfF92Nl72FgwDNkop/58lqA/akgkazuVEtdmKd/gDKIkJypH9X4yC+2Ta8z5 9xK8FBDYAkA1HFFWju8Y0LECHDmKZ+I3nZQlz9MZ0oz9eBkAB2eEZXcZXMIDkcLlROY0 TkRA== X-Gm-Message-State: AJaThX5T9Di0j/IP7RBiVTYZ9KvMNTvvxWCzqblX/YXf2/ILKFf1gCPY M7y5j3iLmnkOKz31OJZDw+M= 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-Mailman-Approved-At: Wed, 15 Nov 2017 08:31:51 +0000 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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