@@ -161,6 +161,10 @@ struct k3_ring {
161
161
int proxy_id ;
162
162
};
163
163
164
+ struct k3_ringacc_ops {
165
+ int (* init )(struct platform_device * pdev , struct k3_ringacc * ringacc );
166
+ };
167
+
164
168
/**
165
169
* struct k3_ringacc - Rings accelerator descriptor
166
170
*
@@ -179,6 +183,7 @@ struct k3_ring {
179
183
* @tisci: pointer ti-sci handle
180
184
* @tisci_ring_ops: ti-sci rings ops
181
185
* @tisci_dev_id: ti-sci device id
186
+ * @ops: SoC specific ringacc operation
182
187
*/
183
188
struct k3_ringacc {
184
189
struct device * dev ;
@@ -199,6 +204,8 @@ struct k3_ringacc {
199
204
const struct ti_sci_handle * tisci ;
200
205
const struct ti_sci_rm_ringacc_ops * tisci_ring_ops ;
201
206
u32 tisci_dev_id ;
207
+
208
+ const struct k3_ringacc_ops * ops ;
202
209
};
203
210
204
211
static long k3_ringacc_ring_get_fifo_pos (struct k3_ring * ring )
@@ -1075,21 +1082,14 @@ static int k3_ringacc_probe_dt(struct k3_ringacc *ringacc)
1075
1082
ringacc -> rm_gp_range );
1076
1083
}
1077
1084
1078
- static int k3_ringacc_probe (struct platform_device * pdev )
1085
+ static int k3_ringacc_init (struct platform_device * pdev ,
1086
+ struct k3_ringacc * ringacc )
1079
1087
{
1080
- struct k3_ringacc * ringacc ;
1081
1088
void __iomem * base_fifo , * base_rt ;
1082
1089
struct device * dev = & pdev -> dev ;
1083
1090
struct resource * res ;
1084
1091
int ret , i ;
1085
1092
1086
- ringacc = devm_kzalloc (dev , sizeof (* ringacc ), GFP_KERNEL );
1087
- if (!ringacc )
1088
- return - ENOMEM ;
1089
-
1090
- ringacc -> dev = dev ;
1091
- mutex_init (& ringacc -> req_lock );
1092
-
1093
1093
dev -> msi_domain = of_msi_get_domain (dev , dev -> of_node ,
1094
1094
DOMAIN_BUS_TI_SCI_INTA_MSI );
1095
1095
if (!dev -> msi_domain ) {
@@ -1148,14 +1148,9 @@ static int k3_ringacc_probe(struct platform_device *pdev)
1148
1148
ringacc -> rings [i ].ring_id = i ;
1149
1149
ringacc -> rings [i ].proxy_id = K3_RINGACC_PROXY_NOT_USED ;
1150
1150
}
1151
- dev_set_drvdata (dev , ringacc );
1152
1151
1153
1152
ringacc -> tisci_ring_ops = & ringacc -> tisci -> ops .rm_ring_ops ;
1154
1153
1155
- mutex_lock (& k3_ringacc_list_lock );
1156
- list_add_tail (& ringacc -> list , & k3_ringacc_list );
1157
- mutex_unlock (& k3_ringacc_list_lock );
1158
-
1159
1154
dev_info (dev , "Ring Accelerator probed rings:%u, gp-rings[%u,%u] sci-dev-id:%u\n" ,
1160
1155
ringacc -> num_rings ,
1161
1156
ringacc -> rm_gp_range -> desc [0 ].start ,
@@ -1165,15 +1160,60 @@ static int k3_ringacc_probe(struct platform_device *pdev)
1165
1160
ringacc -> dma_ring_reset_quirk ? "enabled" : "disabled" );
1166
1161
dev_info (dev , "RA Proxy rev. %08x, num_proxies:%u\n" ,
1167
1162
readl (& ringacc -> proxy_gcfg -> revision ), ringacc -> num_proxies );
1163
+
1168
1164
return 0 ;
1169
1165
}
1170
1166
1167
+ struct ringacc_match_data {
1168
+ struct k3_ringacc_ops ops ;
1169
+ };
1170
+
1171
+ static struct ringacc_match_data k3_ringacc_data = {
1172
+ .ops = {
1173
+ .init = k3_ringacc_init ,
1174
+ },
1175
+ };
1176
+
1171
1177
/* Match table for of_platform binding */
1172
1178
static const struct of_device_id k3_ringacc_of_match [] = {
1173
- { .compatible = "ti,am654-navss-ringacc" , },
1179
+ { .compatible = "ti,am654-navss-ringacc" , . data = & k3_ringacc_data , },
1174
1180
{},
1175
1181
};
1176
1182
1183
+ static int k3_ringacc_probe (struct platform_device * pdev )
1184
+ {
1185
+ const struct ringacc_match_data * match_data ;
1186
+ const struct of_device_id * match ;
1187
+ struct device * dev = & pdev -> dev ;
1188
+ struct k3_ringacc * ringacc ;
1189
+ int ret ;
1190
+
1191
+ match = of_match_node (k3_ringacc_of_match , dev -> of_node );
1192
+ if (!match )
1193
+ return - ENODEV ;
1194
+ match_data = match -> data ;
1195
+
1196
+ ringacc = devm_kzalloc (dev , sizeof (* ringacc ), GFP_KERNEL );
1197
+ if (!ringacc )
1198
+ return - ENOMEM ;
1199
+
1200
+ ringacc -> dev = dev ;
1201
+ mutex_init (& ringacc -> req_lock );
1202
+ ringacc -> ops = & match_data -> ops ;
1203
+
1204
+ ret = ringacc -> ops -> init (pdev , ringacc );
1205
+ if (ret )
1206
+ return ret ;
1207
+
1208
+ dev_set_drvdata (dev , ringacc );
1209
+
1210
+ mutex_lock (& k3_ringacc_list_lock );
1211
+ list_add_tail (& ringacc -> list , & k3_ringacc_list );
1212
+ mutex_unlock (& k3_ringacc_list_lock );
1213
+
1214
+ return 0 ;
1215
+ }
1216
+
1177
1217
static struct platform_driver k3_ringacc_driver = {
1178
1218
.probe = k3_ringacc_probe ,
1179
1219
.driver = {
0 commit comments