Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp543324imm; Fri, 31 Aug 2018 07:07:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYPFlT2YJ8BuPDE7er1YpmJUU9BIhwGmtKfHTvIjgDqVmesArw2yWR2rHt+t5m8TRprrm5N X-Received: by 2002:a63:447:: with SMTP id 68-v6mr14584619pge.409.1535724245076; Fri, 31 Aug 2018 07:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535724244; cv=none; d=google.com; s=arc-20160816; b=EfJTIaO/tAdvgopi78HomEnxVh9xNAubZmoX2AR3DA11yPxuOpUBzDd5qqSVT5csJe 6z/dAJ+WI2630OdS2y10MZm9S35IKQ10ETsp1N54d+jTuN7khk70eKqnmUP0/9R3rUT1 DsRgOrcoQ7p2SXepqUSXyYnQWoybEElu2GiDgy3Q2+r63asUR3Qhqxn4n3oCXvTvzAIk CE5FB3yUjqOMzd0/VR5LHpZQxz8WpKkRXyq2WKtI6enTkC5CHgkve+QDFYo8aAKZLJos FsO+/Os/OSnogfgUq6RIoNur/l5cHeRl6mbtJNEXvmld8cbXuE4PlCIK+1MAuZ3pE9WC MQZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=8HF3qZ2Lwi3oBhE9eE9UZt563B4q3pDktMT+Mr7r+Jk=; b=odB0jHdZ3Zm9Vgm7QDkoy4tJvaBwEdpWStCwbxZ9SS43nC5VVrOEpN5atW06d4eLoV I6wSytEOFiPOL+hm/vclv7Z4ZokC2G+clNlj5k3Q5/buRULmcxZoBMyz1ES3dH8udIse Ysos/GvxDvvp8Rbr2LpRer9oGNpZUEhoRkxF1qK34+KApUFD8tD0SyK7RQLkTMcRJndd UpMH96J7Gcld4t6sEG+ADTQGrxlTvSvEn4JWnb1NfiYJGpgexo9CGPZvvXmuLYxFs2ua sx1NFDp87W87e11kfvV4GJtEfm6SCHM6OuL5RgtRnfc5vrvSl7Uj/HV3NKLAMBV7PccD lsVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18-v6si10281963pfb.161.2018.08.31.07.03.50; Fri, 31 Aug 2018 07:04:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728544AbeHaRsK (ORCPT + 99 others); Fri, 31 Aug 2018 13:48:10 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:58953 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728464AbeHaRsK (ORCPT ); Fri, 31 Aug 2018 13:48:10 -0400 X-IronPort-AV: E=Sophos;i="5.53,311,1531810800"; d="scan'208";a="16999761" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 Aug 2018 06:40:37 -0700 Received: from m19893.microchip.com (10.10.76.4) by chn-sv-exch02.mchp-main.com (10.10.76.38) with Microsoft SMTP Server id 14.3.352.0; Fri, 31 Aug 2018 06:40:36 -0700 From: Radu Pirea To: , , , , , , , , , CC: , , , , , Radu Pirea Subject: [RESEND PATCH v11 3/6] mfd: at91-usart: added mfd driver for usart Date: Fri, 31 Aug 2018 16:41:38 +0300 Message-ID: <20180831134141.9335-4-radu.pirea@microchip.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180831134141.9335-1-radu.pirea@microchip.com> References: <20180831134141.9335-1-radu.pirea@microchip.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This mfd driver is just a wrapper over atmel_serial driver and spi-at91-usart driver. Selection of one of the drivers is based on a property from device tree. If the property is not specified, the default driver is atmel_serial. Signed-off-by: Radu Pirea Reviewed-by: Andy Shevchenko Acked-by: Rob Herring Acked-for-MFD-by: Lee Jones Acked-by: Nicolas Ferre --- drivers/mfd/Kconfig | 9 +++++ drivers/mfd/Makefile | 1 + drivers/mfd/at91-usart.c | 71 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 drivers/mfd/at91-usart.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 11841f4b7b2b..0b79c5d04cc9 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -99,6 +99,15 @@ config MFD_AAT2870_CORE additional drivers must be enabled in order to use the functionality of the device. +config MFD_AT91_USART + tristate "AT91 USART Driver" + select MFD_CORE + help + Select this to get support for AT91 USART IP. This is a wrapper + over at91-usart-serial driver and usart-spi-driver. Only one function + can be used at a time. The choice is done at boot time by the probe + function of this MFD driver according to a device tree property. + config MFD_ATMEL_FLEXCOM tristate "Atmel Flexcom (Flexible Serial Communication Unit)" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 5856a9489cbd..12980a4ad460 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -196,6 +196,7 @@ obj-$(CONFIG_MFD_SPMI_PMIC) += qcom-spmi-pmic.o obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o obj-$(CONFIG_MFD_TPS65090) += tps65090.o obj-$(CONFIG_MFD_AAT2870_CORE) += aat2870-core.o +obj-$(CONFIG_MFD_AT91_USART) += at91-usart.o obj-$(CONFIG_MFD_ATMEL_FLEXCOM) += atmel-flexcom.o obj-$(CONFIG_MFD_ATMEL_HLCDC) += atmel-hlcdc.o obj-$(CONFIG_MFD_ATMEL_SMC) += atmel-smc.o diff --git a/drivers/mfd/at91-usart.c b/drivers/mfd/at91-usart.c new file mode 100644 index 000000000000..a4b9929c156f --- /dev/null +++ b/drivers/mfd/at91-usart.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Driver for AT91 USART + * + * Copyright (C) 2018 Microchip Technology + * + * Author: Radu Pirea + * + */ + +#include + +#include +#include +#include + +static struct mfd_cell at91_usart_spi_subdev = { + .name = "at91_usart_spi", + .of_compatible = "microchip,at91sam9g45-usart-spi", + }; + +static struct mfd_cell at91_usart_serial_subdev = { + .name = "atmel_usart_serial", + .of_compatible = "atmel,at91rm9200-usart-serial", + }; + +static int at91_usart_mode_probe(struct platform_device *pdev) +{ + struct mfd_cell cell; + u32 opmode = AT91_USART_MODE_SERIAL; + + device_property_read_u32(&pdev->dev, "atmel,usart-mode", &opmode); + + switch (opmode) { + case AT91_USART_MODE_SPI: + cell = at91_usart_spi_subdev; + break; + case AT91_USART_MODE_SERIAL: + cell = at91_usart_serial_subdev; + break; + default: + dev_err(&pdev->dev, "atmel,usart-mode has an invalid value %u\n", + opmode); + return -EINVAL; + } + + return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, &cell, 1, + NULL, 0, NULL); +} + +static const struct of_device_id at91_usart_mode_of_match[] = { + { .compatible = "atmel,at91rm9200-usart" }, + { .compatible = "atmel,at91sam9260-usart" }, + { /* sentinel */ } +}; + +MODULE_DEVICE_TABLE(of, at91_usart_mode_of_match); + +static struct platform_driver at91_usart_mfd = { + .probe = at91_usart_mode_probe, + .driver = { + .name = "at91_usart_mode", + .of_match_table = at91_usart_mode_of_match, + }, +}; + +module_platform_driver(at91_usart_mfd); + +MODULE_AUTHOR("Radu Pirea "); +MODULE_DESCRIPTION("AT91 USART MFD driver"); +MODULE_LICENSE("GPL v2"); -- 2.18.0