* Re: [RFC 1/3] serdev: Add ACPI support
From: Frédéric Danis @ 2017-09-29 12:17 UTC (permalink / raw)
To: Marcel Holtmann
Cc: Rob Herring, sre, loic.poulain, linux-bluetooth, linux-serial,
linux-acpi, johan
In-Reply-To: <D48CDCC9-F039-4E80-BA12-5A579E13E09F@holtmann.org>
Hi Marcel,
Le 29/09/2017 à 14:00, Marcel Holtmann a écrit :
> Hi Fred,
>
>>>>> +#ifdef CONFIG_ACPI
>>>>> +static acpi_status acpi_serdev_register_device(struct serdev_controller *ctrl,
>>>>> + struct acpi_device *adev)
>>>>> +{
>>>>> + struct serdev_device *serdev = NULL;
>>>>> + int err;
>>>>> +
>>>>> + if (acpi_bus_get_status(adev) || !adev->status.present ||
>>>>> + acpi_device_enumerated(adev))
>>>>> + return AE_OK;
>>>>> +
>>>>> + serdev = serdev_device_alloc(ctrl);
>>>>> + if (!serdev) {
>>>>> + dev_err(&ctrl->dev, "failed to allocate Serial device for %s\n",
>>>>> + dev_name(&adev->dev));
>>>>> + return AE_NO_MEMORY;
>>>>> + }
>>>>> +
>>>>> + ACPI_COMPANION_SET(&serdev->dev, adev);
>>>>> + acpi_device_set_enumerated(adev);
>>>>> +
>>>>> + err = serdev_device_add(serdev);
>>>>> + if (err) {
>>>>> + dev_err(&serdev->dev,
>>>>> + "failure adding ACPI device. status %d\n", err);
>>>>> + serdev_device_put(serdev);
>>>>> + }
>>>>> +
>>>>> + return AE_OK;
>>>>> +}
>>>>> +
>>>>> +static acpi_status acpi_serdev_add_device(acpi_handle handle, u32 level,
>>>>> + void *data, void **return_value)
>>>>> +{
>>>>> + struct serdev_controller *ctrl = data;
>>>>> + struct acpi_device *adev;
>>>>> +
>>>>> + if (acpi_bus_get_device(handle, &adev))
>>>>> + return AE_OK;
>>>>> +
>>>>> + return acpi_serdev_register_device(ctrl, adev);
>>>>> +}
>>>>> +
>>>>> +static int acpi_serdev_register_devices(struct serdev_controller *ctrl)
>>>>> +{
>>>>> + acpi_status status;
>>>>> + acpi_handle handle;
>>>>> +
>>>>> + handle = ACPI_HANDLE(ctrl->dev.parent);
>>>>> + if (!handle)
>>>>> + return -ENODEV;
>>>>> +
>>>>> + status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
>>>>> + acpi_serdev_add_device, NULL, ctrl, NULL);
>>>>> + if (ACPI_FAILURE(status)) {
>>>>> + dev_warn(&ctrl->dev, "failed to enumerate Serial slaves\n");
>>>>> + return -ENODEV;
>>>>> + }
>>>>> +
>>>>> + return 0;
>>>>> +}
>>>> how are we ensuring that we only take UART devices into account here?
>>> acpi_serdev_add_device() callback will only take into account entries without enumerated flag set.
>>> This flags is set for all entries during ACPI scan, except for SPI and I2C serial devices, and for UART with 2nd patch in the series.
>> sounds good to me. Can you respin this series with the other comments addressed and maybe add some extra comments in the code or the commit message to make this clear.
> any updates on this?
While working on it, I tried to add the PM support
(bcm_serdev_driver.driver.pm = &bcm_pm_ops) but it ends up in kernel
freeze during suspend to ram test.
I may have found the problem but do not have access to T100 now to test
it (this may take some times as I work on it on spare time).
Regards,
Fred
^ permalink raw reply
* Re: [RFC 1/3] serdev: Add ACPI support
From: Marcel Holtmann @ 2017-09-29 12:00 UTC (permalink / raw)
To: Frédéric Danis
Cc: Rob Herring, sre, loic.poulain, linux-bluetooth, linux-serial,
linux-acpi
In-Reply-To: <AC100BF1-B6E9-47ED-95A0-7E7E75C0DE89@holtmann.org>
Hi Fred,
>>>> +#ifdef CONFIG_ACPI
>>>> +static acpi_status acpi_serdev_register_device(struct serdev_controller *ctrl,
>>>> + struct acpi_device *adev)
>>>> +{
>>>> + struct serdev_device *serdev = NULL;
>>>> + int err;
>>>> +
>>>> + if (acpi_bus_get_status(adev) || !adev->status.present ||
>>>> + acpi_device_enumerated(adev))
>>>> + return AE_OK;
>>>> +
>>>> + serdev = serdev_device_alloc(ctrl);
>>>> + if (!serdev) {
>>>> + dev_err(&ctrl->dev, "failed to allocate Serial device for %s\n",
>>>> + dev_name(&adev->dev));
>>>> + return AE_NO_MEMORY;
>>>> + }
>>>> +
>>>> + ACPI_COMPANION_SET(&serdev->dev, adev);
>>>> + acpi_device_set_enumerated(adev);
>>>> +
>>>> + err = serdev_device_add(serdev);
>>>> + if (err) {
>>>> + dev_err(&serdev->dev,
>>>> + "failure adding ACPI device. status %d\n", err);
>>>> + serdev_device_put(serdev);
>>>> + }
>>>> +
>>>> + return AE_OK;
>>>> +}
>>>> +
>>>> +static acpi_status acpi_serdev_add_device(acpi_handle handle, u32 level,
>>>> + void *data, void **return_value)
>>>> +{
>>>> + struct serdev_controller *ctrl = data;
>>>> + struct acpi_device *adev;
>>>> +
>>>> + if (acpi_bus_get_device(handle, &adev))
>>>> + return AE_OK;
>>>> +
>>>> + return acpi_serdev_register_device(ctrl, adev);
>>>> +}
>>>> +
>>>> +static int acpi_serdev_register_devices(struct serdev_controller *ctrl)
>>>> +{
>>>> + acpi_status status;
>>>> + acpi_handle handle;
>>>> +
>>>> + handle = ACPI_HANDLE(ctrl->dev.parent);
>>>> + if (!handle)
>>>> + return -ENODEV;
>>>> +
>>>> + status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
>>>> + acpi_serdev_add_device, NULL, ctrl, NULL);
>>>> + if (ACPI_FAILURE(status)) {
>>>> + dev_warn(&ctrl->dev, "failed to enumerate Serial slaves\n");
>>>> + return -ENODEV;
>>>> + }
>>>> +
>>>> + return 0;
>>>> +}
>>> how are we ensuring that we only take UART devices into account here?
>>
>> acpi_serdev_add_device() callback will only take into account entries without enumerated flag set.
>> This flags is set for all entries during ACPI scan, except for SPI and I2C serial devices, and for UART with 2nd patch in the series.
>
> sounds good to me. Can you respin this series with the other comments addressed and maybe add some extra comments in the code or the commit message to make this clear.
any updates on this?
Regards
Marcel
^ permalink raw reply
* [PATCH] serial: imx: Correct comment imx_flush_buffer()
From: Martyn Welch @ 2017-09-29 9:22 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Martyn Welch
The comment in imx_flush_buffer() states that the state of 4 registers
are to be saved/restored, then only saves and restores 3 registers. The
missing register (UBRC) is read only and thus can't be restored.
Update the comment to reflect reality.
Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
---
drivers/tty/serial/imx.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 474b5bc..63f544e 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1415,10 +1415,14 @@ static void imx_flush_buffer(struct uart_port *port)
/*
* According to the Reference Manual description of the UART SRST bit:
+ *
* "Reset the transmit and receive state machines,
* all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD
- * and UTS[6-3]". As we don't need to restore the old values from
- * USR1, USR2, URXD, UTXD, only save/restore the other four registers
+ * and UTS[6-3]".
+ *
+ * We don't need to restore the old values from USR1, USR2, URXD and
+ * UTXD. UBRC is read only, so only save/restore the other three
+ * registers.
*/
ubir = readl(sport->port.membase + UBIR);
ubmr = readl(sport->port.membase + UBMR);
--
1.8.3.1
^ permalink raw reply related
* [PATCH 2/3] Arm: dts: stm32: remove extra compatible string from DT & driver
From: Vikas Manocha @ 2017-09-28 22:51 UTC (permalink / raw)
To: linux-kernel
Cc: Vikas Manocha, alexandre.torgue, patrice.chotard,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
Greg Kroah-Hartman, Jiri Slaby, moderated list:ARM PORT,
open list:SERIAL DRIVERS, Mark Rutland, Maxime Coquelin,
Rob Herring, Russell King
In-Reply-To: <1506639114-16913-1-git-send-email-vikas.manocha@st.com>
This patch remove the extra compatibility string "st,stm32-usart" from
driver & device tree.
Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
---
arch/arm/boot/dts/stm32f429.dtsi | 12 ++++++------
arch/arm/boot/dts/stm32f746.dtsi | 12 ++++++------
arch/arm/boot/dts/stm32h743.dtsi | 4 ++--
drivers/tty/serial/stm32-usart.c | 3 ---
4 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi
index dd7e99b..5d6bfdf 100644
--- a/arch/arm/boot/dts/stm32f429.dtsi
+++ b/arch/arm/boot/dts/stm32f429.dtsi
@@ -315,7 +315,7 @@
};
usart2: serial@40004400 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40004400 0x400>;
interrupts = <38>;
clocks = <&rcc 0 STM32F4_APB1_CLOCK(UART2)>;
@@ -323,7 +323,7 @@
};
usart3: serial@40004800 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40004800 0x400>;
interrupts = <39>;
clocks = <&rcc 0 STM32F4_APB1_CLOCK(UART3)>;
@@ -387,7 +387,7 @@
};
usart7: serial@40007800 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40007800 0x400>;
interrupts = <82>;
clocks = <&rcc 0 STM32F4_APB1_CLOCK(UART7)>;
@@ -395,7 +395,7 @@
};
usart8: serial@40007c00 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40007c00 0x400>;
interrupts = <83>;
clocks = <&rcc 0 STM32F4_APB1_CLOCK(UART8)>;
@@ -445,7 +445,7 @@
};
usart1: serial@40011000 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40011000 0x400>;
interrupts = <37>;
clocks = <&rcc 0 STM32F4_APB2_CLOCK(USART1)>;
@@ -456,7 +456,7 @@
};
usart6: serial@40011400 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40011400 0x400>;
interrupts = <71>;
clocks = <&rcc 0 STM32F4_APB2_CLOCK(USART6)>;
diff --git a/arch/arm/boot/dts/stm32f746.dtsi b/arch/arm/boot/dts/stm32f746.dtsi
index 5633860..5f94178 100644
--- a/arch/arm/boot/dts/stm32f746.dtsi
+++ b/arch/arm/boot/dts/stm32f746.dtsi
@@ -136,7 +136,7 @@
};
usart2: serial@40004400 {
- compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+ compatible = "st,stm32f7-uart";
reg = <0x40004400 0x400>;
interrupts = <38>;
clocks = <&rcc 1 CLK_USART2>;
@@ -144,7 +144,7 @@
};
usart3: serial@40004800 {
- compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+ compatible = "st,stm32f7-uart";
reg = <0x40004800 0x400>;
interrupts = <39>;
clocks = <&rcc 1 CLK_USART3>;
@@ -177,7 +177,7 @@
};
usart7: serial@40007800 {
- compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+ compatible = "st,stm32f7-uart";
reg = <0x40007800 0x400>;
interrupts = <82>;
clocks = <&rcc 1 CLK_UART7>;
@@ -185,7 +185,7 @@
};
usart8: serial@40007c00 {
- compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+ compatible = "st,stm32f7-uart";
reg = <0x40007c00 0x400>;
interrupts = <83>;
clocks = <&rcc 1 CLK_UART8>;
@@ -193,7 +193,7 @@
};
usart1: serial@40011000 {
- compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+ compatible = "st,stm32f7-uart";
reg = <0x40011000 0x400>;
interrupts = <37>;
clocks = <&rcc 1 CLK_USART1>;
@@ -201,7 +201,7 @@
};
usart6: serial@40011400 {
- compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+ compatible = "st,stm32f7-uart";
reg = <0x40011400 0x400>;
interrupts = <71>;
clocks = <&rcc 1 CLK_USART6>;
diff --git a/arch/arm/boot/dts/stm32h743.dtsi b/arch/arm/boot/dts/stm32h743.dtsi
index 58ec227..26de315 100644
--- a/arch/arm/boot/dts/stm32h743.dtsi
+++ b/arch/arm/boot/dts/stm32h743.dtsi
@@ -67,7 +67,7 @@
};
usart2: serial@40004400 {
- compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+ compatible = "st,stm32f7-uart";
reg = <0x40004400 0x400>;
interrupts = <38>;
status = "disabled";
@@ -99,7 +99,7 @@
};
usart1: serial@40011000 {
- compatible = "st,stm32f7-usart", "st,stm32f7-uart";
+ compatible = "st,stm32f7-uart";
reg = <0x40011000 0x400>;
interrupts = <37>;
status = "disabled";
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 03a58326..46a1f86 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -736,11 +736,8 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev)
#ifdef CONFIG_OF
static const struct of_device_id stm32_match[] = {
- { .compatible = "st,stm32-usart", .data = &stm32f4_info},
{ .compatible = "st,stm32-uart", .data = &stm32f4_info},
- { .compatible = "st,stm32f7-usart", .data = &stm32f7_info},
{ .compatible = "st,stm32f7-uart", .data = &stm32f7_info},
- { .compatible = "st,stm32h7-usart", .data = &stm32h7_info},
{ .compatible = "st,stm32h7-uart", .data = &stm32h7_info},
{},
};
--
1.9.1
^ permalink raw reply related
* [PATCH 1/3] Arm: dts: stm32: remove extra compatible string for uart
From: Vikas Manocha @ 2017-09-28 22:51 UTC (permalink / raw)
To: linux-kernel
Cc: Vikas Manocha, alexandre.torgue, patrice.chotard,
open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM,
Greg Kroah-Hartman, moderated list:ARM/STM32 ARCHITECTURE,
open list:SERIAL DRIVERS, Mark Rutland, Maxime Coquelin,
Rob Herring, Vinod Koul
In-Reply-To: <1506639114-16913-1-git-send-email-vikas.manocha@st.com>
This patch removes the extra compatibility string "st,stm32-usart" to
avoid confusion, save some time & space.
Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
---
Documentation/devicetree/bindings/dma/stm32-dma.txt | 2 +-
Documentation/devicetree/bindings/serial/st,stm32-usart.txt | 10 +++-------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/Documentation/devicetree/bindings/dma/stm32-dma.txt b/Documentation/devicetree/bindings/dma/stm32-dma.txt
index 4408af6..6f44df9 100644
--- a/Documentation/devicetree/bindings/dma/stm32-dma.txt
+++ b/Documentation/devicetree/bindings/dma/stm32-dma.txt
@@ -71,7 +71,7 @@ channel: a phandle to the DMA controller plus the following four integer cells:
Example:
usart1: serial@40011000 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40011000 0x400>;
interrupts = <37>;
clocks = <&clk_pclk2>;
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
index 3657f9f..d150b04 100644
--- a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
+++ b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt
@@ -2,14 +2,10 @@
Required properties:
- compatible: can be either:
- - "st,stm32-usart",
- "st,stm32-uart",
- - "st,stm32f7-usart",
- "st,stm32f7-uart",
- - "st,stm32h7-usart"
- "st,stm32h7-uart".
- depending on whether the device supports synchronous mode
- and is compatible with stm32(f4), stm32f7 or stm32h7.
+ depending is compatible with stm32(f4), stm32f7 or stm32h7.
- reg: The address and length of the peripheral registers space
- interrupts:
- The interrupt line for the USART instance,
@@ -33,7 +29,7 @@ usart4: serial@40004c00 {
};
usart2: serial@40004400 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40004400 0x400>;
interrupts = <38>;
clocks = <&clk_pclk1>;
@@ -43,7 +39,7 @@ usart2: serial@40004400 {
};
usart1: serial@40011000 {
- compatible = "st,stm32-usart", "st,stm32-uart";
+ compatible = "st,stm32-uart";
reg = <0x40011000 0x400>;
interrupts = <37>;
clocks = <&rcc 0 164>;
--
1.9.1
^ permalink raw reply related
* RE: [patch v9 0/4] JTAG driver introduction
From: Oleksandr Shamray @ 2017-09-28 11:11 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Greg KH, Arnd Bergmann,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
openbmc-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org, Joel Stanley,
Jiri Pirko, Tobias Klauser,
linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
mec-WqBc5aa1uDFeoWH0uzbU5w@public.gmane.org, Vadim Pasternak,
system-sw-low-level, Rob Herring,
openocd-devel-owner-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CAMuHMdX1HNym4n67y2VbZqFDLHFGunfRp-LPn0g2K4qhya_w9g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> -----Original Message-----
> From: geert.uytterhoeven@gmail.com [mailto:geert.uytterhoeven@gmail.com]
> On Behalf Of Geert Uytterhoeven
> Sent: Thursday, September 28, 2017 12:02 PM
> To: Oleksandr Shamray <oleksandrs@mellanox.com>
> Cc: Greg KH <gregkh@linuxfoundation.org>; Arnd Bergmann
> <arnd@arndb.de>; linux-kernel@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; devicetree@vger.kernel.org;
> openbmc@lists.ozlabs.org; Joel Stanley <joel@jms.id.au>; Jiri Pirko
> <jiri@resnulli.us>; Tobias Klauser <tklauser@distanz.ch>; linux-
> serial@vger.kernel.org; mec@shout.net; Vadim Pasternak
> <vadimp@mellanox.com>; system-sw-low-level <system-sw-low-
> level@mellanox.com>; Rob Herring <robh+dt@kernel.org>; openocd-devel-
> owner@lists.sourceforge.net; linux-api@vger.kernel.org; David S. Miller
> <davem@davemloft.net>; Mauro Carvalho Chehab <mchehab@kernel.org>;
> linux-spi <linux-spi@vger.kernel.org>; Mark Brown <broonie@kernel.org>
> Subject: Re: [patch v9 0/4] JTAG driver introduction
>
> Hi Oleksandr,
>
> On Thu, Sep 28, 2017 at 10:53 AM, Oleksandr Shamray
> <oleksandrs@mellanox.com> wrote:
> >> [My attention was drawn by
> >> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flw
> >> n.net
> >>
> %2FArticles%2F734440%2F&data=02%7C01%7Coleksandrs%40mellanox.com%7
> >>
> C97b8ba88686a42daaace08d5064b92eb%7Ca652971c7d2e4d9ba6a4d149256f
> >>
> 461b%7C0%7C0%7C636421844026854216&sdata=TeHD4a3%2FBN6a5XG3Jizf5
> >> pmsyJHJjzkEzkpnqsXC6S0%3D&reserved=0]
> >> [CC linux-spi, which was never included, while linux-serial was]
> >>
> >> On Thu, Sep 21, 2017 at 11:25 AM, Oleksandr Shamray
> >> <oleksandrs@mellanox.com> wrote:
> >> > When a need raise up to use JTAG interface for system's devices
> >> > programming or CPU debugging, usually the user layer application
> >> > implements jtag protocol by bit-bang or using a proprietary
> >> > connection to vendor hardware.
> >> > This method can be slow and not generic.
> >> >
> >
> >
> > [..]
> >
> >> >
> >> > Initial version provides the system calls set for:
> >> > - SIR (Scan Instruction Register, IEEE 1149.1 Data Register scan);
> >> > - SDR (Scan Data Register, IEEE 1149.1 Instruction Register scan);
> >> > - RUNTEST (Forces the IEEE 1149.1 bus to a run state for a specified
> >> > number of clocks.
> >> >
> >> > SoC which are not equipped with JTAG master interface, can be built
> >> > on top of JTAG core driver infrastructure, by applying bit-banging
> >> > of TDI, TDO, TCK and TMS pins within the hardware specific driver.
> >>
> >> Or by using an SPI master?
> >>
> >
> > I think it depends on how flexible the SPI interface is. If you can
> > set it to transfer from 1 to n bits at a time, and you control the TMS
> > line in software, you should be able to use it. If the SPI interface
> > can only transfer a multiple of 8 bits at a time, then in general it would not be
> suitable for JTAG.
>
> Sure, that depends on the actual SPI master interface.
> But I guess you can write a generic JTAG-over-SPI driver, and use a tms-gpios
> property in DT to specify how to control TMS.
>
Yes, this is a good idea for SoC which are not equipped with JTAG hardware.
> 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
^ permalink raw reply
* [PATCH] serial: imx: Switch setting dma_is_txing from "false" to "0"
From: Martyn Welch @ 2017-09-28 10:38 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Martyn Welch
The variable "dma_is_txing" is an unsigned int, set as either "0" or "1"
in all but one location, where it is instead set to "false". For
consistency, set dma_is_txing to "0" in this location too.
Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
---
drivers/tty/serial/imx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 9da109a..474b5bc 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1410,7 +1410,7 @@ static void imx_flush_buffer(struct uart_port *port)
temp = readl(sport->port.membase + UCR1);
temp &= ~UCR1_TDMAEN;
writel(temp, sport->port.membase + UCR1);
- sport->dma_is_txing = false;
+ sport->dma_is_txing = 0;
}
/*
--
1.8.3.1
^ permalink raw reply related
* [PATCH v2] Use RX_BUF_SIZE to set size of RX buffer
From: Martyn Welch @ 2017-09-28 10:07 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-serial, linux-kernel, Uwe Kleine-König,
Martyn Welch
The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
the length of the buffer when initialising the scatter gather list.
In order to ensure that this stays consistent, use RX_BUF_SIZE in both
locations.
Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
Acked-by: Uwe Kleine-König <u.kleine-könig@pengtronix.de>
---
v2: Add missing SoB and Uwe's Acked-by.
drivers/tty/serial/imx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1691ed2..9da109a 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1164,7 +1164,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
goto err;
}
- sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
if (!sport->rx_buf) {
ret = -ENOMEM;
goto err;
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] Use RX_BUF_SIZE to set size of RX buffer
From: Martyn Welch @ 2017-09-28 10:04 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel
In-Reply-To: <20170928100019.ynpbdctn65vxf7kq@pengutronix.de>
On Thu, Sep 28, 2017 at 12:00:19PM +0200, Uwe Kleine-König wrote:
> On Thu, Sep 28, 2017 at 10:52:15AM +0100, Martyn Welch wrote:
> > The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
> > uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
> > the length of the buffer when initialising the scatter gather list.
> >
> > In order to ensure that this stays consistent, use RX_BUF_SIZE in both
> > locations.
>
> Missing SoB Line
Doh! v2 on way...
>
> > ---
> > drivers/tty/serial/imx.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index fe368a4..bc2f2a2f 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1165,7 +1165,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
> > goto err;
> > }
> >
> > - sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
> > + sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
> > if (!sport->rx_buf) {
> > ret = -ENOMEM;
> > goto err;
> Acked-by: Uwe Kleine-König <u.kleine-könig@pengtronix.de>
>
>
> --
> Pengutronix e.K. | Uwe Kleine-König |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply
* [PATCH] serial: imx: only set dma_is_rxing when DMA starts
From: Martyn Welch @ 2017-09-28 10:03 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Jiri Slaby, linux-serial, linux-kernel, Uwe Kleine-König,
Romain Perier, Martyn Welch
From: Romain Perier <romain.perier@collabora.com>
The variable dma_is_rxing is currently set to 1 in imx_disable_rx_int().
This is problematic as:
- whilst imx_disable_rx_int() is currently always called before
start_rx_dma() this dependency isn't obvious.
- start_rx_dma() does error checking and might exit without
enabling DMA. Currently this will result in dma_is_rxing suggesting
that DMA is being used for recieving.
To avoid these issues, move the setting of dma_is_rxing to
start_rx_dma() when appropriate.
Signed-off-by: Romain Perier <romain.perier@collabora.com>
Signed-off-by: Martyn Welch <martyn.welch@collabora.co.uk>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
This patch has been split out of series: "[PATCH v3 0/6] serial: imx:
various improvements" as this is a stand alone fix and some of the
patches in the series are problematic.
drivers/tty/serial/imx.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe368a4..1691ed2 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -714,8 +714,6 @@ static void imx_disable_rx_int(struct imx_port *sport)
{
unsigned long temp;
- sport->dma_is_rxing = 1;
-
/* disable the receiver ready and aging timer interrupts */
temp = readl(sport->port.membase + UCR1);
temp &= ~(UCR1_RRDYEN);
@@ -1074,6 +1072,7 @@ static int start_rx_dma(struct imx_port *sport)
desc->callback_param = sport;
dev_dbg(dev, "RX: prepare for the DMA.\n");
+ sport->dma_is_rxing = 1;
sport->rx_cookie = dmaengine_submit(desc);
dma_async_issue_pending(chan);
return 0;
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH v4 0/8] Various patches for SAMA5D2 backup mode
From: Alexandre Belloni @ 2017-09-28 10:02 UTC (permalink / raw)
To: Romain Izard
Cc: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
Hi,
On 28/09/2017 at 11:46:19 +0200, Romain Izard wrote:
> While the core of the backup mode for SAMA5D2 has been integrated in
> v4.13, it is far from complete. Individual controllers in the chip have
> drivers that do not support the reset of the registers during suspend,
> and they need to be adapted to handle it.
>
> The first patch uses the clock wakeup code from the prototype backup
> mode instead of the version integrated in the mainline, as the mainline
> version is not stable. During a test loop with two-second backup
> suspend, the mainline version will hang in less than one day, whereas
> the prototype version has been running the same test for more than a
> week without hanging.
>
> While all these patches are provided in a series, the clock, mtd,
> usb, pwm and mfd patch do not depend on each other.
>
> Changes in v2:
> * drop the IIO patch duplicating existing code
> * determine the number of programmable clocks to save dynamically
> * declare a required local variable in the tty/serial patch
>
> Changes in v3:
> * drop dev_printk changes for PMECC
> * rework the resume code for PMECC
> * improve comments on PMC clock handling
>
> Changes in v4:
> * fix a bug in the PMECC resume code
>
> Romain Izard (8):
> clk: at91: pmc: Wait for clocks when resuming
> clk: at91: pmc: Save SCSR during suspend
> clk: at91: pmc: Support backup for programmable clocks
> mtd: nand: atmel: Avoid ECC errors when leaving backup mode
> ehci-atmel: Power down during suspend is normal
> pwm: atmel-tcb: Support backup mode
> atmel_flexcom: Support backup mode
> tty/serial: atmel: Prevent a warning on suspend
>
Really, you have to stop sending those independent patches as a series
if you want to have a chance to see them being merged.
> drivers/clk/at91/clk-programmable.c | 2 +
> drivers/clk/at91/pmc.c | 63 ++++++++++++++++++++++++++-----
> drivers/clk/at91/pmc.h | 2 +
> drivers/mfd/atmel-flexcom.c | 65 ++++++++++++++++++++++++--------
> drivers/mtd/nand/atmel/nand-controller.c | 3 ++
> drivers/mtd/nand/atmel/pmecc.c | 17 +++++----
> drivers/mtd/nand/atmel/pmecc.h | 1 +
> drivers/pwm/pwm-atmel-tcb.c | 63 ++++++++++++++++++++++++++++++-
> drivers/tty/serial/atmel_serial.c | 13 +++++++
> drivers/usb/host/ehci-atmel.c | 3 +-
> 10 files changed, 196 insertions(+), 36 deletions(-)
>
> --
> 2.11.0
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply
* Re: [PATCH] Use RX_BUF_SIZE to set size of RX buffer
From: Uwe Kleine-König @ 2017-09-28 10:00 UTC (permalink / raw)
To: Martyn Welch; +Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel
In-Reply-To: <1506592335-12623-1-git-send-email-martyn.welch@collabora.co.uk>
On Thu, Sep 28, 2017 at 10:52:15AM +0100, Martyn Welch wrote:
> The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
> uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
> the length of the buffer when initialising the scatter gather list.
>
> In order to ensure that this stays consistent, use RX_BUF_SIZE in both
> locations.
Missing SoB Line
> ---
> drivers/tty/serial/imx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index fe368a4..bc2f2a2f 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -1165,7 +1165,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
> goto err;
> }
>
> - sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
> + sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
> if (!sport->rx_buf) {
> ret = -ENOMEM;
> goto err;
Acked-by: Uwe Kleine-König <u.kleine-könig@pengtronix.de>
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply
* [PATCH] Use RX_BUF_SIZE to set size of RX buffer
From: Martyn Welch @ 2017-09-28 9:52 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, linux-kernel, Martyn Welch
The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
the length of the buffer when initialising the scatter gather list.
In order to ensure that this stays consistent, use RX_BUF_SIZE in both
locations.
---
drivers/tty/serial/imx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe368a4..bc2f2a2f 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1165,7 +1165,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
goto err;
}
- sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
if (!sport->rx_buf) {
ret = -ENOMEM;
goto err;
--
1.8.3.1
^ permalink raw reply related
* [PATCH v4 8/8] tty/serial: atmel: Prevent a warning on suspend
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Ale
Cc: linux-clk, linux-kernel, linux-mtd, linux-pwm, linux-serial,
linux-usb, Romain Izard
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
The atmel serial port driver reported the following warning on suspend:
atmel_usart f8020000.serial: ttyS1: Unable to drain transmitter
As the ATMEL_US_TXEMPTY status bit in ATMEL_US_CSR is always cleared
when the transmitter is disabled, we need to know the transmitter's
state to return the real fifo state. And as ATMEL_US_CR is write-only,
it is necessary to save the state of the transmitter in a local
variable, and update the variable when TXEN and TXDIS is written in
ATMEL_US_CR.
After those changes, atmel_tx_empty can return "empty" on suspend, the
warning in uart_suspend_port disappears, and suspending is 20ms shorter
for each enabled Atmel serial port.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Tested-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Richard Genoud <richard.genoud@gmail.com>
---
drivers/tty/serial/atmel_serial.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 7551cab438ff..ce45b4ada0bf 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -171,6 +171,7 @@ struct atmel_uart_port {
bool has_hw_timer;
struct timer_list uart_timer;
+ bool tx_stopped;
bool suspended;
unsigned int pending;
unsigned int pending_status;
@@ -380,6 +381,10 @@ static int atmel_config_rs485(struct uart_port *port,
*/
static u_int atmel_tx_empty(struct uart_port *port)
{
+ struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
+
+ if (atmel_port->tx_stopped)
+ return TIOCSER_TEMT;
return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ?
TIOCSER_TEMT :
0;
@@ -485,6 +490,7 @@ static void atmel_stop_tx(struct uart_port *port)
* is fully transmitted.
*/
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS);
+ atmel_port->tx_stopped = true;
/* Disable interrupts */
atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask);
@@ -521,6 +527,7 @@ static void atmel_start_tx(struct uart_port *port)
/* re-enable the transmitter */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
+ atmel_port->tx_stopped = false;
}
/*
@@ -1866,6 +1873,7 @@ static int atmel_startup(struct uart_port *port)
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
/* enable xmit & rcvr */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+ atmel_port->tx_stopped = false;
setup_timer(&atmel_port->uart_timer,
atmel_uart_timer_callback,
@@ -2122,6 +2130,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
/* disable receiver and transmitter */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS);
+ atmel_port->tx_stopped = true;
/* mode */
if (port->rs485.flags & SER_RS485_ENABLED) {
@@ -2207,6 +2216,7 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,
atmel_uart_writel(port, ATMEL_US_BRGR, quot);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+ atmel_port->tx_stopped = false;
/* restore interrupts */
atmel_uart_writel(port, ATMEL_US_IER, imr);
@@ -2450,6 +2460,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
/* Make sure that tx path is actually able to send characters */
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN);
+ atmel_port->tx_stopped = false;
uart_console_write(port, s, count, atmel_console_putchar);
@@ -2511,6 +2522,7 @@ static int __init atmel_console_setup(struct console *co, char *options)
{
int ret;
struct uart_port *port = &atmel_ports[co->index].uart;
+ struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
int baud = 115200;
int bits = 8;
int parity = 'n';
@@ -2528,6 +2540,7 @@ static int __init atmel_console_setup(struct console *co, char *options)
atmel_uart_writel(port, ATMEL_US_IDR, -1);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX);
atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN);
+ atmel_port->tx_stopped = false;
if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow);
--
2.11.0
^ permalink raw reply related
* [PATCH v4 7/8] atmel_flexcom: Support backup mode
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Ale
Cc: linux-clk, linux-kernel, linux-mtd, linux-pwm, linux-serial,
linux-usb, Romain Izard
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
The controller used by a flexcom module is configured at boot, and left
alone after this. As the configuration will be lost after backup mode,
restore the state of the flexcom driver on resume.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Tested-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
drivers/mfd/atmel-flexcom.c | 65 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 50 insertions(+), 15 deletions(-)
diff --git a/drivers/mfd/atmel-flexcom.c b/drivers/mfd/atmel-flexcom.c
index 064bde9cff5a..ef1235c4a179 100644
--- a/drivers/mfd/atmel-flexcom.c
+++ b/drivers/mfd/atmel-flexcom.c
@@ -39,34 +39,44 @@
#define FLEX_MR_OPMODE(opmode) (((opmode) << FLEX_MR_OPMODE_OFFSET) & \
FLEX_MR_OPMODE_MASK)
+struct atmel_flexcom {
+ void __iomem *base;
+ u32 opmode;
+ struct clk *clk;
+};
static int atmel_flexcom_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
- struct clk *clk;
struct resource *res;
- void __iomem *base;
- u32 opmode;
+ struct atmel_flexcom *afc;
int err;
+ u32 val;
+
+ afc = devm_kzalloc(&pdev->dev, sizeof(*afc), GFP_KERNEL);
+ if (!afc)
+ return -ENOMEM;
- err = of_property_read_u32(np, "atmel,flexcom-mode", &opmode);
+ platform_set_drvdata(pdev, afc);
+
+ err = of_property_read_u32(np, "atmel,flexcom-mode", &afc->opmode);
if (err)
return err;
- if (opmode < ATMEL_FLEXCOM_MODE_USART ||
- opmode > ATMEL_FLEXCOM_MODE_TWI)
+ if (afc->opmode < ATMEL_FLEXCOM_MODE_USART ||
+ afc->opmode > ATMEL_FLEXCOM_MODE_TWI)
return -EINVAL;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(base))
- return PTR_ERR(base);
+ afc->base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(afc->base))
+ return PTR_ERR(afc->base);
- clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(clk))
- return PTR_ERR(clk);
+ afc->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(afc->clk))
+ return PTR_ERR(afc->clk);
- err = clk_prepare_enable(clk);
+ err = clk_prepare_enable(afc->clk);
if (err)
return err;
@@ -76,9 +86,10 @@ static int atmel_flexcom_probe(struct platform_device *pdev)
* inaccessible and are read as zero. Also the external I/O lines of the
* Flexcom are muxed to reach the selected device.
*/
- writel(FLEX_MR_OPMODE(opmode), base + FLEX_MR);
+ val = FLEX_MR_OPMODE(afc->opmode);
+ writel(val, afc->base + FLEX_MR);
- clk_disable_unprepare(clk);
+ clk_disable_unprepare(afc->clk);
return devm_of_platform_populate(&pdev->dev);
}
@@ -89,10 +100,34 @@ static const struct of_device_id atmel_flexcom_of_match[] = {
};
MODULE_DEVICE_TABLE(of, atmel_flexcom_of_match);
+#ifdef CONFIG_PM_SLEEP
+static int atmel_flexcom_resume(struct device *dev)
+{
+ struct atmel_flexcom *afc = dev_get_drvdata(dev);
+ int err;
+ u32 val;
+
+ err = clk_prepare_enable(afc->clk);
+ if (err)
+ return err;
+
+ val = FLEX_MR_OPMODE(afc->opmode),
+ writel(val, afc->base + FLEX_MR);
+
+ clk_disable_unprepare(afc->clk);
+
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(atmel_flexcom_pm_ops, NULL,
+ atmel_flexcom_resume);
+
static struct platform_driver atmel_flexcom_driver = {
.probe = atmel_flexcom_probe,
.driver = {
.name = "atmel_flexcom",
+ .pm = &atmel_flexcom_pm_ops,
.of_match_table = atmel_flexcom_of_match,
},
};
--
2.11.0
^ permalink raw reply related
* [PATCH v4 6/8] pwm: atmel-tcb: Support backup mode
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Ale
Cc: linux-clk, linux-kernel, linux-mtd, linux-pwm, linux-serial,
linux-usb, Romain Izard
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
Save and restore registers for the PWM on suspend and resume, which
makes hibernation and backup modes possible.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
drivers/pwm/pwm-atmel-tcb.c | 63 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 61 insertions(+), 2 deletions(-)
diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
index 75db585a2a94..acd3ce8ecf3f 100644
--- a/drivers/pwm/pwm-atmel-tcb.c
+++ b/drivers/pwm/pwm-atmel-tcb.c
@@ -37,11 +37,20 @@ struct atmel_tcb_pwm_device {
unsigned period; /* PWM period expressed in clk cycles */
};
+struct atmel_tcb_channel {
+ u32 enabled;
+ u32 cmr;
+ u32 ra;
+ u32 rb;
+ u32 rc;
+};
+
struct atmel_tcb_pwm_chip {
struct pwm_chip chip;
spinlock_t lock;
struct atmel_tc *tc;
struct atmel_tcb_pwm_device *pwms[NPWM];
+ struct atmel_tcb_channel bkup[NPWM / 2];
};
static inline struct atmel_tcb_pwm_chip *to_tcb_chip(struct pwm_chip *chip)
@@ -175,12 +184,15 @@ static void atmel_tcb_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
* Use software trigger to apply the new setting.
* If both PWM devices in this group are disabled we stop the clock.
*/
- if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC)))
+ if (!(cmr & (ATMEL_TC_ACPC | ATMEL_TC_BCPC))) {
__raw_writel(ATMEL_TC_SWTRG | ATMEL_TC_CLKDIS,
regs + ATMEL_TC_REG(group, CCR));
- else
+ tcbpwmc->bkup[group].enabled = 1;
+ } else {
__raw_writel(ATMEL_TC_SWTRG, regs +
ATMEL_TC_REG(group, CCR));
+ tcbpwmc->bkup[group].enabled = 0;
+ }
spin_unlock(&tcbpwmc->lock);
}
@@ -263,6 +275,7 @@ static int atmel_tcb_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
/* Use software trigger to apply the new setting */
__raw_writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
regs + ATMEL_TC_REG(group, CCR));
+ tcbpwmc->bkup[group].enabled = 1;
spin_unlock(&tcbpwmc->lock);
return 0;
}
@@ -445,10 +458,56 @@ static const struct of_device_id atmel_tcb_pwm_dt_ids[] = {
};
MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
+#ifdef CONFIG_PM_SLEEP
+static int atmel_tcb_pwm_suspend(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
+ void __iomem *base = tcbpwm->tc->regs;
+ int i;
+
+ for (i = 0; i < (NPWM / 2); i++) {
+ struct atmel_tcb_channel *chan = &tcbpwm->bkup[i];
+
+ chan->cmr = readl(base + ATMEL_TC_REG(i, CMR));
+ chan->ra = readl(base + ATMEL_TC_REG(i, RA));
+ chan->rb = readl(base + ATMEL_TC_REG(i, RB));
+ chan->rc = readl(base + ATMEL_TC_REG(i, RC));
+ }
+ return 0;
+}
+
+static int atmel_tcb_pwm_resume(struct device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
+ void __iomem *base = tcbpwm->tc->regs;
+ int i;
+
+ for (i = 0; i < (NPWM / 2); i++) {
+ struct atmel_tcb_channel *chan = &tcbpwm->bkup[i];
+
+ writel(chan->cmr, base + ATMEL_TC_REG(i, CMR));
+ writel(chan->ra, base + ATMEL_TC_REG(i, RA));
+ writel(chan->rb, base + ATMEL_TC_REG(i, RB));
+ writel(chan->rc, base + ATMEL_TC_REG(i, RC));
+ if (chan->enabled) {
+ writel(ATMEL_TC_CLKEN | ATMEL_TC_SWTRG,
+ base + ATMEL_TC_REG(i, CCR));
+ }
+ }
+ return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(atmel_tcb_pwm_pm_ops, atmel_tcb_pwm_suspend,
+ atmel_tcb_pwm_resume);
+
static struct platform_driver atmel_tcb_pwm_driver = {
.driver = {
.name = "atmel-tcb-pwm",
.of_match_table = atmel_tcb_pwm_dt_ids,
+ .pm = &atmel_tcb_pwm_pm_ops,
},
.probe = atmel_tcb_pwm_probe,
.remove = atmel_tcb_pwm_remove,
--
2.11.0
^ permalink raw reply related
* [PATCH v4 5/8] ehci-atmel: Power down during suspend is normal
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Ale
Cc: linux-clk, linux-kernel, linux-mtd, linux-pwm, linux-serial,
linux-usb, Romain Izard
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
When an Atmel SoC is suspended with the backup mode, the USB bus will be
powered down. As this is expected, do not return an error to the driver
core when ehci_resume detects it.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
drivers/usb/host/ehci-atmel.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c
index 7440722bfbf0..2a8b9bdc0e57 100644
--- a/drivers/usb/host/ehci-atmel.c
+++ b/drivers/usb/host/ehci-atmel.c
@@ -205,7 +205,8 @@ static int __maybe_unused ehci_atmel_drv_resume(struct device *dev)
struct atmel_ehci_priv *atmel_ehci = hcd_to_atmel_ehci_priv(hcd);
atmel_start_clock(atmel_ehci);
- return ehci_resume(hcd, false);
+ ehci_resume(hcd, false);
+ return 0;
}
#ifdef CONFIG_OF
--
2.11.0
^ permalink raw reply related
* [PATCH v4 4/8] mtd: nand: atmel: Avoid ECC errors when leaving backup mode
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Alexandre Belloni
Cc: linux-pwm, linux-usb, linux-kernel, linux-mtd, linux-serial,
Romain Izard, linux-clk
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
During backup mode, the contents of all registers will be cleared as the
SoC will be completely powered down. For a product that boots on NAND
Flash memory, the bootloader will obviously use the related controller
to read the Flash and correct any detected error in the memory, before
handling back control to the kernel's resuming entry point.
But it does not clean the NAND controller registers after use and on its
side the kernel driver expects the error locator to be powered down and
in a clean state. Add a resume hook for the PMECC error locator, and
reset its registers.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
---
Changes in v3:
* keep the PMECC disabled when not in use, and use atmel_pmecc_resume to
reset the controller after the bootloader has left it enabled.
Changes in v4:
* export atmel_pmecc_reset instead of atmel_pmecc_resume
* use the correct pointer in atmel_nand_controller_resume
drivers/mtd/nand/atmel/nand-controller.c | 3 +++
drivers/mtd/nand/atmel/pmecc.c | 17 +++++++++--------
drivers/mtd/nand/atmel/pmecc.h | 1 +
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c
index f25eca79f4e5..8afcff9a66ea 100644
--- a/drivers/mtd/nand/atmel/nand-controller.c
+++ b/drivers/mtd/nand/atmel/nand-controller.c
@@ -2530,6 +2530,9 @@ static __maybe_unused int atmel_nand_controller_resume(struct device *dev)
struct atmel_nand_controller *nc = dev_get_drvdata(dev);
struct atmel_nand *nand;
+ if (nc->pmecc)
+ atmel_pmecc_reset(nc->pmecc);
+
list_for_each_entry(nand, &nc->chips, node) {
int i;
diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c
index 146af8218314..0a3f12141c45 100644
--- a/drivers/mtd/nand/atmel/pmecc.c
+++ b/drivers/mtd/nand/atmel/pmecc.c
@@ -765,6 +765,13 @@ void atmel_pmecc_get_generated_eccbytes(struct atmel_pmecc_user *user,
}
EXPORT_SYMBOL_GPL(atmel_pmecc_get_generated_eccbytes);
+void atmel_pmecc_reset(struct atmel_pmecc *pmecc)
+{
+ writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
+ writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
+}
+EXPORT_SYMBOL_GPL(atmel_pmecc_reset);
+
int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op)
{
struct atmel_pmecc *pmecc = user->pmecc;
@@ -797,10 +804,7 @@ EXPORT_SYMBOL_GPL(atmel_pmecc_enable);
void atmel_pmecc_disable(struct atmel_pmecc_user *user)
{
- struct atmel_pmecc *pmecc = user->pmecc;
-
- writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
- writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
+ atmel_pmecc_reset(user->pmecc);
mutex_unlock(&user->pmecc->lock);
}
EXPORT_SYMBOL_GPL(atmel_pmecc_disable);
@@ -855,10 +859,7 @@ static struct atmel_pmecc *atmel_pmecc_create(struct platform_device *pdev,
/* Disable all interrupts before registering the PMECC handler. */
writel(0xffffffff, pmecc->regs.base + ATMEL_PMECC_IDR);
-
- /* Reset the ECC engine */
- writel(PMECC_CTRL_RST, pmecc->regs.base + ATMEL_PMECC_CTRL);
- writel(PMECC_CTRL_DISABLE, pmecc->regs.base + ATMEL_PMECC_CTRL);
+ atmel_pmecc_reset(pmecc);
return pmecc;
}
diff --git a/drivers/mtd/nand/atmel/pmecc.h b/drivers/mtd/nand/atmel/pmecc.h
index a8ddbfca2ea5..817e0dd9fd15 100644
--- a/drivers/mtd/nand/atmel/pmecc.h
+++ b/drivers/mtd/nand/atmel/pmecc.h
@@ -61,6 +61,7 @@ atmel_pmecc_create_user(struct atmel_pmecc *pmecc,
struct atmel_pmecc_user_req *req);
void atmel_pmecc_destroy_user(struct atmel_pmecc_user *user);
+void atmel_pmecc_reset(struct atmel_pmecc *pmecc);
int atmel_pmecc_enable(struct atmel_pmecc_user *user, int op);
void atmel_pmecc_disable(struct atmel_pmecc_user *user);
int atmel_pmecc_wait_rdy(struct atmel_pmecc_user *user);
--
2.11.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related
* [PATCH v4 3/8] clk: at91: pmc: Support backup for programmable clocks
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Ale
Cc: linux-clk, linux-kernel, linux-mtd, linux-pwm, linux-serial,
linux-usb, Romain Izard, Romain Izard
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
From: Romain Izard <romain.izard@mobile-devices.fr>
When an AT91 programmable clock is declared in the device tree, register
it into the Power Management Controller driver. On entering suspend mode,
the driver saves and restores the Programmable Clock registers to support
the backup mode for these clocks.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
Changes in v2:
* register PCKs on clock startup
Changes in v3:
* improve comments on hanling 0 in pmc_register_id and pmc_register_pck
* declare local variables earlier for checkpatch
drivers/clk/at91/clk-programmable.c | 2 ++
drivers/clk/at91/pmc.c | 35 +++++++++++++++++++++++++++++++++++
drivers/clk/at91/pmc.h | 2 ++
3 files changed, 39 insertions(+)
diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c
index 85a449cf61e3..0e6aab1252fc 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -204,6 +204,8 @@ at91_clk_register_programmable(struct regmap *regmap,
if (ret) {
kfree(prog);
hw = ERR_PTR(ret);
+ } else {
+ pmc_register_pck(id);
}
return hw;
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 07dc2861ad3f..1fa27f4ea538 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -22,6 +22,7 @@
#include "pmc.h"
#define PMC_MAX_IDS 128
+#define PMC_MAX_PCKS 8
int of_at91_get_clk_range(struct device_node *np, const char *propname,
struct clk_range *range)
@@ -50,6 +51,7 @@ EXPORT_SYMBOL_GPL(of_at91_get_clk_range);
static struct regmap *pmcreg;
static u8 registered_ids[PMC_MAX_IDS];
+static u8 registered_pcks[PMC_MAX_PCKS];
static struct
{
@@ -66,8 +68,13 @@ static struct
u32 pcr[PMC_MAX_IDS];
u32 audio_pll0;
u32 audio_pll1;
+ u32 pckr[PMC_MAX_PCKS];
} pmc_cache;
+/*
+ * As Peripheral ID 0 is invalid on AT91 chips, the identifier is stored
+ * without alteration in the table, and 0 is for unused clocks.
+ */
void pmc_register_id(u8 id)
{
int i;
@@ -82,9 +89,28 @@ void pmc_register_id(u8 id)
}
}
+/*
+ * As Programmable Clock 0 is valid on AT91 chips, there is an offset
+ * of 1 between the stored value and the real clock ID.
+ */
+void pmc_register_pck(u8 pck)
+{
+ int i;
+
+ for (i = 0; i < PMC_MAX_PCKS; i++) {
+ if (registered_pcks[i] == 0) {
+ registered_pcks[i] = pck + 1;
+ break;
+ }
+ if (registered_pcks[i] == (pck + 1))
+ break;
+ }
+}
+
static int pmc_suspend(void)
{
int i;
+ u8 num;
regmap_read(pmcreg, AT91_PMC_SCSR, &pmc_cache.scsr);
regmap_read(pmcreg, AT91_PMC_PCSR, &pmc_cache.pcsr0);
@@ -103,6 +129,10 @@ static int pmc_suspend(void)
regmap_read(pmcreg, AT91_PMC_PCR,
&pmc_cache.pcr[registered_ids[i]]);
}
+ for (i = 0; registered_pcks[i]; i++) {
+ num = registered_pcks[i] - 1;
+ regmap_read(pmcreg, AT91_PMC_PCKR(num), &pmc_cache.pckr[num]);
+ }
return 0;
}
@@ -119,6 +149,7 @@ static bool pmc_ready(unsigned int mask)
static void pmc_resume(void)
{
int i;
+ u8 num;
u32 tmp;
u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA;
@@ -143,6 +174,10 @@ static void pmc_resume(void)
pmc_cache.pcr[registered_ids[i]] |
AT91_PMC_PCR_CMD);
}
+ for (i = 0; registered_pcks[i]; i++) {
+ num = registered_pcks[i] - 1;
+ regmap_write(pmcreg, AT91_PMC_PCKR(num), pmc_cache.pckr[num]);
+ }
if (pmc_cache.uckr & AT91_PMC_UPLLEN)
mask |= AT91_PMC_LOCKU;
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
index 858e8ef7e8db..d22b1fa9ecdc 100644
--- a/drivers/clk/at91/pmc.h
+++ b/drivers/clk/at91/pmc.h
@@ -31,8 +31,10 @@ int of_at91_get_clk_range(struct device_node *np, const char *propname,
#ifdef CONFIG_PM
void pmc_register_id(u8 id);
+void pmc_register_pck(u8 pck);
#else
static inline void pmc_register_id(u8 id) {}
+static inline void pmc_register_pck(u8 pck) {}
#endif
#endif /* __PMC_H_ */
--
2.11.0
^ permalink raw reply related
* [PATCH v4 2/8] clk: at91: pmc: Save SCSR during suspend
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Alexandre Belloni
Cc: linux-pwm, linux-usb, linux-kernel, linux-mtd, linux-serial,
Romain Izard, linux-clk
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
The contents of the System Clock Status Register (SCSR) needs to be
restored into the System Clock Enable Register (SCER).
As the bootloader will restore some clocks by itself, the issue can be
missed as only the USB controller, the LCD controller, the Image Sensor
controller and the programmable clocks will be impacted.
Fix the obvious typo in the suspend/resume code, as the IMR register
does not need to be saved twice.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
drivers/clk/at91/pmc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 5c2b26de303e..07dc2861ad3f 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -86,7 +86,7 @@ static int pmc_suspend(void)
{
int i;
- regmap_read(pmcreg, AT91_PMC_IMR, &pmc_cache.scsr);
+ regmap_read(pmcreg, AT91_PMC_SCSR, &pmc_cache.scsr);
regmap_read(pmcreg, AT91_PMC_PCSR, &pmc_cache.pcsr0);
regmap_read(pmcreg, AT91_CKGR_UCKR, &pmc_cache.uckr);
regmap_read(pmcreg, AT91_CKGR_MOR, &pmc_cache.mor);
@@ -129,7 +129,7 @@ static void pmc_resume(void)
if (pmc_cache.pllar != tmp)
pr_warn("PLLAR was not configured properly by the firmware\n");
- regmap_write(pmcreg, AT91_PMC_IMR, pmc_cache.scsr);
+ regmap_write(pmcreg, AT91_PMC_SCER, pmc_cache.scsr);
regmap_write(pmcreg, AT91_PMC_PCER, pmc_cache.pcsr0);
regmap_write(pmcreg, AT91_CKGR_UCKR, pmc_cache.uckr);
regmap_write(pmcreg, AT91_CKGR_MOR, pmc_cache.mor);
--
2.11.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related
* [PATCH v4 1/8] clk: at91: pmc: Wait for clocks when resuming
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Ale
Cc: linux-clk, linux-kernel, linux-mtd, linux-pwm, linux-serial,
linux-usb, Romain Izard
In-Reply-To: <20170928094627.31017-1-romain.izard.pro@gmail.com>
Wait for the syncronization of all clocks when resuming, not only the
UPLL clock. Do not use regmap_read_poll_timeout, as it will call BUG()
when interrupts are masked, which is the case in here.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
---
drivers/clk/at91/pmc.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 775af473fe11..5c2b26de303e 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -107,10 +107,20 @@ static int pmc_suspend(void)
return 0;
}
+static bool pmc_ready(unsigned int mask)
+{
+ unsigned int status;
+
+ regmap_read(pmcreg, AT91_PMC_SR, &status);
+
+ return ((status & mask) == mask) ? 1 : 0;
+}
+
static void pmc_resume(void)
{
- int i, ret = 0;
+ int i;
u32 tmp;
+ u32 mask = AT91_PMC_MCKRDY | AT91_PMC_LOCKA;
regmap_read(pmcreg, AT91_PMC_MCKR, &tmp);
if (pmc_cache.mckr != tmp)
@@ -134,13 +144,11 @@ static void pmc_resume(void)
AT91_PMC_PCR_CMD);
}
- if (pmc_cache.uckr & AT91_PMC_UPLLEN) {
- ret = regmap_read_poll_timeout(pmcreg, AT91_PMC_SR, tmp,
- !(tmp & AT91_PMC_LOCKU),
- 10, 5000);
- if (ret)
- pr_crit("USB PLL didn't lock when resuming\n");
- }
+ if (pmc_cache.uckr & AT91_PMC_UPLLEN)
+ mask |= AT91_PMC_LOCKU;
+
+ while (!pmc_ready(mask))
+ cpu_relax();
}
static struct syscore_ops pmc_syscore_ops = {
--
2.11.0
^ permalink raw reply related
* [PATCH v4 0/8] Various patches for SAMA5D2 backup mode
From: Romain Izard @ 2017-09-28 9:46 UTC (permalink / raw)
To: Boris Brezillon, Michael Turquette, Stephen Boyd, Lee Jones,
Wenyou Yang, Josh Wu, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen, Thierry Reding,
Richard Genoud, Greg Kroah-Hartman, Jiri Slaby, Alan Stern,
Ludovic Desroches, Nicolas Ferre, Ale
Cc: linux-clk-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-pwm-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, Romain Izard
While the core of the backup mode for SAMA5D2 has been integrated in
v4.13, it is far from complete. Individual controllers in the chip have
drivers that do not support the reset of the registers during suspend,
and they need to be adapted to handle it.
The first patch uses the clock wakeup code from the prototype backup
mode instead of the version integrated in the mainline, as the mainline
version is not stable. During a test loop with two-second backup
suspend, the mainline version will hang in less than one day, whereas
the prototype version has been running the same test for more than a
week without hanging.
While all these patches are provided in a series, the clock, mtd,
usb, pwm and mfd patch do not depend on each other.
Changes in v2:
* drop the IIO patch duplicating existing code
* determine the number of programmable clocks to save dynamically
* declare a required local variable in the tty/serial patch
Changes in v3:
* drop dev_printk changes for PMECC
* rework the resume code for PMECC
* improve comments on PMC clock handling
Changes in v4:
* fix a bug in the PMECC resume code
Romain Izard (8):
clk: at91: pmc: Wait for clocks when resuming
clk: at91: pmc: Save SCSR during suspend
clk: at91: pmc: Support backup for programmable clocks
mtd: nand: atmel: Avoid ECC errors when leaving backup mode
ehci-atmel: Power down during suspend is normal
pwm: atmel-tcb: Support backup mode
atmel_flexcom: Support backup mode
tty/serial: atmel: Prevent a warning on suspend
drivers/clk/at91/clk-programmable.c | 2 +
drivers/clk/at91/pmc.c | 63 ++++++++++++++++++++++++++-----
drivers/clk/at91/pmc.h | 2 +
drivers/mfd/atmel-flexcom.c | 65 ++++++++++++++++++++++++--------
drivers/mtd/nand/atmel/nand-controller.c | 3 ++
drivers/mtd/nand/atmel/pmecc.c | 17 +++++----
drivers/mtd/nand/atmel/pmecc.h | 1 +
drivers/pwm/pwm-atmel-tcb.c | 63 ++++++++++++++++++++++++++++++-
drivers/tty/serial/atmel_serial.c | 13 +++++++
drivers/usb/host/ehci-atmel.c | 3 +-
10 files changed, 196 insertions(+), 36 deletions(-)
--
2.11.0
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [patch v9 0/4] JTAG driver introduction
From: Geert Uytterhoeven @ 2017-09-28 9:02 UTC (permalink / raw)
To: Oleksandr Shamray
Cc: Greg KH, Arnd Bergmann, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
openbmc@lists.ozlabs.org, Joel Stanley, Jiri Pirko,
Tobias Klauser, linux-serial@vger.kernel.org, mec@shout.net,
Vadim Pasternak, system-sw-low-level, Rob Herring,
openocd-devel-owner@lists.sourceforge.net, linux-api
In-Reply-To: <AM4PR0501MB2194D67623C640E20B3A7FABB1790@AM4PR0501MB2194.eurprd05.prod.outlook.com>
Hi Oleksandr,
On Thu, Sep 28, 2017 at 10:53 AM, Oleksandr Shamray
<oleksandrs@mellanox.com> wrote:
>> [My attention was drawn by
>> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flwn.net
>> %2FArticles%2F734440%2F&data=02%7C01%7Coleksandrs%40mellanox.com%7
>> C97b8ba88686a42daaace08d5064b92eb%7Ca652971c7d2e4d9ba6a4d149256f
>> 461b%7C0%7C0%7C636421844026854216&sdata=TeHD4a3%2FBN6a5XG3Jizf5
>> pmsyJHJjzkEzkpnqsXC6S0%3D&reserved=0]
>> [CC linux-spi, which was never included, while linux-serial was]
>>
>> On Thu, Sep 21, 2017 at 11:25 AM, Oleksandr Shamray
>> <oleksandrs@mellanox.com> wrote:
>> > When a need raise up to use JTAG interface for system's devices
>> > programming or CPU debugging, usually the user layer application
>> > implements jtag protocol by bit-bang or using a proprietary connection
>> > to vendor hardware.
>> > This method can be slow and not generic.
>> >
>
>
> [..]
>
>> >
>> > Initial version provides the system calls set for:
>> > - SIR (Scan Instruction Register, IEEE 1149.1 Data Register scan);
>> > - SDR (Scan Data Register, IEEE 1149.1 Instruction Register scan);
>> > - RUNTEST (Forces the IEEE 1149.1 bus to a run state for a specified
>> > number of clocks.
>> >
>> > SoC which are not equipped with JTAG master interface, can be built on
>> > top of JTAG core driver infrastructure, by applying bit-banging of
>> > TDI, TDO, TCK and TMS pins within the hardware specific driver.
>>
>> Or by using an SPI master?
>>
>
> I think it depends on how flexible the SPI interface is. If you can set it to transfer
> from 1 to n bits at a time, and you control the TMS line in software, you should
> be able to use it. If the SPI interface can only transfer a multiple of 8 bits
> at a time, then in general it would not be suitable for JTAG.
Sure, that depends on the actual SPI master interface.
But I guess you can write a generic JTAG-over-SPI driver, and use a tms-gpios
property in DT to specify how to control TMS.
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
^ permalink raw reply
* RE: [patch v9 0/4] JTAG driver introduction
From: Oleksandr Shamray @ 2017-09-28 8:53 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Greg KH, Arnd Bergmann,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
openbmc-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org, Joel Stanley,
Jiri Pirko, Tobias Klauser,
linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
mec-WqBc5aa1uDFeoWH0uzbU5w@public.gmane.org, Vadim Pasternak,
system-sw-low-level, Rob Herring,
openocd-devel-owner-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CAMuHMdWfoYzWPJYaGOhF8qshKhvngwFKs=kvuH62PYif9q9+0g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
> -----Original Message-----
> From: geert.uytterhoeven@gmail.com [mailto:geert.uytterhoeven@gmail.com]
> On Behalf Of Geert Uytterhoeven
> Sent: Thursday, September 28, 2017 11:33 AM
> To: Oleksandr Shamray <oleksandrs@mellanox.com>
> Cc: Greg KH <gregkh@linuxfoundation.org>; Arnd Bergmann
> <arnd@arndb.de>; linux-kernel@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; devicetree@vger.kernel.org;
> openbmc@lists.ozlabs.org; Joel Stanley <joel@jms.id.au>; Jiri Pirko
> <jiri@resnulli.us>; Tobias Klauser <tklauser@distanz.ch>; linux-
> serial@vger.kernel.org; mec@shout.net; Vadim Pasternak
> <vadimp@mellanox.com>; system-sw-low-level <system-sw-low-
> level@mellanox.com>; Rob Herring <robh+dt@kernel.org>; openocd-devel-
> owner@lists.sourceforge.net; linux-api@vger.kernel.org; David S. Miller
> <davem@davemloft.net>; Mauro Carvalho Chehab <mchehab@kernel.org>;
> linux-spi <linux-spi@vger.kernel.org>; Mark Brown <broonie@kernel.org>
> Subject: Re: [patch v9 0/4] JTAG driver introduction
>
> Hi Oleksandr,
>
> [My attention was drawn by
> https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flwn.net
> %2FArticles%2F734440%2F&data=02%7C01%7Coleksandrs%40mellanox.com%7
> C97b8ba88686a42daaace08d5064b92eb%7Ca652971c7d2e4d9ba6a4d149256f
> 461b%7C0%7C0%7C636421844026854216&sdata=TeHD4a3%2FBN6a5XG3Jizf5
> pmsyJHJjzkEzkpnqsXC6S0%3D&reserved=0]
> [CC linux-spi, which was never included, while linux-serial was]
>
> On Thu, Sep 21, 2017 at 11:25 AM, Oleksandr Shamray
> <oleksandrs@mellanox.com> wrote:
> > When a need raise up to use JTAG interface for system's devices
> > programming or CPU debugging, usually the user layer application
> > implements jtag protocol by bit-bang or using a proprietary connection
> > to vendor hardware.
> > This method can be slow and not generic.
> >
[..]
> >
> > Initial version provides the system calls set for:
> > - SIR (Scan Instruction Register, IEEE 1149.1 Data Register scan);
> > - SDR (Scan Data Register, IEEE 1149.1 Instruction Register scan);
> > - RUNTEST (Forces the IEEE 1149.1 bus to a run state for a specified
> > number of clocks.
> >
> > SoC which are not equipped with JTAG master interface, can be built on
> > top of JTAG core driver infrastructure, by applying bit-banging of
> > TDI, TDO, TCK and TMS pins within the hardware specific driver.
>
> Or by using an SPI master?
>
I think it depends on how flexible the SPI interface is. If you can set it to transfer
from 1 to n bits at a time, and you control the TMS line in software, you should
be able to use it. If the SPI interface can only transfer a multiple of 8 bits
at a time, then in general it would not be suitable for JTAG.
> 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
^ permalink raw reply
* Re: [patch v9 0/4] JTAG driver introduction
From: Geert Uytterhoeven @ 2017-09-28 8:33 UTC (permalink / raw)
To: Oleksandr Shamray
Cc: Greg KH, Arnd Bergmann,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
openbmc-uLR06cmDAlY/bJ5BZ2RsiQ, Joel Stanley, Jiri Pirko,
Tobias Klauser,
linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
mec-WqBc5aa1uDFeoWH0uzbU5w, Vadim Pasternak,
system-sw-low-level-VPRAkNaXOzVWk0Htik3J/w, Rob Herring,
openocd-devel-owner-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
David S. Miller, Mauro Carvalho Chehab
In-Reply-To: <1505985932-27568-1-git-send-email-oleksandrs-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Hi Oleksandr,
[My attention was drawn by https://lwn.net/Articles/734440/]
[CC linux-spi, which was never included, while linux-serial was]
On Thu, Sep 21, 2017 at 11:25 AM, Oleksandr Shamray
<oleksandrs-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote:
> When a need raise up to use JTAG interface for system's devices
> programming or CPU debugging, usually the user layer
> application implements jtag protocol by bit-bang or using a
> proprietary connection to vendor hardware.
> This method can be slow and not generic.
>
> We propose to implement general JTAG interface and infrastructure
> to communicate with user layer application. In such way, we can
> have the standard JTAG interface core part and separation from
> specific HW implementation.
> This allow new capability to debug the CPU or program system's
> device via BMC without additional devices nor cost.
>
> This patch purpose is to add JTAG master core infrastructure by
> defining new JTAG class and provide generic JTAG interface
> to allow hardware specific drivers to connect this interface.
> This will enable all JTAG drivers to use the common interface
> part and will have separate for hardware implementation.
>
> The JTAG (Joint Test Action Group) core driver provides minimal generic
> JTAG interface, which can be used by hardware specific JTAG master
> controllers. By providing common interface for the JTAG controllers,
> user space device programing is hardware independent.
>
> Modern SoC which in use for embedded system' equipped with
> internal JTAG master interface.
> This interface is used for programming and debugging system's
> hardware components, like CPLD, FPGA, CPU, voltage and
> industrial controllers.
> Firmware for such devices can be upgraded through JTAG interface during
> Runtime. The JTAG standard support for multiple devices programming,
> is in case their lines are daisy-chained together.
>
> For example, systems which equipped with host CPU, BMC SoC or/and
> number of programmable devices are capable to connect a pin and
> select system components dynamically for programming and debugging,
> This is using by the BMC which is equipped with internal SoC master
> controller.
> For example:
>
> BMC JTAG master --> pin selected to CPLDs chain for programming (filed
> upgrade, production)
> BMC JTAG master --> pin selected to voltage monitors for programming
> (field upgrade, production)
> BMC JTAG master --> pin selected to host CPU (on-site debugging
> and developers debugging)
>
> For example, we can have application in user space which using calls
> to JTAG driver executes CPLD programming directly from SVF file
>
> The JTAG standard (IEEE 1149.1) defines the next connector pins:
> - TDI (Test Data In);
> - TDO (Test Data Out);
> - TCK (Test Clock);
> - TMS (Test Mode Select);
> - TRST (Test Reset) (Optional);
>
> The SoC equipped with JTAG master controller, performs
> device programming on command or vector level. For example
> a file in a standard SVF (Serial Vector Format) that contains
> boundary scan vectors, can be used by sending each vector
> to the JTAG interface and the JTAG controller will execute
> the programming.
>
> Initial version provides the system calls set for:
> - SIR (Scan Instruction Register, IEEE 1149.1 Data Register scan);
> - SDR (Scan Data Register, IEEE 1149.1 Instruction Register scan);
> - RUNTEST (Forces the IEEE 1149.1 bus to a run state for a specified
> number of clocks.
>
> SoC which are not equipped with JTAG master interface, can be built
> on top of JTAG core driver infrastructure, by applying bit-banging of
> TDI, TDO, TCK and TMS pins within the hardware specific driver.
Or by using an SPI master?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.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
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox