Skip to content

Commit 40a2a7c

Browse files
grygoriySSantoshShilimkar
authored andcommitted
soc: ti: k3-ringacc: separate soc specific initialization
Separate SoC specific initialization and and OF mach data in preparation of adding support for more K3 SoCs Signed-off-by: Grygorii Strashko <[email protected]> Reviewed-by: Peter Ujfalusi <[email protected]> Signed-off-by: Santosh Shilimkar <[email protected]>
1 parent 43148b1 commit 40a2a7c

File tree

1 file changed

+55
-15
lines changed

1 file changed

+55
-15
lines changed

drivers/soc/ti/k3-ringacc.c

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ struct k3_ring {
161161
int proxy_id;
162162
};
163163

164+
struct k3_ringacc_ops {
165+
int (*init)(struct platform_device *pdev, struct k3_ringacc *ringacc);
166+
};
167+
164168
/**
165169
* struct k3_ringacc - Rings accelerator descriptor
166170
*
@@ -179,6 +183,7 @@ struct k3_ring {
179183
* @tisci: pointer ti-sci handle
180184
* @tisci_ring_ops: ti-sci rings ops
181185
* @tisci_dev_id: ti-sci device id
186+
* @ops: SoC specific ringacc operation
182187
*/
183188
struct k3_ringacc {
184189
struct device *dev;
@@ -199,6 +204,8 @@ struct k3_ringacc {
199204
const struct ti_sci_handle *tisci;
200205
const struct ti_sci_rm_ringacc_ops *tisci_ring_ops;
201206
u32 tisci_dev_id;
207+
208+
const struct k3_ringacc_ops *ops;
202209
};
203210

204211
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)
10751082
ringacc->rm_gp_range);
10761083
}
10771084

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)
10791087
{
1080-
struct k3_ringacc *ringacc;
10811088
void __iomem *base_fifo, *base_rt;
10821089
struct device *dev = &pdev->dev;
10831090
struct resource *res;
10841091
int ret, i;
10851092

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-
10931093
dev->msi_domain = of_msi_get_domain(dev, dev->of_node,
10941094
DOMAIN_BUS_TI_SCI_INTA_MSI);
10951095
if (!dev->msi_domain) {
@@ -1148,14 +1148,9 @@ static int k3_ringacc_probe(struct platform_device *pdev)
11481148
ringacc->rings[i].ring_id = i;
11491149
ringacc->rings[i].proxy_id = K3_RINGACC_PROXY_NOT_USED;
11501150
}
1151-
dev_set_drvdata(dev, ringacc);
11521151

11531152
ringacc->tisci_ring_ops = &ringacc->tisci->ops.rm_ring_ops;
11541153

1155-
mutex_lock(&k3_ringacc_list_lock);
1156-
list_add_tail(&ringacc->list, &k3_ringacc_list);
1157-
mutex_unlock(&k3_ringacc_list_lock);
1158-
11591154
dev_info(dev, "Ring Accelerator probed rings:%u, gp-rings[%u,%u] sci-dev-id:%u\n",
11601155
ringacc->num_rings,
11611156
ringacc->rm_gp_range->desc[0].start,
@@ -1165,15 +1160,60 @@ static int k3_ringacc_probe(struct platform_device *pdev)
11651160
ringacc->dma_ring_reset_quirk ? "enabled" : "disabled");
11661161
dev_info(dev, "RA Proxy rev. %08x, num_proxies:%u\n",
11671162
readl(&ringacc->proxy_gcfg->revision), ringacc->num_proxies);
1163+
11681164
return 0;
11691165
}
11701166

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+
11711177
/* Match table for of_platform binding */
11721178
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, },
11741180
{},
11751181
};
11761182

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+
11771217
static struct platform_driver k3_ringacc_driver = {
11781218
.probe = k3_ringacc_probe,
11791219
.driver = {

0 commit comments

Comments
 (0)