Message ID | 20201016134320.20321-1-qiangqing.zhang@nxp.com |
---|---|
Headers | show |
Series | can: flexcan: add stop mode support for i.MX8QM | expand |
On 10/16/20 3:43 PM, Joakim Zhang wrote: > For SoCs with SCU support, need setup stop mode via SCU firmware, > so this property can help indicate a resource. > > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> > --- > Documentation/devicetree/bindings/net/can/fsl-flexcan.txt | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > index 6af67f5e581c..839c0c0064a2 100644 > --- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > +++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > @@ -43,6 +43,10 @@ Optional properties: > 0: clock source 0 (oscillator clock) > 1: clock source 1 (peripheral clock) > > +- fsl,can-index: The index of CAN instance. > + For SoCs with SCU support, need setup stop mode via SCU firmware, > + so this property can help indicate a resource. This property is not CAN specific. So the name could be more general. > + > - wakeup-source: enable CAN remote wakeup > > Example: > @@ -54,4 +58,5 @@ Example: > interrupt-parent = <&mpic>; > clock-frequency = <200000000>; // filled in by bootloader > fsl,clk-source = /bits/ 8 <0>; // select clock source 0 for PE > + fsl,can-index = /bits/ 8 <1>; // the second CAN instance > }; > Marc
Hi Marc, > -----Original Message----- > From: Marc Kleine-Budde <mkl@pengutronix.de> > Sent: 2020年10月16日 14:20 > To: Joakim Zhang <qiangqing.zhang@nxp.com>; robh+dt@kernel.org; > shawnguo@kernel.org; s.hauer@pengutronix.de > Cc: devicetree@vger.kernel.org; Peng Fan <peng.fan@nxp.com>; Ying Liu > <victor.liu@nxp.com>; netdev@vger.kernel.org; Pankaj Bansal > <pankaj.bansal@nxp.com>; linux-kernel@vger.kernel.org; > linux-can@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; > kernel@pengutronix.de > Subject: Re: [PATCH 3/6] dt-bindings: can: flexcan: add fsl, can-index property > to indicate a resource > > On 10/16/20 3:43 PM, Joakim Zhang wrote: > > For SoCs with SCU support, need setup stop mode via SCU firmware, so > > this property can help indicate a resource. > > > > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> > > --- > > Documentation/devicetree/bindings/net/can/fsl-flexcan.txt | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > > b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > > index 6af67f5e581c..839c0c0064a2 100644 > > --- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > > +++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt > > @@ -43,6 +43,10 @@ Optional properties: > > 0: clock source 0 (oscillator clock) > > 1: clock source 1 (peripheral clock) > > > > +- fsl,can-index: The index of CAN instance. > > + For SoCs with SCU support, need setup stop mode via > SCU firmware, > > + so this property can help indicate a resource. > > This property is not CAN specific. So the name could be more general. How about "fsl,index"? Best Regards, Joakim Zhang > > + > > - wakeup-source: enable CAN remote wakeup > > > > Example: > > @@ -54,4 +58,5 @@ Example: > > interrupt-parent = <&mpic>; > > clock-frequency = <200000000>; // filled in by bootloader > > fsl,clk-source = /bits/ 8 <0>; // select clock source 0 for PE > > + fsl,can-index = /bits/ 8 <1>; // the second CAN instance > > }; > > > > Marc > > -- > Pengutronix e.K. | Marc Kleine-Budde | > Embedded Linux | https://www.pengutronix.de | > Vertretung West/Dortmund | Phone: +49-231-2826-924 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On 10/16/20 8:46 AM, Joakim Zhang wrote: >>> @@ -2019,6 +2109,7 @@ static int flexcan_probe(struct platform_device >> *pdev) >>> priv->clk_src = clk_src; >>> priv->devtype_data = devtype_data; >>> priv->reg_xceiver = reg_xceiver; >>> + priv->can_idx = can_idx; >>> >>> if (priv->devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) { >>> priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD | @@ >> -2030,6 >>> +2121,10 @@ static int flexcan_probe(struct platform_device *pdev) >>> priv->can.bittiming_const = &flexcan_bittiming_const; >>> } >>> >>> + err = flexcan_setup_stop_mode(pdev); >>> + if (err == -EPROBE_DEFER) >>> + return -EPROBE_DEFER; >> >> You need to free "dev". What about moving this directly before allocating dev. > > Yes, need free "dev" here if defer probe. Flexcan_priv has not allocated > before allocating dev, but we need initialize and check it when setup stop > mode. Right, please take care of freeing all ressouces in case of defered probe. >> Do you have to undo device_set_wakeup_capable() and >> device_set_wakeup_enable() in case of a failure and/or on flexcan_remove()? > > Yes, should invoke device_wakeup_disable() in flexcan_remove. Make it so. regards, Marc
On 10/16/20 8:52 AM, Joakim Zhang wrote: > > Hi Marc, > >> -----Original Message----- >> From: Marc Kleine-Budde <mkl@pengutronix.de> >> Sent: 2020年10月16日 14:20 >> To: Joakim Zhang <qiangqing.zhang@nxp.com>; robh+dt@kernel.org; >> shawnguo@kernel.org; s.hauer@pengutronix.de >> Cc: devicetree@vger.kernel.org; Peng Fan <peng.fan@nxp.com>; Ying Liu >> <victor.liu@nxp.com>; netdev@vger.kernel.org; Pankaj Bansal >> <pankaj.bansal@nxp.com>; linux-kernel@vger.kernel.org; >> linux-can@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; >> kernel@pengutronix.de >> Subject: Re: [PATCH 3/6] dt-bindings: can: flexcan: add fsl, can-index property >> to indicate a resource >> >> On 10/16/20 3:43 PM, Joakim Zhang wrote: >>> For SoCs with SCU support, need setup stop mode via SCU firmware, so >>> this property can help indicate a resource. >>> >>> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> >>> --- >>> Documentation/devicetree/bindings/net/can/fsl-flexcan.txt | 5 +++++ >>> 1 file changed, 5 insertions(+) >>> >>> diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt >>> b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt >>> index 6af67f5e581c..839c0c0064a2 100644 >>> --- a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt >>> +++ b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt >>> @@ -43,6 +43,10 @@ Optional properties: >>> 0: clock source 0 (oscillator clock) >>> 1: clock source 1 (peripheral clock) >>> >>> +- fsl,can-index: The index of CAN instance. >>> + For SoCs with SCU support, need setup stop mode via >> SCU firmware, >>> + so this property can help indicate a resource. >> >> This property is not CAN specific. So the name could be more general. > > How about "fsl,index"? Maybe something with "scu", as it's specific to the SCU firmware. I think it's up to Rob's and the DT people. Marc
On 10/16/20 12:00 PM, Joakim Zhang wrote: >>>> +static int flexcan_stop_mode_enable_scfw(struct flexcan_priv *priv, >>>> +bool enabled) { >>>> + u8 idx = priv->can_idx; >>>> + u32 rsrc_id, val; >>>> + >>>> + if (idx == 0) >>>> + rsrc_id = IMX_SC_R_CAN_0; >>>> + else if (idx == 1) >>>> + rsrc_id = IMX_SC_R_CAN_1; >>>> + else >>>> + rsrc_id = IMX_SC_R_CAN_2; >>> >>> Can you introduce something like and make use of it: >>> >>> #define IMX_SC_R_CAN(x) (105 + (x)) >> OK. > > I thought it over again, from my point of view, use macro here directly could > be more intuitive, and can achieve a direct jump. > If change to above wrapper, on the contrary make confusion, and generate the > magic number 105. ☹ The define should go into the rsrc.h, and probably be: #define IMX_SC_R_CAN(x) (IMX_SC_R_CAN_0 + (x)) and if you change the firmware interface, you probably have more problems :) >>>> + >>>> + if (enabled) >>>> + val = 1; >>>> + else >>>> + val = 0; >>>> + >>>> + /* stop mode request via scu firmware */ >>>> + return imx_sc_misc_set_control(priv->sc_ipc_handle, rsrc_id, >>>> +IMX_SC_C_IPG_STOP, val); } > > We still need use IMX_SC_C_IPG_STOP, why not be consistent? Sorry I don't get what you want to tell me here. Marc