All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joao Pinto <Joao.Pinto-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>
To: Akinobu Mita
	<akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Joao Pinto <Joao.Pinto-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>
Cc: vinayak holikatti
	<vinholikatti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Julian Calaby
	<julian.calaby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	Gilad Broner <gbroner-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	Subhash Jadavani
	<subhashj-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	CARLOS.PALMINHA-HKixBCOQz3hWk0Htik3J/w@public.gmane.org,
	Ian Campbell
	<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"open list:OPEN FIRMWARE AND..."
	<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v7 3/3] add support for DWC UFS Host Controller
Date: Mon, 15 Feb 2016 11:16:26 +0000	[thread overview]
Message-ID: <56C1B38A.6070901@synopsys.com> (raw)
In-Reply-To: <CAC5umyh6VGfsD+CzuimiMCum=E4UrA0rGj7pgPaRLO_aVen-gQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Akinobu,

On 2/13/2016 1:27 PM, Akinobu Mita wrote:
> Hi Joao,
> 
> 2016-02-11 21:13 GMT+09:00 Joao Pinto <Joao.Pinto-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>:
>> +static int ufshcd_dwc_connection_setup(struct ufs_hba *hba)
>> +{
>> +       int ret = 0;
>> +
>> +       /* Local side Configuration */
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_TRAFFICCLASS), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), 0x6);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTMODE), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +
>> +       /* Peer side Configuration */
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(N_DEVICEID), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_PEERCPORTID), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_TRAFFICCLASS), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), 0x6);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_CPORTMODE), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +out:
>> +       return ret;
>> +}
> 
> This looks a bit redundant.  The most part of the functions in this file is
> doing ufshcd_dme_set() or ufshcd_dme_peer_set(), so should we
> introduce ufshcd_dme_set_attrs() like below?  It will also increase
> readability.

We can do that, it would make the function body lighter and more easy to read I
agree with you!

> 
> struct ufshcd_dme_attr_val {
>         u32 attr_sel;
>         u32 mib_val;
>         u8 peer;
> };
> 
> int ufshcd_dme_set_attrs(struct ufs_hba *hba,
>                         const struct ufshcd_dme_attr_val *v, int n)
> {
>         for (i = 0; i < n; i++) {
>                 int ret = ufshcd_dme_set_attr(hba, v[i].attr_sel, ...);
> 
>                 if (ret)
>                         return ret;
>         }
>         return 0;
> }
> 
> static int ufshcd_dwc_connection_setup(struct ufs_hba *hba)
> {
>         const struct ufshcd_dme_attr setup_attrs[] = {
>                 { UIC_ARG_MIB(T_CONNECTIONSTATE), 0, DME_LOCAL },
>                 { UIC_ARG_MIB(T_DEVICEID), 0, DME_LOCAL },
>                 ...
>         };
> 
>         return ufshcd_dme_set_attrs(hba, setup_attrs, ARRAY_SIZE(setup_attrs));
> }
> 
>> +static int ufshcd_dwc_setup_tc(struct ufs_hba *hba)
>> +{
>> +       int ret = 0;
>> +
>> +#ifdef CONFIG_SCSI_UFS_DWC_40BIT_RMMI
>> +       dev_info(hba->dev, "Configuring Test Chip 40-bit RMMI");
>> +       ret = ufshcd_dwc_setup_40bit_rmmi(hba);
>> +       if (ret) {
>> +               dev_err(hba->dev, "Configuration failed");
> 
> Please add \n in the end of message.
> (and there are same issues in this file)
> 
>> +
>> +/* Clock Divider Values: Hex equivalent of frequency in MHz */
>> +enum clk_div_values {
>> +       UFSHCD_CLK_DIV_62_5     = 0x3e,
>> +       UFSHCD_CLK_DIV_125      = 0x7d,
>> +       UFSHCD_CLK_DIV_200      = 0xc8,
>> +};
> 
> This is used as register value for DWC_UFS_REG_HCLKDIV.  So should they
> have similar prefix (DWC_UFS_REG_HCLKDIV_*)?

I agree with you, they should have since they are DWC specific.

> 
>> diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
> 
> ...
> 
>> +/*Other attributes*/
>> +#define VS_MPHYCFGUPDT         0xD085
>> +#define VS_DEBUGOMC            0xD09E
>> +#define VS_POWERSTATE          0xD083
> 
> Are these vendor specific attributes?  If so, please move them to
> ufshci-dwc.h.

These are not DWC specific, that's why I added them to the common unipro.h

> 

Thanks.


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Joao Pinto <Joao.Pinto@synopsys.com>
To: Akinobu Mita <akinobu.mita@gmail.com>,
	Joao Pinto <Joao.Pinto@synopsys.com>
Cc: vinayak holikatti <vinholikatti@gmail.com>,
	Julian Calaby <julian.calaby@gmail.com>,
	Christoph Hellwig <hch@infradead.org>,
	"Arnd Bergmann" <arnd@arndb.de>,
	Mark Rutland <mark.rutland@arm.com>,
	Gilad Broner <gbroner@codeaurora.org>,
	Subhash Jadavani <subhashj@codeaurora.org>,
	<CARLOS.PALMINHA@synopsys.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	LKML <linux-kernel@vger.kernel.org>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"open list:OPEN FIRMWARE AND..." <devicetree@vger.kernel.org>
Subject: Re: [PATCH v7 3/3] add support for DWC UFS Host Controller
Date: Mon, 15 Feb 2016 11:16:26 +0000	[thread overview]
Message-ID: <56C1B38A.6070901@synopsys.com> (raw)
In-Reply-To: <CAC5umyh6VGfsD+CzuimiMCum=E4UrA0rGj7pgPaRLO_aVen-gQ@mail.gmail.com>

Hi Akinobu,

On 2/13/2016 1:27 PM, Akinobu Mita wrote:
> Hi Joao,
> 
> 2016-02-11 21:13 GMT+09:00 Joao Pinto <Joao.Pinto@synopsys.com>:
>> +static int ufshcd_dwc_connection_setup(struct ufs_hba *hba)
>> +{
>> +       int ret = 0;
>> +
>> +       /* Local side Configuration */
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_PEERCPORTID), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_TRAFFICCLASS), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), 0x6);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_CPORTMODE), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +
>> +       /* Peer side Configuration */
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(N_DEVICEID), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(N_DEVICEID_VALID), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_PEERDEVICEID), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_PEERCPORTID), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_TRAFFICCLASS), 0);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_CPORTFLAGS), 0x6);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_CPORTMODE), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +       ret = ufshcd_dme_peer_set(hba, UIC_ARG_MIB(T_CONNECTIONSTATE), 1);
>> +       if (ret)
>> +               goto out;
>> +
>> +out:
>> +       return ret;
>> +}
> 
> This looks a bit redundant.  The most part of the functions in this file is
> doing ufshcd_dme_set() or ufshcd_dme_peer_set(), so should we
> introduce ufshcd_dme_set_attrs() like below?  It will also increase
> readability.

We can do that, it would make the function body lighter and more easy to read I
agree with you!

> 
> struct ufshcd_dme_attr_val {
>         u32 attr_sel;
>         u32 mib_val;
>         u8 peer;
> };
> 
> int ufshcd_dme_set_attrs(struct ufs_hba *hba,
>                         const struct ufshcd_dme_attr_val *v, int n)
> {
>         for (i = 0; i < n; i++) {
>                 int ret = ufshcd_dme_set_attr(hba, v[i].attr_sel, ...);
> 
>                 if (ret)
>                         return ret;
>         }
>         return 0;
> }
> 
> static int ufshcd_dwc_connection_setup(struct ufs_hba *hba)
> {
>         const struct ufshcd_dme_attr setup_attrs[] = {
>                 { UIC_ARG_MIB(T_CONNECTIONSTATE), 0, DME_LOCAL },
>                 { UIC_ARG_MIB(T_DEVICEID), 0, DME_LOCAL },
>                 ...
>         };
> 
>         return ufshcd_dme_set_attrs(hba, setup_attrs, ARRAY_SIZE(setup_attrs));
> }
> 
>> +static int ufshcd_dwc_setup_tc(struct ufs_hba *hba)
>> +{
>> +       int ret = 0;
>> +
>> +#ifdef CONFIG_SCSI_UFS_DWC_40BIT_RMMI
>> +       dev_info(hba->dev, "Configuring Test Chip 40-bit RMMI");
>> +       ret = ufshcd_dwc_setup_40bit_rmmi(hba);
>> +       if (ret) {
>> +               dev_err(hba->dev, "Configuration failed");
> 
> Please add \n in the end of message.
> (and there are same issues in this file)
> 
>> +
>> +/* Clock Divider Values: Hex equivalent of frequency in MHz */
>> +enum clk_div_values {
>> +       UFSHCD_CLK_DIV_62_5     = 0x3e,
>> +       UFSHCD_CLK_DIV_125      = 0x7d,
>> +       UFSHCD_CLK_DIV_200      = 0xc8,
>> +};
> 
> This is used as register value for DWC_UFS_REG_HCLKDIV.  So should they
> have similar prefix (DWC_UFS_REG_HCLKDIV_*)?

I agree with you, they should have since they are DWC specific.

> 
>> diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
> 
> ...
> 
>> +/*Other attributes*/
>> +#define VS_MPHYCFGUPDT         0xD085
>> +#define VS_DEBUGOMC            0xD09E
>> +#define VS_POWERSTATE          0xD083
> 
> Are these vendor specific attributes?  If so, please move them to
> ufshci-dwc.h.

These are not DWC specific, that's why I added them to the common unipro.h

> 

Thanks.

  parent reply	other threads:[~2016-02-15 11:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-11 12:13 [PATCH v7 0/3] add support for DWC UFS Controller Joao Pinto
2016-02-11 12:13 ` [PATCH v7 1/3] fixed typo in ufshcd-pltfrm Joao Pinto
2016-02-11 12:13 ` [PATCH v7 2/3] added UFS 2.0 capabilities Joao Pinto
2016-02-11 12:13 ` [PATCH v7 3/3] add support for DWC UFS Host Controller Joao Pinto
     [not found]   ` <ee97e9b0ece0d819debe403c752d233c6267e02e.1455192008.git.jpinto-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>
2016-02-12 16:36     ` Rob Herring
2016-02-12 16:36       ` Rob Herring
2016-02-12 17:52       ` Joao Pinto
2016-02-12 17:52         ` Joao Pinto
     [not found]         ` <56BE1BC8.5020604-HKixBCOQz3hWk0Htik3J/w@public.gmane.org>
2016-02-12 19:36           ` Rob Herring
2016-02-12 19:36             ` Rob Herring
2016-02-13 13:27     ` Akinobu Mita
2016-02-13 13:27       ` Akinobu Mita
     [not found]       ` <CAC5umyh6VGfsD+CzuimiMCum=E4UrA0rGj7pgPaRLO_aVen-gQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-15 11:16         ` Joao Pinto [this message]
2016-02-15 11:16           ` Joao Pinto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C1B38A.6070901@synopsys.com \
    --to=joao.pinto-hkixbcoqz3hwk0htik3j/w@public.gmane.org \
    --cc=CARLOS.PALMINHA-HKixBCOQz3hWk0Htik3J/w@public.gmane.org \
    --cc=akinobu.mita-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=gbroner-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
    --cc=julian.calaby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=subhashj-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=vinholikatti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.