Driver for at91 usart in spi mode
Subsystems (8)
v3 cover Driver for at91 usart in spi mode
Hello,
This is the second version of driver. I added a mfd driver which by default probes atmel_serial driver and if in dt is specified to probe the spi driver, then the spi-at91-usart driver will be probed. The compatible for atmel_serial is now the compatible for at91-usart mfd driver and compatilbe for atmel_serial driver was changed in order to keep the bindings for serial as they are.
Changes in v1:
- added spi-at91-usart driver
Changes in v2:
- added at91-usart mfd driver
- modified spi-at91-usart driver to work as mfd driver child
- modified atmel_serial driver to work as mfd driver child
Changes in v3:
- fixed spi slaves probing
Radu Pirea (6):
MAINTAINERS: add at91 usart mfd driver
mfd: at91-usart: added mfd driver for usart
MAINTAINERS: add at91 usart spi driver
dt-bindings: add binding for at91-usart in spi mode
spi: at91-usart: add driver for at91-usart as spi tty/serial: atmel: changed the driver to work under at91-usart mfd
.../bindings/spi/microchip,at91-usart-spi.txt | 28 + MAINTAINERS | 14 + drivers/mfd/Kconfig | 10 + drivers/mfd/Makefile | 1 + drivers/mfd/at91-usart.c | 75 +++ drivers/spi/Kconfig | 9 + drivers/spi/Makefile | 1 + drivers/spi/spi-at91-usart.c | 544 ++++++++++++++++++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/atmel_serial.c | 29 +- include/dt-bindings/mfd/at91-usart.h | 17 + 11 files changed, 715 insertions(+), 14 deletions(-) create mode 100644 Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt 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
Signature · 1 line
2.17.0
PATCH v3 1/6 MAINTAINERS: add at91 usart mfd driver
Added entry for at91 usart mfd driver.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -9192,6 +9192,13 @@ S: Supported F: drivers/mtd/nand/raw/atmel/* F: Documentation/devicetree/bindings/mtd/atmel-nand.txt +MICROCHIP AT91 USART MFD DRIVER +M: Radu Pirea <[email protected]> +L: [email protected] +S: Supported +F: drivers/mfd/at91-usart.c +F: include/dt-bindings/mfd/at91-usart.h + MICROCHIP KSZ SERIES ETHERNET SWITCH DRIVER M: Woojung Huh <[email protected]> M: Microchip Linux Driver Support <[email protected]>
Signature · 1 line
2.17.0
PATCH v3 2/6 mfd: at91-usart: added mfd driver for usart
In reply to Radu PireaThis 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.
--- 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
drivers/mfd/Kconfig +10 -0
@@ -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
drivers/mfd/Makefile +1 -0
@@ -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
drivers/mfd/at91-usart.c new file +75 -0
75 lines not on this page · raw message
include/dt-bindings/mfd/at91-usart.h new file +17 -0
@@ -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 <[email protected]> +* +*/ + +#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__ */
Signature · 1 line
2.17.0
Rob Herring
maintainerRe: [PATCH v3 2/6] mfd: at91-usart: added mfd driver for usart
Quoted 16 lines · Radu Pirea
This mfd driver is just a wrapper over
atmel_serialdriver 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 isatmel_serial.Signed-off-by Radu Pirea <[email protected]>--- 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
include/dt-bindings/mfd/at91-usart.h line 15
Quoted 5 lines
include/dt-bindings/mfd/at91-usart.h new file +5
-0+#ifndef __DT_BINDINGS_AT91_USART_H__ +#define __DT_BINDINGS_AT91_USART_H__ + +#define AT91_USART_MODE_SERIAL 1 +#define AT91_USART_MODE_SPI 2
Won't this require a DT update for serial mode to add the mode property? That breaks compatibility.
Rob
Alexandre Belloni
maintainerRe: [PATCH v3 2/6] mfd: at91-usart: added mfd driver for usart
Quoted 17 lines · Rob Herring
Quoted 15 lines · Radu Pirea
This mfd driver is just a wrapper over
atmel_serialdriver 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 isatmel_serial.Signed-off-by Radu Pirea <[email protected]>--- 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
Quoted 9 lines
include/dt-bindings/mfd/at91-usart.h line 15
Quoted 5 lines
include/dt-bindings/mfd/at91-usart.h new file +5
-0+#ifndef __DT_BINDINGS_AT91_USART_H__ +#define __DT_BINDINGS_AT91_USART_H__ + +#define AT91_USART_MODE_SERIAL 1 +#define AT91_USART_MODE_SPI 2Won't this require a DT update for serial mode to add the mode property? That breaks compatibility.
If the mode property is not present, it defaults to serial to keep compatibility.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
PATCH v3 3/6 MAINTAINERS: add at91 usart spi driver
In reply to Radu PireaAdded entry for at91 usart mfd driver.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -9199,6 +9199,13 @@ S: Supported F: drivers/mfd/at91-usart.c F: include/dt-bindings/mfd/at91-usart.h +MICROCHIP AT91 USART SPI DRIVER +M: Radu Pirea <[email protected]> +L: linux-spi at vger.kernel.org +S: Supported +F: drivers/spi/spi-at91-usart.c +F: Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt + MICROCHIP KSZ SERIES ETHERNET SWITCH DRIVER M: Woojung Huh <[email protected]> M: Microchip Linux Driver Support <[email protected]>
Signature · 1 line
2.17.0
Re: [PATCH v3 3/6] MAINTAINERS: add at91 usart spi driver
Quoted 2 lines · Radu Pirea
Added entry for at91 usart mfd driver.
You are adding a record for not existing file?
Quoted 26 lines
Signed-off-by Radu Pirea <[email protected]>--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)MAINTAINERS +7
-1@@ -9199,6 +9199,13 @@ S: Supported F: drivers/mfd/at91-usart.c F: include/dt-bindings/mfd/at91-usart.h +MICROCHIP AT91 USART SPI DRIVER +M: Radu Pirea <[email protected]> +L: linux-spi at vger.kernel.org +S: Supported +F: drivers/spi/spi-at91-usart.c +F: Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt + MICROCHIP KSZ SERIES ETHERNET SWITCH DRIVER M: Woojung Huh <[email protected]> M: Microchip Linux Driver Support <[email protected]> --2.17.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v3 4/6 dt-bindings: add binding for at91-usart in spi mode
In reply to Radu PireaThese are bindings for at91-usart IP in spi spi mode. There is no support for internal chip select. Only kind of chip selects available are gpio chip selects.
--- .../bindings/spi/microchip,at91-usart-spi.txt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt
Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt new file +28 -0
@@ -0,0 +1,28 @@ +* Universal Synchronous Asynchronous Receiver/Transmitter (USART) in SPI mode + +Required properties: +- #size-cells : Must be <0> +- #address-cells : Must be <1> +- compatible: Should be "atmel,at91rm9200-usart" or "atmel,at91sam9260-usart" +- reg: Should contain registers location and length +- interrupts: Should contain interrupt +- clocks: phandles to input clocks. +- clock-names: tuple listing input clock names. + Required elements: "usart" +- cs-gpios: chipselects (internal cs not supported) +- at91,usart-mode: AT91_USART_MODE_SPI (found in dt-bindings/mfd/at91-usart.h) + +Example: + #include <dt-bindings/mfd/at91-usart.h> + + spi0: spi@f001c000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "atmel,at91rm9200-usart", "atmel,at91sam9260-usart"; + at91,usart-mode = <AT91_USART_MODE_SPI>; + reg = <0xf001c000 0x100>; + interrupts = <12 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&usart0_clk>; + clock-names = "usart"; + cs-gpios = <&pioB 3 0>; + };
Signature · 1 line
2.17.0
Rob Herring
maintainerRe: [PATCH v3 4/6] dt-bindings: add binding for at91-usart in spi mode
Quoted 1 line · Radu Pirea
These are bindings for at91-usart IP in spi spi mode. There is no support for
s/spi spi/SPI/
Quoted 1 line
internal chip select. Only kind of chip selects available are gpio chip
GPIO
Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt
Quoted 13 lines
selects.
Signed-off-by Radu Pirea <[email protected]>--- .../bindings/spi/microchip,at91-usart-spi.txt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txtDocumentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt new file +0
-0
So now we have 2 copies of the same thing that varies by 2 properties? Please make this one doc.
Quoted 4 lines
Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt new file +3
-0@@ -0,0 +1,28 @@ +* Universal Synchronous Asynchronous Receiver/Transmitter (USART) in SPI mode + +Required properties:
Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt line 13
Quoted 10 lines
Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt new file +10
-0+- #size-cells : Must be <0> +- #address-cells : Must be <1> +- compatible: Should be "atmel,at91rm9200-usart" or "atmel,at91sam9260-usart" +- reg: Should contain registers location and length +- interrupts: Should contain interrupt +- clocks: phandles to input clocks. +- clock-names: tuple listing input clock names. + Required elements: "usart" +- cs-gpios: chipselects (internal cs not supported) +- at91,usart-mode: AT91_USART_MODE_SPI (found in dt-bindings/mfd/at91-usart.h)
at91 is not a vendor.
Quoted 18 lines
Documentation/devicetree/bindings/spi/microchip,at91-usart-spi.txt new file +15
-0+ +Example: + #include <dt-bindings/mfd/at91-usart.h> + + spi0: spi at f001c000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "atmel,at91rm9200-usart", "atmel,at91sam9260-usart"; + at91,usart-mode = <AT91_USART_MODE_SPI>; + reg = <0xf001c000 0x100>; + interrupts = <12 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&usart0_clk>; + clock-names = "usart"; + cs-gpios = <&pioB 3 0>; + };Signature · 1 line
2.17.0
PATCH v3 5/6 spi: at91-usart: add driver for at91-usart as spi
In reply to Radu PireaThis is the driver for at91-usart in spi mode. The USART IP can be configured to work in many modes and one of them is SPI.
The driver was tested on sama5d3-xplained and sama5d4-xplained boards with enc28j60 ethernet controller as slave.
--- drivers/spi/Kconfig | 9 + drivers/spi/Makefile | 1 + drivers/spi/spi-at91-usart.c | 544 +++++++++++++++++++++++++++++++++++ 3 files changed, 554 insertions(+) create mode 100644 drivers/spi/spi-at91-usart.c
drivers/spi/Kconfig +9 -0
@@ -77,6 +77,15 @@ config SPI_ATMEL This selects a driver for the Atmel SPI Controller, present on many AT91 (ARM) chips. +config SPI_AT91_USART + tristate "Atmel USART Controller as SPI" + depends on HAS_DMA + depends on (ARCH_AT91 || COMPILE_TEST) + select MFD_AT91_USART + help + This selects a driver for the AT91 USART Controller as SPI Master, + present on AT91 and SAMA5 SoC series. + config SPI_AU1550 tristate "Au1550/Au1200/Au1300 SPI Controller" depends on MIPS_ALCHEMY
drivers/spi/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_SPI_LOOPBACK_TEST) += spi-loopback-test.o obj-$(CONFIG_SPI_ALTERA) += spi-altera.o obj-$(CONFIG_SPI_ARMADA_3700) += spi-armada-3700.o obj-$(CONFIG_SPI_ATMEL) += spi-atmel.o +obj-$(CONFIG_SPI_AT91_USART) += spi-at91-usart.o obj-$(CONFIG_SPI_ATH79) += spi-ath79.o obj-$(CONFIG_SPI_AU1550) += spi-au1550.o obj-$(CONFIG_SPI_AXI_SPI_ENGINE) += spi-axi-spi-engine.o
drivers/spi/spi-at91-usart.c new file +544 -0
544 lines not on this page · raw message
Signature · 1 line
2.17.0
Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
drivers/spi/spi-at91-usart.c line 13
Quoted 5 lines · Radu Pirea
This is the driver for at91-usart in spi mode. The USART IP can be configured to work in many modes and one of them is SPI.
drivers/spi/spi-at91-usart.c new file +2
-0+#include <linux/gpio.h> +#include <linux/gpio/consumer.h>
Here is something wrong. You need to use latter one in new code.
drivers/spi/spi-at91-usart.c line 20
Quoted 7 lines
drivers/spi/spi-at91-usart.c new file +7
-0+#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_gpio.h>
Hmm... Do you need all of them?
Quoted 2 lines
(quoted diff) +2
-0+static inline void at91_usart_spi_cs_activate(struct spi_device *spi) +{
...
Quoted 6 lines
drivers/spi/spi-at91-usart.c new file +6
-0+gpiod_set_value (ausd->npcs_pin, active); + aus->cs_active = true; +} + +static inline void at91_usart_spi_cs_deactivate (struct spi_device *spi) +{
...
Quoted 3 lines
drivers/spi/spi-at91-usart.c new file +3
-0+gpiod_set_value (ausd->npcs_pin, !active); + aus->cs_active = false; +}
...
Quoted 3 lines
drivers/spi/spi-at91-usart.c new file +3
-0+if (!ausd) { +if (gpio_is_valid (spi->cs_gpio)) { + npcs_pin =gpio_to_desc (spi->cs_gpio);
...
Quoted 1 line
+ }
...
Quoted 3 lines
drivers/spi/spi-at91-usart.c new file +3
-0+gpiod_direction_output (npcs_pin, !(spi->mode &SPI_CS_HIGH )); + + ausd->npcs_pin = npcs_pin;
...
Quoted 1 line
+ }
I will refer to above as (1) later on.
drivers/spi/spi-at91-usart.c line 350
Quoted 2 lines
drivers/spi/spi-at91-usart.c new file +2
-0+dev_dbg (&spi->dev,"new message %p submitted for %s\n" , + msg,dev_name (&spi->dev));
%p does make a very little sense.
drivers/spi/spi-at91-usart.c line 364
Quoted 5 lines
drivers/spi/spi-at91-usart.c new file +5
-0+list_for_each_entry (xfer, &msg->transfers, transfer_list) { + ret =at91_usart_spi_one_transfer (controller, msg, xfer); +if (ret) + goto msg_done; + }
Cant SPI core do this for your?
drivers/spi/spi-at91-usart.c line 384
Quoted 7 lines
drivers/spi/spi-at91-usart.c new file +6
-0+static void at91_usart_spi_cleanup (struct spi_device *spi) +{ +struct at91_usart_spi_device *ausd = spi->controller_state; + +if (!ausd) +return ;
Is it even possible?
Anyway the code below will work fine even if it's the case.
Quoted 21 lines
drivers/spi/spi-at91-usart.c new file +20
-0+ + spi->controller_state =NULL ; +kfree (ausd); +} +static int at91_usart_spi_gpio_cs (struct platform_device *pdev) +{ +struct spi_controller *controller =platform_get_drvdata (pdev); +struct device_node *np = controller->dev.parent->of_node; +struct gpio_desc *cs_gpio; +int nb; +int i; + +if (!np) +return 0 ; + + nb =of_gpio_named_count (np,"cs-gpios" ); +for (i =0 ; i < nb; i++) { + cs_gpio = devm_gpiod_get_from_of_node(&pdev->dev, + pdev->dev.parent->of_node, + "cs-gpios",
drivers/spi/spi-at91-usart.c line 415
Quoted 10 lines
drivers/spi/spi-at91-usart.c new file +10
-0+ i,GPIOD_OUT_HIGH , + dev_name(&pdev->dev)); +if (IS_ERR (cs_gpio)) +return PTR_ERR (cs_gpio); + } + + controller->num_chipselect = nb; + +return 0 ; +}
The question is, why you didn't utilize what SPI core provides you?
drivers/spi/spi-at91-usart.c line 422
Quoted 4 lines
drivers/spi/spi-at91-usart.c new file +4
-0+spi_writel (aus,MR ,US_MR_SPI_MASTER |US_MR_CHRL |US_MR_CLKO | +US_MR_WRDBT ); +spi_writel (aus,CR ,US_CR_RXDIS |US_CR_TXDIS |US_CR_RSTRX | +US_CR_RSTTX );
I didn't check over, but it seems like you might have duplication in these bitwise ORs. Consider to unify them into another (shorter) definitions and reuse all over the code.
drivers/spi/spi-at91-usart.c line 437
Quoted 4 lines
drivers/spi/spi-at91-usart.c new file +4
-0+ regs =platform_get_resource (to_platform_device (pdev->dev.parent), +IORESOURCE_MEM ,0 ); +if (!regs) +return -ENXIO ;
Strange error code for getting MMIO resource. ENOMEM sounds better.
drivers/spi/spi-at91-usart.c line 502
Quoted 4 lines
drivers/spi/spi-at91-usart.c new file +4
-0+dev_info (&pdev->dev, +"Atmel USART SPI Controller version 0x%x at 0x%08lx (irq %d)\n" , +spi_readl (aus,VERSION ), + (unsigned long )regs->start, irq);
If you do explicit casting when printing something you are doing wrong. Please use %pR or %pr in this case.
drivers/spi/spi-at91-usart.c line 535
Quoted 5 lines
drivers/spi/spi-at91-usart.c new file +4
-0+static struct platform_driver at91_usart_spi_driver = { + .driver = { + .name ="at91_usart_spi" , + .of_match_table =of_match_ptr (at91_usart_spi_dt_ids),
Can it work as pure platform driver? If no, of_match_ptr() is redundant.
drivers/spi/spi-at91-usart.c line 538
Quoted 3 lines
drivers/spi/spi-at91-usart.c new file +3
-0+ }, + .probe = at91_usart_spi_probe, + .remove = at91_usart_spi_remove, };
Two lines at one. Split.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
Quoted 3 lines
I will refer to above as (1) later on.
The question is, why you didn't utilize what SPI core provides you?
Here I should have referred to (1).
Signature · 2 lines
With Best Regards, Andy Shevchenko
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
First of all, do not remove mailing lists from Cc and people if you are not sure they do not need your stuff.
Quoted 12 lines · Radu Pirea
Quoted 11 lines · Andy Shevchenko
On Fri, May 11, 2018 at 1:38 PM, Radu Pirea <[email protected]
drivers/spi/spi-at91-usart.c line 384
Quoted 8 lines
wrote:
drivers/spi/spi-at91-usart.c new file +6
-0+static void at91_usart_spi_cleanup (struct spi_device *spi) +{ +struct at91_usart_spi_device *ausd = spi->controller_state; + +if (!ausd) +return ;Is it even possible?
Quoted 1 line
Theoretically yes.
I would like to know real circumstances when it might happen.
Quoted 10 lines
Quoted 9 lines
Anyway the code below will work fine even if it's the case.
drivers/spi/spi-at91-usart.c line 388
Quoted 4 lines
drivers/spi/spi-at91-usart.c new file +4
-0+ + spi->controller_state =NULL ; +kfree (ausd); +}The question is, why you didn't utilize what SPI core provides you?
I tried, but it did not work the way I expected.
So, what is not going as expected in "SPI core takes care of CSs" case? Did you use oscilloscope for that?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
Quoted 3 lines · Andy Shevchenko
First of all, do not remove mailing lists from Cc and people if you are not sure they do not need your stuff.
Sorry. My mistake.
Quoted 14 lines
Quoted 12 lines · Radu Pirea
Quoted 11 lines · Andy Shevchenko
On Fri, May 11, 2018 at 1:38 PM, Radu Pirea <radu.pirea@microchip .com
Quoted 8 lines
wrote:
drivers/spi/spi-at91-usart.c new file +3
-0+static void at91_usart_spi_cleanup (struct spi_device *spi) +{ + struct at91_usart_spi_device *ausd = spi-Quoted 1 line
controller_state;drivers/spi/spi-at91-usart.c new file +3
-0+ +if (!ausd) +return ;
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Is it even possible?
Theoretically yes.
I would like to know real circumstances when it might happen.
That check was used in debug stage of driver. I will remove.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Anyway the code below will work fine even if it's the case.
drivers/spi/spi-at91-usart.c line 388
Quoted 4 lines
drivers/spi/spi-at91-usart.c new file +4
-0+ + spi->controller_state =NULL ; +kfree (ausd); +}The question is, why you didn't utilize what SPI core provides you?
Quoted 5 lines
Quoted 1 line
I tried, but it did not work the way I expected.
So, what is not going as expected in "SPI core takes care of CSs" case?
Did you use oscilloscope for that?
Yes, I used and CSs was not asserted. Anyway, I will will try again.
Quoted 1 line
Mark Brown
maintainerRe: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
Quoted 7 lines · Radu Pirea
Quoted 3 lines · Andy Shevchenko
So, what is not going as expected in "SPI core takes care of CSs" case?
Did you use oscilloscope for that?Yes, I used and CSs was not asserted. Anyway, I will will try again.
If the core chip select handling is not working properly for some reason
then the core chip select handling should be fixed rather than just open
coding in your driver - probably it's also broken for other users.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180517/795c8270/attachment-0001.sig>
Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
Quoted 7 lines · Mark Brown
Quoted 5 lines · Radu Pirea
Quoted 3 lines · Andy Shevchenko
So, what is not going as expected in "SPI core takes care of CSs" case?
Did you use oscilloscope for that?
Quoted 6 lines
Quoted 1 line
Yes, I used and CSs was not asserted. Anyway, I will will try again.
If the core chip select handling is not working properly for some reason then the core chip select handling should be fixed rather than just open coding in your driver - probably it's also broken for other users.
Hi Mark,
I found the fix for cs-gpios. If I change spi_add_device function like this(see below) everything is ok.
int spi_add_device(struct spi_device *spi)
...
if (ctlr->cs_gpios){
spi->cs_gpio = ctlr->cs_gpios[spi->chip_select];
if(gpio_is_valid(spi->cs_gpio))
gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
}
...
return status; }
In the subsystem gpio direction of pins is never set and gpio_set_value() don't set the direction. In my opinion gpio_direction_output() set direction should be called in spi_add_device. What do you think? Is ok?
Alexandre Belloni
maintainerRe: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
Hi,
Quoted 35 lines · Radu Pirea
Quoted 7 lines · Mark Brown
Quoted 5 lines · Radu Pirea
Quoted 3 lines · Andy Shevchenko
So, what is not going as expected in "SPI core takes care of CSs" case?
Did you use oscilloscope for that?Quoted 6 lines
Quoted 1 line
Yes, I used and CSs was not asserted. Anyway, I will will try again.
If the core chip select handling is not working properly for some reason then the core chip select handling should be fixed rather than just open coding in your driver - probably it's also broken for other users.
Hi Mark,
I found the fix for cs-gpios. If I change
spi_add_devicefunction like this(see below) everything is ok.int
spi_add_device(struct spi_device *spi)...
if (ctlr->cs_gpios){ spi->cs_gpio = ctlr->cs_gpios[spi->chip_select]; if(gpio_is_valid(spi->cs_gpio)) gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); }...
Quoted 7 lines
return status; }In the subsystem gpio direction of pins is never set and
gpio_set_value()don't set the direction.
In my opiniongpio_direction_output()set direction should be called inspi_add_device. What do you think? Is ok?
Back in 2014, I was suggesting using devm_gpio_request_one() in of_spi_register_master(). That would take care of setting the direction of the GPIO:
https://www.spinics.net/lists/arm-kernel/msg351251.html
I never took the time to create the patch and test though.
Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com
Mark Brown
maintainerRe: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
Quoted 7 lines · Alexandre Belloni
Back in 2014, I was suggesting using
devm_gpio_request_one()inof_spi_register_master(). That would take care of setting the direction of the GPIO:https://www.spinics.net/lists/arm-kernel/msg351251.html
I never took the time to create the patch and test though.
Right, this'd be ideal but unfortunately it does mean we'd have to
transition all the existing users that open code their requests which is
a pain. It'd be really nice if someone had the time/enthusiam to do it
though.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180524/4bbd58ed/attachment.sig>
Mark Brown
maintainerRe: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
In reply to Radu PireaQuoted 6 lines · Radu Pirea
if (ctlr->cs_gpios){
spi->cs_gpio = ctlr->cs_gpios[spi->chip_select];
if(gpio_is_valid(spi->cs_gpio))
gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
}You're expected to request the GPIOs in your driver using one of the
modern request functions like gpio_request_one() (or ideally the GPIO
descriptor APIs now) which combine the direction setting and request
into a single operation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180524/afe4d42a/attachment.sig>
Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
In reply to Andy ShevchenkoQuoted 148 lines · Andy Shevchenko
On Fri, May 11, 2018 at 1:38 PM, Radu Pirea <[email protected]
drivers/spi/spi-at91-usart.c line 13
Quoted 6 lines
wrote:
This is the driver for at91-usart in spi mode. The USART IP can be configured
to work in many modes and one of them is SPI.drivers/spi/spi-at91-usart.c new file +2
-0+#include <linux/gpio.h> +#include <linux/gpio/consumer.h> Here is something wrong. You need to use latter one in new code.
drivers/spi/spi-at91-usart.c line 20
Quoted 7 lines
drivers/spi/spi-at91-usart.c new file +7
-0+#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/of_gpio.h> Hmm... Do you need all of them?
Quoted 3 lines
+static inline void
at91_usart_spi_cs_activate(struct spi_device *spi)
+{...
Quoted 7 lines
drivers/spi/spi-at91-usart.c new file +5
-0+gpiod_set_value (ausd->npcs_pin, active); + aus->cs_active = true; +} + +static inline void at91_usart_spi_cs_deactivate(struct spi_device*spi)
+{...
Quoted 3 lines
drivers/spi/spi-at91-usart.c new file +3
-0+gpiod_set_value (ausd->npcs_pin, !active); + aus->cs_active = false; +}...
Quoted 3 lines
drivers/spi/spi-at91-usart.c new file +3
-0+if (!ausd) { +if (gpio_is_valid (spi->cs_gpio)) { + npcs_pin =gpio_to_desc (spi->cs_gpio);...
Quoted 1 line
+ }
...
Quoted 4 lines
+ gpiod_direction_output(npcs_pin, !(spi->mode &
SPI_CS_HIGH));drivers/spi/spi-at91-usart.c new file +2
-0+ + ausd->npcs_pin = npcs_pin;...
Quoted 1 line
+ }
I will refer to above as (1) later on.
drivers/spi/spi-at91-usart.c line 350
Quoted 2 lines
drivers/spi/spi-at91-usart.c new file +2
-0+dev_dbg (&spi->dev,"new message %p submitted for %s\n" , + msg,dev_name (&spi->dev));%p does make a very little sense.
drivers/spi/spi-at91-usart.c line 364
Quoted 6 lines
(quoted diff) +2
-0+ list_for_each_entry(xfer, &msg->transfers, transfer_list) { + ret = at91_usart_spi_one_transfer(controller, msg,xfer);
drivers/spi/spi-at91-usart.c new file +3
-0+if (ret) + goto msg_done; + }Cant SPI core do this for your?
drivers/spi/spi-at91-usart.c line 384
Quoted 6 lines
drivers/spi/spi-at91-usart.c new file +6
-0+static void at91_usart_spi_cleanup (struct spi_device *spi) +{ +struct at91_usart_spi_device *ausd = spi->controller_state; + +if (!ausd) +return ;Is it even possible?
Anyway the code below will work fine even if it's the case.
Quoted 26 lines
drivers/spi/spi-at91-usart.c new file +7
-0+ + spi->controller_state =NULL ; +kfree (ausd); +} +static int at91_usart_spi_gpio_cs (struct platform_device *pdev) +{ + struct spi_controller *controller =
platform_get_drvdata(pdev);drivers/spi/spi-at91-usart.c new file +12
-0+struct device_node *np = controller->dev.parent->of_node; +struct gpio_desc *cs_gpio; +int nb; +int i; + +if (!np) +return 0 ; + + nb =of_gpio_named_count (np,"cs-gpios" ); +for (i =0 ; i < nb; i++) { + cs_gpio = devm_gpiod_get_from_of_node(&pdev->dev, + pdev-Quoted 1 line
dev.parent->of_node,(quoted diff) +2
-0+ "cs-gpios", + i,
GPIOD_OUT_HIGH,
+ dev_name(&pdev->dev));drivers/spi/spi-at91-usart.c line 415
Quoted 8 lines
drivers/spi/spi-at91-usart.c new file +8
-0+if (IS_ERR (cs_gpio)) +return PTR_ERR (cs_gpio); + } + + controller->num_chipselect = nb; + +return 0 ; +}The question is, why you didn't utilize what SPI core provides you?
Quoted 6 lines
+ spi_writel(aus, MR,
US_MR_SPI_MASTER|US_MR_CHRL|US_MR_CLKO|(quoted diff) +2
-0+ US_MR_WRDBT); + spi_writel(aus, CR, US_CR_RXDIS | US_CR_TXDIS | US_CR_RSTRX|
+US_CR_RSTTX);I didn't check over, but it seems like you might have duplication in these bitwise ORs. Consider to unify them into another (shorter) definitions and reuse all over the code.
drivers/spi/spi-at91-usart.c line 437
Quoted 5 lines
+ regs = platform_get_resource(to_platform_device(pdev-
Quoted 1 line
dev.parent),
drivers/spi/spi-at91-usart.c new file +3
-0+ IORESOURCE_MEM, 0); +if (!regs) +return -ENXIO ;Strange error code for getting MMIO resource. ENOMEM sounds better.
drivers/spi/spi-at91-usart.c line 502
Quoted 5 lines
(quoted diff) +2
-0+ dev_info(&pdev->dev, + "Atmel USART SPI Controller version 0x%x at0x%08lx (irq %d)\n",
drivers/spi/spi-at91-usart.c new file +2
-0+spi_readl (aus,VERSION ), + (unsigned long)regs->start, irq);If you do explicit casting when printing something you are doing wrong.
Please use %pR or %pr in this case.
Quoted 8 lines
Quoted 5 lines
drivers/spi/spi-at91-usart.c new file +4
-0+static struct platform_driver at91_usart_spi_driver = { + .driver = { + .name ="at91_usart_spi" , + .of_match_table =
of_match_ptr(at91_usart_spi_dt_ids),Can it work as pure platform driver? If no,
of_match_ptr()is redundant.
This driver can not work as pure platform driver, but I the way I used to probe it from MFD(by compatbile string).
Do you know another way?
Quoted 7 lines
drivers/spi/spi-at91-usart.c line 538
Quoted 4 lines
drivers/spi/spi-at91-usart.c new file +3
-0+ }, + .probe = at91_usart_spi_probe, + .remove = at91_usart_spi_remove, };Two lines at one. Split.
Mark Brown
maintainerRe: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
In reply to Radu Pireadrivers/spi/Kconfig config SPI_ATMEL · line 88
Quoted 9 lines · Radu Pirea
drivers/spi/Kconfig +9
-0+config SPI_AT91_USART + tristate "Atmel USART Controller as SPI" + depends on HAS_DMA + depends on (ARCH_AT91 || COMPILE_TEST) + select MFD_AT91_USART + help + This selects a driver for the AT91 USART Controller as SPI Master, + present on AT91 and SAMA5 SoC series. +
This looks like there's some tab/space mixing going on here.
drivers/spi/spi-at91-usart.c line 5
Quoted 5 lines
drivers/spi/spi-at91-usart.c new file +5
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* Driver for AT91 USART Controllers as SPI +* +* Copyright (C) 2018 Microchip Technology Inc.
Make the entire block a C++ comment so it looks more intentional rather tha mixing C and C++.
drivers/spi/spi-at91-usart.c line 133
Quoted 10 lines
drivers/spi/spi-at91-usart.c new file +10
-0+static inline void at91_usart_spi_tx (struct at91_usart_spi *aus) +{ +unsigned int len = aus->current_transfer->len; +unsigned int remaining = aus->current_tx_remaining_bytes; +const u8 *tx_buf = aus->current_transfer->tx_buf; + +if (tx_buf && remaining) { +if (at91_usart_spi_tx_ready (aus)) +spi_writel (aus,THR , tx_buf[len - remaining]); + aus->current_tx_remaining_bytes--;
Missing braces here - we only write to the FIFO if there's space but we unconditionally decrement the counter.
drivers/spi/spi-at91-usart.c line 138
Quoted 5 lines
drivers/spi/spi-at91-usart.c new file +5
-0+ }else { +if (at91_usart_spi_tx_ready (aus)) +spi_writel (aus,THR ,US_DUMMY_TX ); + } +}
This looks like you're open coding SPI_CONTROLLER_MUST_TX
drivers/spi/spi-at91-usart.c line 151
Quoted 10 lines
drivers/spi/spi-at91-usart.c new file +10
-0+int len = aus->current_transfer->len; +int remaining = aus->current_rx_remaining_bytes; +u8 *rx_buf = aus->current_transfer->rx_buf; + +if (aus->current_rx_remaining_bytes) { + rx_buf[len - remaining] =spi_readb (aus,RHR ); + aus->current_rx_remaining_bytes--; + }else { +spi_readb (aus,RHR ); + }
Similarly for _MUST_RX.
drivers/spi/spi-at91-usart.c line 457
Quoted 1 line
drivers/spi/spi-at91-usart.c new file +1
-0+ controller->flags =SPI_MASTER_MUST_RX |SPI_MASTER_MUST_TX ;
You're actually setting both flags... this means that the handling for
cases with missing TX or RX buffers can't happen.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180517/75f75572/attachment-0001.sig>
Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
Quoted 14 lines · Mark Brown
drivers/spi/Kconfig config SPI_ATMEL · line 88
Quoted 9 lines · Radu Pirea
drivers/spi/Kconfig +9
-0+config SPI_AT91_USART + tristate "Atmel USART Controller as SPI" + depends on HAS_DMA + depends on (ARCH_AT91 || COMPILE_TEST) + select MFD_AT91_USART + help + This selects a driver for the AT91 USART Controller as SPI Master, + present on AT91 and SAMA5 SoC series. +This looks like there's some tab/space mixing going on here.
Quoted 8 lines
drivers/spi/spi-at91-usart.c line 5
Quoted 5 lines
drivers/spi/spi-at91-usart.c new file +5
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* Driver for AT91 USART Controllers as SPI +* +* Copyright (C) 2018 Microchip Technology Inc. Make the entire block a C++ comment so it looks more intentional rather tha mixing C and C++.
Hi Mark,
I know it's ugly, but SPDX license identifier must be in a separate comment block.
Quoted 15 lines
drivers/spi/spi-at91-usart.c line 133
Quoted 11 lines
drivers/spi/spi-at91-usart.c new file +10
-0+static inline void at91_usart_spi_tx (struct at91_usart_spi *aus) +{ +unsigned int len = aus->current_transfer->len; +unsigned int remaining = aus->current_tx_remaining_bytes; +const u8 *tx_buf = aus->current_transfer->tx_buf; + +if (tx_buf && remaining) { +if (at91_usart_spi_tx_ready (aus)) +spi_writel (aus,THR , tx_buf[len - remaining]); + aus->current_tx_remaining_bytes--;Missing braces here - we only write to the FIFO if there's space but we unconditionally decrement the counter.
Thanks. I will fix it.
Quoted 21 lines
drivers/spi/spi-at91-usart.c line 138
Quoted 5 lines
drivers/spi/spi-at91-usart.c new file +5
-0+ }else { +if (at91_usart_spi_tx_ready (aus)) +spi_writel (aus,THR ,US_DUMMY_TX ); + } +}This looks like you're open coding
SPI_CONTROLLER_MUST_TXdrivers/spi/spi-at91-usart.c line 151
Quoted 10 lines
drivers/spi/spi-at91-usart.c new file +10
-0+int len = aus->current_transfer->len; +int remaining = aus->current_rx_remaining_bytes; +u8 *rx_buf = aus->current_transfer->rx_buf; + +if (aus->current_rx_remaining_bytes) { + rx_buf[len - remaining] =spi_readb (aus,RHR ); + aus->current_rx_remaining_bytes--; + }else { +spi_readb (aus,RHR ); + }Similarly for
_MUST_RX.
Quoted 4 lines
drivers/spi/spi-at91-usart.c line 457
Quoted 1 line
drivers/spi/spi-at91-usart.c new file +1
-0+ controller->flags =SPI_MASTER_MUST_RX |SPI_MASTER_MUST_TX ;You're actually setting both flags... this means that the handling for cases with missing TX or RX buffers can't happen.
Sorry. My mistake. I will remove unnecessary code.
Mark Brown
maintainerRe: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi
Quoted 11 lines · Radu Pirea
Quoted 8 lines · Mark Brown
drivers/spi/spi-at91-usart.c line 5
Quoted 5 lines
drivers/spi/spi-at91-usart.c new file +5
-0+// SPDX-License-Identifier: GPL-2.0 +/* +* Driver for AT91 USART Controllers as SPI +* +* Copyright (C) 2018 Microchip Technology Inc. Make the entire block a C++ comment so it looks more intentional rather tha mixing C and C++.
Quoted 2 lines
I know it's ugly, but SPDX license identifier must be in a separate comment block.
No, it doesn't - it just needs to be the first line of the file.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180523/77fafae7/attachment.sig>
PATCH v3 6/6 tty/serial: atmel: changed the driver to work under at91-usart mfd
In reply to Radu PireaThis patch modifies the place where resources and device tree properties are searched.
--- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/atmel_serial.c | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-)
drivers/tty/serial/Kconfig +1 -0
@@ -119,6 +119,7 @@ config SERIAL_ATMEL depends on ARCH_AT91 || COMPILE_TEST select SERIAL_CORE select SERIAL_MCTRL_GPIO if GPIOLIB + select MFD_AT91_USART help This enables the driver for the on-chip UARTs of the Atmel AT91 processors.
drivers/tty/serial/atmel_serial.c +15 -14
@@ -193,8 +193,8 @@ static struct console atmel_console;#if defined(CONFIG_OF )static const struct of_device_id atmel_serial_dt_ids[] = { - { .compatible ="atmel,at91rm9200-usart" }, - { .compatible ="atmel,at91sam9260-usart" }, + { .compatible ="atmel,at91rm9200-usart-serial" }, + { .compatible ="atmel,at91sam9260-usart-serial" }, {/* sentinel */ } };#endif
@@ -1631,7 +1631,7 @@ static void atmel_tasklet_tx_func(unsigned long data)static void atmel_init_property (struct atmel_uart_port *atmel_port,struct platform_device *pdev) { -struct device_node *np = pdev->dev.of_node; +struct device_node *np = pdev->dev.parent->of_node;/* DMA/PDC usage specification */ if (of_property_read_bool (np,"atmel,use-dma-rx" )) {
@@ -2223,7 +2223,8 @@ static const char *atmel_type(struct uart_port *port)static void atmel_release_port (struct uart_port *port) {struct platform_device *pdev =to_platform_device (port->dev); -int size = pdev->resource[0 ].end - pdev->resource[0 ].start +1 ; +int size =to_platform_device (pdev->dev.parent)->resource[0 ].end - +to_platform_device (pdev->dev.parent)->resource[0 ].start +1 ;release_mem_region (port->mapbase, size);
@@ -2239,7 +2240,8 @@ static void atmel_release_port(struct uart_port *port)static int atmel_request_port (struct uart_port *port) {struct platform_device *pdev =to_platform_device (port->dev); -int size = pdev->resource[0 ].end - pdev->resource[0 ].start +1 ; +int size =to_platform_device (pdev->dev.parent)->resource[0 ].end - +to_platform_device (pdev->dev.parent)->resource[0 ].start +1 ;if (!request_mem_region (port->mapbase, size,"atmel_serial" ))return -EBUSY ;
@@ -2345,23 +2347,23 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,atmel_init_property (atmel_port, pdev);atmel_set_ops (port); -uart_get_rs485_mode (&pdev->dev, &port->rs485); +uart_get_rs485_mode (pdev->dev.parent, &port->rs485); port->iotype =UPIO_MEM ; port->flags =UPF_BOOT_AUTOCONF |UPF_IOREMAP ; port->ops = &atmel_pops; port->fifosize =1 ; port->dev = &pdev->dev; - port->mapbase = pdev->resource[0 ].start; - port->irq = pdev->resource[1 ].start; + port->mapbase =to_platform_device (pdev->dev.parent)->resource[0 ].start; + port->irq =to_platform_device (pdev->dev.parent)->resource[1 ].start; port->rs485_config = atmel_config_rs485; - port->membase =NULL ; + port->membase =NULL ;memset (&atmel_port->rx_ring,0 ,sizeof (atmel_port->rx_ring));/* for console, the clock could already be configured */ if (!atmel_port->clk) { - atmel_port->clk =clk_get (&pdev->dev,"usart" ); + atmel_port->clk =clk_get (pdev->dev.parent,"usart" );if (IS_ERR (atmel_port->clk)) { ret =PTR_ERR (atmel_port->clk); atmel_port->clk =NULL ;
@@ -2656,7 +2658,7 @@ static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port, atmel_port->rts_low =0 ; atmel_port->rts_high =0 ; -if (of_property_read_u32 (pdev->dev.of_node, +if (of_property_read_u32 (pdev->dev.parent->of_node,"atmel,fifo-size" , &atmel_port->fifo_size))return ;
@@ -2694,11 +2696,10 @@ static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port,static int atmel_serial_probe (struct platform_device *pdev) {struct atmel_uart_port *atmel_port; -struct device_node *np = pdev->dev.of_node; +struct device_node *np = pdev->dev.parent->of_node;void *data;int ret = -ENODEV ;bool rs485_enabled; -BUILD_BUG_ON (ATMEL_SERIAL_RINGSIZE & (ATMEL_SERIAL_RINGSIZE -1 )); ret =of_alias_get_id (np,"serial" );
@@ -2845,7 +2846,7 @@ static struct platform_driver atmel_serial_driver = { .suspend = atmel_serial_suspend, .resume = atmel_serial_resume, .driver = { - .name = "atmel_usart", + .name = "atmel_usart_serial", .of_match_table = of_match_ptr(atmel_serial_dt_ids), }, };
Signature · 1 line
2.17.0
Re: [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd
Hi,
Quoted 46 lines · Radu Pirea
This patch modifies the place where resources and device tree properties are searched.
Signed-off-by Radu Pirea <[email protected]>--- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/atmel_serial.c | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-)drivers/tty/serial/Kconfig +1
-0@@ -119,6 +119,7 @@ config SERIAL_ATMEL depends on ARCH_AT91 || COMPILE_TEST select SERIAL_CORE select SERIAL_MCTRL_GPIO if GPIOLIB + select MFD_AT91_USART help This enables the driver for the on-chip UARTs of the Atmel AT91 processors.drivers/tty/serial/atmel_serial.c +3
-3@@ -193,8 +193,8 @@ static struct console atmel_console;#if defined(CONFIG_OF )static const struct of_device_id atmel_serial_dt_ids[] = { - { .compatible ="atmel,at91rm9200-usart" }, - { .compatible ="atmel,at91sam9260-usart" }, + { .compatible ="atmel,at91rm9200-usart-serial" }, + { .compatible ="atmel,at91sam9260-usart-serial" }, {/* sentinel */ } };#endif @@ -1631,7 +1631,7 @@ static void atmel_tasklet_tx_func(unsigned long data)static void atmel_init_property (struct atmel_uart_port *atmel_port,struct platform_device *pdev) { -struct device_node *np = pdev->dev.of_node; +struct device_node *np = pdev->dev.parent->of_node;/* DMA/PDC usage specification */ if (of_property_read_bool (np,"atmel,use-dma-rx" )) {
drivers/tty/serial/atmel_serial.c static const char *atmel_type(struct uart_port *port) · line 2227
Quoted 6 lines
drivers/tty/serial/atmel_serial.c +2
-1@@ -2223,7 +2223,8 @@ static const char *atmel_type(struct uart_port *port)static void atmel_release_port (struct uart_port *port) {struct platform_device *pdev =to_platform_device (port->dev); -int size = pdev->resource[0 ].end - pdev->resource[0 ].start +1 ; +int size =to_platform_device (pdev->dev.parent)->resource[0 ].end - +to_platform_device (pdev->dev.parent)->resource[0 ].start +1 ;
I think it may be simpler with something like:
+ struct platform_device *mfd_pdev = to_platform_device(port->dev->parent);
+ int size = mfd_pdev->resource[0].end - mfd_pdev->resource[0].start + 1;
drivers/tty/serial/atmel_serial.c static void atmel_release_port(struct uart_port *port) · line 2245
Quoted 11 lines
drivers/tty/serial/atmel_serial.c +2
-1release_mem_region (port->mapbase, size);@@ -2239,7 +2240,8 @@ static void atmel_release_port(struct uart_port *port)static int atmel_request_port (struct uart_port *port) {struct platform_device *pdev =to_platform_device (port->dev); -int size = pdev->resource[0 ].end - pdev->resource[0 ].start +1 ; +int size =to_platform_device (pdev->dev.parent)->resource[0 ].end - +to_platform_device (pdev->dev.parent)->resource[0 ].start +1 ;
ditto
drivers/tty/serial/atmel_serial.c static int atmel_init_port(struct atmel_uart_port *atmel_port,
Quoted 3 lines
drivers/tty/serial/atmel_serial.c +0
-0if (!request_mem_region (port->mapbase, size,"atmel_serial" ))return -EBUSY ;@@ -2345,23 +2347,23 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,
Here, we could also add:
+ struct device *mfd_dev = pdev->dev.parent;
+ struct platform_device *mfd_pdev = to_platform_device(mfd_dev);
drivers/tty/serial/atmel_serial.c static int atmel_init_port(struct atmel_uart_port *atmel_port, · line 2350
Quoted 5 lines
drivers/tty/serial/atmel_serial.c +1
-1atmel_init_property (atmel_port, pdev);atmel_set_ops (port); -uart_get_rs485_mode (&pdev->dev, &port->rs485); +uart_get_rs485_mode (pdev->dev.parent, &port->rs485);
...and use them here
drivers/tty/serial/atmel_serial.c static int atmel_init_port(struct atmel_uart_port *atmel_port, · line 2358
Quoted 10 lines
drivers/tty/serial/atmel_serial.c +2
-2port->iotype =UPIO_MEM ; port->flags =UPF_BOOT_AUTOCONF |UPF_IOREMAP ; port->ops = &atmel_pops; port->fifosize =1 ; port->dev = &pdev->dev; - port->mapbase = pdev->resource[0 ].start; - port->irq = pdev->resource[1 ].start; + port->mapbase =to_platform_device (pdev->dev.parent)->resource[0 ].start; + port->irq =to_platform_device (pdev->dev.parent)->resource[1 ].start;
and here
I think it would be easier to read.
drivers/tty/serial/atmel_serial.c static int atmel_init_port(struct atmel_uart_port *atmel_port, · line 2366
Quoted 10 lines
drivers/tty/serial/atmel_serial.c +2
-2port->rs485_config = atmel_config_rs485; - port->membase =NULL ; + port->membase =NULL ;memset (&atmel_port->rx_ring,0 ,sizeof (atmel_port->rx_ring));/* for console, the clock could already be configured */ if (!atmel_port->clk) { - atmel_port->clk =clk_get (&pdev->dev,"usart" ); + atmel_port->clk =clk_get (pdev->dev.parent,"usart" );
and here
Quoted 13 lines
drivers/tty/serial/atmel_serial.c +1
-1if (IS_ERR (atmel_port->clk)) { ret =PTR_ERR (atmel_port->clk); atmel_port->clk =NULL ;@@ -2656,7 +2658,7 @@ static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port, atmel_port->rts_low =0 ; atmel_port->rts_high =0 ; -if (of_property_read_u32 (pdev->dev.of_node, +if (of_property_read_u32 (pdev->dev.parent->of_node,"atmel,fifo-size" , &atmel_port->fifo_size))return ;
drivers/tty/serial/atmel_serial.c static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port, · line 2701
Quoted 9 lines
drivers/tty/serial/atmel_serial.c +1
-2@@ -2694,11 +2696,10 @@ static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port,static int atmel_serial_probe (struct platform_device *pdev) {struct atmel_uart_port *atmel_port; -struct device_node *np = pdev->dev.of_node; +struct device_node *np = pdev->dev.parent->of_node;void *data;int ret = -ENODEV ;bool rs485_enabled; -
I think this line feed wasn't so bad.
drivers/tty/serial/atmel_serial.c static struct platform_driver atmel_serial_driver = { · line 2852
Quoted 13 lines
drivers/tty/serial/atmel_serial.c +1
-1BUILD_BUG_ON (ATMEL_SERIAL_RINGSIZE & (ATMEL_SERIAL_RINGSIZE -1 )); ret =of_alias_get_id (np,"serial" );@@ -2845,7 +2846,7 @@ static struct platform_driver atmel_serial_driver = { .suspend = atmel_serial_suspend, .resume = atmel_serial_resume, .driver = { - .name = "atmel_usart", + .name = "atmel_usart_serial", .of_match_table = of_match_ptr(atmel_serial_dt_ids), }, };
After your patch, the DMA is not selected anymore:atmel_usart_serial atmel_usart_serial.0.auto: TX channel not available, switch to pio instead of:atmel_usart fffff200.serial: using dma1chan2 for tx DMA transfers
And the kernel doesn't log anymore on the serial console, despite the loglevel=8 (after reverting this series, the kernel logs reappears on the serial console)
(tests done on sam9g35)
regards,
Richard
Re: [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd
Quoted 7 lines · Richard Genoud
Quoted 2 lines · Radu Pirea
This patch modifies the place where resources and device tree properties are searched.
I think it may be simpler with something like:
+ int size = mfd_pdev->resource[0].end - mfd_pdev->resource[0].start + 1;
Isn't resource_size() macro for this very purpose?
Quoted 4 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ int size = to_platform_device(pdev->dev.parent)->resource[0].end - + to_platform_device(pdev->dev.parent)->resource[0].start + 1;ditto
Ditto.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd
Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Richard Genoud
Quoted 2 lines · Radu Pirea
This patch modifies the place where resources and device tree properties are searched.
I think it may be simpler with something like:
+ int size = mfd_pdev->resource[0].end - mfd_pdev->resource[0].start + 1;
Isn't
resource_size()macro for this very purpose?
Indeed.
+ int size = resource_size(mfd_pdev->resource);
would be even simpler !
Quoted 8 lines
Quoted 5 lines
Review
Quoted 4 lines
(quoted diff) +2
-0+ int size = to_platform_device(pdev->dev.parent)->resource[0].end - + to_platform_device(pdev->dev.parent)->resource[0].start + 1;ditto
Ditto.
Thanks !
Richard.
Re: [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd
In reply to Richard GenoudQuoted 186 lines · Richard Genoud
Hi,
Quoted 63 lines · Radu Pirea
This patch modifies the place where resources and device tree properties
are searched.Signed-off-by Radu Pirea <[email protected]>--- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/atmel_serial.c | 29 +++++++++++++++---------- ---- 2 files changed, 16 insertions(+), 14 deletions(-)drivers/tty/serial/Kconfig +1
-0@@ -119,6 +119,7 @@ config SERIAL_ATMEL depends on ARCH_AT91 || COMPILE_TEST select SERIAL_CORE select SERIAL_MCTRL_GPIO if GPIOLIB + select MFD_AT91_USART help This enables the driver for the on-chip UARTs of theAtmel
drivers/tty/serial/Kconfig +0
-0AT91 processors.drivers/tty/serial/atmel_serial.c +3
-3@@ -193,8 +193,8 @@ static struct console atmel_console;#if defined(CONFIG_OF )static const struct of_device_id atmel_serial_dt_ids[] = { - { .compatible ="atmel,at91rm9200-usart" }, - { .compatible ="atmel,at91sam9260-usart" }, + { .compatible ="atmel,at91rm9200-usart-serial" }, + { .compatible ="atmel,at91sam9260-usart-serial" }, {/* sentinel */ } };#endif @@ -1631,7 +1631,7 @@ static void atmel_tasklet_tx_func(unsigned long data)static void atmel_init_property (struct atmel_uart_port *atmel_port,struct platform_device *pdev) { -struct device_node *np = pdev->dev.of_node; +struct device_node *np = pdev->dev.parent->of_node;drivers/tty/serial/atmel_serial.c +2
-1/* DMA/PDC usage specification */ if (of_property_read_bool (np,"atmel,use-dma-rx" )) {@@ -2223,7 +2223,8 @@ static const char *atmel_type(struct uart_port *port)static void atmel_release_port (struct uart_port *port) {struct platform_device *pdev =to_platform_device (port- >dev); -int size = pdev->resource[0 ].end - pdev->resource[0 ].start +1 ; + int size = to_platform_device(pdev->dev.parent)-Quoted 1 line
resource[0].end -
drivers/tty/serial/atmel_serial.c +1
-0+ to_platform_device(pdev->dev.parent)-Quoted 1 line
Quoted 1 line
resource[0].start + 1;
I think it may be simpler with something like:
(quoted diff) +1
-0+ struct platform_device *mfd_pdev = to_platform_device(port-Quoted 1 line
dev->parent);(quoted diff) +1
-0+ int size = mfd_pdev->resource[0].end - mfd_pdev-Quoted 16 lines
resource[0].start + 1;
drivers/tty/serial/atmel_serial.c +2
-1release_mem_region (port->mapbase, size);@@ -2239,7 +2240,8 @@ static void atmel_release_port(struct uart_port *port)static int atmel_request_port (struct uart_port *port) {struct platform_device *pdev =to_platform_device (port- >dev); -int size = pdev->resource[0 ].end - pdev->resource[0 ].start +1 ; + int size = to_platform_device(pdev->dev.parent)-Quoted 1 line
resource[0].end -
drivers/tty/serial/atmel_serial.c +1
-0+ to_platform_device(pdev->dev.parent)-Quoted 2 lines
Quoted 1 line
resource[0].start + 1;
ditto
drivers/tty/serial/atmel_serial.c static int atmel_init_port(struct · line 2347
Quoted 5 lines
if (!request_mem_region(port->mapbase, size,
"atmel_serial"))drivers/tty/serial/atmel_serial.c +0
-0return -EBUSY ;@@ -2345,23 +2347,23 @@ static int atmel_init_port(struct atmel_uart_port *atmel_port,Here, we could also add:
(quoted diff) +2
-0+ struct device *mfd_dev = pdev->dev.parent; + struct platform_device *mfd_pdev =
to_platform_device(mfd_dev);drivers/tty/serial/atmel_serial.c static int atmel_init_port(struct atmel_uart_port *atmel_port, · line 2350
Quoted 5 lines
drivers/tty/serial/atmel_serial.c +1
-1atmel_init_property (atmel_port, pdev);atmel_set_ops (port); -uart_get_rs485_mode (&pdev->dev, &port->rs485); +uart_get_rs485_mode (pdev->dev.parent, &port->rs485);...and use them here
drivers/tty/serial/atmel_serial.c static int atmel_init_port(struct atmel_uart_port *atmel_port,
Quoted 13 lines
drivers/tty/serial/atmel_serial.c +2
-2port->iotype =UPIO_MEM ; port->flags =UPF_BOOT_AUTOCONF |UPF_IOREMAP ; port->ops = &atmel_pops; port->fifosize =1 ; port->dev = &pdev->dev; - port->mapbase = pdev->resource[0 ].start; - port->irq = pdev->resource[1 ].start; + port->mapbase =to_platform_device (pdev- >dev.parent)->resource[0].start; + port->irq =to_platform_device (pdev- >dev.parent)->resource[1].start;and here
I think it would be easier to read.Quoted 11 lines
drivers/tty/serial/atmel_serial.c +2
-2port->rs485_config = atmel_config_rs485; - port->membase =NULL ; + port->membase =NULL ;memset (&atmel_port->rx_ring,0 ,sizeof (atmel_port- >rx_ring));/* for console, the clock could already be configured */ if (!atmel_port->clk) { - atmel_port->clk =clk_get (&pdev->dev,"usart" ); + atmel_port->clk = clk_get(pdev->dev.parent,Quoted 1 line
"usart");
and here
Quoted 14 lines
drivers/tty/serial/atmel_serial.c +1
-1if (IS_ERR (atmel_port->clk)) { ret =PTR_ERR (atmel_port->clk); atmel_port->clk =NULL ;@@ -2656,7 +2658,7 @@ static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port, atmel_port->rts_low =0 ; atmel_port->rts_high =0 ; -if (of_property_read_u32 (pdev->dev.of_node, +if (of_property_read_u32 (pdev->dev.parent->of_node,"atmel,fifo-size" , &atmel_port->fifo_size))drivers/tty/serial/atmel_serial.c +0
-0return ;drivers/tty/serial/atmel_serial.c static void atmel_serial_probe_fifos(struct · line 2702
Quoted 10 lines
drivers/tty/serial/atmel_serial.c +1
-2@@ -2694,11 +2696,10 @@ static void atmel_serial_probe_fifos(structatmel_uart_port *atmel_port, static int atmel_serial_probe(struct platform_device *pdev) { struct atmel_uart_port *atmel_port; -struct device_node *np = pdev->dev.of_node; +struct device_node *np = pdev->dev.parent->of_node;void *data;int ret = -ENODEV ;bool rs485_enabled; -I think this line feed wasn't so bad.
Quoted 15 lines
drivers/tty/serial/atmel_serial.c +0
-0BUILD_BUG_ON (ATMEL_SERIAL_RINGSIZE & (ATMEL_SERIAL_RINGSIZE -1 ));drivers/tty/serial/atmel_serial.c +1
-1ret =of_alias_get_id (np,"serial" );@@ -2845,7 +2846,7 @@ static struct platform_driver atmel_serial_driver = { .suspend = atmel_serial_suspend, .resume = atmel_serial_resume, .driver = { - .name ="atmel_usart" , + .name = "atmel_usart_serial", .of_match_table =
of_match_ptr(atmel_serial_dt_ids),
},
Quoted 9 lines
Quoted 2 lines
};
After your patch, the DMA is not selected anymore:
atmel_usart_serialatmel_usart_serial.0.auto: TX channel not available, switch to pio
instead of:atmel_usartfffff200.serial: using dma1chan2 for tx DMA transfers
Fixed.
Quoted 5 lines
And the kernel doesn't log anymore on the serial console, despite the loglevel=8
(after reverting this series, the kernel logs reappears on the serial console)
Which serial are you using as console?
Quoted 2 lines
(tests done on sam9g35)
I will consider the rest of suggestions.
Quoted 3 lines
regards,
Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180515/f865516c/attachment.sig>
Re: [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd
Quoted 7 lines · Radu Pirea
Quoted 6 lines · Richard Genoud
After your patch, the DMA is not selected anymore:
atmel_usart_serialatmel_usart_serial.0.auto: TX channel not available, switch to pio
instead of:atmel_usartfffff200.serial: using dma1chan2 for tx DMA transfers
Quoted 7 lines
Fixed.
Quoted 5 lines
And the kernel doesn't log anymore on the serial console, despite the loglevel=8
(after reverting this series, the kernel logs reappears on the serial console)Which serial are you using as console?
fffff200.serial (sam9g35-cm)
( stdout-path = "serial0:115200n8"; in the DTS )
With this series applied, all the kernel log goes on the screen. Without, it goes on the serial debug.
Quoted 5 lines
Quoted 2 lines
(tests done on sam9g35)
I will consider the rest of suggestions.
Quoted 2 lines
regards,
Richard
Re: [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd
Quoted 14 lines · Richard Genoud
Quoted 13 lines · Radu Pirea
Quoted 6 lines · Richard Genoud
After your patch, the DMA is not selected anymore:
atmel_usart_serialatmel_usart_serial.0.auto: TX channel not available, switch to pio
instead of:atmel_usartfffff200.serial: using dma1chan2 for tx DMA transfersFixed.
Quoted 5 lines
And the kernel doesn't log anymore on the serial console, despite the loglevel=8
(after reverting this series, the kernel logs reappears on the serial console)
Quoted 7 lines
Quoted 1 line
Which serial are you using as console?
fffff200.serial (sam9g35-cm)
( stdout-path = "serial0:115200n8"; in the DTS )With this series applied, all the kernel log goes on the screen. Without, it goes on the serial debug.
I tested again with archlinux arm and poky-linux4sam release as distros and kernel log goes on the serial debug. Can you give me more details like cmdline?
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
(tests done on sam9g35)
I will consider the rest of suggestions.
Quoted 2 lines
regards,
Richard
Re: [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd
Quoted 21 lines · Radu Pirea
Quoted 18 lines · Richard Genoud
Quoted 7 lines · Radu Pirea
Quoted 6 lines · Richard Genoud
After your patch, the DMA is not selected anymore:
atmel_usart_serialatmel_usart_serial.0.auto: TX channel not available, switch to pio
instead of:atmel_usartfffff200.serial: using dma1chan2 for tx DMA transfersQuoted 7 lines
Fixed.
Quoted 5 lines
And the kernel doesn't log anymore on the serial console, despite the loglevel=8
(after reverting this series, the kernel logs reappears on the serial console)Which serial are you using as console?
fffff200.serial (sam9g35-cm)
( stdout-path = "serial0:115200n8"; in the DTS )
Quoted 6 lines
Quoted 3 lines
With this series applied, all the kernel log goes on the screen. Without, it goes on the serial debug.
I tested again with archlinux arm and poky-linux4sam release as distros and kernel log goes on the serial debug. Can you give me more details like cmdline?
I used kernel 4.17-rc6at91_dt_defconfig
at91sam9g35ek.dtb
Kernel command line: root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs ( the one from the DTS )
Detailed instructions:
git checkout v4.17-rc6
ARCH=arm CROSS_COMPILE=path_to_my_Xchain/arm-linux- LOADADDR=0x20008000 make -j 12 at91_dt_defconfig ARCH=arm CROSS_COMPILE=path_to_my_Xchain/arm-linux- LOADADDR=0x20008000 make -j 12 uImage at91sam9g35ek.dtb cp arch/arm/boot/uImage arch/arm/boot/dts/at91sam9g35ek.dtb /tftpboot/
Quoted 1 line
From uboot:
tftpboot 0x20007FC0 uImage
tftpboot 0x26400000 at91sam9g35ek.dtb
bootm 0x20007FC0 - 0x26400000
[ I see the logs on the serial debug ]
git am \[PATCH\ v3\ [1-6]*
ARCH=arm CROSS_COMPILE=path_to_my_Xchain/arm-linux- LOADADDR=0x20008000 make -j 12 uImage at91sam9g35ek.dtb cp arch/arm/boot/uImage arch/arm/boot/dts/at91sam9g35ek.dtb /tftpboot/
Quoted 1 line
From uboot:
tftpboot 0x20007FC0 uImage
tftpboot 0x26400000 at91sam9g35ek.dtb
bootm 0x20007FC0 - 0x26400000
[ I don't see the logs on the serial debug anymore ]
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
(tests done on sam9g35)
I will consider the rest of suggestions.
Quoted 2 lines
regards,
Richard
Re: [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd
Quoted 25 lines · Richard Genoud
Quoted 24 lines · Radu Pirea
Quoted 21 lines · Richard Genoud
Quoted 7 lines · Radu Pirea
Quoted 6 lines · Richard Genoud
After your patch, the DMA is not selected anymore:
atmel_usart_serialatmel_usart_serial.0.auto: TX channel not available, switch to pio
instead of:atmel_usartfffff200.serial: using dma1chan2 for tx DMA transfersQuoted 7 lines
Fixed.
Quoted 5 lines
And the kernel doesn't log anymore on the serial console, despite the loglevel=8
(after reverting this series, the kernel logs reappears on the serial console)Which serial are you using as console?
fffff200.serial (sam9g35-cm)
( stdout-path = "serial0:115200n8"; in the DTS )With this series applied, all the kernel log goes on the screen. Without, it goes on the serial debug.
Quoted 8 lines
Quoted 3 lines
I tested again with archlinux arm and poky-linux4sam release as distros and kernel log goes on the serial debug. Can you give me more details like cmdline?
I used kernel 4.17-rc6
at91_dt_defconfig
at91sam9g35ek.dtbKernel command line: root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs
I reproduced your issue.
If in cmdline console is not set like this "console=ttyS0,115200", the console goes to the lcd.
Quoted 36 lines
( the one from the DTS )
Detailed instructions:
git checkout v4.17-rc6
ARCH=arm CROSS_COMPILE=path_to_my_Xchain/arm-linux- LOADADDR=0x20008000 make -j 12at91_dt_defconfigARCH=arm CROSS_COMPILE=path_to_my_Xchain/arm-linux- LOADADDR=0x20008000 make -j 12 uImage at91sam9g35ek.dtb cparch/arm/boot/uImagearch/arm/boot/dts/at91sam9g35ek.dtb/tftpboot/From uboot:
tftpboot0x20007FC0uImage
tftpboot0x26400000at91sam9g35ek.dtb
bootm0x20007FC0-0x26400000[ I see the logs on the serial debug ]
git am \[PATCH\ v3\ [1-6]*
ARCH=arm CROSS_COMPILE=path_to_my_Xchain/arm-linux- LOADADDR=0x20008000 make -j 12 uImage at91sam9g35ek.dtb cp
arch/arm/boot/uImagearch/arm/boot/dts/at91sam9g35ek.dtb/tftpboot/From uboot:
tftpboot0x20007FC0uImage
tftpboot0x26400000at91sam9g35ek.dtb
bootm0x20007FC0-0x26400000[ I don't see the logs on the serial debug anymore ]
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
(tests done on sam9g35)
I will consider the rest of suggestions.
Quoted 2 lines
regards,
Richard