From: Ma Jun <redacted>
This patch set is used to support the mbigen v1 chip.
Compared to mbigen v2 chip, the main difference between them is
register layout(address,format)
As a sequence of this difference, the functions used to get or calculate
register address are also changed for this reason.
I posted this driver as a independent patch set but not change the mbigen-v2
driver to support mbigen-v1 hardware.
Ma Jun (5):
dt-binding: Change the mbigen bindding file to support the mbigen-v1
dt-binding:Rename the mbigen binding file name
irqchip: add platform device driver for mbigen device
irqchip:create irq domain for each mbigen device
irqchip:implement the mbigen irq chip operation functions
.../interrupt-controller/hisilicon,mbigen-v2.txt | 74 -----
.../interrupt-controller/hisilicon,mbigen.txt | 74 +++++
drivers/irqchip/Makefile | 2 +-
drivers/irqchip/irq-mbigen-v1.c | 295 ++++++++++++++++++++
4 files changed, 370 insertions(+), 75 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen-v2.txt
create mode 100644 Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen.txt
create mode 100644 drivers/irqchip/irq-mbigen-v1.c
From: Ma Jun <redacted>
Add the "hisilicon,mbigen-v1" string in binding file.
Signed-off-by: Ma Jun <redacted>
---
.../interrupt-controller/hisilicon,mbigen-v2.txt | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
@@ -16,7 +16,7 @@ The mbigen chip and devices connect to mbigen have the following properties: Mbigen main node required properties: --------------------------------------------- compatible: Should be "hisilicon,mbigen-v2"+- compatible: Should be "hisilicon,mbigen-v2" or "hisilicon,mbigen-v1" - reg: Specifies the base physical address and size of the Mbigen registers.
From: Ma Jun <redacted>
Because added the mbigen-v1 compatible string, the origin name is
not suitable any more. So,I remove the version number from file name.
Signed-off-by: Ma Jun <redacted>
---
.../interrupt-controller/hisilicon,mbigen-v2.txt | 74 --------------------
.../interrupt-controller/hisilicon,mbigen.txt | 74 ++++++++++++++++++++
2 files changed, 74 insertions(+), 74 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen-v2.txt
create mode 100644 Documentation/devicetree/bindings/interrupt-controller/hisilicon,mbigen.txt
@@ -1,74 +0,0 @@-Hisilicon mbigen device tree bindings.-=======================================--Mbigen means: message based interrupt generator.--MBI is kind of msi interrupt only used on Non-PCI devices.--To reduce the wired interrupt number connected to GIC,-Hisilicon designed mbigen to collect and generate interrupt.---Non-pci devices can connect to mbigen and generate the-interrupt by writing ITS register.--The mbigen chip and devices connect to mbigen have the following properties:--Mbigen main node required properties:---------------------------------------------- compatible: Should be "hisilicon,mbigen-v2" or "hisilicon,mbigen-v1"--- reg: Specifies the base physical address and size of the Mbigen- registers.--- interrupt controller: Identifies the node as an interrupt controller--- msi-parent: Specifies the MSI controller this mbigen use.- For more detail information,please refer to the generic msi-parent binding in- Documentation/devicetree/bindings/interrupt-controller/msi.txt.--- num-pins: the total number of pins implemented in this Mbigen- instance.--- #interrupt-cells : Specifies the number of cells needed to encode an- interrupt source. The value must be 2.-- The 1st cell is hardware pin number of the interrupt.This number is local to- each mbigen chip and in the range from 0 to the maximum interrupts number- of the mbigen.-- The 2nd cell is the interrupt trigger type.- The value of this cell should be:- 1: rising edge triggered- or- 4: high level triggered--Examples:-- mbigen_device_gmac:intc {- compatible = "hisilicon,mbigen-v2";- reg = <0x0 0xc0080000 0x0 0x10000>;- interrupt-controller;- msi-parent = <&its_dsa 0x40b1c>;- num-pins = <9>;- #interrupt-cells = <2>;- };--Devices connect to mbigen required properties:-------------------------------------------------------interrupt-parent: Specifies the mbigen device node which device connected.---interrupts:Specifies the interrupt source.- For the specific information of each cell in this property,please refer to- the "interrupt-cells" description mentioned above.--Examples:- gmac0: ethernet at c2080000 {- #address-cells = <1>;- #size-cells = <0>;- reg = <0 0xc2080000 0 0x20000>,- <0 0xc0000000 0 0x1000>;- interrupt-parent = <&mbigen_device_gmac>;- interrupts = <656 1>,- <657 1>;- };
@@ -0,0 +1,74 @@+Hisilicon mbigen device tree bindings.+=======================================++Mbigen means: message based interrupt generator.++MBI is kind of msi interrupt only used on Non-PCI devices.++To reduce the wired interrupt number connected to GIC,+Hisilicon designed mbigen to collect and generate interrupt.+++Non-pci devices can connect to mbigen and generate the+interrupt by writing ITS register.++The mbigen chip and devices connect to mbigen have the following properties:++Mbigen main node required properties:+-------------------------------------------+- compatible: Should be "hisilicon,mbigen-v2" or "hisilicon,mbigen-v1"++- reg: Specifies the base physical address and size of the Mbigen+ registers.++- interrupt controller: Identifies the node as an interrupt controller++- msi-parent: Specifies the MSI controller this mbigen use.+ For more detail information,please refer to the generic msi-parent binding in+ Documentation/devicetree/bindings/interrupt-controller/msi.txt.++- num-pins: the total number of pins implemented in this Mbigen+ instance.++- #interrupt-cells : Specifies the number of cells needed to encode an+ interrupt source. The value must be 2.++ The 1st cell is hardware pin number of the interrupt.This number is local to+ each mbigen chip and in the range from 0 to the maximum interrupts number+ of the mbigen.++ The 2nd cell is the interrupt trigger type.+ The value of this cell should be:+ 1: rising edge triggered+ or+ 4: high level triggered++Examples:++ mbigen_device_gmac:intc {+ compatible = "hisilicon,mbigen-v2";+ reg = <0x0 0xc0080000 0x0 0x10000>;+ interrupt-controller;+ msi-parent = <&its_dsa 0x40b1c>;+ num-pins = <9>;+ #interrupt-cells = <2>;+ };++Devices connect to mbigen required properties:+----------------------------------------------------+-interrupt-parent: Specifies the mbigen device node which device connected.++-interrupts:Specifies the interrupt source.+ For the specific information of each cell in this property,please refer to+ the "interrupt-cells" description mentioned above.++Examples:+ gmac0: ethernet at c2080000 {+ #address-cells = <1>;+ #size-cells = <0>;+ reg = <0 0xc2080000 0 0x20000>,+ <0 0xc0000000 0 0x1000>;+ interrupt-parent = <&mbigen_device_gmac>;+ interrupts = <656 1>,+ <657 1>;+ };
From: Ma Jun <redacted>
Add the platform device driver for mbigen chip v1.
This patch just same as mbigen v2.
Signed-off-by: Ma Jun <redacted>
---
drivers/irqchip/Makefile | 2 +-
drivers/irqchip/irq-mbigen-v1.c | 76 +++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 1 deletions(-)
create mode 100644 drivers/irqchip/irq-mbigen-v1.c
@@ -0,0 +1,76 @@+/*+*Copyright(C)2015HisiliconLimited,AllRightsReserved.+*Author:JunMa<majun258@huawei.com>+*Author:YunWu<wuyun.wu@huawei.com>+*+*Thisprogramisfreesoftware;youcanredistributeitand/ormodify+*itunderthetermsoftheGNUGeneralPublicLicenseversion2as+*publishedbytheFreeSoftwareFoundation.+*+*Thisprogramisdistributedinthehopethatitwillbeuseful,+*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof+*MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe+*GNUGeneralPublicLicenseformoredetails.+*+*YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense+*alongwiththisprogram.Ifnot,see<http://www.gnu.org/licenses/>.+*/++#include<linux/module.h>+#include<linux/of_platform.h>+#include<linux/platform_device.h>+#include<linux/slab.h>++/**+*structmbigen_device-holdstheinformationofmbigendevice.+*+*@pdev:pointertotheplatformdevicestructureofmbigenchip.+*@base:mappedaddressofthismbigenchip.+*/+structmbigen_device{+structplatform_device*pdev;+void__iomem*base;+};++staticintmbigen_device_probe(structplatform_device*pdev)+{+structmbigen_device*mgn_chip;+structresource*res;++mgn_chip=devm_kzalloc(&pdev->dev,sizeof(*mgn_chip),GFP_KERNEL);+if(!mgn_chip)+return-ENOMEM;++mgn_chip->pdev=pdev;++res=platform_get_resource(pdev,IORESOURCE_MEM,0);+mgn_chip->base=devm_ioremap(&pdev->dev,res->start,resource_size(res));+if(IS_ERR(mgn_chip->base))+returnPTR_ERR(mgn_chip->base);++platform_set_drvdata(pdev,mgn_chip);++return0;+}++staticconststructof_device_idmbigen_of_match[]={+{.compatible="hisilicon,mbigen-v1"},+{/* END */}+};+MODULE_DEVICE_TABLE(of,mbigen_of_match);++staticstructplatform_drivermbigen_platform_driver={+.driver={+.name="Hisilicon MBIGEN-V1",+.owner=THIS_MODULE,+.of_match_table=mbigen_of_match,+},+.probe=mbigen_device_probe,+};++module_platform_driver(mbigen_platform_driver);++MODULE_AUTHOR("Jun Ma <majun258@huawei.com>");+MODULE_AUTHOR("Yun Wu <wuyun.wu@huawei.com>");+MODULE_LICENSE("GPL");+MODULE_DESCRIPTION("Hisilicon MBI Generator driver");
From: kbuild test robot <hidden> Date: 2016-02-14 06:09:58
Hi Ma,
[auto build test ERROR on tip/irq/core]
[also build test ERROR on v4.5-rc3 next-20160212]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/MaJun/irqchip-Add-support-for-Hisilicon-mbigen-v1-chip/20160214-101957
config: arm64-defconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64
Note: the linux-review/MaJun/irqchip-Add-support-for-Hisilicon-mbigen-v1-chip/20160214-101957 HEAD 9acb433456cd9671c97c0eeb1ccca8cc3b986081 builds fine.
It only hurts bisectibility.
All error/warnings (new ones prefixed by >>):
drivers/irqchip/irq-mbigen-v1.c: In function 'mbigen_device_probe':
quoted
drivers/irqchip/irq-mbigen-v1.c:47:2: error: implicit declaration of function 'devm_ioremap' [-Werror=implicit-function-declaration]
From: Ma Jun <redacted>
For peripheral devices which connect to mbigen,mbigen is a interrupt
controller. So, we create irq domain for each mbigen device and add
mbigen irq domain into irq hierarchy structure.
Signed-off-by: Ma Jun <redacted>
---
drivers/irqchip/irq-mbigen-v1.c | 144 +++++++++++++++++++++++++++++++++++++++
1 files changed, 144 insertions(+), 0 deletions(-)
@@ -16,11 +16,30 @@*alongwiththisprogram.Ifnot,see<http://www.gnu.org/licenses/>.*/+#include<linux/interrupt.h>+#include<linux/irqchip.h>#include<linux/module.h>+#include<linux/msi.h>+#include<linux/of_address.h>+#include<linux/of_irq.h>#include<linux/of_platform.h>#include<linux/platform_device.h>#include<linux/slab.h>+/* The maximum IRQ pin number of mbigen chip(start from 0) */+#define MAXIMUM_IRQ_PIN_NUM 640++/**+*Inmbigenvectorregister+*bit[31:16]:deviceid+*bit[15:0]:eventidvalue+*/+#define IRQ_EVENT_ID_MASK 0xffff++/* offset of vector register in mbigen node */+#define REG_MBIGEN_VEC_OFFSET 0x300+#define REG_MBIGEN_EXT_VEC_OFFSET 0x320+/***structmbigen_device-holdstheinformationofmbigendevice.*
@@ -32,10 +51,120 @@ struct mbigen_device {void__iomem*base;};+staticintget_mbigen_nid(unsignedintoffset)+{+intnid=0;++if(offset<256)+nid=offset/64;+elseif(offset<384)+nid=4;+elseif(offset<640)+nid=5;++returnnid;+}++staticinlineunsignedintget_mbigen_vec_reg(irq_hw_number_thwirq)+{+unsignedintnid;++nid=get_mbigen_nid(hwirq);++if(nid<4)+return(nid*4)+REG_MBIGEN_VEC_OFFSET;+else+return(nid-4)*4+REG_MBIGEN_EXT_VEC_OFFSET;+}++staticstructirq_chipmbigen_irq_chip={+.name="mbigen-v1",+};++staticvoidmbigen_write_msg(structmsi_desc*desc,structmsi_msg*msg)+{+structirq_data*d=irq_get_irq_data(desc->irq);+void__iomem*base=d->chip_data;+u32val;++base+=get_mbigen_vec_reg(d->hwirq);+val=readl_relaxed(base);++val&=~IRQ_EVENT_ID_MASK;+val|=msg->data;++/* The address of doorbell is encoded in mbigen register by default+*So,wedon'tneedtoprogramthedoorbelladdressathere+*/+writel_relaxed(val,base);+}++staticintmbigen_domain_translate(structirq_domain*d,+structirq_fwspec*fwspec,+unsignedlong*hwirq,+unsignedint*type)+{+if(is_of_node(fwspec->fwnode)){+if(fwspec->param_count!=2)+return-EINVAL;++if(fwspec->param[0]>MAXIMUM_IRQ_PIN_NUM)+return-EINVAL;++*hwirq=fwspec->param[0];++/* If there is no valid irq type, just use the default type */+if((fwspec->param[1]==IRQ_TYPE_EDGE_RISING)||+(fwspec->param[1]==IRQ_TYPE_LEVEL_HIGH))+*type=fwspec->param[1];+else+return-EINVAL;++return0;+}+return-EINVAL;+}++staticintmbigen_irq_domain_alloc(structirq_domain*domain,+unsignedintvirq,+unsignedintnr_irqs,+void*args)+{+structirq_fwspec*fwspec=args;+irq_hw_number_thwirq;+unsignedinttype;+structmbigen_device*mgn_chip;+inti,err;++err=mbigen_domain_translate(domain,fwspec,&hwirq,&type);+if(err)+returnerr;++err=platform_msi_domain_alloc(domain,virq,nr_irqs);+if(err)+returnerr;++mgn_chip=platform_msi_get_host_data(domain);++for(i=0;i<nr_irqs;i++)+irq_domain_set_hwirq_and_chip(domain,virq+i,hwirq+i,+&mbigen_irq_chip,mgn_chip->base);++return0;+}++staticstructirq_domain_opsmbigen_domain_ops={+.translate=mbigen_domain_translate,+.alloc=mbigen_irq_domain_alloc,+.free=irq_domain_free_irqs_common,+};+staticintmbigen_device_probe(structplatform_device*pdev){structmbigen_device*mgn_chip;structresource*res;+structirq_domain*domain;+u32num_pins;mgn_chip=devm_kzalloc(&pdev->dev,sizeof(*mgn_chip),GFP_KERNEL);if(!mgn_chip)
From: Ma Jun <redacted>
Add the interrupt controller chip operation functions of mbigen chip.
Signed-off-by: Ma Jun <redacted>
---
drivers/irqchip/irq-mbigen-v1.c | 75 +++++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 0 deletions(-)