xref: /linux/drivers/irqchip/irq-mbigen.c (revision 42b16d3ac371a2fac9b6f08fd75f23f34ba3955a)
1caab277bSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2717c3dbcSMa Jun /*
364ec2ad3SHao Fang  * Copyright (C) 2015 HiSilicon Limited, All Rights Reserved.
4717c3dbcSMa Jun  * Author: Jun Ma <majun258@huawei.com>
5717c3dbcSMa Jun  * Author: Yun Wu <wuyun.wu@huawei.com>
6717c3dbcSMa Jun  */
7717c3dbcSMa Jun 
8f907c515SHanjun Guo #include <linux/acpi.h>
99650c60eSMa Jun #include <linux/interrupt.h>
109650c60eSMa Jun #include <linux/irqchip.h>
11717c3dbcSMa Jun #include <linux/module.h>
129650c60eSMa Jun #include <linux/msi.h>
13717c3dbcSMa Jun #include <linux/of_address.h>
14717c3dbcSMa Jun #include <linux/of_irq.h>
15717c3dbcSMa Jun #include <linux/of_platform.h>
16717c3dbcSMa Jun #include <linux/platform_device.h>
17717c3dbcSMa Jun #include <linux/slab.h>
18717c3dbcSMa Jun 
199650c60eSMa Jun /* Interrupt numbers per mbigen node supported */
209650c60eSMa Jun #define IRQS_PER_MBIGEN_NODE		128
219650c60eSMa Jun 
229650c60eSMa Jun /* 64 irqs (Pin0-pin63) are reserved for each mbigen chip */
239650c60eSMa Jun #define RESERVED_IRQ_PER_MBIGEN_CHIP	64
249650c60eSMa Jun 
259650c60eSMa Jun /* The maximum IRQ pin number of mbigen chip(start from 0) */
269650c60eSMa Jun #define MAXIMUM_IRQ_PIN_NUM		1407
279650c60eSMa Jun 
28b9994883SRandy Dunlap /*
299650c60eSMa Jun  * In mbigen vector register
309650c60eSMa Jun  * bit[21:12]:	event id value
319650c60eSMa Jun  * bit[11:0]:	device id
329650c60eSMa Jun  */
339650c60eSMa Jun #define IRQ_EVENT_ID_SHIFT		12
349650c60eSMa Jun #define IRQ_EVENT_ID_MASK		0x3ff
359650c60eSMa Jun 
369650c60eSMa Jun /* register range of each mbigen node */
379650c60eSMa Jun #define MBIGEN_NODE_OFFSET		0x1000
389650c60eSMa Jun 
399650c60eSMa Jun /* offset of vector register in mbigen node */
409650c60eSMa Jun #define REG_MBIGEN_VEC_OFFSET		0x200
419650c60eSMa Jun 
42b9994883SRandy Dunlap /*
43a6c2f87bSMa Jun  * offset of clear register in mbigen node
44a6c2f87bSMa Jun  * This register is used to clear the status
45a6c2f87bSMa Jun  * of interrupt
46a6c2f87bSMa Jun  */
47a6c2f87bSMa Jun #define REG_MBIGEN_CLEAR_OFFSET		0xa000
48a6c2f87bSMa Jun 
49b9994883SRandy Dunlap /*
50a6c2f87bSMa Jun  * offset of interrupt type register
51a6c2f87bSMa Jun  * This register is used to configure interrupt
52a6c2f87bSMa Jun  * trigger type
53a6c2f87bSMa Jun  */
54a6c2f87bSMa Jun #define REG_MBIGEN_TYPE_OFFSET		0x0
55a6c2f87bSMa Jun 
56a6c2f87bSMa Jun /**
57717c3dbcSMa Jun  * struct mbigen_device - holds the information of mbigen device.
58717c3dbcSMa Jun  *
59717c3dbcSMa Jun  * @pdev:		pointer to the platform device structure of mbigen chip.
60717c3dbcSMa Jun  * @base:		mapped address of this mbigen chip.
61717c3dbcSMa Jun  */
62717c3dbcSMa Jun struct mbigen_device {
63717c3dbcSMa Jun 	struct platform_device	*pdev;
64717c3dbcSMa Jun 	void __iomem		*base;
65717c3dbcSMa Jun };
66717c3dbcSMa Jun 
get_mbigen_node_offset(unsigned int nid)67*6be6cba9SYipeng Zou static inline unsigned int get_mbigen_node_offset(unsigned int nid)
68*6be6cba9SYipeng Zou {
69*6be6cba9SYipeng Zou 	unsigned int offset = nid * MBIGEN_NODE_OFFSET;
70*6be6cba9SYipeng Zou 
71*6be6cba9SYipeng Zou 	/*
72*6be6cba9SYipeng Zou 	 * To avoid touched clear register in unexpected way, we need to directly
73*6be6cba9SYipeng Zou 	 * skip clear register when access to more than 10 mbigen nodes.
74*6be6cba9SYipeng Zou 	 */
75*6be6cba9SYipeng Zou 	if (nid >= (REG_MBIGEN_CLEAR_OFFSET / MBIGEN_NODE_OFFSET))
76*6be6cba9SYipeng Zou 		offset += MBIGEN_NODE_OFFSET;
77*6be6cba9SYipeng Zou 
78*6be6cba9SYipeng Zou 	return offset;
79*6be6cba9SYipeng Zou }
80*6be6cba9SYipeng Zou 
get_mbigen_vec_reg(irq_hw_number_t hwirq)819650c60eSMa Jun static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq)
829650c60eSMa Jun {
839650c60eSMa Jun 	unsigned int nid, pin;
849650c60eSMa Jun 
859650c60eSMa Jun 	hwirq -= RESERVED_IRQ_PER_MBIGEN_CHIP;
869650c60eSMa Jun 	nid = hwirq / IRQS_PER_MBIGEN_NODE + 1;
879650c60eSMa Jun 	pin = hwirq % IRQS_PER_MBIGEN_NODE;
889650c60eSMa Jun 
89*6be6cba9SYipeng Zou 	return pin * 4 + get_mbigen_node_offset(nid) + REG_MBIGEN_VEC_OFFSET;
909650c60eSMa Jun }
919650c60eSMa Jun 
get_mbigen_type_reg(irq_hw_number_t hwirq,u32 * mask,u32 * addr)92a6c2f87bSMa Jun static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
93a6c2f87bSMa Jun 					u32 *mask, u32 *addr)
94a6c2f87bSMa Jun {
95a6c2f87bSMa Jun 	unsigned int nid, irq_ofst, ofst;
96a6c2f87bSMa Jun 
97a6c2f87bSMa Jun 	hwirq -= RESERVED_IRQ_PER_MBIGEN_CHIP;
98a6c2f87bSMa Jun 	nid = hwirq / IRQS_PER_MBIGEN_NODE + 1;
99a6c2f87bSMa Jun 	irq_ofst = hwirq % IRQS_PER_MBIGEN_NODE;
100a6c2f87bSMa Jun 
101a6c2f87bSMa Jun 	*mask = 1 << (irq_ofst % 32);
102a6c2f87bSMa Jun 	ofst = irq_ofst / 32 * 4;
103a6c2f87bSMa Jun 
104*6be6cba9SYipeng Zou 	*addr = ofst + get_mbigen_node_offset(nid) + REG_MBIGEN_TYPE_OFFSET;
105a6c2f87bSMa Jun }
106a6c2f87bSMa Jun 
get_mbigen_clear_reg(irq_hw_number_t hwirq,u32 * mask,u32 * addr)107a6c2f87bSMa Jun static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq,
108a6c2f87bSMa Jun 					u32 *mask, u32 *addr)
109a6c2f87bSMa Jun {
1109459a04bSMaJun 	unsigned int ofst = (hwirq / 32) * 4;
111a6c2f87bSMa Jun 
112a6c2f87bSMa Jun 	*mask = 1 << (hwirq % 32);
113a6c2f87bSMa Jun 	*addr = ofst + REG_MBIGEN_CLEAR_OFFSET;
114a6c2f87bSMa Jun }
115a6c2f87bSMa Jun 
mbigen_eoi_irq(struct irq_data * data)116a6c2f87bSMa Jun static void mbigen_eoi_irq(struct irq_data *data)
117a6c2f87bSMa Jun {
118a6c2f87bSMa Jun 	void __iomem *base = data->chip_data;
119a6c2f87bSMa Jun 	u32 mask, addr;
120a6c2f87bSMa Jun 
121a6c2f87bSMa Jun 	get_mbigen_clear_reg(data->hwirq, &mask, &addr);
122a6c2f87bSMa Jun 
123a6c2f87bSMa Jun 	writel_relaxed(mask, base + addr);
124a6c2f87bSMa Jun 
125a6c2f87bSMa Jun 	irq_chip_eoi_parent(data);
126a6c2f87bSMa Jun }
127a6c2f87bSMa Jun 
mbigen_set_type(struct irq_data * data,unsigned int type)128a6c2f87bSMa Jun static int mbigen_set_type(struct irq_data *data, unsigned int type)
129a6c2f87bSMa Jun {
130a6c2f87bSMa Jun 	void __iomem *base = data->chip_data;
131a6c2f87bSMa Jun 	u32 mask, addr, val;
132a6c2f87bSMa Jun 
133a6c2f87bSMa Jun 	if (type != IRQ_TYPE_LEVEL_HIGH && type != IRQ_TYPE_EDGE_RISING)
134a6c2f87bSMa Jun 		return -EINVAL;
135a6c2f87bSMa Jun 
136a6c2f87bSMa Jun 	get_mbigen_type_reg(data->hwirq, &mask, &addr);
137a6c2f87bSMa Jun 
138a6c2f87bSMa Jun 	val = readl_relaxed(base + addr);
139a6c2f87bSMa Jun 
140a6c2f87bSMa Jun 	if (type == IRQ_TYPE_LEVEL_HIGH)
141a6c2f87bSMa Jun 		val |= mask;
142a6c2f87bSMa Jun 	else
143a6c2f87bSMa Jun 		val &= ~mask;
144a6c2f87bSMa Jun 
145a6c2f87bSMa Jun 	writel_relaxed(val, base + addr);
146a6c2f87bSMa Jun 
147a6c2f87bSMa Jun 	return 0;
148a6c2f87bSMa Jun }
149a6c2f87bSMa Jun 
mbigen_write_msi_msg(struct irq_data * d,struct msi_msg * msg)150fbfe7e13SThomas Gleixner static void mbigen_write_msi_msg(struct irq_data *d, struct msi_msg *msg)
1519650c60eSMa Jun {
1529650c60eSMa Jun 	void __iomem *base = d->chip_data;
1539650c60eSMa Jun 	u32 val;
1549650c60eSMa Jun 
155fca269f2SJianguo Chen 	if (!msg->address_lo && !msg->address_hi)
156fca269f2SJianguo Chen 		return;
157fca269f2SJianguo Chen 
1589650c60eSMa Jun 	base += get_mbigen_vec_reg(d->hwirq);
1599650c60eSMa Jun 	val = readl_relaxed(base);
1609650c60eSMa Jun 
1619650c60eSMa Jun 	val &= ~(IRQ_EVENT_ID_MASK << IRQ_EVENT_ID_SHIFT);
1629650c60eSMa Jun 	val |= (msg->data << IRQ_EVENT_ID_SHIFT);
1639650c60eSMa Jun 
1649650c60eSMa Jun 	/* The address of doorbell is encoded in mbigen register by default
1659650c60eSMa Jun 	 * So,we don't need to program the doorbell address at here
1669650c60eSMa Jun 	 */
1679650c60eSMa Jun 	writel_relaxed(val, base);
1689650c60eSMa Jun }
1699650c60eSMa Jun 
mbigen_domain_translate(struct irq_domain * d,struct irq_fwspec * fwspec,unsigned long * hwirq,unsigned int * type)170fbfe7e13SThomas Gleixner static int mbigen_domain_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
171fbfe7e13SThomas Gleixner 				   unsigned long *hwirq, unsigned int *type)
1729650c60eSMa Jun {
173f907c515SHanjun Guo 	if (is_of_node(fwspec->fwnode) || is_acpi_device_node(fwspec->fwnode)) {
1749650c60eSMa Jun 		if (fwspec->param_count != 2)
1759650c60eSMa Jun 			return -EINVAL;
1769650c60eSMa Jun 
1779650c60eSMa Jun 		if ((fwspec->param[0] > MAXIMUM_IRQ_PIN_NUM) ||
1789650c60eSMa Jun 			(fwspec->param[0] < RESERVED_IRQ_PER_MBIGEN_CHIP))
1799650c60eSMa Jun 			return -EINVAL;
1809650c60eSMa Jun 		else
1819650c60eSMa Jun 			*hwirq = fwspec->param[0];
1829650c60eSMa Jun 
1839650c60eSMa Jun 		/* If there is no valid irq type, just use the default type */
1849650c60eSMa Jun 		if ((fwspec->param[1] == IRQ_TYPE_EDGE_RISING) ||
1859650c60eSMa Jun 			(fwspec->param[1] == IRQ_TYPE_LEVEL_HIGH))
1869650c60eSMa Jun 			*type = fwspec->param[1];
1879650c60eSMa Jun 		else
1889650c60eSMa Jun 			return -EINVAL;
1899650c60eSMa Jun 
1909650c60eSMa Jun 		return 0;
1919650c60eSMa Jun 	}
1929650c60eSMa Jun 	return -EINVAL;
1939650c60eSMa Jun }
1949650c60eSMa Jun 
mbigen_domain_set_desc(msi_alloc_info_t * arg,struct msi_desc * desc)195fbfe7e13SThomas Gleixner static void mbigen_domain_set_desc(msi_alloc_info_t *arg, struct msi_desc *desc)
196fbfe7e13SThomas Gleixner {
197fbfe7e13SThomas Gleixner 	arg->desc = desc;
198fbfe7e13SThomas Gleixner 	arg->hwirq = (u32)desc->data.icookie.value;
199fbfe7e13SThomas Gleixner }
200fbfe7e13SThomas Gleixner 
201fbfe7e13SThomas Gleixner static const struct msi_domain_template mbigen_msi_template = {
202fbfe7e13SThomas Gleixner 	.chip = {
203fbfe7e13SThomas Gleixner 		.name			= "mbigen-v2",
204fbfe7e13SThomas Gleixner 		.irq_mask		= irq_chip_mask_parent,
205fbfe7e13SThomas Gleixner 		.irq_unmask		= irq_chip_unmask_parent,
206fbfe7e13SThomas Gleixner 		.irq_eoi		= mbigen_eoi_irq,
207fbfe7e13SThomas Gleixner 		.irq_set_type		= mbigen_set_type,
208fbfe7e13SThomas Gleixner 		.irq_write_msi_msg	= mbigen_write_msi_msg,
209fbfe7e13SThomas Gleixner 	},
210fbfe7e13SThomas Gleixner 
211fbfe7e13SThomas Gleixner 	.ops = {
212fbfe7e13SThomas Gleixner 		.set_desc		= mbigen_domain_set_desc,
213fbfe7e13SThomas Gleixner 		.msi_translate		= mbigen_domain_translate,
214fbfe7e13SThomas Gleixner 	},
215fbfe7e13SThomas Gleixner 
216fbfe7e13SThomas Gleixner 	.info = {
217fbfe7e13SThomas Gleixner 		.bus_token		= DOMAIN_BUS_WIRED_TO_MSI,
218fbfe7e13SThomas Gleixner 		.flags			= MSI_FLAG_USE_DEV_FWNODE,
219fbfe7e13SThomas Gleixner 	},
220fbfe7e13SThomas Gleixner };
221fbfe7e13SThomas Gleixner 
mbigen_create_device_domain(struct device * dev,unsigned int size,struct mbigen_device * mgn_chip)222fbfe7e13SThomas Gleixner static bool mbigen_create_device_domain(struct device *dev, unsigned int size,
223fbfe7e13SThomas Gleixner 					struct mbigen_device *mgn_chip)
224fbfe7e13SThomas Gleixner {
225752e021fSThomas Gleixner 	if (WARN_ON_ONCE(!dev->msi.domain))
226fbfe7e13SThomas Gleixner 		return false;
227fbfe7e13SThomas Gleixner 
228fbfe7e13SThomas Gleixner 	return msi_create_device_irq_domain(dev, MSI_DEFAULT_DOMAIN,
229fbfe7e13SThomas Gleixner 					    &mbigen_msi_template, size,
230fbfe7e13SThomas Gleixner 					    NULL, mgn_chip->base);
231fbfe7e13SThomas Gleixner }
232fbfe7e13SThomas Gleixner 
mbigen_of_create_domain(struct platform_device * pdev,struct mbigen_device * mgn_chip)23376e1f77fSKefeng Wang static int mbigen_of_create_domain(struct platform_device *pdev,
23476e1f77fSKefeng Wang 				   struct mbigen_device *mgn_chip)
235717c3dbcSMa Jun {
236ed2a1002SMaJun 	struct platform_device *child;
237ed2a1002SMaJun 	u32 num_pins;
2389650c60eSMa Jun 
239cddb536aSKefeng Wang 	for_each_child_of_node_scoped(pdev->dev.of_node, np) {
240cddb536aSKefeng Wang 		if (!of_property_read_bool(np, "interrupt-controller"))
241ed2a1002SMaJun 			continue;
242ed2a1002SMaJun 
243ed2a1002SMaJun 		child = of_platform_device_create(np, NULL, NULL);
244ed2a1002SMaJun 		if (!child)
245fb33a46cSChen Jun 			return -ENOMEM;
246321275f0SNishka Dasgupta 
247cddb536aSKefeng Wang 		if (of_property_read_u32(child->dev.of_node, "num-pins",
248cddb536aSKefeng Wang 					 &num_pins) < 0) {
249fea087fcSGreg Kroah-Hartman 			dev_err(&pdev->dev, "No num-pins property\n");
250ed2a1002SMaJun 			return -EINVAL;
251ed2a1002SMaJun 		}
252ed2a1002SMaJun 
2539650c60eSMa Jun 		if (!mbigen_create_device_domain(&child->dev, num_pins, mgn_chip))
254cddb536aSKefeng Wang 			return -ENOMEM;
255cddb536aSKefeng Wang 	}
2569650c60eSMa Jun 
2579650c60eSMa Jun 	return 0;
258fbfe7e13SThomas Gleixner }
259cddb536aSKefeng Wang 
260cddb536aSKefeng Wang #ifdef CONFIG_ACPI
261ed2a1002SMaJun static const struct acpi_device_id mbigen_acpi_match[] = {
262321275f0SNishka Dasgupta 	{ "HISI0152", 0 },
2639650c60eSMa Jun 	{}
264cddb536aSKefeng Wang };
265cddb536aSKefeng Wang MODULE_DEVICE_TABLE(acpi, mbigen_acpi_match);
266cddb536aSKefeng Wang 
mbigen_acpi_create_domain(struct platform_device * pdev,struct mbigen_device * mgn_chip)267cddb536aSKefeng Wang static int mbigen_acpi_create_domain(struct platform_device *pdev,
26876e1f77fSKefeng Wang 				     struct mbigen_device *mgn_chip)
26976e1f77fSKefeng Wang {
270f907c515SHanjun Guo 	u32 num_pins = 0;
271c96d6abbSYang Yingliang 	int ret;
272c96d6abbSYang Yingliang 
273c96d6abbSYang Yingliang 	/*
274c96d6abbSYang Yingliang 	 * "num-pins" is the total number of interrupt pins implemented in
275c96d6abbSYang Yingliang 	 * this mbigen instance, and mbigen is an interrupt controller
276c96d6abbSYang Yingliang 	 * connected to ITS  converting wired interrupts into MSI, so we
277f907c515SHanjun Guo 	 * use "num-pins" to alloc MSI vectors which are needed by client
278f907c515SHanjun Guo 	 * devices connected to it.
279f907c515SHanjun Guo 	 *
280f907c515SHanjun Guo 	 * Here is the DSDT device node used for mbigen in firmware:
281f907c515SHanjun Guo 	 *	Device(MBI0) {
282f907c515SHanjun Guo 	 *		Name(_HID, "HISI0152")
283f907c515SHanjun Guo 	 *		Name(_UID, Zero)
284f907c515SHanjun Guo 	 *		Name(_CRS, ResourceTemplate() {
285f907c515SHanjun Guo 	 *			Memory32Fixed(ReadWrite, 0xa0080000, 0x10000)
286f907c515SHanjun Guo 	 *		})
287f907c515SHanjun Guo 	 *
288f907c515SHanjun Guo 	 *		Name(_DSD, Package () {
289f907c515SHanjun Guo 	 *			ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
290f907c515SHanjun Guo 	 *			Package () {
291f907c515SHanjun Guo 	 *				Package () {"num-pins", 378}
292f907c515SHanjun Guo 	 *			}
293f907c515SHanjun Guo 	 *		})
294f907c515SHanjun Guo 	 *	}
295f907c515SHanjun Guo 	 */
296f907c515SHanjun Guo 	ret = device_property_read_u32(&pdev->dev, "num-pins", &num_pins);
297f907c515SHanjun Guo 	if (ret || num_pins == 0)
298f907c515SHanjun Guo 		return -EINVAL;
299f907c515SHanjun Guo 
300f907c515SHanjun Guo 	if (!mbigen_create_device_domain(&pdev->dev, num_pins, mgn_chip))
301f907c515SHanjun Guo 		return -ENOMEM;
302f907c515SHanjun Guo 
303f907c515SHanjun Guo 	return 0;
304f907c515SHanjun Guo }
305f907c515SHanjun Guo #else
mbigen_acpi_create_domain(struct platform_device * pdev,struct mbigen_device * mgn_chip)306f907c515SHanjun Guo static inline int mbigen_acpi_create_domain(struct platform_device *pdev,
307f907c515SHanjun Guo 					    struct mbigen_device *mgn_chip)
308f907c515SHanjun Guo {
309f907c515SHanjun Guo 	return -ENODEV;
310fbfe7e13SThomas Gleixner }
311f907c515SHanjun Guo #endif
312f907c515SHanjun Guo 
mbigen_device_probe(struct platform_device * pdev)313f907c515SHanjun Guo static int mbigen_device_probe(struct platform_device *pdev)
314f907c515SHanjun Guo {
315f907c515SHanjun Guo 	struct mbigen_device *mgn_chip;
316f907c515SHanjun Guo 	struct resource *res;
317f907c515SHanjun Guo 	int err;
318f907c515SHanjun Guo 
319f907c515SHanjun Guo 	mgn_chip = devm_kzalloc(&pdev->dev, sizeof(*mgn_chip), GFP_KERNEL);
320f907c515SHanjun Guo 	if (!mgn_chip)
321f907c515SHanjun Guo 		return -ENOMEM;
322f907c515SHanjun Guo 
32376e1f77fSKefeng Wang 	mgn_chip->pdev = pdev;
32476e1f77fSKefeng Wang 
32576e1f77fSKefeng Wang 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
32676e1f77fSKefeng Wang 	if (!res)
32776e1f77fSKefeng Wang 		return -EINVAL;
32876e1f77fSKefeng Wang 
32976e1f77fSKefeng Wang 	mgn_chip->base = devm_ioremap(&pdev->dev, res->start,
33076e1f77fSKefeng Wang 				      resource_size(res));
33176e1f77fSKefeng Wang 	if (!mgn_chip->base) {
33276e1f77fSKefeng Wang 		dev_err(&pdev->dev, "failed to ioremap %pR\n", res);
33376e1f77fSKefeng Wang 		return -ENOMEM;
33476e1f77fSKefeng Wang 	}
33576e1f77fSKefeng Wang 
336ad7cc3c0SHanjun Guo 	if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node)
337ad7cc3c0SHanjun Guo 		err = mbigen_of_create_domain(pdev, mgn_chip);
338ad7cc3c0SHanjun Guo 	else if (ACPI_COMPANION(&pdev->dev))
3395ba9b0a1SHanjun Guo 		err = mbigen_acpi_create_domain(pdev, mgn_chip);
3405ba9b0a1SHanjun Guo 	else
3415ba9b0a1SHanjun Guo 		err = -EINVAL;
3425ba9b0a1SHanjun Guo 
3435ba9b0a1SHanjun Guo 	if (err) {
3445ba9b0a1SHanjun Guo 		dev_err(&pdev->dev, "Failed to create mbi-gen irqdomain\n");
34576e1f77fSKefeng Wang 		return err;
346f907c515SHanjun Guo 	}
34776e1f77fSKefeng Wang 
348f907c515SHanjun Guo 	platform_set_drvdata(pdev, mgn_chip);
349f907c515SHanjun Guo 	return 0;
350f907c515SHanjun Guo }
351f907c515SHanjun Guo 
352f907c515SHanjun Guo static const struct of_device_id mbigen_of_match[] = {
353f907c515SHanjun Guo 	{ .compatible = "hisilicon,mbigen-v2" },
3540bdd0047SKefeng Wang 	{ /* END */ }
35576e1f77fSKefeng Wang };
356f907c515SHanjun Guo MODULE_DEVICE_TABLE(of, mbigen_of_match);
35776e1f77fSKefeng Wang 
358717c3dbcSMa Jun static struct platform_driver mbigen_platform_driver = {
359717c3dbcSMa Jun 	.driver = {
360717c3dbcSMa Jun 		.name		= "Hisilicon MBIGEN-V2",
361717c3dbcSMa Jun 		.of_match_table	= mbigen_of_match,
362717c3dbcSMa Jun 		.acpi_match_table = ACPI_PTR(mbigen_acpi_match),
363717c3dbcSMa Jun 		.suppress_bind_attrs = true,
364717c3dbcSMa Jun 	},
365717c3dbcSMa Jun 	.probe			= mbigen_device_probe,
366717c3dbcSMa Jun };
367717c3dbcSMa Jun 
368717c3dbcSMa Jun module_platform_driver(mbigen_platform_driver);
369717c3dbcSMa Jun 
370717c3dbcSMa Jun MODULE_AUTHOR("Jun Ma <majun258@huawei.com>");
371717c3dbcSMa Jun MODULE_AUTHOR("Yun Wu <wuyun.wu@huawei.com>");
372f907c515SHanjun Guo MODULE_DESCRIPTION("HiSilicon MBI Generator driver");
373d6152e6eSJohn Garry