Re: [PATCH] platform/x86: pmc_atom: Match all Beckhoff Automation baytrail boards with critclk_systems DMI table

2021-04-12 Thread linux-kernel-dev
On Mo, 2021-04-12 at 12:43 +0300, Andy Shevchenko wrote:
>
> On Mon, Apr 12, 2021 at 12:29 PM Steffen Dirkwinkel
>  wrote:
> >
> > From: Steffen Dirkwinkel 
> >
> > pmc_plt_clk* clocks are used for ethernet controllers so need to stay
> > turned on. This adds the affected board family to critclk_systems DMI
> > table so the clocks are marked as CLK_CRITICAL and not turned off.
> >
> > This replaces the previosly listed boards with a match for the whole
>
> "...previously..."
thanks

>
> > device family. There are new affected boards that would otherwise need
> > to be listed. There are only few unaffected boards in the family and
>
> "...only a few..."
will drop the phrase

>
> > having the clocks turned on is not an issue on those.
>
> "...not an issue."
Not an issue for these industrial PCs as sleep is an unusual use case.
Having no ethernet after boot/sleep is worse.

>
> > Fixes: 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
> > Signed-off-by: Steffen Dirkwinkel 
>
> I'm afraid it's a bit too much. Is there any guarantee all the boards
> based on x86 will be Baytrail only?
>
Sorry, I guess I should make this clearer in the message.
All boards with "CBxx63" are Baytrail.


> --
> With Best Regards,
> Andy Shevchenko
>

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans 
Beckhoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075



Re: [PATCH] platform/x86: pmc_atom: Match all Beckhoff Automation baytrail boards with critclk_systems DMI table

2021-04-12 Thread linux-kernel-dev
On Mo, 2021-04-12 at 13:54 +0300, Andy Shevchenko wrote:
> CAUTION: External Email!!
>
>
> On Mon, Apr 12, 2021 at 1:39 PM linux-kernel-dev
>  wrote:
> > On Mo, 2021-04-12 at 12:43 +0300, Andy Shevchenko wrote:
> > > On Mon, Apr 12, 2021 at 12:29 PM Steffen Dirkwinkel
> > >  wrote:
>
> ...
>
> > > I'm afraid it's a bit too much. Is there any guarantee all the boards
> > > based on x86 will be Baytrail only?
> > >
> > Sorry, I guess I should make this clearer in the message.
> > All boards with "CBxx63" are Baytrail.
>
> Exactly! And this supports my idea that this shouldn't be done like in
> this patch.
> Are you guaranteeing that *all x86-based* boards produced by your
> company will be Baytrail only?
> Above tells that the answer is rather "no". So, I think we can't apply
> this patch in its current form.

All boards with DMI_PRODUCT_FAMILY="CBxx63" are Baytrail boards. We do produce 
other x86 boards but the family
is exclusive to Baytrail.
I might be misunderstanding how the matching works. Does this match anything 
other than CBxx63?

 .matches = {
 DMI_MATCH(DMI_SYS_VENDOR, "Beckhoff Automation"),
DMI_MATCH(DMI_PRODUCT_FAMILY, "CBxx63"),
},

I can switch it to DMI_EXACT_MATCH but even substring matching works.

>
> --
> With Best Regards,
> Andy Shevchenko
>

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans 
Beckhoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075



Re: [PATCH] ARM: dts: imx53: fix EIM_D27/29 pad UART2 configuration

2015-12-07 Thread linux-kernel-dev
From: Patrick Brünn 

On Tue, Dec 1, 2015 at 20:52:25 PST, shawn...@kernel.org wrote:
> On Thu, Nov 26, 2015 at 11:59:15AM +0100, linux-kernel-...@beckhoff.com wrote:
>> MX53_PAD_EIM_D27__UART2_RXD_MUX and MX53_PAD_EIM_D29__UART2_RTS input_val 
>> must be configured as 0 instead of 1 to have UART2 muxed on EIM pins working
>
> I'm not sure why you think that.  But the i.MX53 Reference Manual in my hands 
> doesn't agree with that.  It says ...
>> 
>> Signed-off-by: Patrick Brünn 
>> ---
>>  arch/arm/boot/dts/imx53-pinfunc.h | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/arm/boot/dts/imx53-pinfunc.h 
>> b/arch/arm/boot/dts/imx53-pinfunc.h
>> index aec406b..a4c973d 100644
>> --- a/arch/arm/boot/dts/imx53-pinfunc.h
>> +++ b/arch/arm/boot/dts/imx53-pinfunc.h
>> @@ -532,7 +532,7 @@
>>  #define MX53_PAD_EIM_D26__IPU_DISP1_DAT_22  0x144 0x48c 
>> 0x000 0x7 0x0
>>  #define MX53_PAD_EIM_D27__EMI_WEIM_D_27 0x148 
>> 0x490 0x000 0x0 0x0
>>  #define MX53_PAD_EIM_D27__GPIO3_27  0x148 0x490 
>> 0x000 0x1 0x0
>> -#define MX53_PAD_EIM_D27__UART2_RXD_MUX 0x148 
>> 0x490 0x880 0x2 0x1
>> +#define MX53_PAD_EIM_D27__UART2_RXD_MUX 0x148 
>> 0x490 0x880 0x2 0x0
>
> IOMUXC_UART2_IPP_UART_RXD_MUX_SELECT_INPUT DAISY field descriptions
>
> 000 - Selecting Pad: EIM_D26 for Mode: ALT2.
> 001 - Selecting Pad: EIM_D27 for Mode: ALT2.
> 010 - Selecting Pad: PATA_DMARQ for Mode: ALT3.
> 011 - Selecting Pad: PATA_BUFFER_EN for Mode: ALT3.
> 100 - Selecting Pad: GPIO_7 for Mode: ALT4.
> 101 - Selecting Pad: GPIO_8 for Mode: ALT4.


Thanks for the hint. I had a closer look at the reference manual and our 
schematics. Of course, you are right. The defines are good as they are, my 
patch was stupid.

I just realized RXD and TXD are inverted on our hardware (CX9020 Embedded PC). 
Which requires a pinmux configuration like this:
EIM_D26->UART2_RXD
EIM_D27->UART2_TXD
EIM_D28->UART2_RTS
EIM_D29->UART2_CTS

In my opinion the reference manual allows such a configuration, but I am not 
sure if it's appropriate for mainline.

Would you accept a patch like the following:

>8--8<
ARM: dts: imx53: add EIM pad config for UART2

Add another pinmux configuration to mux UART2 on EIM pads:

EIM_D26->UART2_RXD
EIM_D27->UART2_TXD
EIM_D28->UART2_RTS
EIM_D29->UART2_CTS

Signed-off-by: Patrick Brünn 
---
 arch/arm/boot/dts/imx53-pinfunc.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/imx53-pinfunc.h 
b/arch/arm/boot/dts/imx53-pinfunc.h
index aec406b..7d26d16 100644
--- a/arch/arm/boot/dts/imx53-pinfunc.h
+++ b/arch/arm/boot/dts/imx53-pinfunc.h
@@ -525,6 +525,7 @@
 #define MX53_PAD_EIM_D26__EMI_WEIM_D_260x144 
0x48c 0x000 0x0 0x0
 #define MX53_PAD_EIM_D26__GPIO3_26 0x144 0x48c 
0x000 0x1 0x0
 #define MX53_PAD_EIM_D26__UART2_TXD_MUX0x144 
0x48c 0x000 0x2 0x0
+#define MX53_PAD_EIM_D26__UART2_RXD_MUX0x144 
0x48c 0x880 0x2 0x0
 #define MX53_PAD_EIM_D26__FIRI_RXD 0x144 0x48c 
0x80c 0x3 0x0
 #define MX53_PAD_EIM_D26__IPU_CSI0_D_1 0x144 0x48c 
0x000 0x4 0x0
 #define MX53_PAD_EIM_D26__IPU_DI1_PIN110x144 
0x48c 0x000 0x5 0x0
@@ -532,6 +533,7 @@
 #define MX53_PAD_EIM_D26__IPU_DISP1_DAT_22 0x144 0x48c 
0x000 0x7 0x0
 #define MX53_PAD_EIM_D27__EMI_WEIM_D_270x148 
0x490 0x000 0x0 0x0
 #define MX53_PAD_EIM_D27__GPIO3_27 0x148 0x490 
0x000 0x1 0x0
+#define MX53_PAD_EIM_D27__UART2_TXD_MUX0x148 
0x490 0x000 0x2 0x0
 #define MX53_PAD_EIM_D27__UART2_RXD_MUX0x148 
0x490 0x880 0x2 0x1
 #define MX53_PAD_EIM_D27__FIRI_TXD 0x148 0x490 
0x000 0x3 0x0
 #define MX53_PAD_EIM_D27__IPU_CSI0_D_0 0x148 0x490 
0x000 0x4 0x0
@@ -541,6 +543,7 @@
 #define MX53_PAD_EIM_D28__EMI_WEIM_D_280x14c 
0x494 0x000 0x0 0x0
 #define MX53_PAD_EIM_D28__GPIO3_28 0x14c 0x494 
0x000 0x1 0x0
 #define MX53_PAD_EIM_D28__UART2_CTS0x14c 0x494 
0x000 0x2 0x0
+#define MX53_PAD_EIM_D28__UART2_RTS0x14c 0x494 
0x87c 0x2 0x0
 #define MX53_PAD_EIM_D28__IPU_DISPB0_SER_DIO   0x14c 0x494 
0x82c 0x3 0x1
 #define MX53_PAD_EIM_D28__CSPI_MOSI0x14c 0x494 
0x788 0x4 0x1
 #define MX53_PAD_EIM_D28__I2C1_SDA 0x14c 0x494 
0x818 0x5 0x1
@@ -548,6 +551,7 @@
 #define MX53_PAD_EIM_D28__IPU_DI0_PIN130x14c 
0x494 0x000 0x7 0x0
 #define MX53_PAD_EIM_D29__EMI_WEIM_D_29  

[PATCH v2] clk: imx5: ipu_di_sel clocks can set parent rates

2015-12-02 Thread linux-kernel-dev
From: Patrick Brünn 

To obtain exact pixel clocks, allow the DI clock selectors to influence
the PLLs that they are derived from.

Commit 4591b13289b5 ("ARM: i.MX6: ipu_di_sel clocks can set parent
rates") did this for i.MX6.
Port it to enable high display resolutions on i.MX53 based platforms
such as CX9020 Embedded PC, too.

Signed-off-by: Patrick Brünn 
---
v2: add clk maintainers to CC and fix commit message format

 drivers/clk/imx/clk-imx51-imx53.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/imx/clk-imx51-imx53.c 
b/drivers/clk/imx/clk-imx51-imx53.c
index c677034..29d4c44 100644
--- a/drivers/clk/imx/clk-imx51-imx53.c
+++ b/drivers/clk/imx/clk-imx51-imx53.c
@@ -519,10 +519,10 @@ static void __init mx53_clocks_init(struct device_node 
*np)
mx53_ldb_di0_sel, 
ARRAY_SIZE(mx53_ldb_di0_sel), CLK_SET_RATE_PARENT);
clk[IMX5_CLK_LDB_DI0_GATE]  = imx_clk_gate2("ldb_di0_gate", 
"ldb_di0_div", MXC_CCM_CCGR6, 28);
clk[IMX5_CLK_LDB_DI1_GATE]  = imx_clk_gate2("ldb_di1_gate", 
"ldb_di1_div", MXC_CCM_CCGR6, 30);
-   clk[IMX5_CLK_IPU_DI0_SEL]   = imx_clk_mux("ipu_di0_sel", 
MXC_CCM_CSCMR2, 26, 3,
-   mx53_ipu_di0_sel, 
ARRAY_SIZE(mx53_ipu_di0_sel));
-   clk[IMX5_CLK_IPU_DI1_SEL]   = imx_clk_mux("ipu_di1_sel", 
MXC_CCM_CSCMR2, 29, 3,
-   mx53_ipu_di1_sel, 
ARRAY_SIZE(mx53_ipu_di1_sel));
+   clk[IMX5_CLK_IPU_DI0_SEL]   = imx_clk_mux_flags("ipu_di0_sel", 
MXC_CCM_CSCMR2, 26, 3,
+   mx53_ipu_di0_sel, 
ARRAY_SIZE(mx53_ipu_di0_sel), CLK_SET_RATE_PARENT);
+   clk[IMX5_CLK_IPU_DI1_SEL]   = imx_clk_mux_flags("ipu_di1_sel", 
MXC_CCM_CSCMR2, 29, 3,
+   mx53_ipu_di1_sel, 
ARRAY_SIZE(mx53_ipu_di1_sel), CLK_SET_RATE_PARENT);
clk[IMX5_CLK_TVE_EXT_SEL]   = imx_clk_mux_flags("tve_ext_sel", 
MXC_CCM_CSCMR1, 6, 1,
mx53_tve_ext_sel, 
ARRAY_SIZE(mx53_tve_ext_sel), CLK_SET_RATE_PARENT);
clk[IMX5_CLK_TVE_GATE]  = imx_clk_gate2("tve_gate", "tve_pred", 
MXC_CCM_CCGR2, 30);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/1] Add several Beckhoff Automation boards to critclk_systems DMI table

2019-05-02 Thread linux-kernel-dev
From: Steffen Dirkwinkel 

There are several Beckhoff Automation industrial PC boards which use
pmc_plt_clk* clocks for ethernet controllers. The patch adds affected boards
to critclk_systems DMI table so the clocks are marked as CLK_CRITICAL and
not turned off.
This should be applied on top of another patch as both change
the same table:
[PATCH] platform/x86: pmc_atom: Add Lex 3I380D industrial PC to critclk_systems 
DMI table

Steffen Dirkwinkel (1):
  platform/x86: pmc_atom: Add several Beckhoff Automation boards to
critclk_systems DMI table

 drivers/platform/x86/pmc_atom.c | 24 
 1 file changed, 24 insertions(+)

-- 
2.21.0


[PATCH 1/1] platform/x86: pmc_atom: Add several Beckhoff Automation boards to critclk_systems DMI table

2019-05-02 Thread linux-kernel-dev
From: Steffen Dirkwinkel 

There are several Beckhoff Automation industrial PC boards which use
pmc_plt_clk* clocks for ethernet controllers. This adds affected boards
to critclk_systems DMI table so the clocks are marked as CLK_CRITICAL and
not turned off.

Fixes: 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
Signed-off-by: Steffen Dirkwinkel 
---
 drivers/platform/x86/pmc_atom.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/platform/x86/pmc_atom.c b/drivers/platform/x86/pmc_atom.c
index a311f48ce7c9..b1d804376237 100644
--- a/drivers/platform/x86/pmc_atom.c
+++ b/drivers/platform/x86/pmc_atom.c
@@ -413,6 +413,30 @@ static const struct dmi_system_id critclk_systems[] = {
DMI_MATCH(DMI_PRODUCT_NAME, "3I380D"),
},
},
+   {
+   /* pmc_plt_clk* - are used for ethernet controllers */
+   .ident = "Beckhoff CB3163",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "Beckhoff Automation"),
+   DMI_MATCH(DMI_BOARD_NAME, "CB3163"),
+   },
+   },
+   {
+   /* pmc_plt_clk* - are used for ethernet controllers */
+   .ident = "Beckhoff CB6263",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "Beckhoff Automation"),
+   DMI_MATCH(DMI_BOARD_NAME, "CB6263"),
+   },
+   },
+   {
+   /* pmc_plt_clk* - are used for ethernet controllers */
+   .ident = "Beckhoff CB6363",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "Beckhoff Automation"),
+   DMI_MATCH(DMI_BOARD_NAME, "CB6363"),
+   },
+   },
{ /*sentinel*/ }
 };
 
-- 
2.21.0


[PATCH] platform/x86: pmc_atom: Add CB4063 Beckhoff Automation board to critclk_systems DMI table

2019-06-18 Thread linux-kernel-dev
From: Steffen Dirkwinkel 

The CB4063 board uses pmc_plt_clk* clocks for ethernet controllers. This
adds it to the critclk_systems DMI table so the clocks are marked as
CLK_CRITICAL and not turned off.

Fixes: 648e921888ad ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
Signed-off-by: Steffen Dirkwinkel 
---
 drivers/platform/x86/pmc_atom.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/platform/x86/pmc_atom.c b/drivers/platform/x86/pmc_atom.c
index be802fd2182d..551ed44dd361 100644
--- a/drivers/platform/x86/pmc_atom.c
+++ b/drivers/platform/x86/pmc_atom.c
@@ -412,6 +412,14 @@ static const struct dmi_system_id critclk_systems[] = {
DMI_MATCH(DMI_BOARD_NAME, "CB3163"),
},
},
+   {
+   /* pmc_plt_clk* - are used for ethernet controllers */
+   .ident = "Beckhoff CB4063",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "Beckhoff Automation"),
+   DMI_MATCH(DMI_BOARD_NAME, "CB4063"),
+   },
+   },
{
/* pmc_plt_clk* - are used for ethernet controllers */
.ident = "Beckhoff CB6263",
-- 
2.22.0


[PATCH] firmware: fix NULL pointer dereference in __fw_load_abort()

2017-01-04 Thread linux-kernel-dev
From: Patrick Bruenn 

Since commit 5d47ec02c37ea632398cb251c884e3a488dff794
("firmware: Correct handling of fw_state_wait() return value")

I see the following NULL pointer dereference:
[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.10.0-rc2-CX9020-10+ (patrickbr@lbs1) (gcc 
version 5.4.0 20160609 (Debian 5.4.0-6) ) #23 PREEMPT Wed Jan 4 08:10:24 CET 
2017
[0.00] CPU: ARMv7 Processor [412fc085] revision 5 (ARMv7), cr=10c5387d
[0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing 
instruction cache
[0.00] OF: fdt:Machine model: Freescale i.MX53 based Beckhoff CX9020
...
[3.098826] Unable to handle kernel NULL pointer dereference at virtual 
address 0018
[3.115823] pgd = c0004000
[3.118632] [0018] *pgd=
[3.122279] Internal error: Oops: 17 [#1] PREEMPT ARM
[3.127406] Modules linked in: pwm_imx parallel_display panel_simple 
uio_pdrv_genirq uio
[3.135637] CPU: 0 PID: 26 Comm: kworker/0:1 Not tainted 
4.10.0-rc2-CX9020-10+ #23
[3.143313] Hardware name: Freescale i.MX53 (Device Tree Support)
[3.149517] Workqueue: events request_firmware_work_func
[3.154908] task: dedbde00 task.stack: dee76000
[3.159510] PC is at _request_firmware+0x878/0x948
[3.164375] LR is at __mutex_lock_slowpath+0x2a8/0x340
[3.169576] pc : []lr : []psr: 60030013
sp : dee77e68  ip : dee77e20  fp : dee77ed4
[3.181183] r10: dee56a08  r9 : ded92410  r8 : dee56a00
[3.186470] r7 : dee77ee4  r6 : fffe  r5 : def41680  r4 : deeb1e00
[3.193070] r3 :   r2 :   r1 :   r0 : 
[3.199673] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[3.206891] Control: 10c5387d  Table: 8e1c8019  DAC: 0051
[3.212704] Process kworker/0:1 (pid: 26, stack limit = 0xdee76210)
[3.219044] Stack: (0xdee77e68 to 0xdee78000)
[3.223458] 7e60:   7fff  0001 c0102e2c 
c0c7a088 c0c735f8
[3.231731] 7e80: c0c5124c 0002 0001 7fff c0c04384 c0d1ae30 
1770 dec9d000
[3.240004] 7ea0: dedbde00 c0c12708  def41580 dee55680 c0c0ff68 
df263100 
[3.248290] 7ec0:  c0c6daf8 dee77efc dee77ed8 c04fffbc c04ff514 
 0007
[3.256565] 7ee0: 0c0e0832 c01413dc def41580 def41580 dee77f34 dee77f00 
c0141420 c04fff8c
[3.264841] 7f00: c0c0ff7c dee76038 dee58558 c0c0ff68 dee55698 c0c17e00 
c0c0ff7c dee76038
[3.273115] 7f20: 0008 dee55680 dee77f7c dee77f38 c014186c c01412f0 
dee77f54 dee76000
[3.281387] 7f40:  dee53cc0 c0c17e00 c0c217a1 dee58558 dee58540 
 dee53cc0
[3.289667] 7f60: dee55680 c0141810 dee58558 ded0be94 dee77fac dee77f80 
c0147dfc c014181c
[3.297945] 7f80: dee76000 dee53cc0 c0147ce8    
 
[3.306217] 7fa0:  dee77fb0 c0108e18 c0147cf4   
 
[3.314489] 7fc0:       
 
[3.322762] 7fe0:     0013  
 
[3.331055] [] (_request_firmware) from [] 
(request_firmware_work_func+0x3c/0x74)
[3.343535] [] (request_firmware_work_func) from [] 
(process_one_work+0x13c/0x52c)
[3.356057] [] (process_one_work) from [] 
(worker_thread+0x5c/0x620)
[3.367393] [] (worker_thread) from [] 
(kthread+0x114/0x144)
[3.378045] [] (kthread) from [] 
(ret_from_fork+0x14/0x3c)
[3.388481] Code: eafffdf5 e59f00bc eb08fe40 e5980100 (e5903018)
[3.682255] ---[ end trace dbbc5ea21820dd99 ]---

I believe I tracked it down to:
drivers/dma/imx-sdma.c request_firmware()
-> fw_load_from_user_helper()
-> _request_firmware_load()
-> call fw_state_wait_timeout()

Some time later firmware_loading_store() scans a control value of "-1"
-> switch(loading) case -1: will call
-> fw_load_abort(fw_priv) which calls
-> __fw_load_abort(fw_priv->buf)
-> and set fw_priv->buf = NULL;

back in _request_firmware_load()
fw_state_wait_timeout() returns -ENOENT
-> since mentioned commit
-> fw_load_abort(fw_priv) is called a second time
-> and this time it would call:
-> __fw_load_abort(NULL /* fw_priv->buf */)
-> and we get: NULL->fw_st.status which fits 0x18:
offsetof(struct firmware_buf, fw_st) + offsetof(struct fw_state, status)

As a novice, I have no idea how to fix the original patch in a clean way.
My workaround is to just check buf in fw_load_abort() or __fw_load_abort()
Maybe I am totally wrong and misconfigured my board.
Feedback is very much appreciated.

Signed-off-by: Patrick Bruenn 
---
 drivers/base/firmware_class.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 4497d263209f..3960ee117453 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -542,6 +542,8 @@ static struct firmware_priv *to_firmware_priv(struct device 
*dev)
 
 static void __fw_load_abort(st

[PATCH v2] firmware: fix NULL pointer dereference in __fw_load_abort()

2017-01-17 Thread linux-kernel-dev
From: Patrick Bruenn 

Since commit 5d47ec02c37ea632398cb251c884e3a488dff794
("firmware: Correct handling of fw_state_wait() return value")
fw_load_abort(fw_priv) could be called twice. The first call would
set fw_priv->buf = NULL; and the second call would pass that NULL
to __fw_load_abort() which would dereference that pointer:

[0.00] Booting Linux on physical CPU 0x0
[0.00] Linux version 4.10.0-rc2-CX9020-10+ (patrickbr@lbs1) (gcc 
version 5.4.0 20160609 (Debian 5.4.0-6) ) #23 PREEMPT Wed Jan 4 08:10:24 CET 
2017
[0.00] CPU: ARMv7 Processor [412fc085] revision 5 (ARMv7), cr=10c5387d
[0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing 
instruction cache
[0.00] OF: fdt:Machine model: Freescale i.MX53 based Beckhoff CX9020
...
[3.098826] Unable to handle kernel NULL pointer dereference at virtual 
address 0018
[3.115823] pgd = c0004000
[3.118632] [0018] *pgd=
[3.122279] Internal error: Oops: 17 [#1] PREEMPT ARM
[3.127406] Modules linked in: pwm_imx parallel_display panel_simple 
uio_pdrv_genirq uio
[3.135637] CPU: 0 PID: 26 Comm: kworker/0:1 Not tainted 
4.10.0-rc2-CX9020-10+ #23
[3.143313] Hardware name: Freescale i.MX53 (Device Tree Support)
[3.149517] Workqueue: events request_firmware_work_func
[3.154908] task: dedbde00 task.stack: dee76000
[3.159510] PC is at _request_firmware+0x878/0x948
[3.164375] LR is at __mutex_lock_slowpath+0x2a8/0x340
[3.169576] pc : []lr : []psr: 60030013
sp : dee77e68  ip : dee77e20  fp : dee77ed4
[3.181183] r10: dee56a08  r9 : ded92410  r8 : dee56a00
[3.186470] r7 : dee77ee4  r6 : fffe  r5 : def41680  r4 : deeb1e00
[3.193070] r3 :   r2 :   r1 :   r0 : 
[3.199673] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[3.206891] Control: 10c5387d  Table: 8e1c8019  DAC: 0051
[3.212704] Process kworker/0:1 (pid: 26, stack limit = 0xdee76210)
[3.219044] Stack: (0xdee77e68 to 0xdee78000)
[3.223458] 7e60:   7fff  0001 c0102e2c 
c0c7a088 c0c735f8
[3.231731] 7e80: c0c5124c 0002 0001 7fff c0c04384 c0d1ae30 
1770 dec9d000
[3.240004] 7ea0: dedbde00 c0c12708  def41580 dee55680 c0c0ff68 
df263100 
[3.248290] 7ec0:  c0c6daf8 dee77efc dee77ed8 c04fffbc c04ff514 
 0007
[3.256565] 7ee0: 0c0e0832 c01413dc def41580 def41580 dee77f34 dee77f00 
c0141420 c04fff8c
[3.264841] 7f00: c0c0ff7c dee76038 dee58558 c0c0ff68 dee55698 c0c17e00 
c0c0ff7c dee76038
[3.273115] 7f20: 0008 dee55680 dee77f7c dee77f38 c014186c c01412f0 
dee77f54 dee76000
[3.281387] 7f40:  dee53cc0 c0c17e00 c0c217a1 dee58558 dee58540 
 dee53cc0
[3.289667] 7f60: dee55680 c0141810 dee58558 ded0be94 dee77fac dee77f80 
c0147dfc c014181c
[3.297945] 7f80: dee76000 dee53cc0 c0147ce8    
 
[3.306217] 7fa0:  dee77fb0 c0108e18 c0147cf4   
 
[3.314489] 7fc0:       
 
[3.322762] 7fe0:     0013  
 
[3.331055] [] (_request_firmware) from [] 
(request_firmware_work_func+0x3c/0x74)
[3.343535] [] (request_firmware_work_func) from [] 
(process_one_work+0x13c/0x52c)
[3.356057] [] (process_one_work) from [] 
(worker_thread+0x5c/0x620)
[3.367393] [] (worker_thread) from [] 
(kthread+0x114/0x144)
[3.378045] [] (kthread) from [] 
(ret_from_fork+0x14/0x3c)
[3.388481] Code: eafffdf5 e59f00bc eb08fe40 e5980100 (e5903018)
[3.682255] ---[ end trace dbbc5ea21820dd99 ]---

In above case the call hierarchy looks like:
drivers/dma/imx-sdma.c request_firmware()
-> fw_load_from_user_helper()
-> _request_firmware_load()
-> call fw_state_wait_timeout()

Some time later firmware_loading_store() scans a control value of "-1"
-> switch(loading) case -1: will call
-> fw_load_abort(fw_priv) which calls
-> __fw_load_abort(fw_priv->buf)
-> and set fw_priv->buf = NULL;

back in _request_firmware_load()
fw_state_wait_timeout() returns -ENOENT
-> since mentioned commit
-> fw_load_abort(fw_priv) is called a second time
-> and this time it would call:
-> __fw_load_abort(NULL /* fw_priv->buf */)
-> and we get: NULL->fw_st.status which fits 0x18:
offsetof(struct firmware_buf, fw_st) + offsetof(struct fw_state, status)

Workaround: check buf in fw_load_abort() before passing it to __fw_load_abort().

Fixes: 5d47ec02c37ea632398cb251c884e3a488dff794
("firmware: Correct handling of fw_state_wait() return value")

Signed-off-by: Patrick Bruenn 
Cc: sta...@vger.kernel.org
---
Hi Luis,
It's not my intention to bugging you. I just noticed we got rc4 still
unpatched, so this is my attempt to resend you a version, which might
be easier to apply.
Regards,
Patrick

v2:
- check buf in fw_load_abort() as suggested by

RE: [PATCHv2] firmware: Correct handling of fw_state_wait_timeout() return value

2017-01-17 Thread linux-kernel-dev
>From: Jakub Kicinski [mailto:jakub.kicin...@netronome.com]
>Sent: Dienstag, 17. Januar 2017 22:18
>
>On Tue, Jan 17, 2017 at 12:53 PM, Luis R. Rodriguez 
>wrote:
>> On Tue, Jan 17, 2017 at 10:04:20AM -0800, Jakub Kicinski wrote:
>>> On Tue, Jan 17, 2017 at 9:30 AM, Luis R. Rodriguez 
>wrote:
>>> > On Tue, Jan 17, 2017 at 08:30:37AM -0800, Jakub Kicinski wrote:
>>> >> Adding a NULL-check would just paper over the
>>> >> issue and can cause trouble down the line.
>>> >
>>> > We typically bail on errors and use similar code to bail out, and we
>>> > typically do these things. Here its no different. The *real* issue
>>> > is the fact that we have a waiting timeout which can fail race against
>>> > a user imposed error out on the sysfs interface. There is one catch:
>>> >
>>> > We already lock with the big fw_lock and use this to be able to check
>>> > for the status of the fw, so once aborted we technically should not have
>>> > to abort again. A proper way to address then this would have been to
>check
>>> > for the status of the fw prior to aborting again given we also lock on the
>>> > big fw_lock. A problem with this though is the status is part of the buf
>>> > which is set to NULL after we are done aborting.
>>>
>>> Yes, I've seen that too :\  This race seems to have been there prior
>>> to 4.9, though.  I guess we could fix both issues with the NULL-check
>>> although I would prefer if we had both patches.
>>>
>>> FWIW I think the NULL-check could be put in the existing conditional:
>>>
>>>  * There is a small window in which user can write to 'loading'
>>>  * between loading done and disappearance of 'loading'
>>>  */
>>> -   if (fw_state_is_done(&buf->fw_st))
>>> +   if (!buf || fw_state_is_done(&buf->fw_st))
>>> return;
>>>
>>> list_del_init(&buf->pending_list);
>>>
>>> Note that the comment above seems to be mentioning the race we're
>>> trying to solve.
>>
>> Right, I think another approach is to *enable* the state of the buf
>> to be used to avoid further use on the sysfs iterface instead. Fortunately
>> other sysfs interfaces already use fw_state_is_done() to bail out,
>> so all that would be needed I think would be:
>>
>> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
>> index b9ac348e8d33..30ccf7aea3ca 100644
>> --- a/drivers/base/firmware_class.c
>> +++ b/drivers/base/firmware_class.c
>> @@ -558,9 +558,6 @@ static void fw_load_abort(struct firmware_priv
>*fw_priv)
>> struct firmware_buf *buf = fw_priv->buf;
>>
>> __fw_load_abort(buf);
>> -
>> -   /* avoid user action after loading abort */
>> -   fw_priv->buf = NULL;
>>  }
>>
>>  static LIST_HEAD(pending_fw_head);
>> @@ -713,7 +710,7 @@ static ssize_t firmware_loading_store(struct device
>*dev,
>>
>> mutex_lock(&fw_lock);
>> fw_buf = fw_priv->buf;
>> -   if (!fw_buf)
>> +   if (!fw_buf || fw_state_is_aborted(&fw_buf->fw_st))
>> goto out;
>>
>> switch (loading) {
>
>IMHO this one is nice!  I think you can even drop the !fw_buf check in
>this case because AFAICS the only case where fw_buf is set to NULL is
>in the abort function.
>
I can confirm, that patch looks nice and is working for my setup, even without 
the !fw_buf. 
Feel free to grab everything you need from my commit log, if it helps.
Unfortunately there is a crazy spam filter between us, so you can't rely on me.
 


[PATCH] ARM: dts: imx53-qsb-common: fix FEC pinmux config

2017-01-24 Thread linux-kernel-dev
From: Patrick Bruenn 

The pinmux configuration in device tree was different from manual
muxing in /board/freescale/mx53loco/mx53loco.c
All pins were configured as NO_PAD_CTL(1 << 31), which was fine as the
bootloader already did the correct pinmuxing for us.
But recently u-boot is migrating to reuse device tree files from the
kernel tree, so it seems to be better to have the correct pinmuxing in
our files, too.

Signed-off-by: Patrick Bruenn 
---
 arch/arm/boot/dts/imx53-qsb-common.dtsi | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi 
b/arch/arm/boot/dts/imx53-qsb-common.dtsi
index c05e7cfd0cbc..40b3e31935d0 100644
--- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
@@ -215,16 +215,16 @@
 
pinctrl_fec: fecgrp {
fsl,pins = <
-   MX53_PAD_FEC_MDC__FEC_MDC   
0x8000
-   MX53_PAD_FEC_MDIO__FEC_MDIO 
0x8000
-   MX53_PAD_FEC_REF_CLK__FEC_TX_CLK
0x8000
-   MX53_PAD_FEC_RX_ER__FEC_RX_ER   
0x8000
-   MX53_PAD_FEC_CRS_DV__FEC_RX_DV  
0x8000
-   MX53_PAD_FEC_RXD1__FEC_RDATA_1  
0x8000
-   MX53_PAD_FEC_RXD0__FEC_RDATA_0  
0x8000
-   MX53_PAD_FEC_TX_EN__FEC_TX_EN   
0x8000
-   MX53_PAD_FEC_TXD1__FEC_TDATA_1  
0x8000
-   MX53_PAD_FEC_TXD0__FEC_TDATA_0  
0x8000
+   MX53_PAD_FEC_MDC__FEC_MDC   0x4
+   MX53_PAD_FEC_MDIO__FEC_MDIO 0x1fc
+   MX53_PAD_FEC_REF_CLK__FEC_TX_CLK0x180
+   MX53_PAD_FEC_RX_ER__FEC_RX_ER   0x180
+   MX53_PAD_FEC_CRS_DV__FEC_RX_DV  0x180
+   MX53_PAD_FEC_RXD1__FEC_RDATA_1  0x180
+   MX53_PAD_FEC_RXD0__FEC_RDATA_0  0x180
+   MX53_PAD_FEC_TX_EN__FEC_TX_EN   0x4
+   MX53_PAD_FEC_TXD1__FEC_TDATA_1  0x4
+   MX53_PAD_FEC_TXD0__FEC_TDATA_0  0x4
>;
};
 
-- 
2.11.0




[RFC] ARM: dts: imx53-qsb-common: fix FEC pinmux config

2017-01-23 Thread linux-kernel-dev
From: Patrick Bruenn 

The pinmux configuration in device tree is different from manual
muxing in /board/freescale/mx53loco/mx53loco.c
It seems the device tree configuration is never used by any kernel
driver and the correct setting, preconfigured by u-boot, was never
overwritten. So this issue never showed up anywhere.

---
I stumbled upon this difference, while adding the imx53 based CX9020
Embedded PC to u-boot bootloader. "New" boards are encouraged to use
device tree for pinmuxing in u-boot, so I tried to reuse
imx53-qsb-common.dtsi for that. That failed with a high packet loss on
the fec_mxc device. With the attached patch that device tree based
pinmuxing seems successful in u-boot. My suggestion is to apply it to
imx53-qsb-common.dtsi, too. That will help other "late adopters" and
prevent similar issues, in case any kernel driver starts using this
pinmux configurations.

Signed-off-by: Patrick Bruenn 
---
 arch/arm/boot/dts/imx53-qsb-common.dtsi | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi 
b/arch/arm/boot/dts/imx53-qsb-common.dtsi
index c05e7cfd0cbc..40b3e31935d0 100644
--- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
@@ -215,16 +215,16 @@
 
pinctrl_fec: fecgrp {
fsl,pins = <
-   MX53_PAD_FEC_MDC__FEC_MDC   
0x8000
-   MX53_PAD_FEC_MDIO__FEC_MDIO 
0x8000
-   MX53_PAD_FEC_REF_CLK__FEC_TX_CLK
0x8000
-   MX53_PAD_FEC_RX_ER__FEC_RX_ER   
0x8000
-   MX53_PAD_FEC_CRS_DV__FEC_RX_DV  
0x8000
-   MX53_PAD_FEC_RXD1__FEC_RDATA_1  
0x8000
-   MX53_PAD_FEC_RXD0__FEC_RDATA_0  
0x8000
-   MX53_PAD_FEC_TX_EN__FEC_TX_EN   
0x8000
-   MX53_PAD_FEC_TXD1__FEC_TDATA_1  
0x8000
-   MX53_PAD_FEC_TXD0__FEC_TDATA_0  
0x8000
+   MX53_PAD_FEC_MDC__FEC_MDC   0x4
+   MX53_PAD_FEC_MDIO__FEC_MDIO 0x1fc
+   MX53_PAD_FEC_REF_CLK__FEC_TX_CLK0x180
+   MX53_PAD_FEC_RX_ER__FEC_RX_ER   0x180
+   MX53_PAD_FEC_CRS_DV__FEC_RX_DV  0x180
+   MX53_PAD_FEC_RXD1__FEC_RDATA_1  0x180
+   MX53_PAD_FEC_RXD0__FEC_RDATA_0  0x180
+   MX53_PAD_FEC_TX_EN__FEC_TX_EN   0x4
+   MX53_PAD_FEC_TXD1__FEC_TDATA_1  0x4
+   MX53_PAD_FEC_TXD0__FEC_TDATA_0  0x4
>;
};
 
-- 
2.11.0




[PATCH v2 2/2] drm/panel: simple: Add support for ddc-only panel

2017-07-13 Thread linux-kernel-dev
From: Patrick Bruenn 

This is a fix for the CX9020 Embedded PC. On that device the 24-bit
parallel-display signal of the imx53 is combined with an I2C channel
and converted to DVI-D port. Devicetree magic always requires a panel
connected to the parallel-display port.
We add an empty panel_desc, to get recognized by the panel-simple
driver, which can then use the ddc bus to read the panels configuration.

Signed-off-by: Patrick Bruenn 
---
 drivers/gpu/drm/panel/panel-simple.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index c4566ce8fda7..52b2a7fb59ed 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1856,6 +1856,9 @@ static const struct panel_desc winstar_wf35ltiacd = {
.bus_format = MEDIA_BUS_FMT_RGB888_1X24,
 };
 
+static const struct panel_desc simple_ddc_only = {
+};
+
 static const struct of_device_id platform_of_match[] = {
{
.compatible = "ampire,am-480272h3tmqw-t01h",
@@ -2050,6 +2053,9 @@ static const struct of_device_id platform_of_match[] = {
.compatible = "winstar,wf35ltiacd",
.data = &winstar_wf35ltiacd,
}, {
+   .compatible = "simple,ddc-only",
+   .data = &simple_ddc_only,
+   }, {
/* sentinel */
}
 };
-- 
2.11.0




[PATCH v2 0/2] Add CX9020 device tree

2017-07-13 Thread linux-kernel-dev
From: Patrick Bruenn 

Add device tree for Beckhoff CX9020 Embedded PC.

The CX9020 differs from i.MX53 Quick Start Board by:
- use uart2 instead of uart1
- DVI-D connector instead of VGA
- no audio
- CCAT FPGA connected to emi
- enable rtc

Patrick Bruenn (2):
  ARM: dts: imx: add CX9020 Embedded PC device tree
  drm/panel: simple: Add support for ddc-only panel

 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/imx53-cx9020.dts   | 370 +++
 drivers/gpu/drm/panel/panel-simple.c |   6 +
 3 files changed, 377 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-cx9020.dts

-- 
2.11.0




[PATCH v2 1/2] ARM: dts: imx: add CX9020 Embedded PC device tree

2017-07-13 Thread linux-kernel-dev
From: Patrick Bruenn 

The CX9020 differs from i.MX53 Quick Start Board by:
- use uart2 instead of uart1
- DVI-D connector instead of VGA
- no audio
- CCAT FPGA connected to emi
- enable rtc

Signed-off-by: Patrick Bruenn 
---
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/imx53-cx9020.dts | 370 +
 2 files changed, 371 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-cx9020.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 9c5e1d944d1c..590cdb77d972 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -338,6 +338,7 @@ dtb-$(CONFIG_SOC_IMX51) += \
imx51-ts4800.dtb
 dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
+   imx53-cx9020.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
imx53-qsb.dtb \
diff --git a/arch/arm/boot/dts/imx53-cx9020.dts 
b/arch/arm/boot/dts/imx53-cx9020.dts
new file mode 100644
index ..0c3de61a5f4f
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-cx9020.dts
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx53.dtsi"
+
+#define MX53_PAD_EIM_D26__UART2_RXD_MUX0x144 0x48c 0x880 0x2 0x0
+#define MX53_PAD_EIM_D27__UART2_TXD_MUX0x148 0x490 0x000 0x2 0x0
+#define MX53_PAD_EIM_D28__UART2_RTS0x14c 0x494 0x87c 0x2 0x0
+#define MX53_PAD_EIM_D29__UART2_CTS0x150 0x498 0x000 0x2 0x0
+
+/ {
+   model = "Freescale i.MX53 based Beckhoff CX9020";
+   compatible = "fsl,imx53-qsb", "fsl,imx53";
+
+   chosen {
+   stdout-path = &uart2;
+   };
+
+   memory {
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   ccat {
+   compatible = "bhf,emi-ccat";
+   };
+
+   display-0 {
+   #address-cells =<1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx-parallel-display";
+   interface-pix-fmt = "rgb24";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu_disp0>;
+   status = "okay";
+
+   port@0 {
+   reg = <0>;
+   display0_in: endpoint {
+   remote-endpoint = <&ipu_di0_disp0>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+   display0_out: endpoint {
+   remote-endpoint = <&panel_in>;
+   };
+   };
+   };
+
+   panel-0 {
+   #address-cells =<1>;
+   #size-cells = <0>;
+   compatible = "simple,ddc-only";
+   ddc-i2c-bus = <&i2c2>;
+
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <&display0_out>;
+   };
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pwr_r {
+   gpios = <&gpio3 22 0>;
+   default-state = "off";
+   };
+   pwr_g {
+   gpios = <&gpio3 24 0>;
+   default-state = "on";
+   };
+   pwr_b {
+   gpios = <&gpio3 23 0>;
+   default-state = "off";
+   };
+   };
+
+   rtc: rtc@53fa4000 {
+   compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   interrupt-parent = <&tzic>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+   clock-names = "ipg";
+   };
+
+   reg_3p2v: regulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "3P2V";
+   regulator-min-microvolt = <320>;
+   regulator-max-microvolt = <320>;
+   regulator-always-on;
+   };
+
+   reg_usb_vbus: regulator@1 {
+   compatible = "regulator-fixed";
+   regulator-name = "usb_vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   gpio = <&gpio7 8 0>;
+   enable-active-high;
+   };
+};
+
+&esdhc1 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_esdhc1>;
+   cd-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
+   bus-width = <4>;
+   status = "okay";
+};
+
+&esdhc2 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_esdhc2>;
+   cd-gpios = <&gpio1 4 

[PATCH v3 1/2] ARM: dts: imx: add CX9020 Embedded PC device tree

2017-07-13 Thread linux-kernel-dev
From: Patrick Bruenn 

The CX9020 differs from i.MX53 Quick Start Board by:
- use uart2 instead of uart1
- DVI-D connector instead of VGA
- no audio
- CCAT FPGA connected to emi
- enable rtc

Signed-off-by: Patrick Bruenn 

---
Cc: Andrew Lunn 

v3: add missig changelog
v2:
- keep alphabetic order of dts/Makefile
- configure uart2 with 'fsl,dte-mode'
- use display-0 and panel-0 as node names
- remove unnecessary "simple-bus" for fixed regulators
---
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/imx53-cx9020.dts | 370 +
 2 files changed, 371 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-cx9020.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 9c5e1d944d1c..590cdb77d972 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -338,6 +338,7 @@ dtb-$(CONFIG_SOC_IMX51) += \
imx51-ts4800.dtb
 dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
+   imx53-cx9020.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
imx53-qsb.dtb \
diff --git a/arch/arm/boot/dts/imx53-cx9020.dts 
b/arch/arm/boot/dts/imx53-cx9020.dts
new file mode 100644
index ..0c3de61a5f4f
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-cx9020.dts
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx53.dtsi"
+
+#define MX53_PAD_EIM_D26__UART2_RXD_MUX0x144 0x48c 0x880 0x2 0x0
+#define MX53_PAD_EIM_D27__UART2_TXD_MUX0x148 0x490 0x000 0x2 0x0
+#define MX53_PAD_EIM_D28__UART2_RTS0x14c 0x494 0x87c 0x2 0x0
+#define MX53_PAD_EIM_D29__UART2_CTS0x150 0x498 0x000 0x2 0x0
+
+/ {
+   model = "Freescale i.MX53 based Beckhoff CX9020";
+   compatible = "fsl,imx53-qsb", "fsl,imx53";
+
+   chosen {
+   stdout-path = &uart2;
+   };
+
+   memory {
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   ccat {
+   compatible = "bhf,emi-ccat";
+   };
+
+   display-0 {
+   #address-cells =<1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx-parallel-display";
+   interface-pix-fmt = "rgb24";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu_disp0>;
+   status = "okay";
+
+   port@0 {
+   reg = <0>;
+   display0_in: endpoint {
+   remote-endpoint = <&ipu_di0_disp0>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+   display0_out: endpoint {
+   remote-endpoint = <&panel_in>;
+   };
+   };
+   };
+
+   panel-0 {
+   #address-cells =<1>;
+   #size-cells = <0>;
+   compatible = "simple,ddc-only";
+   ddc-i2c-bus = <&i2c2>;
+
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <&display0_out>;
+   };
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pwr_r {
+   gpios = <&gpio3 22 0>;
+   default-state = "off";
+   };
+   pwr_g {
+   gpios = <&gpio3 24 0>;
+   default-state = "on";
+   };
+   pwr_b {
+   gpios = <&gpio3 23 0>;
+   default-state = "off";
+   };
+   };
+
+   rtc: rtc@53fa4000 {
+   compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   interrupt-parent = <&tzic>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+   clock-names = "ipg";
+   };
+
+   reg_3p2v: regulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "3P2V";
+   regulator-min-microvolt = <320>;
+   regulator-max-microvolt = <320>;
+   regulator-always-on;
+   };
+
+   reg_usb_vbus: regulator@1 {
+   compatible = "regulator-fixed";
+   regulator-name = "usb_vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   gpio = <&gpio7 8 0>;
+   enable-active-high;
+   };
+};
+
+&esdhc1 {
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl

[PATCH v3 0/2] Add CX9020 device tree

2017-07-13 Thread linux-kernel-dev
From: Patrick Bruenn 

Add device tree for Beckhoff CX9020 Embedded PC.

The CX9020 differs from i.MX53 Quick Start Board by:
- use uart2 instead of uart1
- DVI-D connector instead of VGA
- no audio
- CCAT FPGA connected to emi
- enable rtc

v3: add missing changelog, sorry about the noise
v2:
- include simple ddc-only panel patch
- keep alphabetic order of dts/Makefile
- configure uart2 with 'fsl,dte-mode'
- use display-0 and panel-0 as node names
- remove unnecessary "simple-bus" for fixed regulators


Patrick Bruenn (2):
  ARM: dts: imx: add CX9020 Embedded PC device tree
  drm/panel: simple: Add support for ddc-only panel

 arch/arm/boot/dts/Makefile   |   1 +
 arch/arm/boot/dts/imx53-cx9020.dts   | 370 +++
 drivers/gpu/drm/panel/panel-simple.c |   6 +
 3 files changed, 377 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-cx9020.dts

-- 
2.11.0




[PATCH v3 2/2] drm/panel: simple: Add support for ddc-only panel

2017-07-13 Thread linux-kernel-dev
From: Patrick Bruenn 

This is a fix for the CX9020 Embedded PC. On that device the 24-bit
parallel-display signal of the imx53 is combined with an I2C channel
and converted to DVI-D port. Devicetree magic always requires a panel
connected to the parallel-display port.
We add an empty panel_desc, to get recognized by the panel-simple
driver, which can then use the ddc bus to read the panels configuration.

Signed-off-by: Patrick Bruenn 
---
 drivers/gpu/drm/panel/panel-simple.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index c4566ce8fda7..52b2a7fb59ed 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1856,6 +1856,9 @@ static const struct panel_desc winstar_wf35ltiacd = {
.bus_format = MEDIA_BUS_FMT_RGB888_1X24,
 };
 
+static const struct panel_desc simple_ddc_only = {
+};
+
 static const struct of_device_id platform_of_match[] = {
{
.compatible = "ampire,am-480272h3tmqw-t01h",
@@ -2050,6 +2053,9 @@ static const struct of_device_id platform_of_match[] = {
.compatible = "winstar,wf35ltiacd",
.data = &winstar_wf35ltiacd,
}, {
+   .compatible = "simple,ddc-only",
+   .data = &simple_ddc_only,
+   }, {
/* sentinel */
}
 };
-- 
2.11.0




[PATCH] ARM: dts: imx: add CX9020 Embedded PC device tree

2017-07-12 Thread linux-kernel-dev
From: Patrick Brünn 

The CX9020 differs from i.MX53 Quick Start Board by:
- use uart2 instead of uart1
- DVI-D connector instead of VGA
- no audio
- CCAT FPGA connected to emi
- enable rtc

Signed-off-by: Patrick Brünn 
---
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/imx53-cx9020.dts | 377 +
 2 files changed, 378 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-cx9020.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 9c5e1d944d1c..ea60698f9783 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -340,6 +340,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
+   imx53-cx9020.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-smd.dtb \
diff --git a/arch/arm/boot/dts/imx53-cx9020.dts 
b/arch/arm/boot/dts/imx53-cx9020.dts
new file mode 100644
index ..e6d05ffa9022
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-cx9020.dts
@@ -0,0 +1,377 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx53.dtsi"
+
+#define MX53_PAD_EIM_D26__UART2_RXD_MUX0x144 0x48c 0x880 0x2 0x0
+#define MX53_PAD_EIM_D27__UART2_TXD_MUX0x148 0x490 0x000 0x2 0x0
+#define MX53_PAD_EIM_D28__UART2_RTS0x14c 0x494 0x87c 0x2 0x0
+#define MX53_PAD_EIM_D29__UART2_CTS0x150 0x498 0x000 0x2 0x0
+
+/ {
+   model = "Freescale i.MX53 based Beckhoff CX9020";
+   compatible = "fsl,imx53-qsb", "fsl,imx53";
+
+   chosen {
+   stdout-path = &uart2;
+   };
+
+   memory {
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   ccat {
+   compatible = "bhf,emi-ccat";
+   };
+
+   display0: display@di0 {
+   #address-cells =<1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx-parallel-display";
+   interface-pix-fmt = "rgb24";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu_disp0>;
+   status = "okay";
+
+   port@0 {
+   reg = <0>;
+   display0_in: endpoint {
+   remote-endpoint = <&ipu_di0_disp0>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+   display0_out: endpoint {
+   remote-endpoint = <&panel_in>;
+   };
+   };
+   };
+
+   dvi_panel: display@0 {
+   #address-cells =<1>;
+   #size-cells = <0>;
+   compatible = "simple,ddc-only";
+   ddc-i2c-bus = <&i2c2>;
+
+   port {
+   panel_in: endpoint {
+   remote-endpoint = <&display0_out>;
+   };
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pwr_r {
+   gpios = <&gpio3 22 0>;
+   default-state = "off";
+   };
+   pwr_g {
+   gpios = <&gpio3 24 0>;
+   default-state = "on";
+   };
+   pwr_b {
+   gpios = <&gpio3 23 0>;
+   default-state = "off";
+   };
+   };
+
+   rtc: rtc@53fa4000 {
+   compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   interrupt-parent = <&tzic>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+   clock-names = "ipg";
+   };
+
+   regulators {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   reg_3p2v: regulator@0 {
+   compatible = "regulator-fixed";
+   reg = <0>;
+   regulator-name = "3P2V";
+   regulator-min-microvolt = <320>;
+   regulator-max-microvolt = <320>;
+   regulator-always-on;
+   };
+
+   reg_usb_vbus: regulator@1 {
+   compatible = "regulator-fixed";
+   reg = <1>;
+   regulator-name = "usb_vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   gpio = <&gpio7 8 0>;
+   e

[PATCH v4 1/2] dt-bindings: arm: Add entry for Beckhoff CX9020

2017-07-20 Thread linux-kernel-dev
From: Patrick Bruenn 

- add vendor prefix bhf for Beckhoff
- add new board binding bhf,cx9020

Signed-off-by: Patrick Bruenn 
---
 Documentation/devicetree/bindings/arm/bhf.txt | 6 ++
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 MAINTAINERS   | 5 +
 3 files changed, 12 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/bhf.txt

diff --git a/Documentation/devicetree/bindings/arm/bhf.txt 
b/Documentation/devicetree/bindings/arm/bhf.txt
new file mode 100644
index ..886b503caf9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/bhf.txt
@@ -0,0 +1,6 @@
+Beckhoff Automation Platforms Device Tree Bindings
+--
+
+CX9020 Embedded PC
+Required root node properties:
+- compatible = "bhf,cx9020", "fsl,imx53";
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index daf465bef758..20c2cf57ebc9 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -47,6 +47,7 @@ avic  Shanghai AVIC Optoelectronics Co., Ltd.
 axentiaAxentia Technologies AB
 axis   Axis Communications AB
 bananapi BIPAI KEJI LIMITED
+bhfBeckhoff Automation GmbH & Co. KG
 boeBOE Technology Group Co., Ltd.
 bosch  Bosch Sensortec GmbH
 boundary   Boundary Devices Inc.
diff --git a/MAINTAINERS b/MAINTAINERS
index 205d3977ac46..1bf282843dc2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1172,6 +1172,11 @@ M:   Boris Brezillon 

 S: Maintained
 F: drivers/clk/at91
 
+ARM/BECKHOFF SUPPORT
+M: Patrick Bruenn 
+S: Maintained
+F: Documentation/devicetree/bindings/arm/bhf.txt
+
 ARM/CALXEDA HIGHBANK ARCHITECTURE
 M: Rob Herring 
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
-- 
2.11.0




[PATCH v4 2/2] ARM: dts: imx: add CX9020 Embedded PC device tree

2017-07-20 Thread linux-kernel-dev
From: Patrick Bruenn 

The CX9020 differs from i.MX53 Quick Start Board by:
- use uart2 instead of uart1
- DVI-D connector instead of VGA
- no audio
- no SATA connector
- CCAT FPGA connected to emi
- enable rtc

Signed-off-by: Patrick Bruenn 

---

v4:
- move alternative UART2 pinmux settings to imx53-pinfunc.h
- fix copyright notice and model name to clearify cx9020 is a
  Beckhoff board and not from Freescale/NXP/Qualcomm
- add "bhf,cx9020" compatible
- remove ccat node and pin configuration as long as the ccat
  driver is not mainlined
- use dvi-connector + ti,tfp410 instead of panel-simple
- add newlines between property list and child nodes
- replace underscores in node names with hypens
- replace magic number 0 with polarity defines from
  include/dt-bindings/gpio/gpio.h
- move rtc node into imx53.dtsi, change it's name into 'srtc',
  to avoid a conflict with 'rtc' node in imx53-m53.dtsi
- rename regulator-3p2v
- drop imx53-qsb container node
- make iomux configuration explicit
- remove unused audmux
- remove unused led_pin_gpio3_23 configuration
- use blue gpio-leds as disk-activity indicators for mmc0 and mmc1
- add mmc indicator leds to sdhc pingroups
- keep node names in alphabetical order
- remove unused sata and ssi2
- remove unused pin configs from hoggrp
- add entry for imx53-cx9020.dts to MAINTAINERS

v3: add missig changelog
v2:
- keep alphabetic order of dts/Makefile
- configure uart2 with 'fsl,dte-mode'
- use display-0 and panel-0 as node names
- remove unnecessary "simple-bus" for fixed regulators

Cc: Andrew Lunn 
---
 MAINTAINERS|   1 +
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/imx53-cx9020.dts | 295 +
 arch/arm/boot/dts/imx53-pinfunc.h  |   4 +
 arch/arm/boot/dts/imx53.dtsi   |   9 ++
 5 files changed, 310 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-cx9020.dts

diff --git a/MAINTAINERS b/MAINTAINERS
index 1bf282843dc2..1bd06328f79b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1176,6 +1176,7 @@ ARM/BECKHOFF SUPPORT
 M: Patrick Bruenn 
 S: Maintained
 F: Documentation/devicetree/bindings/arm/bhf.txt
+F: arch/arm/boot/dts/imx53-cx9020.dts
 
 ARM/CALXEDA HIGHBANK ARCHITECTURE
 M: Rob Herring 
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 4b17f35dc9a7..f0ba9be523e0 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -340,6 +340,7 @@ dtb-$(CONFIG_SOC_IMX51) += \
imx51-ts4800.dtb
 dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
+   imx53-cx9020.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
imx53-qsb.dtb \
diff --git a/arch/arm/boot/dts/imx53-cx9020.dts 
b/arch/arm/boot/dts/imx53-cx9020.dts
new file mode 100644
index ..c4f9c89668c2
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-cx9020.dts
@@ -0,0 +1,295 @@
+/*
+ * Copyright 2017 Beckhoff Automation GmbH & Co. KG
+ * based on imx53-qsb.dts
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx53.dtsi"
+
+/ {
+   model = "Beckhoff CX9020 Embedded PC";
+   compatible = "bhf,cx9020", "fsl,imx53";
+
+   chosen {
+   stdout-path = &uart2;
+   };
+
+   memory {
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   display-0 {
+   #address-cells =<1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx-parallel-display";
+   interface-pix-fmt = "rgb24";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu_disp0>;
+   status = "okay";
+
+   port@0 {
+   reg = <0>;
+
+   display0_in: endpoint {
+   remote-endpoint = <&ipu_di0_disp0>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   display0_out: endpoint {
+   remote-endpoint = <&tfp410_in>;
+   };
+   };
+   };
+
+   dvi-connector {
+   compatible = "dvi-connector";
+   ddc-i2c-bus = <&i2c2>;
+   digital;
+
+   port {
+   dvi_connector_in: endpoint {
+   remote-endpoint = <&tfp410_out>;
+   };
+   };
+   };
+
+   dvi-converter {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "ti,tfp410";
+
+   port@0 {
+   reg = <0>;
+
+   tfp410_in: endpoint {
+ 

[PATCH] Documentation: dt: rtc-imxdi: imx53-rtc is not compatible

2017-11-16 Thread linux-kernel-dev
From: Patrick Bruenn 

rtc-imxdi driver is not compatible with imx53-rtc like the example
suggested.
Only the raw timestamp register offsets match by accident, which has the
effect, that during startup/shutdown system clock syncronization with
rtc seems to work for imx53, too.
However hwclock and rtctest, will not work as expected on imx53.
To avoid future reverts like [1], we should adjust the documentation.

[1] 
http://lists.infradead.org/pipermail/linux-arm-kernel/2017-November/542312.html

Signed-off-by: Patrick Bruenn 

---

To: Alessandro Zummo 
To: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
---
 Documentation/devicetree/bindings/rtc/imxdi-rtc.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt 
b/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
index 323cf26374cb..af853b0ceac5 100644
--- a/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/imxdi-rtc.txt
@@ -1,6 +1,6 @@
 * i.MX25 Real Time Clock controller
 
-This binding supports the following chips: i.MX25, i.MX53
+This binding supports the following chips: i.MX25
 
 Required properties:
 - compatible: should be: "fsl,imx25-rtc"
@@ -14,7 +14,7 @@ Optional properties:
 Example:
 
 rtc@80056000 {
-   compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
+   compatible = "fsl,imx25-rtc";
reg = <0x80056000 2000>;
interrupts = <29 56>;
 };
-- 
2.11.0




[PATCH v2 2/5] ARM: dts: imx53: add srtc node

2017-12-05 Thread linux-kernel-dev
From: Patrick Bruenn 

rtc-mxc_v2 driver will add support for the i.MX53 SRTC

Signed-off-by: Patrick Bruenn 

---

To: Shawn Guo 
To: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 arch/arm/boot/dts/imx53.dtsi | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 589a67c5f796..e4ca9d9ba2fe 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -434,12 +434,10 @@
};
 
srtc: srtc@53fa4000 {
-   compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
+   compatible = "fsl,imx53-rtc";
reg = <0x53fa4000 0x4000>;
interrupts = <24>;
-   interrupt-parent = <&tzic>;
clocks = <&clks IMX5_CLK_SRTC_GATE>;
-   clock-names = "ipg";
};
 
iomuxc: iomuxc@53fa8000 {
-- 
2.11.0


[PATCH v2 0/5] add mxc driver for i.MX53 SRTC

2017-12-05 Thread linux-kernel-dev
From: Patrick Bruenn 

Neither rtc-imxdi, rtc-mxc nor rtc-snvs are compatible with i.MX53.

This is driver enables support for the low power domain SRTC features:
- 32-bit MSB of non-rollover time counter
- 32-bit alarm register

Based on:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/rtc/rtc-mxc_v2.c?h=imx_2.6.35_11.09.01

v2:
- have seperate patches for dt-binding, CONFIG option, imx53.dtsi and driver
- add SPDX-License-Identifier and cleanup copyright notice
- replace __raw_readl/writel() with readl/writel()
- fix PM_SLEEP callbacks
- add CONFIG_RTC_DRV_MXC_V2 to build rtc-mxc_v2.c
- remove misleading or obvious comments and fix style of the remaining
- avoid endless loop while waiting for hw
- implement consistent locking; make spinlock a member of dev struct
- enable clk only for register accesses
- remove all udelay() calls since they are obsolete or redundant
  (we are already waiting for register flags to change)
- init platform_data before registering irq callback
- let set_time() fail, when 32 bit rtc counter exceeded
- make names more consistent
- cleanup and reorder includes
- cleanup and remove unused defines

To: Alessandro Zummo 
To: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 

Patrick Bruenn (5):
  dt-bindings: rtc: add bindings for i.MX53 SRTC
  ARM: dts: imx53: add srtc node
  rtc: mxc_v2: add driver for i.MX53 SRTC
  ARM: imx_v4_v5_defconfig: enable RTC_DRV_MXC_V2
  rtc: add mxc driver for i.MX53 SRTC

 .../devicetree/bindings/rtc/rtc-mxc_v2.txt |  17 +
 arch/arm/boot/dts/imx53.dtsi   |   4 +-
 arch/arm/configs/imx_v4_v5_defconfig   |   1 +
 drivers/rtc/Kconfig|  10 +
 drivers/rtc/Makefile   |   1 +
 drivers/rtc/rtc-mxc_v2.c   | 433 +
 6 files changed, 463 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
 create mode 100644 drivers/rtc/rtc-mxc_v2.c

-- 
2.11.0


[PATCH v2 1/5] dt-bindings: rtc: add bindings for i.MX53 SRTC

2017-12-05 Thread linux-kernel-dev
From: Patrick Bruenn 

Document the binding for i.MX53 SRTC implemented by rtc-mxc_v2

Signed-off-by: Patrick Bruenn 

---

To: Alessandro Zummo 
To: Alexandre Belloni 

Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt

diff --git a/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt 
b/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
new file mode 100644
index ..796e7f4995db
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
@@ -0,0 +1,17 @@
+* i.MX53 Real Time Clock controller
+
+Required properties:
+- compatible: should be: "fsl,imx53-rtc"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- clocks: should contain the phandle for the rtc clock
+- interrupts: rtc alarm interrupt
+
+Example:
+
+srtc@53fa4000 {
+   compatible = "fsl,imx53-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+};
-- 
2.11.0


[PATCH v2 3/5] rtc: mxc_v2: add driver for i.MX53 SRTC

2017-12-05 Thread linux-kernel-dev
From: Patrick Bruenn 

Add RTC_DRV_MXC_V2 config option

Signed-off-by: Patrick Bruenn 

---

To: Alessandro Zummo 
To: Alexandre Belloni 

Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 drivers/rtc/Kconfig | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index b59a31b079a5..440edebf5c71 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1689,6 +1689,16 @@ config RTC_DRV_MXC
   This driver can also be built as a module, if so, the module
   will be called "rtc-mxc".
 
+config RTC_DRV_MXC_V2
+   tristate "Freescale MXC Real Time Clock for i.MX53"
+   depends on ARCH_MXC
+   help
+  If you say yes here you get support for the Freescale MXC
+  SRTC module in i.MX53 processor.
+
+  This driver can also be built as a module, if so, the module
+  will be called "rtc-mxc_v2".
+
 config RTC_DRV_SNVS
tristate "Freescale SNVS RTC support"
select REGMAP_MMIO
-- 
2.11.0


[PATCH v2 4/5] ARM: imx_v4_v5_defconfig: enable RTC_DRV_MXC_V2

2017-12-05 Thread linux-kernel-dev
From: Patrick Bruenn 

Enable SRTC driver for i.MX53 in default config

Signed-off-by: Patrick Bruenn 

---

To: Shawn Guo 
To: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 arch/arm/configs/imx_v4_v5_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v4_v5_defconfig 
b/arch/arm/configs/imx_v4_v5_defconfig
index ca0f13cafe38..b48efd5ff8a7 100644
--- a/arch/arm/configs/imx_v4_v5_defconfig
+++ b/arch/arm/configs/imx_v4_v5_defconfig
@@ -167,6 +167,7 @@ CONFIG_RTC_DRV_PCF8563=y
 CONFIG_RTC_DRV_IMXDI=y
 CONFIG_RTC_DRV_MC13XXX=y
 CONFIG_RTC_DRV_MXC=y
+CONFIG_RTC_DRV_MXC_V2=y
 CONFIG_DMADEVICES=y
 CONFIG_IMX_DMA=y
 CONFIG_IMX_SDMA=y
-- 
2.11.0


[PATCH v2 5/5] rtc: add mxc driver for i.MX53 SRTC

2017-12-05 Thread linux-kernel-dev
From: Patrick Bruenn 

Neither rtc-imxdi, rtc-mxc nor rtc-snvs are compatible with i.MX53.

This is driver enables support for the low power domain SRTC features:
- 32-bit MSB of non-rollover time counter
- 32-bit alarm register

Based on:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/rtc/rtc-mxc_v2.c?h=imx_2.6.35_11.09.01

Signed-off-by: Patrick Bruenn 

---

v2:
- have seperate patches for dt-binding, CONFIG option, imx53.dtsi and driver
- add SPDX-License-Identifier and cleanup copyright notice
- replace __raw_readl/writel() with readl/writel()
- fix PM_SLEEP callbacks
- add CONFIG_RTC_DRV_MXC_V2 to build rtc-mxc_v2.c
- remove misleading or obvious comments and fix style of the remaining
- avoid endless loop while waiting for hw
- implement consistent locking; make spinlock a member of dev struct
- enable clk only for register accesses
- remove all udelay() calls since they are obsolete or redundant
  (we are already waiting for register flags to change)
- init platform_data before registering irq callback
- let set_time() fail, when 32 bit rtc counter exceeded
- make names more consistent
- cleanup and reorder includes
- cleanup and remove unused defines

To: Alessandro Zummo 
To: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 drivers/rtc/Makefile |   1 +
 drivers/rtc/rtc-mxc_v2.c | 433 +++
 2 files changed, 434 insertions(+)
 create mode 100644 drivers/rtc/rtc-mxc_v2.c

diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index f2f50c11dc38..dcf60e61ae5c 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -106,6 +106,7 @@ obj-$(CONFIG_RTC_DRV_MT6397)+= rtc-mt6397.o
 obj-$(CONFIG_RTC_DRV_MT7622)   += rtc-mt7622.o
 obj-$(CONFIG_RTC_DRV_MV)   += rtc-mv.o
 obj-$(CONFIG_RTC_DRV_MXC)  += rtc-mxc.o
+obj-$(CONFIG_RTC_DRV_MXC_V2)   += rtc-mxc_v2.o
 obj-$(CONFIG_RTC_DRV_NUC900)   += rtc-nuc900.o
 obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
 obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o
diff --git a/drivers/rtc/rtc-mxc_v2.c b/drivers/rtc/rtc-mxc_v2.c
new file mode 100644
index ..c5a6d2c293bb
--- /dev/null
+++ b/drivers/rtc/rtc-mxc_v2.c
@@ -0,0 +1,433 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Real Time Clock (RTC) Driver for i.MX53
+ * Copyright (c) 2004-2011 Freescale Semiconductor, Inc.
+ * Copyright (c) 2017 Beckhoff Automation GmbH & Co. KG
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SRTC_LPPDR_INIT   0x41736166   /* init for glitch detect */
+
+#define SRTC_LPCR_EN_LP   BIT(3)   /* lp enable */
+#define SRTC_LPCR_WAE BIT(4)   /* lp wakeup alarm enable */
+#define SRTC_LPCR_ALP BIT(7)   /* lp alarm flag */
+#define SRTC_LPCR_NSA BIT(11)  /* lp non secure access */
+#define SRTC_LPCR_NVE BIT(14)  /* lp non valid state exit bit */
+#define SRTC_LPCR_IE  BIT(15)  /* lp init state exit bit */
+
+#define SRTC_LPSR_ALP BIT(3)   /* lp alarm flag */
+#define SRTC_LPSR_NVESBIT(14)  /* lp non-valid state exit status */
+#define SRTC_LPSR_IES BIT(15)  /* lp init state exit status */
+
+#define SRTC_LPSCMR0x00/* LP Secure Counter MSB Reg */
+#define SRTC_LPSCLR0x04/* LP Secure Counter LSB Reg */
+#define SRTC_LPSAR 0x08/* LP Secure Alarm Reg */
+#define SRTC_LPCR  0x10/* LP Control Reg */
+#define SRTC_LPSR  0x14/* LP Status Reg */
+#define SRTC_LPPDR 0x18/* LP Power Supply Glitch Detector Reg */
+
+/* max. number of retries to read registers, 120 was max during test */
+#define REG_READ_TIMEOUT 2000
+
+struct mxc_rtc_data {
+   struct rtc_device *rtc;
+   void __iomem *ioaddr;
+   struct clk *clk;
+   spinlock_t lock; /* protects register access */
+   int irq;
+};
+
+/*
+ * This function does write synchronization for writes to the lp srtc block.
+ * To take care of the asynchronous CKIL clock, all writes from the IP domain
+ * will be synchronized to the CKIL domain.
+ * The caller should hold the pdata->lock
+ */
+static inline void mxc_rtc_sync_lp_locked(void __iomem *ioaddr)
+{
+   unsigned int i;
+
+   /* Wait for 3 CKIL cycles */
+   for (i = 0; i < 3; i++) {
+   const u32 count = readl(ioaddr + SRTC_LPSCLR);
+   unsigned int timeout = REG_READ_TIMEOUT;
+
+   while

[PATCH v4 0/4] rtc: add mxc driver for i.MX53 SRTC

2017-12-18 Thread linux-kernel-dev
From: Patrick Bruenn 

Neither rtc-imxdi, rtc-mxc nor rtc-snvs are compatible with i.MX53.

This is driver enables support for the low power domain SRTC features:
- 32-bit MSB of non-rollover time counter
- 32-bit alarm register

Select the new config option RTC_DRV_MXC_V2 to build this driver

Based on:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/rtc/rtc-mxc_v2.c?h=imx_2.6.35_11.09.01

Signed-off-by: Patrick Bruenn 

---

v4:
- rename "srtc" node into generic "rtc" keep the label as "srtc" to avoid
  duplication with imx53-m53.dtsi
- fix Signed-off-by: in bindings-patch

v3:
- introduce new config option with the same patch, which adds the driver
- call rtc_update_irq() only if necessary
- merge mxc_rtc_write_alarm_locked() with mxc_rtc_set_alarm()
- only use clk_enable/disable (without "prepare") during operation
- rebase on v4.15-rc3
- consistently use rtc_tm_to_time64() and time64_t
- refactor mxc_rtc_read_time(): don't lock for readl() only;
  don't rtc_valid_tm(); use time64_t
- check returncode of mxc_rtc_wait_for_flag()
- restructure mxc_rtc_sync_lp_locked() to replace pr_err() with
  dev_err_once(); remove explicit 'inline'
- don't touch imx_v4_v5_defconfig, instead add to imx_v6_v7_defconfig

v2:
- have seperate patches for dt-binding, CONFIG option, imx53.dtsi and driver
- add SPDX-License-Identifier and cleanup copyright notice
- replace __raw_readl/writel() with readl/writel()
- fix PM_SLEEP callbacks
- add CONFIG_RTC_DRV_MXC_V2 to build rtc-mxc_v2.c
- remove misleading or obvious comments and fix style of the remaining
- avoid endless loop while waiting for hw
- implement consistent locking; make spinlock a member of dev struct
- enable clk only for register accesses
- remove all udelay() calls since they are obsolete or redundant
  (we are already waiting for register flags to change)
- init platform_data before registering irq callback
- let set_time() fail, when 32 bit rtc counter exceeded
- make names more consistent
- cleanup and reorder includes
- cleanup and remove unused defines

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---

Patrick Bruenn (4):
  dt-bindings: rtc: add bindings for i.MX53 SRTC
  ARM: dts: imx53: add srtc node
  rtc: add mxc driver for i.MX53 SRTC
  ARM: imx_v6_v7_defconfig: enable RTC_DRV_MXC_V2

 .../devicetree/bindings/rtc/rtc-mxc_v2.txt |  17 +
 arch/arm/boot/dts/imx53.dtsi   |   7 +
 arch/arm/configs/imx_v6_v7_defconfig   |   1 +
 drivers/rtc/Kconfig|  10 +
 drivers/rtc/Makefile   |   1 +
 drivers/rtc/rtc-mxc_v2.c   | 422 +
 6 files changed, 458 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
 create mode 100644 drivers/rtc/rtc-mxc_v2.c

-- 
2.11.0


[PATCH v4 3/4] rtc: add mxc driver for i.MX53 SRTC

2017-12-18 Thread linux-kernel-dev
From: Patrick Bruenn 

Neither rtc-imxdi, rtc-mxc nor rtc-snvs are compatible with i.MX53.

This is driver enables support for the low power domain SRTC features:
- 32-bit MSB of non-rollover time counter
- 32-bit alarm register

Select the new config option RTC_DRV_MXC_V2 to build this driver

Based on:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/rtc/rtc-mxc_v2.c?h=imx_2.6.35_11.09.01

Signed-off-by: Patrick Bruenn 

---

v3:
- introduce new config option with the same patch, which adds the driver
- call rtc_update_irq() only if necessary
- merge mxc_rtc_write_alarm_locked() with mxc_rtc_set_alarm()
- only use clk_enable/disable (without "prepare") during operation
- rebase on v4.15-rc3
- consistently use rtc_tm_to_time64() and time64_t
- refactor mxc_rtc_read_time(): don't lock for readl() only;
  don't rtc_valid_tm(); use time64_t
- check returncode of mxc_rtc_wait_for_flag()
- restructure mxc_rtc_sync_lp_locked() to replace pr_err() with
  dev_err_once(); remove explicit 'inline'
- don't touch imx_v4_v5_defconfig, instead add to imx_v6_v7_defconfig

v2:
- have seperate patches for dt-binding, CONFIG option, imx53.dtsi and driver
- add SPDX-License-Identifier and cleanup copyright notice
- replace __raw_readl/writel() with readl/writel()
- fix PM_SLEEP callbacks
- add CONFIG_RTC_DRV_MXC_V2 to build rtc-mxc_v2.c
- remove misleading or obvious comments and fix style of the remaining
- avoid endless loop while waiting for hw
- implement consistent locking; make spinlock a member of dev struct
- enable clk only for register accesses
- remove all udelay() calls since they are obsolete or redundant
  (we are already waiting for register flags to change)
- init platform_data before registering irq callback
- let set_time() fail, when 32 bit rtc counter exceeded
- make names more consistent
- cleanup and reorder includes
- cleanup and remove unused defines

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 drivers/rtc/Kconfig  |  10 ++
 drivers/rtc/Makefile |   1 +
 drivers/rtc/rtc-mxc_v2.c | 422 +++
 3 files changed, 433 insertions(+)
 create mode 100644 drivers/rtc/rtc-mxc_v2.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index b59a31b079a5..440edebf5c71 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1689,6 +1689,16 @@ config RTC_DRV_MXC
   This driver can also be built as a module, if so, the module
   will be called "rtc-mxc".
 
+config RTC_DRV_MXC_V2
+   tristate "Freescale MXC Real Time Clock for i.MX53"
+   depends on ARCH_MXC
+   help
+  If you say yes here you get support for the Freescale MXC
+  SRTC module in i.MX53 processor.
+
+  This driver can also be built as a module, if so, the module
+  will be called "rtc-mxc_v2".
+
 config RTC_DRV_SNVS
tristate "Freescale SNVS RTC support"
select REGMAP_MMIO
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index f2f50c11dc38..dcf60e61ae5c 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -106,6 +106,7 @@ obj-$(CONFIG_RTC_DRV_MT6397)+= rtc-mt6397.o
 obj-$(CONFIG_RTC_DRV_MT7622)   += rtc-mt7622.o
 obj-$(CONFIG_RTC_DRV_MV)   += rtc-mv.o
 obj-$(CONFIG_RTC_DRV_MXC)  += rtc-mxc.o
+obj-$(CONFIG_RTC_DRV_MXC_V2)   += rtc-mxc_v2.o
 obj-$(CONFIG_RTC_DRV_NUC900)   += rtc-nuc900.o
 obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
 obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o
diff --git a/drivers/rtc/rtc-mxc_v2.c b/drivers/rtc/rtc-mxc_v2.c
new file mode 100644
index ..b637095b0716
--- /dev/null
+++ b/drivers/rtc/rtc-mxc_v2.c
@@ -0,0 +1,422 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Real Time Clock (RTC) Driver for i.MX53
+ * Copyright (c) 2004-2011 Freescale Semiconductor, Inc.
+ * Copyright (c) 2017 Beckhoff Automation GmbH & Co. KG
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SRTC_LPPDR_INIT   0x41736166   /* init for glitch detect */
+
+#define SRTC_LPCR_EN_LP   BIT(3)   /* lp enable */
+#define SRTC_LPCR_WAE BIT(4)   /* lp wakeup alarm enable */
+#define SRTC_LPCR_ALP BIT(7)   /* lp alarm flag */
+#define SRTC_LPCR_NSA BIT(11)  /* lp non secure access */
+#define SRTC_LPCR_NVE BIT(14)  /* lp non valid state exit bit */
+#define SRTC_L

[PATCH v4 2/4] ARM: dts: imx53: add srtc node

2017-12-18 Thread linux-kernel-dev
From: Patrick Bruenn 

rtc-mxc_v2 driver will add support for the i.MX53 SRTC

Note: we keep the 'srtc' label to avoid duplicate with imx53-m53.dtsi

Signed-off-by: Patrick Bruenn 

---

v4:
- replace "srtc" node name with generic "rtc"

Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 arch/arm/boot/dts/imx53.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 84f17f7abb71..beca1c830623 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -433,6 +433,13 @@
clock-names = "ipg", "per";
};
 
+   srtc: rtc@53fa4000 {
+   compatible = "fsl,imx53-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+   };
+
iomuxc: iomuxc@53fa8000 {
compatible = "fsl,imx53-iomuxc";
reg = <0x53fa8000 0x4000>;
-- 
2.11.0


[PATCH v4 1/4] dt-bindings: rtc: add bindings for i.MX53 SRTC

2017-12-18 Thread linux-kernel-dev
From: Patrick Bruenn 

Document the binding for i.MX53 SRTC implemented by rtc-mxc_v2

Signed-off-by: Patrick Bruenn 

---

v4:
- replace "srtc" node name with generic "rtc"

v2:
- added "Secure" and (SRTC) to the description

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 

Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt

diff --git a/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt 
b/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
new file mode 100644
index ..79d7e87b0d91
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
@@ -0,0 +1,17 @@
+* i.MX53 Secure Real Time Clock (SRTC)
+
+Required properties:
+- compatible: should be: "fsl,imx53-rtc"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- clocks: should contain the phandle for the rtc clock
+- interrupts: rtc alarm interrupt
+
+Example:
+
+rtc@53fa4000 {
+   compatible = "fsl,imx53-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+};
-- 
2.11.0


[PATCH v4 4/4] ARM: imx_v6_v7_defconfig: enable RTC_DRV_MXC_V2

2017-12-18 Thread linux-kernel-dev
From: Patrick Bruenn 

Enable SRTC driver for i.MX53 in default config

Signed-off-by: Patrick Bruenn 

---
v3:
- imx_v4_v5_defconfig was the wrong default config for i.MX53

Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 0d4494922561..548c11142a4e 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -349,6 +349,7 @@ CONFIG_RTC_DRV_PCF8563=y
 CONFIG_RTC_DRV_M41T80=y
 CONFIG_RTC_DRV_MC13XXX=y
 CONFIG_RTC_DRV_MXC=y
+CONFIG_RTC_DRV_MXC_V2=y
 CONFIG_RTC_DRV_SNVS=y
 CONFIG_DMADEVICES=y
 CONFIG_FSL_EDMA=y
-- 
2.11.0


[PATCH v5 0/4] ARM: dts: imx: add CX9020 Embedded PC device tree

2017-07-26 Thread linux-kernel-dev
From: Patrick Bruenn 

The CX9020 differs from i.MX53 Quick Start Board by:
- use uart2 instead of uart1
- DVI-D connector instead of VGA
- no audio
- no SATA connector
- CCAT FPGA connected to emi
- enable rtc

v5:
- rebased on v4.13-rc2
- don't take maintainership for imx53-cx9020.dtsi, keep it to
  ARM/FREESCALE IMX maintainers
- add explicit pinmux settings for pwr leds (EIM_D22 - D24)
- remove display0->status="okay"
- use "regulator-vbus" as name for usb_vbus regulator node
- use correct reset values for explicit pinmux settings of:
  MX53_PAD_GPIO_0__CCM_CLKO
  MX53_PAD_GPIO_16__I2C3_SDA
  MX53_PAD_GPIO_1__ESDHC1_CD
  MX53_PAD_GPIO_3__GPIO1_3
  MX53_PAD_GPIO_8__GPIO1_8

v4:
- move alternative UART2 pinmux settings to imx53-pinfunc.h
- fix copyright notice and model name to clearify cx9020 is a
  Beckhoff board and not from Freescale/NXP/Qualcomm
- add "bhf,cx9020" compatible
- remove ccat node and pin configuration as long as the ccat
  driver is not mainlined
- use dvi-connector + ti,tfp410 instead of panel-simple
- add newlines between property list and child nodes
- replace underscores in node names with hypens
- replace magic number 0 with polarity defines from
  include/dt-bindings/gpio/gpio.h
- move rtc node into imx53.dtsi, change it's name into 'srtc',
  to avoid a conflict with 'rtc' node in imx53-m53.dtsi
- rename regulator-3p2v
- drop imx53-qsb container node
- make iomux configuration explicit
- remove unused audmux
- remove unused led_pin_gpio3_23 configuration
- use blue gpio-leds as disk-activity indicators for mmc0 and mmc1
- add mmc indicator leds to sdhc pingroups
- keep node names in alphabetical order
- remove unused sata and ssi2
- remove unused pin configs from hoggrp
- add entry for Beckhoff related files to MAINTAINERS

v3: add missig changelog
v2:
- keep alphabetic order of dts/Makefile
- configure uart2 with 'fsl,dte-mode'
- use display-0 and panel-0 as node names
- remove unnecessary "simple-bus" for fixed regulators

Patrick Bruenn (4):
  dt-bindings: arm: Add entry for Beckhoff CX9020
  ARM: dts: imx53: add srtc node
  ARM: dts: imx53: add alternative UART2 configuration
  ARM: dts: imx: add CX9020 Embedded PC device tree

 Documentation/devicetree/bindings/arm/bhf.txt  |   6 +
 .../devicetree/bindings/vendor-prefixes.txt|   1 +
 MAINTAINERS|   5 +
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/imx53-cx9020.dts | 297 +
 arch/arm/boot/dts/imx53-pinfunc.h  |   4 +
 arch/arm/boot/dts/imx53.dtsi   |   9 +
 7 files changed, 323 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/bhf.txt
 create mode 100644 arch/arm/boot/dts/imx53-cx9020.dts

-- 
2.11.0


[PATCH v5 4/4] ARM: dts: imx: add CX9020 Embedded PC device tree

2017-07-26 Thread linux-kernel-dev
From: Patrick Bruenn 

The CX9020 differs from i.MX53 Quick Start Board by:
- use uart2 instead of uart1
- DVI-D connector instead of VGA
- no audio
- no SATA connector
- CCAT FPGA connected to emi
- enable rtc

Signed-off-by: Patrick Bruenn 
---
 arch/arm/boot/dts/Makefile |   1 +
 arch/arm/boot/dts/imx53-cx9020.dts | 297 +
 2 files changed, 298 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-cx9020.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 4b17f35dc9a7..f0ba9be523e0 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -340,6 +340,7 @@ dtb-$(CONFIG_SOC_IMX51) += \
imx51-ts4800.dtb
 dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
+   imx53-cx9020.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
imx53-qsb.dtb \
diff --git a/arch/arm/boot/dts/imx53-cx9020.dts 
b/arch/arm/boot/dts/imx53-cx9020.dts
new file mode 100644
index ..4f54fd4418a3
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-cx9020.dts
@@ -0,0 +1,297 @@
+/*
+ * Copyright 2017 Beckhoff Automation GmbH & Co. KG
+ * based on imx53-qsb.dts
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx53.dtsi"
+
+/ {
+   model = "Beckhoff CX9020 Embedded PC";
+   compatible = "bhf,cx9020", "fsl,imx53";
+
+   chosen {
+   stdout-path = &uart2;
+   };
+
+   memory {
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   display-0 {
+   #address-cells =<1>;
+   #size-cells = <0>;
+   compatible = "fsl,imx-parallel-display";
+   interface-pix-fmt = "rgb24";
+   pinctrl-names = "default";
+   pinctrl-0 = <&pinctrl_ipu_disp0>;
+
+   port@0 {
+   reg = <0>;
+
+   display0_in: endpoint {
+   remote-endpoint = <&ipu_di0_disp0>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   display0_out: endpoint {
+   remote-endpoint = <&tfp410_in>;
+   };
+   };
+   };
+
+   dvi-connector {
+   compatible = "dvi-connector";
+   ddc-i2c-bus = <&i2c2>;
+   digital;
+
+   port {
+   dvi_connector_in: endpoint {
+   remote-endpoint = <&tfp410_out>;
+   };
+   };
+   };
+
+   dvi-converter {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "ti,tfp410";
+
+   port@0 {
+   reg = <0>;
+
+   tfp410_in: endpoint {
+   remote-endpoint = <&display0_out>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   tfp410_out: endpoint {
+   remote-endpoint = <&dvi_connector_in>;
+   };
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+
+   pwr-r {
+   gpios = <&gpio3 22 GPIO_ACTIVE_HIGH>;
+   default-state = "off";
+   };
+
+   pwr-g {
+   gpios = <&gpio3 24 GPIO_ACTIVE_HIGH>;
+   default-state = "on";
+   };
+
+   pwr-b {
+   gpios = <&gpio3 23 GPIO_ACTIVE_HIGH>;
+   default-state = "off";
+   };
+
+   sd1-b {
+   linux,default-trigger = "mmc0";
+   gpios = <&gpio3 20 GPIO_ACTIVE_HIGH>;
+   };
+
+   sd2-b {
+   linux,default-trigger = "mmc1";
+   gpios = <&gpio3 17 GPIO_ACTIVE_HIGH>;
+   };
+   };
+
+   regulator-3p2v {
+   compatible = "regulator-fixed";
+   regulator-name = "3P2V";
+   regulator-min-microvolt = <320>;
+   regulator-max-microvolt = <320>;
+   regulator-always-on;
+   };
+
+   reg_usb_vbus: regulator-vbus {
+   compatible = "regulator-fixed";
+   regulator-name = "usb_vbus";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   gpio = <&gpio7 8 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+   };
+};
+
+&esdhc1 {
+   pinctrl-names = "defau

[PATCH v5 1/4] dt-bindings: arm: Add entry for Beckhoff CX9020

2017-07-26 Thread linux-kernel-dev
From: Patrick Bruenn 

- add vendor prefix bhf for Beckhoff
- add new board binding bhf,cx9020

Signed-off-by: Patrick Bruenn 
---
 Documentation/devicetree/bindings/arm/bhf.txt | 6 ++
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 MAINTAINERS   | 5 +
 3 files changed, 12 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/bhf.txt

diff --git a/Documentation/devicetree/bindings/arm/bhf.txt 
b/Documentation/devicetree/bindings/arm/bhf.txt
new file mode 100644
index ..886b503caf9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/bhf.txt
@@ -0,0 +1,6 @@
+Beckhoff Automation Platforms Device Tree Bindings
+--
+
+CX9020 Embedded PC
+Required root node properties:
+- compatible = "bhf,cx9020", "fsl,imx53";
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index daf465bef758..20c2cf57ebc9 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -47,6 +47,7 @@ avic  Shanghai AVIC Optoelectronics Co., Ltd.
 axentiaAxentia Technologies AB
 axis   Axis Communications AB
 bananapi BIPAI KEJI LIMITED
+bhfBeckhoff Automation GmbH & Co. KG
 boeBOE Technology Group Co., Ltd.
 bosch  Bosch Sensortec GmbH
 boundary   Boundary Devices Inc.
diff --git a/MAINTAINERS b/MAINTAINERS
index f66488dfdbc9..e1d3111aea97 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1196,6 +1196,11 @@ F:   arch/arm/boot/dts/sama*.dtsi
 F: arch/arm/include/debug/at91.S
 F: drivers/memory/atmel*
 
+ARM/BECKHOFF SUPPORT
+M: Patrick Bruenn 
+S: Maintained
+F: Documentation/devicetree/bindings/arm/bhf.txt
+
 ARM/CALXEDA HIGHBANK ARCHITECTURE
 M: Rob Herring 
 L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers)
-- 
2.11.0




[PATCH v5 2/4] ARM: dts: imx53: add srtc node

2017-07-26 Thread linux-kernel-dev
From: Patrick Bruenn 

The i.MX53 has an integrated secure real time clock. Add it to the dtsi.

Signed-off-by: Patrick Bruenn 
---
 arch/arm/boot/dts/imx53.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 2e516f4985e4..8bf0d89cdd35 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -433,6 +433,15 @@
clock-names = "ipg", "per";
};
 
+   srtc: srtc@53fa4000 {
+   compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   interrupt-parent = <&tzic>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+   clock-names = "ipg";
+   };
+
iomuxc: iomuxc@53fa8000 {
compatible = "fsl,imx53-iomuxc";
reg = <0x53fa8000 0x4000>;
-- 
2.11.0




[PATCH v5 3/4] ARM: dts: imx53: add alternative UART2 configuration

2017-07-26 Thread linux-kernel-dev
From: Patrick Bruenn 

UART2 on EIM_D26 - EIM_D29 pins supports interchanging RXD/TXD pins
and RTS/CTS pins.
One board using these alternate settings is Beckhoff CX9020. Add the
alternative configuration here, to make it available to others, too.

Signed-off-by: Patrick Bruenn 
---
 arch/arm/boot/dts/imx53-pinfunc.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/imx53-pinfunc.h 
b/arch/arm/boot/dts/imx53-pinfunc.h
index aec406bc65eb..59f9c29e3fe2 100644
--- a/arch/arm/boot/dts/imx53-pinfunc.h
+++ b/arch/arm/boot/dts/imx53-pinfunc.h
@@ -524,6 +524,7 @@
 #define MX53_PAD_EIM_D25__UART1_DSR0x140 0x488 
0x000 0x7 0x0
 #define MX53_PAD_EIM_D26__EMI_WEIM_D_260x144 
0x48c 0x000 0x0 0x0
 #define MX53_PAD_EIM_D26__GPIO3_26 0x144 0x48c 
0x000 0x1 0x0
+#define MX53_PAD_EIM_D26__UART2_RXD_MUX0x144 
0x48c 0x880 0x2 0x0
 #define MX53_PAD_EIM_D26__UART2_TXD_MUX0x144 
0x48c 0x000 0x2 0x0
 #define MX53_PAD_EIM_D26__FIRI_RXD 0x144 0x48c 
0x80c 0x3 0x0
 #define MX53_PAD_EIM_D26__IPU_CSI0_D_1 0x144 0x48c 
0x000 0x4 0x0
@@ -533,6 +534,7 @@
 #define MX53_PAD_EIM_D27__EMI_WEIM_D_270x148 
0x490 0x000 0x0 0x0
 #define MX53_PAD_EIM_D27__GPIO3_27 0x148 0x490 
0x000 0x1 0x0
 #define MX53_PAD_EIM_D27__UART2_RXD_MUX0x148 
0x490 0x880 0x2 0x1
+#define MX53_PAD_EIM_D27__UART2_TXD_MUX0x148 
0x490 0x000 0x2 0x0
 #define MX53_PAD_EIM_D27__FIRI_TXD 0x148 0x490 
0x000 0x3 0x0
 #define MX53_PAD_EIM_D27__IPU_CSI0_D_0 0x148 0x490 
0x000 0x4 0x0
 #define MX53_PAD_EIM_D27__IPU_DI1_PIN130x148 
0x490 0x000 0x5 0x0
@@ -541,6 +543,7 @@
 #define MX53_PAD_EIM_D28__EMI_WEIM_D_280x14c 
0x494 0x000 0x0 0x0
 #define MX53_PAD_EIM_D28__GPIO3_28 0x14c 0x494 
0x000 0x1 0x0
 #define MX53_PAD_EIM_D28__UART2_CTS0x14c 0x494 
0x000 0x2 0x0
+#define MX53_PAD_EIM_D28__UART2_RTS0x14c 0x494 
0x87c 0x2 0x0
 #define MX53_PAD_EIM_D28__IPU_DISPB0_SER_DIO   0x14c 0x494 
0x82c 0x3 0x1
 #define MX53_PAD_EIM_D28__CSPI_MOSI0x14c 0x494 
0x788 0x4 0x1
 #define MX53_PAD_EIM_D28__I2C1_SDA 0x14c 0x494 
0x818 0x5 0x1
@@ -548,6 +551,7 @@
 #define MX53_PAD_EIM_D28__IPU_DI0_PIN130x14c 
0x494 0x000 0x7 0x0
 #define MX53_PAD_EIM_D29__EMI_WEIM_D_290x150 
0x498 0x000 0x0 0x0
 #define MX53_PAD_EIM_D29__GPIO3_29 0x150 0x498 
0x000 0x1 0x0
+#define MX53_PAD_EIM_D29__UART2_CTS0x150 0x498 
0x000 0x2 0x0
 #define MX53_PAD_EIM_D29__UART2_RTS0x150 0x498 
0x87c 0x2 0x1
 #define MX53_PAD_EIM_D29__IPU_DISPB0_SER_RS0x150 0x498 
0x000 0x3 0x0
 #define MX53_PAD_EIM_D29__CSPI_SS0 0x150 0x498 
0x78c 0x4 0x2
-- 
2.11.0




[PATCH] rtc: add mxc driver for i.MX53

2017-11-27 Thread linux-kernel-dev
From: Patrick Bruenn 

Neither rtc-imxdi nor rtc-mxc are compatible with i.MX53.
Add a modernized version of mxc_v2 from here:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/rtc/rtc-mxc_v2.c?h=imx_2.6.35_11.09.01

Changes to that version:
- updated to v4.15-rc1
- removed ioctl()
- removed proc()
- removed manual(redundant) enable_irq flag

Signed-off-by: Patrick Bruenn 

---

Open issues:
- driver naming, should it be merged with rtc-mxc.c ?
- document DT binding "fsl,imx53-rtc" accordingly
- Should unused defines be removed or kept for someone else to be
  useful?
- Is the use of __raw_readl/writel() correct? Should it be replaced with
  readl/writel()?
- suspend/resume() seems different to existing rtc-mxc.c, should I apply
  the pattern from rtc-mxc.c?
- On Shawns tree imx53.dtsi has been reverted already[1][2]. Should I split
  the imx53.dtsi change into a separate patch based on his tree? Or can
  we still stop the full revert and just remove the imx25-rtc compatible?
  I am not in a hurry, so we could just wait until the revert landed in
  Linus tree. Whatever you think is best.

[1] https://www.spinics.net/lists/arm-kernel/msg617113.html
[2] commit ee76f7729babd2700afd6f3874449d8084dd85ea

To: Alessandro Zummo 
To: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)
---
 arch/arm/boot/dts/imx53.dtsi |   2 +-
 drivers/rtc/Makefile |   1 +
 drivers/rtc/rtc-mxc_v2.c | 531 +++
 3 files changed, 533 insertions(+), 1 deletion(-)
 create mode 100644 drivers/rtc/rtc-mxc_v2.c

diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 589a67c5f796..3d1a55e11ea8 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -434,7 +434,7 @@
};
 
srtc: srtc@53fa4000 {
-   compatible = "fsl,imx53-rtc", "fsl,imx25-rtc";
+   compatible = "fsl,imx53-rtc";
reg = <0x53fa4000 0x4000>;
interrupts = <24>;
interrupt-parent = <&tzic>;
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index f2f50c11dc38..fb3dc458c185 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -106,6 +106,7 @@ obj-$(CONFIG_RTC_DRV_MT6397)+= rtc-mt6397.o
 obj-$(CONFIG_RTC_DRV_MT7622)   += rtc-mt7622.o
 obj-$(CONFIG_RTC_DRV_MV)   += rtc-mv.o
 obj-$(CONFIG_RTC_DRV_MXC)  += rtc-mxc.o
+obj-$(CONFIG_RTC_DRV_MXC)  += rtc-mxc_v2.o
 obj-$(CONFIG_RTC_DRV_NUC900)   += rtc-nuc900.o
 obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
 obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o
diff --git a/drivers/rtc/rtc-mxc_v2.c b/drivers/rtc/rtc-mxc_v2.c
new file mode 100644
index ..5049b521b38e
--- /dev/null
+++ b/drivers/rtc/rtc-mxc_v2.c
@@ -0,0 +1,531 @@
+/*
+ * Copyright (C) 2004-2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+/*
+ * Implementation based on rtc-ds1553.c
+ */
+
+/*!
+ * @defgroup RTC Real Time Clock (RTC) Driver for i.MX53
+ */
+/*!
+ * @file rtc-mxc_v2.c
+ * @brief Real Time Clock interface
+ *
+ * This file contains Real Time Clock interface for Linux.
+ *
+ * @ingroup RTC
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+//#include 
+#define RTC_READ_TIME_47BIT_IOR('p', 0x20, unsigned long long)
+/* blocks until LPSCMR is set, returns difference */
+#define RTC_WAIT_TIME_SET  _IOR('p', 0x21, int64_t)
+
+#define SRTC_LPSCLR_LLPSC_LSH  17  /* start bit for LSB time value */
+
+#define SRTC_LPPDR_INIT   0x41736166   /* init for glitch detect */
+
+#define SRTC_LPCR_SWR_LP  (1 << 0) /* lp software reset */
+#define SRTC_LPCR_EN_LP   (1 << 3) /* lp enable */
+#define SRTC_LPCR_WAE (1 << 4) /* lp wakeup alarm enable */
+#define SRTC_LPCR_SAE (1 << 5) /* lp security alarm enable */
+#define SRTC_LPCR_SI  (1 << 6) /* lp security interrupt enable */
+#define SRTC_LPCR_ALP (1 << 7) /* lp alarm 

[PATCH v3 1/4] dt-bindings: rtc: add bindings for i.MX53 SRTC

2017-12-11 Thread linux-kernel-dev
From: Patrick Bruenn 

Document the binding for i.MX53 SRTC implemented by rtc-mxc_v2

Signed-off-by: Patrick Bruenn 

---

v2:
- added "Secure" and (SRTC) to the description

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 

Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt

diff --git a/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt 
b/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
new file mode 100644
index ..454a08918cc3
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
@@ -0,0 +1,17 @@
+* i.MX53 Secure Real Time Clock (SRTC)
+
+Required properties:
+- compatible: should be: "fsl,imx53-rtc"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- clocks: should contain the phandle for the rtc clock
+- interrupts: rtc alarm interrupt
+
+Example:
+
+srtc@53fa4000 {
+   compatible = "fsl,imx53-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+};
-- 
2.11.0


[PATCH v3 0/4] rtc: add mxc driver for i.MX53 SRTC

2017-12-11 Thread linux-kernel-dev
From: Patrick Bruenn 

Neither rtc-imxdi, rtc-mxc nor rtc-snvs are compatible with i.MX53.

This is driver enables support for the low power domain SRTC features:
- 32-bit MSB of non-rollover time counter
- 32-bit alarm register

Select the new config option RTC_DRV_MXC_V2 to build this driver

Based on:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/rtc/rtc-mxc_v2.c?h=imx_2.6.35_11.09.01

Signed-off-by: Patrick Bruenn 

---

Open issue:
- naming of the device tree node "rtc" vs. "srtc"

v3:
- introduce new config option with the same patch, which adds the driver
- call rtc_update_irq() only if necessary
- merge mxc_rtc_write_alarm_locked() with mxc_rtc_set_alarm()
- only use clk_enable/disable (without "prepare") during operation
- rebase on v4.15-rc3
- consistently use rtc_tm_to_time64() and time64_t
- refactor mxc_rtc_read_time(): don't lock for readl() only;
  don't rtc_valid_tm(); use time64_t
- check returncode of mxc_rtc_wait_for_flag()
- restructure mxc_rtc_sync_lp_locked() to replace pr_err() with
  dev_err_once(); remove explicit 'inline'
- don't touch imx_v4_v5_defconfig, instead add to imx_v6_v7_defconfig

v2:
- have seperate patches for dt-binding, CONFIG option, imx53.dtsi and driver
- add SPDX-License-Identifier and cleanup copyright notice
- replace __raw_readl/writel() with readl/writel()
- fix PM_SLEEP callbacks
- add CONFIG_RTC_DRV_MXC_V2 to build rtc-mxc_v2.c
- remove misleading or obvious comments and fix style of the remaining
- avoid endless loop while waiting for hw
- implement consistent locking; make spinlock a member of dev struct
- enable clk only for register accesses
- remove all udelay() calls since they are obsolete or redundant
  (we are already waiting for register flags to change)
- init platform_data before registering irq callback
- let set_time() fail, when 32 bit rtc counter exceeded
- make names more consistent
- cleanup and reorder includes
- cleanup and remove unused defines

To: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 

Patrick Bruenn (4):
  dt-bindings: rtc: add bindings for i.MX53 SRTC
  ARM: dts: imx53: add srtc node
  rtc: add mxc driver for i.MX53 SRTC
  ARM: imx_v6_v7_defconfig: enable RTC_DRV_MXC_V2

 .../devicetree/bindings/rtc/rtc-mxc_v2.txt |  17 +
 arch/arm/boot/dts/imx53.dtsi   |   7 +
 arch/arm/configs/imx_v6_v7_defconfig   |   1 +
 drivers/rtc/Kconfig|  10 +
 drivers/rtc/Makefile   |   1 +
 drivers/rtc/rtc-mxc_v2.c   | 422 +
 6 files changed, 458 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc_v2.txt
 create mode 100644 drivers/rtc/rtc-mxc_v2.c

-- 
2.11.0


[PATCH v3 2/4] ARM: dts: imx53: add srtc node

2017-12-11 Thread linux-kernel-dev
From: Patrick Bruenn 

rtc-mxc_v2 driver will add support for the i.MX53 SRTC

Signed-off-by: Patrick Bruenn 

---

Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 arch/arm/boot/dts/imx53.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 84f17f7abb71..e4ca9d9ba2fe 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -433,6 +433,13 @@
clock-names = "ipg", "per";
};
 
+   srtc: srtc@53fa4000 {
+   compatible = "fsl,imx53-rtc";
+   reg = <0x53fa4000 0x4000>;
+   interrupts = <24>;
+   clocks = <&clks IMX5_CLK_SRTC_GATE>;
+   };
+
iomuxc: iomuxc@53fa8000 {
compatible = "fsl,imx53-iomuxc";
reg = <0x53fa8000 0x4000>;
-- 
2.11.0


[PATCH v3 4/4] ARM: imx_v6_v7_defconfig: enable RTC_DRV_MXC_V2

2017-12-11 Thread linux-kernel-dev
From: Patrick Bruenn 

Enable SRTC driver for i.MX53 in default config

Signed-off-by: Patrick Bruenn 

---
v3:
- imx_v4_v5_defconfig was the wrong default config for i.MX53

Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig 
b/arch/arm/configs/imx_v6_v7_defconfig
index 0d4494922561..548c11142a4e 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -349,6 +349,7 @@ CONFIG_RTC_DRV_PCF8563=y
 CONFIG_RTC_DRV_M41T80=y
 CONFIG_RTC_DRV_MC13XXX=y
 CONFIG_RTC_DRV_MXC=y
+CONFIG_RTC_DRV_MXC_V2=y
 CONFIG_RTC_DRV_SNVS=y
 CONFIG_DMADEVICES=y
 CONFIG_FSL_EDMA=y
-- 
2.11.0


[PATCH v3 3/4] rtc: add mxc driver for i.MX53 SRTC

2017-12-11 Thread linux-kernel-dev
From: Patrick Bruenn 

Neither rtc-imxdi, rtc-mxc nor rtc-snvs are compatible with i.MX53.

This is driver enables support for the low power domain SRTC features:
- 32-bit MSB of non-rollover time counter
- 32-bit alarm register

Select the new config option RTC_DRV_MXC_V2 to build this driver

Based on:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/drivers/rtc/rtc-mxc_v2.c?h=imx_2.6.35_11.09.01

Signed-off-by: Patrick Bruenn 

---

Open issue:
- naming of the device tree node "rtc" vs. "srtc"

v3:
- introduce new config option with the same patch, which adds the driver
- call rtc_update_irq() only if necessary
- merge mxc_rtc_write_alarm_locked() with mxc_rtc_set_alarm()
- only use clk_enable/disable (without "prepare") during operation
- rebase on v4.15-rc3
- consistently use rtc_tm_to_time64() and time64_t
- refactor mxc_rtc_read_time(): don't lock for readl() only;
  don't rtc_valid_tm(); use time64_t
- check returncode of mxc_rtc_wait_for_flag()
- restructure mxc_rtc_sync_lp_locked() to replace pr_err() with
  dev_err_once(); remove explicit 'inline'
- don't touch imx_v4_v5_defconfig, instead add to imx_v6_v7_defconfig

v2:
- have seperate patches for dt-binding, CONFIG option, imx53.dtsi and driver
- add SPDX-License-Identifier and cleanup copyright notice
- replace __raw_readl/writel() with readl/writel()
- fix PM_SLEEP callbacks
- add CONFIG_RTC_DRV_MXC_V2 to build rtc-mxc_v2.c
- remove misleading or obvious comments and fix style of the remaining
- avoid endless loop while waiting for hw
- implement consistent locking; make spinlock a member of dev struct
- enable clk only for register accesses
- remove all udelay() calls since they are obsolete or redundant
  (we are already waiting for register flags to change)
- init platform_data before registering irq callback
- let set_time() fail, when 32 bit rtc counter exceeded
- make names more consistent
- cleanup and reorder includes
- cleanup and remove unused defines

Cc: Alessandro Zummo 
Cc: Alexandre Belloni 
Cc: Rob Herring 
Cc: Mark Rutland  (maintainer:OPEN FIRMWARE AND FLATTENED 
DEVICE TREE BINDINGS)
Cc: linux-...@vger.kernel.org (open list:REAL TIME CLOCK (RTC) SUBSYSTEM)
Cc: devicet...@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE 
TREE BINDINGS)
Cc: linux-kernel@vger.kernel.org (open list)
Cc: Fabio Estevam 
Cc: Juergen Borleis 
Cc: Noel Vellemans 
Cc: Shawn Guo 
Cc: Sascha Hauer  (maintainer:ARM/FREESCALE IMX / MXC 
ARM ARCHITECTURE)
Cc: Russell King  (maintainer:ARM PORT)
Cc: linux-arm-ker...@lists.infradead.org (moderated list:ARM/FREESCALE IMX / 
MXC ARM ARCHITECTURE)

Cc: Philippe Ombredanne 
Cc: Lothar Waßmann 
---
 drivers/rtc/Kconfig  |  10 ++
 drivers/rtc/Makefile |   1 +
 drivers/rtc/rtc-mxc_v2.c | 422 +++
 3 files changed, 433 insertions(+)
 create mode 100644 drivers/rtc/rtc-mxc_v2.c

diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index b59a31b079a5..440edebf5c71 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1689,6 +1689,16 @@ config RTC_DRV_MXC
   This driver can also be built as a module, if so, the module
   will be called "rtc-mxc".
 
+config RTC_DRV_MXC_V2
+   tristate "Freescale MXC Real Time Clock for i.MX53"
+   depends on ARCH_MXC
+   help
+  If you say yes here you get support for the Freescale MXC
+  SRTC module in i.MX53 processor.
+
+  This driver can also be built as a module, if so, the module
+  will be called "rtc-mxc_v2".
+
 config RTC_DRV_SNVS
tristate "Freescale SNVS RTC support"
select REGMAP_MMIO
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index f2f50c11dc38..dcf60e61ae5c 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -106,6 +106,7 @@ obj-$(CONFIG_RTC_DRV_MT6397)+= rtc-mt6397.o
 obj-$(CONFIG_RTC_DRV_MT7622)   += rtc-mt7622.o
 obj-$(CONFIG_RTC_DRV_MV)   += rtc-mv.o
 obj-$(CONFIG_RTC_DRV_MXC)  += rtc-mxc.o
+obj-$(CONFIG_RTC_DRV_MXC_V2)   += rtc-mxc_v2.o
 obj-$(CONFIG_RTC_DRV_NUC900)   += rtc-nuc900.o
 obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
 obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o
diff --git a/drivers/rtc/rtc-mxc_v2.c b/drivers/rtc/rtc-mxc_v2.c
new file mode 100644
index ..b637095b0716
--- /dev/null
+++ b/drivers/rtc/rtc-mxc_v2.c
@@ -0,0 +1,422 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Real Time Clock (RTC) Driver for i.MX53
+ * Copyright (c) 2004-2011 Freescale Semiconductor, Inc.
+ * Copyright (c) 2017 Beckhoff Automation GmbH & Co. KG
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SRTC_LPPDR_INIT   0x41736166   /* init for glitch detect */
+
+#define SRTC_LPCR_EN_LP   BIT(3)   /* lp enable */
+#define SRTC_LPCR_WAE BIT(4)   /* lp wakeup alarm enable */
+#define SRTC_LPCR_ALP BIT(7)   /* lp alarm flag */
+#define SRTC_LPCR_NSA BIT(11)  /* lp non secure access */
+#define SRTC_LPCR_NVE