Convert CONFIG_SAMSUNG_ONENAND to Kconfig
[platform/kernel/u-boot.git] / include / scsi.h
index 20f6932..b47c746 100644 (file)
@@ -1,12 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*
  * (C) Copyright 2001
  * Denis Peter, MPL AG Switzerland
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
  #ifndef _SCSI_H
  #define _SCSI_H
 
+#include <asm/cache.h>
+#include <linux/dma-direction.h>
+
+/* Fix this to the maximum */
+#define SCSI_MAX_DEVICE \
+       (CONFIG_SYS_SCSI_MAX_SCSI_ID * CONFIG_SYS_SCSI_MAX_LUN)
+
+struct udevice;
+
 struct scsi_cmd {
        unsigned char           cmd[16];                                        /* command                                 */
        /* for request sense */
@@ -27,6 +35,7 @@ struct scsi_cmd {
        unsigned long           trans_bytes;                    /* tranfered bytes              */
 
        unsigned int            priv;
+       enum dma_data_direction dma_dir;
 };
 
 /*-----------------------------------------------------------
@@ -159,16 +168,18 @@ struct scsi_cmd {
 #define SCSI_WRITE_SAME        0x41            /* Write Same (O) */
 
 /**
- * struct scsi_platdata - stores information about SCSI controller
+ * struct scsi_plat - stores information about SCSI controller
  *
  * @base: Controller base address
  * @max_lun: Maximum number of logical units
  * @max_id: Maximum number of target ids
+ * @max_bytes_per_req: Maximum number of bytes per read/write request
  */
-struct scsi_platdata {
+struct scsi_plat {
        unsigned long base;
        unsigned long max_lun;
        unsigned long max_id;
+       unsigned long max_bytes_per_req;
 };
 
 /* Operations for SCSI */
@@ -191,12 +202,25 @@ struct scsi_ops {
        int (*bus_reset)(struct udevice *dev);
 };
 
-#ifndef CONFIG_DM_SCSI
-void scsi_low_level_init(int busdevfunc);
-void scsi_init(void);
-#endif
+#define scsi_get_ops(dev)        ((struct scsi_ops *)(dev)->driver->ops)
+
+extern struct scsi_ops scsi_ops;
+
+/**
+ * scsi_exec() - execute a command
+ *
+ * @dev:       SCSI bus
+ * @cmd:       Command to execute
+ * Return: 0 if OK, -ve on error
+ */
+int scsi_exec(struct udevice *dev, struct scsi_cmd *cmd);
 
-int scsi_exec(struct udevice *dev, struct scsi_cmd *pccb);
+/**
+ * scsi_bus_reset() - reset the bus
+ *
+ * @dev:       SCSI bus to reset
+ * Return: 0 if OK, -ve on error
+ */
 int scsi_bus_reset(struct udevice *dev);
 
 /**
@@ -206,6 +230,19 @@ int scsi_bus_reset(struct udevice *dev);
  */
 int scsi_scan(bool verbose);
 
+/**
+ * scsi_scan_dev() - scan a SCSI bus and create devices
+ *
+ * @dev:       SCSI bus
+ * @verbose:   true to show information about each device found
+ */
+int scsi_scan_dev(struct udevice *dev, bool verbose);
+
+#ifndef CONFIG_DM_SCSI
+void scsi_low_level_init(int busdevfunc);
+void scsi_init(void);
+#endif
+
 #define SCSI_IDENTIFY                                  0xC0  /* not used */
 
 /* Hardware errors  */