Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp604300imm; Fri, 11 May 2018 03:38:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoZlHyWAgas4vzMuizdHzrZej9gEaZ7lov3szIANwXuaDVVI9YGxAxyShvCCISatasN1UsK X-Received: by 2002:a17:902:b286:: with SMTP id u6-v6mr5023683plr.68.1526035094094; Fri, 11 May 2018 03:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526035094; cv=none; d=google.com; s=arc-20160816; b=DYesLZ3ZPpsFAmxg1fdSZuoBruVS/M+hQSuczeQe5OyuJtbiN18cH9X5jR+IZAPm0b akGq/xfVFehbRO/CUg6NHK/ib3fbBISTw6ENfriejCkdyFaDgZA5RpXVYyIs9XshjZ1M BkxoelWtL9FKPh4TK29eLl8iorke/mOyTOvHN2XVv69h57sKeYtgGYVRlL3gsnLtM3Xn f9QEuAkYDyETeoM0TP29Q8OdQGCWZHYFV9xjQWvGJLEfXsowr1aZsbTr6xMw+KhjAmij GfNTB7w2gQySNXYHcz13v46TERKkiGGeNyevUIWJUc/dLJVuqFs6F0oVpbvMprf2MLLZ b+SQ== 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=NpWa9ztkuuXScgQCXXi7gP9OB32qe0LM/2pEBsZkHFU=; b=RHu1P2SToFH3wJVUJW8mO2XaI97uZCjfKs76nZ6q3jgwnVQZGohjAcBFRb/GMPHZ3l p3C/YkEBGqDUO+LIQF1QzUlWpdDDNoo9ziVaeVBcP2ALM6cG7dNhwCets2BkgVoRgJwj V7CutP2C2LYJ7PidRTJo1nMKyoumZ3SBtiOqnG/5s9zhUoBc9KN/AisbqGgfvvFpJp0j OHmn1bdUbUNCGW4hweHw9eWEiUyTx8BjnkvNnghzG24U9aSMcxnpxvlb5rarDguZ25eN InNdqVEVx7eSUTjymyzBrBaYRsRGMs1Q6ERrX6H6/mLFgyppV3CcX5FmB62Gxpb21lmg 9P5g== 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 o78-v6si2963004pfa.54.2018.05.11.03.37.59; Fri, 11 May 2018 03:38:14 -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 S1753006AbeEKKh2 (ORCPT + 99 others); Fri, 11 May 2018 06:37:28 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:3481 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752981AbeEKKhY (ORCPT ); Fri, 11 May 2018 06:37:24 -0400 X-IronPort-AV: E=Sophos;i="5.49,388,1520924400"; d="scan'208";a="11960899" 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; 11 May 2018 03:37:23 -0700 Received: from m19893.microchip.com (10.10.76.4) by chn-sv-exch05.mchp-main.com (10.10.76.106) with Microsoft SMTP Server id 14.3.352.0; Fri, 11 May 2018 03:37:22 -0700 From: Radu Pirea To: , , , , CC: , , , , , , , , , Radu Pirea Subject: [PATCH v3 2/6] mfd: at91-usart: added mfd driver for usart Date: Fri, 11 May 2018 13:38:18 +0300 Message-ID: <20180511103822.31698-3-radu.pirea@microchip.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180511103822.31698-1-radu.pirea@microchip.com> References: <20180511103822.31698-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 --- drivers/mfd/Kconfig | 10 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/at91-usart.c | 75 ++++++++++++++++++++++++++++ include/dt-bindings/mfd/at91-usart.h | 17 +++++++ 4 files changed, 103 insertions(+) create mode 100644 drivers/mfd/at91-usart.c create mode 100644 include/dt-bindings/mfd/at91-usart.h diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index b860eb5aa194..de99b79061b7 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -99,6 +99,16 @@ 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 + depends on OF + 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 d9d2cf0d32ef..db1332aa96db 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -185,6 +185,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..87094463f8f4 --- /dev/null +++ b/drivers/mfd/at91-usart.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for AT91 USART + * + * Copyright (C) 2018 Microchip Technology + * + * Author: Radu Pirea + * + */ + +#include + +#include +#include +#include +#include +#include +#include +#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 device_node *np = pdev->dev.of_node; + struct mfd_cell cell; + u32 opmode; + int err; + + err = of_property_read_u32(np, "at91,usart-mode", &opmode); + + switch (opmode) { + case AT91_USART_MODE_SPI: + cell = at91_usart_spi_subdev; + break; + case AT91_USART_MODE_SERIAL: + default: + cell = at91_usart_serial_subdev; + } + + return 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_flexcom_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"); diff --git a/include/dt-bindings/mfd/at91-usart.h b/include/dt-bindings/mfd/at91-usart.h new file mode 100644 index 000000000000..ac811628a42d --- /dev/null +++ b/include/dt-bindings/mfd/at91-usart.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * This header provides macros for AT91 USART DT bindings. + * + * Copyright (C) 2018 Microchip Technology + * + * Author: Radu Pirea + * + */ + +#ifndef __DT_BINDINGS_AT91_USART_H__ +#define __DT_BINDINGS_AT91_USART_H__ + +#define AT91_USART_MODE_SERIAL 1 +#define AT91_USART_MODE_SPI 2 + +#endif /* __DT_BINDINGS_AT91_USART_H__ */ -- 2.17.0