21
21
22
22
#define SG2042_MAX_MSI_VECTOR 32
23
23
24
- struct sg2042_msi_chipdata {
24
+ struct sg204x_msi_chipdata {
25
25
void __iomem * reg_clr ; // clear reg, see TRM, 10.1.33, GP_INTR0_CLR
26
26
27
27
phys_addr_t doorbell_addr ; // see TRM, 10.1.32, GP_INTR0_SET
@@ -33,7 +33,7 @@ struct sg2042_msi_chipdata {
33
33
struct mutex msi_map_lock ; // lock for msi_map
34
34
};
35
35
36
- static int sg2042_msi_allocate_hwirq (struct sg2042_msi_chipdata * data , int num_req )
36
+ static int sg204x_msi_allocate_hwirq (struct sg204x_msi_chipdata * data , int num_req )
37
37
{
38
38
int first ;
39
39
@@ -43,15 +43,15 @@ static int sg2042_msi_allocate_hwirq(struct sg2042_msi_chipdata *data, int num_r
43
43
return first >= 0 ? first : - ENOSPC ;
44
44
}
45
45
46
- static void sg2042_msi_free_hwirq (struct sg2042_msi_chipdata * data , int hwirq , int num_req )
46
+ static void sg204x_msi_free_hwirq (struct sg204x_msi_chipdata * data , int hwirq , int num_req )
47
47
{
48
48
guard (mutex )(& data -> msi_map_lock );
49
49
bitmap_release_region (data -> msi_map , hwirq , get_count_order (num_req ));
50
50
}
51
51
52
52
static void sg2042_msi_irq_ack (struct irq_data * d )
53
53
{
54
- struct sg2042_msi_chipdata * data = irq_data_get_irq_chip_data (d );
54
+ struct sg204x_msi_chipdata * data = irq_data_get_irq_chip_data (d );
55
55
int bit_off = d -> hwirq ;
56
56
57
57
writel (1 << bit_off , data -> reg_clr );
@@ -61,7 +61,7 @@ static void sg2042_msi_irq_ack(struct irq_data *d)
61
61
62
62
static void sg2042_msi_irq_compose_msi_msg (struct irq_data * d , struct msi_msg * msg )
63
63
{
64
- struct sg2042_msi_chipdata * data = irq_data_get_irq_chip_data (d );
64
+ struct sg204x_msi_chipdata * data = irq_data_get_irq_chip_data (d );
65
65
66
66
msg -> address_hi = upper_32_bits (data -> doorbell_addr );
67
67
msg -> address_lo = lower_32_bits (data -> doorbell_addr );
@@ -79,9 +79,9 @@ static const struct irq_chip sg2042_msi_middle_irq_chip = {
79
79
.irq_compose_msi_msg = sg2042_msi_irq_compose_msi_msg ,
80
80
};
81
81
82
- static int sg2042_msi_parent_domain_alloc (struct irq_domain * domain , unsigned int virq , int hwirq )
82
+ static int sg204x_msi_parent_domain_alloc (struct irq_domain * domain , unsigned int virq , int hwirq )
83
83
{
84
- struct sg2042_msi_chipdata * data = domain -> host_data ;
84
+ struct sg204x_msi_chipdata * data = domain -> host_data ;
85
85
struct irq_fwspec fwspec ;
86
86
struct irq_data * d ;
87
87
int ret ;
@@ -99,18 +99,18 @@ static int sg2042_msi_parent_domain_alloc(struct irq_domain *domain, unsigned in
99
99
return d -> chip -> irq_set_type (d , IRQ_TYPE_EDGE_RISING );
100
100
}
101
101
102
- static int sg2042_msi_middle_domain_alloc (struct irq_domain * domain , unsigned int virq ,
102
+ static int sg204x_msi_middle_domain_alloc (struct irq_domain * domain , unsigned int virq ,
103
103
unsigned int nr_irqs , void * args )
104
104
{
105
- struct sg2042_msi_chipdata * data = domain -> host_data ;
105
+ struct sg204x_msi_chipdata * data = domain -> host_data ;
106
106
int hwirq , err , i ;
107
107
108
- hwirq = sg2042_msi_allocate_hwirq (data , nr_irqs );
108
+ hwirq = sg204x_msi_allocate_hwirq (data , nr_irqs );
109
109
if (hwirq < 0 )
110
110
return hwirq ;
111
111
112
112
for (i = 0 ; i < nr_irqs ; i ++ ) {
113
- err = sg2042_msi_parent_domain_alloc (domain , virq + i , hwirq + i );
113
+ err = sg204x_msi_parent_domain_alloc (domain , virq + i , hwirq + i );
114
114
if (err )
115
115
goto err_hwirq ;
116
116
@@ -121,25 +121,25 @@ static int sg2042_msi_middle_domain_alloc(struct irq_domain *domain, unsigned in
121
121
return 0 ;
122
122
123
123
err_hwirq :
124
- sg2042_msi_free_hwirq (data , hwirq , nr_irqs );
124
+ sg204x_msi_free_hwirq (data , hwirq , nr_irqs );
125
125
irq_domain_free_irqs_parent (domain , virq , i );
126
126
127
127
return err ;
128
128
}
129
129
130
- static void sg2042_msi_middle_domain_free (struct irq_domain * domain , unsigned int virq ,
130
+ static void sg204x_msi_middle_domain_free (struct irq_domain * domain , unsigned int virq ,
131
131
unsigned int nr_irqs )
132
132
{
133
133
struct irq_data * d = irq_domain_get_irq_data (domain , virq );
134
- struct sg2042_msi_chipdata * data = irq_data_get_irq_chip_data (d );
134
+ struct sg204x_msi_chipdata * data = irq_data_get_irq_chip_data (d );
135
135
136
136
irq_domain_free_irqs_parent (domain , virq , nr_irqs );
137
- sg2042_msi_free_hwirq (data , d -> hwirq , nr_irqs );
137
+ sg204x_msi_free_hwirq (data , d -> hwirq , nr_irqs );
138
138
}
139
139
140
- static const struct irq_domain_ops sg2042_msi_middle_domain_ops = {
141
- .alloc = sg2042_msi_middle_domain_alloc ,
142
- .free = sg2042_msi_middle_domain_free ,
140
+ static const struct irq_domain_ops sg204x_msi_middle_domain_ops = {
141
+ .alloc = sg204x_msi_middle_domain_alloc ,
142
+ .free = sg204x_msi_middle_domain_free ,
143
143
.select = msi_lib_irq_domain_select ,
144
144
};
145
145
@@ -157,14 +157,14 @@ static const struct msi_parent_ops sg2042_msi_parent_ops = {
157
157
.init_dev_msi_info = msi_lib_init_dev_msi_info ,
158
158
};
159
159
160
- static int sg2042_msi_init_domains (struct sg2042_msi_chipdata * data ,
160
+ static int sg204x_msi_init_domains (struct sg204x_msi_chipdata * data ,
161
161
struct irq_domain * plic_domain , struct device * dev )
162
162
{
163
163
struct fwnode_handle * fwnode = dev_fwnode (dev );
164
164
struct irq_domain * middle_domain ;
165
165
166
166
middle_domain = irq_domain_create_hierarchy (plic_domain , 0 , data -> num_irqs , fwnode ,
167
- & sg2042_msi_middle_domain_ops , data );
167
+ & sg204x_msi_middle_domain_ops , data );
168
168
if (!middle_domain ) {
169
169
pr_err ("Failed to create the MSI middle domain\n" );
170
170
return - ENOMEM ;
@@ -181,13 +181,13 @@ static int sg2042_msi_init_domains(struct sg2042_msi_chipdata *data,
181
181
static int sg2042_msi_probe (struct platform_device * pdev )
182
182
{
183
183
struct fwnode_reference_args args = { };
184
- struct sg2042_msi_chipdata * data ;
184
+ struct sg204x_msi_chipdata * data ;
185
185
struct device * dev = & pdev -> dev ;
186
186
struct irq_domain * plic_domain ;
187
187
struct resource * res ;
188
188
int ret ;
189
189
190
- data = devm_kzalloc (dev , sizeof (struct sg2042_msi_chipdata ), GFP_KERNEL );
190
+ data = devm_kzalloc (dev , sizeof (struct sg204x_msi_chipdata ), GFP_KERNEL );
191
191
if (!data )
192
192
return - ENOMEM ;
193
193
@@ -231,7 +231,7 @@ static int sg2042_msi_probe(struct platform_device *pdev)
231
231
232
232
mutex_init (& data -> msi_map_lock );
233
233
234
- return sg2042_msi_init_domains (data , plic_domain , dev );
234
+ return sg204x_msi_init_domains (data , plic_domain , dev );
235
235
}
236
236
237
237
static const struct of_device_id sg2042_msi_of_match [] = {
0 commit comments