[PATCH 2/2] ARM: bus: da8xx-mstpri: new driver

2016-10-31 Thread Sekhar Nori
On Monday 31 October 2016 03:24 PM, Bartosz Golaszewski wrote:
> 2016-10-31 10:52 GMT+01:00 Sekhar Nori :
>> Hi Bartosz,
>>
>> On Monday 31 October 2016 03:10 PM, Bartosz Golaszewski wrote:
>>> 2016-10-31 5:30 GMT+01:00 Rob Herring :
 On Wed, Oct 26, 2016 at 07:35:55PM +0200, Bartosz Golaszewski wrote:
> Create the driver for the da8xx master peripheral priority
> configuration and implement support for writing to the three
> Master Priority registers on da850 SoCs.
>
> Signed-off-by: Bartosz Golaszewski 
> ---
>  .../devicetree/bindings/bus/ti,da850-mstpri.txt|  20 ++
>  drivers/bus/Kconfig|   9 +
>  drivers/bus/Makefile   |   2 +
>  drivers/bus/da8xx-mstpri.c | 266 
> +
>  4 files changed, 297 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>  create mode 100644 drivers/bus/da8xx-mstpri.c
>
> diff --git a/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt 
> b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
> new file mode 100644
> index 000..225af09
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
> @@ -0,0 +1,20 @@
> +* Device tree bindings for Texas Instruments da8xx master peripheral
> +  priority driver
> +
> +DA8XX SoCs feature a set of registers allowing to change the priority of 
> all
> +peripherals classified as masters.
> +
> +Documentation:
> +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf
> +
> +Required properties:
> +
> +- compatible:"ti,da850-mstpri", "syscon" - for da850 
> based boards

 Drop syscon. Doesn't look like it is needed and the example doesn't
 match.
>>>
>>> Hi Rob,
>>>
>>> it is needed: syscon_regmap_lookup_by_compatible() fails without it. I
>>> fixed the example instead.
>>
>> Why are master priority registers under syscon? This driver should be
>> the only entity touching them. So do we need an MFD driver?
>>
> 
> It should, but syscfg0 registers are mapped all over the place. I

Not sure what you mean by this. Yes, the sysconfig module has many
functionalities. But the registers for a given functionality are all
grouped together AFAICS (except CHIPCFGn, see below).

Pinmux registers are part of syscfg module, but don't use syscon.

In the work going on for OHCI support, chipcfg registers are being put
under a syscon node. But that makes sense, I think, because chipcfg
registers are catering to really diverse functionality like PLL and EDMA
related stuff being placed in the same register - CHIPCFG0.

> thought it would be safer to put them under syscon and Kevin agreed.

Before using syscon for the whole syscfg space, I think we need some
analysis as to where the likely races are going to be.

Thanks,
Sekhar


[PATCH 2/2] ARM: bus: da8xx-mstpri: new driver

2016-10-31 Thread Sekhar Nori
Hi Bartosz,

On Monday 31 October 2016 03:10 PM, Bartosz Golaszewski wrote:
> 2016-10-31 5:30 GMT+01:00 Rob Herring :
>> On Wed, Oct 26, 2016 at 07:35:55PM +0200, Bartosz Golaszewski wrote:
>>> Create the driver for the da8xx master peripheral priority
>>> configuration and implement support for writing to the three
>>> Master Priority registers on da850 SoCs.
>>>
>>> Signed-off-by: Bartosz Golaszewski 
>>> ---
>>>  .../devicetree/bindings/bus/ti,da850-mstpri.txt|  20 ++
>>>  drivers/bus/Kconfig|   9 +
>>>  drivers/bus/Makefile   |   2 +
>>>  drivers/bus/da8xx-mstpri.c | 266 
>>> +
>>>  4 files changed, 297 insertions(+)
>>>  create mode 100644 
>>> Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>>>  create mode 100644 drivers/bus/da8xx-mstpri.c
>>>
>>> diff --git a/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt 
>>> b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>>> new file mode 100644
>>> index 000..225af09
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>>> @@ -0,0 +1,20 @@
>>> +* Device tree bindings for Texas Instruments da8xx master peripheral
>>> +  priority driver
>>> +
>>> +DA8XX SoCs feature a set of registers allowing to change the priority of 
>>> all
>>> +peripherals classified as masters.
>>> +
>>> +Documentation:
>>> +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf
>>> +
>>> +Required properties:
>>> +
>>> +- compatible:"ti,da850-mstpri", "syscon" - for da850 based 
>>> boards
>>
>> Drop syscon. Doesn't look like it is needed and the example doesn't
>> match.
> 
> Hi Rob,
> 
> it is needed: syscon_regmap_lookup_by_compatible() fails without it. I
> fixed the example instead.

Why are master priority registers under syscon? This driver should be
the only entity touching them. So do we need an MFD driver?

Thanks,
Sekhar


[PATCH 2/2] ARM: bus: da8xx-mstpri: new driver

2016-10-31 Thread Kevin Hilman
Sekhar Nori  writes:

> On Monday 31 October 2016 03:24 PM, Bartosz Golaszewski wrote:
>> 2016-10-31 10:52 GMT+01:00 Sekhar Nori :
>>> Hi Bartosz,
>>>
>>> On Monday 31 October 2016 03:10 PM, Bartosz Golaszewski wrote:
 2016-10-31 5:30 GMT+01:00 Rob Herring :
> On Wed, Oct 26, 2016 at 07:35:55PM +0200, Bartosz Golaszewski wrote:
>> Create the driver for the da8xx master peripheral priority
>> configuration and implement support for writing to the three
>> Master Priority registers on da850 SoCs.
>>
>> Signed-off-by: Bartosz Golaszewski 
>> ---
>>  .../devicetree/bindings/bus/ti,da850-mstpri.txt|  20 ++
>>  drivers/bus/Kconfig|   9 +
>>  drivers/bus/Makefile   |   2 +
>>  drivers/bus/da8xx-mstpri.c | 266 
>> +
>>  4 files changed, 297 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>>  create mode 100644 drivers/bus/da8xx-mstpri.c
>>
>> diff --git a/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt 
>> b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>> new file mode 100644
>> index 000..225af09
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>> @@ -0,0 +1,20 @@
>> +* Device tree bindings for Texas Instruments da8xx master peripheral
>> +  priority driver
>> +
>> +DA8XX SoCs feature a set of registers allowing to change the priority 
>> of all
>> +peripherals classified as masters.
>> +
>> +Documentation:
>> +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf
>> +
>> +Required properties:
>> +
>> +- compatible:"ti,da850-mstpri", "syscon" - for da850 
>> based boards
>
> Drop syscon. Doesn't look like it is needed and the example doesn't
> match.

 Hi Rob,

 it is needed: syscon_regmap_lookup_by_compatible() fails without it. I
 fixed the example instead.
>>>
>>> Why are master priority registers under syscon? This driver should be
>>> the only entity touching them. So do we need an MFD driver?
>>>
>> 
>> It should, but syscfg0 registers are mapped all over the place. I
>
> Not sure what you mean by this. Yes, the sysconfig module has many
> functionalities. But the registers for a given functionality are all
> grouped together AFAICS (except CHIPCFGn, see below).
>
> Pinmux registers are part of syscfg module, but don't use syscon.
>
> In the work going on for OHCI support, chipcfg registers are being put
> under a syscon node. But that makes sense, I think, because chipcfg
> registers are catering to really diverse functionality like PLL and EDMA
> related stuff being placed in the same register - CHIPCFG0.
>
>> thought it would be safer to put them under syscon and Kevin agreed.
>
> Before using syscon for the whole syscfg space, I think we need some
> analysis as to where the likely races are going to be.

I'm OK with that for now.  It makes the most sense to use sycon only for
the register (ranges) that will actually be shared.

Kevin


[PATCH 2/2] ARM: bus: da8xx-mstpri: new driver

2016-10-31 Thread Bartosz Golaszewski
2016-10-31 10:52 GMT+01:00 Sekhar Nori :
> Hi Bartosz,
>
> On Monday 31 October 2016 03:10 PM, Bartosz Golaszewski wrote:
>> 2016-10-31 5:30 GMT+01:00 Rob Herring :
>>> On Wed, Oct 26, 2016 at 07:35:55PM +0200, Bartosz Golaszewski wrote:
 Create the driver for the da8xx master peripheral priority
 configuration and implement support for writing to the three
 Master Priority registers on da850 SoCs.

 Signed-off-by: Bartosz Golaszewski 
 ---
  .../devicetree/bindings/bus/ti,da850-mstpri.txt|  20 ++
  drivers/bus/Kconfig|   9 +
  drivers/bus/Makefile   |   2 +
  drivers/bus/da8xx-mstpri.c | 266 
 +
  4 files changed, 297 insertions(+)
  create mode 100644 
 Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
  create mode 100644 drivers/bus/da8xx-mstpri.c

 diff --git a/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt 
 b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
 new file mode 100644
 index 000..225af09
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
 @@ -0,0 +1,20 @@
 +* Device tree bindings for Texas Instruments da8xx master peripheral
 +  priority driver
 +
 +DA8XX SoCs feature a set of registers allowing to change the priority of 
 all
 +peripherals classified as masters.
 +
 +Documentation:
 +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf
 +
 +Required properties:
 +
 +- compatible:"ti,da850-mstpri", "syscon" - for da850 
 based boards
>>>
>>> Drop syscon. Doesn't look like it is needed and the example doesn't
>>> match.
>>
>> Hi Rob,
>>
>> it is needed: syscon_regmap_lookup_by_compatible() fails without it. I
>> fixed the example instead.
>
> Why are master priority registers under syscon? This driver should be
> the only entity touching them. So do we need an MFD driver?
>

It should, but syscfg0 registers are mapped all over the place. I
thought it would be safer to put them under syscon and Kevin agreed.

Thanks,
Bartosz Golaszewski


[PATCH 2/2] ARM: bus: da8xx-mstpri: new driver

2016-10-31 Thread Bartosz Golaszewski
2016-10-31 5:30 GMT+01:00 Rob Herring :
> On Wed, Oct 26, 2016 at 07:35:55PM +0200, Bartosz Golaszewski wrote:
>> Create the driver for the da8xx master peripheral priority
>> configuration and implement support for writing to the three
>> Master Priority registers on da850 SoCs.
>>
>> Signed-off-by: Bartosz Golaszewski 
>> ---
>>  .../devicetree/bindings/bus/ti,da850-mstpri.txt|  20 ++
>>  drivers/bus/Kconfig|   9 +
>>  drivers/bus/Makefile   |   2 +
>>  drivers/bus/da8xx-mstpri.c | 266 
>> +
>>  4 files changed, 297 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>>  create mode 100644 drivers/bus/da8xx-mstpri.c
>>
>> diff --git a/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt 
>> b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>> new file mode 100644
>> index 000..225af09
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>> @@ -0,0 +1,20 @@
>> +* Device tree bindings for Texas Instruments da8xx master peripheral
>> +  priority driver
>> +
>> +DA8XX SoCs feature a set of registers allowing to change the priority of all
>> +peripherals classified as masters.
>> +
>> +Documentation:
>> +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf
>> +
>> +Required properties:
>> +
>> +- compatible:"ti,da850-mstpri", "syscon" - for da850 based 
>> boards
>
> Drop syscon. Doesn't look like it is needed and the example doesn't
> match.

Hi Rob,

it is needed: syscon_regmap_lookup_by_compatible() fails without it. I
fixed the example instead.

Thanks,
Bartosz Golaszewski


[PATCH 2/2] ARM: bus: da8xx-mstpri: new driver

2016-10-31 Thread Rob Herring
On Wed, Oct 26, 2016 at 07:35:55PM +0200, Bartosz Golaszewski wrote:
> Create the driver for the da8xx master peripheral priority
> configuration and implement support for writing to the three
> Master Priority registers on da850 SoCs.
> 
> Signed-off-by: Bartosz Golaszewski 
> ---
>  .../devicetree/bindings/bus/ti,da850-mstpri.txt|  20 ++
>  drivers/bus/Kconfig|   9 +
>  drivers/bus/Makefile   |   2 +
>  drivers/bus/da8xx-mstpri.c | 266 
> +
>  4 files changed, 297 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
>  create mode 100644 drivers/bus/da8xx-mstpri.c
> 
> diff --git a/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt 
> b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
> new file mode 100644
> index 000..225af09
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
> @@ -0,0 +1,20 @@
> +* Device tree bindings for Texas Instruments da8xx master peripheral
> +  priority driver
> +
> +DA8XX SoCs feature a set of registers allowing to change the priority of all
> +peripherals classified as masters.
> +
> +Documentation:
> +OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf
> +
> +Required properties:
> +
> +- compatible:"ti,da850-mstpri", "syscon" - for da850 based 
> boards

Drop syscon. Doesn't look like it is needed and the example doesn't 
match.

> +- reg:   offset and length of the mstpri registers
> +
> +Example for da850-lcdk is shown below.
> +
> +mstpri {
> + compatible = "ti,da850-mstpri";
> + reg = <0x14110 0x0c>;
> +};


[PATCH 2/2] ARM: bus: da8xx-mstpri: new driver

2016-10-26 Thread Bartosz Golaszewski
Create the driver for the da8xx master peripheral priority
configuration and implement support for writing to the three
Master Priority registers on da850 SoCs.

Signed-off-by: Bartosz Golaszewski 
---
 .../devicetree/bindings/bus/ti,da850-mstpri.txt|  20 ++
 drivers/bus/Kconfig|   9 +
 drivers/bus/Makefile   |   2 +
 drivers/bus/da8xx-mstpri.c | 266 +
 4 files changed, 297 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
 create mode 100644 drivers/bus/da8xx-mstpri.c

diff --git a/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt 
b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
new file mode 100644
index 000..225af09
--- /dev/null
+++ b/Documentation/devicetree/bindings/bus/ti,da850-mstpri.txt
@@ -0,0 +1,20 @@
+* Device tree bindings for Texas Instruments da8xx master peripheral
+  priority driver
+
+DA8XX SoCs feature a set of registers allowing to change the priority of all
+peripherals classified as masters.
+
+Documentation:
+OMAP-L138 (DA850) - http://www.ti.com/lit/ug/spruh82c/spruh82c.pdf
+
+Required properties:
+
+- compatible:  "ti,da850-mstpri", "syscon" - for da850 based boards
+- reg: offset and length of the mstpri registers
+
+Example for da850-lcdk is shown below.
+
+mstpri {
+   compatible = "ti,da850-mstpri";
+   reg = <0x14110 0x0c>;
+};
diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
index 7010dca..ed6a89c 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -166,4 +166,13 @@ config VEXPRESS_CONFIG
help
  Platform configuration infrastructure for the ARM Ltd.
  Versatile Express.
+
+config DA8XX_MSTPRI
+   bool "TI da8xx master peripheral priority driver"
+   depends on ARCH_DAVINCI_DA8XX
+   help
+ Driver for Texas Instruments da8xx master peripheral priority
+ configuration. Allows to adjust the priorities of all master
+ peripherals.
+
 endmenu
diff --git a/drivers/bus/Makefile b/drivers/bus/Makefile
index c6cfa6b..2adb540 100644
--- a/drivers/bus/Makefile
+++ b/drivers/bus/Makefile
@@ -21,3 +21,5 @@ obj-$(CONFIG_SIMPLE_PM_BUS)   += simple-pm-bus.o
 obj-$(CONFIG_TEGRA_ACONNECT)   += tegra-aconnect.o
 obj-$(CONFIG_UNIPHIER_SYSTEM_BUS)  += uniphier-system-bus.o
 obj-$(CONFIG_VEXPRESS_CONFIG)  += vexpress-config.o
+
+obj-$(CONFIG_DA8XX_MSTPRI) += da8xx-mstpri.o
diff --git a/drivers/bus/da8xx-mstpri.c b/drivers/bus/da8xx-mstpri.c
new file mode 100644
index 000..00c4f83
--- /dev/null
+++ b/drivers/bus/da8xx-mstpri.c
@@ -0,0 +1,266 @@
+/*
+ * TI da8xx master peripheral priority driver
+ *
+ * Copyright (C) 2016 BayLibre SAS
+ *
+ * Author:
+ *   Bartosz Golaszewski 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * REVISIT: Linux doesn't have a good framework for the kind of performance
+ * knobs this driver controls. We can't use device tree properties as it deals
+ * with hardware configuration rather than description. We also don't want to
+ * commit to maintaining some random sysfs attributes.
+ *
+ * For now we just hardcode the register values for the boards that need
+ * some changes (as is the case for the LCD controller on da850-lcdk - the
+ * first board we support here). When linux gets an appropriate framework,
+ * we'll easily convert the driver to it.
+ */
+
+#define DA8XX_MSTPRI0_OFFSET   0
+#define DA8XX_MSTPRI1_OFFSET   4
+#define DA8XX_MSTPRI2_OFFSET   8
+
+enum {
+   DA8XX_MSTPRI_ARM_I = 0,
+   DA8XX_MSTPRI_ARM_D,
+   DA8XX_MSTPRI_UPP,
+   DA8XX_MSTPRI_SATA,
+   DA8XX_MSTPRI_PRU0,
+   DA8XX_MSTPRI_PRU1,
+   DA8XX_MSTPRI_EDMA30TC0,
+   DA8XX_MSTPRI_EDMA30TC1,
+   DA8XX_MSTPRI_EDMA31TC0,
+   DA8XX_MSTPRI_VPIF_DMA_0,
+   DA8XX_MSTPRI_VPIF_DMA_1,
+   DA8XX_MSTPRI_EMAC,
+   DA8XX_MSTPRI_USB0CFG,
+   DA8XX_MSTPRI_USB0CDMA,
+   DA8XX_MSTPRI_UHPI,
+   DA8XX_MSTPRI_USB1,
+   DA8XX_MSTPRI_LCDC,
+};
+
+struct da8xx_mstpri_descr {
+   int reg;
+   int shift;
+   int mask;
+};
+
+static const struct da8xx_mstpri_descr da8xx_mstpri_priority_list[] = {
+   [DA8XX_MSTPRI_ARM_I] = {
+   .reg = DA8XX_MSTPRI0_OFFSET,
+   .shift = 0,
+   .mask = 0x000f,
+   },
+   [DA8XX_MSTPRI_ARM_D] = {
+   .reg = DA8XX_MSTPRI0_OFFSET,
+   .shift = 4,
+   .mask = 0x00f0,
+   },
+   [DA8XX_MSTPRI_UPP] = {
+   .reg = DA8XX_MSTPRI0_OFFSET,
+   .shift = 16,
+   .mask = 0x000f,
+   },
+   [DA8XX_MSTPRI_SATA] = {
+   .reg =