Re: [RFC v1 2/3] interconnect: Add Qualcomm msm8916 interconnect provider driver

2017-05-16 Thread Georgi Djakov
On 05/15/2017 07:01 PM, Geert Uytterhoeven wrote:
> Hi Georgi,
> 
> On Mon, May 15, 2017 at 5:35 PM, Georgi Djakov  
> wrote:
>> --- /dev/null
>> +++ b/drivers/interconnect/qcom/interconnect_msm8916.c
> 
>> +struct qcom_interconnect_node {
>> +   struct interconnect_node node;
>> +   unsigned int id;
> 
> 4 byte gap due to alignment rules on 64-bit.
> 
>> +   unsigned char *name;
>> +   struct interconnect_node *links[8];
>> +   int num_links;
>> +   int port;
>> +   int buswidth;
> 
> 4 byte gap due to alignment rules.
> 
>> +   u64 ib;
>> +   u64 ab;
>> +   u64 rate;
>> +};
> 
> You can avoid the gaps by putting members of the same size and alignment
> together.

Thanks Geert, i will rearrange this to reduce the padding bytes!

BR,
Georgi


Re: [RFC v1 2/3] interconnect: Add Qualcomm msm8916 interconnect provider driver

2017-05-16 Thread Georgi Djakov
On 05/15/2017 07:01 PM, Geert Uytterhoeven wrote:
> Hi Georgi,
> 
> On Mon, May 15, 2017 at 5:35 PM, Georgi Djakov  
> wrote:
>> --- /dev/null
>> +++ b/drivers/interconnect/qcom/interconnect_msm8916.c
> 
>> +struct qcom_interconnect_node {
>> +   struct interconnect_node node;
>> +   unsigned int id;
> 
> 4 byte gap due to alignment rules on 64-bit.
> 
>> +   unsigned char *name;
>> +   struct interconnect_node *links[8];
>> +   int num_links;
>> +   int port;
>> +   int buswidth;
> 
> 4 byte gap due to alignment rules.
> 
>> +   u64 ib;
>> +   u64 ab;
>> +   u64 rate;
>> +};
> 
> You can avoid the gaps by putting members of the same size and alignment
> together.

Thanks Geert, i will rearrange this to reduce the padding bytes!

BR,
Georgi


Re: [RFC v1 2/3] interconnect: Add Qualcomm msm8916 interconnect provider driver

2017-05-15 Thread Geert Uytterhoeven
Hi Georgi,

On Mon, May 15, 2017 at 5:35 PM, Georgi Djakov  wrote:
> --- /dev/null
> +++ b/drivers/interconnect/qcom/interconnect_msm8916.c

> +struct qcom_interconnect_node {
> +   struct interconnect_node node;
> +   unsigned int id;

4 byte gap due to alignment rules on 64-bit.

> +   unsigned char *name;
> +   struct interconnect_node *links[8];
> +   int num_links;
> +   int port;
> +   int buswidth;

4 byte gap due to alignment rules.

> +   u64 ib;
> +   u64 ab;
> +   u64 rate;
> +};

You can avoid the gaps by putting members of the same size and alignment
together.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [RFC v1 2/3] interconnect: Add Qualcomm msm8916 interconnect provider driver

2017-05-15 Thread Geert Uytterhoeven
Hi Georgi,

On Mon, May 15, 2017 at 5:35 PM, Georgi Djakov  wrote:
> --- /dev/null
> +++ b/drivers/interconnect/qcom/interconnect_msm8916.c

> +struct qcom_interconnect_node {
> +   struct interconnect_node node;
> +   unsigned int id;

4 byte gap due to alignment rules on 64-bit.

> +   unsigned char *name;
> +   struct interconnect_node *links[8];
> +   int num_links;
> +   int port;
> +   int buswidth;

4 byte gap due to alignment rules.

> +   u64 ib;
> +   u64 ab;
> +   u64 rate;
> +};

You can avoid the gaps by putting members of the same size and alignment
together.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[RFC v1 2/3] interconnect: Add Qualcomm msm8916 interconnect provider driver

2017-05-15 Thread Georgi Djakov
Add driver for the Qualcomm interconnect controllers found in
msm8916 based platforms.

Signed-off-by: Georgi Djakov 
---
 drivers/interconnect/Kconfig |   5 +
 drivers/interconnect/Makefile|   1 +
 drivers/interconnect/qcom/Kconfig|  12 +
 drivers/interconnect/qcom/Makefile   |   2 +
 drivers/interconnect/qcom/interconnect_msm8916.c | 394 +++
 include/dt-bindings/interconnect/qcom,msm8916.h  |  87 +
 6 files changed, 501 insertions(+)
 create mode 100644 drivers/interconnect/qcom/Kconfig
 create mode 100644 drivers/interconnect/qcom/Makefile
 create mode 100644 drivers/interconnect/qcom/interconnect_msm8916.c
 create mode 100644 include/dt-bindings/interconnect/qcom,msm8916.h

diff --git a/drivers/interconnect/Kconfig b/drivers/interconnect/Kconfig
index 1e50e951cdc1..b123a76e2f9d 100644
--- a/drivers/interconnect/Kconfig
+++ b/drivers/interconnect/Kconfig
@@ -8,3 +8,8 @@ menuconfig INTERCONNECT
 
  If unsure, say no.
 
+if INTERCONNECT
+
+source "drivers/interconnect/qcom/Kconfig"
+
+endif
diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
index d9da6a6c3560..62a01de24aeb 100644
--- a/drivers/interconnect/Makefile
+++ b/drivers/interconnect/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_INTERCONNECT)  += interconnect.o
+obj-$(CONFIG_INTERCONNECT_QCOM)+= qcom/
diff --git a/drivers/interconnect/qcom/Kconfig 
b/drivers/interconnect/qcom/Kconfig
new file mode 100644
index ..d96dbf5fd547
--- /dev/null
+++ b/drivers/interconnect/qcom/Kconfig
@@ -0,0 +1,12 @@
+config INTERCONNECT_QCOM
+   bool "Qualcomm Network-on-Chip interconnect drivers"
+   depends on OF
+   depends on ARCH_QCOM || COMPILE_TEST
+   default y
+
+config INTERCONNECT_QCOM_MSM8916
+   tristate "Qualcomm MSM8916 interconnect driver"
+   depends on INTERCONNECT_QCOM
+   help
+ This is a driver for the Qualcomm Network-on-Chip on msm8916-based 
platforms.
+
diff --git a/drivers/interconnect/qcom/Makefile 
b/drivers/interconnect/qcom/Makefile
new file mode 100644
index ..e5bf8e2b92ac
--- /dev/null
+++ b/drivers/interconnect/qcom/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_INTERCONNECT_QCOM_MSM8916) += interconnect_msm8916.o
+
diff --git a/drivers/interconnect/qcom/interconnect_msm8916.c 
b/drivers/interconnect/qcom/interconnect_msm8916.c
new file mode 100644
index ..258c0ae20e32
--- /dev/null
+++ b/drivers/interconnect/qcom/interconnect_msm8916.c
@@ -0,0 +1,394 @@
+/*
+ * Copyright (C) 2017 Linaro Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define to_qcom_icp(_icp) container_of(_icp, struct 
qcom_interconnect_provider, icp)
+#define to_qcom_node(_node) container_of(_node, struct qcom_interconnect_node, 
node)
+
+enum qcom_bus_type {
+   QCOM_BUS_TYPE_NOC = 0,
+   QCOM_BUS_TYPE_MEM,
+   QCOM_BUS_TYPE_MAX,
+};
+
+struct qcom_interconnect_provider {
+   struct icp  icp;
+   void __iomem*base;
+   enum qcom_bus_type  type;
+   u32 base_offset;
+   u32 qos_offset;
+   struct clk  *bus_clk;
+   struct clk  *bus_a_clk;
+};
+
+struct qcom_interconnect_node {
+   struct interconnect_node node;
+   unsigned int id;
+   unsigned char *name;
+   struct interconnect_node *links[8];
+   int num_links;
+   int port;
+   int buswidth;
+   u64 ib;
+   u64 ab;
+   u64 rate;
+};
+
+static struct qcom_interconnect_node snoc_int_0;
+static struct qcom_interconnect_node snoc_int_1;
+static struct qcom_interconnect_node snoc_int_bimc;
+static struct qcom_interconnect_node snoc_bimc_0_mas;
+static struct qcom_interconnect_node pnoc_snoc_slv;
+
+static struct qcom_interconnect_node snoc_bimc_0_slv;
+static struct qcom_interconnect_node slv_ebi_ch0;
+
+static struct qcom_interconnect_node pnoc_int_1;
+static struct qcom_interconnect_node mas_pnoc_sdcc_1;
+static struct qcom_interconnect_node mas_pnoc_sdcc_2;
+static struct qcom_interconnect_node pnoc_snoc_mas;
+
+struct qcom_interconnect_desc {
+   struct qcom_interconnect_node **nodes;
+   size_t num_nodes;
+};
+
+static struct qcom_interconnect_node snoc_int_0 = {
+   .id = 10004,
+   .name = "snoc-int-0",
+   /*.links = { _pnoc_mas.node },
+   .num_links = 1,*/

[RFC v1 2/3] interconnect: Add Qualcomm msm8916 interconnect provider driver

2017-05-15 Thread Georgi Djakov
Add driver for the Qualcomm interconnect controllers found in
msm8916 based platforms.

Signed-off-by: Georgi Djakov 
---
 drivers/interconnect/Kconfig |   5 +
 drivers/interconnect/Makefile|   1 +
 drivers/interconnect/qcom/Kconfig|  12 +
 drivers/interconnect/qcom/Makefile   |   2 +
 drivers/interconnect/qcom/interconnect_msm8916.c | 394 +++
 include/dt-bindings/interconnect/qcom,msm8916.h  |  87 +
 6 files changed, 501 insertions(+)
 create mode 100644 drivers/interconnect/qcom/Kconfig
 create mode 100644 drivers/interconnect/qcom/Makefile
 create mode 100644 drivers/interconnect/qcom/interconnect_msm8916.c
 create mode 100644 include/dt-bindings/interconnect/qcom,msm8916.h

diff --git a/drivers/interconnect/Kconfig b/drivers/interconnect/Kconfig
index 1e50e951cdc1..b123a76e2f9d 100644
--- a/drivers/interconnect/Kconfig
+++ b/drivers/interconnect/Kconfig
@@ -8,3 +8,8 @@ menuconfig INTERCONNECT
 
  If unsure, say no.
 
+if INTERCONNECT
+
+source "drivers/interconnect/qcom/Kconfig"
+
+endif
diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
index d9da6a6c3560..62a01de24aeb 100644
--- a/drivers/interconnect/Makefile
+++ b/drivers/interconnect/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_INTERCONNECT)  += interconnect.o
+obj-$(CONFIG_INTERCONNECT_QCOM)+= qcom/
diff --git a/drivers/interconnect/qcom/Kconfig 
b/drivers/interconnect/qcom/Kconfig
new file mode 100644
index ..d96dbf5fd547
--- /dev/null
+++ b/drivers/interconnect/qcom/Kconfig
@@ -0,0 +1,12 @@
+config INTERCONNECT_QCOM
+   bool "Qualcomm Network-on-Chip interconnect drivers"
+   depends on OF
+   depends on ARCH_QCOM || COMPILE_TEST
+   default y
+
+config INTERCONNECT_QCOM_MSM8916
+   tristate "Qualcomm MSM8916 interconnect driver"
+   depends on INTERCONNECT_QCOM
+   help
+ This is a driver for the Qualcomm Network-on-Chip on msm8916-based 
platforms.
+
diff --git a/drivers/interconnect/qcom/Makefile 
b/drivers/interconnect/qcom/Makefile
new file mode 100644
index ..e5bf8e2b92ac
--- /dev/null
+++ b/drivers/interconnect/qcom/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_INTERCONNECT_QCOM_MSM8916) += interconnect_msm8916.o
+
diff --git a/drivers/interconnect/qcom/interconnect_msm8916.c 
b/drivers/interconnect/qcom/interconnect_msm8916.c
new file mode 100644
index ..258c0ae20e32
--- /dev/null
+++ b/drivers/interconnect/qcom/interconnect_msm8916.c
@@ -0,0 +1,394 @@
+/*
+ * Copyright (C) 2017 Linaro Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define to_qcom_icp(_icp) container_of(_icp, struct 
qcom_interconnect_provider, icp)
+#define to_qcom_node(_node) container_of(_node, struct qcom_interconnect_node, 
node)
+
+enum qcom_bus_type {
+   QCOM_BUS_TYPE_NOC = 0,
+   QCOM_BUS_TYPE_MEM,
+   QCOM_BUS_TYPE_MAX,
+};
+
+struct qcom_interconnect_provider {
+   struct icp  icp;
+   void __iomem*base;
+   enum qcom_bus_type  type;
+   u32 base_offset;
+   u32 qos_offset;
+   struct clk  *bus_clk;
+   struct clk  *bus_a_clk;
+};
+
+struct qcom_interconnect_node {
+   struct interconnect_node node;
+   unsigned int id;
+   unsigned char *name;
+   struct interconnect_node *links[8];
+   int num_links;
+   int port;
+   int buswidth;
+   u64 ib;
+   u64 ab;
+   u64 rate;
+};
+
+static struct qcom_interconnect_node snoc_int_0;
+static struct qcom_interconnect_node snoc_int_1;
+static struct qcom_interconnect_node snoc_int_bimc;
+static struct qcom_interconnect_node snoc_bimc_0_mas;
+static struct qcom_interconnect_node pnoc_snoc_slv;
+
+static struct qcom_interconnect_node snoc_bimc_0_slv;
+static struct qcom_interconnect_node slv_ebi_ch0;
+
+static struct qcom_interconnect_node pnoc_int_1;
+static struct qcom_interconnect_node mas_pnoc_sdcc_1;
+static struct qcom_interconnect_node mas_pnoc_sdcc_2;
+static struct qcom_interconnect_node pnoc_snoc_mas;
+
+struct qcom_interconnect_desc {
+   struct qcom_interconnect_node **nodes;
+   size_t num_nodes;
+};
+
+static struct qcom_interconnect_node snoc_int_0 = {
+   .id = 10004,
+   .name = "snoc-int-0",
+   /*.links = { _pnoc_mas.node },
+   .num_links = 1,*/
+   .buswidth = 8,