Skip to content
Snippets Groups Projects
Commit f6ab5a92 authored by Simon Glass's avatar Simon Glass
Browse files

dm: scsi: Add operations for SCSI devices


The SCSI uclass currently has no operations. It just uses the global SCSI
functions. Fix this by adding operations to the only two drivers that use
the uclass, and replacing the global functions with those defined locally
in the SCSI code.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
parent 4e749014
No related branches found
No related tags found
No related merge requests found
...@@ -1141,6 +1141,12 @@ static int ahci_scsi_bus_reset(struct udevice *dev) ...@@ -1141,6 +1141,12 @@ static int ahci_scsi_bus_reset(struct udevice *dev)
return 0; return 0;
} }
#ifdef CONFIG_DM_SCSI
struct scsi_ops scsi_ops = {
.exec = ahci_scsi_exec,
.bus_reset = ahci_scsi_bus_reset,
};
#else
int scsi_exec(struct udevice *dev, struct scsi_cmd *pccb) int scsi_exec(struct udevice *dev, struct scsi_cmd *pccb)
{ {
return ahci_scsi_exec(dev, pccb); return ahci_scsi_exec(dev, pccb);
...@@ -1152,3 +1158,4 @@ __weak int scsi_bus_reset(struct udevice *dev) ...@@ -1152,3 +1158,4 @@ __weak int scsi_bus_reset(struct udevice *dev)
return 0; return 0;
} }
#endif
...@@ -98,6 +98,7 @@ U_BOOT_DRIVER(dwc_ahci) = { ...@@ -98,6 +98,7 @@ U_BOOT_DRIVER(dwc_ahci) = {
.id = UCLASS_SCSI, .id = UCLASS_SCSI,
.of_match = dwc_ahci_ids, .of_match = dwc_ahci_ids,
.ofdata_to_platdata = dwc_ahci_ofdata_to_platdata, .ofdata_to_platdata = dwc_ahci_ofdata_to_platdata,
.ops = &scsi_ops,
.probe = dwc_ahci_probe, .probe = dwc_ahci_probe,
.priv_auto_alloc_size = sizeof(struct dwc_ahci_priv), .priv_auto_alloc_size = sizeof(struct dwc_ahci_priv),
.flags = DM_FLAG_ALLOC_PRIV_DMA, .flags = DM_FLAG_ALLOC_PRIV_DMA,
......
...@@ -144,6 +144,7 @@ U_BOOT_DRIVER(ceva_host_blk) = { ...@@ -144,6 +144,7 @@ U_BOOT_DRIVER(ceva_host_blk) = {
.name = "ceva_sata", .name = "ceva_sata",
.id = UCLASS_SCSI, .id = UCLASS_SCSI,
.of_match = sata_ceva_ids, .of_match = sata_ceva_ids,
.ops = &scsi_ops,
.probe = sata_ceva_probe, .probe = sata_ceva_probe,
.ofdata_to_platdata = sata_ceva_ofdata_to_platdata, .ofdata_to_platdata = sata_ceva_ofdata_to_platdata,
}; };
...@@ -13,6 +13,26 @@ ...@@ -13,6 +13,26 @@
#include <dm.h> #include <dm.h>
#include <scsi.h> #include <scsi.h>
int scsi_exec(struct udevice *dev, struct scsi_cmd *pccb)
{
struct scsi_ops *ops = scsi_get_ops(dev);
if (!ops->exec)
return -ENOSYS;
return ops->exec(dev, pccb);
}
int scsi_bus_reset(struct udevice *dev)
{
struct scsi_ops *ops = scsi_get_ops(dev);
if (!ops->bus_reset)
return -ENOSYS;
return ops->bus_reset(dev);
}
UCLASS_DRIVER(scsi) = { UCLASS_DRIVER(scsi) = {
.id = UCLASS_SCSI, .id = UCLASS_SCSI,
.name = "scsi", .name = "scsi",
......
...@@ -191,12 +191,25 @@ struct scsi_ops { ...@@ -191,12 +191,25 @@ struct scsi_ops {
int (*bus_reset)(struct udevice *dev); int (*bus_reset)(struct udevice *dev);
}; };
#ifndef CONFIG_DM_SCSI #define scsi_get_ops(dev) ((struct scsi_ops *)(dev)->driver->ops)
void scsi_low_level_init(int busdevfunc);
void scsi_init(void); extern struct scsi_ops scsi_ops;
#endif
/**
* 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); int scsi_bus_reset(struct udevice *dev);
/** /**
...@@ -206,6 +219,11 @@ int scsi_bus_reset(struct udevice *dev); ...@@ -206,6 +219,11 @@ int scsi_bus_reset(struct udevice *dev);
*/ */
int scsi_scan(bool verbose); int scsi_scan(bool verbose);
#ifndef CONFIG_DM_SCSI
void scsi_low_level_init(int busdevfunc);
void scsi_init(void);
#endif
#define SCSI_IDENTIFY 0xC0 /* not used */ #define SCSI_IDENTIFY 0xC0 /* not used */
/* Hardware errors */ /* Hardware errors */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment