1、linux下通过  cmdline 实现

参考 :Documentation/admin-guide/kernel-parameters.txt

    libata.force=   [LIBATA] Force configurations.  The format is commaseparated list of "[ID:]VAL" where ID isPORT[.DEVICE].  PORT and DEVICE are decimal numbersmatching port, link or device.  Basically, it matchesthe ATA ID string printed on console by libata.  Ifthe whole ID part is omitted, the last PORT and DEVICEvalues are used.  If ID hasn't been specified yet, theconfiguration applies to all ports, links and devices.If only DEVICE is omitted, the parameter applies tothe port and all links and devices behind it.  DEVICEnumber of 0 either selects the first device or thefirst fan-out link behind PMP device.  It does notselect the host link.  DEVICE number of 15 selects thehost link and device attached to it.The VAL specifies the configuration to force.  As longas there's no ambiguity shortcut notation is allowed.For example, both 1.5 and 1.5G would work for 1.5Gbps.The following configurations can be forced.* Cable type: 40c, 80c, short40c, unk, ign or sata.Any ID with matching PORT is used.* SATA link speed limit: 1.5Gbps or 3.0Gbps.* Transfer mode: pio[0-7], mwdma[0-4] and udma[0-7].udma[/][16,25,33,44,66,100,133] notation is alsoallowed.* [no]ncq: Turn on or off NCQ.* nohrst, nosrst, norst: suppress hard, softand both resets.* dump_id: dump IDENTIFY data.If there are multiple matching configurations changingthe same attribute, the last one is used.

可以将上面的参数加到 cmdline 中,从uboot传给内核的参数

如果要限制具体那个port  , 可以根据 dmesg 来看

So, the tricky part is finding out which port X and device Y (dmesg ataX.YY) is which controller and drive. I think - that notation matches PORT[.DEVICE], but there's also the W:X:Y:Z notation. I'm guessing ataX.YY :)

libata.force=1:1.5G,2:1.5G,3:1.5G

2、uboot下 通过修改 sata controller 实现

我们在 linux 启动的log里经常看到如下信息,

ata2: SATA link up 1.5 Gbps (SStatus 113 SControl 300) .ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)

从SStatus 就可以看出 sata link speed , 0x133 就是6.0Gbps的速度。从 SControl 就可以看到 sata phy 的设置,这个 sata phy register是 sata 控制器的组成部分,如果 sata 接口是 CPU的资源,需要参考cpu 的手册,不过 sata phy register是一个标准,基本所有的控制器设计的时候都按照这个规范来的。以NXP LS1046A  ARM64平台为例,就1个sata controller (可以查看serdes配置,0x3040, 0x5a59 还有dts查看sata控制器地址),下面是 SATA status register (PxSSTS) 。

SATA control register (PxSCTL)

# u-boot-ls $ grep PORT_SCR -nR include/
include/ahci.h:54:#define PORT_SCR      0x28 /* SATA phy register block */
include/ahci.h:55:#define PORT_SCR_STAT     0x28 /* SATA phy register: SStatus */
include/ahci.h:56:#define PORT_SCR_CTL      0x2c /* SATA phy register: SControl */
include/ahci.h:57:#define PORT_SCR_ERR      0x30 /* SATA phy register: SError */
include/ahci.h:58:#define PORT_SCR_ACT      0x34 /* SATA phy register: SActive */
include/ahci.h:93:/* PORT_SCR_STAT bits */
include/ahci.h:94:#define PORT_SCR_STAT_DET_MASK    0x3
include/ahci.h:95:#define PORT_SCR_STAT_DET_COMINIT 0x1
include/ahci.h:96:#define PORT_SCR_STAT_DET_PHYRDY 0x3

这里的设置 可以参考 u-boot/board/highbank/ahci.c 来实现

具体实现如下:

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 18b748a..f6078c0 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -251,6 +251,15 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)sunxi_dma_init(port_mmio);#endif+#ifdef CONFIG_TARGET_YY_XXXXXXXXXXX
+               /* limit sata speed 1.5Gbps */
+               writel(0x311, port_mmio + PORT_SCR_CTL);
+               udelay(1000);
+               writel(0x310, port_mmio + PORT_SCR_CTL);
+               udelay(1000);
+#endif
+/* Add the spinup command to whatever mode bits may* already be on in the command register.*/
@@ -314,7 +323,7 @@ static int ahci_host_init(struct ahci_uc_priv *uc_priv)/* register linkup ports */tmp = readl(port_mmio + PORT_SCR_STAT);
-               debug("SATA port %d status: 0x%x\n", i, tmp);
+               printf("SATA port %d status: 0x%x\n", i, tmp);if ((tmp & PORT_SCR_STAT_DET_MASK) == PORT_SCR_STAT_DET_PHYRDY)uc_priv->link_port_map |= (0x01 << i);}

不过需要注意的是,这里修改过寄存器后,linux下的 sata speed 也被限制到了 gen2, 如果只想在 uboot下限制 speed ,加载硬盘里的内核之后,可以在  执行 bootm命令之前将寄存器修改回来。

diff --git a/cmd/bootm.c b/cmd/bootm.c
index c3a0634..7d1c292 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -8,6 +8,7 @@* Boot support*/#include <common.h>
+#include <asm/io.h>#include <bootm.h>#include <command.h>#include <environment.h>
@@ -90,6 +91,14 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc,int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]){
+#ifdef CONFIG_TARGET_YY_XXXXXX
+               /* do not limit sata speed any more */
+               writel(0x301, 0x320012c);
+               udelay(1000);
+               writel(0x300, 0x320012c);
+               udelay(1000);
+#endif
+

uboot 或者 linux 下限制 sata speed相关推荐

  1. SATA、mSATA接口定义及linux下的挂载硬盘、速度测试

    SATA接口的定义 SATA电源线和数据线接口定义 SATA是Serial ATA的缩写,即串行ATA.2001年,由Intel.APT.Dell.IBM.希捷.迈拓这几大厂商组成的Serial AT ...

  2. 在Linux下使用dnw和u-boot烧写系统

    启动u-boot,按住空格进入u-boot菜单后:(mincom) Linux会识别到一个新的USB设备,执行lsusb可以看到如下信息: azheng@ubuntu:~$ lsusb Bus 001 ...

  3. linux下uboot内存测试,uboot中内存测试,内存检测方法

    内存检测方法 针对常见的DDR内存故障进行了严格的检测处理,下图描述了该检测处理过程的三个步骤:检测数据线.地址线和DDR物理存储部件,主要涉及这三个步骤的处理过程和方法. 下面主要是相关的检测处理思 ...

  4. bios设置识别linux硬盘,linux下如何查看硬盘插在主板那个SATA接口上?梅捷主板SY-A77M3+ bios设置 咋设置啊...

    在上一篇文章中,小编为您详细介绍了关于<联想的主板是哪的?修改技嘉主板bios安装联想win7 64位>相关知识.本篇中小编将再为您讲解标题linux下如何查看硬盘插在主板那个SATA接口 ...

  5. linux ide sata硬盘,Linux 下SATA与IDE硬盘区别

    linux下看到的sda字样表示该机器是IDE模式的硬盘,看到sda字样表示机器是SATA模式的硬盘 解析: 使用df -lh(df -h)可以清晰的查看硬盘使用情况 [root@localhost ...

  6. linux命令进u 盘,在Linux下制作一个磁盘文件,在u-boot 阶段对emmc 烧写整个Linux系统方法...

    在Linux 下制作一个磁盘文件, 可以给他分区,以及存储文件,然后dd 到SD卡便可启动系统. 在u-boot 下启动后可以读取该文件,直接在u-boot 阶段就可以做烧写操作,省略了进入系统后才进 ...

  7. Linux系统移植:官板 uboot 修改(下)

    文章目录 Linux系统移植:官板 uboot 修改(下) 一.LCD 驱动修改 二.网口驱动修改 2.1 PHY 地址修改 2.2 删除 uboot 中 74LV595 的驱动代码 2.3 添加 I ...

  8. Linux下 WiFi rtl 移植,IMX6Q Linux WIFI+BT(RTL8723au)模块移植问题

    软件环境:IMX6Q 4核,Linux 下    BSP: L3.0.35_4.1.0_130816_source 开机打印信息: U-Boot 2009.08 ( 5��月 26 2016 - 12 ...

  9. LINUX下查看CPU、主板、硬盘、内存,网卡信息

    lspci查看硬件信息 在CentOS的最小化安装中,默认是不会安装lspci工具的,需要自己手动安装. 安装步骤: yum  whatprovides  */lspci  /*查找lspci是通过哪 ...

最新文章

  1. 2021湖北省普通高考成绩查询果,2021年湖北高考录取结果查询登录网址入口
  2. 关于Cocos2d-x很多奇怪的报错
  3. SpringBoot自动装载
  4. c++ 输出二进制_Python之输入输出(input_output)
  5. 用户自定义一个异常,编程创建并抛出某个异常类的实例。运行该程序并观察执行结果。
  6. 计算机知识和技能,计算机基本知识和技能PPT课件.ppt
  7. 字符串string和内存流MemoryStream及比特数组byte[]互转
  8. 类的反射实例(servlet的抽取)
  9. 基于百度tts-实现文字转语音,支持下载,在线预览
  10. c3p0连接池配置模板,SSM中使用c3p0连接池配置属性
  11. MFC设置编辑框内容
  12. 了解cuda和显卡等基本概念
  13. 说说Python中切片是什么?
  14. J2EE达内18天笔记
  15. CSS实现表格细边框的三种方式
  16. win7计算机评分性能,Win7内存评分:两种规格6分以内_内存硬盘技巧-中关村在线...
  17. Ubuntu16.04 下安装RTL8111/8168/8411 驱动
  18. 1.虚拟机克隆后的处理步骤
  19. CorelDRAW x4精简版突然弹窗禁用警告问题解决办法
  20. Flash Builder 4.6 配合使用 Adobe Scout CC || SWF Scout Enabler

热门文章

  1. 实现html表单下划线可输入/css实现input只显示下划线
  2. UML协作图(通信图)——软件需求分析与设计
  3. ERP项目实施过程中的致命过失(转)
  4. linux下的vim使用教程!从零基础到入门!
  5. 大数据行业部署实战2:环境大数据统计
  6. VMware Centos7 NAT 环境配置(镜像源+静态IP)
  7. 好用的不行不行!超级炫酷的键盘最应该留给最般配的猿们!
  8. nag在逆向中是什么意思_OD调试4----去除nag窗口的几种方法
  9. 张艾迪(创始人): 年少发明与干净的我
  10. 如何使用iTerm2+oh-my-zsh+Dracula美化你的MAC终端