Re: [PATCH for-next] scsi: ufs: Update dwc driver maintainer to Pedro Sousa

2019-02-05 Thread Joao Pinto
Thanks Martin.

On 2/5/2019 3:37 AM, Martin K. Petersen wrote:
> Joao,
>
>> Currently I am managing the Synopsys drivers & tools team (full-time) and
>> so I am passing the DWC UFS driver maintenance to Pedro Sousa.
> Applied to 5.1/scsi-queue, thanks.
>


Re: [PATCH v3] MAINTAINERS: Add reviewers for UFS patches

2019-02-04 Thread Joao Pinto
Hi Marc,

Thanks for the pro-activity!

On 2/4/2019 12:11 PM, Marc Gonzalez wrote:
> According to git log and the linux-scsi archives, Vinayak has been
> inactive for several years. Removing him as maintainer will make the
> get_maintainer.pl script generate an extensive list of recipients.
> Add three reviewers as well to vet future UFS patches.
>
> Signed-off-by: Marc Gonzalez 
> ---
> Alim, Avri, Pedro, can we get your Acked-by for this patch?
> Did I leave anyone out who wants to be an official Reviewer?
> Martin: I'm hoping you can land this patch in time for 5.1-rc1 so that future
> patches get routed to the right people.
> ---
>  MAINTAINERS | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 8c68de3cfd80..7386f5d0f9d1 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -15676,7 +15676,9 @@ F:drivers/visorbus/
>  F:   drivers/staging/unisys/
>  
>  UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
> -M:   Vinayak Holikatti 
> +R:   Alim Akhtar 
> +R:   Avri Altman 
> +R:   Pedro Sousa 
>  L:   linux-scsi@vger.kernel.org
>  S:   Supported
>  F:   Documentation/scsi/ufs.txt

Acked-by: Joao Pinto 




Re: [PATCH for-next] scsi: ufs: Update dwc driver maintainer to Pedro Sousa

2019-01-30 Thread Joao Pinto
Hello Bart,

First of all thanks for the feedback.

On 1/30/2019 5:54 PM, Bart Van Assche wrote:
> On Wed, 2019-01-30 at 18:48 +0100, Joao Pinto wrote:
>> Currently I am managing the Synopsys drivers & tools team (full-time) and
>> so I am passing the DWC UFS driver maintenance to Pedro Sousa.
>>
>> Signed-off-by: Joao Pinto 
>> Cc: Pedro Sousa 
>> Cc: Marc Gonzalez 
>> Cc: Alex Lemberg 
>> ---
>>  MAINTAINERS | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 70c93b1..458a2a2 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -15673,7 +15673,7 @@ F:   Documentation/scsi/ufs.txt
>>  F:  drivers/scsi/ufs/
>>  
>>  UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
>> -M:  Joao Pinto 
>> +M:  Pedro Sousa 
>>  L:  linux-scsi@vger.kernel.org
>>  S:  Supported
>>  F:  drivers/scsi/ufs/*dwc*
> Shouldn't people have proven to be willing to stick around before being
> added as a kernel maintainer? Additionally, what is the experience level of
> Pedro with kernel development? All I know is the following:

Pedro Sousa is my team member and has been working in Unipro/UFS Synopsys
drivers for almost 2 years.

His work has been mainly internal, and now our goal is to start using the
mainline DWC UFS driver I submitted 2 years ago in our regular activities,
update and maintain it effectively as we are doing in other titles.

Currently I am Pedro' manager, and in my opinion he has the right experience for
this step and that is why I am suggesting to transfer Synopsys driver
maintenance from me to him.

>
> $ git log --author "Pedro Sousa" | wc -l
> 0
> $ git log | grep -c "Pedro Sousa"
> 0
>
> Are you aware that people who are not mentioned in the MAINTAINERS file are
> allowed to review kernel patches?

Yes, I am aware and Pedro is perfectly capable of doing that, and for that
reason I am suggesting him as the right person to maintain Synopsys UFS driver.

>
> Thanks,
>
> Bart.
>
Thanks,

Joao




[PATCH for-next] scsi: ufs: Update dwc driver maintainer to Pedro Sousa

2019-01-30 Thread Joao Pinto
Currently I am managing the Synopsys drivers & tools team (full-time) and
so I am passing the DWC UFS driver maintenance to Pedro Sousa.

Signed-off-by: Joao Pinto 
Cc: Pedro Sousa 
Cc: Marc Gonzalez 
Cc: Alex Lemberg 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 70c93b1..458a2a2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15673,7 +15673,7 @@ F:  Documentation/scsi/ufs.txt
 F: drivers/scsi/ufs/
 
 UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
-M: Joao Pinto 
+M: Pedro Sousa 
 L: linux-scsi@vger.kernel.org
 S: Supported
 F: drivers/scsi/ufs/*dwc*
-- 
2.7.4



Re: [PATCH v2] MAINTAINERS: Mark UFS as Orphan

2019-01-28 Thread Joao Pinto
Hi Marc,

On 1/28/2019 10:35 AM, Marc Gonzalez wrote:
> On 22/01/2019 18:39, Joao Pinto wrote:
>
>> On 1/22/2019 5:15 PM, Marc Gonzalez wrote:
>>
>>> Looking through git log and the linux-scsi archives, it seems that
>>> Vinayak vanished after 2013. Removing him as a maintainer will make
>>> get_maintainer.pl generate the list of relevant contributors.
>>>
>>> Signed-off-by: Marc Gonzalez 
>>> ---
>>> Martin, sorry for v1, it was a mistake.
>>> ---
>>>  MAINTAINERS | 3 +--
>>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>> index 32d76a90..76104c9c4824 100644
>>> --- a/MAINTAINERS
>>> +++ b/MAINTAINERS
>>> @@ -15666,9 +15666,8 @@ F:  drivers/visorbus/
>>>  F: drivers/staging/unisys/
>>>  
>>>  UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
>>> -M: Vinayak Holikatti 
>>>  L: linux-scsi@vger.kernel.org
>>> -S: Supported
>>> +S: Orphan
>>>  F: Documentation/scsi/ufs.txt
>>>  F: drivers/scsi/ufs/
>>>  
>> I started contributing to the UFS, but currently I am managing one of the 
>> driver
>> development teams in Synopsys, so my bandwitdh is now low.
>>
>> Currently I have a person in my team that is very involved in SW development 
>> for
>> UFS Host and we have plans to improve Synopsys driver and submit the 
>> improvements.
>>
>> I was planning to send this week a patch to add my team member as Maintainer 
>> of
>> the Synopsys UFS driver and if you agree I could suggest him to pick the 
>> total
>> UFS maintenance.
>>
>> Please let me know your thoughts about this.
> As far as I'm concerned, "Supported" or "Maintained" is better than "Orphan" 
> ;-)
>
> @Vinayak, do you want to remain as maintainer?
> Should your email address be updated?
>
> @Joao, is your team member still interested?
> I can send a patch adding him as maintainer, what's his name and address?

Yes, we are interested. I was planning to send a patch to put my team member
Pedro Sousa (pedrom.so...@synopsys.com) maintaining DWC UFS driver and so if
there are no objections I can send an e-mail adding Pedro as UFS and DWC UFS
maintainer.

Please let me know you thoughts,

Joao

>
> Is anyone else interested in being maintainer for drivers/scsi/ufs/ ?
>
> Regards.


Re: [PATCH v2] MAINTAINERS: Mark UFS as Orphan

2019-01-22 Thread Joao Pinto
Hi Marc and all,

On 1/22/2019 5:15 PM, Marc Gonzalez wrote:
> Looking through git log and the linux-scsi archives, it seems that
> Vinayak vanished after 2013. Removing him as a maintainer will make
> get_maintainer.pl generate the list of relevant contributors.
>
> Signed-off-by: Marc Gonzalez 
> ---
> Martin, sorry for v1, it was a mistake.
> ---
>  MAINTAINERS | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 32d76a90..76104c9c4824 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -15666,9 +15666,8 @@ F:drivers/visorbus/
>  F:   drivers/staging/unisys/
>  
>  UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER
> -M:   Vinayak Holikatti 
>  L:   linux-scsi@vger.kernel.org
> -S:   Supported
> +S:   Orphan
>  F:   Documentation/scsi/ufs.txt
>  F:   drivers/scsi/ufs/
>  

I started contributing to the UFS, but currently I am managing one of the driver
development teams in Synopsys, so my bandwitdh is now low.

Currently I have a person in my team that is very involved in SW development for
UFS Host and we have plans to improve Synopsys driver and submit the 
improvements.

I was planning to send this week a patch to add my team member as Maintainer of
the Synopsys UFS driver and if you agree I could suggest him to pick the total
UFS maintenance.

Please let me know your thoughts about this.

regards,

Joao



Re: [PATCH 1/1] scsi: ufs: changing maintainer

2017-07-18 Thread Joao Pinto

Hello Greg and Prabu,

Às 10:31 AM de 7/18/2017, Greg  Kroah-Hartman (gre...@linuxfoundation.org) 
escreveu:
> On Tue, Jul 18, 2017 at 09:15:58AM +, Prabu Thangamuthu wrote:
>> As per internal decision, Joao Pinto will be maintainer for DWC UFS driver.
> 
> That's "odd", does Joao want this?  Do you want this?
> 
> thanks,
> 
> greg k-h
> 

I developed and submited the driver a year ago, so I would be glad to maintain
it once again, no problem.

Best Regards,
Joao


Re: [PATCH V4 2/2] scsi: ufshcd-pci: Add Intel CNL support

2017-06-08 Thread Joao Pinto
Hello to all,

Às 2:16 PM de 6/7/2017, Christoph Hellwig escreveu:
> On Tue, Jun 06, 2017 at 02:35:31PM +0300, Adrian Hunter wrote:
>> Add PCI id and variant ops for Intel CNL UFS host controller.
> 
> Looks good:
> 
> Reviewed-by: Christoph Hellwig 
> 
> It would be great if we could fold tc-dwc-g210-pci into ufshcd-pci the
> same way.
> 

I have forward the suggestion to the person on charge of UFS driver maintenance
at Synopsys. We will definitely have a look at it!

Thanks,
Joao



Back to Synopsys

2016-11-15 Thread Joao Pinto
Hi all,

I am back to Synopsys, so please don't apply the patches I sent a few weeks ago
with the goal of changing the UFS drivers author e-mail.
I will be available to help in anything you need.

Thanks,
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: ufs: changing authors e-mail

2016-10-21 Thread Joao Pinto
Although I am leaving Synopsys, I would like to keep working with the
linux kernel community and help in what you might find useful. For that
I am sending this patch to change my contact e-mail. 

Signed-off-by: Joao Pinto 
---
 drivers/scsi/ufs/tc-dwc-g210-pci.c| 4 ++--
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c | 4 ++--
 drivers/scsi/ufs/tc-dwc-g210.c| 4 ++--
 drivers/scsi/ufs/tc-dwc-g210.h| 2 +-
 drivers/scsi/ufs/ufshcd-dwc.c | 4 ++--
 drivers/scsi/ufs/ufshcd-dwc.h | 2 +-
 drivers/scsi/ufs/ufshci-dwc.h | 2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
index c09a0fe..13b9e6c 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pci.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
  *
- * Authors: Joao Pinto 
+ * Authors: Joao Pinto 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -176,6 +176,6 @@ static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
 
 module_pci_driver(tc_dwc_g210_pci_driver);
 
-MODULE_AUTHOR("Joao Pinto ");
+MODULE_AUTHOR("Joao Pinto ");
 MODULE_DESCRIPTION("Synopsys Test Chip G210 PCI glue driver");
 MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c 
b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
index 2d3f527..89166a9 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
  *
- * Authors: Joao Pinto 
+ * Authors: Joao Pinto 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -109,5 +109,5 @@ static int tc_dwc_g210_pltfm_remove(struct platform_device 
*pdev)
 
 MODULE_ALIAS("platform:tc-dwc-g210-pltfm");
 MODULE_DESCRIPTION("Synopsys Test Chip G210 platform glue driver");
-MODULE_AUTHOR("Joao Pinto ");
+MODULE_AUTHOR("Joao Pinto ");
 MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
index dc03e47..aeff7ff 100644
--- a/drivers/scsi/ufs/tc-dwc-g210.c
+++ b/drivers/scsi/ufs/tc-dwc-g210.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
  *
- * Authors: Joao Pinto 
+ * Authors: Joao Pinto 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -315,6 +315,6 @@ int tc_dwc_g210_config_20_bit(struct ufs_hba *hba)
 }
 EXPORT_SYMBOL(tc_dwc_g210_config_20_bit);
 
-MODULE_AUTHOR("Joao Pinto ");
+MODULE_AUTHOR("Joao Pinto ");
 MODULE_DESCRIPTION("Synopsys G210 Test Chip driver");
 MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/scsi/ufs/tc-dwc-g210.h b/drivers/scsi/ufs/tc-dwc-g210.h
index fb177db..3ec4373 100644
--- a/drivers/scsi/ufs/tc-dwc-g210.h
+++ b/drivers/scsi/ufs/tc-dwc-g210.h
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
  *
- * Authors: Joao Pinto 
+ * Authors: Joao Pinto 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c
index 5fd16c7..28bd3a3 100644
--- a/drivers/scsi/ufs/ufshcd-dwc.c
+++ b/drivers/scsi/ufs/ufshcd-dwc.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
  *
- * Authors: Joao Pinto 
+ * Authors: Joao Pinto 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -149,6 +149,6 @@ int ufshcd_dwc_link_startup_notify(struct ufs_hba *hba,
 }
 EXPORT_SYMBOL(ufshcd_dwc_link_startup_notify);
 
-MODULE_AUTHOR("Joao Pinto ");
+MODULE_AUTHOR("Joao Pinto ");
 MODULE_DESCRIPTION("UFS Host driver for Synopsys Designware Core");
 MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/scsi/ufs/ufshcd-dwc.h b/drivers/scsi/ufs/ufshcd-dwc.h
index c8be295..0bbad1b 100644
--- a/drivers/scsi/ufs/ufshcd-dwc.h
+++ b/drivers/scsi/ufs/ufshcd-dwc.h
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
  *
- * Authors: Joao Pinto 
+ * Authors: Joao Pinto 
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
diff --git a/drivers/scsi/ufs/ufshci-dwc.h b/drivers/scsi/ufs/ufshci-dwc.h
index ca341fe..1b31330 100644
--- a/drivers/scsi/ufs/ufshci-dwc.h
+++ b/drivers/scsi/ufs/ufshci-dwc.h
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2015-2016 Synopsys, Inc. (www.syno

[PATCH] scsi: ufs: changing maintainer

2016-10-14 Thread Joao Pinto
I am going to leave Synopsys and so this patch changes the Maintainer
for UFS Synopsys' specific drivers to my colleagues Manjunath and Prabu.

Signed-off-by: Joao Pinto 
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5ac91d8a..d9855b5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12084,7 +12084,8 @@ F:  Documentation/scsi/ufs.txt
 F: drivers/scsi/ufs/
 
 UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
-M: Joao Pinto 
+M: Manjunath M Bettegowda 
+M: Prabu Thangamuthu 
 L: linux-scsi@vger.kernel.org
 S: Supported
 F: drivers/scsi/ufs/*dwc*
-- 
1.8.1.5

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


[PATCH] ufs: changing maintainer

2016-10-13 Thread Joao Pinto

Signed-off-by: Joao Pinto 
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5ac91d8a..d9855b5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12084,7 +12084,8 @@ F:  Documentation/scsi/ufs.txt
 F: drivers/scsi/ufs/
 
 UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
-M: Joao Pinto 
+M: Manjunath M Bettegowda 
+M: Prabu Thangamuthu 
 L: linux-scsi@vger.kernel.org
 S: Supported
 F: drivers/scsi/ufs/*dwc*
-- 
1.8.1.5

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


Re: UFS API in the kernel

2016-09-28 Thread Joao Pinto

I was able to get the 7 patches to have the UFS IOCTL features from your repo.
BTW, why weren't these features submitted to the kernel?
I checked lots of tweaks that you have been making to the UFS... do you
synchronize them periodically with the mainline? Thanks!

On 9/28/2016 10:19 AM, Joao Pinto wrote:
> 
> Hi again!
> Could you also send me an example of how you are using the IOCTL from your 
> user
> app (send/receive data)? I already have my implemented but you use a different
> mechanism (I have checked your structures in uapi/scsi/ufs/) and I have to 
> port
> it! Thanks!
> 
> 
> On 9/28/2016 10:06 AM, Joao Pinto wrote:
>>
>> Hi Subhash,
>>
>> On 9/28/2016 12:05 AM, subha...@codeaurora.org wrote:
>>> Hi Joao,
>>>
>>>
>>> On 2016-09-26 18:10, Kiwoong Kim wrote:
>>>> Hi.
>>>>
>>>> If you want to declare some things for user interface,
>>>> is it be better to put those thing include/uapi/linux/ than include/linux?
>>>>
>>>> Agreed with Mr. Pinto's opinion with respect to implementing additional 
>>>> ioctls.
>>>
>>> Yes, "scsi_host_template" allows the LLD's to export their ioctl callback 
>>> and
>>> then you can use the sg interface to issue UFS specific ioctls. We had
>>> implemented similar ioctl for our use, here is the reference code:
>>> https://source.codeaurora.org/quic/la/kernel/msm-3.18/tree/drivers/scsi/ufs/ufshcd.c?h=LA.HB.1.1.1.c2#n6791.
>>> This was mainly done to  export the UFS query request interface to user 
>>> space.
>>> Declarations where exported under include/uapi/scsi/ufs/ . If you want to 
>>> build
>>> upon this already existing functionality, i can post the formal patch on 
>>> mailing
>>> list.
>>
>> Yes, of course I have interest on building on top of what you have done 
>> already.
>> Did yu submit this patch to the kernel already? Could you please send me the
>> patch and kernel version to apply?
>>
>> Thanks,
>> Joao
>>
>>>
>>> Regards,
>>> Subhash
>>>
>>>
>>>>
>>>> Regards.
>>>>
>>>>> -Original Message-
>>>>> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
>>>>> ow...@vger.kernel.org] On Behalf Of Shaun Tancheff
>>>>> Sent: Tuesday, September 27, 2016 4:23 AM
>>>>> To: Joao Pinto
>>>>> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org
>>>>> Subject: Re: UFS API in the kernel
>>>>>
>>>>> On Thu, Sep 22, 2016 at 10:21 AM, Joao Pinto 
>>>>> wrote:
>>>>>> Hi!
>>>>>>
>>>>>> I am designing an application that has the goal to be an utility for
>>>>>> Unipro and UFS testing purposes. This application is going to run on
>>>>>> top of a recent Linux Kernel containing the new UFS stack (including the
>>>>> new DWC drivers).
>>>>>>
>>>>>> I am considering doing the following:
>>>>>> a) Create a new config item called CONFIG_UFS_CHARDEV which is going
>>>>>> to create a char device responsible to make some IOCTL available for
>>>>>> user-space applications
>>>>>> b) Create a linux/ufs.h header file that contains data structures
>>>>>> declarations that will be needed in user-space applications
>>>>>
>>>>> I am not very familiar with UFS devices, that said you should have an sgX
>>>>> chardev being created already so you can handle SG_IO requests.
>>>>> There also appear to be some sysfs entries being created.
>>>>>
>>>>> So between sg and sysfs you should be able to handle any user-space out of
>>>>> band requests without resorting to making a new chardev.
>>>>>
>>>>> Adding more sysfs entries, if you need them, should be fine.
>>>>>
>>>>> You may find it easier to expand on the existing interfaces than to get
>>>>> consensus on a new driver and ioctls.
>>>>>
>>>>> Hope this helps,
>>>>> Shaun
>>>>>
>>>>>> Could you please advise me about what the correct approach should be
>>>>>> to make it as standard as possible and usable in the future?
>>>>>>
>>>>>> Thank you very much for your help!
>>>>>>
>>&

Re: UFS API in the kernel

2016-09-28 Thread Joao Pinto

Hi Subhash,

On 9/28/2016 12:05 AM, subha...@codeaurora.org wrote:
> Hi Joao,
> 
> 
> On 2016-09-26 18:10, Kiwoong Kim wrote:
>> Hi.
>>
>> If you want to declare some things for user interface,
>> is it be better to put those thing include/uapi/linux/ than include/linux?
>>
>> Agreed with Mr. Pinto's opinion with respect to implementing additional 
>> ioctls.
> 
> Yes, "scsi_host_template" allows the LLD's to export their ioctl callback and
> then you can use the sg interface to issue UFS specific ioctls. We had
> implemented similar ioctl for our use, here is the reference code:
> https://source.codeaurora.org/quic/la/kernel/msm-3.18/tree/drivers/scsi/ufs/ufshcd.c?h=LA.HB.1.1.1.c2#n6791.
> This was mainly done to  export the UFS query request interface to user space.
> Declarations where exported under include/uapi/scsi/ufs/ . If you want to 
> build
> upon this already existing functionality, i can post the formal patch on 
> mailing
> list.

Yes, of course I have interest on building on top of what you have done already.
Did yu submit this patch to the kernel already? Could you please send me the
patch and kernel version to apply?

Thanks,
Joao

> 
> Regards,
> Subhash
> 
> 
>>
>> Regards.
>>
>>> -Original Message-
>>> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
>>> ow...@vger.kernel.org] On Behalf Of Shaun Tancheff
>>> Sent: Tuesday, September 27, 2016 4:23 AM
>>> To: Joao Pinto
>>> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org
>>> Subject: Re: UFS API in the kernel
>>>
>>> On Thu, Sep 22, 2016 at 10:21 AM, Joao Pinto 
>>> wrote:
>>> > Hi!
>>> >
>>> > I am designing an application that has the goal to be an utility for
>>> > Unipro and UFS testing purposes. This application is going to run on
>>> > top of a recent Linux Kernel containing the new UFS stack (including the
>>> new DWC drivers).
>>> >
>>> > I am considering doing the following:
>>> > a) Create a new config item called CONFIG_UFS_CHARDEV which is going
>>> > to create a char device responsible to make some IOCTL available for
>>> > user-space applications
>>> > b) Create a linux/ufs.h header file that contains data structures
>>> > declarations that will be needed in user-space applications
>>>
>>> I am not very familiar with UFS devices, that said you should have an sgX
>>> chardev being created already so you can handle SG_IO requests.
>>> There also appear to be some sysfs entries being created.
>>>
>>> So between sg and sysfs you should be able to handle any user-space out of
>>> band requests without resorting to making a new chardev.
>>>
>>> Adding more sysfs entries, if you need them, should be fine.
>>>
>>> You may find it easier to expand on the existing interfaces than to get
>>> consensus on a new driver and ioctls.
>>>
>>> Hope this helps,
>>> Shaun
>>>
>>> > Could you please advise me about what the correct approach should be
>>> > to make it as standard as possible and usable in the future?
>>> >
>>> > Thank you very much for your help!
>>> >
>>> > regards,
>>> > Joao
>>> > --
>>> > To unsubscribe from this list: send the line "unsubscribe linux-scsi"
>>> > in the body of a message to majord...@vger.kernel.org More majordomo
>>> > info at
>>> > https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_ma
>>> > jordomo-2Dinfo.html&d=DQICaQ&c=IGDlg0lD0b-nebmJJ0Kp8A&r=Wg5NqlNlVTT7Ug
>>> > l8V50qIHLe856QW0qfG3WVYGOrWzA&m=vJFB6pCywWtdvkgHz9Vc0jQz0xzeyZlr-7eCWY
>>> > u88nM&s=yiQLPFpqmMrbqLZz1Jb3aNqOje2dRMLJHEzUDobwcXc&e=
>>>
>>>
>>>
>>> -- 
>>> Shaun Tancheff
>>> -- 
>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>>> the body of a message to majord...@vger.kernel.org More majordomo info at
>>> http://vger.kernel.org/majordomo-info.html
>>
>>
>> -- 
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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


Re: UFS API in the kernel

2016-09-28 Thread Joao Pinto

Hi again!
Could you also send me an example of how you are using the IOCTL from your user
app (send/receive data)? I already have my implemented but you use a different
mechanism (I have checked your structures in uapi/scsi/ufs/) and I have to port
it! Thanks!


On 9/28/2016 10:06 AM, Joao Pinto wrote:
> 
> Hi Subhash,
> 
> On 9/28/2016 12:05 AM, subha...@codeaurora.org wrote:
>> Hi Joao,
>>
>>
>> On 2016-09-26 18:10, Kiwoong Kim wrote:
>>> Hi.
>>>
>>> If you want to declare some things for user interface,
>>> is it be better to put those thing include/uapi/linux/ than include/linux?
>>>
>>> Agreed with Mr. Pinto's opinion with respect to implementing additional 
>>> ioctls.
>>
>> Yes, "scsi_host_template" allows the LLD's to export their ioctl callback and
>> then you can use the sg interface to issue UFS specific ioctls. We had
>> implemented similar ioctl for our use, here is the reference code:
>> https://source.codeaurora.org/quic/la/kernel/msm-3.18/tree/drivers/scsi/ufs/ufshcd.c?h=LA.HB.1.1.1.c2#n6791.
>> This was mainly done to  export the UFS query request interface to user 
>> space.
>> Declarations where exported under include/uapi/scsi/ufs/ . If you want to 
>> build
>> upon this already existing functionality, i can post the formal patch on 
>> mailing
>> list.
> 
> Yes, of course I have interest on building on top of what you have done 
> already.
> Did yu submit this patch to the kernel already? Could you please send me the
> patch and kernel version to apply?
> 
> Thanks,
> Joao
> 
>>
>> Regards,
>> Subhash
>>
>>
>>>
>>> Regards.
>>>
>>>> -Original Message-
>>>> From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
>>>> ow...@vger.kernel.org] On Behalf Of Shaun Tancheff
>>>> Sent: Tuesday, September 27, 2016 4:23 AM
>>>> To: Joao Pinto
>>>> Cc: linux-scsi@vger.kernel.org; linux-ker...@vger.kernel.org
>>>> Subject: Re: UFS API in the kernel
>>>>
>>>> On Thu, Sep 22, 2016 at 10:21 AM, Joao Pinto 
>>>> wrote:
>>>>> Hi!
>>>>>
>>>>> I am designing an application that has the goal to be an utility for
>>>>> Unipro and UFS testing purposes. This application is going to run on
>>>>> top of a recent Linux Kernel containing the new UFS stack (including the
>>>> new DWC drivers).
>>>>>
>>>>> I am considering doing the following:
>>>>> a) Create a new config item called CONFIG_UFS_CHARDEV which is going
>>>>> to create a char device responsible to make some IOCTL available for
>>>>> user-space applications
>>>>> b) Create a linux/ufs.h header file that contains data structures
>>>>> declarations that will be needed in user-space applications
>>>>
>>>> I am not very familiar with UFS devices, that said you should have an sgX
>>>> chardev being created already so you can handle SG_IO requests.
>>>> There also appear to be some sysfs entries being created.
>>>>
>>>> So between sg and sysfs you should be able to handle any user-space out of
>>>> band requests without resorting to making a new chardev.
>>>>
>>>> Adding more sysfs entries, if you need them, should be fine.
>>>>
>>>> You may find it easier to expand on the existing interfaces than to get
>>>> consensus on a new driver and ioctls.
>>>>
>>>> Hope this helps,
>>>> Shaun
>>>>
>>>>> Could you please advise me about what the correct approach should be
>>>>> to make it as standard as possible and usable in the future?
>>>>>
>>>>> Thank you very much for your help!
>>>>>
>>>>> regards,
>>>>> Joao
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi"
>>>>> in the body of a message to majord...@vger.kernel.org More majordomo
>>>>> info at
>>>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_ma
>>>>> jordomo-2Dinfo.html&d=DQICaQ&c=IGDlg0lD0b-nebmJJ0Kp8A&r=Wg5NqlNlVTT7Ug
>>>>> l8V50qIHLe856QW0qfG3WVYGOrWzA&m=vJFB6pCywWtdvkgHz9Vc0jQz0xzeyZlr-7eCWY
>>>>> u88nM&s=yiQLPFpqmMrbqLZz1Jb3aNqOje2dRMLJHEzUDobwcXc&e=
>>>>
>>>>
>>>>
>>>> -- 
>>>> Shaun Tancheff
>>>> -- 
>>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>>>> the body of a message to majord...@vger.kernel.org More majordomo info at
>>>> http://vger.kernel.org/majordomo-info.html
>>>
>>>
>>> -- 
>>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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


[PATCH] scsi: ufs: Kconfig fix

2016-09-23 Thread Joao Pinto
Currently if we have PCI and UFSHCD configured in the kernel, both
SCSI_UFS_DWC_TC_PCI and SCSI_UFSHCD_PCI show up, which is not correct.
This patch changes the UFS Kconfig to assure hierarchy between the 2
options.

Signed-off-by: Joao Pinto 
---
 drivers/scsi/ufs/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 4796690..e27b4d4 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -63,7 +63,7 @@ config SCSI_UFSHCD_PCI
 
 config SCSI_UFS_DWC_TC_PCI
tristate "DesignWare pci support using a G210 Test Chip"
-   depends on SCSI_UFSHCD && PCI
+   depends on SCSI_UFSHCD_PCI
---help---
  Synopsys Test Chip is a PHY for prototyping purposes.
 
-- 
1.8.1.5

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


UFS API in the kernel

2016-09-22 Thread Joao Pinto
Hi!

I am designing an application that has the goal to be an utility for Unipro and
UFS testing purposes. This application is going to run on top of a recent Linux
Kernel containing the new UFS stack (including the new DWC drivers).

I am considering doing the following:
a) Create a new config item called CONFIG_UFS_CHARDEV which is going to create a
char device responsible to make some IOCTL available for user-space applications
b) Create a linux/ufs.h header file that contains data structures declarations
that will be needed in user-space applications

Could you please advise me about what the correct approach should be to make it
as standard as possible and usable in the future?

Thank you very much for your help!

regards,
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] scsi: ufs: tc-dwc-g210 driver fix for 20-bit RMMI

2016-07-14 Thread Joao Pinto
On 7/14/2016 10:17 AM, Joao Pinto wrote:
> On 7/12/2016 2:55 PM, Manjunath M B wrote:
>> The code was checking on PA_CONNECTEDRXLANES and
>> PA_CONNECTEDTXLANES attributes to program the Lane#1
>> attributes. The correct attributes are PA_AVAILRXDATALANES and
>> PA_AVAILTXDATALANES respectively.
>>
>> Signed-off-by: Manjunath M B 
>> ---
>>  drivers/scsi/ufs/tc-dwc-g210.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
>> index d6c5388..70db6d9 100644
>> --- a/drivers/scsi/ufs/tc-dwc-g210.c
>> +++ b/drivers/scsi/ufs/tc-dwc-g210.c
>> @@ -187,9 +187,9 @@ static int tc_dwc_g210_setup_20bit_rmmi_lane1(struct 
>> ufs_hba *hba)
>>  };
>>  
>>  /* Get the available lane count */
>> -ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDRXDATALANES),
>> +ufshcd_dme_get(hba, UIC_ARG_MIB(PA_AVAILRXDATALANES),
>>  &connected_rx_lanes);
>> -ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES),
>> +ufshcd_dme_get(hba, UIC_ARG_MIB(PA_AVAILTXDATALANES),
>>  &connected_tx_lanes);
>>  
>>  if (connected_tx_lanes == 2) {
>>

Tested-by: Joao Pinto 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] scsi: ufs: tc-dwc-g210 driver fix for 20-bit RMMI

2016-07-14 Thread Joao Pinto
On 7/12/2016 2:55 PM, Manjunath M B wrote:
> The code was checking on PA_CONNECTEDRXLANES and
> PA_CONNECTEDTXLANES attributes to program the Lane#1
> attributes. The correct attributes are PA_AVAILRXDATALANES and
> PA_AVAILTXDATALANES respectively.
> 
> Signed-off-by: Manjunath M B 
> ---
>  drivers/scsi/ufs/tc-dwc-g210.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
> index d6c5388..70db6d9 100644
> --- a/drivers/scsi/ufs/tc-dwc-g210.c
> +++ b/drivers/scsi/ufs/tc-dwc-g210.c
> @@ -187,9 +187,9 @@ static int tc_dwc_g210_setup_20bit_rmmi_lane1(struct 
> ufs_hba *hba)
>   };
>  
>   /* Get the available lane count */
> - ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDRXDATALANES),
> + ufshcd_dme_get(hba, UIC_ARG_MIB(PA_AVAILRXDATALANES),
>   &connected_rx_lanes);
> - ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES),
> + ufshcd_dme_get(hba, UIC_ARG_MIB(PA_AVAILTXDATALANES),
>   &connected_tx_lanes);
>  
>   if (connected_tx_lanes == 2) {
> 

Tested-by: Joao Pinto 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ufs: Adding license info do tc-dwc-g210 and ufshcd-dwc to enable loadable modules

2016-05-23 Thread Joao Pinto
This patch adds license info to the tc-dwc-g210 and ufshcd-dwc files in
order for them to have access to some ufshcd symbols when all are built
as modules.

Signed-off-by: Joao Pinto 
---
 drivers/scsi/ufs/tc-dwc-g210.c | 4 
 drivers/scsi/ufs/ufshcd-dwc.c  | 4 
 2 files changed, 8 insertions(+)

diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
index 181f208..d6c5388 100644
--- a/drivers/scsi/ufs/tc-dwc-g210.c
+++ b/drivers/scsi/ufs/tc-dwc-g210.c
@@ -313,3 +313,7 @@ out:
return ret;
 }
 EXPORT_SYMBOL(tc_dwc_g210_config_20_bit);
+
+MODULE_AUTHOR("Joao Pinto ");
+MODULE_DESCRIPTION("Synopsys G210 Test Chip driver");
+MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c
index 9b3ca7f..5fd16c7 100644
--- a/drivers/scsi/ufs/ufshcd-dwc.c
+++ b/drivers/scsi/ufs/ufshcd-dwc.c
@@ -148,3 +148,7 @@ out:
return err;
 }
 EXPORT_SYMBOL(ufshcd_dwc_link_startup_notify);
+
+MODULE_AUTHOR("Joao Pinto ");
+MODULE_DESCRIPTION("UFS Host driver for Synopsys Designware Core");
+MODULE_LICENSE("Dual BSD/GPL");
-- 
1.8.1.5

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


[PATCH 2/2] ufs: driver changed to avoid name collision with Samsung's

2016-05-16 Thread Joao Pinto
This patch changes the tc-dwc-g210-pci driver's name to avoid name collisions
with the Smsung's driver.

Signed-off-by: Joao Pinto 
---
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
index 0667c76..c09a0fe 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pci.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -164,7 +164,7 @@ static const struct pci_device_id tc_dwc_g210_pci_tbl[] = {
 MODULE_DEVICE_TABLE(pci, tc_dwc_g210_pci_tbl);
 
 static struct pci_driver tc_dwc_g210_pci_driver = {
-   .name = UFSHCD,
+   .name = "tc-dwc-g210-pci",
.id_table = tc_dwc_g210_pci_tbl,
.probe = tc_dwc_g210_pci_probe,
.remove = tc_dwc_g210_pci_remove,
-- 
1.8.1.5

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


[PATCH 0/2] UFS DWC Test Chip pci driver tweaks

2016-05-16 Thread Joao Pinto
This patch set has the tweaks that I described to you in an e-mail, all
related with the ufs test chip pci driver.

Joao Pinto (2):
  ufs: Test Chip pci driver not dependent of Samsung's
  ufs: driver changed to avoid name collision with Samsung's

 drivers/scsi/ufs/Kconfig   | 2 +-
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
1.8.1.5

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


[PATCH 1/2] ufs: Test Chip pci driver not dependent of Samsung's

2016-05-16 Thread Joao Pinto
This patch breaks the dependency between the two drivers, because they are
completely indenpendent.

Signed-off-by: Joao Pinto 
---
 drivers/scsi/ufs/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index e27b4d4..4796690 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -63,7 +63,7 @@ config SCSI_UFSHCD_PCI
 
 config SCSI_UFS_DWC_TC_PCI
tristate "DesignWare pci support using a G210 Test Chip"
-   depends on SCSI_UFSHCD_PCI
+   depends on SCSI_UFSHCD && PCI
---help---
  Synopsys Test Chip is a PHY for prototyping purposes.
 
-- 
1.8.1.5

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


[PATCH v16 9/9] ufs: add TC G210 pci driver

2016-05-11 Thread Joao Pinto
This patch adds a glue pci driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v15->v16 (Martin K. Petersen):
- The glue driver Makefile entry calls the dwc and tc objects directly.
Changes v13->v15:
- Nothing changed (just to keep up with patch set version).
Changes v12->v13:
- Nothing changed (just to keep up with patch set version).
Changes v10->v12 (Tomas Winkler):
- custom_phy_initialization replaced by phy_initialization
Changes v10->v11 (Arnd Bergmann):
- tc_type is now initialized to TC_G210_INV
- probe function checks if the test chip version is specified
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/Kconfig   |   8 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 181 +
 3 files changed, 190 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 81fdfb3..e27b4d4 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -61,6 +61,14 @@ config SCSI_UFSHCD_PCI
 
  If unsure, say N.
 
+config SCSI_UFS_DWC_TC_PCI
+   tristate "DesignWare pci support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PCI
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N.
+
 config SCSI_UFSHCD_PLATFORM
tristate "Platform bus based UFS Controller support"
depends on SCSI_UFSHCD
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index d5774c6..6e77cb0 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,4 +1,5 @@
 # UFSHCD makefile
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o ufshcd-dwc.o 
tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o 
tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
new file mode 100644
index 000..0667c76
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -0,0 +1,181 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+#include 
+#include 
+
+/* Test Chip type expected values */
+#define TC_G210_20BIT 20
+#define TC_G210_40BIT 40
+#define TC_G210_INV 0
+
+static int tc_type = TC_G210_INV;
+module_param(tc_type, int, 0);
+MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");
+
+static int tc_dwc_g210_pci_suspend(struct device *dev)
+{
+   return ufshcd_system_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_resume(struct device *dev)
+{
+   return ufshcd_system_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_suspend(struct device *dev)
+{
+   return ufshcd_runtime_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_resume(struct device *dev)
+{
+   return ufshcd_runtime_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_idle(struct device *dev)
+{
+   return ufshcd_runtime_idle(dev_get_drvdata(dev));
+}
+
+/**
+ * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_pci_hba_vops = {
+   .name   = "tc-dwc-g210-pci",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+};
+
+/**
+ * tc_dwc_g210_pci_shutdown - main function to put the controller in reset 
state
+ * @pdev: pointer to PCI device handle
+ */
+static void tc_dwc_g210_pci_shutdown(struct pci_dev *pdev)
+{
+   ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
+}
+
+/**
+ * tc_dwc_g210_pci_remove - de-allocate PCI/SCSI host and host memory space
+ * data structure memory
+ * @pdev - pointer to PCI handle
+ */
+static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
+{
+   struct ufs_hba *hba = pci_get_drvdata(pdev);
+
+   pm_runtime_forbid(&pdev->dev);
+   pm_runtime_get_noresume(&pdev->dev);
+   ufshcd_remove(hba);
+}
+
+/**
+ * tc_dwc_g210_pci_probe - probe routine of the driver
+ * @pdev: pointer to PCI device handle
+ * @id: PCI device id
+ *
+ * Returns 0 on success, non-zero value on failure
+ */
+static int
+tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   int err;
+
+   /* Check Test Chip type and set the specific setup routine 

[PATCH v16 8/9] add TC G210 platform driver

2016-05-11 Thread Joao Pinto
This patch adds a glue platform driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v15->v16 (Martin K. Petersen):
- The glue driver Makefile entry calls the dwc and tc objects directly.
Changes v13->v15:
- Nothing changed (just to keep up with patch set version).
Changes v12->v13 (Rob Herring):
- Removed spaces from the compatibility string (pltfm driver and DT bindings)
- Removed underscores from the node descriptor
Changes v11->v12 (Tomas Winkler):
- custom_phy_initialization replaced by phy_initialization
Changes v10->v11 (Arnd Bergmann):
- vops structs are now passed in .data
Changes v0->v10:
- This patch only appeared in v10

 .../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt |  26 +
 drivers/scsi/ufs/Kconfig   |   8 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 113 +
 4 files changed, 148 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c

diff --git a/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
new file mode 100644
index 000..71c0777
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
@@ -0,0 +1,26 @@
+* Universal Flash Storage (UFS) DesignWare Host Controller
+
+DWC_UFS nodes are defined to describe on-chip UFS host controllers and MPHY.
+Each UFS controller instance should have its own node.
+
+Required properties:
+- compatible   : compatible list must contain the PHY type & version:
+   "snps,g210-tc-6.00-20bit"
+   "snps,g210-tc-6.00-40bit"
+ complemented with the Controller IP version:
+   "snps,dwc-ufshcd-1.40a"
+ complemented with the JEDEC version:
+   "jedec,ufs-1.1"
+   "jedec,ufs-2.0"
+
+- reg  : 
+- interrupts   : 
+
+Example for a setup using a 1.40a DWC Controller with a 6.00 G210 40-bit TC:
+   dwc-ufs@d000 {
+   compatible = "snps,g210-tc-6.00-40bit",
+"snps,dwc-ufshcd-1.40a",
+"jedec,ufs-2.0";
+   reg = < 0xd000 0x1 >;
+   interrupts = < 24 >;
+   };
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 097894a..81fdfb3 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -72,6 +72,14 @@ config SCSI_UFSHCD_PLATFORM
 
  If unsure, say N.
 
+config SCSI_UFS_DWC_TC_PLATFORM
+   tristate "DesignWare platform support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PLATFORM
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N.
+
 config SCSI_UFS_QCOM
tristate "QCOM specific hooks to UFS controller platform driver"
depends on SCSI_UFSHCD_PLATFORM && ARCH_QCOM
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 8303bcc..d5774c6 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,4 +1,5 @@
 # UFSHCD makefile
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o 
tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c 
b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
new file mode 100644
index 000..69b7036
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -0,0 +1,113 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ufshcd-pltfrm.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+/**
+ * UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+   .phy_initialization = tc_dwc_g210_config_20_bit,
+};
+
+static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+   .phy_initialization = tc_dwc_g210_config_40_bit,
+};
+
+static const struct of_device_id tc_dwc_g210_pltfm_match[] = {
+   {

[PATCH v16 1/9] ufs: fixed typo in ufshcd-pltfrm

2016-05-11 Thread Joao Pinto
Fixed typo in ufshcd-pltfrm.

Signed-off-by: Joao Pinto 
Acked-by: Arnd Bergmann 
Acked-by: Tomas Winkler 
Reviewed-by: Hannes Reinecke 
---
Changes v0->v16:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 718f12e..db53f38 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -372,6 +372,6 @@ EXPORT_SYMBOL_GPL(ufshcd_pltfrm_init);
 
 MODULE_AUTHOR("Santosh Yaragnavi ");
 MODULE_AUTHOR("Vinayak Holikatti ");
-MODULE_DESCRIPTION("UFS host controller Pltform bus based glue driver");
+MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(UFSHCD_DRIVER_VERSION);
-- 
1.8.1.5

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


[PATCH v16 4/9] ufs: add unipro attributes

2016-05-11 Thread Joao Pinto
Add unipro attributes.

Signed-off-by: Joao Pinto 
Acked-by: Tomas Winkler 
Reviewed-by: Hannes Reinecke 
---
Changes v12->v16:
- Nothing changed (just to keep up with patch set version).
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 drivers/scsi/ufs/unipro.h | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
index e2854e4..eff8b56 100644
--- a/drivers/scsi/ufs/unipro.h
+++ b/drivers/scsi/ufs/unipro.h
@@ -36,6 +36,10 @@
 #define TX_LCC_SEQUENCER   0x0032
 #define TX_MIN_ACTIVATETIME0x0033
 #define TX_PWM_G6_G7_SYNC_LENGTH   0x0034
+#define TX_REFCLKFREQ  0x00EB
+#define TX_CFGCLKFREQVAL   0x00EC
+#defineCFGEXTRATTR 0x00F0
+#define DITHERCTRL20x00F1
 
 /*
  * M-RX Configuration Attributes
@@ -51,10 +55,40 @@
 #define RX_TERMINATION_FORCE_ENABLE0x0089
 #define RX_MIN_ACTIVATETIME_CAPABILITY 0x008F
 #define RX_HIBERN8TIME_CAPABILITY  0x0092
+#define RX_REFCLKFREQ  0x00EB
+#defineRX_CFGCLKFREQVAL0x00EC
+#define CFGWIDEINLN0x00F0
+#define CFGRXCDR8  0x00BA
+#define ENARXDIRECTCFG40x00F2
+#define CFGRXOVR8  0x00BD
+#define RXDIRECTCTRL2  0x00C7
+#define ENARXDIRECTCFG30x00F3
+#define RXCALCTRL  0x00B4
+#define ENARXDIRECTCFG20x00F4
+#define CFGRXOVR4  0x00E9
+#define RXSQCTRL   0x00B5
+#define CFGRXOVR6  0x00BF
 
 #define is_mphy_tx_attr(attr)  (attr < RX_MODE)
 #define RX_MIN_ACTIVATETIME_UNIT_US100
 #define HIBERN8TIME_UNIT_US100
+
+/*
+ * Common Block Attributes
+ */
+#define TX_GLOBALHIBERNATE UNIPRO_CB_OFFSET(0x002B)
+#define REFCLKMODE UNIPRO_CB_OFFSET(0x00BF)
+#define DIRECTCTRL19   UNIPRO_CB_OFFSET(0x00CD)
+#define DIRECTCTRL10   UNIPRO_CB_OFFSET(0x00E6)
+#define CDIRECTCTRL6   UNIPRO_CB_OFFSET(0x00EA)
+#define RTOBSERVESELECTUNIPRO_CB_OFFSET(0x00F0)
+#define CBDIVFACTORUNIPRO_CB_OFFSET(0x00F1)
+#define CBDCOCTRL5 UNIPRO_CB_OFFSET(0x00F3)
+#define CBPRGPLL2  UNIPRO_CB_OFFSET(0x00F8)
+#define CBPRGTUNINGUNIPRO_CB_OFFSET(0x00FB)
+
+#define UNIPRO_CB_OFFSET(x)(0x8000 | x)
+
 /*
  * PHY Adpater attributes
  */
@@ -119,6 +153,11 @@
 #define PA_TACTIVATE_TIME_UNIT_US  10
 #define PA_HIBERN8_TIME_UNIT_US100
 
+/*Other attributes*/
+#define VS_MPHYCFGUPDT 0xD085
+#define VS_DEBUGOMC0xD09E
+#define VS_POWERSTATE  0xD083
+
 /* PHY Adapter Protocol Constants */
 #define PA_MAXDATALANES4
 
-- 
1.8.1.5

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


[PATCH v16 2/9] ufs: add UFS 2.0 to ufshcd-pltfrm bindings

2016-05-11 Thread Joao Pinto
Add UFS 2.0 to the ufshcd-pltfrm devicetree binding.

Signed-off-by: Joao Pinto 
Acked-by: Rob Herring 
Acked-by: Tomas Winkler 
Reviewed-by: Hannes Reinecke 
---
Changes v12->v16:
- Nothing changed (just to keep up with patch set version).
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
index 66f6adf..a99ed55 100644
--- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
+++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
@@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host 
controllers.
 Each UFS controller instance should have its own node.
 
 Required properties:
-- compatible   : must contain "jedec,ufs-1.1", may also list one or 
more
- of the following:
+- compatible   : must contain "jedec,ufs-1.1" or "jedec,ufs-2.0", may
+ also list one or more of the following:
  "qcom,msm8994-ufshc"
  "qcom,msm8996-ufshc"
  "qcom,ufshc"
-- 
1.8.1.5

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


[PATCH v16 5/9] ufs: add link status to ufshci

2016-05-11 Thread Joao Pinto
Add link status to ufshci.

Signed-off-by: Joao Pinto 
Acked-by: Tomas Winkler 
Reviewed-by: Hannes Reinecke 
---
Changes v12->v16:
- Nothing changed (just to keep up with patch set version).
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 drivers/scsi/ufs/ufshci.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index 36f5879..9599741 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -220,6 +220,12 @@ enum {
 #define UIC_ARG_ATTR_TYPE(t)   (((t) & 0xFF) << 16)
 #define UIC_GET_ATTR_ID(v) (((v) >> 16) & 0x)
 
+/* Link Status*/
+enum link_status {
+   UFSHCD_LINK_IS_DOWN = 1,
+   UFSHCD_LINK_IS_UP   = 2,
+};
+
 /* UIC Commands */
 enum uic_cmd_dme {
UIC_CMD_DME_GET = 0x01,
-- 
1.8.1.5

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


[PATCH v16 0/9] add support for DWC UFS Controller

2016-05-11 Thread Joao Pinto
As requested, I am sending v15 to be included in the SCSI patchwork.
The patches were produced on top of the latest (2016-05-02) 4.7/scsi-queue
branch. The patches were also validated by checkpatch.pl.

The work consisted of:
- Fixed typo in ufshcd-pltfrm.c
- Tweak ufshcd.c for UFS 2.0 support
- Implement ufshcd-dwc which contains all DWC HW specific code
- Unipro attributes were added and new registers were added to the driver
- Implement a tc-dwc-g210 containing G210 MPHY specific code
- Implement a tc-dwc-g210 glue platform driver
- Implement a tc-dwc-g210 glue pci driver
- Documentation update

Joao Pinto (9):
  ufs: fixed typo in ufshcd-pltfrm
  ufs: add UFS 2.0 to ufshcd-pltfrm bindings
  ufs: add UFS 2.0 capabilities
  ufs: add unipro attributes
  ufs: add link status to ufshci
  ufs: add support for DesignWare Controller
  ufs: add support for Synopsys G210 Test Chip
  ufs: add TC G210 platform driver
  ufs: add TC G210 pci driver

 .../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt |  26 ++
 .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |   4 +-
 MAINTAINERS|   6 +
 drivers/scsi/ufs/Kconfig   |  16 ++
 drivers/scsi/ufs/Makefile  |   2 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 181 
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 113 
 drivers/scsi/ufs/tc-dwc-g210.c | 315 +
 drivers/scsi/ufs/tc-dwc-g210.h |  19 ++
 drivers/scsi/ufs/ufshcd-dwc.c  | 150 ++
 drivers/scsi/ufs/ufshcd-dwc.h  |  26 ++
 drivers/scsi/ufs/ufshcd-pltfrm.c   |   2 +-
 drivers/scsi/ufs/ufshcd.c  |  89 +++---
 drivers/scsi/ufs/ufshcd.h  |   7 +
 drivers/scsi/ufs/ufshci-dwc.h  |  36 +++
 drivers/scsi/ufs/ufshci.h  |  11 +
 drivers/scsi/ufs/unipro.h  |  39 +++
 17 files changed, 998 insertions(+), 44 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

-- 
1.8.1.5

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


[PATCH v16 3/9] ufs: add UFS 2.0 capabilities

2016-05-11 Thread Joao Pinto
Add UFS 2.0 support to the UFS core driver.

Signed-off-by: Joao Pinto 
Acked-by: Arnd Bergmann 
Acked-by: Tomas Winkler 
Reviewed-by: Hannes Reinecke 
---
Changes v12->v16:
- Nothing changed (just to keep up with patch set version).
Changes v11->v12 (Tomas Winkler):
- devicetree binding tweak was moved to a separated patch
- unipro tweaks were moved to a separated patch
- ufshcd_compose_upiu was decomposed in 2 functions
- UTP_CMD_TYPE_UFS_STORAGE is now 0x1 (previously was 0x11)
Changes v8->v11:
- Nothing changed (just to keep up with patch set version).
Changes v7->v8:
- Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings
Changes v0->v7:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd.c | 89 +--
 drivers/scsi/ufs/ufshci.h |  5 +++
 2 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f8fa72c..8e8989a 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1173,7 +1173,7 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 
intrs)
  * @cmd_dir: requests data direction
  */
 static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
-   u32 *upiu_flags, enum dma_data_direction cmd_dir)
+   u32 *upiu_flags, enum dma_data_direction cmd_dir)
 {
struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
u32 data_direction;
@@ -1299,47 +1299,55 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct 
ufshcd_lrb *lrbp)
 }
 
 /**
- * ufshcd_compose_upiu - form UFS Protocol Information Unit(UPIU)
+ * ufshcd_comp_devman_upiu - UFS Protocol Information Unit(UPIU)
+ *  for Device Management Purposes
  * @hba - per adapter instance
  * @lrb - pointer to local reference block
  */
-static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
+static int ufshcd_comp_devman_upiu(struct ufs_hba *hba, struct ufshcd_lrb 
*lrbp)
 {
u32 upiu_flags;
int ret = 0;
 
-   switch (lrbp->command_type) {
-   case UTP_CMD_TYPE_SCSI:
-   if (likely(lrbp->cmd)) {
-   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
-   lrbp->cmd->sc_data_direction);
-   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
-   } else {
-   ret = -EINVAL;
-   }
-   break;
-   case UTP_CMD_TYPE_DEV_MANAGE:
-   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
-   if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
-   ufshcd_prepare_utp_query_req_upiu(
-   hba, lrbp, upiu_flags);
-   else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
-   ufshcd_prepare_utp_nop_upiu(lrbp);
-   else
-   ret = -EINVAL;
-   break;
-   case UTP_CMD_TYPE_UFS:
-   /* For UFS native command implementation */
-   ret = -ENOTSUPP;
-   dev_err(hba->dev, "%s: UFS native command are not supported\n",
-   __func__);
-   break;
-   default:
-   ret = -ENOTSUPP;
-   dev_err(hba->dev, "%s: unknown command type: 0x%x\n",
-   __func__, lrbp->command_type);
-   break;
-   } /* end of switch */
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
+   if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
+   ufshcd_prepare_utp_query_req_upiu(hba, lrbp, upiu_flags);
+   else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
+   ufshcd_prepare_utp_nop_upiu(lrbp);
+   else
+   ret = -EINVAL;
+
+   return ret;
+}
+
+/**
+ * ufshcd_comp_scsi_upiu - UFS Protocol Information Unit(UPIU)
+ *for SCSI Purposes
+ * @hba - per adapter instance
+ * @lrb - pointer to local reference block
+ */
+static int ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
+{
+   u32 upiu_flags;
+   int ret = 0;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_SCSI;
+
+   if (likely(lrbp->cmd)) {
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
+   lrbp->cmd->sc_data_direction);
+   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
+   } else {
+   re

[PATCH v16 7/9] ufs: add support for Synopsys G210 Test Chip

2016-05-11 Thread Joao Pinto
This patch adds support for Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v15->v16 (Martin K. Petersen):
- Test Chip G210 does not longer have a Kconfig item (also affected Makefile)
  Kconfig options reduction was the justification for this change.
Changes v10->v15:
- Nothing changed (just to keep up with patch set version).
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/tc-dwc-g210.c | 315 +
 drivers/scsi/ufs/tc-dwc-g210.h |  19 +++
 2 files changed, 334 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h

diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
new file mode 100644
index 000..181f208
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210.c
@@ -0,0 +1,315 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "unipro.h"
+
+#include "ufshcd-dwc.h"
+#include "ufshci-dwc.h"
+
+/**
+ * tc_dwc_g210_setup_40bit_rmmi()
+ * This function configures Synopsys TC specific atributes (40-bit RMMI)
+ * @hba: Pointer to drivers structure
+ *
+ * Returns 0 on success or non-zero value on failure
+ */
+static int tc_dwc_g210_setup_40bit_rmmi(struct ufs_hba *hba)
+{
+   const struct ufshcd_dme_attr_val setup_attrs[] = {
+   { UIC_ARG_MIB(TX_GLOBALHIBERNATE), 0x00, DME_LOCAL },
+   { UIC_ARG_MIB(REFCLKMODE), 0x01, DME_LOCAL },
+   { UIC_ARG_MIB(CDIRECTCTRL6), 0x80, DME_LOCAL },
+   { UIC_ARG_MIB(CBDIVFACTOR), 0x08, DME_LOCAL },
+   { UIC_ARG_MIB(CBDCOCTRL5), 0x64, DME_LOCAL },
+   { UIC_ARG_MIB(CBPRGTUNING), 0x09, DME_LOCAL },
+   { UIC_ARG_MIB(RTOBSERVESELECT), 0x00, DME_LOCAL },
+   { UIC_ARG_MIB_SEL(TX_REFCLKFREQ, SELIND_LN0_TX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(TX_CFGCLKFREQVAL, SELIND_LN0_TX), 0x19,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGEXTRATTR, SELIND_LN0_TX), 0x14,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(DITHERCTRL2, SELIND_LN0_TX), 0xd6,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RX_REFCLKFREQ, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RX_CFGCLKFREQVAL, SELIND_LN0_RX), 0x19,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGWIDEINLN, SELIND_LN0_RX), 4,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXCDR8, SELIND_LN0_RX), 0x80,
+   DME_LOCAL },
+   { UIC_ARG_MIB(DIRECTCTRL10), 0x04, DME_LOCAL },
+   { UIC_ARG_MIB(DIRECTCTRL19), 0x02, DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXCDR8, SELIND_LN0_RX), 0x80,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG4, SELIND_LN0_RX), 0x03,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXOVR8, SELIND_LN0_RX), 0x16,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXDIRECTCTRL2, SELIND_LN0_RX), 0x42,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG3, SELIND_LN0_RX), 0xa4,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXCALCTRL, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG2, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXOVR4, SELIND_LN0_RX), 0x28,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXSQCTRL, SELIND_LN0_RX), 0x1E,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXOVR6, SELIND_LN0_RX), 0x2f,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXOVR6, SELIND_LN0_RX), 0x2f,
+   

[PATCH v16 6/9] ufs: add support for DesignWare Controller

2016-05-11 Thread Joao Pinto
This patch has the goal to add support for DesignWare UFS Controller
specific operations.

Signed-off-by: Joao Pinto 
---
Changes v15->v16 (Martin K. Petersen):
- DWC core does not longer have a Kconfig item (also affected Makefile)
  Kconfig options reduction was the justification for this change.
Changes v12->v15:
- Nothing changed (just to keep up with patch set version).
Changes v11->v12 (Tomas Winkler):
- custom_phy_initialization is now phy_initialization
- ufshcd_is_intr_aggr_allowed() has now a DWC tweak
- link status was now moved to a separated patch
Changes v10->v11:
- Nothing changed (just to keep up with patch set version).
Changes v9->v10 (Arnd Bergmann):
- Patch now only has DWC controller specific code
- Added custom_phy_initialization callback for PHY specific code
Changes v8->v9 (Robert Herring):
- drop 0x in the node declaration
- most specific compatibility string declared first
Changes v7->v8 (Akinobu Mita):
- DME sets were simplified for easier reading
- CLK DIV default values definitions names were changed to match the
 register's name
- New line added to dev_err and dev_info statements
Changes v6->v7 (Arnd Bergmann):
- Changed DT node name (to ufs only) and the memory address (to 0xd00)
- Removed CONFIG_PM from the PCI glue driver (pm.h already does this)
- No other changes are necessary in ufshcd.c because of the link up notify
 function usage (it is simpler now)
- Removed the PHY mentioning since the Test Chip is not a real PHY for real
 world usage, since it is a test chip for prototyping with a very specific
 usage
- Added again the Test Chip 20-bit option
Changes v5->v6:
- Patch bad format fixed
Changes v4->v5 (Akinobu Mita):
- All functions used only locally in ufshcd-dwc are now declared as static
- ufshcd_dwc_configuration() was removed in ufshcd-dwc and a notify
 function (ufshcd_dwc_link_startup_notify) was created to deal with the
 DWC specific init routines
- 20-bit RMMI option was removed from Kconfig. Now if MPHY TC is selected
 and 40-bit is not then it assumes a 20-bit config
Changes v3->v4 (Arnd Bergmann and Mark Rutland):
- SCSI_UFS_DWC_HOOKS is now silent and selected by the SCSI_UFS_DWC_PLAT
 or SCSI_UFS_DWC_PCI
- Compatibility string has the ufs core version for info purposes since
 the driver is capable of getting the controller version from its 
 registers
- Created ufs-dwc-pci glue driver with specific DWC data
- MPHY configuration remains in the ufshcd-dwc since it is unipro
 attribute writting only not following the a linux phy framework logic
Changes v2->v3 (Julian Calaby):
- Implement a common DWC code to be used by the platform and pci glue
 drivers
- Synopsys ID & Class added to the existing pci driver and specific DWC
 was also added to the pci driver
Changes v1->v2 (Akinobu Mita):
- Implement a platform driver that uses the existing UFS core driver
- Add DWC specific code to the existing UFS core driver

 MAINTAINERS   |   6 ++
 drivers/scsi/ufs/ufshcd-dwc.c | 150 ++
 drivers/scsi/ufs/ufshcd-dwc.h |  26 
 drivers/scsi/ufs/ufshcd.h |   7 ++
 drivers/scsi/ufs/ufshci-dwc.h |  36 ++
 5 files changed, 225 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

diff --git a/MAINTAINERS b/MAINTAINERS
index a87defa..08d05a3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11451,6 +11451,12 @@ S: Supported
 F: Documentation/scsi/ufs.txt
 F: drivers/scsi/ufs/
 
+UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
+M: Joao Pinto 
+L: linux-scsi@vger.kernel.org
+S: Supported
+F: drivers/scsi/ufs/*dwc*
+
 UNSORTED BLOCK IMAGES (UBI)
 M: Artem Bityutskiy 
 M: Richard Weinberger 
diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c
new file mode 100644
index 000..9b3ca7f
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-dwc.c
@@ -0,0 +1,150 @@
+/*
+ * UFS Host driver for Synopsys Designware Core
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "unipro.h"
+
+#include "ufshcd-dwc.h"
+#include "ufshci-dwc.h"
+
+int ufshcd_dwc_dme_set_attrs(struct ufs_hba *hba,
+   const struct ufshcd_dme_attr_val *v, int n)
+{
+   int ret = 0;
+   int attr_node = 0;
+
+   for (attr_node = 0; attr_node < n; attr_node++) {
+   ret = ufshcd_dme_set_attr(hba, v[attr_node].attr_sel,
+   ATTR_SET_NOR, v[attr_node].mib_val, v[attr_node].peer);
+
+   if (ret)
+

Re: UFS patchset

2016-05-02 Thread Joao Pinto
Hi Martin,

On 4/30/2016 1:24 AM, Martin K. Petersen wrote:
>> "Martin" == Martin K Petersen  writes:
> 
> Joao,
> 
> Martin> In a previous email you said you had sent v14 to
> Martin> linux-scsi. However, I don't see neither v14, nor v13 in
> Martin> patchworks. The latest I have is v12 and it does not apply to
> Martin> 4.7/scsi-queue.
> 
> I found v14 in my mailbox. Not sure why it's not in patchworks.
> 
> In any case: It still doesn't apply to 4.7/scsi-queue and there are
> several checkpatch warnings throughout the series. Please fix.
> 
> Also make sure to prefix your patch subject lines with "ufs:" so it's
> easy to identify which subsystem they go into.
> 
> Thanks!
> 

As promissed I sent you a new patch set based on the latest 4.7 queue branch,
with "ufs:" prefix and completely tested and validated by checkpatch.

Thanks.
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v15 2/9] ufs: add UFS 2.0 to ufshcd-pltfrm bindings

2016-05-02 Thread Joao Pinto
Add UFS 2.0 to the ufshcd-pltfrm devicetree binding.

Signed-off-by: Joao Pinto 
Acked-by: Rob Herring 
Acked-by: Tomas Winkler 
---
Changes v12->v15:
- Nothing changed (just to keep up with patch set version).
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
index 66f6adf..a99ed55 100644
--- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
+++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
@@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host 
controllers.
 Each UFS controller instance should have its own node.
 
 Required properties:
-- compatible   : must contain "jedec,ufs-1.1", may also list one or 
more
- of the following:
+- compatible   : must contain "jedec,ufs-1.1" or "jedec,ufs-2.0", may
+ also list one or more of the following:
  "qcom,msm8994-ufshc"
  "qcom,msm8996-ufshc"
  "qcom,ufshc"
-- 
1.8.1.5

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


[PATCH v15 1/9] ufs:fixed typo in ufshcd-pltfrm

2016-05-02 Thread Joao Pinto
Fixed typo in ufshcd-pltfrm.

Signed-off-by: Joao Pinto 
Acked-by: Arnd Bergmann 
Acked-by: Tomas Winkler 
---
Changes v0->v15:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index 718f12e..db53f38 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -372,6 +372,6 @@ EXPORT_SYMBOL_GPL(ufshcd_pltfrm_init);
 
 MODULE_AUTHOR("Santosh Yaragnavi ");
 MODULE_AUTHOR("Vinayak Holikatti ");
-MODULE_DESCRIPTION("UFS host controller Pltform bus based glue driver");
+MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(UFSHCD_DRIVER_VERSION);
-- 
1.8.1.5

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


[PATCH v15 4/9] ufs: added unipro attributes

2016-05-02 Thread Joao Pinto
Added unipro attributes.

Signed-off-by: Joao Pinto 
Acked-by: Tomas Winkler 
---
Changes v12->v15:
- Nothing changed (just to keep up with patch set version).
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 drivers/scsi/ufs/unipro.h | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
index e2854e4..eff8b56 100644
--- a/drivers/scsi/ufs/unipro.h
+++ b/drivers/scsi/ufs/unipro.h
@@ -36,6 +36,10 @@
 #define TX_LCC_SEQUENCER   0x0032
 #define TX_MIN_ACTIVATETIME0x0033
 #define TX_PWM_G6_G7_SYNC_LENGTH   0x0034
+#define TX_REFCLKFREQ  0x00EB
+#define TX_CFGCLKFREQVAL   0x00EC
+#defineCFGEXTRATTR 0x00F0
+#define DITHERCTRL20x00F1
 
 /*
  * M-RX Configuration Attributes
@@ -51,10 +55,40 @@
 #define RX_TERMINATION_FORCE_ENABLE0x0089
 #define RX_MIN_ACTIVATETIME_CAPABILITY 0x008F
 #define RX_HIBERN8TIME_CAPABILITY  0x0092
+#define RX_REFCLKFREQ  0x00EB
+#defineRX_CFGCLKFREQVAL0x00EC
+#define CFGWIDEINLN0x00F0
+#define CFGRXCDR8  0x00BA
+#define ENARXDIRECTCFG40x00F2
+#define CFGRXOVR8  0x00BD
+#define RXDIRECTCTRL2  0x00C7
+#define ENARXDIRECTCFG30x00F3
+#define RXCALCTRL  0x00B4
+#define ENARXDIRECTCFG20x00F4
+#define CFGRXOVR4  0x00E9
+#define RXSQCTRL   0x00B5
+#define CFGRXOVR6  0x00BF
 
 #define is_mphy_tx_attr(attr)  (attr < RX_MODE)
 #define RX_MIN_ACTIVATETIME_UNIT_US100
 #define HIBERN8TIME_UNIT_US100
+
+/*
+ * Common Block Attributes
+ */
+#define TX_GLOBALHIBERNATE UNIPRO_CB_OFFSET(0x002B)
+#define REFCLKMODE UNIPRO_CB_OFFSET(0x00BF)
+#define DIRECTCTRL19   UNIPRO_CB_OFFSET(0x00CD)
+#define DIRECTCTRL10   UNIPRO_CB_OFFSET(0x00E6)
+#define CDIRECTCTRL6   UNIPRO_CB_OFFSET(0x00EA)
+#define RTOBSERVESELECTUNIPRO_CB_OFFSET(0x00F0)
+#define CBDIVFACTORUNIPRO_CB_OFFSET(0x00F1)
+#define CBDCOCTRL5 UNIPRO_CB_OFFSET(0x00F3)
+#define CBPRGPLL2  UNIPRO_CB_OFFSET(0x00F8)
+#define CBPRGTUNINGUNIPRO_CB_OFFSET(0x00FB)
+
+#define UNIPRO_CB_OFFSET(x)(0x8000 | x)
+
 /*
  * PHY Adpater attributes
  */
@@ -119,6 +153,11 @@
 #define PA_TACTIVATE_TIME_UNIT_US  10
 #define PA_HIBERN8_TIME_UNIT_US100
 
+/*Other attributes*/
+#define VS_MPHYCFGUPDT 0xD085
+#define VS_DEBUGOMC0xD09E
+#define VS_POWERSTATE  0xD083
+
 /* PHY Adapter Protocol Constants */
 #define PA_MAXDATALANES4
 
-- 
1.8.1.5

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


[PATCH v15 7/9] ufs: added support for Synopsys G210 Test Chip

2016-05-02 Thread Joao Pinto
This patch adds support for Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
Acked-by: Arnd Bergmann 
---
Changes v10->v15:
- Nothing changed (just to keep up with patch set version).
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/Kconfig   |   4 +
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210.c | 315 +
 drivers/scsi/ufs/tc-dwc-g210.h |  19 +++
 4 files changed, 339 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 06ff8ba..9594558 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -87,3 +87,7 @@ config SCSI_UFS_QCOM
 
 config SCSI_UFS_DWC
bool
+
+config SCSI_UFS_DWC_TC
+   bool
+   select SCSI_UFS_DWC
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index ccbad53..9468d7b 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,5 +1,6 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
new file mode 100644
index 000..181f208
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210.c
@@ -0,0 +1,315 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "unipro.h"
+
+#include "ufshcd-dwc.h"
+#include "ufshci-dwc.h"
+
+/**
+ * tc_dwc_g210_setup_40bit_rmmi()
+ * This function configures Synopsys TC specific atributes (40-bit RMMI)
+ * @hba: Pointer to drivers structure
+ *
+ * Returns 0 on success or non-zero value on failure
+ */
+static int tc_dwc_g210_setup_40bit_rmmi(struct ufs_hba *hba)
+{
+   const struct ufshcd_dme_attr_val setup_attrs[] = {
+   { UIC_ARG_MIB(TX_GLOBALHIBERNATE), 0x00, DME_LOCAL },
+   { UIC_ARG_MIB(REFCLKMODE), 0x01, DME_LOCAL },
+   { UIC_ARG_MIB(CDIRECTCTRL6), 0x80, DME_LOCAL },
+   { UIC_ARG_MIB(CBDIVFACTOR), 0x08, DME_LOCAL },
+   { UIC_ARG_MIB(CBDCOCTRL5), 0x64, DME_LOCAL },
+   { UIC_ARG_MIB(CBPRGTUNING), 0x09, DME_LOCAL },
+   { UIC_ARG_MIB(RTOBSERVESELECT), 0x00, DME_LOCAL },
+   { UIC_ARG_MIB_SEL(TX_REFCLKFREQ, SELIND_LN0_TX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(TX_CFGCLKFREQVAL, SELIND_LN0_TX), 0x19,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGEXTRATTR, SELIND_LN0_TX), 0x14,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(DITHERCTRL2, SELIND_LN0_TX), 0xd6,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RX_REFCLKFREQ, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RX_CFGCLKFREQVAL, SELIND_LN0_RX), 0x19,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGWIDEINLN, SELIND_LN0_RX), 4,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXCDR8, SELIND_LN0_RX), 0x80,
+   DME_LOCAL },
+   { UIC_ARG_MIB(DIRECTCTRL10), 0x04, DME_LOCAL },
+   { UIC_ARG_MIB(DIRECTCTRL19), 0x02, DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXCDR8, SELIND_LN0_RX), 0x80,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG4, SELIND_LN0_RX), 0x03,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXOVR8, SELIND_LN0_RX), 0x16,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXDIRECTCTRL2, SELIND_LN0_RX), 0x42,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG3, SELIND_LN0_RX), 0xa4,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXCALCTRL, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG

[PATCH v15 5/9] ufs: added link status to ufshci

2016-05-02 Thread Joao Pinto
Added link status to ufshci.

Signed-off-by: Joao Pinto 
Acked-by: Tomas Winkler 
---
Changes v12->v15:
- Nothing changed (just to keep up with patch set version).
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 drivers/scsi/ufs/ufshci.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index 3a2439f..6c7479c 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -220,6 +220,12 @@ enum {
 #define UIC_ARG_ATTR_TYPE(t)   (((t) & 0xFF) << 16)
 #define UIC_GET_ATTR_ID(v) (((v) >> 16) & 0x)
 
+/* Link Status*/
+enum link_status {
+   UFSHCD_LINK_IS_DOWN = 1,
+   UFSHCD_LINK_IS_UP   = 2,
+};
+
 /* UIC Commands */
 enum uic_cmd_dme {
UIC_CMD_DME_GET = 0x01,
-- 
1.8.1.5

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


[PATCH v15 8/9] ufs: add TC G210 platform driver

2016-05-02 Thread Joao Pinto
This patch adds a glue platform driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v13->v15:
- Nothing changed (just to keep up with patch set version).
Changes v12->v13 (Rob Herring):
- Removed spaces from the compatibility string (pltfm driver and DT bindings)
- Removed underscores from the node descriptor
Changes v11->v12 (Tomas Winkler):
- custom_phy_initialization replaced by phy_initialization
Changes v10->v11 (Arnd Bergmann):
- vops structs are now passed in .data
Changes v0->v10:
- This patch only appeared in v10

 .../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt |  26 +
 drivers/scsi/ufs/Kconfig   |   9 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 113 +
 4 files changed, 149 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c

diff --git a/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
new file mode 100644
index 000..71c0777
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
@@ -0,0 +1,26 @@
+* Universal Flash Storage (UFS) DesignWare Host Controller
+
+DWC_UFS nodes are defined to describe on-chip UFS host controllers and MPHY.
+Each UFS controller instance should have its own node.
+
+Required properties:
+- compatible   : compatible list must contain the PHY type & version:
+   "snps,g210-tc-6.00-20bit"
+   "snps,g210-tc-6.00-40bit"
+ complemented with the Controller IP version:
+   "snps,dwc-ufshcd-1.40a"
+ complemented with the JEDEC version:
+   "jedec,ufs-1.1"
+   "jedec,ufs-2.0"
+
+- reg  : 
+- interrupts   : 
+
+Example for a setup using a 1.40a DWC Controller with a 6.00 G210 40-bit TC:
+   dwc-ufs@d000 {
+   compatible = "snps,g210-tc-6.00-40bit",
+"snps,dwc-ufshcd-1.40a",
+"jedec,ufs-2.0";
+   reg = < 0xd000 0x1 >;
+   interrupts = < 24 >;
+   };
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 9594558..87f20d1 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -91,3 +91,12 @@ config SCSI_UFS_DWC
 config SCSI_UFS_DWC_TC
bool
select SCSI_UFS_DWC
+
+config SCSI_UFS_DWC_TC_PLATFORM
+   tristate "DesignWare platform support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PLATFORM
+   select SCSI_UFS_DWC_TC
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N."
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9468d7b..a977fe0 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,6 +1,7 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c 
b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
new file mode 100644
index 000..69b7036
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -0,0 +1,113 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ufshcd-pltfrm.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+/**
+ * UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+   .phy_initialization = tc_dwc_g210_config_20_bit,
+};
+
+static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+   .phy_initialization = tc_dwc_g210_config_40_bit,
+};
+
+static const struct of_device_id tc_dwc_g210_pltfm_match[] = {
+   {
+   .compatible = "snps,g210-tc-6.00-20bit",
+   .data = &tc_dwc_g210_20bit_pltfm_hba_vops,
+   },
+   {
+ 

[PATCH v15 9/9] ufs: add TC G210 pci driver

2016-05-02 Thread Joao Pinto
This patch adds a glue pci driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v13->v15:
- Nothing changed (just to keep up with patch set version).
Changes v12->v13:
- Nothing changed (just to keep up with patch set version).
Changes v10->v12 (Tomas Winkler):
- custom_phy_initialization replaced by phy_initialization
Changes v10->v11 (Arnd Bergmann):
- tc_type is now initialized to TC_G210_INV
- probe function checks if the test chip version is specified
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/Kconfig   |   9 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 181 +
 3 files changed, 191 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 87f20d1..54ccff2 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -100,3 +100,12 @@ config SCSI_UFS_DWC_TC_PLATFORM
  Synopsys Test Chip is a PHY for prototyping purposes.
 
  If unsure, say N."
+
+config SCSI_UFS_DWC_TC_PCI
+   tristate "DesignWare pci support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PCI
+   select SCSI_UFS_DWC_TC
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N."
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index a977fe0..5303d85 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
new file mode 100644
index 000..0667c76
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -0,0 +1,181 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+#include 
+#include 
+
+/* Test Chip type expected values */
+#define TC_G210_20BIT 20
+#define TC_G210_40BIT 40
+#define TC_G210_INV 0
+
+static int tc_type = TC_G210_INV;
+module_param(tc_type, int, 0);
+MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");
+
+static int tc_dwc_g210_pci_suspend(struct device *dev)
+{
+   return ufshcd_system_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_resume(struct device *dev)
+{
+   return ufshcd_system_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_suspend(struct device *dev)
+{
+   return ufshcd_runtime_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_resume(struct device *dev)
+{
+   return ufshcd_runtime_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_idle(struct device *dev)
+{
+   return ufshcd_runtime_idle(dev_get_drvdata(dev));
+}
+
+/**
+ * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_pci_hba_vops = {
+   .name   = "tc-dwc-g210-pci",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+};
+
+/**
+ * tc_dwc_g210_pci_shutdown - main function to put the controller in reset 
state
+ * @pdev: pointer to PCI device handle
+ */
+static void tc_dwc_g210_pci_shutdown(struct pci_dev *pdev)
+{
+   ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
+}
+
+/**
+ * tc_dwc_g210_pci_remove - de-allocate PCI/SCSI host and host memory space
+ * data structure memory
+ * @pdev - pointer to PCI handle
+ */
+static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
+{
+   struct ufs_hba *hba = pci_get_drvdata(pdev);
+
+   pm_runtime_forbid(&pdev->dev);
+   pm_runtime_get_noresume(&pdev->dev);
+   ufshcd_remove(hba);
+}
+
+/**
+ * tc_dwc_g210_pci_probe - probe routine of the driver
+ * @pdev: pointer to PCI device handle
+ * @id: PCI device id
+ *
+ * Returns 0 on success, non-zero value on failure
+ */
+static int
+tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   int err;
+
+   /* Check Test Chip type and set the specific setup routine */
+   if (tc_type == TC_G210_20BIT) {
+   tc_dwc_g210_pci_hba_vops.phy_initialization =
+ 

[PATCH v15 6/9] ufs: added support for DesignWare Controller

2016-05-02 Thread Joao Pinto
This patch has the goal to add support for DesignWare UFS Controller
specific operations.

Signed-off-by: Joao Pinto 
Acked-by: Arnd Bergmann 
---
Changes v12->v15:
- Nothing changed (just to keep up with patch set version).
Changes v11->v12 (Tomas Winkler):
- custom_phy_initialization is now phy_initialization
- ufshcd_is_intr_aggr_allowed() has now a DWC tweak
- link status was now moved to a separated patch
Changes v10->v11:
- Nothing changed (just to keep up with patch set version).
Changes v9->v10 (Arnd Bergmann):
- Patch now only has DWC controller specific code
- Added custom_phy_initialization callback for PHY specific code
Changes v8->v9 (Robert Herring):
- drop 0x in the node declaration
- most specific compatibility string declared first
Changes v7->v8 (Akinobu Mita):
- DME sets were simplified for easier reading
- CLK DIV default values definitions names were changed to match the
 register's name
- New line added to dev_err and dev_info statements
Changes v6->v7 (Arnd Bergmann):
- Changed DT node name (to ufs only) and the memory address (to 0xd00)
- Removed CONFIG_PM from the PCI glue driver (pm.h already does this)
- No other changes are necessary in ufshcd.c because of the link up notify
 function usage (it is simpler now)
- Removed the PHY mentioning since the Test Chip is not a real PHY for real
 world usage, since it is a test chip for prototyping with a very specific
 usage
- Added again the Test Chip 20-bit option
Changes v5->v6:
- Patch bad format fixed
Changes v4->v5 (Akinobu Mita):
- All functions used only locally in ufshcd-dwc are now declared as static
- ufshcd_dwc_configuration() was removed in ufshcd-dwc and a notify
 function (ufshcd_dwc_link_startup_notify) was created to deal with the
 DWC specific init routines
- 20-bit RMMI option was removed from Kconfig. Now if MPHY TC is selected
 and 40-bit is not then it assumes a 20-bit config
Changes v3->v4 (Arnd Bergmann and Mark Rutland):
- SCSI_UFS_DWC_HOOKS is now silent and selected by the SCSI_UFS_DWC_PLAT
 or SCSI_UFS_DWC_PCI
- Compatibility string has the ufs core version for info purposes since
 the driver is capable of getting the controller version from its 
 registers
- Created ufs-dwc-pci glue driver with specific DWC data
- MPHY configuration remains in the ufshcd-dwc since it is unipro
 attribute writting only not following the a linux phy framework logic
Changes v2->v3 (Julian Calaby):
- Implement a common DWC code to be used by the platform and pci glue
 drivers
- Synopsys ID & Class added to the existing pci driver and specific DWC
 was also added to the pci driver
Changes v1->v2 (Akinobu Mita):
- Implement a platform driver that uses the existing UFS core driver
- Add DWC specific code to the existing UFS core driver

 MAINTAINERS   |   6 ++
 drivers/scsi/ufs/Kconfig  |   3 +
 drivers/scsi/ufs/Makefile |   1 +
 drivers/scsi/ufs/ufshcd-dwc.c | 150 ++
 drivers/scsi/ufs/ufshcd-dwc.h |  26 
 drivers/scsi/ufs/ufshcd.h |   7 ++
 drivers/scsi/ufs/ufshci-dwc.h |  36 ++
 7 files changed, 229 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

diff --git a/MAINTAINERS b/MAINTAINERS
index a87defa..08d05a3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11451,6 +11451,12 @@ S: Supported
 F: Documentation/scsi/ufs.txt
 F: drivers/scsi/ufs/
 
+UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
+M: Joao Pinto 
+L: linux-scsi@vger.kernel.org
+S: Supported
+F: drivers/scsi/ufs/*dwc*
+
 UNSORTED BLOCK IMAGES (UBI)
 M: Artem Bityutskiy 
 M: Richard Weinberger 
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 097894a..06ff8ba 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -84,3 +84,6 @@ config SCSI_UFS_QCOM
 
  Select this if you have UFS controller on QCOM chipset.
  If unsure, say N.
+
+config SCSI_UFS_DWC
+   bool
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 8303bcc..ccbad53 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,4 +1,5 @@
 # UFSHCD makefile
+obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c
new file mode 100644
index 000..9b3ca7f
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-dwc.c
@@ -0,0 +1,150 @@
+/*
+ * UFS Host driver for Synopsys Designware Core
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free So

[PATCH v15 3/9] ufs: added UFS 2.0 capabilities

2016-05-02 Thread Joao Pinto
Adding UFS 2.0 support to the UFS core driver.

Signed-off-by: Joao Pinto 
Acked-by: Arnd Bergmann 
Acked-by: Tomas Winkler 
---
Changes v12->v15:
- Nothing changed (just to keep up with patch set version).
Changes v11->v12 (Tomas Winkler):
- devicetree binding tweak was moved to a separated patch
- unipro tweaks were moved to a separated patch
- ufshcd_compose_upiu was decomposed in 2 functions
- UTP_CMD_TYPE_UFS_STORAGE is now 0x1 (previously was 0x11)
Changes v8->v11:
- Nothing changed (just to keep up with patch set version).
Changes v7->v8:
- Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings
Changes v0->v7:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd.c | 89 +--
 drivers/scsi/ufs/ufshci.h |  5 +++
 2 files changed, 53 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f8fa72c..891c4fd 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1173,7 +1173,7 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 
intrs)
  * @cmd_dir: requests data direction
  */
 static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
-   u32 *upiu_flags, enum dma_data_direction cmd_dir)
+   u32 *upiu_flags, enum dma_data_direction cmd_dir)
 {
struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
u32 data_direction;
@@ -1299,47 +1299,55 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct 
ufshcd_lrb *lrbp)
 }
 
 /**
- * ufshcd_compose_upiu - form UFS Protocol Information Unit(UPIU)
+ * ufshcd_comp_devman_upiu - UFS Protocol Information Unit(UPIU)
+ *  for Device Management Purposes
  * @hba - per adapter instance
  * @lrb - pointer to local reference block
  */
-static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
+static int ufshcd_comp_devman_upiu(struct ufs_hba *hba, struct ufshcd_lrb 
*lrbp)
 {
u32 upiu_flags;
int ret = 0;
 
-   switch (lrbp->command_type) {
-   case UTP_CMD_TYPE_SCSI:
-   if (likely(lrbp->cmd)) {
-   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
-   lrbp->cmd->sc_data_direction);
-   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
-   } else {
-   ret = -EINVAL;
-   }
-   break;
-   case UTP_CMD_TYPE_DEV_MANAGE:
-   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
-   if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
-   ufshcd_prepare_utp_query_req_upiu(
-   hba, lrbp, upiu_flags);
-   else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
-   ufshcd_prepare_utp_nop_upiu(lrbp);
-   else
-   ret = -EINVAL;
-   break;
-   case UTP_CMD_TYPE_UFS:
-   /* For UFS native command implementation */
-   ret = -ENOTSUPP;
-   dev_err(hba->dev, "%s: UFS native command are not supported\n",
-   __func__);
-   break;
-   default:
-   ret = -ENOTSUPP;
-   dev_err(hba->dev, "%s: unknown command type: 0x%x\n",
-   __func__, lrbp->command_type);
-   break;
-   } /* end of switch */
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
+   if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
+   ufshcd_prepare_utp_query_req_upiu(hba, lrbp, upiu_flags);
+   else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
+   ufshcd_prepare_utp_nop_upiu(lrbp);
+   else
+   ret = -EINVAL;
+
+   return ret;
+}
+
+/**
+ * ufshcd_comp_scsi_upiu - UFS Protocol Information Unit(UPIU)
+ *for SCSI Purposes
+ * @hba - per adapter instance
+ * @lrb - pointer to local reference block
+ */
+static int ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
+{
+   u32 upiu_flags;
+   int ret = 0;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_SCSI;
+
+   if (likely(lrbp->cmd)) {
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
+   lrbp->cmd->sc_data_direction);
+   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
+   } else {
+   ret = -EINVAL;
+   }
 

Re: UFS patchset

2016-05-02 Thread Joao Pinto
Hi Martin!

On 4/30/2016 1:24 AM, Martin K. Petersen wrote:
>> "Martin" == Martin K Petersen  writes:
> 
> Joao,
> 
> Martin> In a previous email you said you had sent v14 to
> Martin> linux-scsi. However, I don't see neither v14, nor v13 in
> Martin> patchworks. The latest I have is v12 and it does not apply to
> Martin> 4.7/scsi-queue.
> 
> I found v14 in my mailbox. Not sure why it's not in patchworks.
> 
> In any case: It still doesn't apply to 4.7/scsi-queue and there are
> several checkpatch warnings throughout the series. Please fix.

The patch were made based on a 4.7-queue from about 1 or 2 months. I will do the
needed fixes and send you the v15.

> 
> Also make sure to prefix your patch subject lines with "ufs:" so it's
> easy to identify which subsystem they go into.
> 
> Thanks!
> 

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: UFS patchset

2016-04-29 Thread Joao Pinto
On 4/29/2016 1:19 PM, Martin K. Petersen wrote:
>>>>>> "Joao" == Joao Pinto  writes:
> 
> Joao,
> 
> Joao> Could you please give me feedback about the UFS patch-set?  The
> Joao> patches have been acked by various developers, so maybe could it
> Joao> be possible to put it into the 4.7 queue?
> 
> It is on my list.

Ok, great!

> 
> I think we are OK from a SCSI perspective but I believe there were still
> a couple of concerns in the ARM/device tree department. So I would like
> some confirmation from those developers that the code is now acceptable.
> 

The concerns were from Rob Herring about mixing PHY and controller in the
compatibility string, but that was justified. Check the extract:

">>
>>>
>>> Combining the phy and controller compatible strings is a bit strange.
>>> Generally, they would be separate nodes using the common phy binding.
>>>
>>
>> Correct, but in this case is just the compatibility string is just to
>> tell the dw ufs host that it has a 40-bit or a 20-bit test chip
>> connected. The Test chip is initialized by a unipro command sequence and
there is no more ops related to it.
>
> Okay. In that case, I think it should be a separate property unless
> the controller h/w is synthesized for one or the other.

Yes, the hardware must be synthesized for a certain PHY type, 20 or 40-bit.

>
> Rob
>

Joao"

Thanks,
Joao

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


UFS patchset

2016-04-29 Thread Joao Pinto
Hi Martin,

Could you please give me feedback about the UFS patch-set?
The patches have been acked by various developers, so maybe could it be possible
to put it into the 4.7 queue?

Patch-set Cover Letter:
http://www.spinics.net/lists/linux-scsi/msg95664.html

Thank you,
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v14 6/9] added support for DesignWare Controller

2016-04-13 Thread Joao Pinto

Hi Akinobu,

On 4/13/2016 1:19 PM, Akinobu Mita wrote:
> Hi Joao,
> 
> 2016-04-13 18:04 GMT+09:00 Joao Pinto :
> 
>> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
>> index e3931d0..c780d14 100644
>> --- a/drivers/scsi/ufs/ufshcd.h
>> +++ b/drivers/scsi/ufs/ufshcd.h
>> @@ -263,6 +263,7 @@ struct ufs_pwr_mode_info {
>>   * @suspend: called during host controller PM callback
>>   * @resume: called during host controller PM callback
>>   * @dbg_register_dump: used to dump controller debug information
>> + * @phy_initialization: used to initialize phys
>>   */
>>  struct ufs_hba_variant_ops {
>> const char *name;
>> @@ -284,6 +285,7 @@ struct ufs_hba_variant_ops {
>> int (*suspend)(struct ufs_hba *, enum ufs_pm_op);
>> int (*resume)(struct ufs_hba *, enum ufs_pm_op);
>> void(*dbg_register_dump)(struct ufs_hba *hba);
>> +   int (*phy_initialization)(struct ufs_hba *);
>>  };
> 
> This vops->phy_initialization is only called from ufs dwc specific
> source files and not called from ufs core.  So this should not belong
> to ufs_hba_variant_ops.

At this time only DWC specific uses the phy_initialization, but can be used by
others in the future when the same necessity comes.

> 
> You can use hba->priv to put the controller specific data structure
> including phy_initialization and you also need to define vops->init
> callback which allocates and initialize the data structure.
> 

Joao

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


UFS patch

2016-04-11 Thread Joao Pinto

Hi Martin,

I would like to know what are your plans regarding the UFS patches. Sending the
URLS for the last patch set version:

[PATCH v13 0/9] add support for DWC UFS Controller
https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1115046.html

[PATCH v13 1/9] fixed typo in ufshcd-pltfrm
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115043.html

[PATCH v13 2/9] add UFS 2.0 to ufshcd-pltfrm bindings
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115045.html

[PATCH v13 3/9] added UFS 2.0 capabilities
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115047.html

[PATCH v13 4/9] added unipro attributes
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115044.html

[PATCH v13 5/9] added link status to ufshci
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115051.html

[PATCH v13 6/9] added support for DesignWare Controller
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115053.html

[PATCH v13 7/9] added support for Synopsys G210 Test Chip
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115049.html

[PATCH v13 8/9] add TC G210 platform driver
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115048.html

[PATCH v13 9/9] add TC G210 pci driver
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg1115050.html

Thanks,
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 8/8] scsi: ufs: connect to RPMB subsystem

2016-04-08 Thread Joao Pinto
Hi,

On 4/7/2016 10:15 PM, Winkler, Tomas wrote:
> On Wed, 2016-04-06 at 09:51 +0100, Joao Pinto wrote:
>> Hi!
>>
>> On 4/4/2016 12:11 PM, Tomas Winkler wrote:
>>> Register UFS RPMB LUN with the RPMB subsystem and provide
>>> implementation for the RPMB access operations. RPMB partition is
>>> accessed via a sequence of security protocol in and security
>>> protocol
>>> out commands with UFS specific parameters. This multi step process
>>> is
>>> abstracted into 4 basic RPMB commands.
>>
>> [snip]
>>
>>>  * "UFS device" W-LU.
>>>  */
>>> struct scsi_device *sdev_ufs_device;
>>> +   struct scsi_device *sdev_ufs_rpmb;
>>>  
>>> enum ufs_dev_pwr_mode curr_dev_pwr_mode;
>>> enum uic_link_state uic_link_state;
>>>
>>
>> I have a UFS device emulator that has the RPMB capability. What are
>> the expected
>> good results for me to validate?
> 
> Hi Joao, thanks for that. I'm attaching an archive with few basic
> samples via user space interface. 
> You should run the program key first (program-key.sh), just don't do it
> on a real device it's one in life time operation. 
> 

Managed to cross-compile to ARC and execute your test app in my platform. I made
it in Buildroot, so I have the patches to enable the tool cross-compilation if
necessary in the future.

The tool execution gives no errors, but also no info. I suggest you had success
info and maybe some statistic (e.g. bytes read or written).

> Thanks
> Tomas
> 

Thanks,
Joao


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


Re: [PATCH v2 8/8] scsi: ufs: connect to RPMB subsystem

2016-04-08 Thread Joao Pinto
On 4/7/2016 10:15 PM, Winkler, Tomas wrote:
> On Wed, 2016-04-06 at 09:51 +0100, Joao Pinto wrote:
>> Hi!
>>
>> On 4/4/2016 12:11 PM, Tomas Winkler wrote:
>>> Register UFS RPMB LUN with the RPMB subsystem and provide
>>> implementation for the RPMB access operations. RPMB partition is
>>> accessed via a sequence of security protocol in and security
>>> protocol
>>> out commands with UFS specific parameters. This multi step process
>>> is
>>> abstracted into 4 basic RPMB commands.
>>
>> [snip]
>>
>>>  * "UFS device" W-LU.
>>>  */
>>> struct scsi_device *sdev_ufs_device;
>>> +   struct scsi_device *sdev_ufs_rpmb;
>>>  
>>> enum ufs_dev_pwr_mode curr_dev_pwr_mode;
>>> enum uic_link_state uic_link_state;
>>>
>>
>> I have a UFS device emulator that has the RPMB capability. What are
>> the expected
>> good results for me to validate?
> 
> Hi Joao, thanks for that. I'm attaching an archive with few basic
> samples via user space interface. 
> You should run the program key first (program-key.sh), just don't do it
> on a real device it's one in life time operation. 

Sorry, I have received the attachment. Going to explore it now.

> 
> Thanks
> Tomas
> 

Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 8/8] scsi: ufs: connect to RPMB subsystem

2016-04-08 Thread Joao Pinto
Hi,

On 4/7/2016 10:15 PM, Winkler, Tomas wrote:
> On Wed, 2016-04-06 at 09:51 +0100, Joao Pinto wrote:
>> Hi!
>>
>> On 4/4/2016 12:11 PM, Tomas Winkler wrote:
>>> Register UFS RPMB LUN with the RPMB subsystem and provide
>>> implementation for the RPMB access operations. RPMB partition is
>>> accessed via a sequence of security protocol in and security
>>> protocol
>>> out commands with UFS specific parameters. This multi step process
>>> is
>>> abstracted into 4 basic RPMB commands.
>>
>> [snip]
>>
>>>  * "UFS device" W-LU.
>>>  */
>>> struct scsi_device *sdev_ufs_device;
>>> +   struct scsi_device *sdev_ufs_rpmb;
>>>  
>>> enum ufs_dev_pwr_mode curr_dev_pwr_mode;
>>> enum uic_link_state uic_link_state;
>>>
>>
>> I have a UFS device emulator that has the RPMB capability. What are
>> the expected
>> good results for me to validate?
> 
> Hi Joao, thanks for that. I'm attaching an archive with few basic
> samples via user space interface. 
> You should run the program key first (program-key.sh), just don't do it
> on a real device it's one in life time operation. 
> 
> Thanks
> Tomas
> 

I have tested your patch set the following way:

Patches applied:
- Got 4.7-queue from the SCSI repo
- Applied the patch set for DW UFS support
- Applied your patch set for RPMB support

Platform (UFS IP Prototyping Kit):
- CPU: ARC CPU 32-bit
- UFS 2.0 Core running in FPGA

Results:
Kernel Build without RPMB configured: OK
Kernel Build with RPMB configured: OK
UFS Device partitions shown in UFS Host without RPMB configured: Yes
UFS Device partitions shown in UFS Host with RPMB configured: Yes

I would like to run more verifications regarding RPMB. Could you tell me what is
the procedure you suggest?

Thanks,
Joao

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


Re: [PATCH v2 8/8] scsi: ufs: connect to RPMB subsystem

2016-04-08 Thread Joao Pinto
Hi!

On 4/7/2016 10:15 PM, Winkler, Tomas wrote:
> On Wed, 2016-04-06 at 09:51 +0100, Joao Pinto wrote:
>> Hi!
>>
>> On 4/4/2016 12:11 PM, Tomas Winkler wrote:
>>> Register UFS RPMB LUN with the RPMB subsystem and provide
>>> implementation for the RPMB access operations. RPMB partition is
>>> accessed via a sequence of security protocol in and security
>>> protocol
>>> out commands with UFS specific parameters. This multi step process
>>> is
>>> abstracted into 4 basic RPMB commands.
>>
>> [snip]
>>
>>>  * "UFS device" W-LU.
>>>  */
>>> struct scsi_device *sdev_ufs_device;
>>> +   struct scsi_device *sdev_ufs_rpmb;
>>>  
>>> enum ufs_dev_pwr_mode curr_dev_pwr_mode;
>>> enum uic_link_state uic_link_state;
>>>
>>
>> I have a UFS device emulator that has the RPMB capability. What are
>> the expected
>> good results for me to validate?
> 
> Hi Joao, thanks for that. I'm attaching an archive with few basic
> samples via user space interface. 
> You should run the program key first (program-key.sh), just don't do it
> on a real device it's one in life time operation. 

No attachment received.

> 
> Thanks
> Tomas
> 

Thanks,
Joao

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


Re: [PATCH v12 8/9] add TC G210 platform driver

2016-04-08 Thread Joao Pinto
Hi Rob,

On 4/7/2016 6:57 PM, Rob Herring wrote:
> On Mon, Apr 04, 2016 at 11:48:23AM +0100, Joao Pinto wrote:
>>
>> Hi Rob,
>>
>> On 4/4/2016 6:15 AM, Rob Herring wrote:
>>> On Thu, Mar 31, 2016 at 07:57:21PM +0100, Joao Pinto wrote:
>>>> This patch adds a glue platform driver for the Synopsys G210 Test Chip.
>>>>
>>>> Signed-off-by: Joao Pinto 
>>>> ---
>>
>> [snip]
>>
>>>> +
>>>> +Required properties:
>>>> +- compatible  : compatible list must contain the PHY type & version:
>>>> +  "snps, g210-tc-6.00-20bit"
>>>> +  "snps, g210-tc-6.00-40bit"
>>> Remove the space  ^
>>>
>>>> +complemented with the Controller IP version:
>>>> +  "snps, dwc-ufshcd-1.40a"
>>>
>>> ditto
>>
>> Ok, will do that!
>>
>>>
>>> Combining the phy and controller compatible strings is a bit strange. 
>>> Generally, they would be separate nodes using the common phy binding.
>>>
>>
>> Correct, but in this case is just the compatibility string is just to tell 
>> the
>> dw ufs host that it has a 40-bit or a 20-bit test chip connected. The Test 
>> chip
>> is initialized by a unipro command sequence and there is no more ops related 
>> to it.
> 
> Okay. In that case, I think it should be a separate property unless the 
> controller h/w is synthesized for one or the other.

Yes, the hardware must be synthesized for a certain PHY type, 20 or 40-bit.

> 
> Rob
> 

Joao

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


Re: [PATCH v2 8/8] scsi: ufs: connect to RPMB subsystem

2016-04-06 Thread Joao Pinto
Hi!

On 4/4/2016 12:11 PM, Tomas Winkler wrote:
> Register UFS RPMB LUN with the RPMB subsystem and provide
> implementation for the RPMB access operations. RPMB partition is
> accessed via a sequence of security protocol in and security protocol
> out commands with UFS specific parameters. This multi step process is
> abstracted into 4 basic RPMB commands.

[snip]

>* "UFS device" W-LU.
>*/
>   struct scsi_device *sdev_ufs_device;
> + struct scsi_device *sdev_ufs_rpmb;
>  
>   enum ufs_dev_pwr_mode curr_dev_pwr_mode;
>   enum uic_link_state uic_link_state;
> 

I have a UFS device emulator that has the RPMB capability. What are the expected
good results for me to validate?

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v13 0/9] add support for DWC UFS Controller

2016-04-05 Thread Joao Pinto
On 4/5/2016 11:15 AM, Winkler, Tomas wrote:
> 
> Hi,
> 
> On 4/5/2016 12:34 AM, Martin K. Petersen wrote:
>>>>>>> "Joao" == Joao Pinto  writes:
>>
>> Joao,
>>
>> Joao> The work consisted of: - Fixed typo in ufshcd-pltfrm.c - Tweak 
>> Joao> ufshcd.c for UFS 2.0 support - Implement ufshcd-dwc which 
>> Joao> contains all DWC HW specific code - Unipro attributes were added 
>> Joao> and new registers were added to the driver - Implement a 
>> Joao> tc-dwc-g210 containing G210 MPHY specific code - Implement a 
>> Joao> tc-dwc-g210 glue platform driver - Implement a tc-dwc-g210 glue 
>> Joao> pci driver - Documentation update
>>
>> You really need to keep track of which Acked-by: and Reviewed-by: tags 
>> you have gotten from people and apply them to patches that you haven't 
>> changed. Otherwise we start from scratch every time you resubmit.
>>
>> Thanks!
>>
> 
> It's ok to submit the same v13 with the ACK tags?
> 
> You can add my Ack on the core patches, not DWC specific, I didn't really 
> look at those properly.
> Thanks
> Tomas 

Nice! Going to send a new v13 with your acks.

> 

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v13 0/9] add support for DWC UFS Controller

2016-04-05 Thread Joao Pinto
Hi,

On 4/5/2016 12:34 AM, Martin K. Petersen wrote:
>>>>>> "Joao" == Joao Pinto  writes:
> 
> Joao,
> 
> Joao> The work consisted of: - Fixed typo in ufshcd-pltfrm.c - Tweak
> Joao> ufshcd.c for UFS 2.0 support - Implement ufshcd-dwc which contains
> Joao> all DWC HW specific code - Unipro attributes were added and new
> Joao> registers were added to the driver - Implement a tc-dwc-g210
> Joao> containing G210 MPHY specific code - Implement a tc-dwc-g210 glue
> Joao> platform driver - Implement a tc-dwc-g210 glue pci driver -
> Joao> Documentation update
> 
> You really need to keep track of which Acked-by: and Reviewed-by: tags
> you have gotten from people and apply them to patches that you haven't
> changed. Otherwise we start from scratch every time you resubmit.
> 
> Thanks!
> 

It's ok to submit the same v13 with the ACK tags?

Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 8/9] add TC G210 platform driver

2016-04-04 Thread Joao Pinto

Hi Rob,

On 4/4/2016 6:15 AM, Rob Herring wrote:
> On Thu, Mar 31, 2016 at 07:57:21PM +0100, Joao Pinto wrote:
>> This patch adds a glue platform driver for the Synopsys G210 Test Chip.
>>
>> Signed-off-by: Joao Pinto 
>> ---

[snip]

>> +
>> +Required properties:
>> +- compatible: compatible list must contain the PHY type & version:
>> +"snps, g210-tc-6.00-20bit"
>> +"snps, g210-tc-6.00-40bit"
> Remove the space  ^
> 
>> +  complemented with the Controller IP version:
>> +"snps, dwc-ufshcd-1.40a"
> 
> ditto

Ok, will do that!

> 
> Combining the phy and controller compatible strings is a bit strange. 
> Generally, they would be separate nodes using the common phy binding.
> 

Correct, but in this case is just the compatibility string is just to tell the
dw ufs host that it has a 40-bit or a 20-bit test chip connected. The Test chip
is initialized by a unipro command sequence and there is no more ops related to 
it.

>> +  complemented with the JEDEC version:
>> +"jedec,ufs-1.1"
>> +"jedec,ufs-2.0"
>> +
>> +- reg   : 
>> +- interrupts: 
>> +
>> +Example for a setup using a 1.40a DWC Controller with a 6.00 G210 40-bit TC:
>> +dwc_ufs@d000 {
> 
> No underscores please.

Ok, will update it.

> 
>> +compatible = "snps, g210-tc-6.00-40bit",
>> + "snps, dwc-ufshcd-1.40a",
>> + "jedec,ufs-2.0";
>> +reg = < 0xd000 0x1 >;
>> +interrupts = < 24 >;
>> +};
> 

Will send a v13 with these tweaks.

Thanks.

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


Re: [PATCH 8/8] scsi: ufs: connect to RPMB subsystem

2016-04-04 Thread Joao Pinto

Hi!

On 4/3/2016 10:42 AM, Tomas Winkler wrote:
> Register UFS RPMB LUN with the RPMB subsystem and provide
> implementation for the RPMB access operations. RPMB partition is
> accessed via a sequence of security protocol in and security protocol
> out commands with UFS specific parameters. This multi step process is
> abstracted into 4 basic RPMB commands.
> 
> Signed-off-by: Alexander Usyskin 
> Signed-off-by: Tomas Winkler 
> ---
>  drivers/scsi/ufs/ufshcd.c | 219 
> ++
>  drivers/scsi/ufs/ufshcd.h |   2 +
>  2 files changed, 221 insertions(+)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index f8fa72c31a9d..c087e9713db3 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -37,10 +37,13 @@
>   * license terms, and distributes only under these terms.
>   */
>  

[snip]

>   scsi_remove_host(hba->host);
>   /* disable interrupts */
>   ufshcd_disable_intr(hba, hba->intr_mask);
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 4bb65669f052..92bfddf80ae8 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -346,6 +346,7 @@ struct ufs_init_prefetch {
>   * @utmrdl_dma_addr: UTMRDL DMA address
>   * @host: Scsi_Host instance of the driver
>   * @dev: device handle
> + * @sdev_ufs_rpmb: reference to RPMB device W-LU
>   * @lrb: local reference block
>   * @lrb_in_use: lrb in use
>   * @outstanding_tasks: Bits representing outstanding task requests
> @@ -408,6 +409,7 @@ struct ufs_hba {
>* "UFS device" W-LU.
>*/
>   struct scsi_device *sdev_ufs_device;
> + struct scsi_device *sdev_ufs_rpmb;
>  
>   enum ufs_dev_pwr_mode curr_dev_pwr_mode;
>   enum uic_link_state uic_link_state;
> 

I saw some kbuild robot issues regarding the patchset, so I would suggest you
make a v2 of the patch set and I can run some tests with the DW UFS Host design.

Thanks.
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v12 3/9] added UFS 2.0 capabilities

2016-04-01 Thread Joao Pinto
On 3/31/2016 9:27 PM, Winkler, Tomas wrote:
> On Thu, 2016-03-31 at 19:57 +0100, Joao Pinto wrote:
>> Adding UFS 2.0 support to the UFS core driver.
>>
>> Signed-off-by: Joao Pinto 
> 
> Looks good to me, though not tested yet
> Tomas

I have tested the build in a x86 and ARC. Also tested the functionality by using
a HAPS-DX FPGA with the UFS 2.0 design + MPHY G210.

> 
>> ---
>> Changes v11->v12 (Tomas Winkler):
>> - devicetree binding tweak was moved to a separated patch
>> - unipro tweaks were moved to a separated patch
>> - ufshcd_compose_upiu was decomposed in 2 functions

[snip]

>> +enum {
>> +UTP_CMD_TYPE_UFS_STORAGE= 0x1,
>> +};
>> +
>>  enum {
>>  UTP_SCSI_COMMAND= 0x,
>>  UTP_NATIVE_UFS_COMMAND  = 0x1000,

If you need anything else, please let me know.

Thanks.
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v12 0/9] add support for DWC UFS Controller

2016-03-31 Thread Joao Pinto
The work consisted of:
- Fixed typo in ufshcd-pltfrm.c
- Tweak ufshcd.c for UFS 2.0 support
- Implement ufshcd-dwc which contains all DWC HW specific code
- Unipro attributes were added and new registers were added to the driver
- Implement a tc-dwc-g210 containing G210 MPHY specific code
- Implement a tc-dwc-g210 glue platform driver
- Implement a tc-dwc-g210 glue pci driver
- Documentation update

Joao Pinto (9):
  fixed typo in ufshcd-pltfrm
  add UFS 2.0 to ufshcd-pltfrm bindings
  added UFS 2.0 capabilities
  added unipro attributes
  added link status to ufshci
  added support for DesignWare Controller
  added support for Synopsys G210 Test Chip
  add TC G210 platform driver
  add TC G210 pci driver

 .../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt |  26 ++
 .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |   4 +-
 MAINTAINERS|   6 +
 drivers/scsi/ufs/Kconfig   |  25 ++
 drivers/scsi/ufs/Makefile  |   4 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 181 
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 113 
 drivers/scsi/ufs/tc-dwc-g210.c | 315 +
 drivers/scsi/ufs/tc-dwc-g210.h |  19 ++
 drivers/scsi/ufs/ufshcd-dwc.c  | 150 ++
 drivers/scsi/ufs/ufshcd-dwc.h  |  26 ++
 drivers/scsi/ufs/ufshcd-pltfrm.c   |   2 +-
 drivers/scsi/ufs/ufshcd.c  |  90 +++---
 drivers/scsi/ufs/ufshcd.h  |   7 +
 drivers/scsi/ufs/ufshci-dwc.h  |  36 +++
 drivers/scsi/ufs/ufshci.h  |  11 +
 drivers/scsi/ufs/unipro.h  |  39 +++
 17 files changed, 1010 insertions(+), 44 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

-- 
1.8.1.5

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


[PATCH v12 4/9] added unipro attributes

2016-03-31 Thread Joao Pinto
Added unipro attributes.

Signed-off-by: Joao Pinto 
---
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 drivers/scsi/ufs/unipro.h | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
index 816a8a4..da16254 100644
--- a/drivers/scsi/ufs/unipro.h
+++ b/drivers/scsi/ufs/unipro.h
@@ -35,6 +35,10 @@
 #define TX_LCC_SEQUENCER   0x0032
 #define TX_MIN_ACTIVATETIME0x0033
 #define TX_PWM_G6_G7_SYNC_LENGTH   0x0034
+#define TX_REFCLKFREQ  0x00EB
+#define TX_CFGCLKFREQVAL   0x00EC
+#defineCFGEXTRATTR 0x00F0
+#define DITHERCTRL20x00F1
 
 /*
  * M-RX Configuration Attributes
@@ -48,8 +52,38 @@
 #define RX_ENTER_HIBERN8   0x00A7
 #define RX_BYPASS_8B10B_ENABLE 0x00A8
 #define RX_TERMINATION_FORCE_ENABLE0x0089
+#define RX_REFCLKFREQ  0x00EB
+#defineRX_CFGCLKFREQVAL0x00EC
+#define CFGWIDEINLN0x00F0
+#define CFGRXCDR8  0x00BA
+#define ENARXDIRECTCFG40x00F2
+#define CFGRXOVR8  0x00BD
+#define RXDIRECTCTRL2  0x00C7
+#define ENARXDIRECTCFG30x00F3
+#define RXCALCTRL  0x00B4
+#define ENARXDIRECTCFG20x00F4
+#define CFGRXOVR4  0x00E9
+#define RXSQCTRL   0x00B5
+#define CFGRXOVR6  0x00BF
 
 #define is_mphy_tx_attr(attr)  (attr < RX_MODE)
+
+/*
+ * Common Block Attributes
+ */
+#define TX_GLOBALHIBERNATE UNIPRO_CB_OFFSET(0x002B)
+#define REFCLKMODE UNIPRO_CB_OFFSET(0x00BF)
+#define DIRECTCTRL19   UNIPRO_CB_OFFSET(0x00CD)
+#define DIRECTCTRL10   UNIPRO_CB_OFFSET(0x00E6)
+#define CDIRECTCTRL6   UNIPRO_CB_OFFSET(0x00EA)
+#define RTOBSERVESELECTUNIPRO_CB_OFFSET(0x00F0)
+#define CBDIVFACTORUNIPRO_CB_OFFSET(0x00F1)
+#define CBDCOCTRL5 UNIPRO_CB_OFFSET(0x00F3)
+#define CBPRGPLL2  UNIPRO_CB_OFFSET(0x00F8)
+#define CBPRGTUNINGUNIPRO_CB_OFFSET(0x00FB)
+
+#define UNIPRO_CB_OFFSET(x)(0x8000 | x)
+
 /*
  * PHY Adpater attributes
  */
@@ -110,6 +144,11 @@
 #define PA_STALLNOCONFIGTIME   0x15A3
 #define PA_SAVECONFIGTIME  0x15A4
 
+/*Other attributes*/
+#define VS_MPHYCFGUPDT 0xD085
+#define VS_DEBUGOMC0xD09E
+#define VS_POWERSTATE  0xD083
+
 /* PA power modes */
 enum {
FAST_MODE   = 1,
-- 
1.8.1.5

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


[PATCH v12 3/9] added UFS 2.0 capabilities

2016-03-31 Thread Joao Pinto
Adding UFS 2.0 support to the UFS core driver.

Signed-off-by: Joao Pinto 
---
Changes v11->v12 (Tomas Winkler):
- devicetree binding tweak was moved to a separated patch
- unipro tweaks were moved to a separated patch
- ufshcd_compose_upiu was decomposed in 2 functions
- UTP_CMD_TYPE_UFS_STORAGE is now 0x1 (previously was 0x11)
Changes v8->v11:
- Nothing changed (just to keep up with patch set version).
Changes v7->v8:
- Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings
Changes v0->v7:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd.c | 90 ++-
 drivers/scsi/ufs/ufshci.h |  5 +++
 2 files changed, 54 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 9c1b94b..a69d637 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1127,7 +1127,7 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 
intrs)
  * @cmd_dir: requests data direction
  */
 static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
-   u32 *upiu_flags, enum dma_data_direction cmd_dir)
+   u32 *upiu_flags, enum dma_data_direction cmd_dir)
 {
struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
u32 data_direction;
@@ -1253,47 +1253,55 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct 
ufshcd_lrb *lrbp)
 }
 
 /**
- * ufshcd_compose_upiu - form UFS Protocol Information Unit(UPIU)
+ * ufshcd_comp_devman_upiu - UFS Protocol Information Unit(UPIU) 
+ *  for Device Management Purposes
  * @hba - per adapter instance
  * @lrb - pointer to local reference block
  */
-static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
+static int ufshcd_comp_devman_upiu(struct ufs_hba *hba, struct ufshcd_lrb 
*lrbp)
 {
u32 upiu_flags;
int ret = 0;
 
-   switch (lrbp->command_type) {
-   case UTP_CMD_TYPE_SCSI:
-   if (likely(lrbp->cmd)) {
-   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
-   lrbp->cmd->sc_data_direction);
-   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
-   } else {
-   ret = -EINVAL;
-   }
-   break;
-   case UTP_CMD_TYPE_DEV_MANAGE:
-   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
-   if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
-   ufshcd_prepare_utp_query_req_upiu(
-   hba, lrbp, upiu_flags);
-   else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
-   ufshcd_prepare_utp_nop_upiu(lrbp);
-   else
-   ret = -EINVAL;
-   break;
-   case UTP_CMD_TYPE_UFS:
-   /* For UFS native command implementation */
-   ret = -ENOTSUPP;
-   dev_err(hba->dev, "%s: UFS native command are not supported\n",
-   __func__);
-   break;
-   default:
-   ret = -ENOTSUPP;
-   dev_err(hba->dev, "%s: unknown command type: 0x%x\n",
-   __func__, lrbp->command_type);
-   break;
-   } /* end of switch */
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
+   if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
+   ufshcd_prepare_utp_query_req_upiu(hba, lrbp, upiu_flags);
+   else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
+   ufshcd_prepare_utp_nop_upiu(lrbp);
+   else
+   ret = -EINVAL;
+
+   return ret;
+}
+
+/**
+ * ufshcd_comp_scsi_upiu - UFS Protocol Information Unit(UPIU) 
+ *for SCSI Purposes
+ * @hba - per adapter instance
+ * @lrb - pointer to local reference block
+ */
+static int ufshcd_comp_scsi_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
+{
+   u32 upiu_flags;
+   int ret = 0;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_SCSI;
+
+   if (likely(lrbp->cmd)) {
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
+   lrbp->cmd->sc_data_direction);
+   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
+   } else {
+   ret = -EINVAL;
+   }
 
return ret;
 }
@@ -1405,10 +1414,9 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd 

[PATCH v12 2/9] add UFS 2.0 to ufshcd-pltfrm bindings

2016-03-31 Thread Joao Pinto
Add UFS 2.0 to the ufshcd-pltfrm devicetree binding.

Signed-off-by: Joao Pinto 
---
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
index 03c0e98..8d9a9d2 100644
--- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
+++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
@@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host 
controllers.
 Each UFS controller instance should have its own node.
 
 Required properties:
-- compatible   : must contain "jedec,ufs-1.1", may also list one or 
more
- of the following:
+- compatible   : must contain "jedec,ufs-1.1" or "jedec,ufs-2.0", may
+ also list one or more of the following:
  "qcom,msm8994-ufshc"
  "qcom,msm8996-ufshc"
  "qcom,ufshc"
-- 
1.8.1.5

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


[PATCH v12 1/9] fixed typo in ufshcd-pltfrm

2016-03-31 Thread Joao Pinto
Fixed typo in ufshcd-pltfrm.

Signed-off-by: Joao Pinto 
---
Changes v0->v12:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index d2a7b12..0522891 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -353,6 +353,6 @@ EXPORT_SYMBOL_GPL(ufshcd_pltfrm_init);
 
 MODULE_AUTHOR("Santosh Yaragnavi ");
 MODULE_AUTHOR("Vinayak Holikatti ");
-MODULE_DESCRIPTION("UFS host controller Pltform bus based glue driver");
+MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(UFSHCD_DRIVER_VERSION);
-- 
1.8.1.5

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


[PATCH v12 6/9] added support for DesignWare Controller

2016-03-31 Thread Joao Pinto
This patch has the goal to add support for DesignWare UFS Controller
specific operations.

Signed-off-by: Joao Pinto 
---
Changes v11->v12 (Tomas Winkler):
- custom_phy_initialization is now phy_initialization
- ufshcd_is_intr_aggr_allowed() has now a DWC tweak
- link status was now moved to a separated patch
Changes v10->v11:
- Nothing changed (just to keep up with patch set version).
Changes v9->v10 (Arnd Bergmann):
- Patch now only has DWC controller specific code
- Added custom_phy_initialization callback for PHY specific code
Changes v8->v9 (Robert Herring):
- drop 0x in the node declaration
- most specific compatibility string declared first
Changes v7->v8 (Akinobu Mita):
- DME sets were simplified for easier reading
- CLK DIV default values definitions names were changed to match the
 register's name
- New line added to dev_err and dev_info statements
Changes v6->v7 (Arnd Bergmann):
- Changed DT node name (to ufs only) and the memory address (to 0xd00)
- Removed CONFIG_PM from the PCI glue driver (pm.h already does this)
- No other changes are necessary in ufshcd.c because of the link up notify
 function usage (it is simpler now)
- Removed the PHY mentioning since the Test Chip is not a real PHY for real
 world usage, since it is a test chip for prototyping with a very specific
 usage
- Added again the Test Chip 20-bit option
Changes v5->v6:
- Patch bad format fixed
Changes v4->v5 (Akinobu Mita):
- All functions used only locally in ufshcd-dwc are now declared as static
- ufshcd_dwc_configuration() was removed in ufshcd-dwc and a notify
 function (ufshcd_dwc_link_startup_notify) was created to deal with the
 DWC specific init routines
- 20-bit RMMI option was removed from Kconfig. Now if MPHY TC is selected
 and 40-bit is not then it assumes a 20-bit config
Changes v3->v4 (Arnd Bergmann and Mark Rutland):
- SCSI_UFS_DWC_HOOKS is now silent and selected by the SCSI_UFS_DWC_PLAT
 or SCSI_UFS_DWC_PCI
- Compatibility string has the ufs core version for info purposes since
 the driver is capable of getting the controller version from its 
 registers
- Created ufs-dwc-pci glue driver with specific DWC data
- MPHY configuration remains in the ufshcd-dwc since it is unipro
 attribute writting only not following the a linux phy framework logic
Changes v2->v3 (Julian Calaby):
- Implement a common DWC code to be used by the platform and pci glue
 drivers
- Synopsys ID & Class added to the existing pci driver and specific DWC
 was also added to the pci driver
Changes v1->v2 (Akinobu Mita):
- Implement a platform driver that uses the existing UFS core driver
- Add DWC specific code to the existing UFS core driver

 MAINTAINERS   |   6 ++
 drivers/scsi/ufs/Kconfig  |   3 +
 drivers/scsi/ufs/Makefile |   1 +
 drivers/scsi/ufs/ufshcd-dwc.c | 150 ++
 drivers/scsi/ufs/ufshcd-dwc.h |  26 
 drivers/scsi/ufs/ufshcd.h |   7 ++
 drivers/scsi/ufs/ufshci-dwc.h |  36 ++
 7 files changed, 229 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 32bafda..7fc2730 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11408,6 +11408,12 @@ S: Supported
 F: Documentation/scsi/ufs.txt
 F: drivers/scsi/ufs/
 
+UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
+M: Joao Pinto 
+L: linux-scsi@vger.kernel.org
+S: Supported
+F: drivers/scsi/ufs/*dwc*
+
 UNSORTED BLOCK IMAGES (UBI)
 M: Artem Bityutskiy 
 M: Richard Weinberger 
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 5f45307..647c324 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -83,3 +83,6 @@ config SCSI_UFS_QCOM
 
  Select this if you have UFS controller on QCOM chipset.
  If unsure, say N.
+
+config SCSI_UFS_DWC
+   bool
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 8303bcc..ccbad53 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,4 +1,5 @@
 # UFSHCD makefile
+obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c
new file mode 100644
index 000..9b3ca7f
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-dwc.c
@@ -0,0 +1,150 @@
+/*
+ * UFS Host driver for Synopsys Designware Core
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "unipro.h"
+
+#include "ufs

[PATCH v12 7/9] added support for Synopsys G210 Test Chip

2016-03-31 Thread Joao Pinto
This patch adds support for Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v10->v12:
- Nothing changed (just to keep up with patch set version).
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/Kconfig   |   4 +
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210.c | 315 +
 drivers/scsi/ufs/tc-dwc-g210.h |  19 +++
 4 files changed, 339 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 647c324..9d218f9 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -86,3 +86,7 @@ config SCSI_UFS_QCOM
 
 config SCSI_UFS_DWC
bool
+
+config SCSI_UFS_DWC_TC
+   bool
+   select SCSI_UFS_DWC
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index ccbad53..9468d7b 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,5 +1,6 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
new file mode 100644
index 000..181f208
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210.c
@@ -0,0 +1,315 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "unipro.h"
+
+#include "ufshcd-dwc.h"
+#include "ufshci-dwc.h"
+
+/**
+ * tc_dwc_g210_setup_40bit_rmmi()
+ * This function configures Synopsys TC specific atributes (40-bit RMMI)
+ * @hba: Pointer to drivers structure
+ *
+ * Returns 0 on success or non-zero value on failure
+ */
+static int tc_dwc_g210_setup_40bit_rmmi(struct ufs_hba *hba)
+{
+   const struct ufshcd_dme_attr_val setup_attrs[] = {
+   { UIC_ARG_MIB(TX_GLOBALHIBERNATE), 0x00, DME_LOCAL },
+   { UIC_ARG_MIB(REFCLKMODE), 0x01, DME_LOCAL },
+   { UIC_ARG_MIB(CDIRECTCTRL6), 0x80, DME_LOCAL },
+   { UIC_ARG_MIB(CBDIVFACTOR), 0x08, DME_LOCAL },
+   { UIC_ARG_MIB(CBDCOCTRL5), 0x64, DME_LOCAL },
+   { UIC_ARG_MIB(CBPRGTUNING), 0x09, DME_LOCAL },
+   { UIC_ARG_MIB(RTOBSERVESELECT), 0x00, DME_LOCAL },
+   { UIC_ARG_MIB_SEL(TX_REFCLKFREQ, SELIND_LN0_TX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(TX_CFGCLKFREQVAL, SELIND_LN0_TX), 0x19,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGEXTRATTR, SELIND_LN0_TX), 0x14,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(DITHERCTRL2, SELIND_LN0_TX), 0xd6,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RX_REFCLKFREQ, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RX_CFGCLKFREQVAL, SELIND_LN0_RX), 0x19,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGWIDEINLN, SELIND_LN0_RX), 4,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXCDR8, SELIND_LN0_RX), 0x80,
+   DME_LOCAL },
+   { UIC_ARG_MIB(DIRECTCTRL10), 0x04, DME_LOCAL },
+   { UIC_ARG_MIB(DIRECTCTRL19), 0x02, DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXCDR8, SELIND_LN0_RX), 0x80,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG4, SELIND_LN0_RX), 0x03,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXOVR8, SELIND_LN0_RX), 0x16,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXDIRECTCTRL2, SELIND_LN0_RX), 0x42,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG3, SELIND_LN0_RX), 0xa4,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXCALCTRL, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG

[PATCH v12 8/9] add TC G210 platform driver

2016-03-31 Thread Joao Pinto
This patch adds a glue platform driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v11->v12 (Tomas Winkler):
- custom_phy_initialization replaced by phy_initialization
Changes v10->v11 (Arnd Bergmann):
- vops structs are now passed in .data
Changes v0->v10:
- This patch only appeared in v10

 .../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt |  26 +
 drivers/scsi/ufs/Kconfig   |   9 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 113 +
 4 files changed, 149 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c

diff --git a/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
new file mode 100644
index 000..6ec9647
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
@@ -0,0 +1,26 @@
+* Universal Flash Storage (UFS) DesignWare Host Controller
+
+DWC_UFS nodes are defined to describe on-chip UFS host controllers and MPHY.
+Each UFS controller instance should have its own node.
+
+Required properties:
+- compatible   : compatible list must contain the PHY type & version:
+   "snps, g210-tc-6.00-20bit"
+   "snps, g210-tc-6.00-40bit"
+ complemented with the Controller IP version:
+   "snps, dwc-ufshcd-1.40a"
+ complemented with the JEDEC version:
+   "jedec,ufs-1.1"
+   "jedec,ufs-2.0"
+
+- reg  : 
+- interrupts   : 
+
+Example for a setup using a 1.40a DWC Controller with a 6.00 G210 40-bit TC:
+   dwc_ufs@d000 {
+   compatible = "snps, g210-tc-6.00-40bit",
+"snps, dwc-ufshcd-1.40a",
+"jedec,ufs-2.0";
+   reg = < 0xd000 0x1 >;
+   interrupts = < 24 >;
+   };
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 9d218f9..5cfa87b 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -90,3 +90,12 @@ config SCSI_UFS_DWC
 config SCSI_UFS_DWC_TC
bool
select SCSI_UFS_DWC
+
+config SCSI_UFS_DWC_TC_PLATFORM
+   tristate "DesignWare platform support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PLATFORM
+   select SCSI_UFS_DWC_TC
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N."
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9468d7b..a977fe0 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,6 +1,7 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c 
b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
new file mode 100644
index 000..1193a30
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -0,0 +1,113 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ufshcd-pltfrm.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+/**
+ * UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+   .phy_initialization = tc_dwc_g210_config_20_bit,
+};
+
+static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+   .phy_initialization = tc_dwc_g210_config_40_bit,
+};
+
+static const struct of_device_id tc_dwc_g210_pltfm_match[] = {
+   {
+   .compatible = "snps, g210-tc-6.00-20bit",
+   .data = &tc_dwc_g210_20bit_pltfm_hba_vops,
+   },
+   {
+   .compatible = "snps, g210-tc-6.00-40bit",
+   .data = &tc_dwc_g210_40bit_pltfm_hba_vops,
+   },
+   { },
+};
+MODULE_DEVICE_TABLE(of, tc_dwc_g210_pltfm_match);
+
+/**
+ * tc_dwc_g210

[PATCH v12 9/9] add TC G210 pci driver

2016-03-31 Thread Joao Pinto
This patch adds a glue pci driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v10->v12 (Tomas Winkler):
- custom_phy_initialization replaced by phy_initialization
Changes v10->v11 (Arnd Bergmann):
- tc_type is now initialized to TC_G210_INV
- probe function checks if the test chip version is specified
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/Kconfig   |   9 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 181 +
 3 files changed, 191 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 5cfa87b..5a3fde7 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -99,3 +99,12 @@ config SCSI_UFS_DWC_TC_PLATFORM
  Synopsys Test Chip is a PHY for prototyping purposes.
 
  If unsure, say N."
+
+config SCSI_UFS_DWC_TC_PCI
+   tristate "DesignWare pci support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PCI
+   select SCSI_UFS_DWC_TC
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N."
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index a977fe0..5303d85 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
new file mode 100644
index 000..0667c76
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -0,0 +1,181 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+#include 
+#include 
+
+/* Test Chip type expected values */
+#define TC_G210_20BIT 20
+#define TC_G210_40BIT 40
+#define TC_G210_INV 0
+
+static int tc_type = TC_G210_INV;
+module_param(tc_type, int, 0);
+MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");
+
+static int tc_dwc_g210_pci_suspend(struct device *dev)
+{
+   return ufshcd_system_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_resume(struct device *dev)
+{
+   return ufshcd_system_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_suspend(struct device *dev)
+{
+   return ufshcd_runtime_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_resume(struct device *dev)
+{
+   return ufshcd_runtime_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_idle(struct device *dev)
+{
+   return ufshcd_runtime_idle(dev_get_drvdata(dev));
+}
+
+/**
+ * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_pci_hba_vops = {
+   .name   = "tc-dwc-g210-pci",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+};
+
+/**
+ * tc_dwc_g210_pci_shutdown - main function to put the controller in reset 
state
+ * @pdev: pointer to PCI device handle
+ */
+static void tc_dwc_g210_pci_shutdown(struct pci_dev *pdev)
+{
+   ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
+}
+
+/**
+ * tc_dwc_g210_pci_remove - de-allocate PCI/SCSI host and host memory space
+ * data structure memory
+ * @pdev - pointer to PCI handle
+ */
+static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
+{
+   struct ufs_hba *hba = pci_get_drvdata(pdev);
+
+   pm_runtime_forbid(&pdev->dev);
+   pm_runtime_get_noresume(&pdev->dev);
+   ufshcd_remove(hba);
+}
+
+/**
+ * tc_dwc_g210_pci_probe - probe routine of the driver
+ * @pdev: pointer to PCI device handle
+ * @id: PCI device id
+ *
+ * Returns 0 on success, non-zero value on failure
+ */
+static int
+tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   int err;
+
+   /* Check Test Chip type and set the specific setup routine */
+   if (tc_type == TC_G210_20BIT) {
+   tc_dwc_g210_pci_hba_vops.phy_initialization =
+   tc_dwc_g210_config_20_bit;
+   } else if (tc_type == TC_G210_40BIT) {
+   tc_dwc_g210_pci_hba_vops.phy_initializatio

[PATCH v12 5/9] added link status to ufshci

2016-03-31 Thread Joao Pinto
Added link status to ufshci.

Signed-off-by: Joao Pinto 
---
Changes v0->v12 (Tomas Winkler):
- This patch only appeared in v12

 drivers/scsi/ufs/ufshci.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index 20ece18..169363e 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -216,6 +216,12 @@ enum {
 #define UIC_ARG_ATTR_TYPE(t)   (((t) & 0xFF) << 16)
 #define UIC_GET_ATTR_ID(v) (((v) >> 16) & 0x)
 
+/* Link Status*/
+enum link_status {
+   UFSHCD_LINK_IS_DOWN = 1,
+   UFSHCD_LINK_IS_UP   = 2,
+};
+
 /* UIC Commands */
 enum uic_cmd_dme {
UIC_CMD_DME_GET = 0x01,
-- 
1.8.1.5

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


Re: [RESEND] [PATCH v11 3/6] added support for DesignWare Controller

2016-03-30 Thread Joao Pinto

Hi Thomas,

On 3/29/2016 1:15 PM, Winkler, Tomas wrote:
> 
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 
> 2570d94..8b0cdf0 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -262,6 +262,7 @@ struct ufs_pwr_mode_info {
>   * @suspend: called during host controller PM callback
>   * @resume: called during host controller PM callback
>   * @dbg_register_dump: used to dump controller debug information
> + * @custom_phy_initialization: used to initialize phys in DWC Cores
>   */
>  struct ufs_hba_variant_ops {
>   const char *name;
> @@ -283,6 +284,7 @@ struct ufs_hba_variant_ops {
>   int (*suspend)(struct ufs_hba *, enum ufs_pm_op);
>   int (*resume)(struct ufs_hba *, enum ufs_pm_op);
>   void(*dbg_register_dump)(struct ufs_hba *hba);

[snip]...

>  /*
>   * PHY Adpater attributes
>   */
> @@ -110,6 +144,11 @@
>  #define PA_STALLNOCONFIGTIME 0x15A3
>  #define PA_SAVECONFIGTIME0x15A4
>  
> +/*Other attributes*/
> +#define VS_MPHYCFGUPDT   0xD085
> +#define VS_DEBUGOMC  0xD09E
> +#define VS_POWERSTATE0xD083
> +
>  /* PA power modes */
>  enum {
>   FAST_MODE   = 1,
> --
> 1.8.1.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the 
> body of a message to majord...@vger.kernel.org More majordomo info at  
> http://vger.kernel.org/majordomo-info.html
> 

I am planning to start working today in the v12 of the patch-set. Did you have
opportunity to check the other patches (4, 5 and 6)?

Thanks,
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND] [PATCH v11 2/6] added UFS 2.0 capabilities

2016-03-29 Thread Joao Pinto
On 3/29/2016 12:33 PM, Winkler, Tomas wrote:
> Hi Thomas,
> 
> On 3/29/2016 11:41 AM, Winkler, Tomas wrote:
>>
>> Adding UFS 2.0 support to the UFS core driver.
>>
>> Signed-off-by: Joao Pinto 
>> Acked-by: Arnd Bergmann 
>> Acked-by: Rob Herring 
>> ---
>> Changes v8->v11:
>> - Nothing changed (just to keep up with patch set version).
>> Changes v7->v8:
>> - Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings 
>> Changes v0->v7:
>> - Nothing changed (just to keep up with patch set version).
>>
>>  .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |  4 +--
>>  drivers/scsi/ufs/ufshcd.c  | 29 
>> +++---
>>  drivers/scsi/ufs/ufshci.h  |  1 +
>>  3 files changed, 28 insertions(+), 6 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt 
>> b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
>> index 03c0e98..8d9a9d2 100644
>> --- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
>> +++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
>> @@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host 
>> controllers.
>>  Each UFS controller instance should have its own node.
>>  
>>  Required properties:
>> -- compatible: must contain "jedec,ufs-1.1", may also list 
>> one or more
>> -  of the following:
>> +- compatible: must contain "jedec,ufs-1.1" or 
>> "jedec,ufs-2.0", may
>> +  also list one or more of the following:
>>"qcom,msm8994-ufshc"
>>"qcom,msm8996-ufshc"
>>"qcom,ufshc"
>> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c 
>> index 85cd256..2b5f2bf 100644
>>
>> I think this should go in separate patch
> 
> In my opinion it only makes sense to add 2.0 to the device-tree binding if 
> the driver actually supports it, that was why I added to the same patch, but 
> of course it can be separated if more people agree with the approach.
> 
> Yes, we have ufshcd-pci device that needs that so I think this should go 
> separately 

I will separate this, no problem.

>>
>> --- a/drivers/scsi/ufs/ufshcd.c
>> +++ b/drivers/scsi/ufs/ufshcd.c
>> @@ -1223,6 +1223,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, 
>> struct ufshcd_lrb *lrbp)
>>  ret = -EINVAL;
>>  }
>>  break;
>> +case UTP_CMD_TYPE_UFS_STORAGE:
>>  case UTP_CMD_TYPE_DEV_MANAGE:
>>  ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
>>  if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY) @@ -1287,6 +1288,7 
>> @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd 
>> *cmd)
>>  struct ufshcd_lrb *lrbp;
>>  struct ufs_hba *hba;
>>  unsigned long flags;
>> +u32 upiu_flags;
>>  int tag;
>>  int err = 0;
>>  
>> @@ -1343,10 +1345,23 @@ static int ufshcd_queuecommand(struct Scsi_Host 
>> *host, struct scsi_cmnd *cmd)
>>  lrbp->task_tag = tag;
>>  lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
>>  lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;
>> -lrbp->command_type = UTP_CMD_TYPE_SCSI;
>> +
>> +if (hba->ufs_version == UFSHCI_VERSION_20)
>> +lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
>> +else
>> +lrbp->command_type = UTP_CMD_TYPE_SCSI;
>> This translation can be pushed to prepare_req_desc_hdr and you end up 
>> with  ~oneliner fix
> 
> I think your suggestion is good! We have to check the 2.0 version in 2 places 
> and with your approach we would only check it in prepare_req_desc_hdr() once.
> I will do that update!
> 
> Okay I think you can alter ufshcd_lrb structure and push the information 
> there,
> Add ufs version there as hba is not available in req_desc_hdr, I think both 
> command_type and ufs_version can be u8 so the structure won't grow. 

Going to check it out.

> 
> 
>>
>>  
>>  /* form UPIU before issuing the command */
>> -ufshcd_compose_upiu(hba, lrbp);
>> +if (hba->ufs_version == UFSHCI_VERSION_20) {
>> +if (likely(lrbp->cmd)) {
>> How this can be possible NULL, 

Re: [RESEND] [PATCH v11 2/6] added UFS 2.0 capabilities

2016-03-29 Thread Joao Pinto
Hi Thomas,

On 3/29/2016 11:41 AM, Winkler, Tomas wrote:
> 
> Adding UFS 2.0 support to the UFS core driver.
> 
> Signed-off-by: Joao Pinto 
> Acked-by: Arnd Bergmann 
> Acked-by: Rob Herring 
> ---
> Changes v8->v11:
> - Nothing changed (just to keep up with patch set version).
> Changes v7->v8:
> - Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings Changes 
> v0->v7:
> - Nothing changed (just to keep up with patch set version).
> 
>  .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |  4 +--
>  drivers/scsi/ufs/ufshcd.c  | 29 
> +++---
>  drivers/scsi/ufs/ufshci.h  |  1 +
>  3 files changed, 28 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt 
> b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
> index 03c0e98..8d9a9d2 100644
> --- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
> +++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
> @@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host 
> controllers.
>  Each UFS controller instance should have its own node.
>  
>  Required properties:
> -- compatible : must contain "jedec,ufs-1.1", may also list one or 
> more
> -   of the following:
> +- compatible : must contain "jedec,ufs-1.1" or "jedec,ufs-2.0", may
> +   also list one or more of the following:
> "qcom,msm8994-ufshc"
> "qcom,msm8996-ufshc"
> "qcom,ufshc"
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 
> 85cd256..2b5f2bf 100644
> 
> I think this should go in separate patch

In my opinion it only makes sense to add 2.0 to the device-tree binding if the
driver actually supports it, that was why I added to the same patch, but of
course it can be separated if more people agree with the approach.

> 
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -1223,6 +1223,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, 
> struct ufshcd_lrb *lrbp)
>   ret = -EINVAL;
>   }
>   break;
> + case UTP_CMD_TYPE_UFS_STORAGE:
>   case UTP_CMD_TYPE_DEV_MANAGE:
>   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
>   if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY) @@ -1287,6 +1288,7 
> @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd 
> *cmd)
>   struct ufshcd_lrb *lrbp;
>   struct ufs_hba *hba;
>   unsigned long flags;
> + u32 upiu_flags;
>   int tag;
>   int err = 0;
>  
> @@ -1343,10 +1345,23 @@ static int ufshcd_queuecommand(struct Scsi_Host 
> *host, struct scsi_cmnd *cmd)
>   lrbp->task_tag = tag;
>   lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
>   lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;
> - lrbp->command_type = UTP_CMD_TYPE_SCSI;
> +
> + if (hba->ufs_version == UFSHCI_VERSION_20)
> + lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
> + else
> + lrbp->command_type = UTP_CMD_TYPE_SCSI;
> This translation can be pushed to prepare_req_desc_hdr and you end up with  
> ~oneliner fix 

I think your suggestion is good! We have to check the 2.0 version in 2 places
and with your approach we would only check it in prepare_req_desc_hdr() once.
I will do that update!

> 
>  
>   /* form UPIU before issuing the command */
> - ufshcd_compose_upiu(hba, lrbp);
> + if (hba->ufs_version == UFSHCI_VERSION_20) {
> + if (likely(lrbp->cmd)) {
> How this can be possible NULL, the code above will crash or I'm missing 
> something ? 
> + ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
> + lrbp->cmd->sc_data_direction);
> + ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
> What is different her from the code in ufshcd_compose_upiu ?
> + } else
> + err = -EINVAL;
> + } else
> + ufshcd_compose_upiu(hba, lrbp);

If you check ufshcd_compose_upiu() you will see that it contains 2 scopes:
cmd_upiu and query_req_upiu. Before 2.0 this single function approach that had
both scopes worked well, but now with 2.0 we must use the same command_type
(UTP_CMD_TYPE_UFS_STORAGE) which causes incompatibility. This was why I put the
same code from cmd_upiu in the outside.

Of c

Re: UFS V11 patch-set

2016-03-24 Thread Joao Pinto
On 3/23/2016 9:16 PM, Martin K. Petersen wrote:
>>>>>> "Joao" == Joao Pinto  writes:
> 
> Joao,
> 
> Joao> Isn't it possible to be merged into a ufs-dwc branch in the SCSI
> Joao> Git tree that could be pulled later, like Bjorn did in the PCIe
> Joao> RC?
> 
> I just started 4.7/scsi-queue so now is a good time to resubmit.
> 
> Thanks!
> 

Hi Martin!
Thanks, I will do that in a minute.

Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UFS V11 patch-set

2016-03-19 Thread Joao Pinto
Hi!

Could you please check the following patch-set in order to evaluate if it is
ready for v4.6?

[PATCH v11 0/6] add support for DWC UFS Controller
http://www.gossamer-threads.com/lists/linux/kernel/2396797?#2396797

[PATCH v11 1/6] fixed typo in ufshcd-pltfrm
http://www.gossamer-threads.com/lists/linux/kernel/2396790?#2396790

[PATCH v11 2/6] added UFS 2.0 capabilities
http://www.gossamer-threads.com/lists/linux/kernel/2396791?#2396791

[PATCH v11 3/6] added support for DesignWare Controller
http://www.gossamer-threads.com/lists/linux/kernel/2396795?#2396795

[PATCH v11 4/6] added support for Synopsys G210 Test Chip
http://www.gossamer-threads.com/lists/linux/kernel/2396792?#2396792

[PATCH v11 5/6] add TC G210 platform driver
http://www.gossamer-threads.com/lists/linux/kernel/2396794?#2396794

[PATCH v11 6/6] add-TC-G210-pci-driver
http://www.gossamer-threads.com/lists/linux/kernel/2396793?#2396793

Thank you very much!

Regards,
Joao

PS: Changed JBottomley e-mail address.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


UFS V11 patch-set

2016-03-19 Thread Joao Pinto
Hi!

Could you please check the following patch-set in order to evaluate if it is
ready for v4.6?

[PATCH v11 0/6] add support for DWC UFS Controller
http://www.gossamer-threads.com/lists/linux/kernel/2396797?#2396797

[PATCH v11 1/6] fixed typo in ufshcd-pltfrm
http://www.gossamer-threads.com/lists/linux/kernel/2396790?#2396790

[PATCH v11 2/6] added UFS 2.0 capabilities
http://www.gossamer-threads.com/lists/linux/kernel/2396791?#2396791

[PATCH v11 3/6] added support for DesignWare Controller
http://www.gossamer-threads.com/lists/linux/kernel/2396795?#2396795

[PATCH v11 4/6] added support for Synopsys G210 Test Chip
http://www.gossamer-threads.com/lists/linux/kernel/2396792?#2396792

[PATCH v11 5/6] add TC G210 platform driver
http://www.gossamer-threads.com/lists/linux/kernel/2396794?#2396794

[PATCH v11 6/6] add-TC-G210-pci-driver
http://www.gossamer-threads.com/lists/linux/kernel/2396793?#2396793

Thank you very much!

Regards,
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: UFS V11 patch-set

2016-03-19 Thread Joao Pinto
Hi!

On 3/18/2016 2:49 PM, Arnd Bergmann wrote:
> On Friday 18 March 2016 12:52:13 Joao Pinto wrote:
>> Hi!
>>
>> Could you please check the following patch-set in order to evaluate if it is
>> ready for v4.6?
>>
> 
> I think the code is ok now, but the timing apparently didn't work for 4.6.
> I'd suggest you resend as soon as 4.6-rc1 is out so it can get merged into 
> 4.7.

Isn't it possible to be merged into a ufs-dwc branch in the SCSI Git tree that
could be pulled later, like Bjorn did in the PCIe RC?

> 
>   Arnd
> 

Joao

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


[PATCH v11 6/6] add-TC-G210-pci-driver

2016-03-07 Thread Joao Pinto
This patch adds a glue pci driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v10->v11 (Arnd Bergmann):
- tc_type is now initialized to TC_G210_INV
- probe function checks if the test chip version is specified
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/Kconfig   |   9 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 181 +
 3 files changed, 191 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 5cfa87b..5a3fde7 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -99,3 +99,12 @@ config SCSI_UFS_DWC_TC_PLATFORM
  Synopsys Test Chip is a PHY for prototyping purposes.
 
  If unsure, say N."
+
+config SCSI_UFS_DWC_TC_PCI
+   tristate "DesignWare pci support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PCI
+   select SCSI_UFS_DWC_TC
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N."
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index a977fe0..5303d85 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
new file mode 100644
index 000..be8790f
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -0,0 +1,181 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+#include 
+#include 
+
+/* Test Chip type expected values */
+#define TC_G210_20BIT 20
+#define TC_G210_40BIT 40
+#define TC_G210_INV 0
+
+static int tc_type = TC_G210_INV;
+module_param(tc_type, int, 0);
+MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");
+
+static int tc_dwc_g210_pci_suspend(struct device *dev)
+{
+   return ufshcd_system_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_resume(struct device *dev)
+{
+   return ufshcd_system_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_suspend(struct device *dev)
+{
+   return ufshcd_runtime_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_resume(struct device *dev)
+{
+   return ufshcd_runtime_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_idle(struct device *dev)
+{
+   return ufshcd_runtime_idle(dev_get_drvdata(dev));
+}
+
+/**
+ * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_pci_hba_vops = {
+   .name   = "tc-dwc-g210-pci",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+};
+
+/**
+ * tc_dwc_g210_pci_shutdown - main function to put the controller in reset 
state
+ * @pdev: pointer to PCI device handle
+ */
+static void tc_dwc_g210_pci_shutdown(struct pci_dev *pdev)
+{
+   ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
+}
+
+/**
+ * tc_dwc_g210_pci_remove - de-allocate PCI/SCSI host and host memory space
+ * data structure memory
+ * @pdev - pointer to PCI handle
+ */
+static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
+{
+   struct ufs_hba *hba = pci_get_drvdata(pdev);
+
+   pm_runtime_forbid(&pdev->dev);
+   pm_runtime_get_noresume(&pdev->dev);
+   ufshcd_remove(hba);
+}
+
+/**
+ * tc_dwc_g210_pci_probe - probe routine of the driver
+ * @pdev: pointer to PCI device handle
+ * @id: PCI device id
+ *
+ * Returns 0 on success, non-zero value on failure
+ */
+static int
+tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   int err;
+
+   /* Check Test Chip type and set the specific setup routine */
+   if (tc_type == TC_G210_20BIT) {
+   tc_dwc_g210_pci_hba_vops.custom_phy_initialization =
+   tc_dwc_g210_config_20_bit;
+   } else if (tc_type == TC_G210_40BIT) {
+   tc_dwc_g210_pci_hba_vops.custom_phy_initialization =
+   tc_dwc_g210_config_40_bi

[PATCH v11 5/6] add TC G210 platform driver

2016-03-07 Thread Joao Pinto
This patch adds a glue platform driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v10->v11 (Arnd Bergmann):
- vops structs are now passed in .data
Changes v0->v10:
- This patch only appeared in v10

 .../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt |  26 +
 drivers/scsi/ufs/Kconfig   |   9 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 113 +
 4 files changed, 149 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c

diff --git a/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
new file mode 100644
index 000..6ec9647
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
@@ -0,0 +1,26 @@
+* Universal Flash Storage (UFS) DesignWare Host Controller
+
+DWC_UFS nodes are defined to describe on-chip UFS host controllers and MPHY.
+Each UFS controller instance should have its own node.
+
+Required properties:
+- compatible   : compatible list must contain the PHY type & version:
+   "snps, g210-tc-6.00-20bit"
+   "snps, g210-tc-6.00-40bit"
+ complemented with the Controller IP version:
+   "snps, dwc-ufshcd-1.40a"
+ complemented with the JEDEC version:
+   "jedec,ufs-1.1"
+   "jedec,ufs-2.0"
+
+- reg  : 
+- interrupts   : 
+
+Example for a setup using a 1.40a DWC Controller with a 6.00 G210 40-bit TC:
+   dwc_ufs@d000 {
+   compatible = "snps, g210-tc-6.00-40bit",
+"snps, dwc-ufshcd-1.40a",
+"jedec,ufs-2.0";
+   reg = < 0xd000 0x1 >;
+   interrupts = < 24 >;
+   };
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 9d218f9..5cfa87b 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -90,3 +90,12 @@ config SCSI_UFS_DWC
 config SCSI_UFS_DWC_TC
bool
select SCSI_UFS_DWC
+
+config SCSI_UFS_DWC_TC_PLATFORM
+   tristate "DesignWare platform support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PLATFORM
+   select SCSI_UFS_DWC_TC
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N."
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9468d7b..a977fe0 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,6 +1,7 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c 
b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
new file mode 100644
index 000..9bffb98
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -0,0 +1,113 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ufshcd-pltfrm.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+/**
+ * UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+   .custom_phy_initialization = tc_dwc_g210_config_20_bit,
+};
+
+static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+   .custom_phy_initialization = tc_dwc_g210_config_40_bit,
+};
+
+static const struct of_device_id tc_dwc_g210_pltfm_match[] = {
+   {
+   .compatible = "snps, g210-tc-6.00-20bit",
+   .data = &tc_dwc_g210_20bit_pltfm_hba_vops,
+   },
+   {
+   .compatible = "snps, g210-tc-6.00-40bit",
+   .data = &tc_dwc_g210_40bit_pltfm_hba_vops,
+   },
+   { },
+};
+MODULE_DEVICE_TABLE(of, tc_dwc_g210_pltfm_match);
+
+/**
+ * tc_dwc_g210_pltfm_probe()
+ * @pdev: pointer to platform device structure
+ *
+ */
+static int tc

Re: [PATCH v10 6/6] add TC G210 pci driver

2016-03-07 Thread Joao Pinto
Hi,

On 3/4/2016 9:17 PM, Arnd Bergmann wrote:
> On Friday 04 March 2016 17:22:19 Joao Pinto wrote:
>> This patch adds a glue pci driver for the Synopsys G210 Test Chip.
>>
>> Signed-off-by: Joao Pinto 
> 
> Mostly ok, just a few suggestions:
> 
>> +
>> +/* Test Chip type expected values */
>> +#define TC_G210_20BIT 20
>> +#define TC_G210_40BIT 40
>> +#define TC_G210_DEFAULTBIT 40
>> +
>> +static int tc_type = TC_G210_DEFAULTBIT;
>> +module_param(tc_type, int, 0);
>> +MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");
>>
> 
> What is the effect of setting the wrong one here? I was thinking
> it would be best to have the default be 'invalid' and then return
> an error from the probe() function when you neither value is
> set.

You're right. Maybe an TC_G210_20BIT_INV by default and also check if the
inserted value is TC_G210_20BIT or TC_G210_40BIT. if not, then abort the probe.

> 
>> +
>> +/* Check Test Chip type and set the specific setup routine */
>> +if (tc_type == TC_G210_20BIT) {
>> +tc_dwc_g210_pci_hba_vops.custom_phy_initialization =
>> +tc_dwc_g210_config_20_bit;
>> +} else if (tc_type == TC_G210_40BIT) {
>> +tc_dwc_g210_pci_hba_vops.custom_phy_initialization =
>> +tc_dwc_g210_config_40_bit;
>> +}
> 
> As for the platform driver, I would define two separate structures here,
> and then mark the operations as 'const'.
> 
>> +static const struct pci_device_id tc_dwc_g210_pci_tbl[] = {
>> +{ PCI_VENDOR_ID_SYNOPSYS, 0xB101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
>> +{ PCI_VENDOR_ID_SYNOPSYS, 0xB102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
>> +{ } /* terminate list */
>> +};
> 
> Is there any difference between these two IDs?

The Synopsys can be identified by one of these 2 IDs. There is no particular 
reason.

> 
>   Arnd
> 

Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v10 5/6] add TC G210 platform driver

2016-03-07 Thread Joao Pinto
Hi,

On 3/4/2016 9:12 PM, Arnd Bergmann wrote:
> On Friday 04 March 2016 17:22:18 Joao Pinto wrote:
>> This patch adds a glue platform driver for the Synopsys G210 Test Chip.
>>
>> Signed-off-by: Joao Pinto 
> 
> Looks basically ok, but I think it can be simplified a little:
> 
>> +/**
>> + * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
>> + */
>> +static struct ufs_hba_variant_ops tc_dwc_g210_pltfm_hba_vops = {
>> +.name   = "tc-dwc-g210-pltfm",
>> +.link_startup_notify= ufshcd_dwc_link_startup_notify,
>> +};
>> +
>> +/**
>> + * tc_dwc_g210_pltfm_probe()
>> + * @pdev: pointer to platform device structure
>> + *
>> + */
>> +static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev)
>> +{
>> +int err;
>> +struct device *dev = &pdev->dev;
>> +struct device_node *np = dev->of_node;
>> +
>> +/* Check Test Chip type and set the specific setup routine */
>> +if (of_device_is_compatible(np, "snps, g210-tc-6.00-20bit")) {
>> +tc_dwc_g210_pltfm_hba_vops.custom_phy_initialization =
>> +tc_dwc_g210_config_20_bit;
>> +} else if (of_device_is_compatible(np, "snps, g210-tc-6.00-40bit")) {
>> +tc_dwc_g210_pltfm_hba_vops.custom_phy_initialization =
>> +tc_dwc_g210_config_40_bit;
>> +}
> 
> Instead of manually checking the compatible string, define two copies
> of the ufs_hba_variant_ops, and put a pointer to them into the
> .data field of tc_dwc_g210_pltfm_match.

Sounds nice. I'll do that!

> 
>   Arnd
> 

Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v10 1/6] fixed typo in ufshcd-pltfrm

2016-03-04 Thread Joao Pinto
Fixed typo in ufshcd-pltfrm.

Signed-off-by: Joao Pinto 
---
Changes v0->v10:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index d2a7b12..0522891 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -353,6 +353,6 @@ EXPORT_SYMBOL_GPL(ufshcd_pltfrm_init);
 
 MODULE_AUTHOR("Santosh Yaragnavi ");
 MODULE_AUTHOR("Vinayak Holikatti ");
-MODULE_DESCRIPTION("UFS host controller Pltform bus based glue driver");
+MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(UFSHCD_DRIVER_VERSION);
-- 
1.8.1.5

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


[PATCH v10 3/6] added support for DesignWare Controller

2016-03-04 Thread Joao Pinto
This patch has the goal to add support for DesignWare UFS Controller
specific operations.

Signed-off-by: Joao Pinto 
---
Changes v9->v10 (Arnd Bergmann):
- Patch now only has DWC controller specific code
- Added custom_phy_initialization callback for PHY specific code
Changes v8->v9 (Robert Herring):
- drop 0x in the node declaration
- most specific compatibility string declared first
Changes v7->v8 (Akinobu Mita):
- DME sets were simplified for easier reading
- CLK DIV default values definitions names were changed to match the
 register's name
- New line added to dev_err and dev_info statements
Changes v6->v7 (Arnd Bergmann):
- Changed DT node name (to ufs only) and the memory address (to 0xd00)
- Removed CONFIG_PM from the PCI glue driver (pm.h already does this)
- No other changes are necessary in ufshcd.c because of the link up notify
 function usage (it is simpler now)
- Removed the PHY mentioning since the Test Chip is not a real PHY for real
 world usage, since it is a test chip for prototyping with a very specific
 usage
- Added again the Test Chip 20-bit option
Changes v5->v6:
- Patch bad format fixed
Changes v4->v5 (Akinobu Mita):
- All functions used only locally in ufshcd-dwc are now declared as static
- ufshcd_dwc_configuration() was removed in ufshcd-dwc and a notify
 function (ufshcd_dwc_link_startup_notify) was created to deal with the
 DWC specific init routines
- 20-bit RMMI option was removed from Kconfig. Now if MPHY TC is selected
 and 40-bit is not then it assumes a 20-bit config
Changes v3->v4 (Arnd Bergmann and Mark Rutland):
- SCSI_UFS_DWC_HOOKS is now silent and selected by the SCSI_UFS_DWC_PLAT
 or SCSI_UFS_DWC_PCI
- Compatibility string has the ufs core version for info purposes since
 the driver is capable of getting the controller version from its 
 registers
- Created ufs-dwc-pci glue driver with specific DWC data
- MPHY configuration remains in the ufshcd-dwc since it is unipro
 attribute writting only not following the a linux phy framework logic
Changes v2->v3 (Julian Calaby):
- Implement a common DWC code to be used by the platform and pci glue
 drivers
- Synopsys ID & Class added to the existing pci driver and specific DWC
 was also added to the pci driver
Changes v1->v2 (Akinobu Mita):
- Implement a platform driver that uses the existing UFS core driver
- Add DWC specific code to the existing UFS core driver

 MAINTAINERS   |   6 ++
 drivers/scsi/ufs/Kconfig  |   3 +
 drivers/scsi/ufs/Makefile |   1 +
 drivers/scsi/ufs/ufshcd-dwc.c | 150 ++
 drivers/scsi/ufs/ufshcd-dwc.h |  26 
 drivers/scsi/ufs/ufshcd.h |   2 +
 drivers/scsi/ufs/ufshci-dwc.h |  42 
 drivers/scsi/ufs/unipro.h |  39 +++
 8 files changed, 269 insertions(+)
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

diff --git a/MAINTAINERS b/MAINTAINERS
index d2f94e2..3db3c4c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11006,6 +11006,12 @@ S: Supported
 F: Documentation/scsi/ufs.txt
 F: drivers/scsi/ufs/
 
+UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
+M: Joao Pinto 
+L: linux-scsi@vger.kernel.org
+S: Supported
+F: drivers/scsi/ufs/*dwc*
+
 UNSORTED BLOCK IMAGES (UBI)
 M: Artem Bityutskiy 
 M: Richard Weinberger 
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 5f45307..647c324 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -83,3 +83,6 @@ config SCSI_UFS_QCOM
 
  Select this if you have UFS controller on QCOM chipset.
  If unsure, say N.
+
+config SCSI_UFS_DWC
+   bool
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 8303bcc..ccbad53 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,4 +1,5 @@
 # UFSHCD makefile
+obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/ufshcd-dwc.c b/drivers/scsi/ufs/ufshcd-dwc.c
new file mode 100644
index 000..c1b8a7f
--- /dev/null
+++ b/drivers/scsi/ufs/ufshcd-dwc.c
@@ -0,0 +1,150 @@
+/*
+ * UFS Host driver for Synopsys Designware Core
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "unipro.h"
+
+#include "ufshcd-dwc.h"
+#include "ufshci-dwc.h"
+
+int ufshcd_dwc_dme_set_attrs(struct ufs_hba *hba,
+   const struct ufshcd_dme_attr_val *v, int n)
+{
+   int ret = 0;
+

[PATCH v10 2/6] added UFS 2.0 capabilities

2016-03-04 Thread Joao Pinto
Adding UFS 2.0 support to the UFS core driver.

Signed-off-by: Joao Pinto 
---
Changes v8->v10:
- Nothing changed (just to keep up with patch set version).
Changes v7->v8:
- Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings
Changes v0->v7:
- Nothing changed (just to keep up with patch set version).

 .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |  4 +--
 drivers/scsi/ufs/ufshcd.c  | 29 +++---
 drivers/scsi/ufs/ufshci.h  |  1 +
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
index 03c0e98..8d9a9d2 100644
--- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
+++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
@@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host 
controllers.
 Each UFS controller instance should have its own node.
 
 Required properties:
-- compatible   : must contain "jedec,ufs-1.1", may also list one or 
more
- of the following:
+- compatible   : must contain "jedec,ufs-1.1" or "jedec,ufs-2.0", may
+ also list one or more of the following:
  "qcom,msm8994-ufshc"
  "qcom,msm8996-ufshc"
  "qcom,ufshc"
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 85cd256..2b5f2bf 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1223,6 +1223,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, 
struct ufshcd_lrb *lrbp)
ret = -EINVAL;
}
break;
+   case UTP_CMD_TYPE_UFS_STORAGE:
case UTP_CMD_TYPE_DEV_MANAGE:
ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
@@ -1287,6 +1288,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *cmd)
struct ufshcd_lrb *lrbp;
struct ufs_hba *hba;
unsigned long flags;
+   u32 upiu_flags;
int tag;
int err = 0;
 
@@ -1343,10 +1345,23 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *cmd)
lrbp->task_tag = tag;
lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;
-   lrbp->command_type = UTP_CMD_TYPE_SCSI;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_SCSI;
 
/* form UPIU before issuing the command */
-   ufshcd_compose_upiu(hba, lrbp);
+   if (hba->ufs_version == UFSHCI_VERSION_20) {
+   if (likely(lrbp->cmd)) {
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
+   lrbp->cmd->sc_data_direction);
+   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
+   } else
+   err = -EINVAL;
+   } else
+   ufshcd_compose_upiu(hba, lrbp);
+
err = ufshcd_map_sg(lrbp);
if (err) {
lrbp->cmd = NULL;
@@ -1371,7 +1386,12 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
lrbp->sense_buffer = NULL;
lrbp->task_tag = tag;
lrbp->lun = 0; /* device management cmd is not specific to any LUN */
-   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
lrbp->intr_cmd = true; /* No interrupt aggregation */
hba->dev_cmd.type = cmd_type;
 
@@ -3187,7 +3207,8 @@ static void ufshcd_transfer_req_compl(struct ufs_hba *hba)
/* Do not touch lrbp after scsi done */
cmd->scsi_done(cmd);
__ufshcd_release(hba);
-   } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) {
+   } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
+   lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) {
if (hba->dev_cmd.complete)
complete(hba->dev_cmd.complete);
}
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index 0ae0967..8dba0e7 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -273,6 +273,7 @@ enum {
UTP_CMD_TYPE_SCSI   = 0x

[PATCH v10 6/6] add TC G210 pci driver

2016-03-04 Thread Joao Pinto
This patch adds a glue pci driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/Kconfig   |   9 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 178 +
 3 files changed, 188 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 5cfa87b..5a3fde7 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -99,3 +99,12 @@ config SCSI_UFS_DWC_TC_PLATFORM
  Synopsys Test Chip is a PHY for prototyping purposes.
 
  If unsure, say N."
+
+config SCSI_UFS_DWC_TC_PCI
+   tristate "DesignWare pci support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PCI
+   select SCSI_UFS_DWC_TC
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N."
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index a977fe0..5303d85 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -2,6 +2,7 @@
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PCI) += tc-dwc-g210-pci.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c 
b/drivers/scsi/ufs/tc-dwc-g210-pci.c
new file mode 100644
index 000..cac8fae
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -0,0 +1,178 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+#include 
+#include 
+
+/* Test Chip type expected values */
+#define TC_G210_20BIT 20
+#define TC_G210_40BIT 40
+#define TC_G210_DEFAULTBIT 40
+
+static int tc_type = TC_G210_DEFAULTBIT;
+module_param(tc_type, int, 0);
+MODULE_PARM_DESC(tc_type, "Test Chip Type (20 = 20-bit, 40 = 40-bit)");
+
+static int tc_dwc_g210_pci_suspend(struct device *dev)
+{
+   return ufshcd_system_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_resume(struct device *dev)
+{
+   return ufshcd_system_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_suspend(struct device *dev)
+{
+   return ufshcd_runtime_suspend(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_resume(struct device *dev)
+{
+   return ufshcd_runtime_resume(dev_get_drvdata(dev));
+}
+
+static int tc_dwc_g210_pci_runtime_idle(struct device *dev)
+{
+   return ufshcd_runtime_idle(dev_get_drvdata(dev));
+}
+
+/**
+ * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_pci_hba_vops = {
+   .name   = "tc-dwc-g210-pci",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+};
+
+/**
+ * tc_dwc_g210_pci_shutdown - main function to put the controller in reset 
state
+ * @pdev: pointer to PCI device handle
+ */
+static void tc_dwc_g210_pci_shutdown(struct pci_dev *pdev)
+{
+   ufshcd_shutdown((struct ufs_hba *)pci_get_drvdata(pdev));
+}
+
+/**
+ * tc_dwc_g210_pci_remove - de-allocate PCI/SCSI host and host memory space
+ * data structure memory
+ * @pdev - pointer to PCI handle
+ */
+static void tc_dwc_g210_pci_remove(struct pci_dev *pdev)
+{
+   struct ufs_hba *hba = pci_get_drvdata(pdev);
+
+   pm_runtime_forbid(&pdev->dev);
+   pm_runtime_get_noresume(&pdev->dev);
+   ufshcd_remove(hba);
+}
+
+/**
+ * tc_dwc_g210_pci_probe - probe routine of the driver
+ * @pdev: pointer to PCI device handle
+ * @id: PCI device id
+ *
+ * Returns 0 on success, non-zero value on failure
+ */
+static int
+tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+   struct ufs_hba *hba;
+   void __iomem *mmio_base;
+   int err;
+
+   /* Check Test Chip type and set the specific setup routine */
+   if (tc_type == TC_G210_20BIT) {
+   tc_dwc_g210_pci_hba_vops.custom_phy_initialization =
+   tc_dwc_g210_config_20_bit;
+   } else if (tc_type == TC_G210_40BIT) {
+   tc_dwc_g210_pci_hba_vops.custom_phy_initialization =
+   tc_dwc_g210_config_40_bit;
+   }
+
+   err = pcim_enable_device(pdev);
+   if (err) {
+   dev_err(&pdev->dev, "

[PATCH v10 5/6] add TC G210 platform driver

2016-03-04 Thread Joao Pinto
This patch adds a glue platform driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v0->v10:
- This patch only appeared in v10

 .../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt |  26 +
 drivers/scsi/ufs/Kconfig   |   9 ++
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 109 +
 4 files changed, 145 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c

diff --git a/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
new file mode 100644
index 000..6ec9647
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
@@ -0,0 +1,26 @@
+* Universal Flash Storage (UFS) DesignWare Host Controller
+
+DWC_UFS nodes are defined to describe on-chip UFS host controllers and MPHY.
+Each UFS controller instance should have its own node.
+
+Required properties:
+- compatible   : compatible list must contain the PHY type & version:
+   "snps, g210-tc-6.00-20bit"
+   "snps, g210-tc-6.00-40bit"
+ complemented with the Controller IP version:
+   "snps, dwc-ufshcd-1.40a"
+ complemented with the JEDEC version:
+   "jedec,ufs-1.1"
+   "jedec,ufs-2.0"
+
+- reg  : 
+- interrupts   : 
+
+Example for a setup using a 1.40a DWC Controller with a 6.00 G210 40-bit TC:
+   dwc_ufs@d000 {
+   compatible = "snps, g210-tc-6.00-40bit",
+"snps, dwc-ufshcd-1.40a",
+"jedec,ufs-2.0";
+   reg = < 0xd000 0x1 >;
+   interrupts = < 24 >;
+   };
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 9d218f9..5cfa87b 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -90,3 +90,12 @@ config SCSI_UFS_DWC
 config SCSI_UFS_DWC_TC
bool
select SCSI_UFS_DWC
+
+config SCSI_UFS_DWC_TC_PLATFORM
+   tristate "DesignWare platform support using a G210 Test Chip"
+   depends on SCSI_UFSHCD_PLATFORM
+   select SCSI_UFS_DWC_TC
+   ---help---
+ Synopsys Test Chip is a PHY for prototyping purposes.
+
+ If unsure, say N."
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index 9468d7b..a977fe0 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,6 +1,7 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
 obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c 
b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
new file mode 100644
index 000..c91d4b9
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -0,0 +1,109 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ufshcd-pltfrm.h"
+#include "ufshcd-dwc.h"
+#include "tc-dwc-g210.h"
+
+/**
+ * struct ufs_hba_dwc_vops - UFS DWC specific variant operations
+ */
+static struct ufs_hba_variant_ops tc_dwc_g210_pltfm_hba_vops = {
+   .name   = "tc-dwc-g210-pltfm",
+   .link_startup_notify= ufshcd_dwc_link_startup_notify,
+};
+
+/**
+ * tc_dwc_g210_pltfm_probe()
+ * @pdev: pointer to platform device structure
+ *
+ */
+static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev)
+{
+   int err;
+   struct device *dev = &pdev->dev;
+   struct device_node *np = dev->of_node;
+
+   /* Check Test Chip type and set the specific setup routine */
+   if (of_device_is_compatible(np, "snps, g210-tc-6.00-20bit")) {
+   tc_dwc_g210_pltfm_hba_vops.custom_phy_initialization =
+   tc_dwc_g210_config_20_bit;
+   } else if (of_device_is_compatible(np, "snps, g210-tc-6.00-40bit")) {
+   tc_dwc_g210_pltfm_hba_vops.custom_phy_initialization =
+   tc_dwc_g210_config_40_bit;
+   }
+
+   /* Perform generic probe */
+   err = ufshcd_pltfrm_init(pdev, &tc_dwc_g210_pltfm_hba_vops);
+   if

[PATCH v10 4/6] added support for Synopsys G210 Test Chip

2016-03-04 Thread Joao Pinto
This patch adds support for Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto 
---
Changes v0->v10:
- This patch only appeared in v10

 drivers/scsi/ufs/Kconfig   |   4 +
 drivers/scsi/ufs/Makefile  |   1 +
 drivers/scsi/ufs/tc-dwc-g210.c | 315 +
 drivers/scsi/ufs/tc-dwc-g210.h |  19 +++
 4 files changed, 339 insertions(+)
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h

diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 647c324..9d218f9 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -86,3 +86,7 @@ config SCSI_UFS_QCOM
 
 config SCSI_UFS_DWC
bool
+
+config SCSI_UFS_DWC_TC
+   bool
+   select SCSI_UFS_DWC
diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile
index ccbad53..9468d7b 100644
--- a/drivers/scsi/ufs/Makefile
+++ b/drivers/scsi/ufs/Makefile
@@ -1,5 +1,6 @@
 # UFSHCD makefile
 obj-$(CONFIG_SCSI_UFS_DWC) += ufshcd-dwc.o
+obj-$(CONFIG_SCSI_UFS_DWC_TC) += tc-dwc-g210.o
 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o
 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o
 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
diff --git a/drivers/scsi/ufs/tc-dwc-g210.c b/drivers/scsi/ufs/tc-dwc-g210.c
new file mode 100644
index 000..181f208
--- /dev/null
+++ b/drivers/scsi/ufs/tc-dwc-g210.c
@@ -0,0 +1,315 @@
+/*
+ * Synopsys G210 Test Chip driver
+ *
+ * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com)
+ *
+ * Authors: Joao Pinto 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "ufshcd.h"
+#include "unipro.h"
+
+#include "ufshcd-dwc.h"
+#include "ufshci-dwc.h"
+
+/**
+ * tc_dwc_g210_setup_40bit_rmmi()
+ * This function configures Synopsys TC specific atributes (40-bit RMMI)
+ * @hba: Pointer to drivers structure
+ *
+ * Returns 0 on success or non-zero value on failure
+ */
+static int tc_dwc_g210_setup_40bit_rmmi(struct ufs_hba *hba)
+{
+   const struct ufshcd_dme_attr_val setup_attrs[] = {
+   { UIC_ARG_MIB(TX_GLOBALHIBERNATE), 0x00, DME_LOCAL },
+   { UIC_ARG_MIB(REFCLKMODE), 0x01, DME_LOCAL },
+   { UIC_ARG_MIB(CDIRECTCTRL6), 0x80, DME_LOCAL },
+   { UIC_ARG_MIB(CBDIVFACTOR), 0x08, DME_LOCAL },
+   { UIC_ARG_MIB(CBDCOCTRL5), 0x64, DME_LOCAL },
+   { UIC_ARG_MIB(CBPRGTUNING), 0x09, DME_LOCAL },
+   { UIC_ARG_MIB(RTOBSERVESELECT), 0x00, DME_LOCAL },
+   { UIC_ARG_MIB_SEL(TX_REFCLKFREQ, SELIND_LN0_TX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(TX_CFGCLKFREQVAL, SELIND_LN0_TX), 0x19,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGEXTRATTR, SELIND_LN0_TX), 0x14,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(DITHERCTRL2, SELIND_LN0_TX), 0xd6,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RX_REFCLKFREQ, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RX_CFGCLKFREQVAL, SELIND_LN0_RX), 0x19,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGWIDEINLN, SELIND_LN0_RX), 4,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXCDR8, SELIND_LN0_RX), 0x80,
+   DME_LOCAL },
+   { UIC_ARG_MIB(DIRECTCTRL10), 0x04, DME_LOCAL },
+   { UIC_ARG_MIB(DIRECTCTRL19), 0x02, DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXCDR8, SELIND_LN0_RX), 0x80,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG4, SELIND_LN0_RX), 0x03,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(CFGRXOVR8, SELIND_LN0_RX), 0x16,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXDIRECTCTRL2, SELIND_LN0_RX), 0x42,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG3, SELIND_LN0_RX), 0xa4,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(RXCALCTRL, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },
+   { UIC_ARG_MIB_SEL(ENARXDIRECTCFG2, SELIND_LN0_RX), 0x01,
+   DME_LOCAL },

[PATCH v10 0/6] add support for DWC UFS Controller

2016-03-04 Thread Joao Pinto
The work consisted of:
- Fixed typo in ufshcd-pltfrm.c
- Tweak ufshcd.c for UFS 2.0 support
- Implement ufshcd-dwc which contains all DWC HW specific code
- Unipro attributes were added and new registers were added to the driver
- Implement a tc-dwc-g210 containing G210 MPHY specific code
- Implement a tc-dwc-g210 glue platform driver
- Implement a tc-dwc-g210 glue pci driver
- Documentation update

Remark: The individual patches are not atomic, depending on other patches of
the set. The patch set was made like this to improve readability.

Joao Pinto (6):
  fixed typo in ufshcd-pltfrm
  added UFS 2.0 capabilities
  added support for DesignWare Controller
  added support for Synopsys G210 Test Chip
  add TC G210 platform driver
  add TC G210 pci driver

 .../devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt |  26 ++
 .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |   4 +-
 MAINTAINERS|   6 +
 drivers/scsi/ufs/Kconfig   |  25 ++
 drivers/scsi/ufs/Makefile  |   4 +
 drivers/scsi/ufs/tc-dwc-g210-pci.c | 178 
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c  | 109 +++
 drivers/scsi/ufs/tc-dwc-g210.c | 315 +
 drivers/scsi/ufs/tc-dwc-g210.h |  19 ++
 drivers/scsi/ufs/ufshcd-dwc.c  | 150 ++
 drivers/scsi/ufs/ufshcd-dwc.h  |  26 ++
 drivers/scsi/ufs/ufshcd-pltfrm.c   |   2 +-
 drivers/scsi/ufs/ufshcd.c  |  29 +-
 drivers/scsi/ufs/ufshcd.h  |   2 +
 drivers/scsi/ufs/ufshci-dwc.h  |  42 +++
 drivers/scsi/ufs/ufshci.h  |   1 +
 drivers/scsi/ufs/unipro.h  |  39 +++
 17 files changed, 970 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pci.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.c
 create mode 100644 drivers/scsi/ufs/tc-dwc-g210.h
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

-- 
1.8.1.5

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


Re: [PATCH v9 3/3] add support for DWC UFS Host Controller

2016-03-03 Thread Joao Pinto

On 3/3/2016 2:12 PM, Arnd Bergmann wrote:
> On Thursday 03 March 2016 13:52:39 Joao Pinto wrote:
>>
>> config SCSI_UFS_DWC
>> bool
>>
>> config SCSI_UFS_DWC_TC_PLATFORM
>> tristate "DesignWare platform support using a G210 Test Chip"
>> depends on SCSI_UFSHCD_PLATFORM
>> select SCSI_UFS_DWC
>> ---help---
>>   Synopsys Test Chip is a PHY for prototyping purposes.
>>
>>   If unsure, say N."
>>
>> config SCSI_UFS_DWC_TC_PCI
>> tristate "DesignWare pci support using a G210 Test Chip"
>> depends on SCSI_UFSHCD_PCI
>> select SCSI_UFS_DWC
>> ---help---
>>   Synopsys Test Chip is a PHY for prototyping purposes.
>>
>>   If unsure, say N."
>>
>> I would keep SCSI_UFS_DWC to avoid building DWC specific source everytime.
>>
>> Agree?
>>
> 
> Yes, looks good to me.
> 
>   Arnd
> 

Nice! Thanks for the inputs. I'm going to implement the changes and send a v10 
soon.

Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 3/3] add support for DWC UFS Host Controller

2016-03-03 Thread Joao Pinto
Hi,

On 3/3/2016 12:04 PM, Arnd Bergmann wrote:
> On Thursday 03 March 2016 11:39:05 Joao Pinto wrote:
>> Hi Arnd,
>>
>> On 3/2/2016 7:55 PM, Arnd Bergmann wrote:
>>> On Wednesday 02 March 2016 16:46:47 Joao Pinto wrote:
>>>> On 2/19/2016 3:03 PM, Arnd Bergmann wrote:
>>>>> On Thursday 18 February 2016 17:20:27 Joao Pinto wrote:
>>
>> Facts:
>>
>> - Test Chip type are currently not detectable in runtime through the 
>> controller
>> - In the future the Test Chip version will be available in the controller
>> - Test Chip initialization is different for each type
>> - The IP Core version is 1.40a
>> - Test Chip version is 6.00
>> - Teh UFS version is 2.0
> 
> Ok.
> 
>> Suggested driver architecture:
>>
>> Platform setup:
>>  tc-dwc-g210-pltfrm --> tc-dwc-g210 --> ufshcd-dwc-pltfrm --> ufshcd-dwc --> 
>> ufs
>>
>> The test chip platform driver could be called through 2 compatibility 
>> strings.
>> indicating the chip's version and bit type:
>>  "snps, g210-tc-6.00-20bit"
>>  "snps, g210-tc-6.00-40bit"
> 
> Yes, this sounds good. We can probably skip one of the middle layers,
> but basically that is what I was looking for.
> 
>> The device tree node would have additional info compatibility strings as the 
>> DWC
>> IP core version and UFS version:
>>  "snps, dwc-ufshcd-1.40a"
>>  "jedec, ufs-2.0"
>>
>> PCI based setup:
>>  tc-dwc-g210-pci --> tc-dwc-g210 --> ufshcd-dwc-pci --> ufshcd-dwc --> ufs
> 
> The tc-dwc-g210 portion probably shouldn't depend on both
> ufshcd-dwc-pltfrm and ufshcd-dwc-pci here, so how about leaving
> those two out?
> 
> 
> Then it becomes
> 
>tc-dwc-g210-pci ---> tc-dwc-g210 --> ufshcd-dwc --> ufs
> tc-dwc-g210-pltfrm --/

Ok, understood. It becomes simpler without the pltfm and pci "middle layer".

> 
>> The test chip type would be configured by a parameter to be passed in the 
>> kernel
>> boot args: tc_type = 20 (20-bit) or tc_type = 40 (40-bit)
> 
> Right. With module_param() helper, this will be either a boot command
> line option, or a module load option, depending on whether the driver
> is built-on or not.
> 
> modprobe tc-dwc-g210-pci tc_type=20
> 
> command line: tc-dwc-g210-pci.tc_type=20
>  

Right, that was the idea.

>> Having this in mind the KConfig would be:
>>
>> "config SCSI_UFS_DWC_HOOKS
>>  bool
> 
> I think we can now remove the config option for the hooks as well.
> 
>> config SCSI_UFS_DWC_PLAT
>>  tristate "DesignWare UFS controller platform glue driver"
>>  depends on SCSI_UFSHCD_PLATFORM
>>  select SCSI_UFS_DWC_HOOKS
>>  help
>>This selects the DesignWare UFS host controller platform glue driver.
>>
>>Select this if you have a DesignWare UFS controller on Platform bus.
>>If unsure, say N.
>>
>> config SCSI_UFS_DWC_PCI
>>  tristate "DesignWare UFS controller pci glue driver"
>>  depends on SCSI_UFSHCD_PCI
>>  select SCSI_UFS_DWC_HOOKS
>>  help
>>This selects the DesignWare UFS host controller pci glue driver.
>>
>>Select this if you have a DesignWare UFS controller on pci bus.
>>If unsure, say N.
>>
>> config SCSI_UFS_DWC_TC
>>  bool "Support for the Synopsys Test Chip"
>>  depends on SCSI_UFS_DWC_HOOKS && (SCSI_UFSHCD_PCI || SCSI_UFS_DWC_PLAT)
>>  ---help---
>>Synopsys Test Chip is a Phy for prototyping purposes.
>>This selects the support for the Synopsys Test Chip.
>>
>>Select this if you have a Synopsys Test Chip.
>>If unsure, say N."
>>
>> Agree with the approach?
> 
> This would work, but I think it's better to define the options in terms
> of the top-level drivers, i.e. SCSI_UFS_DWC_TC_PCI and 
> SCSI_UFS_DWC_TC_PLATFORM,
> and then make the other options hidden and implicitly turned out by them.
> 

config SCSI_UFS_DWC
bool

config SCSI_UFS_DWC_TC_PLATFORM
tristate "DesignWare platform support using a G210 Test Chip"
depends on SCSI_UFSHCD_PLATFORM
select SCSI_UFS_DWC
---help---
  Synopsys Test Chip is a PHY for prototyping purposes.

  If unsure, say N."

config SCSI_UFS_DWC_TC_PCI
tristate "DesignWare pci support using a G210 Test Chip"
depends on SCSI_UFSHCD_PCI
select SCSI_UFS_DWC
---help---
  Synopsys Test Chip is a PHY for prototyping purposes.

  If unsure, say N."

I would keep SCSI_UFS_DWC to avoid building DWC specific source everytime.

Agree?

>   Arnd
> 

Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 3/3] add support for DWC UFS Host Controller

2016-03-03 Thread Joao Pinto
Hi Arnd,

On 3/2/2016 7:55 PM, Arnd Bergmann wrote:
> On Wednesday 02 March 2016 16:46:47 Joao Pinto wrote:
>> On 2/19/2016 3:03 PM, Arnd Bergmann wrote:
>>> On Thursday 18 February 2016 17:20:27 Joao Pinto wrote:

Facts:

- Test Chip type are currently not detectable in runtime through the controller
- In the future the Test Chip version will be available in the controller
- Test Chip initialization is different for each type
- The IP Core version is 1.40a
- Test Chip version is 6.00
- Teh UFS version is 2.0

Suggested driver architecture:

Platform setup:
 tc-dwc-g210-pltfrm --> tc-dwc-g210 --> ufshcd-dwc-pltfrm --> ufshcd-dwc --> ufs

The test chip platform driver could be called through 2 compatibility strings.
indicating the chip's version and bit type:
 "snps, g210-tc-6.00-20bit"
 "snps, g210-tc-6.00-40bit"

The device tree node would have additional info compatibility strings as the DWC
IP core version and UFS version:
 "snps, dwc-ufshcd-1.40a"
 "jedec, ufs-2.0"

PCI based setup:
 tc-dwc-g210-pci --> tc-dwc-g210 --> ufshcd-dwc-pci --> ufshcd-dwc --> ufs

The test chip type would be configured by a parameter to be passed in the kernel
boot args: tc_type = 20 (20-bit) or tc_type = 40 (40-bit)

Having this in mind the KConfig would be:

"config SCSI_UFS_DWC_HOOKS
bool

config SCSI_UFS_DWC_PLAT
tristate "DesignWare UFS controller platform glue driver"
depends on SCSI_UFSHCD_PLATFORM
select SCSI_UFS_DWC_HOOKS
help
  This selects the DesignWare UFS host controller platform glue driver.

  Select this if you have a DesignWare UFS controller on Platform bus.
  If unsure, say N.

config SCSI_UFS_DWC_PCI
tristate "DesignWare UFS controller pci glue driver"
depends on SCSI_UFSHCD_PCI
select SCSI_UFS_DWC_HOOKS
help
  This selects the DesignWare UFS host controller pci glue driver.

  Select this if you have a DesignWare UFS controller on pci bus.
  If unsure, say N.

config SCSI_UFS_DWC_TC
bool "Support for the Synopsys Test Chip"
depends on SCSI_UFS_DWC_HOOKS && (SCSI_UFSHCD_PCI || SCSI_UFS_DWC_PLAT)
---help---
  Synopsys Test Chip is a Phy for prototyping purposes.
  This selects the support for the Synopsys Test Chip.

  Select this if you have a Synopsys Test Chip.
  If unsure, say N."

Agree with the approach?

Thanks for the help.

Joao

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


Re: [PATCH v9 3/3] add support for DWC UFS Host Controller

2016-03-02 Thread Joao Pinto

Hi Arnd,

On 2/19/2016 3:03 PM, Arnd Bergmann wrote:
> On Thursday 18 February 2016 17:20:27 Joao Pinto wrote:
>>
>>  Documentation/devicetree/bindings/ufs/ufs-dwc.txt |  19 +
>>  MAINTAINERS   |   6 +
>>  drivers/scsi/ufs/Kconfig  |  51 +++
>>  drivers/scsi/ufs/Makefile |   3 +
>>  drivers/scsi/ufs/ufs-dwc-pci.c| 172 +
>>  drivers/scsi/ufs/ufs-dwc.c|  96 +
>>  drivers/scsi/ufs/ufshcd-dwc.c | 431 
>> ++
>>  drivers/scsi/ufs/ufshcd-dwc.h |  18 +
>>  drivers/scsi/ufs/ufshci-dwc.h |  42 +++
>>  drivers/scsi/ufs/unipro.h |  39 ++
> 
> I still think this can be split up further. From your previous
> explanation, I understand that there is a specific test chip
> that uses the "snps,ufshcd-dwc" implementation along with some
> other glue logic.
> 
> Please split this out so you have anything related to the test
> chips separate from the patch that implements core logic.

Ok, I will split more the patches.

>  
>> diff --git a/Documentation/devicetree/bindings/ufs/ufs-dwc.txt 
>> b/Documentation/devicetree/bindings/ufs/ufs-dwc.txt
>> new file mode 100644
>> index 000..59e9822
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/ufs/ufs-dwc.txt
>> @@ -0,0 +1,19 @@
>> +* Universal Flash Storage (UFS) DesignWare Host Controller
>> +
>> +DWC_UFSHC nodes are defined to describe on-chip UFS host controllers.
>> +Each UFS controller instance should have its own node.
>> +
>> +Required properties:
>> +- compatible: compatible list must contain "snps,ufshcd-dwc" and 
>> should
>> +  also contain the JEDEC version of the controller:
>> +"jedec,ufs-1.1"
>> +"jedec,ufs-2.0"
>> +- reg   : 
>> +- interrupts: 
> 
> 
> Based on your last reply to me (sorry for coming back to this so
> late), I think having just "snps,ufshcd-dwc" as the compatible
> string is not appropriate: This assumes that all "snps,ufshcd-dwc"
> instances are 100% compatible, but your code makes it very clear
> that this is not the case.
> 
> Please for the last time (!) add a proper version number of the
> specific IP block to the compatible strings so you can identify
> what hardware you are talking to.
> 
> You earlier confused the version number of the UFS standard with
> the version number of the controller, and that has been clarified
> now, but you really still need to use a version for the hardware
> as well.

Ok, we can have a "snps,ufshcd-dwc-1.1" and a "snps,ufshcd-dwc-2.0". Agree?

> 
>> +config SCSI_UFS_DWC_TC
>> +bool "Support for the Synopsys Test Chip"
>> +depends on SCSI_UFS_DWC_HOOKS && (SCSI_UFSHCD_PCI || SCSI_UFS_DWC_PLAT)
>> +---help---
>> +  Synopsys Test Chip is a Phy for prototyping purposes.
>> +  This selects the support for the Synopsys Test Chip.
>> +
>> +  Select this if you have a Synopsys Test Chip.
>> +  If unsure, say N.
>> +
>> +config SCSI_UFS_DWC_20BIT_RMMI
>> +bool "20-bit RMMI support"
>> +depends on SCSI_UFS_DWC_TC
>> +---help---
>> +  This specifies that the Synopsys Test Chip supports 20-bit RMMI.
>> +
>> +  Select this if you are using a 20-bit RMMI Synopsys Test Chip.
>> +  If unsure, say N.
>> +
>> +config SCSI_UFS_DWC_40BIT_RMMI
>> +bool "40-bit RMMI support"
>> +depends on SCSI_UFS_DWC_TC
>> +---help---
>> +  Synopsys Test Chip is a Phy for prototyping purposes.
>> +
>> +  Select this if you are using a 40-bit RMMI Synopsys Test Chip.
>> +  If unsure, say N.
> 
> I think it would be better to remove the SCSI_UFS_DWC_20BIT_RMMI
> and SCSI_UFS_DWC_40BIT_RMMI configuration options now, and always
> support both. There is not really much need for the options
> as this is just a test chip, and nobody is going to care much
> about saving a few bytes of object code.

We need to know if we are dealing with a 20-bit test chip or a 40-bit test chip
because the initialization is different. That can be made in the device tree as
you say bellow, but we can also use a setup in which the host is a PC (so no
device tree) connected by pci bus to an fpga containing the UFS controller.
Having this, I think that the only way is to choose the 20/40bit stuff in the
m

[PATCH v8 2/3] added UFS 2.0 capabilities

2016-02-15 Thread Joao Pinto
Adding UFS 2.0 support to the UFS core driver.

Signed-off-by: Joao Pinto 
---
Changes v7->v8:
- Added "jedec, ufs-2.0" to the ufschd-platform compatibility strings
Changes v0->v7:
- Nothing changed (just to keep up with patch set version).

 .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |  4 +--
 drivers/scsi/ufs/ufshcd.c  | 29 +++---
 drivers/scsi/ufs/ufshci.h  |  1 +
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt 
b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
index 03c0e98..8d9a9d2 100644
--- a/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
+++ b/Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt
@@ -4,8 +4,8 @@ UFSHC nodes are defined to describe on-chip UFS host 
controllers.
 Each UFS controller instance should have its own node.
 
 Required properties:
-- compatible   : must contain "jedec,ufs-1.1", may also list one or 
more
- of the following:
+- compatible   : must contain "jedec,ufs-1.1" or "jedec,ufs-2.0", may
+ also list one or more of the following:
  "qcom,msm8994-ufshc"
  "qcom,msm8996-ufshc"
  "qcom,ufshc"
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 85cd256..2b5f2bf 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1223,6 +1223,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, 
struct ufshcd_lrb *lrbp)
ret = -EINVAL;
}
break;
+   case UTP_CMD_TYPE_UFS_STORAGE:
case UTP_CMD_TYPE_DEV_MANAGE:
ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
@@ -1287,6 +1288,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *cmd)
struct ufshcd_lrb *lrbp;
struct ufs_hba *hba;
unsigned long flags;
+   u32 upiu_flags;
int tag;
int err = 0;
 
@@ -1343,10 +1345,23 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *cmd)
lrbp->task_tag = tag;
lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;
-   lrbp->command_type = UTP_CMD_TYPE_SCSI;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_SCSI;
 
/* form UPIU before issuing the command */
-   ufshcd_compose_upiu(hba, lrbp);
+   if (hba->ufs_version == UFSHCI_VERSION_20) {
+   if (likely(lrbp->cmd)) {
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
+   lrbp->cmd->sc_data_direction);
+   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
+   } else
+   err = -EINVAL;
+   } else
+   ufshcd_compose_upiu(hba, lrbp);
+
err = ufshcd_map_sg(lrbp);
if (err) {
lrbp->cmd = NULL;
@@ -1371,7 +1386,12 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
lrbp->sense_buffer = NULL;
lrbp->task_tag = tag;
lrbp->lun = 0; /* device management cmd is not specific to any LUN */
-   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
lrbp->intr_cmd = true; /* No interrupt aggregation */
hba->dev_cmd.type = cmd_type;
 
@@ -3187,7 +3207,8 @@ static void ufshcd_transfer_req_compl(struct ufs_hba *hba)
/* Do not touch lrbp after scsi done */
cmd->scsi_done(cmd);
__ufshcd_release(hba);
-   } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) {
+   } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
+   lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) {
if (hba->dev_cmd.complete)
complete(hba->dev_cmd.complete);
}
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index 0ae0967..8dba0e7 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -273,6 +273,7 @@ enum {
UTP_CMD_TYPE_SCSI   = 0x0,
UTP_CMD_TYPE_UFS= 0x1,
UTP_CMD_TYPE_DEV_MANAGE 

[PATCH v8 1/3] fixed typo in ufshcd-pltfrm

2016-02-15 Thread Joao Pinto
Fixed typo in ufshcd-pltfrm.

Signed-off-by: Joao Pinto 
---
Changes v0->v8:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index d2a7b12..0522891 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -353,6 +353,6 @@ EXPORT_SYMBOL_GPL(ufshcd_pltfrm_init);
 
 MODULE_AUTHOR("Santosh Yaragnavi ");
 MODULE_AUTHOR("Vinayak Holikatti ");
-MODULE_DESCRIPTION("UFS host controller Pltform bus based glue driver");
+MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(UFSHCD_DRIVER_VERSION);
-- 
1.8.1.5

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


[PATCH v8 3/3] add support for DWC UFS Host Controller

2016-02-15 Thread Joao Pinto
This patch has the goal to add support for DesignWare UFS Controller
specific operations and to add specific platform and pci drivers.

Signed-off-by: Joao Pinto 
---
Changes v7->v8 (Akinobu Mita):
- DME sets were simplified for easier reading
- CLK DIV default values definitions names were changed to match the
 register's name
- New line added to dev_err and dev_info statements
Changes v6->v7 (Arnd Bergmann):
- Changed DT node name (to ufs only) and the memory address (to 0xd00)
- Removed CONFIG_PM from the PCI glue driver (pm.h already does this)
- No other changes are necessary in ufshcd.c because of the link up notify
 function usage (it is simpler now)
- Removed the PHY mentioning since the Test Chip is not a real PHY for real
 world usage, since it is a test chip for prototyping with a very specific
 usage
- Added again the Test Chip 20-bit option
Changes v5->v6:
- Patch bad format fixed
Changes v4->v5 (Akinobu Mita):
- All functions used only locally in ufshcd-dwc are now declared as static
- ufshcd_dwc_configuration() was removed in ufshcd-dwc and a notify
 function (ufshcd_dwc_link_startup_notify) was created to deal with the
 DWC specific init routines
- 20-bit RMMI option was removed from Kconfig. Now if MPHY TC is selected
 and 40-bit is not then it assumes a 20-bit config
Changes v3->v4 (Arnd Bergmann and Mark Rutland):
- SCSI_UFS_DWC_HOOKS is now silent and selected by the SCSI_UFS_DWC_PLAT
 or SCSI_UFS_DWC_PCI
- Compatibility string has the ufs core version for info purposes since
 the driver is capable of getting the controller version from its 
 registers
- Created ufs-dwc-pci glue driver with specific DWC data
- MPHY configuration remains in the ufshcd-dwc since it is unipro
 attribute writting only not following the a linux phy framework logic
Changes v2->v3 (Julian Calaby):
- Implement a common DWC code to be used by the platform and pci glue
 drivers
- Synopsys ID & Class added to the existing pci driver and specific DWC
 was also added to the pci driver
Changes v1->v2 (Akinobu Mita):
- Implement a platform driver that uses the existing UFS core driver
- Add DWC specific code to the existing UFS core driver

 Documentation/devicetree/bindings/ufs/ufs-dwc.txt |  19 +
 MAINTAINERS   |   6 +
 drivers/scsi/ufs/Kconfig  |  51 +++
 drivers/scsi/ufs/Makefile |   3 +
 drivers/scsi/ufs/ufs-dwc-pci.c| 172 +
 drivers/scsi/ufs/ufs-dwc.c|  96 +
 drivers/scsi/ufs/ufshcd-dwc.c | 431 ++
 drivers/scsi/ufs/ufshcd-dwc.h |  18 +
 drivers/scsi/ufs/ufshci-dwc.h |  42 +++
 drivers/scsi/ufs/unipro.h |  39 ++
 10 files changed, 877 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufs-dwc.txt
 create mode 100644 drivers/scsi/ufs/ufs-dwc-pci.c
 create mode 100644 drivers/scsi/ufs/ufs-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

diff --git a/Documentation/devicetree/bindings/ufs/ufs-dwc.txt 
b/Documentation/devicetree/bindings/ufs/ufs-dwc.txt
new file mode 100644
index 000..59e9822
--- /dev/null
+++ b/Documentation/devicetree/bindings/ufs/ufs-dwc.txt
@@ -0,0 +1,19 @@
+* Universal Flash Storage (UFS) DesignWare Host Controller
+
+DWC_UFSHC nodes are defined to describe on-chip UFS host controllers.
+Each UFS controller instance should have its own node.
+
+Required properties:
+- compatible: compatible list must contain "snps,ufshcd-dwc" and should
+ also contain the JEDEC version of the controller:
+   "jedec,ufs-1.1"
+   "jedec,ufs-2.0"
+- reg   : 
+- interrupts: 
+
+Example:
+   ufs@0xd000 {
+   compatible = "jedec,ufs-2.0", "snps,dwc-ufshcd";
+   reg = < 0xd000 0x1 >;
+   interrupts = < 24 >;
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index d2f94e2..3db3c4c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11006,6 +11006,12 @@ S: Supported
 F: Documentation/scsi/ufs.txt
 F:     drivers/scsi/ufs/
 
+UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER DWC HOOKS
+M: Joao Pinto 
+L: linux-scsi@vger.kernel.org
+S: Supported
+F: drivers/scsi/ufs/*dwc*
+
 UNSORTED BLOCK IMAGES (UBI)
 M: Artem Bityutskiy 
 M: Richard Weinberger 
diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig
index 5f45307..35e9ddf 100644
--- a/drivers/scsi/ufs/Kconfig
+++ b/drivers/scsi/ufs/Kconfig
@@ -83,3 +83,54 @@ config SCSI_UFS_QCOM
 
  Select this if you have UFS controller on QCOM chipset.
  If unsure, say N.
+
+config SCSI_UFS_DWC_HOOKS
+   bool
+
+config SCSI_UFS_D

[PATCH v8 0/3] add support for DWC UFS Controller

2016-02-15 Thread Joao Pinto
The work consisted of:
- Fixed typo in ufshcd-pltfrm.c
- Tweak ufshcd.c for UFS 2.0 support
- Implement ufshcd-dwc which contains all DWC HW specific code
- Unipro attributes were added and new registers were added to the driver
- Implement a ufs-dwc glue platform driver
- Implement a ufs-dwc-pci glue pci driver
- Documentation update

Joao Pinto (3):
  fixed typo in ufshcd-pltfrm
  added UFS 2.0 capabilities
  add support for DWC UFS Host Controller

 Documentation/devicetree/bindings/ufs/ufs-dwc.txt  |  19 +
 .../devicetree/bindings/ufs/ufshcd-pltfrm.txt  |   4 +-
 MAINTAINERS|   6 +
 drivers/scsi/ufs/Kconfig   |  51 +++
 drivers/scsi/ufs/Makefile  |   3 +
 drivers/scsi/ufs/ufs-dwc-pci.c | 172 
 drivers/scsi/ufs/ufs-dwc.c |  96 +
 drivers/scsi/ufs/ufshcd-dwc.c  | 431 +
 drivers/scsi/ufs/ufshcd-dwc.h  |  18 +
 drivers/scsi/ufs/ufshcd-pltfrm.c   |   2 +-
 drivers/scsi/ufs/ufshcd.c  |  29 +-
 drivers/scsi/ufs/ufshci-dwc.h  |  42 ++
 drivers/scsi/ufs/ufshci.h  |   1 +
 drivers/scsi/ufs/unipro.h  |  39 ++
 14 files changed, 906 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufs-dwc.txt
 create mode 100644 drivers/scsi/ufs/ufs-dwc-pci.c
 create mode 100644 drivers/scsi/ufs/ufs-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

-- 
1.8.1.5

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


Re: [PATCH v7 3/3] add support for DWC UFS Host Controller

2016-02-15 Thread Joao Pinto
Hi Akinobu,

On 2/13/2016 1:27 PM, Akinobu Mita wrote:
> Hi Joao,
> 
> 2016-02-11 21:13 GMT+09:00 Joao Pinto :
>> +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

Re: [PATCH v7 3/3] add support for DWC UFS Host Controller

2016-02-12 Thread Joao Pinto
Hi Rob,

On 2/12/2016 4:36 PM, Rob Herring wrote:
> On Thu, Feb 11, 2016 at 12:13:06PM +0000, Joao Pinto wrote:
>> +Required properties:
>> +- compatible: compatible string ("snps,ufshcd-1.0", 
>> "snps,ufshcd-1.1"
>> +  or "snps,ufshcd-2.0")
> 
> History has taught us this needs to have a vendor specific compatible 
> string as well. Don't necessarily have to define it now, but just state 
> a vendor string is needed too.

The compatibility string already as the "snps" which is the acronym for Synopsys
which is the HW Controller vendor. Isn't this enough?

> 
>> +- reg   : 
>> +- interrupts: 
>> +
>> +Example:
>> +ufs@0xd000 {
>> +compatible = "snps,ufshcd-2.0";
>> +reg = < 0xd000 0x1 >;
>> +interrupts = < 24 >;
>> +};

Thanks,
Joao
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 2/3] added UFS 2.0 capabilities

2016-02-11 Thread Joao Pinto
Adding UFS 2.0 support to the UFS core driver.

Signed-off-by: Joao Pinto 
---
Changes v0->v7:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd.c | 29 +
 drivers/scsi/ufs/ufshci.h |  1 +
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 85cd256..2b5f2bf 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1223,6 +1223,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, 
struct ufshcd_lrb *lrbp)
ret = -EINVAL;
}
break;
+   case UTP_CMD_TYPE_UFS_STORAGE:
case UTP_CMD_TYPE_DEV_MANAGE:
ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
@@ -1287,6 +1288,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *cmd)
struct ufshcd_lrb *lrbp;
struct ufs_hba *hba;
unsigned long flags;
+   u32 upiu_flags;
int tag;
int err = 0;
 
@@ -1343,10 +1345,23 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, 
struct scsi_cmnd *cmd)
lrbp->task_tag = tag;
lrbp->lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
lrbp->intr_cmd = !ufshcd_is_intr_aggr_allowed(hba) ? true : false;
-   lrbp->command_type = UTP_CMD_TYPE_SCSI;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_SCSI;
 
/* form UPIU before issuing the command */
-   ufshcd_compose_upiu(hba, lrbp);
+   if (hba->ufs_version == UFSHCI_VERSION_20) {
+   if (likely(lrbp->cmd)) {
+   ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
+   lrbp->cmd->sc_data_direction);
+   ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
+   } else
+   err = -EINVAL;
+   } else
+   ufshcd_compose_upiu(hba, lrbp);
+
err = ufshcd_map_sg(lrbp);
if (err) {
lrbp->cmd = NULL;
@@ -1371,7 +1386,12 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba,
lrbp->sense_buffer = NULL;
lrbp->task_tag = tag;
lrbp->lun = 0; /* device management cmd is not specific to any LUN */
-   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
+   if (hba->ufs_version == UFSHCI_VERSION_20)
+   lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
+   else
+   lrbp->command_type = UTP_CMD_TYPE_DEV_MANAGE;
+
lrbp->intr_cmd = true; /* No interrupt aggregation */
hba->dev_cmd.type = cmd_type;
 
@@ -3187,7 +3207,8 @@ static void ufshcd_transfer_req_compl(struct ufs_hba *hba)
/* Do not touch lrbp after scsi done */
cmd->scsi_done(cmd);
__ufshcd_release(hba);
-   } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) {
+   } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
+   lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) {
if (hba->dev_cmd.complete)
complete(hba->dev_cmd.complete);
}
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index 0ae0967..8dba0e7 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -273,6 +273,7 @@ enum {
UTP_CMD_TYPE_SCSI   = 0x0,
UTP_CMD_TYPE_UFS= 0x1,
UTP_CMD_TYPE_DEV_MANAGE = 0x2,
+   UTP_CMD_TYPE_UFS_STORAGE= 0x11,
 };
 
 enum {
-- 
1.8.1.5

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


[PATCH v7 0/3] add support for DWC UFS Controller

2016-02-11 Thread Joao Pinto
The work consisted of:
- Fixed typo in ufshcd-pltfrm.c
- Tweak ufshcd.c for UFS 2.0 support
- Implement ufshcd-dwc which contains all DWC HW specific code
- Unipro attributes were added and new registers were added to the driver
- Implement a ufs-dwc glue platform driver
- Implement a ufs-dwc-pci glue pci driver

Joao Pinto (3):
  fixed typo in ufshcd-pltfrm
  added UFS 2.0 capabilities
  add support for DWC UFS Host Controller

 Documentation/devicetree/bindings/ufs/ufs-dwc.txt |  17 +
 MAINTAINERS   |   6 +
 drivers/scsi/ufs/Kconfig  |  51 ++
 drivers/scsi/ufs/Makefile |   3 +
 drivers/scsi/ufs/ufs-dwc-pci.c| 172 +
 drivers/scsi/ufs/ufs-dwc.c| 102 +++
 drivers/scsi/ufs/ufshcd-dwc.c | 739 ++
 drivers/scsi/ufs/ufshcd-dwc.h |  18 +
 drivers/scsi/ufs/ufshcd-pltfrm.c  |   2 +-
 drivers/scsi/ufs/ufshcd.c |  29 +-
 drivers/scsi/ufs/ufshci-dwc.h |  42 ++
 drivers/scsi/ufs/ufshci.h |   1 +
 drivers/scsi/ufs/unipro.h |  39 ++
 13 files changed, 1216 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/ufs/ufs-dwc.txt
 create mode 100644 drivers/scsi/ufs/ufs-dwc-pci.c
 create mode 100644 drivers/scsi/ufs/ufs-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.c
 create mode 100644 drivers/scsi/ufs/ufshcd-dwc.h
 create mode 100644 drivers/scsi/ufs/ufshci-dwc.h

-- 
1.8.1.5

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


[PATCH v7 1/3] fixed typo in ufshcd-pltfrm

2016-02-11 Thread Joao Pinto
Fixed typo in ufshcd-pltfrm.

Signed-off-by: Joao Pinto 
---
Changes v0->v7:
- Nothing changed (just to keep up with patch set version).

 drivers/scsi/ufs/ufshcd-pltfrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index d2a7b12..0522891 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -353,6 +353,6 @@ EXPORT_SYMBOL_GPL(ufshcd_pltfrm_init);
 
 MODULE_AUTHOR("Santosh Yaragnavi ");
 MODULE_AUTHOR("Vinayak Holikatti ");
-MODULE_DESCRIPTION("UFS host controller Pltform bus based glue driver");
+MODULE_DESCRIPTION("UFS host controller Platform bus based glue driver");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(UFSHCD_DRIVER_VERSION);
-- 
1.8.1.5

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


  1   2   >