From owner-svn-src-all@freebsd.org Fri Jul 24 21:14:59 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC55F3746CF; Fri, 24 Jul 2020 21:14:59 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BD25v5KB9z4JBX; Fri, 24 Jul 2020 21:14:59 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 959FA10C1A; Fri, 24 Jul 2020 21:14:59 +0000 (UTC) (envelope-from kibab@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 06OLExnG032706; Fri, 24 Jul 2020 21:14:59 GMT (envelope-from kibab@FreeBSD.org) Received: (from kibab@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06OLExIJ032705; Fri, 24 Jul 2020 21:14:59 GMT (envelope-from kibab@FreeBSD.org) Message-Id: <202007242114.06OLExIJ032705@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kibab set sender to kibab@FreeBSD.org using -f From: Ilya Bakulin Date: Fri, 24 Jul 2020 21:14:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363497 - head/sbin/camcontrol X-SVN-Group: head X-SVN-Commit-Author: kibab X-SVN-Commit-Paths: head/sbin/camcontrol X-SVN-Commit-Revision: 363497 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jul 2020 21:14:59 -0000 Author: kibab Date: Fri Jul 24 21:14:59 2020 New Revision: 363497 URL: https://svnweb.freebsd.org/changeset/base/363497 Log: Make it possible to get/set MMC frequency from camcontrol Enhance camcontrol(8) so that it's possible to manually set frequency for SD/MMC cards. While here, display more information about the current controller, such as supported operating modes and VCCQ voltages, as well as current VCCQ voltage. Reviewed by: manu Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D25795 Modified: head/sbin/camcontrol/camcontrol.c Modified: head/sbin/camcontrol/camcontrol.c ============================================================================== --- head/sbin/camcontrol/camcontrol.c Fri Jul 24 20:54:07 2020 (r363496) +++ head/sbin/camcontrol/camcontrol.c Fri Jul 24 21:14:59 2020 (r363497) @@ -190,7 +190,7 @@ static struct camcontrol_opts option_table[] = { {"rescan", CAM_CMD_RESCAN, CAM_ARG_NONE, NULL}, {"reset", CAM_CMD_RESET, CAM_ARG_NONE, NULL}, {"cmd", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, - {"mmcsdcmd", CAM_CMD_MMCSD_CMD, CAM_ARG_NONE, "c:a:f:Wb:l:41S:I"}, + {"mmcsdcmd", CAM_CMD_MMCSD_CMD, CAM_ARG_NONE, "c:a:F:f:Wb:l:41S:I"}, {"command", CAM_CMD_SCSI_CMD, CAM_ARG_NONE, scsicmd_opts}, {"smpcmd", CAM_CMD_SMP_CMD, CAM_ARG_NONE, "r:R:"}, {"smprg", CAM_CMD_SMP_RG, CAM_ARG_NONE, smprg_opts}, @@ -7833,10 +7833,12 @@ mmcsdcmd(struct cam_device *device, int argc, char **a int retval; int is_write = 0; int is_bw_4 = 0, is_bw_1 = 0; + int is_frequency = 0; int is_highspeed = 0, is_stdspeed = 0; int is_info_request = 0; int flags = 0; uint8_t mmc_data_byte = 0; + uint32_t mmc_frequency = 0; /* For IO_RW_EXTENDED command */ uint8_t *mmc_data = NULL; @@ -7873,6 +7875,10 @@ mmcsdcmd(struct cam_device *device, int argc, char **a case 'I': is_info_request = 1; break; + case 'F': + is_frequency = 1; + mmc_frequency = strtol(optarg, NULL, 0); + break; case 'c': mmc_opcode = strtol(optarg, NULL, 0); if (mmc_opcode < 0) { @@ -7978,6 +7984,23 @@ mmcsdcmd(struct cam_device *device, int argc, char **a return (retval); } + if (is_frequency) { + struct ccb_trans_settings_mmc *cts; + ccb->ccb_h.func_code = XPT_SET_TRAN_SETTINGS; + ccb->ccb_h.flags = 0; + cts = &ccb->cts.proto_specific.mmc; + cts->ios.clock = mmc_frequency; + cts->ios_valid = MMC_CLK; + if (((retval = cam_send_ccb(device, ccb)) < 0) + || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) { + warn("Error sending command"); + } else { + printf("Parameters set OK\n"); + } + cam_freeccb(ccb); + return (retval); + } + // Switch bus speed instead of sending IO command if (is_stdspeed || is_highspeed) { struct ccb_trans_settings_mmc *cts; @@ -8011,13 +8034,48 @@ mmcsdcmd(struct cam_device *device, int argc, char **a printf("Host OCR: 0x%x\n", cts->host_ocr); printf("Min frequency: %u KHz\n", cts->host_f_min / 1000); printf("Max frequency: %u MHz\n", cts->host_f_max / 1000000); - printf("Supported bus width: "); + printf("Supported bus width:\n"); if (cts->host_caps & MMC_CAP_4_BIT_DATA) printf(" 4 bit\n"); if (cts->host_caps & MMC_CAP_8_BIT_DATA) printf(" 8 bit\n"); - printf("\nCurrent settings:\n"); - printf("Bus width: "); + + printf("Supported operating modes:\n"); + if (cts->host_caps & MMC_CAP_HSPEED) + printf(" Can do High Speed transfers\n"); + if (cts->host_caps & MMC_CAP_UHS_SDR12) + printf(" Can do UHS SDR12\n"); + if (cts->host_caps & MMC_CAP_UHS_SDR25) + printf(" Can do UHS SDR25\n"); + if (cts->host_caps & MMC_CAP_UHS_SDR50) + printf(" Can do UHS SDR50\n"); + if (cts->host_caps & MMC_CAP_UHS_SDR104) + printf(" Can do UHS SDR104\n"); + if (cts->host_caps & MMC_CAP_UHS_DDR50) + printf(" Can do UHS DDR50\n"); + if (cts->host_caps & MMC_CAP_MMC_DDR52_120) + printf(" Can do eMMC DDR52 at 1.2V\n"); + if (cts->host_caps & MMC_CAP_MMC_DDR52_180) + printf(" Can do eMMC DDR52 at 1.8V\n"); + if (cts->host_caps & MMC_CAP_MMC_HS200_120) + printf(" Can do eMMC HS200 at 1.2V\n"); + if (cts->host_caps & MMC_CAP_MMC_HS200_180) + printf(" Can do eMMC HS200 at 1.8V\n"); + if (cts->host_caps & MMC_CAP_MMC_HS400_120) + printf(" Can do eMMC HS400 at 1.2V\n"); + if (cts->host_caps & MMC_CAP_MMC_HS400_180) + printf(" Can do eMMC HS400 at 1.8V\n"); + + printf("Supported VCCQ voltages:\n"); + if (cts->host_caps & MMC_CAP_SIGNALING_120) + printf(" 1.2V\n"); + if (cts->host_caps & MMC_CAP_SIGNALING_180) + printf(" 1.8V\n"); + if (cts->host_caps & MMC_CAP_SIGNALING_330) + printf(" 3.3V\n"); + + printf("Current settings:\n"); + printf(" Bus width: "); switch (cts->ios.bus_width) { case bus_width_1: printf("1 bit\n"); @@ -8029,10 +8087,23 @@ mmcsdcmd(struct cam_device *device, int argc, char **a printf("8 bit\n"); break; } - printf("Freq: %d.%03d MHz%s\n", + printf(" Freq: %d.%03d MHz%s\n", cts->ios.clock / 1000000, (cts->ios.clock / 1000) % 1000, - cts->ios.timing == bus_timing_hs ? "(high-speed timing)" : ""); + cts->ios.timing == bus_timing_hs ? " (high-speed timing)" : ""); + + printf(" VCCQ: "); + switch (cts->ios.vccq) { + case vccq_330: + printf("3.3V\n"); + break; + case vccq_180: + printf("1.8V\n"); + break; + case vccq_120: + printf("1.2V\n"); + break; + } return (0); }