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 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) #ifndef SCM_BLK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #define SCM_BLK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/blk-mq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/genhd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/eadm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define SCM_NR_PARTS 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define SCM_QUEUE_DELAY 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct scm_blk_dev {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	struct request_queue *rq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	struct gendisk *gendisk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	struct blk_mq_tag_set tag_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	struct scm_device *scmdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	atomic_t queued_reqs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	enum {SCM_OPER, SCM_WR_PROHIBIT} state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	struct list_head finished_requests;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct scm_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	struct scm_blk_dev *bdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	struct aidaw *next_aidaw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	struct request **request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	struct aob *aob;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	u8 retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	blk_status_t error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define to_aobrq(rq) container_of((void *) rq, struct aob_rq_header, data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int scm_blk_dev_setup(struct scm_blk_dev *, struct scm_device *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) void scm_blk_dev_cleanup(struct scm_blk_dev *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void scm_blk_set_available(struct scm_blk_dev *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) void scm_blk_irq(struct scm_device *, void *, blk_status_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct aidaw *scm_aidaw_fetch(struct scm_request *scmrq, unsigned int bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int scm_drv_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) void scm_drv_cleanup(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) extern debug_info_t *scm_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define SCM_LOG(imp, txt) do {					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		debug_text_event(scm_debug, imp, txt);		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static inline void SCM_LOG_HEX(int level, void *data, int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	debug_event(scm_debug, level, data, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static inline void SCM_LOG_STATE(int level, struct scm_device *scmdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 		u64 address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 		u8 oper_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 		u8 rank;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	} __packed data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 		.address = scmdev->address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		.oper_state = scmdev->attrs.oper_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 		.rank = scmdev->attrs.rank,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	SCM_LOG_HEX(level, &data, sizeof(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #endif /* SCM_BLK_H */