Changeset View
Changeset View
Standalone View
Standalone View
sys/arm/allwinner/aw_mmc.c
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | |||||
static int aw_mmc_get_ro(device_t, device_t); | static int aw_mmc_get_ro(device_t, device_t); | ||||
static int aw_mmc_acquire_host(device_t, device_t); | static int aw_mmc_acquire_host(device_t, device_t); | ||||
static int aw_mmc_release_host(device_t, device_t); | static int aw_mmc_release_host(device_t, device_t); | ||||
#ifdef MMCCAM | #ifdef MMCCAM | ||||
static void aw_mmc_cam_action(struct cam_sim *, union ccb *); | static void aw_mmc_cam_action(struct cam_sim *, union ccb *); | ||||
static void aw_mmc_cam_poll(struct cam_sim *); | static void aw_mmc_cam_poll(struct cam_sim *); | ||||
static int aw_mmc_cam_settran_settings(struct aw_mmc_softc *, union ccb *); | static int aw_mmc_cam_settran_settings(struct aw_mmc_softc *, union ccb *); | ||||
static int aw_mmc_cam_request(struct aw_mmc_softc *, union ccb *); | static int aw_mmc_cam_request(struct aw_mmc_softc *, union ccb *); | ||||
static void aw_mmc_cam_start_discovery(device_t); | |||||
static void aw_mmc_cam_handle_mmcio(struct cam_sim *, union ccb *); | static void aw_mmc_cam_handle_mmcio(struct cam_sim *, union ccb *); | ||||
#endif | #endif | ||||
#define AW_MMC_LOCK(_sc) mtx_lock(&(_sc)->aw_mtx) | #define AW_MMC_LOCK(_sc) mtx_lock(&(_sc)->aw_mtx) | ||||
#define AW_MMC_UNLOCK(_sc) mtx_unlock(&(_sc)->aw_mtx) | #define AW_MMC_UNLOCK(_sc) mtx_unlock(&(_sc)->aw_mtx) | ||||
#define AW_MMC_READ_4(_sc, _reg) \ | #define AW_MMC_READ_4(_sc, _reg) \ | ||||
bus_read_4((_sc)->aw_res[AW_MMC_MEMRES], _reg) | bus_read_4((_sc)->aw_res[AW_MMC_MEMRES], _reg) | ||||
#define AW_MMC_WRITE_4(_sc, _reg, _value) \ | #define AW_MMC_WRITE_4(_sc, _reg, _value) \ | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
sc->ccb = ccb; | sc->ccb = ccb; | ||||
/* aw_mmc_request locks again */ | /* aw_mmc_request locks again */ | ||||
AW_MMC_UNLOCK(sc); | AW_MMC_UNLOCK(sc); | ||||
aw_mmc_request(sc->aw_dev, NULL, NULL); | aw_mmc_request(sc->aw_dev, NULL, NULL); | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | |||||
aw_mmc_cam_start_discovery(device_t dev) | |||||
{ | |||||
struct aw_mmc_softc *sc; | |||||
union ccb *ccb; | |||||
uint32_t pathid; | |||||
sc = device_get_softc(dev); | |||||
pathid = cam_sim_path(sc->sim); | |||||
imp: I can't see what this protects in this code. Do you need it?
| |||||
Done Inline ActionsSeems indeed this is excessive. kibab: Seems indeed this is excessive. | |||||
ccb = xpt_alloc_ccb_nowait(); | |||||
if (ccb == NULL) { | |||||
device_printf(dev, "Unable to alloc CCB for rescan\n"); | |||||
return; | |||||
} | |||||
/* | |||||
* We create a rescan request for BUS:0:0, since the card | |||||
* will be at lun 0. | |||||
*/ | |||||
if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid, | |||||
/* target */ 0, /* lun */ 0) != CAM_REQ_CMP) { | |||||
device_printf(dev, "Unable to create path for rescan\n"); | |||||
xpt_free_ccb(ccb); | |||||
return; | |||||
} | |||||
xpt_rescan(ccb); | |||||
} | |||||
#endif /* MMCCAM */ | #endif /* MMCCAM */ | ||||
static int | static int | ||||
aw_mmc_probe(device_t dev) | aw_mmc_probe(device_t dev) | ||||
{ | { | ||||
if (!ofw_bus_status_okay(dev)) | if (!ofw_bus_status_okay(dev)) | ||||
return (ENXIO); | return (ENXIO); | ||||
▲ Show 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | if (xpt_bus_register(sc->sim, sc->aw_dev, 0) != 0) { | ||||
device_printf(dev, "cannot register SCSI pass-through bus\n"); | device_printf(dev, "cannot register SCSI pass-through bus\n"); | ||||
cam_sim_free(sc->sim, FALSE); | cam_sim_free(sc->sim, FALSE); | ||||
cam_simq_free(sc->devq); | cam_simq_free(sc->devq); | ||||
mtx_unlock(&sc->sim_mtx); | mtx_unlock(&sc->sim_mtx); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
mtx_unlock(&sc->sim_mtx); | mtx_unlock(&sc->sim_mtx); | ||||
/* Force rescan */ | |||||
aw_mmc_cam_start_discovery(dev); | |||||
#else /* !MMCCAM */ | #else /* !MMCCAM */ | ||||
child = device_add_child(dev, "mmc", -1); | child = device_add_child(dev, "mmc", -1); | ||||
if (child == NULL) { | if (child == NULL) { | ||||
device_printf(dev, "attaching MMC bus failed!\n"); | device_printf(dev, "attaching MMC bus failed!\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
if (device_probe_and_attach(child) != 0) { | if (device_probe_and_attach(child) != 0) { | ||||
device_printf(dev, "attaching MMC child failed!\n"); | device_printf(dev, "attaching MMC child failed!\n"); | ||||
▲ Show 20 Lines • Show All 970 Lines • Show Last 20 Lines |
I can't see what this protects in this code. Do you need it?