From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hayes Wang Date: Thu, 11 Jun 2020 03:18:52 +0000 Subject: [PATCH u-boot 4/4] eth/r8152: support RTL8153B/RTL8154B In-Reply-To: <6c791826-d28b-cc89-b230-6b5d1a252399@denx.de> References: <1394712342-15778-377-Taiwan-albertk@realtek.com> <1394712342-15778-381-Taiwan-albertk@realtek.com> <78409d87-514d-1321-76de-a3b5161086a7@denx.de> <581ab1fe517047fb8624bf22ac46151c@realtek.com> <6a79f2a4d85c42138fb93ffef5222a6e@realtek.com> <6c791826-d28b-cc89-b230-6b5d1a252399@denx.de> Message-ID: <43e79ab399134d4392770f0f28a29372@realtek.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Marek Vasut [mailto:marex at denx.de] > Sent: Wednesday, June 10, 2020 9:21 PM [...] > >>>>> + /* ADC Bias Calibration: > >>>>> + * read efuse offset 0x7d to get a 17-bit data. Remove the > >> dummy/fake > >>>>> + * bit (bit3) to rebuild the real 16-bit data. Write the data to the > >>>>> + * ADC ioffset. > >>>>> + */ > >>>>> + ocp_data = r8152_efuse_read(tp, 0x7d); > >>>>> + data = (u16)(((ocp_data & 0x1fff0) >> 1) | (ocp_data & 0x7)); > >>>> > >>>> Are these type casts really needed ? > >>> > >>> Is there not a warning from u32 to u16? > >> > >> There is, but it seems justified to warn about conversion from u32 to > >> u16, so maybe that needs to be fixed ? > > > > Excuse me. I don't understand what you mean. > > The original is 17-bit data, so I use u32 to store it. And, > > the final desired data is 16-bit. That is why > > I have to convert it from u32 to u16. > > So what happens to that bit 17 , is it dropped ? I have descripted is in the code, such as following. /* ADC Bias Calibration: * read efuse offset 0x7d to get a 17-bit data. Remove the dummy/fake * bit (bit3) to rebuild the real 16-bit data. Write the data to the * ADC ioffset. */ The real data (16-bit) would be inserted a dummy bit, and store the 17-bit to efuse offset 0x7d. Therefore, when reading the 17-bit data from efuse, we have to remove the dummy to get the real data. Best Regards, Hayes