Lines Matching refs:periph

119 	struct cam_periph *periph;
174 static void sddadone(struct cam_periph *periph,
180 static uint16_t get_rca(struct cam_periph *periph);
183 static void sdda_process_mmc_partitions(struct cam_periph *periph, union ccb *start_ccb);
184 static uint32_t sdda_get_host_caps(struct cam_periph *periph, union ccb *ccb);
185 static int mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca);
186 static inline uint32_t mmc_get_sector_size(struct cam_periph *periph) {return MMC_SECTOR_SIZE;}
196 static inline bool sdda_get_read_only(struct cam_periph *periph, union ccb *start_ccb)
202 static uint32_t mmc_get_spec_vers(struct cam_periph *periph);
203 static uint64_t mmc_get_media_size(struct cam_periph *periph);
204 static uint32_t mmc_get_cmd6_timeout(struct cam_periph *periph);
205 static bool sdda_add_part(struct cam_periph *periph, u_int type,
235 get_rca(struct cam_periph *periph) {
236 return periph->path->device->mmc_ident_data.card_rca;
461 struct cam_periph *periph;
467 periph = softc->periph;
468 if (cam_periph_acquire(periph) != 0) {
472 cam_periph_lock(periph);
473 if ((error = cam_periph_hold(periph, PRIBIO|PCATCH)) != 0) {
474 cam_periph_unlock(periph);
475 cam_periph_release(periph);
479 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddaopen\n"));
483 cam_periph_unhold(periph);
484 cam_periph_unlock(periph);
492 struct cam_periph *periph;
497 periph = softc->periph;
500 cam_periph_lock(periph);
502 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddaclose\n"));
505 cam_periph_sleep(periph, &softc->refcount, PRIBIO, "sddaclose", 1);
506 cam_periph_unlock(periph);
507 cam_periph_release(periph);
512 sddaschedule(struct cam_periph *periph)
514 struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
530 xpt_schedule(periph, CAM_PRIORITY_NORMAL);
542 struct cam_periph *periph;
548 periph = softc->periph;
550 cam_periph_lock(periph);
552 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddastrategy(%p)\n", bp));
557 if ((periph->flags & CAM_PERIPH_INVALID) != 0) {
558 cam_periph_unlock(periph);
571 sddaschedule(periph);
572 cam_periph_unlock(periph);
601 struct cam_periph *periph;
605 periph = part->sc->periph;
606 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddadiskgonecb\n"));
608 cam_periph_release(periph);
612 sddaoninvalidate(struct cam_periph *periph)
617 softc = (struct sdda_softc *)periph->softc;
619 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddaoninvalidate\n"));
624 xpt_register_async(0, sddaasync, periph, periph->path);
631 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("bioq_flush start\n"));
638 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("bioq_flush end\n"));
643 sddacleanup(struct cam_periph *periph)
649 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddacleanup\n"));
650 softc = (struct sdda_softc *)periph->softc;
652 cam_periph_unlock(periph);
662 cam_periph_lock(periph);
670 struct cam_periph *periph;
673 periph = (struct cam_periph *)callback_arg;
714 softc = (struct sdda_softc *)periph->softc;
715 xpt_setup_ccb(&cgd.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
718 cam_periph_async(periph, code, path, arg);
732 softc = periph->softc;
744 cam_periph_async(periph, code, path, arg);
752 struct cam_periph *periph;
759 periph = softc->periph;
760 cam_periph_lock(periph);
762 periph->path);
763 cam_periph_unlock(periph);
770 sddaregister(struct cam_periph *periph, void *arg)
776 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddaregister\n"));
800 periph->softc = softc;
801 softc->periph = periph;
804 xpt_schedule(periph, CAM_PRIORITY_XPT);
805 TASK_INIT(&softc->start_init_task, 0, sdda_start_init_task, periph);
812 mmc_exec_app_cmd(struct cam_periph *periph, union ccb *ccb,
824 /*mmc_arg*/ get_rca(periph) << 16,
867 mmc_app_get_scr(struct cam_periph *periph, union ccb *ccb, uint32_t *rawscr) {
885 err = mmc_exec_app_cmd(periph, ccb, &cmd);
892 mmc_send_ext_csd(struct cam_periph *periph, union ccb *ccb,
957 mmc_select_card(struct cam_periph *periph, union ccb *ccb, uint32_t rca)
978 mmc_switch(struct cam_periph *periph, union ccb *ccb,
990 mmc_get_spec_vers(struct cam_periph *periph) {
991 struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
997 mmc_get_media_size(struct cam_periph *periph) {
998 struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
1004 mmc_get_cmd6_timeout(struct cam_periph *periph)
1006 struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
1008 if (mmc_get_spec_vers(periph) >= 6)
1014 mmc_sd_switch(struct cam_periph *periph, union ccb *ccb,
1048 mmc_set_timing(struct cam_periph *periph,
1055 struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
1056 struct mmc_params *mmcp = &periph->path->device->mmc_ident_data;
1071 err = mmc_switch(periph, ccb, EXT_CSD_CMD_SET_NORMAL,
1074 err = mmc_sd_switch(periph, ccb, SD_SWITCH_MODE_SET, SD_SWITCH_GROUP1, value, switch_res);
1095 struct cam_periph *periph;
1097 periph = (struct cam_periph *)context;
1098 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sdda_start_init_task\n"));
1100 xpt_setup_ccb(&new_ccb->ccb_h, periph->path,
1103 cam_periph_lock(periph);
1104 cam_periph_hold(periph, PRIBIO|PCATCH);
1106 cam_periph_unhold(periph);
1107 cam_periph_unlock(periph);
1112 sdda_set_bus_width(struct cam_periph *periph, union ccb *ccb, int width) {
1113 struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
1114 struct mmc_params *mmcp = &periph->path->device->mmc_ident_data;
1117 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sdda_set_bus_width\n"));
1135 err = mmc_switch(periph, ccb, EXT_CSD_CMD_SET_NORMAL,
1144 err = mmc_exec_app_cmd(periph, ccb, &cmd);
1148 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Error %d when setting bus width on the card\n", err));
1202 sdda_get_host_caps(struct cam_periph *periph, union ccb *ccb)
1221 sdda_get_max_data(struct cam_periph *periph, union ccb *ccb)
1244 struct cam_periph *periph = (struct cam_periph *)context;
1252 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sdda_start_init\n"));
1253 /* periph was held for us when this task was enqueued */
1254 if ((periph->flags & CAM_PERIPH_INVALID) != 0) {
1255 cam_periph_release(periph);
1259 struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
1261 struct mmc_params *mmcp = &periph->path->device->mmc_ident_data;
1262 struct cam_ed *device = periph->path->device;
1267 if (mmc_get_spec_vers(periph) >= 4) {
1268 err = mmc_send_ext_csd(periph, start_ccb,
1272 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
1284 softc->cmd6_time = mmc_get_cmd6_timeout(periph);
1287 if (mmc_get_spec_vers(periph) >= 4) {
1299 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
1345 if (mmc_app_get_scr(periph, start_ccb, rawscr)) {
1346 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Cannot get SCR\n"));
1352 mmc_sd_switch(periph, start_ccb, SD_SWITCH_MODE_CHECK,
1355 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Card supports HS\n"));
1369 mmc_select_card(periph, start_ccb, 0);
1370 mmc_select_card(periph, start_ccb, get_rca(periph));
1372 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Not trying the switch\n"));
1377 if (mmcp->card_features & CARD_FEATURE_MMC && mmc_get_spec_vers(periph) >= 4) {
1387 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Card supports DDR52 at 1.2V\n"));
1393 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Card supports DDR52 at 1.8V\n"));
1399 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Card supports HS200 at 1.2V\n"));
1405 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Card supports HS200 at 1.8V\n"));
1412 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Set SD freq to %d MHz (min out of host f=%d MHz and card f=%d MHz)\n", f_max / 1000000, host_f_max / 1000000, softc->card_f_max / 1000000));
1416 err = mmc_set_timing(periph, start_ccb, bus_timing_hs);
1418 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("Cannot switch card to high-speed mode"));
1490 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
1495 sdda_set_bus_width(periph, start_ccb, desired_bus_width);
1499 cam_periph_unhold(periph);
1501 if (mmcp->card_features & CARD_FEATURE_MMC && mmc_get_spec_vers(periph) >= 4) {
1502 sdda_process_mmc_partitions(periph, start_ccb);
1505 if (sdda_add_part(periph, 0, "sdda",
1506 periph->unit_number,
1507 mmc_get_media_size(periph),
1508 sdda_get_read_only(periph, start_ccb)) == false)
1512 cam_periph_hold(periph, PRIBIO|PCATCH);
1514 xpt_announce_periph(periph, softc->card_id_string);
1522 AC_ADVINFO_CHANGED, sddaasync, periph, periph->path);
1526 sdda_add_part(struct cam_periph *periph, u_int type, const char *name,
1529 struct sdda_softc *sc = (struct sdda_softc *)periph->softc;
1533 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
1550 snprintf(part->name, sizeof(part->name), name, periph->unit_number);
1560 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
1568 xpt_setup_ccb(&cpi.ccb_h, periph->path, CAM_PRIORITY_NONE);
1575 (void)cam_periph_hold(periph, PRIBIO);
1576 cam_periph_unlock(periph);
1595 MIN(maxphys, sdda_get_max_data(periph,
1596 (union ccb *)&cpi) * mmc_get_sector_size(periph));
1610 part->disk->d_sectorsize = mmc_get_sector_size(periph);
1620 * Acquire a reference to the periph before we register with GEOM.
1624 if (cam_periph_acquire(periph) != 0) {
1625 xpt_print(periph->path, "%s: lost periph during "
1627 cam_periph_lock(periph);
1631 cam_periph_lock(periph);
1632 cam_periph_unhold(periph);
1642 sdda_process_mmc_partitions(struct cam_periph *periph, union ccb *ccb)
1644 struct sdda_softc *sc = (struct sdda_softc *)periph->softc;
1645 struct mmc_params *mmcp = &periph->path->device->mmc_ident_data;
1677 sector_size = mmc_get_sector_size(periph);
1689 if (size != mmc_get_media_size(periph) * sector_size) {
1697 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
1705 ro = sdda_get_read_only(periph, ccb);
1706 sdda_add_part(periph, EXT_CSD_PART_CONFIG_ACC_DEFAULT, "sdda",
1707 periph->unit_number, mmc_get_media_size(periph), ro);
1710 if (mmc_get_spec_vers(periph) < 3)
1715 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
1729 if (size > 0 && (sdda_get_host_caps(periph, ccb) & MMC_CAP_BOOT_NOACC) == 0) {
1730 sdda_add_part(periph, EXT_CSD_PART_CONFIG_ACC_BOOT0,
1734 sdda_add_part(periph, EXT_CSD_PART_CONFIG_ACC_BOOT1,
1743 sdda_add_part(periph, EXT_CSD_PART_CONFIG_ACC_RPMB,
1763 sdda_add_part(periph, EXT_CSD_PART_CONFIG_ACC_GP0 + i,
1777 sdda_init_switch_part(struct cam_periph *periph, union ccb *start_ccb,
1780 struct sdda_softc *sc = (struct sdda_softc *)periph->softc;
1794 cam_periph_unlock(periph);
1796 cam_periph_lock(periph);
1799 /* Called with periph lock held! */
1801 sddastart(struct cam_periph *periph, union ccb *start_ccb)
1804 struct sdda_softc *softc = (struct sdda_softc *)periph->softc;
1806 struct mmc_params *mmcp = &periph->path->device->mmc_ident_data;
1809 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sddastart\n"));
1812 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("device is not in SDDA_STATE_NORMAL yet\n"));
1833 CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
1847 sdda_init_switch_part(periph, start_ccb, part_index);
1855 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("BIO_WRITE\n"));
1866 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("BIO_READ\n"));
1867 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE,
1912 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("BIO_FLUSH\n"));
1913 sddaschedule(periph);
1916 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("BIO_DELETE\n"));
1917 sddaschedule(periph);
1927 cam_periph_unlock(periph);
1929 cam_periph_lock(periph);
1932 sddaschedule(periph);
1936 sddadone(struct cam_periph *periph, union ccb *done_ccb)
1945 softc = (struct sdda_softc *)periph->softc;
1950 // cam_periph_lock(periph);
1983 xpt_schedule(periph, CAM_PRIORITY_NORMAL);
1995 xpt_schedule(periph, CAM_PRIORITY_NORMAL);
2014 * Release the periph refcount taken in sddastart() for each CCB.