Skip to contentSkip to conversation

Add xhci-exynos for Exynos SOC

PATCH In review Daehwan Jung 4 participants 11 messages May 6, 2022 – May 9, 2022 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20220506063316epcas2p197ed75070ed4f4ba29439f5c0def90b4@epcas2p1.samsung.com

#1 lore raw

v5 cover Add xhci-exynos for Exynos SOC

This patchset is for Samsung Exynos xHCI host conroller. It uses xhci platform driver and extends some functions by xhci hooks and overrides.

This driver supports USB offload which makes Co-processor to use some memories of xhci. Especially it's useful for USB Audio scenario. Audio stream would get shortcut because Co-processor directly write/read data in xhci memories. It could get speed-up using faster memory like SRAM. That's why this gives vendors flexibilty of memory management. This feature is done with xhci hooks and overrides.

It supports USB offload only for first connected device. It follows normal sequence from 2nd device.

Changes in v2 :
- Fix commit message by adding Signed-off-by in each patch.
- Fix conflict on latest.

Changes in v3 :
- Remove export symbols and xhci hooks which xhci-exynos don't need.
- Modify commit message to clarify why it needs to export symbols.
- Check compiling of xhci-exynos.

Changes in v4 :
- Modify commit message to clarify why it needs to export symbols.
- Add a function for override of hc driver in xhci-plat.
- Make xhci-exynos extending xhci-plat by xhci hooks and overrides. (vendor_init / vendor_cleanup hooks are useful from here v4)
- Change the term (USB offload -> xhci-exynos) on subject of patches.

Changes in v5 :
- Rename subject of cover-letter.
- Add code in xhci_alloc_segments_for_uram.
- Add code for supporting several devices.
- Move adding xhci_address_device to other commit. (usb: host: add some to xhci overrides for xhci-exynos

    -> usb: host: export symbols for xhci-exynos to use xhci hooks)

- Add new commit (usb: dwc3: dwc3-exynos: add host init)

Daehwan Jung (6):
usb: host: export symbols for xhci-exynos to use xhci hooks
usb: host: add xhci hooks for xhci-exynos
usb: host: xhci-plat: support override of hc driver
usb: host: add some to xhci overrides for xhci-exynos
usb: host: add xhci-exynos driver
usb: dwc3: dwc3-exynos: add host init

 drivers/usb/dwc3/dwc3-exynos.c | 100 ++++-
 drivers/usb/host/Kconfig       |   8 +
 drivers/usb/host/Makefile      |   1 +
 drivers/usb/host/xhci-exynos.c | 775 +++++++++++++++++++++++++++++++++
 drivers/usb/host/xhci-hub.c    |   7 +
 drivers/usb/host/xhci-mem.c    | 150 ++++++-
 drivers/usb/host/xhci-plat.c   |  50 ++-
 drivers/usb/host/xhci-plat.h   |   9 +
 drivers/usb/host/xhci-ring.c   |   1 +
 drivers/usb/host/xhci.c        |  90 +++-
 drivers/usb/host/xhci.h        |  57 +++
 11 files changed, 1222 insertions(+), 26 deletions(-)
 create mode 100644 drivers/usb/host/xhci-exynos.c
Signature · 1 line
2.31.1
#2 lore raw

PATCH v5 1/6 usb: host: export symbols for xhci-exynos to use xhci hooks

Export symbols for xhci hooks usage:
xhci_get_slot_ctx
xhci_get_endpoint_address
- Allow xhci hook to get ep_ctx from the xhci_container_ctx for getting the ep_ctx information to know which ep is offloading and comparing the context in remote subsystem memory if needed.

xhci_ring_alloc
- Allow xhci hook to allocate vendor specific ring. Vendors could alloc additional event ring.

xhci_trb_virt_to_dma
- Used to retrieve the DMA address of vendor specific ring. Vendors could get dequeue address of event ring.

xhci_segment_free
xhci_link_segments
- Allow xhci hook to handle vendor specific segment. Vendors could directly free or link segments of vendor specific ring.

xhci_initialize_ring_info
- Allow xhci hook to initialize vendor specific ring.

xhci_check_trb_in_td_math
- Allow xhci hook to Check TRB math for validation. Vendors could check trb when allocating vendor specific ring.

xhci_address_device
- Allow override to give configuration info to Co-processor.

xhci_bus_suspend
xhci_bus_resume
- Allow override of suspend and resume for power scenario.

xhci_remove_stream_mapping
- Allow to xhci hook to remove stream mapping. Vendors need to do it when free-ing vendor specific ring if it's stream type.

---
 drivers/usb/host/xhci-hub.c  |  2 ++
 drivers/usb/host/xhci-mem.c  | 19 +++++++++++++------
 drivers/usb/host/xhci-ring.c |  1 +
 drivers/usb/host/xhci.c      |  4 +++-
 drivers/usb/host/xhci.h      |  7 +++++++
 5 files changed, 26 insertions(+), 7 deletions(-)
drivers/usb/host/xhci-hub.c +2 -0
index f65f1ba2b592..841617952ac7 100644
@@ -1812,6 +1812,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(xhci_bus_suspend);
 
 /*
  * Workaround for missing Cold Attach Status (CAS) if device re-plugged in S3.
@@ -1956,6 +1957,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
 	spin_unlock_irqrestore(&xhci->lock, flags);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(xhci_bus_resume);
 
 unsigned long xhci_get_resuming_ports(struct usb_hcd *hcd)
 {
drivers/usb/host/xhci-mem.c +13 -6
index bbb27ee2c6a3..82b9f90c0f27 100644
@@ -65,7 +65,7 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci,
 	return seg;
 }
 
-static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg)
+void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg)
 {
 	if (seg->trbs) {
 		dma_pool_free(xhci->segment_pool, seg->trbs, seg->dma);
@@ -74,6 +74,7 @@ static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg)
 	kfree(seg->bounce_buf);
 	kfree(seg);
 }
+EXPORT_SYMBOL_GPL(xhci_segment_free);
 
 static void xhci_free_segments_for_ring(struct xhci_hcd *xhci,
 				struct xhci_segment *first)
@@ -96,9 +97,9 @@ static void xhci_free_segments_for_ring(struct xhci_hcd *xhci,
  * DMA address of the next segment.  The caller needs to set any Link TRB
  * related flags, such as End TRB, Toggle Cycle, and no snoop.
  */
-static void xhci_link_segments(struct xhci_segment *prev,
-			       struct xhci_segment *next,
-			       enum xhci_ring_type type, bool chain_links)
+void xhci_link_segments(struct xhci_segment *prev,
+			struct xhci_segment *next,
+			enum xhci_ring_type type, bool chain_links)
 {
 	u32 val;
 
@@ -118,6 +119,7 @@ static void xhci_link_segments(struct xhci_segment *prev,
 		prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val);
 	}
 }
+EXPORT_SYMBOL_GPL(xhci_link_segments);
 
 /*
  * Link the ring to the new segments.
@@ -256,7 +258,7 @@ static int xhci_update_stream_segment_mapping(
 	return ret;
 }
 
-static void xhci_remove_stream_mapping(struct xhci_ring *ring)
+void xhci_remove_stream_mapping(struct xhci_ring *ring)
 {
 	struct xhci_segment *seg;
 
@@ -269,6 +271,7 @@ static void xhci_remove_stream_mapping(struct xhci_ring *ring)
 		seg = seg->next;
 	} while (seg != ring->first_seg);
 }
+EXPORT_SYMBOL_GPL(xhci_remove_stream_mapping);
 
 static int xhci_update_stream_mapping(struct xhci_ring *ring, gfp_t mem_flags)
 {
@@ -316,6 +319,7 @@ void xhci_initialize_ring_info(struct xhci_ring *ring,
 	 */
 	ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1;
 }
+EXPORT_SYMBOL_GPL(xhci_initialize_ring_info);
 
 /* Allocate segments and link them for a ring */
 static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci,
@@ -407,6 +411,7 @@ struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci,
 	kfree(ring);
 	return NULL;
 }
+EXPORT_SYMBOL_GPL(xhci_ring_alloc);
 
 void xhci_free_endpoint_ring(struct xhci_hcd *xhci,
 		struct xhci_virt_device *virt_dev,
@@ -518,6 +523,7 @@ struct xhci_slot_ctx *xhci_get_slot_ctx(struct xhci_hcd *xhci,
 	return (struct xhci_slot_ctx *)
 		(ctx->bytes + CTX_SIZE(xhci->hcc_params));
 }
+EXPORT_SYMBOL_GPL(xhci_get_slot_ctx);
 
 struct xhci_ep_ctx *xhci_get_ep_ctx(struct xhci_hcd *xhci,
 				    struct xhci_container_ctx *ctx,
@@ -1965,7 +1971,7 @@ static int xhci_test_trb_in_td(struct xhci_hcd *xhci,
 }
 
 /* TRB math checks for xhci_trb_in_td(), using the command and event rings. */
-static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci)
+int xhci_check_trb_in_td_math(struct xhci_hcd *xhci)
 {
 	struct {
 		dma_addr_t		input_dma;
@@ -2085,6 +2091,7 @@ static int xhci_check_trb_in_td_math(struct xhci_hcd *xhci)
 	xhci_dbg(xhci, "TRB math tests passed.\n");
 	return 0;
 }
+EXPORT_SYMBOL_GPL(xhci_check_trb_in_td_math);
 
 static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
 {
drivers/usb/host/xhci-ring.c +1 -0
index f9707997969d..652b37cd9c5e 100644
@@ -79,6 +79,7 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg,
 		return 0;
 	return seg->dma + (segment_offset * sizeof(*trb));
 }
+EXPORT_SYMBOL_GPL(xhci_trb_virt_to_dma);
 
 static bool trb_is_noop(union xhci_trb *trb)
 {
drivers/usb/host/xhci.c +3 -1
index 25b87e99b4dd..c06e8b21b724 100644
@@ -1468,6 +1468,7 @@ unsigned int xhci_get_endpoint_address(unsigned int ep_index)
 	unsigned int direction = ep_index % 2 ? USB_DIR_OUT : USB_DIR_IN;
 	return direction | number;
 }
+EXPORT_SYMBOL_GPL(xhci_get_endpoint_address);
 
 /* Find the flag for this endpoint (for use in the control context).  Use the
  * endpoint index to create a bitmask.  The slot context is bit 0, endpoint 0 is
@@ -4324,10 +4325,11 @@ static int xhci_setup_device(struct usb_hcd *hcd, struct usb_device *udev,
 	return ret;
 }
 
-static int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
+int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
 {
 	return xhci_setup_device(hcd, udev, SETUP_CONTEXT_ADDRESS);
 }
+EXPORT_SYMBOL_GPL(xhci_address_device);
 
 static int xhci_enable_device(struct usb_hcd *hcd, struct usb_device *udev)
 {
drivers/usb/host/xhci.h +7 -0
index 473a33ce299e..5316841e9b26 100644
@@ -2054,6 +2054,11 @@ void xhci_free_erst(struct xhci_hcd *xhci, struct xhci_erst *erst);
 void xhci_free_endpoint_ring(struct xhci_hcd *xhci,
 		struct xhci_virt_device *virt_dev,
 		unsigned int ep_index);
+void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg);
+void xhci_link_segments(struct xhci_segment *prev,
+			struct xhci_segment *next,
+			enum xhci_ring_type type, bool chain_links);
+void xhci_remove_stream_mapping(struct xhci_ring *ring);
 struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci,
 		unsigned int num_stream_ctxs,
 		unsigned int num_streams,
@@ -2100,6 +2105,7 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
 		       struct usb_host_endpoint *ep);
 int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
 void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
+int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev);
 int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id);
 int xhci_ext_cap_init(struct xhci_hcd *xhci);
 
@@ -2116,6 +2122,7 @@ int xhci_alloc_tt_info(struct xhci_hcd *xhci,
 
 /* xHCI ring, segment, TRB, and TD functions */
 dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, union xhci_trb *trb);
+int xhci_check_trb_in_td_math(struct xhci_hcd *xhci);
 struct xhci_segment *trb_in_td(struct xhci_hcd *xhci,
 		struct xhci_segment *start_seg, union xhci_trb *start_trb,
 		union xhci_trb *end_trb, dma_addr_t suspect_dma, bool debug);
Signature · 1 line
2.31.1
#3 lore raw

PATCH v5 2/6 usb: host: add xhci hooks for xhci-exynos

In reply to Daehwan Jung

To enable supporting for USB offload, define "offload" in usb controller node of device tree. "offload" value can be used to determine which type of offload was been enabled in the SoC.

For example:

&usbdrd_dwc3 {
        ...
        /* support usb offloading, 0: disabled, 1: audio */
        offload = <1>;
        ...
};

There are several vendor_ops introduced by this patch:

struct xhci_vendor_ops - function callbacks for vendor specific operations {
@vendor_init:
- called for vendor init process during xhci-plat-hcd probe.
@vendor_cleanup:
- called for vendor cleanup process during xhci-plat-hcd remove.
@is_usb_offload_enabled:
- called to check if usb offload enabled.
@alloc_dcbaa:
- called when allocating vendor specific dcbaa during memory initializtion.
@free_dcbaa:
- called to free vendor specific dcbaa when cleanup the memory.
@alloc_transfer_ring:
- called when vendor specific transfer ring allocation is required
@free_transfer_ring:
- called to free vendor specific transfer ring
@sync_dev_ctx:
- called when synchronization for device context is required
@alloc_container_ctx
- called to alloc vendor specific container context
@free_container_ctx
- called to free vendor specific container context
}

The xhci hooks with prefix "xhci_vendor_" on the ops in xhci_vendor_ops. For example, vendor_init ops will be invoked by xhci_vendor_init() hook, is_usb_offload_enabled ops will be invoked by xhci_vendor_is_usb_offload_enabled(), and so on.

---
 drivers/usb/host/xhci-hub.c  |   5 ++
 drivers/usb/host/xhci-mem.c  | 131 +++++++++++++++++++++++++++++++----
 drivers/usb/host/xhci-plat.c |  44 +++++++++++-
 drivers/usb/host/xhci-plat.h |   8 +++
 drivers/usb/host/xhci.c      |  80 ++++++++++++++++++++-
 drivers/usb/host/xhci.h      |  47 +++++++++++++
 6 files changed, 297 insertions(+), 18 deletions(-)
drivers/usb/host/xhci-hub.c +5 -0
index 841617952ac7..e07c9c132061 100644
@@ -535,8 +535,13 @@ static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
 	    cmd->status == COMP_COMMAND_RING_STOPPED) {
 		xhci_warn(xhci, "Timeout while waiting for stop endpoint command\n");
 		ret = -ETIME;
+		goto cmd_cleanup;
 	}
 
+	ret = xhci_vendor_sync_dev_ctx(xhci, slot_id);
+	if (ret)
+		xhci_warn(xhci, "Sync device context failed, ret=%d\n", ret);
+
 cmd_cleanup:
 	xhci_free_command(xhci, cmd);
 	return ret;
drivers/usb/host/xhci-mem.c +116 -15

196 lines not on this page · raw message

drivers/usb/host/xhci-plat.c +42 -2

69 lines not on this page · raw message

drivers/usb/host/xhci-plat.h +8 -0
index 1fb149d1fbce..8c204f3234d8 100644
@@ -17,8 +17,16 @@ struct xhci_plat_priv {
 	int (*init_quirk)(struct usb_hcd *);
 	int (*suspend_quirk)(struct usb_hcd *);
 	int (*resume_quirk)(struct usb_hcd *);
+	void *vendor_priv;
 };
 
 #define hcd_to_xhci_priv(h) ((struct xhci_plat_priv *)hcd_to_xhci(h)->priv)
 #define xhci_to_priv(x) ((struct xhci_plat_priv *)(x)->priv)
+
+struct xhci_plat_priv_overwrite {
+	struct xhci_vendor_ops *vendor_ops;
+};
+
+int xhci_plat_register_vendor_ops(struct xhci_vendor_ops *vendor_ops);
+
 #endif	/* _XHCI_PLAT_H */
drivers/usb/host/xhci.c +79 -1

140 lines not on this page · raw message

drivers/usb/host/xhci.h +47 -0

59 lines not on this page · raw message

Signature · 1 line
2.31.1
#4 lore raw

PATCH v5 3/6 usb: host: xhci-plat: support override of hc driver

In reply to Daehwan Jung

It helps xhci-plat driver increase usability. Vendors could use functions in xhci-plat mostly and use some overrides to do what they wants without modifying xhci-plat driver.

---
 drivers/usb/host/xhci-plat.c | 6 ++++++
 drivers/usb/host/xhci-plat.h | 1 +
 2 files changed, 7 insertions(+)
drivers/usb/host/xhci-plat.c +6 -0
index a5881ff945a6..a340e14ce9a6 100644
@@ -173,6 +173,12 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+void xhci_plat_override_driver(const struct xhci_driver_overrides *xhci_vendor_overrides)
+{
+	xhci_init_driver(&xhci_plat_hc_driver, xhci_vendor_overrides);
+}
+EXPORT_SYMBOL_GPL(xhci_plat_override_driver);
+
 static struct xhci_plat_priv_overwrite xhci_plat_vendor_overwrite;
 
 int xhci_plat_register_vendor_ops(struct xhci_vendor_ops *vendor_ops)
drivers/usb/host/xhci-plat.h +1 -0
index 8c204f3234d8..455e0018d5e6 100644
@@ -28,5 +28,6 @@ struct xhci_plat_priv_overwrite {
 };
 
 int xhci_plat_register_vendor_ops(struct xhci_vendor_ops *vendor_ops);
+void xhci_plat_override_driver(const struct xhci_driver_overrides *xhci_vendor_overrides);
 
 #endif	/* _XHCI_PLAT_H */
Signature · 1 line
2.31.1
#5 lore raw

PATCH v5 4/6 usb: host: add some to xhci overrides for xhci-exynos

In reply to Daehwan Jung

Co-processor needs some information about connected usb device. It's proper to pass information after usb device gets address when getting "Set Address" command. It supports vendors to implement it using xhci overrides. There're several power scenarios depending on vendors. It gives vendors flexibilty to meet their power requirement. They can override suspend and resume of root hub.

---
 drivers/usb/host/xhci.c | 6 ++++++
 drivers/usb/host/xhci.h | 3 +++
 2 files changed, 9 insertions(+)
drivers/usb/host/xhci.c +6 -0
index 5ccf1bbe8732..8b3df1302650 100644
@@ -5555,6 +5555,12 @@ void xhci_init_driver(struct hc_driver *drv,
 			drv->check_bandwidth = over->check_bandwidth;
 		if (over->reset_bandwidth)
 			drv->reset_bandwidth = over->reset_bandwidth;
+		if (over->address_device)
+			drv->address_device = over->address_device;
+		if (over->bus_suspend)
+			drv->bus_suspend = over->bus_suspend;
+		if (over->bus_resume)
+			drv->bus_resume = over->bus_resume;
 	}
 }
 EXPORT_SYMBOL_GPL(xhci_init_driver);
drivers/usb/host/xhci.h +3 -0
index 5d356f40c2b9..ab74b24a13b3 100644
@@ -1947,6 +1947,9 @@ struct xhci_driver_overrides {
 			     struct usb_host_endpoint *ep);
 	int (*check_bandwidth)(struct usb_hcd *, struct usb_device *);
 	void (*reset_bandwidth)(struct usb_hcd *, struct usb_device *);
+	int (*address_device)(struct usb_hcd *hcd, struct usb_device *udev);
+	int (*bus_suspend)(struct usb_hcd *hcd);
+	int (*bus_resume)(struct usb_hcd *hcd);
 };
 
 #define	XHCI_CFC_DELAY		10
Signature · 1 line
2.31.1
#6 lore raw

RFC PATCH v5 5/6 usb: host: add xhci-exynos driver

In reply to Daehwan Jung

This driver is for Samsung Exynos xHCI host conroller. It works based on xhci platform driver and extends functions by xhci hooks and overrides. Vendor ops(xhci hooks) should be mapped before probing driver. It overrides functions of hc driver on vendor init.

It supports USB Audio offload with Co-processor. It only cares DCBAA, Device Context, Transfer Ring, Event Ring, and ERST. They are allocated on specific address with xhci hooks. Co-processor could use them directly without xhci driver after then.

---
 drivers/usb/host/Kconfig       |   8 +
 drivers/usb/host/Makefile      |   1 +
 drivers/usb/host/xhci-exynos.c | 775 +++++++++++++++++++++++++++++++++
 3 files changed, 784 insertions(+)
 create mode 100644 drivers/usb/host/xhci-exynos.c
drivers/usb/host/Kconfig +8 -0
index 682b3d2da623..ccafcd9b4212 100644
@@ -104,6 +104,14 @@ config USB_XHCI_TEGRA
 	  Say 'Y' to enable the support for the xHCI host controller
 	  found in NVIDIA Tegra124 and later SoCs.
 
+config USB_XHCI_EXYNOS
+	tristate "xHCI support for Samsung Exynos SoC Series"
+	depends on USB_XHCI_PLATFORM
+	depends on ARCH_EXYNOS || COMPILE_TEST
+	help
+	  Say 'Y' to enable the support for the xHCI host controller
+	  found in Samsung Exynos SoCs.
+
 endif # USB_XHCI_HCD
 
 config USB_EHCI_BRCMSTB
drivers/usb/host/Makefile +1 -0
index 2948983618fb..300f22b6eb1b 100644
@@ -86,3 +86,4 @@ obj-$(CONFIG_USB_HCD_SSB)	+= ssb-hcd.o
 obj-$(CONFIG_USB_FOTG210_HCD)	+= fotg210-hcd.o
 obj-$(CONFIG_USB_MAX3421_HCD)	+= max3421-hcd.o
 obj-$(CONFIG_USB_XEN_HCD)	+= xen-hcd.o
+obj-$(CONFIG_USB_XHCI_EXYNOS)	+= xhci-exynos.o
drivers/usb/host/xhci-exynos.c new file +775 -0

775 lines not on this page · raw message

Signature · 1 line
2.31.1
#7 lore raw

Re: [PATCH RFC v5 5/6] usb: host: add xhci-exynos driver

Quoted 1 line · Daehwan Jung

This driver is for Samsung Exynos xHCI host conroller. It works based on

https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95

Quoted 9 lines

xhci platform driver and extends functions by xhci hooks and overrides. Vendor ops(xhci hooks) should be mapped before probing driver. It overrides functions of hc driver on vendor init.

It supports USB Audio offload with Co-processor. It only cares DCBAA, Device Context, Transfer Ring, Event Ring, and ERST. They are allocated on specific address with xhci hooks. Co-processor could use them directly without xhci driver after then.

Quoted 5 lines
---
 drivers/usb/host/Kconfig       |   8 +
 drivers/usb/host/Makefile      |   1 +
 drivers/usb/host/xhci-exynos.c | 775 +++++++++++++++++++++++++++++++++

This is your fifth version and *it still does not compile*. Can you compile your changes before sending them? It saves reviewer's time.

/usr/bin/aarch64-linux-gnu-ld: drivers/usb/dwc3/dwc3-exynos.o: in function `dwc3_exynos_probe':

dwc3-exynos.c:(.text+0x470): undefined reference to `xhci_exynos_register_vendor_ops'

drivers/usb/host/Kconfig config USB_XHCI_TEGRA · line 108

Quoted 13 lines
 3 files changed, 784 insertions(+)
 create mode 100644 drivers/usb/host/xhci-exynos.c
drivers/usb/host/Kconfig +2 -0
index 682b3d2da623..ccafcd9b4212 100644
@@ -104,6 +104,14 @@ config USB_XHCI_TEGRA
 	  Say 'Y' to enable the support for the xHCI host controller
 	  found in NVIDIA Tegra124 and later SoCs.
 
+config USB_XHCI_EXYNOS
+	tristate "xHCI support for Samsung Exynos SoC Series"

XHCI was supported before, wasn't it? If yes, this title does not make really sense.

You need to provide proper title explaining this option.

drivers/usb/host/Kconfig config USB_XHCI_TEGRA · line 113

Quoted 5 lines
drivers/usb/host/Kconfig +5 -0
+	depends on USB_XHCI_PLATFORM
+	depends on ARCH_EXYNOS || COMPILE_TEST
+	help
+	  Say 'Y' to enable the support for the xHCI host controller
+	  found in Samsung Exynos SoCs.

The same.

Quoted 19 lines
drivers/usb/host/Kconfig +1 -0
+
 endif # USB_XHCI_HCD
 
 config USB_EHCI_BRCMSTB
drivers/usb/host/Makefile +1 -0
index 2948983618fb..300f22b6eb1b 100644
@@ -86,3 +86,4 @@ obj-$(CONFIG_USB_HCD_SSB)	+= ssb-hcd.o
 obj-$(CONFIG_USB_FOTG210_HCD)	+= fotg210-hcd.o
 obj-$(CONFIG_USB_MAX3421_HCD)	+= max3421-hcd.o
 obj-$(CONFIG_USB_XEN_HCD)	+= xen-hcd.o
+obj-$(CONFIG_USB_XHCI_EXYNOS)	+= xhci-exynos.o
drivers/usb/host/xhci-exynos.c new file +0 -0
new file mode 100644
index 000000000000..5318a51ac5ee

drivers/usb/host/xhci-exynos.c line 8

Quoted 8 lines
drivers/usb/host/xhci-exynos.c new file +8 -0
@@ -0,0 +1,775 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * xhci-exynos.c - xHCI host controller driver platform Bus Glue for Exynos.
+ *
+ * Copyright (C) 2022 Samsung Electronics Incorporated - http://www.samsung.com
+ * Author: Daehwan Jung <[email protected]>
+ *
+ * A lot of code borrowed from the Linux xHCI driver.

Then please keep original copyrights, as a derivative work.

drivers/usb/host/xhci-exynos.c line 17

Quoted 9 lines
drivers/usb/host/xhci-exynos.c new file +9 -0
+ */
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+
+#include "xhci.h"
+#include "xhci-plat.h"
+
+/* EXYNOS uram memory map */
+#define EXYNOS_URAM_ABOX_EVT_RING_ADDR	0x02a00000

Are these SoC memory map addresses? If yes, they should not be hard-coded in the driver.

Quoted 4 lines
drivers/usb/host/xhci-exynos.c new file +4 -0
+#define EXYNOS_URAM_ISOC_OUT_RING_ADDR	0x02a01000
+#define EXYNOS_URAM_ISOC_IN_RING_ADDR	0x02a02000
+#define EXYNOS_URAM_DEVICE_CTX_ADDR	0x02a03000
+#define EXYNOS_URAM_DCBAA_ADDR		0x02a03880

drivers/usb/host/xhci-exynos.c line 31

Quoted 10 lines
drivers/usb/host/xhci-exynos.c new file +10 -0
+#define EXYNOS_URAM_ABOX_ERST_SEG_ADDR	0x02a03C80
+#define EXYNOS_URAM_CTX_SIZE		2112
+
+int xhci_exynos_register_vendor_ops(void);
+
+struct xhci_hcd_exynos {
+	struct	xhci_intr_reg __iomem *ir_set_audio;
+
+	struct xhci_ring	*event_ring_audio;
+	struct xhci_erst	erst_audio;

Why "xHCI support for Samsung Exynos SoC Series" comes specific to audio? Isn't XHCI related to USB, so a Universal use? Cannot XHCI driver support mass storage?

drivers/usb/host/xhci-exynos.c line 38

Quoted 7 lines
drivers/usb/host/xhci-exynos.c new file +7 -0
+
+	struct device		*dev;
+	struct usb_hcd		*hcd;
+	struct usb_hcd		*shared_hcd;
+
+	struct wakeup_source *main_wakelock; /* Wakelock for HS HCD */
+	struct wakeup_source *shared_wakelock; /* Wakelock for SS HCD */

None of other USB drivers use wakeloks so why is this one special?

drivers/usb/host/xhci-exynos.c line 48

Quoted 10 lines
drivers/usb/host/xhci-exynos.c new file +10 -0
+
+	u32 in_ep;
+	u32 out_ep;
+	u32 in_deq;
+	u32 out_deq;
+
+	/* This flag is used to check first allocation for URAM */
+	bool			exynos_uram_ctx_alloc;
+	bool			exynos_uram_isoc_out_alloc;
+	bool			exynos_uram_isoc_in_alloc;

This indentation is really troubling me - just few lines above, you don't indent variables. Here you indent. You need to clean up your driver before submitting. Run checkpatch --strict and fix all the issues. Add const to all static variables and most of pointed memory. Remove any inconsistencies. Remove double blank lines. Fix indentation.

Best regards,
Krzysztof

#8 lore raw

RFC PATCH v5 6/6 usb: dwc3: dwc3-exynos: add host init

In reply to Daehwan Jung

This is for xHCI Host Controller driver on Exynos SOC. It registers vendor ops before loading xhci platform driver.

---
 drivers/usb/dwc3/dwc3-exynos.c | 100 ++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-exynos.c +99 -1
index 0ecf20eeceee..c22ea5cd6ab0 100644
@@ -17,6 +17,12 @@
 #include <linux/of_platform.h>
 #include <linux/regulator/consumer.h>
 
+#include "core.h"
+
+#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS)
+int xhci_exynos_register_vendor_ops(void);
+#endif
+
 #define DWC3_EXYNOS_MAX_CLOCKS	4
 
 struct dwc3_exynos_driverdata {
@@ -27,6 +33,7 @@ struct dwc3_exynos_driverdata {
 
 struct dwc3_exynos {
 	struct device		*dev;
+	struct dwc3		*dwc;
 
 	const char		**clk_names;
 	struct clk		*clks[DWC3_EXYNOS_MAX_CLOCKS];
@@ -46,12 +53,81 @@ static int dwc3_exynos_remove_child(struct device *dev, void *unused)
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS)
+static int dwc3_exynos_host_init(struct dwc3_exynos *exynos)
+{
+	struct dwc3		*dwc = exynos->dwc;
+	struct device		*dev = exynos->dev;
+	struct platform_device	*xhci;
+	struct resource		*res;
+	struct platform_device	*dwc3_pdev = to_platform_device(dwc->dev);
+	int			ret = 0;
+
+	/* Configuration xhci resources */
+	xhci_exynos_register_vendor_ops();
+
+	res = platform_get_resource(dwc3_pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(dev, "missing memory resource\n");
+		return -ENODEV;
+	}
+	dwc->xhci_resources[0].start = res->start;
+	dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
+					DWC3_XHCI_REGS_END;
+	dwc->xhci_resources[0].flags = res->flags;
+	dwc->xhci_resources[0].name = res->name;
+
+	res = platform_get_resource(dwc3_pdev, IORESOURCE_IRQ, 0);
+	if (!res) {
+		dev_err(dev, "missing irq resource\n");
+		return -ENODEV;
+	}
+
+	dwc->xhci_resources[1].start = dwc->irq_gadget;
+	dwc->xhci_resources[1].end = dwc->irq_gadget;
+	dwc->xhci_resources[1].flags = res->flags;
+	dwc->xhci_resources[1].name = res->name;
+
+	xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
+	if (!xhci) {
+		dev_err(dwc->dev, "couldn't allocate xHCI device\n");
+		return -ENOMEM;
+	}
+
+	xhci->dev.parent	= dwc->dev;
+	ret = dma_set_mask_and_coherent(&xhci->dev, DMA_BIT_MASK(36));
+	if (ret) {
+		pr_err("xhci dma set mask ret = %d\n", ret);
+		return ret;
+	}
+
+	ret = platform_device_add_resources(xhci, dwc->xhci_resources,
+						DWC3_XHCI_RESOURCES_NUM);
+	if (ret) {
+		dev_err(dwc->dev, "couldn't add resources to xHCI device\n");
+		goto err;
+	}
+
+	ret = platform_device_add(xhci);
+	if (ret) {
+		dev_err(dwc->dev, "couldn't add xHCI device\n");
+		goto err;
+	}
+
+	return 0;
+err:
+	platform_device_put(xhci);
+	return ret;
+}
+#endif
+
 static int dwc3_exynos_probe(struct platform_device *pdev)
 {
 	struct dwc3_exynos	*exynos;
 	struct device		*dev = &pdev->dev;
-	struct device_node	*node = dev->of_node;
+	struct device_node	*node = dev->of_node, *dwc3_np;
 	const struct dwc3_exynos_driverdata *driver_data;
+	struct platform_device *dwc3_pdev;
 	int			i, ret;
 
 	exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL);
@@ -109,6 +185,12 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
 		goto vdd10_err;
 	}
 
+	dwc3_np = of_get_compatible_child(node, "snps,dwc3");
+	if (!dwc3_np) {
+		dev_err(dev, "failed to find dwc3 core child!\n");
+		goto vdd33_err;
+	}
+
 	if (node) {
 		ret = of_platform_populate(node, NULL, NULL, dev);
 		if (ret) {
@@ -121,6 +203,22 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
 		goto populate_err;
 	}
 
+	dwc3_pdev = of_find_device_by_node(dwc3_np);
+	exynos->dwc = platform_get_drvdata(dwc3_pdev);
+	if (!exynos->dwc) {
+		ret = -EPROBE_DEFER;
+		dev_err(dev, "failed to get dwc3 core node!\n");
+		goto populate_err;
+	}
+
+#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS)
+	/* USB host initialization. */
+	ret = dwc3_exynos_host_init(exynos);
+	if (ret) {
+		dev_err(dev, "USB host pre-initialization fail!\n");
+		goto populate_err;
+	}
+#endif
 	return 0;
 
 populate_err:
Signature · 1 line
2.31.1
#9 lore raw

Re: [PATCH RFC v5 6/6] usb: dwc3: dwc3-exynos: add host init

Quoted 1 line · Daehwan Jung

This is for xHCI Host Controller driver on Exynos SOC.

https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95

Quoted 1 line

It registers vendor ops before loading xhci platform driver.

It does not explain why do you need it, why do you do it, what is this going to achieve or give us.

Quoted 11 lines
---
 drivers/usb/dwc3/dwc3-exynos.c | 100 ++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-exynos.c +0 -0
index 0ecf20eeceee..c22ea5cd6ab0 100644

drivers/usb/dwc3/dwc3-exynos.c line 22

Quoted 6 lines
drivers/usb/dwc3/dwc3-exynos.c +3 -0
@@ -17,6 +17,12 @@
 #include <linux/of_platform.h>
 #include <linux/regulator/consumer.h>
 
+#include "core.h"
+
+#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS)

This symbol does not exist at this point, so your patch does not look like correctly ordered.

Quoted 20 lines
drivers/usb/dwc3/dwc3-exynos.c +6 -0
+int xhci_exynos_register_vendor_ops(void);
+#endif
+
 #define DWC3_EXYNOS_MAX_CLOCKS	4
 
 struct dwc3_exynos_driverdata {
@@ -27,6 +33,7 @@ struct dwc3_exynos_driverdata {
 
 struct dwc3_exynos {
 	struct device		*dev;
+	struct dwc3		*dwc;
 
 	const char		**clk_names;
 	struct clk		*clks[DWC3_EXYNOS_MAX_CLOCKS];
@@ -46,12 +53,81 @@ static int dwc3_exynos_remove_child(struct device *dev, void *unused)
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS)
+static int dwc3_exynos_host_init(struct dwc3_exynos *exynos)

drivers/usb/dwc3/dwc3-exynos.c static int dwc3_exynos_remove_child(struct device *dev, void *unused) · line 67

Quoted 10 lines
drivers/usb/dwc3/dwc3-exynos.c +10 -0
+{
+	struct dwc3		*dwc = exynos->dwc;
+	struct device		*dev = exynos->dev;
+	struct platform_device	*xhci;
+	struct resource		*res;
+	struct platform_device	*dwc3_pdev = to_platform_device(dwc->dev);
+	int			ret = 0;
+
+	/* Configuration xhci resources */
+	xhci_exynos_register_vendor_ops();

Why this is always being called? Runtime features should not be added like that.

Quoted 20 lines
drivers/usb/dwc3/dwc3-exynos.c +20 -0
+
+	res = platform_get_resource(dwc3_pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(dev, "missing memory resource\n");
+		return -ENODEV;
+	}
+	dwc->xhci_resources[0].start = res->start;
+	dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
+					DWC3_XHCI_REGS_END;
+	dwc->xhci_resources[0].flags = res->flags;
+	dwc->xhci_resources[0].name = res->name;
+
+	res = platform_get_resource(dwc3_pdev, IORESOURCE_IRQ, 0);
+	if (!res) {
+		dev_err(dev, "missing irq resource\n");
+		return -ENODEV;
+	}
+
+	dwc->xhci_resources[1].start = dwc->irq_gadget;
+	dwc->xhci_resources[1].end = dwc->irq_gadget;

drivers/usb/dwc3/dwc3-exynos.c static int dwc3_exynos_remove_child(struct device *dev, void *unused) · line 97

Quoted 10 lines
drivers/usb/dwc3/dwc3-exynos.c +10 -0
+	dwc->xhci_resources[1].flags = res->flags;
+	dwc->xhci_resources[1].name = res->name;
+
+	xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
+	if (!xhci) {
+		dev_err(dwc->dev, "couldn't allocate xHCI device\n");
+		return -ENOMEM;
+	}
+
+	xhci->dev.parent	= dwc->dev;

Remove any duplicates spaces/tabs which should not be in the code (no need for indenting '=').

drivers/usb/dwc3/dwc3-exynos.c static int dwc3_exynos_remove_child(struct device *dev, void *unused) · line 105

Quoted 8 lines
drivers/usb/dwc3/dwc3-exynos.c +8 -0
+	ret = dma_set_mask_and_coherent(&xhci->dev, DMA_BIT_MASK(36));
+	if (ret) {
+		pr_err("xhci dma set mask ret = %d\n", ret);
+		return ret;
+	}
+
+	ret = platform_device_add_resources(xhci, dwc->xhci_resources,
+						DWC3_XHCI_RESOURCES_NUM);

But this should be properly indented, how checkpatch asks.

Quoted 30 lines
drivers/usb/dwc3/dwc3-exynos.c +20 -1
+	if (ret) {
+		dev_err(dwc->dev, "couldn't add resources to xHCI device\n");
+		goto err;
+	}
+
+	ret = platform_device_add(xhci);
+	if (ret) {
+		dev_err(dwc->dev, "couldn't add xHCI device\n");
+		goto err;
+	}
+
+	return 0;
+err:
+	platform_device_put(xhci);
+	return ret;
+}
+#endif
+
 static int dwc3_exynos_probe(struct platform_device *pdev)
 {
 	struct dwc3_exynos	*exynos;
 	struct device		*dev = &pdev->dev;
-	struct device_node	*node = dev->of_node;
+	struct device_node	*node = dev->of_node, *dwc3_np;
 	const struct dwc3_exynos_driverdata *driver_data;
+	struct platform_device *dwc3_pdev;
 	int			i, ret;
 
 	exynos = devm_kzalloc(dev, sizeof(*exynos), GFP_KERNEL);

drivers/usb/dwc3/dwc3-exynos.c static int dwc3_exynos_probe(struct platform_device *pdev) · line 190

Quoted 6 lines
drivers/usb/dwc3/dwc3-exynos.c +3 -0
@@ -109,6 +185,12 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
 		goto vdd10_err;
 	}
 
+	dwc3_np = of_get_compatible_child(node, "snps,dwc3");
+	if (!dwc3_np) {
+		dev_err(dev, "failed to find dwc3 core child!\n");

Please keep messages consistent with other, so start with capital letter and do not shout.

drivers/usb/dwc3/dwc3-exynos.c static int dwc3_exynos_probe(struct platform_device *pdev) · line 207

Quoted 12 lines
drivers/usb/dwc3/dwc3-exynos.c +5 -0
+		goto vdd33_err;
+	}
+
 	if (node) {
 		ret = of_platform_populate(node, NULL, NULL, dev);
 		if (ret) {
@@ -121,6 +203,22 @@ static int dwc3_exynos_probe(struct platform_device *pdev)
 		goto populate_err;
 	}
 
+	dwc3_pdev = of_find_device_by_node(dwc3_np);
+	exynos->dwc = platform_get_drvdata(dwc3_pdev);

Driver should not poke into its child. You violate device layering here. No, no. This is a glue driver, not a "let's do something inside DWC3" driver.

drivers/usb/dwc3/dwc3-exynos.c static int dwc3_exynos_probe(struct platform_device *pdev) · line 210

Quoted 3 lines
drivers/usb/dwc3/dwc3-exynos.c +3 -0
+	if (!exynos->dwc) {
+		ret = -EPROBE_DEFER;
+		dev_err(dev, "failed to get dwc3 core node!\n");

Again no reason for shouting.

Quoted 4 lines
drivers/usb/dwc3/dwc3-exynos.c +4 -0
+		goto populate_err;
+	}
+
+#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS)

drivers/usb/dwc3/dwc3-exynos.c static int dwc3_exynos_probe(struct platform_device *pdev) · line 224

Quoted 10 lines
drivers/usb/dwc3/dwc3-exynos.c +7 -0
+	/* USB host initialization. */
+	ret = dwc3_exynos_host_init(exynos);
+	if (ret) {
+		dev_err(dev, "USB host pre-initialization fail!\n");
+		goto populate_err;
+	}
+#endif
 	return 0;
 
 populate_err:

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH RFC v5 6/6] usb: dwc3: dwc3-exynos: add host init

Quoted 9 lines · Krzysztof Kozlowski
Quoted 1 line · Daehwan Jung

This is for xHCI Host Controller driver on Exynos SOC.

https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95

Quoted 1 line

It registers vendor ops before loading xhci platform driver.

It does not explain why do you need it, why do you do it, what is this going to achieve or give us.

Nver mind that the whole concept if "vendor" ops doesnt make any sense whatsoever, as I've repeatedly pointed out. The "vendor" is completely irrelevant for a Linux driver.

#11 lore raw

Re: [PATCH RFC v5 6/6] usb: dwc3: dwc3-exynos: add host init

In reply to Daehwan Jung
Quoted 14 lines · Daehwan Jung

This is for xHCI Host Controller driver on Exynos SOC. It registers vendor ops before loading xhci platform driver.

---
 drivers/usb/dwc3/dwc3-exynos.c | 100 ++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-exynos.c +0 -0
index 0ecf20eeceee..c22ea5cd6ab0 100644

drivers/usb/dwc3/dwc3-exynos.c line 24

Quoted 8 lines
drivers/usb/dwc3/dwc3-exynos.c +5 -0
@@ -17,6 +17,12 @@
 #include <linux/of_platform.h>
 #include <linux/regulator/consumer.h>
 
+#include "core.h"
+
+#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS)
+int xhci_exynos_register_vendor_ops(void);
+#endif

Function declarations should always be in a header file, and not guarded by an #ifdef. This particular one is probably not needed anyway if the driver is done correctly though, see below.

Quoted 41 lines
drivers/usb/dwc3/dwc3-exynos.c +37 -0
@@ -46,12 +53,81 @@ static int dwc3_exynos_remove_child(struct device *dev, void *unused)
        return 0;
 }
 
+#if IS_ENABLED(CONFIG_USB_XHCI_EXYNOS)
+static int dwc3_exynos_host_init(struct dwc3_exynos *exynos)
+{
+       struct dwc3             *dwc = exynos->dwc;
+       struct device           *dev = exynos->dev;
+       struct platform_device  *xhci;
+       struct resource         *res;
+       struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
+       int                     ret = 0;
+
+       /* Configuration xhci resources */
+       xhci_exynos_register_vendor_ops();
+
+       res = platform_get_resource(dwc3_pdev, IORESOURCE_MEM, 0);
+       if (!res) {
+               dev_err(dev, "missing memory resource\n");
+               return -ENODEV;
+       }
+       dwc->xhci_resources[0].start = res->start;
+       dwc->xhci_resources[0].end = dwc->xhci_resources[0].start +
+                                       DWC3_XHCI_REGS_END;
+       dwc->xhci_resources[0].flags = res->flags;
+       dwc->xhci_resources[0].name = res->name;
+
+       res = platform_get_resource(dwc3_pdev, IORESOURCE_IRQ, 0);
+       if (!res) {
+               dev_err(dev, "missing irq resource\n");
+               return -ENODEV;
+       }
+
+       dwc->xhci_resources[1].start = dwc->irq_gadget;
+       dwc->xhci_resources[1].end = dwc->irq_gadget;
+       dwc->xhci_resources[1].flags = res->flags;
+       dwc->xhci_resources[1].name = res->name;
+
+       xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
+       if (!xhci) {

drivers/usb/dwc3/dwc3-exynos.c static int dwc3_exynos_remove_child(struct device *dev, void *unused) · line 102

Quoted 10 lines
drivers/usb/dwc3/dwc3-exynos.c +10 -0
+               dev_err(dwc->dev, "couldn't allocate xHCI device\n");
+               return -ENOMEM;
+       }
+
+       xhci->dev.parent        = dwc->dev;
+       ret = dma_set_mask_and_coherent(&xhci->dev, DMA_BIT_MASK(36));
+       if (ret) {
+               pr_err("xhci dma set mask ret = %d\n", ret);
+               return ret;
+       }

This looks like you have the abstraction backwards from what normal drivers do. If you need a specialization of a driver that already exists, create a new driver module with a platform_driver that matches the specialized of_device_id, and have it call into the more general driver, do avoid having the general driver know about the specializations.

Allocating a platform_device and making it DMA capable doesn't generally work correctly, and misses the IOMMU setup, so make sure you have a device node for it instead and probe it from DT.

Arnd