Skip to content

Hardware Parameter Tuning Guide


REVISION HISTORY

Revison No.
Description
Date
1.0
  • Initial release
  • 11/21/2023
    1.1
  • Delete USB3.0
  • Replace gmac by emac/SD&eMMC merge/PAD_PM_GPIO index change
  • 01/24/2024
    1.2
  • add disp driving capability adjustment and clk reverse configuration
  • 12/25/2024
    1.3
  • add SATA CTS configuration
  • 01/03/2025
    1.4
  • add hdmitx driving capability adjustment and ssc adjustment
  • 01/08/2025
    1.5
  • add IIC & PWM driving capability adjustment
  • 01/08/2025
    1.6
  • add MSPI & UART driving capability adjustment
  • 01/09/2025
    1.7
  • add PCIe PHY parameter tuning
  • 05/18/2026

    1. Analog IP Hardware Parameter Tuning

    1.1. USB 2.0

    Five parameters are available for tuning, namely: pre-emphasis, slew rate, swing trim, disconnect detector reference voltage, and RX squelch calibration reference voltage (swing trim may have been trimmed in OTP, so please pay attention when adjusting this parameter).

    1.1.1. pre_emphasis

    The parameter pre_emphasis is located in UTMI bank offset 0x43[9:8]. Parameter range: 0 ~ 3. The larger the value, the stronger the pre-emphasis is.

    1. Query the current value: cat /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/pre_emphasis

    2. Set the value: echo value > /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/pre_emphasis

    1.1.2. slew_rate

    The parameter slew_rate is located in UTMI bank offset 0x44[2:1]. Parameter range: 0 ~ 3.

    1. Query the current value: cat /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/slew_rate

    2. Set the value: echo value > /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/slew_rate

    1.1.3. swing trim (This parameter may have been trimmed in OTP, so please confirm with hardware RD before adjusting this parameter).

    The parameter swing trim is located in UTMI bank offset 0x44[9:4]. Parameter range: 0 ~ 63.

    1. Query the current value: cat /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/swing_trim

    2. Set the value: echo value > /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/swing_trim

    1.1.4. disconnect detector reference voltage

    The parameter disconnect detector reference voltage is located in UTMI bank offset 0x41[4:0]. Parameter range: 0 ~ 31.

    1. Query the current value: cat /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/disconnect_refer_voltage

    2. Set the value: echo value > /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/disconnect_refer_voltage

    1.1.5. RX squelch calibration reference voltage

    The parameter RX squelch calibration reference voltage is located in UTMI bank offset 0x4b[4:0]. Parameter range: 0 ~ 31.

    1. Query the current value: cat /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/squelch_refer_voltage

    2. Set the value: echo value > /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/squelch_refer_voltage

    1.1.6. Eye Diagram Test

    1. After booting the device, enter the kernel and run the following commands, and then you can connect with an oscilloscope to view the eye diagram.

    2. When the waveform result of eye diagram test does not meet the requirements, you can adjust the above five parameters until the waveform is perfect.

      To perform highspeed eye diagram test, run: echo “hs” > /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/eye_diagram_switch

      To perform fullspeed eye diagram test, run: echo “fs” > /sys/kernel/debug/usb/phy-soc\:u2phy0@0x1f284200.0/eye_diagram_switch


    1.2. USB 3.0

    mHera USB3.0 Port 3 uses PIPE PHY, and Port 2 uses SUPPHY. Each has different driving capability parameters.

    1.2.1. Port 3 - PIPE PHY

    Three parameters are available for PIPE PHY tuning: idrv (drive current), idem (de-emphasis) and biasi (bias current).

    1.2.1.1. idrv (TX Drive Current)

    Located at PHYD Offset 0x41[7:2], range: 0~63. Higher value means stronger drive current.

    Query current idrv level: cat /sys/kernel/debug/usb/phy-1f2a5200.pipe.6/tx-idrv
    
    Set idrv level: echo level > /sys/kernel/debug/usb/phy-1f2a5200.pipe.6/tx-idrv
    
    1.2.1.2. idem (TX De-Emphasis)

    Located at PHYD Offset 0x41[13:8], range: 0~63. Higher value means stronger de-emphasis.

    Query current idem level: cat /sys/kernel/debug/usb/phy-1f2a5200.pipe.6/tx-idem
    
    Set idem level: echo level > /sys/kernel/debug/usb/phy-1f2a5200.pipe.6/tx-idem
    
    1.2.1.3. biasi (TX Bias Current)

    Located at PHYD Offset 0x26[3:1], range: 0~7. Higher value means larger bias current.

    Query current biasi level: cat /sys/kernel/debug/usb/phy-1f2a5200.pipe.6/tx-biasi
    
    Set biasi level: echo level > /sys/kernel/debug/usb/phy-1f2a5200.pipe.6/tx-biasi
    

    1.2.2. Port 2 - SUPPHY

    Three parameters are available for SUPPHY tuning: swing-mode (swing mode selection), swing-amplitude (low-swing amplitude) and tx-deemphasis (TX de-emphasis).

    1.2.2.1. swing-mode (Swing Mode Selection)

    Located at PHYD Offset 0x02[1:0], used to switch between Full-Swing and Low-Swing modes.

    Value Mode
    2 Full-Swing
    3 Low-Swing
    Query current mode: cat /sys/kernel/debug/usb/phy-1f2b2600.pipe.7/swing-mode
    
    Switch to Low-Swing mode: echo 3 > /sys/kernel/debug/usb/phy-1f2b2600.pipe.7/swing-mode
    
    Switch to Full-Swing mode: echo 2 > /sys/kernel/debug/usb/phy-1f2b2600.pipe.7/swing-mode
    
    1.2.2.2. swing-amplitude (Low-Swing Amplitude)

    Configure the SUPPHY low-swing amplitude level. Only configurable and readable in Low-Swing mode. Located at PHYD Offset 0x10[7:0], controlled by level value 0~5.

    Level Register Value Description
    0 0x6C -1.5dB (84%)
    1 0x60 -2.5dB (75%)
    2 0x56 -3.5dB (67%)
    3 0x4D -4.5dB (60%)
    4 0x40 -6dB (50%)
    5 0x36 -7.6dB (42%)
    Query current level: cat /sys/kernel/debug/usb/phy-1f2b2600.pipe.7/swing-amplitude
    
    Set level: echo 3 > /sys/kernel/debug/usb/phy-1f2b2600.pipe.7/swing-amplitude
    
    1.2.2.3. tx-deemphasis (TX De-Emphasis Amplitude)

    Located at PHYD Offset 0x02[7:6] (amplitude) and PHYD Offset 0x03[8] (enable), range: 0~2. Writing any value automatically enables de-emphasis (PHYD 0x03[8]=1).

    Value De-Emphasis
    0 -6dB
    1 -3.5dB
    2 0dB
    Query current tx-deemphasis value: cat /sys/kernel/debug/usb/phy-1f2b2600.pipe.7/tx-deemphasis
    
    Set tx-deemphasis value: echo value > /sys/kernel/debug/usb/phy-1f2b2600.pipe.7/tx-deemphasis
    

    1.3. SDMMC Driving Capability Configuration

    1.3.1. Driving Capability Configured by sysfs

    SDMMC driver provides sysfs control pin driving capability, please refer to the following instruction:

    1. cd /sys/devices/soc0/soc/<reg>:sgs_sdmmc[i]
    2. # <reg> - Generate Reg value based on the actual configuration information of DTSI
    3. # [i]   - Generate index value based on the actual configuration information of DTSI
    4. echo [slotNo] <signal> [level] > set_sdmmc_driving_control
    5. # Set driving capability as [level] for the signal line <signal> of [slotNo].
    6. # [slotNo] - Select the slot to be operated.
    7. # <signal> - You may choose to set clk, cmd, data, all, or null (equal to all).
    8. # [level]  - driving capability level. Value range: 0 ~ 7.
    

    Set the driving capability of all signal pins of sd to 2

    1. cd /sys/devices/platform/soc/1f282600.sgs_sdmmc1
    2. echo 0 all 2 > set_sdmmc_driving_control
    

    Set the driving capability of the four data pins of emmc to 1:

    1. cd /sys/devices/platform/soc/1f282000.sgs_sdmmc0
    2. echo 1 data 1 > set_sdmmc_driving_control
    

    1.3.2. Driving Capability Configured by dts

    SDMMC driver supports configuring the driving capabilities of clk, cmd and data signal lines from dts. The configuration is as follows:

    1. sgs_sdmmc0: sgs_sdmmc0 {
    2.     compatible = "sgs,sdmmc";
    3.     bus-width = <4>;
    4.     no-sdio;
    5.     no-sd;
    6.     7.     clk-driving = <2>,<0>,<0>;
    8.     cmd-driving = <2>,<0>,<0>;
    9.     data-driving = <2>,<0>,<0>;
    10.    11. }
    
    1. sgs_sdmmc1: sgs_sdmmc1 {
    2.     compatible = "sgs,sdmmc";
    3.     bus-width = <4>;
    4.     no-mmc;
    5.     6.     clk-driving = <2>,<0>,<0>;
    7.     cmd-driving = <2>,<0>,<0>;
    8.     data-driving = <2>,<0>,<0>;
    9.    10. }
    

    As shown above, these three attribute parameters configure the driving capabilities of the clk line, cmd line and four data lines, respectively. You can see that each parameter has three values. These three values represent the driving capability of each slot. The driving level is determined by the actual selected PAD. For details, please refer to the relevant GPIO PAD configuration document.


    1.4. DISP

    1.4.1. Driving Capability Adjustment

    DISP driver supports configuraing the driving capability of the panel pin from the screen parameters. The configuration is as follows:

    1、configure padmux

    padmux file path:

    #arm32
    kernel/arch/arm/boot/dts/$(boardname)-padmux.dtsi
    #arm64
    kernel/arch/arm64/boot/dts/sgs/$(boardname)-padmux.dtsi
    

    Change padmux #if 0 to #if 1 based on the interface currently required.

    2、set m_wPadDrvngLvl on the screen parameters

    screen parameters path:

    project\board\$(chip)\screen_param\config_disp.json
    
    m_wPadDrvngLvl
    0: 4mA
    1: 8mA
    2: 12mA
    3: 16mA
    

    Add and configure m_wPadDrvngLvl in the screen parameters, and run disp again to display the diagram. The driving level of the pin can be uniformly adjusted.

    The configurable driving levels of different pins may vary. For details, please refer to the relevant GPIO PAD configuration document.

    3、VGA driving capability config/detect

    Config driving capability:

    echo vga_drv RTrim GTrim BTrim > /proc/mi_modules/mi_disp/debug_hal/turndrv
    

    Detect driving capability:

    cat /proc/mi_modules/mi_disp/debug_hal/turndrv
    

    RTrim/GTrim/BTrim value range is 0x00 ~ 0x7F. The larger the value, the greater the driving capability.

    1.4.2. clk positive and negative configuration

    screen parameters path:

    project\board\$(chip)\screen_param\config_disp.json
    
    m_bPanelInvDCLK
    0: default
    1: reverse
    

    Configure m_bPanelInvDCLK in the screen parameters, and run disp again to display the diagram. The forward and reverse direction of the clk can be adjusted.


    1.5. SATA


    1.5.1. HW CTS Setting

    Perform SATA PHY layer signal quality tuning via the Sysfs interface. The confirmed parameters must be updated to the dts before the SATA driver will apply the adjusted CTS parameters.

    Sysfs path: /sys/devices/virtual/sgs/sata or sata1

    Note: The transmission speed (test_gen) must be set before the test pattern (cts_pattern), because the PHY driver needs speed information to correctly force speed when entering CTS pattern.

    a. Set Transmission Speed (test_gen)

    test_gen Speed Description
    0 1.5 Gbps SATA GEN1
    1 3.0 Gbps SATA GEN2
    2 6.0 Gbps SATA GEN3
    echo [test_gen] > test_gen
    

    b. Set Test Pattern (cts_pattern)

    cts_pattern Pattern Name Description
    0 HFTP High Frequency Test Pattern
    1 MFTP Mid Frequency Test Pattern
    2 LFTP Low Frequency Test Pattern
    3 LBP Low Bit Pattern
    4 SSOP Spread Spectrum Oscillation Pattern
    echo [cts_pattern] > cts_pattern
    

    c. Set TX Parameters (de_emphasis)

    TX parameters include De-emphasis and voltage swing (Vpp) for signal quality optimization:

    echo [enable] [db] [level] > de_emphasis
    
    Parameter Description Available Values
    enable GEN3 de-emphasis enable 0=Vpp only, 1=enable de-emphasis
    db De-emphasis level (only for enable=1) 0=-1.5dB, 1=-2.5dB, 2=-3.5dB, 3=-6.0dB
    level Voltage swing level 0~8, see table below

    Voltage swing (Vpp) levels and GEN support:

    level Voltage Swing GEN1 GEN2 GEN3
    0 0.4 Vpp Yes Yes Yes
    1 0.5 Vpp Yes Yes Yes
    2 0.6 Vpp Yes Yes Yes
    3 0.7 Vpp Yes Yes Yes
    4 0.8 Vpp Yes Yes Yes
    5 0.9 Vpp - Yes Yes
    6 1.0 Vpp - - Yes
    7 1.1 Vpp - - Yes
    8 1.2 Vpp - - Yes

    GEN1/GEN2 only support Vpp adjustment. De-emphasis is only available in GEN3 mode.

    Configuration examples:

    # GEN3: Vpp only (no de-emphasis), 0.7Vpp
    echo 0 0 3 > de_emphasis
    
    # GEN3: -2.5dB de-emphasis + 0.8Vpp (medium distance)
    echo 1 1 4 > de_emphasis
    
    # GEN3: -6.0dB de-emphasis + 1.0Vpp (long distance)
    echo 1 3 6 > de_emphasis
    

    1.5.2. Hardware Parameter Configured by dts

    The optimal parameters confirmed by CTS testing must be updated to the dts. The Sysfs command echo [enable] [db] [level] > de_emphasis maps directly to the DTS parameter tx_gen3_de_emphasis = <enable>, <db>, <level>. The value 0xFF means use default.

    sgs_sataphy: sgs-sata-phy {
        compatible = "sgs,sataphy";
        
        phy_mode = <2>;                              /* PHY speed mode: 0=GEN1, 1=GEN2, 2=GEN3 */
        tx_ssc_mode = <0>;                           /* Spread spectrum clock: 0=disable, 1=enable */
        tx_gen1_gen2_Vpp = <0xFF>,<0xFF>;            /* GEN1/GEN2 TX voltage swing, 0xFF=default */
        tx_gen3_de_emphasis = <0xFF>,<0xFF>,<0xFF>;  /* GEN3: <enable>,<db>,<level>, 0xFF=default */
        rx_eq_rs1 = <0xFF>,<0xFF>,<0xFF>;            /* RX equalization RS1, 0xFF=default */
        rx_eq_rs2 = <0xFF>,<0xFF>,<0xFF>;            /* RX equalization RS2, 0xFF=default */
        rx_eq_ctle = <0xFF>;                         /* RX equalization CTLE, 0xFF=default */
        
    };
    

    DTS configuration examples:

    /* Example 1: GEN3 with -2.5dB de-emphasis + 0.8Vpp */
    tx_gen3_de_emphasis = <1>, <1>, <4>;
    
    /* Example 2: GEN3 Vpp only (no de-emphasis), 0.7Vpp */
    tx_gen3_de_emphasis = <0>, <0xFF>, <3>;
    
    /* Example 3: GEN1/GEN2 Vpp, two values for GEN1 and GEN2 respectively */
    tx_gen1_gen2_Vpp = <3>, <3>;   /* GEN1=0.7Vpp, GEN2=0.7Vpp */
    

    1.6. HDMITX


    1.6.1. Driving Capability Adjustment

    HDMITX driver supports configuraing the driving capability by "echo" cmd. The configuration is as follows:

    echo Tap1Ch0 Tap1Ch1 Tap1Ch2 Tap1Ch3 Tap2Ch0 Tap2Ch1 Tap2Ch2 Tap2Ch3 RetrmCh PreDrvCh MuCh > /proc/mi_modules/mi_hdmi/debug_hal/turndrv
    

    Get driving config:

    cat /proc/mi_modules/mi_hdmi/debug_hal/turndrv
    

    1.6.2. SSC

    Spread spectrum setting supports auto & manual by "echo" cmd.

    The auto adjustment is as follows:

    echo ssc $en auto Modulation(hz) Deviation(%) > /proc/mi_modules/mi_hdmi/debug_hal/turndrv
    

    The manual adjustment is as follows:

    echo ssc $en manual STEP(0x) SAPN(0x) > /proc/mi_modules/mi_hdmi/debug_hal/turndrv
    

    Get adjustment parameters as follows:

    cat /proc/mi_modules/mi_hdmi/debug_hal/turndrv
    

    1.7. IIC


    1.7.1. Configuration of IIC Drive Capability

    The drive capability of IIC is influenced by both the drive strength of the GPIO used and the IIC IP settings. The configuration method for the former can refer to the GPIO debugging methods, while adjustments for the latter are as follows;

    The IIC IP provides four configurable settings related to drive capability, as shown in the following table:

    Mode Num Mode Name description
    Mode 1 Pure Open drain Pure open-drain output without auxiliary drive; this results in the slowest rise time
    Mode 2 PUSH EN Auxiliary drive for 1 T, the rise time is faster than Mode 1
    Mode 3 PUSH EN M+ Auxiliary drive for 16 T, the rise time is faster than Mode 2
    Mode 4 PUSH PULL Push-pull output mode, this results in a faster rise time

    The IIC IP drive capability needs to be configured in the IIC node within the dtsi file, with the file path being:

    #arm32
    kernel/arch/arm/boot/dts/$(boardname).dtsi
    #arm64
    kernel/arch/arm64/boot/dts/sgs/$(boardname).dtsi
    

    The node properties are as follows. Modify the output-mode to the target mode and then compile to change the IIC IP output mode configuration:

            i2c0: i2c@1f223000 {
                    compatible = "sgs,i2c";
                    reg = <0x1F223000 0x200>;
                    #address-cells = <1>;
                    #size-cells = <0>;
                    interrupts = <GIC_SPI INT_IRQ_MIIC_0 IRQ_TYPE_LEVEL_HIGH>;
                    clocks = <&CLK_miic0>;
                    dma-enable;
                    group = <0>;
                    speed = <200000>;
                    //if u want set tSU/tHD, it should be set to a non-zero value, with units in ns
                    t-su-sta = <0>;
                    t-hd-sta = <0>;
                    t-su-sto = <0>;
                    t-hd-sto = <0>;
                    //1->open drain; 2->open drain + one push; 3->open drain + mult push; 4->push-pull
                    output-mode = <2>;
                    status = "okay";
                };
    

    1.8. PWM


    1.8.1. Adjustment of PWM Drive Capability

    The drive capability of PWM is influenced by the GPIO it uses; the configuration method for the latter can refer to the GPIO debugging methods.


    1.9. MSPI


    1.9.1. Adjustment of MSPI Drive Capability

    The drive capability of MSPI is influenced by the GPIO it uses; the configuration method for the latter can refer to the GPIO debugging methods.


    1.10. UART


    1.10.1. Adjustment of UART Drive Capability

    The drive capability of UART is influenced by the GPIO it uses; the configuration method for the latter can refer to the GPIO debugging methods.


    1.11. PCIe


    PCIe PHY signal parameters can be tuned at runtime through the debugfs interface for signal quality debugging. Prerequisite: the kernel must have CONFIG_DEBUG_FS enabled.

    The debugfs nodes are located at /sys/kernel/debug/pcie\<port>/, where \<port> is the PCIe port number (0 or 1).

    1.11.1. swing_mode (Swing Mode)

    Configure the PCIe transmitter swing mode.

    Value Description
    0 Full-swing
    1 Low-swing
    1. Query the current value: cat /sys/kernel/debug/pcie0/swing_mode

    2. Set the value: echo 1 > /sys/kernel/debug/pcie0/swing_mode

    1.11.2. swing_amplitude (Swing Amplitude)

    Configure the PCIe transmitter swing amplitude gear. Only configurable and readable in Low-swing mode. PCIe has two lanes, and the configuration applies to both lanes simultaneously.

    Gear Register Value Description
    0 0x6C -1.5dB (84%)
    1 0x60 -2.5dB (75%)
    2 0x56 -3.5dB (67%)
    3 0x4D -4.5dB (60%)
    4 0x40 -6dB (50%)
    5 0x36 -7.6dB (42%)
    1. Query the current value: cat /sys/kernel/debug/pcie0/swing_amplitude

    2. Set the value: echo 3 > /sys/kernel/debug/pcie0/swing_amplitude

    1.11.3. de_emphasis_us (De-emphasis - Upstream Port)

    Configure the de-emphasis parameter for the PCIe upstream port (EP mode). Only configurable and readable in Full-swing mode, and only visible in EP mode.

    Value Description
    0 -6dB
    1 -3.5dB
    1. Query the current value: cat /sys/kernel/debug/pcie0/de_emphasis_us

    2. Set the value: echo 1 > /sys/kernel/debug/pcie0/de_emphasis_us

    1.11.4. de_emphasis_ds (De-emphasis - Downstream Port)

    Configure the de-emphasis parameter for the PCIe downstream port (RC mode). Only configurable and readable in Full-swing mode, and only visible in RC mode.

    Value Description
    0 -6dB
    1 -3.5dB
    1. Query the current value: cat /sys/kernel/debug/pcie0/de_emphasis_ds

    2. Set the value: echo 1 > /sys/kernel/debug/pcie0/de_emphasis_ds

    1.11.5. status (Status Overview)

    Display all current PHY parameter configurations in read-only mode.

    cat /sys/kernel/debug/pcie0/status
    

    2. Digital Interface Driving Capability Adjustment

    2.1. Usage Background

    Since GPIO lib does not support interfaces for GPIO pull-up, pull-down and driving capability adjustment, our GPIO Hal layer driver lacks the support of GPIO pull-up, pull-down and driving capability setting. In daily use, however, the GPIO pull-up, pull-down and driving capability often need to be dynamically adjusted, so it is necessary to add APIs as well as user-level interfaces for these setting.

    2.2. Kernel Interface

    2.2.1. sgs_gpio_pull_up

    • Objective

      Enable the pull-up function of a specified GPIO.

    • Syntax

      U8 sgs_gpio_pull_up(U8 gpio_index)
      
    • Parameter

      Parameter Description
      gpio index gpio num
    • Return Value

      Return Value Description
      0 Setting successful.
      Other The pin does not support pull-up and pull-down settings or the input parameter is incorrect.

    2.2.2. sgs_gpio_pull_down

    • Objective

      Enable the pull-down function of a specified GPIO.

    • Syntax

      U8 sgs_gpio_pull_down(U8 gpio_index)
      
    • Parameter

      Parameter Description
      gpio index gpio num
    • Return Value

      Return Value Description
      0 Setting successful.
      Other The pin does not support pull-up and pull-down settings or the input parameter is incorrect.

    2.2.3. sgs_gpio_pull_off

    • Objective

      Disable the pull-up/pull-down function of a specified GPIO, and switch the GPIO to no-pull state.

    • Syntax

      U8 sgs_gpio_pull_off(U8 gpio_index)
      
    • Parameter

      Parameter Description
      gpio index gpio num
    • Return Value

      Return Value Description
      0 Setting successful.
      Other The pin does not support pull-up and pull-down settings or the input parameter is incorrect.

    2.2.4. sgs_gpio_drv_set

    • Objective

      Set driving capability of a specified GPIO.

    • Syntax

      U8 sgs_gpio_drv_set(U8 gpio_index, U8 level)
      
    • Parameter

      Parameter Description
      gpio index gpio num
      level The level of supported driving capability: 0, 1, 2, 3...
    • Return Value

      Return Value Description
      0 Setting successful.
      Other The pin does not support pull-up and pull-down settings or the input parameter is incorrect.

    2.3. User-Level Tuning Guide

    2.3.1. Enable the Function

    To use the user-level interface, you need to enable CONFIG_MSYS_GPIO, the configuration is located in menuconfig:

    Device Drivers
        sgs SoC platform drivers
            msys api
                support GPIO pull and driving modify
    

    2.3.2. Use the Function

    Before setting the pull-up/pull-down, you need to set the GPIO to the input state. The pull-up and pull-down cannot be measured in the output state:

    1. # cd /sys/class/gpio
    2. # echo gpio_index > export
    3. # echo in > gpiogpio_index/direction
    

    Set pull-up, pull-down, or no-pull:

    1. # cd sys/class/sgs/msys
    2. # echo gpio_index/gpio_name down/up/off > gpio_pull
    

    Check the current state:

    1. # cd sys/class/sgs/msys
    2. # cat gpio_pull
    

    Using PAD_PM_GPIO0 as an example, set it to input state:

    1. # cd /sys/class/gpio
    2. # echo 71 > export
    3. # echo in > gpio71/direction
    

    Set it to pull-up:

    1. # cd sys/class/sgs/msys
    2. # echo 71 up > gpio_pull
    3. # echo PAD_PM_GPIO0 up > gpio_pull //the same to above
    

    Set it to no-pull:

    1. # cd sys/class/sgs/msys
    2. # echo 71 off > gpio_pull
    3. # echo PAD_PM_GPIO0 off > gpio_pull //the same to above
    

    Check the current state:

    1. # cd sys/class/sgs/msys
    2. # cat gpio_pull
    

    Before setting the driving capability, you need to set the GPIO to high level output state to facilitate measurement:

    1. # cd /sys/class/gpio
    2. # echo gpio_index > export
    3. # echo high > gpiogpio_index/direction
    

    Adjust the driving capability:

    1. # cd sys/class/sgs/msys
    2. # echo gpio_index/gpio_name level_num > gpio_drive
    

    Set PAD_PM_GPIO0 to 8mA as an example:

    1. # cd /sys/class/gpio
    2. # echo 71 > export
    3. # echo high > gpio71 /direction
    4. # cd sys/class/sgs/msys
    5. # echo 71 1 > gpio_drive
    6. # echo PAD_PM_GPIO0 1 > gpio_drive //the same to above
    

    Every time after echo command is executed, you can confirm the status of the previous echo command by cat the same file.