diff mbox series

[U-Boot,v2,1/3] x86: irq: Parse number of PIRQ links from device tree

Message ID 1528792007-7167-2-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit dcec5d565a20e025d843828d8424851d0271677b
Delegated to: Bin Meng
Headers show
Series x86: ivybridge: cougarcanyon2: Various enhancements | expand

Commit Message

Bin Meng June 12, 2018, 8:26 a.m. UTC
The "intel,pirq-link" property in Intel IRQ router's dt bindings
has two cells, where the second one represents the number of PIRQ
links on the platform. However current driver does not parse this
information from device tree. This adds the codes to do the parse
and save it for future use.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v2:
- drop patches that were applied to u-boot-x86
- drop v1 patches using Kconfig option CONFIG_DISCRETE_PIRQ_ROUT
- new patch to "parse number of PIRQ links from device tree"

 arch/x86/cpu/irq.c         | 14 ++++++++++----
 arch/x86/include/asm/irq.h |  2 ++
 2 files changed, 12 insertions(+), 4 deletions(-)

Comments

Simon Glass June 13, 2018, 1:29 a.m. UTC | #1
Hi Bin,

On 12 June 2018 at 02:26, Bin Meng <bmeng.cn@gmail.com> wrote:
> The "intel,pirq-link" property in Intel IRQ router's dt bindings
> has two cells, where the second one represents the number of PIRQ
> links on the platform. However current driver does not parse this
> information from device tree. This adds the codes to do the parse
> and save it for future use.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - drop patches that were applied to u-boot-x86
> - drop v1 patches using Kconfig option CONFIG_DISCRETE_PIRQ_ROUT
> - new patch to "parse number of PIRQ links from device tree"
>
>  arch/x86/cpu/irq.c         | 14 ++++++++++----
>  arch/x86/include/asm/irq.h |  2 ++
>  2 files changed, 12 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

At some point this driver should be converted to livetree.
Bin Meng June 13, 2018, 1:48 a.m. UTC | #2
On Wed, Jun 13, 2018 at 9:29 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Bin,
>
> On 12 June 2018 at 02:26, Bin Meng <bmeng.cn@gmail.com> wrote:
>> The "intel,pirq-link" property in Intel IRQ router's dt bindings
>> has two cells, where the second one represents the number of PIRQ
>> links on the platform. However current driver does not parse this
>> information from device tree. This adds the codes to do the parse
>> and save it for future use.
>>
>> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>>
>> ---
>>
>> Changes in v2:
>> - drop patches that were applied to u-boot-x86
>> - drop v1 patches using Kconfig option CONFIG_DISCRETE_PIRQ_ROUT
>> - new patch to "parse number of PIRQ links from device tree"
>>
>>  arch/x86/cpu/irq.c         | 14 ++++++++++----
>>  arch/x86/include/asm/irq.h |  2 ++
>>  2 files changed, 12 insertions(+), 4 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> At some point this driver should be converted to livetree.

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/arch/x86/cpu/irq.c b/arch/x86/cpu/irq.c
index ec556d3..096c34f 100644
--- a/arch/x86/cpu/irq.c
+++ b/arch/x86/cpu/irq.c
@@ -116,10 +116,16 @@  static int create_pirq_routing_table(struct udevice *dev)
 			return -EINVAL;
 	}
 
-	ret = fdtdec_get_int(blob, node, "intel,pirq-link", -1);
-	if (ret == -1)
-		return ret;
-	priv->link_base = ret;
+	cell = fdt_getprop(blob, node, "intel,pirq-link", &len);
+	if (!cell || len != 8)
+		return -EINVAL;
+	priv->link_base = fdt_addr_to_cpu(cell[0]);
+	priv->link_num = fdt_addr_to_cpu(cell[1]);
+	if (priv->link_num > CONFIG_MAX_PIRQ_LINKS) {
+		debug("Limiting supported PIRQ link number from %d to %d\n",
+		      priv->link_num, CONFIG_MAX_PIRQ_LINKS);
+		priv->link_num = CONFIG_MAX_PIRQ_LINKS;
+	}
 
 	priv->irq_mask = fdtdec_get_int(blob, node,
 					"intel,pirq-mask", PIRQ_BITMAP);
diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
index bfa58cf..9ac91f2 100644
--- a/arch/x86/include/asm/irq.h
+++ b/arch/x86/include/asm/irq.h
@@ -29,6 +29,7 @@  enum pirq_config {
  *
  * @config:	PIRQ_VIA_PCI or PIRQ_VIA_IBASE
  * @link_base:	link value base number
+ * @link_num:	number of PIRQ links supported
  * @irq_mask:	IRQ mask reprenting the 16 IRQs in 8259, bit N is 1 means
  *		IRQ N is available to be routed
  * @lb_bdf:	irq router's PCI bus/device/function number encoding
@@ -39,6 +40,7 @@  enum pirq_config {
 struct irq_router {
 	int config;
 	u32 link_base;
+	int link_num;
 	u16 irq_mask;
 	u32 bdf;
 	u32 ibase;