1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2023 Cirrus Logic, Inc. and
3 // Cirrus Logic International Semiconductor Ltd.
5 #include <linux/device.h>
6 #include <linux/fwnode.h>
8 #include <linux/irqdomain.h>
9 #include <linux/soundwire/sdw.h>
12 static int sdw_irq_map(struct irq_domain
*h
, unsigned int virq
,
15 struct sdw_bus
*bus
= h
->host_data
;
17 irq_set_chip_data(virq
, bus
);
18 irq_set_chip(virq
, &bus
->irq_chip
);
19 irq_set_nested_thread(virq
, 1);
20 irq_set_noprobe(virq
);
25 static const struct irq_domain_ops sdw_domain_ops
= {
29 int sdw_irq_create(struct sdw_bus
*bus
,
30 struct fwnode_handle
*fwnode
)
32 bus
->irq_chip
.name
= dev_name(bus
->dev
);
34 bus
->domain
= irq_domain_create_linear(fwnode
, SDW_MAX_DEVICES
,
35 &sdw_domain_ops
, bus
);
37 dev_err(bus
->dev
, "Failed to add IRQ domain\n");
44 void sdw_irq_delete(struct sdw_bus
*bus
)
46 irq_domain_remove(bus
->domain
);
49 void sdw_irq_create_mapping(struct sdw_slave
*slave
)
51 slave
->irq
= irq_create_mapping(slave
->bus
->domain
, slave
->dev_num
);
53 dev_warn(&slave
->dev
, "Failed to map IRQ\n");
56 void sdw_irq_dispose_mapping(struct sdw_slave
*slave
)
58 irq_dispose_mapping(irq_find_mapping(slave
->bus
->domain
, slave
->dev_num
));