[PATCH 3/6] soc: ti: k3-ringacc: Separate soc specific initialization

Vignesh Raghavendra vigneshr at ti.com
Mon Jul 6 09:56:24 CEST 2020


In preparation of adding more K3 SoCs, separate soc specific
initialization add a SoC specific initialization hook.

Signed-off-by: Vignesh Raghavendra <vigneshr at ti.com>
---
 drivers/soc/ti/k3-navss-ringacc.c | 49 +++++++++++++++++++++++++------
 1 file changed, 40 insertions(+), 9 deletions(-)

diff --git a/drivers/soc/ti/k3-navss-ringacc.c b/drivers/soc/ti/k3-navss-ringacc.c
index 81de75af20..c48e9befe4 100644
--- a/drivers/soc/ti/k3-navss-ringacc.c
+++ b/drivers/soc/ti/k3-navss-ringacc.c
@@ -180,6 +180,10 @@ struct k3_nav_ring {
 	int		proxy_id;
 };
 
+struct k3_nav_ringacc_ops {
+	int (*init)(struct udevice *dev, struct k3_nav_ringacc *ringacc);
+};
+
 /**
  * struct k3_nav_ringacc - Rings accelerator descriptor
  *
@@ -195,6 +199,7 @@ struct k3_nav_ring {
  * @tisci - pointer ti-sci handle
  * @tisci_ring_ops - ti-sci rings ops
  * @tisci_dev_id - ti-sci device id
+ * @ops: SoC specific ringacc operation
  */
 struct k3_nav_ringacc {
 	struct udevice *dev;
@@ -213,6 +218,8 @@ struct k3_nav_ringacc {
 	const struct ti_sci_handle *tisci;
 	const struct ti_sci_rm_ringacc_ops *tisci_ring_ops;
 	u32  tisci_dev_id;
+
+	const struct k3_nav_ringacc_ops *ops;
 };
 
 static long k3_nav_ringacc_ring_get_fifo_pos(struct k3_nav_ring *ring)
@@ -1008,18 +1015,11 @@ static int k3_nav_ringacc_probe_dt(struct k3_nav_ringacc *ringacc)
 	return 0;
 }
 
-static int k3_nav_ringacc_probe(struct udevice *dev)
+static int k3_nav_ringacc_init(struct udevice *dev, struct k3_nav_ringacc *ringacc)
 {
-	struct k3_nav_ringacc *ringacc;
 	void __iomem *base_fifo, *base_rt;
 	int ret, i;
 
-	ringacc = dev_get_priv(dev);
-	if (!ringacc)
-		return -ENOMEM;
-
-	ringacc->dev = dev;
-
 	ret = k3_nav_ringacc_probe_dt(ringacc);
 	if (ret)
 		return ret;
@@ -1089,11 +1089,42 @@ static int k3_nav_ringacc_probe(struct udevice *dev)
 	return 0;
 }
 
+struct ringacc_match_data {
+	struct k3_nav_ringacc_ops ops;
+};
+
+static struct ringacc_match_data k3_nav_ringacc_data = {
+	.ops = {
+		.init = k3_nav_ringacc_init,
+	},
+};
+
 static const struct udevice_id knav_ringacc_ids[] = {
-	{ .compatible = "ti,am654-navss-ringacc" },
+	{ .compatible = "ti,am654-navss-ringacc", .data = (ulong)&k3_nav_ringacc_data, },
 	{},
 };
 
+static int k3_nav_ringacc_probe(struct udevice *dev)
+{
+	struct k3_nav_ringacc *ringacc;
+	int ret;
+	const struct ringacc_match_data *match_data;
+
+	match_data = (struct ringacc_match_data *)dev_get_driver_data(dev);
+
+	ringacc = dev_get_priv(dev);
+	if (!ringacc)
+		return -ENOMEM;
+
+	ringacc->dev = dev;
+	ringacc->ops = &match_data->ops;
+	ret = ringacc->ops->init(dev, ringacc);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 U_BOOT_DRIVER(k3_navss_ringacc) = {
 	.name	= "k3-navss-ringacc",
 	.id	= UCLASS_MISC,
-- 
2.27.0



More information about the U-Boot mailing list