Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3718460imm; Fri, 25 May 2018 10:20:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpuzKgLbo6pbvCn+F0TbQB1j5nKJYKE5n8Fbl9l65EIjJHeTDjhug3dSnRPNkNCurDr8mun X-Received: by 2002:a63:3c4b:: with SMTP id i11-v6mr2669122pgn.414.1527268832193; Fri, 25 May 2018 10:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527268832; cv=none; d=google.com; s=arc-20160816; b=NHyxOLpo69n9yGRB1tS/sRUnkua3ZbyV7o2WcJ1bwwLuxa7SvgL2cD3/9sKtQJIbYm 5W63MAFMts/NsBdjxbQErrlQIbljr8EmT23SMh2mQRosfON83TBIXQwIaGpiX2RzEDYR s7HEnpGPSNKPukgpW3yegNnn44lmABjoslPmLxiPDisAvzYCXL2V8Fjd2uSLUhhcHLRj BUzRCPuJ27Oq7vpgdVV2MlI3/ZYPOOhHhvwDXmpZ4t91R+HAMLFqNcNnOl6ThKSlWSsb hehbFeenjgIO1BLOzkvVX1eHJoqAYt1tzJeQur5nSkKemX109GPQXXym5eWQpMLBVhW1 XsEw== 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=x4lGxZv3sST0GM/arArDmzZNb3kCid3xw3IZ3Z3Bl4w=; b=OJ9Opcv5paqlMh0Nlz9kMY+xQ8Xso/YKUfb/LnoPzBvfJRFAiNMp70s3BcJbwDQeMB R+5PSjeYv22piZ503RN10tQrwNlZlPBiRjg5vg5UJ5BeXWThDutRJuRi058M2QjBDnsg vkNWLVvT/0a/8iMc9FBxHVbtIlMs8EavJIKiNR7Pev0XUjxWhXbdvgb/TJb6NV1BvJ4f a4Li+73Nh+395hNgkvNPOKTjqZBbO1OhRT4ZWT1Fc11xAXzPvLLcTtzbJXdg3NE1VflB 6Zjuy1lpsG7yGq/L0f7pAVZk7smR6etj22RAbN8jZ298ckxLzyrv4HbGX0dHjAtkkv0j c2rw== 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 p61-v6si24418073plb.472.2018.05.25.10.20.17; Fri, 25 May 2018 10:20:32 -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 S967492AbeEYRTr (ORCPT + 99 others); Fri, 25 May 2018 13:19:47 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:15060 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967472AbeEYRTo (ORCPT ); Fri, 25 May 2018 13:19:44 -0400 X-IronPort-AV: E=Sophos;i="5.49,440,1520924400"; d="scan'208";a="14357820" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 May 2018 10:19:44 -0700 Received: from m19893.microchip.com (10.10.76.4) by chn-sv-exch04.mchp-main.com (10.10.76.105) with Microsoft SMTP Server id 14.3.352.0; Fri, 25 May 2018 10:19:43 -0700 From: Radu Pirea To: , , , , , , , CC: , , , , , Radu Pirea Subject: [PATCH v4 3/6] mfd: at91-usart: added mfd driver for usart Date: Fri, 25 May 2018 20:19:38 +0300 Message-ID: <20180525171941.26766-4-radu.pirea@microchip.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180525171941.26766-1-radu.pirea@microchip.com> References: <20180525171941.26766-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..0535a256a3c0 --- /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, "atmel,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