Thread (73 messages) 73 messages, 9 authors, 2024-04-08

Re: [PATCH net-next v2 3/9] net: ethernet: oa_tc6: implement OA TC6 configuration function

From: <Parthiban.Veerasooran@microchip.com>
Date: 2023-10-25 12:03:18
Also in: linux-devicetree, linux-doc, lkml

Hi Andrew,

On 24/10/23 4:28 am, Andrew Lunn wrote:
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
quoted
+     /* Read and configure the IMASK0 register for unmasking the interrupts */
+     ret = oa_tc6_perform_ctrl(tc6, IMASK0, &regval, 1, false, false);
+     if (ret)
+             return ret;
Can you use oa_tc6_read_register() here? I guess the question is, what
does tc6->protect default to until it is set later in this function?
So long as it defaults to false, i guess you can use the register
read/write functions, which are a lot more readable than this generic
oa_tc6_perform_ctrl().
Yes, I will do that. Also for next two calls as well.
quoted
+
+     regval &= ~(TXPEM & TXBOEM & TXBUEM & RXBOEM & LOFEM & HDREM);
+
+     ret = oa_tc6_perform_ctrl(tc6, IMASK0, &regval, 1, true, false);
+     if (ret)
+             return ret;
+
+     /* Read STDCAP register to get the MAC-PHY standard capabilities */
+     ret = oa_tc6_perform_ctrl(tc6, STDCAP, &regval, 1, false, false);
+     if (ret)
+             return ret;
+
+     mincps = FIELD_GET(MINCPS, regval);
+     ctc = (regval & CTC) ? true : false;
+
+     regval = 0;
+     oa_node = of_get_child_by_name(spi->dev.of_node, "oa-tc6");
+     if (oa_node) {
+             /* Read OA parameters from DT */
+             if (of_property_present(oa_node, "oa-cps")) {
+                     ret = of_property_read_u32(oa_node, "oa-cps", &tc6->cps);
If of_property_read_u32() does not find the property, it is documented
to not touch tc6->cps. So you can set tc6->cps to the default 64,
before the big if, and skip the of_property_present(). You can then
probably remove the else at the end as well.
Ah ok, will do that.
quoted
+                     if (ret < 0)
+                             return ret;
+                     /* Return error if the configured cps is less than the
+                      * minimum cps supported by the MAC-PHY.
+                      */
+                     if (tc6->cps < mincps)
+                             return -ENODEV;
A dev_err() would be nice here to indicate why.
Ok sure.
quoted
+             } else {
+                     tc6->cps = 64;
+             }
+             if (of_property_present(oa_node, "oa-txcte")) {
+                     /* Return error if the tx cut through mode is configured
+                      * but it is not supported by MAC-PHY.
+                      */
+                     if (ctc)
+                             regval |= TXCTE;
+                     else
+                             return -ENODEV;
and a dev_err() here as well.
Ok sure.
quoted
+             }
+             if (of_property_present(oa_node, "oa-rxcte")) {
+                     /* Return error if the rx cut through mode is configured
+                      * but it is not supported by MAC-PHY.
+                      */
+                     if (ctc)
+                             regval |= RXCTE;
+                     else
+                             return -ENODEV;
+             }
and another dev_err(). Without these prints, you probably need to
modify the code to figure out why the probe failed.
Yes I understand. Will do that in the next revision.
quoted
+             if (of_property_present(oa_node, "oa-prote")) {
+                     regval |= PROTE;
+                     tc6->prote = true;
+             }
+     } else {
+             tc6->cps = 64;
+     }
+
+     regval |= FIELD_PREP(CPS, ilog2(tc6->cps) / ilog2(2)) | SYNC;
+
+     return oa_tc6_perform_ctrl(tc6, CONFIG0, &regval, 1, true, false);
+}
+
  static int oa_tc6_sw_reset(struct oa_tc6 *tc6)
  {
       u32 regval;
@@ -310,7 +387,7 @@ EXPORT_SYMBOL_GPL(oa_tc6_read_registers);
   * Returns pointer reference to the oa_tc6 structure if all the memory
   * allocation success otherwise NULL.
   */
-struct oa_tc6 *oa_tc6_init(struct spi_device *spi, bool prote)
+struct oa_tc6 *oa_tc6_init(struct spi_device *spi)
Was there a reason to have prote initially, and then remove it here?
The reason is, control communication uses "protect". But in the first 
patch there was no dt used. Later in this patch, dt used for all the 
configuration parameters and this also part of that. That's why removed 
and moved this to dt configuration.

What's your opinion? shall I keep as it is like this? or remove the 
protect in the first two patches and introduce in this patch?

Best Regards,
Parthiban V
     Andrew
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help