Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4444373imm; Tue, 11 Sep 2018 12:00:23 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda70DOPAEFkULOePHjdzFHY53s1qNfmfh6jqELqbWpO4LSBI37gnNEVDGxvukgvqgP8Qf/n X-Received: by 2002:a62:aa02:: with SMTP id e2-v6mr30890957pff.211.1536692423366; Tue, 11 Sep 2018 12:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536692423; cv=none; d=google.com; s=arc-20160816; b=GptEGQiBEhageyqJXe+xA9UKQAZjzcVGmDOwFcnrDxKjJyH3Yt4n+erj68OJun1St2 9OWY7fty0rSwXtLZionQW9V5XBj7P3F1jlKRSufqfO7Ltnk+B/fe+a7bFx8g9c2xlXBO payqaYG9EU0ElBwAYm937OBNsP7RE2hUtDKv7BxySekzif2qRIYLdeHQPzE46josNXSn pIXEarjCJDSui559gIHvmuk+RifDsDm76So62qXVt6kEL11ICpeHeiUC343qQ/o5OvKe nw3O1nVXTsz9ZVBNRbCYHYuW5/GuvDxi3dTzcoehN1PCNG+z9r3dFBomyqp2hVwHQyX3 Q7sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=nbJfPC/7OLVXR+pZM3OrG1JkPMOdJCJanLlsjxs3gQc=; b=mm9TRM7J/tB8/zT4V78mKbSSvHY4jD4+3zf+aK6s14jVMTLKZLqJ2ncezGHZR0/uOU pzgUh+uCoHfp9EjbQarOnNtfJtipNV5CPw8BIEp0KywbLGhT7jfPdHt/Xq6zFdaUjgwV DVGnMsdwQ7YgOPcCmeuF1iPK8abBZ3Fl33FWbmEwrFosnYuSA58lkPspkdXfydJ/KEsv HXFeTUrtPKTEJXBQPeFuis1e2yC/QZn18YCbmwsxtC1kCklgLNATnNMpcfAbpCag/Xro wH91hrPTK4lJJf2zg3oyYnW7BIATyUDOZSXqWKZKCykSRMPL3XFDH3nF5qD2ug+UBTz3 l6mQ== 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 i189-v6si21896070pgd.668.2018.09.11.12.00.05; Tue, 11 Sep 2018 12:00:23 -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 S1727413AbeILAAE (ORCPT + 99 others); Tue, 11 Sep 2018 20:00:04 -0400 Received: from mail-ua1-f65.google.com ([209.85.222.65]:45772 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbeILAAE (ORCPT ); Tue, 11 Sep 2018 20:00:04 -0400 Received: by mail-ua1-f65.google.com with SMTP id q7-v6so21646759uam.12; Tue, 11 Sep 2018 11:59:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nbJfPC/7OLVXR+pZM3OrG1JkPMOdJCJanLlsjxs3gQc=; b=GOFxJw8eOfdil8PPOhs2FiBOyWwZFp5KwIfViVrgo4dqAIFfDReaaHmm729IrLi97K xkPgY2ZdN80DyGY9malbykXYfmx+rCZftB1STTw9yRz7wPnt9CTIhA1mpVINzHRVTDxs WAfCsgBF8SHV+V2SEWyDWJRge0o/5S33UhHahJXus0SFCtdxWsMRH9Ae9sM8+L0AbVOJ J6mZfTcOrxoKnyXIXnbt3AOAArp3q8Yi93dQrydNRL7EICRrZps7kEAWAaM5CQdKLTBf TSY/hNCrLXprgBEncPWSlTvm3hDz+1TRP9G+KWFh/RvscvYk12M7Vno56RAn7MHoNwZy iXHg== X-Gm-Message-State: APzg51BupbwEqNpidgR5kAPfvKpVw+3klRWsQFiOidoYI9vA2Cwcd6ec Bixg+dRJi7AMWCUS9c/H5LX0A4XQz/OTb3gcwN8= X-Received: by 2002:a67:6908:: with SMTP id e8-v6mr9844272vsc.21.1536692363895; Tue, 11 Sep 2018 11:59:23 -0700 (PDT) MIME-Version: 1.0 References: <20180904111310.4049-1-radu_nicolae.pirea@upb.ro> <20180911093356.GE4185@dell> <20180911093917.GL2494@piout.net> <20180911153621.GP2494@piout.net> <20180911181838.GI4185@dell> In-Reply-To: <20180911181838.GI4185@dell> From: Geert Uytterhoeven Date: Tue, 11 Sep 2018 20:59:12 +0200 Message-ID: Subject: Re: [PATCH v12 0/6] Driver for at91 usart in spi mode To: Lee Jones Cc: Alexandre Belloni , radu_nicolae.pirea@upb.ro, Rob Herring , Mark Rutland , Nicolas Ferre , Greg KH , Mark Brown , Jiri Slaby , Richard Genoud , "David S. Miller" , Mauro Carvalho Chehab , Andrew Morton , Arnd Bergmann , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux ARM , Linux Kernel Mailing List , "open list:SERIAL DRIVERS" , linux-spi Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lee, On Tue, Sep 11, 2018 at 8:40 PM Lee Jones wrote: > On Tue, 11 Sep 2018, Geert Uytterhoeven wrote: > > On Tue, Sep 11, 2018 at 5:36 PM Alexandre Belloni > > wrote: > > > On 11/09/2018 16:59:09+0200, Geert Uytterhoeven wrote: > > > > On Tue, Sep 11, 2018 at 11:40 AM Alexandre Belloni > > > > wrote: > > > > > On 11/09/2018 10:33:56+0100, Lee Jones wrote: > > > > > > On Tue, 04 Sep 2018, Radu Pirea wrote: > > > > > > > Radu Pirea (6): > > > > > > > MAINTAINERS: add at91 usart mfd driver > > > > > > > dt-bindings: add binding for atmel-usart in SPI mode > > > > > > > mfd: at91-usart: added mfd driver for usart > > > > > > > MAINTAINERS: add at91 usart spi driver > > > > > > > spi: at91-usart: add driver for at91-usart as spi > > > > > > > tty/serial: atmel: change the driver to work under at91-usart mfd > > > > > > > > > > > > > > .../bindings/{serial => mfd}/atmel-usart.txt | 25 +- > > > > > > > MAINTAINERS | 16 + > > > > > > > drivers/mfd/Kconfig | 9 + > > > > > > > drivers/mfd/Makefile | 1 + > > > > > > > drivers/mfd/at91-usart.c | 71 +++ > > > > > > > drivers/spi/Kconfig | 8 + > > > > > > > drivers/spi/Makefile | 1 + > > > > > > > drivers/spi/spi-at91-usart.c | 432 ++++++++++++++++++ > > > > > > > drivers/tty/serial/Kconfig | 1 + > > > > > > > drivers/tty/serial/atmel_serial.c | 42 +- > > > > > > > include/dt-bindings/mfd/at91-usart.h | 17 + > > > > > > > 11 files changed, 606 insertions(+), 17 deletions(-) > > > > > > > rename Documentation/devicetree/bindings/{serial => mfd}/atmel-usart.txt (76%) > > > > > > > create mode 100644 drivers/mfd/at91-usart.c > > > > > > > create mode 100644 drivers/spi/spi-at91-usart.c > > > > > > > create mode 100644 include/dt-bindings/mfd/at91-usart.h > > > > > > > > > > > > Seeing as this patch-set has caused some issues this morning, I took > > > > > > the liberty to peruse back into its history to figure out where things > > > > > > started to go wrong. I also re-reviewed the MFD driver - and I'm glad > > > > > > I did! > > > > > > > > > > > > My Acked-by has been attached to the MFD portion since v5, which is > > > > > > why the code hasn't caught my eye before today. I reviewed the > > > > > > relocation of the *binding document* (serial => mfd with no changes) > > > > > > in v4 and nothing else. It appears as though you mistakenly added it > > > > > > to the *MFD driver* instead. This explains my confusion in v10 when I > > > > > > told you I'd already reviewed the binding document. > > > > > > > > > > > > As I said, I have re-reviewed the MFD driver and I'm afraid to say > > > > > > that I do not like what I see. Besides the missing header file and > > > > > > the whitespace tabbing errors, I do not agree with the implementation. > > > > > > Using MFD as a shim to hack around driver selection is not a valid > > > > > > use-case. > > > > > > > > > > > > What's stopping you from just using the compatible string directly to > > > > > > select which driver you need to probe? > > > > > > > > > > > > > > > > Then you'd have multiple compatible strings for the same IP which is a > > > > > big no-no. > > > > > > > > It's still the same hardware device, isn't? > > > > What if the SPI or UART slave is not on-board, but on an expansion board? > > > > Then the SoC-specific .dtsi has no idea what mode should be used. > > > > > > > > Hence shouldn't the software derive the hardware mode from the full > > > > hardware description in DT? If that's impossible (I didn't look into detail > > > > whether an SPI bus can easily be distinguished from a UART bus), perhaps > > > > a mode property should be added? > > > > > > Yes, this is exactly what is done: > > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/tree/drivers/mfd/at91-usart.c?h=ib-mfd-spi-tty-4.20-1#n33 > > > > OK. > > > > I guess the main "hackish" part is that the mfd_cell uses of_compatible, > > which thus requires having additional compatible values? > > > > I think those can just be removed. AFAICS, the SPI and serial drivers already > > match against the "at91_usart_spi" resp. "atmel_usart_serial" platform device > > names? > > The hackish part of this driver is that it's using MFD for something > which is clearly not an MFD. It's a USART device. Nothing more, > nothing less. > > Does anyone have the datasheet to hand? I haven't read it, but I believe it's not unlike Renesas SCIF, which is served by both drivers/tty/serial/sh-sci.c and drivers/spi/spi-sh-sci.c. But the latter is not used from DT, so we haven't experienced (and solved) the similar issue yet. Would it work if the UART driver and SPI driver would match against the same compatible value, but the UART driver would do in its probe() function: device_property_read_u32(&pdev->dev, "atmel,usart-mode", &opmode); if (opmode != AT91_USART_MODE_SERIAL) return ENODEV; while the SPI driver would do: device_property_read_u32(&pdev->dev, "atmel,usart-mode", &opmode); if (opmode != AT91_USART_MODE_SPI) return ENODEV; ? No MFD driver involved. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds