Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1651667imm; Thu, 14 Jun 2018 01:21:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIpuZ0PWZvA9iy3KLt3veYCQJEiV5rnObs9VkDI9EYobG9vXNRj3AWvKBcM7A0sdORGF8sN X-Received: by 2002:a17:902:6105:: with SMTP id t5-v6mr1950946plj.138.1528964519342; Thu, 14 Jun 2018 01:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528964519; cv=none; d=google.com; s=arc-20160816; b=JlZg437l304ytcCXnYugP/4W97Fq+4pgflNb3MOczN82YpjzTwc2PIA0qNJfBNinfG Wdy1UABcbliv6iS710ePLsfVVMUxWotgA/Ao8pF+CqRn65ls4wY7AfnwItYSldtdrYRz nubeo7VAlvJP+9q0CSxNjwFJuXkU7j8x94/Lm659+1Q2sCq7wQqfu/EZVQijY7src8M5 jZPrMlIStZIW8FfSPYCJJ0xPOawoqGzh239ZDZS5NJhJBiF+kE6wMkHw4mBzO6lbvzMm Qq4Vaibq9tUtWmEa8XxfJjoTL4wQ/1skA4Bo7FOw7tzxWPBY/Y3a9SHPguXNmJSZ6/PL AIcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:arc-authentication-results; bh=+Fh9gvW/yeFxldVhLQQrCXZWya2vRaz25VQkaPwPpMU=; b=mnpYtgUYHIhwVtIJ30KZ70dGg1qcKYHUypYyHG2OcZjfveNf+STdHdeCSDaN1yIbUd RVCm/B0SjNUP9SlHwRRHoqcYGwzYdjV7/IlqU/OQ+ErwhlkZB9iap0LDGt87vjJBqlf/ +5a9Z/ZVsOpgA+I43GdXfzjxjteyESLpkezXUpHcFy5lFbNnfn5xFuoQiVsEYjRXqIiO 4AVmpY+UuypEnBATAwoJeL+PRftwV55wsJI0rTEgyb6t8V+b6mS2pzcTyAshu7pXJ+QI CEX/PSn6+4RioWlQkzNnWT2jI24Mm3iRYQrYNBknFyinUX43vUA/0N0KSxwnnO0KLUuF EliQ== 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 k9-v6si4094487pgf.60.2018.06.14.01.21.45; Thu, 14 Jun 2018 01:21:59 -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 S1754790AbeFNIVO (ORCPT + 99 others); Thu, 14 Jun 2018 04:21:14 -0400 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:12036 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752876AbeFNIVL (ORCPT ); Thu, 14 Jun 2018 04:21:11 -0400 X-IronPort-AV: E=Sophos;i="5.51,222,1526367600"; d="scan'208";a="15245826" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 14 Jun 2018 01:21:10 -0700 Received: from [10.145.4.57] (10.10.76.4) by chn-sv-exch06.mchp-main.com (10.10.76.107) with Microsoft SMTP Server id 14.3.352.0; Thu, 14 Jun 2018 01:21:09 -0700 Subject: Re: [PATCH v7 3/6] mfd: at91-usart: added mfd driver for usart To: , , , , , , , , , , , , References: <20180613163621.23995-1-radu.pirea@microchip.com> <20180613163621.23995-4-radu.pirea@microchip.com> <20180614075849.dfiqwcu6rtzgpzq7@rfolt0960.corp.atmel.com> From: Radu Pirea Message-ID: <1086330e-40e4-8d9b-50aa-1ae9bf48aa22@microchip.com> Date: Thu, 14 Jun 2018 11:22:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180614075849.dfiqwcu6rtzgpzq7@rfolt0960.corp.atmel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/14/2018 10:58 AM, Ludovic Desroches wrote: > On Wed, Jun 13, 2018 at 07:36:18PM +0300, Radu Pirea wrote: >> 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 >> Acked-by: Rob Herring >> Reviewed-by: Andy Shevchenko >> Acked-for-MFD-by: Lee Jones >> --- >> drivers/mfd/Kconfig | 9 ++++++ >> drivers/mfd/Makefile | 1 + >> drivers/mfd/at91-usart.c | 69 ++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 79 insertions(+) >> create mode 100644 drivers/mfd/at91-usart.c >> >> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig >> index b860eb5aa194..a886672b960d 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 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..3014ce532644 >> --- /dev/null >> +++ b/drivers/mfd/at91-usart.c >> @@ -0,0 +1,69 @@ >> +// 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: >> + break; > > If there is an invalid opmode from the DT, you will pass a non initialized cell > to mfd_add_device(). > > Regards > > Ludovic Hi Ludovic, Tnx. That's true. How is better to do if atmel,usart-mode has an invalid value? To initialize cell with at91_usart_serial_subdev or to print an error message and return -EINVAL? Regards. Radu Pirea > >> + } >> + >> + 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_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"); >> -- >> 2.17.1 >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel