Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright 2014-2016 Freescale Semiconductor Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright 2017-2019 NXP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #ifndef __FSL_DPAA2_IO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define __FSL_DPAA2_IO_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/cpumask.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/irqreturn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "dpaa2-fd.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "dpaa2-global.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) struct dpaa2_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) struct dpaa2_io_store;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * DOC: DPIO Service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * The DPIO service provides APIs for users to interact with the datapath
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * by enqueueing and dequeing frame descriptors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * The following set of APIs can be used to enqueue and dequeue frames
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * as well as producing notification callbacks when data is available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * for dequeue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define DPAA2_IO_ANY_CPU	-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * struct dpaa2_io_desc - The DPIO descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * @receives_notifications: Use notificaton mode. Non-zero if the DPIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  *                  has a channel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * @has_8prio:      Set to non-zero for channel with 8 priority WQs.  Ignored
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  *                  unless receives_notification is TRUE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * @cpu:            The cpu index that at least interrupt handlers will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  *                  execute on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  * @stash_affinity: The stash affinity for this portal favour 'cpu'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  * @regs_cena:      The cache enabled regs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44)  * @regs_cinh:      The cache inhibited regs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45)  * @dpio_id:        The dpio index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)  * @qman_version:   The qman version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  * Describes the attributes and features of the DPIO object.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) struct dpaa2_io_desc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	int receives_notifications;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	int has_8prio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	void *regs_cena;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	void __iomem *regs_cinh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	int dpio_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	u32 qman_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 				 struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) void dpaa2_io_down(struct dpaa2_io *d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) irqreturn_t dpaa2_io_irq(struct dpaa2_io *obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct dpaa2_io *dpaa2_io_service_select(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  * struct dpaa2_io_notification_ctx - The DPIO notification context structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * @cb:           The callback to be invoked when the notification arrives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * @is_cdan:      Zero for FQDAN, non-zero for CDAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  * @id:           FQID or channel ID, needed for rearm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)  * @desired_cpu:  The cpu on which the notifications will show up. Use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75)  *                DPAA2_IO_ANY_CPU if don't care
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76)  * @dpio_id:      The dpio index
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)  * @qman64:       The 64-bit context value shows up in the FQDAN/CDAN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * @node:         The list node
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * @dpio_private: The dpio object internal to dpio_service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * Used when a FQDAN/CDAN registration is made by drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) struct dpaa2_io_notification_ctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	void (*cb)(struct dpaa2_io_notification_ctx *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int is_cdan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	u32 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	int desired_cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	int dpio_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	u64 qman64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	struct list_head node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	void *dpio_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) int dpaa2_io_get_cpu(struct dpaa2_io *d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) int dpaa2_io_service_register(struct dpaa2_io *service,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			      struct dpaa2_io_notification_ctx *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			      struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) void dpaa2_io_service_deregister(struct dpaa2_io *service,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 				 struct dpaa2_io_notification_ctx *ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 				 struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) int dpaa2_io_service_rearm(struct dpaa2_io *service,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			   struct dpaa2_io_notification_ctx *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) int dpaa2_io_service_pull_fq(struct dpaa2_io *d, u32 fqid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			     struct dpaa2_io_store *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) int dpaa2_io_service_pull_channel(struct dpaa2_io *d, u32 channelid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 				  struct dpaa2_io_store *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int dpaa2_io_service_enqueue_fq(struct dpaa2_io *d, u32 fqid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 				const struct dpaa2_fd *fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) int dpaa2_io_service_enqueue_multiple_fq(struct dpaa2_io *d, u32 fqid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 				const struct dpaa2_fd *fd, int number_of_frame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, u32 *fqid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 				const struct dpaa2_fd *fd, int number_of_frame);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int dpaa2_io_service_enqueue_qd(struct dpaa2_io *d, u32 qdid, u8 prio,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 				u16 qdbin, const struct dpaa2_fd *fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int dpaa2_io_service_release(struct dpaa2_io *d, u16 bpid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			     const u64 *buffers, unsigned int num_buffers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int dpaa2_io_service_acquire(struct dpaa2_io *d, u16 bpid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 			     u64 *buffers, unsigned int num_buffers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 					     struct device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) void dpaa2_io_store_destroy(struct dpaa2_io_store *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			    u32 *fcnt, u32 *bcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			    u32 *num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #endif /* __FSL_DPAA2_IO_H */