<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to read XPCS registers from Linux in S32G</title>
    <link>https://community.nxp.com/t5/S32G/How-to-read-XPCS-registers-from-Linux/m-p/1979153#M11375</link>
    <description>&lt;P&gt;Hello, &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/234092"&gt;@minersrevolt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for you post.&lt;/P&gt;
&lt;P&gt;Well, I do not see any reference code/document that accessing the XPCS registers from user space, may I know if you have referenced the xpcs_read/write functions from the BSP Linux source code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Chenyin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Oct 2024 10:26:51 GMT</pubDate>
    <dc:creator>chenyin_h</dc:creator>
    <dc:date>2024-10-22T10:26:51Z</dc:date>
    <item>
      <title>How to read XPCS registers from Linux</title>
      <link>https://community.nxp.com/t5/S32G/How-to-read-XPCS-registers-from-Linux/m-p/1977402#M11341</link>
      <description>&lt;P&gt;Attempting to read the SERDES XPCS registers from Linux following the S32G3 SerDes Subsystem Reference Manual and it does not return valid results. I wrote the following script to attempt this, would appreciate if someone could review this and provide a method if one already exists.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/bash
# Write to S32G3 SERDES XPCS registers, reference 
# S32G3 SerDes Subsystem Reference Manual section 5.2 Accessing XPCS registers
serdes=$1 # 0 or 1
xpcs=$2 # 0 or 1
reg=$3
write=$4
writeval=$5
debug=1

if [ $# -lt 3 ]; then
    echo "Read Usage: $0 &amp;lt;serdes 0|1&amp;gt; &amp;lt;xpcs 0|1&amp;gt; &amp;lt;hex register&amp;gt;"
    echo "Write Usage: $0 &amp;lt;serdes 0|1&amp;gt; &amp;lt;xpcs 0|1&amp;gt; &amp;lt;hex register&amp;gt; 1 &amp;lt;hex value to write&amp;gt;"
    exit 1
elif [ $# -ne 5 ]; then
    write=0
fi

addr_xpcs_0=0x823FC
addr_xpcs_1=0x82BFC
serdes0=0x40480000
serdes1=0x44180000

ofs=${reg#0x}
ofsleft="0x${ofs:0:4}"  # First 4 characters 
ofsright="0x${ofs:4:2}" # Last 2 characters
data1=$ofsleft


if [ $xpcs -eq 0 ]; then
    addr1=$addr_xpcs_0
    addr2=$((0x82000 + $ofsright * 4))
elif [ $xpcs -eq 1 ]; then
    addr1=$addr_xpcs_1
    addr2=$((0x82800 + $ofsright * 4))
else
    echo "Invalid choice for xpcs must be 0|1"
    exit 1
fi

if [ $serdes -eq 0 ]; then
    addr1=$(($addr1 + $serdes0))
    addr2=$(($addr2 + $serdes0))
elif [ $serdes -eq 1 ]; then
    addr1=$(($addr1 + $serdes1))
    addr2=$(($addr2 + $serdes1))
else
    echo "Serdes must be 0|1"
    exit 1
fi
addr1=$(printf "0x%x" $addr1)
addr2=$(printf "0x%x" $addr2)

devmem $addr1 32 $data1
if [ $write -eq 1 ]; then
    echo "writing $writeval to $reg"
    devmem $addr2 32 $writeval
else
    echo "reading from $reg : $(devmem $addr2)"
fi

if [ $debug -eq 1 ]; then
    echo "write $write"
    echo "writeval $writeval"
    echo "ofs $ofs"
    echo "ofsleft $ofsleft"
    echo "ofsright $ofsright"
    echo "data1 $data1"
    echo "addr1 $addr1"
    echo "addr2 $addr2"
fi&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 20:33:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32G/How-to-read-XPCS-registers-from-Linux/m-p/1977402#M11341</guid>
      <dc:creator>minersrevolt</dc:creator>
      <dc:date>2024-10-18T20:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to read XPCS registers from Linux</title>
      <link>https://community.nxp.com/t5/S32G/How-to-read-XPCS-registers-from-Linux/m-p/1977408#M11342</link>
      <description>&lt;P&gt;Here is the section from the User Guide I implemented,&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="minersrevolt_0-1729283706722.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/305614i2F8298DA9F06E068/image-size/medium?v=v2&amp;amp;px=400" role="button" title="minersrevolt_0-1729283706722.png" alt="minersrevolt_0-1729283706722.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2024 20:35:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32G/How-to-read-XPCS-registers-from-Linux/m-p/1977408#M11342</guid>
      <dc:creator>minersrevolt</dc:creator>
      <dc:date>2024-10-18T20:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to read XPCS registers from Linux</title>
      <link>https://community.nxp.com/t5/S32G/How-to-read-XPCS-registers-from-Linux/m-p/1979153#M11375</link>
      <description>&lt;P&gt;Hello, &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/234092"&gt;@minersrevolt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for you post.&lt;/P&gt;
&lt;P&gt;Well, I do not see any reference code/document that accessing the XPCS registers from user space, may I know if you have referenced the xpcs_read/write functions from the BSP Linux source code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Chenyin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 10:26:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32G/How-to-read-XPCS-registers-from-Linux/m-p/1979153#M11375</guid>
      <dc:creator>chenyin_h</dc:creator>
      <dc:date>2024-10-22T10:26:51Z</dc:date>
    </item>
  </channel>
</rss>

